gs-maplibre-draw 0.1.26 → 0.1.28
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 +66 -53
- package/dist/index.umd.cjs +1 -1
- package/dist/types/drawTool/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var mn=Object.defineProperty;var xn=(o,e,r)=>e in o?mn(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var B=(o,e,r)=>xn(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{abs:We,cos:be,sin:ze,acos:wn,atan2:Ze,sqrt:Pe,pow:me}=Math;function Ke(o){return o<0?-me(-o,1/3):me(o,1/3)}const xo=Math.PI,vt=2*xo,Le=xo/2,_n=1e-6,Ot=Number.MAX_SAFE_INTEGER||9007199254740991,It=Number.MIN_SAFE_INTEGER||-9007199254740991,Mn={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),Pe(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 s=e;if(n===0)return e[0].t=o,e[0];if(n===1){const u={x:i*s[0].x+o*s[1].x,y:i*s[0].y+o*s[1].y,t:o};return r&&(u.z=i*s[0].z+o*s[1].z),u}if(n<4){let u=i*i,c=o*o,l,v,h,g=0;n===2?(s=[s[0],s[1],s[2],Mn],l=u,v=i*o*2,h=c):n===3&&(l=u*i,v=u*o*3,h=i*c*3,g=o*c);const d={x:l*s[0].x+v*s[1].x+h*s[2].x+g*s[3].x,y:l*s[0].y+v*s[1].y+h*s[2].y+g*s[3].y,t:o};return r&&(d.z=l*s[0].z+v*s[1].z+h*s[2].z+g*s[3].z),d}const a=JSON.parse(JSON.stringify(e));for(;a.length>1;){for(let u=0;u<a.length-1;u++)a[u]={x:a[u].x+(a[u+1].x-a[u].x)*o,y:a[u].y+(a[u+1].y-a[u].y)*o},typeof a[u].z<"u"&&(a[u].z=a[u].z+(a[u+1].z-a[u].z)*o);a.splice(a.length-1,1)}return a[0].t=o,a[0]},computeWithRatios:function(o,e,r,n){const i=1-o,s=r,a=e;let u=s[0],c=s[1],l=s[2],v=s[3],h;if(u*=i,c*=o,a.length===2)return h=u+c,{x:(u*a[0].x+c*a[1].x)/h,y:(u*a[0].y+c*a[1].y)/h,z:n?(u*a[0].z+c*a[1].z)/h:!1,t:o};if(u*=i,c*=2*i,l*=o*o,a.length===3)return h=u+c+l,{x:(u*a[0].x+c*a[1].x+l*a[2].x)/h,y:(u*a[0].y+c*a[1].y+l*a[2].y)/h,z:n?(u*a[0].z+c*a[1].z+l*a[2].z)/h:!1,t:o};if(u*=i,c*=1.5*i,l*=3*i,v*=o*o*o,a.length===4)return h=u+c+l+v,{x:(u*a[0].x+c*a[1].x+l*a[2].x+v*a[3].x)/h,y:(u*a[0].y+c*a[1].y+l*a[2].y+v*a[3].y)/h,z:n?(u*a[0].z+c*a[1].z+l*a[2].z+v*a[3].z)/h:!1,t:o}},derive:function(o,e){const r=[];for(let n=o,i=n.length,s=i-1;i>1;i--,s--){const a=[];for(let u=0,c;u<s;u++)c={x:s*(n[u+1].x-n[u].x),y:s*(n[u+1].y-n[u].y)},e&&(c.z=s*(n[u+1].z-n[u].z)),a.push(c);r.push(a),n=a}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 We(o-e)<=(r||_n)},length:function(o){const r=S.Tvalues.length;let n=0;for(let i=0,s;i<r;i++)s=.5*S.Tvalues[i]+.5,n+=S.Cvalues[i]*S.arcfn(s,o);return .5*n},map:function(o,e,r,n,i){const s=r-e,a=i-n,u=o-e,c=u/s;return n+a*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,s=r.x-o.x,a=r.y-o.y,u=n*a-i*s,c=n*s+i*a;return Ze(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 Pe(r*r+n*n)},closest:function(o,e){let r=me(2,63),n,i;return o.forEach(function(s,a){i=S.dist(e,s),i<r&&(r=i,n=a)}),{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=me(o,e)+me(1-o,e),n=r-1;return We(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=me(1-o,e),n=me(o,e)+r;return r/n},lli8:function(o,e,r,n,i,s,a,u){const c=(o*n-e*r)*(i-a)-(o-r)*(i*u-s*a),l=(o*n-e*r)*(s-u)-(e-n)*(i*u-s*a),v=(o-r)*(s-u)-(e-n)*(i-a);return v==0?!1:{x:c/v,y:l/v}},lli4:function(o,e,r,n){const i=o.x,s=o.y,a=e.x,u=e.y,c=r.x,l=r.y,v=n.x,h=n.y;return S.lli8(i,s,a,u,c,l,v,h)},lli:function(o,e){return S.lli4(o,o.c,e,e.c)},makeline:function(o,e){return new Z(o.x,o.y,(o.x+e.x)/2,(o.y+e.y)/2,e.x,e.y)},findbbox:function(o){let e=Ot,r=Ot,n=It,i=It;return o.forEach(function(s){const a=s.bbox();e>a.x.min&&(e=a.x.min),r>a.y.min&&(r=a.y.min),n<a.x.max&&(n=a.x.max),i<a.y.max&&(i=a.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 s=[],a=[o.startcap,o.forward,o.back,o.endcap],u=[r.startcap,r.forward,r.back,r.endcap];return a.forEach(function(c){c.virtual||u.forEach(function(l){if(l.virtual)return;const v=c.intersects(l,i);v.length>0&&(v.c1=c,v.c2=l,v.s1=o,v.s2=r,s.push(v))})}),s},makeshape:function(o,e,r){const n=e.points.length,i=o.points.length,s=S.makeline(e.points[n-1],o.points[0]),a=S.makeline(o.points[i-1],e.points[0]),u={startcap:s,forward:o,back:e,endcap:a,bbox:S.findbbox([s,o,e,a])};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=Ot,i=It,s,a;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++)s=r[u],a=o.get(s),a[e]<n&&(n=a[e]),a[e]>i&&(i=a[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=-Ze(e.p2.y-n,e.p2.x-r),s=function(a){return{x:(a.x-r)*be(i)-(a.y-n)*ze(i),y:(a.x-r)*ze(i)+(a.y-n)*be(i)}};return o.map(s)},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,w=n[1].y,L=n[2].y,D=M-2*w+L;if(D!==0){const E=-Pe(w*w-M*L),I=-M+w,j=-(E+I)/D,T=-(-E+I)/D;return[j,T].filter(i)}else if(w!==L&&D===0)return[(2*w-L)/(2*w-2*L)].filter(i);return[]}const s=n[0].y,a=n[1].y,u=n[2].y,c=n[3].y;let l=-s+3*a-3*u+c,v=3*s-6*a+3*u,h=-3*s+3*a,g=s;if(S.approximately(l,0)){if(S.approximately(v,0))return S.approximately(h,0)?[]:[-g/h].filter(i);const M=Pe(h*h-4*v*g),w=2*v;return[(M-h)/w,(-h-M)/w].filter(i)}v/=l,h/=l,g/=l;const d=(3*h-v*v)/3,_=d/3,A=(2*v*v*v-9*v*h+27*g)/27,O=A/2,$=O*O+_*_*_;let f,y,p,m,b;if($<0){const M=-d/3,w=M*M*M,L=Pe(w),D=-A/(2*L),E=D<-1?-1:D>1?1:D,I=wn(E),j=Ke(L),T=2*j;return p=T*be(I/3)-v/3,m=T*be((I+vt)/3)-v/3,b=T*be((I+2*vt)/3)-v/3,[p,m,b].filter(i)}else{if($===0)return f=O<0?Ke(-O):-Ke(O),p=2*f-v/3,m=-f-v/3,[p,m].filter(i);{const M=Pe($);return f=Ke(-O+M),y=Ke(O+M),[f-y-v/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 s=-Pe(r*r-e*n),a=-e+r,u=-(s+a)/i,c=-(-s+a)/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 s,a,u,c,l=0,v=0;const h=S.compute(o,e),g=S.compute(o,r),d=h.x*h.x+h.y*h.y;if(n?(s=Pe(me(h.y*g.z-g.y*h.z,2)+me(h.z*g.x-g.z*h.x,2)+me(h.x*g.y-g.x*h.y,2)),a=me(d+h.z*h.z,3/2)):(s=h.x*g.y-h.y*g.x,a=me(d,3/2)),s===0||a===0)return{k:0,r:0};if(l=s/a,v=a/s,!i){const _=S.curvature(o-.001,e,r,n,!0).k,A=S.curvature(o+.001,e,r,n,!0).k;c=(A-l+(l-_))/2,u=(We(A-l)+We(l-_))/2}return{k:l,r:v,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,s=e[3].x*e[2].y,a=18*(-3*r+2*n+3*i-s),u=18*(3*r-n-3*i),c=18*(i-r);if(S.approximately(a,0)){if(!S.approximately(u,0)){let g=-c/u;if(0<=g&&g<=1)return[g]}return[]}const l=2*a;if(S.approximately(l,0))return[];const v=u*u-4*a*c;if(v<0)return[];const h=Math.sqrt(v);return[(h-u)/l,-(u+h)/l].filter(function(g){return 0<=g&&g<=1})},bboxoverlap:function(o,e){const r=["x","y"],n=r.length;for(let i=0,s,a,u,c;i<n;i++)if(s=r[i],a=o[s].mid,u=e[s].mid,c=(o[s].size+e[s].size)/2,We(a-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(),s=1e5,a=r||.5;if(n.x.size+n.y.size<a&&i.x.size+i.y.size<a)return[(s*(o._t1+o._t2)/2|0)/s+"/"+(s*(e._t1+e._t2)/2|0)/s];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(h){return S.bboxoverlap(h.left.bbox(),h.right.bbox())});let v=[];return l.length===0||(l.forEach(function(h){v=v.concat(S.pairiteration(h.left,h.right,a))}),v=v.filter(function(h,g){return v.indexOf(h)===g})),v},getccenter:function(o,e,r){const n=e.x-o.x,i=e.y-o.y,s=r.x-e.x,a=r.y-e.y,u=n*be(Le)-i*ze(Le),c=n*ze(Le)+i*be(Le),l=s*be(Le)-a*ze(Le),v=s*ze(Le)+a*be(Le),h=(o.x+e.x)/2,g=(o.y+e.y)/2,d=(e.x+r.x)/2,_=(e.y+r.y)/2,A=h+u,O=g+c,$=d+l,f=_+v,y=S.lli8(h,g,A,O,d,_,$,f),p=S.dist(y,o);let m=Ze(o.y-y.y,o.x-y.x),b=Ze(e.y-y.y,e.x-y.x),M=Ze(r.y-y.y,r.x-y.x),w;return m<M?((m>b||b>M)&&(m+=vt),m>M&&(w=M,M=m,m=w)):M<b&&b<m?(w=M,M=m,m=w):M+=vt,y.s=m,y.e=M,y.r=p,y},numberSort:function(o,e){return o-e}};class ot{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 ot(r)}}const{abs:Qe,min:_r,max:Mr,cos:bn,sin:Sn,acos:Pn,sqrt:et}=Math,Ln=Math.PI;class Z{constructor(e){let r=e&&e.forEach?e:Array.from(arguments).slice(),n=!1;if(typeof r[0]=="object"){n=r.length;const d=[];r.forEach(function(_){["x","y","z"].forEach(function(A){typeof _[A]<"u"&&d.push(_[A])})}),r=d}let i=!1;const s=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(s!==6&&s!==8&&s!==9&&s!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const a=this._3d=!i&&(s===9||s===12)||e&&e[0]&&typeof e[0].z<"u",u=this.points=[];for(let d=0,_=a?3:2;d<s;d+=_){var c={x:r[d],y:r[d+1]};a&&(c.z=r[d+2]),u.push(c)}const l=this.order=u.length-1,v=this.dims=["x","y"];a&&v.push("z"),this.dimlen=v.length;const h=S.align(u,{p1:u[0],p2:u[l]}),g=S.dist(u[0],u[l]);this._linear=h.reduce((d,_)=>d+Qe(_.y),0)<g/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 Z(r,r,n);if(i===1)return new Z(e,r,r);const s=Z.getABC(2,e,r,n,i);return new Z(e,s.A,n)}static cubicFromPoints(e,r,n,i,s){typeof i>"u"&&(i=.5);const a=Z.getABC(3,e,r,n,i);typeof s>"u"&&(s=S.dist(r,a.C));const u=s*(1-i)/i,c=S.dist(e,n),l=(n.x-e.x)/c,v=(n.y-e.y)/c,h=s*l,g=s*v,d=u*l,_=u*v,A={x:r.x-h,y:r.y-g},O={x:r.x+d,y:r.y+_},$=a.A,f={x:$.x+(A.x-$.x)/(1-i),y:$.y+(A.y-$.y)/(1-i)},y={x:$.x+(O.x-$.x)/i,y:$.y+(O.y-$.y)/i},p={x:e.x+(f.x-e.x)/i,y:e.y+(f.y-e.y)/i},m={x:n.x+(y.x-n.x)/(1-i),y:n.y+(y.y-n.y)/(1-i)};return new Z(e,p,m,n)}static getUtils(){return S}getUtils(){return Z.getUtils()}static get PolyBezier(){return ot}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 s=1,a=e.length;s<a;s++)i.push(e[s].x),i.push(e[s].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,s=.5){const a=S.projectionratio(s,e),u=1-a,c={x:a*r.x+u*i.x,y:a*r.y+u*i.y},l=S.abcratio(s,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 Z.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 s=0,a,u=0;s<n.length;s++)a=n[s],S.dist(a,e)<r&&(i.push(a),u+=s/n.length);return i.length?t/=i.length:!1}project(e){const r=this.getLUT(),n=r.length-1,i=S.closest(r,e),s=i.mpos,a=(s-1)/n,u=(s+1)/n,c=.1/n;let l=i.mdist,v=a,h=v,g;l+=1;for(let d;v<u+c;v+=c)g=this.compute(v),d=S.dist(e,g),d<l&&(l=d,h=v);return h=h<0?0:h>1?1:h,g=this.compute(h),g.t=h,g.d=l,g}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,s,a;i<n;i++)s=e[i],a=e[i-1],r[i]={x:(n-i)/n*s.x+i/n*a.x,y:(n-i)/n*s.y+i/n*a.y};return r[n]=e[n-1],new Z(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 Z(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=et(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=et(r.x*r.x+r.y*r.y+r.z*r.z),s=et(n.x*n.x+n.y*n.y+n.z*n.z);r.x/=i,r.y/=i,r.z/=i,n.x/=s,n.y/=s,n.z/=s;const a={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=et(a.x*a.x+a.y*a.y+a.z*a.z);a.x/=u,a.y/=u,a.z/=u;const c=[a.x*a.x,a.x*a.y-a.z,a.x*a.z+a.y,a.x*a.y+a.z,a.y*a.y,a.y*a.z-a.x,a.x*a.z-a.y,a.y*a.z+a.x,a.z*a.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=[],s=0;for(i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],this.order===3&&(i[s++]=r[3]);r.length>1;){n=[];for(let a=0,u,c=r.length-1;a<c;a++)u=S.lerp(e,r[a],r[a+1]),i[s++]=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 Z([n[0],n[3],n[5]]):new Z([n[0],n[4],n[7],n[9]]),right:this.order===2?new Z([n[5],n[4],n[2]]):new Z([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(a){return a[n]},s=this.dpoints[0].map(i);e[n]=S.droots(s),this.order===3&&(s=this.dpoints[1].map(i),e[n]=e[n].concat(S.droots(s))),e[n]=e[n].filter(function(a){return a>=0&&a<=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),s={c:n,n:i,x:n.x+i.x*r,y:n.y+i.y*r};return this._3d&&(s.z=n.z+i.z*r),s}if(this._linear){const n=this.normal(0),i=this.points.map(function(s){const a={x:s.x+e*n.x,y:s.y+e*n.y};return s.z&&n.z&&(a.z=s.z+e*n.z),a});return[new Z(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]),s=S.angle(this.points[0],this.points[3],this.points[2]);if(i>0&&s<0||i<0&&s>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(Pn(n))<Ln/3}reduce(){let e,r=0,n=0,i=.01,s,a=[],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],s=this.split(r,n),s._t1=r,s._t2=n,a.push(s),r=n;return a.forEach(function(l){for(r=0,n=0;n<=1;)for(n=r+i;n<=1+i;n+=i)if(s=l.split(r,n),!s.simple()){if(n-=i,Qe(r-n)<i)return[];s=l.split(r,n),s._t1=S.map(r,0,1,l._t1,l._t2),s._t2=S.map(n,0,1,l._t1,l._t2),u.push(s),r=n;break}r<1&&(s=l.split(r,1),s._t1=S.map(r,0,1,l._t1,l._t2),s._t2=l._t2,u.push(s))}),u}translate(e,r,n){n=typeof n=="number"?n:r;const i=this.order;let s=this.points.map((a,u)=>(1-u/i)*r+u/i*n);return new Z(this.points.map((a,u)=>({x:a.x+e.x*s[u],y:a.y+e.y*s[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,s=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):e,n?n(1):e);const a=n?n(0):e,u=n?n(1):e,c=[this.offset(0,10),this.offset(1,10)],l=[],v=S.lli4(c[0],c[0].c,c[1],c[1].c);if(!v)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(h){const g=l[h*r]=S.copy(s[h*r]);g.x+=(h?u:a)*c[h].n.x,g.y+=(h?u:a)*c[h].n.y}),n?([0,1].forEach(function(h){if(!(r===2&&h)){var g=s[h+1],d={x:g.x-v.x,y:g.y-v.y},_=n?n((h+1)/r):e;n&&!i&&(_=-_);var A=et(d.x*d.x+d.y*d.y);d.x/=A,d.y/=A,l[h+1]={x:g.x+_*d.x,y:g.y+_*d.y}}}),new Z(l)):([0,1].forEach(h=>{if(r===2&&h)return;const g=l[h*r],d=this.derivative(h),_={x:g.x+d.x,y:g.y+d.y};l[h+1]=S.lli4(g,_,v,s[h+1])}),new Z(l))}outline(e,r,n,i){if(r=r===void 0?e:r,this._linear){const m=this.normal(0),b=this.points[0],M=this.points[this.points.length-1];let w,L,D;n===void 0&&(n=e,i=r),w={x:b.x+m.x*e,y:b.y+m.y*e},D={x:M.x+m.x*n,y:M.y+m.y*n},L={x:(w.x+D.x)/2,y:(w.y+D.y)/2};const E=[w,L,D];w={x:b.x-m.x*r,y:b.y-m.y*r},D={x:M.x-m.x*i,y:M.y-m.y*i},L={x:(w.x+D.x)/2,y:(w.y+D.y)/2};const I=[D,L,w],j=S.makeline(I[2],E[0]),T=S.makeline(E[2],I[0]),ce=[j,new Z(E),T,new Z(I)];return new ot(ce)}const s=this.reduce(),a=s.length,u=[];let c=[],l,v=0,h=this.length();const g=typeof n<"u"&&typeof i<"u";function d(m,b,M,w,L){return function(D){const E=w/M,I=(w+L)/M,j=b-m;return S.map(D,0,1,m+E*j,m+I*j)}}s.forEach(function(m){const b=m.length();g?(u.push(m.scale(d(e,n,h,v,b))),c.push(m.scale(d(-r,-i,h,v,b)))):(u.push(m.scale(e)),c.push(m.scale(-r))),v+=b}),c=c.map(function(m){return l=m.points,l[3]?m.points=[l[3],l[2],l[1],l[0]]:m.points=[l[2],l[1],l[0]],m}).reverse();const _=u[0].points[0],A=u[a-1].points[u[a-1].points.length-1],O=c[a-1].points[c[a-1].points.length-1],$=c[0].points[0],f=S.makeline(O,_),y=S.makeline(A,$),p=[f].concat(u).concat([y]).concat(c);return new ot(p)}outlineshapes(e,r,n){r=r||e;const i=this.outline(e,r).curves,s=[];for(let a=1,u=i.length;a<u/2;a++){const c=S.makeshape(i[a],i[u-a],n);c.startcap.virtual=a>1,c.endcap.virtual=a<u/2-1,s.push(c)}return s}intersects(e,r){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof Z&&(e=e.reduce()),this.curveintersects(this.reduce(),e,r)):this.selfintersects(r)}lineIntersects(e){const r=_r(e.p1.x,e.p2.x),n=_r(e.p1.y,e.p2.y),i=Mr(e.p1.x,e.p2.x),s=Mr(e.p1.y,e.p2.y);return S.roots(this.points,e).filter(a=>{var u=this.get(a);return S.between(u.x,r,i)&&S.between(u.y,n,s)})}selfintersects(e){const r=this.reduce(),n=r.length-2,i=[];for(let s=0,a,u,c;s<n;s++)u=r.slice(s,s+1),c=r.slice(s+2),a=this.curveintersects(u,c,e),i.push(...a);return i}curveintersects(e,r,n){const i=[];e.forEach(function(a){r.forEach(function(u){a.overlaps(u)&&i.push({left:a,right:u})})});let s=[];return i.forEach(function(a){const u=S.pairiteration(a.left,a.right,n);u.length>0&&(s=s.concat(u))}),s}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,r,n,i){const s=(i-n)/4,a=this.get(n+s),u=this.get(i-s),c=S.dist(e,r),l=S.dist(e,a),v=S.dist(e,u);return Qe(l-c)+Qe(v-c)}_iterate(e,r){let n=0,i=1,s;do{s=0,i=1;let a=this.get(n),u,c,l,v,h=!1,g=!1,d,_=i,A=1;do if(g=h,v=l,_=(n+i)/2,u=this.get(_),c=this.get(i),l=S.getccenter(a,u,c),l.interval={start:n,end:i},h=this._error(l,a,n,i)<=e,d=g&&!h,d||(A=i),h){if(i>=1){if(l.interval.end=A=1,v=l,i>1){let $={x:l.x+l.r*bn(l.e),y:l.y+l.r*Sn(l.e)};l.e+=S.angle({x:l.x,y:l.y},$,this.get(1))}break}i=i+(i-n)/2}else i=_;while(!d&&s++<100);if(s>=100)break;v=v||l,r.push(v),n=A}while(i<1);return r}}var ge=63710088e-1,wo={centimeters:ge*100,centimetres:ge*100,degrees:ge/111325,feet:ge*3.28084,inches:ge*39.37,kilometers:ge/1e3,kilometres:ge/1e3,meters:ge,metres:ge,miles:ge/1609.344,millimeters:ge*1e3,millimetres:ge*1e3,nauticalmiles:ge/1852,radians:1,yards:ge*1.0936};function kt(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 Se(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(!br(o[0])||!br(o[1]))throw new Error("coordinates must contain numbers");var n={type:"Point",coordinates:o};return kt(n,e,r)}function Ue(o,e,r){r===void 0&&(r={});for(var n=0,i=o;n<i.length;n++){var s=i[n];if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<s[s.length-1].length;a++)if(s[s.length-1][a]!==s[0][a])throw new Error("First and last Position are not equivalent.")}var u={type:"Polygon",coordinates:o};return kt(u,e,r)}function Xe(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 kt(n,e,r)}function mt(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 An(o,e){e===void 0&&(e="kilometers");var r=wo[e];if(!r)throw new Error(e+" units is invalid");return o*r}function kn(o,e){e===void 0&&(e="kilometers");var r=wo[e];if(!r)throw new Error(e+" units is invalid");return o/r}function Kt(o){var e=o%(2*Math.PI);return e*180/Math.PI}function we(o){var e=o%360;return e*Math.PI/180}function br(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function Dn(o){return!!o&&o.constructor===Object}function ct(o,e,r){if(o!==null)for(var n,i,s,a,u,c,l,v=0,h=0,g,d=o.type,_=d==="FeatureCollection",A=d==="Feature",O=_?o.features.length:1,$=0;$<O;$++){l=_?o.features[$].geometry:A?o.geometry:o,g=l?l.type==="GeometryCollection":!1,u=g?l.geometries.length:1;for(var f=0;f<u;f++){var y=0,p=0;if(a=g?l.geometries[f]:l,a!==null){c=a.coordinates;var m=a.type;switch(v=r&&(m==="Polygon"||m==="MultiPolygon")?1:0,m){case null:break;case"Point":if(e(c,h,$,y,p)===!1)return!1;h++,y++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(e(c[n],h,$,y,p)===!1)return!1;h++,m==="MultiPoint"&&y++}m==="LineString"&&y++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-v;i++){if(e(c[n][i],h,$,y,p)===!1)return!1;h++}m==="MultiLineString"&&y++,m==="Polygon"&&p++}m==="Polygon"&&y++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(p=0,i=0;i<c[n].length;i++){for(s=0;s<c[n][i].length-v;s++){if(e(c[n][i][s],h,$,y,p)===!1)return!1;h++}p++}y++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(ct(a.geometries[n],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function _o(o,e){var r,n,i,s,a,u,c,l,v,h,g=0,d=o.type==="FeatureCollection",_=o.type==="Feature",A=d?o.features.length:1;for(r=0;r<A;r++){for(u=d?o.features[r].geometry:_?o.geometry:o,l=d?o.features[r].properties:_?o.properties:{},v=d?o.features[r].bbox:_?o.bbox:void 0,h=d?o.features[r].id:_?o.id:void 0,c=u?u.type==="GeometryCollection":!1,a=c?u.geometries.length:1,i=0;i<a;i++){if(s=c?u.geometries[i]:u,s===null){if(e(null,g,l,v,h)===!1)return!1;continue}switch(s.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(s,g,l,v,h)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<s.geometries.length;n++)if(e(s.geometries[n],g,l,v,h)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}g++}}function Fn(o,e,r){var n=r;return _o(o,function(i,s,a,u,c){n=e(n,i,s,a,u,c)}),n}function Qt(o){var e=[1/0,1/0,-1/0,-1/0];return ct(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}Qt.default=Qt;function Ye(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 _t(o){if(Array.isArray(o))return o;if(o.type==="Feature"){if(o.geometry!==null)return o.geometry.coordinates}else if(o.coordinates)return o.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function er(o){return o.type==="Feature"?o.geometry:o}function Mo(o,e){return o.type==="FeatureCollection"?"FeatureCollection":o.type==="GeometryCollection"?"GeometryCollection":o.type==="Feature"&&o.geometry!==null?o.geometry.type:o.type}var bo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function So(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function En(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 lr={exports:{}},Po={exports:{}};(function(o,e){(function(r,n){o.exports=n()})(bo,function(){function r(f,y,p,m,b){(function M(w,L,D,E,I){for(;E>D;){if(E-D>600){var j=E-D+1,T=L-D+1,ce=Math.log(j),K=.5*Math.exp(2*ce/3),ee=.5*Math.sqrt(ce*K*(j-K)/j)*(T-j/2<0?-1:1),V=Math.max(D,Math.floor(L-T*K/j+ee)),le=Math.min(E,Math.floor(L+(j-T)*K/j+ee));M(w,L,V,le,I)}var F=w[L],x=D,k=E;for(n(w,D,L),I(w[E],F)>0&&n(w,D,E);x<k;){for(n(w,x,k),x++,k--;I(w[x],F)<0;)x++;for(;I(w[k],F)>0;)k--}I(w[D],F)===0?n(w,D,k):n(w,++k,E),k<=L&&(D=k+1),L<=k&&(E=k-1)}})(f,y,p||0,m||f.length-1,b||i)}function n(f,y,p){var m=f[y];f[y]=f[p],f[p]=m}function i(f,y){return f<y?-1:f>y?1:0}var s=function(f){f===void 0&&(f=9),this._maxEntries=Math.max(4,f),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function a(f,y,p){if(!p)return y.indexOf(f);for(var m=0;m<y.length;m++)if(p(f,y[m]))return m;return-1}function u(f,y){c(f,0,f.children.length,y,f)}function c(f,y,p,m,b){b||(b=O(null)),b.minX=1/0,b.minY=1/0,b.maxX=-1/0,b.maxY=-1/0;for(var M=y;M<p;M++){var w=f.children[M];l(b,f.leaf?m(w):w)}return b}function l(f,y){return f.minX=Math.min(f.minX,y.minX),f.minY=Math.min(f.minY,y.minY),f.maxX=Math.max(f.maxX,y.maxX),f.maxY=Math.max(f.maxY,y.maxY),f}function v(f,y){return f.minX-y.minX}function h(f,y){return f.minY-y.minY}function g(f){return(f.maxX-f.minX)*(f.maxY-f.minY)}function d(f){return f.maxX-f.minX+(f.maxY-f.minY)}function _(f,y){return f.minX<=y.minX&&f.minY<=y.minY&&y.maxX<=f.maxX&&y.maxY<=f.maxY}function A(f,y){return y.minX<=f.maxX&&y.minY<=f.maxY&&y.maxX>=f.minX&&y.maxY>=f.minY}function O(f){return{children:f,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function $(f,y,p,m,b){for(var M=[y,p];M.length;)if(!((p=M.pop())-(y=M.pop())<=m)){var w=y+Math.ceil((p-y)/m/2)*m;r(f,w,y,p,b),M.push(y,w,w,p)}}return s.prototype.all=function(){return this._all(this.data,[])},s.prototype.search=function(f){var y=this.data,p=[];if(!A(f,y))return p;for(var m=this.toBBox,b=[];y;){for(var M=0;M<y.children.length;M++){var w=y.children[M],L=y.leaf?m(w):w;A(f,L)&&(y.leaf?p.push(w):_(f,L)?this._all(w,p):b.push(w))}y=b.pop()}return p},s.prototype.collides=function(f){var y=this.data;if(!A(f,y))return!1;for(var p=[];y;){for(var m=0;m<y.children.length;m++){var b=y.children[m],M=y.leaf?this.toBBox(b):b;if(A(f,M)){if(y.leaf||_(f,M))return!0;p.push(b)}}y=p.pop()}return!1},s.prototype.load=function(f){if(!f||!f.length)return this;if(f.length<this._minEntries){for(var y=0;y<f.length;y++)this.insert(f[y]);return this}var p=this._build(f.slice(),0,f.length-1,0);if(this.data.children.length)if(this.data.height===p.height)this._splitRoot(this.data,p);else{if(this.data.height<p.height){var m=this.data;this.data=p,p=m}this._insert(p,this.data.height-p.height-1,!0)}else this.data=p;return this},s.prototype.insert=function(f){return f&&this._insert(f,this.data.height-1),this},s.prototype.clear=function(){return this.data=O([]),this},s.prototype.remove=function(f,y){if(!f)return this;for(var p,m,b,M=this.data,w=this.toBBox(f),L=[],D=[];M||L.length;){if(M||(M=L.pop(),m=L[L.length-1],p=D.pop(),b=!0),M.leaf){var E=a(f,M.children,y);if(E!==-1)return M.children.splice(E,1),L.push(M),this._condense(L),this}b||M.leaf||!_(M,w)?m?(p++,M=m.children[p],b=!1):M=null:(L.push(M),D.push(p),p=0,m=M,M=M.children[0])}return this},s.prototype.toBBox=function(f){return f},s.prototype.compareMinX=function(f,y){return f.minX-y.minX},s.prototype.compareMinY=function(f,y){return f.minY-y.minY},s.prototype.toJSON=function(){return this.data},s.prototype.fromJSON=function(f){return this.data=f,this},s.prototype._all=function(f,y){for(var p=[];f;)f.leaf?y.push.apply(y,f.children):p.push.apply(p,f.children),f=p.pop();return y},s.prototype._build=function(f,y,p,m){var b,M=p-y+1,w=this._maxEntries;if(M<=w)return u(b=O(f.slice(y,p+1)),this.toBBox),b;m||(m=Math.ceil(Math.log(M)/Math.log(w)),w=Math.ceil(M/Math.pow(w,m-1))),(b=O([])).leaf=!1,b.height=m;var L=Math.ceil(M/w),D=L*Math.ceil(Math.sqrt(w));$(f,y,p,D,this.compareMinX);for(var E=y;E<=p;E+=D){var I=Math.min(E+D-1,p);$(f,E,I,L,this.compareMinY);for(var j=E;j<=I;j+=L){var T=Math.min(j+L-1,I);b.children.push(this._build(f,j,T,m-1))}}return u(b,this.toBBox),b},s.prototype._chooseSubtree=function(f,y,p,m){for(;m.push(y),!y.leaf&&m.length-1!==p;){for(var b=1/0,M=1/0,w=void 0,L=0;L<y.children.length;L++){var D=y.children[L],E=g(D),I=(j=f,T=D,(Math.max(T.maxX,j.maxX)-Math.min(T.minX,j.minX))*(Math.max(T.maxY,j.maxY)-Math.min(T.minY,j.minY))-E);I<M?(M=I,b=E<b?E:b,w=D):I===M&&E<b&&(b=E,w=D)}y=w||y.children[0]}var j,T;return y},s.prototype._insert=function(f,y,p){var m=p?f:this.toBBox(f),b=[],M=this._chooseSubtree(m,this.data,y,b);for(M.children.push(f),l(M,m);y>=0&&b[y].children.length>this._maxEntries;)this._split(b,y),y--;this._adjustParentBBoxes(m,b,y)},s.prototype._split=function(f,y){var p=f[y],m=p.children.length,b=this._minEntries;this._chooseSplitAxis(p,b,m);var M=this._chooseSplitIndex(p,b,m),w=O(p.children.splice(M,p.children.length-M));w.height=p.height,w.leaf=p.leaf,u(p,this.toBBox),u(w,this.toBBox),y?f[y-1].children.push(w):this._splitRoot(p,w)},s.prototype._splitRoot=function(f,y){this.data=O([f,y]),this.data.height=f.height+1,this.data.leaf=!1,u(this.data,this.toBBox)},s.prototype._chooseSplitIndex=function(f,y,p){for(var m,b,M,w,L,D,E,I=1/0,j=1/0,T=y;T<=p-y;T++){var ce=c(f,0,T,this.toBBox),K=c(f,T,p,this.toBBox),ee=(b=ce,M=K,w=void 0,L=void 0,D=void 0,E=void 0,w=Math.max(b.minX,M.minX),L=Math.max(b.minY,M.minY),D=Math.min(b.maxX,M.maxX),E=Math.min(b.maxY,M.maxY),Math.max(0,D-w)*Math.max(0,E-L)),V=g(ce)+g(K);ee<I?(I=ee,m=T,j=V<j?V:j):ee===I&&V<j&&(j=V,m=T)}return m||p-y},s.prototype._chooseSplitAxis=function(f,y,p){var m=f.leaf?this.compareMinX:v,b=f.leaf?this.compareMinY:h;this._allDistMargin(f,y,p,m)<this._allDistMargin(f,y,p,b)&&f.children.sort(m)},s.prototype._allDistMargin=function(f,y,p,m){f.children.sort(m);for(var b=this.toBBox,M=c(f,0,y,b),w=c(f,p-y,p,b),L=d(M)+d(w),D=y;D<p-y;D++){var E=f.children[D];l(M,f.leaf?b(E):E),L+=d(M)}for(var I=p-y-1;I>=y;I--){var j=f.children[I];l(w,f.leaf?b(j):j),L+=d(w)}return L},s.prototype._adjustParentBBoxes=function(f,y,p){for(var m=p;m>=0;m--)l(y[m],f)},s.prototype._condense=function(f){for(var y=f.length-1,p=void 0;y>=0;y--)f[y].children.length===0?y>0?(p=f[y-1].children).splice(p.indexOf(f[y]),1):this.clear():u(f[y],this.toBBox)},s})})(Po);var $n=Po.exports;class On{constructor(e=[],r=In){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 s=e-1>>1,a=r[s];if(n(i,a)>=0)break;r[e]=a,e=s}r[e]=i}_down(e){const{data:r,compare:n}=this,i=this.length>>1,s=r[e];for(;e<i;){let a=(e<<1)+1,u=r[a];const c=a+1;if(c<this.length&&n(r[c],u)<0&&(a=c,u=r[c]),n(u,s)>=0)break;r[e]=u,e=a}r[e]=s}}function In(o,e){return o<e?-1:o>e?1:0}const zn=Object.freeze(Object.defineProperty({__proto__:null,default:On},Symbol.toStringTag,{value:"Module"})),Cn=En(zn);var Dt={exports:{}},Rn=function(e,r,n,i){var s=e[0],a=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=(i-n)/2,l=0,v=c-1;l<c;v=l++){var h=r[n+l*2+0],g=r[n+l*2+1],d=r[n+v*2+0],_=r[n+v*2+1],A=g>a!=_>a&&s<(d-h)*(a-g)/(_-g)+h;A&&(u=!u)}return u},jn=function(e,r,n,i){var s=e[0],a=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=i-n,l=0,v=c-1;l<c;v=l++){var h=r[l+n][0],g=r[l+n][1],d=r[v+n][0],_=r[v+n][1],A=g>a!=_>a&&s<(d-h)*(a-g)/(_-g)+h;A&&(u=!u)}return u},Lo=Rn,Ao=jn;Dt.exports=function(e,r,n,i){return r.length>0&&Array.isArray(r[0])?Ao(e,r,n,i):Lo(e,r,n,i)};Dt.exports.nested=Ao;Dt.exports.flat=Lo;var Jn=Dt.exports,tr={exports:{}};(function(o,e){(function(r,n){n(e)})(bo,function(r){const i=33306690738754706e-32;function s(A,O,$,f,y){let p,m,b,M,w=O[0],L=f[0],D=0,E=0;L>w==L>-w?(p=w,w=O[++D]):(p=L,L=f[++E]);let I=0;if(D<A&&E<$)for(L>w==L>-w?(b=p-((m=w+p)-w),w=O[++D]):(b=p-((m=L+p)-L),L=f[++E]),p=m,b!==0&&(y[I++]=b);D<A&&E<$;)L>w==L>-w?(b=p-((m=p+w)-(M=m-p))+(w-M),w=O[++D]):(b=p-((m=p+L)-(M=m-p))+(L-M),L=f[++E]),p=m,b!==0&&(y[I++]=b);for(;D<A;)b=p-((m=p+w)-(M=m-p))+(w-M),w=O[++D],p=m,b!==0&&(y[I++]=b);for(;E<$;)b=p-((m=p+L)-(M=m-p))+(L-M),L=f[++E],p=m,b!==0&&(y[I++]=b);return p===0&&I!==0||(y[I++]=p),I}function a(A){return new Float64Array(A)}const u=33306690738754716e-32,c=22204460492503146e-32,l=11093356479670487e-47,v=a(4),h=a(8),g=a(12),d=a(16),_=a(4);r.orient2d=function(A,O,$,f,y,p){const m=(O-p)*($-y),b=(A-y)*(f-p),M=m-b;if(m===0||b===0||m>0!=b>0)return M;const w=Math.abs(m+b);return Math.abs(M)>=u*w?M:-function(L,D,E,I,j,T,ce){let K,ee,V,le,F,x,k,C,N,W,J,q,G,H,oe,te,ne,Q;const he=L-j,ie=E-j,re=D-T,de=I-T;F=(oe=(C=he-(k=(x=134217729*he)-(x-he)))*(W=de-(N=(x=134217729*de)-(x-de)))-((H=he*de)-k*N-C*N-k*W))-(J=oe-(ne=(C=re-(k=(x=134217729*re)-(x-re)))*(W=ie-(N=(x=134217729*ie)-(x-ie)))-((te=re*ie)-k*N-C*N-k*W))),v[0]=oe-(J+F)+(F-ne),F=(G=H-((q=H+J)-(F=q-H))+(J-F))-(J=G-te),v[1]=G-(J+F)+(F-te),F=(Q=q+J)-q,v[2]=q-(Q-F)+(J-F),v[3]=Q;let _e=function(He,Oe){let dt=Oe[0];for(let Ie=1;Ie<He;Ie++)dt+=Oe[Ie];return dt}(4,v),ke=c*ce;if(_e>=ke||-_e>=ke||(K=L-(he+(F=L-he))+(F-j),V=E-(ie+(F=E-ie))+(F-j),ee=D-(re+(F=D-re))+(F-T),le=I-(de+(F=I-de))+(F-T),K===0&&ee===0&&V===0&&le===0)||(ke=l*ce+i*Math.abs(_e),(_e+=he*le+de*K-(re*V+ie*ee))>=ke||-_e>=ke))return _e;F=(oe=(C=K-(k=(x=134217729*K)-(x-K)))*(W=de-(N=(x=134217729*de)-(x-de)))-((H=K*de)-k*N-C*N-k*W))-(J=oe-(ne=(C=ee-(k=(x=134217729*ee)-(x-ee)))*(W=ie-(N=(x=134217729*ie)-(x-ie)))-((te=ee*ie)-k*N-C*N-k*W))),_[0]=oe-(J+F)+(F-ne),F=(G=H-((q=H+J)-(F=q-H))+(J-F))-(J=G-te),_[1]=G-(J+F)+(F-te),F=(Q=q+J)-q,_[2]=q-(Q-F)+(J-F),_[3]=Q;const pt=s(4,v,4,_,h);F=(oe=(C=he-(k=(x=134217729*he)-(x-he)))*(W=le-(N=(x=134217729*le)-(x-le)))-((H=he*le)-k*N-C*N-k*W))-(J=oe-(ne=(C=re-(k=(x=134217729*re)-(x-re)))*(W=V-(N=(x=134217729*V)-(x-V)))-((te=re*V)-k*N-C*N-k*W))),_[0]=oe-(J+F)+(F-ne),F=(G=H-((q=H+J)-(F=q-H))+(J-F))-(J=G-te),_[1]=G-(J+F)+(F-te),F=(Q=q+J)-q,_[2]=q-(Q-F)+(J-F),_[3]=Q;const $t=s(pt,h,4,_,g);F=(oe=(C=K-(k=(x=134217729*K)-(x-K)))*(W=le-(N=(x=134217729*le)-(x-le)))-((H=K*le)-k*N-C*N-k*W))-(J=oe-(ne=(C=ee-(k=(x=134217729*ee)-(x-ee)))*(W=V-(N=(x=134217729*V)-(x-V)))-((te=ee*V)-k*N-C*N-k*W))),_[0]=oe-(J+F)+(F-ne),F=(G=H-((q=H+J)-(F=q-H))+(J-F))-(J=G-te),_[1]=G-(J+F)+(F-te),F=(Q=q+J)-q,_[2]=q-(Q-F)+(J-F),_[3]=Q;const $e=s($t,g,4,_,d);return d[$e-1]}(A,O,$,f,y,p,w)},r.orient2dfast=function(A,O,$,f,y,p){return(O-p)*($-y)-(A-y)*(f-p)},Object.defineProperty(r,"__esModule",{value:!0})})})(tr,tr.exports);var Bn=tr.exports,Sr=$n,Mt=Cn,Nn=Jn,Tn=Bn.orient2d;Mt.default&&(Mt=Mt.default);lr.exports=ko;lr.exports.default=ko;function ko(o,e,r){e=Math.max(0,e===void 0?2:e),r=r||0;var n=qn(o),i=new Sr(16);i.toBBox=function(f){return{minX:f[0],minY:f[1],maxX:f[0],maxY:f[1]}},i.compareMinX=function(f,y){return f[0]-y[0]},i.compareMinY=function(f,y){return f[1]-y[1]},i.load(o);for(var s=[],a=0,u;a<n.length;a++){var c=n[a];i.remove(c),u=Ar(c,u),s.push(u)}var l=new Sr(16);for(a=0;a<s.length;a++)l.insert(zt(s[a]));for(var v=e*e,h=r*r;s.length;){var g=s.shift(),d=g.p,_=g.next.p,A=Ct(d,_);if(!(A<h)){var O=A/v;c=Un(i,g.prev.p,d,_,g.next.next.p,O,l),c&&Math.min(Ct(c,d),Ct(c,_))<=O&&(s.push(g),s.push(Ar(c,g)),i.remove(c),l.remove(g),l.insert(zt(g)),l.insert(zt(g.next)))}}g=u;var $=[];do $.push(g.p),g=g.next;while(g!==u);return $.push(g.p),$}function Un(o,e,r,n,i,s,a){for(var u=new Mt([],Xn),c=o.data;c;){for(var l=0;l<c.children.length;l++){var v=c.children[l],h=c.leaf?Rt(v,r,n):Yn(r,n,v);h>s||u.push({node:v,dist:h})}for(;u.length&&!u.peek().node.children;){var g=u.pop(),d=g.node,_=Rt(d,e,r),A=Rt(d,n,i);if(g.dist<_&&g.dist<A&&Lr(r,d,a)&&Lr(n,d,a))return d}c=u.pop(),c&&(c=c.node)}return null}function Xn(o,e){return o.dist-e.dist}function Yn(o,e,r){if(Pr(o,r)||Pr(e,r))return 0;var n=xt(o[0],o[1],e[0],e[1],r.minX,r.minY,r.maxX,r.minY);if(n===0)return 0;var i=xt(o[0],o[1],e[0],e[1],r.minX,r.minY,r.minX,r.maxY);if(i===0)return 0;var s=xt(o[0],o[1],e[0],e[1],r.maxX,r.minY,r.maxX,r.maxY);if(s===0)return 0;var a=xt(o[0],o[1],e[0],e[1],r.minX,r.maxY,r.maxX,r.maxY);return a===0?0:Math.min(n,i,s,a)}function Pr(o,e){return o[0]>=e.minX&&o[0]<=e.maxX&&o[1]>=e.minY&&o[1]<=e.maxY}function Lr(o,e,r){for(var n=Math.min(o[0],e[0]),i=Math.min(o[1],e[1]),s=Math.max(o[0],e[0]),a=Math.max(o[1],e[1]),u=r.search({minX:n,minY:i,maxX:s,maxY:a}),c=0;c<u.length;c++)if(Gn(u[c].p,u[c].next.p,o,e))return!1;return!0}function Be(o,e,r){return Tn(o[0],o[1],e[0],e[1],r[0],r[1])}function Gn(o,e,r,n){return o!==n&&e!==r&&Be(o,e,r)>0!=Be(o,e,n)>0&&Be(r,n,o)>0!=Be(r,n,e)>0}function zt(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 qn(o){for(var e=o[0],r=o[0],n=o[0],i=o[0],s=0;s<o.length;s++){var a=o[s];a[0]<e[0]&&(e=a),a[0]>n[0]&&(n=a),a[1]<r[1]&&(r=a),a[1]>i[1]&&(i=a)}var u=[e,r,n,i],c=u.slice();for(s=0;s<o.length;s++)Nn(o[s],u)||c.push(o[s]);return Hn(c)}function Ar(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 Rt(o,e,r){var n=e[0],i=e[1],s=r[0]-n,a=r[1]-i;if(s!==0||a!==0){var u=((o[0]-n)*s+(o[1]-i)*a)/(s*s+a*a);u>1?(n=r[0],i=r[1]):u>0&&(n+=s*u,i+=a*u)}return s=o[0]-n,a=o[1]-i,s*s+a*a}function xt(o,e,r,n,i,s,a,u){var c=r-o,l=n-e,v=a-i,h=u-s,g=o-i,d=e-s,_=c*c+l*l,A=c*v+l*h,O=v*v+h*h,$=c*g+l*d,f=v*g+h*d,y=_*O-A*A,p,m,b,M,w=y,L=y;y===0?(m=0,w=1,M=f,L=O):(m=A*f-O*$,M=_*f-A*$,m<0?(m=0,M=f,L=O):m>w&&(m=w,M=f+A,L=O)),M<0?(M=0,-$<0?m=0:-$>_?m=w:(m=-$,w=_)):M>L&&(M=L,-$+A<0?m=0:-$+A>_?m=w:(m=-$+A,w=_)),p=m===0?0:m/w,b=M===0?0:M/L;var D=(1-p)*o+p*r,E=(1-p)*e+p*n,I=(1-b)*i+b*a,j=(1-b)*s+b*u,T=I-D,ce=j-E;return T*T+ce*ce}function Vn(o,e){return o[0]===e[0]?o[1]-e[1]:o[0]-e[0]}function Hn(o){o.sort(Vn);for(var e=[],r=0;r<o.length;r++){for(;e.length>=2&&Be(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&&Be(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 Wn=lr.exports;const Zn=So(Wn);function Kn(o,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var r=[];if(ct(o,function(i){r.push([i[0],i[1]])}),!r.length)return null;var n=Zn(r,e.concavity);return n.length>3?Ue([n]):null}function rr(o,e,r){r===void 0&&(r={});var n=Ye(o),i=Ye(e),s=we(i[1]-n[1]),a=we(i[0]-n[0]),u=we(n[1]),c=we(i[1]),l=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(u)*Math.cos(c);return An(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),r.units)}function R(o){if(!o)throw new Error("geojson is required");switch(o.type){case"Feature":return Do(o);case"FeatureCollection":return Qn(o);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return hr(o);default:throw new Error("unknown GeoJSON type")}}function Do(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=Fo(o.properties),e.geometry=hr(o.geometry),e}function Fo(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]=Fo(n):e[r]=n}),e}function Qn(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 Do(r)}),e}function hr(o){var e={type:o.type};return o.bbox&&(e.bbox=o.bbox),o.type==="GeometryCollection"?(e.geometries=o.geometries.map(function(r){return hr(r)}),e):(e.coordinates=Eo(o.coordinates),e)}function Eo(o){var e=o;return typeof e[0]!="object"?e.slice():e.map(function(r){return Eo(r)})}function or(o,e){e===void 0&&(e={});var r=typeof e=="object"?e.mutate:e;if(!o)throw new Error("geojson is required");var n=Mo(o),i=[];switch(n){case"LineString":i=jt(o);break;case"MultiLineString":case"Polygon":_t(o).forEach(function(a){i.push(jt(a))});break;case"MultiPolygon":_t(o).forEach(function(a){var u=[];a.forEach(function(c){u.push(jt(c))}),i.push(u)});break;case"Point":return o;case"MultiPoint":var s={};_t(o).forEach(function(a){var u=a.join("-");Object.prototype.hasOwnProperty.call(s,u)||(i.push(a),s[u]=!0)});break;default:throw new Error(n+" geometry not supported")}return o.coordinates?r===!0?(o.coordinates=i,o):{type:n,coordinates:i}:r===!0?(o.geometry.coordinates=i,o):kt({type:n,coordinates:i},o.properties,{bbox:o.bbox,id:o.id})}function jt(o){var e=_t(o);if(e.length===2&&!kr(e[0],e[1]))return e;var r=[],n=e.length-1,i=r.length;r.push(e[0]);for(var s=1;s<n;s++){var a=r[r.length-1];e[s][0]===a[0]&&e[s][1]===a[1]||(r.push(e[s]),i=r.length,i>2&&Dr(r[i-3],r[i-1],r[i-2])&&r.splice(r.length-2,1))}if(r.push(e[e.length-1]),i=r.length,kr(e[0],e[e.length-1])&&i<4)throw new Error("invalid polygon");return Dr(r[i-3],r[i-1],r[i-2])&&r.splice(r.length-2,1),r}function kr(o,e){return o[0]===e[0]&&o[1]===e[1]}function Dr(o,e,r){var n=r[0],i=r[1],s=o[0],a=o[1],u=e[0],c=e[1],l=n-s,v=i-a,h=u-s,g=c-a,d=l*g-v*h;return d!==0?!1:Math.abs(h)>=Math.abs(g)?h>0?s<=n&&n<=u:u<=n&&n<=s:g>0?a<=i&&i<=c:c<=i&&i<=a}function ei(o,e){var r=o.x-e.x,n=o.y-e.y;return r*r+n*n}function ti(o,e,r){var n=e.x,i=e.y,s=r.x-n,a=r.y-i;if(s!==0||a!==0){var u=((o.x-n)*s+(o.y-i)*a)/(s*s+a*a);u>1?(n=r.x,i=r.y):u>0&&(n+=s*u,i+=a*u)}return s=o.x-n,a=o.y-i,s*s+a*a}function ri(o,e){for(var r=o[0],n=[r],i,s=1,a=o.length;s<a;s++)i=o[s],ei(i,r)>e&&(n.push(i),r=i);return r!==i&&n.push(i),n}function nr(o,e,r,n,i){for(var s=n,a,u=e+1;u<r;u++){var c=ti(o[u],o[e],o[r]);c>s&&(a=u,s=c)}s>n&&(a-e>1&&nr(o,e,a,n,i),i.push(o[a]),r-a>1&&nr(o,a,r,n,i))}function oi(o,e){var r=o.length-1,n=[o[0]];return nr(o,0,r,e,n),n.push(o[r]),n}function ir(o,e,r){if(o.length<=2)return o;var n=e!==void 0?e*e:1;return o=r?o:ri(o,n),o=oi(o,n),o}function ni(o,e){if(e=e||{},!Dn(e))throw new Error("options is invalid");var r=e.tolerance!==void 0?e.tolerance:1,n=e.highQuality||!1,i=e.mutate||!1;if(!o)throw new Error("geojson is required");if(r&&r<0)throw new Error("invalid tolerance");return i!==!0&&(o=R(o)),_o(o,function(s){ii(s,r,n)}),o}function ii(o,e,r){var n=o.type;if(n==="Point"||n==="MultiPoint")return o;or(o,!0);var i=o.coordinates;switch(n){case"LineString":o.coordinates=Fr(i,e,r);break;case"MultiLineString":o.coordinates=i.map(function(s){return Fr(s,e,r)});break;case"Polygon":o.coordinates=Er(i,e,r);break;case"MultiPolygon":o.coordinates=i.map(function(s){return Er(s,e,r)})}return o}function Fr(o,e,r){return ir(o.map(function(n){return{x:n[0],y:n[1],z:n[2]}}),e,r).map(function(n){return n.z?[n.x,n.y,n.z]:[n.x,n.y]})}function Er(o,e,r){return o.map(function(n){var i=n.map(function(a){return{x:a[0],y:a[1]}});if(i.length<4)throw new Error("invalid polygon");for(var s=ir(i,e,r).map(function(a){return[a.x,a.y]});!si(s);)e-=e*.01,s=ir(i,e,r).map(function(a){return[a.x,a.y]});return(s[s.length-1][0]!==s[0][0]||s[s.length-1][1]!==s[0][1])&&s.push(s[0]),s})}function si(o){return o.length<3?!1:!(o.length===3&&o[2][0]===o[0][0]&&o[2][1]===o[0][1])}var ai=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 s=this.points[r+1].x-(this.centers[r].x+this.centers[r+1].x)/2,a=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+s),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r].y+a),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+s),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r+1].y+a),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 s=this.pos(i),a=Math.sqrt((s.x-n.x)*(s.x-n.x)+(s.y-n.y)*(s.y-n.y)+(s.z-n.z)*(s.z-n.z));a>e&&(r.push(i),n=s)}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),s=(this.length-1)*n-i;return ui(s,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])},o}();function ui(o,e,r,n,i){var s=ci(o),a={x:i.x*s[0]+n.x*s[1]+r.x*s[2]+e.x*s[3],y:i.y*s[0]+n.y*s[1]+r.y*s[2]+e.y*s[3],z:i.z*s[0]+n.z*s[1]+r.z*s[2]+e.z*s[3]};return a}function ci(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 st(o,e){e===void 0&&(e={});for(var r=e.resolution||1e4,n=e.sharpness||.85,i=[],s=er(o).coordinates.map(function(l){return{x:l[0],y:l[1]}}),a=new ai({duration:r,points:s,sharpness:n}),u=function(l){var v=a.pos(l);Math.floor(l/100)%2===0&&i.push([v.x,v.y])},c=0;c<a.duration;c+=10)u(c);return u(a.duration),Xe(i,e.properties)}function li(o,e){e===void 0&&(e={});var r=Number(o[0]),n=Number(o[1]),i=Number(o[2]),s=Number(o[3]);if(o.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var a=[r,n],u=[r,s],c=[i,s],l=[i,n];return Ue([[a,l,c,u,a]],e.properties,{bbox:o,id:e.id})}function $o(o,e,r,n){n===void 0&&(n={});var i=Ye(o),s=we(i[0]),a=we(i[1]),u=we(r),c=kn(e,n.units),l=Math.asin(Math.sin(a)*Math.cos(c)+Math.cos(a)*Math.sin(c)*Math.cos(u)),v=s+Math.atan2(Math.sin(u)*Math.sin(c)*Math.cos(a),Math.cos(c)-Math.sin(a)*Math.sin(l)),h=Kt(v),g=Kt(l);return Se([h,g],n.properties)}function Oo(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:{},s=[],a=0;a<n;a++)s.push($o(o,e,a*-360/n,r).geometry.coordinates);return s.push(s[0]),Ue([s],i)}function Io(o,e,r){if(r===void 0&&(r={}),r.final===!0)return hi(o,e);var n=Ye(o),i=Ye(e),s=we(n[0]),a=we(i[0]),u=we(n[1]),c=we(i[1]),l=Math.sin(a-s)*Math.cos(c),v=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(a-s);return Kt(Math.atan2(l,v))}function hi(o,e){var r=Io(e,o);return r=(r+180)%360,r}function fi(o,e){var r=rr(o,e),n=Io(o,e),i=$o(o,r/2,n);return i}function $r(o,e){e===void 0&&(e={});var r=0,n=0,i=0;return ct(o,function(s){r+=s[0],n+=s[1],i++},!0),Se([r/i,n/i],e.properties)}function sr(o,e){switch(e===void 0&&(e={}),Mo(o)){case"Point":return Se(Ye(o),e.properties);case"Polygon":var r=[];ct(o,function(p){r.push(p)});var n=$r(o,{properties:e.properties}),i=n.geometry.coordinates,s=0,a=0,u=0,c,l,v,h,g,d,_,A,O=r.map(function(p){return[p[0]-i[0],p[1]-i[1]]});for(c=0;c<r.length-1;c++)l=O[c],h=l[0],d=l[1],v=O[c+1],g=v[0],_=v[1],A=h*_-g*d,u+=A,s+=(h+g)*A,a+=(d+_)*A;if(u===0)return n;var $=u*.5,f=1/(6*$);return Se([i[0]+f*s,i[1]+f*a],e.properties);default:var y=Kn(o);return y?sr(y,{properties:e.properties}):$r(o,{properties:e.properties})}}var Or=6378137;function Jt(o){return Fn(o,function(e,r){return e+yi(r)},0)}function yi(o){var e=0,r;switch(o.type){case"Polygon":return Ir(o.coordinates);case"MultiPolygon":for(r=0;r<o.coordinates.length;r++)e+=Ir(o.coordinates[r]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function Ir(o){var e=0;if(o&&o.length>0){e+=Math.abs(zr(o[0]));for(var r=1;r<o.length;r++)e-=Math.abs(zr(o[r]))}return e}function zr(o){var e,r,n,i,s,a,u,c=0,l=o.length;if(l>2){for(u=0;u<l;u++)u===l-2?(i=l-2,s=l-1,a=0):u===l-1?(i=l-1,s=0,a=1):(i=u,s=u+1,a=u+2),e=o[i],r=o[s],n=o[a],c+=(Bt(n[0])-Bt(e[0]))*Math.sin(Bt(r[1]));c=c*Or*Or/2}return c}function Bt(o){return o*Math.PI/180}var Cr=Object.prototype.toString,zo=function(e){var r=Cr.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Cr.call(e.callee)==="[object Function]"),n},Nt,Rr;function pi(){if(Rr)return Nt;Rr=1;var o;if(!Object.keys){var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=zo,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),a=i.call(function(){},"prototype"),u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(g){var d=g.constructor;return d&&d.prototype===g},l={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},v=function(){if(typeof window>"u")return!1;for(var g in window)try{if(!l["$"+g]&&e.call(window,g)&&window[g]!==null&&typeof window[g]=="object")try{c(window[g])}catch{return!0}}catch{return!0}return!1}(),h=function(g){if(typeof window>"u"||!v)return c(g);try{return c(g)}catch{return!1}};o=function(d){var _=d!==null&&typeof d=="object",A=r.call(d)==="[object Function]",O=n(d),$=_&&r.call(d)==="[object String]",f=[];if(!_&&!A&&!O)throw new TypeError("Object.keys called on a non-object");var y=a&&A;if($&&d.length>0&&!e.call(d,0))for(var p=0;p<d.length;++p)f.push(String(p));if(O&&d.length>0)for(var m=0;m<d.length;++m)f.push(String(m));else for(var b in d)!(y&&b==="prototype")&&e.call(d,b)&&f.push(String(b));if(s)for(var M=h(d),w=0;w<u.length;++w)!(M&&u[w]==="constructor")&&e.call(d,u[w])&&f.push(u[w]);return f}}return Nt=o,Nt}var di=Array.prototype.slice,gi=zo,jr=Object.keys,bt=jr?function(e){return jr(e)}:pi(),Jr=Object.keys;bt.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return gi(n)?Jr(di.call(n)):Jr(n)})}else Object.keys=bt;return Object.keys||bt};var Co=bt,Ro=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var u=Object.getOwnPropertyDescriptor(e,r);if(u.value!==i||u.enumerable!==!0)return!1}return!0},vi=Ro,fr=function(){return vi()&&!!Symbol.toStringTag},jo=Object,Jo=Error,mi=EvalError,xi=RangeError,wi=ReferenceError,Bo=SyntaxError,qe=TypeError,_i=URIError,Mi=Math.abs,bi=Math.floor,Si=Math.max,Pi=Math.min,Li=Math.pow,Ai=Math.round,ki=Number.isNaN||function(e){return e!==e},Di=ki,Fi=function(e){return Di(e)||e===0?e:e<0?-1:1},Ei=Object.getOwnPropertyDescriptor,St=Ei;if(St)try{St([],"length")}catch{St=null}var Ve=St,Pt=Object.defineProperty||!1;if(Pt)try{Pt({},"a",{value:1})}catch{Pt=!1}var Ft=Pt,Tt,Br;function $i(){if(Br)return Tt;Br=1;var o=typeof Symbol<"u"&&Symbol,e=Ro;return Tt=function(){return typeof o!="function"||typeof Symbol!="function"||typeof o("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Tt}var No=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,Oi=jo,To=Oi.getPrototypeOf||null,Ii="Function.prototype.bind called on incompatible ",zi=Object.prototype.toString,Ci=Math.max,Ri="[object Function]",Nr=function(e,r){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var s=0;s<r.length;s+=1)n[s+e.length]=r[s];return n},ji=function(e,r){for(var n=[],i=r,s=0;i<e.length;i+=1,s+=1)n[s]=e[i];return n},Ji=function(o,e){for(var r="",n=0;n<o.length;n+=1)r+=o[n],n+1<o.length&&(r+=e);return r},Bi=function(e){var r=this;if(typeof r!="function"||zi.apply(r)!==Ri)throw new TypeError(Ii+r);for(var n=ji(arguments,1),i,s=function(){if(this instanceof i){var v=r.apply(this,Nr(n,arguments));return Object(v)===v?v:this}return r.apply(e,Nr(n,arguments))},a=Ci(0,r.length-n.length),u=[],c=0;c<a;c++)u[c]="$"+c;if(i=Function("binder","return function ("+Ji(u,",")+"){ return binder.apply(this,arguments); }")(s),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i},Ni=Bi,lt=Function.prototype.bind||Ni,yr=Function.prototype.call,pr=Function.prototype.apply,Ti=typeof Reflect<"u"&&Reflect&&Reflect.apply,Ui=lt,Xi=pr,Yi=yr,Gi=Ti,Uo=Gi||Ui.call(Yi,Xi),qi=lt,Vi=qe,Hi=yr,Wi=Uo,dr=function(e){if(e.length<1||typeof e[0]!="function")throw new Vi("a function is required");return Wi(qi,Hi,e)},Zi=dr,Tr=Ve,Xo;try{Xo=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var Ut=!!Xo&&Tr&&Tr(Object.prototype,"__proto__"),Yo=Object,Ur=Yo.getPrototypeOf,Ki=Ut&&typeof Ut.get=="function"?Zi([Ut.get]):typeof Ur=="function"?function(e){return Ur(e==null?e:Yo(e))}:!1,Xr=No,Yr=To,Gr=Ki,Go=Xr?function(e){return Xr(e)}:Yr?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Yr(e)}:Gr?function(e){return Gr(e)}:null,Qi=Function.prototype.call,es=Object.prototype.hasOwnProperty,ts=lt,qo=ts.call(Qi,es),X,rs=jo,os=Jo,ns=mi,is=xi,ss=wi,Ge=Bo,Te=qe,as=_i,us=Mi,cs=bi,ls=Si,hs=Pi,fs=Li,ys=Ai,ps=Fi,Vo=Function,Xt=function(o){try{return Vo('"use strict"; return ('+o+").constructor;")()}catch{}},at=Ve,ds=Ft,Yt=function(){throw new Te},gs=at?function(){try{return arguments.callee,Yt}catch{try{return at(arguments,"callee").get}catch{return Yt}}}():Yt,Ce=$i()(),ue=Go,vs=To,ms=No,Ho=pr,ht=yr,je={},xs=typeof Uint8Array>"u"||!ue?X:ue(Uint8Array),Ee={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?X:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?X:ArrayBuffer,"%ArrayIteratorPrototype%":Ce&&ue?ue([][Symbol.iterator]()):X,"%AsyncFromSyncIteratorPrototype%":X,"%AsyncFunction%":je,"%AsyncGenerator%":je,"%AsyncGeneratorFunction%":je,"%AsyncIteratorPrototype%":je,"%Atomics%":typeof Atomics>"u"?X:Atomics,"%BigInt%":typeof BigInt>"u"?X:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?X:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?X:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?X:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":os,"%eval%":eval,"%EvalError%":ns,"%Float16Array%":typeof Float16Array>"u"?X:Float16Array,"%Float32Array%":typeof Float32Array>"u"?X:Float32Array,"%Float64Array%":typeof Float64Array>"u"?X:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?X:FinalizationRegistry,"%Function%":Vo,"%GeneratorFunction%":je,"%Int8Array%":typeof Int8Array>"u"?X:Int8Array,"%Int16Array%":typeof Int16Array>"u"?X:Int16Array,"%Int32Array%":typeof Int32Array>"u"?X:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ce&&ue?ue(ue([][Symbol.iterator]())):X,"%JSON%":typeof JSON=="object"?JSON:X,"%Map%":typeof Map>"u"?X:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ce||!ue?X:ue(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":rs,"%Object.getOwnPropertyDescriptor%":at,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?X:Promise,"%Proxy%":typeof Proxy>"u"?X:Proxy,"%RangeError%":is,"%ReferenceError%":ss,"%Reflect%":typeof Reflect>"u"?X:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?X:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ce||!ue?X:ue(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?X:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ce&&ue?ue(""[Symbol.iterator]()):X,"%Symbol%":Ce?Symbol:X,"%SyntaxError%":Ge,"%ThrowTypeError%":gs,"%TypedArray%":xs,"%TypeError%":Te,"%Uint8Array%":typeof Uint8Array>"u"?X:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?X:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?X:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?X:Uint32Array,"%URIError%":as,"%WeakMap%":typeof WeakMap>"u"?X:WeakMap,"%WeakRef%":typeof WeakRef>"u"?X:WeakRef,"%WeakSet%":typeof WeakSet>"u"?X:WeakSet,"%Function.prototype.call%":ht,"%Function.prototype.apply%":Ho,"%Object.defineProperty%":ds,"%Object.getPrototypeOf%":vs,"%Math.abs%":us,"%Math.floor%":cs,"%Math.max%":ls,"%Math.min%":hs,"%Math.pow%":fs,"%Math.round%":ys,"%Math.sign%":ps,"%Reflect.getPrototypeOf%":ms};if(ue)try{null.error}catch(o){var ws=ue(ue(o));Ee["%Error.prototype%"]=ws}var _s=function o(e){var r;if(e==="%AsyncFunction%")r=Xt("async function () {}");else if(e==="%GeneratorFunction%")r=Xt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Xt("async function* () {}");else if(e==="%AsyncGenerator%"){var n=o("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=o("%AsyncGenerator%");i&&ue&&(r=ue(i.prototype))}return Ee[e]=r,r},qr={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ft=lt,Lt=qo,Ms=ft.call(ht,Array.prototype.concat),bs=ft.call(Ho,Array.prototype.splice),Vr=ft.call(ht,String.prototype.replace),At=ft.call(ht,String.prototype.slice),Ss=ft.call(ht,RegExp.prototype.exec),Ps=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ls=/\\(\\)?/g,As=function(e){var r=At(e,0,1),n=At(e,-1);if(r==="%"&&n!=="%")throw new Ge("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Ge("invalid intrinsic syntax, expected opening `%`");var i=[];return Vr(e,Ps,function(s,a,u,c){i[i.length]=u?Vr(c,Ls,"$1"):a||s}),i},ks=function(e,r){var n=e,i;if(Lt(qr,n)&&(i=qr[n],n="%"+i[0]+"%"),Lt(Ee,n)){var s=Ee[n];if(s===je&&(s=_s(n)),typeof s>"u"&&!r)throw new Te("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new Ge("intrinsic "+e+" does not exist!")},Wo=function(e,r){if(typeof e!="string"||e.length===0)throw new Te("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Te('"allowMissing" argument must be a boolean');if(Ss(/^%?[^%]*%?$/,e)===null)throw new Ge("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=As(e),i=n.length>0?n[0]:"",s=ks("%"+i+"%",r),a=s.name,u=s.value,c=!1,l=s.alias;l&&(i=l[0],bs(n,Ms([0,1],l)));for(var v=1,h=!0;v<n.length;v+=1){var g=n[v],d=At(g,0,1),_=At(g,-1);if((d==='"'||d==="'"||d==="`"||_==='"'||_==="'"||_==="`")&&d!==_)throw new Ge("property names with quotes must have matching quotes");if((g==="constructor"||!h)&&(c=!0),i+="."+g,a="%"+i+"%",Lt(Ee,a))u=Ee[a];else if(u!=null){if(!(g in u)){if(!r)throw new Te("base intrinsic for "+e+" exists, but the property is not available.");return}if(at&&v+1>=n.length){var A=at(u,g);h=!!A,h&&"get"in A&&!("originalValue"in A.get)?u=A.get:u=u[g]}else h=Lt(u,g),u=u[g];h&&!c&&(Ee[a]=u)}}return u},Zo=Wo,Ko=dr,Ds=Ko([Zo("%String.prototype.indexOf%")]),gr=function(e,r){var n=Zo(e,!!r);return typeof n=="function"&&Ds(e,".prototype.")>-1?Ko([n]):n},Fs=fr(),Es=gr,ar=Es("Object.prototype.toString"),Et=function(e){return Fs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:ar(e)==="[object Arguments]"},Qo=function(e){return Et(e)?!0:e!==null&&typeof e=="object"&&"length"in e&&typeof e.length=="number"&&e.length>=0&&ar(e)!=="[object Array]"&&"callee"in e&&ar(e.callee)==="[object Function]"},$s=function(){return Et(arguments)}();Et.isLegacyArguments=Qo;var Os=$s?Et:Qo,Hr=Ft,Is=Bo,Re=qe,Wr=Ve,vr=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Re("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Re("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Re("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Re("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Re("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Re("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,c=!!Wr&&Wr(e,r);if(Hr)Hr(e,r,{configurable:a===null&&c?c.configurable:!a,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(u||!i&&!s&&!a)e[r]=n;else throw new Is("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ur=Ft,en=function(){return!!ur};en.hasArrayLengthDefineBug=function(){if(!ur)return null;try{return ur([],"length",{value:1}).length!==1}catch{return!0}};var mr=en,zs=Co,Cs=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Rs=Object.prototype.toString,js=Array.prototype.concat,Zr=vr,Js=function(o){return typeof o=="function"&&Rs.call(o)==="[object Function]"},tn=mr(),Bs=function(o,e,r,n){if(e in o){if(n===!0){if(o[e]===r)return}else if(!Js(n)||!n())return}tn?Zr(o,e,r,!0):Zr(o,e,r)},rn=function(o,e){var r=arguments.length>2?arguments[2]:{},n=zs(e);Cs&&(n=js.call(n,Object.getOwnPropertySymbols(e)));for(var i=0;i<n.length;i+=1)Bs(o,n[i],e[n[i]],r[n[i]])};rn.supportsDescriptors=!!tn;var yt=rn,on={exports:{}},Ns=Wo,Kr=vr,Ts=mr(),Qr=Ve,eo=qe,Us=Ns("%Math.floor%"),Xs=function(e,r){if(typeof e!="function")throw new eo("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Us(r)!==r)throw new eo("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Qr){var a=Qr(e,"length");a&&!a.configurable&&(i=!1),a&&!a.writable&&(s=!1)}return(i||s||!n)&&(Ts?Kr(e,"length",r,!0,!0):Kr(e,"length",r)),e},Ys=lt,Gs=pr,qs=Uo,Vs=function(){return qs(Ys,Gs,arguments)};(function(o){var e=Xs,r=Ft,n=dr,i=Vs;o.exports=function(a){var u=n(arguments),c=a.length-(arguments.length-1);return e(u,1+(c>0?c:0),!0)},r?r(o.exports,"apply",{value:i}):o.exports.apply=i})(on);var nn=on.exports,to=function(o){return o!==o},sn=function(e,r){return e===0&&r===0?1/e===1/r:!!(e===r||to(e)&&to(r))},Hs=sn,an=function(){return typeof Object.is=="function"?Object.is:Hs},Ws=an,Zs=yt,Ks=function(){var e=Ws();return Zs(Object,{is:e},{is:function(){return Object.is!==e}}),e},Qs=yt,ea=nn,ta=sn,un=an,ra=Ks,cn=ea(un(),Object);Qs(cn,{getPolyfill:un,implementation:ta,shim:ra});var oa=cn,ro=gr,na=fr(),ia=qo,sa=Ve,cr;if(na){var aa=ro("RegExp.prototype.exec"),oo={},Gt=function(){throw oo},no={toString:Gt,valueOf:Gt};typeof Symbol.toPrimitive=="symbol"&&(no[Symbol.toPrimitive]=Gt),cr=function(e){if(!e||typeof e!="object")return!1;var r=sa(e,"lastIndex"),n=r&&ia(r,"value");if(!n)return!1;try{aa(e,no)}catch(i){return i===oo}}}else{var ua=ro("Object.prototype.toString"),ca="[object RegExp]";cr=function(e){return!e||typeof e!="object"&&typeof e!="function"?!1:ua(e)===ca}}var la=cr,ut=function(){return typeof(function(){}).name=="string"},nt=Object.getOwnPropertyDescriptor;if(nt)try{nt([],"length")}catch{nt=null}ut.functionsHaveConfigurableNames=function(){if(!ut()||!nt)return!1;var e=nt(function(){},"name");return!!e&&!!e.configurable};var ha=Function.prototype.bind;ut.boundFunctionsHaveNames=function(){return ut()&&typeof ha=="function"&&(function(){}).bind().name!==""};var fa=ut,io=vr,ya=mr(),pa=fa.functionsHaveConfigurableNames(),da=qe,ga=function(e,r){if(typeof e!="function")throw new da("`fn` is not a function");var n=arguments.length>2&&!!arguments[2];return(!n||pa)&&(ya?io(e,"name",r,!0,!0):io(e,"name",r)),e},va=ga,ma=qe,xa=Object,ln=va(function(){if(this==null||this!==xa(this))throw new ma("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),wa=ln,_a=yt.supportsDescriptors,Ma=Object.getOwnPropertyDescriptor,hn=function(){if(_a&&/a/mig.flags==="gim"){var e=Ma(RegExp.prototype,"flags");if(e&&typeof e.get=="function"&&"dotAll"in RegExp.prototype&&"hasIndices"in RegExp.prototype){var r="",n={};if(Object.defineProperty(n,"hasIndices",{get:function(){r+="d"}}),Object.defineProperty(n,"sticky",{get:function(){r+="y"}}),e.get.call(n),r==="dy")return e.get}}return wa},ba=yt.supportsDescriptors,Sa=hn,Pa=Ve,La=Object.defineProperty,Aa=Jo,so=Go,ka=/a/,Da=function(){if(!ba||!so)throw new Aa("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=Sa(),r=so(ka),n=Pa(r,"flags");return(!n||n.get!==e)&&La(r,"flags",{configurable:!0,enumerable:!1,get:e}),e},Fa=yt,Ea=nn,$a=ln,fn=hn,Oa=Da,yn=Ea(fn());Fa(yn,{getPolyfill:fn,implementation:$a,shim:Oa});var Ia=yn,pn=gr,za=pn("Date.prototype.getDay"),Ca=function(e){try{return za(e),!0}catch{return!1}},Ra=pn("Object.prototype.toString"),ja="[object Date]",Ja=fr(),Ba=function(e){return typeof e!="object"||e===null?!1:Ja?Ca(e):Ra(e)===ja},ao=Co,uo=Os,co=oa,lo=la,ho=Ia,fo=Ba,yo=Date.prototype.getTime;function dn(o,e,r){var n=r||{};return(n.strict?co(o,e):o===e)?!0:!o||!e||typeof o!="object"&&typeof e!="object"?n.strict?co(o,e):o==e:Na(o,e,n)}function po(o){return o==null}function go(o){return!(!o||typeof o!="object"||typeof o.length!="number"||typeof o.copy!="function"||typeof o.slice!="function"||o.length>0&&typeof o[0]!="number")}function Na(o,e,r){var n,i;if(typeof o!=typeof e||po(o)||po(e)||o.prototype!==e.prototype||uo(o)!==uo(e))return!1;var s=lo(o),a=lo(e);if(s!==a)return!1;if(s||a)return o.source===e.source&&ho(o)===ho(e);if(fo(o)&&fo(e))return yo.call(o)===yo.call(e);var u=go(o),c=go(e);if(u!==c)return!1;if(u||c){if(o.length!==e.length)return!1;for(n=0;n<o.length;n++)if(o[n]!==e[n])return!1;return!0}if(typeof o!=typeof e)return!1;try{var l=ao(o),v=ao(e)}catch{return!1}if(l.length!==v.length)return!1;for(l.sort(),v.sort(),n=l.length-1;n>=0;n--)if(l[n]!=v[n])return!1;for(n=l.length-1;n>=0;n--)if(i=l[n],!dn(o[i],e[i],r))return!1;return!0}var Ta=dn,Ua=Ta,Me=function(o){this.precision=o&&o.precision?o.precision:17,this.direction=o&&o.direction?o.direction:!1,this.pseudoNode=o&&o.pseudoNode?o.pseudoNode:!1,this.objectComparator=o&&o.objectComparator?o.objectComparator:Xa};Me.prototype.compare=function(o,e){if(o.type!==e.type||!gn(o,e))return!1;switch(o.type){case"Point":return this.compareCoord(o.coordinates,e.coordinates);case"LineString":return this.compareLine(o.coordinates,e.coordinates,0,!1);case"Polygon":return this.comparePolygon(o,e);case"Feature":return this.compareFeature(o,e);default:if(o.type.indexOf("Multi")===0){var r=this,n=vo(o),i=vo(e);return n.every(function(s){return this.some(function(a){return r.compare(s,a)})},i)}}return!1};function vo(o){return o.coordinates.map(function(e){return{type:o.type.replace("Multi",""),coordinates:e}})}function gn(o,e){return o.hasOwnProperty("coordinates")?o.coordinates.length===e.coordinates.length:o.length===e.length}Me.prototype.compareCoord=function(o,e){if(o.length!==e.length)return!1;for(var r=0;r<o.length;r++)if(o[r].toFixed(this.precision)!==e[r].toFixed(this.precision))return!1;return!0};Me.prototype.compareLine=function(o,e,r,n){if(!gn(o,e))return!1;var i=this.pseudoNode?o:this.removePseudo(o),s=this.pseudoNode?e:this.removePseudo(e);if(!(n&&!this.compareCoord(i[0],s[0])&&(s=this.fixStartIndex(s,i),!s))){var a=this.compareCoord(i[r],s[r]);return this.direction||a?this.comparePath(i,s):this.compareCoord(i[r],s[s.length-(1+r)])?this.comparePath(i.slice().reverse(),s):!1}};Me.prototype.fixStartIndex=function(o,e){for(var r,n=-1,i=0;i<o.length;i++)if(this.compareCoord(o[i],e[0])){n=i;break}return n>=0&&(r=[].concat(o.slice(n,o.length),o.slice(1,n+1))),r};Me.prototype.comparePath=function(o,e){var r=this;return o.every(function(n,i){return r.compareCoord(n,this[i])},e)};Me.prototype.comparePolygon=function(o,e){if(this.compareLine(o.coordinates[0],e.coordinates[0],1,!0)){var r=o.coordinates.slice(1,o.coordinates.length),n=e.coordinates.slice(1,e.coordinates.length),i=this;return r.every(function(s){return this.some(function(a){return i.compareLine(s,a,1,!0)})},n)}else return!1};Me.prototype.compareFeature=function(o,e){return o.id!==e.id||!this.objectComparator(o.properties,e.properties)||!this.compareBBox(o,e)?!1:this.compare(o.geometry,e.geometry)};Me.prototype.compareBBox=function(o,e){return!!(!o.bbox&&!e.bbox||o.bbox&&e.bbox&&this.compareCoord(o.bbox,e.bbox))};Me.prototype.removePseudo=function(o){return o};function Xa(o,e){return Ua(o,e,{strict:!0})}var Ya=Me;const Ga=So(Ya);function qa(o,e){var r=er(o).type,n=er(e).type;if(r!==n)return!1;var i=new Ga({precision:6});return i.compare(or(o),or(e))}const qt=(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}})},tt=(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}})},wt=(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 Va(o,e,r,n,i){let s="free",a="",u=[],c=[],l={},v=!1,h=!0,g=!1,d=!0,_=[],A=!0,O=5e4,$=!1,f={type:"FeatureCollection",features:[]},y={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},p={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}};const m=(P,z)=>{let U=0;return function(...Y){const ye=new Date().getTime();ye-U<z||(U=ye,P(...Y))}},b=P=>{switch(o.off("click",N),o.off("mousemove",re),o.off("contextmenu",G),le(),ie(),v&&(h=!0,C(!1)),v=!0,s=P.type||"point",A=P.multipleLine||!1,g=P.smooth||!1,O=P.brushSize*1e3||3e4,l=P,d=P.showLayer,y.properties=P,p.properties=P,s){case"point":break;case"brush":I();break}o.on("click",N),o.getCanvas().style.cursor=s=="brush"?"move":"crosshair"},M=P=>{s=P,y.properties.type=s,p.properties.type=s},w=P=>{if(r)if(u.length){const Y=[u[u.length-1]];r(Y)}else r([]);x(),ie(),o.addSource(a,{type:"geojson",data:f}),qt(o,a,a,l),f.features.push({type:"Feature",properties:l,geometry:{type:"Point",coordinates:P.lngLat.toArray()}}),o.getSource(a).setData(R(f)),e&&e(Q())},L=P=>{if(h){if(r)if(u.length){const U=u[u.length-1],Y=[U,U+"point"];r(Y)}else r([]);x(),ie(),o.addSource(a,{type:"geojson",data:y}),tt(o,a,a),qt(o,a+"point",a,l),h=!1,o.on("mousemove",re),o.on("contextmenu",G),o.dragRotate.enable()}y.geometry.coordinates.push(P.lngLat.toArray());const z=o.getSource(a);z.setData(y),!A&&y.geometry.coordinates.length==3&&(o.off("mousemove",re),o.off("contextmenu",G),h=!0,C(!1),y.geometry.coordinates.pop(),z.setData(R(y)),e&&e(Q()))},D=P=>{if(h){if(r)if(u.length){const Y=u[u.length-1],ye=[Y,Y+"outline",Y+"point"];r(ye)}else r([]);x(),ie(),o.addSource(a,{type:"geojson",data:p}),o.addSource(a+"point",{type:"geojson",data:f}),wt(o,a,a,l),tt(o,a+"outline",a,{"line-color":"black","line-width":2,...l}),qt(o,a+"point",a+"point",l),h=!1,o.on("mousemove",re),o.on("contextmenu",G),o.dragRotate.enable()}p.geometry.coordinates[0].length>=3&&p.geometry.coordinates[0].pop(),p.geometry.coordinates[0].push(P.lngLat.toArray()),p.geometry.coordinates[0].push(p.geometry.coordinates[0][0]),f.features.push(R({type:"Feature",geometry:{type:"Point",coordinates:P.lngLat.toArray()}})),o.getSource(a+"point").setData(f);const U=o.getSource(a);p.geometry.coordinates[0].length<=3&&!g&&U.setData(p),C(!0)},E=P=>{if(h){if(r)if(u.length){const U=u[u.length-1],Y=[U,U+"outline"];r(Y)}else r([]);x(),ie(),o.addSource(a,{type:"geojson",data:p}),wt(o,a,a,l),tt(o,a+"outline",a,{"line-color":"black","line-width":2,...l}),h=!1,p.geometry.coordinates[0].push(P.lngLat.toArray()),o.getSource(a).setData(p),o.on("mousemove",re),o.on("contextmenu",G),C(!0),o.dragRotate.enable()}},I=()=>{o.on("mousedown",H),o.on("mouseup",oe),o.on("mousemove",J),o.on("mouseover",te),o.on("mouseout",ne)},j=()=>{x(),ie(),o.addSource(a,{type:"geojson",data:p}),wt(o,a,a,l),tt(o,a+"outline",a,{"line-color":"black","line-width":2,...l})},T=(P,z)=>{const U=Se([P.lng,P.lat]),Y=z/2/111320,ye=Qt(Oo(U,Y,{units:"degrees"}));return li(ye)},ce=(P,z)=>{const U=T(P,z);p.geometry=U.geometry,o.getSource(a).setData(p)},K=()=>{const P=a,U=o.getSource(P).serialize().data;e&&e(U)},ee=P=>{O=P*1e3},V=P=>{p.properties.MGValue=P},le=()=>{o.off("mousedown",H),o.off("mouseup",oe),o.off("mousemove",J),o.off("mouseover",te),o.off("mouseout",ne)},F=P=>{let z=R(P);const U=Xe(z.geometry.coordinates[0]),Y=st(U,{sharpness:.6});return z.geometry.coordinates[0]=Y.geometry.coordinates,z},x=()=>{a=k(),u.push(a),c.push(a)},k=()=>{let P=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){const Y=(P+Math.random()*16)%16|0;return P=Math.floor(P/16),(U==="x"?Y:Y&3|8).toString(16)})},C=P=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(U=>{P?o[U].disable():o[U].enable()})},N=P=>{switch(s){case"point":w(P);break;case"line":L(P);break;case"polygon":D(P);break;case"free":E(P);break}},W=P=>{switch(s){case"line":y.geometry.coordinates.length&&(y.geometry.coordinates.length==1&&y.geometry.coordinates.push(P.lngLat.toArray()),y.geometry.coordinates[y.geometry.coordinates.length-1]=P.lngLat.toArray(),o.getSource(a).setData(y));break;case"polygon":const z=p.geometry.coordinates[0].length;if(z){z==2?p.geometry.coordinates[0][z-1]=P.lngLat.toArray():p.geometry.coordinates[0][z-2]=P.lngLat.toArray();const Y=o.getSource(a);Y.setData(p),g&&p.geometry.coordinates[0].length>=3&&Y.setData(F(p))}break;case"free":p.geometry.coordinates[0].length&&(_.push(P.point),p.geometry.coordinates[0].length!=1&&p.geometry.coordinates[0].pop(),p.geometry.coordinates[0].push(P.lngLat.toArray()),p.geometry.coordinates[0].push(p.geometry.coordinates[0][0]),o.getSource(a).setData(p));break}},J=P=>{ce(P.lngLat,O),$&&q()},q=m(K,0),G=P=>{P.preventDefault(),o.off("mousemove",re),o.off("contextmenu",G),h=!0,_.push(P.point),C(!1),o.dragRotate.disable();const z=o.getSource(a);switch(s){case"line":y.geometry.coordinates.length&&z.setData(R(y));break;case"polygon":if(p.geometry.coordinates[0].length){const U=p.geometry.coordinates[0].length;p.geometry.coordinates[0].splice(U-2,1),z.setData(R(p))}d||(o.setLayoutProperty(a,"visibility","none"),o.setLayoutProperty(a+"outline","visibility","none")),o.setLayoutProperty(a+"point","visibility","none"),g&&z.setData(R(F(p)));break;case"free":if(p.geometry.coordinates[0].length){const U=p.geometry.coordinates[0].length;if(p.geometry.coordinates[0].splice(U-2,1),z.setData(R(p)),d||(o.setLayoutProperty(a,"visibility","none"),o.setLayoutProperty(a+"outline","visibility","none")),g){const Y=[..._.slice(_.length/5),..._.slice(0,_.length/5),_.slice(_.length/5)[0]],ye=Y.length>10?5:3,pe=Math.ceil(Y.length/ye),gt=[];for(let ve=0;ve<Y.length;ve+=pe)gt.push(Y.slice(ve,ve+pe));let De=[];gt.forEach(ve=>{if(ve.length>1){const vn=new Z(ve).getLUT();De.push(...vn)}else De.push(...ve)}),p.geometry.coordinates[0].length=0;for(let ve=0;ve<De.length;ve++){const wr=o.unproject(De[ve]);p.geometry.coordinates[0].push(wr.toArray())}z.setData(R(p))}}break}e&&e(Q())},H=()=>{o.dragPan.disable(),o.dragRotate.disable(),$=!0,K()},oe=()=>{o.dragPan.enable(),o.dragRotate.enable(),$=!1},te=()=>{j()},ne=()=>{o.getLayer(a)&&o.removeLayer(a),o.getLayer(a+"outline")&&o.removeLayer(a+"outline"),o.getSource(a)&&o.removeSource(a)},Q=()=>{const P=u,z=[];return P.forEach((U,Y)=>{if(o.getSource(U)){const pe=o.getSource(U).serialize().data;pe.features?(pe.features[0].properties.layerId=U,pe.features[0].properties.sourceId=c[Y],z.push(...pe.features)):(pe.properties.layerId=U,pe.properties.sourceId=c[Y],z.push(pe))}}),z},he=()=>{u.forEach(P=>{o.getLayer(P)&&o.removeLayer(P),o.getLayer(P+"outline")&&o.removeLayer(P+"outline"),o.getLayer(P+"point")&&o.removeLayer(P+"point"),o.getLayer(P+"text")&&o.removeLayer(P+"text")}),c.forEach(P=>{o.getSource(P)&&o.removeSource(P),o.getSource(P+"point")&&o.removeSource(P+"point"),o.getSource(P+"text")&&o.removeSource(P+"text")}),u.length=0,c.length=0},ie=()=>{_.length=0,f.features.length=0,y.geometry.coordinates.length=0,p.geometry.coordinates.length=0,p.geometry.coordinates[0]=[],p.properties.result=""},re=m(W,30),de=()=>{le(),o.off("click",N),o.off("mousemove",re),o.off("contextmenu",G),o.getCanvas().style.cursor="pointer",C(!1)},_e=()=>{(s=="free"||s=="polygon"||s=="point"||s=="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())},ke=()=>{if((s=="free"||s=="polygon")&&c.length){const P=u.length-c.length,z=c.slice(P);if(P!==0&&z.length){const ye=o.getSource(z[0]).serialize().data.valueOf();o.getLayer(z[0])||(u.push(z[0]),wt(o,z[0],z[0],{"fill-color":ye.properties["fill-color"]}),tt(o,z[0]+"outline",z[0],{"line-color":"black","line-width":2,...ye.properties}))}}};let pt=!1;const $t=P=>{pt=P};let $e,He=!1,Oe="";o.on("mousedown",P=>{const z=o.queryRenderedFeatures(P.point);z.length>0&&(Oe=z[0].layer.source,pt&&dt(P))});const dt=P=>{o.dragPan.disable(),$e=P.lngLat,He=!0,o.on("mouseup",Ie),o.on("mousemove",xr),i&&i()},Ie=()=>{if(He=!1,o.off("mouseup",Ie),o.off("mousemove",xr),o.dragPan.enable(),n){const z=o.getSource(Oe).serialize().data;n(z)}},xr=P=>{if(!He)return;const z=P.lngLat,U=z.lng-$e.lng,Y=z.lat-$e.lat;$e=z;const ye=o.getSource(Oe),pe=ye.serialize().data;pe.geometry.coordinates=pe.geometry.coordinates.map(gt=>gt.map(De=>[De[0]+U,De[1]+Y])),ye.setData(pe)};return{startDraw:b,revoke:_e,redo:ke,getFeaturesFromDraw:Q,clearDraw:he,stopDraw:de,setBrushSize:ee,setValue:V,setDrawMethod:M,setDragMode:$t}}const Ha=(o,e,r,n={},i)=>{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)??{}}},"")},Ne=(o,e,r,n={},i)=>{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)??{}}},"")},Fe=(o,e,r,n={},i)=>{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)??{}}},i??"")},rt=(o,e,r,n={},i)=>{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)??{}}},"")},it=(o,e,r,n={},i)=>{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)??{}}},i??"")},se=(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)},ae=(o,e,r)=>{const n=o.getSource(e);n?n.setData(r):console.warn(`[popillon] Source with id "${e}" is not a GeoJSONSource.`)},xe=(o,e)=>{o.getSource(e)&&o.removeSource(e)},fe=(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 Wa(o,e){let r="free",n="",i=[],s=[],a={},u=!1,c=!0,l=!1,v=[],h={type:"FeatureCollection",features:[]},g={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},d={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},_={type:"Feature",properties:{result:""},geometry:{type:"Point",coordinates:[]}};const A=x=>{o.off("click",L),o.off("mousemove",F),o.off("contextmenu",E),V(),u&&(c=!0,w(!1)),u=!0,r=x.type||"point",x.measure,l=x.smooth||!1,a=x,g.properties=x,d.properties=x,_.properties=x,o.on("click",L),o.getCanvas().style.cursor="crosshair"},O=x=>{b(),V(),o.addSource(n,{type:"geojson",data:h}),Ne(o,n,n,a),rt(o,n+"text",n,{}),h.features.push({type:"Feature",properties:a,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(R(h)),e&&e(I())},$=x=>{b(),V(),o.addSource(n,{type:"geojson",data:h}),Ha(o,n,n,a),h.features.push({type:"Feature",properties:a,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(R(h)),e&&e(I())},f=x=>{c&&(b(),V(),o.addSource(n,{type:"geojson",data:g}),o.addSource(n+"text",{type:"geojson",data:h}),Fe(o,n,n),Ne(o,n+"point",n,a),rt(o,n+"text",n+"text",{}),c=!1,o.on("mousemove",F),o.on("contextmenu",E)),g.geometry.coordinates.push(x.lngLat.toArray()),o.getSource(n).setData(g),h.features.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n+"text").setData(h)},y=x=>{c&&(b(),V(),o.addSource(n,{type:"geojson",data:d}),o.addSource(n+"area",{type:"geojson",data:_}),it(o,n,n),Fe(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),Ne(o,n+"point",n),rt(o,n+"area",n+"area",{}),c=!1,o.on("mousemove",F),o.on("contextmenu",E)),d.geometry.coordinates[0].length>=3&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(x.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),v.push(x.point),o.getSource(n).setData(d),w(!0)},p=x=>{c&&(b(),V(),o.addSource(n,{type:"geojson",data:d}),o.addSource(n+"area",{type:"geojson",data:_}),it(o,n,n,a),Fe(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),rt(o,n+"area",n+"area",{}),c=!1,d.geometry.coordinates[0].push(x.lngLat.toArray()),o.getSource(n).setData(d),o.on("mousemove",F),o.on("contextmenu",E),w(!0))},m=x=>{if(c){b(),V(),o.addSource(n,{type:"geojson",data:d}),o.addSource(n+"area",{type:"geojson",data:_}),o.addSource(n+"point",{type:"geojson",data:h}),it(o,n,n,a),Fe(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),Ne(o,n+"point",n+"point"),rt(o,n+"area",n+"area",{}),c=!1;const k={type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}};h.features.push(R(k)),h.features.push(R(k)),_.geometry.coordinates=x.lngLat.toArray(),o.getSource(n+"point").setData(h),o.on("mousemove",F),o.on("contextmenu",E),w(!0)}},b=()=>{n=M(),i.push(n),s.push(n)},M=()=>{let x=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(C){const N=(x+Math.random()*16)%16|0;return x=Math.floor(x/16),(C==="x"?N:N&3|8).toString(16)})},w=x=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(C=>{x?o[C].disable():o[C].enable()})},L=x=>{switch(r){case"symbol":$(x);break;case"point":O(x);break;case"line":f(x);break;case"polygon":y(x);break;case"free":p(x);break;case"circle":m(x);break}},D=x=>{switch(r){case"line":if(g.geometry.coordinates.length){g.geometry.coordinates.length==1&&g.geometry.coordinates.push(x.lngLat.toArray()),g.geometry.coordinates[g.geometry.coordinates.length-1]=x.lngLat.toArray(),o.getSource(n).setData(g);const ne=g.geometry.coordinates[g.geometry.coordinates.length-2],Q=g.geometry.coordinates[g.geometry.coordinates.length-1],he=rr(ne,Q,{units:"kilometers"}),ie=fi(Se(ne),Se(Q)),re=h.features[h.features.length-1];re.properties.result=mt(he,4)+"km",re.geometry.coordinates=ie.geometry.coordinates,o.getSource(n+"text").setData(R(h))}break;case"polygon":const H=d.geometry.coordinates[0].length;if(H){H==2?d.geometry.coordinates[0][H-1]=x.lngLat.toArray():d.geometry.coordinates[0][H-2]=x.lngLat.toArray();const te=Jt(d)/1e6;if(H>=4){var k=Ue(d.geometry.coordinates),C=sr(k);_.geometry.coordinates=C.geometry.coordinates,_.properties.result=mt(te,2)+"km²"}const ne=o.getSource(n);ne.setData(d),o.getSource(n+"area").setData(_),l&&d.geometry.coordinates[0].length>=3&&ne.setData(j(d))}break;case"free":const oe=d.geometry.coordinates[0].length;if(oe){v.push(x.point),d.geometry.coordinates[0].length!=1&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(x.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]);const te=Jt(d)/1e6;if(oe>=4){var k=Ue(d.geometry.coordinates),C=sr(k);_.geometry.coordinates=C.geometry.coordinates,_.properties.result=mt(te,2)+"km²"}o.getSource(n).setData(d),o.getSource(n+"area").setData(_)}break;case"circle":if(h.features.length){h.features[1].geometry.coordinates=x.lngLat.toArray();var N=Se(h.features[0].geometry.coordinates),W=Se(h.features[1].geometry.coordinates),J=rr(N,W,{units:"miles"}),q={steps:500,units:"miles",properties:{foo:"bar"}},G=Oo(N,J,q);d.geometry.coordinates=G.geometry.coordinates;const te=Jt(d)/1e6;_.properties.result=mt(te,2)+"km²";const ne=o.getSource(n+"point"),Q=o.getSource(n),he=o.getSource(n+"area");ne.setData(h),Q.setData(d),he.setData(_)}break}},E=x=>{x.preventDefault(),o.off("mousemove",F),o.off("contextmenu",E),c=!0,v.push(x.point),w(!1);const k=o.getSource(n);switch(r){case"line":g.geometry.coordinates.length&&(console.log(g),k.setData(R(g)),o.removeLayer(n+"point"),l&&g.geometry.coordinates.length>=2&&k.setData(T(g)));break;case"polygon":d.geometry.coordinates[0].length&&k.setData(R(d)),o.setLayoutProperty(n+"point","visibility","none"),l&&k.setData(R(j(d)));break;case"free":if(d.geometry.coordinates[0].length&&(k.setData(R(d)),l)){const C=[...v.slice(v.length/5),...v.slice(0,v.length/5),v.slice(v.length/5)[0]],N=C.length>10?5:3,W=Math.ceil(C.length/N),J=[];for(let G=0;G<C.length;G+=W)J.push(C.slice(G,G+W));let q=[];J.forEach(G=>{if(G.length>1){const oe=new Z(G).getLUT();q.push(...oe)}else q.push(...G)}),d.geometry.coordinates[0].length=0;for(let G=0;G<q.length;G++){const H=o.unproject(q[G]);d.geometry.coordinates[0].push(H.toArray())}k.setData(R(d))}break;case"circle":o.removeLayer(n+"point"),o.removeSource(n+"point");break}e&&e(I())},I=()=>{const x=i,k=[];return x.forEach((C,N)=>{const J=o.getSource(C).serialize().data;J.features?(J.features[0].properties.layerId=C,J.features[0].properties.sourceId=s[N],k.push(...J.features)):(J.properties.layerId=C,J.properties.sourceId=s[N],k.push(J))}),k},j=x=>{let k=R(x);const C=Xe(k.geometry.coordinates[0]),N=st(C,{sharpness:.6});return k.geometry.coordinates[0]=N.geometry.coordinates,k},T=x=>{let k=R(x);console.log(k,"lineFeature");const C=Xe(k.geometry.coordinates),N=st(C,{sharpness:.6});return k.geometry.coordinates=N.geometry.coordinates,k},ce=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(k=>k!==x)},K=()=>{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")}),s.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,s.length=0},ee=()=>{o.off("click",L),o.off("mousemove",F),o.off("contextmenu",E),o.getCanvas().style.cursor="pointer",w(!1)},V=()=>{v.length=0,h.features.length=0,g.geometry.coordinates.length=0,d.geometry.coordinates.length=0,d.geometry.coordinates[0]=[],d.properties.result="",_.geometry.coordinates.length=0},F=((x,k)=>{let C=0;return function(...N){const W=new Date().getTime();W-C<k||(C=W,x(...N))}})(D,30);return{startMeasure:A,clearMeasure:K,stopMeasure:ee,getFeaturesFromMeasure:I,clearLayerById:ce}}const Vt=()=>{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)})},Ht=o=>{let e=R(o);const r=Xe(e.geometry.coordinates[0]),n=st(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates[0]=n.geometry.coordinates,e},Wt=o=>{const e=R(o),r=Xe(e.geometry.coordinates),n=st(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates=n.geometry.coordinates,e},mo=(o,e)=>{let r=0;return function(...n){const i=new Date().getTime();i-r<e||(r=i,o(...n))}},Zt=o=>["fill","line","circle","symbol"].includes(o.type)&&"source"in o&&o.source!=="maplibre",Je=(o,e,r,n)=>{if(!r||!r.geometry)return;switch(r.geometry.type){case"Point":case"MultiPoint":break;case"LineString":case"MultiLineString":Fe(o,e,e,n);break;case"Polygon":case"MultiPolygon":it(o,e,e,n),Fe(o,e+"outline",e,n);break}};class Za{constructor(e){B(this,"map");B(this,"historyStack",[]);B(this,"redoStack",[]);this.map=e}push(e){this.historyStack.push(e),this.redoStack=[]}undo(){const{map:e}=this,r=this.historyStack.pop();if(!r)return;switch(this.redoStack.push(r),r.type){case"add":case"clone":this.removeLayerWithOutline(r.layerId);break;case"remove":r.before&&this.addLayerWithOutline(r.layerId,r.before);break;case"edit":case"move":r.before&&ae(e,r.layerId,r.before);break}const n=this.historyStack[this.historyStack.length-1];(n==null?void 0:n.type)=="clone"&&this.undo()}redo(){const{map:e}=this,r=this.redoStack.pop();if(r)switch(this.historyStack.push(r),r.type){case"add":r.after&&this.addLayerWithOutline(r.layerId,r.after);break;case"clone":r.after&&this.addLayerWithOutline(r.layerId,r.after);const n=this.redoStack[this.redoStack.length-1];(n==null?void 0:n.type)=="move"&&this.redo();break;case"remove":this.removeLayerWithOutline(r.layerId);break;case"edit":case"move":r.after&&ae(e,r.layerId,r.after);break}}removeLayerWithOutline(e){se(this.map,e),se(this.map,e+"outline")}addLayerWithOutline(e,r){Je(this.map,e,r,{...r.properties})}getHistoryStack(){return this.historyStack}getRedoStack(){return this.redoStack}clear(){this.historyStack=[],this.redoStack=[]}}class Ka{constructor(e){B(this,"map");B(this,"eventMap",new Map);B(this,"uuid","");B(this,"toolMode","draw");B(this,"_followPointId","followPointId");B(this,"options",{drawMode:"polygon",smooth:!0,showFeature:!0,showLastFeatureOnly:!1,polyline:!0,drawFreeMouseMode:0,brushState:!1,brushSize:5e4});B(this,"newDraw",!0);B(this,"saveFreePolygonPoint",[]);B(this,"_activeLayer");B(this,"_cacheActiveLayerSource");B(this,"_editMode","idle");B(this,"_dragIndex",null);B(this,"_vertexSourceId","custom-vertex-source");B(this,"_vertexLayerId","custom-vertex-layer");B(this,"keydownHandler");B(this,"dragOptions",{cloneLayer:!1});B(this,"_isCloneLayer",!1);B(this,"_isDragging",!1);B(this,"_dragOrigin",null);B(this,"history");B(this,"_externalLayerIds",[]);B(this,"_onMapClick",this._onMapClick_.bind(this));B(this,"_onMapDblclick",this._onMapDblclick_.bind(this));B(this,"_onMapMousemove",mo(this._onMapMousemove_.bind(this),10));B(this,"_onMapMousedown",this._onMapMousedown_.bind(this));B(this,"_onMapMouseup",this._onMapMouseup_.bind(this));B(this,"_onMapMouseover",this._onMapMouseover_.bind(this));B(this,"_onMapMouseout",this._onMapMouseout_.bind(this));B(this,"_emitFinishBrushThrottled",mo(()=>{this.emit("finishBrush",R(this.polygonJson))},33));B(this,"pointJson",{type:"FeatureCollection",features:[]});B(this,"lineJson",{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}});B(this,"polygonJson",{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});B(this,"drawFreePolygon",e=>{if(e.originalEvent.button!==this.options.drawFreeMouseMode)return;const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),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}),Je(r,this.uuid,this.polygonJson,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),this._setMapActionEvents(!1))});B(this,"_getCoords",e=>{if(e.type!=="GeometryCollection"&&Array.isArray(e.coordinates)){if(e.type==="Polygon"&&Array.isArray(e.coordinates[0]))return e.coordinates[0];if(e.type==="LineString"&&Array.isArray(e.coordinates))return e.coordinates}return[]});B(this,"getFeatureLatest",()=>{const{map:e}=this,r=this.history.getHistoryStack();return r.length?fe(e,r[r.length-1].layerId):void 0});B(this,"getFeatures",()=>{const{map:e}=this,r=this.history.getHistoryStack();return r.length?r.map(n=>fe(e,n.layerId)):[]});B(this,"addFeature",(e,r)=>{const{map:n}=this;if(!e||!e.geometry)return;const i=Vt();this._externalLayerIds.push(i);const s=R(e);s.properties={...this.options,...s.properties,...r,layerId:i,sourceId:i},Ae(n,i,{type:"geojson",data:s}),Je(n,i,s,s.properties)});B(this,"removeFeatures",()=>{const{map:e}=this;this._externalLayerIds.forEach(r=>{se(e,r),se(e,r+"outline"),xe(e,r)}),this._externalLayerIds.splice(0)});B(this,"setFeatureVisible",e=>{const{map:r}=this,n=this.history.getHistoryStack();n.length&&n.forEach(i=>{r.getLayer(i.layerId)&&r.setLayoutProperty(i.layerId,"visibility",e?"visible":"none"),r.getLayer(i.layerId+"outline")&&r.setLayoutProperty(i.layerId+"outline","visibility",e?"visible":"none")})});B(this,"setFeatureVisibleById",(e,r)=>{const{map:n}=this;n.getLayer(e)&&n.setLayoutProperty(e,"visibility",r?"visible":"none"),n.getLayer(e+"outline")&&n.setLayoutProperty(e+"outline","visibility",r?"visible":"none")});B(this,"undo",()=>{this._removeVertexPoints(),this._removeFollowPoints(),this.history.undo();const e=this.history.getHistoryStack();e.length&&this.options.showLastFeatureOnly&&(this.setFeatureVisible(!1),this.setFeatureVisibleById(e[e.length-1].layerId,!0))});B(this,"redo",()=>{this._removeVertexPoints(),this._removeFollowPoints(),this.history.redo();const e=this.history.getHistoryStack();e.length&&this.options.showLastFeatureOnly&&(this.setFeatureVisible(!1),this.setFeatureVisibleById(e[e.length-1].layerId,!0))});this.map=e,this.history=new Za(e),this.keydownHandler=this.onKeyDown.bind(this),window.addEventListener("keydown",this.keydownHandler)}_creatFollowPoints(e){const{map:r,_followPointId:n}=this;Ae(r,n,{type:"geojson",data:this.pointJson}),Ne(r,n,n,this.options);const i={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e}};this.pointJson.features.push(R(i)),this.pointJson.features.push(R(i)),ae(r,n,R(this.pointJson))}_updateFollowPoints(e){const{map:r,_followPointId:n}=this;this.pointJson.features[1].geometry.coordinates=e,ae(r,n,R(this.pointJson))}_removeFollowPoints(){const{map:e,_followPointId:r}=this;se(e,r),xe(e,r)}drawPoint(e){const{map:r}=this;this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.pointJson}),Ne(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()}}),ae(r,this.uuid,R(this.pointJson)),this.emit("finishDraw",this.getFeatureLatest())}drawLine(e){const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),this.options.showLastLineOnly&&this.setFeatureVisible(!1),this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.lineJson}),Je(r,this.uuid,this.lineJson,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(),ae(r,this.uuid,R(this.lineJson)),this._setMapActionEvents(!0),this._removeFollowPoints(),this.history.push({type:"add",layerId:this.uuid,after:fe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest()))}drawPolygon(e){const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.polygonJson}),Je(r,this.uuid,this.polygonJson,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=r/2,i=111320,s=Math.cos(e.lat*Math.PI/180),a=i*Math.max(Math.abs(s),1e-6),u=n/i,c=n/a,l=e.lng-c,v=e.lng+c,h=e.lat-u,g=e.lat+u;return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[l,h],[v,h],[v,g],[l,g],[l,h]]]}}}setBrushSize(e){this.options.brushSize=e*1e3}startDraw(e){const{map:r}=this;switch(Object.assign(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(),ae(r,this.uuid,this.options.smooth&&i>=2?Wt(this.lineJson):R(this.lineJson)));break;case"polygon":this._updateFollowPoints(n);const s=this.polygonJson.geometry.coordinates[0].length;s&&(s==2?this.polygonJson.geometry.coordinates[0][s-1]=n:this.polygonJson.geometry.coordinates[0][s-2]=n,s>=3&&ae(r,this.uuid,this.options.smooth?Ht(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]),ae(r,this.uuid,this.polygonJson));break;case"brush":const u=this._createRectangle(e.lngLat,this.options.brushSize??5e4);this.polygonJson.geometry=u.geometry,ae(r,this.uuid,this.polygonJson),this.options.brushState&&this._emitFinishBrushThrottled();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),this.lineJson.properties.feedbackFeature=R(this.lineJson),ae(r,this.uuid,this.options.smooth&&this.lineJson.geometry.coordinates.length>=2?Wt(this.lineJson):R(this.lineJson)),this.history.push({type:"add",layerId:this.uuid,after:fe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())):(se(r,this.uuid),se(r,this.uuid+"line"),xe(r,this.uuid),xe(r,this.uuid+"line"));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.showFeature||(r.setLayoutProperty(this.uuid,"visibility","none"),r.setLayoutProperty(this.uuid+"outline","visibility","none")),this.polygonJson.properties.feedbackFeature=R(this.polygonJson),ae(r,this.uuid,this.options.smooth?Ht(this.polygonJson):R(this.polygonJson)),this.history.push({type:"add",layerId:this.uuid,after:fe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())):(se(r,this.uuid),se(r,this.uuid+"line"),xe(r,this.uuid),xe(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}),Je(e,this.uuid,this.polygonJson,this.options);break}}_onMapMouseoutDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":se(e,this.uuid),se(e,this.uuid+"outline"),xe(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",R(this.polygonJson));break}}_onMapMouseupDraw(e){const{map:r}=this;switch(this.options.drawMode){case"freePolygon":if(e.originalEvent.button!==this.options.drawFreeMouseMode)return;if(r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.polygonJson.geometry.coordinates[0].length){this._removeFollowPoints();const a=this.polygonJson.geometry.coordinates[0].length;if(this.polygonJson.geometry.coordinates[0].splice(a-2,1),ae(r,this.uuid,R(this.polygonJson)),this.options.showFeature||(this.map.setLayoutProperty(this.uuid,"visibility","none"),this.map.setLayoutProperty(this.uuid+"outline","visibility","none")),a>=2&&this.options.smooth){const u=this.saveFreePolygonPoint,c=[...u.slice(u.length/5),...u.slice(0,u.length/5),u.slice(u.length/5)[0]],l=c.length>10?5:3,v=Math.ceil(c.length/l),h=[];for(let d=0;d<c.length;d+=v)h.push(c.slice(d,d+v));let g=[];h.forEach(d=>{if(d.length>1){const A=new Z(d).getLUT();g.push(...A)}else g.push(...d)}),this.polygonJson.geometry.coordinates[0].length=0;for(let d=0;d<g.length;d++){const _=this.map.unproject(g[d]);this.polygonJson.geometry.coordinates[0].push(_.toArray())}var n=Ue(this.polygonJson.geometry.coordinates),i={tolerance:.008,highQuality:!0},s=ni(n,i);this.polygonJson.geometry=s.geometry,ae(r,this.uuid,R(this.polygonJson))}this.history.push({type:"add",layerId:this.uuid,after:fe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())}else se(r,this.uuid),se(r,this.uuid+"outline"),xe(r,this.uuid);break;case"brush":r.dragPan.enable(),r.dragRotate.enable(),this.options.brushState=!1;break}}startEdit(){const{map:e}=this;this.stop(),this.toolMode="edit",this.setFeatureVisible(!0),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 s;const{map:e}=this,r=fe(e,this._activeLayer.source);if(!r)return;const n=(s=r.properties)!=null&&s.feedbackFeature?this._getCoords(r.properties.feedbackFeature.geometry):this._getCoords(r.geometry);if(!n.length)return;let i=[];r.geometry.type==="Polygon"&&n.length>2?i=n.slice(0,-1).map((a,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:a}})):r.geometry.type==="LineString"&&(i=n.map((a,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:a}}))),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"}})),ae(e,this._vertexSourceId,R({type:"FeatureCollection",features:i}))}_removeVertexPoints(){const{map:e,_vertexLayerId:r,_vertexSourceId:n}=this;se(e,r),xe(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 s=i.layer;Zt(s)&&!s.id.includes("outline")?(this._activeLayer&&this._activeLayer.id!==s.id&&(this._editMode="idle"),this._activeLayer=s,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 a,u,c;const{map:r}=this;if(this._editMode==="edit"&&this._dragIndex!==null){const l=fe(r,this._activeLayer.source);if(!l||!("geometry"in l))return;const v=(a=l.properties)==null?void 0:a.feedbackFeature,h=R(v?(u=l==null?void 0:l.properties)==null?void 0:u.feedbackFeature:l),{geometry:g}=h;if(g.type==="Polygon"){const d=g.coordinates[0];if(d[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],d.length>2&&(d[d.length-1]=d[0]),v){h.properties.feedbackFeature=R(h);const _=h.properties.smooth?Ht(R(h)):h;ae(r,this._activeLayer.source,_)}else ae(r,this._activeLayer.source,h);this._updateVertexPoints()}else if(g.type==="LineString"){const d=g.coordinates;if(d[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],v){h.properties.feedbackFeature=R(h);const _=h.properties.smooth?Wt(R(h)):h;ae(r,this._activeLayer.source,_)}else ae(r,this._activeLayer.source,h);this._updateVertexPoints()}}const n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0,s=((c=i==null?void 0:i.layer)==null?void 0:c.id)===this._vertexLayerId;this._setMapCursorStyle(s?"move":void 0)}_onMapMousedownEdit(e){var s,a;const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0;((s=i==null?void 0:i.layer)==null?void 0:s.id)===this._vertexLayerId?(this._dragIndex=((a=i==null?void 0:i.properties)==null?void 0:a.index)??null,this._setMapActionEvents(!1),this._cacheActiveLayerSource=fe(r,this._activeLayer.source),this.emit("startEdit",fe(r,this._activeLayer.source))):this._dragIndex=null}_onMapMouseupEdit(){const{map:e}=this;this._dragIndex=null,this._setMapActionEvents(!0),this.history.push({type:"edit",layerId:this._activeLayer.id,before:this._cacheActiveLayerSource,after:fe(e,this._activeLayer.source)}),this.emit("finishEdit",fe(e,this._activeLayer.source))}_onMapMouseoverEdit(){this.emit("editPointMouseover")}_onMapMouseoutEdit(){this.emit("editPointMouseout")}startDrag(e){const{map:r}=this;Object.assign(this.dragOptions,e),this.stop(),this.toolMode="drag",this.setFeatureVisible(!0),r.on("mousemove",this._onMapMousemove),r.on("mousedown",this._onMapMousedown),r.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 s,a;const{map:r}=this;if(this._isDragging&&this._dragOrigin&&this._activeLayer){if(this.dragOptions.cloneLayer&&!this._isCloneLayer){const g=Vt(),d=R(this._cacheActiveLayerSource);d.properties.layerId=g,d.properties.sourceId=g,Ae(r,g,{type:"geojson",data:d}),it(r,g,g,d.properties,this._activeLayer.id),Fe(r,g+"outline",g,d.options,this._activeLayer.id),this.history.push({type:"clone",layerId:g,after:d}),this._isCloneLayer=!0}const u=this._activeLayer.source,c=fe(r,u);if(!c||!("geometry"in c))return;const l=e.lngLat.lng-this._dragOrigin[0],v=e.lngLat.lat-this._dragOrigin[1];this._dragOrigin=[e.lngLat.lng,e.lngLat.lat];const{geometry:h}=c;if(c.geometry.type!=="GeometryCollection"&&h.type==="Polygon"){const d=c.geometry.coordinates[0].map(([_,A])=>[_+l,A+v]);if(c.geometry.coordinates[0]=d,(s=c==null?void 0:c.properties)!=null&&s.feedbackFeature){const A=c.properties.feedbackFeature.geometry.coordinates[0].map(([O,$])=>[O+l,$+v]);c.properties.feedbackFeature.geometry.coordinates[0]=A}ae(r,u,R(c));return}}const n=(a=r.queryRenderedFeatures(e.point))==null?void 0:a[0],i=n==null?void 0:n.layer;n&&i&&Zt(i)?this._setMapCursorStyle("move"):this._setMapCursorStyle()}_onMapMousedownDrag(e){if(e.originalEvent.button!==0)return;const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n==null?void 0:n[0];if(!i)return;const s=i.layer;Zt(s)&&(this._isDragging=!0,this._isCloneLayer=!1,this._dragOrigin=[e.lngLat.lng,e.lngLat.lat],this._activeLayer=s,this._setMapActionEvents(!1),this._cacheActiveLayerSource=fe(r,this._activeLayer.source),this.emit("startDrag",fe(r,this._activeLayer.source)))}_onMapMouseupDrag(){const{map:e}=this;if(this._isDragging)try{const r=fe(e,this._activeLayer.source);r&&this._cacheActiveLayerSource&&(qa(this._cacheActiveLayerSource,r)||(this.history.push({type:"move",layerId:this._activeLayer.id,before:this._cacheActiveLayerSource,after:r}),this.emit("finishDrag",r)))}catch(r){console.warn("[DrawTool] _onMapMouseupDrag error:",r)}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_(e){switch(this.toolMode){case"draw":this._onMapMouseupDraw(e);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}}onKeyDown(e){(e.key==="Delete"||e.key==="Backspace")&&this.deleteLayer()}deleteLayer(){const{map:e}=this;this._editMode=="edit"&&(se(e,this._activeLayer.id),se(e,this._activeLayer.id+"outline"),this._editMode="idle",this._removeVertexPoints(),this._setMapCursorStyle(),this.history.push({type:"remove",layerId:this._activeLayer.id,before:fe(e,this._activeLayer.source)}))}_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=Vt()}_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.stopDraw(),this.stopDrag(),this.stopEdit()}destroy(){this.stop(),this._clearJson(),this.clearLayers(),this.eventMap.clear(),this._cacheActiveLayerSource=void 0,window.removeEventListener("keydown",this.keydownHandler)}clearLayers(){const{map:e}=this;this.history.getHistoryStack().forEach(n=>{const i=n.layerId;se(e,i),se(e,i+"outline"),xe(e,i)}),this._externalLayerIds.forEach(n=>{se(e,n),se(e,n+"outline"),xe(e,n)}),this._removeVertexPoints(),this._removeFollowPoints(),this.history.clear(),this._externalLayerIds.splice(0)}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=Ka;exports.draw=Va;exports.measure=Wa;
|
|
1
|
+
"use strict";var mn=Object.defineProperty;var xn=(o,e,r)=>e in o?mn(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var B=(o,e,r)=>xn(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{abs:We,cos:be,sin:ze,acos:wn,atan2:Ze,sqrt:Pe,pow:me}=Math;function Ke(o){return o<0?-me(-o,1/3):me(o,1/3)}const xo=Math.PI,vt=2*xo,Le=xo/2,_n=1e-6,Ot=Number.MAX_SAFE_INTEGER||9007199254740991,It=Number.MIN_SAFE_INTEGER||-9007199254740991,Mn={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),Pe(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 s=e;if(n===0)return e[0].t=o,e[0];if(n===1){const u={x:i*s[0].x+o*s[1].x,y:i*s[0].y+o*s[1].y,t:o};return r&&(u.z=i*s[0].z+o*s[1].z),u}if(n<4){let u=i*i,c=o*o,l,v,h,g=0;n===2?(s=[s[0],s[1],s[2],Mn],l=u,v=i*o*2,h=c):n===3&&(l=u*i,v=u*o*3,h=i*c*3,g=o*c);const d={x:l*s[0].x+v*s[1].x+h*s[2].x+g*s[3].x,y:l*s[0].y+v*s[1].y+h*s[2].y+g*s[3].y,t:o};return r&&(d.z=l*s[0].z+v*s[1].z+h*s[2].z+g*s[3].z),d}const a=JSON.parse(JSON.stringify(e));for(;a.length>1;){for(let u=0;u<a.length-1;u++)a[u]={x:a[u].x+(a[u+1].x-a[u].x)*o,y:a[u].y+(a[u+1].y-a[u].y)*o},typeof a[u].z<"u"&&(a[u].z=a[u].z+(a[u+1].z-a[u].z)*o);a.splice(a.length-1,1)}return a[0].t=o,a[0]},computeWithRatios:function(o,e,r,n){const i=1-o,s=r,a=e;let u=s[0],c=s[1],l=s[2],v=s[3],h;if(u*=i,c*=o,a.length===2)return h=u+c,{x:(u*a[0].x+c*a[1].x)/h,y:(u*a[0].y+c*a[1].y)/h,z:n?(u*a[0].z+c*a[1].z)/h:!1,t:o};if(u*=i,c*=2*i,l*=o*o,a.length===3)return h=u+c+l,{x:(u*a[0].x+c*a[1].x+l*a[2].x)/h,y:(u*a[0].y+c*a[1].y+l*a[2].y)/h,z:n?(u*a[0].z+c*a[1].z+l*a[2].z)/h:!1,t:o};if(u*=i,c*=1.5*i,l*=3*i,v*=o*o*o,a.length===4)return h=u+c+l+v,{x:(u*a[0].x+c*a[1].x+l*a[2].x+v*a[3].x)/h,y:(u*a[0].y+c*a[1].y+l*a[2].y+v*a[3].y)/h,z:n?(u*a[0].z+c*a[1].z+l*a[2].z+v*a[3].z)/h:!1,t:o}},derive:function(o,e){const r=[];for(let n=o,i=n.length,s=i-1;i>1;i--,s--){const a=[];for(let u=0,c;u<s;u++)c={x:s*(n[u+1].x-n[u].x),y:s*(n[u+1].y-n[u].y)},e&&(c.z=s*(n[u+1].z-n[u].z)),a.push(c);r.push(a),n=a}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 We(o-e)<=(r||_n)},length:function(o){const r=S.Tvalues.length;let n=0;for(let i=0,s;i<r;i++)s=.5*S.Tvalues[i]+.5,n+=S.Cvalues[i]*S.arcfn(s,o);return .5*n},map:function(o,e,r,n,i){const s=r-e,a=i-n,u=o-e,c=u/s;return n+a*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,s=r.x-o.x,a=r.y-o.y,u=n*a-i*s,c=n*s+i*a;return Ze(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 Pe(r*r+n*n)},closest:function(o,e){let r=me(2,63),n,i;return o.forEach(function(s,a){i=S.dist(e,s),i<r&&(r=i,n=a)}),{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=me(o,e)+me(1-o,e),n=r-1;return We(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=me(1-o,e),n=me(o,e)+r;return r/n},lli8:function(o,e,r,n,i,s,a,u){const c=(o*n-e*r)*(i-a)-(o-r)*(i*u-s*a),l=(o*n-e*r)*(s-u)-(e-n)*(i*u-s*a),v=(o-r)*(s-u)-(e-n)*(i-a);return v==0?!1:{x:c/v,y:l/v}},lli4:function(o,e,r,n){const i=o.x,s=o.y,a=e.x,u=e.y,c=r.x,l=r.y,v=n.x,h=n.y;return S.lli8(i,s,a,u,c,l,v,h)},lli:function(o,e){return S.lli4(o,o.c,e,e.c)},makeline:function(o,e){return new Z(o.x,o.y,(o.x+e.x)/2,(o.y+e.y)/2,e.x,e.y)},findbbox:function(o){let e=Ot,r=Ot,n=It,i=It;return o.forEach(function(s){const a=s.bbox();e>a.x.min&&(e=a.x.min),r>a.y.min&&(r=a.y.min),n<a.x.max&&(n=a.x.max),i<a.y.max&&(i=a.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 s=[],a=[o.startcap,o.forward,o.back,o.endcap],u=[r.startcap,r.forward,r.back,r.endcap];return a.forEach(function(c){c.virtual||u.forEach(function(l){if(l.virtual)return;const v=c.intersects(l,i);v.length>0&&(v.c1=c,v.c2=l,v.s1=o,v.s2=r,s.push(v))})}),s},makeshape:function(o,e,r){const n=e.points.length,i=o.points.length,s=S.makeline(e.points[n-1],o.points[0]),a=S.makeline(o.points[i-1],e.points[0]),u={startcap:s,forward:o,back:e,endcap:a,bbox:S.findbbox([s,o,e,a])};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=Ot,i=It,s,a;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++)s=r[u],a=o.get(s),a[e]<n&&(n=a[e]),a[e]>i&&(i=a[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=-Ze(e.p2.y-n,e.p2.x-r),s=function(a){return{x:(a.x-r)*be(i)-(a.y-n)*ze(i),y:(a.x-r)*ze(i)+(a.y-n)*be(i)}};return o.map(s)},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,w=n[1].y,L=n[2].y,D=M-2*w+L;if(D!==0){const E=-Pe(w*w-M*L),I=-M+w,j=-(E+I)/D,T=-(-E+I)/D;return[j,T].filter(i)}else if(w!==L&&D===0)return[(2*w-L)/(2*w-2*L)].filter(i);return[]}const s=n[0].y,a=n[1].y,u=n[2].y,c=n[3].y;let l=-s+3*a-3*u+c,v=3*s-6*a+3*u,h=-3*s+3*a,g=s;if(S.approximately(l,0)){if(S.approximately(v,0))return S.approximately(h,0)?[]:[-g/h].filter(i);const M=Pe(h*h-4*v*g),w=2*v;return[(M-h)/w,(-h-M)/w].filter(i)}v/=l,h/=l,g/=l;const d=(3*h-v*v)/3,_=d/3,A=(2*v*v*v-9*v*h+27*g)/27,O=A/2,$=O*O+_*_*_;let f,y,p,m,b;if($<0){const M=-d/3,w=M*M*M,L=Pe(w),D=-A/(2*L),E=D<-1?-1:D>1?1:D,I=wn(E),j=Ke(L),T=2*j;return p=T*be(I/3)-v/3,m=T*be((I+vt)/3)-v/3,b=T*be((I+2*vt)/3)-v/3,[p,m,b].filter(i)}else{if($===0)return f=O<0?Ke(-O):-Ke(O),p=2*f-v/3,m=-f-v/3,[p,m].filter(i);{const M=Pe($);return f=Ke(-O+M),y=Ke(O+M),[f-y-v/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 s=-Pe(r*r-e*n),a=-e+r,u=-(s+a)/i,c=-(-s+a)/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 s,a,u,c,l=0,v=0;const h=S.compute(o,e),g=S.compute(o,r),d=h.x*h.x+h.y*h.y;if(n?(s=Pe(me(h.y*g.z-g.y*h.z,2)+me(h.z*g.x-g.z*h.x,2)+me(h.x*g.y-g.x*h.y,2)),a=me(d+h.z*h.z,3/2)):(s=h.x*g.y-h.y*g.x,a=me(d,3/2)),s===0||a===0)return{k:0,r:0};if(l=s/a,v=a/s,!i){const _=S.curvature(o-.001,e,r,n,!0).k,A=S.curvature(o+.001,e,r,n,!0).k;c=(A-l+(l-_))/2,u=(We(A-l)+We(l-_))/2}return{k:l,r:v,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,s=e[3].x*e[2].y,a=18*(-3*r+2*n+3*i-s),u=18*(3*r-n-3*i),c=18*(i-r);if(S.approximately(a,0)){if(!S.approximately(u,0)){let g=-c/u;if(0<=g&&g<=1)return[g]}return[]}const l=2*a;if(S.approximately(l,0))return[];const v=u*u-4*a*c;if(v<0)return[];const h=Math.sqrt(v);return[(h-u)/l,-(u+h)/l].filter(function(g){return 0<=g&&g<=1})},bboxoverlap:function(o,e){const r=["x","y"],n=r.length;for(let i=0,s,a,u,c;i<n;i++)if(s=r[i],a=o[s].mid,u=e[s].mid,c=(o[s].size+e[s].size)/2,We(a-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(),s=1e5,a=r||.5;if(n.x.size+n.y.size<a&&i.x.size+i.y.size<a)return[(s*(o._t1+o._t2)/2|0)/s+"/"+(s*(e._t1+e._t2)/2|0)/s];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(h){return S.bboxoverlap(h.left.bbox(),h.right.bbox())});let v=[];return l.length===0||(l.forEach(function(h){v=v.concat(S.pairiteration(h.left,h.right,a))}),v=v.filter(function(h,g){return v.indexOf(h)===g})),v},getccenter:function(o,e,r){const n=e.x-o.x,i=e.y-o.y,s=r.x-e.x,a=r.y-e.y,u=n*be(Le)-i*ze(Le),c=n*ze(Le)+i*be(Le),l=s*be(Le)-a*ze(Le),v=s*ze(Le)+a*be(Le),h=(o.x+e.x)/2,g=(o.y+e.y)/2,d=(e.x+r.x)/2,_=(e.y+r.y)/2,A=h+u,O=g+c,$=d+l,f=_+v,y=S.lli8(h,g,A,O,d,_,$,f),p=S.dist(y,o);let m=Ze(o.y-y.y,o.x-y.x),b=Ze(e.y-y.y,e.x-y.x),M=Ze(r.y-y.y,r.x-y.x),w;return m<M?((m>b||b>M)&&(m+=vt),m>M&&(w=M,M=m,m=w)):M<b&&b<m?(w=M,M=m,m=w):M+=vt,y.s=m,y.e=M,y.r=p,y},numberSort:function(o,e){return o-e}};class ot{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 ot(r)}}const{abs:Qe,min:_r,max:Mr,cos:bn,sin:Sn,acos:Pn,sqrt:et}=Math,Ln=Math.PI;class Z{constructor(e){let r=e&&e.forEach?e:Array.from(arguments).slice(),n=!1;if(typeof r[0]=="object"){n=r.length;const d=[];r.forEach(function(_){["x","y","z"].forEach(function(A){typeof _[A]<"u"&&d.push(_[A])})}),r=d}let i=!1;const s=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(s!==6&&s!==8&&s!==9&&s!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const a=this._3d=!i&&(s===9||s===12)||e&&e[0]&&typeof e[0].z<"u",u=this.points=[];for(let d=0,_=a?3:2;d<s;d+=_){var c={x:r[d],y:r[d+1]};a&&(c.z=r[d+2]),u.push(c)}const l=this.order=u.length-1,v=this.dims=["x","y"];a&&v.push("z"),this.dimlen=v.length;const h=S.align(u,{p1:u[0],p2:u[l]}),g=S.dist(u[0],u[l]);this._linear=h.reduce((d,_)=>d+Qe(_.y),0)<g/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 Z(r,r,n);if(i===1)return new Z(e,r,r);const s=Z.getABC(2,e,r,n,i);return new Z(e,s.A,n)}static cubicFromPoints(e,r,n,i,s){typeof i>"u"&&(i=.5);const a=Z.getABC(3,e,r,n,i);typeof s>"u"&&(s=S.dist(r,a.C));const u=s*(1-i)/i,c=S.dist(e,n),l=(n.x-e.x)/c,v=(n.y-e.y)/c,h=s*l,g=s*v,d=u*l,_=u*v,A={x:r.x-h,y:r.y-g},O={x:r.x+d,y:r.y+_},$=a.A,f={x:$.x+(A.x-$.x)/(1-i),y:$.y+(A.y-$.y)/(1-i)},y={x:$.x+(O.x-$.x)/i,y:$.y+(O.y-$.y)/i},p={x:e.x+(f.x-e.x)/i,y:e.y+(f.y-e.y)/i},m={x:n.x+(y.x-n.x)/(1-i),y:n.y+(y.y-n.y)/(1-i)};return new Z(e,p,m,n)}static getUtils(){return S}getUtils(){return Z.getUtils()}static get PolyBezier(){return ot}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 s=1,a=e.length;s<a;s++)i.push(e[s].x),i.push(e[s].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,s=.5){const a=S.projectionratio(s,e),u=1-a,c={x:a*r.x+u*i.x,y:a*r.y+u*i.y},l=S.abcratio(s,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 Z.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 s=0,a,u=0;s<n.length;s++)a=n[s],S.dist(a,e)<r&&(i.push(a),u+=s/n.length);return i.length?t/=i.length:!1}project(e){const r=this.getLUT(),n=r.length-1,i=S.closest(r,e),s=i.mpos,a=(s-1)/n,u=(s+1)/n,c=.1/n;let l=i.mdist,v=a,h=v,g;l+=1;for(let d;v<u+c;v+=c)g=this.compute(v),d=S.dist(e,g),d<l&&(l=d,h=v);return h=h<0?0:h>1?1:h,g=this.compute(h),g.t=h,g.d=l,g}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,s,a;i<n;i++)s=e[i],a=e[i-1],r[i]={x:(n-i)/n*s.x+i/n*a.x,y:(n-i)/n*s.y+i/n*a.y};return r[n]=e[n-1],new Z(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 Z(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=et(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=et(r.x*r.x+r.y*r.y+r.z*r.z),s=et(n.x*n.x+n.y*n.y+n.z*n.z);r.x/=i,r.y/=i,r.z/=i,n.x/=s,n.y/=s,n.z/=s;const a={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=et(a.x*a.x+a.y*a.y+a.z*a.z);a.x/=u,a.y/=u,a.z/=u;const c=[a.x*a.x,a.x*a.y-a.z,a.x*a.z+a.y,a.x*a.y+a.z,a.y*a.y,a.y*a.z-a.x,a.x*a.z-a.y,a.y*a.z+a.x,a.z*a.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=[],s=0;for(i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],this.order===3&&(i[s++]=r[3]);r.length>1;){n=[];for(let a=0,u,c=r.length-1;a<c;a++)u=S.lerp(e,r[a],r[a+1]),i[s++]=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 Z([n[0],n[3],n[5]]):new Z([n[0],n[4],n[7],n[9]]),right:this.order===2?new Z([n[5],n[4],n[2]]):new Z([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(a){return a[n]},s=this.dpoints[0].map(i);e[n]=S.droots(s),this.order===3&&(s=this.dpoints[1].map(i),e[n]=e[n].concat(S.droots(s))),e[n]=e[n].filter(function(a){return a>=0&&a<=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),s={c:n,n:i,x:n.x+i.x*r,y:n.y+i.y*r};return this._3d&&(s.z=n.z+i.z*r),s}if(this._linear){const n=this.normal(0),i=this.points.map(function(s){const a={x:s.x+e*n.x,y:s.y+e*n.y};return s.z&&n.z&&(a.z=s.z+e*n.z),a});return[new Z(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]),s=S.angle(this.points[0],this.points[3],this.points[2]);if(i>0&&s<0||i<0&&s>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(Pn(n))<Ln/3}reduce(){let e,r=0,n=0,i=.01,s,a=[],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],s=this.split(r,n),s._t1=r,s._t2=n,a.push(s),r=n;return a.forEach(function(l){for(r=0,n=0;n<=1;)for(n=r+i;n<=1+i;n+=i)if(s=l.split(r,n),!s.simple()){if(n-=i,Qe(r-n)<i)return[];s=l.split(r,n),s._t1=S.map(r,0,1,l._t1,l._t2),s._t2=S.map(n,0,1,l._t1,l._t2),u.push(s),r=n;break}r<1&&(s=l.split(r,1),s._t1=S.map(r,0,1,l._t1,l._t2),s._t2=l._t2,u.push(s))}),u}translate(e,r,n){n=typeof n=="number"?n:r;const i=this.order;let s=this.points.map((a,u)=>(1-u/i)*r+u/i*n);return new Z(this.points.map((a,u)=>({x:a.x+e.x*s[u],y:a.y+e.y*s[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,s=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):e,n?n(1):e);const a=n?n(0):e,u=n?n(1):e,c=[this.offset(0,10),this.offset(1,10)],l=[],v=S.lli4(c[0],c[0].c,c[1],c[1].c);if(!v)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(h){const g=l[h*r]=S.copy(s[h*r]);g.x+=(h?u:a)*c[h].n.x,g.y+=(h?u:a)*c[h].n.y}),n?([0,1].forEach(function(h){if(!(r===2&&h)){var g=s[h+1],d={x:g.x-v.x,y:g.y-v.y},_=n?n((h+1)/r):e;n&&!i&&(_=-_);var A=et(d.x*d.x+d.y*d.y);d.x/=A,d.y/=A,l[h+1]={x:g.x+_*d.x,y:g.y+_*d.y}}}),new Z(l)):([0,1].forEach(h=>{if(r===2&&h)return;const g=l[h*r],d=this.derivative(h),_={x:g.x+d.x,y:g.y+d.y};l[h+1]=S.lli4(g,_,v,s[h+1])}),new Z(l))}outline(e,r,n,i){if(r=r===void 0?e:r,this._linear){const m=this.normal(0),b=this.points[0],M=this.points[this.points.length-1];let w,L,D;n===void 0&&(n=e,i=r),w={x:b.x+m.x*e,y:b.y+m.y*e},D={x:M.x+m.x*n,y:M.y+m.y*n},L={x:(w.x+D.x)/2,y:(w.y+D.y)/2};const E=[w,L,D];w={x:b.x-m.x*r,y:b.y-m.y*r},D={x:M.x-m.x*i,y:M.y-m.y*i},L={x:(w.x+D.x)/2,y:(w.y+D.y)/2};const I=[D,L,w],j=S.makeline(I[2],E[0]),T=S.makeline(E[2],I[0]),le=[j,new Z(E),T,new Z(I)];return new ot(le)}const s=this.reduce(),a=s.length,u=[];let c=[],l,v=0,h=this.length();const g=typeof n<"u"&&typeof i<"u";function d(m,b,M,w,L){return function(D){const E=w/M,I=(w+L)/M,j=b-m;return S.map(D,0,1,m+E*j,m+I*j)}}s.forEach(function(m){const b=m.length();g?(u.push(m.scale(d(e,n,h,v,b))),c.push(m.scale(d(-r,-i,h,v,b)))):(u.push(m.scale(e)),c.push(m.scale(-r))),v+=b}),c=c.map(function(m){return l=m.points,l[3]?m.points=[l[3],l[2],l[1],l[0]]:m.points=[l[2],l[1],l[0]],m}).reverse();const _=u[0].points[0],A=u[a-1].points[u[a-1].points.length-1],O=c[a-1].points[c[a-1].points.length-1],$=c[0].points[0],f=S.makeline(O,_),y=S.makeline(A,$),p=[f].concat(u).concat([y]).concat(c);return new ot(p)}outlineshapes(e,r,n){r=r||e;const i=this.outline(e,r).curves,s=[];for(let a=1,u=i.length;a<u/2;a++){const c=S.makeshape(i[a],i[u-a],n);c.startcap.virtual=a>1,c.endcap.virtual=a<u/2-1,s.push(c)}return s}intersects(e,r){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof Z&&(e=e.reduce()),this.curveintersects(this.reduce(),e,r)):this.selfintersects(r)}lineIntersects(e){const r=_r(e.p1.x,e.p2.x),n=_r(e.p1.y,e.p2.y),i=Mr(e.p1.x,e.p2.x),s=Mr(e.p1.y,e.p2.y);return S.roots(this.points,e).filter(a=>{var u=this.get(a);return S.between(u.x,r,i)&&S.between(u.y,n,s)})}selfintersects(e){const r=this.reduce(),n=r.length-2,i=[];for(let s=0,a,u,c;s<n;s++)u=r.slice(s,s+1),c=r.slice(s+2),a=this.curveintersects(u,c,e),i.push(...a);return i}curveintersects(e,r,n){const i=[];e.forEach(function(a){r.forEach(function(u){a.overlaps(u)&&i.push({left:a,right:u})})});let s=[];return i.forEach(function(a){const u=S.pairiteration(a.left,a.right,n);u.length>0&&(s=s.concat(u))}),s}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,r,n,i){const s=(i-n)/4,a=this.get(n+s),u=this.get(i-s),c=S.dist(e,r),l=S.dist(e,a),v=S.dist(e,u);return Qe(l-c)+Qe(v-c)}_iterate(e,r){let n=0,i=1,s;do{s=0,i=1;let a=this.get(n),u,c,l,v,h=!1,g=!1,d,_=i,A=1;do if(g=h,v=l,_=(n+i)/2,u=this.get(_),c=this.get(i),l=S.getccenter(a,u,c),l.interval={start:n,end:i},h=this._error(l,a,n,i)<=e,d=g&&!h,d||(A=i),h){if(i>=1){if(l.interval.end=A=1,v=l,i>1){let $={x:l.x+l.r*bn(l.e),y:l.y+l.r*Sn(l.e)};l.e+=S.angle({x:l.x,y:l.y},$,this.get(1))}break}i=i+(i-n)/2}else i=_;while(!d&&s++<100);if(s>=100)break;v=v||l,r.push(v),n=A}while(i<1);return r}}var ge=63710088e-1,wo={centimeters:ge*100,centimetres:ge*100,degrees:ge/111325,feet:ge*3.28084,inches:ge*39.37,kilometers:ge/1e3,kilometres:ge/1e3,meters:ge,metres:ge,miles:ge/1609.344,millimeters:ge*1e3,millimetres:ge*1e3,nauticalmiles:ge/1852,radians:1,yards:ge*1.0936};function kt(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 Se(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(!br(o[0])||!br(o[1]))throw new Error("coordinates must contain numbers");var n={type:"Point",coordinates:o};return kt(n,e,r)}function Ue(o,e,r){r===void 0&&(r={});for(var n=0,i=o;n<i.length;n++){var s=i[n];if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<s[s.length-1].length;a++)if(s[s.length-1][a]!==s[0][a])throw new Error("First and last Position are not equivalent.")}var u={type:"Polygon",coordinates:o};return kt(u,e,r)}function Xe(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 kt(n,e,r)}function mt(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 An(o,e){e===void 0&&(e="kilometers");var r=wo[e];if(!r)throw new Error(e+" units is invalid");return o*r}function kn(o,e){e===void 0&&(e="kilometers");var r=wo[e];if(!r)throw new Error(e+" units is invalid");return o/r}function Kt(o){var e=o%(2*Math.PI);return e*180/Math.PI}function we(o){var e=o%360;return e*Math.PI/180}function br(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function Dn(o){return!!o&&o.constructor===Object}function ct(o,e,r){if(o!==null)for(var n,i,s,a,u,c,l,v=0,h=0,g,d=o.type,_=d==="FeatureCollection",A=d==="Feature",O=_?o.features.length:1,$=0;$<O;$++){l=_?o.features[$].geometry:A?o.geometry:o,g=l?l.type==="GeometryCollection":!1,u=g?l.geometries.length:1;for(var f=0;f<u;f++){var y=0,p=0;if(a=g?l.geometries[f]:l,a!==null){c=a.coordinates;var m=a.type;switch(v=r&&(m==="Polygon"||m==="MultiPolygon")?1:0,m){case null:break;case"Point":if(e(c,h,$,y,p)===!1)return!1;h++,y++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(e(c[n],h,$,y,p)===!1)return!1;h++,m==="MultiPoint"&&y++}m==="LineString"&&y++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-v;i++){if(e(c[n][i],h,$,y,p)===!1)return!1;h++}m==="MultiLineString"&&y++,m==="Polygon"&&p++}m==="Polygon"&&y++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(p=0,i=0;i<c[n].length;i++){for(s=0;s<c[n][i].length-v;s++){if(e(c[n][i][s],h,$,y,p)===!1)return!1;h++}p++}y++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(ct(a.geometries[n],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function _o(o,e){var r,n,i,s,a,u,c,l,v,h,g=0,d=o.type==="FeatureCollection",_=o.type==="Feature",A=d?o.features.length:1;for(r=0;r<A;r++){for(u=d?o.features[r].geometry:_?o.geometry:o,l=d?o.features[r].properties:_?o.properties:{},v=d?o.features[r].bbox:_?o.bbox:void 0,h=d?o.features[r].id:_?o.id:void 0,c=u?u.type==="GeometryCollection":!1,a=c?u.geometries.length:1,i=0;i<a;i++){if(s=c?u.geometries[i]:u,s===null){if(e(null,g,l,v,h)===!1)return!1;continue}switch(s.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(s,g,l,v,h)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<s.geometries.length;n++)if(e(s.geometries[n],g,l,v,h)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}g++}}function Fn(o,e,r){var n=r;return _o(o,function(i,s,a,u,c){n=e(n,i,s,a,u,c)}),n}function Qt(o){var e=[1/0,1/0,-1/0,-1/0];return ct(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}Qt.default=Qt;function Ye(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 _t(o){if(Array.isArray(o))return o;if(o.type==="Feature"){if(o.geometry!==null)return o.geometry.coordinates}else if(o.coordinates)return o.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function er(o){return o.type==="Feature"?o.geometry:o}function Mo(o,e){return o.type==="FeatureCollection"?"FeatureCollection":o.type==="GeometryCollection"?"GeometryCollection":o.type==="Feature"&&o.geometry!==null?o.geometry.type:o.type}var bo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function So(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function En(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 lr={exports:{}},Po={exports:{}};(function(o,e){(function(r,n){o.exports=n()})(bo,function(){function r(f,y,p,m,b){(function M(w,L,D,E,I){for(;E>D;){if(E-D>600){var j=E-D+1,T=L-D+1,le=Math.log(j),K=.5*Math.exp(2*le/3),ee=.5*Math.sqrt(le*K*(j-K)/j)*(T-j/2<0?-1:1),V=Math.max(D,Math.floor(L-T*K/j+ee)),he=Math.min(E,Math.floor(L+(j-T)*K/j+ee));M(w,L,V,he,I)}var F=w[L],x=D,k=E;for(n(w,D,L),I(w[E],F)>0&&n(w,D,E);x<k;){for(n(w,x,k),x++,k--;I(w[x],F)<0;)x++;for(;I(w[k],F)>0;)k--}I(w[D],F)===0?n(w,D,k):n(w,++k,E),k<=L&&(D=k+1),L<=k&&(E=k-1)}})(f,y,p||0,m||f.length-1,b||i)}function n(f,y,p){var m=f[y];f[y]=f[p],f[p]=m}function i(f,y){return f<y?-1:f>y?1:0}var s=function(f){f===void 0&&(f=9),this._maxEntries=Math.max(4,f),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function a(f,y,p){if(!p)return y.indexOf(f);for(var m=0;m<y.length;m++)if(p(f,y[m]))return m;return-1}function u(f,y){c(f,0,f.children.length,y,f)}function c(f,y,p,m,b){b||(b=O(null)),b.minX=1/0,b.minY=1/0,b.maxX=-1/0,b.maxY=-1/0;for(var M=y;M<p;M++){var w=f.children[M];l(b,f.leaf?m(w):w)}return b}function l(f,y){return f.minX=Math.min(f.minX,y.minX),f.minY=Math.min(f.minY,y.minY),f.maxX=Math.max(f.maxX,y.maxX),f.maxY=Math.max(f.maxY,y.maxY),f}function v(f,y){return f.minX-y.minX}function h(f,y){return f.minY-y.minY}function g(f){return(f.maxX-f.minX)*(f.maxY-f.minY)}function d(f){return f.maxX-f.minX+(f.maxY-f.minY)}function _(f,y){return f.minX<=y.minX&&f.minY<=y.minY&&y.maxX<=f.maxX&&y.maxY<=f.maxY}function A(f,y){return y.minX<=f.maxX&&y.minY<=f.maxY&&y.maxX>=f.minX&&y.maxY>=f.minY}function O(f){return{children:f,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function $(f,y,p,m,b){for(var M=[y,p];M.length;)if(!((p=M.pop())-(y=M.pop())<=m)){var w=y+Math.ceil((p-y)/m/2)*m;r(f,w,y,p,b),M.push(y,w,w,p)}}return s.prototype.all=function(){return this._all(this.data,[])},s.prototype.search=function(f){var y=this.data,p=[];if(!A(f,y))return p;for(var m=this.toBBox,b=[];y;){for(var M=0;M<y.children.length;M++){var w=y.children[M],L=y.leaf?m(w):w;A(f,L)&&(y.leaf?p.push(w):_(f,L)?this._all(w,p):b.push(w))}y=b.pop()}return p},s.prototype.collides=function(f){var y=this.data;if(!A(f,y))return!1;for(var p=[];y;){for(var m=0;m<y.children.length;m++){var b=y.children[m],M=y.leaf?this.toBBox(b):b;if(A(f,M)){if(y.leaf||_(f,M))return!0;p.push(b)}}y=p.pop()}return!1},s.prototype.load=function(f){if(!f||!f.length)return this;if(f.length<this._minEntries){for(var y=0;y<f.length;y++)this.insert(f[y]);return this}var p=this._build(f.slice(),0,f.length-1,0);if(this.data.children.length)if(this.data.height===p.height)this._splitRoot(this.data,p);else{if(this.data.height<p.height){var m=this.data;this.data=p,p=m}this._insert(p,this.data.height-p.height-1,!0)}else this.data=p;return this},s.prototype.insert=function(f){return f&&this._insert(f,this.data.height-1),this},s.prototype.clear=function(){return this.data=O([]),this},s.prototype.remove=function(f,y){if(!f)return this;for(var p,m,b,M=this.data,w=this.toBBox(f),L=[],D=[];M||L.length;){if(M||(M=L.pop(),m=L[L.length-1],p=D.pop(),b=!0),M.leaf){var E=a(f,M.children,y);if(E!==-1)return M.children.splice(E,1),L.push(M),this._condense(L),this}b||M.leaf||!_(M,w)?m?(p++,M=m.children[p],b=!1):M=null:(L.push(M),D.push(p),p=0,m=M,M=M.children[0])}return this},s.prototype.toBBox=function(f){return f},s.prototype.compareMinX=function(f,y){return f.minX-y.minX},s.prototype.compareMinY=function(f,y){return f.minY-y.minY},s.prototype.toJSON=function(){return this.data},s.prototype.fromJSON=function(f){return this.data=f,this},s.prototype._all=function(f,y){for(var p=[];f;)f.leaf?y.push.apply(y,f.children):p.push.apply(p,f.children),f=p.pop();return y},s.prototype._build=function(f,y,p,m){var b,M=p-y+1,w=this._maxEntries;if(M<=w)return u(b=O(f.slice(y,p+1)),this.toBBox),b;m||(m=Math.ceil(Math.log(M)/Math.log(w)),w=Math.ceil(M/Math.pow(w,m-1))),(b=O([])).leaf=!1,b.height=m;var L=Math.ceil(M/w),D=L*Math.ceil(Math.sqrt(w));$(f,y,p,D,this.compareMinX);for(var E=y;E<=p;E+=D){var I=Math.min(E+D-1,p);$(f,E,I,L,this.compareMinY);for(var j=E;j<=I;j+=L){var T=Math.min(j+L-1,I);b.children.push(this._build(f,j,T,m-1))}}return u(b,this.toBBox),b},s.prototype._chooseSubtree=function(f,y,p,m){for(;m.push(y),!y.leaf&&m.length-1!==p;){for(var b=1/0,M=1/0,w=void 0,L=0;L<y.children.length;L++){var D=y.children[L],E=g(D),I=(j=f,T=D,(Math.max(T.maxX,j.maxX)-Math.min(T.minX,j.minX))*(Math.max(T.maxY,j.maxY)-Math.min(T.minY,j.minY))-E);I<M?(M=I,b=E<b?E:b,w=D):I===M&&E<b&&(b=E,w=D)}y=w||y.children[0]}var j,T;return y},s.prototype._insert=function(f,y,p){var m=p?f:this.toBBox(f),b=[],M=this._chooseSubtree(m,this.data,y,b);for(M.children.push(f),l(M,m);y>=0&&b[y].children.length>this._maxEntries;)this._split(b,y),y--;this._adjustParentBBoxes(m,b,y)},s.prototype._split=function(f,y){var p=f[y],m=p.children.length,b=this._minEntries;this._chooseSplitAxis(p,b,m);var M=this._chooseSplitIndex(p,b,m),w=O(p.children.splice(M,p.children.length-M));w.height=p.height,w.leaf=p.leaf,u(p,this.toBBox),u(w,this.toBBox),y?f[y-1].children.push(w):this._splitRoot(p,w)},s.prototype._splitRoot=function(f,y){this.data=O([f,y]),this.data.height=f.height+1,this.data.leaf=!1,u(this.data,this.toBBox)},s.prototype._chooseSplitIndex=function(f,y,p){for(var m,b,M,w,L,D,E,I=1/0,j=1/0,T=y;T<=p-y;T++){var le=c(f,0,T,this.toBBox),K=c(f,T,p,this.toBBox),ee=(b=le,M=K,w=void 0,L=void 0,D=void 0,E=void 0,w=Math.max(b.minX,M.minX),L=Math.max(b.minY,M.minY),D=Math.min(b.maxX,M.maxX),E=Math.min(b.maxY,M.maxY),Math.max(0,D-w)*Math.max(0,E-L)),V=g(le)+g(K);ee<I?(I=ee,m=T,j=V<j?V:j):ee===I&&V<j&&(j=V,m=T)}return m||p-y},s.prototype._chooseSplitAxis=function(f,y,p){var m=f.leaf?this.compareMinX:v,b=f.leaf?this.compareMinY:h;this._allDistMargin(f,y,p,m)<this._allDistMargin(f,y,p,b)&&f.children.sort(m)},s.prototype._allDistMargin=function(f,y,p,m){f.children.sort(m);for(var b=this.toBBox,M=c(f,0,y,b),w=c(f,p-y,p,b),L=d(M)+d(w),D=y;D<p-y;D++){var E=f.children[D];l(M,f.leaf?b(E):E),L+=d(M)}for(var I=p-y-1;I>=y;I--){var j=f.children[I];l(w,f.leaf?b(j):j),L+=d(w)}return L},s.prototype._adjustParentBBoxes=function(f,y,p){for(var m=p;m>=0;m--)l(y[m],f)},s.prototype._condense=function(f){for(var y=f.length-1,p=void 0;y>=0;y--)f[y].children.length===0?y>0?(p=f[y-1].children).splice(p.indexOf(f[y]),1):this.clear():u(f[y],this.toBBox)},s})})(Po);var $n=Po.exports;class On{constructor(e=[],r=In){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 s=e-1>>1,a=r[s];if(n(i,a)>=0)break;r[e]=a,e=s}r[e]=i}_down(e){const{data:r,compare:n}=this,i=this.length>>1,s=r[e];for(;e<i;){let a=(e<<1)+1,u=r[a];const c=a+1;if(c<this.length&&n(r[c],u)<0&&(a=c,u=r[c]),n(u,s)>=0)break;r[e]=u,e=a}r[e]=s}}function In(o,e){return o<e?-1:o>e?1:0}const zn=Object.freeze(Object.defineProperty({__proto__:null,default:On},Symbol.toStringTag,{value:"Module"})),Cn=En(zn);var Dt={exports:{}},Rn=function(e,r,n,i){var s=e[0],a=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=(i-n)/2,l=0,v=c-1;l<c;v=l++){var h=r[n+l*2+0],g=r[n+l*2+1],d=r[n+v*2+0],_=r[n+v*2+1],A=g>a!=_>a&&s<(d-h)*(a-g)/(_-g)+h;A&&(u=!u)}return u},jn=function(e,r,n,i){var s=e[0],a=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=i-n,l=0,v=c-1;l<c;v=l++){var h=r[l+n][0],g=r[l+n][1],d=r[v+n][0],_=r[v+n][1],A=g>a!=_>a&&s<(d-h)*(a-g)/(_-g)+h;A&&(u=!u)}return u},Lo=Rn,Ao=jn;Dt.exports=function(e,r,n,i){return r.length>0&&Array.isArray(r[0])?Ao(e,r,n,i):Lo(e,r,n,i)};Dt.exports.nested=Ao;Dt.exports.flat=Lo;var Jn=Dt.exports,tr={exports:{}};(function(o,e){(function(r,n){n(e)})(bo,function(r){const i=33306690738754706e-32;function s(A,O,$,f,y){let p,m,b,M,w=O[0],L=f[0],D=0,E=0;L>w==L>-w?(p=w,w=O[++D]):(p=L,L=f[++E]);let I=0;if(D<A&&E<$)for(L>w==L>-w?(b=p-((m=w+p)-w),w=O[++D]):(b=p-((m=L+p)-L),L=f[++E]),p=m,b!==0&&(y[I++]=b);D<A&&E<$;)L>w==L>-w?(b=p-((m=p+w)-(M=m-p))+(w-M),w=O[++D]):(b=p-((m=p+L)-(M=m-p))+(L-M),L=f[++E]),p=m,b!==0&&(y[I++]=b);for(;D<A;)b=p-((m=p+w)-(M=m-p))+(w-M),w=O[++D],p=m,b!==0&&(y[I++]=b);for(;E<$;)b=p-((m=p+L)-(M=m-p))+(L-M),L=f[++E],p=m,b!==0&&(y[I++]=b);return p===0&&I!==0||(y[I++]=p),I}function a(A){return new Float64Array(A)}const u=33306690738754716e-32,c=22204460492503146e-32,l=11093356479670487e-47,v=a(4),h=a(8),g=a(12),d=a(16),_=a(4);r.orient2d=function(A,O,$,f,y,p){const m=(O-p)*($-y),b=(A-y)*(f-p),M=m-b;if(m===0||b===0||m>0!=b>0)return M;const w=Math.abs(m+b);return Math.abs(M)>=u*w?M:-function(L,D,E,I,j,T,le){let K,ee,V,he,F,x,k,C,N,W,J,q,G,H,oe,te,ne,Q;const fe=L-j,ie=E-j,re=D-T,de=I-T;F=(oe=(C=fe-(k=(x=134217729*fe)-(x-fe)))*(W=de-(N=(x=134217729*de)-(x-de)))-((H=fe*de)-k*N-C*N-k*W))-(J=oe-(ne=(C=re-(k=(x=134217729*re)-(x-re)))*(W=ie-(N=(x=134217729*ie)-(x-ie)))-((te=re*ie)-k*N-C*N-k*W))),v[0]=oe-(J+F)+(F-ne),F=(G=H-((q=H+J)-(F=q-H))+(J-F))-(J=G-te),v[1]=G-(J+F)+(F-te),F=(Q=q+J)-q,v[2]=q-(Q-F)+(J-F),v[3]=Q;let _e=function(He,Oe){let dt=Oe[0];for(let Ie=1;Ie<He;Ie++)dt+=Oe[Ie];return dt}(4,v),ke=c*le;if(_e>=ke||-_e>=ke||(K=L-(fe+(F=L-fe))+(F-j),V=E-(ie+(F=E-ie))+(F-j),ee=D-(re+(F=D-re))+(F-T),he=I-(de+(F=I-de))+(F-T),K===0&&ee===0&&V===0&&he===0)||(ke=l*le+i*Math.abs(_e),(_e+=fe*he+de*K-(re*V+ie*ee))>=ke||-_e>=ke))return _e;F=(oe=(C=K-(k=(x=134217729*K)-(x-K)))*(W=de-(N=(x=134217729*de)-(x-de)))-((H=K*de)-k*N-C*N-k*W))-(J=oe-(ne=(C=ee-(k=(x=134217729*ee)-(x-ee)))*(W=ie-(N=(x=134217729*ie)-(x-ie)))-((te=ee*ie)-k*N-C*N-k*W))),_[0]=oe-(J+F)+(F-ne),F=(G=H-((q=H+J)-(F=q-H))+(J-F))-(J=G-te),_[1]=G-(J+F)+(F-te),F=(Q=q+J)-q,_[2]=q-(Q-F)+(J-F),_[3]=Q;const pt=s(4,v,4,_,h);F=(oe=(C=fe-(k=(x=134217729*fe)-(x-fe)))*(W=he-(N=(x=134217729*he)-(x-he)))-((H=fe*he)-k*N-C*N-k*W))-(J=oe-(ne=(C=re-(k=(x=134217729*re)-(x-re)))*(W=V-(N=(x=134217729*V)-(x-V)))-((te=re*V)-k*N-C*N-k*W))),_[0]=oe-(J+F)+(F-ne),F=(G=H-((q=H+J)-(F=q-H))+(J-F))-(J=G-te),_[1]=G-(J+F)+(F-te),F=(Q=q+J)-q,_[2]=q-(Q-F)+(J-F),_[3]=Q;const $t=s(pt,h,4,_,g);F=(oe=(C=K-(k=(x=134217729*K)-(x-K)))*(W=he-(N=(x=134217729*he)-(x-he)))-((H=K*he)-k*N-C*N-k*W))-(J=oe-(ne=(C=ee-(k=(x=134217729*ee)-(x-ee)))*(W=V-(N=(x=134217729*V)-(x-V)))-((te=ee*V)-k*N-C*N-k*W))),_[0]=oe-(J+F)+(F-ne),F=(G=H-((q=H+J)-(F=q-H))+(J-F))-(J=G-te),_[1]=G-(J+F)+(F-te),F=(Q=q+J)-q,_[2]=q-(Q-F)+(J-F),_[3]=Q;const $e=s($t,g,4,_,d);return d[$e-1]}(A,O,$,f,y,p,w)},r.orient2dfast=function(A,O,$,f,y,p){return(O-p)*($-y)-(A-y)*(f-p)},Object.defineProperty(r,"__esModule",{value:!0})})})(tr,tr.exports);var Bn=tr.exports,Sr=$n,Mt=Cn,Nn=Jn,Tn=Bn.orient2d;Mt.default&&(Mt=Mt.default);lr.exports=ko;lr.exports.default=ko;function ko(o,e,r){e=Math.max(0,e===void 0?2:e),r=r||0;var n=qn(o),i=new Sr(16);i.toBBox=function(f){return{minX:f[0],minY:f[1],maxX:f[0],maxY:f[1]}},i.compareMinX=function(f,y){return f[0]-y[0]},i.compareMinY=function(f,y){return f[1]-y[1]},i.load(o);for(var s=[],a=0,u;a<n.length;a++){var c=n[a];i.remove(c),u=Ar(c,u),s.push(u)}var l=new Sr(16);for(a=0;a<s.length;a++)l.insert(zt(s[a]));for(var v=e*e,h=r*r;s.length;){var g=s.shift(),d=g.p,_=g.next.p,A=Ct(d,_);if(!(A<h)){var O=A/v;c=Un(i,g.prev.p,d,_,g.next.next.p,O,l),c&&Math.min(Ct(c,d),Ct(c,_))<=O&&(s.push(g),s.push(Ar(c,g)),i.remove(c),l.remove(g),l.insert(zt(g)),l.insert(zt(g.next)))}}g=u;var $=[];do $.push(g.p),g=g.next;while(g!==u);return $.push(g.p),$}function Un(o,e,r,n,i,s,a){for(var u=new Mt([],Xn),c=o.data;c;){for(var l=0;l<c.children.length;l++){var v=c.children[l],h=c.leaf?Rt(v,r,n):Yn(r,n,v);h>s||u.push({node:v,dist:h})}for(;u.length&&!u.peek().node.children;){var g=u.pop(),d=g.node,_=Rt(d,e,r),A=Rt(d,n,i);if(g.dist<_&&g.dist<A&&Lr(r,d,a)&&Lr(n,d,a))return d}c=u.pop(),c&&(c=c.node)}return null}function Xn(o,e){return o.dist-e.dist}function Yn(o,e,r){if(Pr(o,r)||Pr(e,r))return 0;var n=xt(o[0],o[1],e[0],e[1],r.minX,r.minY,r.maxX,r.minY);if(n===0)return 0;var i=xt(o[0],o[1],e[0],e[1],r.minX,r.minY,r.minX,r.maxY);if(i===0)return 0;var s=xt(o[0],o[1],e[0],e[1],r.maxX,r.minY,r.maxX,r.maxY);if(s===0)return 0;var a=xt(o[0],o[1],e[0],e[1],r.minX,r.maxY,r.maxX,r.maxY);return a===0?0:Math.min(n,i,s,a)}function Pr(o,e){return o[0]>=e.minX&&o[0]<=e.maxX&&o[1]>=e.minY&&o[1]<=e.maxY}function Lr(o,e,r){for(var n=Math.min(o[0],e[0]),i=Math.min(o[1],e[1]),s=Math.max(o[0],e[0]),a=Math.max(o[1],e[1]),u=r.search({minX:n,minY:i,maxX:s,maxY:a}),c=0;c<u.length;c++)if(Gn(u[c].p,u[c].next.p,o,e))return!1;return!0}function Be(o,e,r){return Tn(o[0],o[1],e[0],e[1],r[0],r[1])}function Gn(o,e,r,n){return o!==n&&e!==r&&Be(o,e,r)>0!=Be(o,e,n)>0&&Be(r,n,o)>0!=Be(r,n,e)>0}function zt(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 qn(o){for(var e=o[0],r=o[0],n=o[0],i=o[0],s=0;s<o.length;s++){var a=o[s];a[0]<e[0]&&(e=a),a[0]>n[0]&&(n=a),a[1]<r[1]&&(r=a),a[1]>i[1]&&(i=a)}var u=[e,r,n,i],c=u.slice();for(s=0;s<o.length;s++)Nn(o[s],u)||c.push(o[s]);return Hn(c)}function Ar(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 Rt(o,e,r){var n=e[0],i=e[1],s=r[0]-n,a=r[1]-i;if(s!==0||a!==0){var u=((o[0]-n)*s+(o[1]-i)*a)/(s*s+a*a);u>1?(n=r[0],i=r[1]):u>0&&(n+=s*u,i+=a*u)}return s=o[0]-n,a=o[1]-i,s*s+a*a}function xt(o,e,r,n,i,s,a,u){var c=r-o,l=n-e,v=a-i,h=u-s,g=o-i,d=e-s,_=c*c+l*l,A=c*v+l*h,O=v*v+h*h,$=c*g+l*d,f=v*g+h*d,y=_*O-A*A,p,m,b,M,w=y,L=y;y===0?(m=0,w=1,M=f,L=O):(m=A*f-O*$,M=_*f-A*$,m<0?(m=0,M=f,L=O):m>w&&(m=w,M=f+A,L=O)),M<0?(M=0,-$<0?m=0:-$>_?m=w:(m=-$,w=_)):M>L&&(M=L,-$+A<0?m=0:-$+A>_?m=w:(m=-$+A,w=_)),p=m===0?0:m/w,b=M===0?0:M/L;var D=(1-p)*o+p*r,E=(1-p)*e+p*n,I=(1-b)*i+b*a,j=(1-b)*s+b*u,T=I-D,le=j-E;return T*T+le*le}function Vn(o,e){return o[0]===e[0]?o[1]-e[1]:o[0]-e[0]}function Hn(o){o.sort(Vn);for(var e=[],r=0;r<o.length;r++){for(;e.length>=2&&Be(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&&Be(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 Wn=lr.exports;const Zn=So(Wn);function Kn(o,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var r=[];if(ct(o,function(i){r.push([i[0],i[1]])}),!r.length)return null;var n=Zn(r,e.concavity);return n.length>3?Ue([n]):null}function rr(o,e,r){r===void 0&&(r={});var n=Ye(o),i=Ye(e),s=we(i[1]-n[1]),a=we(i[0]-n[0]),u=we(n[1]),c=we(i[1]),l=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(u)*Math.cos(c);return An(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),r.units)}function R(o){if(!o)throw new Error("geojson is required");switch(o.type){case"Feature":return Do(o);case"FeatureCollection":return Qn(o);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return hr(o);default:throw new Error("unknown GeoJSON type")}}function Do(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=Fo(o.properties),e.geometry=hr(o.geometry),e}function Fo(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]=Fo(n):e[r]=n}),e}function Qn(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 Do(r)}),e}function hr(o){var e={type:o.type};return o.bbox&&(e.bbox=o.bbox),o.type==="GeometryCollection"?(e.geometries=o.geometries.map(function(r){return hr(r)}),e):(e.coordinates=Eo(o.coordinates),e)}function Eo(o){var e=o;return typeof e[0]!="object"?e.slice():e.map(function(r){return Eo(r)})}function or(o,e){e===void 0&&(e={});var r=typeof e=="object"?e.mutate:e;if(!o)throw new Error("geojson is required");var n=Mo(o),i=[];switch(n){case"LineString":i=jt(o);break;case"MultiLineString":case"Polygon":_t(o).forEach(function(a){i.push(jt(a))});break;case"MultiPolygon":_t(o).forEach(function(a){var u=[];a.forEach(function(c){u.push(jt(c))}),i.push(u)});break;case"Point":return o;case"MultiPoint":var s={};_t(o).forEach(function(a){var u=a.join("-");Object.prototype.hasOwnProperty.call(s,u)||(i.push(a),s[u]=!0)});break;default:throw new Error(n+" geometry not supported")}return o.coordinates?r===!0?(o.coordinates=i,o):{type:n,coordinates:i}:r===!0?(o.geometry.coordinates=i,o):kt({type:n,coordinates:i},o.properties,{bbox:o.bbox,id:o.id})}function jt(o){var e=_t(o);if(e.length===2&&!kr(e[0],e[1]))return e;var r=[],n=e.length-1,i=r.length;r.push(e[0]);for(var s=1;s<n;s++){var a=r[r.length-1];e[s][0]===a[0]&&e[s][1]===a[1]||(r.push(e[s]),i=r.length,i>2&&Dr(r[i-3],r[i-1],r[i-2])&&r.splice(r.length-2,1))}if(r.push(e[e.length-1]),i=r.length,kr(e[0],e[e.length-1])&&i<4)throw new Error("invalid polygon");return Dr(r[i-3],r[i-1],r[i-2])&&r.splice(r.length-2,1),r}function kr(o,e){return o[0]===e[0]&&o[1]===e[1]}function Dr(o,e,r){var n=r[0],i=r[1],s=o[0],a=o[1],u=e[0],c=e[1],l=n-s,v=i-a,h=u-s,g=c-a,d=l*g-v*h;return d!==0?!1:Math.abs(h)>=Math.abs(g)?h>0?s<=n&&n<=u:u<=n&&n<=s:g>0?a<=i&&i<=c:c<=i&&i<=a}function ei(o,e){var r=o.x-e.x,n=o.y-e.y;return r*r+n*n}function ti(o,e,r){var n=e.x,i=e.y,s=r.x-n,a=r.y-i;if(s!==0||a!==0){var u=((o.x-n)*s+(o.y-i)*a)/(s*s+a*a);u>1?(n=r.x,i=r.y):u>0&&(n+=s*u,i+=a*u)}return s=o.x-n,a=o.y-i,s*s+a*a}function ri(o,e){for(var r=o[0],n=[r],i,s=1,a=o.length;s<a;s++)i=o[s],ei(i,r)>e&&(n.push(i),r=i);return r!==i&&n.push(i),n}function nr(o,e,r,n,i){for(var s=n,a,u=e+1;u<r;u++){var c=ti(o[u],o[e],o[r]);c>s&&(a=u,s=c)}s>n&&(a-e>1&&nr(o,e,a,n,i),i.push(o[a]),r-a>1&&nr(o,a,r,n,i))}function oi(o,e){var r=o.length-1,n=[o[0]];return nr(o,0,r,e,n),n.push(o[r]),n}function ir(o,e,r){if(o.length<=2)return o;var n=e!==void 0?e*e:1;return o=r?o:ri(o,n),o=oi(o,n),o}function ni(o,e){if(e=e||{},!Dn(e))throw new Error("options is invalid");var r=e.tolerance!==void 0?e.tolerance:1,n=e.highQuality||!1,i=e.mutate||!1;if(!o)throw new Error("geojson is required");if(r&&r<0)throw new Error("invalid tolerance");return i!==!0&&(o=R(o)),_o(o,function(s){ii(s,r,n)}),o}function ii(o,e,r){var n=o.type;if(n==="Point"||n==="MultiPoint")return o;or(o,!0);var i=o.coordinates;switch(n){case"LineString":o.coordinates=Fr(i,e,r);break;case"MultiLineString":o.coordinates=i.map(function(s){return Fr(s,e,r)});break;case"Polygon":o.coordinates=Er(i,e,r);break;case"MultiPolygon":o.coordinates=i.map(function(s){return Er(s,e,r)})}return o}function Fr(o,e,r){return ir(o.map(function(n){return{x:n[0],y:n[1],z:n[2]}}),e,r).map(function(n){return n.z?[n.x,n.y,n.z]:[n.x,n.y]})}function Er(o,e,r){return o.map(function(n){var i=n.map(function(a){return{x:a[0],y:a[1]}});if(i.length<4)throw new Error("invalid polygon");for(var s=ir(i,e,r).map(function(a){return[a.x,a.y]});!si(s);)e-=e*.01,s=ir(i,e,r).map(function(a){return[a.x,a.y]});return(s[s.length-1][0]!==s[0][0]||s[s.length-1][1]!==s[0][1])&&s.push(s[0]),s})}function si(o){return o.length<3?!1:!(o.length===3&&o[2][0]===o[0][0]&&o[2][1]===o[0][1])}var ai=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 s=this.points[r+1].x-(this.centers[r].x+this.centers[r+1].x)/2,a=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+s),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r].y+a),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+s),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r+1].y+a),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 s=this.pos(i),a=Math.sqrt((s.x-n.x)*(s.x-n.x)+(s.y-n.y)*(s.y-n.y)+(s.z-n.z)*(s.z-n.z));a>e&&(r.push(i),n=s)}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),s=(this.length-1)*n-i;return ui(s,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])},o}();function ui(o,e,r,n,i){var s=ci(o),a={x:i.x*s[0]+n.x*s[1]+r.x*s[2]+e.x*s[3],y:i.y*s[0]+n.y*s[1]+r.y*s[2]+e.y*s[3],z:i.z*s[0]+n.z*s[1]+r.z*s[2]+e.z*s[3]};return a}function ci(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 st(o,e){e===void 0&&(e={});for(var r=e.resolution||1e4,n=e.sharpness||.85,i=[],s=er(o).coordinates.map(function(l){return{x:l[0],y:l[1]}}),a=new ai({duration:r,points:s,sharpness:n}),u=function(l){var v=a.pos(l);Math.floor(l/100)%2===0&&i.push([v.x,v.y])},c=0;c<a.duration;c+=10)u(c);return u(a.duration),Xe(i,e.properties)}function li(o,e){e===void 0&&(e={});var r=Number(o[0]),n=Number(o[1]),i=Number(o[2]),s=Number(o[3]);if(o.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var a=[r,n],u=[r,s],c=[i,s],l=[i,n];return Ue([[a,l,c,u,a]],e.properties,{bbox:o,id:e.id})}function $o(o,e,r,n){n===void 0&&(n={});var i=Ye(o),s=we(i[0]),a=we(i[1]),u=we(r),c=kn(e,n.units),l=Math.asin(Math.sin(a)*Math.cos(c)+Math.cos(a)*Math.sin(c)*Math.cos(u)),v=s+Math.atan2(Math.sin(u)*Math.sin(c)*Math.cos(a),Math.cos(c)-Math.sin(a)*Math.sin(l)),h=Kt(v),g=Kt(l);return Se([h,g],n.properties)}function Oo(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:{},s=[],a=0;a<n;a++)s.push($o(o,e,a*-360/n,r).geometry.coordinates);return s.push(s[0]),Ue([s],i)}function Io(o,e,r){if(r===void 0&&(r={}),r.final===!0)return hi(o,e);var n=Ye(o),i=Ye(e),s=we(n[0]),a=we(i[0]),u=we(n[1]),c=we(i[1]),l=Math.sin(a-s)*Math.cos(c),v=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(a-s);return Kt(Math.atan2(l,v))}function hi(o,e){var r=Io(e,o);return r=(r+180)%360,r}function fi(o,e){var r=rr(o,e),n=Io(o,e),i=$o(o,r/2,n);return i}function $r(o,e){e===void 0&&(e={});var r=0,n=0,i=0;return ct(o,function(s){r+=s[0],n+=s[1],i++},!0),Se([r/i,n/i],e.properties)}function sr(o,e){switch(e===void 0&&(e={}),Mo(o)){case"Point":return Se(Ye(o),e.properties);case"Polygon":var r=[];ct(o,function(p){r.push(p)});var n=$r(o,{properties:e.properties}),i=n.geometry.coordinates,s=0,a=0,u=0,c,l,v,h,g,d,_,A,O=r.map(function(p){return[p[0]-i[0],p[1]-i[1]]});for(c=0;c<r.length-1;c++)l=O[c],h=l[0],d=l[1],v=O[c+1],g=v[0],_=v[1],A=h*_-g*d,u+=A,s+=(h+g)*A,a+=(d+_)*A;if(u===0)return n;var $=u*.5,f=1/(6*$);return Se([i[0]+f*s,i[1]+f*a],e.properties);default:var y=Kn(o);return y?sr(y,{properties:e.properties}):$r(o,{properties:e.properties})}}var Or=6378137;function Jt(o){return Fn(o,function(e,r){return e+yi(r)},0)}function yi(o){var e=0,r;switch(o.type){case"Polygon":return Ir(o.coordinates);case"MultiPolygon":for(r=0;r<o.coordinates.length;r++)e+=Ir(o.coordinates[r]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function Ir(o){var e=0;if(o&&o.length>0){e+=Math.abs(zr(o[0]));for(var r=1;r<o.length;r++)e-=Math.abs(zr(o[r]))}return e}function zr(o){var e,r,n,i,s,a,u,c=0,l=o.length;if(l>2){for(u=0;u<l;u++)u===l-2?(i=l-2,s=l-1,a=0):u===l-1?(i=l-1,s=0,a=1):(i=u,s=u+1,a=u+2),e=o[i],r=o[s],n=o[a],c+=(Bt(n[0])-Bt(e[0]))*Math.sin(Bt(r[1]));c=c*Or*Or/2}return c}function Bt(o){return o*Math.PI/180}var Cr=Object.prototype.toString,zo=function(e){var r=Cr.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Cr.call(e.callee)==="[object Function]"),n},Nt,Rr;function pi(){if(Rr)return Nt;Rr=1;var o;if(!Object.keys){var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=zo,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),a=i.call(function(){},"prototype"),u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(g){var d=g.constructor;return d&&d.prototype===g},l={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},v=function(){if(typeof window>"u")return!1;for(var g in window)try{if(!l["$"+g]&&e.call(window,g)&&window[g]!==null&&typeof window[g]=="object")try{c(window[g])}catch{return!0}}catch{return!0}return!1}(),h=function(g){if(typeof window>"u"||!v)return c(g);try{return c(g)}catch{return!1}};o=function(d){var _=d!==null&&typeof d=="object",A=r.call(d)==="[object Function]",O=n(d),$=_&&r.call(d)==="[object String]",f=[];if(!_&&!A&&!O)throw new TypeError("Object.keys called on a non-object");var y=a&&A;if($&&d.length>0&&!e.call(d,0))for(var p=0;p<d.length;++p)f.push(String(p));if(O&&d.length>0)for(var m=0;m<d.length;++m)f.push(String(m));else for(var b in d)!(y&&b==="prototype")&&e.call(d,b)&&f.push(String(b));if(s)for(var M=h(d),w=0;w<u.length;++w)!(M&&u[w]==="constructor")&&e.call(d,u[w])&&f.push(u[w]);return f}}return Nt=o,Nt}var di=Array.prototype.slice,gi=zo,jr=Object.keys,bt=jr?function(e){return jr(e)}:pi(),Jr=Object.keys;bt.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return gi(n)?Jr(di.call(n)):Jr(n)})}else Object.keys=bt;return Object.keys||bt};var Co=bt,Ro=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var u=Object.getOwnPropertyDescriptor(e,r);if(u.value!==i||u.enumerable!==!0)return!1}return!0},vi=Ro,fr=function(){return vi()&&!!Symbol.toStringTag},jo=Object,Jo=Error,mi=EvalError,xi=RangeError,wi=ReferenceError,Bo=SyntaxError,qe=TypeError,_i=URIError,Mi=Math.abs,bi=Math.floor,Si=Math.max,Pi=Math.min,Li=Math.pow,Ai=Math.round,ki=Number.isNaN||function(e){return e!==e},Di=ki,Fi=function(e){return Di(e)||e===0?e:e<0?-1:1},Ei=Object.getOwnPropertyDescriptor,St=Ei;if(St)try{St([],"length")}catch{St=null}var Ve=St,Pt=Object.defineProperty||!1;if(Pt)try{Pt({},"a",{value:1})}catch{Pt=!1}var Ft=Pt,Tt,Br;function $i(){if(Br)return Tt;Br=1;var o=typeof Symbol<"u"&&Symbol,e=Ro;return Tt=function(){return typeof o!="function"||typeof Symbol!="function"||typeof o("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Tt}var No=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,Oi=jo,To=Oi.getPrototypeOf||null,Ii="Function.prototype.bind called on incompatible ",zi=Object.prototype.toString,Ci=Math.max,Ri="[object Function]",Nr=function(e,r){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var s=0;s<r.length;s+=1)n[s+e.length]=r[s];return n},ji=function(e,r){for(var n=[],i=r,s=0;i<e.length;i+=1,s+=1)n[s]=e[i];return n},Ji=function(o,e){for(var r="",n=0;n<o.length;n+=1)r+=o[n],n+1<o.length&&(r+=e);return r},Bi=function(e){var r=this;if(typeof r!="function"||zi.apply(r)!==Ri)throw new TypeError(Ii+r);for(var n=ji(arguments,1),i,s=function(){if(this instanceof i){var v=r.apply(this,Nr(n,arguments));return Object(v)===v?v:this}return r.apply(e,Nr(n,arguments))},a=Ci(0,r.length-n.length),u=[],c=0;c<a;c++)u[c]="$"+c;if(i=Function("binder","return function ("+Ji(u,",")+"){ return binder.apply(this,arguments); }")(s),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i},Ni=Bi,lt=Function.prototype.bind||Ni,yr=Function.prototype.call,pr=Function.prototype.apply,Ti=typeof Reflect<"u"&&Reflect&&Reflect.apply,Ui=lt,Xi=pr,Yi=yr,Gi=Ti,Uo=Gi||Ui.call(Yi,Xi),qi=lt,Vi=qe,Hi=yr,Wi=Uo,dr=function(e){if(e.length<1||typeof e[0]!="function")throw new Vi("a function is required");return Wi(qi,Hi,e)},Zi=dr,Tr=Ve,Xo;try{Xo=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var Ut=!!Xo&&Tr&&Tr(Object.prototype,"__proto__"),Yo=Object,Ur=Yo.getPrototypeOf,Ki=Ut&&typeof Ut.get=="function"?Zi([Ut.get]):typeof Ur=="function"?function(e){return Ur(e==null?e:Yo(e))}:!1,Xr=No,Yr=To,Gr=Ki,Go=Xr?function(e){return Xr(e)}:Yr?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Yr(e)}:Gr?function(e){return Gr(e)}:null,Qi=Function.prototype.call,es=Object.prototype.hasOwnProperty,ts=lt,qo=ts.call(Qi,es),X,rs=jo,os=Jo,ns=mi,is=xi,ss=wi,Ge=Bo,Te=qe,as=_i,us=Mi,cs=bi,ls=Si,hs=Pi,fs=Li,ys=Ai,ps=Fi,Vo=Function,Xt=function(o){try{return Vo('"use strict"; return ('+o+").constructor;")()}catch{}},at=Ve,ds=Ft,Yt=function(){throw new Te},gs=at?function(){try{return arguments.callee,Yt}catch{try{return at(arguments,"callee").get}catch{return Yt}}}():Yt,Ce=$i()(),ce=Go,vs=To,ms=No,Ho=pr,ht=yr,je={},xs=typeof Uint8Array>"u"||!ce?X:ce(Uint8Array),Ee={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?X:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?X:ArrayBuffer,"%ArrayIteratorPrototype%":Ce&&ce?ce([][Symbol.iterator]()):X,"%AsyncFromSyncIteratorPrototype%":X,"%AsyncFunction%":je,"%AsyncGenerator%":je,"%AsyncGeneratorFunction%":je,"%AsyncIteratorPrototype%":je,"%Atomics%":typeof Atomics>"u"?X:Atomics,"%BigInt%":typeof BigInt>"u"?X:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?X:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?X:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?X:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":os,"%eval%":eval,"%EvalError%":ns,"%Float16Array%":typeof Float16Array>"u"?X:Float16Array,"%Float32Array%":typeof Float32Array>"u"?X:Float32Array,"%Float64Array%":typeof Float64Array>"u"?X:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?X:FinalizationRegistry,"%Function%":Vo,"%GeneratorFunction%":je,"%Int8Array%":typeof Int8Array>"u"?X:Int8Array,"%Int16Array%":typeof Int16Array>"u"?X:Int16Array,"%Int32Array%":typeof Int32Array>"u"?X:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ce&&ce?ce(ce([][Symbol.iterator]())):X,"%JSON%":typeof JSON=="object"?JSON:X,"%Map%":typeof Map>"u"?X:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ce||!ce?X:ce(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":rs,"%Object.getOwnPropertyDescriptor%":at,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?X:Promise,"%Proxy%":typeof Proxy>"u"?X:Proxy,"%RangeError%":is,"%ReferenceError%":ss,"%Reflect%":typeof Reflect>"u"?X:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?X:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ce||!ce?X:ce(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?X:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ce&&ce?ce(""[Symbol.iterator]()):X,"%Symbol%":Ce?Symbol:X,"%SyntaxError%":Ge,"%ThrowTypeError%":gs,"%TypedArray%":xs,"%TypeError%":Te,"%Uint8Array%":typeof Uint8Array>"u"?X:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?X:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?X:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?X:Uint32Array,"%URIError%":as,"%WeakMap%":typeof WeakMap>"u"?X:WeakMap,"%WeakRef%":typeof WeakRef>"u"?X:WeakRef,"%WeakSet%":typeof WeakSet>"u"?X:WeakSet,"%Function.prototype.call%":ht,"%Function.prototype.apply%":Ho,"%Object.defineProperty%":ds,"%Object.getPrototypeOf%":vs,"%Math.abs%":us,"%Math.floor%":cs,"%Math.max%":ls,"%Math.min%":hs,"%Math.pow%":fs,"%Math.round%":ys,"%Math.sign%":ps,"%Reflect.getPrototypeOf%":ms};if(ce)try{null.error}catch(o){var ws=ce(ce(o));Ee["%Error.prototype%"]=ws}var _s=function o(e){var r;if(e==="%AsyncFunction%")r=Xt("async function () {}");else if(e==="%GeneratorFunction%")r=Xt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Xt("async function* () {}");else if(e==="%AsyncGenerator%"){var n=o("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=o("%AsyncGenerator%");i&&ce&&(r=ce(i.prototype))}return Ee[e]=r,r},qr={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ft=lt,Lt=qo,Ms=ft.call(ht,Array.prototype.concat),bs=ft.call(Ho,Array.prototype.splice),Vr=ft.call(ht,String.prototype.replace),At=ft.call(ht,String.prototype.slice),Ss=ft.call(ht,RegExp.prototype.exec),Ps=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ls=/\\(\\)?/g,As=function(e){var r=At(e,0,1),n=At(e,-1);if(r==="%"&&n!=="%")throw new Ge("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Ge("invalid intrinsic syntax, expected opening `%`");var i=[];return Vr(e,Ps,function(s,a,u,c){i[i.length]=u?Vr(c,Ls,"$1"):a||s}),i},ks=function(e,r){var n=e,i;if(Lt(qr,n)&&(i=qr[n],n="%"+i[0]+"%"),Lt(Ee,n)){var s=Ee[n];if(s===je&&(s=_s(n)),typeof s>"u"&&!r)throw new Te("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new Ge("intrinsic "+e+" does not exist!")},Wo=function(e,r){if(typeof e!="string"||e.length===0)throw new Te("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Te('"allowMissing" argument must be a boolean');if(Ss(/^%?[^%]*%?$/,e)===null)throw new Ge("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=As(e),i=n.length>0?n[0]:"",s=ks("%"+i+"%",r),a=s.name,u=s.value,c=!1,l=s.alias;l&&(i=l[0],bs(n,Ms([0,1],l)));for(var v=1,h=!0;v<n.length;v+=1){var g=n[v],d=At(g,0,1),_=At(g,-1);if((d==='"'||d==="'"||d==="`"||_==='"'||_==="'"||_==="`")&&d!==_)throw new Ge("property names with quotes must have matching quotes");if((g==="constructor"||!h)&&(c=!0),i+="."+g,a="%"+i+"%",Lt(Ee,a))u=Ee[a];else if(u!=null){if(!(g in u)){if(!r)throw new Te("base intrinsic for "+e+" exists, but the property is not available.");return}if(at&&v+1>=n.length){var A=at(u,g);h=!!A,h&&"get"in A&&!("originalValue"in A.get)?u=A.get:u=u[g]}else h=Lt(u,g),u=u[g];h&&!c&&(Ee[a]=u)}}return u},Zo=Wo,Ko=dr,Ds=Ko([Zo("%String.prototype.indexOf%")]),gr=function(e,r){var n=Zo(e,!!r);return typeof n=="function"&&Ds(e,".prototype.")>-1?Ko([n]):n},Fs=fr(),Es=gr,ar=Es("Object.prototype.toString"),Et=function(e){return Fs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:ar(e)==="[object Arguments]"},Qo=function(e){return Et(e)?!0:e!==null&&typeof e=="object"&&"length"in e&&typeof e.length=="number"&&e.length>=0&&ar(e)!=="[object Array]"&&"callee"in e&&ar(e.callee)==="[object Function]"},$s=function(){return Et(arguments)}();Et.isLegacyArguments=Qo;var Os=$s?Et:Qo,Hr=Ft,Is=Bo,Re=qe,Wr=Ve,vr=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Re("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Re("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Re("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Re("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Re("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Re("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,c=!!Wr&&Wr(e,r);if(Hr)Hr(e,r,{configurable:a===null&&c?c.configurable:!a,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(u||!i&&!s&&!a)e[r]=n;else throw new Is("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ur=Ft,en=function(){return!!ur};en.hasArrayLengthDefineBug=function(){if(!ur)return null;try{return ur([],"length",{value:1}).length!==1}catch{return!0}};var mr=en,zs=Co,Cs=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Rs=Object.prototype.toString,js=Array.prototype.concat,Zr=vr,Js=function(o){return typeof o=="function"&&Rs.call(o)==="[object Function]"},tn=mr(),Bs=function(o,e,r,n){if(e in o){if(n===!0){if(o[e]===r)return}else if(!Js(n)||!n())return}tn?Zr(o,e,r,!0):Zr(o,e,r)},rn=function(o,e){var r=arguments.length>2?arguments[2]:{},n=zs(e);Cs&&(n=js.call(n,Object.getOwnPropertySymbols(e)));for(var i=0;i<n.length;i+=1)Bs(o,n[i],e[n[i]],r[n[i]])};rn.supportsDescriptors=!!tn;var yt=rn,on={exports:{}},Ns=Wo,Kr=vr,Ts=mr(),Qr=Ve,eo=qe,Us=Ns("%Math.floor%"),Xs=function(e,r){if(typeof e!="function")throw new eo("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Us(r)!==r)throw new eo("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Qr){var a=Qr(e,"length");a&&!a.configurable&&(i=!1),a&&!a.writable&&(s=!1)}return(i||s||!n)&&(Ts?Kr(e,"length",r,!0,!0):Kr(e,"length",r)),e},Ys=lt,Gs=pr,qs=Uo,Vs=function(){return qs(Ys,Gs,arguments)};(function(o){var e=Xs,r=Ft,n=dr,i=Vs;o.exports=function(a){var u=n(arguments),c=a.length-(arguments.length-1);return e(u,1+(c>0?c:0),!0)},r?r(o.exports,"apply",{value:i}):o.exports.apply=i})(on);var nn=on.exports,to=function(o){return o!==o},sn=function(e,r){return e===0&&r===0?1/e===1/r:!!(e===r||to(e)&&to(r))},Hs=sn,an=function(){return typeof Object.is=="function"?Object.is:Hs},Ws=an,Zs=yt,Ks=function(){var e=Ws();return Zs(Object,{is:e},{is:function(){return Object.is!==e}}),e},Qs=yt,ea=nn,ta=sn,un=an,ra=Ks,cn=ea(un(),Object);Qs(cn,{getPolyfill:un,implementation:ta,shim:ra});var oa=cn,ro=gr,na=fr(),ia=qo,sa=Ve,cr;if(na){var aa=ro("RegExp.prototype.exec"),oo={},Gt=function(){throw oo},no={toString:Gt,valueOf:Gt};typeof Symbol.toPrimitive=="symbol"&&(no[Symbol.toPrimitive]=Gt),cr=function(e){if(!e||typeof e!="object")return!1;var r=sa(e,"lastIndex"),n=r&&ia(r,"value");if(!n)return!1;try{aa(e,no)}catch(i){return i===oo}}}else{var ua=ro("Object.prototype.toString"),ca="[object RegExp]";cr=function(e){return!e||typeof e!="object"&&typeof e!="function"?!1:ua(e)===ca}}var la=cr,ut=function(){return typeof(function(){}).name=="string"},nt=Object.getOwnPropertyDescriptor;if(nt)try{nt([],"length")}catch{nt=null}ut.functionsHaveConfigurableNames=function(){if(!ut()||!nt)return!1;var e=nt(function(){},"name");return!!e&&!!e.configurable};var ha=Function.prototype.bind;ut.boundFunctionsHaveNames=function(){return ut()&&typeof ha=="function"&&(function(){}).bind().name!==""};var fa=ut,io=vr,ya=mr(),pa=fa.functionsHaveConfigurableNames(),da=qe,ga=function(e,r){if(typeof e!="function")throw new da("`fn` is not a function");var n=arguments.length>2&&!!arguments[2];return(!n||pa)&&(ya?io(e,"name",r,!0,!0):io(e,"name",r)),e},va=ga,ma=qe,xa=Object,ln=va(function(){if(this==null||this!==xa(this))throw new ma("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),wa=ln,_a=yt.supportsDescriptors,Ma=Object.getOwnPropertyDescriptor,hn=function(){if(_a&&/a/mig.flags==="gim"){var e=Ma(RegExp.prototype,"flags");if(e&&typeof e.get=="function"&&"dotAll"in RegExp.prototype&&"hasIndices"in RegExp.prototype){var r="",n={};if(Object.defineProperty(n,"hasIndices",{get:function(){r+="d"}}),Object.defineProperty(n,"sticky",{get:function(){r+="y"}}),e.get.call(n),r==="dy")return e.get}}return wa},ba=yt.supportsDescriptors,Sa=hn,Pa=Ve,La=Object.defineProperty,Aa=Jo,so=Go,ka=/a/,Da=function(){if(!ba||!so)throw new Aa("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=Sa(),r=so(ka),n=Pa(r,"flags");return(!n||n.get!==e)&&La(r,"flags",{configurable:!0,enumerable:!1,get:e}),e},Fa=yt,Ea=nn,$a=ln,fn=hn,Oa=Da,yn=Ea(fn());Fa(yn,{getPolyfill:fn,implementation:$a,shim:Oa});var Ia=yn,pn=gr,za=pn("Date.prototype.getDay"),Ca=function(e){try{return za(e),!0}catch{return!1}},Ra=pn("Object.prototype.toString"),ja="[object Date]",Ja=fr(),Ba=function(e){return typeof e!="object"||e===null?!1:Ja?Ca(e):Ra(e)===ja},ao=Co,uo=Os,co=oa,lo=la,ho=Ia,fo=Ba,yo=Date.prototype.getTime;function dn(o,e,r){var n=r||{};return(n.strict?co(o,e):o===e)?!0:!o||!e||typeof o!="object"&&typeof e!="object"?n.strict?co(o,e):o==e:Na(o,e,n)}function po(o){return o==null}function go(o){return!(!o||typeof o!="object"||typeof o.length!="number"||typeof o.copy!="function"||typeof o.slice!="function"||o.length>0&&typeof o[0]!="number")}function Na(o,e,r){var n,i;if(typeof o!=typeof e||po(o)||po(e)||o.prototype!==e.prototype||uo(o)!==uo(e))return!1;var s=lo(o),a=lo(e);if(s!==a)return!1;if(s||a)return o.source===e.source&&ho(o)===ho(e);if(fo(o)&&fo(e))return yo.call(o)===yo.call(e);var u=go(o),c=go(e);if(u!==c)return!1;if(u||c){if(o.length!==e.length)return!1;for(n=0;n<o.length;n++)if(o[n]!==e[n])return!1;return!0}if(typeof o!=typeof e)return!1;try{var l=ao(o),v=ao(e)}catch{return!1}if(l.length!==v.length)return!1;for(l.sort(),v.sort(),n=l.length-1;n>=0;n--)if(l[n]!=v[n])return!1;for(n=l.length-1;n>=0;n--)if(i=l[n],!dn(o[i],e[i],r))return!1;return!0}var Ta=dn,Ua=Ta,Me=function(o){this.precision=o&&o.precision?o.precision:17,this.direction=o&&o.direction?o.direction:!1,this.pseudoNode=o&&o.pseudoNode?o.pseudoNode:!1,this.objectComparator=o&&o.objectComparator?o.objectComparator:Xa};Me.prototype.compare=function(o,e){if(o.type!==e.type||!gn(o,e))return!1;switch(o.type){case"Point":return this.compareCoord(o.coordinates,e.coordinates);case"LineString":return this.compareLine(o.coordinates,e.coordinates,0,!1);case"Polygon":return this.comparePolygon(o,e);case"Feature":return this.compareFeature(o,e);default:if(o.type.indexOf("Multi")===0){var r=this,n=vo(o),i=vo(e);return n.every(function(s){return this.some(function(a){return r.compare(s,a)})},i)}}return!1};function vo(o){return o.coordinates.map(function(e){return{type:o.type.replace("Multi",""),coordinates:e}})}function gn(o,e){return o.hasOwnProperty("coordinates")?o.coordinates.length===e.coordinates.length:o.length===e.length}Me.prototype.compareCoord=function(o,e){if(o.length!==e.length)return!1;for(var r=0;r<o.length;r++)if(o[r].toFixed(this.precision)!==e[r].toFixed(this.precision))return!1;return!0};Me.prototype.compareLine=function(o,e,r,n){if(!gn(o,e))return!1;var i=this.pseudoNode?o:this.removePseudo(o),s=this.pseudoNode?e:this.removePseudo(e);if(!(n&&!this.compareCoord(i[0],s[0])&&(s=this.fixStartIndex(s,i),!s))){var a=this.compareCoord(i[r],s[r]);return this.direction||a?this.comparePath(i,s):this.compareCoord(i[r],s[s.length-(1+r)])?this.comparePath(i.slice().reverse(),s):!1}};Me.prototype.fixStartIndex=function(o,e){for(var r,n=-1,i=0;i<o.length;i++)if(this.compareCoord(o[i],e[0])){n=i;break}return n>=0&&(r=[].concat(o.slice(n,o.length),o.slice(1,n+1))),r};Me.prototype.comparePath=function(o,e){var r=this;return o.every(function(n,i){return r.compareCoord(n,this[i])},e)};Me.prototype.comparePolygon=function(o,e){if(this.compareLine(o.coordinates[0],e.coordinates[0],1,!0)){var r=o.coordinates.slice(1,o.coordinates.length),n=e.coordinates.slice(1,e.coordinates.length),i=this;return r.every(function(s){return this.some(function(a){return i.compareLine(s,a,1,!0)})},n)}else return!1};Me.prototype.compareFeature=function(o,e){return o.id!==e.id||!this.objectComparator(o.properties,e.properties)||!this.compareBBox(o,e)?!1:this.compare(o.geometry,e.geometry)};Me.prototype.compareBBox=function(o,e){return!!(!o.bbox&&!e.bbox||o.bbox&&e.bbox&&this.compareCoord(o.bbox,e.bbox))};Me.prototype.removePseudo=function(o){return o};function Xa(o,e){return Ua(o,e,{strict:!0})}var Ya=Me;const Ga=So(Ya);function qa(o,e){var r=er(o).type,n=er(e).type;if(r!==n)return!1;var i=new Ga({precision:6});return i.compare(or(o),or(e))}const qt=(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}})},tt=(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}})},wt=(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 Va(o,e,r,n,i){let s="free",a="",u=[],c=[],l={},v=!1,h=!0,g=!1,d=!0,_=[],A=!0,O=5e4,$=!1,f={type:"FeatureCollection",features:[]},y={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},p={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}};const m=(P,z)=>{let U=0;return function(...Y){const ye=new Date().getTime();ye-U<z||(U=ye,P(...Y))}},b=P=>{switch(o.off("click",N),o.off("mousemove",re),o.off("contextmenu",G),he(),ie(),v&&(h=!0,C(!1)),v=!0,s=P.type||"point",A=P.multipleLine||!1,g=P.smooth||!1,O=P.brushSize*1e3||3e4,l=P,d=P.showLayer,y.properties=P,p.properties=P,s){case"point":break;case"brush":I();break}o.on("click",N),o.getCanvas().style.cursor=s=="brush"?"move":"crosshair"},M=P=>{s=P,y.properties.type=s,p.properties.type=s},w=P=>{if(r)if(u.length){const Y=[u[u.length-1]];r(Y)}else r([]);x(),ie(),o.addSource(a,{type:"geojson",data:f}),qt(o,a,a,l),f.features.push({type:"Feature",properties:l,geometry:{type:"Point",coordinates:P.lngLat.toArray()}}),o.getSource(a).setData(R(f)),e&&e(Q())},L=P=>{if(h){if(r)if(u.length){const U=u[u.length-1],Y=[U,U+"point"];r(Y)}else r([]);x(),ie(),o.addSource(a,{type:"geojson",data:y}),tt(o,a,a),qt(o,a+"point",a,l),h=!1,o.on("mousemove",re),o.on("contextmenu",G),o.dragRotate.enable()}y.geometry.coordinates.push(P.lngLat.toArray());const z=o.getSource(a);z.setData(y),!A&&y.geometry.coordinates.length==3&&(o.off("mousemove",re),o.off("contextmenu",G),h=!0,C(!1),y.geometry.coordinates.pop(),z.setData(R(y)),e&&e(Q()))},D=P=>{if(h){if(r)if(u.length){const Y=u[u.length-1],ye=[Y,Y+"outline",Y+"point"];r(ye)}else r([]);x(),ie(),o.addSource(a,{type:"geojson",data:p}),o.addSource(a+"point",{type:"geojson",data:f}),wt(o,a,a,l),tt(o,a+"outline",a,{"line-color":"black","line-width":2,...l}),qt(o,a+"point",a+"point",l),h=!1,o.on("mousemove",re),o.on("contextmenu",G),o.dragRotate.enable()}p.geometry.coordinates[0].length>=3&&p.geometry.coordinates[0].pop(),p.geometry.coordinates[0].push(P.lngLat.toArray()),p.geometry.coordinates[0].push(p.geometry.coordinates[0][0]),f.features.push(R({type:"Feature",geometry:{type:"Point",coordinates:P.lngLat.toArray()}})),o.getSource(a+"point").setData(f);const U=o.getSource(a);p.geometry.coordinates[0].length<=3&&!g&&U.setData(p),C(!0)},E=P=>{if(h){if(r)if(u.length){const U=u[u.length-1],Y=[U,U+"outline"];r(Y)}else r([]);x(),ie(),o.addSource(a,{type:"geojson",data:p}),wt(o,a,a,l),tt(o,a+"outline",a,{"line-color":"black","line-width":2,...l}),h=!1,p.geometry.coordinates[0].push(P.lngLat.toArray()),o.getSource(a).setData(p),o.on("mousemove",re),o.on("contextmenu",G),C(!0),o.dragRotate.enable()}},I=()=>{o.on("mousedown",H),o.on("mouseup",oe),o.on("mousemove",J),o.on("mouseover",te),o.on("mouseout",ne)},j=()=>{x(),ie(),o.addSource(a,{type:"geojson",data:p}),wt(o,a,a,l),tt(o,a+"outline",a,{"line-color":"black","line-width":2,...l})},T=(P,z)=>{const U=Se([P.lng,P.lat]),Y=z/2/111320,ye=Qt(Oo(U,Y,{units:"degrees"}));return li(ye)},le=(P,z)=>{const U=T(P,z);p.geometry=U.geometry,o.getSource(a).setData(p)},K=()=>{const P=a,U=o.getSource(P).serialize().data;e&&e(U)},ee=P=>{O=P*1e3},V=P=>{p.properties.MGValue=P},he=()=>{o.off("mousedown",H),o.off("mouseup",oe),o.off("mousemove",J),o.off("mouseover",te),o.off("mouseout",ne)},F=P=>{let z=R(P);const U=Xe(z.geometry.coordinates[0]),Y=st(U,{sharpness:.6});return z.geometry.coordinates[0]=Y.geometry.coordinates,z},x=()=>{a=k(),u.push(a),c.push(a)},k=()=>{let P=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){const Y=(P+Math.random()*16)%16|0;return P=Math.floor(P/16),(U==="x"?Y:Y&3|8).toString(16)})},C=P=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(U=>{P?o[U].disable():o[U].enable()})},N=P=>{switch(s){case"point":w(P);break;case"line":L(P);break;case"polygon":D(P);break;case"free":E(P);break}},W=P=>{switch(s){case"line":y.geometry.coordinates.length&&(y.geometry.coordinates.length==1&&y.geometry.coordinates.push(P.lngLat.toArray()),y.geometry.coordinates[y.geometry.coordinates.length-1]=P.lngLat.toArray(),o.getSource(a).setData(y));break;case"polygon":const z=p.geometry.coordinates[0].length;if(z){z==2?p.geometry.coordinates[0][z-1]=P.lngLat.toArray():p.geometry.coordinates[0][z-2]=P.lngLat.toArray();const Y=o.getSource(a);Y.setData(p),g&&p.geometry.coordinates[0].length>=3&&Y.setData(F(p))}break;case"free":p.geometry.coordinates[0].length&&(_.push(P.point),p.geometry.coordinates[0].length!=1&&p.geometry.coordinates[0].pop(),p.geometry.coordinates[0].push(P.lngLat.toArray()),p.geometry.coordinates[0].push(p.geometry.coordinates[0][0]),o.getSource(a).setData(p));break}},J=P=>{le(P.lngLat,O),$&&q()},q=m(K,0),G=P=>{P.preventDefault(),o.off("mousemove",re),o.off("contextmenu",G),h=!0,_.push(P.point),C(!1),o.dragRotate.disable();const z=o.getSource(a);switch(s){case"line":y.geometry.coordinates.length&&z.setData(R(y));break;case"polygon":if(p.geometry.coordinates[0].length){const U=p.geometry.coordinates[0].length;p.geometry.coordinates[0].splice(U-2,1),z.setData(R(p))}d||(o.setLayoutProperty(a,"visibility","none"),o.setLayoutProperty(a+"outline","visibility","none")),o.setLayoutProperty(a+"point","visibility","none"),g&&z.setData(R(F(p)));break;case"free":if(p.geometry.coordinates[0].length){const U=p.geometry.coordinates[0].length;if(p.geometry.coordinates[0].splice(U-2,1),z.setData(R(p)),d||(o.setLayoutProperty(a,"visibility","none"),o.setLayoutProperty(a+"outline","visibility","none")),g){const Y=[..._.slice(_.length/5),..._.slice(0,_.length/5),_.slice(_.length/5)[0]],ye=Y.length>10?5:3,pe=Math.ceil(Y.length/ye),gt=[];for(let ve=0;ve<Y.length;ve+=pe)gt.push(Y.slice(ve,ve+pe));let De=[];gt.forEach(ve=>{if(ve.length>1){const vn=new Z(ve).getLUT();De.push(...vn)}else De.push(...ve)}),p.geometry.coordinates[0].length=0;for(let ve=0;ve<De.length;ve++){const wr=o.unproject(De[ve]);p.geometry.coordinates[0].push(wr.toArray())}z.setData(R(p))}}break}e&&e(Q())},H=()=>{o.dragPan.disable(),o.dragRotate.disable(),$=!0,K()},oe=()=>{o.dragPan.enable(),o.dragRotate.enable(),$=!1},te=()=>{j()},ne=()=>{o.getLayer(a)&&o.removeLayer(a),o.getLayer(a+"outline")&&o.removeLayer(a+"outline"),o.getSource(a)&&o.removeSource(a)},Q=()=>{const P=u,z=[];return P.forEach((U,Y)=>{if(o.getSource(U)){const pe=o.getSource(U).serialize().data;pe.features?(pe.features[0].properties.layerId=U,pe.features[0].properties.sourceId=c[Y],z.push(...pe.features)):(pe.properties.layerId=U,pe.properties.sourceId=c[Y],z.push(pe))}}),z},fe=()=>{u.forEach(P=>{o.getLayer(P)&&o.removeLayer(P),o.getLayer(P+"outline")&&o.removeLayer(P+"outline"),o.getLayer(P+"point")&&o.removeLayer(P+"point"),o.getLayer(P+"text")&&o.removeLayer(P+"text")}),c.forEach(P=>{o.getSource(P)&&o.removeSource(P),o.getSource(P+"point")&&o.removeSource(P+"point"),o.getSource(P+"text")&&o.removeSource(P+"text")}),u.length=0,c.length=0},ie=()=>{_.length=0,f.features.length=0,y.geometry.coordinates.length=0,p.geometry.coordinates.length=0,p.geometry.coordinates[0]=[],p.properties.result=""},re=m(W,30),de=()=>{he(),o.off("click",N),o.off("mousemove",re),o.off("contextmenu",G),o.getCanvas().style.cursor="pointer",C(!1)},_e=()=>{(s=="free"||s=="polygon"||s=="point"||s=="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())},ke=()=>{if((s=="free"||s=="polygon")&&c.length){const P=u.length-c.length,z=c.slice(P);if(P!==0&&z.length){const ye=o.getSource(z[0]).serialize().data.valueOf();o.getLayer(z[0])||(u.push(z[0]),wt(o,z[0],z[0],{"fill-color":ye.properties["fill-color"]}),tt(o,z[0]+"outline",z[0],{"line-color":"black","line-width":2,...ye.properties}))}}};let pt=!1;const $t=P=>{pt=P};let $e,He=!1,Oe="";o.on("mousedown",P=>{const z=o.queryRenderedFeatures(P.point);z.length>0&&(Oe=z[0].layer.source,pt&&dt(P))});const dt=P=>{o.dragPan.disable(),$e=P.lngLat,He=!0,o.on("mouseup",Ie),o.on("mousemove",xr),i&&i()},Ie=()=>{if(He=!1,o.off("mouseup",Ie),o.off("mousemove",xr),o.dragPan.enable(),n){const z=o.getSource(Oe).serialize().data;n(z)}},xr=P=>{if(!He)return;const z=P.lngLat,U=z.lng-$e.lng,Y=z.lat-$e.lat;$e=z;const ye=o.getSource(Oe),pe=ye.serialize().data;pe.geometry.coordinates=pe.geometry.coordinates.map(gt=>gt.map(De=>[De[0]+U,De[1]+Y])),ye.setData(pe)};return{startDraw:b,revoke:_e,redo:ke,getFeaturesFromDraw:Q,clearDraw:fe,stopDraw:de,setBrushSize:ee,setValue:V,setDrawMethod:M,setDragMode:$t}}const Ha=(o,e,r,n={},i)=>{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)??{}}},"")},Ne=(o,e,r,n={},i)=>{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)??{}}},"")},Fe=(o,e,r,n={},i)=>{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)??{}}},i??"")},rt=(o,e,r,n={},i)=>{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)??{}}},"")},it=(o,e,r,n={},i)=>{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)??{}}},i??"")},se=(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)},ae=(o,e,r)=>{const n=o.getSource(e);n?n.setData(r):console.warn(`[popillon] Source with id "${e}" is not a GeoJSONSource.`)},xe=(o,e)=>{o.getSource(e)&&o.removeSource(e)},ue=(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 Wa(o,e){let r="free",n="",i=[],s=[],a={},u=!1,c=!0,l=!1,v=[],h={type:"FeatureCollection",features:[]},g={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},d={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},_={type:"Feature",properties:{result:""},geometry:{type:"Point",coordinates:[]}};const A=x=>{o.off("click",L),o.off("mousemove",F),o.off("contextmenu",E),V(),u&&(c=!0,w(!1)),u=!0,r=x.type||"point",x.measure,l=x.smooth||!1,a=x,g.properties=x,d.properties=x,_.properties=x,o.on("click",L),o.getCanvas().style.cursor="crosshair"},O=x=>{b(),V(),o.addSource(n,{type:"geojson",data:h}),Ne(o,n,n,a),rt(o,n+"text",n,{}),h.features.push({type:"Feature",properties:a,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(R(h)),e&&e(I())},$=x=>{b(),V(),o.addSource(n,{type:"geojson",data:h}),Ha(o,n,n,a),h.features.push({type:"Feature",properties:a,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(R(h)),e&&e(I())},f=x=>{c&&(b(),V(),o.addSource(n,{type:"geojson",data:g}),o.addSource(n+"text",{type:"geojson",data:h}),Fe(o,n,n),Ne(o,n+"point",n,a),rt(o,n+"text",n+"text",{}),c=!1,o.on("mousemove",F),o.on("contextmenu",E)),g.geometry.coordinates.push(x.lngLat.toArray()),o.getSource(n).setData(g),h.features.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n+"text").setData(h)},y=x=>{c&&(b(),V(),o.addSource(n,{type:"geojson",data:d}),o.addSource(n+"area",{type:"geojson",data:_}),it(o,n,n),Fe(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),Ne(o,n+"point",n),rt(o,n+"area",n+"area",{}),c=!1,o.on("mousemove",F),o.on("contextmenu",E)),d.geometry.coordinates[0].length>=3&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(x.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),v.push(x.point),o.getSource(n).setData(d),w(!0)},p=x=>{c&&(b(),V(),o.addSource(n,{type:"geojson",data:d}),o.addSource(n+"area",{type:"geojson",data:_}),it(o,n,n,a),Fe(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),rt(o,n+"area",n+"area",{}),c=!1,d.geometry.coordinates[0].push(x.lngLat.toArray()),o.getSource(n).setData(d),o.on("mousemove",F),o.on("contextmenu",E),w(!0))},m=x=>{if(c){b(),V(),o.addSource(n,{type:"geojson",data:d}),o.addSource(n+"area",{type:"geojson",data:_}),o.addSource(n+"point",{type:"geojson",data:h}),it(o,n,n,a),Fe(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),Ne(o,n+"point",n+"point"),rt(o,n+"area",n+"area",{}),c=!1;const k={type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}};h.features.push(R(k)),h.features.push(R(k)),_.geometry.coordinates=x.lngLat.toArray(),o.getSource(n+"point").setData(h),o.on("mousemove",F),o.on("contextmenu",E),w(!0)}},b=()=>{n=M(),i.push(n),s.push(n)},M=()=>{let x=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(C){const N=(x+Math.random()*16)%16|0;return x=Math.floor(x/16),(C==="x"?N:N&3|8).toString(16)})},w=x=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(C=>{x?o[C].disable():o[C].enable()})},L=x=>{switch(r){case"symbol":$(x);break;case"point":O(x);break;case"line":f(x);break;case"polygon":y(x);break;case"free":p(x);break;case"circle":m(x);break}},D=x=>{switch(r){case"line":if(g.geometry.coordinates.length){g.geometry.coordinates.length==1&&g.geometry.coordinates.push(x.lngLat.toArray()),g.geometry.coordinates[g.geometry.coordinates.length-1]=x.lngLat.toArray(),o.getSource(n).setData(g);const ne=g.geometry.coordinates[g.geometry.coordinates.length-2],Q=g.geometry.coordinates[g.geometry.coordinates.length-1],fe=rr(ne,Q,{units:"kilometers"}),ie=fi(Se(ne),Se(Q)),re=h.features[h.features.length-1];re.properties.result=mt(fe,4)+"km",re.geometry.coordinates=ie.geometry.coordinates,o.getSource(n+"text").setData(R(h))}break;case"polygon":const H=d.geometry.coordinates[0].length;if(H){H==2?d.geometry.coordinates[0][H-1]=x.lngLat.toArray():d.geometry.coordinates[0][H-2]=x.lngLat.toArray();const te=Jt(d)/1e6;if(H>=4){var k=Ue(d.geometry.coordinates),C=sr(k);_.geometry.coordinates=C.geometry.coordinates,_.properties.result=mt(te,2)+"km²"}const ne=o.getSource(n);ne.setData(d),o.getSource(n+"area").setData(_),l&&d.geometry.coordinates[0].length>=3&&ne.setData(j(d))}break;case"free":const oe=d.geometry.coordinates[0].length;if(oe){v.push(x.point),d.geometry.coordinates[0].length!=1&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(x.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]);const te=Jt(d)/1e6;if(oe>=4){var k=Ue(d.geometry.coordinates),C=sr(k);_.geometry.coordinates=C.geometry.coordinates,_.properties.result=mt(te,2)+"km²"}o.getSource(n).setData(d),o.getSource(n+"area").setData(_)}break;case"circle":if(h.features.length){h.features[1].geometry.coordinates=x.lngLat.toArray();var N=Se(h.features[0].geometry.coordinates),W=Se(h.features[1].geometry.coordinates),J=rr(N,W,{units:"miles"}),q={steps:500,units:"miles",properties:{foo:"bar"}},G=Oo(N,J,q);d.geometry.coordinates=G.geometry.coordinates;const te=Jt(d)/1e6;_.properties.result=mt(te,2)+"km²";const ne=o.getSource(n+"point"),Q=o.getSource(n),fe=o.getSource(n+"area");ne.setData(h),Q.setData(d),fe.setData(_)}break}},E=x=>{x.preventDefault(),o.off("mousemove",F),o.off("contextmenu",E),c=!0,v.push(x.point),w(!1);const k=o.getSource(n);switch(r){case"line":g.geometry.coordinates.length&&(console.log(g),k.setData(R(g)),o.removeLayer(n+"point"),l&&g.geometry.coordinates.length>=2&&k.setData(T(g)));break;case"polygon":d.geometry.coordinates[0].length&&k.setData(R(d)),o.setLayoutProperty(n+"point","visibility","none"),l&&k.setData(R(j(d)));break;case"free":if(d.geometry.coordinates[0].length&&(k.setData(R(d)),l)){const C=[...v.slice(v.length/5),...v.slice(0,v.length/5),v.slice(v.length/5)[0]],N=C.length>10?5:3,W=Math.ceil(C.length/N),J=[];for(let G=0;G<C.length;G+=W)J.push(C.slice(G,G+W));let q=[];J.forEach(G=>{if(G.length>1){const oe=new Z(G).getLUT();q.push(...oe)}else q.push(...G)}),d.geometry.coordinates[0].length=0;for(let G=0;G<q.length;G++){const H=o.unproject(q[G]);d.geometry.coordinates[0].push(H.toArray())}k.setData(R(d))}break;case"circle":o.removeLayer(n+"point"),o.removeSource(n+"point");break}e&&e(I())},I=()=>{const x=i,k=[];return x.forEach((C,N)=>{const J=o.getSource(C).serialize().data;J.features?(J.features[0].properties.layerId=C,J.features[0].properties.sourceId=s[N],k.push(...J.features)):(J.properties.layerId=C,J.properties.sourceId=s[N],k.push(J))}),k},j=x=>{let k=R(x);const C=Xe(k.geometry.coordinates[0]),N=st(C,{sharpness:.6});return k.geometry.coordinates[0]=N.geometry.coordinates,k},T=x=>{let k=R(x);console.log(k,"lineFeature");const C=Xe(k.geometry.coordinates),N=st(C,{sharpness:.6});return k.geometry.coordinates=N.geometry.coordinates,k},le=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(k=>k!==x)},K=()=>{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")}),s.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,s.length=0},ee=()=>{o.off("click",L),o.off("mousemove",F),o.off("contextmenu",E),o.getCanvas().style.cursor="pointer",w(!1)},V=()=>{v.length=0,h.features.length=0,g.geometry.coordinates.length=0,d.geometry.coordinates.length=0,d.geometry.coordinates[0]=[],d.properties.result="",_.geometry.coordinates.length=0},F=((x,k)=>{let C=0;return function(...N){const W=new Date().getTime();W-C<k||(C=W,x(...N))}})(D,30);return{startMeasure:A,clearMeasure:K,stopMeasure:ee,getFeaturesFromMeasure:I,clearLayerById:le}}const Vt=()=>{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)})},Ht=o=>{let e=R(o);const r=Xe(e.geometry.coordinates[0]),n=st(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates[0]=n.geometry.coordinates,e},Wt=o=>{const e=R(o),r=Xe(e.geometry.coordinates),n=st(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates=n.geometry.coordinates,e},mo=(o,e)=>{let r=0;return function(...n){const i=new Date().getTime();i-r<e||(r=i,o(...n))}},Zt=o=>["fill","line","circle","symbol"].includes(o.type)&&"source"in o&&o.source!=="maplibre",Je=(o,e,r,n)=>{if(!r||!r.geometry)return;switch(r.geometry.type){case"Point":case"MultiPoint":break;case"LineString":case"MultiLineString":Fe(o,e,e,n);break;case"Polygon":case"MultiPolygon":it(o,e,e,n),Fe(o,e+"outline",e,n);break}};class Za{constructor(e){B(this,"map");B(this,"historyStack",[]);B(this,"redoStack",[]);this.map=e}push(e){this.historyStack.push(e),this.redoStack=[]}undo(){const{map:e}=this,r=this.historyStack.pop();if(!r)return;switch(this.redoStack.push(r),r.type){case"add":case"clone":this.removeLayerWithOutline(r.layerId);break;case"remove":r.before&&this.addLayerWithOutline(r.layerId,r.before);break;case"edit":case"move":r.before&&ae(e,r.layerId,r.before);break}const n=this.historyStack[this.historyStack.length-1];(n==null?void 0:n.type)=="clone"&&this.undo()}redo(){const{map:e}=this,r=this.redoStack.pop();if(r)switch(this.historyStack.push(r),r.type){case"add":r.after&&this.addLayerWithOutline(r.layerId,r.after);break;case"clone":r.after&&this.addLayerWithOutline(r.layerId,r.after);const n=this.redoStack[this.redoStack.length-1];(n==null?void 0:n.type)=="move"&&this.redo();break;case"remove":this.removeLayerWithOutline(r.layerId);break;case"edit":case"move":r.after&&ae(e,r.layerId,r.after);break}}removeLayerWithOutline(e){se(this.map,e),se(this.map,e+"outline")}addLayerWithOutline(e,r){Je(this.map,e,r,{...r.properties})}getHistoryStack(){return this.historyStack}getRedoStack(){return this.redoStack}clear(){this.historyStack=[],this.redoStack=[]}}class Ka{constructor(e){B(this,"map");B(this,"eventMap",new Map);B(this,"uuid","");B(this,"toolMode","draw");B(this,"_followPointId","followPointId");B(this,"options",{drawMode:"polygon",smooth:!0,showFeature:!0,showLastFeatureOnly:!1,polyline:!0,drawFreeMouseMode:0,brushState:!1,brushSize:5e4});B(this,"newDraw",!0);B(this,"saveFreePolygonPoint",[]);B(this,"_activeLayer");B(this,"_cacheActiveLayerSource");B(this,"_editMode","idle");B(this,"_dragIndex",null);B(this,"_vertexSourceId","custom-vertex-source");B(this,"_vertexLayerId","custom-vertex-layer");B(this,"keydownHandler");B(this,"dragOptions",{cloneLayer:!1});B(this,"_isCloneLayer",!1);B(this,"_isDragging",!1);B(this,"_dragOrigin",null);B(this,"history");B(this,"_externalLayerIds",[]);B(this,"_onMapClick",this._onMapClick_.bind(this));B(this,"_onMapDblclick",this._onMapDblclick_.bind(this));B(this,"_onMapMousemove",mo(this._onMapMousemove_.bind(this),10));B(this,"_onMapMousedown",this._onMapMousedown_.bind(this));B(this,"_onMapMouseup",this._onMapMouseup_.bind(this));B(this,"_onMapMouseover",this._onMapMouseover_.bind(this));B(this,"_onMapMouseout",this._onMapMouseout_.bind(this));B(this,"_emitFinishBrushThrottled",mo(()=>{this.emit("finishBrush",R(this.polygonJson))},33));B(this,"pointJson",{type:"FeatureCollection",features:[]});B(this,"lineJson",{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}});B(this,"polygonJson",{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});B(this,"drawFreePolygon",e=>{if(e.originalEvent.button!==this.options.drawFreeMouseMode)return;const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),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}),Je(r,this.uuid,this.polygonJson,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),this._setMapActionEvents(!1))});B(this,"_getCoords",e=>{if(e.type!=="GeometryCollection"&&Array.isArray(e.coordinates)){if(e.type==="Polygon"&&Array.isArray(e.coordinates[0]))return e.coordinates[0];if(e.type==="LineString"&&Array.isArray(e.coordinates))return e.coordinates}return[]});B(this,"getFeatureLatest",()=>{const{map:e}=this,r=this.history.getHistoryStack();if(!r.length)return;const n=this._getActiveHistoryLayerIds();for(let i=r.length-1;i>=0;i--){const s=r[i].layerId;if(n.has(s))return ue(e,s)}});B(this,"getFeatures",()=>{const{map:e}=this,n=[...this._getActiveHistoryLayerIds()].map(s=>ue(e,s)),i=this._externalLayerIds.map(s=>ue(e,s));return[...n,...i].filter(Boolean)});B(this,"addFeature",(e,r)=>{const{map:n}=this;if(!e||!e.geometry)return;const i=Vt();this._externalLayerIds.push(i);const s=R(e);s.properties={...this.options,...s.properties,...r,layerId:i,sourceId:i},Ae(n,i,{type:"geojson",data:s}),Je(n,i,s,s.properties)});B(this,"removeFeatures",()=>{const{map:e}=this;this._externalLayerIds.forEach(r=>{se(e,r),se(e,r+"outline"),xe(e,r)}),this._externalLayerIds.splice(0)});B(this,"setFeatureVisible",e=>{const{map:r}=this,n=this.history.getHistoryStack();n.length&&n.forEach(i=>{r.getLayer(i.layerId)&&r.setLayoutProperty(i.layerId,"visibility",e?"visible":"none"),r.getLayer(i.layerId+"outline")&&r.setLayoutProperty(i.layerId+"outline","visibility",e?"visible":"none")})});B(this,"setFeatureVisibleById",(e,r)=>{const{map:n}=this;n.getLayer(e)&&n.setLayoutProperty(e,"visibility",r?"visible":"none"),n.getLayer(e+"outline")&&n.setLayoutProperty(e+"outline","visibility",r?"visible":"none")});B(this,"undo",()=>{this._removeVertexPoints(),this._removeFollowPoints(),this.history.undo();const e=this.history.getHistoryStack();e.length&&this.options.showLastFeatureOnly&&(this.setFeatureVisible(!1),this.setFeatureVisibleById(e[e.length-1].layerId,!0))});B(this,"redo",()=>{this._removeVertexPoints(),this._removeFollowPoints(),this.history.redo();const e=this.history.getHistoryStack();e.length&&this.options.showLastFeatureOnly&&(this.setFeatureVisible(!1),this.setFeatureVisibleById(e[e.length-1].layerId,!0))});this.map=e,this.history=new Za(e),this.keydownHandler=this.onKeyDown.bind(this),window.addEventListener("keydown",this.keydownHandler)}_creatFollowPoints(e){const{map:r,_followPointId:n}=this;Ae(r,n,{type:"geojson",data:this.pointJson}),Ne(r,n,n,this.options);const i={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e}};this.pointJson.features.push(R(i)),this.pointJson.features.push(R(i)),ae(r,n,R(this.pointJson))}_updateFollowPoints(e){const{map:r,_followPointId:n}=this;this.pointJson.features[1].geometry.coordinates=e,ae(r,n,R(this.pointJson))}_removeFollowPoints(){const{map:e,_followPointId:r}=this;se(e,r),xe(e,r)}drawPoint(e){const{map:r}=this;this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.pointJson}),Ne(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()}}),ae(r,this.uuid,R(this.pointJson)),this.emit("finishDraw",this.getFeatureLatest())}drawLine(e){const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),this.options.showLastLineOnly&&this.setFeatureVisible(!1),this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.lineJson}),Je(r,this.uuid,this.lineJson,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(),ae(r,this.uuid,R(this.lineJson)),this._setMapActionEvents(!0),this._removeFollowPoints(),this.history.push({type:"add",layerId:this.uuid,after:ue(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest()))}drawPolygon(e){const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.polygonJson}),Je(r,this.uuid,this.polygonJson,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=r/2,i=111320,s=Math.cos(e.lat*Math.PI/180),a=i*Math.max(Math.abs(s),1e-6),u=n/i,c=n/a,l=e.lng-c,v=e.lng+c,h=e.lat-u,g=e.lat+u;return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[l,h],[v,h],[v,g],[l,g],[l,h]]]}}}setBrushSize(e){this.options.brushSize=e*1e3}startDraw(e){const{map:r}=this;switch(Object.assign(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(),ae(r,this.uuid,this.options.smooth&&i>=2?Wt(this.lineJson):R(this.lineJson)));break;case"polygon":this._updateFollowPoints(n);const s=this.polygonJson.geometry.coordinates[0].length;s&&(s==2?this.polygonJson.geometry.coordinates[0][s-1]=n:this.polygonJson.geometry.coordinates[0][s-2]=n,s>=3&&ae(r,this.uuid,this.options.smooth?Ht(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]),ae(r,this.uuid,this.polygonJson));break;case"brush":const u=this._createRectangle(e.lngLat,this.options.brushSize??5e4);this.polygonJson.geometry=u.geometry,ae(r,this.uuid,this.polygonJson),this.options.brushState&&this._emitFinishBrushThrottled();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),this.lineJson.properties.feedbackFeature=R(this.lineJson),ae(r,this.uuid,this.options.smooth&&this.lineJson.geometry.coordinates.length>=2?Wt(this.lineJson):R(this.lineJson)),this.history.push({type:"add",layerId:this.uuid,after:ue(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())):(se(r,this.uuid),se(r,this.uuid+"line"),xe(r,this.uuid),xe(r,this.uuid+"line"));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.showFeature||(r.setLayoutProperty(this.uuid,"visibility","none"),r.setLayoutProperty(this.uuid+"outline","visibility","none")),this.polygonJson.properties.feedbackFeature=R(this.polygonJson),ae(r,this.uuid,this.options.smooth?Ht(this.polygonJson):R(this.polygonJson)),this.history.push({type:"add",layerId:this.uuid,after:ue(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())):(se(r,this.uuid),se(r,this.uuid+"line"),xe(r,this.uuid),xe(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}),Je(e,this.uuid,this.polygonJson,this.options);break}}_onMapMouseoutDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":se(e,this.uuid),se(e,this.uuid+"outline"),xe(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",R(this.polygonJson));break}}_onMapMouseupDraw(e){const{map:r}=this;switch(this.options.drawMode){case"freePolygon":if(e.originalEvent.button!==this.options.drawFreeMouseMode)return;if(r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.polygonJson.geometry.coordinates[0].length){this._removeFollowPoints();const a=this.polygonJson.geometry.coordinates[0].length;if(this.polygonJson.geometry.coordinates[0].splice(a-2,1),ae(r,this.uuid,R(this.polygonJson)),this.options.showFeature||(this.map.setLayoutProperty(this.uuid,"visibility","none"),this.map.setLayoutProperty(this.uuid+"outline","visibility","none")),a>=2&&this.options.smooth){const u=this.saveFreePolygonPoint,c=[...u.slice(u.length/5),...u.slice(0,u.length/5),u.slice(u.length/5)[0]],l=c.length>10?5:3,v=Math.ceil(c.length/l),h=[];for(let d=0;d<c.length;d+=v)h.push(c.slice(d,d+v));let g=[];h.forEach(d=>{if(d.length>1){const A=new Z(d).getLUT();g.push(...A)}else g.push(...d)}),this.polygonJson.geometry.coordinates[0].length=0;for(let d=0;d<g.length;d++){const _=this.map.unproject(g[d]);this.polygonJson.geometry.coordinates[0].push(_.toArray())}var n=Ue(this.polygonJson.geometry.coordinates),i={tolerance:.008,highQuality:!0},s=ni(n,i);this.polygonJson.geometry=s.geometry,ae(r,this.uuid,R(this.polygonJson))}this.history.push({type:"add",layerId:this.uuid,after:ue(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())}else se(r,this.uuid),se(r,this.uuid+"outline"),xe(r,this.uuid);break;case"brush":r.dragPan.enable(),r.dragRotate.enable(),this.options.brushState=!1;break}}startEdit(){const{map:e}=this;this.stop(),this.toolMode="edit",this.setFeatureVisible(!0),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 s;const{map:e}=this,r=ue(e,this._activeLayer.source);if(!r)return;const n=(s=r.properties)!=null&&s.feedbackFeature?this._getCoords(r.properties.feedbackFeature.geometry):this._getCoords(r.geometry);if(!n.length)return;let i=[];r.geometry.type==="Polygon"&&n.length>2?i=n.slice(0,-1).map((a,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:a}})):r.geometry.type==="LineString"&&(i=n.map((a,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:a}}))),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"}})),ae(e,this._vertexSourceId,R({type:"FeatureCollection",features:i}))}_removeVertexPoints(){const{map:e,_vertexLayerId:r,_vertexSourceId:n}=this;se(e,r),xe(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 s=i.layer;Zt(s)&&!s.id.includes("outline")?(this._activeLayer&&this._activeLayer.id!==s.id&&(this._editMode="idle"),this._activeLayer=s,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 a,u,c;const{map:r}=this;if(this._editMode==="edit"&&this._dragIndex!==null){const l=ue(r,this._activeLayer.source);if(!l||!("geometry"in l))return;const v=(a=l.properties)==null?void 0:a.feedbackFeature,h=R(v?(u=l==null?void 0:l.properties)==null?void 0:u.feedbackFeature:l),{geometry:g}=h;if(g.type==="Polygon"){const d=g.coordinates[0];if(d[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],d.length>2&&(d[d.length-1]=d[0]),v){h.properties.feedbackFeature=R(h);const _=h.properties.smooth?Ht(R(h)):h;ae(r,this._activeLayer.source,_)}else ae(r,this._activeLayer.source,h);this._updateVertexPoints()}else if(g.type==="LineString"){const d=g.coordinates;if(d[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],v){h.properties.feedbackFeature=R(h);const _=h.properties.smooth?Wt(R(h)):h;ae(r,this._activeLayer.source,_)}else ae(r,this._activeLayer.source,h);this._updateVertexPoints()}}const n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0,s=((c=i==null?void 0:i.layer)==null?void 0:c.id)===this._vertexLayerId;this._setMapCursorStyle(s?"move":void 0)}_onMapMousedownEdit(e){var s,a;const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0;((s=i==null?void 0:i.layer)==null?void 0:s.id)===this._vertexLayerId?(this._dragIndex=((a=i==null?void 0:i.properties)==null?void 0:a.index)??null,this._setMapActionEvents(!1),this._cacheActiveLayerSource=ue(r,this._activeLayer.source),this.emit("startEdit",ue(r,this._activeLayer.source))):this._dragIndex=null}_onMapMouseupEdit(){const{map:e}=this;this._dragIndex=null,this._setMapActionEvents(!0),this.history.push({type:"edit",layerId:this._activeLayer.id,before:this._cacheActiveLayerSource,after:ue(e,this._activeLayer.source)}),this.emit("finishEdit",ue(e,this._activeLayer.source))}_onMapMouseoverEdit(){this.emit("editPointMouseover")}_onMapMouseoutEdit(){this.emit("editPointMouseout")}startDrag(e){const{map:r}=this;Object.assign(this.dragOptions,e),this.stop(),this.toolMode="drag",this.setFeatureVisible(!0),r.on("mousemove",this._onMapMousemove),r.on("mousedown",this._onMapMousedown),r.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 s,a;const{map:r}=this;if(this._isDragging&&this._dragOrigin&&this._activeLayer){if(this.dragOptions.cloneLayer&&!this._isCloneLayer){const g=Vt(),d=R(this._cacheActiveLayerSource);d.properties.layerId=g,d.properties.sourceId=g,Ae(r,g,{type:"geojson",data:d}),it(r,g,g,d.properties,this._activeLayer.id),Fe(r,g+"outline",g,d.options,this._activeLayer.id),this.history.push({type:"clone",layerId:g,after:d}),this._isCloneLayer=!0}const u=this._activeLayer.source,c=ue(r,u);if(!c||!("geometry"in c))return;const l=e.lngLat.lng-this._dragOrigin[0],v=e.lngLat.lat-this._dragOrigin[1];this._dragOrigin=[e.lngLat.lng,e.lngLat.lat];const{geometry:h}=c;if(c.geometry.type!=="GeometryCollection"&&h.type==="Polygon"){const d=c.geometry.coordinates[0].map(([_,A])=>[_+l,A+v]);if(c.geometry.coordinates[0]=d,(s=c==null?void 0:c.properties)!=null&&s.feedbackFeature){const A=c.properties.feedbackFeature.geometry.coordinates[0].map(([O,$])=>[O+l,$+v]);c.properties.feedbackFeature.geometry.coordinates[0]=A}ae(r,u,R(c));return}}const n=(a=r.queryRenderedFeatures(e.point))==null?void 0:a[0],i=n==null?void 0:n.layer;n&&i&&Zt(i)?this._setMapCursorStyle("move"):this._setMapCursorStyle()}_onMapMousedownDrag(e){if(e.originalEvent.button!==0)return;const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n==null?void 0:n[0];if(!i)return;const s=i.layer;Zt(s)&&(this._isDragging=!0,this._isCloneLayer=!1,this._dragOrigin=[e.lngLat.lng,e.lngLat.lat],this._activeLayer=s,this._setMapActionEvents(!1),this._cacheActiveLayerSource=ue(r,this._activeLayer.source),this.emit("startDrag",ue(r,this._activeLayer.source)))}_onMapMouseupDrag(){const{map:e}=this;if(this._isDragging)try{const r=ue(e,this._activeLayer.source);r&&this._cacheActiveLayerSource&&(qa(this._cacheActiveLayerSource,r)||(this.history.push({type:"move",layerId:this._activeLayer.id,before:this._cacheActiveLayerSource,after:r}),this.emit("finishDrag",r)))}catch(r){console.warn("[DrawTool] _onMapMouseupDrag error:",r)}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_(e){switch(this.toolMode){case"draw":this._onMapMouseupDraw(e);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}}onKeyDown(e){(e.key==="Delete"||e.key==="Backspace")&&this.deleteLayer()}deleteLayer(){const{map:e}=this;this._editMode=="edit"&&(se(e,this._activeLayer.id),se(e,this._activeLayer.id+"outline"),this._editMode="idle",this._removeVertexPoints(),this._setMapCursorStyle(),this.history.push({type:"remove",layerId:this._activeLayer.id,before:ue(e,this._activeLayer.source)}))}_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=Vt()}_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.stopDraw(),this.stopDrag(),this.stopEdit()}destroy(){this.stop(),this._clearJson(),this.clearLayers(),this.eventMap.clear(),this._cacheActiveLayerSource=void 0,window.removeEventListener("keydown",this.keydownHandler)}clearLayers(){const{map:e}=this;this.history.getHistoryStack().forEach(n=>{const i=n.layerId;se(e,i),se(e,i+"outline"),xe(e,i)}),this._externalLayerIds.forEach(n=>{se(e,n),se(e,n+"outline"),xe(e,n)}),this._removeVertexPoints(),this._removeFollowPoints(),this.history.clear(),this._externalLayerIds.splice(0)}_getActiveHistoryLayerIds(){const e=new Set;for(const r of this.history.getHistoryStack())r.type==="add"||r.type==="clone"?e.add(r.layerId):r.type==="remove"&&e.delete(r.layerId);return e}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=Ka;exports.draw=Va;exports.measure=Wa;
|