gs-maplibre-draw 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +627 -591
- package/dist/index.umd.cjs +1 -1
- package/dist/types/drawTool/index.d.ts +12 -1
- package/dist/types/drawTool/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Wt=Object.defineProperty;var Kt=(o,e,r)=>e in o?Wt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var T=(o,e,r)=>Kt(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{abs:Oe,cos:xe,sin:Fe,acos:er,atan2:Re,sqrt:_e,pow:ye}=Math;function Be(o){return o<0?-ye(-o,1/3):ye(o,1/3)}const Ot=Math.PI,We=2*Ot,we=Ot/2,tr=1e-6,st=Number.MAX_SAFE_INTEGER||9007199254740991,at=Number.MIN_SAFE_INTEGER||-9007199254740991,rr={x:0,y:0,z:0},S={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(o,e){const r=e(o);let n=r.x*r.x+r.y*r.y;return typeof r.z<"u"&&(n+=r.z*r.z),_e(n)},compute:function(o,e,r){if(o===0)return e[0].t=0,e[0];const n=e.length-1;if(o===1)return e[n].t=1,e[n];const s=1-o;let a=e;if(n===0)return e[0].t=o,e[0];if(n===1){const u={x:s*a[0].x+o*a[1].x,y:s*a[0].y+o*a[1].y,t:o};return r&&(u.z=s*a[0].z+o*a[1].z),u}if(n<4){let u=s*s,c=o*o,l,g,y,m=0;n===2?(a=[a[0],a[1],a[2],rr],l=u,g=s*o*2,y=c):n===3&&(l=u*s,g=u*o*3,y=s*c*3,m=o*c);const v={x:l*a[0].x+g*a[1].x+y*a[2].x+m*a[3].x,y:l*a[0].y+g*a[1].y+y*a[2].y+m*a[3].y,t:o};return r&&(v.z=l*a[0].z+g*a[1].z+y*a[2].z+m*a[3].z),v}const i=JSON.parse(JSON.stringify(e));for(;i.length>1;){for(let u=0;u<i.length-1;u++)i[u]={x:i[u].x+(i[u+1].x-i[u].x)*o,y:i[u].y+(i[u+1].y-i[u].y)*o},typeof i[u].z<"u"&&(i[u].z=i[u].z+(i[u+1].z-i[u].z)*o);i.splice(i.length-1,1)}return i[0].t=o,i[0]},computeWithRatios:function(o,e,r,n){const s=1-o,a=r,i=e;let u=a[0],c=a[1],l=a[2],g=a[3],y;if(u*=s,c*=o,i.length===2)return y=u+c,{x:(u*i[0].x+c*i[1].x)/y,y:(u*i[0].y+c*i[1].y)/y,z:n?(u*i[0].z+c*i[1].z)/y:!1,t:o};if(u*=s,c*=2*s,l*=o*o,i.length===3)return y=u+c+l,{x:(u*i[0].x+c*i[1].x+l*i[2].x)/y,y:(u*i[0].y+c*i[1].y+l*i[2].y)/y,z:n?(u*i[0].z+c*i[1].z+l*i[2].z)/y:!1,t:o};if(u*=s,c*=1.5*s,l*=3*s,g*=o*o*o,i.length===4)return y=u+c+l+g,{x:(u*i[0].x+c*i[1].x+l*i[2].x+g*i[3].x)/y,y:(u*i[0].y+c*i[1].y+l*i[2].y+g*i[3].y)/y,z:n?(u*i[0].z+c*i[1].z+l*i[2].z+g*i[3].z)/y:!1,t:o}},derive:function(o,e){const r=[];for(let n=o,s=n.length,a=s-1;s>1;s--,a--){const i=[];for(let u=0,c;u<a;u++)c={x:a*(n[u+1].x-n[u].x),y:a*(n[u+1].y-n[u].y)},e&&(c.z=a*(n[u+1].z-n[u].z)),i.push(c);r.push(i),n=i}return r},between:function(o,e,r){return e<=o&&o<=r||S.approximately(o,e)||S.approximately(o,r)},approximately:function(o,e,r){return Oe(o-e)<=(r||tr)},length:function(o){const r=S.Tvalues.length;let n=0;for(let s=0,a;s<r;s++)a=.5*S.Tvalues[s]+.5,n+=S.Cvalues[s]*S.arcfn(a,o);return .5*n},map:function(o,e,r,n,s){const a=r-e,i=s-n,u=o-e,c=u/a;return n+i*c},lerp:function(o,e,r){const n={x:e.x+o*(r.x-e.x),y:e.y+o*(r.y-e.y)};return e.z!==void 0&&r.z!==void 0&&(n.z=e.z+o*(r.z-e.z)),n},pointToString:function(o){let e=o.x+"/"+o.y;return typeof o.z<"u"&&(e+="/"+o.z),e},pointsToString:function(o){return"["+o.map(S.pointToString).join(", ")+"]"},copy:function(o){return JSON.parse(JSON.stringify(o))},angle:function(o,e,r){const n=e.x-o.x,s=e.y-o.y,a=r.x-o.x,i=r.y-o.y,u=n*i-s*a,c=n*a+s*i;return Re(u,c)},round:function(o,e){const r=""+o,n=r.indexOf(".");return parseFloat(r.substring(0,n+1+e))},dist:function(o,e){const r=o.x-e.x,n=o.y-e.y;return _e(r*r+n*n)},closest:function(o,e){let r=ye(2,63),n,s;return o.forEach(function(a,i){s=S.dist(e,a),s<r&&(r=s,n=i)}),{mdist:r,mpos:n}},abcratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const r=ye(o,e)+ye(1-o,e),n=r-1;return Oe(n/r)},projectionratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const r=ye(1-o,e),n=ye(o,e)+r;return r/n},lli8:function(o,e,r,n,s,a,i,u){const c=(o*n-e*r)*(s-i)-(o-r)*(s*u-a*i),l=(o*n-e*r)*(a-u)-(e-n)*(s*u-a*i),g=(o-r)*(a-u)-(e-n)*(s-i);return g==0?!1:{x:c/g,y:l/g}},lli4:function(o,e,r,n){const s=o.x,a=o.y,i=e.x,u=e.y,c=r.x,l=r.y,g=n.x,y=n.y;return S.lli8(s,a,i,u,c,l,g,y)},lli:function(o,e){return S.lli4(o,o.c,e,e.c)},makeline:function(o,e){return new H(o.x,o.y,(o.x+e.x)/2,(o.y+e.y)/2,e.x,e.y)},findbbox:function(o){let e=st,r=st,n=at,s=at;return o.forEach(function(a){const i=a.bbox();e>i.x.min&&(e=i.x.min),r>i.y.min&&(r=i.y.min),n<i.x.max&&(n=i.x.max),s<i.y.max&&(s=i.y.max)}),{x:{min:e,mid:(e+n)/2,max:n,size:n-e},y:{min:r,mid:(r+s)/2,max:s,size:s-r}}},shapeintersections:function(o,e,r,n,s){if(!S.bboxoverlap(e,n))return[];const a=[],i=[o.startcap,o.forward,o.back,o.endcap],u=[r.startcap,r.forward,r.back,r.endcap];return i.forEach(function(c){c.virtual||u.forEach(function(l){if(l.virtual)return;const g=c.intersects(l,s);g.length>0&&(g.c1=c,g.c2=l,g.s1=o,g.s2=r,a.push(g))})}),a},makeshape:function(o,e,r){const n=e.points.length,s=o.points.length,a=S.makeline(e.points[n-1],o.points[0]),i=S.makeline(o.points[s-1],e.points[0]),u={startcap:a,forward:o,back:e,endcap:i,bbox:S.findbbox([a,o,e,i])};return u.intersections=function(c){return S.shapeintersections(u,u.bbox,c,c.bbox,r)},u},getminmax:function(o,e,r){if(!r)return{min:0,max:0};let n=st,s=at,a,i;r.indexOf(0)===-1&&(r=[0].concat(r)),r.indexOf(1)===-1&&r.push(1);for(let u=0,c=r.length;u<c;u++)a=r[u],i=o.get(a),i[e]<n&&(n=i[e]),i[e]>s&&(s=i[e]);return{min:n,mid:(n+s)/2,max:s,size:s-n}},align:function(o,e){const r=e.p1.x,n=e.p1.y,s=-Re(e.p2.y-n,e.p2.x-r),a=function(i){return{x:(i.x-r)*xe(s)-(i.y-n)*Fe(s),y:(i.x-r)*Fe(s)+(i.y-n)*xe(s)}};return o.map(a)},roots:function(o,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const r=o.length-1,n=S.align(o,e),s=function(M){return 0<=M&&M<=1};if(r===2){const M=n[0].y,_=n[1].y,P=n[2].y,k=M-2*_+P;if(k!==0){const F=-_e(_*_-M*P),C=-M+_,Y=-(F+C)/k,q=-(-F+C)/k;return[Y,q].filter(s)}else if(_!==P&&k===0)return[(2*_-P)/(2*_-2*P)].filter(s);return[]}const a=n[0].y,i=n[1].y,u=n[2].y,c=n[3].y;let l=-a+3*i-3*u+c,g=3*a-6*i+3*u,y=-3*a+3*i,m=a;if(S.approximately(l,0)){if(S.approximately(g,0))return S.approximately(y,0)?[]:[-m/y].filter(s);const M=_e(y*y-4*g*m),_=2*g;return[(M-y)/_,(-y-M)/_].filter(s)}g/=l,y/=l,m/=l;const v=(3*y-g*g)/3,L=v/3,D=(2*g*g*g-9*g*y+27*m)/27,I=D/2,A=I*I+L*L*L;let h,f,d,p,w;if(A<0){const M=-v/3,_=M*M*M,P=_e(_),k=-D/(2*P),F=k<-1?-1:k>1?1:k,C=er(F),Y=Be(P),q=2*Y;return d=q*xe(C/3)-g/3,p=q*xe((C+We)/3)-g/3,w=q*xe((C+2*We)/3)-g/3,[d,p,w].filter(s)}else{if(A===0)return h=I<0?Be(-I):-Be(I),d=2*h-g/3,p=-h-g/3,[d,p].filter(s);{const M=_e(A);return h=Be(-I+M),f=Be(I+M),[h-f-g/3].filter(s)}}},droots:function(o){if(o.length===3){const e=o[0],r=o[1],n=o[2],s=e-2*r+n;if(s!==0){const a=-_e(r*r-e*n),i=-e+r,u=-(a+i)/s,c=-(-a+i)/s;return[u,c]}else if(r!==n&&s===0)return[(2*r-n)/(2*(r-n))];return[]}if(o.length===2){const e=o[0],r=o[1];return e!==r?[e/(e-r)]:[]}return[]},curvature:function(o,e,r,n,s){let a,i,u,c,l=0,g=0;const y=S.compute(o,e),m=S.compute(o,r),v=y.x*y.x+y.y*y.y;if(n?(a=_e(ye(y.y*m.z-m.y*y.z,2)+ye(y.z*m.x-m.z*y.x,2)+ye(y.x*m.y-m.x*y.y,2)),i=ye(v+y.z*y.z,3/2)):(a=y.x*m.y-y.y*m.x,i=ye(v,3/2)),a===0||i===0)return{k:0,r:0};if(l=a/i,g=i/a,!s){const L=S.curvature(o-.001,e,r,n,!0).k,D=S.curvature(o+.001,e,r,n,!0).k;c=(D-l+(l-L))/2,u=(Oe(D-l)+Oe(l-L))/2}return{k:l,r:g,dk:c,adk:u}},inflections:function(o){if(o.length<4)return[];const e=S.align(o,{p1:o[0],p2:o.slice(-1)[0]}),r=e[2].x*e[1].y,n=e[3].x*e[1].y,s=e[1].x*e[2].y,a=e[3].x*e[2].y,i=18*(-3*r+2*n+3*s-a),u=18*(3*r-n-3*s),c=18*(s-r);if(S.approximately(i,0)){if(!S.approximately(u,0)){let m=-c/u;if(0<=m&&m<=1)return[m]}return[]}const l=2*i;if(S.approximately(l,0))return[];const g=u*u-4*i*c;if(g<0)return[];const y=Math.sqrt(g);return[(y-u)/l,-(u+y)/l].filter(function(m){return 0<=m&&m<=1})},bboxoverlap:function(o,e){const r=["x","y"],n=r.length;for(let s=0,a,i,u,c;s<n;s++)if(a=r[s],i=o[a].mid,u=e[a].mid,c=(o[a].size+e[a].size)/2,Oe(i-u)>=c)return!1;return!0},expandbox:function(o,e){e.x.min<o.x.min&&(o.x.min=e.x.min),e.y.min<o.y.min&&(o.y.min=e.y.min),e.z&&e.z.min<o.z.min&&(o.z.min=e.z.min),e.x.max>o.x.max&&(o.x.max=e.x.max),e.y.max>o.y.max&&(o.y.max=e.y.max),e.z&&e.z.max>o.z.max&&(o.z.max=e.z.max),o.x.mid=(o.x.min+o.x.max)/2,o.y.mid=(o.y.min+o.y.max)/2,o.z&&(o.z.mid=(o.z.min+o.z.max)/2),o.x.size=o.x.max-o.x.min,o.y.size=o.y.max-o.y.min,o.z&&(o.z.size=o.z.max-o.z.min)},pairiteration:function(o,e,r){const n=o.bbox(),s=e.bbox(),a=1e5,i=r||.5;if(n.x.size+n.y.size<i&&s.x.size+s.y.size<i)return[(a*(o._t1+o._t2)/2|0)/a+"/"+(a*(e._t1+e._t2)/2|0)/a];let u=o.split(.5),c=e.split(.5),l=[{left:u.left,right:c.left},{left:u.left,right:c.right},{left:u.right,right:c.right},{left:u.right,right:c.left}];l=l.filter(function(y){return S.bboxoverlap(y.left.bbox(),y.right.bbox())});let g=[];return l.length===0||(l.forEach(function(y){g=g.concat(S.pairiteration(y.left,y.right,i))}),g=g.filter(function(y,m){return g.indexOf(y)===m})),g},getccenter:function(o,e,r){const n=e.x-o.x,s=e.y-o.y,a=r.x-e.x,i=r.y-e.y,u=n*xe(we)-s*Fe(we),c=n*Fe(we)+s*xe(we),l=a*xe(we)-i*Fe(we),g=a*Fe(we)+i*xe(we),y=(o.x+e.x)/2,m=(o.y+e.y)/2,v=(e.x+r.x)/2,L=(e.y+r.y)/2,D=y+u,I=m+c,A=v+l,h=L+g,f=S.lli8(y,m,D,I,v,L,A,h),d=S.dist(f,o);let p=Re(o.y-f.y,o.x-f.x),w=Re(e.y-f.y,e.x-f.x),M=Re(r.y-f.y,r.x-f.x),_;return p<M?((p>w||w>M)&&(p+=We),p>M&&(_=M,M=p,p=_)):M<w&&w<p?(_=M,M=p,p=_):M+=We,f.s=p,f.e=M,f.r=d,f},numberSort:function(o,e){return o-e}};class Te{constructor(e){this.curves=[],this._3d=!1,e&&(this.curves=e,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map(function(e){return S.pointsToString(e.points)}).join(", ")+"]"}addCurve(e){this.curves.push(e),this._3d=this._3d||e._3d}length(){return this.curves.map(function(e){return e.length()}).reduce(function(e,r){return e+r})}curve(e){return this.curves[e]}bbox(){const e=this.curves;for(var r=e[0].bbox(),n=1;n<e.length;n++)S.expandbox(r,e[n].bbox());return r}offset(e){const r=[];return this.curves.forEach(function(n){r.push(...n.offset(e))}),new Te(r)}}const{abs:qe,min:Pt,max:zt,cos:or,sin:nr,acos:ir,sqrt:Ue}=Math,sr=Math.PI;class H{constructor(e){let r=e&&e.forEach?e:Array.from(arguments).slice(),n=!1;if(typeof r[0]=="object"){n=r.length;const v=[];r.forEach(function(L){["x","y","z"].forEach(function(D){typeof L[D]<"u"&&v.push(L[D])})}),r=v}let s=!1;const a=r.length;if(n){if(n>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");s=!0}}else if(a!==6&&a!==8&&a!==9&&a!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const i=this._3d=!s&&(a===9||a===12)||e&&e[0]&&typeof e[0].z<"u",u=this.points=[];for(let v=0,L=i?3:2;v<a;v+=L){var c={x:r[v],y:r[v+1]};i&&(c.z=r[v+2]),u.push(c)}const l=this.order=u.length-1,g=this.dims=["x","y"];i&&g.push("z"),this.dimlen=g.length;const y=S.align(u,{p1:u[0],p2:u[l]}),m=S.dist(u[0],u[l]);this._linear=y.reduce((v,L)=>v+qe(L.y),0)<m/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,r,n,s){if(typeof s>"u"&&(s=.5),s===0)return new H(r,r,n);if(s===1)return new H(e,r,r);const a=H.getABC(2,e,r,n,s);return new H(e,a.A,n)}static cubicFromPoints(e,r,n,s,a){typeof s>"u"&&(s=.5);const i=H.getABC(3,e,r,n,s);typeof a>"u"&&(a=S.dist(r,i.C));const u=a*(1-s)/s,c=S.dist(e,n),l=(n.x-e.x)/c,g=(n.y-e.y)/c,y=a*l,m=a*g,v=u*l,L=u*g,D={x:r.x-y,y:r.y-m},I={x:r.x+v,y:r.y+L},A=i.A,h={x:A.x+(D.x-A.x)/(1-s),y:A.y+(D.y-A.y)/(1-s)},f={x:A.x+(I.x-A.x)/s,y:A.y+(I.y-A.y)/s},d={x:e.x+(h.x-e.x)/s,y:e.y+(h.y-e.y)/s},p={x:n.x+(f.x-n.x)/(1-s),y:n.y+(f.y-n.y)/(1-s)};return new H(e,d,p,n)}static getUtils(){return S}getUtils(){return H.getUtils()}static get PolyBezier(){return Te}valueOf(){return this.toString()}toString(){return S.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,r=e[0].x,n=e[0].y,s=["M",r,n,this.order===2?"Q":"C"];for(let a=1,i=e.length;a<i;a++)s.push(e[a].x),s.push(e[a].y);return s.join(" ")}setRatios(e){if(e.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=e,this._lut=[]}verify(){const e=this.coordDigest();e!==this._print&&(this._print=e,this.update())}coordDigest(){return this.points.map(function(e,r){return""+r+e.x+e.y+(e.z?e.z:0)}).join("")}update(){this._lut=[],this.dpoints=S.derive(this.points,this._3d),this.computedirection()}computedirection(){const e=this.points,r=S.angle(e[0],e[this.order],e[1]);this.clockwise=r>0}length(){return S.length(this.derivative.bind(this))}static getABC(e=2,r,n,s,a=.5){const i=S.projectionratio(a,e),u=1-i,c={x:i*r.x+u*s.x,y:i*r.y+u*s.y},l=S.abcratio(a,e);return{A:{x:n.x+(n.x-c.x)/l,y:n.y+(n.y-c.y)/l},B:n,C:c,S:r,E:s}}getABC(e,r){r=r||this.get(e);let n=this.points[0],s=this.points[this.order];return H.getABC(this.order,n,r,s,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e+1)return this._lut;this._lut=[],e++,this._lut=[];for(let r=0,n,s;r<e;r++)s=r/(e-1),n=this.compute(s),n.t=s,this._lut.push(n);return this._lut}on(e,r){r=r||5;const n=this.getLUT(),s=[];for(let a=0,i,u=0;a<n.length;a++)i=n[a],S.dist(i,e)<r&&(s.push(i),u+=a/n.length);return s.length?t/=s.length:!1}project(e){const r=this.getLUT(),n=r.length-1,s=S.closest(r,e),a=s.mpos,i=(a-1)/n,u=(a+1)/n,c=.1/n;let l=s.mdist,g=i,y=g,m;l+=1;for(let v;g<u+c;g+=c)m=this.compute(g),v=S.dist(e,m),v<l&&(l=v,y=g);return y=y<0?0:y>1?1:y,m=this.compute(y),m.t=y,m.d=l,m}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?S.computeWithRatios(e,this.points,this.ratios,this._3d):S.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,r=[e[0]],n=e.length;for(let s=1,a,i;s<n;s++)a=e[s],i=e[s-1],r[s]={x:(n-s)/n*a.x+s/n*i.x,y:(n-s)/n*a.y+s/n*i.y};return r[n]=e[n-1],new H(r)}derivative(e){return S.compute(e,this.dpoints[0],this._3d)}dderivative(e){return S.compute(e,this.dpoints[1],this._3d)}align(){let e=this.points;return new H(S.align(e,{p1:e[0],p2:e[e.length-1]}))}curvature(e){return S.curvature(e,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return S.inflections(this.points)}normal(e){return this._3d?this.__normal3(e):this.__normal2(e)}__normal2(e){const r=this.derivative(e),n=Ue(r.x*r.x+r.y*r.y);return{t:e,x:-r.y/n,y:r.x/n}}__normal3(e){const r=this.derivative(e),n=this.derivative(e+.01),s=Ue(r.x*r.x+r.y*r.y+r.z*r.z),a=Ue(n.x*n.x+n.y*n.y+n.z*n.z);r.x/=s,r.y/=s,r.z/=s,n.x/=a,n.y/=a,n.z/=a;const i={x:n.y*r.z-n.z*r.y,y:n.z*r.x-n.x*r.z,z:n.x*r.y-n.y*r.x},u=Ue(i.x*i.x+i.y*i.y+i.z*i.z);i.x/=u,i.y/=u,i.z/=u;const c=[i.x*i.x,i.x*i.y-i.z,i.x*i.z+i.y,i.x*i.y+i.z,i.y*i.y,i.y*i.z-i.x,i.x*i.z-i.y,i.y*i.z+i.x,i.z*i.z];return{t:e,x:c[0]*r.x+c[1]*r.y+c[2]*r.z,y:c[3]*r.x+c[4]*r.y+c[5]*r.z,z:c[6]*r.x+c[7]*r.y+c[8]*r.z}}hull(e){let r=this.points,n=[],s=[],a=0;for(s[a++]=r[0],s[a++]=r[1],s[a++]=r[2],this.order===3&&(s[a++]=r[3]);r.length>1;){n=[];for(let i=0,u,c=r.length-1;i<c;i++)u=S.lerp(e,r[i],r[i+1]),s[a++]=u,n.push(u);r=n}return s}split(e,r){if(e===0&&r)return this.split(r).left;if(r===1)return this.split(e).right;const n=this.hull(e),s={left:this.order===2?new H([n[0],n[3],n[5]]):new H([n[0],n[4],n[7],n[9]]),right:this.order===2?new H([n[5],n[4],n[2]]):new H([n[9],n[8],n[6],n[3]]),span:n};return s.left._t1=S.map(0,0,1,this._t1,this._t2),s.left._t2=S.map(e,0,1,this._t1,this._t2),s.right._t1=S.map(e,0,1,this._t1,this._t2),s.right._t2=S.map(1,0,1,this._t1,this._t2),r?(r=S.map(r,e,1,0,1),s.right.split(r).left):s}extrema(){const e={};let r=[];return this.dims.forEach((function(n){let s=function(i){return i[n]},a=this.dpoints[0].map(s);e[n]=S.droots(a),this.order===3&&(a=this.dpoints[1].map(s),e[n]=e[n].concat(S.droots(a))),e[n]=e[n].filter(function(i){return i>=0&&i<=1}),r=r.concat(e[n].sort(S.numberSort))}).bind(this)),e.values=r.sort(S.numberSort).filter(function(n,s){return r.indexOf(n)===s}),e}bbox(){const e=this.extrema(),r={};return this.dims.forEach((function(n){r[n]=S.getminmax(this,n,e[n])}).bind(this)),r}overlaps(e){const r=this.bbox(),n=e.bbox();return S.bboxoverlap(r,n)}offset(e,r){if(typeof r<"u"){const n=this.get(e),s=this.normal(e),a={c:n,n:s,x:n.x+s.x*r,y:n.y+s.y*r};return this._3d&&(a.z=n.z+s.z*r),a}if(this._linear){const n=this.normal(0),s=this.points.map(function(a){const i={x:a.x+e*n.x,y:a.y+e*n.y};return a.z&&n.z&&(i.z=a.z+e*n.z),i});return[new H(s)]}return this.reduce().map(function(n){return n._linear?n.offset(e)[0]:n.scale(e)})}simple(){if(this.order===3){const s=S.angle(this.points[0],this.points[3],this.points[1]),a=S.angle(this.points[0],this.points[3],this.points[2]);if(s>0&&a<0||s<0&&a>0)return!1}const e=this.normal(0),r=this.normal(1);let n=e.x*r.x+e.y*r.y;return this._3d&&(n+=e.z*r.z),qe(ir(n))<sr/3}reduce(){let e,r=0,n=0,s=.01,a,i=[],u=[],c=this.extrema().values;for(c.indexOf(0)===-1&&(c=[0].concat(c)),c.indexOf(1)===-1&&c.push(1),r=c[0],e=1;e<c.length;e++)n=c[e],a=this.split(r,n),a._t1=r,a._t2=n,i.push(a),r=n;return i.forEach(function(l){for(r=0,n=0;n<=1;)for(n=r+s;n<=1+s;n+=s)if(a=l.split(r,n),!a.simple()){if(n-=s,qe(r-n)<s)return[];a=l.split(r,n),a._t1=S.map(r,0,1,l._t1,l._t2),a._t2=S.map(n,0,1,l._t1,l._t2),u.push(a),r=n;break}r<1&&(a=l.split(r,1),a._t1=S.map(r,0,1,l._t1,l._t2),a._t2=l._t2,u.push(a))}),u}translate(e,r,n){n=typeof n=="number"?n:r;const s=this.order;let a=this.points.map((i,u)=>(1-u/s)*r+u/s*n);return new H(this.points.map((i,u)=>({x:i.x+e.x*a[u],y:i.y+e.y*a[u]})))}scale(e){const r=this.order;let n=!1;if(typeof e=="function"&&(n=e),n&&r===2)return this.raise().scale(n);const s=this.clockwise,a=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):e,n?n(1):e);const i=n?n(0):e,u=n?n(1):e,c=[this.offset(0,10),this.offset(1,10)],l=[],g=S.lli4(c[0],c[0].c,c[1],c[1].c);if(!g)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(y){const m=l[y*r]=S.copy(a[y*r]);m.x+=(y?u:i)*c[y].n.x,m.y+=(y?u:i)*c[y].n.y}),n?([0,1].forEach(function(y){if(!(r===2&&y)){var m=a[y+1],v={x:m.x-g.x,y:m.y-g.y},L=n?n((y+1)/r):e;n&&!s&&(L=-L);var D=Ue(v.x*v.x+v.y*v.y);v.x/=D,v.y/=D,l[y+1]={x:m.x+L*v.x,y:m.y+L*v.y}}}),new H(l)):([0,1].forEach(y=>{if(r===2&&y)return;const m=l[y*r],v=this.derivative(y),L={x:m.x+v.x,y:m.y+v.y};l[y+1]=S.lli4(m,L,g,a[y+1])}),new H(l))}outline(e,r,n,s){if(r=r===void 0?e:r,this._linear){const p=this.normal(0),w=this.points[0],M=this.points[this.points.length-1];let _,P,k;n===void 0&&(n=e,s=r),_={x:w.x+p.x*e,y:w.y+p.y*e},k={x:M.x+p.x*n,y:M.y+p.y*n},P={x:(_.x+k.x)/2,y:(_.y+k.y)/2};const F=[_,P,k];_={x:w.x-p.x*r,y:w.y-p.y*r},k={x:M.x-p.x*s,y:M.y-p.y*s},P={x:(_.x+k.x)/2,y:(_.y+k.y)/2};const C=[k,P,_],Y=S.makeline(C[2],F[0]),q=S.makeline(F[2],C[0]),ie=[Y,new H(F),q,new H(C)];return new Te(ie)}const a=this.reduce(),i=a.length,u=[];let c=[],l,g=0,y=this.length();const m=typeof n<"u"&&typeof s<"u";function v(p,w,M,_,P){return function(k){const F=_/M,C=(_+P)/M,Y=w-p;return S.map(k,0,1,p+F*Y,p+C*Y)}}a.forEach(function(p){const w=p.length();m?(u.push(p.scale(v(e,n,y,g,w))),c.push(p.scale(v(-r,-s,y,g,w)))):(u.push(p.scale(e)),c.push(p.scale(-r))),g+=w}),c=c.map(function(p){return l=p.points,l[3]?p.points=[l[3],l[2],l[1],l[0]]:p.points=[l[2],l[1],l[0]],p}).reverse();const L=u[0].points[0],D=u[i-1].points[u[i-1].points.length-1],I=c[i-1].points[c[i-1].points.length-1],A=c[0].points[0],h=S.makeline(I,L),f=S.makeline(D,A),d=[h].concat(u).concat([f]).concat(c);return new Te(d)}outlineshapes(e,r,n){r=r||e;const s=this.outline(e,r).curves,a=[];for(let i=1,u=s.length;i<u/2;i++){const c=S.makeshape(s[i],s[u-i],n);c.startcap.virtual=i>1,c.endcap.virtual=i<u/2-1,a.push(c)}return a}intersects(e,r){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof H&&(e=e.reduce()),this.curveintersects(this.reduce(),e,r)):this.selfintersects(r)}lineIntersects(e){const r=Pt(e.p1.x,e.p2.x),n=Pt(e.p1.y,e.p2.y),s=zt(e.p1.x,e.p2.x),a=zt(e.p1.y,e.p2.y);return S.roots(this.points,e).filter(i=>{var u=this.get(i);return S.between(u.x,r,s)&&S.between(u.y,n,a)})}selfintersects(e){const r=this.reduce(),n=r.length-2,s=[];for(let a=0,i,u,c;a<n;a++)u=r.slice(a,a+1),c=r.slice(a+2),i=this.curveintersects(u,c,e),s.push(...i);return s}curveintersects(e,r,n){const s=[];e.forEach(function(i){r.forEach(function(u){i.overlaps(u)&&s.push({left:i,right:u})})});let a=[];return s.forEach(function(i){const u=S.pairiteration(i.left,i.right,n);u.length>0&&(a=a.concat(u))}),a}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,r,n,s){const a=(s-n)/4,i=this.get(n+a),u=this.get(s-a),c=S.dist(e,r),l=S.dist(e,i),g=S.dist(e,u);return qe(l-c)+qe(g-c)}_iterate(e,r){let n=0,s=1,a;do{a=0,s=1;let i=this.get(n),u,c,l,g,y=!1,m=!1,v,L=s,D=1;do if(m=y,g=l,L=(n+s)/2,u=this.get(L),c=this.get(s),l=S.getccenter(i,u,c),l.interval={start:n,end:s},y=this._error(l,i,n,s)<=e,v=m&&!y,v||(D=s),y){if(s>=1){if(l.interval.end=D=1,g=l,s>1){let A={x:l.x+l.r*or(l.e),y:l.y+l.r*nr(l.e)};l.e+=S.angle({x:l.x,y:l.y},A,this.get(1))}break}s=s+(s-n)/2}else s=L;while(!v&&a++<100);if(a>=100)break;g=g||l,r.push(g),n=D}while(s<1);return r}}var fe=63710088e-1,Rt={centimeters:fe*100,centimetres:fe*100,degrees:fe/111325,feet:fe*3.28084,inches:fe*39.37,kilometers:fe/1e3,kilometres:fe/1e3,meters:fe,metres:fe,miles:fe/1609.344,millimeters:fe*1e3,millimetres:fe*1e3,nauticalmiles:fe/1852,radians:1,yards:fe*1.0936};function Mt(o,e,r){r===void 0&&(r={});var n={type:"Feature"};return(r.id===0||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=o,n}function ve(o,e,r){if(r===void 0&&(r={}),!o)throw new Error("coordinates is required");if(!Array.isArray(o))throw new Error("coordinates must be an Array");if(o.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Dt(o[0])||!Dt(o[1]))throw new Error("coordinates must contain numbers");var n={type:"Point",coordinates:o};return Mt(n,e,r)}function Ge(o,e,r){r===void 0&&(r={});for(var n=0,s=o;n<s.length;n++){var a=s[n];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var i=0;i<a[a.length-1].length;i++)if(a[a.length-1][i]!==a[0][i])throw new Error("First and last Position are not equivalent.")}var u={type:"Polygon",coordinates:o};return Mt(u,e,r)}function Je(o,e,r){if(r===void 0&&(r={}),o.length<2)throw new Error("coordinates must be an array of two or more positions");var n={type:"LineString",coordinates:o};return Mt(n,e,r)}function Ke(o,e){if(e===void 0&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,e||0);return Math.round(o*r)/r}function ar(o,e){e===void 0&&(e="kilometers");var r=Rt[e];if(!r)throw new Error(e+" units is invalid");return o*r}function ur(o,e){e===void 0&&(e="kilometers");var r=Rt[e];if(!r)throw new Error(e+" units is invalid");return o/r}function pt(o){var e=o%(2*Math.PI);return e*180/Math.PI}function ge(o){var e=o%360;return e*Math.PI/180}function Dt(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function Ze(o,e,r){if(o!==null)for(var n,s,a,i,u,c,l,g=0,y=0,m,v=o.type,L=v==="FeatureCollection",D=v==="Feature",I=L?o.features.length:1,A=0;A<I;A++){l=L?o.features[A].geometry:D?o.geometry:o,m=l?l.type==="GeometryCollection":!1,u=m?l.geometries.length:1;for(var h=0;h<u;h++){var f=0,d=0;if(i=m?l.geometries[h]:l,i!==null){c=i.coordinates;var p=i.type;switch(g=r&&(p==="Polygon"||p==="MultiPolygon")?1:0,p){case null:break;case"Point":if(e(c,y,A,f,d)===!1)return!1;y++,f++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(e(c[n],y,A,f,d)===!1)return!1;y++,p==="MultiPoint"&&f++}p==="LineString"&&f++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(s=0;s<c[n].length-g;s++){if(e(c[n][s],y,A,f,d)===!1)return!1;y++}p==="MultiLineString"&&f++,p==="Polygon"&&d++}p==="Polygon"&&f++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(d=0,s=0;s<c[n].length;s++){for(a=0;a<c[n][s].length-g;a++){if(e(c[n][s][a],y,A,f,d)===!1)return!1;y++}d++}f++}break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(Ze(i.geometries[n],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function cr(o,e){var r,n,s,a,i,u,c,l,g,y,m=0,v=o.type==="FeatureCollection",L=o.type==="Feature",D=v?o.features.length:1;for(r=0;r<D;r++){for(u=v?o.features[r].geometry:L?o.geometry:o,l=v?o.features[r].properties:L?o.properties:{},g=v?o.features[r].bbox:L?o.bbox:void 0,y=v?o.features[r].id:L?o.id:void 0,c=u?u.type==="GeometryCollection":!1,i=c?u.geometries.length:1,s=0;s<i;s++){if(a=c?u.geometries[s]:u,a===null){if(e(null,m,l,g,y)===!1)return!1;continue}switch(a.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(a,m,l,g,y)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<a.geometries.length;n++)if(e(a.geometries[n],m,l,g,y)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}m++}}function lr(o,e,r){var n=r;return cr(o,function(s,a,i,u,c){a===0&&r===void 0?n=s:n=e(n,s,a,i,u,c)}),n}function ot(o){var e=[1/0,1/0,-1/0,-1/0];return Ze(o,function(r){e[0]>r[0]&&(e[0]=r[0]),e[1]>r[1]&&(e[1]=r[1]),e[2]<r[0]&&(e[2]=r[0]),e[3]<r[1]&&(e[3]=r[1])}),e}ot.default=ot;function Xe(o){if(!o)throw new Error("coord is required");if(!Array.isArray(o)){if(o.type==="Feature"&&o.geometry!==null&&o.geometry.type==="Point")return o.geometry.coordinates;if(o.type==="Point")return o.coordinates}if(Array.isArray(o)&&o.length>=2&&!Array.isArray(o[0])&&!Array.isArray(o[1]))return o;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function hr(o){return o.type==="Feature"?o.geometry:o}function fr(o,e){return o.type==="FeatureCollection"?"FeatureCollection":o.type==="GeometryCollection"?"GeometryCollection":o.type==="Feature"&&o.geometry!==null?o.geometry.type:o.type}var Bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dr(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function yr(o){if(o.__esModule)return o;var e=o.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(o).forEach(function(n){var s=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return o[n]}})}),r}var _t={exports:{}},qt={exports:{}};(function(o,e){(function(r,n){o.exports=n()})(Bt,function(){function r(h,f,d,p,w){(function M(_,P,k,F,C){for(;F>k;){if(F-k>600){var Y=F-k+1,q=P-k+1,ie=Math.log(Y),Q=.5*Math.exp(2*ie/3),K=.5*Math.sqrt(ie*Q*(Y-Q)/Y)*(q-Y/2<0?-1:1),j=Math.max(k,Math.floor(P-q*Q/Y+K)),se=Math.min(F,Math.floor(P+(Y-q)*Q/Y+K));M(_,P,j,se,C)}var E=_[P],x=k,z=F;for(n(_,k,P),C(_[F],E)>0&&n(_,k,F);x<z;){for(n(_,x,z),x++,z--;C(_[x],E)<0;)x++;for(;C(_[z],E)>0;)z--}C(_[k],E)===0?n(_,k,z):n(_,++z,F),z<=P&&(k=z+1),P<=z&&(F=z-1)}})(h,f,d||0,p||h.length-1,w||s)}function n(h,f,d){var p=h[f];h[f]=h[d],h[d]=p}function s(h,f){return h<f?-1:h>f?1:0}var a=function(h){h===void 0&&(h=9),this._maxEntries=Math.max(4,h),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function i(h,f,d){if(!d)return f.indexOf(h);for(var p=0;p<f.length;p++)if(d(h,f[p]))return p;return-1}function u(h,f){c(h,0,h.children.length,f,h)}function c(h,f,d,p,w){w||(w=I(null)),w.minX=1/0,w.minY=1/0,w.maxX=-1/0,w.maxY=-1/0;for(var M=f;M<d;M++){var _=h.children[M];l(w,h.leaf?p(_):_)}return w}function l(h,f){return h.minX=Math.min(h.minX,f.minX),h.minY=Math.min(h.minY,f.minY),h.maxX=Math.max(h.maxX,f.maxX),h.maxY=Math.max(h.maxY,f.maxY),h}function g(h,f){return h.minX-f.minX}function y(h,f){return h.minY-f.minY}function m(h){return(h.maxX-h.minX)*(h.maxY-h.minY)}function v(h){return h.maxX-h.minX+(h.maxY-h.minY)}function L(h,f){return h.minX<=f.minX&&h.minY<=f.minY&&f.maxX<=h.maxX&&f.maxY<=h.maxY}function D(h,f){return f.minX<=h.maxX&&f.minY<=h.maxY&&f.maxX>=h.minX&&f.maxY>=h.minY}function I(h){return{children:h,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function A(h,f,d,p,w){for(var M=[f,d];M.length;)if(!((d=M.pop())-(f=M.pop())<=p)){var _=f+Math.ceil((d-f)/p/2)*p;r(h,_,f,d,w),M.push(f,_,_,d)}}return a.prototype.all=function(){return this._all(this.data,[])},a.prototype.search=function(h){var f=this.data,d=[];if(!D(h,f))return d;for(var p=this.toBBox,w=[];f;){for(var M=0;M<f.children.length;M++){var _=f.children[M],P=f.leaf?p(_):_;D(h,P)&&(f.leaf?d.push(_):L(h,P)?this._all(_,d):w.push(_))}f=w.pop()}return d},a.prototype.collides=function(h){var f=this.data;if(!D(h,f))return!1;for(var d=[];f;){for(var p=0;p<f.children.length;p++){var w=f.children[p],M=f.leaf?this.toBBox(w):w;if(D(h,M)){if(f.leaf||L(h,M))return!0;d.push(w)}}f=d.pop()}return!1},a.prototype.load=function(h){if(!h||!h.length)return this;if(h.length<this._minEntries){for(var f=0;f<h.length;f++)this.insert(h[f]);return this}var d=this._build(h.slice(),0,h.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var p=this.data;this.data=d,d=p}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},a.prototype.insert=function(h){return h&&this._insert(h,this.data.height-1),this},a.prototype.clear=function(){return this.data=I([]),this},a.prototype.remove=function(h,f){if(!h)return this;for(var d,p,w,M=this.data,_=this.toBBox(h),P=[],k=[];M||P.length;){if(M||(M=P.pop(),p=P[P.length-1],d=k.pop(),w=!0),M.leaf){var F=i(h,M.children,f);if(F!==-1)return M.children.splice(F,1),P.push(M),this._condense(P),this}w||M.leaf||!L(M,_)?p?(d++,M=p.children[d],w=!1):M=null:(P.push(M),k.push(d),d=0,p=M,M=M.children[0])}return this},a.prototype.toBBox=function(h){return h},a.prototype.compareMinX=function(h,f){return h.minX-f.minX},a.prototype.compareMinY=function(h,f){return h.minY-f.minY},a.prototype.toJSON=function(){return this.data},a.prototype.fromJSON=function(h){return this.data=h,this},a.prototype._all=function(h,f){for(var d=[];h;)h.leaf?f.push.apply(f,h.children):d.push.apply(d,h.children),h=d.pop();return f},a.prototype._build=function(h,f,d,p){var w,M=d-f+1,_=this._maxEntries;if(M<=_)return u(w=I(h.slice(f,d+1)),this.toBBox),w;p||(p=Math.ceil(Math.log(M)/Math.log(_)),_=Math.ceil(M/Math.pow(_,p-1))),(w=I([])).leaf=!1,w.height=p;var P=Math.ceil(M/_),k=P*Math.ceil(Math.sqrt(_));A(h,f,d,k,this.compareMinX);for(var F=f;F<=d;F+=k){var C=Math.min(F+k-1,d);A(h,F,C,P,this.compareMinY);for(var Y=F;Y<=C;Y+=P){var q=Math.min(Y+P-1,C);w.children.push(this._build(h,Y,q,p-1))}}return u(w,this.toBBox),w},a.prototype._chooseSubtree=function(h,f,d,p){for(;p.push(f),!f.leaf&&p.length-1!==d;){for(var w=1/0,M=1/0,_=void 0,P=0;P<f.children.length;P++){var k=f.children[P],F=m(k),C=(Y=h,q=k,(Math.max(q.maxX,Y.maxX)-Math.min(q.minX,Y.minX))*(Math.max(q.maxY,Y.maxY)-Math.min(q.minY,Y.minY))-F);C<M?(M=C,w=F<w?F:w,_=k):C===M&&F<w&&(w=F,_=k)}f=_||f.children[0]}var Y,q;return f},a.prototype._insert=function(h,f,d){var p=d?h:this.toBBox(h),w=[],M=this._chooseSubtree(p,this.data,f,w);for(M.children.push(h),l(M,p);f>=0&&w[f].children.length>this._maxEntries;)this._split(w,f),f--;this._adjustParentBBoxes(p,w,f)},a.prototype._split=function(h,f){var d=h[f],p=d.children.length,w=this._minEntries;this._chooseSplitAxis(d,w,p);var M=this._chooseSplitIndex(d,w,p),_=I(d.children.splice(M,d.children.length-M));_.height=d.height,_.leaf=d.leaf,u(d,this.toBBox),u(_,this.toBBox),f?h[f-1].children.push(_):this._splitRoot(d,_)},a.prototype._splitRoot=function(h,f){this.data=I([h,f]),this.data.height=h.height+1,this.data.leaf=!1,u(this.data,this.toBBox)},a.prototype._chooseSplitIndex=function(h,f,d){for(var p,w,M,_,P,k,F,C=1/0,Y=1/0,q=f;q<=d-f;q++){var ie=c(h,0,q,this.toBBox),Q=c(h,q,d,this.toBBox),K=(w=ie,M=Q,_=void 0,P=void 0,k=void 0,F=void 0,_=Math.max(w.minX,M.minX),P=Math.max(w.minY,M.minY),k=Math.min(w.maxX,M.maxX),F=Math.min(w.maxY,M.maxY),Math.max(0,k-_)*Math.max(0,F-P)),j=m(ie)+m(Q);K<C?(C=K,p=q,Y=j<Y?j:Y):K===C&&j<Y&&(Y=j,p=q)}return p||d-f},a.prototype._chooseSplitAxis=function(h,f,d){var p=h.leaf?this.compareMinX:g,w=h.leaf?this.compareMinY:y;this._allDistMargin(h,f,d,p)<this._allDistMargin(h,f,d,w)&&h.children.sort(p)},a.prototype._allDistMargin=function(h,f,d,p){h.children.sort(p);for(var w=this.toBBox,M=c(h,0,f,w),_=c(h,d-f,d,w),P=v(M)+v(_),k=f;k<d-f;k++){var F=h.children[k];l(M,h.leaf?w(F):F),P+=v(M)}for(var C=d-f-1;C>=f;C--){var Y=h.children[C];l(_,h.leaf?w(Y):Y),P+=v(_)}return P},a.prototype._adjustParentBBoxes=function(h,f,d){for(var p=d;p>=0;p--)l(f[p],h)},a.prototype._condense=function(h){for(var f=h.length-1,d=void 0;f>=0;f--)h[f].children.length===0?f>0?(d=h[f-1].children).splice(d.indexOf(h[f]),1):this.clear():u(h[f],this.toBBox)},a})})(qt);var gr=qt.exports;class pr{constructor(e=[],r=mr){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:n}=this,s=r[e];for(;e>0;){const a=e-1>>1,i=r[a];if(n(s,i)>=0)break;r[e]=i,e=a}r[e]=s}_down(e){const{data:r,compare:n}=this,s=this.length>>1,a=r[e];for(;e<s;){let i=(e<<1)+1,u=r[i];const c=i+1;if(c<this.length&&n(r[c],u)<0&&(i=c,u=r[c]),n(u,a)>=0)break;r[e]=u,e=i}r[e]=a}}function mr(o,e){return o<e?-1:o>e?1:0}const vr=Object.freeze(Object.defineProperty({__proto__:null,default:pr},Symbol.toStringTag,{value:"Module"})),xr=yr(vr);var nt={exports:{}},Mr=function(e,r,n,s){var a=e[0],i=e[1],u=!1;n===void 0&&(n=0),s===void 0&&(s=r.length);for(var c=(s-n)/2,l=0,g=c-1;l<c;g=l++){var y=r[n+l*2+0],m=r[n+l*2+1],v=r[n+g*2+0],L=r[n+g*2+1],D=m>i!=L>i&&a<(v-y)*(i-m)/(L-m)+y;D&&(u=!u)}return u},_r=function(e,r,n,s){var a=e[0],i=e[1],u=!1;n===void 0&&(n=0),s===void 0&&(s=r.length);for(var c=s-n,l=0,g=c-1;l<c;g=l++){var y=r[l+n][0],m=r[l+n][1],v=r[g+n][0],L=r[g+n][1],D=m>i!=L>i&&a<(v-y)*(i-m)/(L-m)+y;D&&(u=!u)}return u},Ut=Mr,$t=_r;nt.exports=function(e,r,n,s){return r.length>0&&Array.isArray(r[0])?$t(e,r,n,s):Ut(e,r,n,s)};nt.exports.nested=$t;nt.exports.flat=Ut;var wr=nt.exports,mt={exports:{}};(function(o,e){(function(r,n){n(e)})(Bt,function(r){const s=33306690738754706e-32;function a(D,I,A,h,f){let d,p,w,M,_=I[0],P=h[0],k=0,F=0;P>_==P>-_?(d=_,_=I[++k]):(d=P,P=h[++F]);let C=0;if(k<D&&F<A)for(P>_==P>-_?(w=d-((p=_+d)-_),_=I[++k]):(w=d-((p=P+d)-P),P=h[++F]),d=p,w!==0&&(f[C++]=w);k<D&&F<A;)P>_==P>-_?(w=d-((p=d+_)-(M=p-d))+(_-M),_=I[++k]):(w=d-((p=d+P)-(M=p-d))+(P-M),P=h[++F]),d=p,w!==0&&(f[C++]=w);for(;k<D;)w=d-((p=d+_)-(M=p-d))+(_-M),_=I[++k],d=p,w!==0&&(f[C++]=w);for(;F<A;)w=d-((p=d+P)-(M=p-d))+(P-M),P=h[++F],d=p,w!==0&&(f[C++]=w);return d===0&&C!==0||(f[C++]=d),C}function i(D){return new Float64Array(D)}const u=33306690738754716e-32,c=22204460492503146e-32,l=11093356479670487e-47,g=i(4),y=i(8),m=i(12),v=i(16),L=i(4);r.orient2d=function(D,I,A,h,f,d){const p=(I-d)*(A-f),w=(D-f)*(h-d),M=p-w;if(p===0||w===0||p>0!=w>0)return M;const _=Math.abs(p+w);return Math.abs(M)>=u*_?M:-function(P,k,F,C,Y,q,ie){let Q,K,j,se,E,x,z,X,R,V,O,G,N,Z,re,ee,oe,W;const ae=P-Y,ne=F-Y,te=k-q,he=C-q;E=(re=(X=ae-(z=(x=134217729*ae)-(x-ae)))*(V=he-(R=(x=134217729*he)-(x-he)))-((Z=ae*he)-z*R-X*R-z*V))-(O=re-(oe=(X=te-(z=(x=134217729*te)-(x-te)))*(V=ne-(R=(x=134217729*ne)-(x-ne)))-((ee=te*ne)-z*R-X*R-z*V))),g[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),g[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,g[2]=G-(W-E)+(O-E),g[3]=W;let pe=function(Ye,ke){let He=ke[0];for(let Ee=1;Ee<Ye;Ee++)He+=ke[Ee];return He}(4,g),be=c*ie;if(pe>=be||-pe>=be||(Q=P-(ae+(E=P-ae))+(E-Y),j=F-(ne+(E=F-ne))+(E-Y),K=k-(te+(E=k-te))+(E-q),se=C-(he+(E=C-he))+(E-q),Q===0&&K===0&&j===0&&se===0)||(be=l*ie+s*Math.abs(pe),(pe+=ae*se+he*Q-(te*j+ne*K))>=be||-pe>=be))return pe;E=(re=(X=Q-(z=(x=134217729*Q)-(x-Q)))*(V=he-(R=(x=134217729*he)-(x-he)))-((Z=Q*he)-z*R-X*R-z*V))-(O=re-(oe=(X=K-(z=(x=134217729*K)-(x-K)))*(V=ne-(R=(x=134217729*ne)-(x-ne)))-((ee=K*ne)-z*R-X*R-z*V))),L[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),L[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,L[2]=G-(W-E)+(O-E),L[3]=W;const Ve=a(4,g,4,L,y);E=(re=(X=ae-(z=(x=134217729*ae)-(x-ae)))*(V=se-(R=(x=134217729*se)-(x-se)))-((Z=ae*se)-z*R-X*R-z*V))-(O=re-(oe=(X=te-(z=(x=134217729*te)-(x-te)))*(V=j-(R=(x=134217729*j)-(x-j)))-((ee=te*j)-z*R-X*R-z*V))),L[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),L[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,L[2]=G-(W-E)+(O-E),L[3]=W;const it=a(Ve,y,4,L,m);E=(re=(X=Q-(z=(x=134217729*Q)-(x-Q)))*(V=se-(R=(x=134217729*se)-(x-se)))-((Z=Q*se)-z*R-X*R-z*V))-(O=re-(oe=(X=K-(z=(x=134217729*K)-(x-K)))*(V=j-(R=(x=134217729*j)-(x-j)))-((ee=K*j)-z*R-X*R-z*V))),L[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),L[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,L[2]=G-(W-E)+(O-E),L[3]=W;const De=a(it,m,4,L,v);return v[De-1]}(D,I,A,h,f,d,_)},r.orient2dfast=function(D,I,A,h,f,d){return(I-d)*(A-f)-(D-f)*(h-d)},Object.defineProperty(r,"__esModule",{value:!0})})})(mt,mt.exports);var Lr=mt.exports,kt=gr,rt=xr,Sr=wr,br=Lr.orient2d;rt.default&&(rt=rt.default);_t.exports=Nt;_t.exports.default=Nt;function Nt(o,e,r){e=Math.max(0,e===void 0?2:e),r=r||0;var n=Er(o),s=new kt(16);s.toBBox=function(h){return{minX:h[0],minY:h[1],maxX:h[0],maxY:h[1]}},s.compareMinX=function(h,f){return h[0]-f[0]},s.compareMinY=function(h,f){return h[1]-f[1]},s.load(o);for(var a=[],i=0,u;i<n.length;i++){var c=n[i];s.remove(c),u=At(c,u),a.push(u)}var l=new kt(16);for(i=0;i<a.length;i++)l.insert(ut(a[i]));for(var g=e*e,y=r*r;a.length;){var m=a.shift(),v=m.p,L=m.next.p,D=ct(v,L);if(!(D<y)){var I=D/g;c=Pr(s,m.prev.p,v,L,m.next.next.p,I,l),c&&Math.min(ct(c,v),ct(c,L))<=I&&(a.push(m),a.push(At(c,m)),s.remove(c),l.remove(m),l.insert(ut(m)),l.insert(ut(m.next)))}}m=u;var A=[];do A.push(m.p),m=m.next;while(m!==u);return A.push(m.p),A}function Pr(o,e,r,n,s,a,i){for(var u=new rt([],zr),c=o.data;c;){for(var l=0;l<c.children.length;l++){var g=c.children[l],y=c.leaf?lt(g,r,n):Dr(r,n,g);y>a||u.push({node:g,dist:y})}for(;u.length&&!u.peek().node.children;){var m=u.pop(),v=m.node,L=lt(v,e,r),D=lt(v,n,s);if(m.dist<L&&m.dist<D&&Ft(r,v,i)&&Ft(n,v,i))return v}c=u.pop(),c&&(c=c.node)}return null}function zr(o,e){return o.dist-e.dist}function Dr(o,e,r){if(Et(o,r)||Et(e,r))return 0;var n=et(o[0],o[1],e[0],e[1],r.minX,r.minY,r.maxX,r.minY);if(n===0)return 0;var s=et(o[0],o[1],e[0],e[1],r.minX,r.minY,r.minX,r.maxY);if(s===0)return 0;var a=et(o[0],o[1],e[0],e[1],r.maxX,r.minY,r.maxX,r.maxY);if(a===0)return 0;var i=et(o[0],o[1],e[0],e[1],r.minX,r.maxY,r.maxX,r.maxY);return i===0?0:Math.min(n,s,a,i)}function Et(o,e){return o[0]>=e.minX&&o[0]<=e.maxX&&o[1]>=e.minY&&o[1]<=e.maxY}function Ft(o,e,r){for(var n=Math.min(o[0],e[0]),s=Math.min(o[1],e[1]),a=Math.max(o[0],e[0]),i=Math.max(o[1],e[1]),u=r.search({minX:n,minY:s,maxX:a,maxY:i}),c=0;c<u.length;c++)if(kr(u[c].p,u[c].next.p,o,e))return!1;return!0}function Ce(o,e,r){return br(o[0],o[1],e[0],e[1],r[0],r[1])}function kr(o,e,r,n){return o!==n&&e!==r&&Ce(o,e,r)>0!=Ce(o,e,n)>0&&Ce(r,n,o)>0!=Ce(r,n,e)>0}function ut(o){var e=o.p,r=o.next.p;return o.minX=Math.min(e[0],r[0]),o.minY=Math.min(e[1],r[1]),o.maxX=Math.max(e[0],r[0]),o.maxY=Math.max(e[1],r[1]),o}function Er(o){for(var e=o[0],r=o[0],n=o[0],s=o[0],a=0;a<o.length;a++){var i=o[a];i[0]<e[0]&&(e=i),i[0]>n[0]&&(n=i),i[1]<r[1]&&(r=i),i[1]>s[1]&&(s=i)}var u=[e,r,n,s],c=u.slice();for(a=0;a<o.length;a++)Sr(o[a],u)||c.push(o[a]);return Ar(c)}function At(o,e){var r={p:o,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(r.next=e.next,r.prev=e,e.next.prev=r,e.next=r):(r.prev=r,r.next=r),r}function ct(o,e){var r=o[0]-e[0],n=o[1]-e[1];return r*r+n*n}function lt(o,e,r){var n=e[0],s=e[1],a=r[0]-n,i=r[1]-s;if(a!==0||i!==0){var u=((o[0]-n)*a+(o[1]-s)*i)/(a*a+i*i);u>1?(n=r[0],s=r[1]):u>0&&(n+=a*u,s+=i*u)}return a=o[0]-n,i=o[1]-s,a*a+i*i}function et(o,e,r,n,s,a,i,u){var c=r-o,l=n-e,g=i-s,y=u-a,m=o-s,v=e-a,L=c*c+l*l,D=c*g+l*y,I=g*g+y*y,A=c*m+l*v,h=g*m+y*v,f=L*I-D*D,d,p,w,M,_=f,P=f;f===0?(p=0,_=1,M=h,P=I):(p=D*h-I*A,M=L*h-D*A,p<0?(p=0,M=h,P=I):p>_&&(p=_,M=h+D,P=I)),M<0?(M=0,-A<0?p=0:-A>L?p=_:(p=-A,_=L)):M>P&&(M=P,-A+D<0?p=0:-A+D>L?p=_:(p=-A+D,_=L)),d=p===0?0:p/_,w=M===0?0:M/P;var k=(1-d)*o+d*r,F=(1-d)*e+d*n,C=(1-w)*s+w*i,Y=(1-w)*a+w*u,q=C-k,ie=Y-F;return q*q+ie*ie}function Fr(o,e){return o[0]===e[0]?o[1]-e[1]:o[0]-e[0]}function Ar(o){o.sort(Fr);for(var e=[],r=0;r<o.length;r++){for(;e.length>=2&&Ce(e[e.length-2],e[e.length-1],o[r])<=0;)e.pop();e.push(o[r])}for(var n=[],s=o.length-1;s>=0;s--){for(;n.length>=2&&Ce(n[n.length-2],n[n.length-1],o[s])<=0;)n.pop();n.push(o[s])}return n.pop(),e.pop(),e.concat(n)}var Cr=_t.exports;const Ir=dr(Cr);function Jr(o,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var r=[];if(Ze(o,function(s){r.push([s[0],s[1]])}),!r.length)return null;var n=Ir(r,e.concavity);return n.length>3?Ge([n]):null}function vt(o,e,r){r===void 0&&(r={});var n=Xe(o),s=Xe(e),a=ge(s[1]-n[1]),i=ge(s[0]-n[0]),u=ge(n[1]),c=ge(s[1]),l=Math.pow(Math.sin(a/2),2)+Math.pow(Math.sin(i/2),2)*Math.cos(u)*Math.cos(c);return ar(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),r.units)}function B(o){if(!o)throw new Error("geojson is required");switch(o.type){case"Feature":return Tt(o);case"FeatureCollection":return Xr(o);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return wt(o);default:throw new Error("unknown GeoJSON type")}}function Tt(o){var e={type:"Feature"};return Object.keys(o).forEach(function(r){switch(r){case"type":case"properties":case"geometry":return;default:e[r]=o[r]}}),e.properties=Gt(o.properties),e.geometry=wt(o.geometry),e}function Gt(o){var e={};return o&&Object.keys(o).forEach(function(r){var n=o[r];typeof n=="object"?n===null?e[r]=null:Array.isArray(n)?e[r]=n.map(function(s){return s}):e[r]=Gt(n):e[r]=n}),e}function Xr(o){var e={type:"FeatureCollection"};return Object.keys(o).forEach(function(r){switch(r){case"type":case"features":return;default:e[r]=o[r]}}),e.features=o.features.map(function(r){return Tt(r)}),e}function wt(o){var e={type:o.type};return o.bbox&&(e.bbox=o.bbox),o.type==="GeometryCollection"?(e.geometries=o.geometries.map(function(r){return wt(r)}),e):(e.coordinates=jt(o.coordinates),e)}function jt(o){var e=o;return typeof e[0]!="object"?e.slice():e.map(function(r){return jt(r)})}var Yr=function(){function o(e){this.points=e.points||[],this.duration=e.duration||1e4,this.sharpness=e.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=e.stepLength||60,this.length=this.points.length,this.delay=0;for(var r=0;r<this.length;r++)this.points[r].z=this.points[r].z||0;for(var r=0;r<this.length-1;r++){var n=this.points[r],s=this.points[r+1];this.centers.push({x:(n.x+s.x)/2,y:(n.y+s.y)/2,z:(n.z+s.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var r=0;r<this.centers.length-1;r++){var a=this.points[r+1].x-(this.centers[r].x+this.centers[r+1].x)/2,i=this.points[r+1].y-(this.centers[r].y+this.centers[r+1].y)/2,u=this.points[r+1].z-(this.centers[r].y+this.centers[r+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[r+1].x+this.sharpness*(this.centers[r].x+a),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r].y+i),z:(1-this.sharpness)*this.points[r+1].z+this.sharpness*(this.centers[r].z+u)},{x:(1-this.sharpness)*this.points[r+1].x+this.sharpness*(this.centers[r+1].x+a),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r+1].y+i),z:(1-this.sharpness)*this.points[r+1].z+this.sharpness*(this.centers[r+1].z+u)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}return o.prototype.cacheSteps=function(e){var r=[],n=this.pos(0);r.push(0);for(var s=0;s<this.duration;s+=10){var a=this.pos(s),i=Math.sqrt((a.x-n.x)*(a.x-n.x)+(a.y-n.y)*(a.y-n.y)+(a.z-n.z)*(a.z-n.z));i>e&&(r.push(s),n=a)}return r},o.prototype.vector=function(e){var r=this.pos(e+10),n=this.pos(e-10);return{angle:180*Math.atan2(r.y-n.y,r.x-n.x)/3.14,speed:Math.sqrt((n.x-r.x)*(n.x-r.x)+(n.y-r.y)*(n.y-r.y)+(n.z-r.z)*(n.z-r.z))}},o.prototype.pos=function(e){var r=e-this.delay;r<0&&(r=0),r>this.duration&&(r=this.duration-1);var n=r/this.duration;if(n>=1)return this.points[this.length-1];var s=Math.floor((this.points.length-1)*n),a=(this.length-1)*n-s;return Or(a,this.points[s],this.controls[s][1],this.controls[s+1][0],this.points[s+1])},o}();function Or(o,e,r,n,s){var a=Rr(o),i={x:s.x*a[0]+n.x*a[1]+r.x*a[2]+e.x*a[3],y:s.y*a[0]+n.y*a[1]+r.y*a[2]+e.y*a[3],z:s.z*a[0]+n.z*a[1]+r.z*a[2]+e.z*a[3]};return i}function Rr(o){var e=o*o,r=e*o;return[r,3*e*(1-o),3*o*(1-o)*(1-o),(1-o)*(1-o)*(1-o)]}function je(o,e){e===void 0&&(e={});for(var r=e.resolution||1e4,n=e.sharpness||.85,s=[],a=hr(o).coordinates.map(function(l){return{x:l[0],y:l[1]}}),i=new Yr({duration:r,points:a,sharpness:n}),u=function(l){var g=i.pos(l);Math.floor(l/100)%2===0&&s.push([g.x,g.y])},c=0;c<i.duration;c+=10)u(c);return u(i.duration),Je(s,e.properties)}function Zt(o,e){e===void 0&&(e={});var r=Number(o[0]),n=Number(o[1]),s=Number(o[2]),a=Number(o[3]);if(o.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var i=[r,n],u=[r,a],c=[s,a],l=[s,n];return Ge([[i,l,c,u,i]],e.properties,{bbox:o,id:e.id})}function Vt(o,e,r,n){n===void 0&&(n={});var s=Xe(o),a=ge(s[0]),i=ge(s[1]),u=ge(r),c=ur(e,n.units),l=Math.asin(Math.sin(i)*Math.cos(c)+Math.cos(i)*Math.sin(c)*Math.cos(u)),g=a+Math.atan2(Math.sin(u)*Math.sin(c)*Math.cos(i),Math.cos(c)-Math.sin(i)*Math.sin(l)),y=pt(g),m=pt(l);return ve([y,m],n.properties)}function Lt(o,e,r){r===void 0&&(r={});for(var n=r.steps||64,s=r.properties?r.properties:!Array.isArray(o)&&o.type==="Feature"&&o.properties?o.properties:{},a=[],i=0;i<n;i++)a.push(Vt(o,e,i*-360/n,r).geometry.coordinates);return a.push(a[0]),Ge([a],s)}function Ht(o,e,r){if(r===void 0&&(r={}),r.final===!0)return Br(o,e);var n=Xe(o),s=Xe(e),a=ge(n[0]),i=ge(s[0]),u=ge(n[1]),c=ge(s[1]),l=Math.sin(i-a)*Math.cos(c),g=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(i-a);return pt(Math.atan2(l,g))}function Br(o,e){var r=Ht(e,o);return r=(r+180)%360,r}function qr(o,e){var r=vt(o,e),n=Ht(o,e),s=Vt(o,r/2,n);return s}function Ct(o,e){e===void 0&&(e={});var r=0,n=0,s=0;return Ze(o,function(a){r+=a[0],n+=a[1],s++},!0),ve([r/s,n/s],e.properties)}function xt(o,e){switch(e===void 0&&(e={}),fr(o)){case"Point":return ve(Xe(o),e.properties);case"Polygon":var r=[];Ze(o,function(d){r.push(d)});var n=Ct(o,{properties:e.properties}),s=n.geometry.coordinates,a=0,i=0,u=0,c,l,g,y,m,v,L,D,I=r.map(function(d){return[d[0]-s[0],d[1]-s[1]]});for(c=0;c<r.length-1;c++)l=I[c],y=l[0],v=l[1],g=I[c+1],m=g[0],L=g[1],D=y*L-m*v,u+=D,a+=(y+m)*D,i+=(v+L)*D;if(u===0)return n;var A=u*.5,h=1/(6*A);return ve([s[0]+h*a,s[1]+h*i],e.properties);default:var f=Jr(o);return f?xt(f,{properties:e.properties}):Ct(o,{properties:e.properties})}}var It=6378137;function ht(o){return lr(o,function(e,r){return e+Ur(r)},0)}function Ur(o){var e=0,r;switch(o.type){case"Polygon":return Jt(o.coordinates);case"MultiPolygon":for(r=0;r<o.coordinates.length;r++)e+=Jt(o.coordinates[r]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function Jt(o){var e=0;if(o&&o.length>0){e+=Math.abs(Xt(o[0]));for(var r=1;r<o.length;r++)e-=Math.abs(Xt(o[r]))}return e}function Xt(o){var e,r,n,s,a,i,u,c=0,l=o.length;if(l>2){for(u=0;u<l;u++)u===l-2?(s=l-2,a=l-1,i=0):u===l-1?(s=l-1,a=0,i=1):(s=u,a=u+1,i=u+2),e=o[s],r=o[a],n=o[i],c+=(ft(n[0])-ft(e[0]))*Math.sin(ft(r[1]));c=c*It*It/2}return c}function ft(o){return o*Math.PI/180}const dt=(o,e,r,n)=>{o.addLayer({id:e,type:"circle",source:r,paint:{"circle-color":(n==null?void 0:n["circle-color"])||"#ff0","circle-radius":(n==null?void 0:n["circle-radius"])||5,"circle-stroke-color":(n==null?void 0:n["circle-stroke-color"])||"#000","circle-stroke-width":(n==null?void 0:n["circle-stroke-width"])||2}})},$e=(o,e,r,n)=>{o.addLayer({id:e,type:"line",source:r,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":(n==null?void 0:n["line-color"])||"#ff0","line-width":(n==null?void 0:n["line-width"])||4}})},tt=(o,e,r,n)=>{o.addLayer({id:e,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":(n==null?void 0:n["fill-color"])||"#ff0","fill-opacity":.8}})};function $r(o,e,r,n,s){let a="free",i="",u=[],c=[],l={},g=!1,y=!0,m=!1,v=!0,L=[],D=!0,I=5e4,A=!1,h={type:"FeatureCollection",features:[]},f={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},d={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}};const p=(b,J)=>{let U=0;return function(...$){const ce=new Date().getTime();ce-U<J||(U=ce,b(...$))}},w=b=>{switch(o.off("click",R),o.off("mousemove",te),o.off("contextmenu",N),se(),ne(),g&&(y=!0,X(!1)),g=!0,a=b.type||"point",D=b.multipleLine||!1,m=b.smooth||!1,I=b.brushSize*1e3||3e4,l=b,v=b.showLayer,f.properties=b,d.properties=b,a){case"point":break;case"brush":C();break}o.on("click",R),o.getCanvas().style.cursor=a=="brush"?"move":"crosshair"},M=b=>{a=b,f.properties.type=a,d.properties.type=a},_=b=>{if(r)if(u.length){const $=[u[u.length-1]];r($)}else r([]);x(),ne(),o.addSource(i,{type:"geojson",data:h}),dt(o,i,i,l),h.features.push({type:"Feature",properties:l,geometry:{type:"Point",coordinates:b.lngLat.toArray()}}),o.getSource(i).setData(B(h)),e&&e(W())},P=b=>{if(y){if(r)if(u.length){const U=u[u.length-1],$=[U,U+"point"];r($)}else r([]);x(),ne(),o.addSource(i,{type:"geojson",data:f}),$e(o,i,i),dt(o,i+"point",i,l),y=!1,o.on("mousemove",te),o.on("contextmenu",N),o.dragRotate.enable()}f.geometry.coordinates.push(b.lngLat.toArray());const J=o.getSource(i);J.setData(f),!D&&f.geometry.coordinates.length==3&&(o.off("mousemove",te),o.off("contextmenu",N),y=!0,X(!1),f.geometry.coordinates.pop(),J.setData(B(f)),e&&e(W()))},k=b=>{if(y){if(r)if(u.length){const $=u[u.length-1],ce=[$,$+"outline",$+"point"];r(ce)}else r([]);x(),ne(),o.addSource(i,{type:"geojson",data:d}),o.addSource(i+"point",{type:"geojson",data:h}),tt(o,i,i,l),$e(o,i+"outline",i,{"line-color":"black","line-width":2,...l}),dt(o,i+"point",i+"point",l),y=!1,o.on("mousemove",te),o.on("contextmenu",N),o.dragRotate.enable()}d.geometry.coordinates[0].length>=3&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(b.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),h.features.push(B({type:"Feature",geometry:{type:"Point",coordinates:b.lngLat.toArray()}})),o.getSource(i+"point").setData(h);const U=o.getSource(i);d.geometry.coordinates[0].length<=3&&!m&&U.setData(d),X(!0)},F=b=>{if(y){if(r)if(u.length){const U=u[u.length-1],$=[U,U+"outline"];r($)}else r([]);x(),ne(),o.addSource(i,{type:"geojson",data:d}),tt(o,i,i,l),$e(o,i+"outline",i,{"line-color":"black","line-width":2,...l}),y=!1,d.geometry.coordinates[0].push(b.lngLat.toArray()),o.getSource(i).setData(d),o.on("mousemove",te),o.on("contextmenu",N),X(!0),o.dragRotate.enable()}},C=()=>{o.on("mousedown",Z),o.on("mouseup",re),o.on("mousemove",O),o.on("mouseover",ee),o.on("mouseout",oe)},Y=()=>{x(),ne(),o.addSource(i,{type:"geojson",data:d}),tt(o,i,i,l),$e(o,i+"outline",i,{"line-color":"black","line-width":2,...l})},q=(b,J)=>{const U=ve([b.lng,b.lat]),$=J/2/111320,ce=ot(Lt(U,$,{units:"degrees"}));return Zt(ce)},ie=(b,J)=>{const U=q(b,J);d.geometry=U.geometry,o.getSource(i).setData(d)},Q=()=>{const b=i,U=o.getSource(b).serialize().data;e&&e(U)},K=b=>{I=b*1e3},j=b=>{d.properties.MGValue=b},se=()=>{o.off("mousedown",Z),o.off("mouseup",re),o.off("mousemove",O),o.off("mouseover",ee),o.off("mouseout",oe)},E=b=>{let J=B(b);const U=Je(J.geometry.coordinates[0]),$=je(U,{sharpness:.6});return J.geometry.coordinates[0]=$.geometry.coordinates,J},x=()=>{i=z(),u.push(i),c.push(i)},z=()=>{let b=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){const $=(b+Math.random()*16)%16|0;return b=Math.floor(b/16),(U==="x"?$:$&3|8).toString(16)})},X=b=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(U=>{b?o[U].disable():o[U].enable()})},R=b=>{switch(a){case"point":_(b);break;case"line":P(b);break;case"polygon":k(b);break;case"free":F(b);break}},V=b=>{switch(a){case"line":f.geometry.coordinates.length&&(f.geometry.coordinates.length==1&&f.geometry.coordinates.push(b.lngLat.toArray()),f.geometry.coordinates[f.geometry.coordinates.length-1]=b.lngLat.toArray(),o.getSource(i).setData(f));break;case"polygon":const J=d.geometry.coordinates[0].length;if(J){J==2?d.geometry.coordinates[0][J-1]=b.lngLat.toArray():d.geometry.coordinates[0][J-2]=b.lngLat.toArray();const $=o.getSource(i);$.setData(d),m&&d.geometry.coordinates[0].length>=3&&$.setData(E(d))}break;case"free":d.geometry.coordinates[0].length&&(L.push(b.point),d.geometry.coordinates[0].length!=1&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(b.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),o.getSource(i).setData(d));break}},O=b=>{ie(b.lngLat,I),A&&G()},G=p(Q,0),N=b=>{b.preventDefault(),o.off("mousemove",te),o.off("contextmenu",N),y=!0,L.push(b.point),X(!1),o.dragRotate.disable();const J=o.getSource(i);switch(a){case"line":f.geometry.coordinates.length&&J.setData(B(f));break;case"polygon":if(d.geometry.coordinates[0].length){const U=d.geometry.coordinates[0].length;d.geometry.coordinates[0].splice(U-2,1),J.setData(B(d))}v||(o.setLayoutProperty(i,"visibility","none"),o.setLayoutProperty(i+"outline","visibility","none")),o.setLayoutProperty(i+"point","visibility","none"),m&&J.setData(B(E(d)));break;case"free":if(d.geometry.coordinates[0].length){const U=d.geometry.coordinates[0].length;if(d.geometry.coordinates[0].splice(U-2,1),J.setData(B(d)),v||(o.setLayoutProperty(i,"visibility","none"),o.setLayoutProperty(i+"outline","visibility","none")),m){const $=[...L.slice(L.length/5),...L.slice(0,L.length/5),L.slice(L.length/5)[0]],ce=$.length>10?5:3,le=Math.ceil($.length/ce),Qe=[];for(let de=0;de<$.length;de+=le)Qe.push($.slice(de,de+le));let Pe=[];Qe.forEach(de=>{if(de.length>1){const Qt=new H(de).getLUT();Pe.push(...Qt)}else Pe.push(...de)}),d.geometry.coordinates[0].length=0;for(let de=0;de<Pe.length;de++){const bt=o.unproject(Pe[de]);d.geometry.coordinates[0].push(bt.toArray())}J.setData(B(d))}}break}e&&e(W())},Z=()=>{o.dragPan.disable(),o.dragRotate.disable(),A=!0,Q()},re=()=>{o.dragPan.enable(),o.dragRotate.enable(),A=!1},ee=()=>{Y()},oe=()=>{o.getLayer(i)&&o.removeLayer(i),o.getLayer(i+"outline")&&o.removeLayer(i+"outline"),o.getSource(i)&&o.removeSource(i)},W=()=>{const b=u,J=[];return b.forEach((U,$)=>{if(o.getSource(U)){const le=o.getSource(U).serialize().data;le.features?(le.features[0].properties.layerId=U,le.features[0].properties.sourceId=c[$],J.push(...le.features)):(le.properties.layerId=U,le.properties.sourceId=c[$],J.push(le))}}),J},ae=()=>{u.forEach(b=>{o.getLayer(b)&&o.removeLayer(b),o.getLayer(b+"outline")&&o.removeLayer(b+"outline"),o.getLayer(b+"point")&&o.removeLayer(b+"point"),o.getLayer(b+"text")&&o.removeLayer(b+"text")}),c.forEach(b=>{o.getSource(b)&&o.removeSource(b),o.getSource(b+"point")&&o.removeSource(b+"point"),o.getSource(b+"text")&&o.removeSource(b+"text")}),u.length=0,c.length=0},ne=()=>{L.length=0,h.features.length=0,f.geometry.coordinates.length=0,d.geometry.coordinates.length=0,d.geometry.coordinates[0]=[],d.properties.result=""},te=p(V,30),he=()=>{se(),o.off("click",R),o.off("mousemove",te),o.off("contextmenu",N),o.getCanvas().style.cursor="pointer",X(!1)},pe=()=>{(a=="free"||a=="polygon"||a=="point"||a=="line")&&u.length&&(o.removeLayer(u[u.length-1]),o.getLayer(u[u.length-1]+"outline")&&o.removeLayer(u[u.length-1]+"outline"),o.getLayer(u[u.length-1]+"point")&&o.removeLayer(u[u.length-1]+"point"),u.pop())},be=()=>{if((a=="free"||a=="polygon")&&c.length){const b=u.length-c.length,J=c.slice(b);if(b!==0&&J.length){const ce=o.getSource(J[0]).serialize().data.valueOf();o.getLayer(J[0])||(u.push(J[0]),tt(o,J[0],J[0],{"fill-color":ce.properties["fill-color"]}),$e(o,J[0]+"outline",J[0],{"line-color":"black","line-width":2,...ce.properties}))}}};let Ve=!1;const it=b=>{Ve=b};let De,Ye=!1,ke="";o.on("mousedown",b=>{const J=o.queryRenderedFeatures(b.point);J.length>0&&(ke=J[0].layer.source,Ve&&He(b))});const He=b=>{o.dragPan.disable(),De=b.lngLat,Ye=!0,o.on("mouseup",Ee),o.on("mousemove",St),s&&s()},Ee=()=>{if(Ye=!1,o.off("mouseup",Ee),o.off("mousemove",St),o.dragPan.enable(),n){const J=o.getSource(ke).serialize().data;n(J)}},St=b=>{if(!Ye)return;const J=b.lngLat,U=J.lng-De.lng,$=J.lat-De.lat;De=J;const ce=o.getSource(ke),le=ce.serialize().data;le.geometry.coordinates=le.geometry.coordinates.map(Qe=>Qe.map(Pe=>[Pe[0]+U,Pe[1]+$])),ce.setData(le)};return{startDraw:w,revoke:pe,redo:be,getFeaturesFromDraw:W,clearDraw:ae,stopDraw:he,setBrushSize:K,setValue:j,setDrawMethod:M,setDragMode:it}}const Nr=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"symbol",source:r,paint:{"text-color":"#006e1a","text-halo-width":3,"text-halo-color":"rgba(255,255,255,1)",...(n==null?void 0:n.symbolPaint)??{}},layout:{"icon-image":"","text-allow-overlap":!0,"icon-allow-overlap":!0,"text-ignore-placement":!0,"icon-ignore-placement":!0,"text-field":"{name}","text-line-height":1.1,"text-size":17,"text-anchor":"left","text-offset":[1,0],"icon-size":.5,"text-font":["Noto Sans Regular"],...(n==null?void 0:n.symbolLayout)??{}}})},Ie=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"circle",source:r,paint:{"circle-color":"#ff0","circle-radius":5,"circle-stroke-color":"#000","circle-stroke-width":2,...(n==null?void 0:n.circlePaint)??{}},layout:{...(n==null?void 0:n.circleLayout)??{}}})},Me=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] ayer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"line",source:r,paint:{"line-color":(n==null?void 0:n["line-color"])||"black","line-width":(n==null?void 0:n["line-width"])||2,...(n==null?void 0:n.linePaint)??{}},layout:{"line-join":"round","line-cap":"round",...(n==null?void 0:n.lineLayout)??{}}})},Ne=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"symbol",source:r,paint:{...(n==null?void 0:n.symbolPaint)??{}},layout:{"text-font":["Noto Sans Regular"],"text-field":["get","result"],"text-allow-overlap":!0,"text-anchor":"bottom","text-overlap":"always","text-offset":[0,-.5],...(n==null?void 0:n.symbolLayout)??{}}})},ze=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":"#ff0","fill-opacity":.8,...(n==null?void 0:n.fillPaint)??{}},layout:{...(n==null?void 0:n.fillLayout)??{}}})},me=(o,e)=>{o.getLayer(e)&&o.removeLayer(e)},Ae=(o,e,r)=>{if(o.getSource(e)){console.warn(`[popillon] Source with id "${e}" already exists. Skipping addSource.`);return}o.addSource(e,r)},ue=(o,e,r)=>{const n=o.getSource(e);n?n.setData(r):console.warn(`[popillon] Source with id "${e}" is not a GeoJSONSource.`)},Le=(o,e)=>{o.getSource(e)&&o.removeSource(e)},Se=(o,e)=>{var r;if(o.getSource(e)){const n=o.getSource(e);return(r=n==null?void 0:n.serialize())==null?void 0:r.data}else{console.warn(`[popillon] Source "${e}" does not exist. Skipping getSourceData.`);return}};function Tr(o,e){let r="free",n="",s=[],a=[],i={},u=!1,c=!0,l=!1,g=[],y={type:"FeatureCollection",features:[]},m={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},v={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},L={type:"Feature",properties:{result:""},geometry:{type:"Point",coordinates:[]}};const D=x=>{o.off("click",P),o.off("mousemove",E),o.off("contextmenu",F),j(),u&&(c=!0,_(!1)),u=!0,r=x.type||"point",x.measure,l=x.smooth||!1,i=x,m.properties=x,v.properties=x,L.properties=x,o.on("click",P),o.getCanvas().style.cursor="crosshair"},I=x=>{w(),j(),o.addSource(n,{type:"geojson",data:y}),Ie(o,n,n,i),Ne(o,n+"text",n,{}),y.features.push({type:"Feature",properties:i,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(B(y)),e&&e(C())},A=x=>{w(),j(),o.addSource(n,{type:"geojson",data:y}),Nr(o,n,n,i),y.features.push({type:"Feature",properties:i,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(B(y)),e&&e(C())},h=x=>{c&&(w(),j(),o.addSource(n,{type:"geojson",data:m}),o.addSource(n+"text",{type:"geojson",data:y}),Me(o,n,n),Ie(o,n+"point",n,i),Ne(o,n+"text",n+"text",{}),c=!1,o.on("mousemove",E),o.on("contextmenu",F)),m.geometry.coordinates.push(x.lngLat.toArray()),o.getSource(n).setData(m),y.features.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n+"text").setData(y)},f=x=>{c&&(w(),j(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:L}),ze(o,n,n),Me(o,n+"outline",n,{"line-color":"black","line-width":2,...i}),Ie(o,n+"point",n),Ne(o,n+"area",n+"area",{}),c=!1,o.on("mousemove",E),o.on("contextmenu",F)),v.geometry.coordinates[0].length>=3&&v.geometry.coordinates[0].pop(),v.geometry.coordinates[0].push(x.lngLat.toArray()),v.geometry.coordinates[0].push(v.geometry.coordinates[0][0]),g.push(x.point),o.getSource(n).setData(v),_(!0)},d=x=>{c&&(w(),j(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:L}),ze(o,n,n,i),Me(o,n+"outline",n,{"line-color":"black","line-width":2,...i}),Ne(o,n+"area",n+"area",{}),c=!1,v.geometry.coordinates[0].push(x.lngLat.toArray()),o.getSource(n).setData(v),o.on("mousemove",E),o.on("contextmenu",F),_(!0))},p=x=>{if(c){w(),j(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:L}),o.addSource(n+"point",{type:"geojson",data:y}),ze(o,n,n,i),Me(o,n+"outline",n,{"line-color":"black","line-width":2,...i}),Ie(o,n+"point",n+"point"),Ne(o,n+"area",n+"area",{}),c=!1;const z={type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}};y.features.push(B(z)),y.features.push(B(z)),L.geometry.coordinates=x.lngLat.toArray(),o.getSource(n+"point").setData(y),o.on("mousemove",E),o.on("contextmenu",F),_(!0)}},w=()=>{n=M(),s.push(n),a.push(n)},M=()=>{let x=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(X){const R=(x+Math.random()*16)%16|0;return x=Math.floor(x/16),(X==="x"?R:R&3|8).toString(16)})},_=x=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(X=>{x?o[X].disable():o[X].enable()})},P=x=>{switch(r){case"symbol":A(x);break;case"point":I(x);break;case"line":h(x);break;case"polygon":f(x);break;case"free":d(x);break;case"circle":p(x);break}},k=x=>{switch(r){case"line":if(m.geometry.coordinates.length){m.geometry.coordinates.length==1&&m.geometry.coordinates.push(x.lngLat.toArray()),m.geometry.coordinates[m.geometry.coordinates.length-1]=x.lngLat.toArray(),o.getSource(n).setData(m);const oe=m.geometry.coordinates[m.geometry.coordinates.length-2],W=m.geometry.coordinates[m.geometry.coordinates.length-1],ae=vt(oe,W,{units:"kilometers"}),ne=qr(ve(oe),ve(W)),te=y.features[y.features.length-1];te.properties.result=Ke(ae,4)+"km",te.geometry.coordinates=ne.geometry.coordinates,o.getSource(n+"text").setData(B(y))}break;case"polygon":const Z=v.geometry.coordinates[0].length;if(Z){Z==2?v.geometry.coordinates[0][Z-1]=x.lngLat.toArray():v.geometry.coordinates[0][Z-2]=x.lngLat.toArray();const ee=ht(v)/1e6;if(Z>=4){var z=Ge(v.geometry.coordinates),X=xt(z);L.geometry.coordinates=X.geometry.coordinates,L.properties.result=Ke(ee,2)+"km²"}const oe=o.getSource(n);oe.setData(v),o.getSource(n+"area").setData(L),l&&v.geometry.coordinates[0].length>=3&&oe.setData(Y(v))}break;case"free":const re=v.geometry.coordinates[0].length;if(re){g.push(x.point),v.geometry.coordinates[0].length!=1&&v.geometry.coordinates[0].pop(),v.geometry.coordinates[0].push(x.lngLat.toArray()),v.geometry.coordinates[0].push(v.geometry.coordinates[0][0]);const ee=ht(v)/1e6;if(re>=4){var z=Ge(v.geometry.coordinates),X=xt(z);L.geometry.coordinates=X.geometry.coordinates,L.properties.result=Ke(ee,2)+"km²"}o.getSource(n).setData(v),o.getSource(n+"area").setData(L)}break;case"circle":if(y.features.length){y.features[1].geometry.coordinates=x.lngLat.toArray();var R=ve(y.features[0].geometry.coordinates),V=ve(y.features[1].geometry.coordinates),O=vt(R,V,{units:"miles"}),G={steps:500,units:"miles",properties:{foo:"bar"}},N=Lt(R,O,G);v.geometry.coordinates=N.geometry.coordinates;const ee=ht(v)/1e6;L.properties.result=Ke(ee,2)+"km²";const oe=o.getSource(n+"point"),W=o.getSource(n),ae=o.getSource(n+"area");oe.setData(y),W.setData(v),ae.setData(L)}break}},F=x=>{x.preventDefault(),o.off("mousemove",E),o.off("contextmenu",F),c=!0,g.push(x.point),_(!1);const z=o.getSource(n);switch(r){case"line":m.geometry.coordinates.length&&(console.log(m),z.setData(B(m)),o.removeLayer(n+"point"),l&&m.geometry.coordinates.length>=2&&z.setData(q(m)));break;case"polygon":v.geometry.coordinates[0].length&&z.setData(B(v)),o.setLayoutProperty(n+"point","visibility","none"),l&&z.setData(B(Y(v)));break;case"free":if(v.geometry.coordinates[0].length&&(z.setData(B(v)),l)){const X=[...g.slice(g.length/5),...g.slice(0,g.length/5),g.slice(g.length/5)[0]],R=X.length>10?5:3,V=Math.ceil(X.length/R),O=[];for(let N=0;N<X.length;N+=V)O.push(X.slice(N,N+V));let G=[];O.forEach(N=>{if(N.length>1){const re=new H(N).getLUT();G.push(...re)}else G.push(...N)}),v.geometry.coordinates[0].length=0;for(let N=0;N<G.length;N++){const Z=o.unproject(G[N]);v.geometry.coordinates[0].push(Z.toArray())}z.setData(B(v))}break;case"circle":o.removeLayer(n+"point"),o.removeSource(n+"point");break}e&&e(C())},C=()=>{const x=s,z=[];return x.forEach((X,R)=>{const O=o.getSource(X).serialize().data;O.features?(O.features[0].properties.layerId=X,O.features[0].properties.sourceId=a[R],z.push(...O.features)):(O.properties.layerId=X,O.properties.sourceId=a[R],z.push(O))}),z},Y=x=>{let z=B(x);const X=Je(z.geometry.coordinates[0]),R=je(X,{sharpness:.6});return z.geometry.coordinates[0]=R.geometry.coordinates,z},q=x=>{let z=B(x);console.log(z,"lineFeature");const X=Je(z.geometry.coordinates),R=je(X,{sharpness:.6});return z.geometry.coordinates=R.geometry.coordinates,z},ie=x=>{o.getLayer(x)&&o.removeLayer(x),o.getLayer(x+"outline")&&o.removeLayer(x+"outline"),o.getLayer(x+"point")&&o.removeLayer(x+"point"),o.getLayer(x+"area")&&o.removeLayer(x+"area"),o.getLayer(x+"text")&&o.removeLayer(x+"text"),s=s.filter(z=>z!==x)},Q=()=>{s.forEach(x=>{o.removeLayer(x),o.getLayer(x+"outline")&&o.removeLayer(x+"outline"),o.getLayer(x+"point")&&o.removeLayer(x+"point"),o.getLayer(x+"area")&&o.removeLayer(x+"area"),o.getLayer(x+"text")&&o.removeLayer(x+"text")}),a.forEach(x=>{o.removeSource(x),o.getSource(x+"point")&&o.removeSource(x+"point"),o.getSource(x+"text")&&o.removeSource(x+"text"),o.getSource(x+"area")&&o.removeSource(x+"area")}),s.length=0,a.length=0},K=()=>{o.off("click",P),o.off("mousemove",E),o.off("contextmenu",F),o.getCanvas().style.cursor="pointer",_(!1)},j=()=>{g.length=0,y.features.length=0,m.geometry.coordinates.length=0,v.geometry.coordinates.length=0,v.geometry.coordinates[0]=[],v.properties.result="",L.geometry.coordinates.length=0},E=((x,z)=>{let X=0;return function(...R){const V=new Date().getTime();V-X<z||(X=V,x(...R))}})(k,30);return{startMeasure:D,clearMeasure:Q,stopMeasure:K,getFeaturesFromMeasure:C,clearLayerById:ie}}const Gr=()=>{let o=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const n=(o+Math.random()*16)%16|0;return o=Math.floor(o/16),(r==="x"?n:n&3|8).toString(16)})},yt=o=>{let e=B(o);const r=Je(e.geometry.coordinates[0]),n=je(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates[0]=n.geometry.coordinates,e},Yt=o=>{const e=B(o),r=Je(e.geometry.coordinates),n=je(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates=n.geometry.coordinates,e},jr=(o,e)=>{let r=0;return function(...n){const s=new Date().getTime();s-r<e||(r=s,o(...n))}},gt=o=>["fill","line","circle","symbol"].includes(o.type)&&"source"in o&&o.source!=="maplibre";class Zr{constructor(e){T(this,"map");T(this,"eventMap",new Map);T(this,"uuid","");T(this,"layerIds",[]);T(this,"sourceIds",[]);T(this,"toolMode","draw");T(this,"_followPointId","followPointId");T(this,"options",{drawMode:"polygon",showLayer:!0,smooth:!0,polyline:!0,brushState:!1,brushSize:5e4});T(this,"newDraw",!0);T(this,"saveFreePolygonPoint",[]);T(this,"_activeLayer");T(this,"_editMode","idle");T(this,"_dragIndex",null);T(this,"_vertexSourceId","custom-vertex-source");T(this,"_vertexLayerId","custom-vertex-layer");T(this,"_isDragging",!1);T(this,"_dragOrigin",null);T(this,"_onMapClick",this._onMapClick_.bind(this));T(this,"_onMapDblclick",this._onMapDblclick_.bind(this));T(this,"_onMapMousemove",jr(this._onMapMousemove_.bind(this),10));T(this,"_onMapMousedown",this._onMapMousedown_.bind(this));T(this,"_onMapMouseup",this._onMapMouseup_.bind(this));T(this,"_onMapMouseover",this._onMapMouseover_.bind(this));T(this,"_onMapMouseout",this._onMapMouseout_.bind(this));T(this,"pointJson",{type:"FeatureCollection",features:[]});T(this,"lineJson",{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}});T(this,"polygonJson",{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});T(this,"drawFreePolygon",e=>{const{map:r}=this;this.newDraw&&(this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),Ae(r,this.uuid,{type:"geojson",data:this.polygonJson}),ze(r,this.uuid,this.uuid,this.options),Me(r,this.uuid+"outline",this.uuid,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),this._setMapActionEvents(!1))});T(this,"_getCoords",e=>e.type!=="GeometryCollection"&&Array.isArray(e.coordinates)&&e.type==="Polygon"&&Array.isArray(e.coordinates[0])?e.coordinates[0]:[]);T(this,"getFeatureLatest",()=>{const{map:e,layerIds:r}=this;return r.length?Se(e,r[r.length-1]):void 0});T(this,"getFeatures",()=>{const{map:e,layerIds:r}=this;return r.length?r.map(n=>Se(e,n)):[]});T(this,"revoke",()=>{const{layerIds:e}=this;if(e.length){const r=e[e.length-1];this.map.getLayer(r)&&this.map.removeLayer(r),this.map.getLayer(r+"outline")&&this.map.removeLayer(r+"outline"),e.pop()}});T(this,"redo",()=>{const{map:e}=this;if(this.sourceIds){const r=this.layerIds.length-this.sourceIds.length,n=this.sourceIds.slice(r);if(r!==0&&n.length){const s=n[0],a=Se(e,s);if(!a)return;this.map.getLayer(n[0])||(this.layerIds.push(n[0]),ze(this.map,n[0],n[0],{...a.properties}),Me(this.map,n[0]+"outline",n[0],{...a.properties}))}}});this.map=e,this.init()}init(){}_creatFollowPoints(e){const{map:r,_followPointId:n}=this;Ae(r,n,{type:"geojson",data:this.pointJson}),Ie(r,n,n,this.options);const s={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e}};this.pointJson.features.push(B(s)),this.pointJson.features.push(B(s)),ue(r,n,B(this.pointJson))}_updateFollowPoints(e){const{map:r,_followPointId:n}=this;this.pointJson.features[1].geometry.coordinates=e,ue(r,n,B(this.pointJson))}_clearFollowPoints(){const{map:e,_followPointId:r}=this;me(e,r),Le(e,r)}drawPoint(e){const{map:r}=this;this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.pointJson}),Ie(r,this.uuid,this.uuid,this.options),this.pointJson.features.push({type:"Feature",properties:{...this.options,layerId:this.uuid,sourceId:this.uuid},geometry:{type:"Point",coordinates:e.lngLat.toArray()}}),ue(r,this.uuid,B(this.pointJson)),this.emit("finishDraw",this.getFeatureLatest())}drawLine(e){const{map:r}=this;this.newDraw&&(this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.lineJson}),Me(r,this.uuid,this.uuid,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),r.on("dblclick",this._onMapDblclick),r.dragRotate.enable()),this.lineJson.geometry.coordinates.push(e.lngLat.toArray()),!this.options.polyline&&this.lineJson.geometry.coordinates.length==3&&(r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this.lineJson.geometry.coordinates.pop(),ue(r,this.uuid,B(this.lineJson)),this._setMapActionEvents(!0),this._clearFollowPoints(),this.emit("finishDraw",this.getFeatureLatest()))}drawPolygon(e){const{map:r}=this;this.newDraw&&(this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.polygonJson}),ze(r,this.uuid,this.uuid,this.options),Me(r,this.uuid+"outline",this.uuid,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),r.on("dblclick",this._onMapDblclick)),this.polygonJson.geometry.coordinates[0].length>=3&&this.polygonJson.geometry.coordinates[0].pop(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),this.polygonJson.geometry.coordinates[0].push(this.polygonJson.geometry.coordinates[0][0]),this._setMapActionEvents(!1)}_createRectangle(e,r){const n=ve([e.lng,e.lat]),s=r/2/111320,a=ot(Lt(n,s,{units:"degrees"}));return Zt(a)}setBrushSize(e){this.options.brushSize=e*1e3}startDraw(e){const{map:r}=this;switch(this.options=e,this.stop(),this.toolMode="draw",r.getCanvas().addEventListener("contextmenu",n=>n.preventDefault()),this._setMapCursorStyle("crosshair"),this.options.drawMode){case"circle":break;case"freePolygon":r.on("mousedown",this._onMapMousedown),r.on("mouseup",this._onMapMouseup);break;case"brush":r.on("mousedown",this._onMapMousedown),r.on("mouseup",this._onMapMouseup),r.on("mousemove",this._onMapMousemove),r.on("mouseover",this._onMapMouseover),r.on("mouseout",this._onMapMouseout),this._setMapCursorStyle("move");break}r.on("click",this._onMapClick)}stopDraw(){this.newDraw=!0,this.options.brushState=!1,this._clearMapEventListeners(),this._setMapActionEvents(!0),this._setMapCursorStyle()}_onMapClickDraw(e){switch(this.options.drawMode){case"circle":this.drawPoint(e);break;case"line":this.drawLine(e);break;case"polygon":this.drawPolygon(e);break}}_onMapMousemoveDraw(e){const{map:r}=this,n=e.lngLat.toArray();switch(this.options.drawMode){case"line":this._updateFollowPoints(n);const s=this.lineJson.geometry.coordinates.length;s&&(s==1&&this.lineJson.geometry.coordinates.push(e.lngLat.toArray()),this.lineJson.geometry.coordinates[s-1]=e.lngLat.toArray(),ue(r,this.uuid,this.options.smooth&&s>=2?Yt(this.lineJson):B(this.lineJson)));break;case"polygon":this._updateFollowPoints(n);const a=this.polygonJson.geometry.coordinates[0].length;a&&(a==2?this.polygonJson.geometry.coordinates[0][a-1]=n:this.polygonJson.geometry.coordinates[0][a-2]=n,a>=3&&ue(r,this.uuid,this.options.smooth?yt(this.polygonJson):this.polygonJson));break;case"freePolygon":this._updateFollowPoints(n),this.polygonJson.geometry.coordinates[0].length&&(this.saveFreePolygonPoint.push(e.point),this.polygonJson.geometry.coordinates[0].length!=1&&this.polygonJson.geometry.coordinates[0].pop(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),this.polygonJson.geometry.coordinates[0].push(this.polygonJson.geometry.coordinates[0][0]),ue(r,this.uuid,this.polygonJson));break;case"brush":const u=this._createRectangle(e.lngLat,this.options.brushSize??5e4);this.polygonJson.geometry=u.geometry,ue(r,this.uuid,this.polygonJson),this.options.brushState&&this.emit("finishBrush",Se(r,this.uuid));break}}_onMapDblclickDraw(e){const{map:r}=this;switch(e.preventDefault(),r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.options.drawMode){case"line":this.lineJson.geometry.coordinates.length?(this._clearFollowPoints(),this.lineJson.geometry.coordinates.splice(-2,1),this.lineJson.geometry.coordinates.splice(-2,1),ue(r,this.uuid,this.options.smooth&&this.lineJson.geometry.coordinates.length>=2?Yt(this.lineJson):B(this.lineJson)),this.emit("finishDraw",this.getFeatureLatest())):(me(r,this.uuid),me(r,this.uuid+"line"),Le(r,this.uuid),Le(r,this.uuid+"line"),this.layerIds.pop(),this.sourceIds.pop());break;case"polygon":this.polygonJson.geometry.coordinates[0].length>=3?(this._clearFollowPoints(),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.options.showLayer||(r.setLayoutProperty(this.uuid,"visibility","none"),r.setLayoutProperty(this.uuid+"outline","visibility","none")),this.polygonJson.properties.feedbackFeature=B(this.polygonJson),ue(r,this.uuid,this.options.smooth?yt(this.polygonJson):B(this.polygonJson)),this.emit("finishDraw",this.getFeatureLatest())):(this.layerIds.pop(),this.sourceIds.pop(),me(r,this.uuid),me(r,this.uuid+"line"),Le(r,this.uuid),Le(r,this.uuid+"line"));break}}_onMapMouseoverDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":this._addUUID(),this._clearJson(),Ae(e,this.uuid,{type:"geojson",data:this.polygonJson}),ze(e,this.uuid,this.uuid,this.options),Me(e,this.uuid+"outline",this.uuid,this.options);break}}_onMapMouseoutDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":me(e,this.uuid),me(e,this.uuid+"outline"),Le(e,this.uuid);break}}_onMapMousedownDraw(e){const{map:r}=this;switch(this.options.drawMode){case"freePolygon":this.drawFreePolygon(e);break;case"brush":r.dragPan.disable(),r.dragRotate.disable(),this.options.brushState=!0,this.emit("finishBrush",Se(r,this.uuid));break}}_onMapMouseupDraw(){const{map:e}=this;switch(this.options.drawMode){case"freePolygon":if(e.off("mousemove",this._onMapMousemove),e.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.polygonJson.geometry.coordinates[0].length){this._clearFollowPoints();const r=this.polygonJson.geometry.coordinates[0].length;if(this.polygonJson.geometry.coordinates[0].splice(r-2,1),ue(e,this.uuid,B(this.polygonJson)),this.options.showLayer||(this.map.setLayoutProperty(this.uuid,"visibility","none"),this.map.setLayoutProperty(this.uuid+"outline","visibility","none")),r>=2&&this.options.smooth){const n=this.saveFreePolygonPoint,s=[...n.slice(n.length/5),...n.slice(0,n.length/5),n.slice(n.length/5)[0]],a=s.length>10?5:3,i=Math.ceil(s.length/a),u=[];for(let l=0;l<s.length;l+=i)u.push(s.slice(l,l+i));let c=[];u.forEach(l=>{if(l.length>1){const y=new H(l).getLUT();c.push(...y)}else c.push(...l)}),this.polygonJson.geometry.coordinates[0].length=0;for(let l=0;l<c.length;l++){const g=this.map.unproject(c[l]);this.polygonJson.geometry.coordinates[0].push(g.toArray())}ue(e,this.uuid,B(this.polygonJson))}this.emit("finishDraw",this.getFeatureLatest())}else me(e,this.uuid),me(e,this.uuid+"outline"),Le(e,this.uuid),this.layerIds.pop(),this.sourceIds.pop();break;case"brush":e.dragPan.enable(),e.dragRotate.enable(),this.options.brushState=!1;break}}startEdit(){const{map:e}=this;this.stop(),this.toolMode="edit",e.on("click",this._onMapClick)}stopEdit(){const{map:e}=this;e.off("mousemove",this._onMapMousemove),e.off("mousedown",this._vertexLayerId,this._onMapMousedown),e.off("mouseup",this._vertexLayerId,this._onMapMouseup),e.off("click",this._onMapClick),this._dragIndex=null,this._removeVertexPoints(),this._setMapActionEvents(!0),this._setMapCursorStyle()}_updateVertexPoints(){var a;const{map:e}=this,r=Se(e,this._activeLayer.source);if(!r)return;const n=(a=r.properties)!=null&&a.feedbackFeature?this._getCoords(r.properties.feedbackFeature.geometry):this._getCoords(r.geometry);if(!n.length)return;const s=n.slice(0,-1).map((i,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:i}}));e.getSource(this._vertexSourceId)||(e.addSource(this._vertexSourceId,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.addLayer({id:this._vertexLayerId,type:"circle",source:this._vertexSourceId,paint:{"circle-radius":5,"circle-color":"#ff0","circle-stroke-width":2,"circle-stroke-color":"#000"}})),ue(e,this._vertexSourceId,B({type:"FeatureCollection",features:s}))}_removeVertexPoints(){const{map:e,_vertexLayerId:r,_vertexSourceId:n}=this;me(e,r),Le(e,n)}_onMapClickEdit(e){const{map:r}=this;r.off("mousemove",this._onMapMousemove),r.off("mousedown",this._vertexLayerId,this._onMapMousedown),r.off("mouseup",this._vertexLayerId,this._onMapMouseup),this._setMapCursorStyle(),this._removeVertexPoints();const n=r.queryRenderedFeatures(e.point),s=n==null?void 0:n[0];if(!s)return;const a=s.layer;gt(a)?(this._activeLayer&&this._activeLayer.id!==a.id&&(this._editMode="idle"),this._activeLayer=a,this._editMode==="idle"?(this._editMode="edit",this._updateVertexPoints(),this._setMapCursorStyle("grab")):(this._editMode="idle",this._removeVertexPoints(),this._setMapCursorStyle()),r.on("mousemove",this._onMapMousemove),r.on("mousedown",this._vertexLayerId,this._onMapMousedown),r.on("mouseup",this._vertexLayerId,this._onMapMouseup)):this._editMode="idle"}_onMapMousemoveEdit(e){var i,u,c;const{map:r}=this;if(this._editMode==="edit"&&this._dragIndex!==null){const l=Se(r,this._activeLayer.source);if(!l||!("geometry"in l))return;const g=(i=l.properties)==null?void 0:i.feedbackFeature,y=B(g?(u=l==null?void 0:l.properties)==null?void 0:u.feedbackFeature:l),{geometry:m}=y;if(m.type==="Polygon"){const v=m.coordinates[0];if(v[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],v.length>2&&(v[v.length-1]=v[0]),g){y.properties.feedbackFeature=B(y);const L=y.properties.smooth?yt(B(y)):y;ue(r,this._activeLayer.id,L)}else ue(r,this._activeLayer.id,y);this._updateVertexPoints()}}const n=r.queryRenderedFeatures(e.point),s=n.length>0?n[0]:void 0,a=((c=s==null?void 0:s.layer)==null?void 0:c.id)===this._vertexLayerId;this._setMapCursorStyle(a?"move":void 0)}_onMapMousedownEdit(e){var a,i;const{map:r}=this,n=r.queryRenderedFeatures(e.point),s=n.length>0?n[0]:void 0;((a=s==null?void 0:s.layer)==null?void 0:a.id)===this._vertexLayerId?(this._dragIndex=((i=s==null?void 0:s.properties)==null?void 0:i.index)??null,this._setMapActionEvents(!1),this.emit("startEdit",this._activeLayer)):this._dragIndex=null}_onMapMouseupEdit(){this._dragIndex=null,this._setMapActionEvents(!0),this.emit("finishEdit",this._activeLayer)}startDrag(){const{map:e}=this;this.stop(),this.toolMode="drag",e.on("mousemove",this._onMapMousemove),e.on("mousedown",this._onMapMousedown),e.on("mouseup",this._onMapMouseup)}stopDrag(){const{map:e}=this;e.off("mousemove",this._onMapMousemove),e.off("mousedown",this._onMapMousedown),e.off("mouseup",this._onMapMouseup),this._isDragging=!1,this._dragOrigin=null,this._setMapActionEvents(!0),this._setMapCursorStyle()}_onMapMousemoveDrag(e){var a;const{map:r}=this;if(this._isDragging&&this._dragOrigin&&this._activeLayer){const i=this._activeLayer.source,u=Se(r,i);if(!u||!("geometry"in u))return;const c=e.lngLat.lng-this._dragOrigin[0],l=e.lngLat.lat-this._dragOrigin[1];this._dragOrigin=[e.lngLat.lng,e.lngLat.lat];const{geometry:g}=u;if(u.geometry.type!=="GeometryCollection"&&g.type==="Polygon"){const m=u.geometry.coordinates[0].map(([v,L])=>[v+c,L+l]);u.geometry.coordinates[0]=m,ue(r,i,B(u));return}}const n=(a=r.queryRenderedFeatures(e.point))==null?void 0:a[0],s=n==null?void 0:n.layer;n&&s&>(s)?this._setMapCursorStyle("move"):this._setMapCursorStyle()}_onMapMousedownDrag(e){const{map:r}=this,n=r.queryRenderedFeatures(e.point),s=n==null?void 0:n[0];if(!s)return;const a=s.layer;gt(a)&&(this._isDragging=!0,this._dragOrigin=[e.lngLat.lng,e.lngLat.lat],this._activeLayer=a,this._setMapActionEvents(!1),this.emit("startDrag",this._activeLayer))}_onMapMouseupDrag(){this._isDragging&&this.emit("finishDrag",this._activeLayer),this._isDragging=!1,this._dragOrigin=null,this._setMapActionEvents(!0)}_onMapClick_(e){switch(this.toolMode){case"draw":this._onMapClickDraw(e);break;case"edit":this._onMapClickEdit(e);break}}_onMapDblclick_(e){switch(this.toolMode){case"draw":this._onMapDblclickDraw(e);break}}_onMapMousemove_(e){switch(this.toolMode){case"draw":this._onMapMousemoveDraw(e);break;case"edit":this._onMapMousemoveEdit(e);break;case"drag":this._onMapMousemoveDrag(e);break}}_onMapMousedown_(e){switch(this.toolMode){case"draw":this._onMapMousedownDraw(e);break;case"edit":this._onMapMousedownEdit(e);break;case"drag":this._onMapMousedownDrag(e);break}}_onMapMouseup_(){switch(this.toolMode){case"draw":this._onMapMouseupDraw();break;case"edit":this._onMapMouseupEdit();break;case"drag":this._onMapMouseupDrag();break}}_onMapMouseover_(){switch(this.toolMode){case"draw":this._onMapMouseoverDraw();break}}_onMapMouseout_(){switch(this.toolMode){case"draw":this._onMapMouseoutDraw();break}}_setMapActionEvents(e){["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(n=>{e?this.map[n].enable():this.map[n].disable()})}_setMapCursorStyle(e){this.map.getCanvas().style.cursor=e??""}_clearMapEventListeners(){const{map:e}=this;e.off("click",this._onMapClick),e.off("dblclick",this._onMapDblclick),e.off("mousemove",this._onMapMousemove),e.off("mouseout",this._onMapMouseout),e.off("mouseover",this._onMapMouseover),e.off("mousedown",this._onMapMousedown),e.off("mouseup",this._onMapMouseup),e.off("mousedown",this._vertexLayerId,this._onMapMousedown),e.off("mouseup",this._vertexLayerId,this._onMapMouseup)}_addUUID(){this.uuid=Gr(),this.layerIds.push(this.uuid),this.sourceIds.push(this.uuid)}_clearJson(){this.saveFreePolygonPoint.length=0,this.pointJson.features=[],this.polygonJson.geometry.coordinates[0].length=0,this.polygonJson.properties={...this.options,layerId:this.uuid,sourceId:this.uuid},this.lineJson.geometry.coordinates.length=0,this.lineJson.properties={...this.options,layerId:this.uuid,sourceId:this.uuid}}stop(){this.stopDrag(),this.stopDrag(),this.stopEdit()}clearLayers(){this.layerIds.forEach(e=>{this.map.getLayer(e)&&this.map.removeLayer(e),this.map.getLayer(e+"outline")&&this.map.removeLayer(e+"outline"),this.map.getLayer(e+"point")&&this.map.removeLayer(e+"point"),this.map.getLayer(e+"text")&&this.map.removeLayer(e+"text")}),this.sourceIds.forEach(e=>{this.map.getSource(e)&&this.map.removeSource(e),this.map.getSource(e+"point")&&this.map.removeSource(e+"point"),this.map.getSource(e+"text")&&this.map.removeSource(e+"text")}),this.layerIds.length=0,this.sourceIds.length=0,this._removeVertexPoints()}emit(e,r){const n=this.eventMap.get(e);n&&n.forEach(s=>s(r))}on(e,r){this.eventMap.has(e)||this.eventMap.set(e,new Set),this.eventMap.get(e).add(r)}off(e,r){var n;(n=this.eventMap.get(e))==null||n.delete(r)}}exports.DrawTool=Zr;exports.draw=$r;exports.measure=Tr;
|
|
1
|
+
"use strict";var Wt=Object.defineProperty;var Kt=(o,e,r)=>e in o?Wt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var T=(o,e,r)=>Kt(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{abs:Oe,cos:Me,sin:Fe,acos:er,atan2:Re,sqrt:we,pow:ge}=Math;function Be(o){return o<0?-ge(-o,1/3):ge(o,1/3)}const Ot=Math.PI,We=2*Ot,Le=Ot/2,tr=1e-6,it=Number.MAX_SAFE_INTEGER||9007199254740991,at=Number.MIN_SAFE_INTEGER||-9007199254740991,rr={x:0,y:0,z:0},S={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(o,e){const r=e(o);let n=r.x*r.x+r.y*r.y;return typeof r.z<"u"&&(n+=r.z*r.z),we(n)},compute:function(o,e,r){if(o===0)return e[0].t=0,e[0];const n=e.length-1;if(o===1)return e[n].t=1,e[n];const i=1-o;let a=e;if(n===0)return e[0].t=o,e[0];if(n===1){const u={x:i*a[0].x+o*a[1].x,y:i*a[0].y+o*a[1].y,t:o};return r&&(u.z=i*a[0].z+o*a[1].z),u}if(n<4){let u=i*i,c=o*o,l,g,y,m=0;n===2?(a=[a[0],a[1],a[2],rr],l=u,g=i*o*2,y=c):n===3&&(l=u*i,g=u*o*3,y=i*c*3,m=o*c);const v={x:l*a[0].x+g*a[1].x+y*a[2].x+m*a[3].x,y:l*a[0].y+g*a[1].y+y*a[2].y+m*a[3].y,t:o};return r&&(v.z=l*a[0].z+g*a[1].z+y*a[2].z+m*a[3].z),v}const s=JSON.parse(JSON.stringify(e));for(;s.length>1;){for(let u=0;u<s.length-1;u++)s[u]={x:s[u].x+(s[u+1].x-s[u].x)*o,y:s[u].y+(s[u+1].y-s[u].y)*o},typeof s[u].z<"u"&&(s[u].z=s[u].z+(s[u+1].z-s[u].z)*o);s.splice(s.length-1,1)}return s[0].t=o,s[0]},computeWithRatios:function(o,e,r,n){const i=1-o,a=r,s=e;let u=a[0],c=a[1],l=a[2],g=a[3],y;if(u*=i,c*=o,s.length===2)return y=u+c,{x:(u*s[0].x+c*s[1].x)/y,y:(u*s[0].y+c*s[1].y)/y,z:n?(u*s[0].z+c*s[1].z)/y:!1,t:o};if(u*=i,c*=2*i,l*=o*o,s.length===3)return y=u+c+l,{x:(u*s[0].x+c*s[1].x+l*s[2].x)/y,y:(u*s[0].y+c*s[1].y+l*s[2].y)/y,z:n?(u*s[0].z+c*s[1].z+l*s[2].z)/y:!1,t:o};if(u*=i,c*=1.5*i,l*=3*i,g*=o*o*o,s.length===4)return y=u+c+l+g,{x:(u*s[0].x+c*s[1].x+l*s[2].x+g*s[3].x)/y,y:(u*s[0].y+c*s[1].y+l*s[2].y+g*s[3].y)/y,z:n?(u*s[0].z+c*s[1].z+l*s[2].z+g*s[3].z)/y:!1,t:o}},derive:function(o,e){const r=[];for(let n=o,i=n.length,a=i-1;i>1;i--,a--){const s=[];for(let u=0,c;u<a;u++)c={x:a*(n[u+1].x-n[u].x),y:a*(n[u+1].y-n[u].y)},e&&(c.z=a*(n[u+1].z-n[u].z)),s.push(c);r.push(s),n=s}return r},between:function(o,e,r){return e<=o&&o<=r||S.approximately(o,e)||S.approximately(o,r)},approximately:function(o,e,r){return Oe(o-e)<=(r||tr)},length:function(o){const r=S.Tvalues.length;let n=0;for(let i=0,a;i<r;i++)a=.5*S.Tvalues[i]+.5,n+=S.Cvalues[i]*S.arcfn(a,o);return .5*n},map:function(o,e,r,n,i){const a=r-e,s=i-n,u=o-e,c=u/a;return n+s*c},lerp:function(o,e,r){const n={x:e.x+o*(r.x-e.x),y:e.y+o*(r.y-e.y)};return e.z!==void 0&&r.z!==void 0&&(n.z=e.z+o*(r.z-e.z)),n},pointToString:function(o){let e=o.x+"/"+o.y;return typeof o.z<"u"&&(e+="/"+o.z),e},pointsToString:function(o){return"["+o.map(S.pointToString).join(", ")+"]"},copy:function(o){return JSON.parse(JSON.stringify(o))},angle:function(o,e,r){const n=e.x-o.x,i=e.y-o.y,a=r.x-o.x,s=r.y-o.y,u=n*s-i*a,c=n*a+i*s;return Re(u,c)},round:function(o,e){const r=""+o,n=r.indexOf(".");return parseFloat(r.substring(0,n+1+e))},dist:function(o,e){const r=o.x-e.x,n=o.y-e.y;return we(r*r+n*n)},closest:function(o,e){let r=ge(2,63),n,i;return o.forEach(function(a,s){i=S.dist(e,a),i<r&&(r=i,n=s)}),{mdist:r,mpos:n}},abcratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const r=ge(o,e)+ge(1-o,e),n=r-1;return Oe(n/r)},projectionratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const r=ge(1-o,e),n=ge(o,e)+r;return r/n},lli8:function(o,e,r,n,i,a,s,u){const c=(o*n-e*r)*(i-s)-(o-r)*(i*u-a*s),l=(o*n-e*r)*(a-u)-(e-n)*(i*u-a*s),g=(o-r)*(a-u)-(e-n)*(i-s);return g==0?!1:{x:c/g,y:l/g}},lli4:function(o,e,r,n){const i=o.x,a=o.y,s=e.x,u=e.y,c=r.x,l=r.y,g=n.x,y=n.y;return S.lli8(i,a,s,u,c,l,g,y)},lli:function(o,e){return S.lli4(o,o.c,e,e.c)},makeline:function(o,e){return new H(o.x,o.y,(o.x+e.x)/2,(o.y+e.y)/2,e.x,e.y)},findbbox:function(o){let e=it,r=it,n=at,i=at;return o.forEach(function(a){const s=a.bbox();e>s.x.min&&(e=s.x.min),r>s.y.min&&(r=s.y.min),n<s.x.max&&(n=s.x.max),i<s.y.max&&(i=s.y.max)}),{x:{min:e,mid:(e+n)/2,max:n,size:n-e},y:{min:r,mid:(r+i)/2,max:i,size:i-r}}},shapeintersections:function(o,e,r,n,i){if(!S.bboxoverlap(e,n))return[];const a=[],s=[o.startcap,o.forward,o.back,o.endcap],u=[r.startcap,r.forward,r.back,r.endcap];return s.forEach(function(c){c.virtual||u.forEach(function(l){if(l.virtual)return;const g=c.intersects(l,i);g.length>0&&(g.c1=c,g.c2=l,g.s1=o,g.s2=r,a.push(g))})}),a},makeshape:function(o,e,r){const n=e.points.length,i=o.points.length,a=S.makeline(e.points[n-1],o.points[0]),s=S.makeline(o.points[i-1],e.points[0]),u={startcap:a,forward:o,back:e,endcap:s,bbox:S.findbbox([a,o,e,s])};return u.intersections=function(c){return S.shapeintersections(u,u.bbox,c,c.bbox,r)},u},getminmax:function(o,e,r){if(!r)return{min:0,max:0};let n=it,i=at,a,s;r.indexOf(0)===-1&&(r=[0].concat(r)),r.indexOf(1)===-1&&r.push(1);for(let u=0,c=r.length;u<c;u++)a=r[u],s=o.get(a),s[e]<n&&(n=s[e]),s[e]>i&&(i=s[e]);return{min:n,mid:(n+i)/2,max:i,size:i-n}},align:function(o,e){const r=e.p1.x,n=e.p1.y,i=-Re(e.p2.y-n,e.p2.x-r),a=function(s){return{x:(s.x-r)*Me(i)-(s.y-n)*Fe(i),y:(s.x-r)*Fe(i)+(s.y-n)*Me(i)}};return o.map(a)},roots:function(o,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const r=o.length-1,n=S.align(o,e),i=function(M){return 0<=M&&M<=1};if(r===2){const M=n[0].y,_=n[1].y,P=n[2].y,k=M-2*_+P;if(k!==0){const F=-we(_*_-M*P),A=-M+_,Y=-(F+A)/k,q=-(-F+A)/k;return[Y,q].filter(i)}else if(_!==P&&k===0)return[(2*_-P)/(2*_-2*P)].filter(i);return[]}const a=n[0].y,s=n[1].y,u=n[2].y,c=n[3].y;let l=-a+3*s-3*u+c,g=3*a-6*s+3*u,y=-3*a+3*s,m=a;if(S.approximately(l,0)){if(S.approximately(g,0))return S.approximately(y,0)?[]:[-m/y].filter(i);const M=we(y*y-4*g*m),_=2*g;return[(M-y)/_,(-y-M)/_].filter(i)}g/=l,y/=l,m/=l;const v=(3*y-g*g)/3,L=v/3,D=(2*g*g*g-9*g*y+27*m)/27,C=D/2,I=C*C+L*L*L;let h,f,d,p,w;if(I<0){const M=-v/3,_=M*M*M,P=we(_),k=-D/(2*P),F=k<-1?-1:k>1?1:k,A=er(F),Y=Be(P),q=2*Y;return d=q*Me(A/3)-g/3,p=q*Me((A+We)/3)-g/3,w=q*Me((A+2*We)/3)-g/3,[d,p,w].filter(i)}else{if(I===0)return h=C<0?Be(-C):-Be(C),d=2*h-g/3,p=-h-g/3,[d,p].filter(i);{const M=we(I);return h=Be(-C+M),f=Be(C+M),[h-f-g/3].filter(i)}}},droots:function(o){if(o.length===3){const e=o[0],r=o[1],n=o[2],i=e-2*r+n;if(i!==0){const a=-we(r*r-e*n),s=-e+r,u=-(a+s)/i,c=-(-a+s)/i;return[u,c]}else if(r!==n&&i===0)return[(2*r-n)/(2*(r-n))];return[]}if(o.length===2){const e=o[0],r=o[1];return e!==r?[e/(e-r)]:[]}return[]},curvature:function(o,e,r,n,i){let a,s,u,c,l=0,g=0;const y=S.compute(o,e),m=S.compute(o,r),v=y.x*y.x+y.y*y.y;if(n?(a=we(ge(y.y*m.z-m.y*y.z,2)+ge(y.z*m.x-m.z*y.x,2)+ge(y.x*m.y-m.x*y.y,2)),s=ge(v+y.z*y.z,3/2)):(a=y.x*m.y-y.y*m.x,s=ge(v,3/2)),a===0||s===0)return{k:0,r:0};if(l=a/s,g=s/a,!i){const L=S.curvature(o-.001,e,r,n,!0).k,D=S.curvature(o+.001,e,r,n,!0).k;c=(D-l+(l-L))/2,u=(Oe(D-l)+Oe(l-L))/2}return{k:l,r:g,dk:c,adk:u}},inflections:function(o){if(o.length<4)return[];const e=S.align(o,{p1:o[0],p2:o.slice(-1)[0]}),r=e[2].x*e[1].y,n=e[3].x*e[1].y,i=e[1].x*e[2].y,a=e[3].x*e[2].y,s=18*(-3*r+2*n+3*i-a),u=18*(3*r-n-3*i),c=18*(i-r);if(S.approximately(s,0)){if(!S.approximately(u,0)){let m=-c/u;if(0<=m&&m<=1)return[m]}return[]}const l=2*s;if(S.approximately(l,0))return[];const g=u*u-4*s*c;if(g<0)return[];const y=Math.sqrt(g);return[(y-u)/l,-(u+y)/l].filter(function(m){return 0<=m&&m<=1})},bboxoverlap:function(o,e){const r=["x","y"],n=r.length;for(let i=0,a,s,u,c;i<n;i++)if(a=r[i],s=o[a].mid,u=e[a].mid,c=(o[a].size+e[a].size)/2,Oe(s-u)>=c)return!1;return!0},expandbox:function(o,e){e.x.min<o.x.min&&(o.x.min=e.x.min),e.y.min<o.y.min&&(o.y.min=e.y.min),e.z&&e.z.min<o.z.min&&(o.z.min=e.z.min),e.x.max>o.x.max&&(o.x.max=e.x.max),e.y.max>o.y.max&&(o.y.max=e.y.max),e.z&&e.z.max>o.z.max&&(o.z.max=e.z.max),o.x.mid=(o.x.min+o.x.max)/2,o.y.mid=(o.y.min+o.y.max)/2,o.z&&(o.z.mid=(o.z.min+o.z.max)/2),o.x.size=o.x.max-o.x.min,o.y.size=o.y.max-o.y.min,o.z&&(o.z.size=o.z.max-o.z.min)},pairiteration:function(o,e,r){const n=o.bbox(),i=e.bbox(),a=1e5,s=r||.5;if(n.x.size+n.y.size<s&&i.x.size+i.y.size<s)return[(a*(o._t1+o._t2)/2|0)/a+"/"+(a*(e._t1+e._t2)/2|0)/a];let u=o.split(.5),c=e.split(.5),l=[{left:u.left,right:c.left},{left:u.left,right:c.right},{left:u.right,right:c.right},{left:u.right,right:c.left}];l=l.filter(function(y){return S.bboxoverlap(y.left.bbox(),y.right.bbox())});let g=[];return l.length===0||(l.forEach(function(y){g=g.concat(S.pairiteration(y.left,y.right,s))}),g=g.filter(function(y,m){return g.indexOf(y)===m})),g},getccenter:function(o,e,r){const n=e.x-o.x,i=e.y-o.y,a=r.x-e.x,s=r.y-e.y,u=n*Me(Le)-i*Fe(Le),c=n*Fe(Le)+i*Me(Le),l=a*Me(Le)-s*Fe(Le),g=a*Fe(Le)+s*Me(Le),y=(o.x+e.x)/2,m=(o.y+e.y)/2,v=(e.x+r.x)/2,L=(e.y+r.y)/2,D=y+u,C=m+c,I=v+l,h=L+g,f=S.lli8(y,m,D,C,v,L,I,h),d=S.dist(f,o);let p=Re(o.y-f.y,o.x-f.x),w=Re(e.y-f.y,e.x-f.x),M=Re(r.y-f.y,r.x-f.x),_;return p<M?((p>w||w>M)&&(p+=We),p>M&&(_=M,M=p,p=_)):M<w&&w<p?(_=M,M=p,p=_):M+=We,f.s=p,f.e=M,f.r=d,f},numberSort:function(o,e){return o-e}};class Te{constructor(e){this.curves=[],this._3d=!1,e&&(this.curves=e,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map(function(e){return S.pointsToString(e.points)}).join(", ")+"]"}addCurve(e){this.curves.push(e),this._3d=this._3d||e._3d}length(){return this.curves.map(function(e){return e.length()}).reduce(function(e,r){return e+r})}curve(e){return this.curves[e]}bbox(){const e=this.curves;for(var r=e[0].bbox(),n=1;n<e.length;n++)S.expandbox(r,e[n].bbox());return r}offset(e){const r=[];return this.curves.forEach(function(n){r.push(...n.offset(e))}),new Te(r)}}const{abs:qe,min:Pt,max:zt,cos:or,sin:nr,acos:sr,sqrt:Ue}=Math,ir=Math.PI;class H{constructor(e){let r=e&&e.forEach?e:Array.from(arguments).slice(),n=!1;if(typeof r[0]=="object"){n=r.length;const v=[];r.forEach(function(L){["x","y","z"].forEach(function(D){typeof L[D]<"u"&&v.push(L[D])})}),r=v}let i=!1;const a=r.length;if(n){if(n>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");i=!0}}else if(a!==6&&a!==8&&a!==9&&a!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const s=this._3d=!i&&(a===9||a===12)||e&&e[0]&&typeof e[0].z<"u",u=this.points=[];for(let v=0,L=s?3:2;v<a;v+=L){var c={x:r[v],y:r[v+1]};s&&(c.z=r[v+2]),u.push(c)}const l=this.order=u.length-1,g=this.dims=["x","y"];s&&g.push("z"),this.dimlen=g.length;const y=S.align(u,{p1:u[0],p2:u[l]}),m=S.dist(u[0],u[l]);this._linear=y.reduce((v,L)=>v+qe(L.y),0)<m/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,r,n,i){if(typeof i>"u"&&(i=.5),i===0)return new H(r,r,n);if(i===1)return new H(e,r,r);const a=H.getABC(2,e,r,n,i);return new H(e,a.A,n)}static cubicFromPoints(e,r,n,i,a){typeof i>"u"&&(i=.5);const s=H.getABC(3,e,r,n,i);typeof a>"u"&&(a=S.dist(r,s.C));const u=a*(1-i)/i,c=S.dist(e,n),l=(n.x-e.x)/c,g=(n.y-e.y)/c,y=a*l,m=a*g,v=u*l,L=u*g,D={x:r.x-y,y:r.y-m},C={x:r.x+v,y:r.y+L},I=s.A,h={x:I.x+(D.x-I.x)/(1-i),y:I.y+(D.y-I.y)/(1-i)},f={x:I.x+(C.x-I.x)/i,y:I.y+(C.y-I.y)/i},d={x:e.x+(h.x-e.x)/i,y:e.y+(h.y-e.y)/i},p={x:n.x+(f.x-n.x)/(1-i),y:n.y+(f.y-n.y)/(1-i)};return new H(e,d,p,n)}static getUtils(){return S}getUtils(){return H.getUtils()}static get PolyBezier(){return Te}valueOf(){return this.toString()}toString(){return S.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,r=e[0].x,n=e[0].y,i=["M",r,n,this.order===2?"Q":"C"];for(let a=1,s=e.length;a<s;a++)i.push(e[a].x),i.push(e[a].y);return i.join(" ")}setRatios(e){if(e.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=e,this._lut=[]}verify(){const e=this.coordDigest();e!==this._print&&(this._print=e,this.update())}coordDigest(){return this.points.map(function(e,r){return""+r+e.x+e.y+(e.z?e.z:0)}).join("")}update(){this._lut=[],this.dpoints=S.derive(this.points,this._3d),this.computedirection()}computedirection(){const e=this.points,r=S.angle(e[0],e[this.order],e[1]);this.clockwise=r>0}length(){return S.length(this.derivative.bind(this))}static getABC(e=2,r,n,i,a=.5){const s=S.projectionratio(a,e),u=1-s,c={x:s*r.x+u*i.x,y:s*r.y+u*i.y},l=S.abcratio(a,e);return{A:{x:n.x+(n.x-c.x)/l,y:n.y+(n.y-c.y)/l},B:n,C:c,S:r,E:i}}getABC(e,r){r=r||this.get(e);let n=this.points[0],i=this.points[this.order];return H.getABC(this.order,n,r,i,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e+1)return this._lut;this._lut=[],e++,this._lut=[];for(let r=0,n,i;r<e;r++)i=r/(e-1),n=this.compute(i),n.t=i,this._lut.push(n);return this._lut}on(e,r){r=r||5;const n=this.getLUT(),i=[];for(let a=0,s,u=0;a<n.length;a++)s=n[a],S.dist(s,e)<r&&(i.push(s),u+=a/n.length);return i.length?t/=i.length:!1}project(e){const r=this.getLUT(),n=r.length-1,i=S.closest(r,e),a=i.mpos,s=(a-1)/n,u=(a+1)/n,c=.1/n;let l=i.mdist,g=s,y=g,m;l+=1;for(let v;g<u+c;g+=c)m=this.compute(g),v=S.dist(e,m),v<l&&(l=v,y=g);return y=y<0?0:y>1?1:y,m=this.compute(y),m.t=y,m.d=l,m}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?S.computeWithRatios(e,this.points,this.ratios,this._3d):S.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,r=[e[0]],n=e.length;for(let i=1,a,s;i<n;i++)a=e[i],s=e[i-1],r[i]={x:(n-i)/n*a.x+i/n*s.x,y:(n-i)/n*a.y+i/n*s.y};return r[n]=e[n-1],new H(r)}derivative(e){return S.compute(e,this.dpoints[0],this._3d)}dderivative(e){return S.compute(e,this.dpoints[1],this._3d)}align(){let e=this.points;return new H(S.align(e,{p1:e[0],p2:e[e.length-1]}))}curvature(e){return S.curvature(e,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return S.inflections(this.points)}normal(e){return this._3d?this.__normal3(e):this.__normal2(e)}__normal2(e){const r=this.derivative(e),n=Ue(r.x*r.x+r.y*r.y);return{t:e,x:-r.y/n,y:r.x/n}}__normal3(e){const r=this.derivative(e),n=this.derivative(e+.01),i=Ue(r.x*r.x+r.y*r.y+r.z*r.z),a=Ue(n.x*n.x+n.y*n.y+n.z*n.z);r.x/=i,r.y/=i,r.z/=i,n.x/=a,n.y/=a,n.z/=a;const s={x:n.y*r.z-n.z*r.y,y:n.z*r.x-n.x*r.z,z:n.x*r.y-n.y*r.x},u=Ue(s.x*s.x+s.y*s.y+s.z*s.z);s.x/=u,s.y/=u,s.z/=u;const c=[s.x*s.x,s.x*s.y-s.z,s.x*s.z+s.y,s.x*s.y+s.z,s.y*s.y,s.y*s.z-s.x,s.x*s.z-s.y,s.y*s.z+s.x,s.z*s.z];return{t:e,x:c[0]*r.x+c[1]*r.y+c[2]*r.z,y:c[3]*r.x+c[4]*r.y+c[5]*r.z,z:c[6]*r.x+c[7]*r.y+c[8]*r.z}}hull(e){let r=this.points,n=[],i=[],a=0;for(i[a++]=r[0],i[a++]=r[1],i[a++]=r[2],this.order===3&&(i[a++]=r[3]);r.length>1;){n=[];for(let s=0,u,c=r.length-1;s<c;s++)u=S.lerp(e,r[s],r[s+1]),i[a++]=u,n.push(u);r=n}return i}split(e,r){if(e===0&&r)return this.split(r).left;if(r===1)return this.split(e).right;const n=this.hull(e),i={left:this.order===2?new H([n[0],n[3],n[5]]):new H([n[0],n[4],n[7],n[9]]),right:this.order===2?new H([n[5],n[4],n[2]]):new H([n[9],n[8],n[6],n[3]]),span:n};return i.left._t1=S.map(0,0,1,this._t1,this._t2),i.left._t2=S.map(e,0,1,this._t1,this._t2),i.right._t1=S.map(e,0,1,this._t1,this._t2),i.right._t2=S.map(1,0,1,this._t1,this._t2),r?(r=S.map(r,e,1,0,1),i.right.split(r).left):i}extrema(){const e={};let r=[];return this.dims.forEach((function(n){let i=function(s){return s[n]},a=this.dpoints[0].map(i);e[n]=S.droots(a),this.order===3&&(a=this.dpoints[1].map(i),e[n]=e[n].concat(S.droots(a))),e[n]=e[n].filter(function(s){return s>=0&&s<=1}),r=r.concat(e[n].sort(S.numberSort))}).bind(this)),e.values=r.sort(S.numberSort).filter(function(n,i){return r.indexOf(n)===i}),e}bbox(){const e=this.extrema(),r={};return this.dims.forEach((function(n){r[n]=S.getminmax(this,n,e[n])}).bind(this)),r}overlaps(e){const r=this.bbox(),n=e.bbox();return S.bboxoverlap(r,n)}offset(e,r){if(typeof r<"u"){const n=this.get(e),i=this.normal(e),a={c:n,n:i,x:n.x+i.x*r,y:n.y+i.y*r};return this._3d&&(a.z=n.z+i.z*r),a}if(this._linear){const n=this.normal(0),i=this.points.map(function(a){const s={x:a.x+e*n.x,y:a.y+e*n.y};return a.z&&n.z&&(s.z=a.z+e*n.z),s});return[new H(i)]}return this.reduce().map(function(n){return n._linear?n.offset(e)[0]:n.scale(e)})}simple(){if(this.order===3){const i=S.angle(this.points[0],this.points[3],this.points[1]),a=S.angle(this.points[0],this.points[3],this.points[2]);if(i>0&&a<0||i<0&&a>0)return!1}const e=this.normal(0),r=this.normal(1);let n=e.x*r.x+e.y*r.y;return this._3d&&(n+=e.z*r.z),qe(sr(n))<ir/3}reduce(){let e,r=0,n=0,i=.01,a,s=[],u=[],c=this.extrema().values;for(c.indexOf(0)===-1&&(c=[0].concat(c)),c.indexOf(1)===-1&&c.push(1),r=c[0],e=1;e<c.length;e++)n=c[e],a=this.split(r,n),a._t1=r,a._t2=n,s.push(a),r=n;return s.forEach(function(l){for(r=0,n=0;n<=1;)for(n=r+i;n<=1+i;n+=i)if(a=l.split(r,n),!a.simple()){if(n-=i,qe(r-n)<i)return[];a=l.split(r,n),a._t1=S.map(r,0,1,l._t1,l._t2),a._t2=S.map(n,0,1,l._t1,l._t2),u.push(a),r=n;break}r<1&&(a=l.split(r,1),a._t1=S.map(r,0,1,l._t1,l._t2),a._t2=l._t2,u.push(a))}),u}translate(e,r,n){n=typeof n=="number"?n:r;const i=this.order;let a=this.points.map((s,u)=>(1-u/i)*r+u/i*n);return new H(this.points.map((s,u)=>({x:s.x+e.x*a[u],y:s.y+e.y*a[u]})))}scale(e){const r=this.order;let n=!1;if(typeof e=="function"&&(n=e),n&&r===2)return this.raise().scale(n);const i=this.clockwise,a=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):e,n?n(1):e);const s=n?n(0):e,u=n?n(1):e,c=[this.offset(0,10),this.offset(1,10)],l=[],g=S.lli4(c[0],c[0].c,c[1],c[1].c);if(!g)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(y){const m=l[y*r]=S.copy(a[y*r]);m.x+=(y?u:s)*c[y].n.x,m.y+=(y?u:s)*c[y].n.y}),n?([0,1].forEach(function(y){if(!(r===2&&y)){var m=a[y+1],v={x:m.x-g.x,y:m.y-g.y},L=n?n((y+1)/r):e;n&&!i&&(L=-L);var D=Ue(v.x*v.x+v.y*v.y);v.x/=D,v.y/=D,l[y+1]={x:m.x+L*v.x,y:m.y+L*v.y}}}),new H(l)):([0,1].forEach(y=>{if(r===2&&y)return;const m=l[y*r],v=this.derivative(y),L={x:m.x+v.x,y:m.y+v.y};l[y+1]=S.lli4(m,L,g,a[y+1])}),new H(l))}outline(e,r,n,i){if(r=r===void 0?e:r,this._linear){const p=this.normal(0),w=this.points[0],M=this.points[this.points.length-1];let _,P,k;n===void 0&&(n=e,i=r),_={x:w.x+p.x*e,y:w.y+p.y*e},k={x:M.x+p.x*n,y:M.y+p.y*n},P={x:(_.x+k.x)/2,y:(_.y+k.y)/2};const F=[_,P,k];_={x:w.x-p.x*r,y:w.y-p.y*r},k={x:M.x-p.x*i,y:M.y-p.y*i},P={x:(_.x+k.x)/2,y:(_.y+k.y)/2};const A=[k,P,_],Y=S.makeline(A[2],F[0]),q=S.makeline(F[2],A[0]),se=[Y,new H(F),q,new H(A)];return new Te(se)}const a=this.reduce(),s=a.length,u=[];let c=[],l,g=0,y=this.length();const m=typeof n<"u"&&typeof i<"u";function v(p,w,M,_,P){return function(k){const F=_/M,A=(_+P)/M,Y=w-p;return S.map(k,0,1,p+F*Y,p+A*Y)}}a.forEach(function(p){const w=p.length();m?(u.push(p.scale(v(e,n,y,g,w))),c.push(p.scale(v(-r,-i,y,g,w)))):(u.push(p.scale(e)),c.push(p.scale(-r))),g+=w}),c=c.map(function(p){return l=p.points,l[3]?p.points=[l[3],l[2],l[1],l[0]]:p.points=[l[2],l[1],l[0]],p}).reverse();const L=u[0].points[0],D=u[s-1].points[u[s-1].points.length-1],C=c[s-1].points[c[s-1].points.length-1],I=c[0].points[0],h=S.makeline(C,L),f=S.makeline(D,I),d=[h].concat(u).concat([f]).concat(c);return new Te(d)}outlineshapes(e,r,n){r=r||e;const i=this.outline(e,r).curves,a=[];for(let s=1,u=i.length;s<u/2;s++){const c=S.makeshape(i[s],i[u-s],n);c.startcap.virtual=s>1,c.endcap.virtual=s<u/2-1,a.push(c)}return a}intersects(e,r){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof H&&(e=e.reduce()),this.curveintersects(this.reduce(),e,r)):this.selfintersects(r)}lineIntersects(e){const r=Pt(e.p1.x,e.p2.x),n=Pt(e.p1.y,e.p2.y),i=zt(e.p1.x,e.p2.x),a=zt(e.p1.y,e.p2.y);return S.roots(this.points,e).filter(s=>{var u=this.get(s);return S.between(u.x,r,i)&&S.between(u.y,n,a)})}selfintersects(e){const r=this.reduce(),n=r.length-2,i=[];for(let a=0,s,u,c;a<n;a++)u=r.slice(a,a+1),c=r.slice(a+2),s=this.curveintersects(u,c,e),i.push(...s);return i}curveintersects(e,r,n){const i=[];e.forEach(function(s){r.forEach(function(u){s.overlaps(u)&&i.push({left:s,right:u})})});let a=[];return i.forEach(function(s){const u=S.pairiteration(s.left,s.right,n);u.length>0&&(a=a.concat(u))}),a}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,r,n,i){const a=(i-n)/4,s=this.get(n+a),u=this.get(i-a),c=S.dist(e,r),l=S.dist(e,s),g=S.dist(e,u);return qe(l-c)+qe(g-c)}_iterate(e,r){let n=0,i=1,a;do{a=0,i=1;let s=this.get(n),u,c,l,g,y=!1,m=!1,v,L=i,D=1;do if(m=y,g=l,L=(n+i)/2,u=this.get(L),c=this.get(i),l=S.getccenter(s,u,c),l.interval={start:n,end:i},y=this._error(l,s,n,i)<=e,v=m&&!y,v||(D=i),y){if(i>=1){if(l.interval.end=D=1,g=l,i>1){let I={x:l.x+l.r*or(l.e),y:l.y+l.r*nr(l.e)};l.e+=S.angle({x:l.x,y:l.y},I,this.get(1))}break}i=i+(i-n)/2}else i=L;while(!v&&a++<100);if(a>=100)break;g=g||l,r.push(g),n=D}while(i<1);return r}}var fe=63710088e-1,Rt={centimeters:fe*100,centimetres:fe*100,degrees:fe/111325,feet:fe*3.28084,inches:fe*39.37,kilometers:fe/1e3,kilometres:fe/1e3,meters:fe,metres:fe,miles:fe/1609.344,millimeters:fe*1e3,millimetres:fe*1e3,nauticalmiles:fe/1852,radians:1,yards:fe*1.0936};function Mt(o,e,r){r===void 0&&(r={});var n={type:"Feature"};return(r.id===0||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=o,n}function xe(o,e,r){if(r===void 0&&(r={}),!o)throw new Error("coordinates is required");if(!Array.isArray(o))throw new Error("coordinates must be an Array");if(o.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Dt(o[0])||!Dt(o[1]))throw new Error("coordinates must contain numbers");var n={type:"Point",coordinates:o};return Mt(n,e,r)}function Ge(o,e,r){r===void 0&&(r={});for(var n=0,i=o;n<i.length;n++){var a=i[n];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}var u={type:"Polygon",coordinates:o};return Mt(u,e,r)}function Je(o,e,r){if(r===void 0&&(r={}),o.length<2)throw new Error("coordinates must be an array of two or more positions");var n={type:"LineString",coordinates:o};return Mt(n,e,r)}function Ke(o,e){if(e===void 0&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,e||0);return Math.round(o*r)/r}function ar(o,e){e===void 0&&(e="kilometers");var r=Rt[e];if(!r)throw new Error(e+" units is invalid");return o*r}function ur(o,e){e===void 0&&(e="kilometers");var r=Rt[e];if(!r)throw new Error(e+" units is invalid");return o/r}function pt(o){var e=o%(2*Math.PI);return e*180/Math.PI}function pe(o){var e=o%360;return e*Math.PI/180}function Dt(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function Ze(o,e,r){if(o!==null)for(var n,i,a,s,u,c,l,g=0,y=0,m,v=o.type,L=v==="FeatureCollection",D=v==="Feature",C=L?o.features.length:1,I=0;I<C;I++){l=L?o.features[I].geometry:D?o.geometry:o,m=l?l.type==="GeometryCollection":!1,u=m?l.geometries.length:1;for(var h=0;h<u;h++){var f=0,d=0;if(s=m?l.geometries[h]:l,s!==null){c=s.coordinates;var p=s.type;switch(g=r&&(p==="Polygon"||p==="MultiPolygon")?1:0,p){case null:break;case"Point":if(e(c,y,I,f,d)===!1)return!1;y++,f++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(e(c[n],y,I,f,d)===!1)return!1;y++,p==="MultiPoint"&&f++}p==="LineString"&&f++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-g;i++){if(e(c[n][i],y,I,f,d)===!1)return!1;y++}p==="MultiLineString"&&f++,p==="Polygon"&&d++}p==="Polygon"&&f++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(d=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-g;a++){if(e(c[n][i][a],y,I,f,d)===!1)return!1;y++}d++}f++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(Ze(s.geometries[n],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function cr(o,e){var r,n,i,a,s,u,c,l,g,y,m=0,v=o.type==="FeatureCollection",L=o.type==="Feature",D=v?o.features.length:1;for(r=0;r<D;r++){for(u=v?o.features[r].geometry:L?o.geometry:o,l=v?o.features[r].properties:L?o.properties:{},g=v?o.features[r].bbox:L?o.bbox:void 0,y=v?o.features[r].id:L?o.id:void 0,c=u?u.type==="GeometryCollection":!1,s=c?u.geometries.length:1,i=0;i<s;i++){if(a=c?u.geometries[i]:u,a===null){if(e(null,m,l,g,y)===!1)return!1;continue}switch(a.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(a,m,l,g,y)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<a.geometries.length;n++)if(e(a.geometries[n],m,l,g,y)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}m++}}function lr(o,e,r){var n=r;return cr(o,function(i,a,s,u,c){a===0&&r===void 0?n=i:n=e(n,i,a,s,u,c)}),n}function ot(o){var e=[1/0,1/0,-1/0,-1/0];return Ze(o,function(r){e[0]>r[0]&&(e[0]=r[0]),e[1]>r[1]&&(e[1]=r[1]),e[2]<r[0]&&(e[2]=r[0]),e[3]<r[1]&&(e[3]=r[1])}),e}ot.default=ot;function Xe(o){if(!o)throw new Error("coord is required");if(!Array.isArray(o)){if(o.type==="Feature"&&o.geometry!==null&&o.geometry.type==="Point")return o.geometry.coordinates;if(o.type==="Point")return o.coordinates}if(Array.isArray(o)&&o.length>=2&&!Array.isArray(o[0])&&!Array.isArray(o[1]))return o;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function hr(o){return o.type==="Feature"?o.geometry:o}function fr(o,e){return o.type==="FeatureCollection"?"FeatureCollection":o.type==="GeometryCollection"?"GeometryCollection":o.type==="Feature"&&o.geometry!==null?o.geometry.type:o.type}var Bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dr(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function yr(o){if(o.__esModule)return o;var e=o.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(o).forEach(function(n){var i=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return o[n]}})}),r}var _t={exports:{}},qt={exports:{}};(function(o,e){(function(r,n){o.exports=n()})(Bt,function(){function r(h,f,d,p,w){(function M(_,P,k,F,A){for(;F>k;){if(F-k>600){var Y=F-k+1,q=P-k+1,se=Math.log(Y),Q=.5*Math.exp(2*se/3),K=.5*Math.sqrt(se*Q*(Y-Q)/Y)*(q-Y/2<0?-1:1),j=Math.max(k,Math.floor(P-q*Q/Y+K)),ie=Math.min(F,Math.floor(P+(Y-q)*Q/Y+K));M(_,P,j,ie,A)}var E=_[P],x=k,z=F;for(n(_,k,P),A(_[F],E)>0&&n(_,k,F);x<z;){for(n(_,x,z),x++,z--;A(_[x],E)<0;)x++;for(;A(_[z],E)>0;)z--}A(_[k],E)===0?n(_,k,z):n(_,++z,F),z<=P&&(k=z+1),P<=z&&(F=z-1)}})(h,f,d||0,p||h.length-1,w||i)}function n(h,f,d){var p=h[f];h[f]=h[d],h[d]=p}function i(h,f){return h<f?-1:h>f?1:0}var a=function(h){h===void 0&&(h=9),this._maxEntries=Math.max(4,h),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(h,f,d){if(!d)return f.indexOf(h);for(var p=0;p<f.length;p++)if(d(h,f[p]))return p;return-1}function u(h,f){c(h,0,h.children.length,f,h)}function c(h,f,d,p,w){w||(w=C(null)),w.minX=1/0,w.minY=1/0,w.maxX=-1/0,w.maxY=-1/0;for(var M=f;M<d;M++){var _=h.children[M];l(w,h.leaf?p(_):_)}return w}function l(h,f){return h.minX=Math.min(h.minX,f.minX),h.minY=Math.min(h.minY,f.minY),h.maxX=Math.max(h.maxX,f.maxX),h.maxY=Math.max(h.maxY,f.maxY),h}function g(h,f){return h.minX-f.minX}function y(h,f){return h.minY-f.minY}function m(h){return(h.maxX-h.minX)*(h.maxY-h.minY)}function v(h){return h.maxX-h.minX+(h.maxY-h.minY)}function L(h,f){return h.minX<=f.minX&&h.minY<=f.minY&&f.maxX<=h.maxX&&f.maxY<=h.maxY}function D(h,f){return f.minX<=h.maxX&&f.minY<=h.maxY&&f.maxX>=h.minX&&f.maxY>=h.minY}function C(h){return{children:h,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function I(h,f,d,p,w){for(var M=[f,d];M.length;)if(!((d=M.pop())-(f=M.pop())<=p)){var _=f+Math.ceil((d-f)/p/2)*p;r(h,_,f,d,w),M.push(f,_,_,d)}}return a.prototype.all=function(){return this._all(this.data,[])},a.prototype.search=function(h){var f=this.data,d=[];if(!D(h,f))return d;for(var p=this.toBBox,w=[];f;){for(var M=0;M<f.children.length;M++){var _=f.children[M],P=f.leaf?p(_):_;D(h,P)&&(f.leaf?d.push(_):L(h,P)?this._all(_,d):w.push(_))}f=w.pop()}return d},a.prototype.collides=function(h){var f=this.data;if(!D(h,f))return!1;for(var d=[];f;){for(var p=0;p<f.children.length;p++){var w=f.children[p],M=f.leaf?this.toBBox(w):w;if(D(h,M)){if(f.leaf||L(h,M))return!0;d.push(w)}}f=d.pop()}return!1},a.prototype.load=function(h){if(!h||!h.length)return this;if(h.length<this._minEntries){for(var f=0;f<h.length;f++)this.insert(h[f]);return this}var d=this._build(h.slice(),0,h.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var p=this.data;this.data=d,d=p}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},a.prototype.insert=function(h){return h&&this._insert(h,this.data.height-1),this},a.prototype.clear=function(){return this.data=C([]),this},a.prototype.remove=function(h,f){if(!h)return this;for(var d,p,w,M=this.data,_=this.toBBox(h),P=[],k=[];M||P.length;){if(M||(M=P.pop(),p=P[P.length-1],d=k.pop(),w=!0),M.leaf){var F=s(h,M.children,f);if(F!==-1)return M.children.splice(F,1),P.push(M),this._condense(P),this}w||M.leaf||!L(M,_)?p?(d++,M=p.children[d],w=!1):M=null:(P.push(M),k.push(d),d=0,p=M,M=M.children[0])}return this},a.prototype.toBBox=function(h){return h},a.prototype.compareMinX=function(h,f){return h.minX-f.minX},a.prototype.compareMinY=function(h,f){return h.minY-f.minY},a.prototype.toJSON=function(){return this.data},a.prototype.fromJSON=function(h){return this.data=h,this},a.prototype._all=function(h,f){for(var d=[];h;)h.leaf?f.push.apply(f,h.children):d.push.apply(d,h.children),h=d.pop();return f},a.prototype._build=function(h,f,d,p){var w,M=d-f+1,_=this._maxEntries;if(M<=_)return u(w=C(h.slice(f,d+1)),this.toBBox),w;p||(p=Math.ceil(Math.log(M)/Math.log(_)),_=Math.ceil(M/Math.pow(_,p-1))),(w=C([])).leaf=!1,w.height=p;var P=Math.ceil(M/_),k=P*Math.ceil(Math.sqrt(_));I(h,f,d,k,this.compareMinX);for(var F=f;F<=d;F+=k){var A=Math.min(F+k-1,d);I(h,F,A,P,this.compareMinY);for(var Y=F;Y<=A;Y+=P){var q=Math.min(Y+P-1,A);w.children.push(this._build(h,Y,q,p-1))}}return u(w,this.toBBox),w},a.prototype._chooseSubtree=function(h,f,d,p){for(;p.push(f),!f.leaf&&p.length-1!==d;){for(var w=1/0,M=1/0,_=void 0,P=0;P<f.children.length;P++){var k=f.children[P],F=m(k),A=(Y=h,q=k,(Math.max(q.maxX,Y.maxX)-Math.min(q.minX,Y.minX))*(Math.max(q.maxY,Y.maxY)-Math.min(q.minY,Y.minY))-F);A<M?(M=A,w=F<w?F:w,_=k):A===M&&F<w&&(w=F,_=k)}f=_||f.children[0]}var Y,q;return f},a.prototype._insert=function(h,f,d){var p=d?h:this.toBBox(h),w=[],M=this._chooseSubtree(p,this.data,f,w);for(M.children.push(h),l(M,p);f>=0&&w[f].children.length>this._maxEntries;)this._split(w,f),f--;this._adjustParentBBoxes(p,w,f)},a.prototype._split=function(h,f){var d=h[f],p=d.children.length,w=this._minEntries;this._chooseSplitAxis(d,w,p);var M=this._chooseSplitIndex(d,w,p),_=C(d.children.splice(M,d.children.length-M));_.height=d.height,_.leaf=d.leaf,u(d,this.toBBox),u(_,this.toBBox),f?h[f-1].children.push(_):this._splitRoot(d,_)},a.prototype._splitRoot=function(h,f){this.data=C([h,f]),this.data.height=h.height+1,this.data.leaf=!1,u(this.data,this.toBBox)},a.prototype._chooseSplitIndex=function(h,f,d){for(var p,w,M,_,P,k,F,A=1/0,Y=1/0,q=f;q<=d-f;q++){var se=c(h,0,q,this.toBBox),Q=c(h,q,d,this.toBBox),K=(w=se,M=Q,_=void 0,P=void 0,k=void 0,F=void 0,_=Math.max(w.minX,M.minX),P=Math.max(w.minY,M.minY),k=Math.min(w.maxX,M.maxX),F=Math.min(w.maxY,M.maxY),Math.max(0,k-_)*Math.max(0,F-P)),j=m(se)+m(Q);K<A?(A=K,p=q,Y=j<Y?j:Y):K===A&&j<Y&&(Y=j,p=q)}return p||d-f},a.prototype._chooseSplitAxis=function(h,f,d){var p=h.leaf?this.compareMinX:g,w=h.leaf?this.compareMinY:y;this._allDistMargin(h,f,d,p)<this._allDistMargin(h,f,d,w)&&h.children.sort(p)},a.prototype._allDistMargin=function(h,f,d,p){h.children.sort(p);for(var w=this.toBBox,M=c(h,0,f,w),_=c(h,d-f,d,w),P=v(M)+v(_),k=f;k<d-f;k++){var F=h.children[k];l(M,h.leaf?w(F):F),P+=v(M)}for(var A=d-f-1;A>=f;A--){var Y=h.children[A];l(_,h.leaf?w(Y):Y),P+=v(_)}return P},a.prototype._adjustParentBBoxes=function(h,f,d){for(var p=d;p>=0;p--)l(f[p],h)},a.prototype._condense=function(h){for(var f=h.length-1,d=void 0;f>=0;f--)h[f].children.length===0?f>0?(d=h[f-1].children).splice(d.indexOf(h[f]),1):this.clear():u(h[f],this.toBBox)},a})})(qt);var gr=qt.exports;class pr{constructor(e=[],r=mr){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:n}=this,i=r[e];for(;e>0;){const a=e-1>>1,s=r[a];if(n(i,s)>=0)break;r[e]=s,e=a}r[e]=i}_down(e){const{data:r,compare:n}=this,i=this.length>>1,a=r[e];for(;e<i;){let s=(e<<1)+1,u=r[s];const c=s+1;if(c<this.length&&n(r[c],u)<0&&(s=c,u=r[c]),n(u,a)>=0)break;r[e]=u,e=s}r[e]=a}}function mr(o,e){return o<e?-1:o>e?1:0}const vr=Object.freeze(Object.defineProperty({__proto__:null,default:pr},Symbol.toStringTag,{value:"Module"})),xr=yr(vr);var nt={exports:{}},Mr=function(e,r,n,i){var a=e[0],s=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=(i-n)/2,l=0,g=c-1;l<c;g=l++){var y=r[n+l*2+0],m=r[n+l*2+1],v=r[n+g*2+0],L=r[n+g*2+1],D=m>s!=L>s&&a<(v-y)*(s-m)/(L-m)+y;D&&(u=!u)}return u},_r=function(e,r,n,i){var a=e[0],s=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=i-n,l=0,g=c-1;l<c;g=l++){var y=r[l+n][0],m=r[l+n][1],v=r[g+n][0],L=r[g+n][1],D=m>s!=L>s&&a<(v-y)*(s-m)/(L-m)+y;D&&(u=!u)}return u},Ut=Mr,$t=_r;nt.exports=function(e,r,n,i){return r.length>0&&Array.isArray(r[0])?$t(e,r,n,i):Ut(e,r,n,i)};nt.exports.nested=$t;nt.exports.flat=Ut;var wr=nt.exports,mt={exports:{}};(function(o,e){(function(r,n){n(e)})(Bt,function(r){const i=33306690738754706e-32;function a(D,C,I,h,f){let d,p,w,M,_=C[0],P=h[0],k=0,F=0;P>_==P>-_?(d=_,_=C[++k]):(d=P,P=h[++F]);let A=0;if(k<D&&F<I)for(P>_==P>-_?(w=d-((p=_+d)-_),_=C[++k]):(w=d-((p=P+d)-P),P=h[++F]),d=p,w!==0&&(f[A++]=w);k<D&&F<I;)P>_==P>-_?(w=d-((p=d+_)-(M=p-d))+(_-M),_=C[++k]):(w=d-((p=d+P)-(M=p-d))+(P-M),P=h[++F]),d=p,w!==0&&(f[A++]=w);for(;k<D;)w=d-((p=d+_)-(M=p-d))+(_-M),_=C[++k],d=p,w!==0&&(f[A++]=w);for(;F<I;)w=d-((p=d+P)-(M=p-d))+(P-M),P=h[++F],d=p,w!==0&&(f[A++]=w);return d===0&&A!==0||(f[A++]=d),A}function s(D){return new Float64Array(D)}const u=33306690738754716e-32,c=22204460492503146e-32,l=11093356479670487e-47,g=s(4),y=s(8),m=s(12),v=s(16),L=s(4);r.orient2d=function(D,C,I,h,f,d){const p=(C-d)*(I-f),w=(D-f)*(h-d),M=p-w;if(p===0||w===0||p>0!=w>0)return M;const _=Math.abs(p+w);return Math.abs(M)>=u*_?M:-function(P,k,F,A,Y,q,se){let Q,K,j,ie,E,x,z,X,R,V,O,G,N,Z,re,ee,oe,W;const ae=P-Y,ne=F-Y,te=k-q,he=A-q;E=(re=(X=ae-(z=(x=134217729*ae)-(x-ae)))*(V=he-(R=(x=134217729*he)-(x-he)))-((Z=ae*he)-z*R-X*R-z*V))-(O=re-(oe=(X=te-(z=(x=134217729*te)-(x-te)))*(V=ne-(R=(x=134217729*ne)-(x-ne)))-((ee=te*ne)-z*R-X*R-z*V))),g[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),g[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,g[2]=G-(W-E)+(O-E),g[3]=W;let me=function(Ye,ke){let He=ke[0];for(let Ee=1;Ee<Ye;Ee++)He+=ke[Ee];return He}(4,g),be=c*se;if(me>=be||-me>=be||(Q=P-(ae+(E=P-ae))+(E-Y),j=F-(ne+(E=F-ne))+(E-Y),K=k-(te+(E=k-te))+(E-q),ie=A-(he+(E=A-he))+(E-q),Q===0&&K===0&&j===0&&ie===0)||(be=l*se+i*Math.abs(me),(me+=ae*ie+he*Q-(te*j+ne*K))>=be||-me>=be))return me;E=(re=(X=Q-(z=(x=134217729*Q)-(x-Q)))*(V=he-(R=(x=134217729*he)-(x-he)))-((Z=Q*he)-z*R-X*R-z*V))-(O=re-(oe=(X=K-(z=(x=134217729*K)-(x-K)))*(V=ne-(R=(x=134217729*ne)-(x-ne)))-((ee=K*ne)-z*R-X*R-z*V))),L[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),L[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,L[2]=G-(W-E)+(O-E),L[3]=W;const Ve=a(4,g,4,L,y);E=(re=(X=ae-(z=(x=134217729*ae)-(x-ae)))*(V=ie-(R=(x=134217729*ie)-(x-ie)))-((Z=ae*ie)-z*R-X*R-z*V))-(O=re-(oe=(X=te-(z=(x=134217729*te)-(x-te)))*(V=j-(R=(x=134217729*j)-(x-j)))-((ee=te*j)-z*R-X*R-z*V))),L[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),L[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,L[2]=G-(W-E)+(O-E),L[3]=W;const st=a(Ve,y,4,L,m);E=(re=(X=Q-(z=(x=134217729*Q)-(x-Q)))*(V=ie-(R=(x=134217729*ie)-(x-ie)))-((Z=Q*ie)-z*R-X*R-z*V))-(O=re-(oe=(X=K-(z=(x=134217729*K)-(x-K)))*(V=j-(R=(x=134217729*j)-(x-j)))-((ee=K*j)-z*R-X*R-z*V))),L[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),L[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,L[2]=G-(W-E)+(O-E),L[3]=W;const De=a(st,m,4,L,v);return v[De-1]}(D,C,I,h,f,d,_)},r.orient2dfast=function(D,C,I,h,f,d){return(C-d)*(I-f)-(D-f)*(h-d)},Object.defineProperty(r,"__esModule",{value:!0})})})(mt,mt.exports);var Lr=mt.exports,kt=gr,rt=xr,Sr=wr,br=Lr.orient2d;rt.default&&(rt=rt.default);_t.exports=Nt;_t.exports.default=Nt;function Nt(o,e,r){e=Math.max(0,e===void 0?2:e),r=r||0;var n=Er(o),i=new kt(16);i.toBBox=function(h){return{minX:h[0],minY:h[1],maxX:h[0],maxY:h[1]}},i.compareMinX=function(h,f){return h[0]-f[0]},i.compareMinY=function(h,f){return h[1]-f[1]},i.load(o);for(var a=[],s=0,u;s<n.length;s++){var c=n[s];i.remove(c),u=It(c,u),a.push(u)}var l=new kt(16);for(s=0;s<a.length;s++)l.insert(ut(a[s]));for(var g=e*e,y=r*r;a.length;){var m=a.shift(),v=m.p,L=m.next.p,D=ct(v,L);if(!(D<y)){var C=D/g;c=Pr(i,m.prev.p,v,L,m.next.next.p,C,l),c&&Math.min(ct(c,v),ct(c,L))<=C&&(a.push(m),a.push(It(c,m)),i.remove(c),l.remove(m),l.insert(ut(m)),l.insert(ut(m.next)))}}m=u;var I=[];do I.push(m.p),m=m.next;while(m!==u);return I.push(m.p),I}function Pr(o,e,r,n,i,a,s){for(var u=new rt([],zr),c=o.data;c;){for(var l=0;l<c.children.length;l++){var g=c.children[l],y=c.leaf?lt(g,r,n):Dr(r,n,g);y>a||u.push({node:g,dist:y})}for(;u.length&&!u.peek().node.children;){var m=u.pop(),v=m.node,L=lt(v,e,r),D=lt(v,n,i);if(m.dist<L&&m.dist<D&&Ft(r,v,s)&&Ft(n,v,s))return v}c=u.pop(),c&&(c=c.node)}return null}function zr(o,e){return o.dist-e.dist}function Dr(o,e,r){if(Et(o,r)||Et(e,r))return 0;var n=et(o[0],o[1],e[0],e[1],r.minX,r.minY,r.maxX,r.minY);if(n===0)return 0;var i=et(o[0],o[1],e[0],e[1],r.minX,r.minY,r.minX,r.maxY);if(i===0)return 0;var a=et(o[0],o[1],e[0],e[1],r.maxX,r.minY,r.maxX,r.maxY);if(a===0)return 0;var s=et(o[0],o[1],e[0],e[1],r.minX,r.maxY,r.maxX,r.maxY);return s===0?0:Math.min(n,i,a,s)}function Et(o,e){return o[0]>=e.minX&&o[0]<=e.maxX&&o[1]>=e.minY&&o[1]<=e.maxY}function Ft(o,e,r){for(var n=Math.min(o[0],e[0]),i=Math.min(o[1],e[1]),a=Math.max(o[0],e[0]),s=Math.max(o[1],e[1]),u=r.search({minX:n,minY:i,maxX:a,maxY:s}),c=0;c<u.length;c++)if(kr(u[c].p,u[c].next.p,o,e))return!1;return!0}function Ae(o,e,r){return br(o[0],o[1],e[0],e[1],r[0],r[1])}function kr(o,e,r,n){return o!==n&&e!==r&&Ae(o,e,r)>0!=Ae(o,e,n)>0&&Ae(r,n,o)>0!=Ae(r,n,e)>0}function ut(o){var e=o.p,r=o.next.p;return o.minX=Math.min(e[0],r[0]),o.minY=Math.min(e[1],r[1]),o.maxX=Math.max(e[0],r[0]),o.maxY=Math.max(e[1],r[1]),o}function Er(o){for(var e=o[0],r=o[0],n=o[0],i=o[0],a=0;a<o.length;a++){var s=o[a];s[0]<e[0]&&(e=s),s[0]>n[0]&&(n=s),s[1]<r[1]&&(r=s),s[1]>i[1]&&(i=s)}var u=[e,r,n,i],c=u.slice();for(a=0;a<o.length;a++)Sr(o[a],u)||c.push(o[a]);return Ir(c)}function It(o,e){var r={p:o,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(r.next=e.next,r.prev=e,e.next.prev=r,e.next=r):(r.prev=r,r.next=r),r}function ct(o,e){var r=o[0]-e[0],n=o[1]-e[1];return r*r+n*n}function lt(o,e,r){var n=e[0],i=e[1],a=r[0]-n,s=r[1]-i;if(a!==0||s!==0){var u=((o[0]-n)*a+(o[1]-i)*s)/(a*a+s*s);u>1?(n=r[0],i=r[1]):u>0&&(n+=a*u,i+=s*u)}return a=o[0]-n,s=o[1]-i,a*a+s*s}function et(o,e,r,n,i,a,s,u){var c=r-o,l=n-e,g=s-i,y=u-a,m=o-i,v=e-a,L=c*c+l*l,D=c*g+l*y,C=g*g+y*y,I=c*m+l*v,h=g*m+y*v,f=L*C-D*D,d,p,w,M,_=f,P=f;f===0?(p=0,_=1,M=h,P=C):(p=D*h-C*I,M=L*h-D*I,p<0?(p=0,M=h,P=C):p>_&&(p=_,M=h+D,P=C)),M<0?(M=0,-I<0?p=0:-I>L?p=_:(p=-I,_=L)):M>P&&(M=P,-I+D<0?p=0:-I+D>L?p=_:(p=-I+D,_=L)),d=p===0?0:p/_,w=M===0?0:M/P;var k=(1-d)*o+d*r,F=(1-d)*e+d*n,A=(1-w)*i+w*s,Y=(1-w)*a+w*u,q=A-k,se=Y-F;return q*q+se*se}function Fr(o,e){return o[0]===e[0]?o[1]-e[1]:o[0]-e[0]}function Ir(o){o.sort(Fr);for(var e=[],r=0;r<o.length;r++){for(;e.length>=2&&Ae(e[e.length-2],e[e.length-1],o[r])<=0;)e.pop();e.push(o[r])}for(var n=[],i=o.length-1;i>=0;i--){for(;n.length>=2&&Ae(n[n.length-2],n[n.length-1],o[i])<=0;)n.pop();n.push(o[i])}return n.pop(),e.pop(),e.concat(n)}var Ar=_t.exports;const Cr=dr(Ar);function Jr(o,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var r=[];if(Ze(o,function(i){r.push([i[0],i[1]])}),!r.length)return null;var n=Cr(r,e.concavity);return n.length>3?Ge([n]):null}function vt(o,e,r){r===void 0&&(r={});var n=Xe(o),i=Xe(e),a=pe(i[1]-n[1]),s=pe(i[0]-n[0]),u=pe(n[1]),c=pe(i[1]),l=Math.pow(Math.sin(a/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(u)*Math.cos(c);return ar(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),r.units)}function B(o){if(!o)throw new Error("geojson is required");switch(o.type){case"Feature":return Tt(o);case"FeatureCollection":return Xr(o);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return wt(o);default:throw new Error("unknown GeoJSON type")}}function Tt(o){var e={type:"Feature"};return Object.keys(o).forEach(function(r){switch(r){case"type":case"properties":case"geometry":return;default:e[r]=o[r]}}),e.properties=Gt(o.properties),e.geometry=wt(o.geometry),e}function Gt(o){var e={};return o&&Object.keys(o).forEach(function(r){var n=o[r];typeof n=="object"?n===null?e[r]=null:Array.isArray(n)?e[r]=n.map(function(i){return i}):e[r]=Gt(n):e[r]=n}),e}function Xr(o){var e={type:"FeatureCollection"};return Object.keys(o).forEach(function(r){switch(r){case"type":case"features":return;default:e[r]=o[r]}}),e.features=o.features.map(function(r){return Tt(r)}),e}function wt(o){var e={type:o.type};return o.bbox&&(e.bbox=o.bbox),o.type==="GeometryCollection"?(e.geometries=o.geometries.map(function(r){return wt(r)}),e):(e.coordinates=jt(o.coordinates),e)}function jt(o){var e=o;return typeof e[0]!="object"?e.slice():e.map(function(r){return jt(r)})}var Yr=function(){function o(e){this.points=e.points||[],this.duration=e.duration||1e4,this.sharpness=e.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=e.stepLength||60,this.length=this.points.length,this.delay=0;for(var r=0;r<this.length;r++)this.points[r].z=this.points[r].z||0;for(var r=0;r<this.length-1;r++){var n=this.points[r],i=this.points[r+1];this.centers.push({x:(n.x+i.x)/2,y:(n.y+i.y)/2,z:(n.z+i.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var r=0;r<this.centers.length-1;r++){var a=this.points[r+1].x-(this.centers[r].x+this.centers[r+1].x)/2,s=this.points[r+1].y-(this.centers[r].y+this.centers[r+1].y)/2,u=this.points[r+1].z-(this.centers[r].y+this.centers[r+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[r+1].x+this.sharpness*(this.centers[r].x+a),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r].y+s),z:(1-this.sharpness)*this.points[r+1].z+this.sharpness*(this.centers[r].z+u)},{x:(1-this.sharpness)*this.points[r+1].x+this.sharpness*(this.centers[r+1].x+a),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r+1].y+s),z:(1-this.sharpness)*this.points[r+1].z+this.sharpness*(this.centers[r+1].z+u)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}return o.prototype.cacheSteps=function(e){var r=[],n=this.pos(0);r.push(0);for(var i=0;i<this.duration;i+=10){var a=this.pos(i),s=Math.sqrt((a.x-n.x)*(a.x-n.x)+(a.y-n.y)*(a.y-n.y)+(a.z-n.z)*(a.z-n.z));s>e&&(r.push(i),n=a)}return r},o.prototype.vector=function(e){var r=this.pos(e+10),n=this.pos(e-10);return{angle:180*Math.atan2(r.y-n.y,r.x-n.x)/3.14,speed:Math.sqrt((n.x-r.x)*(n.x-r.x)+(n.y-r.y)*(n.y-r.y)+(n.z-r.z)*(n.z-r.z))}},o.prototype.pos=function(e){var r=e-this.delay;r<0&&(r=0),r>this.duration&&(r=this.duration-1);var n=r/this.duration;if(n>=1)return this.points[this.length-1];var i=Math.floor((this.points.length-1)*n),a=(this.length-1)*n-i;return Or(a,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])},o}();function Or(o,e,r,n,i){var a=Rr(o),s={x:i.x*a[0]+n.x*a[1]+r.x*a[2]+e.x*a[3],y:i.y*a[0]+n.y*a[1]+r.y*a[2]+e.y*a[3],z:i.z*a[0]+n.z*a[1]+r.z*a[2]+e.z*a[3]};return s}function Rr(o){var e=o*o,r=e*o;return[r,3*e*(1-o),3*o*(1-o)*(1-o),(1-o)*(1-o)*(1-o)]}function je(o,e){e===void 0&&(e={});for(var r=e.resolution||1e4,n=e.sharpness||.85,i=[],a=hr(o).coordinates.map(function(l){return{x:l[0],y:l[1]}}),s=new Yr({duration:r,points:a,sharpness:n}),u=function(l){var g=s.pos(l);Math.floor(l/100)%2===0&&i.push([g.x,g.y])},c=0;c<s.duration;c+=10)u(c);return u(s.duration),Je(i,e.properties)}function Zt(o,e){e===void 0&&(e={});var r=Number(o[0]),n=Number(o[1]),i=Number(o[2]),a=Number(o[3]);if(o.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var s=[r,n],u=[r,a],c=[i,a],l=[i,n];return Ge([[s,l,c,u,s]],e.properties,{bbox:o,id:e.id})}function Vt(o,e,r,n){n===void 0&&(n={});var i=Xe(o),a=pe(i[0]),s=pe(i[1]),u=pe(r),c=ur(e,n.units),l=Math.asin(Math.sin(s)*Math.cos(c)+Math.cos(s)*Math.sin(c)*Math.cos(u)),g=a+Math.atan2(Math.sin(u)*Math.sin(c)*Math.cos(s),Math.cos(c)-Math.sin(s)*Math.sin(l)),y=pt(g),m=pt(l);return xe([y,m],n.properties)}function Lt(o,e,r){r===void 0&&(r={});for(var n=r.steps||64,i=r.properties?r.properties:!Array.isArray(o)&&o.type==="Feature"&&o.properties?o.properties:{},a=[],s=0;s<n;s++)a.push(Vt(o,e,s*-360/n,r).geometry.coordinates);return a.push(a[0]),Ge([a],i)}function Ht(o,e,r){if(r===void 0&&(r={}),r.final===!0)return Br(o,e);var n=Xe(o),i=Xe(e),a=pe(n[0]),s=pe(i[0]),u=pe(n[1]),c=pe(i[1]),l=Math.sin(s-a)*Math.cos(c),g=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(s-a);return pt(Math.atan2(l,g))}function Br(o,e){var r=Ht(e,o);return r=(r+180)%360,r}function qr(o,e){var r=vt(o,e),n=Ht(o,e),i=Vt(o,r/2,n);return i}function At(o,e){e===void 0&&(e={});var r=0,n=0,i=0;return Ze(o,function(a){r+=a[0],n+=a[1],i++},!0),xe([r/i,n/i],e.properties)}function xt(o,e){switch(e===void 0&&(e={}),fr(o)){case"Point":return xe(Xe(o),e.properties);case"Polygon":var r=[];Ze(o,function(d){r.push(d)});var n=At(o,{properties:e.properties}),i=n.geometry.coordinates,a=0,s=0,u=0,c,l,g,y,m,v,L,D,C=r.map(function(d){return[d[0]-i[0],d[1]-i[1]]});for(c=0;c<r.length-1;c++)l=C[c],y=l[0],v=l[1],g=C[c+1],m=g[0],L=g[1],D=y*L-m*v,u+=D,a+=(y+m)*D,s+=(v+L)*D;if(u===0)return n;var I=u*.5,h=1/(6*I);return xe([i[0]+h*a,i[1]+h*s],e.properties);default:var f=Jr(o);return f?xt(f,{properties:e.properties}):At(o,{properties:e.properties})}}var Ct=6378137;function ht(o){return lr(o,function(e,r){return e+Ur(r)},0)}function Ur(o){var e=0,r;switch(o.type){case"Polygon":return Jt(o.coordinates);case"MultiPolygon":for(r=0;r<o.coordinates.length;r++)e+=Jt(o.coordinates[r]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function Jt(o){var e=0;if(o&&o.length>0){e+=Math.abs(Xt(o[0]));for(var r=1;r<o.length;r++)e-=Math.abs(Xt(o[r]))}return e}function Xt(o){var e,r,n,i,a,s,u,c=0,l=o.length;if(l>2){for(u=0;u<l;u++)u===l-2?(i=l-2,a=l-1,s=0):u===l-1?(i=l-1,a=0,s=1):(i=u,a=u+1,s=u+2),e=o[i],r=o[a],n=o[s],c+=(ft(n[0])-ft(e[0]))*Math.sin(ft(r[1]));c=c*Ct*Ct/2}return c}function ft(o){return o*Math.PI/180}const dt=(o,e,r,n)=>{o.addLayer({id:e,type:"circle",source:r,paint:{"circle-color":(n==null?void 0:n["circle-color"])||"#ff0","circle-radius":(n==null?void 0:n["circle-radius"])||5,"circle-stroke-color":(n==null?void 0:n["circle-stroke-color"])||"#000","circle-stroke-width":(n==null?void 0:n["circle-stroke-width"])||2}})},$e=(o,e,r,n)=>{o.addLayer({id:e,type:"line",source:r,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":(n==null?void 0:n["line-color"])||"#ff0","line-width":(n==null?void 0:n["line-width"])||4}})},tt=(o,e,r,n)=>{o.addLayer({id:e,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":(n==null?void 0:n["fill-color"])||"#ff0","fill-opacity":.8}})};function $r(o,e,r,n,i){let a="free",s="",u=[],c=[],l={},g=!1,y=!0,m=!1,v=!0,L=[],D=!0,C=5e4,I=!1,h={type:"FeatureCollection",features:[]},f={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},d={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}};const p=(b,J)=>{let U=0;return function(...$){const ce=new Date().getTime();ce-U<J||(U=ce,b(...$))}},w=b=>{switch(o.off("click",R),o.off("mousemove",te),o.off("contextmenu",N),ie(),ne(),g&&(y=!0,X(!1)),g=!0,a=b.type||"point",D=b.multipleLine||!1,m=b.smooth||!1,C=b.brushSize*1e3||3e4,l=b,v=b.showLayer,f.properties=b,d.properties=b,a){case"point":break;case"brush":A();break}o.on("click",R),o.getCanvas().style.cursor=a=="brush"?"move":"crosshair"},M=b=>{a=b,f.properties.type=a,d.properties.type=a},_=b=>{if(r)if(u.length){const $=[u[u.length-1]];r($)}else r([]);x(),ne(),o.addSource(s,{type:"geojson",data:h}),dt(o,s,s,l),h.features.push({type:"Feature",properties:l,geometry:{type:"Point",coordinates:b.lngLat.toArray()}}),o.getSource(s).setData(B(h)),e&&e(W())},P=b=>{if(y){if(r)if(u.length){const U=u[u.length-1],$=[U,U+"point"];r($)}else r([]);x(),ne(),o.addSource(s,{type:"geojson",data:f}),$e(o,s,s),dt(o,s+"point",s,l),y=!1,o.on("mousemove",te),o.on("contextmenu",N),o.dragRotate.enable()}f.geometry.coordinates.push(b.lngLat.toArray());const J=o.getSource(s);J.setData(f),!D&&f.geometry.coordinates.length==3&&(o.off("mousemove",te),o.off("contextmenu",N),y=!0,X(!1),f.geometry.coordinates.pop(),J.setData(B(f)),e&&e(W()))},k=b=>{if(y){if(r)if(u.length){const $=u[u.length-1],ce=[$,$+"outline",$+"point"];r(ce)}else r([]);x(),ne(),o.addSource(s,{type:"geojson",data:d}),o.addSource(s+"point",{type:"geojson",data:h}),tt(o,s,s,l),$e(o,s+"outline",s,{"line-color":"black","line-width":2,...l}),dt(o,s+"point",s+"point",l),y=!1,o.on("mousemove",te),o.on("contextmenu",N),o.dragRotate.enable()}d.geometry.coordinates[0].length>=3&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(b.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),h.features.push(B({type:"Feature",geometry:{type:"Point",coordinates:b.lngLat.toArray()}})),o.getSource(s+"point").setData(h);const U=o.getSource(s);d.geometry.coordinates[0].length<=3&&!m&&U.setData(d),X(!0)},F=b=>{if(y){if(r)if(u.length){const U=u[u.length-1],$=[U,U+"outline"];r($)}else r([]);x(),ne(),o.addSource(s,{type:"geojson",data:d}),tt(o,s,s,l),$e(o,s+"outline",s,{"line-color":"black","line-width":2,...l}),y=!1,d.geometry.coordinates[0].push(b.lngLat.toArray()),o.getSource(s).setData(d),o.on("mousemove",te),o.on("contextmenu",N),X(!0),o.dragRotate.enable()}},A=()=>{o.on("mousedown",Z),o.on("mouseup",re),o.on("mousemove",O),o.on("mouseover",ee),o.on("mouseout",oe)},Y=()=>{x(),ne(),o.addSource(s,{type:"geojson",data:d}),tt(o,s,s,l),$e(o,s+"outline",s,{"line-color":"black","line-width":2,...l})},q=(b,J)=>{const U=xe([b.lng,b.lat]),$=J/2/111320,ce=ot(Lt(U,$,{units:"degrees"}));return Zt(ce)},se=(b,J)=>{const U=q(b,J);d.geometry=U.geometry,o.getSource(s).setData(d)},Q=()=>{const b=s,U=o.getSource(b).serialize().data;e&&e(U)},K=b=>{C=b*1e3},j=b=>{d.properties.MGValue=b},ie=()=>{o.off("mousedown",Z),o.off("mouseup",re),o.off("mousemove",O),o.off("mouseover",ee),o.off("mouseout",oe)},E=b=>{let J=B(b);const U=Je(J.geometry.coordinates[0]),$=je(U,{sharpness:.6});return J.geometry.coordinates[0]=$.geometry.coordinates,J},x=()=>{s=z(),u.push(s),c.push(s)},z=()=>{let b=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){const $=(b+Math.random()*16)%16|0;return b=Math.floor(b/16),(U==="x"?$:$&3|8).toString(16)})},X=b=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(U=>{b?o[U].disable():o[U].enable()})},R=b=>{switch(a){case"point":_(b);break;case"line":P(b);break;case"polygon":k(b);break;case"free":F(b);break}},V=b=>{switch(a){case"line":f.geometry.coordinates.length&&(f.geometry.coordinates.length==1&&f.geometry.coordinates.push(b.lngLat.toArray()),f.geometry.coordinates[f.geometry.coordinates.length-1]=b.lngLat.toArray(),o.getSource(s).setData(f));break;case"polygon":const J=d.geometry.coordinates[0].length;if(J){J==2?d.geometry.coordinates[0][J-1]=b.lngLat.toArray():d.geometry.coordinates[0][J-2]=b.lngLat.toArray();const $=o.getSource(s);$.setData(d),m&&d.geometry.coordinates[0].length>=3&&$.setData(E(d))}break;case"free":d.geometry.coordinates[0].length&&(L.push(b.point),d.geometry.coordinates[0].length!=1&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(b.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),o.getSource(s).setData(d));break}},O=b=>{se(b.lngLat,C),I&&G()},G=p(Q,0),N=b=>{b.preventDefault(),o.off("mousemove",te),o.off("contextmenu",N),y=!0,L.push(b.point),X(!1),o.dragRotate.disable();const J=o.getSource(s);switch(a){case"line":f.geometry.coordinates.length&&J.setData(B(f));break;case"polygon":if(d.geometry.coordinates[0].length){const U=d.geometry.coordinates[0].length;d.geometry.coordinates[0].splice(U-2,1),J.setData(B(d))}v||(o.setLayoutProperty(s,"visibility","none"),o.setLayoutProperty(s+"outline","visibility","none")),o.setLayoutProperty(s+"point","visibility","none"),m&&J.setData(B(E(d)));break;case"free":if(d.geometry.coordinates[0].length){const U=d.geometry.coordinates[0].length;if(d.geometry.coordinates[0].splice(U-2,1),J.setData(B(d)),v||(o.setLayoutProperty(s,"visibility","none"),o.setLayoutProperty(s+"outline","visibility","none")),m){const $=[...L.slice(L.length/5),...L.slice(0,L.length/5),L.slice(L.length/5)[0]],ce=$.length>10?5:3,le=Math.ceil($.length/ce),Qe=[];for(let de=0;de<$.length;de+=le)Qe.push($.slice(de,de+le));let Pe=[];Qe.forEach(de=>{if(de.length>1){const Qt=new H(de).getLUT();Pe.push(...Qt)}else Pe.push(...de)}),d.geometry.coordinates[0].length=0;for(let de=0;de<Pe.length;de++){const bt=o.unproject(Pe[de]);d.geometry.coordinates[0].push(bt.toArray())}J.setData(B(d))}}break}e&&e(W())},Z=()=>{o.dragPan.disable(),o.dragRotate.disable(),I=!0,Q()},re=()=>{o.dragPan.enable(),o.dragRotate.enable(),I=!1},ee=()=>{Y()},oe=()=>{o.getLayer(s)&&o.removeLayer(s),o.getLayer(s+"outline")&&o.removeLayer(s+"outline"),o.getSource(s)&&o.removeSource(s)},W=()=>{const b=u,J=[];return b.forEach((U,$)=>{if(o.getSource(U)){const le=o.getSource(U).serialize().data;le.features?(le.features[0].properties.layerId=U,le.features[0].properties.sourceId=c[$],J.push(...le.features)):(le.properties.layerId=U,le.properties.sourceId=c[$],J.push(le))}}),J},ae=()=>{u.forEach(b=>{o.getLayer(b)&&o.removeLayer(b),o.getLayer(b+"outline")&&o.removeLayer(b+"outline"),o.getLayer(b+"point")&&o.removeLayer(b+"point"),o.getLayer(b+"text")&&o.removeLayer(b+"text")}),c.forEach(b=>{o.getSource(b)&&o.removeSource(b),o.getSource(b+"point")&&o.removeSource(b+"point"),o.getSource(b+"text")&&o.removeSource(b+"text")}),u.length=0,c.length=0},ne=()=>{L.length=0,h.features.length=0,f.geometry.coordinates.length=0,d.geometry.coordinates.length=0,d.geometry.coordinates[0]=[],d.properties.result=""},te=p(V,30),he=()=>{ie(),o.off("click",R),o.off("mousemove",te),o.off("contextmenu",N),o.getCanvas().style.cursor="pointer",X(!1)},me=()=>{(a=="free"||a=="polygon"||a=="point"||a=="line")&&u.length&&(o.removeLayer(u[u.length-1]),o.getLayer(u[u.length-1]+"outline")&&o.removeLayer(u[u.length-1]+"outline"),o.getLayer(u[u.length-1]+"point")&&o.removeLayer(u[u.length-1]+"point"),u.pop())},be=()=>{if((a=="free"||a=="polygon")&&c.length){const b=u.length-c.length,J=c.slice(b);if(b!==0&&J.length){const ce=o.getSource(J[0]).serialize().data.valueOf();o.getLayer(J[0])||(u.push(J[0]),tt(o,J[0],J[0],{"fill-color":ce.properties["fill-color"]}),$e(o,J[0]+"outline",J[0],{"line-color":"black","line-width":2,...ce.properties}))}}};let Ve=!1;const st=b=>{Ve=b};let De,Ye=!1,ke="";o.on("mousedown",b=>{const J=o.queryRenderedFeatures(b.point);J.length>0&&(ke=J[0].layer.source,Ve&&He(b))});const He=b=>{o.dragPan.disable(),De=b.lngLat,Ye=!0,o.on("mouseup",Ee),o.on("mousemove",St),i&&i()},Ee=()=>{if(Ye=!1,o.off("mouseup",Ee),o.off("mousemove",St),o.dragPan.enable(),n){const J=o.getSource(ke).serialize().data;n(J)}},St=b=>{if(!Ye)return;const J=b.lngLat,U=J.lng-De.lng,$=J.lat-De.lat;De=J;const ce=o.getSource(ke),le=ce.serialize().data;le.geometry.coordinates=le.geometry.coordinates.map(Qe=>Qe.map(Pe=>[Pe[0]+U,Pe[1]+$])),ce.setData(le)};return{startDraw:w,revoke:me,redo:be,getFeaturesFromDraw:W,clearDraw:ae,stopDraw:he,setBrushSize:K,setValue:j,setDrawMethod:M,setDragMode:st}}const Nr=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"symbol",source:r,paint:{"text-color":"#006e1a","text-halo-width":3,"text-halo-color":"rgba(255,255,255,1)",...(n==null?void 0:n.symbolPaint)??{}},layout:{"icon-image":"","text-allow-overlap":!0,"icon-allow-overlap":!0,"text-ignore-placement":!0,"icon-ignore-placement":!0,"text-field":"{name}","text-line-height":1.1,"text-size":17,"text-anchor":"left","text-offset":[1,0],"icon-size":.5,"text-font":["Noto Sans Regular"],...(n==null?void 0:n.symbolLayout)??{}}})},Ce=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"circle",source:r,paint:{"circle-color":"#ff0","circle-radius":5,"circle-stroke-color":"#000","circle-stroke-width":2,...(n==null?void 0:n.circlePaint)??{}},layout:{...(n==null?void 0:n.circleLayout)??{}}})},_e=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] ayer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"line",source:r,paint:{"line-color":(n==null?void 0:n["line-color"])||"black","line-width":(n==null?void 0:n["line-width"])||2,...(n==null?void 0:n.linePaint)??{}},layout:{"line-join":"round","line-cap":"round",...(n==null?void 0:n.lineLayout)??{}}})},Ne=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"symbol",source:r,paint:{...(n==null?void 0:n.symbolPaint)??{}},layout:{"text-font":["Noto Sans Regular"],"text-field":["get","result"],"text-allow-overlap":!0,"text-anchor":"bottom","text-overlap":"always","text-offset":[0,-.5],...(n==null?void 0:n.symbolLayout)??{}}})},ze=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":"#ff0","fill-opacity":.8,...(n==null?void 0:n.fillPaint)??{}},layout:{...(n==null?void 0:n.fillLayout)??{}}})},ve=(o,e)=>{o.getLayer(e)&&o.removeLayer(e)},Ie=(o,e,r)=>{if(o.getSource(e)){console.warn(`[popillon] Source with id "${e}" already exists. Skipping addSource.`);return}o.addSource(e,r)},ue=(o,e,r)=>{const n=o.getSource(e);n?n.setData(r):console.warn(`[popillon] Source with id "${e}" is not a GeoJSONSource.`)},Se=(o,e)=>{o.getSource(e)&&o.removeSource(e)},ye=(o,e)=>{var r;if(o.getSource(e)){const n=o.getSource(e);return(r=n==null?void 0:n.serialize())==null?void 0:r.data}else{console.warn(`[popillon] Source "${e}" does not exist. Skipping getSourceData.`);return}};function Tr(o,e){let r="free",n="",i=[],a=[],s={},u=!1,c=!0,l=!1,g=[],y={type:"FeatureCollection",features:[]},m={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},v={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},L={type:"Feature",properties:{result:""},geometry:{type:"Point",coordinates:[]}};const D=x=>{o.off("click",P),o.off("mousemove",E),o.off("contextmenu",F),j(),u&&(c=!0,_(!1)),u=!0,r=x.type||"point",x.measure,l=x.smooth||!1,s=x,m.properties=x,v.properties=x,L.properties=x,o.on("click",P),o.getCanvas().style.cursor="crosshair"},C=x=>{w(),j(),o.addSource(n,{type:"geojson",data:y}),Ce(o,n,n,s),Ne(o,n+"text",n,{}),y.features.push({type:"Feature",properties:s,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(B(y)),e&&e(A())},I=x=>{w(),j(),o.addSource(n,{type:"geojson",data:y}),Nr(o,n,n,s),y.features.push({type:"Feature",properties:s,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(B(y)),e&&e(A())},h=x=>{c&&(w(),j(),o.addSource(n,{type:"geojson",data:m}),o.addSource(n+"text",{type:"geojson",data:y}),_e(o,n,n),Ce(o,n+"point",n,s),Ne(o,n+"text",n+"text",{}),c=!1,o.on("mousemove",E),o.on("contextmenu",F)),m.geometry.coordinates.push(x.lngLat.toArray()),o.getSource(n).setData(m),y.features.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n+"text").setData(y)},f=x=>{c&&(w(),j(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:L}),ze(o,n,n),_e(o,n+"outline",n,{"line-color":"black","line-width":2,...s}),Ce(o,n+"point",n),Ne(o,n+"area",n+"area",{}),c=!1,o.on("mousemove",E),o.on("contextmenu",F)),v.geometry.coordinates[0].length>=3&&v.geometry.coordinates[0].pop(),v.geometry.coordinates[0].push(x.lngLat.toArray()),v.geometry.coordinates[0].push(v.geometry.coordinates[0][0]),g.push(x.point),o.getSource(n).setData(v),_(!0)},d=x=>{c&&(w(),j(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:L}),ze(o,n,n,s),_e(o,n+"outline",n,{"line-color":"black","line-width":2,...s}),Ne(o,n+"area",n+"area",{}),c=!1,v.geometry.coordinates[0].push(x.lngLat.toArray()),o.getSource(n).setData(v),o.on("mousemove",E),o.on("contextmenu",F),_(!0))},p=x=>{if(c){w(),j(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:L}),o.addSource(n+"point",{type:"geojson",data:y}),ze(o,n,n,s),_e(o,n+"outline",n,{"line-color":"black","line-width":2,...s}),Ce(o,n+"point",n+"point"),Ne(o,n+"area",n+"area",{}),c=!1;const z={type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}};y.features.push(B(z)),y.features.push(B(z)),L.geometry.coordinates=x.lngLat.toArray(),o.getSource(n+"point").setData(y),o.on("mousemove",E),o.on("contextmenu",F),_(!0)}},w=()=>{n=M(),i.push(n),a.push(n)},M=()=>{let x=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(X){const R=(x+Math.random()*16)%16|0;return x=Math.floor(x/16),(X==="x"?R:R&3|8).toString(16)})},_=x=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(X=>{x?o[X].disable():o[X].enable()})},P=x=>{switch(r){case"symbol":I(x);break;case"point":C(x);break;case"line":h(x);break;case"polygon":f(x);break;case"free":d(x);break;case"circle":p(x);break}},k=x=>{switch(r){case"line":if(m.geometry.coordinates.length){m.geometry.coordinates.length==1&&m.geometry.coordinates.push(x.lngLat.toArray()),m.geometry.coordinates[m.geometry.coordinates.length-1]=x.lngLat.toArray(),o.getSource(n).setData(m);const oe=m.geometry.coordinates[m.geometry.coordinates.length-2],W=m.geometry.coordinates[m.geometry.coordinates.length-1],ae=vt(oe,W,{units:"kilometers"}),ne=qr(xe(oe),xe(W)),te=y.features[y.features.length-1];te.properties.result=Ke(ae,4)+"km",te.geometry.coordinates=ne.geometry.coordinates,o.getSource(n+"text").setData(B(y))}break;case"polygon":const Z=v.geometry.coordinates[0].length;if(Z){Z==2?v.geometry.coordinates[0][Z-1]=x.lngLat.toArray():v.geometry.coordinates[0][Z-2]=x.lngLat.toArray();const ee=ht(v)/1e6;if(Z>=4){var z=Ge(v.geometry.coordinates),X=xt(z);L.geometry.coordinates=X.geometry.coordinates,L.properties.result=Ke(ee,2)+"km²"}const oe=o.getSource(n);oe.setData(v),o.getSource(n+"area").setData(L),l&&v.geometry.coordinates[0].length>=3&&oe.setData(Y(v))}break;case"free":const re=v.geometry.coordinates[0].length;if(re){g.push(x.point),v.geometry.coordinates[0].length!=1&&v.geometry.coordinates[0].pop(),v.geometry.coordinates[0].push(x.lngLat.toArray()),v.geometry.coordinates[0].push(v.geometry.coordinates[0][0]);const ee=ht(v)/1e6;if(re>=4){var z=Ge(v.geometry.coordinates),X=xt(z);L.geometry.coordinates=X.geometry.coordinates,L.properties.result=Ke(ee,2)+"km²"}o.getSource(n).setData(v),o.getSource(n+"area").setData(L)}break;case"circle":if(y.features.length){y.features[1].geometry.coordinates=x.lngLat.toArray();var R=xe(y.features[0].geometry.coordinates),V=xe(y.features[1].geometry.coordinates),O=vt(R,V,{units:"miles"}),G={steps:500,units:"miles",properties:{foo:"bar"}},N=Lt(R,O,G);v.geometry.coordinates=N.geometry.coordinates;const ee=ht(v)/1e6;L.properties.result=Ke(ee,2)+"km²";const oe=o.getSource(n+"point"),W=o.getSource(n),ae=o.getSource(n+"area");oe.setData(y),W.setData(v),ae.setData(L)}break}},F=x=>{x.preventDefault(),o.off("mousemove",E),o.off("contextmenu",F),c=!0,g.push(x.point),_(!1);const z=o.getSource(n);switch(r){case"line":m.geometry.coordinates.length&&(console.log(m),z.setData(B(m)),o.removeLayer(n+"point"),l&&m.geometry.coordinates.length>=2&&z.setData(q(m)));break;case"polygon":v.geometry.coordinates[0].length&&z.setData(B(v)),o.setLayoutProperty(n+"point","visibility","none"),l&&z.setData(B(Y(v)));break;case"free":if(v.geometry.coordinates[0].length&&(z.setData(B(v)),l)){const X=[...g.slice(g.length/5),...g.slice(0,g.length/5),g.slice(g.length/5)[0]],R=X.length>10?5:3,V=Math.ceil(X.length/R),O=[];for(let N=0;N<X.length;N+=V)O.push(X.slice(N,N+V));let G=[];O.forEach(N=>{if(N.length>1){const re=new H(N).getLUT();G.push(...re)}else G.push(...N)}),v.geometry.coordinates[0].length=0;for(let N=0;N<G.length;N++){const Z=o.unproject(G[N]);v.geometry.coordinates[0].push(Z.toArray())}z.setData(B(v))}break;case"circle":o.removeLayer(n+"point"),o.removeSource(n+"point");break}e&&e(A())},A=()=>{const x=i,z=[];return x.forEach((X,R)=>{const O=o.getSource(X).serialize().data;O.features?(O.features[0].properties.layerId=X,O.features[0].properties.sourceId=a[R],z.push(...O.features)):(O.properties.layerId=X,O.properties.sourceId=a[R],z.push(O))}),z},Y=x=>{let z=B(x);const X=Je(z.geometry.coordinates[0]),R=je(X,{sharpness:.6});return z.geometry.coordinates[0]=R.geometry.coordinates,z},q=x=>{let z=B(x);console.log(z,"lineFeature");const X=Je(z.geometry.coordinates),R=je(X,{sharpness:.6});return z.geometry.coordinates=R.geometry.coordinates,z},se=x=>{o.getLayer(x)&&o.removeLayer(x),o.getLayer(x+"outline")&&o.removeLayer(x+"outline"),o.getLayer(x+"point")&&o.removeLayer(x+"point"),o.getLayer(x+"area")&&o.removeLayer(x+"area"),o.getLayer(x+"text")&&o.removeLayer(x+"text"),i=i.filter(z=>z!==x)},Q=()=>{i.forEach(x=>{o.removeLayer(x),o.getLayer(x+"outline")&&o.removeLayer(x+"outline"),o.getLayer(x+"point")&&o.removeLayer(x+"point"),o.getLayer(x+"area")&&o.removeLayer(x+"area"),o.getLayer(x+"text")&&o.removeLayer(x+"text")}),a.forEach(x=>{o.removeSource(x),o.getSource(x+"point")&&o.removeSource(x+"point"),o.getSource(x+"text")&&o.removeSource(x+"text"),o.getSource(x+"area")&&o.removeSource(x+"area")}),i.length=0,a.length=0},K=()=>{o.off("click",P),o.off("mousemove",E),o.off("contextmenu",F),o.getCanvas().style.cursor="pointer",_(!1)},j=()=>{g.length=0,y.features.length=0,m.geometry.coordinates.length=0,v.geometry.coordinates.length=0,v.geometry.coordinates[0]=[],v.properties.result="",L.geometry.coordinates.length=0},E=((x,z)=>{let X=0;return function(...R){const V=new Date().getTime();V-X<z||(X=V,x(...R))}})(k,30);return{startMeasure:D,clearMeasure:Q,stopMeasure:K,getFeaturesFromMeasure:A,clearLayerById:se}}const Gr=()=>{let o=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const n=(o+Math.random()*16)%16|0;return o=Math.floor(o/16),(r==="x"?n:n&3|8).toString(16)})},yt=o=>{let e=B(o);const r=Je(e.geometry.coordinates[0]),n=je(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates[0]=n.geometry.coordinates,e},Yt=o=>{const e=B(o),r=Je(e.geometry.coordinates),n=je(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates=n.geometry.coordinates,e},jr=(o,e)=>{let r=0;return function(...n){const i=new Date().getTime();i-r<e||(r=i,o(...n))}},gt=o=>["fill","line","circle","symbol"].includes(o.type)&&"source"in o&&o.source!=="maplibre";class Zr{constructor(e){T(this,"map");T(this,"eventMap",new Map);T(this,"uuid","");T(this,"layerIds",[]);T(this,"sourceIds",[]);T(this,"toolMode","draw");T(this,"_followPointId","followPointId");T(this,"options",{drawMode:"polygon",showLayer:!0,smooth:!0,polyline:!0,brushState:!1,brushSize:5e4});T(this,"newDraw",!0);T(this,"saveFreePolygonPoint",[]);T(this,"_activeLayer");T(this,"_editMode","idle");T(this,"_dragIndex",null);T(this,"_vertexSourceId","custom-vertex-source");T(this,"_vertexLayerId","custom-vertex-layer");T(this,"_isDragging",!1);T(this,"_dragOrigin",null);T(this,"_onMapClick",this._onMapClick_.bind(this));T(this,"_onMapDblclick",this._onMapDblclick_.bind(this));T(this,"_onMapMousemove",jr(this._onMapMousemove_.bind(this),10));T(this,"_onMapMousedown",this._onMapMousedown_.bind(this));T(this,"_onMapMouseup",this._onMapMouseup_.bind(this));T(this,"_onMapMouseover",this._onMapMouseover_.bind(this));T(this,"_onMapMouseout",this._onMapMouseout_.bind(this));T(this,"pointJson",{type:"FeatureCollection",features:[]});T(this,"lineJson",{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}});T(this,"polygonJson",{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});T(this,"drawFreePolygon",e=>{const{map:r}=this;this.newDraw&&(this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),Ie(r,this.uuid,{type:"geojson",data:this.polygonJson}),ze(r,this.uuid,this.uuid,this.options),_e(r,this.uuid+"outline",this.uuid,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),this._setMapActionEvents(!1))});T(this,"_getCoords",e=>e.type!=="GeometryCollection"&&Array.isArray(e.coordinates)&&e.type==="Polygon"&&Array.isArray(e.coordinates[0])?e.coordinates[0]:[]);T(this,"getFeatureLatest",()=>{const{map:e,layerIds:r}=this;return r.length?ye(e,r[r.length-1]):void 0});T(this,"getFeatures",()=>{const{map:e,layerIds:r}=this;return r.length?r.map(n=>ye(e,n)):[]});T(this,"revoke",()=>{const{layerIds:e}=this;if(e.length){const r=e[e.length-1];this.map.getLayer(r)&&this.map.removeLayer(r),this.map.getLayer(r+"outline")&&this.map.removeLayer(r+"outline"),e.pop()}});T(this,"redo",()=>{const{map:e}=this;if(this.sourceIds){const r=this.layerIds.length-this.sourceIds.length,n=this.sourceIds.slice(r);if(r!==0&&n.length){const i=n[0],a=ye(e,i);if(!a)return;this.map.getLayer(n[0])||(this.layerIds.push(n[0]),ze(this.map,n[0],n[0],{...a.properties}),_e(this.map,n[0]+"outline",n[0],{...a.properties}))}}});this.map=e,this.init()}init(){}_creatFollowPoints(e){const{map:r,_followPointId:n}=this;Ie(r,n,{type:"geojson",data:this.pointJson}),Ce(r,n,n,this.options);const i={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e}};this.pointJson.features.push(B(i)),this.pointJson.features.push(B(i)),ue(r,n,B(this.pointJson))}_updateFollowPoints(e){const{map:r,_followPointId:n}=this;this.pointJson.features[1].geometry.coordinates=e,ue(r,n,B(this.pointJson))}_removeFollowPoints(){const{map:e,_followPointId:r}=this;ve(e,r),Se(e,r)}drawPoint(e){const{map:r}=this;this._addUUID(),this._clearJson(),Ie(r,this.uuid,{type:"geojson",data:this.pointJson}),Ce(r,this.uuid,this.uuid,this.options),this.pointJson.features.push({type:"Feature",properties:{...this.options,layerId:this.uuid,sourceId:this.uuid},geometry:{type:"Point",coordinates:e.lngLat.toArray()}}),ue(r,this.uuid,B(this.pointJson)),this.emit("finishDraw",this.getFeatureLatest())}drawLine(e){const{map:r}=this;this.newDraw&&(this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ie(r,this.uuid,{type:"geojson",data:this.lineJson}),_e(r,this.uuid,this.uuid,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),r.on("dblclick",this._onMapDblclick),r.dragRotate.enable()),this.lineJson.geometry.coordinates.push(e.lngLat.toArray()),!this.options.polyline&&this.lineJson.geometry.coordinates.length==3&&(r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this.lineJson.geometry.coordinates.pop(),ue(r,this.uuid,B(this.lineJson)),this._setMapActionEvents(!0),this._removeFollowPoints(),this.emit("finishDraw",this.getFeatureLatest()))}drawPolygon(e){const{map:r}=this;this.newDraw&&(this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ie(r,this.uuid,{type:"geojson",data:this.polygonJson}),ze(r,this.uuid,this.uuid,this.options),_e(r,this.uuid+"outline",this.uuid,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),r.on("dblclick",this._onMapDblclick)),this.polygonJson.geometry.coordinates[0].length>=3&&this.polygonJson.geometry.coordinates[0].pop(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),this.polygonJson.geometry.coordinates[0].push(this.polygonJson.geometry.coordinates[0][0]),this._setMapActionEvents(!1)}_createRectangle(e,r){const n=xe([e.lng,e.lat]),i=r/2/111320,a=ot(Lt(n,i,{units:"degrees"}));return Zt(a)}setBrushSize(e){this.options.brushSize=e*1e3}startDraw(e){const{map:r}=this;switch(this.options=e,this.stop(),this.toolMode="draw",r.getCanvas().addEventListener("contextmenu",n=>n.preventDefault()),this._setMapCursorStyle("crosshair"),this.options.drawMode){case"circle":break;case"freePolygon":r.on("mousedown",this._onMapMousedown),r.on("mouseup",this._onMapMouseup);break;case"brush":r.on("mousedown",this._onMapMousedown),r.on("mouseup",this._onMapMouseup),r.on("mousemove",this._onMapMousemove),r.on("mouseover",this._onMapMouseover),r.on("mouseout",this._onMapMouseout),this._setMapCursorStyle("move");break}r.on("click",this._onMapClick)}stopDraw(){this.newDraw=!0,this.options.brushState=!1,this._clearMapEventListeners(),this._setMapActionEvents(!0),this._setMapCursorStyle(),this._removeFollowPoints()}_onMapClickDraw(e){switch(this.options.drawMode){case"circle":this.drawPoint(e);break;case"line":this.drawLine(e);break;case"polygon":this.drawPolygon(e);break}}_onMapMousemoveDraw(e){const{map:r}=this,n=e.lngLat.toArray();switch(this.options.drawMode){case"line":this._updateFollowPoints(n);const i=this.lineJson.geometry.coordinates.length;i&&(i==1&&this.lineJson.geometry.coordinates.push(e.lngLat.toArray()),this.lineJson.geometry.coordinates[i-1]=e.lngLat.toArray(),ue(r,this.uuid,this.options.smooth&&i>=2?Yt(this.lineJson):B(this.lineJson)));break;case"polygon":this._updateFollowPoints(n);const a=this.polygonJson.geometry.coordinates[0].length;a&&(a==2?this.polygonJson.geometry.coordinates[0][a-1]=n:this.polygonJson.geometry.coordinates[0][a-2]=n,a>=3&&ue(r,this.uuid,this.options.smooth?yt(this.polygonJson):this.polygonJson));break;case"freePolygon":this._updateFollowPoints(n),this.polygonJson.geometry.coordinates[0].length&&(this.saveFreePolygonPoint.push(e.point),this.polygonJson.geometry.coordinates[0].length!=1&&this.polygonJson.geometry.coordinates[0].pop(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),this.polygonJson.geometry.coordinates[0].push(this.polygonJson.geometry.coordinates[0][0]),ue(r,this.uuid,this.polygonJson));break;case"brush":const u=this._createRectangle(e.lngLat,this.options.brushSize??5e4);this.polygonJson.geometry=u.geometry,ue(r,this.uuid,this.polygonJson),this.options.brushState&&this.emit("finishBrush",ye(r,this.uuid));break}}_onMapDblclickDraw(e){const{map:r}=this;switch(e.preventDefault(),r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.options.drawMode){case"line":this.lineJson.geometry.coordinates.length?(this._removeFollowPoints(),this.lineJson.geometry.coordinates.splice(-2,1),this.lineJson.geometry.coordinates.splice(-2,1),ue(r,this.uuid,this.options.smooth&&this.lineJson.geometry.coordinates.length>=2?Yt(this.lineJson):B(this.lineJson)),this.emit("finishDraw",this.getFeatureLatest())):(ve(r,this.uuid),ve(r,this.uuid+"line"),Se(r,this.uuid),Se(r,this.uuid+"line"),this.layerIds.pop(),this.sourceIds.pop());break;case"polygon":this.polygonJson.geometry.coordinates[0].length>=3?(this._removeFollowPoints(),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.options.showLayer||(r.setLayoutProperty(this.uuid,"visibility","none"),r.setLayoutProperty(this.uuid+"outline","visibility","none")),this.polygonJson.properties.feedbackFeature=B(this.polygonJson),ue(r,this.uuid,this.options.smooth?yt(this.polygonJson):B(this.polygonJson)),this.emit("finishDraw",this.getFeatureLatest())):(this.layerIds.pop(),this.sourceIds.pop(),ve(r,this.uuid),ve(r,this.uuid+"line"),Se(r,this.uuid),Se(r,this.uuid+"line"));break}}_onMapMouseoverDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":this._addUUID(),this._clearJson(),Ie(e,this.uuid,{type:"geojson",data:this.polygonJson}),ze(e,this.uuid,this.uuid,this.options),_e(e,this.uuid+"outline",this.uuid,this.options);break}}_onMapMouseoutDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":ve(e,this.uuid),ve(e,this.uuid+"outline"),Se(e,this.uuid);break}}_onMapMousedownDraw(e){const{map:r}=this;switch(this.options.drawMode){case"freePolygon":this.drawFreePolygon(e);break;case"brush":r.dragPan.disable(),r.dragRotate.disable(),this.options.brushState=!0,this.emit("finishBrush",ye(r,this.uuid));break}}_onMapMouseupDraw(){const{map:e}=this;switch(this.options.drawMode){case"freePolygon":if(e.off("mousemove",this._onMapMousemove),e.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.polygonJson.geometry.coordinates[0].length){this._removeFollowPoints();const r=this.polygonJson.geometry.coordinates[0].length;if(this.polygonJson.geometry.coordinates[0].splice(r-2,1),ue(e,this.uuid,B(this.polygonJson)),this.options.showLayer||(this.map.setLayoutProperty(this.uuid,"visibility","none"),this.map.setLayoutProperty(this.uuid+"outline","visibility","none")),r>=2&&this.options.smooth){const n=this.saveFreePolygonPoint,i=[...n.slice(n.length/5),...n.slice(0,n.length/5),n.slice(n.length/5)[0]],a=i.length>10?5:3,s=Math.ceil(i.length/a),u=[];for(let l=0;l<i.length;l+=s)u.push(i.slice(l,l+s));let c=[];u.forEach(l=>{if(l.length>1){const y=new H(l).getLUT();c.push(...y)}else c.push(...l)}),this.polygonJson.geometry.coordinates[0].length=0;for(let l=0;l<c.length;l++){const g=this.map.unproject(c[l]);this.polygonJson.geometry.coordinates[0].push(g.toArray())}ue(e,this.uuid,B(this.polygonJson))}this.emit("finishDraw",this.getFeatureLatest())}else ve(e,this.uuid),ve(e,this.uuid+"outline"),Se(e,this.uuid),this.layerIds.pop(),this.sourceIds.pop();break;case"brush":e.dragPan.enable(),e.dragRotate.enable(),this.options.brushState=!1;break}}startEdit(){const{map:e}=this;this.stop(),this.toolMode="edit",e.on("click",this._onMapClick)}stopEdit(){const{map:e}=this;e.off("mousemove",this._onMapMousemove),e.off("mousedown",this._vertexLayerId,this._onMapMousedown),e.off("mouseup",this._vertexLayerId,this._onMapMouseup),e.off("mouseover",this._vertexLayerId,this._onMapMouseover),e.off("mouseout",this._vertexLayerId,this._onMapMouseout),e.off("click",this._onMapClick),this._dragIndex=null,this._removeVertexPoints(),this._setMapActionEvents(!0),this._setMapCursorStyle()}_updateVertexPoints(){var a;const{map:e}=this,r=ye(e,this._activeLayer.source);if(!r)return;const n=(a=r.properties)!=null&&a.feedbackFeature?this._getCoords(r.properties.feedbackFeature.geometry):this._getCoords(r.geometry);if(!n.length)return;const i=n.slice(0,-1).map((s,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:s}}));e.getSource(this._vertexSourceId)||(e.addSource(this._vertexSourceId,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.addLayer({id:this._vertexLayerId,type:"circle",source:this._vertexSourceId,paint:{"circle-radius":5,"circle-color":"#ff0","circle-stroke-width":2,"circle-stroke-color":"#000"}})),ue(e,this._vertexSourceId,B({type:"FeatureCollection",features:i}))}_removeVertexPoints(){const{map:e,_vertexLayerId:r,_vertexSourceId:n}=this;ve(e,r),Se(e,n)}_onMapClickEdit(e){const{map:r}=this;r.off("mousemove",this._onMapMousemove),r.off("mousedown",this._vertexLayerId,this._onMapMousedown),r.off("mouseup",this._vertexLayerId,this._onMapMouseup),r.off("mouseover",this._vertexLayerId,this._onMapMouseover),r.off("mouseout",this._vertexLayerId,this._onMapMouseout),this._setMapCursorStyle(),this._removeVertexPoints();const n=r.queryRenderedFeatures(e.point),i=n==null?void 0:n[0];if(!i)return;const a=i.layer;gt(a)?(this._activeLayer&&this._activeLayer.id!==a.id&&(this._editMode="idle"),this._activeLayer=a,this._editMode==="idle"?(this._editMode="edit",this._updateVertexPoints(),this._setMapCursorStyle("grab")):(this._editMode="idle",this._removeVertexPoints(),this._setMapCursorStyle()),r.on("mousemove",this._onMapMousemove),r.on("mousedown",this._vertexLayerId,this._onMapMousedown),r.on("mouseup",this._vertexLayerId,this._onMapMouseup),r.on("mouseover",this._vertexLayerId,this._onMapMouseover),r.on("mouseout",this._vertexLayerId,this._onMapMouseout)):this._editMode="idle"}_onMapMousemoveEdit(e){var s,u,c;const{map:r}=this;if(this._editMode==="edit"&&this._dragIndex!==null){const l=ye(r,this._activeLayer.source);if(!l||!("geometry"in l))return;const g=(s=l.properties)==null?void 0:s.feedbackFeature,y=B(g?(u=l==null?void 0:l.properties)==null?void 0:u.feedbackFeature:l),{geometry:m}=y;if(m.type==="Polygon"){const v=m.coordinates[0];if(v[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],v.length>2&&(v[v.length-1]=v[0]),g){y.properties.feedbackFeature=B(y);const L=y.properties.smooth?yt(B(y)):y;ue(r,this._activeLayer.id,L)}else ue(r,this._activeLayer.id,y);this._updateVertexPoints()}}const n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0,a=((c=i==null?void 0:i.layer)==null?void 0:c.id)===this._vertexLayerId;this._setMapCursorStyle(a?"move":void 0)}_onMapMousedownEdit(e){var a,s;const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0;((a=i==null?void 0:i.layer)==null?void 0:a.id)===this._vertexLayerId?(this._dragIndex=((s=i==null?void 0:i.properties)==null?void 0:s.index)??null,this._setMapActionEvents(!1),this.emit("startEdit",ye(r,this._activeLayer.source))):this._dragIndex=null}_onMapMouseupEdit(){const{map:e}=this;this._dragIndex=null,this._setMapActionEvents(!0),this.emit("finishEdit",ye(e,this._activeLayer.source))}_onMapMouseoverEdit(){this.emit("editPointMouseover")}_onMapMouseoutEdit(){this.emit("editPointMouseout")}startDrag(){const{map:e}=this;this.stop(),this.toolMode="drag",e.on("mousemove",this._onMapMousemove),e.on("mousedown",this._onMapMousedown),e.on("mouseup",this._onMapMouseup)}stopDrag(){const{map:e}=this;e.off("mousemove",this._onMapMousemove),e.off("mousedown",this._onMapMousedown),e.off("mouseup",this._onMapMouseup),this._isDragging=!1,this._dragOrigin=null,this._setMapActionEvents(!0),this._setMapCursorStyle()}_onMapMousemoveDrag(e){var a;const{map:r}=this;if(this._isDragging&&this._dragOrigin&&this._activeLayer){const s=this._activeLayer.source,u=ye(r,s);if(!u||!("geometry"in u))return;const c=e.lngLat.lng-this._dragOrigin[0],l=e.lngLat.lat-this._dragOrigin[1];this._dragOrigin=[e.lngLat.lng,e.lngLat.lat];const{geometry:g}=u;if(u.geometry.type!=="GeometryCollection"&&g.type==="Polygon"){const m=u.geometry.coordinates[0].map(([v,L])=>[v+c,L+l]);u.geometry.coordinates[0]=m,ue(r,s,B(u));return}}const n=(a=r.queryRenderedFeatures(e.point))==null?void 0:a[0],i=n==null?void 0:n.layer;n&&i&>(i)?this._setMapCursorStyle("move"):this._setMapCursorStyle()}_onMapMousedownDrag(e){const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n==null?void 0:n[0];if(!i)return;const a=i.layer;gt(a)&&(this._isDragging=!0,this._dragOrigin=[e.lngLat.lng,e.lngLat.lat],this._activeLayer=a,this._setMapActionEvents(!1),this.emit("startDrag",ye(r,this._activeLayer.source)))}_onMapMouseupDrag(){const{map:e}=this;this._isDragging&&this.emit("finishDrag",ye(e,this._activeLayer.source)),this._isDragging=!1,this._dragOrigin=null,this._setMapActionEvents(!0)}_onMapClick_(e){switch(this.toolMode){case"draw":this._onMapClickDraw(e);break;case"edit":this._onMapClickEdit(e);break}}_onMapDblclick_(e){switch(this.toolMode){case"draw":this._onMapDblclickDraw(e);break}}_onMapMousemove_(e){switch(this.toolMode){case"draw":this._onMapMousemoveDraw(e);break;case"edit":this._onMapMousemoveEdit(e);break;case"drag":this._onMapMousemoveDrag(e);break}}_onMapMousedown_(e){switch(this.toolMode){case"draw":this._onMapMousedownDraw(e);break;case"edit":this._onMapMousedownEdit(e);break;case"drag":this._onMapMousedownDrag(e);break}}_onMapMouseup_(){switch(this.toolMode){case"draw":this._onMapMouseupDraw();break;case"edit":this._onMapMouseupEdit();break;case"drag":this._onMapMouseupDrag();break}}_onMapMouseover_(){switch(this.toolMode){case"draw":this._onMapMouseoverDraw();break;case"edit":this._onMapMouseoverEdit();break}}_onMapMouseout_(){switch(this.toolMode){case"draw":this._onMapMouseoutDraw();break;case"edit":this._onMapMouseoutEdit();break}}_setMapActionEvents(e){["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(n=>{e?this.map[n].enable():this.map[n].disable()})}_setMapCursorStyle(e){this.map.getCanvas().style.cursor=e??""}_clearMapEventListeners(){const{map:e}=this;e.off("click",this._onMapClick),e.off("dblclick",this._onMapDblclick),e.off("mousemove",this._onMapMousemove),e.off("mouseout",this._onMapMouseout),e.off("mouseover",this._onMapMouseover),e.off("mousedown",this._onMapMousedown),e.off("mouseup",this._onMapMouseup),e.off("mousedown",this._vertexLayerId,this._onMapMousedown),e.off("mouseup",this._vertexLayerId,this._onMapMouseup),e.on("mouseover",this._vertexLayerId,this._onMapMouseover),e.on("mouseout",this._vertexLayerId,this._onMapMouseout)}_addUUID(){this.uuid=Gr(),this.layerIds.push(this.uuid),this.sourceIds.push(this.uuid)}_clearJson(){this.saveFreePolygonPoint.length=0,this.pointJson.features=[],this.polygonJson.geometry.coordinates[0].length=0,this.polygonJson.properties={...this.options,layerId:this.uuid,sourceId:this.uuid},this.lineJson.geometry.coordinates.length=0,this.lineJson.properties={...this.options,layerId:this.uuid,sourceId:this.uuid}}stop(){this.stopDrag(),this.stopDrag(),this.stopEdit()}clearLayers(){this.layerIds.forEach(e=>{this.map.getLayer(e)&&this.map.removeLayer(e),this.map.getLayer(e+"outline")&&this.map.removeLayer(e+"outline"),this.map.getLayer(e+"point")&&this.map.removeLayer(e+"point"),this.map.getLayer(e+"text")&&this.map.removeLayer(e+"text")}),this.sourceIds.forEach(e=>{this.map.getSource(e)&&this.map.removeSource(e),this.map.getSource(e+"point")&&this.map.removeSource(e+"point"),this.map.getSource(e+"text")&&this.map.removeSource(e+"text")}),this.layerIds.length=0,this.sourceIds.length=0,this._removeVertexPoints(),this._removeFollowPoints()}setOptions(e){Object.assign(this.options,e)}getOptions(){return this.options}emit(e,r){const n=this.eventMap.get(e);n&&n.forEach(i=>i(r))}on(e,r){this.eventMap.has(e)||this.eventMap.set(e,new Set),this.eventMap.get(e).add(r)}off(e,r){var n;(n=this.eventMap.get(e))==null||n.delete(r)}}exports.DrawTool=Zr;exports.draw=$r;exports.measure=Tr;
|