@maplat/tin 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- (function(Dt,Ft){typeof exports=="object"&&typeof module<"u"?Ft(exports):typeof define=="function"&&define.amd?define(["exports"],Ft):(Dt=typeof globalThis<"u"?globalThis:Dt||self,Ft(Dt.tin={}))})(this,(function(Dt){"use strict";var Fi=Object.defineProperty;var Yi=(Dt,Ft,Wt)=>Ft in Dt?Fi(Dt,Ft,{enumerable:!0,configurable:!0,writable:!0,value:Wt}):Dt[Ft]=Wt;var bt=(Dt,Ft,Wt)=>Yi(Dt,typeof Ft!="symbol"?Ft+"":Ft,Wt);function Ft(o,e,t={}){const r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=o,r}function Wt(o,e,t={}){if(!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(!vn(o[0])||!vn(o[1]))throw new Error("coordinates must contain numbers");return Ft({type:"Point",coordinates:o},e,t)}function Me(o,e,t={}){for(const i of o){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let n=0;n<i[i.length-1].length;n++)if(i[i.length-1][n]!==i[0][n])throw new Error("First and last Position are not equivalent.")}return Ft({type:"Polygon",coordinates:o},e,t)}function yn(o,e,t={}){if(o.length<2)throw new Error("coordinates must be an array of two or more positions");return Ft({type:"LineString",coordinates:o},e,t)}function Kt(o,e={}){const t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=o,t}function vn(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function nr(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 rr(o){return o.type==="Feature"?o.geometry:o}function Je(o,e,t){if(o!==null)for(var r,i,n,s,a,c,f,h=0,l=0,p,v=o.type,M=v==="FeatureCollection",S=v==="Feature",C=M?o.features.length:1,F=0;F<C;F++){f=M?o.features[F].geometry:S?o.geometry:o,p=f?f.type==="GeometryCollection":!1,a=p?f.geometries.length:1;for(var m=0;m<a;m++){var w=0,u=0;if(s=p?f.geometries[m]:f,s!==null){c=s.coordinates;var y=s.type;switch(h=t&&(y==="Polygon"||y==="MultiPolygon")?1:0,y){case null:break;case"Point":if(e(c,l,F,w,u)===!1)return!1;l++,w++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(e(c[r],l,F,w,u)===!1)return!1;l++,y==="MultiPoint"&&w++}y==="LineString"&&w++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(i=0;i<c[r].length-h;i++){if(e(c[r][i],l,F,w,u)===!1)return!1;l++}y==="MultiLineString"&&w++,y==="Polygon"&&u++}y==="Polygon"&&w++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(u=0,i=0;i<c[r].length;i++){for(n=0;n<c[r][i].length-h;n++){if(e(c[r][i][n],l,F,w,u)===!1)return!1;l++}u++}w++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(Je(s.geometries[r],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const Yt=11102230246251565e-32,rt=134217729,bn=(3+8*Yt)*Yt;function Rt(o,e,t,r,i){let n,s,a,c,f=e[0],h=r[0],l=0,p=0;h>f==h>-f?(n=f,f=e[++l]):(n=h,h=r[++p]);let v=0;if(l<o&&p<t)for(h>f==h>-f?(s=f+n,a=n-(s-f),f=e[++l]):(s=h+n,a=n-(s-h),h=r[++p]),n=s,a!==0&&(i[v++]=a);l<o&&p<t;)h>f==h>-f?(s=n+f,c=s-n,a=n-(s-c)+(f-c),f=e[++l]):(s=n+h,c=s-n,a=n-(s-c)+(h-c),h=r[++p]),n=s,a!==0&&(i[v++]=a);for(;l<o;)s=n+f,c=s-n,a=n-(s-c)+(f-c),f=e[++l],n=s,a!==0&&(i[v++]=a);for(;p<t;)s=n+h,c=s-n,a=n-(s-c)+(h-c),h=r[++p],n=s,a!==0&&(i[v++]=a);return(n!==0||v===0)&&(i[v++]=n),v}function Jt(o,e,t,r,i,n,s,a){return Rt(Rt(o,e,t,r,s),s,i,n,a)}function q(o,e,t,r){let i,n,s,a,c,f,h,l,p,v,M;h=rt*t,v=h-(h-t),M=t-v;let S=e[0];i=S*t,h=rt*S,l=h-(h-S),p=S-l,s=p*M-(i-l*v-p*v-l*M);let C=0;s!==0&&(r[C++]=s);for(let F=1;F<o;F++)S=e[F],a=S*t,h=rt*S,l=h-(h-S),p=S-l,c=p*M-(a-l*v-p*v-l*M),n=i+c,f=n-i,s=i-(n-f)+(c-f),s!==0&&(r[C++]=s),i=a+n,s=n-(i-a),s!==0&&(r[C++]=s);return(i!==0||C===0)&&(r[C++]=i),C}function xn(o,e){let t=e[0];for(let r=1;r<o;r++)t+=e[r];return t}function yt(o){return new Float64Array(o)}const ir=(3+16*Yt)*Yt,or=(2+12*Yt)*Yt,sr=(9+64*Yt)*Yt*Yt,be=yt(4),_n=yt(8),Mn=yt(12),Sn=yt(16),jt=yt(4);function ar(o,e,t,r,i,n,s){let a,c,f,h,l,p,v,M,S,C,F,m,w,u,y,g,I,B;const E=o-i,X=t-i,A=e-n,D=r-n;u=E*D,p=rt*E,v=p-(p-E),M=E-v,p=rt*D,S=p-(p-D),C=D-S,y=M*C-(u-v*S-M*S-v*C),g=A*X,p=rt*A,v=p-(p-A),M=A-v,p=rt*X,S=p-(p-X),C=X-S,I=M*C-(g-v*S-M*S-v*C),F=y-I,l=y-F,be[0]=y-(F+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t[0]=y-(F+l)+(l-I),m=u+F,l=m-u,w=u-(m-l)+(F-l),F=w-g,l=w-F,jt[1]=w-(F+l)+(l-g),B=m+F,l=B-m,jt[2]=m-(B-l)+(F-l),jt[3]=B;const T=Rt(x,Mn,4,jt,Sn);return Sn[T-1]}function ee(o,e,t,r,i,n){const s=(e-n)*(t-i),a=(o-i)*(r-n),c=s-a,f=Math.abs(s+a);return Math.abs(c)>=ir*f?c:-ar(o,e,t,r,i,n,f)}const cr=(10+96*Yt)*Yt,fr=(4+48*Yt)*Yt,hr=(44+576*Yt)*Yt*Yt,fe=yt(4),he=yt(4),le=yt(4),ne=yt(4),re=yt(4),ie=yt(4),$t=yt(4),qt=yt(4),Ke=yt(8),Qe=yt(8),He=yt(8),Ze=yt(8),tn=yt(8),en=yt(8),Ce=yt(8),De=yt(8),Re=yt(8),pe=yt(4),me=yt(4),ge=yt(4),st=yt(8),dt=yt(16),kt=yt(16),Et=yt(16),xt=yt(32),ue=yt(32),Bt=yt(48),Vt=yt(64);let xe=yt(1152),nn=yt(1152);function Ot(o,e,t){o=Rt(o,xe,e,t,nn);const r=xe;return xe=nn,nn=r,o}function lr(o,e,t,r,i,n,s,a,c){let f,h,l,p,v,M,S,C,F,m,w,u,y,g,I,B,E,X,A,D,V,d,_,x,T,P,R,b,O,L,$,U,z,Q,W;const ft=o-s,ct=t-s,lt=i-s,pt=e-a,gt=r-a,mt=n-a;$=ct*mt,_=rt*ct,x=_-(_-ct),T=ct-x,_=rt*mt,P=_-(_-mt),R=mt-P,U=T*R-($-x*P-T*P-x*R),z=lt*gt,_=rt*lt,x=_-(_-lt),T=lt-x,_=rt*gt,P=_-(_-gt),R=gt-P,Q=T*R-(z-x*P-T*P-x*R),b=U-Q,d=U-b,fe[0]=U-(b+d)+(d-Q),O=$+b,d=O-$,L=$-(O-d)+(b-d),b=L-z,d=L-b,fe[1]=L-(b+d)+(d-z),W=O+b,d=W-O,fe[2]=O-(W-d)+(b-d),fe[3]=W,$=lt*pt,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[1]=L-(b+d)+(d-z),W=O+b,d=W-O,pe[2]=O-(W-d)+(b-d),pe[3]=W,E=4):(Ce[0]=0,g=1,pe[0]=0,E=1),p!==0){const St=q(g,Ce,p,Et);f=Ot(f,Rt(q(u,tn,p,dt),dt,q(St,Et,2*lt,xt),xt,Bt),Bt);const Mt=q(E,pe,p,st);f=Ot(f,Jt(q(Mt,st,2*lt,dt),dt,q(Mt,st,p,kt),kt,q(St,Et,p,xt),xt,ue,Vt),Vt),v!==0&&(f=Ot(f,q(q(4,re,p,st),st,v,dt),dt)),M!==0&&(f=Ot(f,q(q(4,ne,-p,st),st,M,dt),dt))}if(S!==0){const St=q(g,Ce,S,Et);f=Ot(f,Rt(q(y,en,S,dt),dt,q(St,Et,2*mt,xt),xt,Bt),Bt);const Mt=q(E,pe,S,st);f=Ot(f,Jt(q(Mt,st,2*mt,dt),dt,q(Mt,st,S,kt),kt,q(St,Et,S,xt),xt,ue,Vt),Vt)}}return xe[f-1]}function ur(o,e,t,r,i,n,s,a){const c=o-s,f=t-s,h=i-s,l=e-a,p=r-a,v=n-a,M=f*v,S=h*p,C=c*c+l*l,F=h*l,m=c*v,w=f*f+p*p,u=c*p,y=f*l,g=h*h+v*v,I=C*(M-S)+w*(F-m)+g*(u-y),B=(Math.abs(M)+Math.abs(S))*C+(Math.abs(F)+Math.abs(m))*w+(Math.abs(u)+Math.abs(y))*g,E=cr*B;return I>E||-I>E?I:lr(o,e,t,r,i,n,s,a,B)}function dr(o,e){var t,r,i=0,n,s,a,c,f,h,l,p=o[0],v=o[1],M=e.length;for(t=0;t<M;t++){r=0;var S=e[t],C=S.length-1;if(h=S[0],h[0]!==S[C][0]&&h[1]!==S[C][1])throw new Error("First and last coordinates in a ring must be the same");for(s=h[0]-p,a=h[1]-v,r;r<C;r++){if(l=S[r+1],c=l[0]-p,f=l[1]-v,a===0&&f===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(n=ee(s,c,a,f,0,0),n===0)return 0;(n>0&&f>0&&a<=0||n<0&&f<=0&&a>0)&&i++}h=l,a=f,s=c}}return i%2!==0}function rn(o,e,t={}){if(!o)throw new Error("point is required");if(!e)throw new Error("polygon is required");const r=nr(o),i=rr(e),n=i.type,s=e.bbox;let a=i.coordinates;if(s&&pr(r,s)===!1)return!1;n==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const h=dr(r,a[f]);if(h===0)return!t.ignoreBoundary;h&&(c=!0)}return c}function pr(o,e){return e[0]<=o[0]&&e[1]<=o[1]&&e[2]>=o[0]&&e[3]>=o[1]}let kn=class{constructor(e=[],t=mr){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}};function mr(o,e){return o<e?-1:o>e?1:0}function En(o,e){return o.p.x>e.p.x?1:o.p.x<e.p.x?-1:o.p.y!==e.p.y?o.p.y>e.p.y?1:-1:1}function gr(o,e){return o.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:o.rightSweepEvent.p.x<e.rightSweepEvent.p.x?-1:o.rightSweepEvent.p.y!==e.rightSweepEvent.p.y?o.rightSweepEvent.p.y<e.rightSweepEvent.p.y?1:-1:1}class An{constructor(e,t,r,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}function wr(o,e){if(o.type==="FeatureCollection"){const t=o.features;for(let r=0;r<t.length;r++)In(t[r],e)}else In(o,e)}let Fe=0,Ye=0,Le=0;function In(o,e){const t=o.type==="Feature"?o.geometry:o;let r=t.coordinates;(t.type==="Polygon"||t.type==="MultiLineString")&&(r=[r]),t.type==="LineString"&&(r=[[r]]);for(let i=0;i<r.length;i++)for(let n=0;n<r[i].length;n++){let s=r[i][n][0],a=null;Ye=Ye+1;for(let c=0;c<r[i][n].length-1;c++){a=r[i][n][c+1];const f=new An(s,Fe,Ye,Le),h=new An(a,Fe,Ye,Le+1);f.otherEvent=h,h.otherEvent=f,En(f,h)>0?(h.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,h.isLeftEndpoint=!1),e.push(f),e.push(h),s=a,Le=Le+1}}Fe=Fe+1}class yr{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function vr(o,e){if(o===null||e===null||o.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.rightSweepEvent)||o.leftSweepEvent.isSamePoint(e.leftSweepEvent)||o.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;const t=o.leftSweepEvent.p.x,r=o.leftSweepEvent.p.y,i=o.rightSweepEvent.p.x,n=o.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,c=e.rightSweepEvent.p.x,f=e.rightSweepEvent.p.y,h=(f-a)*(i-t)-(c-s)*(n-r),l=(c-s)*(r-a)-(f-a)*(t-s),p=(i-t)*(r-a)-(n-r)*(t-s);if(h===0)return!1;const v=l/h,M=p/h;if(v>=0&&v<=1&&M>=0&&M<=1){const S=t+v*(i-t),C=r+v*(n-r);return[S,C]}return!1}function br(o,e){e=e||!1;const t=[],r=new kn([],gr);for(;o.length;){const i=o.pop();if(i.isLeftEndpoint){const n=new yr(i);for(let s=0;s<r.data.length;s++){const a=r.data[s];if(e&&a.leftSweepEvent.featureId===i.featureId)continue;const c=vr(n,a);c!==!1&&t.push(c)}r.push(n)}else i.isLeftEndpoint===!1&&r.pop()}return t}function xr(o,e){const t=new kn([],En);return wr(o,t),br(t,e)}var _r=xr;function Mr(o,e,t={}){const{removeDuplicates:r=!0,ignoreSelfIntersections:i=!0}=t;let n=[];o.type==="FeatureCollection"?n=n.concat(o.features):o.type==="Feature"?n.push(o):(o.type==="LineString"||o.type==="Polygon"||o.type==="MultiLineString"||o.type==="MultiPolygon")&&n.push(Ft(o)),e.type==="FeatureCollection"?n=n.concat(e.features):e.type==="Feature"?n.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&n.push(Ft(e));const s=_r(Kt(n),i);let a=[];if(r){const c={};s.forEach(f=>{const h=f.join(",");c[h]||(c[h]=!0,a.push(f))})}else a=s;return Kt(a.map(c=>Wt(c)))}function Sr(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function kr(o){if(Object.prototype.hasOwnProperty.call(o,"__esModule"))return o;var e=o.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(o).forEach(function(r){var i=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return o[r]}})}),t}function Er(o,e={}){let t=0,r=0,i=0;return Je(o,function(n){t+=n[0],r+=n[1],i++},!0),Wt([t/i,r/i],e.properties)}var je={exports:{}},$e={exports:{}},Ar=$e.exports,Pn;function Ir(){return Pn||(Pn=1,(function(o,e){(function(t,r){o.exports=r()})(Ar,function(){function t(m,w,u,y,g){(function I(B,E,X,A,D){for(;A>X;){if(A-X>600){var V=A-X+1,d=E-X+1,_=Math.log(V),x=.5*Math.exp(2*_/3),T=.5*Math.sqrt(_*x*(V-x)/V)*(d-V/2<0?-1:1),P=Math.max(X,Math.floor(E-d*x/V+T)),R=Math.min(A,Math.floor(E+(V-d)*x/V+T));I(B,E,P,R,D)}var b=B[E],O=X,L=A;for(r(B,X,E),D(B[A],b)>0&&r(B,X,A);O<L;){for(r(B,O,L),O++,L--;D(B[O],b)<0;)O++;for(;D(B[L],b)>0;)L--}D(B[X],b)===0?r(B,X,L):r(B,++L,A),L<=E&&(X=L+1),E<=L&&(A=L-1)}})(m,w,u||0,y||m.length-1,g||i)}function r(m,w,u){var y=m[w];m[w]=m[u],m[u]=y}function i(m,w){return m<w?-1:m>w?1:0}var n=function(m){m===void 0&&(m=9),this._maxEntries=Math.max(4,m),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(m,w,u){if(!u)return w.indexOf(m);for(var y=0;y<w.length;y++)if(u(m,w[y]))return y;return-1}function a(m,w){c(m,0,m.children.length,w,m)}function c(m,w,u,y,g){g||(g=C(null)),g.minX=1/0,g.minY=1/0,g.maxX=-1/0,g.maxY=-1/0;for(var I=w;I<u;I++){var B=m.children[I];f(g,m.leaf?y(B):B)}return g}function f(m,w){return m.minX=Math.min(m.minX,w.minX),m.minY=Math.min(m.minY,w.minY),m.maxX=Math.max(m.maxX,w.maxX),m.maxY=Math.max(m.maxY,w.maxY),m}function h(m,w){return m.minX-w.minX}function l(m,w){return m.minY-w.minY}function p(m){return(m.maxX-m.minX)*(m.maxY-m.minY)}function v(m){return m.maxX-m.minX+(m.maxY-m.minY)}function M(m,w){return m.minX<=w.minX&&m.minY<=w.minY&&w.maxX<=m.maxX&&w.maxY<=m.maxY}function S(m,w){return w.minX<=m.maxX&&w.minY<=m.maxY&&w.maxX>=m.minX&&w.maxY>=m.minY}function C(m){return{children:m,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function F(m,w,u,y,g){for(var I=[w,u];I.length;)if(!((u=I.pop())-(w=I.pop())<=y)){var B=w+Math.ceil((u-w)/y/2)*y;t(m,B,w,u,g),I.push(w,B,B,u)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(m){var w=this.data,u=[];if(!S(m,w))return u;for(var y=this.toBBox,g=[];w;){for(var I=0;I<w.children.length;I++){var B=w.children[I],E=w.leaf?y(B):B;S(m,E)&&(w.leaf?u.push(B):M(m,E)?this._all(B,u):g.push(B))}w=g.pop()}return u},n.prototype.collides=function(m){var w=this.data;if(!S(m,w))return!1;for(var u=[];w;){for(var y=0;y<w.children.length;y++){var g=w.children[y],I=w.leaf?this.toBBox(g):g;if(S(m,I)){if(w.leaf||M(m,I))return!0;u.push(g)}}w=u.pop()}return!1},n.prototype.load=function(m){if(!m||!m.length)return this;if(m.length<this._minEntries){for(var w=0;w<m.length;w++)this.insert(m[w]);return this}var u=this._build(m.slice(),0,m.length-1,0);if(this.data.children.length)if(this.data.height===u.height)this._splitRoot(this.data,u);else{if(this.data.height<u.height){var y=this.data;this.data=u,u=y}this._insert(u,this.data.height-u.height-1,!0)}else this.data=u;return this},n.prototype.insert=function(m){return m&&this._insert(m,this.data.height-1),this},n.prototype.clear=function(){return this.data=C([]),this},n.prototype.remove=function(m,w){if(!m)return this;for(var u,y,g,I=this.data,B=this.toBBox(m),E=[],X=[];I||E.length;){if(I||(I=E.pop(),y=E[E.length-1],u=X.pop(),g=!0),I.leaf){var A=s(m,I.children,w);if(A!==-1)return I.children.splice(A,1),E.push(I),this._condense(E),this}g||I.leaf||!M(I,B)?y?(u++,I=y.children[u],g=!1):I=null:(E.push(I),X.push(u),u=0,y=I,I=I.children[0])}return this},n.prototype.toBBox=function(m){return m},n.prototype.compareMinX=function(m,w){return m.minX-w.minX},n.prototype.compareMinY=function(m,w){return m.minY-w.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(m){return this.data=m,this},n.prototype._all=function(m,w){for(var u=[];m;)m.leaf?w.push.apply(w,m.children):u.push.apply(u,m.children),m=u.pop();return w},n.prototype._build=function(m,w,u,y){var g,I=u-w+1,B=this._maxEntries;if(I<=B)return a(g=C(m.slice(w,u+1)),this.toBBox),g;y||(y=Math.ceil(Math.log(I)/Math.log(B)),B=Math.ceil(I/Math.pow(B,y-1))),(g=C([])).leaf=!1,g.height=y;var E=Math.ceil(I/B),X=E*Math.ceil(Math.sqrt(B));F(m,w,u,X,this.compareMinX);for(var A=w;A<=u;A+=X){var D=Math.min(A+X-1,u);F(m,A,D,E,this.compareMinY);for(var V=A;V<=D;V+=E){var d=Math.min(V+E-1,D);g.children.push(this._build(m,V,d,y-1))}}return a(g,this.toBBox),g},n.prototype._chooseSubtree=function(m,w,u,y){for(;y.push(w),!w.leaf&&y.length-1!==u;){for(var g=1/0,I=1/0,B=void 0,E=0;E<w.children.length;E++){var X=w.children[E],A=p(X),D=(V=m,d=X,(Math.max(d.maxX,V.maxX)-Math.min(d.minX,V.minX))*(Math.max(d.maxY,V.maxY)-Math.min(d.minY,V.minY))-A);D<I?(I=D,g=A<g?A:g,B=X):D===I&&A<g&&(g=A,B=X)}w=B||w.children[0]}var V,d;return w},n.prototype._insert=function(m,w,u){var y=u?m:this.toBBox(m),g=[],I=this._chooseSubtree(y,this.data,w,g);for(I.children.push(m),f(I,y);w>=0&&g[w].children.length>this._maxEntries;)this._split(g,w),w--;this._adjustParentBBoxes(y,g,w)},n.prototype._split=function(m,w){var u=m[w],y=u.children.length,g=this._minEntries;this._chooseSplitAxis(u,g,y);var I=this._chooseSplitIndex(u,g,y),B=C(u.children.splice(I,u.children.length-I));B.height=u.height,B.leaf=u.leaf,a(u,this.toBBox),a(B,this.toBBox),w?m[w-1].children.push(B):this._splitRoot(u,B)},n.prototype._splitRoot=function(m,w){this.data=C([m,w]),this.data.height=m.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(m,w,u){for(var y,g,I,B,E,X,A,D=1/0,V=1/0,d=w;d<=u-w;d++){var _=c(m,0,d,this.toBBox),x=c(m,d,u,this.toBBox),T=(g=_,I=x,B=void 0,E=void 0,X=void 0,A=void 0,B=Math.max(g.minX,I.minX),E=Math.max(g.minY,I.minY),X=Math.min(g.maxX,I.maxX),A=Math.min(g.maxY,I.maxY),Math.max(0,X-B)*Math.max(0,A-E)),P=p(_)+p(x);T<D?(D=T,y=d,V=P<V?P:V):T===D&&P<V&&(V=P,y=d)}return y||u-w},n.prototype._chooseSplitAxis=function(m,w,u){var y=m.leaf?this.compareMinX:h,g=m.leaf?this.compareMinY:l;this._allDistMargin(m,w,u,y)<this._allDistMargin(m,w,u,g)&&m.children.sort(y)},n.prototype._allDistMargin=function(m,w,u,y){m.children.sort(y);for(var g=this.toBBox,I=c(m,0,w,g),B=c(m,u-w,u,g),E=v(I)+v(B),X=w;X<u-w;X++){var A=m.children[X];f(I,m.leaf?g(A):A),E+=v(I)}for(var D=u-w-1;D>=w;D--){var V=m.children[D];f(B,m.leaf?g(V):V),E+=v(B)}return E},n.prototype._adjustParentBBoxes=function(m,w,u){for(var y=u;y>=0;y--)f(w[y],m)},n.prototype._condense=function(m){for(var w=m.length-1,u=void 0;w>=0;w--)m[w].children.length===0?w>0?(u=m[w-1].children).splice(u.indexOf(m[w]),1):this.clear():a(m[w],this.toBBox)},n})})($e)),$e.exports}class Pr{constructor(e=[],t=Br){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}}function Br(o,e){return o<e?-1:o>e?1:0}const Or=kr(Object.freeze(Object.defineProperty({__proto__:null,default:Pr},Symbol.toStringTag,{value:"Module"})));var Se={exports:{}},on,Bn;function Tr(){return Bn||(Bn=1,on=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=(i-r)/2,f=0,h=c-1;f<c;h=f++){var l=t[r+f*2+0],p=t[r+f*2+1],v=t[r+h*2+0],M=t[r+h*2+1],S=p>s!=M>s&&n<(v-l)*(s-p)/(M-p)+l;S&&(a=!a)}return a}),on}var sn,On;function Nr(){return On||(On=1,sn=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=i-r,f=0,h=c-1;f<c;h=f++){var l=t[f+r][0],p=t[f+r][1],v=t[h+r][0],M=t[h+r][1],S=p>s!=M>s&&n<(v-l)*(s-p)/(M-p)+l;S&&(a=!a)}return a}),sn}var Tn;function Xr(){if(Tn)return Se.exports;Tn=1;var o=Tr(),e=Nr();return Se.exports=function(r,i,n,s){return i.length>0&&Array.isArray(i[0])?e(r,i,n,s):o(r,i,n,s)},Se.exports.nested=e,Se.exports.flat=o,Se.exports}var ke={exports:{}},Cr=ke.exports,Nn;function Dr(){return Nn||(Nn=1,(function(o,e){(function(t,r){r(e)})(Cr,function(t){const i=33306690738754706e-32;function n(S,C,F,m,w){let u,y,g,I,B=C[0],E=m[0],X=0,A=0;E>B==E>-B?(u=B,B=C[++X]):(u=E,E=m[++A]);let D=0;if(X<S&&A<F)for(E>B==E>-B?(g=u-((y=B+u)-B),B=C[++X]):(g=u-((y=E+u)-E),E=m[++A]),u=y,g!==0&&(w[D++]=g);X<S&&A<F;)E>B==E>-B?(g=u-((y=u+B)-(I=y-u))+(B-I),B=C[++X]):(g=u-((y=u+E)-(I=y-u))+(E-I),E=m[++A]),u=y,g!==0&&(w[D++]=g);for(;X<S;)g=u-((y=u+B)-(I=y-u))+(B-I),B=C[++X],u=y,g!==0&&(w[D++]=g);for(;A<F;)g=u-((y=u+E)-(I=y-u))+(E-I),E=m[++A],u=y,g!==0&&(w[D++]=g);return u===0&&D!==0||(w[D++]=u),D}function s(S){return new Float64Array(S)}const a=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,h=s(4),l=s(8),p=s(12),v=s(16),M=s(4);t.orient2d=function(S,C,F,m,w,u){const y=(C-u)*(F-w),g=(S-w)*(m-u),I=y-g;if(y===0||g===0||y>0!=g>0)return I;const B=Math.abs(y+g);return Math.abs(I)>=a*B?I:-(function(E,X,A,D,V,d,_){let x,T,P,R,b,O,L,$,U,z,Q,W,ft,ct,lt,pt,gt,mt;const Pt=E-V,Ct=A-V,St=X-d,Mt=D-d;b=(lt=($=Pt-(L=(O=134217729*Pt)-(O-Pt)))*(z=Mt-(U=(O=134217729*Mt)-(O-Mt)))-((ct=Pt*Mt)-L*U-$*U-L*z))-(Q=lt-(gt=($=St-(L=(O=134217729*St)-(O-St)))*(z=Ct-(U=(O=134217729*Ct)-(O-Ct)))-((pt=St*Ct)-L*U-$*U-L*z))),h[0]=lt-(Q+b)+(b-gt),b=(ft=ct-((W=ct+Q)-(b=W-ct))+(Q-b))-(Q=ft-pt),h[1]=ft-(Q+b)+(b-pt),b=(mt=W+Q)-W,h[2]=W-(mt-b)+(Q-b),h[3]=mt;let oe=(function(wn,zt){let Ge=zt[0];for(let k=1;k<wn;k++)Ge+=zt[k];return Ge})(4,h),ye=c*_;if(oe>=ye||-oe>=ye||(x=E-(Pt+(b=E-Pt))+(b-V),P=A-(Ct+(b=A-Ct))+(b-V),T=X-(St+(b=X-St))+(b-d),R=D-(Mt+(b=D-Mt))+(b-d),x===0&&T===0&&P===0&&R===0)||(ye=f*_+i*Math.abs(oe),(oe+=Pt*R+Mt*x-(St*P+Ct*T))>=ye||-oe>=ye))return oe;b=(lt=($=x-(L=(O=134217729*x)-(O-x)))*(z=Mt-(U=(O=134217729*Mt)-(O-Mt)))-((ct=x*Mt)-L*U-$*U-L*z))-(Q=lt-(gt=($=T-(L=(O=134217729*T)-(O-T)))*(z=Ct-(U=(O=134217729*Ct)-(O-Ct)))-((pt=T*Ct)-L*U-$*U-L*z))),M[0]=lt-(Q+b)+(b-gt),b=(ft=ct-((W=ct+Q)-(b=W-ct))+(Q-b))-(Q=ft-pt),M[1]=ft-(Q+b)+(b-pt),b=(mt=W+Q)-W,M[2]=W-(mt-b)+(Q-b),M[3]=mt;const pn=n(4,h,4,M,l);b=(lt=($=Pt-(L=(O=134217729*Pt)-(O-Pt)))*(z=R-(U=(O=134217729*R)-(O-R)))-((ct=Pt*R)-L*U-$*U-L*z))-(Q=lt-(gt=($=St-(L=(O=134217729*St)-(O-St)))*(z=P-(U=(O=134217729*P)-(O-P)))-((pt=St*P)-L*U-$*U-L*z))),M[0]=lt-(Q+b)+(b-gt),b=(ft=ct-((W=ct+Q)-(b=W-ct))+(Q-b))-(Q=ft-pt),M[1]=ft-(Q+b)+(b-pt),b=(mt=W+Q)-W,M[2]=W-(mt-b)+(Q-b),M[3]=mt;const mn=n(pn,l,4,M,p);b=(lt=($=x-(L=(O=134217729*x)-(O-x)))*(z=R-(U=(O=134217729*R)-(O-R)))-((ct=x*R)-L*U-$*U-L*z))-(Q=lt-(gt=($=T-(L=(O=134217729*T)-(O-T)))*(z=P-(U=(O=134217729*P)-(O-P)))-((pt=T*P)-L*U-$*U-L*z))),M[0]=lt-(Q+b)+(b-gt),b=(ft=ct-((W=ct+Q)-(b=W-ct))+(Q-b))-(Q=ft-pt),M[1]=ft-(Q+b)+(b-pt),b=(mt=W+Q)-W,M[2]=W-(mt-b)+(Q-b),M[3]=mt;const gn=n(mn,p,4,M,v);return v[gn-1]})(S,C,F,m,w,u,B)},t.orient2dfast=function(S,C,F,m,w,u){return(C-u)*(F-w)-(S-w)*(m-u)},Object.defineProperty(t,"__esModule",{value:!0})})})(ke,ke.exports)),ke.exports}var Xn;function Rr(){if(Xn)return je.exports;Xn=1;var o=Ir(),e=Or,t=Xr(),r=Dr().orient2d;e.default&&(e=e.default),je.exports=i,je.exports.default=i;function i(u,y,g){y=Math.max(0,y===void 0?2:y),g=g||0;var I=v(u),B=new o(16);B.toBBox=function(L){return{minX:L[0],minY:L[1],maxX:L[0],maxY:L[1]}},B.compareMinX=function(L,$){return L[0]-$[0]},B.compareMinY=function(L,$){return L[1]-$[1]},B.load(u);for(var E=[],X=0,A;X<I.length;X++){var D=I[X];B.remove(D),A=M(D,A),E.push(A)}var V=new o(16);for(X=0;X<E.length;X++)V.insert(p(E[X]));for(var d=y*y,_=g*g;E.length;){var x=E.shift(),T=x.p,P=x.next.p,R=S(T,P);if(!(R<_)){var b=R/d;D=n(B,x.prev.p,T,P,x.next.next.p,b,V),D&&Math.min(S(D,T),S(D,P))<=b&&(E.push(x),E.push(M(D,x)),B.remove(D),V.remove(x),V.insert(p(x)),V.insert(p(x.next)))}}x=A;var O=[];do O.push(x.p),x=x.next;while(x!==A);return O.push(x.p),O}function n(u,y,g,I,B,E,X){for(var A=new e([],s),D=u.data;D;){for(var V=0;V<D.children.length;V++){var d=D.children[V],_=D.leaf?C(d,g,I):a(g,I,d);_>E||A.push({node:d,dist:_})}for(;A.length&&!A.peek().node.children;){var x=A.pop(),T=x.node,P=C(T,y,g),R=C(T,I,B);if(x.dist<P&&x.dist<R&&f(g,T,X)&&f(I,T,X))return T}D=A.pop(),D&&(D=D.node)}return null}function s(u,y){return u.dist-y.dist}function a(u,y,g){if(c(u,g)||c(y,g))return 0;var I=F(u[0],u[1],y[0],y[1],g.minX,g.minY,g.maxX,g.minY);if(I===0)return 0;var B=F(u[0],u[1],y[0],y[1],g.minX,g.minY,g.minX,g.maxY);if(B===0)return 0;var E=F(u[0],u[1],y[0],y[1],g.maxX,g.minY,g.maxX,g.maxY);if(E===0)return 0;var X=F(u[0],u[1],y[0],y[1],g.minX,g.maxY,g.maxX,g.maxY);return X===0?0:Math.min(I,B,E,X)}function c(u,y){return u[0]>=y.minX&&u[0]<=y.maxX&&u[1]>=y.minY&&u[1]<=y.maxY}function f(u,y,g){for(var I=Math.min(u[0],y[0]),B=Math.min(u[1],y[1]),E=Math.max(u[0],y[0]),X=Math.max(u[1],y[1]),A=g.search({minX:I,minY:B,maxX:E,maxY:X}),D=0;D<A.length;D++)if(l(A[D].p,A[D].next.p,u,y))return!1;return!0}function h(u,y,g){return r(u[0],u[1],y[0],y[1],g[0],g[1])}function l(u,y,g,I){return u!==I&&y!==g&&h(u,y,g)>0!=h(u,y,I)>0&&h(g,I,u)>0!=h(g,I,y)>0}function p(u){var y=u.p,g=u.next.p;return u.minX=Math.min(y[0],g[0]),u.minY=Math.min(y[1],g[1]),u.maxX=Math.max(y[0],g[0]),u.maxY=Math.max(y[1],g[1]),u}function v(u){for(var y=u[0],g=u[0],I=u[0],B=u[0],E=0;E<u.length;E++){var X=u[E];X[0]<y[0]&&(y=X),X[0]>I[0]&&(I=X),X[1]<g[1]&&(g=X),X[1]>B[1]&&(B=X)}var A=[y,g,I,B],D=A.slice();for(E=0;E<u.length;E++)t(u[E],A)||D.push(u[E]);return w(D)}function M(u,y){var g={p:u,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return y?(g.next=y.next,g.prev=y,y.next.prev=g,y.next=g):(g.prev=g,g.next=g),g}function S(u,y){var g=u[0]-y[0],I=u[1]-y[1];return g*g+I*I}function C(u,y,g){var I=y[0],B=y[1],E=g[0]-I,X=g[1]-B;if(E!==0||X!==0){var A=((u[0]-I)*E+(u[1]-B)*X)/(E*E+X*X);A>1?(I=g[0],B=g[1]):A>0&&(I+=E*A,B+=X*A)}return E=u[0]-I,X=u[1]-B,E*E+X*X}function F(u,y,g,I,B,E,X,A){var D=g-u,V=I-y,d=X-B,_=A-E,x=u-B,T=y-E,P=D*D+V*V,R=D*d+V*_,b=d*d+_*_,O=D*x+V*T,L=d*x+_*T,$=P*b-R*R,U,z,Q,W,ft=$,ct=$;$===0?(z=0,ft=1,W=L,ct=b):(z=R*L-b*O,W=P*L-R*O,z<0?(z=0,W=L,ct=b):z>ft&&(z=ft,W=L+R,ct=b)),W<0?(W=0,-O<0?z=0:-O>P?z=ft:(z=-O,ft=P)):W>ct&&(W=ct,-O+R<0?z=0:-O+R>P?z=ft:(z=-O+R,ft=P)),U=z===0?0:z/ft,Q=W===0?0:W/ct;var lt=(1-U)*u+U*g,pt=(1-U)*y+U*I,gt=(1-Q)*B+Q*X,mt=(1-Q)*E+Q*A,Pt=gt-lt,Ct=mt-pt;return Pt*Pt+Ct*Ct}function m(u,y){return u[0]===y[0]?u[1]-y[1]:u[0]-y[0]}function w(u){u.sort(m);for(var y=[],g=0;g<u.length;g++){for(;y.length>=2&&h(y[y.length-2],y[y.length-1],u[g])<=0;)y.pop();y.push(u[g])}for(var I=[],B=u.length-1;B>=0;B--){for(;I.length>=2&&h(I[I.length-2],I[I.length-1],u[B])<=0;)I.pop();I.push(u[B])}return I.pop(),y.pop(),y.concat(I)}return je.exports}var Fr=Rr();const Yr=Sr(Fr);function Cn(o,e={}){e.concavity=e.concavity||1/0;const t=[];if(Je(o,i=>{t.push([i[0],i[1]])}),!t.length)return null;const r=Yr(t,e.concavity);return r.length>3?Me([r]):null}var Ee={exports:{}},Lr=Ee.exports,Dn;function jr(){return Dn||(Dn=1,(function(o,e){(function(t,r){r(e)})(Lr,(function(t){var r=Object.defineProperty,i=(k,N,Y)=>N in k?r(k,N,{enumerable:!0,configurable:!0,writable:!0,value:Y}):k[N]=Y,n=(k,N,Y)=>i(k,typeof N!="symbol"?N+"":N,Y);function s(k,N,Y={}){const j={type:"Feature"};return(Y.id===0||Y.id)&&(j.id=Y.id),Y.bbox&&(j.bbox=Y.bbox),j.properties=N||{},j.geometry=k,j}function a(k,N,Y={}){if(!k)throw new Error("coordinates is required");if(!Array.isArray(k))throw new Error("coordinates must be an Array");if(k.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!h(k[0])||!h(k[1]))throw new Error("coordinates must contain numbers");return s({type:"Point",coordinates:k},N,Y)}function c(k,N,Y={}){for(const j of k){if(j.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(j[j.length-1].length!==j[0].length)throw new Error("First and last Position are not equivalent.");for(let et=0;et<j[j.length-1].length;et++)if(j[j.length-1][et]!==j[0][et])throw new Error("First and last Position are not equivalent.")}return s({type:"Polygon",coordinates:k},N,Y)}function f(k,N={}){const Y={type:"FeatureCollection"};return N.id&&(Y.id=N.id),N.bbox&&(Y.bbox=N.bbox),Y.features=k,Y}function h(k){return!isNaN(k)&&k!==null&&!Array.isArray(k)}function l(k){if(!k)throw new Error("coord is required");if(!Array.isArray(k)){if(k.type==="Feature"&&k.geometry!==null&&k.geometry.type==="Point")return[...k.geometry.coordinates];if(k.type==="Point")return[...k.coordinates]}if(Array.isArray(k)&&k.length>=2&&!Array.isArray(k[0])&&!Array.isArray(k[1]))return[...k];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function p(k){if(Array.isArray(k))return k;if(k.type==="Feature"){if(k.geometry!==null)return k.geometry.coordinates}else if(k.coordinates)return k.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function v(k){return k.type==="Feature"?k.geometry:k}const M=11102230246251565e-32,S=134217729,C=(3+8*M)*M;function F(k,N,Y,j,et){let K,Z,ot,it,at=N[0],ht=j[0],J=0,tt=0;ht>at==ht>-at?(K=at,at=N[++J]):(K=ht,ht=j[++tt]);let ut=0;if(J<k&&tt<Y)for(ht>at==ht>-at?(Z=at+K,ot=K-(Z-at),at=N[++J]):(Z=ht+K,ot=K-(Z-ht),ht=j[++tt]),K=Z,ot!==0&&(et[ut++]=ot);J<k&&tt<Y;)ht>at==ht>-at?(Z=K+at,it=Z-K,ot=K-(Z-it)+(at-it),at=N[++J]):(Z=K+ht,it=Z-K,ot=K-(Z-it)+(ht-it),ht=j[++tt]),K=Z,ot!==0&&(et[ut++]=ot);for(;J<k;)Z=K+at,it=Z-K,ot=K-(Z-it)+(at-it),at=N[++J],K=Z,ot!==0&&(et[ut++]=ot);for(;tt<Y;)Z=K+ht,it=Z-K,ot=K-(Z-it)+(ht-it),ht=j[++tt],K=Z,ot!==0&&(et[ut++]=ot);return(K!==0||ut===0)&&(et[ut++]=K),ut}function m(k,N){let Y=N[0];for(let j=1;j<k;j++)Y+=N[j];return Y}function w(k){return new Float64Array(k)}const u=(3+16*M)*M,y=(2+12*M)*M,g=(9+64*M)*M*M,I=w(4),B=w(8),E=w(12),X=w(16),A=w(4);function D(k,N,Y,j,et,K,Z){let ot,it,at,ht,J,tt,ut,_t,nt,H,G,wt,It,At,Xt,vt,Nt,Lt;const Qt=k-et,Ht=Y-et,Zt=N-K,te=j-K;At=Qt*te,tt=S*Qt,ut=tt-(tt-Qt),_t=Qt-ut,tt=S*te,nt=tt-(tt-te),H=te-nt,Xt=_t*H-(At-ut*nt-_t*nt-ut*H),vt=Zt*Ht,tt=S*Zt,ut=tt-(tt-Zt),_t=Zt-ut,tt=S*Ht,nt=tt-(tt-Ht),H=Ht-nt,Nt=_t*H-(vt-ut*nt-_t*nt-ut*H),G=Xt-Nt,J=Xt-G,I[0]=Xt-(G+J)+(J-Nt),wt=At+G,J=wt-At,It=At-(wt-J)+(G-J),G=It-vt,J=It-G,I[1]=It-(G+J)+(J-vt),Lt=wt+G,J=Lt-wt,I[2]=wt-(Lt-J)+(G-J),I[3]=Lt;let ve=m(4,I),Xe=y*Z;if(ve>=Xe||-ve>=Xe||(J=k-Qt,ot=k-(Qt+J)+(J-et),J=Y-Ht,at=Y-(Ht+J)+(J-et),J=N-Zt,it=N-(Zt+J)+(J-K),J=j-te,ht=j-(te+J)+(J-K),ot===0&&it===0&&at===0&&ht===0)||(Xe=g*Z+C*Math.abs(ve),ve+=Qt*ht+te*ot-(Zt*at+Ht*it),ve>=Xe||-ve>=Xe))return ve;At=ot*te,tt=S*ot,ut=tt-(tt-ot),_t=ot-ut,tt=S*te,nt=tt-(tt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return X[Ri-1]}function V(k,N,Y,j,et,K){const Z=(N-K)*(Y-et),ot=(k-et)*(j-K),it=Z-ot,at=Math.abs(Z+ot);return Math.abs(it)>=u*at?it:-D(k,N,Y,j,et,K,at)}function d(k,N){var Y,j,et=0,K,Z,ot,it,at,ht,J,tt=k[0],ut=k[1],_t=N.length;for(Y=0;Y<_t;Y++){j=0;var nt=N[Y],H=nt.length-1;if(ht=nt[0],ht[0]!==nt[H][0]&&ht[1]!==nt[H][1])throw new Error("First and last coordinates in a ring must be the same");for(Z=ht[0]-tt,ot=ht[1]-ut,j;j<H;j++){if(J=nt[j+1],it=J[0]-tt,at=J[1]-ut,ot===0&&at===0){if(it<=0&&Z>=0||Z<=0&&it>=0)return 0}else if(at>=0&&ot<=0||at<=0&&ot>=0){if(K=V(Z,it,ot,at,0,0),K===0)return 0;(K>0&&at>0&&ot<=0||K<0&&at<=0&&ot>0)&&et++}ht=J,ot=at,Z=it}}return et%2!==0}function _(k,N,Y={}){if(!k)throw new Error("point is required");if(!N)throw new Error("polygon is required");const j=l(k),et=v(N),K=et.type,Z=N.bbox;let ot=et.coordinates;if(Z&&x(j,Z)===!1)return!1;K==="Polygon"&&(ot=[ot]);let it=!1;for(var at=0;at<ot.length;++at){const ht=d(j,ot[at]);if(ht===0)return!Y.ignoreBoundary;ht&&(it=!0)}return it}function x(k,N){return N[0]<=k[0]&&N[1]<=k[1]&&N[2]>=k[0]&&N[3]>=k[1]}function T(k,N){for(let Y=0;Y<N.features.length;Y++)if(_(k,N.features[Y]))return N.features[Y]}function P(k,N,Y){const j=N.geometry.coordinates[0][0],et=N.geometry.coordinates[0][1],K=N.geometry.coordinates[0][2],Z=k.geometry.coordinates,ot=N.properties.a.geom,it=N.properties.b.geom,at=N.properties.c.geom,ht=[et[0]-j[0],et[1]-j[1]],J=[K[0]-j[0],K[1]-j[1]],tt=[Z[0]-j[0],Z[1]-j[1]],ut=[it[0]-ot[0],it[1]-ot[1]],_t=[at[0]-ot[0],at[1]-ot[1]];let nt=(J[1]*tt[0]-J[0]*tt[1])/(ht[0]*J[1]-ht[1]*J[0]),H=(ht[0]*tt[1]-ht[1]*tt[0])/(ht[0]*J[1]-ht[1]*J[0]);if(Y){const G=Y[N.properties.a.index],wt=Y[N.properties.b.index],It=Y[N.properties.c.index];let At;if(nt<0||H<0||1-nt-H<0){const Xt=nt/(nt+H),vt=H/(nt+H);At=nt/wt/(Xt/wt+vt/It),H=H/It/(Xt/wt+vt/It)}else At=nt/wt/(nt/wt+H/It+(1-nt-H)/G),H=H/It/(nt/wt+H/It+(1-nt-H)/G);nt=At}return[nt*ut[0]+H*_t[0]+ot[0],nt*ut[1]+H*_t[1]+ot[1]]}function R(k,N,Y,j){const et=k.geometry.coordinates,K=Y.geometry.coordinates,Z=Math.atan2(et[0]-K[0],et[1]-K[1]),ot=L(Z,N[0]);if(ot===void 0)throw new Error("Unable to determine vertex index");const it=N[1][ot];return P(k,it.features[0],j)}function b(k,N,Y,j,et,K,Z,ot){let it;if(Z&&(it=T(k,f([Z]))),!it)if(Y){const at=k.geometry.coordinates,ht=Y.gridNum,J=Y.xOrigin,tt=Y.yOrigin,ut=Y.xUnit,_t=Y.yUnit,nt=Y.gridCache,H=O(at[0],J,ut,ht),G=O(at[1],tt,_t,ht),wt=nt[H]?nt[H][G]?nt[H][G]:[]:[],It=f(wt.map(At=>N.features[At]));it=T(k,It)}else it=T(k,N);return ot&&ot(it),it?P(k,it,K):R(k,j,et,K)}function O(k,N,Y,j){let et=Math.floor((k-N)/Y);return et<0&&(et=0),et>=j&&(et=j-1),et}function L(k,N){let Y=$(k-N[0]),j=Math.PI*2,et;for(let K=0;K<N.length;K++){const Z=(K+1)%N.length,ot=$(k-N[Z]),it=Math.min(Math.abs(Y),Math.abs(ot));Y*ot<=0&&it<j&&(j=it,et=K),Y=ot}return et}function $(k,N=!1){const Y=2*Math.PI,j=k-Math.floor(k/Y)*Y;return N?j:j>Math.PI?j-Y:j}function U(k,N){return N&&N>=2.00703||Array.isArray(k[0])?k:k.map(Y=>[Y.illstNodes,Y.mercNodes,Y.startEnd])}function z(k){const N=k.features;for(let Y=0;Y<N.length;Y++){const j=N[Y];`${j.properties.a.index}`.substring(0,1)==="b"&&`${j.properties.b.index}`.substring(0,1)==="b"?N[Y]={geometry:{type:"Polygon",coordinates:[[j.geometry.coordinates[0][2],j.geometry.coordinates[0][0],j.geometry.coordinates[0][1],j.geometry.coordinates[0][2]]]},properties:{a:{geom:j.properties.c.geom,index:j.properties.c.index},b:{geom:j.properties.a.geom,index:j.properties.a.index},c:{geom:j.properties.b.geom,index:j.properties.b.index}},type:"Feature"}:`${j.properties.c.index}`.substring(0,1)==="b"&&`${j.properties.a.index}`.substring(0,1)==="b"&&(N[Y]={geometry:{type:"Polygon",coordinates:[[j.geometry.coordinates[0][1],j.geometry.coordinates[0][2],j.geometry.coordinates[0][0],j.geometry.coordinates[0][1]]]},properties:{a:{geom:j.properties.b.geom,index:j.properties.b.index},b:{geom:j.properties.c.geom,index:j.properties.c.index},c:{geom:j.properties.a.geom,index:j.properties.a.index}},type:"Feature"})}return k}function Q(k){const N=["a","b","c","a"].map(K=>k.properties[K].geom),Y=k.geometry.coordinates[0],j=k.properties,et={a:{geom:Y[0],index:j.a.index},b:{geom:Y[1],index:j.b.index},c:{geom:Y[2],index:j.c.index}};return c([N],et)}function W(k){const N=[0,1,2,0].map(j=>k[j][0][0]),Y={a:{geom:k[0][0][1],index:k[0][1]},b:{geom:k[1][0][1],index:k[1][1]},c:{geom:k[2][0][1],index:k[2][1]}};return c([N],Y)}function ft(k,N,Y,j,et,K=!1,Z){const ot=k.map(it=>{(!Z||Z<2.00703)&&(it=ct(it));const at=isFinite(it)?N[it]:it==="c"?j:(function(){const ht=it.match(/^b(\d+)$/);if(ht)return et[parseInt(ht[1])];const J=it.match(/^e(\d+)$/);if(J)return Y[parseInt(J[1])];throw new Error("Bad index value for indexesToTri")})();return K?[[at[1],at[0]],it]:[[at[0],at[1]],it]});return W(ot)}function ct(k){return typeof k=="number"?k:k.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}const lt=2.00703;function pt(k){return!!(k.version!==void 0||!k.tins&&k.points&&k.tins_points)}function gt(k){return{points:k.points,pointsWeightBuffer:Pt(k),strictStatus:Ct(k),verticesParams:St(k),centroid:oe(k),edges:U(k.edges||[]),edgeNodes:k.edgeNodes||[],tins:ye(k),kinks:pn(k.kinks_points),yaxisMode:k.yaxisMode??"invert",strictMode:k.strictMode??"auto",vertexMode:k.vertexMode,bounds:k.bounds,boundsPolygon:k.boundsPolygon,wh:k.wh,xy:k.xy??[0,0]}}function mt(k){const N=mn(k),Y=N.tins;return{compiled:N,tins:Y,points:gn(Y),strictStatus:N.strict_status,pointsWeightBuffer:N.weight_buffer,verticesParams:N.vertices_params,centroid:N.centroid,kinks:N.kinks}}function Pt(k){return!k.version||k.version<lt?["forw","bakw"].reduce((N,Y)=>{const j=k.weight_buffer[Y];return j&&(N[Y]=Object.keys(j).reduce((et,K)=>{const Z=ct(K);return et[Z]=j[K],et},{})),N},{}):k.weight_buffer}function Ct(k){return k.strict_status?k.strict_status:k.kinks_points?"strict_error":k.tins_points.length===2?"loose":"strict"}function St(k){const N={forw:[k.vertices_params[0]],bakw:[k.vertices_params[1]]};return N.forw[1]=Mt(k,!1),N.bakw[1]=Mt(k,!0),N}function Mt(k,N){const Y=k.vertices_points.length;return Array.from({length:Y},(j,et)=>{const K=(et+1)%Y,Z=ft(["c",`b${et}`,`b${K}`],k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,N,lt);return f([Z])})}function oe(k){return{forw:a(k.centroid_point[0],{target:{geom:k.centroid_point[1],index:"c"}}),bakw:a(k.centroid_point[1],{target:{geom:k.centroid_point[0],index:"c"}})}}function ye(k){const N=k.tins_points.length===1?0:1;return{forw:f(k.tins_points[0].map(Y=>ft(Y,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!1,k.version))),bakw:f(k.tins_points[N].map(Y=>ft(Y,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!0,k.version)))}}function pn(k){if(k)return{bakw:f(k.map(N=>a(N)))}}function mn(k){return JSON.parse(JSON.stringify(k).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function gn(k){const N=[],Y=k.forw.features;for(let j=0;j<Y.length;j++){const et=Y[j];["a","b","c"].forEach((K,Z)=>{const ot=et.geometry.coordinates[0][Z],it=et.properties[K].geom,at=et.properties[K].index;typeof at=="number"&&(N[at]=[ot,it])})}return N}const wn=lt,zt=class se{constructor(){n(this,"points",[]),n(this,"pointsWeightBuffer"),n(this,"strict_status"),n(this,"vertices_params"),n(this,"centroid"),n(this,"edgeNodes"),n(this,"edges"),n(this,"tins"),n(this,"kinks"),n(this,"yaxisMode",se.YAXIS_INVERT),n(this,"strictMode",se.MODE_AUTO),n(this,"vertexMode",se.VERTEX_PLAIN),n(this,"bounds"),n(this,"boundsPolygon"),n(this,"wh"),n(this,"xy"),n(this,"indexedTins"),n(this,"stateFull",!1),n(this,"stateTriangle"),n(this,"stateBackward"),n(this,"priority"),n(this,"importance"),n(this,"xyBounds"),n(this,"mercBounds")}setCompiled(N){if(pt(N)){this.applyModernState(gt(N));return}this.applyLegacyState(mt(N))}applyModernState(N){this.points=N.points,this.pointsWeightBuffer=N.pointsWeightBuffer,this.strict_status=N.strictStatus,this.vertices_params=N.verticesParams,this.centroid=N.centroid,this.edges=N.edges,this.edgeNodes=N.edgeNodes||[],this.tins=N.tins,this.addIndexedTin(),this.kinks=N.kinks,this.yaxisMode=N.yaxisMode??se.YAXIS_INVERT,this.vertexMode=N.vertexMode??se.VERTEX_PLAIN,this.strictMode=N.strictMode??se.MODE_AUTO,N.bounds?(this.bounds=N.bounds,this.boundsPolygon=N.boundsPolygon,this.xy=N.xy,this.wh=N.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=N.xy??[0,0],N.wh&&(this.wh=N.wh))}applyLegacyState(N){this.tins=N.tins,this.addIndexedTin(),this.strict_status=N.strictStatus,this.pointsWeightBuffer=N.pointsWeightBuffer,this.vertices_params=N.verticesParams,this.centroid=N.centroid,this.kinks=N.kinks,this.points=N.points}addIndexedTin(){const N=this.tins,Y=N.forw,j=N.bakw,et=Math.ceil(Math.sqrt(Y.features.length));if(et<3){this.indexedTins=void 0;return}let K=[],Z=[];const ot=Y.features.map(nt=>{let H=[];return p(nt)[0].map(G=>{K.length===0?K=[Array.from(G),Array.from(G)]:(G[0]<K[0][0]&&(K[0][0]=G[0]),G[0]>K[1][0]&&(K[1][0]=G[0]),G[1]<K[0][1]&&(K[0][1]=G[1]),G[1]>K[1][1]&&(K[1][1]=G[1])),H.length===0?H=[Array.from(G),Array.from(G)]:(G[0]<H[0][0]&&(H[0][0]=G[0]),G[0]>H[1][0]&&(H[1][0]=G[0]),G[1]<H[0][1]&&(H[0][1]=G[1]),G[1]>H[1][1]&&(H[1][1]=G[1]))}),H}),it=(K[1][0]-K[0][0])/et,at=(K[1][1]-K[0][1])/et,ht=ot.reduce((nt,H,G)=>{const wt=O(H[0][0],K[0][0],it,et),It=O(H[1][0],K[0][0],it,et),At=O(H[0][1],K[0][1],at,et),Xt=O(H[1][1],K[0][1],at,et);for(let vt=wt;vt<=It;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=At;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(G)}return nt},[]),J=j.features.map(nt=>{let H=[];return p(nt)[0].map(G=>{Z.length===0?Z=[Array.from(G),Array.from(G)]:(G[0]<Z[0][0]&&(Z[0][0]=G[0]),G[0]>Z[1][0]&&(Z[1][0]=G[0]),G[1]<Z[0][1]&&(Z[0][1]=G[1]),G[1]>Z[1][1]&&(Z[1][1]=G[1])),H.length===0?H=[Array.from(G),Array.from(G)]:(G[0]<H[0][0]&&(H[0][0]=G[0]),G[0]>H[1][0]&&(H[1][0]=G[0]),G[1]<H[0][1]&&(H[0][1]=G[1]),G[1]>H[1][1]&&(H[1][1]=G[1]))}),H}),tt=(Z[1][0]-Z[0][0])/et,ut=(Z[1][1]-Z[0][1])/et,_t=J.reduce((nt,H,G)=>{const wt=O(H[0][0],Z[0][0],tt,et),It=O(H[1][0],Z[0][0],tt,et),At=O(H[0][1],Z[0][1],ut,et),Xt=O(H[1][1],Z[0][1],ut,et);for(let vt=wt;vt<=It;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=At;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(G)}return nt},[]);this.indexedTins={forw:{gridNum:et,xOrigin:K[0][0],yOrigin:K[0][1],xUnit:it,yUnit:at,gridCache:ht},bakw:{gridNum:et,xOrigin:Z[0][0],yOrigin:Z[0][1],xUnit:tt,yUnit:ut,gridCache:_t}}}transform(N,Y,j){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(Y&&this.strict_status==se.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==se.YAXIS_FOLLOW&&Y&&(N=[N[0],-1*N[1]]);const et=a(N);if(this.bounds&&!Y&&!j&&!_(et,this.boundsPolygon))return!1;const K=Y?this.tins.bakw:this.tins.forw,Z=Y?this.indexedTins.bakw:this.indexedTins.forw,ot=Y?this.vertices_params.bakw:this.vertices_params.forw,it=Y?this.centroid.bakw:this.centroid.forw,at=Y?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let ht,J;this.stateFull&&(this.stateBackward==Y?ht=this.stateTriangle:(this.stateBackward=Y,this.stateTriangle=void 0),J=ut=>{this.stateTriangle=ut});let tt=b(et,K,Z,ot,it,at,ht,J);if(this.bounds&&Y&&!j){const ut=a(tt);if(!_(ut,this.boundsPolygon))return!1}else this.yaxisMode==se.YAXIS_FOLLOW&&!Y&&(tt=[tt[0],-1*tt[1]]);return tt}};n(zt,"VERTEX_PLAIN","plain"),n(zt,"VERTEX_BIRDEYE","birdeye"),n(zt,"MODE_STRICT","strict"),n(zt,"MODE_AUTO","auto"),n(zt,"MODE_LOOSE","loose"),n(zt,"STATUS_STRICT","strict"),n(zt,"STATUS_ERROR","strict_error"),n(zt,"STATUS_LOOSE","loose"),n(zt,"YAXIS_FOLLOW","follow"),n(zt,"YAXIS_INVERT","invert");let Ge=zt;t.Transform=Ge,t.counterTri=Q,t.format_version=wn,t.normalizeEdges=U,t.rotateVerticesTriangle=z,t.transformArr=b,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}))})(Ee,Ee.exports)),Ee.exports}var Gt=jr();const Rn=Math.pow(2,-52),qe=new Uint32Array(512);class an{static from(e,t=zr,r=Wr){const i=e.length,n=new Float64Array(i*2);for(let s=0;s<i;s++){const a=e[s];n[2*s]=t(a),n[2*s+1]=r(a)}return new an(n)}constructor(e){const t=e.length>>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const r=Math.max(2*t-5,0);this._triangles=new Uint32Array(r*3),this._halfedges=new Int32Array(r*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:r,_hullTri:i,_hullHash:n}=this,s=e.length>>1;let a=1/0,c=1/0,f=-1/0,h=-1/0;for(let E=0;E<s;E++){const X=e[2*E],A=e[2*E+1];X<a&&(a=X),A<c&&(c=A),X>f&&(f=X),A>h&&(h=A),this._ids[E]=E}const l=(a+f)/2,p=(c+h)/2;let v,M,S;for(let E=0,X=1/0;E<s;E++){const A=cn(l,p,e[2*E],e[2*E+1]);A<X&&(v=E,X=A)}const C=e[2*v],F=e[2*v+1];for(let E=0,X=1/0;E<s;E++){if(E===v)continue;const A=cn(C,F,e[2*E],e[2*E+1]);A<X&&A>0&&(M=E,X=A)}let m=e[2*M],w=e[2*M+1],u=1/0;for(let E=0;E<s;E++){if(E===v||E===M)continue;const X=Vr(C,F,m,w,e[2*E],e[2*E+1]);X<u&&(S=E,u=X)}let y=e[2*S],g=e[2*S+1];if(u===1/0){for(let A=0;A<s;A++)this._dists[A]=e[2*A]-e[0]||e[2*A+1]-e[1];_e(this._ids,this._dists,0,s-1);const E=new Uint32Array(s);let X=0;for(let A=0,D=-1/0;A<s;A++){const V=this._ids[A],d=this._dists[V];d>D&&(E[X++]=V,D=d)}this.hull=E.subarray(0,X),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(ee(C,F,m,w,y,g)<0){const E=M,X=m,A=w;M=S,m=y,w=g,S=E,y=X,g=A}const I=Ur(C,F,m,w,y,g);this._cx=I.x,this._cy=I.y;for(let E=0;E<s;E++)this._dists[E]=cn(e[2*E],e[2*E+1],I.x,I.y);_e(this._ids,this._dists,0,s-1),this._hullStart=v;let B=3;r[v]=t[S]=M,r[M]=t[v]=S,r[S]=t[M]=v,i[v]=0,i[M]=1,i[S]=2,n.fill(-1),n[this._hashKey(C,F)]=v,n[this._hashKey(m,w)]=M,n[this._hashKey(y,g)]=S,this.trianglesLen=0,this._addTriangle(v,M,S,-1,-1,-1);for(let E=0,X,A;E<this._ids.length;E++){const D=this._ids[E],V=e[2*D],d=e[2*D+1];if(E>0&&Math.abs(V-X)<=Rn&&Math.abs(d-A)<=Rn||(X=V,A=d,D===v||D===M||D===S))continue;let _=0;for(let b=0,O=this._hashKey(V,d);b<this._hashSize&&(_=n[(O+b)%this._hashSize],!(_!==-1&&_!==r[_]));b++);_=t[_];let x=_,T;for(;T=r[x],ee(V,d,e[2*x],e[2*x+1],e[2*T],e[2*T+1])>=0;)if(x=T,x===_){x=-1;break}if(x===-1)continue;let P=this._addTriangle(x,D,r[x],-1,-1,i[x]);i[D]=this._legalize(P+2),i[x]=P,B++;let R=r[x];for(;T=r[R],ee(V,d,e[2*R],e[2*R+1],e[2*T],e[2*T+1])<0;)P=this._addTriangle(R,D,T,i[D],-1,i[R]),i[D]=this._legalize(P+2),r[R]=R,B--,R=T;if(x===_)for(;T=t[x],ee(V,d,e[2*T],e[2*T+1],e[2*x],e[2*x+1])<0;)P=this._addTriangle(T,D,x,-1,i[x],i[T]),this._legalize(P+2),i[T]=P,r[x]=x,B--,x=T;this._hullStart=t[D]=x,r[x]=t[R]=D,r[D]=R,n[this._hashKey(V,d)]=D,n[this._hashKey(e[2*x],e[2*x+1])]=x}this.hull=new Uint32Array(B);for(let E=0,X=this._hullStart;E<B;E++)this.hull[E]=X,X=r[X];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor($r(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:r,coords:i}=this;let n=0,s=0;for(;;){const a=r[e],c=e-e%3;if(s=c+(e+2)%3,a===-1){if(n===0)break;e=qe[--n];continue}const f=a-a%3,h=c+(e+1)%3,l=f+(a+2)%3,p=t[s],v=t[e],M=t[h],S=t[l];if(qr(i[2*p],i[2*p+1],i[2*v],i[2*v+1],i[2*M],i[2*M+1],i[2*S],i[2*S+1])){t[e]=S,t[a]=p;const F=r[l];if(F===-1){let w=this._hullStart;do{if(this._hullTri[w]===l){this._hullTri[w]=e;break}w=this._hullPrev[w]}while(w!==this._hullStart)}this._link(e,F),this._link(a,r[s]),this._link(s,l);const m=f+(a+1)%3;n<qe.length&&(qe[n++]=m)}else{if(n===0)break;e=qe[--n]}}return s}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,r,i,n,s){const a=this.trianglesLen;return this._triangles[a]=e,this._triangles[a+1]=t,this._triangles[a+2]=r,this._link(a,i),this._link(a+1,n),this._link(a+2,s),this.trianglesLen+=3,a}}function $r(o,e){const t=o/(Math.abs(o)+Math.abs(e));return(e>0?3-t:1+t)/4}function cn(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function qr(o,e,t,r,i,n,s,a){const c=o-s,f=e-a,h=t-s,l=r-a,p=i-s,v=n-a,M=c*c+f*f,S=h*h+l*l,C=p*p+v*v;return c*(l*C-S*v)-f*(h*C-S*p)+M*(h*v-l*p)<0}function Vr(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,f=n-e,h=s*s+a*a,l=c*c+f*f,p=.5/(s*f-a*c),v=(f*h-a*l)*p,M=(s*l-c*h)*p;return v*v+M*M}function Ur(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,f=n-e,h=s*s+a*a,l=c*c+f*f,p=.5/(s*f-a*c),v=o+(f*h-a*l)*p,M=e+(s*l-c*h)*p;return{x:v,y:M}}function _e(o,e,t,r){if(r-t<=20)for(let i=t+1;i<=r;i++){const n=o[i],s=e[n];let a=i-1;for(;a>=t&&e[o[a]]>s;)o[a+1]=o[a--];o[a+1]=n}else{const i=t+r>>1;let n=t+1,s=r;Ae(o,i,n),e[o[t]]>e[o[r]]&&Ae(o,t,r),e[o[n]]>e[o[r]]&&Ae(o,n,r),e[o[t]]>e[o[n]]&&Ae(o,t,n);const a=o[n],c=e[a];for(;;){do n++;while(e[o[n]]<c);do s--;while(e[o[s]]>c);if(s<n)break;Ae(o,n,s)}o[t+1]=o[s],o[s]=a,r-n+1>=s-t?(_e(o,e,n,r),_e(o,e,t,s-1)):(_e(o,e,t,s-1),_e(o,e,n,r))}}function Ae(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function zr(o){return o[0]}function Wr(o){return o[1]}class Gr{constructor(e,t){bt(this,"bs");bt(this,"width");this.width=e,this.bs=t}add(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]|=1<<r,this}delete(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]&=~(1<<r),this}set(e,t){const r=Math.floor(e/this.width),n=1<<e%this.width;return this.bs[r]^=(-Number(t)^this.bs[r])&n,t}has(e){const t=Math.floor(e/this.width),r=e%this.width;return(this.bs[t]&1<<r)!==0}forEach(e){const t=this.bs.length;for(let r=0;r<t;r++){let i=0;for(;this.bs[r]&&i<this.width;)this.bs[r]&1<<i&&e(r*this.width+i),i++}return this}}class Fn extends Gr{constructor(e){super(8,new Uint8Array(Math.ceil(e/8)).fill(0))}}function we(o){return o%3===2?o-2:o+1}function ae(o){return o%3===0?o+2:o-1}function Yn(o,e,t,r,i,n,s,a){const c=ee(o,e,i,n,s,a),f=ee(t,r,i,n,s,a);if(c>0&&f>0||c<0&&f<0)return!1;const h=ee(i,n,o,e,t,r),l=ee(s,a,o,e,t,r);return h>0&&l>0||h<0&&l<0?!1:c===0&&f===0&&h===0&&l===0?!(Math.max(i,s)<Math.min(o,t)||Math.max(o,t)<Math.min(i,s)||Math.max(n,a)<Math.min(e,r)||Math.max(e,r)<Math.min(n,a)):!0}class Jr{constructor(e){bt(this,"del");this.del=e}}class Ln extends Jr{constructor(t,r){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);bt(this,"vertMap");bt(this,"flips");bt(this,"consd");const i=2**32-1,n=t.coords.length>>1,s=t.triangles.length;this.vertMap=new Uint32Array(n).fill(i),this.flips=new Fn(s),this.consd=new Fn(s);for(let a=0;a<s;a++){const c=t.triangles[a];this.vertMap[c]===i&&this.updateVert(a)}r&&this.constrainAll(r)}constrainOne(t,r){const{triangles:i,halfedges:n}=this.del,s=this.vertMap[t];let a=s;do{const h=i[a],l=we(a);if(h===r)return this.protect(a);const p=ae(a),v=i[p];if(v===r)return this.protect(l),l;if(this.intersectSegments(t,r,v,h)){a=p;break}a=n[l]}while(a!==-1&&a!==s);let c=a,f=-1;for(;a!==-1;){const h=n[a],l=ae(a),p=ae(h),v=we(h);if(h===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(a))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,r,i[a])||this.isCollinear(t,r,i[h]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[a],i[h],i[l],i[p])){if(f===-1&&(f=a),i[p]===r){if(a===f)throw new Error("Infinite loop: non-convex quadrilateral");a=f,f=-1;continue}if(this.intersectSegments(t,r,i[p],i[h]))a=p;else if(this.intersectSegments(t,r,i[v],i[p]))a=v;else if(f===a)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(a),this.intersectSegments(t,r,i[l],i[p])&&(f===-1&&(f=l),f===l))throw new Error("Infinite loop: flipped diagonal still intersects");i[p]===r?(c=p,a=f,f=-1):this.intersectSegments(t,r,i[v],i[p])&&(a=v)}return this.protect(c),this.delaunify(!0),this.findEdge(t,r)}delaunify(t=!1){const{halfedges:r}=this.del,i=this.flips,n=this.consd,s=r.length;let a;do{a=0;for(let c=0;c<s;c++){if(n.has(c))continue;i.delete(c);const f=r[c];f!==-1&&(i.delete(f),this.isDelaunay(c)||(this.flipDiagonal(c),a++))}}while(t&&a>0);return this}constrainAll(t){const r=t.length;for(let i=0;i<r;i++){const n=t[i];this.constrainOne(n[0],n[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,r){const i=this.vertMap[r],{triangles:n,halfedges:s}=this.del;let a=i,c=-1;do{if(n[a]===t)return a;c=we(a),a=s[c]}while(a!==-1&&a!==i);return n[we(c)]===t?-c:1/0}protect(t){const r=this.del.halfedges[t],i=this.flips,n=this.consd;return i.delete(t),n.add(t),r!==-1?(i.delete(r),n.add(r),r):-t}markFlip(t){const r=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const s=r[t];return s!==-1&&(i.add(t),i.add(s)),!0}flipDiagonal(t){const{triangles:r,halfedges:i}=this.del,n=this.flips,s=this.consd,a=i[t],c=ae(t),f=we(t),h=ae(a),l=we(a),p=i[c],v=i[h];if(s.has(t))throw new Error("Trying to flip a constrained edge");return r[t]=r[h],i[t]=v,n.set(t,n.has(h))||s.set(t,s.has(h)),v!==-1&&(i[v]=t),i[c]=h,r[a]=r[c],i[a]=p,n.set(a,n.has(c))||s.set(a,s.has(c)),p!==-1&&(i[p]=a),i[h]=c,this.markFlip(t),this.markFlip(f),this.markFlip(a),this.markFlip(l),n.add(c),s.delete(c),n.add(h),s.delete(h),this.updateVert(t),this.updateVert(f),this.updateVert(a),this.updateVert(l),c}isCollinear(t,r,i){const n=this.del.coords;return ee(n[t*2],n[t*2+1],n[r*2],n[r*2+1],n[i*2],n[i*2+1])===0}inCircle(t,r,i,n){const s=this.del.coords;return ur(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])<0}isDelaunay(t){const{triangles:r,halfedges:i}=this.del,n=i[t];if(n===-1)return!0;const s=r[ae(t)],a=r[t],c=r[we(t)],f=r[ae(n)];return!this.inCircle(s,a,c,f)}updateVert(t){const{triangles:r,halfedges:i}=this.del,n=this.vertMap,s=r[t];let a=ae(t),c=i[a];for(;c!==-1&&c!==t;)a=ae(c),c=i[a];return n[s]=a,a}intersectSegments(t,r,i,n){const s=this.del.coords;return t===i||t===n||r===i||r===n?!1:Yn(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])}}bt(Ln,"intersectSegments",Yn);function Ie(o,e,t){if(e||(e=[]),typeof o!="object"||o.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(e))throw"Argument points must be Array of Array";const r=o.features.map(c=>c.geometry.coordinates),i=an.from(r);let n;const s=[];i.triangles.length!==0&&e.length!==0&&(n=new Ln(i),n.constrainAll(e));for(let c=0;c<i.triangles.length;c+=3)s.push([i.triangles[c],i.triangles[c+1],i.triangles[c+2]]);const a=["a","b","c"];return Kt(s.map(c=>{const f={},h=c.map((l,p)=>{const v=o.features[l],M=v.geometry.coordinates,S=[M[0],M[1]];return M.length===3?S[2]=M[2]:f[a[p]]=v.properties[t],S});return h[3]=h[0],Me([h],f)}))}function Kr(o,e){const t=[[],[],[],[]],r=[];return Object.keys(o).forEach(i=>{const n=o[i],s=n.forw,a=n.bakw,c=[s[0]-e.forw[0],s[1]-e.forw[1]],f=[a[0]-e.bakw[0],e.bakw[1]-a[1]],h={forw:c,bakw:f};if(r.push(h),c[0]===0||c[1]===0)return;let l=0;c[0]>0&&(l+=1),c[1]>0&&(l+=2),t[l].push(h)}),{perQuad:t,aggregate:r}}function Qr(o){let e=1/0,t=0,r=0;return o.forEach(i=>{const{forw:n,bakw:s}=i,a=Math.hypot(n[0],n[1]),c=Math.hypot(s[0],s[1]);if(c===0)return;const f=a/c,h=Math.atan2(n[0],n[1])-Math.atan2(s[0],s[1]);e=Math.min(e,f),t+=Math.cos(h),r+=Math.sin(h)}),isFinite(e)?[e,Math.atan2(r,t)]:[1,0]}function Hr(o,e,t){const{perQuad:r,aggregate:i}=Kr(o,e),n=r.every(c=>c.length>0),a=(t==="birdeye"?n?r:[i]:[i]).map(c=>Qr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Zr(o,e){let t=0;return o[0]>e[0]&&(t+=1),o[1]>e[1]&&(t+=2),t}function ti(o,e,t){const r=[o[0]-e.forw[0],o[1]-e.forw[1]],n=Math.sqrt(r[0]**2+r[1]**2)/t[0],s=Math.atan2(r[0],r[1])-t[1];return[e.bakw[0]+n*Math.sin(s),e.bakw[1]-n*Math.cos(s)]}function ei(o,e,t,r){const i=e[0]-o[0],n=e[1]-o[1];if(Math.abs(i)<1e-12&&Math.abs(n)<1e-12)return null;const s=r[0]-t[0],a=r[1]-t[1],c=t[0]-o[0],f=t[1]-o[1],h=i*a-n*s;if(Math.abs(h)<1e-12)return null;const l=(c*a-f*s)/h,p=(c*n-f*i)/h;return l<=1e-10||p<-1e-10||p>1+1e-10?null:{t:l,point:[o[0]+l*i,o[1]+l*n]}}function ni(o,e,t){const r=t.length;let i=-1/0,n=null;for(let s=0;s<r;s++){const a=(s+1)%r,c=ei(o,e,t[s].bakw,t[a].bakw);c&&c.t>i&&(i=c.t,n=c.point)}return n}function jn(o,e){const r=Math.atan2(o[0]-e[0],o[1]-e[1])*(180/Math.PI);return r<0?r+360:r}function $n(o,e,t,r,i,n){const s=e[0]-o[0],a=e[1]-o[1];if(s===0&&a===0)return null;const c=[];if(s!==0)for(const h of[t,r]){const l=(h-o[0])/s;if(l>0){const p=o[1]+l*a;p>=i&&p<=n&&c.push({t:l,x:h,y:p})}}if(a!==0)for(const h of[i,n]){const l=(h-o[1])/a;if(l>0){const p=o[0]+l*s;p>=t&&p<=r&&c.push({t:l,x:p,y:h})}}if(c.length===0)return null;c.sort((h,l)=>h.t-l.t);const f=c[0];return[f.x,f.y]}function qn(o,e,t){const r=o.length,i=new Array(r).fill(1);for(const n of e)for(let s=0;s<r;s++){const a=(s+1)%r,c=yn([o[s].bakw,o[a].bakw]),f=yn([t.bakw,n.bakw]),h=Mr(c,f);if(h.features.length>0&&h.features[0].geometry){const l=h.features[0],p=Math.sqrt(Math.pow(n.bakw[0]-t.bakw[0],2)+Math.pow(n.bakw[1]-t.bakw[1],2)),v=Math.sqrt(Math.pow(l.geometry.coordinates[0]-t.bakw[0],2)+Math.pow(l.geometry.coordinates[1]-t.bakw[1],2)),M=p/v;M>i[s]&&(i[s]=M),M>i[a]&&(i[a]=M)}}o.forEach((n,s)=>{const a=i[s];n.bakw=[(n.bakw[0]-t.bakw[0])*a+t.bakw[0],(n.bakw[1]-t.bakw[1])*a+t.bakw[1]]})}function Vn(o,e,t){const{convexBuf:r,centroid:i,allGcps:n,minx:s,maxx:a,miny:c,maxy:f}=o,h=Hr(r,i,e),p=[[s,c],[a,c],[a,f],[s,f]].map(g=>({forw:g,bakw:ti(g,i,h[Zr(g,i.forw)])}));if(p.sort((g,I)=>Math.atan2(g.forw[0]-i.forw[0],g.forw[1]-i.forw[1])-Math.atan2(I.forw[0]-i.forw[0],I.forw[1]-i.forw[1])),qn(p,n,i),!t)return p;const v=4,M=p.map(g=>Math.atan2(g.forw[0]-i.forw[0],g.forw[1]-i.forw[1])),S=p.map(g=>Math.atan2(g.bakw[0]-i.bakw[0],-(g.bakw[1]-i.bakw[1])));function C(g){for(let I=0;I<v;I++){const B=(I+1)%v,E=M[I],X=I<v-1?M[B]:M[B]+2*Math.PI;let A=g;for(;A<E;)A+=2*Math.PI;for(;A>=E+2*Math.PI;)A-=2*Math.PI;if(A>=E&&A<X)return{i:I,j:B,frac:(A-E)/(X-E)}}return{i:0,j:1,frac:0}}function F(g){const{i:I,j:B,frac:E}=C(g),X=S[I];let D=S[B]-X;for(;D>Math.PI;)D-=2*Math.PI;for(;D<-Math.PI;)D+=2*Math.PI;return X+E*D}const m=new Set(p.map(g=>Math.floor(jn(g.forw,i.forw)/10)%36)),w=n.map(g=>({forw:g.forw,bakw:g.bakw,angleDeg:jn(g.forw,i.forw),forwDist:Math.hypot(g.forw[0]-i.forw[0],g.forw[1]-i.forw[1])})),u=[];for(let g=0;g<36;g++){if(m.has(g))continue;const I=g*10,B=w.filter(_=>_.angleDeg>=I&&_.angleDeg<I+10);let E=null;if(B.length>0){const _=B.reduce((x,T)=>T.forwDist>x.forwDist?T:x);E=$n(i.forw,_.forw,s,a,c,f)}if(!E){const _=(I+5)%360*(Math.PI/180),x=[i.forw[0]+Math.sin(_),i.forw[1]+Math.cos(_)];E=$n(i.forw,x,s,a,c,f)}if(!E)continue;const X=[E[0]-i.forw[0],E[1]-i.forw[1]],A=Math.atan2(X[0],X[1]),D=F(A),V=[i.bakw[0]+Math.sin(D),i.bakw[1]-Math.cos(D)],d=ni(i.bakw,V,p);d&&u.push({forw:E,bakw:d})}const y=[...p,...u];return y.sort((g,I)=>Math.atan2(g.forw[0]-i.forw[0],g.forw[1]-i.forw[1])-Math.atan2(I.forw[0]-i.forw[0],I.forw[1]-i.forw[1])),qn(y,n,i),y}function ri(o,e=!1){return Vn(o,"plain",e)}function ii(o,e=!1){return Vn(o,"birdeye",e)}function Un(o){const t=new oi(o).findSegmentIntersections(),r=Qn(t),i=new Map;return r.forEach(n=>{i.set(`${n.x}:${n.y}`,n)}),Array.from(i.values()).map(n=>Wt([n.x,n.y]))}class oi{constructor(e){bt(this,"_xx");bt(this,"_yy");bt(this,"_ii");bt(this,"_nn");bt(this,"_zz",null);bt(this,"_zlimit",0);bt(this,"_bb",null);bt(this,"_allBounds",null);bt(this,"_arcIter",null);bt(this,"_filteredArcIter",null);bt(this,"buf");this.initArcs(e)}initArcs(e){const t=[],r=[],i=e.map(n=>{const s=n?n.length:0;for(let a=0;a<s;a++)t.push(n[a][0]),r.push(n[a][1]);return s});this.initXYData(i,t,r)}initXYData(e,t,r){const i=e.length;this._xx=new Float64Array(t),this._yy=new Float64Array(r),this._nn=new Uint32Array(e),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(i);let n=0;for(let s=0;s<i;s++)this._ii[s]=n,n+=e[s];(n!=this._xx.length||this._xx.length!=this._yy.length)&&fn("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new ki(this._xx,this._yy)}initBounds(){const e=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=e.bb,this._allBounds=e.bounds}calcArcBounds_(e,t,r){const i=r.length,n=new Float64Array(i*4),s=new Be;let a=0,c,f,h;for(let l=0;l<i;l++)c=r[l],c>0&&(f=l*4,h=Ei(e,t,a,c),n[f++]=h[0],n[f++]=h[1],n[f++]=h[2],n[f]=h[3],a+=c,s.mergeBounds(h));return{bb:n,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new Be}forEachSegment(e){let t=0;for(let r=0,i=this.size();r<i;r++)t+=this.forEachArcSegment(r,e);return t}size(){return this._ii&&this._ii.length||0}forEachArcSegment(e,t){const r=e>=0,i=r?e:~e,n=this.getRetainedInterval(),s=this._nn[i],a=r?1:-1;let c=r?this._ii[i]:this._ii[i]+s-1,f=c,h=0;for(let l=1;l<s;l++)f+=a,(n===0||this._zz[f]>=n)&&(t(c,f,this._xx,this._yy),c=f,h++);return h}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(e){const t=e*4;return(!this.buf||this.buf.byteLength<t)&&(this.buf=new ArrayBuffer(t)),new Uint32Array(this.buf,0,e)}getAvgSegment2(){let e=0,t=0;const r=this.forEachSegment((i,n,s,a)=>{e+=Math.abs(s[i]-s[n]),t+=Math.abs(a[i]-a[n])});return[e/r||0,t/r||0]}calcSegmentIntersectionStripeCount(){const e=this.getBounds().height(),t=this.getAvgSegment2()[1];let r=1;return t>0&&e>0&&(r=Math.ceil(e/t/20)),r||1}findSegmentIntersections(){const e=this.getBounds(),t=e.ymin||0,r=(e.ymax||0)-t,i=this.calcSegmentIntersectionStripeCount(),n=new Uint32Array(i),s=i>1?S=>Math.floor((i-1)*(S-t)/r):()=>0;let a,c;this.forEachSegment((S,C,F,m)=>{let w=s(m[S]);const u=s(m[C]);for(;n[w]=n[w]+2,w!=u;)w+=u>w?1:-1});const f=this.getUint32Array(ci(n));let h=0;const l=[];fi(n,S=>{const C=h;h+=S,l.push(f.subarray(C,h))}),hi(n,0),this.forEachSegment((S,C,F,m)=>{let w=s(m[S]);const u=s(m[C]);let y,g;for(;y=n[w],n[w]=y+2,g=l[w],g[y]=S,g[y+1]=C,w!=u;)w+=u>w?1:-1});const p=this.getVertexData(),v=[];let M;for(a=0;a<i;a++)if(p.xx&&p.yy)for(M=li(l[a],p.xx,p.yy),c=0;c<M.length;c++)v.push(M[c]);return Qn(v)}}function fn(...o){const e=o.join(" ");throw new Error(e)}function hn(o){return o?ai(o)?!0:si(o)?!1:o.length===0?!0:o.length>0:!1}function si(o){return o!=null&&o.toString===String.prototype.toString}function ai(o){return Array.isArray(o)}function ci(o,e){hn(o)||fn("utils.sum() expects an array, received:",o);let t=0,r;for(let i=0,n=o.length;i<n;i++)r=o[i],r&&(t+=r);return t}function fi(o,e,t){if(!hn(o))throw new Error(`#forEach() takes an array-like argument. ${o}`);for(let r=0,i=o.length;r<i;r++)e.call(t,o[r],r)}function hi(o,e){for(let t=0,r=o.length;t<r;t++)o[t]=e;return o}function li(o,e,t){const r=o.length-2,i=[];let n,s,a,c,f,h,l,p,v,M,S,C,F,m,w,u,y;for(xi(e,o),u=0;u<r;){for(n=o[u],s=o[u+1],f=e[n],h=e[s],v=t[n],M=t[s],y=u;y<r&&(y+=2,a=o[y],l=e[a],!(h<l));){if(S=t[a],c=o[y+1],p=e[c],C=t[c],v>=S){if(v>C&&M>S&&M>C)continue}else if(v<C&&M<S&&M<C)continue;n==a||n==c||s==a||s==c||(F=ui(f,v,h,M,l,S,p,C),F&&(m=[n,s],w=[a,c],i.push(Jn(F,m,w,e,t)),F.length==4&&i.push(Jn(F.slice(2),m,w,e,t))))}u+=2}return i}function ui(o,e,t,r,i,n,s,a){const c=di(o,e,t,r,i,n,s,a);let f=null;return c&&(f=pi(o,e,t,r,i,n,s,a),f?bi(o,e,t,r,i,n,s,a)&&(f=null):f=vi(o,e,t,r,i,n,s,a)),f}function di(o,e,t,r,i,n,s,a){return Pe(o,e,t,r,i,n)*Pe(o,e,t,r,s,a)<=0&&Pe(i,n,s,a,o,e)*Pe(i,n,s,a,t,r)<=0}function Pe(o,e,t,r,i,n){return zn(o-i,e-n,t-i,r-n)}function zn(o,e,t,r){return o*r-e*t}function pi(o,e,t,r,i,n,s,a){let c=Ve(o,e,t,r,i,n,s,a),f;return c&&(f=gi(c[0],c[1],o,e,t,r,i,n,s,a),f==1?c=Ve(t,r,o,e,i,n,s,a):f==2?c=Ve(i,n,s,a,o,e,t,r):f==3&&(c=Ve(s,a,i,n,o,e,t,r))),c&&yi(c,o,e,t,r,i,n,s,a),c}function Ve(o,e,t,r,i,n,s,a){const c=zn(t-o,r-e,s-i,a-n),f=1e-18;let h;if(c===0)return null;const l=Pe(i,n,s,a,o,e)/c;return c<=f&&c>=-f?h=mi(o,e,t,r,i,n,s,a):h=[o+l*(t-o),e+l*(r-e)],h}function mi(o,e,t,r,i,n,s,a){let c=null;return!ce(o,i,s)&&!ce(e,n,a)?c=[o,e]:!ce(t,i,s)&&!ce(r,n,a)?c=[t,r]:!ce(i,o,t)&&!ce(n,e,r)?c=[i,n]:!ce(s,o,t)&&!ce(a,e,r)&&(c=[s,a]),c}function ce(o,e,t){let r;return e<t?r=o<e||o>t:e>t?r=o>e||o<t:r=o!=e,r}function gi(o,e,...t){let r=-1,i=1/0,n;for(let s=0,a=0,c=t.length;a<c;s++,a+=2)n=wi(o,e,t[a],t[a+1]),n<i&&(i=n,r=s);return r}function wi(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function yi(o,e,t,r,i,n,s,a,c){let f=o[0],h=o[1];f=Ue(f,e,r),f=Ue(f,n,a),h=Ue(h,t,i),h=Ue(h,s,c),o[0]=f,o[1]=h}function Ue(o,e,t){let r;return ce(o,e,t)&&(r=Math.abs(o-e)<Math.abs(o-t)?e:t,o=r),o}function vi(o,e,t,r,i,n,s,a){const c=Math.min(o,t,i,s),f=Math.max(o,t,i,s),h=Math.min(e,r,n,a),l=Math.max(e,r,n,a),p=l-h>f-c;let v=[];return(p?de(e,h,l):de(o,c,f))&&v.push(o,e),(p?de(r,h,l):de(t,c,f))&&v.push(t,r),(p?de(n,h,l):de(i,c,f))&&v.push(i,n),(p?de(a,h,l):de(s,c,f))&&v.push(s,a),(v.length!=2&&v.length!=4||v.length==4&&v[0]==v[2]&&v[1]==v[3])&&(v=null),v}function bi(o,e,t,r,i,n,s,a){return o==i&&e==n||o==s&&e==a||t==i&&r==n||t==s&&r==a}function de(o,e,t){return o>e&&o<t}function xi(o,e){_i(o,e),Wn(o,e,0,e.length-2)}function _i(o,e){for(let t=0,r=e.length;t<r;t+=2)o[e[t]]>o[e[t+1]]&&Mi(e,t,t+1)}function Mi(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function Wn(o,e,t,r){let i=t,n=r,s,a;for(;i<r;){for(s=o[e[t+r>>2<<1]];i<=n;){for(;o[e[i]]<s;)i+=2;for(;o[e[n]]>s;)n-=2;i<=n&&(a=e[i],e[i]=e[n],e[n]=a,a=e[i+1],e[i+1]=e[n+1],e[n+1]=a,i+=2,n-=2)}if(n-t<40?Gn(o,e,t,n):Wn(o,e,t,n),r-i<40){Gn(o,e,i,r);return}t=i,n=r}}function Gn(o,e,t,r){let i,n;for(let s=t+2;s<=r;s+=2){i=e[s],n=e[s+1];let a;for(a=s-2;a>=t&&o[i]<o[e[a]];a-=2)e[a+2]=e[a],e[a+3]=e[a+1];e[a+2]=i,e[a+3]=n}}function Jn(o,e,t,r,i){const n=o[0],s=o[1];e=Kn(n,s,e[0],e[1],r,i),t=Kn(n,s,t[0],t[1],r,i);const a=e[0]<t[0]?e:t,c=a==e?t:e;return{x:n,y:s,a,b:c}}function Kn(o,e,t,r,i,n){let s=t<r?t:r,a=s===t?r:t;return i[s]==o&&n[s]==e?a=s:i[a]==o&&n[a]==e&&(s=a),[s,a]}function Qn(o){const e={};return o.filter(t=>{const r=Si(t);return r in e?!1:(e[r]=!0,!0)})}function Si(o){return`${o.a.join(",")};${o.b.join(",")}`}class ki{constructor(e,t){bt(this,"_i",0);bt(this,"_n",0);bt(this,"_inc",1);bt(this,"_xx");bt(this,"_yy");bt(this,"i",0);bt(this,"x",0);bt(this,"y",0);this._xx=e,this._yy=t}}function Ei(o,e,t,r){let i=t|0;const n=isNaN(r)?o.length-i:r+i;let s,a,c,f,h,l;if(n>0)c=h=o[i],f=l=e[i];else return[void 0,void 0,void 0,void 0];for(i++;i<n;i++)s=o[i],a=e[i],s<c&&(c=s),s>h&&(h=s),a<f&&(f=a),a>l&&(l=a);return[c,f,h,l]}class Be{constructor(...e){bt(this,"xmin");bt(this,"ymin");bt(this,"xmax");bt(this,"ymax");e.length>0&&this.setBounds(e)}cloneBounds(){return this.clone()}clone(){return new Be(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(e,t,r,i){let n,s,a,c;if(arguments.length==1)if(hn(e)){const f=e;n=f[0],s=f[1],a=f[2],c=f[3]}else{const f=e;n=f.xmin,s=f.ymin,a=f.xmax,c=f.ymax}else n=e,s=t,a=r,c=i;return this.xmin=n,this.ymin=s,this.xmax=a,this.ymax=c,(n>a||s>c)&&this.update(),this}update(){let e;this.xmin>this.xmax&&(e=this.xmin,this.xmin=this.xmax,this.xmax=e),this.ymin>this.ymax&&(e=this.ymin,this.ymin=this.ymax,this.ymax=e)}mergeBounds(e,...t){let r,i,n,s;return e instanceof Be?(r=e.xmin,i=e.ymin,n=e.xmax,s=e.ymax):t.length==3?(r=e,i=t[0],n=t[1],s=t[2]):e.length==4?(r=e[0],i=e[1],n=e[2],s=e[3]):fn("Bounds#mergeBounds() invalid argument:",e),this.xmin===void 0?this.setBounds(r,i,n,s):(r<this.xmin&&(this.xmin=r),i<this.ymin&&(this.ymin=i),n>this.xmax&&(this.xmax=n),s>this.ymax&&(this.ymax=s)),this}}function ze(o){const e=["a","b","c"].map(t=>o.properties[t].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(t=>t.map(r=>e[r]).sort().join("-")).sort()}function ln(o,e,t){const r=ze(e.forw),i=ze(e.bakw);if(JSON.stringify(r)!=JSON.stringify(i))throw`${JSON.stringify(e,null,2)}
2
- ${JSON.stringify(r)}
3
- ${JSON.stringify(i)}`;for(let n=0;n<r.length;n++){const s=r[n];o[s]||(o[s]=[]),o[s].push(e)}t&&(t.forw.features.push(e.forw),t.bakw.features.push(e.bakw))}function Hn(o,e,t){const r=ze(e.forw),i=ze(e.bakw);if(JSON.stringify(r)!=JSON.stringify(i))throw`${JSON.stringify(e,null,2)}
4
- ${JSON.stringify(r)}
5
- ${JSON.stringify(i)}`;if(r.forEach(n=>{const s=o[n];if(!s)return;const a=s.filter(c=>c!==e);a.length===0?delete o[n]:o[n]=a}),t){const n=(s,a)=>{!s||!a||(s.features=s.features.filter(c=>c!==a))};n(t.forw,e.forw),n(t.bakw,e.bakw)}}function Oe(o,e,t){return Wt(o,{target:{geom:e,index:t}})}function Te(o){return Wt(o.properties.target.geom,{target:{geom:o.geometry.coordinates,index:o.properties.target.index}})}function un(o,e){const t=o.length,r=e.geometry.coordinates;return Array.from({length:t},(i,n)=>n).map(i=>{const n=(i+1)%t,s=o[i],a=o[n],c=s.geometry.coordinates,f=Math.atan2(c[0]-r[0],c[1]-r[1]),h=[e,s,a,e].map(v=>v.geometry.coordinates),l={a:{geom:e.properties.target.geom,index:e.properties.target.index},b:{geom:s.properties.target.geom,index:s.properties.target.index},c:{geom:a.properties.target.geom,index:a.properties.target.index}},p=Kt([Me([h],l)]);return[f,p]}).reduce((i,n)=>(i[0].push(n[0]),i[1].push(n[1]),i),[[],[]])}function Ai(o){const{tins:e,targets:t,includeReciprocals:r,numBoundaryVertices:i=4}=o,n={};t.forEach(a=>{const c=e[a];if(!c||!c.features)return;n[a]={};const f={};c.features.forEach(h=>{const l=["a","b","c"];for(let p=0;p<3;p++){const v=(p+1)%3,M=l[p],S=l[v],C=h.properties[M].index,F=h.properties[S].index,m=[C,F].sort().join("-");if(f[m])continue;f[m]=!0;const w=h.geometry.coordinates[0][p],u=h.geometry.coordinates[0][v],y=h.properties[M].geom,g=h.properties[S].geom,I=Math.sqrt(Math.pow(y[0]-g[0],2)+Math.pow(y[1]-g[1],2))/Math.sqrt(Math.pow(w[0]-u[0],2)+Math.pow(w[1]-u[1],2)),B=n[a];B[`${C}:${m}`]=I,B[`${F}:${m}`]=I}})});const s={};return r&&(s.bakw={}),t.forEach(a=>{const c=n[a];if(s[a]={},!c)return;const f={};Object.keys(c).forEach(l=>{const[p]=l.split(":");f[p]||(f[p]=[]),f[p].push(c[l])}),Object.keys(f).forEach(l=>{const p=f[l],v=p.reduce((M,S)=>M+S,0)/p.length;s[a][l]=v,r&&s.bakw&&(s.bakw[l]=1/v)});let h=0;for(let l=0;l<i;l++){const p=`b${l}`,v=s[a][p]||0;h+=v}s[a].c=h/i,r&&s.bakw&&(s.bakw.c=1/s[a].c)}),s}function We(o,e=1e-6){const[t,r]=o[0],[i,n]=o[1],[s,a]=o[2];return Math.abs((i-t)*(a-r)-(s-t)*(n-r))<e}function Ii(o,e){const t=o.split("-");if(t.length!==2||!t.every(n=>/^-?\d+$/.test(n)))return!1;const[r,i]=t.map(n=>parseInt(n,10)).sort((n,s)=>n-s);return e.some(n=>{if(n.length!==2)return!1;const s=n.map(c=>parseInt(`${c}`,10));if(s.some(c=>Number.isNaN(c)))return!1;const a=s.sort((c,f)=>c-f);return a[0]===r&&a[1]===i})}function Ne(o){return["a","b","c"].map((e,t)=>({prop:o.properties[e],geom:o.geometry.coordinates[0][t]}))}const Pi=10;function Bi(o,e,t,r,i,n){if(!o&&!e)return!1;const s=o?0:1,a=1-s,c=t[s],f=t[a];if(!c||!f)return!1;const h=Ut(f.geom);let l=!1,p=!1;for(let v=0;v<=1;v++){const M=r[v];if(!M)continue;const S=[String(M.prop.index),String(c.prop.index)].sort().join("-"),C=i[S];if(!C||C.length<2)continue;const F=C.find(A=>A.bakw!==n[s].bakw);if(!F)continue;const w=Ne(F.bakw).find(A=>String(A.prop.index)!==String(M.prop.index)&&String(A.prop.index)!==String(c.prop.index));if(!w)continue;l=!0;const u=Ut(w.geom),y=Ut(M.geom),g=Ut(c.geom),I=g[0]-y[0],B=g[1]-y[1],E=I*(h[1]-y[1])-B*(h[0]-y[0]),X=I*(u[1]-y[1])-B*(u[0]-y[0]);if(E*X>0){p=!0;break}}return l&&!p}function Oi(o,e,t,r){if(!o&&!e)return!1;if(t[0]&&t[1]&&r[0]&&r[1]){const i=r.map(h=>Ut(h.geom)),n=t.map(h=>Ut(h.geom)),s=i[1][0]-i[0][0],a=i[1][1]-i[0][1],c=s*(n[0][1]-i[0][1])-a*(n[0][0]-i[0][0]),f=s*(n[1][1]-i[0][1])-a*(n[1][0]-i[0][0]);return c*f<0}return!1}function Ti(o,e,t){const r=new Set;let i=!1;for(let n=0;n<Pi;n++){let s=!1;for(const a of Object.keys(e)){if(r.has(a))continue;r.add(a);const c=e[a];if(!c||c.length<2)continue;const f=a.split("-");if(f.length!==2||Ii(a,t))continue;const h=Ne(c[0].bakw),l=Ne(c[1].bakw),p=Ne(c[0].forw),v=Ne(c[1].forw),M=f.map(P=>h.find(R=>`${R.prop.index}`===P)||l.find(R=>`${R.prop.index}`===P)),S=f.map(P=>p.find(R=>`${R.prop.index}`===P)||v.find(R=>`${R.prop.index}`===P));if(M.some(P=>!P)||S.some(P=>!P))continue;const C=[h,l].map(P=>P.find(R=>!f.includes(`${R.prop.index}`))),F=[p,v].map(P=>P.find(R=>!f.includes(`${R.prop.index}`)));if(C.some(P=>!P)||F.some(P=>!P))continue;const m=c[0].bakw.geometry.coordinates[0].slice(0,3).map(P=>Ut(P)),w=c[1].bakw.geometry.coordinates[0].slice(0,3).map(P=>Ut(P)),u=c[0].forw.geometry.coordinates[0].slice(0,3).map(P=>Ut(P)),y=c[1].forw.geometry.coordinates[0].slice(0,3).map(P=>Ut(P)),g=We(m),I=We(w),B=We(u),E=We(y),X=Bi(g,I,C,M,e,c),A=Oi(B,E,C,M);if(!(X||A||Zn(Ut(C[0].geom),w)||Zn(Ut(C[1].geom),m)))continue;const V=S.map(P=>Ut(P.geom)),d=F.map(P=>Ut(P.geom)),_=Ni([...V,...d]),x=Xi(_),T=tr(V[0],V[1],d[0])+tr(V[0],V[1],d[1]);dn(x,T)&&(Hn(e,c[0],o),Hn(e,c[1],o),M.forEach(P=>{if(!P)return;const R=[P.geom,C[0].geom,C[1].geom,P.geom],b={a:P.prop,b:C[0].prop,c:C[1].prop},O=Me([R],b),L=Gt.counterTri(O);ln(e,{forw:L,bakw:O},o)}),s=!0,i=!0)}if(!s)break}return i}function Ut(o){return[o[0],o[1]]}function Zn(o,e){const[t,r]=e[0],[i,n]=e[1],[s,a]=e[2],c=s-t,f=a-r,h=i-t,l=n-r,p=o[0]-t,v=o[1]-r,M=c*c+f*f,S=c*h+f*l,C=c*p+f*v,F=h*h+l*l,m=h*p+l*v,w=M*F-S*S;if(w===0)return!1;const u=1/w,y=(F*C-S*m)*u,g=(M*m-S*C)*u,I=1e-9;return y>=-I&&g>=-I&&y+g<=1+I}function Ni(o){const e=o.map(s=>s.slice()).filter((s,a,c)=>c.findIndex(f=>dn(f[0],s[0])&&dn(f[1],s[1]))===a);if(e.length<=1)return e;const t=e.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),i=[];for(const s of t){for(;i.length>=2&&r(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}const n=[];for(let s=t.length-1;s>=0;s--){const a=t[s];for(;n.length>=2&&r(n[n.length-2],n[n.length-1],a)<=0;)n.pop();n.push(a)}return n.pop(),i.pop(),i.concat(n)}function Xi(o){if(o.length<3)return 0;let e=0;for(let t=0;t<o.length;t++){const[r,i]=o[t],[n,s]=o[(t+1)%o.length];e+=r*s-n*i}return Math.abs(e)/2}function tr(o,e,t){return Math.abs((o[0]*(e[1]-t[1])+e[0]*(t[1]-o[1])+t[0]*(o[1]-e[1]))/2)}function dn(o,e,t=1e-9){return Math.abs(o-e)<=t}const er=3;class Tt extends Gt.Transform{constructor(t={}){super();bt(this,"importance");bt(this,"priority");bt(this,"pointsSet");bt(this,"useV2Algorithm");t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||Tt.VERTEX_PLAIN),this.strictMode=t.strictMode||Tt.MODE_AUTO,this.yaxisMode=t.yaxisMode||Tt.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,this.useV2Algorithm=t.useV2Algorithm??!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return this.useV2Algorithm?Gt.format_version:er}setPoints(t){this.yaxisMode===Tt.YAXIS_FOLLOW&&(t=t.map(r=>[r[0],[r[1][0],-1*r[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Gt.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let r=t[0][0],i=r,n=t[0][1],s=n;const a=[t[0]];for(let c=1;c<t.length;c++){const f=t[c];f[0]<r&&(r=f[0]),f[0]>i&&(i=f[0]),f[1]<n&&(n=f[1]),f[1]>s&&(s=f[1]),a.push(f)}a.push(t[0]),this.boundsPolygon=Me([a]),this.xy=[r,n],this.wh=[i-r,s-n],this.vertexMode=Tt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){var i;const t={};t.version=this.useV2Algorithm?Gt.format_version:er,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer??{},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const r=this.vertices_params.forw[1];if(r)for(let n=0;n<r.length;n++){const s=r[n].features[0],a=s.geometry.coordinates[0][1],c=s.properties.b.geom;t.vertices_points[n]=[a,c]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(n=>{t.tins_points[0].push(["a","b","c"].map(s=>n.properties[s].index))}),this.strict_status===Tt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(s=>n.properties[s].index))})):this.strict_status===Tt.STATUS_ERROR&&((i=this.kinks)!=null&&i.bakw)&&(t.kinks_points=this.kinks.bakw.features.map(n=>n.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,this.useV2Algorithm&&(t.xy=this.xy,t.wh=this.wh)):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setCompiled(t){super.setCompiled(t)}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){var n;const t=this.tins.forw.features.map(s=>Gt.counterTri(s));this.tins.bakw=Kt(t);const r={};this.tins.forw.features.forEach((s,a)=>{const c=this.tins.bakw.features[a];ln(r,{forw:s,bakw:c})}),Ti(this.tins,r,((n=this.pointsSet)==null?void 0:n.edges)||[]);const i=["forw","bakw"].map(s=>{const a=this.tins[s].features.map(c=>c.geometry.coordinates[0]);return Un(a)});i[0].length===0&&i[1].length===0?(this.strict_status=Tt.STATUS_STRICT,delete this.kinks):(this.strict_status=Tt.STATUS_ERROR,this.kinks={forw:Kt(i[0]),bakw:Kt(i[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let n=0;n<this.points.length;n++){const s=this.points[n][0],a=this.points[n][1],c=Oe(s,a,n);t.forw.push(c),t.bakw.push(Te(c))}const r=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let n=0;n<this.edges.length;n++){const s=this.edges[n][2],a=Object.assign([],this.edges[n][0]),c=Object.assign([],this.edges[n][1]);if(a.length===0&&c.length===0){r.push(s);continue}a.unshift(this.points[s[0]][0]),a.push(this.points[s[1]][0]),c.unshift(this.points[s[0]][1]),c.push(this.points[s[1]][1]);const f=[a,c].map(h=>{const l=h.map((v,M,S)=>{if(M===0)return 0;const C=S[M-1];return Math.sqrt(Math.pow(v[0]-C[0],2)+Math.pow(v[1]-C[1],2))}),p=l.reduce((v,M,S)=>S===0?[0]:(v.push(v[S-1]+M),v),[]);return p.map((v,M,S)=>{const C=v/S[S.length-1];return[h[M],l[M],p[M],C]})});f.map((h,l)=>{const p=f[l?0:1];return h.filter((v,M)=>!(M===0||M===h.length-1||v[4]==="handled")).flatMap(v=>{const M=v[0],S=v[3],C=p.reduce((F,m,w,u)=>{if(F)return F;const y=u[w+1];if(m[3]===S)return m[4]="handled",[m];if(m[3]<S&&y&&y[3]>S)return[m,y]},void 0);if(C&&C.length===1)return l===0?[[M,C[0][0],S]]:[[C[0][0],M,S]];if(C&&C.length===2){const F=C[0],m=C[1],w=(S-F[3])/(m[3]-F[3]),u=[(m[0][0]-F[0][0])*w+F[0][0],(m[0][1]-F[0][1])*w+F[0][1]];return l===0?[[M,u,S]]:[[u,M,S]]}return[]})}).reduce((h,l)=>h.concat(l),[]).sort((h,l)=>h[2]<l[2]?-1:1).map((h,l,p)=>{this.edgeNodes[i]=[h[0],h[1]];const v=Oe(h[0],h[1],`e${i}`);i++,t.forw.push(v),t.bakw.push(Te(v)),l===0?r.push([s[0],t.forw.length-1]):r.push([t.forw.length-2,t.forw.length-1]),l===p.length-1&&r.push([t.forw.length-1,s[1]])})}return{forw:t.forw,bakw:t.bakw,edges:r}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],r=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],n=this.xy[1]+1.05*this.wh[1];if(this.bounds&&!this.boundsPolygon)throw new Error("Internal error: bounds is set but boundsPolygon is missing");const s=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((f,h)=>f&&(s?rn(h[0],s):h[0][0]>=t&&h[0][0]<=r&&h[0][1]>=i&&h[0][1]<=n),!0))throw"SOME POINTS OUTSIDE";let c=[];return this.wh&&(c=[[t,i],[r,i],[t,n],[r,n]]),{pointsSet:this.generatePointsSet(),bbox:c,minx:t,maxx:r,miny:i,maxy:n}}computeGcpBbox(){let t=1/0,r=-1/0,i=1/0,n=-1/0;for(const c of this.points){const f=c[0][0],h=c[0][1];f<t&&(t=f),f>r&&(r=f),h<i&&(i=h),h>n&&(n=h)}const s=r-t,a=n-i;return{minx:t-.05*s,maxx:r+.05*s,miny:i-.05*a,maxy:n+.05*a}}updateTin(){let t=this.strictMode;t!==Tt.MODE_STRICT&&t!==Tt.MODE_LOOSE&&(t=Tt.MODE_AUTO);const r=!this.useV2Algorithm;let i,n,s,a,c;if(r){if(this.bounds){const A=this.boundsPolygon;if(!A)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(V=>rn(V[0],A)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:n,maxx:s,miny:a,maxy:c}=this.computeGcpBbox()}else{const A=this.validateAndPrepareInputs();i=A.pointsSet,n=A.minx,s=A.maxx,a=A.miny,c=A.maxy}const f={forw:Kt(i.forw),bakw:Kt(i.bakw)},h=Ie(f.forw,i.edges,"target"),l=Ie(f.bakw,i.edges,"target");if(h.features.length===0||l.features.length===0)throw"TOO LINEAR1";const p=Er(f.forw),v=Cn(f.forw);if(!v)throw"TOO LINEAR2";const M={},S=v.geometry.coordinates[0];let C;try{C=S.map(A=>({forw:A,bakw:Gt.transformArr(Wt(A),h)})),C.forEach(A=>{M[`${A.forw[0]}:${A.forw[1]}`]=A})}catch{throw"TOO LINEAR2"}const F=Cn(f.bakw);if(!F)throw"TOO LINEAR2";const m=F.geometry.coordinates[0];try{C=m.map(A=>({bakw:A,forw:Gt.transformArr(Wt(A),l)})),C.forEach(A=>{M[`${A.forw[0]}:${A.forw[1]}`]=A})}catch{throw"TOO LINEAR2"}let w;if(r){const A=p.geometry.coordinates,D=h.features.find(V=>rn(Wt(A),V));if(D){const V=D.geometry.coordinates[0],d=D.properties.a.geom,_=D.properties.b.geom,x=D.properties.c.geom;w={forw:[(V[0][0]+V[1][0]+V[2][0])/3,(V[0][1]+V[1][1]+V[2][1])/3],bakw:[(d[0]+_[0]+x[0])/3,(d[1]+_[1]+x[1])/3]}}else w={forw:A,bakw:Gt.transformArr(p,h)}}else w={forw:p.geometry.coordinates,bakw:Gt.transformArr(p,h)};const u=Oe(w.forw,w.bakw,"c");this.centroid={forw:u,bakw:Te(u)};const y=[...this.points.map(A=>({forw:A[0],bakw:A[1]})),...(this.edgeNodes??[]).map(A=>({forw:A[0],bakw:A[1]}))],g={convexBuf:M,centroid:w,allGcps:y,minx:n,maxx:s,miny:a,maxy:c},I=this.vertexMode===Tt.VERTEX_BIRDEYE?ii(g,r):ri(g,r),B={forw:[],bakw:[]};for(let A=0;A<I.length;A++){const D=I[A].forw,V=I[A].bakw,d=Oe(D,V,`b${A}`),_=Te(d);i.forw.push(d),i.bakw.push(_),B.forw.push(d),B.bakw.push(_)}this.pointsSet={forw:Kt(i.forw),bakw:Kt(i.bakw),edges:i.edges},this.tins={forw:Gt.rotateVerticesTriangle(Ie(this.pointsSet.forw,i.edges,"target"))},(t===Tt.MODE_STRICT||t===Tt.MODE_AUTO)&&this.calcurateStrictTin(),(t===Tt.MODE_LOOSE||t===Tt.MODE_AUTO&&this.strict_status===Tt.STATUS_ERROR)&&(this.tins.bakw=Gt.rotateVerticesTriangle(Ie(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=Tt.STATUS_LOOSE),this.vertices_params={forw:un(B.forw,this.centroid.forw),bakw:un(B.bakw,this.centroid.bakw)},this.addIndexedTin();const E=["forw"];this.strict_status===Tt.STATUS_LOOSE&&E.push("bakw");const X=this.strict_status===Tt.STATUS_STRICT;this.pointsWeightBuffer=Ai({tins:this.tins,targets:E,includeReciprocals:X,numBoundaryVertices:I.length})}async updateTinAsync(){this.updateTin()}}Dt.Tin=Tt,Dt.constrainedTin=Ie,Dt.counterPoint=Te,Dt.createPoint=Oe,Dt.default=Tt,Dt.findIntersections=Un,Dt.format_version=Gt.format_version,Dt.insertSearchIndex=ln,Dt.vertexCalc=un,Object.defineProperties(Dt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(Vt,ie){typeof exports=="object"&&typeof module<"u"?ie(exports):typeof define=="function"&&define.amd?define(["exports"],ie):(Vt=typeof globalThis<"u"?globalThis:Vt||self,ie(Vt.tin={}))})(this,(function(Vt){"use strict";function ie(s,t,e={}){const n={type:"Feature"};return(e.id===0||e.id)&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.properties=t||{},n.geometry=s,n}function ae(s,t,e={}){if(!s)throw new Error("coordinates is required");if(!Array.isArray(s))throw new Error("coordinates must be an Array");if(s.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!_n(s[0])||!_n(s[1]))throw new Error("coordinates must contain numbers");return ie({type:"Point",coordinates:s},t,e)}function Se(s,t,e={}){for(const r of s){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let i=0;i<r[r.length-1].length;i++)if(r[r.length-1][i]!==r[0][i])throw new Error("First and last Position are not equivalent.")}return ie({type:"Polygon",coordinates:s},t,e)}function vn(s,t,e={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return ie({type:"LineString",coordinates:s},t,e)}function Gt(s,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=s,e}function _n(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}function ir(s){if(!s)throw new Error("coord is required");if(!Array.isArray(s)){if(s.type==="Feature"&&s.geometry!==null&&s.geometry.type==="Point")return[...s.geometry.coordinates];if(s.type==="Point")return[...s.coordinates]}if(Array.isArray(s)&&s.length>=2&&!Array.isArray(s[0])&&!Array.isArray(s[1]))return[...s];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function or(s){return s.type==="Feature"?s.geometry:s}function He(s,t,e){if(s!==null)for(var n,r,i,o,a,c,f,u=0,h=0,p,x=s.type,k=x==="FeatureCollection",E=x==="Feature",F=k?s.features.length:1,L=0;L<F;L++){f=k?s.features[L].geometry:E?s.geometry:s,p=f?f.type==="GeometryCollection":!1,a=p?f.geometries.length:1;for(var g=0;g<a;g++){var b=0,l=0;if(o=p?f.geometries[g]:f,o!==null){c=o.coordinates;var w=o.type;switch(u=e&&(w==="Polygon"||w==="MultiPolygon")?1:0,w){case null:break;case"Point":if(t(c,h,L,b,l)===!1)return!1;h++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,L,b,l)===!1)return!1;h++,w==="MultiPoint"&&b++}w==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(r=0;r<c[n].length-u;r++){if(t(c[n][r],h,L,b,l)===!1)return!1;h++}w==="MultiLineString"&&b++,w==="Polygon"&&l++}w==="Polygon"&&b++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(l=0,r=0;r<c[n].length;r++){for(i=0;i<c[n][r].length-u;i++){if(t(c[n][r][i],h,L,b,l)===!1)return!1;h++}l++}b++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(He(o.geometries[n],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const Dt=11102230246251565e-32,st=134217729,Mn=(3+8*Dt)*Dt;function Ct(s,t,e,n,r){let i,o,a,c,f=t[0],u=n[0],h=0,p=0;u>f==u>-f?(i=f,f=t[++h]):(i=u,u=n[++p]);let x=0;if(h<s&&p<e)for(u>f==u>-f?(o=f+i,a=i-(o-f),f=t[++h]):(o=u+i,a=i-(o-u),u=n[++p]),i=o,a!==0&&(r[x++]=a);h<s&&p<e;)u>f==u>-f?(o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h]):(o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p]),i=o,a!==0&&(r[x++]=a);for(;h<s;)o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h],i=o,a!==0&&(r[x++]=a);for(;p<e;)o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p],i=o,a!==0&&(r[x++]=a);return(i!==0||x===0)&&(r[x++]=i),x}function Wt(s,t,e,n,r,i,o,a){return Ct(Ct(s,t,e,n,o),o,r,i,a)}function q(s,t,e,n){let r,i,o,a,c,f,u,h,p,x,k;u=st*e,x=u-(u-e),k=e-x;let E=t[0];r=E*e,u=st*E,h=u-(u-E),p=E-h,o=p*k-(r-h*x-p*x-h*k);let F=0;o!==0&&(n[F++]=o);for(let L=1;L<s;L++)E=t[L],a=E*e,u=st*E,h=u-(u-E),p=E-h,c=p*k-(a-h*x-p*x-h*k),i=r+c,f=i-r,o=r-(i-f)+(c-f),o!==0&&(n[F++]=o),r=a+i,o=i-(r-a),o!==0&&(n[F++]=o);return(r!==0||F===0)&&(n[F++]=r),F}function Sn(s,t){let e=t[0];for(let n=1;n<s;n++)e+=t[n];return e}function bt(s){return new Float64Array(s)}const sr=(3+16*Dt)*Dt,ar=(2+12*Dt)*Dt,cr=(9+64*Dt)*Dt*Dt,xe=bt(4),kn=bt(8),En=bt(12),An=bt(16),Ft=bt(4);function fr(s,t,e,n,r,i,o){let a,c,f,u,h,p,x,k,E,F,L,g,b,l,w,m,B,O;const I=s-r,P=e-r,D=t-i,R=n-i;l=I*R,p=st*I,x=p-(p-I),k=I-x,p=st*R,E=p-(p-R),F=R-E,w=k*F-(l-x*E-k*E-x*F),m=D*P,p=st*D,x=p-(p-D),k=D-x,p=st*P,E=p-(p-P),F=P-E,B=k*F-(m-x*E-k*E-x*F),L=w-B,h=w-L,xe[0]=w-(L+h)+(h-B),g=l+L,h=g-l,b=l-(g-h)+(L-h),L=b-m,h=b-L,xe[1]=b-(L+h)+(h-m),O=g+L,h=O-g,xe[2]=g-(O-h)+(L-h),xe[3]=O;let G=Sn(4,xe),d=ar*o;if(G>=d||-G>=d||(h=s-I,a=s-(I+h)+(h-r),h=e-P,f=e-(P+h)+(h-r),h=t-D,c=t-(D+h)+(h-i),h=n-R,u=n-(R+h)+(h-i),a===0&&c===0&&f===0&&u===0)||(d=cr*o+Mn*Math.abs(G),G+=I*u+R*a-(D*f+P*c),G>=d||-G>=d))return G;l=a*R,p=st*a,x=p-(p-a),k=a-x,p=st*R,E=p-(p-R),F=R-E,w=k*F-(l-x*E-k*E-x*F),m=c*P,p=st*c,x=p-(p-c),k=c-x,p=st*P,E=p-(p-P),F=P-E,B=k*F-(m-x*E-k*E-x*F),L=w-B,h=w-L,Ft[0]=w-(L+h)+(h-B),g=l+L,h=g-l,b=l-(g-h)+(L-h),L=b-m,h=b-L,Ft[1]=b-(L+h)+(h-m),O=g+L,h=O-g,Ft[2]=g-(O-h)+(L-h),Ft[3]=O;const M=Ct(4,xe,4,Ft,kn);l=I*u,p=st*I,x=p-(p-I),k=I-x,p=st*u,E=p-(p-u),F=u-E,w=k*F-(l-x*E-k*E-x*F),m=D*f,p=st*D,x=p-(p-D),k=D-x,p=st*f,E=p-(p-f),F=f-E,B=k*F-(m-x*E-k*E-x*F),L=w-B,h=w-L,Ft[0]=w-(L+h)+(h-B),g=l+L,h=g-l,b=l-(g-h)+(L-h),L=b-m,h=b-L,Ft[1]=b-(L+h)+(h-m),O=g+L,h=O-g,Ft[2]=g-(O-h)+(L-h),Ft[3]=O;const _=Ct(M,kn,4,Ft,En);l=a*u,p=st*a,x=p-(p-a),k=a-x,p=st*u,E=p-(p-u),F=u-E,w=k*F-(l-x*E-k*E-x*F),m=c*f,p=st*c,x=p-(p-c),k=c-x,p=st*f,E=p-(p-f),F=f-E,B=k*F-(m-x*E-k*E-x*F),L=w-B,h=w-L,Ft[0]=w-(L+h)+(h-B),g=l+L,h=g-l,b=l-(g-h)+(L-h),L=b-m,h=b-L,Ft[1]=b-(L+h)+(h-m),O=g+L,h=O-g,Ft[2]=g-(O-h)+(L-h),Ft[3]=O;const X=Ct(_,En,4,Ft,An);return An[X-1]}function Zt(s,t,e,n,r,i){const o=(t-i)*(e-r),a=(s-r)*(n-i),c=o-a,f=Math.abs(o+a);return Math.abs(c)>=sr*f?c:-fr(s,t,e,n,r,i,f)}const hr=(10+96*Dt)*Dt,ur=(4+48*Dt)*Dt,lr=(44+576*Dt)*Dt*Dt,ce=bt(4),fe=bt(4),he=bt(4),te=bt(4),ee=bt(4),ne=bt(4),Yt=bt(4),Lt=bt(4),Ze=bt(8),tn=bt(8),en=bt(8),nn=bt(8),rn=bt(8),on=bt(8),Re=bt(8),Fe=bt(8),Ye=bt(8),de=bt(4),pe=bt(4),me=bt(4),ct=bt(8),lt=bt(16),St=bt(16),kt=bt(16),vt=bt(32),ue=bt(32),Tt=bt(48),jt=bt(64);let ve=bt(1152),sn=bt(1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,kt,2*mt,vt),vt,Tt),Tt);const Mt=q(I,de,E,ct);f=Bt(f,Wt(q(Mt,ct,2*mt,lt),lt,q(Mt,ct,E,St),St,q(_t,kt,E,vt),vt,ue,jt),jt)}}return ve[f-1]}function pr(s,t,e,n,r,i,o,a){const c=s-o,f=e-o,u=r-o,h=t-a,p=n-a,x=i-a,k=f*x,E=u*p,F=c*c+h*h,L=u*h,g=c*x,b=f*f+p*p,l=c*p,w=f*h,m=u*u+x*x,B=F*(k-E)+b*(L-g)+m*(l-w),O=(Math.abs(k)+Math.abs(E))*F+(Math.abs(L)+Math.abs(g))*b+(Math.abs(l)+Math.abs(w))*m,I=hr*O;return B>I||-B>I?B:dr(s,t,e,n,r,i,o,a,O)}function mr(s,t){var e,n,r=0,i,o,a,c,f,u,h,p=s[0],x=s[1],k=t.length;for(e=0;e<k;e++){n=0;var E=t[e],F=E.length-1;if(u=E[0],u[0]!==E[F][0]&&u[1]!==E[F][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-p,a=u[1]-x,n;n<F;n++){if(h=E[n+1],c=h[0]-p,f=h[1]-x,a===0&&f===0){if(c<=0&&o>=0||o<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(i=Zt(o,c,a,f,0,0),i===0)return 0;(i>0&&f>0&&a<=0||i<0&&f<=0&&a>0)&&r++}u=h,a=f,o=c}}return r%2!==0}function an(s,t,e={}){if(!s)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=ir(s),r=or(t),i=r.type,o=t.bbox;let a=r.coordinates;if(o&&gr(n,o)===!1)return!1;i==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const u=mr(n,a[f]);if(u===0)return!e.ignoreBoundary;u&&(c=!0)}return c}function gr(s,t){return t[0]<=s[0]&&t[1]<=s[1]&&t[2]>=s[0]&&t[3]>=s[1]}let In=class{constructor(t=[],e=wr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}};function wr(s,t){return s<t?-1:s>t?1:0}function Tn(s,t){return s.p.x>t.p.x?1:s.p.x<t.p.x?-1:s.p.y!==t.p.y?s.p.y>t.p.y?1:-1:1}function yr(s,t){return s.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:s.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:s.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?s.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class Bn{constructor(t,e,n,r){this.p={x:t[0],y:t[1]},this.featureId=e,this.ringId=n,this.eventId=r,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(t){return this.p.x===t.p.x&&this.p.y===t.p.y}}function br(s,t){if(s.type==="FeatureCollection"){const e=s.features;for(let n=0;n<e.length;n++)Pn(e[n],t)}else Pn(s,t)}let Le=0,$e=0,Ve=0;function Pn(s,t){const e=s.type==="Feature"?s.geometry:s;let n=e.coordinates;(e.type==="Polygon"||e.type==="MultiLineString")&&(n=[n]),e.type==="LineString"&&(n=[[n]]);for(let r=0;r<n.length;r++)for(let i=0;i<n[r].length;i++){let o=n[r][i][0],a=null;$e=$e+1;for(let c=0;c<n[r][i].length-1;c++){a=n[r][i][c+1];const f=new Bn(o,Le,$e,Ve),u=new Bn(a,Le,$e,Ve+1);f.otherEvent=u,u.otherEvent=f,Tn(f,u)>0?(u.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(f),t.push(u),o=a,Ve=Ve+1}}Le=Le+1}class xr{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}}function vr(s,t){if(s===null||t===null||s.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.rightSweepEvent)||s.leftSweepEvent.isSamePoint(t.leftSweepEvent)||s.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const e=s.leftSweepEvent.p.x,n=s.leftSweepEvent.p.y,r=s.rightSweepEvent.p.x,i=s.rightSweepEvent.p.y,o=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,c=t.rightSweepEvent.p.x,f=t.rightSweepEvent.p.y,u=(f-a)*(r-e)-(c-o)*(i-n),h=(c-o)*(n-a)-(f-a)*(e-o),p=(r-e)*(n-a)-(i-n)*(e-o);if(u===0)return!1;const x=h/u,k=p/u;if(x>=0&&x<=1&&k>=0&&k<=1){const E=e+x*(r-e),F=n+x*(i-n);return[E,F]}return!1}function _r(s,t){t=t||!1;const e=[],n=new In([],yr);for(;s.length;){const r=s.pop();if(r.isLeftEndpoint){const i=new xr(r);for(let o=0;o<n.data.length;o++){const a=n.data[o];if(t&&a.leftSweepEvent.featureId===r.featureId)continue;const c=vr(i,a);c!==!1&&e.push(c)}n.push(i)}else r.isLeftEndpoint===!1&&n.pop()}return e}function Mr(s,t){const e=new In([],Tn);return br(s,e),_r(e,t)}var Sr=Mr;function kr(s,t,e={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:r=!0}=e;let i=[];s.type==="FeatureCollection"?i=i.concat(s.features):s.type==="Feature"?i.push(s):(s.type==="LineString"||s.type==="Polygon"||s.type==="MultiLineString"||s.type==="MultiPolygon")&&i.push(ie(s)),t.type==="FeatureCollection"?i=i.concat(t.features):t.type==="Feature"?i.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&i.push(ie(t));const o=Sr(Gt(i),r);let a=[];if(n){const c={};o.forEach(f=>{const u=f.join(",");c[u]||(c[u]=!0,a.push(f))})}else a=o;return Gt(a.map(c=>ae(c)))}function Er(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ar(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var e=function n(){var r=!1;try{r=this instanceof n}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(n){var r=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return s[n]}})}),e}function Ir(s,t={}){let e=0,n=0,r=0;return He(s,function(i){e+=i[0],n+=i[1],r++},!0),ae([e/r,n/r],t.properties)}var je={exports:{}},qe={exports:{}},Tr=qe.exports,On;function Br(){return On||(On=1,(function(s,t){(function(e,n){s.exports=n()})(Tr,function(){function e(g,b,l,w,m){(function B(O,I,P,D,R){for(;D>P;){if(D-P>600){var G=D-P+1,d=I-P+1,M=Math.log(G),_=.5*Math.exp(2*M/3),X=.5*Math.sqrt(M*_*(G-_)/G)*(d-G/2<0?-1:1),T=Math.max(P,Math.floor(I-d*_/G+X)),Y=Math.min(D,Math.floor(I+(G-d)*_/G+X));B(O,I,T,Y,R)}var y=O[I],C=P,j=D;for(n(O,P,I),R(O[D],y)>0&&n(O,P,D);C<j;){for(n(O,C,j),C++,j--;R(O[C],y)<0;)C++;for(;R(O[j],y)>0;)j--}R(O[P],y)===0?n(O,P,j):n(O,++j,D),j<=I&&(P=j+1),I<=j&&(D=j-1)}})(g,b,l||0,w||g.length-1,m||r)}function n(g,b,l){var w=g[b];g[b]=g[l],g[l]=w}function r(g,b){return g<b?-1:g>b?1:0}var i=function(g){g===void 0&&(g=9),this._maxEntries=Math.max(4,g),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(g,b,l){if(!l)return b.indexOf(g);for(var w=0;w<b.length;w++)if(l(g,b[w]))return w;return-1}function a(g,b){c(g,0,g.children.length,b,g)}function c(g,b,l,w,m){m||(m=F(null)),m.minX=1/0,m.minY=1/0,m.maxX=-1/0,m.maxY=-1/0;for(var B=b;B<l;B++){var O=g.children[B];f(m,g.leaf?w(O):O)}return m}function f(g,b){return g.minX=Math.min(g.minX,b.minX),g.minY=Math.min(g.minY,b.minY),g.maxX=Math.max(g.maxX,b.maxX),g.maxY=Math.max(g.maxY,b.maxY),g}function u(g,b){return g.minX-b.minX}function h(g,b){return g.minY-b.minY}function p(g){return(g.maxX-g.minX)*(g.maxY-g.minY)}function x(g){return g.maxX-g.minX+(g.maxY-g.minY)}function k(g,b){return g.minX<=b.minX&&g.minY<=b.minY&&b.maxX<=g.maxX&&b.maxY<=g.maxY}function E(g,b){return b.minX<=g.maxX&&b.minY<=g.maxY&&b.maxX>=g.minX&&b.maxY>=g.minY}function F(g){return{children:g,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function L(g,b,l,w,m){for(var B=[b,l];B.length;)if(!((l=B.pop())-(b=B.pop())<=w)){var O=b+Math.ceil((l-b)/w/2)*w;e(g,O,b,l,m),B.push(b,O,O,l)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(g){var b=this.data,l=[];if(!E(g,b))return l;for(var w=this.toBBox,m=[];b;){for(var B=0;B<b.children.length;B++){var O=b.children[B],I=b.leaf?w(O):O;E(g,I)&&(b.leaf?l.push(O):k(g,I)?this._all(O,l):m.push(O))}b=m.pop()}return l},i.prototype.collides=function(g){var b=this.data;if(!E(g,b))return!1;for(var l=[];b;){for(var w=0;w<b.children.length;w++){var m=b.children[w],B=b.leaf?this.toBBox(m):m;if(E(g,B)){if(b.leaf||k(g,B))return!0;l.push(m)}}b=l.pop()}return!1},i.prototype.load=function(g){if(!g||!g.length)return this;if(g.length<this._minEntries){for(var b=0;b<g.length;b++)this.insert(g[b]);return this}var l=this._build(g.slice(),0,g.length-1,0);if(this.data.children.length)if(this.data.height===l.height)this._splitRoot(this.data,l);else{if(this.data.height<l.height){var w=this.data;this.data=l,l=w}this._insert(l,this.data.height-l.height-1,!0)}else this.data=l;return this},i.prototype.insert=function(g){return g&&this._insert(g,this.data.height-1),this},i.prototype.clear=function(){return this.data=F([]),this},i.prototype.remove=function(g,b){if(!g)return this;for(var l,w,m,B=this.data,O=this.toBBox(g),I=[],P=[];B||I.length;){if(B||(B=I.pop(),w=I[I.length-1],l=P.pop(),m=!0),B.leaf){var D=o(g,B.children,b);if(D!==-1)return B.children.splice(D,1),I.push(B),this._condense(I),this}m||B.leaf||!k(B,O)?w?(l++,B=w.children[l],m=!1):B=null:(I.push(B),P.push(l),l=0,w=B,B=B.children[0])}return this},i.prototype.toBBox=function(g){return g},i.prototype.compareMinX=function(g,b){return g.minX-b.minX},i.prototype.compareMinY=function(g,b){return g.minY-b.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(g){return this.data=g,this},i.prototype._all=function(g,b){for(var l=[];g;)g.leaf?b.push.apply(b,g.children):l.push.apply(l,g.children),g=l.pop();return b},i.prototype._build=function(g,b,l,w){var m,B=l-b+1,O=this._maxEntries;if(B<=O)return a(m=F(g.slice(b,l+1)),this.toBBox),m;w||(w=Math.ceil(Math.log(B)/Math.log(O)),O=Math.ceil(B/Math.pow(O,w-1))),(m=F([])).leaf=!1,m.height=w;var I=Math.ceil(B/O),P=I*Math.ceil(Math.sqrt(O));L(g,b,l,P,this.compareMinX);for(var D=b;D<=l;D+=P){var R=Math.min(D+P-1,l);L(g,D,R,I,this.compareMinY);for(var G=D;G<=R;G+=I){var d=Math.min(G+I-1,R);m.children.push(this._build(g,G,d,w-1))}}return a(m,this.toBBox),m},i.prototype._chooseSubtree=function(g,b,l,w){for(;w.push(b),!b.leaf&&w.length-1!==l;){for(var m=1/0,B=1/0,O=void 0,I=0;I<b.children.length;I++){var P=b.children[I],D=p(P),R=(G=g,d=P,(Math.max(d.maxX,G.maxX)-Math.min(d.minX,G.minX))*(Math.max(d.maxY,G.maxY)-Math.min(d.minY,G.minY))-D);R<B?(B=R,m=D<m?D:m,O=P):R===B&&D<m&&(m=D,O=P)}b=O||b.children[0]}var G,d;return b},i.prototype._insert=function(g,b,l){var w=l?g:this.toBBox(g),m=[],B=this._chooseSubtree(w,this.data,b,m);for(B.children.push(g),f(B,w);b>=0&&m[b].children.length>this._maxEntries;)this._split(m,b),b--;this._adjustParentBBoxes(w,m,b)},i.prototype._split=function(g,b){var l=g[b],w=l.children.length,m=this._minEntries;this._chooseSplitAxis(l,m,w);var B=this._chooseSplitIndex(l,m,w),O=F(l.children.splice(B,l.children.length-B));O.height=l.height,O.leaf=l.leaf,a(l,this.toBBox),a(O,this.toBBox),b?g[b-1].children.push(O):this._splitRoot(l,O)},i.prototype._splitRoot=function(g,b){this.data=F([g,b]),this.data.height=g.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(g,b,l){for(var w,m,B,O,I,P,D,R=1/0,G=1/0,d=b;d<=l-b;d++){var M=c(g,0,d,this.toBBox),_=c(g,d,l,this.toBBox),X=(m=M,B=_,O=void 0,I=void 0,P=void 0,D=void 0,O=Math.max(m.minX,B.minX),I=Math.max(m.minY,B.minY),P=Math.min(m.maxX,B.maxX),D=Math.min(m.maxY,B.maxY),Math.max(0,P-O)*Math.max(0,D-I)),T=p(M)+p(_);X<R?(R=X,w=d,G=T<G?T:G):X===R&&T<G&&(G=T,w=d)}return w||l-b},i.prototype._chooseSplitAxis=function(g,b,l){var w=g.leaf?this.compareMinX:u,m=g.leaf?this.compareMinY:h;this._allDistMargin(g,b,l,w)<this._allDistMargin(g,b,l,m)&&g.children.sort(w)},i.prototype._allDistMargin=function(g,b,l,w){g.children.sort(w);for(var m=this.toBBox,B=c(g,0,b,m),O=c(g,l-b,l,m),I=x(B)+x(O),P=b;P<l-b;P++){var D=g.children[P];f(B,g.leaf?m(D):D),I+=x(B)}for(var R=l-b-1;R>=b;R--){var G=g.children[R];f(O,g.leaf?m(G):G),I+=x(O)}return I},i.prototype._adjustParentBBoxes=function(g,b,l){for(var w=l;w>=0;w--)f(b[w],g)},i.prototype._condense=function(g){for(var b=g.length-1,l=void 0;b>=0;b--)g[b].children.length===0?b>0?(l=g[b-1].children).splice(l.indexOf(g[b]),1):this.clear():a(g[b],this.toBBox)},i})})(qe)),qe.exports}class Pr{constructor(t=[],e=Or){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}}function Or(s,t){return s<t?-1:s>t?1:0}const Nr=Ar(Object.freeze(Object.defineProperty({__proto__:null,default:Pr},Symbol.toStringTag,{value:"Module"})));var ke={exports:{}},cn,Nn;function Xr(){return Nn||(Nn=1,cn=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=(r-n)/2,f=0,u=c-1;f<c;u=f++){var h=e[n+f*2+0],p=e[n+f*2+1],x=e[n+u*2+0],k=e[n+u*2+1],E=p>o!=k>o&&i<(x-h)*(o-p)/(k-p)+h;E&&(a=!a)}return a}),cn}var fn,Xn;function Cr(){return Xn||(Xn=1,fn=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=r-n,f=0,u=c-1;f<c;u=f++){var h=e[f+n][0],p=e[f+n][1],x=e[u+n][0],k=e[u+n][1],E=p>o!=k>o&&i<(x-h)*(o-p)/(k-p)+h;E&&(a=!a)}return a}),fn}var Cn;function Dr(){if(Cn)return ke.exports;Cn=1;var s=Xr(),t=Cr();return ke.exports=function(n,r,i,o){return r.length>0&&Array.isArray(r[0])?t(n,r,i,o):s(n,r,i,o)},ke.exports.nested=t,ke.exports.flat=s,ke.exports}var Ee={exports:{}},Rr=Ee.exports,Dn;function Fr(){return Dn||(Dn=1,(function(s,t){(function(e,n){n(t)})(Rr,function(e){const r=33306690738754706e-32;function i(E,F,L,g,b){let l,w,m,B,O=F[0],I=g[0],P=0,D=0;I>O==I>-O?(l=O,O=F[++P]):(l=I,I=g[++D]);let R=0;if(P<E&&D<L)for(I>O==I>-O?(m=l-((w=O+l)-O),O=F[++P]):(m=l-((w=I+l)-I),I=g[++D]),l=w,m!==0&&(b[R++]=m);P<E&&D<L;)I>O==I>-O?(m=l-((w=l+O)-(B=w-l))+(O-B),O=F[++P]):(m=l-((w=l+I)-(B=w-l))+(I-B),I=g[++D]),l=w,m!==0&&(b[R++]=m);for(;P<E;)m=l-((w=l+O)-(B=w-l))+(O-B),O=F[++P],l=w,m!==0&&(b[R++]=m);for(;D<L;)m=l-((w=l+I)-(B=w-l))+(I-B),I=g[++D],l=w,m!==0&&(b[R++]=m);return l===0&&R!==0||(b[R++]=l),R}function o(E){return new Float64Array(E)}const a=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,u=o(4),h=o(8),p=o(12),x=o(16),k=o(4);e.orient2d=function(E,F,L,g,b,l){const w=(F-l)*(L-b),m=(E-b)*(g-l),B=w-m;if(w===0||m===0||w>0!=m>0)return B;const O=Math.abs(w+m);return Math.abs(B)>=a*O?B:-(function(I,P,D,R,G,d,M){let _,X,T,Y,y,C,j,U,Q,H,rt,J,ut,ht,dt,pt,gt,mt;const It=I-G,Xt=D-G,_t=P-d,Mt=R-d;y=(dt=(U=It-(j=(C=134217729*It)-(C-It)))*(H=Mt-(Q=(C=134217729*Mt)-(C-Mt)))-((ht=It*Mt)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=_t-(j=(C=134217729*_t)-(C-_t)))*(H=Xt-(Q=(C=134217729*Xt)-(C-Xt)))-((pt=_t*Xt)-j*Q-U*Q-j*H))),u[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),u[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,u[2]=J-(mt-y)+(rt-y),u[3]=mt;let re=(function(Ke,Me){let Ce=Me[0];for(let ye=1;ye<Ke;ye++)Ce+=Me[ye];return Ce})(4,u),we=c*M;if(re>=we||-re>=we||(_=I-(It+(y=I-It))+(y-G),T=D-(Xt+(y=D-Xt))+(y-G),X=P-(_t+(y=P-_t))+(y-d),Y=R-(Mt+(y=R-Mt))+(y-d),_===0&&X===0&&T===0&&Y===0)||(we=f*M+r*Math.abs(re),(re+=It*Y+Mt*_-(_t*T+Xt*X))>=we||-re>=we))return re;y=(dt=(U=_-(j=(C=134217729*_)-(C-_)))*(H=Mt-(Q=(C=134217729*Mt)-(C-Mt)))-((ht=_*Mt)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=X-(j=(C=134217729*X)-(C-X)))*(H=Xt-(Q=(C=134217729*Xt)-(C-Xt)))-((pt=X*Xt)-j*Q-U*Q-j*H))),k[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),k[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,k[2]=J-(mt-y)+(rt-y),k[3]=mt;const wn=i(4,u,4,k,h);y=(dt=(U=It-(j=(C=134217729*It)-(C-It)))*(H=Y-(Q=(C=134217729*Y)-(C-Y)))-((ht=It*Y)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=_t-(j=(C=134217729*_t)-(C-_t)))*(H=T-(Q=(C=134217729*T)-(C-T)))-((pt=_t*T)-j*Q-U*Q-j*H))),k[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),k[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,k[2]=J-(mt-y)+(rt-y),k[3]=mt;const $t=i(wn,h,4,k,p);y=(dt=(U=_-(j=(C=134217729*_)-(C-_)))*(H=Y-(Q=(C=134217729*Y)-(C-Y)))-((ht=_*Y)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=X-(j=(C=134217729*X)-(C-X)))*(H=T-(Q=(C=134217729*T)-(C-T)))-((pt=X*T)-j*Q-U*Q-j*H))),k[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),k[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,k[2]=J-(mt-y)+(rt-y),k[3]=mt;const zt=i($t,p,4,k,x);return x[zt-1]})(E,F,L,g,b,l,O)},e.orient2dfast=function(E,F,L,g,b,l){return(F-l)*(L-b)-(E-b)*(g-l)},Object.defineProperty(e,"__esModule",{value:!0})})})(Ee,Ee.exports)),Ee.exports}var Rn;function Yr(){if(Rn)return je.exports;Rn=1;var s=Br(),t=Nr,e=Dr(),n=Fr().orient2d;t.default&&(t=t.default),je.exports=r,je.exports.default=r;function r(l,w,m){w=Math.max(0,w===void 0?2:w),m=m||0;var B=x(l),O=new s(16);O.toBBox=function(j){return{minX:j[0],minY:j[1],maxX:j[0],maxY:j[1]}},O.compareMinX=function(j,U){return j[0]-U[0]},O.compareMinY=function(j,U){return j[1]-U[1]},O.load(l);for(var I=[],P=0,D;P<B.length;P++){var R=B[P];O.remove(R),D=k(R,D),I.push(D)}var G=new s(16);for(P=0;P<I.length;P++)G.insert(p(I[P]));for(var d=w*w,M=m*m;I.length;){var _=I.shift(),X=_.p,T=_.next.p,Y=E(X,T);if(!(Y<M)){var y=Y/d;R=i(O,_.prev.p,X,T,_.next.next.p,y,G),R&&Math.min(E(R,X),E(R,T))<=y&&(I.push(_),I.push(k(R,_)),O.remove(R),G.remove(_),G.insert(p(_)),G.insert(p(_.next)))}}_=D;var C=[];do C.push(_.p),_=_.next;while(_!==D);return C.push(_.p),C}function i(l,w,m,B,O,I,P){for(var D=new t([],o),R=l.data;R;){for(var G=0;G<R.children.length;G++){var d=R.children[G],M=R.leaf?F(d,m,B):a(m,B,d);M>I||D.push({node:d,dist:M})}for(;D.length&&!D.peek().node.children;){var _=D.pop(),X=_.node,T=F(X,w,m),Y=F(X,B,O);if(_.dist<T&&_.dist<Y&&f(m,X,P)&&f(B,X,P))return X}R=D.pop(),R&&(R=R.node)}return null}function o(l,w){return l.dist-w.dist}function a(l,w,m){if(c(l,m)||c(w,m))return 0;var B=L(l[0],l[1],w[0],w[1],m.minX,m.minY,m.maxX,m.minY);if(B===0)return 0;var O=L(l[0],l[1],w[0],w[1],m.minX,m.minY,m.minX,m.maxY);if(O===0)return 0;var I=L(l[0],l[1],w[0],w[1],m.maxX,m.minY,m.maxX,m.maxY);if(I===0)return 0;var P=L(l[0],l[1],w[0],w[1],m.minX,m.maxY,m.maxX,m.maxY);return P===0?0:Math.min(B,O,I,P)}function c(l,w){return l[0]>=w.minX&&l[0]<=w.maxX&&l[1]>=w.minY&&l[1]<=w.maxY}function f(l,w,m){for(var B=Math.min(l[0],w[0]),O=Math.min(l[1],w[1]),I=Math.max(l[0],w[0]),P=Math.max(l[1],w[1]),D=m.search({minX:B,minY:O,maxX:I,maxY:P}),R=0;R<D.length;R++)if(h(D[R].p,D[R].next.p,l,w))return!1;return!0}function u(l,w,m){return n(l[0],l[1],w[0],w[1],m[0],m[1])}function h(l,w,m,B){return l!==B&&w!==m&&u(l,w,m)>0!=u(l,w,B)>0&&u(m,B,l)>0!=u(m,B,w)>0}function p(l){var w=l.p,m=l.next.p;return l.minX=Math.min(w[0],m[0]),l.minY=Math.min(w[1],m[1]),l.maxX=Math.max(w[0],m[0]),l.maxY=Math.max(w[1],m[1]),l}function x(l){for(var w=l[0],m=l[0],B=l[0],O=l[0],I=0;I<l.length;I++){var P=l[I];P[0]<w[0]&&(w=P),P[0]>B[0]&&(B=P),P[1]<m[1]&&(m=P),P[1]>O[1]&&(O=P)}var D=[w,m,B,O],R=D.slice();for(I=0;I<l.length;I++)e(l[I],D)||R.push(l[I]);return b(R)}function k(l,w){var m={p:l,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return w?(m.next=w.next,m.prev=w,w.next.prev=m,w.next=m):(m.prev=m,m.next=m),m}function E(l,w){var m=l[0]-w[0],B=l[1]-w[1];return m*m+B*B}function F(l,w,m){var B=w[0],O=w[1],I=m[0]-B,P=m[1]-O;if(I!==0||P!==0){var D=((l[0]-B)*I+(l[1]-O)*P)/(I*I+P*P);D>1?(B=m[0],O=m[1]):D>0&&(B+=I*D,O+=P*D)}return I=l[0]-B,P=l[1]-O,I*I+P*P}function L(l,w,m,B,O,I,P,D){var R=m-l,G=B-w,d=P-O,M=D-I,_=l-O,X=w-I,T=R*R+G*G,Y=R*d+G*M,y=d*d+M*M,C=R*_+G*X,j=d*_+M*X,U=T*y-Y*Y,Q,H,rt,J,ut=U,ht=U;U===0?(H=0,ut=1,J=j,ht=y):(H=Y*j-y*C,J=T*j-Y*C,H<0?(H=0,J=j,ht=y):H>ut&&(H=ut,J=j+Y,ht=y)),J<0?(J=0,-C<0?H=0:-C>T?H=ut:(H=-C,ut=T)):J>ht&&(J=ht,-C+Y<0?H=0:-C+Y>T?H=ut:(H=-C+Y,ut=T)),Q=H===0?0:H/ut,rt=J===0?0:J/ht;var dt=(1-Q)*l+Q*m,pt=(1-Q)*w+Q*B,gt=(1-rt)*O+rt*P,mt=(1-rt)*I+rt*D,It=gt-dt,Xt=mt-pt;return It*It+Xt*Xt}function g(l,w){return l[0]===w[0]?l[1]-w[1]:l[0]-w[0]}function b(l){l.sort(g);for(var w=[],m=0;m<l.length;m++){for(;w.length>=2&&u(w[w.length-2],w[w.length-1],l[m])<=0;)w.pop();w.push(l[m])}for(var B=[],O=l.length-1;O>=0;O--){for(;B.length>=2&&u(B[B.length-2],B[B.length-1],l[O])<=0;)B.pop();B.push(l[O])}return B.pop(),w.pop(),w.concat(B)}return je.exports}var Lr=Yr();const $r=Er(Lr);function Fn(s,t={}){t.concavity=t.concavity||1/0;const e=[];if(He(s,r=>{e.push([r[0],r[1]])}),!e.length)return null;const n=$r(e,t.concavity);return n.length>3?Se([n]):null}var Ae={exports:{}},Vr=Ae.exports,Yn;function jr(){return Yn||(Yn=1,(function(s,t){(function(e,n){n(t)})(Vr,(function(e){function n(S,v,A={}){const N={type:"Feature"};return(A.id===0||A.id)&&(N.id=A.id),A.bbox&&(N.bbox=A.bbox),N.properties=v||{},N.geometry=S,N}function r(S,v,A={}){if(!S)throw new Error("coordinates is required");if(!Array.isArray(S))throw new Error("coordinates must be an Array");if(S.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!a(S[0])||!a(S[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:S},v,A)}function i(S,v,A={}){for(const N of S){if(N.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(N[N.length-1].length!==N[0].length)throw new Error("First and last Position are not equivalent.");for(let $=0;$<N[N.length-1].length;$++)if(N[N.length-1][$]!==N[0][$])throw new Error("First and last Position are not equivalent.")}return n({type:"Polygon",coordinates:S},v,A)}function o(S,v={}){const A={type:"FeatureCollection"};return v.id&&(A.id=v.id),v.bbox&&(A.bbox=v.bbox),A.features=S,A}function a(S){return!isNaN(S)&&S!==null&&!Array.isArray(S)}function c(S){if(!S)throw new Error("coord is required");if(!Array.isArray(S)){if(S.type==="Feature"&&S.geometry!==null&&S.geometry.type==="Point")return[...S.geometry.coordinates];if(S.type==="Point")return[...S.coordinates]}if(Array.isArray(S)&&S.length>=2&&!Array.isArray(S[0])&&!Array.isArray(S[1]))return[...S];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function f(S){if(Array.isArray(S))return S;if(S.type==="Feature"){if(S.geometry!==null)return S.geometry.coordinates}else if(S.coordinates)return S.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function u(S){return S.type==="Feature"?S.geometry:S}const h=11102230246251565e-32,p=134217729,x=(3+8*h)*h;function k(S,v,A,N,$){let V,z,et,Z,it=v[0],at=N[0],K=0,tt=0;at>it==at>-it?(V=it,it=v[++K]):(V=at,at=N[++tt]);let ft=0;if(K<S&&tt<A)for(at>it==at>-it?(z=it+V,et=V-(z-it),it=v[++K]):(z=at+V,et=V-(z-at),at=N[++tt]),V=z,et!==0&&($[ft++]=et);K<S&&tt<A;)at>it==at>-it?(z=V+it,Z=z-V,et=V-(z-Z)+(it-Z),it=v[++K]):(z=V+at,Z=z-V,et=V-(z-Z)+(at-Z),at=N[++tt]),V=z,et!==0&&($[ft++]=et);for(;K<S;)z=V+it,Z=z-V,et=V-(z-Z)+(it-Z),it=v[++K],V=z,et!==0&&($[ft++]=et);for(;tt<A;)z=V+at,Z=z-V,et=V-(z-Z)+(at-Z),at=N[++tt],V=z,et!==0&&($[ft++]=et);return(V!==0||ft===0)&&($[ft++]=V),ft}function E(S,v){let A=v[0];for(let N=1;N<S;N++)A+=v[N];return A}function F(S){return new Float64Array(S)}const L=(3+16*h)*h,g=(2+12*h)*h,b=(9+64*h)*h*h,l=F(4),w=F(8),m=F(12),B=F(16),O=F(4);function I(S,v,A,N,$,V,z){let et,Z,it,at,K,tt,ft,wt,ot,nt,W,yt,At,Et,Nt,xt,Ot,Rt;const Jt=S-$,Kt=A-$,Qt=v-V,Ht=N-V;Et=Jt*Ht,tt=p*Jt,ft=tt-(tt-Jt),wt=Jt-ft,tt=p*Ht,ot=tt-(tt-Ht),nt=Ht-ot,Nt=wt*nt-(Et-ft*ot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nt=it-ot,Ot=wt*nt-(xt-ft*ot-wt*ot-ft*nt),W=Nt-Ot,K=Nt-W,O[0]=Nt-(W+K)+(K-Ot),yt=Et+W,K=yt-Et,At=Et-(yt-K)+(W-K),W=At-xt,K=At-W,O[1]=At-(W+K)+(K-xt),Rt=yt+W,K=Rt-yt,O[2]=yt-(Rt-K)+(W-K),O[3]=Rt;const Li=k(Yi,w,4,O,m);Et=et*at,tt=p*et,ft=tt-(tt-et),wt=et-ft,tt=p*at,ot=tt-(tt-at),nt=at-ot,Nt=wt*nt-(Et-ft*ot-wt*ot-ft*nt),xt=Z*it,tt=p*Z,ft=tt-(tt-Z),wt=Z-ft,tt=p*it,ot=tt-(tt-it),nt=it-ot,Ot=wt*nt-(xt-ft*ot-wt*ot-ft*nt),W=Nt-Ot,K=Nt-W,O[0]=Nt-(W+K)+(K-Ot),yt=Et+W,K=yt-Et,At=Et-(yt-K)+(W-K),W=At-xt,K=At-W,O[1]=At-(W+K)+(K-xt),Rt=yt+W,K=Rt-yt,O[2]=yt-(Rt-K)+(W-K),O[3]=Rt;const $i=k(Li,m,4,O,B);return B[$i-1]}function P(S,v,A,N,$,V){const z=(v-V)*(A-$),et=(S-$)*(N-V),Z=z-et,it=Math.abs(z+et);return Math.abs(Z)>=L*it?Z:-I(S,v,A,N,$,V,it)}function D(S,v){var A,N,$=0,V,z,et,Z,it,at,K,tt=S[0],ft=S[1],wt=v.length;for(A=0;A<wt;A++){N=0;var ot=v[A],nt=ot.length-1;if(at=ot[0],at[0]!==ot[nt][0]&&at[1]!==ot[nt][1])throw new Error("First and last coordinates in a ring must be the same");for(z=at[0]-tt,et=at[1]-ft,N;N<nt;N++){if(K=ot[N+1],Z=K[0]-tt,it=K[1]-ft,et===0&&it===0){if(Z<=0&&z>=0||z<=0&&Z>=0)return 0}else if(it>=0&&et<=0||it<=0&&et>=0){if(V=P(z,Z,et,it,0,0),V===0)return 0;(V>0&&it>0&&et<=0||V<0&&it<=0&&et>0)&&$++}at=K,et=it,z=Z}}return $%2!==0}function R(S,v,A={}){if(!S)throw new Error("point is required");if(!v)throw new Error("polygon is required");const N=c(S),$=u(v),V=$.type,z=v.bbox;let et=$.coordinates;if(z&&G(N,z)===!1)return!1;V==="Polygon"&&(et=[et]);let Z=!1;for(var it=0;it<et.length;++it){const at=D(N,et[it]);if(at===0)return!A.ignoreBoundary;at&&(Z=!0)}return Z}function G(S,v){return v[0]<=S[0]&&v[1]<=S[1]&&v[2]>=S[0]&&v[3]>=S[1]}function d(S,v){for(let A=0;A<v.features.length;A++)if(R(S,v.features[A]))return v.features[A]}function M(S,v,A){const N=v.geometry.coordinates[0][0],$=v.geometry.coordinates[0][1],V=v.geometry.coordinates[0][2],z=S.geometry.coordinates,et=v.properties.a.geom,Z=v.properties.b.geom,it=v.properties.c.geom,at=[$[0]-N[0],$[1]-N[1]],K=[V[0]-N[0],V[1]-N[1]],tt=[z[0]-N[0],z[1]-N[1]],ft=[Z[0]-et[0],Z[1]-et[1]],wt=[it[0]-et[0],it[1]-et[1]];let ot=(K[1]*tt[0]-K[0]*tt[1])/(at[0]*K[1]-at[1]*K[0]),nt=(at[0]*tt[1]-at[1]*tt[0])/(at[0]*K[1]-at[1]*K[0]);if(A){const W=A[v.properties.a.index],yt=A[v.properties.b.index],At=A[v.properties.c.index];let Et;if(ot<0||nt<0||1-ot-nt<0){const Nt=ot/(ot+nt),xt=nt/(ot+nt);Et=ot/yt/(Nt/yt+xt/At),nt=nt/At/(Nt/yt+xt/At)}else Et=ot/yt/(ot/yt+nt/At+(1-ot-nt)/W),nt=nt/At/(ot/yt+nt/At+(1-ot-nt)/W);ot=Et}return[ot*ft[0]+nt*wt[0]+et[0],ot*ft[1]+nt*wt[1]+et[1]]}function _(S,v,A,N){const $=S.geometry.coordinates,V=A.geometry.coordinates,z=Math.atan2($[0]-V[0],$[1]-V[1]),et=Y(z,v[0]);if(et===void 0)throw new Error("Unable to determine vertex index");const Z=v[1][et];return M(S,Z.features[0],N)}function X(S,v,A,N,$,V,z,et){let Z;if(z&&(Z=d(S,o([z]))),!Z)if(A){const it=S.geometry.coordinates,at=A.gridNum,K=A.xOrigin,tt=A.yOrigin,ft=A.xUnit,wt=A.yUnit,ot=A.gridCache,nt=T(it[0],K,ft,at),W=T(it[1],tt,wt,at),yt=ot[nt]?ot[nt][W]?ot[nt][W]:[]:[],At=o(yt.map(Et=>v.features[Et]));Z=d(S,At)}else Z=d(S,v);return et&&et(Z),Z?M(S,Z,V):_(S,N,$,V)}function T(S,v,A,N){let $=Math.floor((S-v)/A);return $<0&&($=0),$>=N&&($=N-1),$}function Y(S,v){let A=y(S-v[0]),N=Math.PI*2,$;for(let V=0;V<v.length;V++){const z=(V+1)%v.length,et=y(S-v[z]),Z=Math.min(Math.abs(A),Math.abs(et));A*et<=0&&Z<N&&(N=Z,$=V),A=et}return $}function y(S,v=!1){const A=2*Math.PI,N=S-Math.floor(S/A)*A;return v?N:N>Math.PI?N-A:N}function C(S){const v=S.features;for(let A=0;A<v.length;A++){const N=v[A];`${N.properties.a.index}`.substring(0,1)==="b"&&`${N.properties.b.index}`.substring(0,1)==="b"?v[A]={geometry:{type:"Polygon",coordinates:[[N.geometry.coordinates[0][2],N.geometry.coordinates[0][0],N.geometry.coordinates[0][1],N.geometry.coordinates[0][2]]]},properties:{a:{geom:N.properties.c.geom,index:N.properties.c.index},b:{geom:N.properties.a.geom,index:N.properties.a.index},c:{geom:N.properties.b.geom,index:N.properties.b.index}},type:"Feature"}:`${N.properties.c.index}`.substring(0,1)==="b"&&`${N.properties.a.index}`.substring(0,1)==="b"&&(v[A]={geometry:{type:"Polygon",coordinates:[[N.geometry.coordinates[0][1],N.geometry.coordinates[0][2],N.geometry.coordinates[0][0],N.geometry.coordinates[0][1]]]},properties:{a:{geom:N.properties.b.geom,index:N.properties.b.index},b:{geom:N.properties.c.geom,index:N.properties.c.index},c:{geom:N.properties.a.geom,index:N.properties.a.index}},type:"Feature"})}return S}function j(S){const v=["a","b","c","a"].map(V=>S.properties[V].geom),A=S.geometry.coordinates[0],N=S.properties,$={a:{geom:A[0],index:N.a.index},b:{geom:A[1],index:N.b.index},c:{geom:A[2],index:N.c.index}};return i([v],$)}function U(S){const v=[0,1,2,0].map(N=>S[N][0][0]),A={a:{geom:S[0][0][1],index:S[0][1]},b:{geom:S[1][0][1],index:S[1][1]},c:{geom:S[2][0][1],index:S[2][1]}};return i([v],A)}function Q(S,v,A,N,$,V=!1,z){const et=S.map(Z=>{(!z||z<2.00703)&&(Z=H(Z));const it=isFinite(Z)?v[Z]:Z==="c"?N:(function(){const at=Z.match(/^b(\d+)$/);if(at)return $[parseInt(at[1])];const K=Z.match(/^e(\d+)$/);if(K)return A[parseInt(K[1])];throw new Error("Bad index value for indexesToTri")})();return V?[[it[1],it[0]],Z]:[[it[0],it[1]],Z]});return U(et)}function H(S){return typeof S=="number"?S:S.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function rt(S,v){return v&&v>=2.00703||Array.isArray(S[0])?S:S.map(A=>[A.illstNodes,A.mercNodes,A.startEnd])}const J=2.00703;function ut(S){return!!(S.version!==void 0||!S.tins&&S.points&&S.tins_points)}function ht(S){return{points:S.points,pointsWeightBuffer:pt(S),strictStatus:gt(S),verticesParams:mt(S),centroid:Xt(S),edges:rt(S.edges||[]),edgeNodes:S.edgeNodes||[],tins:_t(S),kinks:Mt(S.kinks_points),yaxisMode:S.yaxisMode??"invert",strictMode:S.strictMode??"auto",vertexMode:S.vertexMode,bounds:S.bounds,boundsPolygon:S.boundsPolygon,wh:S.wh,xy:S.xy??[0,0]}}function dt(S){const v=re(S),A=v.tins;return{compiled:v,tins:A,points:we(A),strictStatus:v.strict_status,pointsWeightBuffer:v.weight_buffer,verticesParams:v.vertices_params,centroid:v.centroid,kinks:v.kinks}}function pt(S){return!S.version||S.version<J?["forw","bakw"].reduce((v,A)=>{const N=S.weight_buffer[A];return N&&(v[A]=Object.keys(N).reduce(($,V)=>{const z=H(V);return $[z]=N[V],$},{})),v},{}):S.weight_buffer}function gt(S){return S.strict_status?S.strict_status:S.kinks_points?"strict_error":S.tins_points.length===2?"loose":"strict"}function mt(S){const v={forw:[S.vertices_params[0]],bakw:[S.vertices_params[1]]};return v.forw[1]=It(S,!1),v.bakw[1]=It(S,!0),v}function It(S,v){const A=S.vertices_points.length;return Array.from({length:A},(N,$)=>{const V=($+1)%A,z=Q(["c",`b${$}`,`b${V}`],S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,v,J);return o([z])})}function Xt(S){return{forw:r(S.centroid_point[0],{target:{geom:S.centroid_point[1],index:"c"}}),bakw:r(S.centroid_point[1],{target:{geom:S.centroid_point[0],index:"c"}})}}function _t(S){const v=S.tins_points.length===1?0:1;return{forw:o(S.tins_points[0].map(A=>Q(A,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!1,S.version))),bakw:o(S.tins_points[v].map(A=>Q(A,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!0,S.version)))}}function Mt(S){if(S)return{bakw:o(S.map(v=>r(v)))}}function re(S){return JSON.parse(JSON.stringify(S).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function we(S){const v=[],A=S.forw.features;for(let N=0;N<A.length;N++){const $=A[N];["a","b","c"].forEach((V,z)=>{const et=$.geometry.coordinates[0][z],Z=$.properties[V].geom,it=$.properties[V].index;typeof it=="number"&&(v[it]=[et,Z])})}return v}const wn=J;class $t{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=$t.YAXIS_INVERT;strictMode=$t.MODE_AUTO;vertexMode=$t.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(v){if(ut(v)){this.applyModernState(ht(v));return}this.applyLegacyState(dt(v))}applyModernState(v){this.points=v.points,this.pointsWeightBuffer=v.pointsWeightBuffer,this.strict_status=v.strictStatus,this.vertices_params=v.verticesParams,this.centroid=v.centroid,this.edges=v.edges,this.edgeNodes=v.edgeNodes||[],this.tins=v.tins,this.addIndexedTin(),this.kinks=v.kinks,this.yaxisMode=v.yaxisMode??$t.YAXIS_INVERT,this.vertexMode=v.vertexMode??$t.VERTEX_PLAIN,this.strictMode=v.strictMode??$t.MODE_AUTO,v.bounds?(this.bounds=v.bounds,this.boundsPolygon=v.boundsPolygon,this.xy=v.xy,this.wh=v.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=v.xy??[0,0],v.wh&&(this.wh=v.wh))}applyLegacyState(v){this.tins=v.tins,this.addIndexedTin(),this.strict_status=v.strictStatus,this.pointsWeightBuffer=v.pointsWeightBuffer,this.vertices_params=v.verticesParams,this.centroid=v.centroid,this.kinks=v.kinks,this.points=v.points}addIndexedTin(){const v=this.tins,A=v.forw,N=v.bakw,$=Math.ceil(Math.sqrt(A.features.length));if($<3){this.indexedTins=void 0;return}let V=[],z=[];const et=A.features.map(ot=>{let nt=[];return f(ot)[0].map(W=>{V.length===0?V=[Array.from(W),Array.from(W)]:(W[0]<V[0][0]&&(V[0][0]=W[0]),W[0]>V[1][0]&&(V[1][0]=W[0]),W[1]<V[0][1]&&(V[0][1]=W[1]),W[1]>V[1][1]&&(V[1][1]=W[1])),nt.length===0?nt=[Array.from(W),Array.from(W)]:(W[0]<nt[0][0]&&(nt[0][0]=W[0]),W[0]>nt[1][0]&&(nt[1][0]=W[0]),W[1]<nt[0][1]&&(nt[0][1]=W[1]),W[1]>nt[1][1]&&(nt[1][1]=W[1]))}),nt}),Z=(V[1][0]-V[0][0])/$,it=(V[1][1]-V[0][1])/$,at=et.reduce((ot,nt,W)=>{const yt=T(nt[0][0],V[0][0],Z,$),At=T(nt[1][0],V[0][0],Z,$),Et=T(nt[0][1],V[0][1],it,$),Nt=T(nt[1][1],V[0][1],it,$);for(let xt=yt;xt<=At;xt++){ot[xt]||(ot[xt]=[]);for(let Ot=Et;Ot<=Nt;Ot++)ot[xt][Ot]||(ot[xt][Ot]=[]),ot[xt][Ot].push(W)}return ot},[]),K=N.features.map(ot=>{let nt=[];return f(ot)[0].map(W=>{z.length===0?z=[Array.from(W),Array.from(W)]:(W[0]<z[0][0]&&(z[0][0]=W[0]),W[0]>z[1][0]&&(z[1][0]=W[0]),W[1]<z[0][1]&&(z[0][1]=W[1]),W[1]>z[1][1]&&(z[1][1]=W[1])),nt.length===0?nt=[Array.from(W),Array.from(W)]:(W[0]<nt[0][0]&&(nt[0][0]=W[0]),W[0]>nt[1][0]&&(nt[1][0]=W[0]),W[1]<nt[0][1]&&(nt[0][1]=W[1]),W[1]>nt[1][1]&&(nt[1][1]=W[1]))}),nt}),tt=(z[1][0]-z[0][0])/$,ft=(z[1][1]-z[0][1])/$,wt=K.reduce((ot,nt,W)=>{const yt=T(nt[0][0],z[0][0],tt,$),At=T(nt[1][0],z[0][0],tt,$),Et=T(nt[0][1],z[0][1],ft,$),Nt=T(nt[1][1],z[0][1],ft,$);for(let xt=yt;xt<=At;xt++){ot[xt]||(ot[xt]=[]);for(let Ot=Et;Ot<=Nt;Ot++)ot[xt][Ot]||(ot[xt][Ot]=[]),ot[xt][Ot].push(W)}return ot},[]);this.indexedTins={forw:{gridNum:$,xOrigin:V[0][0],yOrigin:V[0][1],xUnit:Z,yUnit:it,gridCache:at},bakw:{gridNum:$,xOrigin:z[0][0],yOrigin:z[0][1],xUnit:tt,yUnit:ft,gridCache:wt}}}transform(v,A,N){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(A&&this.strict_status==$t.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==$t.YAXIS_FOLLOW&&A&&(v=[v[0],-1*v[1]]);const $=r(v);if(this.bounds&&!A&&!N&&!R($,this.boundsPolygon))return!1;const V=A?this.tins.bakw:this.tins.forw,z=A?this.indexedTins.bakw:this.indexedTins.forw,et=A?this.vertices_params.bakw:this.vertices_params.forw,Z=A?this.centroid.bakw:this.centroid.forw,it=A?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let at,K;this.stateFull&&(this.stateBackward==A?at=this.stateTriangle:(this.stateBackward=A,this.stateTriangle=void 0),K=ft=>{this.stateTriangle=ft});let tt=X($,V,z,et,Z,it,at,K);if(this.bounds&&A&&!N){const ft=r(tt);if(!R(ft,this.boundsPolygon))return!1}else this.yaxisMode==$t.YAXIS_FOLLOW&&!A&&(tt=[tt[0],-1*tt[1]]);return tt}}const zt=20037508342789244e-9,Ke=[[0,0],[0,1],[1,0],[0,-1],[-1,0]];function Me(S,v){return Math.floor(Math.min(S[0],S[1])/4)*zt/128/Math.pow(2,v)}function Ce(S,v){const A=[];for(let N=0;N<S.length;N++){const $=S[N],V=$[0]*Math.cos(v)-$[1]*Math.sin(v),z=$[0]*Math.sin(v)+$[1]*Math.cos(v);A.push([V,z])}return A}function ye(S,v,A,N){const $=Me(N,v);return Ce(Ke,A).map(V=>[V[0]*$+S[0],V[1]*$+S[1]])}function yn(S,v){const A=S[0],N=S.slice(1,5).map(tt=>[tt[0]-A[0],tt[1]-A[1]]),$=[[0,1],[1,0],[0,-1],[-1,0]];let V=0,z=0,et=0;for(let tt=0;tt<4;tt++){const ft=N[tt],wt=$[tt],ot=Math.sqrt(Math.pow(ft[0],2)+Math.pow(ft[1],2));V+=ot;const nt=ft[0]*wt[1]-ft[1]*wt[0],W=Math.acos((ft[0]*wt[0]+ft[1]*wt[1])/ot),yt=nt>0?-1*W:W;z+=Math.cos(yt),et+=Math.sin(yt)}const Z=V/4,it=Math.atan2(et,z),at=Math.floor(Math.min(v[0],v[1])/4),K=Math.log(at*zt/128/Z)/Math.log(2);return{center:A,zoom:K,rotation:it}}function Qe(S,v){const A=S[0]*(2*zt)/v-zt,N=-1*(S[1]*(2*zt)/v-zt);return[A,N]}function bn(S,v){const A=(S[0]+zt)*v/(2*zt),N=(-S[1]+zt)*v/(2*zt);return[A,N]}const xn=256;class Fi{mainTin=null;subTins=[];_maxxy=0;setMapData(v){const A=new $t;if(A.setCompiled(v.compiled),this.mainTin=A,v.maxZoom!==void 0)this._maxxy=Math.pow(2,v.maxZoom)*xn;else if(v.compiled.wh){const N=Math.max(v.compiled.wh[0],v.compiled.wh[1]),$=Math.ceil(Math.log2(N/xn));this._maxxy=Math.pow(2,$)*xn}if(this.subTins=[],v.sub_maps)for(const N of v.sub_maps){const $=new $t;$.setCompiled(N.compiled);const V=N.bounds??N.compiled.bounds;if(!V)throw new Error("SubMapData must have bounds or compiled.bounds to create xyBounds polygon");const z=[...V,V[0]],et=z.map(Z=>{const it=$.transform(Z,!1);if(!it)throw new Error("Failed to transform sub-map bounds to mercator");return it});this.subTins.push({tin:$,priority:N.priority,importance:N.importance,xyBounds:i([z]),mercBounds:i([et])})}}xy2Merc(v){const A=this.xy2MercWithLayer(v);return A?A[1]:!1}merc2Xy(v){const A=this.merc2XyWithLayer(v),N=A[0]||A[1];return N?N[1]:!1}xy2MercWithLayer(v){this._assertMapData();const A=this._getTinsSortedByPriority();for(let N=0;N<A.length;N++){const{index:$,isMain:V}=A[N];if(V||R(r(v),this.subTins[$-1].xyBounds)){const z=this._transformByIndex(v,$,!1);if(z===!1)continue;return[$,z]}}return!1}merc2XyWithLayer(v){return this._assertMapData(),this._getAllTinsWithIndex().map(({index:A,tin:N,isMain:$})=>{const V=this._transformByIndex(v,A,!0);return V===!1?[N,A]:$||R(r(V),this.subTins[A-1].xyBounds)?[N,A,V]:[N,A]}).sort((A,N)=>{const $=A[0].priority??0,V=N[0].priority??0;return $<V?1:-1}).reduce((A,N,$,V)=>{const z=N[0],et=N[1],Z=N[2];if(!Z)return A;for(let it=0;it<$;it++){const at=V[it][1],K=at===0;if(V[it][2]&&(K||R(r(Z),this.subTins[at-1].xyBounds)))if(A.length){const tt=!A[0],ft=tt?A[1][2]:A[0][2],wt=z.importance??0,ot=ft.importance??0;return tt?wt<ot?A:[void 0,[et,Z,z]]:[...A.filter(nt=>nt!==void 0),[et,Z,z]].sort((nt,W)=>(nt[2].importance??0)<(W[2].importance??0)?1:-1).slice(0,2)}else return[[et,Z,z]]}return!A.length||!A[0]?[[et,Z,z]]:(A.push([et,Z,z]),A.sort((it,at)=>{const K=it[2].importance??0,tt=at[2].importance??0;return K<tt?1:-1}).filter((it,at)=>at<2))},[]).map(A=>{if(A)return[A[0],A[1]]})}mercs2SysCoords(v){this._assertMapData();const A=this.merc2XyWithLayer(v[0]);let N=!1;return A.map(($,V)=>{if(!$){N=!0;return}const z=$[0],et=$[1];return V!==0&&!N?[this.xy2SysCoordInternal(et)]:v.map((Z,it)=>it===0?et:this._transformByIndex(Z,z,!0)).map(Z=>this.xy2SysCoordInternal(Z))})}viewpoint2Mercs(v,A){this._assertMapData(),this._assertMaxxy();const N=ye(v.center,v.zoom,v.rotation,A).map(et=>bn(et,this._maxxy)),$=this.xy2MercWithLayer(N[0]);if(!$)throw new Error("viewpoint2Mercs: center point is out of bounds");const V=$[0],z=$[1];return N.map((et,Z)=>{if(Z===0)return z;const it=this._transformByIndex(et,V,!1);if(it===!1)throw new Error(`viewpoint2Mercs: point ${Z} is out of bounds`);return it})}mercs2Viewpoint(v,A){this._assertMapData(),this._assertMaxxy();const N=this.merc2XyWithLayer(v[0]),$=N[0]||N[1];if(!$)throw new Error("mercs2Viewpoint: center point is out of bounds");const V=$[0],z=$[1],et=v.map((Z,it)=>{if(it===0)return z;const at=this._transformByIndex(Z,V,!0);if(at===!1)throw new Error(`mercs2Viewpoint: point ${it} is out of bounds`);return at}).map(Z=>Qe(Z,this._maxxy));return yn(et,A)}static zoom2Radius(v,A){return Me(v,A)}static mercViewpoint2Mercs(v,A,N,$){return ye(v,A,N,$)}static mercs2MercViewpoint(v,A){return yn(v,A)}static xy2SysCoord(v,A){return Qe(v,A)}static sysCoord2Xy(v,A){return bn(v,A)}_assertMapData(){if(!this.mainTin)throw new Error("setMapData() must be called before transformation")}_assertMaxxy(){if(this._maxxy===0)throw new Error("MapData.maxZoom or compiled.wh must be set for viewpoint conversion (xy2SysCoord / sysCoord2Xy)")}getLayerTransform(v){if(v===0)return this.mainTin;const A=this.subTins[v-1];return A?A.tin:null}get layerCount(){return 1+this.subTins.length}get maxxy(){return this._maxxy}_getTinsSortedByPriority(){return this._getAllTinsWithIndex().sort((v,A)=>{const N=v.tin.priority??0,$=A.tin.priority??0;return N<$?1:-1})}_getAllTinsWithIndex(){const v=[{index:0,tin:this.mainTin,isMain:!0}];return this.subTins.forEach((A,N)=>{A.tin.priority=A.priority,A.tin.importance=A.importance,v.push({index:N+1,tin:A.tin,isMain:!1})}),v}_transformByIndex(v,A,N){if(A===0)return this.mainTin.transform(v,N);const $=this.subTins[A-1];return $?$.tin.transform(v,N,!0):!1}xy2SysCoordInternal(v){return Qe(v,this._maxxy)}}e.MERC_CROSSMATRIX=Ke,e.MERC_MAX=zt,e.MapTransform=Fi,e.Transform=$t,e.counterTri=j,e.format_version=wn,e.mercViewpoint2Mercs=ye,e.mercs2MercViewpoint=yn,e.normalizeEdges=rt,e.rotateMatrix=Ce,e.rotateVerticesTriangle=C,e.sysCoord2Xy=bn,e.transformArr=X,e.xy2SysCoord=Qe,e.zoom2Radius=Me,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}))})(Ae,Ae.exports)),Ae.exports}var Ut=jr();const Ln=Math.pow(2,-52),Ue=new Uint32Array(512);class hn{static from(t,e=Gr,n=Jr){const r=t.length,i=new Float64Array(r*2);for(let o=0;o<r;o++){const a=t[o];i[2*o]=e(a),i[2*o+1]=n(a)}return new hn(i)}constructor(t){const e=t.length>>1;if(e>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const n=Math.max(2*e-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:n,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let a=1/0,c=1/0,f=-1/0,u=-1/0;for(let I=0;I<o;I++){const P=t[2*I],D=t[2*I+1];P<a&&(a=P),D<c&&(c=D),P>f&&(f=P),D>u&&(u=D),this._ids[I]=I}const h=(a+f)/2,p=(c+u)/2;let x,k,E;for(let I=0,P=1/0;I<o;I++){const D=un(h,p,t[2*I],t[2*I+1]);D<P&&(x=I,P=D)}const F=t[2*x],L=t[2*x+1];for(let I=0,P=1/0;I<o;I++){if(I===x)continue;const D=un(F,L,t[2*I],t[2*I+1]);D<P&&D>0&&(k=I,P=D)}let g=t[2*k],b=t[2*k+1],l=1/0;for(let I=0;I<o;I++){if(I===x||I===k)continue;const P=zr(F,L,g,b,t[2*I],t[2*I+1]);P<l&&(E=I,l=P)}let w=t[2*E],m=t[2*E+1];if(l===1/0){for(let D=0;D<o;D++)this._dists[D]=t[2*D]-t[0]||t[2*D+1]-t[1];_e(this._ids,this._dists,0,o-1);const I=new Uint32Array(o);let P=0;for(let D=0,R=-1/0;D<o;D++){const G=this._ids[D],d=this._dists[G];d>R&&(I[P++]=G,R=d)}this.hull=I.subarray(0,P),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Zt(F,L,g,b,w,m)<0){const I=k,P=g,D=b;k=E,g=w,b=m,E=I,w=P,m=D}const B=Wr(F,L,g,b,w,m);this._cx=B.x,this._cy=B.y;for(let I=0;I<o;I++)this._dists[I]=un(t[2*I],t[2*I+1],B.x,B.y);_e(this._ids,this._dists,0,o-1),this._hullStart=x;let O=3;n[x]=e[E]=k,n[k]=e[x]=E,n[E]=e[k]=x,r[x]=0,r[k]=1,r[E]=2,i.fill(-1),i[this._hashKey(F,L)]=x,i[this._hashKey(g,b)]=k,i[this._hashKey(w,m)]=E,this.trianglesLen=0,this._addTriangle(x,k,E,-1,-1,-1);for(let I=0,P,D;I<this._ids.length;I++){const R=this._ids[I],G=t[2*R],d=t[2*R+1];if(I>0&&Math.abs(G-P)<=Ln&&Math.abs(d-D)<=Ln||(P=G,D=d,R===x||R===k||R===E))continue;let M=0;for(let y=0,C=this._hashKey(G,d);y<this._hashSize&&(M=i[(C+y)%this._hashSize],!(M!==-1&&M!==n[M]));y++);M=e[M];let _=M,X;for(;X=n[_],Zt(G,d,t[2*_],t[2*_+1],t[2*X],t[2*X+1])>=0;)if(_=X,_===M){_=-1;break}if(_===-1)continue;let T=this._addTriangle(_,R,n[_],-1,-1,r[_]);r[R]=this._legalize(T+2),r[_]=T,O++;let Y=n[_];for(;X=n[Y],Zt(G,d,t[2*Y],t[2*Y+1],t[2*X],t[2*X+1])<0;)T=this._addTriangle(Y,R,X,r[R],-1,r[Y]),r[R]=this._legalize(T+2),n[Y]=Y,O--,Y=X;if(_===M)for(;X=e[_],Zt(G,d,t[2*X],t[2*X+1],t[2*_],t[2*_+1])<0;)T=this._addTriangle(X,R,_,-1,r[_],r[X]),this._legalize(T+2),r[X]=T,n[_]=_,O--,_=X;this._hullStart=e[R]=_,n[_]=e[Y]=R,n[R]=Y,i[this._hashKey(G,d)]=R,i[this._hashKey(t[2*_],t[2*_+1])]=_}this.hull=new Uint32Array(O);for(let I=0,P=this._hullStart;I<O;I++)this.hull[I]=P,P=n[P];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(qr(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:n,coords:r}=this;let i=0,o=0;for(;;){const a=n[t],c=t-t%3;if(o=c+(t+2)%3,a===-1){if(i===0)break;t=Ue[--i];continue}const f=a-a%3,u=c+(t+1)%3,h=f+(a+2)%3,p=e[o],x=e[t],k=e[u],E=e[h];if(Ur(r[2*p],r[2*p+1],r[2*x],r[2*x+1],r[2*k],r[2*k+1],r[2*E],r[2*E+1])){e[t]=E,e[a]=p;const L=n[h];if(L===-1){let b=this._hullStart;do{if(this._hullTri[b]===h){this._hullTri[b]=t;break}b=this._hullPrev[b]}while(b!==this._hullStart)}this._link(t,L),this._link(a,n[o]),this._link(o,h);const g=f+(a+1)%3;i<Ue.length&&(Ue[i++]=g)}else{if(i===0)break;t=Ue[--i]}}return o}_link(t,e){this._halfedges[t]=e,e!==-1&&(this._halfedges[e]=t)}_addTriangle(t,e,n,r,i,o){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=e,this._triangles[a+2]=n,this._link(a,r),this._link(a+1,i),this._link(a+2,o),this.trianglesLen+=3,a}}function qr(s,t){const e=s/(Math.abs(s)+Math.abs(t));return(t>0?3-e:1+e)/4}function un(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function Ur(s,t,e,n,r,i,o,a){const c=s-o,f=t-a,u=e-o,h=n-a,p=r-o,x=i-a,k=c*c+f*f,E=u*u+h*h,F=p*p+x*x;return c*(h*F-E*x)-f*(u*F-E*p)+k*(u*x-h*p)<0}function zr(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),x=(f*u-a*h)*p,k=(o*h-c*u)*p;return x*x+k*k}function Wr(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),x=s+(f*u-a*h)*p,k=t+(o*h-c*u)*p;return{x,y:k}}function _e(s,t,e,n){if(n-e<=20)for(let r=e+1;r<=n;r++){const i=s[r],o=t[i];let a=r-1;for(;a>=e&&t[s[a]]>o;)s[a+1]=s[a--];s[a+1]=i}else{const r=e+n>>1;let i=e+1,o=n;Ie(s,r,i),t[s[e]]>t[s[n]]&&Ie(s,e,n),t[s[i]]>t[s[n]]&&Ie(s,i,n),t[s[e]]>t[s[i]]&&Ie(s,e,i);const a=s[i],c=t[a];for(;;){do i++;while(t[s[i]]<c);do o--;while(t[s[o]]>c);if(o<i)break;Ie(s,i,o)}s[e+1]=s[o],s[o]=a,n-i+1>=o-e?(_e(s,t,i,n),_e(s,t,e,o-1)):(_e(s,t,e,o-1),_e(s,t,i,n))}}function Ie(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Gr(s){return s[0]}function Jr(s){return s[1]}class Kr{bs;width;constructor(t,e){this.width=t,this.bs=e}add(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]|=1<<n,this}delete(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]&=~(1<<n),this}set(t,e){const n=Math.floor(t/this.width),i=1<<t%this.width;return this.bs[n]^=(-Number(e)^this.bs[n])&i,e}has(t){const e=Math.floor(t/this.width),n=t%this.width;return(this.bs[e]&1<<n)!==0}forEach(t){const e=this.bs.length;for(let n=0;n<e;n++){let r=0;for(;this.bs[n]&&r<this.width;)this.bs[n]&1<<r&&t(n*this.width+r),r++}return this}}class $n extends Kr{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function ge(s){return s%3===2?s-2:s+1}function oe(s){return s%3===0?s+2:s-1}function Vn(s,t,e,n,r,i,o,a){const c=Zt(s,t,r,i,o,a),f=Zt(e,n,r,i,o,a);if(c>0&&f>0||c<0&&f<0)return!1;const u=Zt(r,i,s,t,e,n),h=Zt(o,a,s,t,e,n);return u>0&&h>0||u<0&&h<0?!1:c===0&&f===0&&u===0&&h===0?!(Math.max(r,o)<Math.min(s,e)||Math.max(s,e)<Math.min(r,o)||Math.max(i,a)<Math.min(t,n)||Math.max(t,n)<Math.min(i,a)):!0}class Qr{del;constructor(t){this.del=t}}class Hr extends Qr{vertMap;flips;consd;constructor(t,e){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);const n=2**32-1,r=t.coords.length>>1,i=t.triangles.length;this.vertMap=new Uint32Array(r).fill(n),this.flips=new $n(i),this.consd=new $n(i);for(let o=0;o<i;o++){const a=t.triangles[o];this.vertMap[a]===n&&this.updateVert(o)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:n,halfedges:r}=this.del,i=this.vertMap[t];let o=i;do{const f=n[o],u=ge(o);if(f===e)return this.protect(o);const h=oe(o),p=n[h];if(p===e)return this.protect(u),u;if(this.intersectSegments(t,e,p,f)){o=h;break}o=r[u]}while(o!==-1&&o!==i);let a=o,c=-1;for(;o!==-1;){const f=r[o],u=oe(o),h=oe(f),p=ge(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(o))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,e,n[o])||this.isCollinear(t,e,n[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(n[o],n[f],n[u],n[h])){if(c===-1&&(c=o),n[h]===e){if(o===c)throw new Error("Infinite loop: non-convex quadrilateral");o=c,c=-1;continue}if(this.intersectSegments(t,e,n[h],n[f]))o=h;else if(this.intersectSegments(t,e,n[p],n[h]))o=p;else if(c===o)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(o),this.intersectSegments(t,e,n[u],n[h])&&(c===-1&&(c=u),c===u))throw new Error("Infinite loop: flipped diagonal still intersects");n[h]===e?(a=h,o=c,c=-1):this.intersectSegments(t,e,n[p],n[h])&&(o=p)}return this.protect(a),this.delaunify(!0),this.findEdge(t,e)}delaunify(t=!1){const{halfedges:e}=this.del,n=this.flips,r=this.consd,i=e.length;let o;do{o=0;for(let a=0;a<i;a++){if(r.has(a))continue;n.delete(a);const c=e[a];c!==-1&&(n.delete(c),this.isDelaunay(a)||(this.flipDiagonal(a),o++))}}while(t&&o>0);return this}constrainAll(t){const e=t.length;for(let n=0;n<e;n++){const r=t[n];this.constrainOne(r[0],r[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const n=this.vertMap[e],{triangles:r,halfedges:i}=this.del;let o=n,a=-1;do{if(r[o]===t)return o;a=ge(o),o=i[a]}while(o!==-1&&o!==n);return r[ge(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],n=this.flips,r=this.consd;return n.delete(t),r.add(t),e!==-1?(n.delete(e),r.add(e),e):-t}markFlip(t){const e=this.del.halfedges,n=this.flips;if(this.consd.has(t))return!1;const i=e[t];return i!==-1&&(n.add(t),n.add(i)),!0}flipDiagonal(t){const{triangles:e,halfedges:n}=this.del,r=this.flips,i=this.consd,o=n[t],a=oe(t),c=ge(t),f=oe(o),u=ge(o),h=n[a],p=n[f];if(i.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[f],n[t]=p,r.set(t,r.has(f))||i.set(t,i.has(f)),p!==-1&&(n[p]=t),n[a]=f,e[o]=e[a],n[o]=h,r.set(o,r.has(a))||i.set(o,i.has(a)),h!==-1&&(n[h]=o),n[f]=a,this.markFlip(t),this.markFlip(c),this.markFlip(o),this.markFlip(u),r.add(a),i.delete(a),r.add(f),i.delete(f),this.updateVert(t),this.updateVert(c),this.updateVert(o),this.updateVert(u),a}isCollinear(t,e,n){const r=this.del.coords;return Zt(r[t*2],r[t*2+1],r[e*2],r[e*2+1],r[n*2],r[n*2+1])===0}inCircle(t,e,n,r){const i=this.del.coords;return pr(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:n}=this.del,r=n[t];if(r===-1)return!0;const i=e[oe(t)],o=e[t],a=e[ge(t)],c=e[oe(r)];return!this.inCircle(i,o,a,c)}updateVert(t){const{triangles:e,halfedges:n}=this.del,r=this.vertMap,i=e[t];let o=oe(t),a=n[o];for(;a!==-1&&a!==t;)o=oe(a),a=n[o];return r[i]=o,o}intersectSegments(t,e,n,r){const i=this.del.coords;return t===n||t===r||e===n||e===r?!1:Vn(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])}static intersectSegments=Vn}function Te(s,t,e){if(t||(t=[]),typeof s!="object"||s.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const n=s.features.map(c=>c.geometry.coordinates),r=hn.from(n);let i;const o=[];r.triangles.length!==0&&t.length!==0&&(i=new Hr(r),i.constrainAll(t));for(let c=0;c<r.triangles.length;c+=3)o.push([r.triangles[c],r.triangles[c+1],r.triangles[c+2]]);const a=["a","b","c"];return Gt(o.map(c=>{const f={},u=c.map((h,p)=>{const x=s.features[h],k=x.geometry.coordinates,E=[k[0],k[1]];return k.length===3?E[2]=k[2]:f[a[p]]=x.properties[e],E});return u[3]=u[0],Se([u],f)}))}function Zr(s,t){const e=[[],[],[],[]],n=[];return Object.keys(s).forEach(r=>{const i=s[r],o=i.forw,a=i.bakw,c=[o[0]-t.forw[0],o[1]-t.forw[1]],f=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:c,bakw:f};if(n.push(u),c[0]===0||c[1]===0)return;let h=0;c[0]>0&&(h+=1),c[1]>0&&(h+=2),e[h].push(u)}),{perQuad:e,aggregate:n}}function ti(s){let t=1/0,e=0,n=0;return s.forEach(r=>{const{forw:i,bakw:o}=r,a=Math.hypot(i[0],i[1]),c=Math.hypot(o[0],o[1]);if(c===0)return;const f=a/c,u=Math.atan2(i[0],i[1])-Math.atan2(o[0],o[1]);t=Math.min(t,f),e+=Math.cos(u),n+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(n,e)]:[1,0]}function ei(s,t,e){const{perQuad:n,aggregate:r}=Zr(s,t),i=n.every(c=>c.length>0),a=(e==="birdeye"?i?n:[r]:[r]).map(c=>ti(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function ni(s,t){let e=0;return s[0]>t[0]&&(e+=1),s[1]>t[1]&&(e+=2),e}function ri(s,t,e){const n=[s[0]-t.forw[0],s[1]-t.forw[1]],i=Math.sqrt(n[0]**2+n[1]**2)/e[0],o=Math.atan2(n[0],n[1])-e[1];return[t.bakw[0]+i*Math.sin(o),t.bakw[1]-i*Math.cos(o)]}function ii(s,t,e,n){const r=t[0]-s[0],i=t[1]-s[1];if(Math.abs(r)<1e-12&&Math.abs(i)<1e-12)return null;const o=n[0]-e[0],a=n[1]-e[1],c=e[0]-s[0],f=e[1]-s[1],u=r*a-i*o;if(Math.abs(u)<1e-12)return null;const h=(c*a-f*o)/u,p=(c*i-f*r)/u;return h<=1e-10||p<-1e-10||p>1+1e-10?null:{t:h,point:[s[0]+h*r,s[1]+h*i]}}function oi(s,t,e){const n=e.length;let r=-1/0,i=null;for(let o=0;o<n;o++){const a=(o+1)%n,c=ii(s,t,e[o].bakw,e[a].bakw);c&&c.t>r&&(r=c.t,i=c.point)}return i}function jn(s,t){const n=Math.atan2(s[0]-t[0],s[1]-t[1])*(180/Math.PI);return n<0?n+360:n}function qn(s,t,e,n,r,i){const o=t[0]-s[0],a=t[1]-s[1];if(o===0&&a===0)return null;const c=[];if(o!==0)for(const u of[e,n]){const h=(u-s[0])/o;if(h>0){const p=s[1]+h*a;p>=r&&p<=i&&c.push({t:h,x:u,y:p})}}if(a!==0)for(const u of[r,i]){const h=(u-s[1])/a;if(h>0){const p=s[0]+h*o;p>=e&&p<=n&&c.push({t:h,x:p,y:u})}}if(c.length===0)return null;c.sort((u,h)=>u.t-h.t);const f=c[0];return[f.x,f.y]}function Un(s,t,e){const n=s.length,r=new Array(n).fill(1);for(const i of t)for(let o=0;o<n;o++){const a=(o+1)%n,c=vn([s[o].bakw,s[a].bakw]),f=vn([e.bakw,i.bakw]),u=kr(c,f);if(u.features.length>0&&u.features[0].geometry){const h=u.features[0],p=Math.sqrt(Math.pow(i.bakw[0]-e.bakw[0],2)+Math.pow(i.bakw[1]-e.bakw[1],2)),x=Math.sqrt(Math.pow(h.geometry.coordinates[0]-e.bakw[0],2)+Math.pow(h.geometry.coordinates[1]-e.bakw[1],2)),k=p/x;k>r[o]&&(r[o]=k),k>r[a]&&(r[a]=k)}}s.forEach((i,o)=>{const a=r[o];i.bakw=[(i.bakw[0]-e.bakw[0])*a+e.bakw[0],(i.bakw[1]-e.bakw[1])*a+e.bakw[1]]})}function zn(s,t,e){const{convexBuf:n,centroid:r,allGcps:i,minx:o,maxx:a,miny:c,maxy:f}=s,u=ei(n,r,t),p=[[o,c],[a,c],[a,f],[o,f]].map(m=>({forw:m,bakw:ri(m,r,u[ni(m,r.forw)])}));if(p.sort((m,B)=>Math.atan2(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])-Math.atan2(B.forw[0]-r.forw[0],B.forw[1]-r.forw[1])),Un(p,i,r),!e)return p;const x=4,k=p.map(m=>Math.atan2(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])),E=p.map(m=>Math.atan2(m.bakw[0]-r.bakw[0],-(m.bakw[1]-r.bakw[1])));function F(m){for(let B=0;B<x;B++){const O=(B+1)%x,I=k[B],P=B<x-1?k[O]:k[O]+2*Math.PI;let D=m;for(;D<I;)D+=2*Math.PI;for(;D>=I+2*Math.PI;)D-=2*Math.PI;if(D>=I&&D<P)return{i:B,j:O,frac:(D-I)/(P-I)}}return{i:0,j:1,frac:0}}function L(m){const{i:B,j:O,frac:I}=F(m),P=E[B];let R=E[O]-P;for(;R>Math.PI;)R-=2*Math.PI;for(;R<-Math.PI;)R+=2*Math.PI;return P+I*R}const g=new Set(p.map(m=>Math.floor(jn(m.forw,r.forw)/10)%36)),b=i.map(m=>({forw:m.forw,bakw:m.bakw,angleDeg:jn(m.forw,r.forw),forwDist:Math.hypot(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])})),l=[];for(let m=0;m<36;m++){if(g.has(m))continue;const B=m*10,O=b.filter(M=>M.angleDeg>=B&&M.angleDeg<B+10);let I=null;if(O.length>0){const M=O.reduce((_,X)=>X.forwDist>_.forwDist?X:_);I=qn(r.forw,M.forw,o,a,c,f)}if(!I){const M=(B+5)%360*(Math.PI/180),_=[r.forw[0]+Math.sin(M),r.forw[1]+Math.cos(M)];I=qn(r.forw,_,o,a,c,f)}if(!I)continue;const P=[I[0]-r.forw[0],I[1]-r.forw[1]],D=Math.atan2(P[0],P[1]),R=L(D),G=[r.bakw[0]+Math.sin(R),r.bakw[1]-Math.cos(R)],d=oi(r.bakw,G,p);d&&l.push({forw:I,bakw:d})}const w=[...p,...l];return w.sort((m,B)=>Math.atan2(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])-Math.atan2(B.forw[0]-r.forw[0],B.forw[1]-r.forw[1])),Un(w,i,r),w}function si(s,t=!1){return zn(s,"plain",t)}function ai(s,t=!1){return zn(s,"birdeye",t)}function Wn(s){const e=new ci(s).findSegmentIntersections(),n=Zn(e),r=new Map;return n.forEach(i=>{r.set(`${i.x}:${i.y}`,i)}),Array.from(r.values()).map(i=>ae([i.x,i.y]))}class ci{_xx;_yy;_ii;_nn;_zz=null;_zlimit=0;_bb=null;_allBounds=null;_arcIter=null;_filteredArcIter=null;buf;constructor(t){this.initArcs(t)}initArcs(t){const e=[],n=[],r=t.map(i=>{const o=i?i.length:0;for(let a=0;a<o;a++)e.push(i[a][0]),n.push(i[a][1]);return o});this.initXYData(r,e,n)}initXYData(t,e,n){const r=t.length;this._xx=new Float64Array(e),this._yy=new Float64Array(n),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(r);let i=0;for(let o=0;o<r;o++)this._ii[o]=i,i+=t[o];(i!=this._xx.length||this._xx.length!=this._yy.length)&&ln("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Ii(this._xx,this._yy)}initBounds(){const t=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=t.bb,this._allBounds=t.bounds}calcArcBounds_(t,e,n){const r=n.length,i=new Float64Array(r*4),o=new Pe;let a=0,c,f,u;for(let h=0;h<r;h++)c=n[h],c>0&&(f=h*4,u=Ti(t,e,a,c),i[f++]=u[0],i[f++]=u[1],i[f++]=u[2],i[f]=u[3],a+=c,o.mergeBounds(u));return{bb:i,bounds:o}}getBounds(){return this._allBounds?this._allBounds.clone():new Pe}forEachSegment(t){let e=0;for(let n=0,r=this.size();n<r;n++)e+=this.forEachArcSegment(n,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const n=t>=0,r=n?t:~t,i=this.getRetainedInterval(),o=this._nn[r],a=n?1:-1;let c=n?this._ii[r]:this._ii[r]+o-1,f=c,u=0;for(let h=1;h<o;h++)f+=a,(i===0||this._zz[f]>=i)&&(e(c,f,this._xx,this._yy),c=f,u++);return u}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(t){const e=t*4;return(!this.buf||this.buf.byteLength<e)&&(this.buf=new ArrayBuffer(e)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,e=0;const n=this.forEachSegment((r,i,o,a)=>{t+=Math.abs(o[r]-o[i]),e+=Math.abs(a[r]-a[i])});return[t/n||0,e/n||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),e=this.getAvgSegment2()[1];let n=1;return e>0&&t>0&&(n=Math.ceil(t/e/20)),n||1}findSegmentIntersections(){const t=this.getBounds(),e=t.ymin||0,n=(t.ymax||0)-e,r=this.calcSegmentIntersectionStripeCount(),i=new Uint32Array(r),o=r>1?E=>Math.floor((r-1)*(E-e)/n):()=>0;let a,c;this.forEachSegment((E,F,L,g)=>{let b=o(g[E]);const l=o(g[F]);for(;i[b]=i[b]+2,b!=l;)b+=l>b?1:-1});const f=this.getUint32Array(ui(i));let u=0;const h=[];li(i,E=>{const F=u;u+=E,h.push(f.subarray(F,u))}),di(i,0),this.forEachSegment((E,F,L,g)=>{let b=o(g[E]);const l=o(g[F]);let w,m;for(;w=i[b],i[b]=w+2,m=h[b],m[w]=E,m[w+1]=F,b!=l;)b+=l>b?1:-1});const p=this.getVertexData(),x=[];let k;for(a=0;a<r;a++)if(p.xx&&p.yy)for(k=pi(h[a],p.xx,p.yy),c=0;c<k.length;c++)x.push(k[c]);return Zn(x)}}function ln(...s){const t=s.join(" ");throw new Error(t)}function dn(s){return s?hi(s)?!0:fi(s)?!1:s.length===0?!0:s.length>0:!1}function fi(s){return s!=null&&s.toString===String.prototype.toString}function hi(s){return Array.isArray(s)}function ui(s,t){dn(s)||ln("utils.sum() expects an array, received:",s);let e=0,n;for(let r=0,i=s.length;r<i;r++)n=s[r],n&&(e+=n);return e}function li(s,t,e){if(!dn(s))throw new Error(`#forEach() takes an array-like argument. ${s}`);for(let n=0,r=s.length;n<r;n++)t.call(e,s[n],n)}function di(s,t){for(let e=0,n=s.length;e<n;e++)s[e]=t;return s}function pi(s,t,e){const n=s.length-2,r=[];let i,o,a,c,f,u,h,p,x,k,E,F,L,g,b,l,w;for(Si(t,s),l=0;l<n;){for(i=s[l],o=s[l+1],f=t[i],u=t[o],x=e[i],k=e[o],w=l;w<n&&(w+=2,a=s[w],h=t[a],!(u<h));){if(E=e[a],c=s[w+1],p=t[c],F=e[c],x>=E){if(x>F&&k>E&&k>F)continue}else if(x<F&&k<E&&k<F)continue;i==a||i==c||o==a||o==c||(L=mi(f,x,u,k,h,E,p,F),L&&(g=[i,o],b=[a,c],r.push(Qn(L,g,b,t,e)),L.length==4&&r.push(Qn(L.slice(2),g,b,t,e))))}l+=2}return r}function mi(s,t,e,n,r,i,o,a){const c=gi(s,t,e,n,r,i,o,a);let f=null;return c&&(f=wi(s,t,e,n,r,i,o,a),f?Mi(s,t,e,n,r,i,o,a)&&(f=null):f=_i(s,t,e,n,r,i,o,a)),f}function gi(s,t,e,n,r,i,o,a){return Be(s,t,e,n,r,i)*Be(s,t,e,n,o,a)<=0&&Be(r,i,o,a,s,t)*Be(r,i,o,a,e,n)<=0}function Be(s,t,e,n,r,i){return Gn(s-r,t-i,e-r,n-i)}function Gn(s,t,e,n){return s*n-t*e}function wi(s,t,e,n,r,i,o,a){let c=ze(s,t,e,n,r,i,o,a),f;return c&&(f=bi(c[0],c[1],s,t,e,n,r,i,o,a),f==1?c=ze(e,n,s,t,r,i,o,a):f==2?c=ze(r,i,o,a,s,t,e,n):f==3&&(c=ze(o,a,r,i,s,t,e,n))),c&&vi(c,s,t,e,n,r,i,o,a),c}function ze(s,t,e,n,r,i,o,a){const c=Gn(e-s,n-t,o-r,a-i),f=1e-18;let u;if(c===0)return null;const h=Be(r,i,o,a,s,t)/c;return c<=f&&c>=-f?u=yi(s,t,e,n,r,i,o,a):u=[s+h*(e-s),t+h*(n-t)],u}function yi(s,t,e,n,r,i,o,a){let c=null;return!se(s,r,o)&&!se(t,i,a)?c=[s,t]:!se(e,r,o)&&!se(n,i,a)?c=[e,n]:!se(r,s,e)&&!se(i,t,n)?c=[r,i]:!se(o,s,e)&&!se(a,t,n)&&(c=[o,a]),c}function se(s,t,e){let n;return t<e?n=s<t||s>e:t>e?n=s>t||s<e:n=s!=t,n}function bi(s,t,...e){let n=-1,r=1/0,i;for(let o=0,a=0,c=e.length;a<c;o++,a+=2)i=xi(s,t,e[a],e[a+1]),i<r&&(r=i,n=o);return n}function xi(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function vi(s,t,e,n,r,i,o,a,c){let f=s[0],u=s[1];f=We(f,t,n),f=We(f,i,a),u=We(u,e,r),u=We(u,o,c),s[0]=f,s[1]=u}function We(s,t,e){let n;return se(s,t,e)&&(n=Math.abs(s-t)<Math.abs(s-e)?t:e,s=n),s}function _i(s,t,e,n,r,i,o,a){const c=Math.min(s,e,r,o),f=Math.max(s,e,r,o),u=Math.min(t,n,i,a),h=Math.max(t,n,i,a),p=h-u>f-c;let x=[];return(p?le(t,u,h):le(s,c,f))&&x.push(s,t),(p?le(n,u,h):le(e,c,f))&&x.push(e,n),(p?le(i,u,h):le(r,c,f))&&x.push(r,i),(p?le(a,u,h):le(o,c,f))&&x.push(o,a),(x.length!=2&&x.length!=4||x.length==4&&x[0]==x[2]&&x[1]==x[3])&&(x=null),x}function Mi(s,t,e,n,r,i,o,a){return s==r&&t==i||s==o&&t==a||e==r&&n==i||e==o&&n==a}function le(s,t,e){return s>t&&s<e}function Si(s,t){ki(s,t),Jn(s,t,0,t.length-2)}function ki(s,t){for(let e=0,n=t.length;e<n;e+=2)s[t[e]]>s[t[e+1]]&&Ei(t,e,e+1)}function Ei(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Jn(s,t,e,n){let r=e,i=n,o,a;for(;r<n;){for(o=s[t[e+n>>2<<1]];r<=i;){for(;s[t[r]]<o;)r+=2;for(;s[t[i]]>o;)i-=2;r<=i&&(a=t[r],t[r]=t[i],t[i]=a,a=t[r+1],t[r+1]=t[i+1],t[i+1]=a,r+=2,i-=2)}if(i-e<40?Kn(s,t,e,i):Jn(s,t,e,i),n-r<40){Kn(s,t,r,n);return}e=r,i=n}}function Kn(s,t,e,n){let r,i;for(let o=e+2;o<=n;o+=2){r=t[o],i=t[o+1];let a;for(a=o-2;a>=e&&s[r]<s[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=r,t[a+3]=i}}function Qn(s,t,e,n,r){const i=s[0],o=s[1];t=Hn(i,o,t[0],t[1],n,r),e=Hn(i,o,e[0],e[1],n,r);const a=t[0]<e[0]?t:e,c=a==t?e:t;return{x:i,y:o,a,b:c}}function Hn(s,t,e,n,r,i){let o=e<n?e:n,a=o===e?n:e;return r[o]==s&&i[o]==t?a=o:r[a]==s&&i[a]==t&&(o=a),[o,a]}function Zn(s){const t={};return s.filter(e=>{const n=Ai(e);return n in t?!1:(t[n]=!0,!0)})}function Ai(s){return`${s.a.join(",")};${s.b.join(",")}`}class Ii{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,e){this._xx=t,this._yy=e}}function Ti(s,t,e,n){let r=e|0;const i=isNaN(n)?s.length-r:n+r;let o,a,c,f,u,h;if(i>0)c=u=s[r],f=h=t[r];else return[void 0,void 0,void 0,void 0];for(r++;r<i;r++)o=s[r],a=t[r],o<c&&(c=o),o>u&&(u=o),a<f&&(f=a),a>h&&(h=a);return[c,f,u,h]}class Pe{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new Pe(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,e,n,r){let i,o,a,c;if(arguments.length==1)if(dn(t)){const f=t;i=f[0],o=f[1],a=f[2],c=f[3]}else{const f=t;i=f.xmin,o=f.ymin,a=f.xmax,c=f.ymax}else i=t,o=e,a=n,c=r;return this.xmin=i,this.ymin=o,this.xmax=a,this.ymax=c,(i>a||o>c)&&this.update(),this}update(){let t;this.xmin>this.xmax&&(t=this.xmin,this.xmin=this.xmax,this.xmax=t),this.ymin>this.ymax&&(t=this.ymin,this.ymin=this.ymax,this.ymax=t)}mergeBounds(t,...e){let n,r,i,o;return t instanceof Pe?(n=t.xmin,r=t.ymin,i=t.xmax,o=t.ymax):e.length==3?(n=t,r=e[0],i=e[1],o=e[2]):t.length==4?(n=t[0],r=t[1],i=t[2],o=t[3]):ln("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(n,r,i,o):(n<this.xmin&&(this.xmin=n),r<this.ymin&&(this.ymin=r),i>this.xmax&&(this.xmax=i),o>this.ymax&&(this.ymax=o)),this}}function Ge(s){const t=["a","b","c"].map(e=>s.properties[e].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(e=>e.map(n=>t[n]).sort().join("-")).sort()}function pn(s,t,e){const n=Ge(t.forw),r=Ge(t.bakw);if(JSON.stringify(n)!=JSON.stringify(r))throw`${JSON.stringify(t,null,2)}
2
+ ${JSON.stringify(n)}
3
+ ${JSON.stringify(r)}`;for(let i=0;i<n.length;i++){const o=n[i];s[o]||(s[o]=[]),s[o].push(t)}e&&(e.forw.features.push(t.forw),e.bakw.features.push(t.bakw))}function tr(s,t,e){const n=Ge(t.forw),r=Ge(t.bakw);if(JSON.stringify(n)!=JSON.stringify(r))throw`${JSON.stringify(t,null,2)}
4
+ ${JSON.stringify(n)}
5
+ ${JSON.stringify(r)}`;if(n.forEach(i=>{const o=s[i];if(!o)return;const a=o.filter(c=>c!==t);a.length===0?delete s[i]:s[i]=a}),e){const i=(o,a)=>{!o||!a||(o.features=o.features.filter(c=>c!==a))};i(e.forw,t.forw),i(e.bakw,t.bakw)}}function Oe(s,t,e){return ae(s,{target:{geom:t,index:e}})}function Ne(s){return ae(s.properties.target.geom,{target:{geom:s.geometry.coordinates,index:s.properties.target.index}})}function mn(s,t){const e=s.length,n=t.geometry.coordinates;return Array.from({length:e},(r,i)=>i).map(r=>{const i=(r+1)%e,o=s[r],a=s[i],c=o.geometry.coordinates,f=Math.atan2(c[0]-n[0],c[1]-n[1]),u=[t,o,a,t].map(x=>x.geometry.coordinates),h={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:o.properties.target.geom,index:o.properties.target.index},c:{geom:a.properties.target.geom,index:a.properties.target.index}},p=Gt([Se([u],h)]);return[f,p]}).reduce((r,i)=>(r[0].push(i[0]),r[1].push(i[1]),r),[[],[]])}function Bi(s){const{tins:t,targets:e,includeReciprocals:n,numBoundaryVertices:r=4}=s,i={};e.forEach(a=>{const c=t[a];if(!c||!c.features)return;i[a]={};const f={};c.features.forEach(u=>{const h=["a","b","c"];for(let p=0;p<3;p++){const x=(p+1)%3,k=h[p],E=h[x],F=u.properties[k].index,L=u.properties[E].index,g=[F,L].sort().join("-");if(f[g])continue;f[g]=!0;const b=u.geometry.coordinates[0][p],l=u.geometry.coordinates[0][x],w=u.properties[k].geom,m=u.properties[E].geom,B=Math.sqrt(Math.pow(w[0]-m[0],2)+Math.pow(w[1]-m[1],2))/Math.sqrt(Math.pow(b[0]-l[0],2)+Math.pow(b[1]-l[1],2)),O=i[a];O[`${F}:${g}`]=B,O[`${L}:${g}`]=B}})});const o={};return n&&(o.bakw={}),e.forEach(a=>{const c=i[a];if(o[a]={},!c)return;const f={};Object.keys(c).forEach(h=>{const[p]=h.split(":");f[p]||(f[p]=[]),f[p].push(c[h])}),Object.keys(f).forEach(h=>{const p=f[h],x=p.reduce((k,E)=>k+E,0)/p.length;o[a][h]=x,n&&o.bakw&&(o.bakw[h]=1/x)});let u=0;for(let h=0;h<r;h++){const p=`b${h}`,x=o[a][p]||0;u+=x}o[a].c=u/r,n&&o.bakw&&(o.bakw.c=1/o[a].c)}),o}function Je(s,t=1e-6){const[e,n]=s[0],[r,i]=s[1],[o,a]=s[2];return Math.abs((r-e)*(a-n)-(o-e)*(i-n))<t}function Pi(s,t){const e=s.split("-");if(e.length!==2||!e.every(i=>/^-?\d+$/.test(i)))return!1;const[n,r]=e.map(i=>parseInt(i,10)).sort((i,o)=>i-o);return t.some(i=>{if(i.length!==2)return!1;const o=i.map(c=>parseInt(`${c}`,10));if(o.some(c=>Number.isNaN(c)))return!1;const a=o.sort((c,f)=>c-f);return a[0]===n&&a[1]===r})}function Xe(s){return["a","b","c"].map((t,e)=>({prop:s.properties[t],geom:s.geometry.coordinates[0][e]}))}const Oi=10;function Ni(s,t,e,n,r,i){if(!s&&!t)return!1;const o=s?0:1,a=1-o,c=e[o],f=e[a];if(!c||!f)return!1;const u=qt(f.geom);let h=!1,p=!1;for(let x=0;x<=1;x++){const k=n[x];if(!k)continue;const E=[String(k.prop.index),String(c.prop.index)].sort().join("-"),F=r[E];if(!F||F.length<2)continue;const L=F.find(D=>D.bakw!==i[o].bakw);if(!L)continue;const b=Xe(L.bakw).find(D=>String(D.prop.index)!==String(k.prop.index)&&String(D.prop.index)!==String(c.prop.index));if(!b)continue;h=!0;const l=qt(b.geom),w=qt(k.geom),m=qt(c.geom),B=m[0]-w[0],O=m[1]-w[1],I=B*(u[1]-w[1])-O*(u[0]-w[0]),P=B*(l[1]-w[1])-O*(l[0]-w[0]);if(I*P>0){p=!0;break}}return h&&!p}function Xi(s,t,e,n){if(!s&&!t)return!1;if(e[0]&&e[1]&&n[0]&&n[1]){const r=n.map(u=>qt(u.geom)),i=e.map(u=>qt(u.geom)),o=r[1][0]-r[0][0],a=r[1][1]-r[0][1],c=o*(i[0][1]-r[0][1])-a*(i[0][0]-r[0][0]),f=o*(i[1][1]-r[0][1])-a*(i[1][0]-r[0][0]);return c*f<0}return!1}function Ci(s,t,e){const n=new Set;let r=!1;for(let i=0;i<Oi;i++){let o=!1;for(const a of Object.keys(t)){if(n.has(a))continue;n.add(a);const c=t[a];if(!c||c.length<2)continue;const f=a.split("-");if(f.length!==2||Pi(a,e))continue;const u=Xe(c[0].bakw),h=Xe(c[1].bakw),p=Xe(c[0].forw),x=Xe(c[1].forw),k=f.map(T=>u.find(Y=>`${Y.prop.index}`===T)||h.find(Y=>`${Y.prop.index}`===T)),E=f.map(T=>p.find(Y=>`${Y.prop.index}`===T)||x.find(Y=>`${Y.prop.index}`===T));if(k.some(T=>!T)||E.some(T=>!T))continue;const F=[u,h].map(T=>T.find(Y=>!f.includes(`${Y.prop.index}`))),L=[p,x].map(T=>T.find(Y=>!f.includes(`${Y.prop.index}`)));if(F.some(T=>!T)||L.some(T=>!T))continue;const g=c[0].bakw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),b=c[1].bakw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),l=c[0].forw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),w=c[1].forw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),m=Je(g),B=Je(b),O=Je(l),I=Je(w),P=Ni(m,B,F,k,t,c),D=Xi(O,I,F,k);if(!(P||D||er(qt(F[0].geom),b)||er(qt(F[1].geom),g)))continue;const G=E.map(T=>qt(T.geom)),d=L.map(T=>qt(T.geom)),M=Di([...G,...d]),_=Ri(M),X=nr(G[0],G[1],d[0])+nr(G[0],G[1],d[1]);gn(_,X)&&(tr(t,c[0],s),tr(t,c[1],s),k.forEach(T=>{if(!T)return;const Y=[T.geom,F[0].geom,F[1].geom,T.geom],y={a:T.prop,b:F[0].prop,c:F[1].prop},C=Se([Y],y),j=Ut.counterTri(C);pn(t,{forw:j,bakw:C},s)}),o=!0,r=!0)}if(!o)break}return r}function qt(s){return[s[0],s[1]]}function er(s,t){const[e,n]=t[0],[r,i]=t[1],[o,a]=t[2],c=o-e,f=a-n,u=r-e,h=i-n,p=s[0]-e,x=s[1]-n,k=c*c+f*f,E=c*u+f*h,F=c*p+f*x,L=u*u+h*h,g=u*p+h*x,b=k*L-E*E;if(b===0)return!1;const l=1/b,w=(L*F-E*g)*l,m=(k*g-E*F)*l,B=1e-9;return w>=-B&&m>=-B&&w+m<=1+B}function Di(s){const t=s.map(o=>o.slice()).filter((o,a,c)=>c.findIndex(f=>gn(f[0],o[0])&&gn(f[1],o[1]))===a);if(t.length<=1)return t;const e=t.sort((o,a)=>o[0]===a[0]?o[1]-a[1]:o[0]-a[0]),n=(o,a,c)=>(a[0]-o[0])*(c[1]-o[1])-(a[1]-o[1])*(c[0]-o[0]),r=[];for(const o of e){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const a=e[o];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),r.pop(),r.concat(i)}function Ri(s){if(s.length<3)return 0;let t=0;for(let e=0;e<s.length;e++){const[n,r]=s[e],[i,o]=s[(e+1)%s.length];t+=n*o-i*r}return Math.abs(t)/2}function nr(s,t,e){return Math.abs((s[0]*(t[1]-e[1])+t[0]*(e[1]-s[1])+e[0]*(s[1]-t[1]))/2)}function gn(s,t,e=1e-9){return Math.abs(s-t)<=e}const rr=3;class Pt extends Ut.Transform{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||Pt.VERTEX_PLAIN),this.strictMode=t.strictMode||Pt.MODE_AUTO,this.yaxisMode=t.yaxisMode||Pt.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,this.useV2Algorithm=t.useV2Algorithm??!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return this.useV2Algorithm?Ut.format_version:rr}setPoints(t){this.yaxisMode===Pt.YAXIS_FOLLOW&&(t=t.map(e=>[e[0],[e[1][0],-1*e[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Ut.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let e=t[0][0],n=e,r=t[0][1],i=r;const o=[t[0]];for(let a=1;a<t.length;a++){const c=t[a];c[0]<e&&(e=c[0]),c[0]>n&&(n=c[0]),c[1]<r&&(r=c[1]),c[1]>i&&(i=c[1]),o.push(c)}o.push(t[0]),this.boundsPolygon=Se([o]),this.xy=[e,r],this.wh=[n-e,i-r],this.vertexMode=Pt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?Ut.format_version:rr,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer??{},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const e=this.vertices_params.forw[1];if(e)for(let n=0;n<e.length;n++){const r=e[n].features[0],i=r.geometry.coordinates[0][1],o=r.properties.b.geom;t.vertices_points[n]=[i,o]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(n=>{t.tins_points[0].push(["a","b","c"].map(r=>n.properties[r].index))}),this.strict_status===Pt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(r=>n.properties[r].index))})):this.strict_status===Pt.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(n=>n.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,this.useV2Algorithm&&(t.xy=this.xy,t.wh=this.wh)):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setCompiled(t){super.setCompiled(t)}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){const t=this.tins.forw.features.map(r=>Ut.counterTri(r));this.tins.bakw=Gt(t);const e={};this.tins.forw.features.forEach((r,i)=>{const o=this.tins.bakw.features[i];pn(e,{forw:r,bakw:o})}),Ci(this.tins,e,this.pointsSet?.edges||[]);const n=["forw","bakw"].map(r=>{const i=this.tins[r].features.map(o=>o.geometry.coordinates[0]);return Wn(i)});n[0].length===0&&n[1].length===0?(this.strict_status=Pt.STATUS_STRICT,delete this.kinks):(this.strict_status=Pt.STATUS_ERROR,this.kinks={forw:Gt(n[0]),bakw:Gt(n[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let r=0;r<this.points.length;r++){const i=this.points[r][0],o=this.points[r][1],a=Oe(i,o,r);t.forw.push(a),t.bakw.push(Ne(a))}const e=[];let n=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let r=0;r<this.edges.length;r++){const i=this.edges[r][2],o=Object.assign([],this.edges[r][0]),a=Object.assign([],this.edges[r][1]);if(o.length===0&&a.length===0){e.push(i);continue}o.unshift(this.points[i[0]][0]),o.push(this.points[i[1]][0]),a.unshift(this.points[i[0]][1]),a.push(this.points[i[1]][1]);const c=[o,a].map(f=>{const u=f.map((p,x,k)=>{if(x===0)return 0;const E=k[x-1];return Math.sqrt(Math.pow(p[0]-E[0],2)+Math.pow(p[1]-E[1],2))}),h=u.reduce((p,x,k)=>k===0?[0]:(p.push(p[k-1]+x),p),[]);return h.map((p,x,k)=>{const E=p/k[k.length-1];return[f[x],u[x],h[x],E]})});c.map((f,u)=>{const h=c[u?0:1];return f.filter((p,x)=>!(x===0||x===f.length-1||p[4]==="handled")).flatMap(p=>{const x=p[0],k=p[3],E=h.reduce((F,L,g,b)=>{if(F)return F;const l=b[g+1];if(L[3]===k)return L[4]="handled",[L];if(L[3]<k&&l&&l[3]>k)return[L,l]},void 0);if(E&&E.length===1)return u===0?[[x,E[0][0],k]]:[[E[0][0],x,k]];if(E&&E.length===2){const F=E[0],L=E[1],g=(k-F[3])/(L[3]-F[3]),b=[(L[0][0]-F[0][0])*g+F[0][0],(L[0][1]-F[0][1])*g+F[0][1]];return u===0?[[x,b,k]]:[[b,x,k]]}return[]})}).reduce((f,u)=>f.concat(u),[]).sort((f,u)=>f[2]<u[2]?-1:1).map((f,u,h)=>{this.edgeNodes[n]=[f[0],f[1]];const p=Oe(f[0],f[1],`e${n}`);n++,t.forw.push(p),t.bakw.push(Ne(p)),u===0?e.push([i[0],t.forw.length-1]):e.push([t.forw.length-2,t.forw.length-1]),u===h.length-1&&e.push([t.forw.length-1,i[1]])})}return{forw:t.forw,bakw:t.bakw,edges:e}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],e=this.xy[0]+1.05*this.wh[0],n=this.xy[1]-.05*this.wh[1],r=this.xy[1]+1.05*this.wh[1];if(this.bounds&&!this.boundsPolygon)throw new Error("Internal error: bounds is set but boundsPolygon is missing");const i=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((c,f)=>c&&(i?an(f[0],i):f[0][0]>=t&&f[0][0]<=e&&f[0][1]>=n&&f[0][1]<=r),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,n],[e,n],[t,r],[e,r]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:e,miny:n,maxy:r}}computeGcpBbox(){let t=1/0,e=-1/0,n=1/0,r=-1/0;for(const a of this.points){const c=a[0][0],f=a[0][1];c<t&&(t=c),c>e&&(e=c),f<n&&(n=f),f>r&&(r=f)}const i=e-t,o=r-n;return{minx:t-.05*i,maxx:e+.05*i,miny:n-.05*o,maxy:r+.05*o}}updateTin(){let t=this.strictMode;t!==Pt.MODE_STRICT&&t!==Pt.MODE_LOOSE&&(t=Pt.MODE_AUTO);const e=!this.useV2Algorithm;let n,r,i,o,a;if(e){if(this.bounds){const P=this.boundsPolygon;if(!P)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(R=>an(R[0],P)))throw"SOME POINTS OUTSIDE"}n=this.generatePointsSet(),{minx:r,maxx:i,miny:o,maxy:a}=this.computeGcpBbox()}else{const P=this.validateAndPrepareInputs();n=P.pointsSet,r=P.minx,i=P.maxx,o=P.miny,a=P.maxy}const c={forw:Gt(n.forw),bakw:Gt(n.bakw)},f=Te(c.forw,n.edges,"target"),u=Te(c.bakw,n.edges,"target");if(f.features.length===0||u.features.length===0)throw"TOO LINEAR1";const h=Ir(c.forw),p=Fn(c.forw);if(!p)throw"TOO LINEAR2";const x={},k=p.geometry.coordinates[0];let E;try{E=k.map(P=>({forw:P,bakw:Ut.transformArr(ae(P),f)})),E.forEach(P=>{x[`${P.forw[0]}:${P.forw[1]}`]=P})}catch{throw"TOO LINEAR2"}const F=Fn(c.bakw);if(!F)throw"TOO LINEAR2";const L=F.geometry.coordinates[0];try{E=L.map(P=>({bakw:P,forw:Ut.transformArr(ae(P),u)})),E.forEach(P=>{x[`${P.forw[0]}:${P.forw[1]}`]=P})}catch{throw"TOO LINEAR2"}let g;if(e){const P=h.geometry.coordinates,D=f.features.find(R=>an(ae(P),R));if(D){const R=D.geometry.coordinates[0],G=D.properties.a.geom,d=D.properties.b.geom,M=D.properties.c.geom;g={forw:[(R[0][0]+R[1][0]+R[2][0])/3,(R[0][1]+R[1][1]+R[2][1])/3],bakw:[(G[0]+d[0]+M[0])/3,(G[1]+d[1]+M[1])/3]}}else g={forw:P,bakw:Ut.transformArr(h,f)}}else g={forw:h.geometry.coordinates,bakw:Ut.transformArr(h,f)};const b=Oe(g.forw,g.bakw,"c");this.centroid={forw:b,bakw:Ne(b)};const l=[...this.points.map(P=>({forw:P[0],bakw:P[1]})),...(this.edgeNodes??[]).map(P=>({forw:P[0],bakw:P[1]}))],w={convexBuf:x,centroid:g,allGcps:l,minx:r,maxx:i,miny:o,maxy:a},m=this.vertexMode===Pt.VERTEX_BIRDEYE?ai(w,e):si(w,e),B={forw:[],bakw:[]};for(let P=0;P<m.length;P++){const D=m[P].forw,R=m[P].bakw,G=Oe(D,R,`b${P}`),d=Ne(G);n.forw.push(G),n.bakw.push(d),B.forw.push(G),B.bakw.push(d)}this.pointsSet={forw:Gt(n.forw),bakw:Gt(n.bakw),edges:n.edges},this.tins={forw:Ut.rotateVerticesTriangle(Te(this.pointsSet.forw,n.edges,"target"))},(t===Pt.MODE_STRICT||t===Pt.MODE_AUTO)&&this.calcurateStrictTin(),(t===Pt.MODE_LOOSE||t===Pt.MODE_AUTO&&this.strict_status===Pt.STATUS_ERROR)&&(this.tins.bakw=Ut.rotateVerticesTriangle(Te(this.pointsSet.bakw,n.edges,"target")),delete this.kinks,this.strict_status=Pt.STATUS_LOOSE),this.vertices_params={forw:mn(B.forw,this.centroid.forw),bakw:mn(B.bakw,this.centroid.bakw)},this.addIndexedTin();const O=["forw"];this.strict_status===Pt.STATUS_LOOSE&&O.push("bakw");const I=this.strict_status===Pt.STATUS_STRICT;this.pointsWeightBuffer=Bi({tins:this.tins,targets:O,includeReciprocals:I,numBoundaryVertices:m.length})}async updateTinAsync(){this.updateTin()}}Vt.Tin=Pt,Vt.constrainedTin=Te,Vt.counterPoint=Ne,Vt.createPoint=Oe,Vt.default=Pt,Vt.findIntersections=Wn,Vt.format_version=Ut.format_version,Vt.insertSearchIndex=pn,Vt.vertexCalc=mn,Object.defineProperties(Vt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.14.0",
7
+ "version": "0.14.1",
8
8
  "description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
9
9
  "type": "module",
10
10
  "module": "./dist/maplat_tin.js",
@@ -49,7 +49,7 @@
49
49
  "deno"
50
50
  ],
51
51
  "dependencies": {
52
- "@maplat/transform": "0.5.0",
52
+ "@maplat/transform": "0.5.2",
53
53
  "@turf/turf": "^7.3.1",
54
54
  "delaunator": "^5.0.1",
55
55
  "robust-predicates": "^3.0.2"
@@ -60,12 +60,12 @@
60
60
  "@types/delaunator": "^5.0.3",
61
61
  "@types/estree": "^1.0.8",
62
62
  "@types/geojson": "^7946.0.16",
63
- "@types/node": "^24.10.4",
64
- "@typescript-eslint/eslint-plugin": "^8.51.0",
65
- "@typescript-eslint/parser": "^8.51.0",
63
+ "@types/node": "^25.5.1",
64
+ "@typescript-eslint/eslint-plugin": "^8.58.0",
65
+ "@typescript-eslint/parser": "^8.58.0",
66
66
  "@vitest/coverage-v8": "^3.2.4",
67
67
  "cross-env": "^10.1.0",
68
- "dotenv": "^17.2.3",
68
+ "dotenv": "^17.4.0",
69
69
  "dotenv-cli": "^11.0.0",
70
70
  "eslint": "^9.39.2",
71
71
  "eslint-config-prettier": "^10.1.8",
@@ -75,8 +75,8 @@
75
75
  "prettier": "^3.7.4",
76
76
  "robust-segment-intersect": "^1.0.1",
77
77
  "typescript": "^5.9.3",
78
- "typescript-eslint": "^8.51.0",
79
- "vite": "^6.4.1",
78
+ "typescript-eslint": "^8.58.0",
79
+ "vite": "^7.3.0",
80
80
  "vite-plugin-dts": "^4.5.4",
81
81
  "vitest": "^3.2.4"
82
82
  },