@maplat/tin 1.1.1 → 1.1.2-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +6 -6
- package/README.md +6 -6
- package/dist/boundary-vertices.d.ts +1 -1
- package/dist/edge-nodes.d.ts +27 -0
- package/dist/edgebound/constrain.d.ts +23 -2
- package/dist/edgebound/index.d.ts +4 -4
- package/dist/index.d.ts +11 -11
- package/dist/kinks.d.ts +20 -0
- package/dist/maplat_tin.js +1533 -1420
- package/dist/maplat_tin.umd.js +3 -3
- package/dist/strict-overlap.d.ts +1 -1
- package/dist/tin.d.ts +5 -2
- package/dist/types/kinks.d.ts +12 -0
- package/dist/types/tin.d.ts +49 -0
- package/package.json +6 -7
- package/src/boundary-vertices.ts +1 -1
- package/src/constrained-tin.ts +1 -1
- package/src/edge-nodes.ts +126 -0
- package/src/edgebound/constrain.ts +74 -0
- package/src/index.ts +2 -2
- package/src/kinks.ts +76 -42
- package/src/tin.ts +45 -91
- package/src/types/kinks.ts +24 -0
- package/src/types/kinks.d.ts +0 -51
- /package/src/types/{tin.d.ts → tin.ts} +0 -0
package/dist/maplat_tin.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(bt,Bt){typeof exports=="object"&&typeof module<"u"?Bt(exports):typeof define=="function"&&define.amd?define(["exports"],Bt):(bt=typeof globalThis<"u"?globalThis:bt||self,Bt(bt.tin={}))})(this,(function(bt){"use strict";function Bt(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function Dt(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!tn(e[0])||!tn(e[1]))throw new Error("coordinates must contain numbers");return Bt({type:"Point",coordinates:e},t,n)}function te(e,t,n={}){for(const o of e){if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(o[o.length-1].length!==o[0].length)throw new Error("First and last Position are not equivalent.");for(let r=0;r<o[o.length-1].length;r++)if(o[o.length-1][r]!==o[0][r])throw new Error("First and last Position are not equivalent.")}return Bt({type:"Polygon",coordinates:e},t,n)}function Ze(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Bt({type:"LineString",coordinates:e},t,n)}function St(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function tn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ti(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ei(e){return e.type==="Feature"?e.geometry:e}function Pe(e,t,n){if(e!==null)for(var i,o,r,s,a,f,l,u=0,c=0,h,p=e.type,M=p==="FeatureCollection",w=p==="Feature",I=M?e.features.length:1,x=0;x<I;x++){l=M?e.features[x].geometry:w?e.geometry:e,h=l?l.type==="GeometryCollection":!1,a=h?l.geometries.length:1;for(var m=0;m<a;m++){var _=0,d=0;if(s=h?l.geometries[m]:l,s!==null){f=s.coordinates;var v=s.type;switch(u=n&&(v==="Polygon"||v==="MultiPolygon")?1:0,v){case null:break;case"Point":if(t(f,c,x,_,d)===!1)return!1;c++,_++;break;case"LineString":case"MultiPoint":for(i=0;i<f.length;i++){if(t(f[i],c,x,_,d)===!1)return!1;c++,v==="MultiPoint"&&_++}v==="LineString"&&_++;break;case"Polygon":case"MultiLineString":for(i=0;i<f.length;i++){for(o=0;o<f[i].length-u;o++){if(t(f[i][o],c,x,_,d)===!1)return!1;c++}v==="MultiLineString"&&_++,v==="Polygon"&&d++}v==="Polygon"&&_++;break;case"MultiPolygon":for(i=0;i<f.length;i++){for(d=0,o=0;o<f[i].length;o++){for(r=0;r<f[i][o].length-u;r++){if(t(f[i][o][r],c,x,_,d)===!1)return!1;c++}d++}_++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(Pe(s.geometries[i],t,n)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const ut=11102230246251565e-32,U=134217729,en=(3+8*ut)*ut;function ft(e,t,n,i,o){let r,s,a,f,l=t[0],u=i[0],c=0,h=0;u>l==u>-l?(r=l,l=t[++c]):(r=u,u=i[++h]);let p=0;if(c<e&&h<n)for(u>l==u>-l?(s=l+r,a=r-(s-l),l=t[++c]):(s=u+r,a=r-(s-u),u=i[++h]),r=s,a!==0&&(o[p++]=a);c<e&&h<n;)u>l==u>-l?(s=r+l,f=s-r,a=r-(s-f)+(l-f),l=t[++c]):(s=r+u,f=s-r,a=r-(s-f)+(u-f),u=i[++h]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+l,f=s-r,a=r-(s-f)+(l-f),l=t[++c],r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+u,f=s-r,a=r-(s-f)+(u-f),u=i[++h],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Mt(e,t,n,i,o,r,s,a){return ft(ft(e,t,n,i,s),s,o,r,a)}function $(e,t,n,i){let o,r,s,a,f,l,u,c,h,p,M;u=U*n,p=u-(u-n),M=n-p;let w=t[0];o=w*n,u=U*w,c=u-(u-w),h=w-c,s=h*M-(o-c*p-h*p-c*M);let I=0;s!==0&&(i[I++]=s);for(let x=1;x<e;x++)w=t[x],a=w*n,u=U*w,c=u-(u-w),h=w-c,f=h*M-(a-c*p-h*p-c*M),r=o+f,l=r-o,s=o-(r-l)+(f-l),s!==0&&(i[I++]=s),o=a+r,s=r-(o-a),s!==0&&(i[I++]=s);return(o!==0||I===0)&&(i[I++]=o),I}function nn(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function tt(e){return new Float64Array(e)}const ni=(3+16*ut)*ut,ii=(2+12*ut)*ut,ri=(9+64*ut)*ut*ut,Jt=tt(4),rn=tt(8),on=tt(12),sn=tt(16),mt=tt(4);function oi(e,t,n,i,o,r,s){let a,f,l,u,c,h,p,M,w,I,x,m,_,d,v,g,k,S;const A=e-o,O=n-o,B=t-r,C=i-r;d=A*C,h=U*A,p=h-(h-A),M=A-p,h=U*C,w=h-(h-C),I=C-w,v=M*I-(d-p*w-M*w-p*I),g=B*O,h=U*B,p=h-(h-B),M=B-p,h=U*O,w=h-(h-O),I=O-w,k=M*I-(g-p*w-M*w-p*I),x=v-k,c=v-x,Jt[0]=v-(x+c)+(c-k),m=d+x,c=m-d,_=d-(m-c)+(x-c),x=_-g,c=_-x,Jt[1]=_-(x+c)+(c-g),S=m+x,c=S-m,Jt[2]=m-(S-c)+(x-c),Jt[3]=S;let Y=nn(4,Jt),y=ii*s;if(Y>=y||-Y>=y||(c=e-A,a=e-(A+c)+(c-o),c=n-O,l=n-(O+c)+(c-o),c=t-B,f=t-(B+c)+(c-r),c=i-C,u=i-(C+c)+(c-r),a===0&&f===0&&l===0&&u===0)||(y=ri*s+en*Math.abs(Y),Y+=A*u+C*a-(B*l+O*f),Y>=y||-Y>=y))return Y;d=a*C,h=U*a,p=h-(h-a),M=a-p,h=U*C,w=h-(h-C),I=C-w,v=M*I-(d-p*w-M*w-p*I),g=f*O,h=U*f,p=h-(h-f),M=f-p,h=U*O,w=h-(h-O),I=O-w,k=M*I-(g-p*w-M*w-p*I),x=v-k,c=v-x,mt[0]=v-(x+c)+(c-k),m=d+x,c=m-d,_=d-(m-c)+(x-c),x=_-g,c=_-x,mt[1]=_-(x+c)+(c-g),S=m+x,c=S-m,mt[2]=m-(S-c)+(x-c),mt[3]=S;const P=ft(4,Jt,4,mt,rn);d=A*u,h=U*A,p=h-(h-A),M=A-p,h=U*u,w=h-(h-u),I=u-w,v=M*I-(d-p*w-M*w-p*I),g=B*l,h=U*B,p=h-(h-B),M=B-p,h=U*l,w=h-(h-l),I=l-w,k=M*I-(g-p*w-M*w-p*I),x=v-k,c=v-x,mt[0]=v-(x+c)+(c-k),m=d+x,c=m-d,_=d-(m-c)+(x-c),x=_-g,c=_-x,mt[1]=_-(x+c)+(c-g),S=m+x,c=S-m,mt[2]=m-(S-c)+(x-c),mt[3]=S;const E=ft(P,rn,4,mt,on);d=a*u,h=U*a,p=h-(h-a),M=a-p,h=U*u,w=h-(h-u),I=u-w,v=M*I-(d-p*w-M*w-p*I),g=f*l,h=U*f,p=h-(h-f),M=f-p,h=U*l,w=h-(h-l),I=l-w,k=M*I-(g-p*w-M*w-p*I),x=v-k,c=v-x,mt[0]=v-(x+c)+(c-k),m=d+x,c=m-d,_=d-(m-c)+(x-c),x=_-g,c=_-x,mt[1]=_-(x+c)+(c-g),S=m+x,c=S-m,mt[2]=m-(S-c)+(x-c),mt[3]=S;const T=ft(E,on,4,mt,sn);return sn[T-1]}function Et(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),f=s-a,l=Math.abs(s+a);return Math.abs(f)>=ni*l?f:-oi(e,t,n,i,o,r,l)}const si=(10+96*ut)*ut,ai=(4+48*ut)*ut,ci=(44+576*ut)*ut*ut,Ft=tt(4),Yt=tt(4),Rt=tt(4),At=tt(4),It=tt(4),Pt=tt(4),gt=tt(4),wt=tt(4),Oe=tt(8),Be=tt(8),Ne=tt(8),Te=tt(8),Ce=tt(8),Xe=tt(8),ge=tt(8),we=tt(8),ye=tt(8),Vt=tt(4),qt=tt(4),Ut=tt(4),z=tt(8),K=tt(16),nt=tt(16),it=tt(16),et=tt(32),$t=tt(32),st=tt(48),xt=tt(64);let Kt=tt(1152),De=tt(1152);function at(e,t,n){e=ft(e,Kt,t,n,De);const i=Kt;return Kt=De,De=i,e}function li(e,t,n,i,o,r,s,a,f){let l,u,c,h,p,M,w,I,x,m,_,d,v,g,k,S,A,O,B,C,Y,y,P,E,T,X,F,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=P-(P-W),T=W-E,q=T*T-(j-E*E-(E+E)*T),b=L+q,y=b-L,Pt[0]=L-(b-y)+(q-y),N=R+b,y=N-R,D=R-(N-y)+(b-y),b=D+j,y=b-D,Pt[1]=D-(b-y)+(j-y),V=N+b,y=V-N,Pt[2]=N-(V-y)+(b-y),Pt[3]=V),u!==0&&(I=$(4,Ft,u,Oe),l=at(l,Mt($(I,Oe,2*J,K),K,$($(4,Pt,u,z),z,Z,nt),nt,$($(4,It,u,z),z,-W,it),it,et,st),st)),p!==0&&(x=$(4,Ft,p,Be),l=at(l,Mt($(x,Be,2*H,K),K,$($(4,It,p,z),z,Q,nt),nt,$($(4,Pt,p,z),z,-G,it),it,et,st),st)),c!==0&&(m=$(4,Yt,c,Ne),l=at(l,Mt($(m,Ne,2*G,K),K,$($(4,At,c,z),z,W,nt),nt,$($(4,Pt,c,z),z,-H,it),it,et,st),st)),M!==0&&(_=$(4,Yt,M,Te),l=at(l,Mt($(_,Te,2*Z,K),K,$($(4,Pt,M,z),z,J,nt),nt,$($(4,At,M,z),z,-Q,it),it,et,st),st)),h!==0&&(d=$(4,Rt,h,Ce),l=at(l,Mt($(d,Ce,2*Q,K),K,$($(4,It,h,z),z,H,nt),nt,$($(4,At,h,z),z,-Z,it),it,et,st),st)),w!==0&&(v=$(4,Rt,w,Xe),l=at(l,Mt($(v,Xe,2*W,K),K,$($(4,At,w,z),z,G,nt),nt,$($(4,It,w,z),z,-J,it),it,et,st),st)),u!==0||p!==0){if(c!==0||M!==0||h!==0||w!==0?(R=c*W,P=U*c,E=P-(P-c),T=c-E,P=U*W,X=P-(P-W),F=W-X,L=T*F-(R-E*X-T*X-E*F),j=G*w,P=U*G,E=P-(P-G),T=G-E,P=U*w,X=P-(P-w),F=w-X,q=T*F-(j-E*X-T*X-E*F),b=L+q,y=b-L,gt[0]=L-(b-y)+(q-y),N=R+b,y=N-R,D=R-(N-y)+(b-y),b=D+j,y=b-D,gt[1]=D-(b-y)+(j-y),V=N+b,y=V-N,gt[2]=N-(V-y)+(b-y),gt[3]=V,R=h*-Z,P=U*h,E=P-(P-h),T=h-E,P=U*-Z,X=P-(P- -Z),F=-Z-X,L=T*F-(R-E*X-T*X-E*F),j=Q*-M,P=U*Q,E=P-(P-Q),T=Q-E,P=U*-M,X=P-(P- -M),F=-M-X,q=T*F-(j-E*X-T*X-E*F),b=L+q,y=b-L,wt[0]=L-(b-y)+(q-y),N=R+b,y=N-R,D=R-(N-y)+(b-y),b=D+j,y=b-D,wt[1]=D-(b-y)+(j-y),V=N+b,y=V-N,wt[2]=N-(V-y)+(b-y),wt[3]=V,k=ft(4,gt,4,wt,we),R=c*w,P=U*c,E=P-(P-c),T=c-E,P=U*w,X=P-(P-w),F=w-X,L=T*F-(R-E*X-T*X-E*F),j=h*M,P=U*h,E=P-(P-h),T=h-E,P=U*M,X=P-(P-M),F=M-X,q=T*F-(j-E*X-T*X-E*F),b=L-q,y=L-b,qt[0]=L-(b+y)+(y-q),N=R+b,y=N-R,D=R-(N-y)+(b-y),b=D-j,y=D-b,qt[1]=D-(b+y)+(y-j),V=N+b,y=V-N,qt[2]=N-(V-y)+(b-y),qt[3]=V,O=4):(we[0]=0,k=1,qt[0]=0,O=1),u!==0){const rt=$(k,we,u,it);l=at(l,ft($(I,Oe,u,K),K,$(rt,it,2*J,et),et,st),st);const ot=$(O,qt,u,z);l=at(l,Mt($(ot,z,2*J,K),K,$(ot,z,u,nt),nt,$(rt,it,u,et),et,$t,xt),xt),M!==0&&(l=at(l,$($(4,Pt,u,z),z,M,K),K)),w!==0&&(l=at(l,$($(4,It,-u,z),z,w,K),K))}if(p!==0){const rt=$(k,we,p,it);l=at(l,ft($(x,Be,p,K),K,$(rt,it,2*H,et),et,st),st);const ot=$(O,qt,p,z);l=at(l,Mt($(ot,z,2*H,K),K,$(ot,z,p,nt),nt,$(rt,it,p,et),et,$t,xt),xt)}}if(c!==0||M!==0){if(h!==0||w!==0||u!==0||p!==0?(R=h*H,P=U*h,E=P-(P-h),T=h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-(V-y)+(b-y),Vt[3]=V,A=4):(ge[0]=0,g=1,Vt[0]=0,A=1),h!==0){const rt=$(g,ge,h,it);l=at(l,ft($(d,Ce,h,K),K,$(rt,it,2*Q,et),et,st),st);const ot=$(A,Vt,h,z);l=at(l,Mt($(ot,z,2*Q,K),K,$(ot,z,h,nt),nt,$(rt,it,h,et),et,$t,xt),xt),p!==0&&(l=at(l,$($(4,It,h,z),z,p,K),K)),M!==0&&(l=at(l,$($(4,At,-h,z),z,M,K),K))}if(w!==0){const rt=$(g,ge,w,it);l=at(l,ft($(v,Xe,w,K),K,$(rt,it,2*W,et),et,st),st);const ot=$(A,Vt,w,z);l=at(l,Mt($(ot,z,2*W,K),K,$(ot,z,w,nt),nt,$(rt,it,w,et),et,$t,xt),xt)}}return Kt[l-1]}function fi(e,t,n,i,o,r,s,a){const f=e-s,l=n-s,u=o-s,c=t-a,h=i-a,p=r-a,M=l*p,w=u*h,I=f*f+c*c,x=u*c,m=f*p,_=l*l+h*h,d=f*h,v=l*c,g=u*u+p*p,k=I*(M-w)+_*(x-m)+g*(d-v),S=(Math.abs(M)+Math.abs(w))*I+(Math.abs(x)+Math.abs(m))*_+(Math.abs(d)+Math.abs(v))*g,A=si*S;return k>A||-k>A?k:li(e,t,n,i,o,r,s,a,S)}function hi(e,t){var n,i,o=0,r,s,a,f,l,u,c,h=e[0],p=e[1],M=t.length;for(n=0;n<M;n++){i=0;var w=t[n],I=w.length-1;if(u=w[0],u[0]!==w[I][0]&&u[1]!==w[I][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-h,a=u[1]-p,i;i<I;i++){if(c=w[i+1],f=c[0]-h,l=c[1]-p,a===0&&l===0){if(f<=0&&s>=0||s<=0&&f>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(r=Et(s,f,a,l,0,0),r===0)return 0;(r>0&&l>0&&a<=0||r<0&&l<=0&&a>0)&&o++}u=c,a=l,s=f}}return o%2!==0}function Fe(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ti(e),o=ei(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&ui(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var f=0;f<a.length;++f){const l=hi(i,a[f]);if(l===0&&!n.ignoreBoundary)return!0;if(l)return!0}return!1}function ui(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}class Ye{constructor(t=[],n=di){if(this.data=t,this.length=this.data.length,this.compare=n,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:n,compare:i}=this,o=n[t];for(;t>0;){const r=t-1>>1,s=n[r];if(i(o,s)>=0)break;n[t]=s,t=r}n[t]=o}_down(t){const{data:n,compare:i}=this,o=this.length>>1,r=n[t];for(;t<o;){let s=(t<<1)+1,a=n[s];const f=s+1;if(f<this.length&&i(n[f],a)<0&&(s=f,a=n[f]),i(a,r)>=0)break;n[t]=a,t=s}n[t]=r}}function di(e,t){return e<t?-1:e>t?1:0}const pi=Object.freeze(Object.defineProperty({__proto__:null,default:Ye},Symbol.toStringTag,{value:"Module"})),Nt=11102230246251565e-32,dt=134217729,mi=(3+8*Nt)*Nt;function Re(e,t,n,i,o){let r,s,a,f,l=t[0],u=i[0],c=0,h=0;u>l==u>-l?(r=l,l=t[++c]):(r=u,u=i[++h]);let p=0;if(c<e&&h<n)for(u>l==u>-l?(s=l+r,a=r-(s-l),l=t[++c]):(s=u+r,a=r-(s-u),u=i[++h]),r=s,a!==0&&(o[p++]=a);c<e&&h<n;)u>l==u>-l?(s=r+l,f=s-r,a=r-(s-f)+(l-f),l=t[++c]):(s=r+u,f=s-r,a=r-(s-f)+(u-f),u=i[++h]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+l,f=s-r,a=r-(s-f)+(l-f),l=t[++c],r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+u,f=s-r,a=r-(s-f)+(u-f),u=i[++h],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function gi(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function ee(e){return new Float64Array(e)}const wi=(3+16*Nt)*Nt,yi=(2+12*Nt)*Nt,vi=(9+64*Nt)*Nt*Nt,Qt=ee(4),an=ee(8),cn=ee(12),ln=ee(16),yt=ee(4);function bi(e,t,n,i,o,r,s){let a,f,l,u,c,h,p,M,w,I,x,m,_,d,v,g,k,S;const A=e-o,O=n-o,B=t-r,C=i-r;d=A*C,h=dt*A,p=h-(h-A),M=A-p,h=dt*C,w=h-(h-C),I=C-w,v=M*I-(d-p*w-M*w-p*I),g=B*O,h=dt*B,p=h-(h-B),M=B-p,h=dt*O,w=h-(h-O),I=O-w,k=M*I-(g-p*w-M*w-p*I),x=v-k,c=v-x,Qt[0]=v-(x+c)+(c-k),m=d+x,c=m-d,_=d-(m-c)+(x-c),x=_-g,c=_-x,Qt[1]=_-(x+c)+(c-g),S=m+x,c=S-m,Qt[2]=m-(S-c)+(x-c),Qt[3]=S;let Y=gi(4,Qt),y=yi*s;if(Y>=y||-Y>=y||(c=e-A,a=e-(A+c)+(c-o),c=n-O,l=n-(O+c)+(c-o),c=t-B,f=t-(B+c)+(c-r),c=i-C,u=i-(C+c)+(c-r),a===0&&f===0&&l===0&&u===0)||(y=vi*s+mi*Math.abs(Y),Y+=A*u+C*a-(B*l+O*f),Y>=y||-Y>=y))return Y;d=a*C,h=dt*a,p=h-(h-a),M=a-p,h=dt*C,w=h-(h-C),I=C-w,v=M*I-(d-p*w-M*w-p*I),g=f*O,h=dt*f,p=h-(h-f),M=f-p,h=dt*O,w=h-(h-O),I=O-w,k=M*I-(g-p*w-M*w-p*I),x=v-k,c=v-x,yt[0]=v-(x+c)+(c-k),m=d+x,c=m-d,_=d-(m-c)+(x-c),x=_-g,c=_-x,yt[1]=_-(x+c)+(c-g),S=m+x,c=S-m,yt[2]=m-(S-c)+(x-c),yt[3]=S;const P=Re(4,Qt,4,yt,an);d=A*u,h=dt*A,p=h-(h-A),M=A-p,h=dt*u,w=h-(h-u),I=u-w,v=M*I-(d-p*w-M*w-p*I),g=B*l,h=dt*B,p=h-(h-B),M=B-p,h=dt*l,w=h-(h-l),I=l-w,k=M*I-(g-p*w-M*w-p*I),x=v-k,c=v-x,yt[0]=v-(x+c)+(c-k),m=d+x,c=m-d,_=d-(m-c)+(x-c),x=_-g,c=_-x,yt[1]=_-(x+c)+(c-g),S=m+x,c=S-m,yt[2]=m-(S-c)+(x-c),yt[3]=S;const E=Re(P,an,4,yt,cn);d=a*u,h=dt*a,p=h-(h-a),M=a-p,h=dt*u,w=h-(h-u),I=u-w,v=M*I-(d-p*w-M*w-p*I),g=f*l,h=dt*f,p=h-(h-f),M=f-p,h=dt*l,w=h-(h-l),I=l-w,k=M*I-(g-p*w-M*w-p*I),x=v-k,c=v-x,yt[0]=v-(x+c)+(c-k),m=d+x,c=m-d,_=d-(m-c)+(x-c),x=_-g,c=_-x,yt[1]=_-(x+c)+(c-g),S=m+x,c=S-m,yt[2]=m-(S-c)+(x-c),yt[3]=S;const T=Re(E,cn,4,yt,ln);return ln[T-1]}function fn(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),f=s-a;if(s===0||a===0||s>0!=a>0)return f;const l=Math.abs(s+a);return Math.abs(f)>=wi*l?f:-bi(e,t,n,i,o,r,l)}function xi(e,t){const n=new Ye([],hn);return Mi(e,n),Si(n,t)}function hn(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x||e.p.x===t.p.x&&(e.featureId!==t.featureId||e.ringId!==t.ringId)&&e.isLeftEndpoint&&!t.isLeftEndpoint?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function _i(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}function Mi(e,t){if(e.type==="FeatureCollection"){const n=e.features;for(let i=0;i<n.length;i++)un(n[i],t)}else un(e,t)}var ve=0,be=0,xe=0;function un(e,t){const n=e.type==="Feature"?e.geometry:e;let i=n.coordinates;(n.type==="Polygon"||n.type==="MultiLineString")&&(i=[i]),n.type==="LineString"&&(i=[[i]]);for(let o=0;o<i.length;o++)for(let r=0;r<i[o].length;r++){let s=i[o][r][0],a=null;be=be+1;for(let f=0;f<i[o][r].length-1;f++){a=i[o][r][f+1];const l=new dn(s,ve,be,xe),u=new dn(a,ve,be,xe+1);l.otherEvent=u,u.otherEvent=l,hn(l,u)>0?(u.isLeftEndpoint=!0,l.isLeftEndpoint=!1):(l.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(l),t.push(u),s=a,xe=xe+1}}ve=ve+1}var dn=class{constructor(e,t,n,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=n,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}asNewXY(){return[this.p.x,this.p.y]}};function Si(e,t=!1){const n=[],i=new Ye([],_i);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const r=new ki(o);for(let s=0;s<i.data.length;s++){const a=i.data[s];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const f=Ei(r,a);f!==!1&&n.push(f)}i.push(r)}else o.isLeftEndpoint===!1&&i.pop()}return n}var ki=class{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}};function Ei(e,t){if(e===null||t===null)return!1;const n=e.leftSweepEvent.p.x,i=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,r=e.rightSweepEvent.p.y,s=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,f=t.rightSweepEvent.p.x,l=t.rightSweepEvent.p.y,u=fn(n,i,o,r,s,a),c=fn(n,i,o,r,f,l);if(u>0&&c>0)return!1;if(u<0&&c<0)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId){if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return!1}else{if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.rightSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY()}const h=(l-a)*(o-n)-(f-s)*(r-i),p=(f-s)*(i-a)-(l-a)*(n-s),M=(o-n)*(i-a)-(r-i)*(n-s);if(h===0)return!1;const w=p/h,I=M/h;if(w>=0&&w<=1&&I>=0&&I<=1){const x=n+w*(o-n),m=i+w*(r-i);return[x,m]}return!1}function Ai(e,t,n={}){const{removeDuplicates:i=!0,ignoreSelfIntersections:o=!0}=n;let r=[];e.type==="FeatureCollection"?r=r.concat(e.features):e.type==="Feature"?r.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&r.push(Bt(e)),t.type==="FeatureCollection"?r=r.concat(t.features):t.type==="Feature"?r.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&r.push(Bt(t));const s=xi(St(r),o);let a=[];if(i){const f={};s.forEach(l=>{const u=l.join(",");f[u]||(f[u]=!0,a.push(l))})}else a=s;return St(a.map(f=>Dt(f)))}function Ii(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Pi(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function i(){var o=!1;try{o=this instanceof i}catch{}return o?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}),n}function Oi(e,t={}){let n=0,i=0,o=0;return Pe(e,function(r){n+=r[0],i+=r[1],o++},!0),Dt([n/o,i/o],t.properties)}var _e={exports:{}},Me={exports:{}},Bi=Me.exports,pn;function Ni(){return pn||(pn=1,(function(e,t){(function(n,i){e.exports=i()})(Bi,function(){function n(m,_,d,v,g){(function k(S,A,O,B,C){for(;B>O;){if(B-O>600){var Y=B-O+1,y=A-O+1,P=Math.log(Y),E=.5*Math.exp(2*P/3),T=.5*Math.sqrt(P*E*(Y-E)/Y)*(y-Y/2<0?-1:1),X=Math.max(O,Math.floor(A-y*E/Y+T)),F=Math.min(B,Math.floor(A+(Y-y)*E/Y+T));k(S,A,X,F,C)}var b=S[A],N=O,D=B;for(i(S,O,A),C(S[B],b)>0&&i(S,O,B);N<D;){for(i(S,N,D),N++,D--;C(S[N],b)<0;)N++;for(;C(S[D],b)>0;)D--}C(S[O],b)===0?i(S,O,D):i(S,++D,B),D<=A&&(O=D+1),A<=D&&(B=D-1)}})(m,_,d||0,v||m.length-1,g||o)}function i(m,_,d){var v=m[_];m[_]=m[d],m[d]=v}function o(m,_){return m<_?-1:m>_?1:0}var r=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,_,d){if(!d)return _.indexOf(m);for(var v=0;v<_.length;v++)if(d(m,_[v]))return v;return-1}function a(m,_){f(m,0,m.children.length,_,m)}function f(m,_,d,v,g){g||(g=I(null)),g.minX=1/0,g.minY=1/0,g.maxX=-1/0,g.maxY=-1/0;for(var k=_;k<d;k++){var S=m.children[k];l(g,m.leaf?v(S):S)}return g}function l(m,_){return m.minX=Math.min(m.minX,_.minX),m.minY=Math.min(m.minY,_.minY),m.maxX=Math.max(m.maxX,_.maxX),m.maxY=Math.max(m.maxY,_.maxY),m}function u(m,_){return m.minX-_.minX}function c(m,_){return m.minY-_.minY}function h(m){return(m.maxX-m.minX)*(m.maxY-m.minY)}function p(m){return m.maxX-m.minX+(m.maxY-m.minY)}function M(m,_){return m.minX<=_.minX&&m.minY<=_.minY&&_.maxX<=m.maxX&&_.maxY<=m.maxY}function w(m,_){return _.minX<=m.maxX&&_.minY<=m.maxY&&_.maxX>=m.minX&&_.maxY>=m.minY}function I(m){return{children:m,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function x(m,_,d,v,g){for(var k=[_,d];k.length;)if(!((d=k.pop())-(_=k.pop())<=v)){var S=_+Math.ceil((d-_)/v/2)*v;n(m,S,_,d,g),k.push(_,S,S,d)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(m){var _=this.data,d=[];if(!w(m,_))return d;for(var v=this.toBBox,g=[];_;){for(var k=0;k<_.children.length;k++){var S=_.children[k],A=_.leaf?v(S):S;w(m,A)&&(_.leaf?d.push(S):M(m,A)?this._all(S,d):g.push(S))}_=g.pop()}return d},r.prototype.collides=function(m){var _=this.data;if(!w(m,_))return!1;for(var d=[];_;){for(var v=0;v<_.children.length;v++){var g=_.children[v],k=_.leaf?this.toBBox(g):g;if(w(m,k)){if(_.leaf||M(m,k))return!0;d.push(g)}}_=d.pop()}return!1},r.prototype.load=function(m){if(!m||!m.length)return this;if(m.length<this._minEntries){for(var _=0;_<m.length;_++)this.insert(m[_]);return this}var d=this._build(m.slice(),0,m.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var v=this.data;this.data=d,d=v}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},r.prototype.insert=function(m){return m&&this._insert(m,this.data.height-1),this},r.prototype.clear=function(){return this.data=I([]),this},r.prototype.remove=function(m,_){if(!m)return this;for(var d,v,g,k=this.data,S=this.toBBox(m),A=[],O=[];k||A.length;){if(k||(k=A.pop(),v=A[A.length-1],d=O.pop(),g=!0),k.leaf){var B=s(m,k.children,_);if(B!==-1)return k.children.splice(B,1),A.push(k),this._condense(A),this}g||k.leaf||!M(k,S)?v?(d++,k=v.children[d],g=!1):k=null:(A.push(k),O.push(d),d=0,v=k,k=k.children[0])}return this},r.prototype.toBBox=function(m){return m},r.prototype.compareMinX=function(m,_){return m.minX-_.minX},r.prototype.compareMinY=function(m,_){return m.minY-_.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(m){return this.data=m,this},r.prototype._all=function(m,_){for(var d=[];m;)m.leaf?_.push.apply(_,m.children):d.push.apply(d,m.children),m=d.pop();return _},r.prototype._build=function(m,_,d,v){var g,k=d-_+1,S=this._maxEntries;if(k<=S)return a(g=I(m.slice(_,d+1)),this.toBBox),g;v||(v=Math.ceil(Math.log(k)/Math.log(S)),S=Math.ceil(k/Math.pow(S,v-1))),(g=I([])).leaf=!1,g.height=v;var A=Math.ceil(k/S),O=A*Math.ceil(Math.sqrt(S));x(m,_,d,O,this.compareMinX);for(var B=_;B<=d;B+=O){var C=Math.min(B+O-1,d);x(m,B,C,A,this.compareMinY);for(var Y=B;Y<=C;Y+=A){var y=Math.min(Y+A-1,C);g.children.push(this._build(m,Y,y,v-1))}}return a(g,this.toBBox),g},r.prototype._chooseSubtree=function(m,_,d,v){for(;v.push(_),!_.leaf&&v.length-1!==d;){for(var g=1/0,k=1/0,S=void 0,A=0;A<_.children.length;A++){var O=_.children[A],B=h(O),C=(Y=m,y=O,(Math.max(y.maxX,Y.maxX)-Math.min(y.minX,Y.minX))*(Math.max(y.maxY,Y.maxY)-Math.min(y.minY,Y.minY))-B);C<k?(k=C,g=B<g?B:g,S=O):C===k&&B<g&&(g=B,S=O)}_=S||_.children[0]}var Y,y;return _},r.prototype._insert=function(m,_,d){var v=d?m:this.toBBox(m),g=[],k=this._chooseSubtree(v,this.data,_,g);for(k.children.push(m),l(k,v);_>=0&&g[_].children.length>this._maxEntries;)this._split(g,_),_--;this._adjustParentBBoxes(v,g,_)},r.prototype._split=function(m,_){var d=m[_],v=d.children.length,g=this._minEntries;this._chooseSplitAxis(d,g,v);var k=this._chooseSplitIndex(d,g,v),S=I(d.children.splice(k,d.children.length-k));S.height=d.height,S.leaf=d.leaf,a(d,this.toBBox),a(S,this.toBBox),_?m[_-1].children.push(S):this._splitRoot(d,S)},r.prototype._splitRoot=function(m,_){this.data=I([m,_]),this.data.height=m.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(m,_,d){for(var v,g,k,S,A,O,B,C=1/0,Y=1/0,y=_;y<=d-_;y++){var P=f(m,0,y,this.toBBox),E=f(m,y,d,this.toBBox),T=(g=P,k=E,S=void 0,A=void 0,O=void 0,B=void 0,S=Math.max(g.minX,k.minX),A=Math.max(g.minY,k.minY),O=Math.min(g.maxX,k.maxX),B=Math.min(g.maxY,k.maxY),Math.max(0,O-S)*Math.max(0,B-A)),X=h(P)+h(E);T<C?(C=T,v=y,Y=X<Y?X:Y):T===C&&X<Y&&(Y=X,v=y)}return v||d-_},r.prototype._chooseSplitAxis=function(m,_,d){var v=m.leaf?this.compareMinX:u,g=m.leaf?this.compareMinY:c;this._allDistMargin(m,_,d,v)<this._allDistMargin(m,_,d,g)&&m.children.sort(v)},r.prototype._allDistMargin=function(m,_,d,v){m.children.sort(v);for(var g=this.toBBox,k=f(m,0,_,g),S=f(m,d-_,d,g),A=p(k)+p(S),O=_;O<d-_;O++){var B=m.children[O];l(k,m.leaf?g(B):B),A+=p(k)}for(var C=d-_-1;C>=_;C--){var Y=m.children[C];l(S,m.leaf?g(Y):Y),A+=p(S)}return A},r.prototype._adjustParentBBoxes=function(m,_,d){for(var v=d;v>=0;v--)l(_[v],m)},r.prototype._condense=function(m){for(var _=m.length-1,d=void 0;_>=0;_--)m[_].children.length===0?_>0?(d=m[_-1].children).splice(d.indexOf(m[_]),1):this.clear():a(m[_],this.toBBox)},r})})(Me)),Me.exports}const Ti=Pi(pi);var ne={exports:{}},$e,mn;function Ci(){return mn||(mn=1,$e=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var f=(o-i)/2,l=0,u=f-1;l<f;u=l++){var c=n[i+l*2+0],h=n[i+l*2+1],p=n[i+u*2+0],M=n[i+u*2+1],w=h>s!=M>s&&r<(p-c)*(s-h)/(M-h)+c;w&&(a=!a)}return a}),$e}var Le,gn;function Xi(){return gn||(gn=1,Le=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var f=o-i,l=0,u=f-1;l<f;u=l++){var c=n[l+i][0],h=n[l+i][1],p=n[u+i][0],M=n[u+i][1],w=h>s!=M>s&&r<(p-c)*(s-h)/(M-h)+c;w&&(a=!a)}return a}),Le}var wn;function Di(){if(wn)return ne.exports;wn=1;var e=Ci(),t=Xi();return ne.exports=function(i,o,r,s){return o.length>0&&Array.isArray(o[0])?t(i,o,r,s):e(i,o,r,s)},ne.exports.nested=t,ne.exports.flat=e,ne.exports}var ie={exports:{}},Fi=ie.exports,yn;function Yi(){return yn||(yn=1,(function(e,t){(function(n,i){i(t)})(Fi,function(n){const o=33306690738754706e-32;function r(w,I,x,m,_){let d,v,g,k,S=I[0],A=m[0],O=0,B=0;A>S==A>-S?(d=S,S=I[++O]):(d=A,A=m[++B]);let C=0;if(O<w&&B<x)for(A>S==A>-S?(g=d-((v=S+d)-S),S=I[++O]):(g=d-((v=A+d)-A),A=m[++B]),d=v,g!==0&&(_[C++]=g);O<w&&B<x;)A>S==A>-S?(g=d-((v=d+S)-(k=v-d))+(S-k),S=I[++O]):(g=d-((v=d+A)-(k=v-d))+(A-k),A=m[++B]),d=v,g!==0&&(_[C++]=g);for(;O<w;)g=d-((v=d+S)-(k=v-d))+(S-k),S=I[++O],d=v,g!==0&&(_[C++]=g);for(;B<x;)g=d-((v=d+A)-(k=v-d))+(A-k),A=m[++B],d=v,g!==0&&(_[C++]=g);return d===0&&C!==0||(_[C++]=d),C}function s(w){return new Float64Array(w)}const a=33306690738754716e-32,f=22204460492503146e-32,l=11093356479670487e-47,u=s(4),c=s(8),h=s(12),p=s(16),M=s(4);n.orient2d=function(w,I,x,m,_,d){const v=(I-d)*(x-_),g=(w-_)*(m-d),k=v-g;if(v===0||g===0||v>0!=g>0)return k;const S=Math.abs(v+g);return Math.abs(k)>=a*S?k:-(function(A,O,B,C,Y,y,P){let E,T,X,F,b,N,D,R,L,j,q,V,J,G,Q,H,Z,W;const ct=A-Y,ht=B-Y,rt=O-y,ot=C-y;b=(Q=(R=ct-(D=(N=134217729*ct)-(N-ct)))*(j=ot-(L=(N=134217729*ot)-(N-ot)))-((G=ct*ot)-D*L-R*L-D*j))-(q=Q-(Z=(R=rt-(D=(N=134217729*rt)-(N-rt)))*(j=ht-(L=(N=134217729*ht)-(N-ht)))-((H=rt*ht)-D*L-R*L-D*j))),u[0]=Q-(q+b)+(b-Z),b=(J=G-((V=G+q)-(b=V-G))+(q-b))-(q=J-H),u[1]=J-(q+b)+(b-H),b=(W=V+q)-V,u[2]=V-(W-b)+(q-b),u[3]=W;let jt=(function(ho,Wn){let Zn=Wn[0];for(let We=1;We<ho;We++)Zn+=Wn[We];return Zn})(4,u),me=f*P;if(jt>=me||-jt>=me||(E=A-(ct+(b=A-ct))+(b-Y),X=B-(ht+(b=B-ht))+(b-Y),T=O-(rt+(b=O-rt))+(b-y),F=C-(ot+(b=C-ot))+(b-y),E===0&&T===0&&X===0&&F===0)||(me=l*P+o*Math.abs(jt),(jt+=ct*F+ot*E-(rt*X+ht*T))>=me||-jt>=me))return jt;b=(Q=(R=E-(D=(N=134217729*E)-(N-E)))*(j=ot-(L=(N=134217729*ot)-(N-ot)))-((G=E*ot)-D*L-R*L-D*j))-(q=Q-(Z=(R=T-(D=(N=134217729*T)-(N-T)))*(j=ht-(L=(N=134217729*ht)-(N-ht)))-((H=T*ht)-D*L-R*L-D*j))),M[0]=Q-(q+b)+(b-Z),b=(J=G-((V=G+q)-(b=V-G))+(q-b))-(q=J-H),M[1]=J-(q+b)+(b-H),b=(W=V+q)-V,M[2]=V-(W-b)+(q-b),M[3]=W;const co=r(4,u,4,M,c);b=(Q=(R=ct-(D=(N=134217729*ct)-(N-ct)))*(j=F-(L=(N=134217729*F)-(N-F)))-((G=ct*F)-D*L-R*L-D*j))-(q=Q-(Z=(R=rt-(D=(N=134217729*rt)-(N-rt)))*(j=X-(L=(N=134217729*X)-(N-X)))-((H=rt*X)-D*L-R*L-D*j))),M[0]=Q-(q+b)+(b-Z),b=(J=G-((V=G+q)-(b=V-G))+(q-b))-(q=J-H),M[1]=J-(q+b)+(b-H),b=(W=V+q)-V,M[2]=V-(W-b)+(q-b),M[3]=W;const lo=r(co,c,4,M,h);b=(Q=(R=E-(D=(N=134217729*E)-(N-E)))*(j=F-(L=(N=134217729*F)-(N-F)))-((G=E*F)-D*L-R*L-D*j))-(q=Q-(Z=(R=T-(D=(N=134217729*T)-(N-T)))*(j=X-(L=(N=134217729*X)-(N-X)))-((H=T*X)-D*L-R*L-D*j))),M[0]=Q-(q+b)+(b-Z),b=(J=G-((V=G+q)-(b=V-G))+(q-b))-(q=J-H),M[1]=J-(q+b)+(b-H),b=(W=V+q)-V,M[2]=V-(W-b)+(q-b),M[3]=W;const fo=r(lo,h,4,M,p);return p[fo-1]})(w,I,x,m,_,d,S)},n.orient2dfast=function(w,I,x,m,_,d){return(I-d)*(x-_)-(w-_)*(m-d)},Object.defineProperty(n,"__esModule",{value:!0})})})(ie,ie.exports)),ie.exports}var vn;function Ri(){if(vn)return _e.exports;vn=1;var e=Ni(),t=Ti,n=Di(),i=Yi().orient2d;t.default&&(t=t.default),_e.exports=o,_e.exports.default=o;function o(d,v,g){v=Math.max(0,v===void 0?2:v),g=g||0;var k=p(d),S=new e(16);S.toBBox=function(D){return{minX:D[0],minY:D[1],maxX:D[0],maxY:D[1]}},S.compareMinX=function(D,R){return D[0]-R[0]},S.compareMinY=function(D,R){return D[1]-R[1]},S.load(d);for(var A=[],O=0,B;O<k.length;O++){var C=k[O];S.remove(C),B=M(C,B),A.push(B)}var Y=new e(16);for(O=0;O<A.length;O++)Y.insert(h(A[O]));for(var y=v*v,P=g*g;A.length;){var E=A.shift(),T=E.p,X=E.next.p,F=w(T,X);if(!(F<P)){var b=F/y;C=r(S,E.prev.p,T,X,E.next.next.p,b,Y),C&&Math.min(w(C,T),w(C,X))<=b&&(A.push(E),A.push(M(C,E)),S.remove(C),Y.remove(E),Y.insert(h(E)),Y.insert(h(E.next)))}}E=B;var N=[];do N.push(E.p),E=E.next;while(E!==B);return N.push(E.p),N}function r(d,v,g,k,S,A,O){for(var B=new t([],s),C=d.data;C;){for(var Y=0;Y<C.children.length;Y++){var y=C.children[Y],P=C.leaf?I(y,g,k):a(g,k,y);P>A||B.push({node:y,dist:P})}for(;B.length&&!B.peek().node.children;){var E=B.pop(),T=E.node,X=I(T,v,g),F=I(T,k,S);if(E.dist<X&&E.dist<F&&l(g,T,O)&&l(k,T,O))return T}C=B.pop(),C&&(C=C.node)}return null}function s(d,v){return d.dist-v.dist}function a(d,v,g){if(f(d,g)||f(v,g))return 0;var k=x(d[0],d[1],v[0],v[1],g.minX,g.minY,g.maxX,g.minY);if(k===0)return 0;var S=x(d[0],d[1],v[0],v[1],g.minX,g.minY,g.minX,g.maxY);if(S===0)return 0;var A=x(d[0],d[1],v[0],v[1],g.maxX,g.minY,g.maxX,g.maxY);if(A===0)return 0;var O=x(d[0],d[1],v[0],v[1],g.minX,g.maxY,g.maxX,g.maxY);return O===0?0:Math.min(k,S,A,O)}function f(d,v){return d[0]>=v.minX&&d[0]<=v.maxX&&d[1]>=v.minY&&d[1]<=v.maxY}function l(d,v,g){for(var k=Math.min(d[0],v[0]),S=Math.min(d[1],v[1]),A=Math.max(d[0],v[0]),O=Math.max(d[1],v[1]),B=g.search({minX:k,minY:S,maxX:A,maxY:O}),C=0;C<B.length;C++)if(c(B[C].p,B[C].next.p,d,v))return!1;return!0}function u(d,v,g){return i(d[0],d[1],v[0],v[1],g[0],g[1])}function c(d,v,g,k){return d!==k&&v!==g&&u(d,v,g)>0!=u(d,v,k)>0&&u(g,k,d)>0!=u(g,k,v)>0}function h(d){var v=d.p,g=d.next.p;return d.minX=Math.min(v[0],g[0]),d.minY=Math.min(v[1],g[1]),d.maxX=Math.max(v[0],g[0]),d.maxY=Math.max(v[1],g[1]),d}function p(d){for(var v=d[0],g=d[0],k=d[0],S=d[0],A=0;A<d.length;A++){var O=d[A];O[0]<v[0]&&(v=O),O[0]>k[0]&&(k=O),O[1]<g[1]&&(g=O),O[1]>S[1]&&(S=O)}var B=[v,g,k,S],C=B.slice();for(A=0;A<d.length;A++)n(d[A],B)||C.push(d[A]);return _(C)}function M(d,v){var g={p:d,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return v?(g.next=v.next,g.prev=v,v.next.prev=g,v.next=g):(g.prev=g,g.next=g),g}function w(d,v){var g=d[0]-v[0],k=d[1]-v[1];return g*g+k*k}function I(d,v,g){var k=v[0],S=v[1],A=g[0]-k,O=g[1]-S;if(A!==0||O!==0){var B=((d[0]-k)*A+(d[1]-S)*O)/(A*A+O*O);B>1?(k=g[0],S=g[1]):B>0&&(k+=A*B,S+=O*B)}return A=d[0]-k,O=d[1]-S,A*A+O*O}function x(d,v,g,k,S,A,O,B){var C=g-d,Y=k-v,y=O-S,P=B-A,E=d-S,T=v-A,X=C*C+Y*Y,F=C*y+Y*P,b=y*y+P*P,N=C*E+Y*T,D=y*E+P*T,R=X*b-F*F,L,j,q,V,J=R,G=R;R===0?(j=0,J=1,V=D,G=b):(j=F*D-b*N,V=X*D-F*N,j<0?(j=0,V=D,G=b):j>J&&(j=J,V=D+F,G=b)),V<0?(V=0,-N<0?j=0:-N>X?j=J:(j=-N,J=X)):V>G&&(V=G,-N+F<0?j=0:-N+F>X?j=J:(j=-N+F,J=X)),L=j===0?0:j/J,q=V===0?0:V/G;var Q=(1-L)*d+L*g,H=(1-L)*v+L*k,Z=(1-q)*S+q*O,W=(1-q)*A+q*B,ct=Z-Q,ht=W-H;return ct*ct+ht*ht}function m(d,v){return d[0]===v[0]?d[1]-v[1]:d[0]-v[0]}function _(d){d.sort(m);for(var v=[],g=0;g<d.length;g++){for(;v.length>=2&&u(v[v.length-2],v[v.length-1],d[g])<=0;)v.pop();v.push(d[g])}for(var k=[],S=d.length-1;S>=0;S--){for(;k.length>=2&&u(k[k.length-2],k[k.length-1],d[S])<=0;)k.pop();k.push(d[S])}return k.pop(),v.pop(),v.concat(k)}return _e.exports}var $i=Ri();const Li=Ii($i);function bn(e,t={}){t.concavity=t.concavity||1/0;const n=[];if(Pe(e,o=>{n.push([o[0],o[1]])}),!n.length)return null;const i=Li(n,t.concavity);return i.length>3?te([i],t.properties):null}function xn(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function re(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Mn(e[0])||!Mn(e[1]))throw new Error("coordinates must contain numbers");return xn({type:"Point",coordinates:e},t,n)}function _n(e,t,n={}){for(const i of e){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 o=0;o<i[i.length-1].length;o++)if(i[i.length-1][o]!==i[0][o])throw new Error("First and last Position are not equivalent.")}return xn({type:"Polygon",coordinates:e},t,n)}function Ht(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function Mn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ji(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Sn(e){if(Array.isArray(e))return e;if(e.type==="Feature"){if(e.geometry!==null)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Vi(e){return e.type==="Feature"?e.geometry:e}const Tt=11102230246251565e-32,pt=134217729,qi=(3+8*Tt)*Tt;function je(e,t,n,i,o){let r,s,a,f,l=t[0],u=i[0],c=0,h=0;u>l==u>-l?(r=l,l=t[++c]):(r=u,u=i[++h]);let p=0;if(c<e&&h<n)for(u>l==u>-l?(s=l+r,a=r-(s-l),l=t[++c]):(s=u+r,a=r-(s-u),u=i[++h]),r=s,a!==0&&(o[p++]=a);c<e&&h<n;)u>l==u>-l?(s=r+l,f=s-r,a=r-(s-f)+(l-f),l=t[++c]):(s=r+u,f=s-r,a=r-(s-f)+(u-f),u=i[++h]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+l,f=s-r,a=r-(s-f)+(l-f),l=t[++c],r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+u,f=s-r,a=r-(s-f)+(u-f),u=i[++h],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Ui(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function oe(e){return new Float64Array(e)}const zi=(3+16*Tt)*Tt,Gi=(2+12*Tt)*Tt,Ji=(9+64*Tt)*Tt*Tt,Wt=oe(4),kn=oe(8),En=oe(12),An=oe(16),vt=oe(4);function Ki(e,t,n,i,o,r,s){let a,f,l,u,c,h,p,M,w,I,x,m,_,d,v,g,k,S;const A=e-o,O=n-o,B=t-r,C=i-r;d=A*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[3]=S;const E=je(P,kn,4,vt,En);d=a*u,h=pt*a,p=h-(h-a),M=a-p,h=pt*u,w=h-(h-u),I=u-w,v=M*I-(d-p*w-M*w-p*I),g=f*l,h=pt*f,p=h-(h-f),M=f-p,h=pt*l,w=h-(h-l),I=l-w,k=M*I-(g-p*w-M*w-p*I),x=v-k,c=v-x,vt[0]=v-(x+c)+(c-k),m=d+x,c=m-d,_=d-(m-c)+(x-c),x=_-g,c=_-x,vt[1]=_-(x+c)+(c-g),S=m+x,c=S-m,vt[2]=m-(S-c)+(x-c),vt[3]=S;const T=je(E,En,4,vt,An);return An[T-1]}function Qi(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),f=s-a,l=Math.abs(s+a);return Math.abs(f)>=zi*l?f:-Ki(e,t,n,i,o,r,l)}function Hi(e,t){var n,i,o=0,r,s,a,f,l,u,c,h=e[0],p=e[1],M=t.length;for(n=0;n<M;n++){i=0;var w=t[n],I=w.length-1;if(u=w[0],u[0]!==w[I][0]&&u[1]!==w[I][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-h,a=u[1]-p,i;i<I;i++){if(c=w[i+1],f=c[0]-h,l=c[1]-p,a===0&&l===0){if(f<=0&&s>=0||s<=0&&f>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(r=Qi(s,f,a,l,0,0),r===0)return 0;(r>0&&l>0&&a<=0||r<0&&l<=0&&a>0)&&o++}u=c,a=l,s=f}}return o%2!==0}function Ve(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ji(e),o=Vi(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&Wi(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var f=0;f<a.length;++f){const l=Hi(i,a[f]);if(l===0&&!n.ignoreBoundary||l)return!0}return!1}function Wi(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}function qe(e,t){for(let n=0;n<t.features.length;n++)if(Ve(e,t.features[n]))return t.features[n]}function In(e,t){const n=t.geometry.coordinates[0][0],i=t.geometry.coordinates[0][1],o=t.geometry.coordinates[0][2],r=e.geometry.coordinates,s=t.properties.a.geom,a=t.properties.b.geom,f=t.properties.c.geom,l=[i[0]-n[0],i[1]-n[1]],u=[o[0]-n[0],o[1]-n[1]],c=[r[0]-n[0],r[1]-n[1]],h=[a[0]-s[0],a[1]-s[1]],p=[f[0]-s[0],f[1]-s[1]],M=(u[1]*c[0]-u[0]*c[1])/(l[0]*u[1]-l[1]*u[0]),w=(l[0]*c[1]-l[1]*c[0])/(l[0]*u[1]-l[1]*u[0]);return[M*h[0]+w*p[0]+s[0],M*h[1]+w*p[1]+s[1]]}function Zi(e,t,n){const i=e.geometry.coordinates,o=n.geometry.coordinates,r=Math.atan2(i[0]-o[0],i[1]-o[1]),s=tr(r,t[0]);if(s===void 0)throw new Error("Unable to determine vertex index");const a=t[1][s];return In(e,a.features[0])}function se(e,t,n,i,o,r,s,a){let f;if(s&&(f=qe(e,Ht([s]))),!f)if(n){const l=e.geometry.coordinates,u=n.gridNum,c=n.xOrigin,h=n.yOrigin,p=n.xUnit,M=n.yUnit,w=n.gridCache,I=Ot(l[0],c,p,u),x=Ot(l[1],h,M,u),m=w[I]?w[I][x]?w[I][x]:[]:[],_=Ht(m.map(d=>t.features[d]));f=qe(e,_)}else f=qe(e,t);return a&&a(f),f?In(e,f):Zi(e,i,o)}function Ot(e,t,n,i){let o=Math.floor((e-t)/n);return o<0&&(o=0),o>=i&&(o=i-1),o}function tr(e,t){let n=Pn(e-t[0]),i=Math.PI*2,o;for(let r=0;r<t.length;r++){const s=(r+1)%t.length,a=Pn(e-t[s]),f=Math.min(Math.abs(n),Math.abs(a));n*a<=0&&f<i&&(i=f,o=r),n=a}return o}function Pn(e,t=!1){const n=2*Math.PI,i=e-Math.floor(e/n)*n;return t?i:i>Math.PI?i-n:i}function On(e){const t=e.features;for(let n=0;n<t.length;n++){const i=t[n];`${i.properties.a.index}`.substring(0,1)==="b"&&`${i.properties.b.index}`.substring(0,1)==="b"?t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1],i.geometry.coordinates[0][2]]]},properties:{a:{geom:i.properties.c.geom,index:i.properties.c.index},b:{geom:i.properties.a.geom,index:i.properties.a.index},c:{geom:i.properties.b.geom,index:i.properties.b.index}},type:"Feature"}:`${i.properties.c.index}`.substring(0,1)==="b"&&`${i.properties.a.index}`.substring(0,1)==="b"&&(t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][1],i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1]]]},properties:{a:{geom:i.properties.b.geom,index:i.properties.b.index},b:{geom:i.properties.c.geom,index:i.properties.c.index},c:{geom:i.properties.a.geom,index:i.properties.a.index}},type:"Feature"})}return e}function Bn(e){const t=["a","b","c","a"].map(r=>e.properties[r].geom),n=e.geometry.coordinates[0],i=e.properties,o={a:{geom:n[0],index:i.a.index},b:{geom:n[1],index:i.b.index},c:{geom:n[2],index:i.c.index}};return _n([t],o)}function er(e){const t=[0,1,2,0].map(i=>e[i][0][0]),n={a:{geom:e[0][0][1],index:e[0][1]},b:{geom:e[1][0][1],index:e[1][1]},c:{geom:e[2][0][1],index:e[2][1]}};return _n([t],n)}function Ue(e,t,n,i,o,r=!1,s){const a=e.map(f=>{(!s||s<2.00703)&&(f=nr(f));const l=isFinite(f)?t[f]:f==="c"?i:(function(){const u=f.match(/^b(\d+)$/);if(u)return o[parseInt(u[1])];const c=f.match(/^e(\d+)$/);if(c)return n[parseInt(c[1])];throw new Error("Bad index value for indexesToTri")})();return r?[[l[1],l[0]],f]:[[l[0],l[1]],f]});return er(a)}function nr(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function Nn(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(n=>[n.illstNodes,n.mercNodes,n.startEnd])}const ir=2.00704;function rr(e){return!!(e.version!==void 0||!e.tins&&e.points&&e.tins_points)}function or(e){return{points:e.points,strictStatus:ar(e),verticesParams:cr(e),centroid:lr(e),edges:Nn(e.edges||[]),edgeNodes:e.edgeNodes||[],tins:fr(e),kinks:hr(e.kinks_points),yaxisMode:e.yaxisMode??"invert",strictMode:e.strictMode??"auto",vertexMode:e.vertexMode,bounds:e.bounds,boundsPolygon:e.boundsPolygon,wh:e.wh,xy:e.xy??[0,0]}}function sr(e){const t=ur(e),n=t.tins;return{compiled:t,tins:n,points:dr(n),strictStatus:t.strict_status,verticesParams:t.vertices_params,centroid:t.centroid,kinks:t.kinks}}function ar(e){return e.strict_status?e.strict_status:e.kinks_points?"strict_error":e.tins_points.length===2?"loose":"strict"}function cr(e){const t={forw:[e.vertices_params[0]],bakw:[e.vertices_params[1]]};return t.forw[1]=Tn(e,!1),t.bakw[1]=Tn(e,!0),t}function Tn(e,t){const n=e.vertices_points.length;return Array.from({length:n},(i,o)=>{const r=(o+1)%n,s=Ue(["c",`b${o}`,`b${r}`],e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,t,ir);return Ht([s])})}function lr(e){return{forw:re(e.centroid_point[0],{target:{geom:e.centroid_point[1],index:"c"}}),bakw:re(e.centroid_point[1],{target:{geom:e.centroid_point[0],index:"c"}})}}function fr(e){const t=e.tins_points.length===1?0:1;return{forw:Ht(e.tins_points[0].map(n=>Ue(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!1,e.version))),bakw:Ht(e.tins_points[t].map(n=>Ue(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!0,e.version)))}}function hr(e){if(e)return{bakw:Ht(e.map(t=>re(t)))}}function ur(e){return JSON.parse(JSON.stringify(e).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function dr(e){const t=[],n=e.forw.features;for(let i=0;i<n.length;i++){const o=n[i];["a","b","c"].forEach((r,s)=>{const a=o.geometry.coordinates[0][s],f=o.properties[r].geom,l=o.properties[r].index;typeof l=="number"&&(t[l]=[a,f])})}return t}class kt{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=kt.YAXIS_INVERT;strictMode=kt.MODE_AUTO;vertexMode=kt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(t){if(rr(t)){this.applyModernState(or(t));return}this.applyLegacyState(sr(t))}applyModernState(t){this.points=t.points,this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.edges=t.edges,this.edgeNodes=t.edgeNodes||[],this.tins=t.tins,this.addIndexedTin(),this.kinks=t.kinks,this.yaxisMode=t.yaxisMode??kt.YAXIS_INVERT,this.vertexMode=t.vertexMode??kt.VERTEX_PLAIN,this.strictMode=t.strictMode??kt.MODE_AUTO,t.bounds?(this.bounds=t.bounds,this.boundsPolygon=t.boundsPolygon,this.xy=t.xy,this.wh=t.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=t.xy??[0,0],t.wh&&(this.wh=t.wh))}applyLegacyState(t){this.tins=t.tins,this.addIndexedTin(),this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.kinks=t.kinks,this.points=t.points}addIndexedTin(){const t=this.tins,n=t.forw,i=t.bakw,o=Math.ceil(Math.sqrt(n.features.length));if(o<3){this.indexedTins=void 0;return}let r=[],s=[];const a=n.features.map(w=>{let I=[];return Sn(w)[0].map(x=>{r.length===0?r=[Array.from(x),Array.from(x)]:(x[0]<r[0][0]&&(r[0][0]=x[0]),x[0]>r[1][0]&&(r[1][0]=x[0]),x[1]<r[0][1]&&(r[0][1]=x[1]),x[1]>r[1][1]&&(r[1][1]=x[1])),I.length===0?I=[Array.from(x),Array.from(x)]:(x[0]<I[0][0]&&(I[0][0]=x[0]),x[0]>I[1][0]&&(I[1][0]=x[0]),x[1]<I[0][1]&&(I[0][1]=x[1]),x[1]>I[1][1]&&(I[1][1]=x[1]))}),I}),f=(r[1][0]-r[0][0])/o,l=(r[1][1]-r[0][1])/o,u=a.reduce((w,I,x)=>{const m=Ot(I[0][0],r[0][0],f,o),_=Ot(I[1][0],r[0][0],f,o),d=Ot(I[0][1],r[0][1],l,o),v=Ot(I[1][1],r[0][1],l,o);for(let g=m;g<=_;g++){w[g]||(w[g]=[]);for(let k=d;k<=v;k++)w[g][k]||(w[g][k]=[]),w[g][k].push(x)}return w},[]),c=i.features.map(w=>{let I=[];return Sn(w)[0].map(x=>{s.length===0?s=[Array.from(x),Array.from(x)]:(x[0]<s[0][0]&&(s[0][0]=x[0]),x[0]>s[1][0]&&(s[1][0]=x[0]),x[1]<s[0][1]&&(s[0][1]=x[1]),x[1]>s[1][1]&&(s[1][1]=x[1])),I.length===0?I=[Array.from(x),Array.from(x)]:(x[0]<I[0][0]&&(I[0][0]=x[0]),x[0]>I[1][0]&&(I[1][0]=x[0]),x[1]<I[0][1]&&(I[0][1]=x[1]),x[1]>I[1][1]&&(I[1][1]=x[1]))}),I}),h=(s[1][0]-s[0][0])/o,p=(s[1][1]-s[0][1])/o,M=c.reduce((w,I,x)=>{const m=Ot(I[0][0],s[0][0],h,o),_=Ot(I[1][0],s[0][0],h,o),d=Ot(I[0][1],s[0][1],p,o),v=Ot(I[1][1],s[0][1],p,o);for(let g=m;g<=_;g++){w[g]||(w[g]=[]);for(let k=d;k<=v;k++)w[g][k]||(w[g][k]=[]),w[g][k].push(x)}return w},[]);this.indexedTins={forw:{gridNum:o,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:f,yUnit:l,gridCache:u},bakw:{gridNum:o,xOrigin:s[0][0],yOrigin:s[0][1],xUnit:h,yUnit:p,gridCache:M}}}transform(t,n,i){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(n&&this.strict_status==kt.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==kt.YAXIS_FOLLOW&&n&&(t=[t[0],-1*t[1]]);const o=re(t);if(this.bounds&&!n&&!i&&!Ve(o,this.boundsPolygon))return!1;const r=n?this.tins.bakw:this.tins.forw,s=n?this.indexedTins.bakw:this.indexedTins.forw,a=n?this.vertices_params.bakw:this.vertices_params.forw,f=n?this.centroid.bakw:this.centroid.forw;let l,u;this.stateFull&&(this.stateBackward==n?l=this.stateTriangle:(this.stateBackward=n,this.stateTriangle=void 0),u=h=>{this.stateTriangle=h});let c=se(o,r,s,a,f,void 0,l,u);if(this.bounds&&n&&!i){const h=re(c);if(!Ve(h,this.boundsPolygon))return!1}else this.yaxisMode==kt.YAXIS_FOLLOW&&!n&&(c=[c[0],-1*c[1]]);return c}}const Cn=Math.pow(2,-52),Se=new Uint32Array(512);class ze{static from(t,n=yr,i=vr){const o=t.length,r=new Float64Array(o*2);for(let s=0;s<o;s++){const a=t[s];r[2*s]=n(a),r[2*s+1]=i(a)}return new ze(r)}constructor(t){const n=t.length>>1;if(n>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const i=Math.max(2*n-5,0);this._triangles=new Uint32Array(i*3),this._halfedges=new Int32Array(i*3),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:i,_hullTri:o,_hullHash:r}=this,s=t.length>>1;let a=1/0,f=1/0,l=-1/0,u=-1/0;for(let A=0;A<s;A++){const O=t[2*A],B=t[2*A+1];O<a&&(a=O),B<f&&(f=B),O>l&&(l=O),B>u&&(u=B),this._ids[A]=A}const c=(a+l)/2,h=(f+u)/2;let p=0,M=0,w=0;for(let A=0,O=1/0;A<s;A++){const B=Ge(c,h,t[2*A],t[2*A+1]);B<O&&(p=A,O=B)}const I=t[2*p],x=t[2*p+1];for(let A=0,O=1/0;A<s;A++){if(A===p)continue;const B=Ge(I,x,t[2*A],t[2*A+1]);B<O&&B>0&&(M=A,O=B)}let m=t[2*M],_=t[2*M+1],d=1/0;for(let A=0;A<s;A++){if(A===p||A===M)continue;const O=gr(I,x,m,_,t[2*A],t[2*A+1]);O<d&&(w=A,d=O)}let v=t[2*w],g=t[2*w+1];if(d===1/0){for(let B=0;B<s;B++)this._dists[B]=t[2*B]-t[0]||t[2*B+1]-t[1];Zt(this._ids,this._dists,0,s-1);const A=new Uint32Array(s);let O=0;for(let B=0,C=-1/0;B<s;B++){const Y=this._ids[B],y=this._dists[Y];y>C&&(A[O++]=Y,C=y)}this.hull=A.subarray(0,O),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(Et(I,x,m,_,v,g)<0){const A=M,O=m,B=_;M=w,m=v,_=g,w=A,v=O,g=B}const k=wr(I,x,m,_,v,g);this._cx=k.x,this._cy=k.y;for(let A=0;A<s;A++)this._dists[A]=Ge(t[2*A],t[2*A+1],k.x,k.y);Zt(this._ids,this._dists,0,s-1),this._hullStart=p;let S=3;i[p]=n[w]=M,i[M]=n[p]=w,i[w]=n[M]=p,o[p]=0,o[M]=1,o[w]=2,r.fill(-1),r[this._hashKey(I,x)]=p,r[this._hashKey(m,_)]=M,r[this._hashKey(v,g)]=w,this.trianglesLen=0,this._addTriangle(p,M,w,-1,-1,-1);for(let A=0,O=0,B=0;A<this._ids.length;A++){const C=this._ids[A],Y=t[2*C],y=t[2*C+1];if(A>0&&Math.abs(Y-O)<=Cn&&Math.abs(y-B)<=Cn||(O=Y,B=y,C===p||C===M||C===w))continue;let P=0;for(let b=0,N=this._hashKey(Y,y);b<this._hashSize&&(P=r[(N+b)%this._hashSize],!(P!==-1&&P!==i[P]));b++);P=n[P];let E=P,T;for(;T=i[E],Et(Y,y,t[2*E],t[2*E+1],t[2*T],t[2*T+1])>=0;)if(E=T,E===P){E=-1;break}if(E===-1)continue;let X=this._addTriangle(E,C,i[E],-1,-1,o[E]);o[C]=this._legalize(X+2),o[E]=X,S++;let F=i[E];for(;T=i[F],Et(Y,y,t[2*F],t[2*F+1],t[2*T],t[2*T+1])<0;)X=this._addTriangle(F,C,T,o[C],-1,o[F]),o[C]=this._legalize(X+2),i[F]=F,S--,F=T;if(E===P)for(;T=n[E],Et(Y,y,t[2*T],t[2*T+1],t[2*E],t[2*E+1])<0;)X=this._addTriangle(T,C,E,-1,o[E],o[T]),this._legalize(X+2),o[T]=X,i[E]=E,S--,E=T;this._hullStart=n[C]=E,i[E]=n[F]=C,i[C]=F,r[this._hashKey(Y,y)]=C,r[this._hashKey(t[2*E],t[2*E+1])]=E}this.hull=new Uint32Array(S);for(let A=0,O=this._hullStart;A<S;A++)this.hull[A]=O,O=i[O];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,n){return Math.floor(pr(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:i,coords:o}=this;let r=0,s=0;for(;;){const a=i[t],f=t-t%3;if(s=f+(t+2)%3,a===-1){if(r===0)break;t=Se[--r];continue}const l=a-a%3,u=f+(t+1)%3,c=l+(a+2)%3,h=n[s],p=n[t],M=n[u],w=n[c];if(mr(o[2*h],o[2*h+1],o[2*p],o[2*p+1],o[2*M],o[2*M+1],o[2*w],o[2*w+1])){n[t]=w,n[a]=h;const x=i[c];if(x===-1){let _=this._hullStart;do{if(this._hullTri[_]===c){this._hullTri[_]=t;break}_=this._hullPrev[_]}while(_!==this._hullStart)}this._link(t,x),this._link(a,i[s]),this._link(s,c);const m=l+(a+1)%3;r<Se.length&&(Se[r++]=m)}else{if(r===0)break;t=Se[--r]}}return s}_link(t,n){this._halfedges[t]=n,n!==-1&&(this._halfedges[n]=t)}_addTriangle(t,n,i,o,r,s){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=n,this._triangles[a+2]=i,this._link(a,o),this._link(a+1,r),this._link(a+2,s),this.trianglesLen+=3,a}}function pr(e,t){const n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function Ge(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function mr(e,t,n,i,o,r,s,a){const f=e-s,l=t-a,u=n-s,c=i-a,h=o-s,p=r-a,M=f*f+l*l,w=u*u+c*c,I=h*h+p*p;return f*(c*I-w*p)-l*(u*I-w*h)+M*(u*p-c*h)<0}function gr(e,t,n,i,o,r){const s=n-e,a=i-t,f=o-e,l=r-t,u=s*s+a*a,c=f*f+l*l,h=.5/(s*l-a*f),p=(l*u-a*c)*h,M=(s*c-f*u)*h;return p*p+M*M}function wr(e,t,n,i,o,r){const s=n-e,a=i-t,f=o-e,l=r-t,u=s*s+a*a,c=f*f+l*l,h=.5/(s*l-a*f),p=e+(l*u-a*c)*h,M=t+(s*c-f*u)*h;return{x:p,y:M}}function Zt(e,t,n,i){if(i-n<=20)for(let o=n+1;o<=i;o++){const r=e[o],s=t[r];let a=o-1;for(;a>=n&&t[e[a]]>s;)e[a+1]=e[a--];e[a+1]=r}else{const o=n+i>>1;let r=n+1,s=i;ae(e,o,r),t[e[n]]>t[e[i]]&&ae(e,n,i),t[e[r]]>t[e[i]]&&ae(e,r,i),t[e[n]]>t[e[r]]&&ae(e,n,r);const a=e[r],f=t[a];for(;;){do r++;while(t[e[r]]<f);do s--;while(t[e[s]]>f);if(s<r)break;ae(e,r,s)}e[n+1]=e[s],e[s]=a,i-r+1>=s-n?(Zt(e,t,r,i),Zt(e,t,n,s-1)):(Zt(e,t,n,s-1),Zt(e,t,r,i))}}function ae(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function yr(e){return e[0]}function vr(e){return e[1]}class br{bs;width;constructor(t,n){this.width=t,this.bs=n}add(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]|=1<<i,this}delete(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]&=~(1<<i),this}set(t,n){const i=Math.floor(t/this.width),r=1<<t%this.width;return this.bs[i]^=(-Number(n)^this.bs[i])&r,n}has(t){const n=Math.floor(t/this.width),i=t%this.width;return(this.bs[n]&1<<i)!==0}forEach(t){const n=this.bs.length;for(let i=0;i<n;i++){let o=0;for(;this.bs[i]&&o<this.width;)this.bs[i]&1<<o&&t(i*this.width+o),o++}return this}}class Xn extends br{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function zt(e){return e%3===2?e-2:e+1}function Ct(e){return e%3===0?e+2:e-1}function Dn(e,t,n,i,o,r,s,a){const f=Et(e,t,o,r,s,a),l=Et(n,i,o,r,s,a);if(f>0&&l>0||f<0&&l<0)return!1;const u=Et(o,r,e,t,n,i),c=Et(s,a,e,t,n,i);return u>0&&c>0||u<0&&c<0?!1:f===0&&l===0&&u===0&&c===0?!(Math.max(o,s)<Math.min(e,n)||Math.max(e,n)<Math.min(o,s)||Math.max(r,a)<Math.min(t,i)||Math.max(t,i)<Math.min(r,a)):!0}class xr{del;constructor(t){this.del=t}}class _r extends xr{vertMap;flips;consd;constructor(t,n){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 i=2**32-1,o=t.coords.length>>1,r=t.triangles.length;this.vertMap=new Uint32Array(o).fill(i),this.flips=new Xn(r),this.consd=new Xn(r);for(let s=0;s<r;s++){const a=t.triangles[s];this.vertMap[a]===i&&this.updateVert(s)}n&&this.constrainAll(n)}constrainOne(t,n){const{triangles:i,halfedges:o}=this.del,r=this.vertMap[t];let s=r;do{const l=i[s],u=zt(s);if(l===n)return this.protect(s);const c=Ct(s),h=i[c];if(h===n)return this.protect(u),u;if(this.intersectSegments(t,n,h,l)){s=c;break}s=o[u]}while(s!==-1&&s!==r);let a=s,f=-1;for(;s!==-1;){const l=o[s],u=Ct(s),c=Ct(l),h=zt(l);if(l===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(s))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,n,i[s])||this.isCollinear(t,n,i[l]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[s],i[l],i[u],i[c])){if(f===-1&&(f=s),i[c]===n){if(s===f)throw new Error("Infinite loop: non-convex quadrilateral");s=f,f=-1;continue}if(this.intersectSegments(t,n,i[c],i[l]))s=c;else if(this.intersectSegments(t,n,i[h],i[c]))s=h;else if(f===s)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(s),this.intersectSegments(t,n,i[u],i[c])&&(f===-1&&(f=u),f===u))throw new Error("Infinite loop: flipped diagonal still intersects");i[c]===n?(a=c,s=f,f=-1):this.intersectSegments(t,n,i[h],i[c])&&(s=h)}return this.protect(a),this.delaunify(!0),this.findEdge(t,n)}delaunify(t=!1){const{halfedges:n}=this.del,i=this.flips,o=this.consd,r=n.length;let s;do{s=0;for(let a=0;a<r;a++){if(o.has(a))continue;i.delete(a);const f=n[a];f!==-1&&(i.delete(f),this.isDelaunay(a)||(this.flipDiagonal(a),s++))}}while(t&&s>0);return this}constrainAll(t){const n=t.length;for(let i=0;i<n;i++){const o=t[i];this.constrainOne(o[0],o[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,n){const i=this.vertMap[n],{triangles:o,halfedges:r}=this.del;let s=i,a;do{if(o[s]===t)return s;a=zt(s),s=r[a]}while(s!==-1&&s!==i);return o[zt(a)]===t?-a:1/0}protect(t){const n=this.del.halfedges[t],i=this.flips,o=this.consd;return i.delete(t),o.add(t),n!==-1?(i.delete(n),o.add(n),n):-t}markFlip(t){const n=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const r=n[t];return r!==-1&&(i.add(t),i.add(r)),!0}flipDiagonal(t){const{triangles:n,halfedges:i}=this.del,o=this.flips,r=this.consd,s=i[t],a=Ct(t),f=zt(t),l=Ct(s),u=zt(s),c=i[a],h=i[l];if(r.has(t))throw new Error("Trying to flip a constrained edge");return n[t]=n[l],i[t]=h,o.set(t,o.has(l))||r.set(t,r.has(l)),h!==-1&&(i[h]=t),i[a]=l,n[s]=n[a],i[s]=c,o.set(s,o.has(a))||r.set(s,r.has(a)),c!==-1&&(i[c]=s),i[l]=a,this.markFlip(t),this.markFlip(f),this.markFlip(s),this.markFlip(u),o.add(a),r.delete(a),o.add(l),r.delete(l),this.updateVert(t),this.updateVert(f),this.updateVert(s),this.updateVert(u),a}isCollinear(t,n,i){const o=this.del.coords;return Et(o[t*2],o[t*2+1],o[n*2],o[n*2+1],o[i*2],o[i*2+1])===0}inCircle(t,n,i,o){const r=this.del.coords;return fi(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])<0}isDelaunay(t){const{triangles:n,halfedges:i}=this.del,o=i[t];if(o===-1)return!0;const r=n[Ct(t)],s=n[t],a=n[zt(t)],f=n[Ct(o)];return!this.inCircle(r,s,a,f)}updateVert(t){const{triangles:n,halfedges:i}=this.del,o=this.vertMap,r=n[t];let s=Ct(t),a=i[s];for(;a!==-1&&a!==t;)s=Ct(a),a=i[s];return o[r]=s,s}intersectSegments(t,n,i,o){const r=this.del.coords;return t===i||t===o||n===i||n===o?!1:Dn(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])}static intersectSegments=Dn}function ce(e,t,n){if(t||(t=[]),typeof e!="object"||e.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const i=e.features.map(f=>f.geometry.coordinates),o=ze.from(i);let r;const s=[];o.triangles.length!==0&&t.length!==0&&(r=new _r(o),r.constrainAll(t));for(let f=0;f<o.triangles.length;f+=3)s.push([o.triangles[f],o.triangles[f+1],o.triangles[f+2]]);const a=["a","b","c"];return St(s.map(f=>{const l={},u=f.map((c,h)=>{const p=e.features[c],M=p.geometry.coordinates,w=[M[0],M[1]];return M.length===3?w[2]=M[2]:l[a[h]]=p.properties[n],w});return u[3]=u[0],te([u],l)}))}function Mr(e,t){const n=[[],[],[],[]],i=[];return Object.keys(e).forEach(o=>{const r=e[o],s=r.forw,a=r.bakw,f=[s[0]-t.forw[0],s[1]-t.forw[1]],l=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:f,bakw:l};if(i.push(u),f[0]===0||f[1]===0)return;let c=0;f[0]>0&&(c+=1),f[1]>0&&(c+=2),n[c].push(u)}),{perQuad:n,aggregate:i}}function Sr(e){let t=1/0,n=0,i=0;return e.forEach(o=>{const{forw:r,bakw:s}=o,a=Math.hypot(r[0],r[1]),f=Math.hypot(s[0],s[1]);if(f===0)return;const l=a/f,u=Math.atan2(r[0],r[1])-Math.atan2(s[0],s[1]);t=Math.min(t,l),n+=Math.cos(u),i+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(i,n)]:[1,0]}function kr(e,t,n){const{perQuad:i,aggregate:o}=Mr(e,t),r=i.every(f=>f.length>0),a=(n==="birdeye"?r?i:[o]:[o]).map(f=>Sr(f));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Er(e,t){let n=0;return e[0]>t[0]&&(n+=1),e[1]>t[1]&&(n+=2),n}function Ar(e,t,n){const i=[e[0]-t.forw[0],e[1]-t.forw[1]],r=Math.sqrt(i[0]**2+i[1]**2)/n[0],s=Math.atan2(i[0],i[1])-n[1];return[t.bakw[0]+r*Math.sin(s),t.bakw[1]-r*Math.cos(s)]}function Ir(e,t,n,i){const o=t[0]-e[0],r=t[1]-e[1];if(Math.abs(o)<1e-12&&Math.abs(r)<1e-12)return null;const s=i[0]-n[0],a=i[1]-n[1],f=n[0]-e[0],l=n[1]-e[1],u=o*a-r*s;if(Math.abs(u)<1e-12)return null;const c=(f*a-l*s)/u,h=(f*r-l*o)/u;return c<=1e-10||h<-1e-10||h>1+1e-10?null:{t:c,point:[e[0]+c*o,e[1]+c*r]}}function Pr(e,t,n){const i=n.length;let o=-1/0,r=null;for(let s=0;s<i;s++){const a=(s+1)%i,f=Ir(e,t,n[s].bakw,n[a].bakw);f&&f.t>o&&(o=f.t,r=f.point)}return r}function Fn(e,t){const i=Math.atan2(e[0]-t[0],e[1]-t[1])*(180/Math.PI);return i<0?i+360:i}function Yn(e,t,n,i,o,r){const s=t[0]-e[0],a=t[1]-e[1];if(s===0&&a===0)return null;const f=[];if(s!==0)for(const u of[n,i]){const c=(u-e[0])/s;if(c>0){const h=e[1]+c*a;h>=o&&h<=r&&f.push({t:c,x:u,y:h})}}if(a!==0)for(const u of[o,r]){const c=(u-e[1])/a;if(c>0){const h=e[0]+c*s;h>=n&&h<=i&&f.push({t:c,x:h,y:u})}}if(f.length===0)return null;f.sort((u,c)=>u.t-c.t);const l=f[0];return[l.x,l.y]}function Rn(e,t,n){const i=e.length,o=new Array(i).fill(1);for(const r of t)for(let s=0;s<i;s++){const a=(s+1)%i,f=Ze([e[s].bakw,e[a].bakw]),l=Ze([n.bakw,r.bakw]),u=Ai(f,l);if(u.features.length>0&&u.features[0].geometry){const c=u.features[0],h=Math.sqrt(Math.pow(r.bakw[0]-n.bakw[0],2)+Math.pow(r.bakw[1]-n.bakw[1],2)),p=Math.sqrt(Math.pow(c.geometry.coordinates[0]-n.bakw[0],2)+Math.pow(c.geometry.coordinates[1]-n.bakw[1],2)),M=h/p;M>o[s]&&(o[s]=M),M>o[a]&&(o[a]=M)}}e.forEach((r,s)=>{const a=o[s];r.bakw=[(r.bakw[0]-n.bakw[0])*a+n.bakw[0],(r.bakw[1]-n.bakw[1])*a+n.bakw[1]]})}function $n(e,t,n){const{convexBuf:i,centroid:o,allGcps:r,minx:s,maxx:a,miny:f,maxy:l}=e,u=kr(i,o,t),h=[[s,f],[a,f],[a,l],[s,l]].map(g=>({forw:g,bakw:Ar(g,o,u[Er(g,o.forw)])}));if(h.sort((g,k)=>Math.atan2(g.forw[0]-o.forw[0],g.forw[1]-o.forw[1])-Math.atan2(k.forw[0]-o.forw[0],k.forw[1]-o.forw[1])),Rn(h,r,o),!n)return h;const p=4,M=h.map(g=>Math.atan2(g.forw[0]-o.forw[0],g.forw[1]-o.forw[1])),w=h.map(g=>Math.atan2(g.bakw[0]-o.bakw[0],-(g.bakw[1]-o.bakw[1])));function I(g){for(let k=0;k<p;k++){const S=(k+1)%p,A=M[k],O=k<p-1?M[S]:M[S]+2*Math.PI;let B=g;for(;B<A;)B+=2*Math.PI;for(;B>=A+2*Math.PI;)B-=2*Math.PI;if(B>=A&&B<O)return{i:k,j:S,frac:(B-A)/(O-A)}}return{i:0,j:1,frac:0}}function x(g){const{i:k,j:S,frac:A}=I(g),O=w[k];let C=w[S]-O;for(;C>Math.PI;)C-=2*Math.PI;for(;C<-Math.PI;)C+=2*Math.PI;return O+A*C}const m=new Set(h.map(g=>Math.floor(Fn(g.forw,o.forw)/10)%36)),_=r.map(g=>({forw:g.forw,bakw:g.bakw,angleDeg:Fn(g.forw,o.forw),forwDist:Math.hypot(g.forw[0]-o.forw[0],g.forw[1]-o.forw[1])})),d=[];for(let g=0;g<36;g++){if(m.has(g))continue;const k=g*10,S=_.filter(P=>P.angleDeg>=k&&P.angleDeg<k+10);let A=null;if(S.length>0){const P=S.reduce((E,T)=>T.forwDist>E.forwDist?T:E);A=Yn(o.forw,P.forw,s,a,f,l)}if(!A){const P=(k+5)%360*(Math.PI/180),E=[o.forw[0]+Math.sin(P),o.forw[1]+Math.cos(P)];A=Yn(o.forw,E,s,a,f,l)}if(!A)continue;const O=[A[0]-o.forw[0],A[1]-o.forw[1]],B=Math.atan2(O[0],O[1]),C=x(B),Y=[o.bakw[0]+Math.sin(C),o.bakw[1]-Math.cos(C)],y=Pr(o.bakw,Y,h);y&&d.push({forw:A,bakw:y})}const v=[...h,...d];return v.sort((g,k)=>Math.atan2(g.forw[0]-o.forw[0],g.forw[1]-o.forw[1])-Math.atan2(k.forw[0]-o.forw[0],k.forw[1]-o.forw[1])),Rn(v,r,o),v}function Or(e,t=!1){return $n(e,"plain",t)}function Br(e,t=!1){return $n(e,"birdeye",t)}function Ln(e){Nr(e);const n=new Tr(e).findSegmentIntersections(),i=Gn(n),o=new Map;return i.forEach(r=>{o.set(`${r.x}:${r.y}`,r)}),Array.from(o.values()).map(r=>Dt([r.x,r.y]))}function Nr(e){for(let t=0,n=e.length;t<n;t++){const i=e[t];le(i)||Gt("findIntersections() received invalid coordinates:",`line=${t}`,`points=${i}`);for(let o=0,r=i.length;o<r;o++){const s=i[o];(!le(s)||!Number.isFinite(s[0])||!Number.isFinite(s[1]))&&Gt("findIntersections() received non-finite coordinates:",`line=${t}`,`point=${o}`,`coordinates=${JSON.stringify(s)}`)}}}class Tr{_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 n=[],i=[],o=t.map(r=>{const s=r?r.length:0;for(let a=0;a<s;a++)n.push(r[a][0]),i.push(r[a][1]);return s});this.initXYData(o,n,i)}initXYData(t,n,i){const o=t.length;this._xx=new Float64Array(n),this._yy=new Float64Array(i),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(o);let r=0;for(let s=0;s<o;s++)this._ii[s]=r,r+=t[s];(r!=this._xx.length||this._xx.length!=this._yy.length)&&Gt("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Zr(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,n,i){const o=i.length,r=new Float64Array(o*4),s=new he;let a=0,f,l,u;for(let c=0;c<o;c++)f=i[c],f>0&&(l=c*4,u=to(t,n,a,f),r[l++]=u[0],r[l++]=u[1],r[l++]=u[2],r[l]=u[3],a+=f,s.mergeBounds(u));return{bb:r,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new he}forEachSegment(t){let n=0;for(let i=0,o=this.size();i<o;i++)n+=this.forEachArcSegment(i,t);return n}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,n){const i=t>=0,o=i?t:~t,r=this.getRetainedInterval(),s=this._nn[o],a=i?1:-1;let f=i?this._ii[o]:this._ii[o]+s-1,l=f,u=0;for(let c=1;c<s;c++)l+=a,(r===0||this._zz[l]>=r)&&(n(f,l,this._xx,this._yy),f=l,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 n=t*4;return(!this.buf||this.buf.byteLength<n)&&(this.buf=new ArrayBuffer(n)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,n=0;const i=this.forEachSegment((o,r,s,a)=>{t+=Math.abs(s[o]-s[r]),n+=Math.abs(a[o]-a[r])});return[t/i||0,n/i||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),n=this.getAvgSegment2()[1];let i=1;return n>0&&t>0&&(i=Math.ceil(t/n/20)),i||1}findSegmentIntersections(){const t=this.getBounds(),n=t.ymin||0,i=(t.ymax||0)-n,o=this.calcSegmentIntersectionStripeCount(),r=new Uint32Array(o),s=o>1?I=>Math.floor((o-1)*(I-n)/i):()=>0,a=o+1;let f,l;this.forEachSegment((I,x,m,_)=>{let d=s(_[I]);const v=s(_[x]);let g=0;for(;r[d]=r[d]+2,d!=v;)g++,g>a&&Gt("findSegmentIntersections() exceeded the stripe iteration limit:",`stripeCount=${o}`,`s1=${d}`,`s2=${v}`),d+=v>d?1:-1});const u=this.getUint32Array(Dr(r));let c=0;const h=[];Fr(r,I=>{const x=c;c+=I,h.push(u.subarray(x,c))}),Yr(r,0),this.forEachSegment((I,x,m,_)=>{let d=s(_[I]);const v=s(_[x]);let g,k,S=0;for(;g=r[d],r[d]=g+2,k=h[d],k[g]=I,k[g+1]=x,d!=v;)S++,S>a&&Gt("findSegmentIntersections() exceeded the stripe iteration limit:",`stripeCount=${o}`,`s1=${d}`,`s2=${v}`),d+=v>d?1:-1});const p=this.getVertexData(),M=[];let w;for(f=0;f<o;f++)if(p.xx&&p.yy)for(w=Rr(h[f],p.xx,p.yy),l=0;l<w.length;l++)M.push(w[l]);return Gn(M)}}function Gt(...e){const t=e.join(" ");throw new Error(t)}function le(e){return e?Xr(e)?!0:Cr(e)?!1:e.length===0?!0:e.length>0:!1}function Cr(e){return e!=null&&e.toString===String.prototype.toString}function Xr(e){return Array.isArray(e)}function Dr(e,t){le(e)||Gt("utils.sum() expects an array, received:",e);let n=0,i;for(let o=0,r=e.length;o<r;o++)i=e[o],i&&(n+=i);return n}function Fr(e,t,n){if(!le(e))throw new Error(`#forEach() takes an array-like argument. ${e}`);for(let i=0,o=e.length;i<o;i++)t.call(n,e[i],i)}function Yr(e,t){for(let n=0,i=e.length;n<i;n++)e[n]=t;return e}function Rr(e,t,n){const i=e.length-2,o=[];let r,s,a,f,l,u,c,h,p,M,w,I,x,m,_,d,v;for(Kr(t,e),d=0;d<i;){for(r=e[d],s=e[d+1],l=t[r],u=t[s],p=n[r],M=n[s],v=d;v<i&&(v+=2,a=e[v],c=t[a],!(u<c));){if(w=n[a],f=e[v+1],h=t[f],I=n[f],p>=w){if(p>I&&M>w&&M>I)continue}else if(p<I&&M<w&&M<I)continue;r==a||r==f||s==a||s==f||(x=$r(l,p,u,M,c,w,h,I),x&&(m=[r,s],_=[a,f],o.push(Un(x,m,_,t,n)),x.length==4&&o.push(Un(x.slice(2),m,_,t,n))))}d+=2}return o}function $r(e,t,n,i,o,r,s,a){const f=Lr(e,t,n,i,o,r,s,a);let l=null;return f&&(l=jr(e,t,n,i,o,r,s,a),l?Jr(e,t,n,i,o,r,s,a)&&(l=null):l=Gr(e,t,n,i,o,r,s,a)),l}function Lr(e,t,n,i,o,r,s,a){return fe(e,t,n,i,o,r)*fe(e,t,n,i,s,a)<=0&&fe(o,r,s,a,e,t)*fe(o,r,s,a,n,i)<=0}function fe(e,t,n,i,o,r){return jn(e-o,t-r,n-o,i-r)}function jn(e,t,n,i){return e*i-t*n}function jr(e,t,n,i,o,r,s,a){let f=ke(e,t,n,i,o,r,s,a),l;return f&&(l=qr(f[0],f[1],e,t,n,i,o,r,s,a),l==1?f=ke(n,i,e,t,o,r,s,a):l==2?f=ke(o,r,s,a,e,t,n,i):l==3&&(f=ke(s,a,o,r,e,t,n,i))),f&&zr(f,e,t,n,i,o,r,s,a),f}function ke(e,t,n,i,o,r,s,a){const f=jn(n-e,i-t,s-o,a-r),l=1e-18;let u;if(f===0)return null;const c=fe(o,r,s,a,e,t)/f;return f<=l&&f>=-l?u=Vr(e,t,n,i,o,r,s,a):u=[e+c*(n-e),t+c*(i-t)],u}function Vr(e,t,n,i,o,r,s,a){let f=null;return!Xt(e,o,s)&&!Xt(t,r,a)?f=[e,t]:!Xt(n,o,s)&&!Xt(i,r,a)?f=[n,i]:!Xt(o,e,n)&&!Xt(r,t,i)?f=[o,r]:!Xt(s,e,n)&&!Xt(a,t,i)&&(f=[s,a]),f}function Xt(e,t,n){let i;return t<n?i=e<t||e>n:t>n?i=e>t||e<n:i=e!=t,i}function qr(e,t,...n){let i=-1,o=1/0,r;for(let s=0,a=0,f=n.length;a<f;s++,a+=2)r=Ur(e,t,n[a],n[a+1]),r<o&&(o=r,i=s);return i}function Ur(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function zr(e,t,n,i,o,r,s,a,f){let l=e[0],u=e[1];l=Ee(l,t,i),l=Ee(l,r,a),u=Ee(u,n,o),u=Ee(u,s,f),e[0]=l,e[1]=u}function Ee(e,t,n){let i;return Xt(e,t,n)&&(i=Math.abs(e-t)<Math.abs(e-n)?t:n,e=i),e}function Gr(e,t,n,i,o,r,s,a){const f=Math.min(e,n,o,s),l=Math.max(e,n,o,s),u=Math.min(t,i,r,a),c=Math.max(t,i,r,a),h=c-u>l-f;let p=[];return(h?Lt(t,u,c):Lt(e,f,l))&&p.push(e,t),(h?Lt(i,u,c):Lt(n,f,l))&&p.push(n,i),(h?Lt(r,u,c):Lt(o,f,l))&&p.push(o,r),(h?Lt(a,u,c):Lt(s,f,l))&&p.push(s,a),(p.length!=2&&p.length!=4||p.length==4&&p[0]==p[2]&&p[1]==p[3])&&(p=null),p}function Jr(e,t,n,i,o,r,s,a){return e==o&&t==r||e==s&&t==a||n==o&&i==r||n==s&&i==a}function Lt(e,t,n){return e>t&&e<n}function Kr(e,t){Qr(e,t),Vn(e,t,0,t.length-2)}function Qr(e,t){for(let n=0,i=t.length;n<i;n+=2)e[t[n]]>e[t[n+1]]&&Hr(t,n,n+1)}function Hr(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function Vn(e,t,n,i){let o=n,r=i,s,a;for(;o<i;){for(s=e[t[n+i>>2<<1]];o<=r;){for(;e[t[o]]<s;)o+=2;for(;e[t[r]]>s;)r-=2;o<=r&&(a=t[o],t[o]=t[r],t[r]=a,a=t[o+1],t[o+1]=t[r+1],t[r+1]=a,o+=2,r-=2)}if(r-n<40?qn(e,t,n,r):Vn(e,t,n,r),i-o<40){qn(e,t,o,i);return}n=o,r=i}}function qn(e,t,n,i){let o,r;for(let s=n+2;s<=i;s+=2){o=t[s],r=t[s+1];let a;for(a=s-2;a>=n&&e[o]<e[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=o,t[a+3]=r}}function Un(e,t,n,i,o){const r=e[0],s=e[1];t=zn(r,s,t[0],t[1],i,o),n=zn(r,s,n[0],n[1],i,o);const a=t[0]<n[0]?t:n,f=a==t?n:t;return{x:r,y:s,a,b:f}}function zn(e,t,n,i,o,r){let s=n<i?n:i,a=s===n?i:n;return o[s]==e&&r[s]==t?a=s:o[a]==e&&r[a]==t&&(s=a),[s,a]}function Gn(e){const t={};return e.filter(n=>{const i=Wr(n);return i in t?!1:(t[i]=!0,!0)})}function Wr(e){return`${e.a.join(",")};${e.b.join(",")}`}class Zr{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,n){this._xx=t,this._yy=n}}function to(e,t,n,i){let o=n|0;const r=isNaN(i)?e.length-o:i+o;let s,a,f,l,u,c;if(r>0)f=u=e[o],l=c=t[o];else return[void 0,void 0,void 0,void 0];for(o++;o<r;o++)s=e[o],a=t[o],s<f&&(f=s),s>u&&(u=s),a<l&&(l=a),a>c&&(c=a);return[f,l,u,c]}class he{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new he(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,n,i,o){let r,s,a,f;if(arguments.length==1)if(le(t)){const l=t;r=l[0],s=l[1],a=l[2],f=l[3]}else{const l=t;r=l.xmin,s=l.ymin,a=l.xmax,f=l.ymax}else r=t,s=n,a=i,f=o;return this.xmin=r,this.ymin=s,this.xmax=a,this.ymax=f,(r>a||s>f)&&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,...n){let i,o,r,s;return t instanceof he?(i=t.xmin,o=t.ymin,r=t.xmax,s=t.ymax):n.length==3?(i=t,o=n[0],r=n[1],s=n[2]):t.length==4?(i=t[0],o=t[1],r=t[2],s=t[3]):Gt("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(i,o,r,s):(i<this.xmin&&(this.xmin=i),o<this.ymin&&(this.ymin=o),r>this.xmax&&(this.xmax=r),s>this.ymax&&(this.ymax=s)),this}}function Ae(e){const t=["a","b","c"].map(n=>e.properties[n].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(n=>n.map(i=>t[i]).sort().join("-")).sort()}function Je(e,t,n){const i=Ae(t.forw),o=Ae(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
|
|
1
|
+
(function(bt,Nt){typeof exports=="object"&&typeof module<"u"?Nt(exports):typeof define=="function"&&define.amd?define(["exports"],Nt):(bt=typeof globalThis<"u"?globalThis:bt||self,Nt(bt.tin={}))})(this,(function(bt){"use strict";function Nt(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function $t(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!tn(e[0])||!tn(e[1]))throw new Error("coordinates must contain numbers");return Nt({type:"Point",coordinates:e},t,n)}function te(e,t,n={}){for(const o of e){if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(o[o.length-1].length!==o[0].length)throw new Error("First and last Position are not equivalent.");for(let r=0;r<o[o.length-1].length;r++)if(o[o.length-1][r]!==o[0][r])throw new Error("First and last Position are not equivalent.")}return Nt({type:"Polygon",coordinates:e},t,n)}function Ze(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Nt({type:"LineString",coordinates:e},t,n)}function Et(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function tn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ni(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ii(e){return e.type==="Feature"?e.geometry:e}function Oe(e,t,n){if(e!==null)for(var i,o,r,s,a,c,l,h=0,f=0,u,p=e.type,_=p==="FeatureCollection",w=p==="Feature",O=_?e.features.length:1,M=0;M<O;M++){l=_?e.features[M].geometry:w?e.geometry:e,u=l?l.type==="GeometryCollection":!1,a=u?l.geometries.length:1;for(var m=0;m<a;m++){var v=0,d=0;if(s=u?l.geometries[m]:l,s!==null){c=s.coordinates;var b=s.type;switch(h=n&&(b==="Polygon"||b==="MultiPolygon")?1:0,b){case null:break;case"Point":if(t(c,f,M,v,d)===!1)return!1;f++,v++;break;case"LineString":case"MultiPoint":for(i=0;i<c.length;i++){if(t(c[i],f,M,v,d)===!1)return!1;f++,b==="MultiPoint"&&v++}b==="LineString"&&v++;break;case"Polygon":case"MultiLineString":for(i=0;i<c.length;i++){for(o=0;o<c[i].length-h;o++){if(t(c[i][o],f,M,v,d)===!1)return!1;f++}b==="MultiLineString"&&v++,b==="Polygon"&&d++}b==="Polygon"&&v++;break;case"MultiPolygon":for(i=0;i<c.length;i++){for(d=0,o=0;o<c[i].length;o++){for(r=0;r<c[i][o].length-h;r++){if(t(c[i][o][r],f,M,v,d)===!1)return!1;f++}d++}v++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(Oe(s.geometries[i],t,n)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const ut=11102230246251565e-32,q=134217729,en=(3+8*ut)*ut;function lt(e,t,n,i,o){let r,s,a,c,l=t[0],h=i[0],f=0,u=0;h>l==h>-l?(r=l,l=t[++f]):(r=h,h=i[++u]);let p=0;if(f<e&&u<n)for(h>l==h>-l?(s=l+r,a=r-(s-l),l=t[++f]):(s=h+r,a=r-(s-h),h=i[++u]),r=s,a!==0&&(o[p++]=a);f<e&&u<n;)h>l==h>-l?(s=r+l,c=s-r,a=r-(s-c)+(l-c),l=t[++f]):(s=r+h,c=s-r,a=r-(s-c)+(h-c),h=i[++u]),r=s,a!==0&&(o[p++]=a);for(;f<e;)s=r+l,c=s-r,a=r-(s-c)+(l-c),l=t[++f],r=s,a!==0&&(o[p++]=a);for(;u<n;)s=r+h,c=s-r,a=r-(s-c)+(h-c),h=i[++u],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function St(e,t,n,i,o,r,s,a){return lt(lt(e,t,n,i,s),s,o,r,a)}function Y(e,t,n,i){let o,r,s,a,c,l,h,f,u,p,_;h=q*n,p=h-(h-n),_=n-p;let w=t[0];o=w*n,h=q*w,f=h-(h-w),u=w-f,s=u*_-(o-f*p-u*p-f*_);let O=0;s!==0&&(i[O++]=s);for(let M=1;M<e;M++)w=t[M],a=w*n,h=q*w,f=h-(h-w),u=w-f,c=u*_-(a-f*p-u*p-f*_),r=o+c,l=r-o,s=o-(r-l)+(c-l),s!==0&&(i[O++]=s),o=a+r,s=r-(o-a),s!==0&&(i[O++]=s);return(o!==0||O===0)&&(i[O++]=o),O}function nn(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function tt(e){return new Float64Array(e)}const ri=(3+16*ut)*ut,oi=(2+12*ut)*ut,si=(9+64*ut)*ut*ut,Gt=tt(4),rn=tt(8),on=tt(12),sn=tt(16),mt=tt(4);function ai(e,t,n,i,o,r,s){let a,c,l,h,f,u,p,_,w,O,M,m,v,d,b,g,E,S;const k=e-o,P=n-o,N=t-r,C=i-r;d=k*C,u=q*k,p=u-(u-k),_=k-p,u=q*C,w=u-(u-C),O=C-w,b=_*O-(d-p*w-_*w-p*O),g=N*P,u=q*N,p=u-(u-N),_=N-p,u=q*P,w=u-(u-P),O=P-w,E=_*O-(g-p*w-_*w-p*O),M=b-E,f=b-M,Gt[0]=b-(M+f)+(f-E),m=d+M,f=m-d,v=d-(m-f)+(M-f),M=v-g,f=v-M,Gt[1]=v-(M+f)+(f-g),S=m+M,f=S-m,Gt[2]=m-(S-f)+(M-f),Gt[3]=S;let F=nn(4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,on,4,mt,sn);return sn[T-1]}function At(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),c=s-a,l=Math.abs(s+a);return Math.abs(c)>=ri*l?c:-ai(e,t,n,i,o,r,l)}const ci=(10+96*ut)*ut,fi=(4+48*ut)*ut,li=(44+576*ut)*ut*ut,Dt=tt(4),Ft=tt(4),Rt=tt(4),It=tt(4),Ot=tt(4),Pt=tt(4),gt=tt(4),wt=tt(4),Pe=tt(8),Ne=tt(8),Be=tt(8),Te=tt(8),Ce=tt(8),Xe=tt(8),ge=tt(8),we=tt(8),ye=tt(8),jt=tt(4),Ut=tt(4),qt=tt(4),z=tt(8),K=tt(16),nt=tt(16),it=tt(16),et=tt(32),Yt=tt(32),st=tt(48),xt=tt(64);let Kt=tt(1152),$e=tt(1152);function at(e,t,n){e=lt(e,Kt,t,n,$e);const i=Kt;return Kt=$e,$e=i,e}function hi(e,t,n,i,o,r,s,a,c){let l,h,f,u,p,_,w,O,M,m,v,d,b,g,E,S,k,P,N,C,F,y,I,A,T,X,D,x,B,$,R,L,V,U,j;const G=e-s,J=n-s,Q=o-s,H=t-a,Z=i-a,W=r-a;R=J*W,I=q*J,A=I-(I-J),T=J-A,I=q*W,X=I-(I-W),D=W-X,L=T*D-(R-A*X-T*X-A*D),V=Q*Z,I=q*Q,A=I-(I-Q),T=Q-A,I=q*Z,X=I-(I-Z),D=Z-X,U=T*D-(V-A*X-T*X-A*D),x=L-U,y=L-x,Dt[0]=L-(x+y)+(y-U),B=R+x,y=B-R,$=R-(B-y)+(x-y),x=$-V,y=$-x,Dt[1]=$-(x+y)+(y-V),j=B+x,y=j-B,Dt[2]=B-(j-y)+(x-y),Dt[3]=j,R=Q*H,I=q*Q,A=I-(I-Q),T=Q-A,I=q*H,X=I-(I-H),D=H-X,L=T*D-(R-A*X-T*X-A*D),V=G*W,I=q*G,A=I-(I-G),T=G-A,I=q*W,X=I-(I-W),D=W-X,U=T*D-(V-A*X-T*X-A*D),x=L-U,y=L-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W,K),K,Y(ot,z,w,nt),nt,Y(rt,it,w,et),et,Yt,xt),xt)}}return Kt[l-1]}function ui(e,t,n,i,o,r,s,a){const c=e-s,l=n-s,h=o-s,f=t-a,u=i-a,p=r-a,_=l*p,w=h*u,O=c*c+f*f,M=h*f,m=c*p,v=l*l+u*u,d=c*u,b=l*f,g=h*h+p*p,E=O*(_-w)+v*(M-m)+g*(d-b),S=(Math.abs(_)+Math.abs(w))*O+(Math.abs(M)+Math.abs(m))*v+(Math.abs(d)+Math.abs(b))*g,k=ci*S;return E>k||-E>k?E:hi(e,t,n,i,o,r,s,a,S)}function di(e,t){var n,i,o=0,r,s,a,c,l,h,f,u=e[0],p=e[1],_=t.length;for(n=0;n<_;n++){i=0;var w=t[n],O=w.length-1;if(h=w[0],h[0]!==w[O][0]&&h[1]!==w[O][1])throw new Error("First and last coordinates in a ring must be the same");for(s=h[0]-u,a=h[1]-p,i;i<O;i++){if(f=w[i+1],c=f[0]-u,l=f[1]-p,a===0&&l===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(r=At(s,c,a,l,0,0),r===0)return 0;(r>0&&l>0&&a<=0||r<0&&l<=0&&a>0)&&o++}h=f,a=l,s=c}}return o%2!==0}function De(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ni(e),o=ii(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&pi(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var c=0;c<a.length;++c){const l=di(i,a[c]);if(l===0&&!n.ignoreBoundary)return!0;if(l)return!0}return!1}function pi(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}class Fe{constructor(t=[],n=mi){if(this.data=t,this.length=this.data.length,this.compare=n,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:n,compare:i}=this,o=n[t];for(;t>0;){const r=t-1>>1,s=n[r];if(i(o,s)>=0)break;n[t]=s,t=r}n[t]=o}_down(t){const{data:n,compare:i}=this,o=this.length>>1,r=n[t];for(;t<o;){let s=(t<<1)+1,a=n[s];const c=s+1;if(c<this.length&&i(n[c],a)<0&&(s=c,a=n[c]),i(a,r)>=0)break;n[t]=a,t=s}n[t]=r}}function mi(e,t){return e<t?-1:e>t?1:0}const gi=Object.freeze(Object.defineProperty({__proto__:null,default:Fe},Symbol.toStringTag,{value:"Module"})),Bt=11102230246251565e-32,dt=134217729,wi=(3+8*Bt)*Bt;function Re(e,t,n,i,o){let r,s,a,c,l=t[0],h=i[0],f=0,u=0;h>l==h>-l?(r=l,l=t[++f]):(r=h,h=i[++u]);let p=0;if(f<e&&u<n)for(h>l==h>-l?(s=l+r,a=r-(s-l),l=t[++f]):(s=h+r,a=r-(s-h),h=i[++u]),r=s,a!==0&&(o[p++]=a);f<e&&u<n;)h>l==h>-l?(s=r+l,c=s-r,a=r-(s-c)+(l-c),l=t[++f]):(s=r+h,c=s-r,a=r-(s-c)+(h-c),h=i[++u]),r=s,a!==0&&(o[p++]=a);for(;f<e;)s=r+l,c=s-r,a=r-(s-c)+(l-c),l=t[++f],r=s,a!==0&&(o[p++]=a);for(;u<n;)s=r+h,c=s-r,a=r-(s-c)+(h-c),h=i[++u],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function yi(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function ee(e){return new Float64Array(e)}const vi=(3+16*Bt)*Bt,bi=(2+12*Bt)*Bt,xi=(9+64*Bt)*Bt*Bt,Qt=ee(4),an=ee(8),cn=ee(12),fn=ee(16),yt=ee(4);function _i(e,t,n,i,o,r,s){let a,c,l,h,f,u,p,_,w,O,M,m,v,d,b,g,E,S;const k=e-o,P=n-o,N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f),yt[3]=S;const A=Re(I,an,4,yt,cn);d=a*h,u=dt*a,p=u-(u-a),_=a-p,u=dt*h,w=u-(u-h),O=h-w,b=_*O-(d-p*w-_*w-p*O),g=c*l,u=dt*c,p=u-(u-c),_=c-p,u=dt*l,w=u-(u-l),O=l-w,E=_*O-(g-p*w-_*w-p*O),M=b-E,f=b-M,yt[0]=b-(M+f)+(f-E),m=d+M,f=m-d,v=d-(m-f)+(M-f),M=v-g,f=v-M,yt[1]=v-(M+f)+(f-g),S=m+M,f=S-m,yt[2]=m-(S-f)+(M-f),yt[3]=S;const T=Re(A,cn,4,yt,fn);return fn[T-1]}function ln(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),c=s-a;if(s===0||a===0||s>0!=a>0)return c;const l=Math.abs(s+a);return Math.abs(c)>=vi*l?c:-_i(e,t,n,i,o,r,l)}function Mi(e,t){const n=new Fe([],hn);return Ei(e,n),ki(n,t)}function hn(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x||e.p.x===t.p.x&&(e.featureId!==t.featureId||e.ringId!==t.ringId)&&e.isLeftEndpoint&&!t.isLeftEndpoint?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function Si(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}function Ei(e,t){if(e.type==="FeatureCollection"){const n=e.features;for(let i=0;i<n.length;i++)un(n[i],t)}else un(e,t)}var ve=0,be=0,xe=0;function un(e,t){const n=e.type==="Feature"?e.geometry:e;let i=n.coordinates;(n.type==="Polygon"||n.type==="MultiLineString")&&(i=[i]),n.type==="LineString"&&(i=[[i]]);for(let o=0;o<i.length;o++)for(let r=0;r<i[o].length;r++){let s=i[o][r][0],a=null;be=be+1;for(let c=0;c<i[o][r].length-1;c++){a=i[o][r][c+1];const l=new dn(s,ve,be,xe),h=new dn(a,ve,be,xe+1);l.otherEvent=h,h.otherEvent=l,hn(l,h)>0?(h.isLeftEndpoint=!0,l.isLeftEndpoint=!1):(l.isLeftEndpoint=!0,h.isLeftEndpoint=!1),t.push(l),t.push(h),s=a,xe=xe+1}}ve=ve+1}var dn=class{constructor(e,t,n,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=n,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}asNewXY(){return[this.p.x,this.p.y]}};function ki(e,t=!1){const n=[],i=new Fe([],Si);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const r=new Ai(o);for(let s=0;s<i.data.length;s++){const a=i.data[s];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const c=Ii(r,a);c!==!1&&n.push(c)}i.push(r)}else o.isLeftEndpoint===!1&&i.pop()}return n}var Ai=class{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}};function Ii(e,t){if(e===null||t===null)return!1;const n=e.leftSweepEvent.p.x,i=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,r=e.rightSweepEvent.p.y,s=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,c=t.rightSweepEvent.p.x,l=t.rightSweepEvent.p.y,h=ln(n,i,o,r,s,a),f=ln(n,i,o,r,c,l);if(h>0&&f>0)return!1;if(h<0&&f<0)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId){if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return!1}else{if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.rightSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY()}const u=(l-a)*(o-n)-(c-s)*(r-i),p=(c-s)*(i-a)-(l-a)*(n-s),_=(o-n)*(i-a)-(r-i)*(n-s);if(u===0)return!1;const w=p/u,O=_/u;if(w>=0&&w<=1&&O>=0&&O<=1){const M=n+w*(o-n),m=i+w*(r-i);return[M,m]}return!1}function Oi(e,t,n={}){const{removeDuplicates:i=!0,ignoreSelfIntersections:o=!0}=n;let r=[];e.type==="FeatureCollection"?r=r.concat(e.features):e.type==="Feature"?r.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&r.push(Nt(e)),t.type==="FeatureCollection"?r=r.concat(t.features):t.type==="Feature"?r.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&r.push(Nt(t));const s=Mi(Et(r),o);let a=[];if(i){const c={};s.forEach(l=>{const h=l.join(",");c[h]||(c[h]=!0,a.push(l))})}else a=s;return Et(a.map(c=>$t(c)))}function Pi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ni(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function i(){var o=!1;try{o=this instanceof i}catch{}return o?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}),n}function Bi(e,t={}){let n=0,i=0,o=0;return Oe(e,function(r){n+=r[0],i+=r[1],o++},!0),$t([n/o,i/o],t.properties)}var _e={exports:{}},Me={exports:{}},Ti=Me.exports,pn;function Ci(){return pn||(pn=1,(function(e,t){(function(n,i){e.exports=i()})(Ti,function(){function n(m,v,d,b,g){(function E(S,k,P,N,C){for(;N>P;){if(N-P>600){var F=N-P+1,y=k-P+1,I=Math.log(F),A=.5*Math.exp(2*I/3),T=.5*Math.sqrt(I*A*(F-A)/F)*(y-F/2<0?-1:1),X=Math.max(P,Math.floor(k-y*A/F+T)),D=Math.min(N,Math.floor(k+(F-y)*A/F+T));E(S,k,X,D,C)}var x=S[k],B=P,$=N;for(i(S,P,k),C(S[N],x)>0&&i(S,P,N);B<$;){for(i(S,B,$),B++,$--;C(S[B],x)<0;)B++;for(;C(S[$],x)>0;)$--}C(S[P],x)===0?i(S,P,$):i(S,++$,N),$<=k&&(P=$+1),k<=$&&(N=$-1)}})(m,v,d||0,b||m.length-1,g||o)}function i(m,v,d){var b=m[v];m[v]=m[d],m[d]=b}function o(m,v){return m<v?-1:m>v?1:0}var r=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,v,d){if(!d)return v.indexOf(m);for(var b=0;b<v.length;b++)if(d(m,v[b]))return b;return-1}function a(m,v){c(m,0,m.children.length,v,m)}function c(m,v,d,b,g){g||(g=O(null)),g.minX=1/0,g.minY=1/0,g.maxX=-1/0,g.maxY=-1/0;for(var E=v;E<d;E++){var S=m.children[E];l(g,m.leaf?b(S):S)}return g}function l(m,v){return m.minX=Math.min(m.minX,v.minX),m.minY=Math.min(m.minY,v.minY),m.maxX=Math.max(m.maxX,v.maxX),m.maxY=Math.max(m.maxY,v.maxY),m}function h(m,v){return m.minX-v.minX}function f(m,v){return m.minY-v.minY}function u(m){return(m.maxX-m.minX)*(m.maxY-m.minY)}function p(m){return m.maxX-m.minX+(m.maxY-m.minY)}function _(m,v){return m.minX<=v.minX&&m.minY<=v.minY&&v.maxX<=m.maxX&&v.maxY<=m.maxY}function w(m,v){return v.minX<=m.maxX&&v.minY<=m.maxY&&v.maxX>=m.minX&&v.maxY>=m.minY}function O(m){return{children:m,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function M(m,v,d,b,g){for(var E=[v,d];E.length;)if(!((d=E.pop())-(v=E.pop())<=b)){var S=v+Math.ceil((d-v)/b/2)*b;n(m,S,v,d,g),E.push(v,S,S,d)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(m){var v=this.data,d=[];if(!w(m,v))return d;for(var b=this.toBBox,g=[];v;){for(var E=0;E<v.children.length;E++){var S=v.children[E],k=v.leaf?b(S):S;w(m,k)&&(v.leaf?d.push(S):_(m,k)?this._all(S,d):g.push(S))}v=g.pop()}return d},r.prototype.collides=function(m){var v=this.data;if(!w(m,v))return!1;for(var d=[];v;){for(var b=0;b<v.children.length;b++){var g=v.children[b],E=v.leaf?this.toBBox(g):g;if(w(m,E)){if(v.leaf||_(m,E))return!0;d.push(g)}}v=d.pop()}return!1},r.prototype.load=function(m){if(!m||!m.length)return this;if(m.length<this._minEntries){for(var v=0;v<m.length;v++)this.insert(m[v]);return this}var d=this._build(m.slice(),0,m.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var b=this.data;this.data=d,d=b}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},r.prototype.insert=function(m){return m&&this._insert(m,this.data.height-1),this},r.prototype.clear=function(){return this.data=O([]),this},r.prototype.remove=function(m,v){if(!m)return this;for(var d,b,g,E=this.data,S=this.toBBox(m),k=[],P=[];E||k.length;){if(E||(E=k.pop(),b=k[k.length-1],d=P.pop(),g=!0),E.leaf){var N=s(m,E.children,v);if(N!==-1)return E.children.splice(N,1),k.push(E),this._condense(k),this}g||E.leaf||!_(E,S)?b?(d++,E=b.children[d],g=!1):E=null:(k.push(E),P.push(d),d=0,b=E,E=E.children[0])}return this},r.prototype.toBBox=function(m){return m},r.prototype.compareMinX=function(m,v){return m.minX-v.minX},r.prototype.compareMinY=function(m,v){return m.minY-v.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(m){return this.data=m,this},r.prototype._all=function(m,v){for(var d=[];m;)m.leaf?v.push.apply(v,m.children):d.push.apply(d,m.children),m=d.pop();return v},r.prototype._build=function(m,v,d,b){var g,E=d-v+1,S=this._maxEntries;if(E<=S)return a(g=O(m.slice(v,d+1)),this.toBBox),g;b||(b=Math.ceil(Math.log(E)/Math.log(S)),S=Math.ceil(E/Math.pow(S,b-1))),(g=O([])).leaf=!1,g.height=b;var k=Math.ceil(E/S),P=k*Math.ceil(Math.sqrt(S));M(m,v,d,P,this.compareMinX);for(var N=v;N<=d;N+=P){var C=Math.min(N+P-1,d);M(m,N,C,k,this.compareMinY);for(var F=N;F<=C;F+=k){var y=Math.min(F+k-1,C);g.children.push(this._build(m,F,y,b-1))}}return a(g,this.toBBox),g},r.prototype._chooseSubtree=function(m,v,d,b){for(;b.push(v),!v.leaf&&b.length-1!==d;){for(var g=1/0,E=1/0,S=void 0,k=0;k<v.children.length;k++){var P=v.children[k],N=u(P),C=(F=m,y=P,(Math.max(y.maxX,F.maxX)-Math.min(y.minX,F.minX))*(Math.max(y.maxY,F.maxY)-Math.min(y.minY,F.minY))-N);C<E?(E=C,g=N<g?N:g,S=P):C===E&&N<g&&(g=N,S=P)}v=S||v.children[0]}var F,y;return v},r.prototype._insert=function(m,v,d){var b=d?m:this.toBBox(m),g=[],E=this._chooseSubtree(b,this.data,v,g);for(E.children.push(m),l(E,b);v>=0&&g[v].children.length>this._maxEntries;)this._split(g,v),v--;this._adjustParentBBoxes(b,g,v)},r.prototype._split=function(m,v){var d=m[v],b=d.children.length,g=this._minEntries;this._chooseSplitAxis(d,g,b);var E=this._chooseSplitIndex(d,g,b),S=O(d.children.splice(E,d.children.length-E));S.height=d.height,S.leaf=d.leaf,a(d,this.toBBox),a(S,this.toBBox),v?m[v-1].children.push(S):this._splitRoot(d,S)},r.prototype._splitRoot=function(m,v){this.data=O([m,v]),this.data.height=m.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(m,v,d){for(var b,g,E,S,k,P,N,C=1/0,F=1/0,y=v;y<=d-v;y++){var I=c(m,0,y,this.toBBox),A=c(m,y,d,this.toBBox),T=(g=I,E=A,S=void 0,k=void 0,P=void 0,N=void 0,S=Math.max(g.minX,E.minX),k=Math.max(g.minY,E.minY),P=Math.min(g.maxX,E.maxX),N=Math.min(g.maxY,E.maxY),Math.max(0,P-S)*Math.max(0,N-k)),X=u(I)+u(A);T<C?(C=T,b=y,F=X<F?X:F):T===C&&X<F&&(F=X,b=y)}return b||d-v},r.prototype._chooseSplitAxis=function(m,v,d){var b=m.leaf?this.compareMinX:h,g=m.leaf?this.compareMinY:f;this._allDistMargin(m,v,d,b)<this._allDistMargin(m,v,d,g)&&m.children.sort(b)},r.prototype._allDistMargin=function(m,v,d,b){m.children.sort(b);for(var g=this.toBBox,E=c(m,0,v,g),S=c(m,d-v,d,g),k=p(E)+p(S),P=v;P<d-v;P++){var N=m.children[P];l(E,m.leaf?g(N):N),k+=p(E)}for(var C=d-v-1;C>=v;C--){var F=m.children[C];l(S,m.leaf?g(F):F),k+=p(S)}return k},r.prototype._adjustParentBBoxes=function(m,v,d){for(var b=d;b>=0;b--)l(v[b],m)},r.prototype._condense=function(m){for(var v=m.length-1,d=void 0;v>=0;v--)m[v].children.length===0?v>0?(d=m[v-1].children).splice(d.indexOf(m[v]),1):this.clear():a(m[v],this.toBBox)},r})})(Me)),Me.exports}const Xi=Ni(gi);var ne={exports:{}},Ye,mn;function $i(){return mn||(mn=1,Ye=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var c=(o-i)/2,l=0,h=c-1;l<c;h=l++){var f=n[i+l*2+0],u=n[i+l*2+1],p=n[i+h*2+0],_=n[i+h*2+1],w=u>s!=_>s&&r<(p-f)*(s-u)/(_-u)+f;w&&(a=!a)}return a}),Ye}var Le,gn;function Di(){return gn||(gn=1,Le=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var c=o-i,l=0,h=c-1;l<c;h=l++){var f=n[l+i][0],u=n[l+i][1],p=n[h+i][0],_=n[h+i][1],w=u>s!=_>s&&r<(p-f)*(s-u)/(_-u)+f;w&&(a=!a)}return a}),Le}var wn;function Fi(){if(wn)return ne.exports;wn=1;var e=$i(),t=Di();return ne.exports=function(i,o,r,s){return o.length>0&&Array.isArray(o[0])?t(i,o,r,s):e(i,o,r,s)},ne.exports.nested=t,ne.exports.flat=e,ne.exports}var ie={exports:{}},Ri=ie.exports,yn;function Yi(){return yn||(yn=1,(function(e,t){(function(n,i){i(t)})(Ri,function(n){const o=33306690738754706e-32;function r(w,O,M,m,v){let d,b,g,E,S=O[0],k=m[0],P=0,N=0;k>S==k>-S?(d=S,S=O[++P]):(d=k,k=m[++N]);let C=0;if(P<w&&N<M)for(k>S==k>-S?(g=d-((b=S+d)-S),S=O[++P]):(g=d-((b=k+d)-k),k=m[++N]),d=b,g!==0&&(v[C++]=g);P<w&&N<M;)k>S==k>-S?(g=d-((b=d+S)-(E=b-d))+(S-E),S=O[++P]):(g=d-((b=d+k)-(E=b-d))+(k-E),k=m[++N]),d=b,g!==0&&(v[C++]=g);for(;P<w;)g=d-((b=d+S)-(E=b-d))+(S-E),S=O[++P],d=b,g!==0&&(v[C++]=g);for(;N<M;)g=d-((b=d+k)-(E=b-d))+(k-E),k=m[++N],d=b,g!==0&&(v[C++]=g);return d===0&&C!==0||(v[C++]=d),C}function s(w){return new Float64Array(w)}const a=33306690738754716e-32,c=22204460492503146e-32,l=11093356479670487e-47,h=s(4),f=s(8),u=s(12),p=s(16),_=s(4);n.orient2d=function(w,O,M,m,v,d){const b=(O-d)*(M-v),g=(w-v)*(m-d),E=b-g;if(b===0||g===0||b>0!=g>0)return E;const S=Math.abs(b+g);return Math.abs(E)>=a*S?E:-(function(k,P,N,C,F,y,I){let A,T,X,D,x,B,$,R,L,V,U,j,G,J,Q,H,Z,W;const ct=k-F,ht=N-F,rt=P-y,ot=C-y;x=(Q=(R=ct-($=(B=134217729*ct)-(B-ct)))*(V=ot-(L=(B=134217729*ot)-(B-ot)))-((J=ct*ot)-$*L-R*L-$*V))-(U=Q-(Z=(R=rt-($=(B=134217729*rt)-(B-rt)))*(V=ht-(L=(B=134217729*ht)-(B-ht)))-((H=rt*ht)-$*L-R*L-$*V))),h[0]=Q-(U+x)+(x-Z),x=(G=J-((j=J+U)-(x=j-J))+(U-x))-(U=G-H),h[1]=G-(U+x)+(x-H),x=(W=j+U)-j,h[2]=j-(W-x)+(U-x),h[3]=W;let Vt=(function(bo,ti){let ei=ti[0];for(let We=1;We<bo;We++)ei+=ti[We];return ei})(4,h),me=c*I;if(Vt>=me||-Vt>=me||(A=k-(ct+(x=k-ct))+(x-F),X=N-(ht+(x=N-ht))+(x-F),T=P-(rt+(x=P-rt))+(x-y),D=C-(ot+(x=C-ot))+(x-y),A===0&&T===0&&X===0&&D===0)||(me=l*I+o*Math.abs(Vt),(Vt+=ct*D+ot*A-(rt*X+ht*T))>=me||-Vt>=me))return Vt;x=(Q=(R=A-($=(B=134217729*A)-(B-A)))*(V=ot-(L=(B=134217729*ot)-(B-ot)))-((J=A*ot)-$*L-R*L-$*V))-(U=Q-(Z=(R=T-($=(B=134217729*T)-(B-T)))*(V=ht-(L=(B=134217729*ht)-(B-ht)))-((H=T*ht)-$*L-R*L-$*V))),_[0]=Q-(U+x)+(x-Z),x=(G=J-((j=J+U)-(x=j-J))+(U-x))-(U=G-H),_[1]=G-(U+x)+(x-H),x=(W=j+U)-j,_[2]=j-(W-x)+(U-x),_[3]=W;const wo=r(4,h,4,_,f);x=(Q=(R=ct-($=(B=134217729*ct)-(B-ct)))*(V=D-(L=(B=134217729*D)-(B-D)))-((J=ct*D)-$*L-R*L-$*V))-(U=Q-(Z=(R=rt-($=(B=134217729*rt)-(B-rt)))*(V=X-(L=(B=134217729*X)-(B-X)))-((H=rt*X)-$*L-R*L-$*V))),_[0]=Q-(U+x)+(x-Z),x=(G=J-((j=J+U)-(x=j-J))+(U-x))-(U=G-H),_[1]=G-(U+x)+(x-H),x=(W=j+U)-j,_[2]=j-(W-x)+(U-x),_[3]=W;const yo=r(wo,f,4,_,u);x=(Q=(R=A-($=(B=134217729*A)-(B-A)))*(V=D-(L=(B=134217729*D)-(B-D)))-((J=A*D)-$*L-R*L-$*V))-(U=Q-(Z=(R=T-($=(B=134217729*T)-(B-T)))*(V=X-(L=(B=134217729*X)-(B-X)))-((H=T*X)-$*L-R*L-$*V))),_[0]=Q-(U+x)+(x-Z),x=(G=J-((j=J+U)-(x=j-J))+(U-x))-(U=G-H),_[1]=G-(U+x)+(x-H),x=(W=j+U)-j,_[2]=j-(W-x)+(U-x),_[3]=W;const vo=r(yo,u,4,_,p);return p[vo-1]})(w,O,M,m,v,d,S)},n.orient2dfast=function(w,O,M,m,v,d){return(O-d)*(M-v)-(w-v)*(m-d)},Object.defineProperty(n,"__esModule",{value:!0})})})(ie,ie.exports)),ie.exports}var vn;function Li(){if(vn)return _e.exports;vn=1;var e=Ci(),t=Xi,n=Fi(),i=Yi().orient2d;t.default&&(t=t.default),_e.exports=o,_e.exports.default=o;function o(d,b,g){b=Math.max(0,b===void 0?2:b),g=g||0;var E=p(d),S=new e(16);S.toBBox=function($){return{minX:$[0],minY:$[1],maxX:$[0],maxY:$[1]}},S.compareMinX=function($,R){return $[0]-R[0]},S.compareMinY=function($,R){return $[1]-R[1]},S.load(d);for(var k=[],P=0,N;P<E.length;P++){var C=E[P];S.remove(C),N=_(C,N),k.push(N)}var F=new e(16);for(P=0;P<k.length;P++)F.insert(u(k[P]));for(var y=b*b,I=g*g;k.length;){var A=k.shift(),T=A.p,X=A.next.p,D=w(T,X);if(!(D<I)){var x=D/y;C=r(S,A.prev.p,T,X,A.next.next.p,x,F),C&&Math.min(w(C,T),w(C,X))<=x&&(k.push(A),k.push(_(C,A)),S.remove(C),F.remove(A),F.insert(u(A)),F.insert(u(A.next)))}}A=N;var B=[];do B.push(A.p),A=A.next;while(A!==N);return B.push(A.p),B}function r(d,b,g,E,S,k,P){for(var N=new t([],s),C=d.data;C;){for(var F=0;F<C.children.length;F++){var y=C.children[F],I=C.leaf?O(y,g,E):a(g,E,y);I>k||N.push({node:y,dist:I})}for(;N.length&&!N.peek().node.children;){var A=N.pop(),T=A.node,X=O(T,b,g),D=O(T,E,S);if(A.dist<X&&A.dist<D&&l(g,T,P)&&l(E,T,P))return T}C=N.pop(),C&&(C=C.node)}return null}function s(d,b){return d.dist-b.dist}function a(d,b,g){if(c(d,g)||c(b,g))return 0;var E=M(d[0],d[1],b[0],b[1],g.minX,g.minY,g.maxX,g.minY);if(E===0)return 0;var S=M(d[0],d[1],b[0],b[1],g.minX,g.minY,g.minX,g.maxY);if(S===0)return 0;var k=M(d[0],d[1],b[0],b[1],g.maxX,g.minY,g.maxX,g.maxY);if(k===0)return 0;var P=M(d[0],d[1],b[0],b[1],g.minX,g.maxY,g.maxX,g.maxY);return P===0?0:Math.min(E,S,k,P)}function c(d,b){return d[0]>=b.minX&&d[0]<=b.maxX&&d[1]>=b.minY&&d[1]<=b.maxY}function l(d,b,g){for(var E=Math.min(d[0],b[0]),S=Math.min(d[1],b[1]),k=Math.max(d[0],b[0]),P=Math.max(d[1],b[1]),N=g.search({minX:E,minY:S,maxX:k,maxY:P}),C=0;C<N.length;C++)if(f(N[C].p,N[C].next.p,d,b))return!1;return!0}function h(d,b,g){return i(d[0],d[1],b[0],b[1],g[0],g[1])}function f(d,b,g,E){return d!==E&&b!==g&&h(d,b,g)>0!=h(d,b,E)>0&&h(g,E,d)>0!=h(g,E,b)>0}function u(d){var b=d.p,g=d.next.p;return d.minX=Math.min(b[0],g[0]),d.minY=Math.min(b[1],g[1]),d.maxX=Math.max(b[0],g[0]),d.maxY=Math.max(b[1],g[1]),d}function p(d){for(var b=d[0],g=d[0],E=d[0],S=d[0],k=0;k<d.length;k++){var P=d[k];P[0]<b[0]&&(b=P),P[0]>E[0]&&(E=P),P[1]<g[1]&&(g=P),P[1]>S[1]&&(S=P)}var N=[b,g,E,S],C=N.slice();for(k=0;k<d.length;k++)n(d[k],N)||C.push(d[k]);return v(C)}function _(d,b){var g={p:d,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return b?(g.next=b.next,g.prev=b,b.next.prev=g,b.next=g):(g.prev=g,g.next=g),g}function w(d,b){var g=d[0]-b[0],E=d[1]-b[1];return g*g+E*E}function O(d,b,g){var E=b[0],S=b[1],k=g[0]-E,P=g[1]-S;if(k!==0||P!==0){var N=((d[0]-E)*k+(d[1]-S)*P)/(k*k+P*P);N>1?(E=g[0],S=g[1]):N>0&&(E+=k*N,S+=P*N)}return k=d[0]-E,P=d[1]-S,k*k+P*P}function M(d,b,g,E,S,k,P,N){var C=g-d,F=E-b,y=P-S,I=N-k,A=d-S,T=b-k,X=C*C+F*F,D=C*y+F*I,x=y*y+I*I,B=C*A+F*T,$=y*A+I*T,R=X*x-D*D,L,V,U,j,G=R,J=R;R===0?(V=0,G=1,j=$,J=x):(V=D*$-x*B,j=X*$-D*B,V<0?(V=0,j=$,J=x):V>G&&(V=G,j=$+D,J=x)),j<0?(j=0,-B<0?V=0:-B>X?V=G:(V=-B,G=X)):j>J&&(j=J,-B+D<0?V=0:-B+D>X?V=G:(V=-B+D,G=X)),L=V===0?0:V/G,U=j===0?0:j/J;var Q=(1-L)*d+L*g,H=(1-L)*b+L*E,Z=(1-U)*S+U*P,W=(1-U)*k+U*N,ct=Z-Q,ht=W-H;return ct*ct+ht*ht}function m(d,b){return d[0]===b[0]?d[1]-b[1]:d[0]-b[0]}function v(d){d.sort(m);for(var b=[],g=0;g<d.length;g++){for(;b.length>=2&&h(b[b.length-2],b[b.length-1],d[g])<=0;)b.pop();b.push(d[g])}for(var E=[],S=d.length-1;S>=0;S--){for(;E.length>=2&&h(E[E.length-2],E[E.length-1],d[S])<=0;)E.pop();E.push(d[S])}return E.pop(),b.pop(),b.concat(E)}return _e.exports}var Vi=Li();const ji=Pi(Vi);function bn(e,t={}){t.concavity=t.concavity||1/0;const n=[];if(Oe(e,o=>{n.push([o[0],o[1]])}),!n.length)return null;const i=ji(n,t.concavity);return i.length>3?te([i],t.properties):null}function xn(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function re(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Mn(e[0])||!Mn(e[1]))throw new Error("coordinates must contain numbers");return xn({type:"Point",coordinates:e},t,n)}function _n(e,t,n={}){for(const i of e){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 o=0;o<i[i.length-1].length;o++)if(i[i.length-1][o]!==i[0][o])throw new Error("First and last Position are not equivalent.")}return xn({type:"Polygon",coordinates:e},t,n)}function Ht(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function Mn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function Ui(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Sn(e){if(Array.isArray(e))return e;if(e.type==="Feature"){if(e.geometry!==null)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function qi(e){return e.type==="Feature"?e.geometry:e}const Tt=11102230246251565e-32,pt=134217729,zi=(3+8*Tt)*Tt;function Ve(e,t,n,i,o){let r,s,a,c,l=t[0],h=i[0],f=0,u=0;h>l==h>-l?(r=l,l=t[++f]):(r=h,h=i[++u]);let p=0;if(f<e&&u<n)for(h>l==h>-l?(s=l+r,a=r-(s-l),l=t[++f]):(s=h+r,a=r-(s-h),h=i[++u]),r=s,a!==0&&(o[p++]=a);f<e&&u<n;)h>l==h>-l?(s=r+l,c=s-r,a=r-(s-c)+(l-c),l=t[++f]):(s=r+h,c=s-r,a=r-(s-c)+(h-c),h=i[++u]),r=s,a!==0&&(o[p++]=a);for(;f<e;)s=r+l,c=s-r,a=r-(s-c)+(l-c),l=t[++f],r=s,a!==0&&(o[p++]=a);for(;u<n;)s=r+h,c=s-r,a=r-(s-c)+(h-c),h=i[++u],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Ji(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function oe(e){return new Float64Array(e)}const Gi=(3+16*Tt)*Tt,Ki=(2+12*Tt)*Tt,Qi=(9+64*Tt)*Tt*Tt,Wt=oe(4),En=oe(8),kn=oe(12),An=oe(16),vt=oe(4);function Hi(e,t,n,i,o,r,s){let a,c,l,h,f,u,p,_,w,O,M,m,v,d,b,g,E,S;const k=e-o,P=n-o,N=t-r,C=i-r;d=k*C,u=pt*k,p=u-(u-k),_=k-p,u=pt*C,w=u-(u-C),O=C-w,b=_*O-(d-p*w-_*w-p*O),g=N*P,u=pt*N,p=u-(u-N),_=N-p,u=pt*P,w=u-(u-P),O=P-w,E=_*O-(g-p*w-_*w-p*O),M=b-E,f=b-M,Wt[0]=b-(M+f)+(f-E),m=d+M,f=m-d,v=d-(m-f)+(M-f),M=v-g,f=v-M,Wt[1]=v-(M+f)+(f-g),S=m+M,f=S-m,Wt[2]=m-(S-f)+(M-f),Wt[3]=S;let F=Ji(4,Wt),y=Ki*s;if(F>=y||-F>=y||(f=e-k,a=e-(k+f)+(f-o),f=n-P,l=n-(P+f)+(f-o),f=t-N,c=t-(N+f)+(f-r),f=i-C,h=i-(C+f)+(f-r),a===0&&c===0&&l===0&&h===0)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,o,r,l)}function Zi(e,t){var n,i,o=0,r,s,a,c,l,h,f,u=e[0],p=e[1],_=t.length;for(n=0;n<_;n++){i=0;var w=t[n],O=w.length-1;if(h=w[0],h[0]!==w[O][0]&&h[1]!==w[O][1])throw new Error("First and last coordinates in a ring must be the same");for(s=h[0]-u,a=h[1]-p,i;i<O;i++){if(f=w[i+1],c=f[0]-u,l=f[1]-p,a===0&&l===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(r=Wi(s,c,a,l,0,0),r===0)return 0;(r>0&&l>0&&a<=0||r<0&&l<=0&&a>0)&&o++}h=f,a=l,s=c}}return o%2!==0}function je(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=Ui(e),o=qi(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&tr(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var c=0;c<a.length;++c){const l=Zi(i,a[c]);if(l===0&&!n.ignoreBoundary||l)return!0}return!1}function tr(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}function Ue(e,t){for(let n=0;n<t.features.length;n++)if(je(e,t.features[n]))return t.features[n]}function In(e,t){const n=t.geometry.coordinates[0][0],i=t.geometry.coordinates[0][1],o=t.geometry.coordinates[0][2],r=e.geometry.coordinates,s=t.properties.a.geom,a=t.properties.b.geom,c=t.properties.c.geom,l=[i[0]-n[0],i[1]-n[1]],h=[o[0]-n[0],o[1]-n[1]],f=[r[0]-n[0],r[1]-n[1]],u=[a[0]-s[0],a[1]-s[1]],p=[c[0]-s[0],c[1]-s[1]],_=(h[1]*f[0]-h[0]*f[1])/(l[0]*h[1]-l[1]*h[0]),w=(l[0]*f[1]-l[1]*f[0])/(l[0]*h[1]-l[1]*h[0]);return[_*u[0]+w*p[0]+s[0],_*u[1]+w*p[1]+s[1]]}function er(e,t,n){const i=e.geometry.coordinates,o=n.geometry.coordinates,r=Math.atan2(i[0]-o[0],i[1]-o[1]),s=ir(r,t[0]);if(s===void 0)throw new Error("Unable to determine vertex index");const a=t[1][s];return In(e,a.features[0])}function se(e,t,n,i,o,r,s,a){let c;if(s&&(c=Ue(e,Ht([s]))),!c)if(n){const l=e.geometry.coordinates,h=n.gridNum,f=n.xOrigin,u=n.yOrigin,p=n.xUnit,_=n.yUnit,w=n.gridCache,O=_t(l[0],f,p,h),M=_t(l[1],u,_,h),m=w[O]?w[O][M]?w[O][M]:[]:[],v=Ht(m.map(d=>t.features[d]));c=Ue(e,v)}else c=Ue(e,t);return a&&a(c),c?In(e,c):er(e,i,o)}function _t(e,t,n,i){let o=Math.floor((e-t)/n);return o<0&&(o=0),o>=i&&(o=i-1),o}const nr=36;function On(e,t,n){const i=(t[1][0]-t[0][0])/n,o=(t[1][1]-t[0][1])/n;return e.reduce((r,s)=>{const a=_t(s[0][0],t[0][0],i,n),c=_t(s[1][0],t[0][0],i,n),l=_t(s[0][1],t[0][1],o,n),h=_t(s[1][1],t[0][1],o,n),f=(c-a+1)*(h-l+1);return f>0?r+f:r},0)}function ir(e,t){let n=Pn(e-t[0]),i=Math.PI*2,o;for(let r=0;r<t.length;r++){const s=(r+1)%t.length,a=Pn(e-t[s]),c=Math.min(Math.abs(n),Math.abs(a));n*a<=0&&c<i&&(i=c,o=r),n=a}return o}function Pn(e,t=!1){const n=2*Math.PI,i=e-Math.floor(e/n)*n;return t?i:i>Math.PI?i-n:i}function Nn(e){const t=e.features;for(let n=0;n<t.length;n++){const i=t[n];`${i.properties.a.index}`.substring(0,1)==="b"&&`${i.properties.b.index}`.substring(0,1)==="b"?t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1],i.geometry.coordinates[0][2]]]},properties:{a:{geom:i.properties.c.geom,index:i.properties.c.index},b:{geom:i.properties.a.geom,index:i.properties.a.index},c:{geom:i.properties.b.geom,index:i.properties.b.index}},type:"Feature"}:`${i.properties.c.index}`.substring(0,1)==="b"&&`${i.properties.a.index}`.substring(0,1)==="b"&&(t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][1],i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1]]]},properties:{a:{geom:i.properties.b.geom,index:i.properties.b.index},b:{geom:i.properties.c.geom,index:i.properties.c.index},c:{geom:i.properties.a.geom,index:i.properties.a.index}},type:"Feature"})}return e}function Bn(e){const t=["a","b","c","a"].map(r=>e.properties[r].geom),n=e.geometry.coordinates[0],i=e.properties,o={a:{geom:n[0],index:i.a.index},b:{geom:n[1],index:i.b.index},c:{geom:n[2],index:i.c.index}};return _n([t],o)}function rr(e){const t=[0,1,2,0].map(i=>e[i][0][0]),n={a:{geom:e[0][0][1],index:e[0][1]},b:{geom:e[1][0][1],index:e[1][1]},c:{geom:e[2][0][1],index:e[2][1]}};return _n([t],n)}function qe(e,t,n,i,o,r=!1,s){const a=e.map(c=>{(!s||s<2.00703)&&(c=or(c));const l=isFinite(c)?t[c]:c==="c"?i:(function(){const h=c.match(/^b(\d+)$/);if(h)return o[parseInt(h[1])];const f=c.match(/^e(\d+)$/);if(f)return n[parseInt(f[1])];throw new Error("Bad index value for indexesToTri")})();return r?[[l[1],l[0]],c]:[[l[0],l[1]],c]});return rr(a)}function or(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function Tn(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(n=>[n.illstNodes,n.mercNodes,n.startEnd])}const sr=2.00704;function ar(e){return!!(e.version!==void 0||!e.tins&&e.points&&e.tins_points)}function cr(e){return{points:e.points,strictStatus:lr(e),verticesParams:hr(e),centroid:ur(e),edges:Tn(e.edges||[]),edgeNodes:e.edgeNodes||[],tins:dr(e),kinks:pr(e.kinks_points),yaxisMode:e.yaxisMode??"invert",strictMode:e.strictMode??"auto",vertexMode:e.vertexMode,bounds:e.bounds,boundsPolygon:e.boundsPolygon,wh:e.wh,xy:e.xy??[0,0]}}function fr(e){const t=mr(e),n=t.tins,i=t.vertices_params;return i!=null&&Cn(i),{compiled:t,tins:n,points:gr(n),strictStatus:t.strict_status,verticesParams:i,centroid:t.centroid,kinks:t.kinks}}function lr(e){return e.strict_status?e.strict_status:e.kinks_points?"strict_error":e.tins_points.length===2?"loose":"strict"}function hr(e){if(!Array.isArray(e.vertices_params)||!Array.isArray(e.vertices_points))throw new Error("Invalid compiled data: vertices_params and vertices_points must be arrays");const t={forw:[e.vertices_params[0]],bakw:[e.vertices_params[1]]};return t.forw[1]=Xn(e,!1),t.bakw[1]=Xn(e,!0),Cn(t),t}function Cn(e){if(typeof e!="object")throw new Error("Invalid compiled data: vertices_params has a wrong shape");["forw","bakw"].forEach(t=>{const n=e[t];if(n==null)return;const i=`vertices_params.${t}`,o=n[0],r=n[1];if(!Array.isArray(o)||!Array.isArray(r))throw new Error(`Invalid compiled data: ${i} must hold two arrays`);if(o.length!==r.length)throw new Error(`Invalid compiled data: ${i} must have one angle per vertex`);for(let s=0;s<o.length;s++)if(typeof o[s]!="number"||!Number.isFinite(o[s]))throw new Error(`Invalid compiled data: ${i} must contain only finite numbers`)})}function Xn(e,t){const n=e.vertices_points.length;return Array.from({length:n},(i,o)=>{const r=(o+1)%n,s=qe(["c",`b${o}`,`b${r}`],e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,t,sr);return Ht([s])})}function ur(e){return{forw:re(e.centroid_point[0],{target:{geom:e.centroid_point[1],index:"c"}}),bakw:re(e.centroid_point[1],{target:{geom:e.centroid_point[0],index:"c"}})}}function dr(e){const t=e.tins_points.length===1?0:1;return{forw:Ht(e.tins_points[0].map(n=>qe(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!1,e.version))),bakw:Ht(e.tins_points[t].map(n=>qe(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!0,e.version)))}}function pr(e){if(e)return{bakw:Ht(e.map(t=>re(t)))}}function mr(e){return JSON.parse(JSON.stringify(e).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function gr(e){const t=[],n=e.forw.features;for(let i=0;i<n.length;i++){const o=n[i];["a","b","c"].forEach((r,s)=>{const a=o.geometry.coordinates[0][s],c=o.properties[r].geom,l=o.properties[r].index;typeof l=="number"&&(t[l]=[a,c])})}return t}class kt{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=kt.YAXIS_INVERT;strictMode=kt.MODE_AUTO;vertexMode=kt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(t){if(ar(t)){this.applyModernState(cr(t));return}this.applyLegacyState(fr(t))}applyModernState(t){this.points=t.points,this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.edges=t.edges,this.edgeNodes=t.edgeNodes||[],this.tins=t.tins,this.addIndexedTin(),this.kinks=t.kinks,this.yaxisMode=t.yaxisMode??kt.YAXIS_INVERT,this.vertexMode=t.vertexMode??kt.VERTEX_PLAIN,this.strictMode=t.strictMode??kt.MODE_AUTO,t.bounds?(this.bounds=t.bounds,this.boundsPolygon=t.boundsPolygon,this.xy=t.xy,this.wh=t.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=t.xy??[0,0],t.wh&&(this.wh=t.wh))}applyLegacyState(t){this.tins=t.tins,this.addIndexedTin(),this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.kinks=t.kinks,this.points=t.points}addIndexedTin(){const t=this.tins,n=t.forw,i=t.bakw,o=Math.ceil(Math.sqrt(n.features.length));if(o<3){this.indexedTins=void 0;return}let r=[],s=[];const a=n.features.map(w=>{let O=[];return Sn(w)[0].map(M=>{r.length===0?r=[Array.from(M),Array.from(M)]:(M[0]<r[0][0]&&(r[0][0]=M[0]),M[0]>r[1][0]&&(r[1][0]=M[0]),M[1]<r[0][1]&&(r[0][1]=M[1]),M[1]>r[1][1]&&(r[1][1]=M[1])),O.length===0?O=[Array.from(M),Array.from(M)]:(M[0]<O[0][0]&&(O[0][0]=M[0]),M[0]>O[1][0]&&(O[1][0]=M[0]),M[1]<O[0][1]&&(O[0][1]=M[1]),M[1]>O[1][1]&&(O[1][1]=M[1]))}),O}),c=i.features.map(w=>{let O=[];return Sn(w)[0].map(M=>{s.length===0?s=[Array.from(M),Array.from(M)]:(M[0]<s[0][0]&&(s[0][0]=M[0]),M[0]>s[1][0]&&(s[1][0]=M[0]),M[1]<s[0][1]&&(s[0][1]=M[1]),M[1]>s[1][1]&&(s[1][1]=M[1])),O.length===0?O=[Array.from(M),Array.from(M)]:(M[0]<O[0][0]&&(O[0][0]=M[0]),M[0]>O[1][0]&&(O[1][0]=M[0]),M[1]<O[0][1]&&(O[0][1]=M[1]),M[1]>O[1][1]&&(O[1][1]=M[1]))}),O});if(Math.max(On(a,r,o),On(c,s,o))>nr*n.features.length){this.indexedTins=void 0;return}const l=(r[1][0]-r[0][0])/o,h=(r[1][1]-r[0][1])/o,f=a.reduce((w,O,M)=>{const m=_t(O[0][0],r[0][0],l,o),v=_t(O[1][0],r[0][0],l,o),d=_t(O[0][1],r[0][1],h,o),b=_t(O[1][1],r[0][1],h,o);for(let g=m;g<=v;g++){w[g]||(w[g]=[]);for(let E=d;E<=b;E++)w[g][E]||(w[g][E]=[]),w[g][E].push(M)}return w},[]),u=(s[1][0]-s[0][0])/o,p=(s[1][1]-s[0][1])/o,_=c.reduce((w,O,M)=>{const m=_t(O[0][0],s[0][0],u,o),v=_t(O[1][0],s[0][0],u,o),d=_t(O[0][1],s[0][1],p,o),b=_t(O[1][1],s[0][1],p,o);for(let g=m;g<=v;g++){w[g]||(w[g]=[]);for(let E=d;E<=b;E++)w[g][E]||(w[g][E]=[]),w[g][E].push(M)}return w},[]);this.indexedTins={forw:{gridNum:o,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:l,yUnit:h,gridCache:f},bakw:{gridNum:o,xOrigin:s[0][0],yOrigin:s[0][1],xUnit:u,yUnit:p,gridCache:_}}}transform(t,n,i){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(n&&this.strict_status==kt.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==kt.YAXIS_FOLLOW&&n&&(t=[t[0],-1*t[1]]);const o=re(t);if(this.bounds&&!n&&!i&&!je(o,this.boundsPolygon))return!1;const r=n?this.tins.bakw:this.tins.forw,s=n?this.indexedTins?.bakw:this.indexedTins?.forw,a=n?this.vertices_params.bakw:this.vertices_params.forw,c=n?this.centroid.bakw:this.centroid.forw;let l,h;this.stateFull&&(this.stateBackward==n?l=this.stateTriangle:(this.stateBackward=n,this.stateTriangle=void 0),h=u=>{this.stateTriangle=u});let f=se(o,r,s,a,c,void 0,l,h);if(this.bounds&&n&&!i){const u=re(f);if(!je(u,this.boundsPolygon))return!1}else this.yaxisMode==kt.YAXIS_FOLLOW&&!n&&(f=[f[0],-1*f[1]]);return f}}const $n=Math.pow(2,-52),Se=new Uint32Array(512);class ze{static from(t,n=xr,i=_r){const o=t.length,r=new Float64Array(o*2);for(let s=0;s<o;s++){const a=t[s];r[2*s]=n(a),r[2*s+1]=i(a)}return new ze(r)}constructor(t){const n=t.length>>1;if(n>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const i=Math.max(2*n-5,0);this._triangles=new Uint32Array(i*3),this._halfedges=new Int32Array(i*3),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:i,_hullTri:o,_hullHash:r}=this,s=t.length>>1;let a=1/0,c=1/0,l=-1/0,h=-1/0;for(let k=0;k<s;k++){const P=t[2*k],N=t[2*k+1];P<a&&(a=P),N<c&&(c=N),P>l&&(l=P),N>h&&(h=N),this._ids[k]=k}const f=(a+l)/2,u=(c+h)/2;let p=0,_=0,w=0;for(let k=0,P=1/0;k<s;k++){const N=Je(f,u,t[2*k],t[2*k+1]);N<P&&(p=k,P=N)}const O=t[2*p],M=t[2*p+1];for(let k=0,P=1/0;k<s;k++){if(k===p)continue;const N=Je(O,M,t[2*k],t[2*k+1]);N<P&&N>0&&(_=k,P=N)}let m=t[2*_],v=t[2*_+1],d=1/0;for(let k=0;k<s;k++){if(k===p||k===_)continue;const P=vr(O,M,m,v,t[2*k],t[2*k+1]);P<d&&(w=k,d=P)}let b=t[2*w],g=t[2*w+1];if(d===1/0){for(let N=0;N<s;N++)this._dists[N]=t[2*N]-t[0]||t[2*N+1]-t[1];Zt(this._ids,this._dists,0,s-1);const k=new Uint32Array(s);let P=0;for(let N=0,C=-1/0;N<s;N++){const F=this._ids[N],y=this._dists[F];y>C&&(k[P++]=F,C=y)}this.hull=k.subarray(0,P),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(At(O,M,m,v,b,g)<0){const k=_,P=m,N=v;_=w,m=b,v=g,w=k,b=P,g=N}const E=br(O,M,m,v,b,g);this._cx=E.x,this._cy=E.y;for(let k=0;k<s;k++)this._dists[k]=Je(t[2*k],t[2*k+1],E.x,E.y);Zt(this._ids,this._dists,0,s-1),this._hullStart=p;let S=3;i[p]=n[w]=_,i[_]=n[p]=w,i[w]=n[_]=p,o[p]=0,o[_]=1,o[w]=2,r.fill(-1),r[this._hashKey(O,M)]=p,r[this._hashKey(m,v)]=_,r[this._hashKey(b,g)]=w,this.trianglesLen=0,this._addTriangle(p,_,w,-1,-1,-1);for(let k=0,P=0,N=0;k<this._ids.length;k++){const C=this._ids[k],F=t[2*C],y=t[2*C+1];if(k>0&&Math.abs(F-P)<=$n&&Math.abs(y-N)<=$n||(P=F,N=y,C===p||C===_||C===w))continue;let I=0;for(let x=0,B=this._hashKey(F,y);x<this._hashSize&&(I=r[(B+x)%this._hashSize],!(I!==-1&&I!==i[I]));x++);I=n[I];let A=I,T;for(;T=i[A],At(F,y,t[2*A],t[2*A+1],t[2*T],t[2*T+1])>=0;)if(A=T,A===I){A=-1;break}if(A===-1)continue;let X=this._addTriangle(A,C,i[A],-1,-1,o[A]);o[C]=this._legalize(X+2),o[A]=X,S++;let D=i[A];for(;T=i[D],At(F,y,t[2*D],t[2*D+1],t[2*T],t[2*T+1])<0;)X=this._addTriangle(D,C,T,o[C],-1,o[D]),o[C]=this._legalize(X+2),i[D]=D,S--,D=T;if(A===I)for(;T=n[A],At(F,y,t[2*T],t[2*T+1],t[2*A],t[2*A+1])<0;)X=this._addTriangle(T,C,A,-1,o[A],o[T]),this._legalize(X+2),o[T]=X,i[A]=A,S--,A=T;this._hullStart=n[C]=A,i[A]=n[D]=C,i[C]=D,r[this._hashKey(F,y)]=C,r[this._hashKey(t[2*A],t[2*A+1])]=A}this.hull=new Uint32Array(S);for(let k=0,P=this._hullStart;k<S;k++)this.hull[k]=P,P=i[P];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,n){return Math.floor(wr(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:i,coords:o}=this;let r=0,s=0;for(;;){const a=i[t],c=t-t%3;if(s=c+(t+2)%3,a===-1){if(r===0)break;t=Se[--r];continue}const l=a-a%3,h=c+(t+1)%3,f=l+(a+2)%3,u=n[s],p=n[t],_=n[h],w=n[f];if(yr(o[2*u],o[2*u+1],o[2*p],o[2*p+1],o[2*_],o[2*_+1],o[2*w],o[2*w+1])){n[t]=w,n[a]=u;const M=i[f];if(M===-1){let v=this._hullStart;do{if(this._hullTri[v]===f){this._hullTri[v]=t;break}v=this._hullPrev[v]}while(v!==this._hullStart)}this._link(t,M),this._link(a,i[s]),this._link(s,f);const m=l+(a+1)%3;r<Se.length&&(Se[r++]=m)}else{if(r===0)break;t=Se[--r]}}return s}_link(t,n){this._halfedges[t]=n,n!==-1&&(this._halfedges[n]=t)}_addTriangle(t,n,i,o,r,s){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=n,this._triangles[a+2]=i,this._link(a,o),this._link(a+1,r),this._link(a+2,s),this.trianglesLen+=3,a}}function wr(e,t){const n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function Je(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function yr(e,t,n,i,o,r,s,a){const c=e-s,l=t-a,h=n-s,f=i-a,u=o-s,p=r-a,_=c*c+l*l,w=h*h+f*f,O=u*u+p*p;return c*(f*O-w*p)-l*(h*O-w*u)+_*(h*p-f*u)<0}function vr(e,t,n,i,o,r){const s=n-e,a=i-t,c=o-e,l=r-t,h=s*s+a*a,f=c*c+l*l,u=.5/(s*l-a*c),p=(l*h-a*f)*u,_=(s*f-c*h)*u;return p*p+_*_}function br(e,t,n,i,o,r){const s=n-e,a=i-t,c=o-e,l=r-t,h=s*s+a*a,f=c*c+l*l,u=.5/(s*l-a*c),p=e+(l*h-a*f)*u,_=t+(s*f-c*h)*u;return{x:p,y:_}}function Zt(e,t,n,i){if(i-n<=20)for(let o=n+1;o<=i;o++){const r=e[o],s=t[r];let a=o-1;for(;a>=n&&t[e[a]]>s;)e[a+1]=e[a--];e[a+1]=r}else{const o=n+i>>1;let r=n+1,s=i;ae(e,o,r),t[e[n]]>t[e[i]]&&ae(e,n,i),t[e[r]]>t[e[i]]&&ae(e,r,i),t[e[n]]>t[e[r]]&&ae(e,n,r);const a=e[r],c=t[a];for(;;){do r++;while(t[e[r]]<c);do s--;while(t[e[s]]>c);if(s<r)break;ae(e,r,s)}e[n+1]=e[s],e[s]=a,i-r+1>=s-n?(Zt(e,t,r,i),Zt(e,t,n,s-1)):(Zt(e,t,n,s-1),Zt(e,t,r,i))}}function ae(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function xr(e){return e[0]}function _r(e){return e[1]}class Mr{bs;width;constructor(t,n){this.width=t,this.bs=n}add(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]|=1<<i,this}delete(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]&=~(1<<i),this}set(t,n){const i=Math.floor(t/this.width),r=1<<t%this.width;return this.bs[i]^=(-Number(n)^this.bs[i])&r,n}has(t){const n=Math.floor(t/this.width),i=t%this.width;return(this.bs[n]&1<<i)!==0}forEach(t){const n=this.bs.length;for(let i=0;i<n;i++){let o=0;for(;this.bs[i]&&o<this.width;)this.bs[i]&1<<o&&t(i*this.width+o),o++}return this}}class Dn extends Mr{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function zt(e){return e%3===2?e-2:e+1}function Ct(e){return e%3===0?e+2:e-1}function Fn(e,t,n,i,o,r,s,a){const c=At(e,t,o,r,s,a),l=At(n,i,o,r,s,a);if(c>0&&l>0||c<0&&l<0)return!1;const h=At(o,r,e,t,n,i),f=At(s,a,e,t,n,i);return h>0&&f>0||h<0&&f<0?!1:c===0&&l===0&&h===0&&f===0?!(Math.max(o,s)<Math.min(e,n)||Math.max(e,n)<Math.min(o,s)||Math.max(r,a)<Math.min(t,i)||Math.max(t,i)<Math.min(r,a)):!0}class Sr{del;constructor(t){this.del=t}}class Er extends Sr{vertMap;flips;consd;constructor(t,n){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 i=2**32-1,o=t.coords.length>>1,r=t.triangles.length;this.vertMap=new Uint32Array(o).fill(i),this.flips=new Dn(r),this.consd=new Dn(r);for(let s=0;s<r;s++){const a=t.triangles[s];this.vertMap[a]===i&&this.updateVert(s)}n&&this.constrainAll(n)}constrainOne(t,n){const{triangles:i,halfedges:o}=this.del;this.assertVertex(t,t,n),this.assertVertex(n,t,n),this.assertInTriangulation(t,t,n),this.assertInTriangulation(n,t,n);const r=this.vertMap[t],s=this.maxConstrainSteps();let a=0,c=r;do{if(++a>s)throw new Error(`Constraining edge [${t}, ${n}] exceeded the iteration limit`);const f=i[c],u=zt(c);if(f===n)return this.protect(c);const p=Ct(c),_=i[p];if(_===n)return this.protect(u),u;if(this.intersectSegments(t,n,_,f)){c=p;break}c=o[u]}while(c!==-1&&c!==r);let l=c,h=-1;for(;c!==-1;){if(++a>s)throw new Error(`Constraining edge [${t}, ${n}] exceeded the iteration limit`);const f=o[c],u=Ct(c),p=Ct(f),_=zt(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(c))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,n,i[c])||this.isCollinear(t,n,i[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[c],i[f],i[u],i[p])){if(h===-1&&(h=c),i[p]===n){if(c===h)throw new Error("Infinite loop: non-convex quadrilateral");c=h,h=-1;continue}if(this.intersectSegments(t,n,i[p],i[f]))c=p;else if(this.intersectSegments(t,n,i[_],i[p]))c=_;else if(h===c)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(c),this.intersectSegments(t,n,i[u],i[p])&&(h===-1&&(h=u),h===u))throw new Error("Infinite loop: flipped diagonal still intersects");i[p]===n?(l=p,c=h,h=-1):this.intersectSegments(t,n,i[_],i[p])&&(c=_)}return this.protect(l),this.delaunify(!0),this.findEdge(t,n)}maxConstrainSteps(){const t=this.del.triangles.length;return Math.max(t*t,4096)}assertInTriangulation(t,n,i){if(this.vertMap[t]>=this.del.triangles.length)throw new Error(`Invalid edge [${n}, ${i}]: vertex ${t} is not part of the triangulation`)}assertVertex(t,n,i){const o=this.vertMap.length;if(!Number.isInteger(t)||t<0||t>=o)throw new Error(`Invalid edge [${String(n)}, ${String(i)}]: vertex ids must be integers from 0 to ${o-1}`)}delaunify(t=!1){const{halfedges:n}=this.del,i=this.flips,o=this.consd,r=n.length;let s;do{s=0;for(let a=0;a<r;a++){if(o.has(a))continue;i.delete(a);const c=n[a];c!==-1&&(i.delete(c),this.isDelaunay(a)||(this.flipDiagonal(a),s++))}}while(t&&s>0);return this}constrainAll(t){const n=t.length;for(let i=0;i<n;i++){const o=t[i];this.constrainOne(o[0],o[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,n){const i=this.vertMap[n],{triangles:o,halfedges:r}=this.del;if(!(i<o.length))return 1/0;let s=i,a,c=0;do{if(++c>o.length)throw new Error(`Looking up edge [${t}, ${n}] exceeded the iteration limit`);if(o[s]===t)return s;a=zt(s),s=r[a]}while(s!==-1&&s!==i);return o[zt(a)]===t?-a:1/0}protect(t){const n=this.del.halfedges[t],i=this.flips,o=this.consd;return i.delete(t),o.add(t),n!==-1?(i.delete(n),o.add(n),n):-t}markFlip(t){const n=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const r=n[t];return r!==-1&&(i.add(t),i.add(r)),!0}flipDiagonal(t){const{triangles:n,halfedges:i}=this.del,o=this.flips,r=this.consd,s=i[t],a=Ct(t),c=zt(t),l=Ct(s),h=zt(s),f=i[a],u=i[l];if(r.has(t))throw new Error("Trying to flip a constrained edge");return n[t]=n[l],i[t]=u,o.set(t,o.has(l))||r.set(t,r.has(l)),u!==-1&&(i[u]=t),i[a]=l,n[s]=n[a],i[s]=f,o.set(s,o.has(a))||r.set(s,r.has(a)),f!==-1&&(i[f]=s),i[l]=a,this.markFlip(t),this.markFlip(c),this.markFlip(s),this.markFlip(h),o.add(a),r.delete(a),o.add(l),r.delete(l),this.updateVert(t),this.updateVert(c),this.updateVert(s),this.updateVert(h),a}isCollinear(t,n,i){const o=this.del.coords;return At(o[t*2],o[t*2+1],o[n*2],o[n*2+1],o[i*2],o[i*2+1])===0}inCircle(t,n,i,o){const r=this.del.coords;return ui(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])<0}isDelaunay(t){const{triangles:n,halfedges:i}=this.del,o=i[t];if(o===-1)return!0;const r=n[Ct(t)],s=n[t],a=n[zt(t)],c=n[Ct(o)];return!this.inCircle(r,s,a,c)}updateVert(t){const{triangles:n,halfedges:i}=this.del,o=this.vertMap,r=n[t];let s=Ct(t),a=i[s];for(;a!==-1&&a!==t;)s=Ct(a),a=i[s];return o[r]=s,s}intersectSegments(t,n,i,o){const r=this.del.coords;return t===i||t===o||n===i||n===o?!1:Fn(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])}static intersectSegments=Fn}function ce(e,t,n){if(t||(t=[]),typeof e!="object"||e.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const i=e.features.map(c=>c.geometry.coordinates),o=ze.from(i);let r;const s=[];o.triangles.length!==0&&t.length!==0&&(r=new Er(o),r.constrainAll(t));for(let c=0;c<o.triangles.length;c+=3)s.push([o.triangles[c],o.triangles[c+1],o.triangles[c+2]]);const a=["a","b","c"];return Et(s.map(c=>{const l={},h=c.map((f,u)=>{const p=e.features[f],_=p.geometry.coordinates,w=[_[0],_[1]];return _.length===3?w[2]=_[2]:l[a[u]]=p.properties[n],w});return h[3]=h[0],te([h],l)}))}const kr=256*Number.EPSILON;function Ar(e,t){const n=[e,t].map(o=>{const r=o.map((a,c,l)=>{if(c===0)return 0;const h=l[c-1];return Math.sqrt(Math.pow(a[0]-h[0],2)+Math.pow(a[1]-h[1],2))}),s=r.reduce((a,c,l)=>l===0?[0]:(a.push(a[l-1]+c),a),[]);return s.map((a,c,l)=>{const h=a/l[l.length-1];return[o[c],r[c],s[c],h]})}),i=[];return n.forEach((o,r)=>{const s=n[r?0:1];o.forEach((a,c)=>{if(c===0||c===o.length-1||a[4]==="handled")return;const l=a[0],h=a[3];let f,u=1/0;for(let p=1;p<s.length-1;p++){const _=s[p];if(_[4]==="handled")continue;const w=Math.abs(_[3]-h);w<=kr&&w<u&&(f=_,u=w)}if(f){f[4]="handled",a[4]="handled",i.push(r===0?[l,f[0],h]:[f[0],l,h]);return}for(let p=0;p<s.length-1;p++){const _=s[p],w=s[p+1],O=_[3],M=w[3];if(O<h&&M>h){const m=(h-O)/(M-O),v=[(w[0][0]-_[0][0])*m+_[0][0],(w[0][1]-_[0][1])*m+_[0][1]];i.push(r===0?[l,v,h]:[v,l,h]);return}}})}),i.sort((o,r)=>o[2]-r[2])}function Ir(e,t){const n=[[],[],[],[]],i=[];return Object.keys(e).forEach(o=>{const r=e[o],s=r.forw,a=r.bakw,c=[s[0]-t.forw[0],s[1]-t.forw[1]],l=[a[0]-t.bakw[0],t.bakw[1]-a[1]],h={forw:c,bakw:l};if(i.push(h),c[0]===0||c[1]===0)return;let f=0;c[0]>0&&(f+=1),c[1]>0&&(f+=2),n[f].push(h)}),{perQuad:n,aggregate:i}}function Or(e){let t=1/0,n=0,i=0;return e.forEach(o=>{const{forw:r,bakw:s}=o,a=Math.hypot(r[0],r[1]),c=Math.hypot(s[0],s[1]);if(c===0)return;const l=a/c,h=Math.atan2(r[0],r[1])-Math.atan2(s[0],s[1]);t=Math.min(t,l),n+=Math.cos(h),i+=Math.sin(h)}),isFinite(t)?[t,Math.atan2(i,n)]:[1,0]}function Pr(e,t,n){const{perQuad:i,aggregate:o}=Ir(e,t),r=i.every(c=>c.length>0),a=(n==="birdeye"?r?i:[o]:[o]).map(c=>Or(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Nr(e,t){let n=0;return e[0]>t[0]&&(n+=1),e[1]>t[1]&&(n+=2),n}function Br(e,t,n){const i=[e[0]-t.forw[0],e[1]-t.forw[1]],r=Math.sqrt(i[0]**2+i[1]**2)/n[0],s=Math.atan2(i[0],i[1])-n[1];return[t.bakw[0]+r*Math.sin(s),t.bakw[1]-r*Math.cos(s)]}function Tr(e,t,n,i){const o=t[0]-e[0],r=t[1]-e[1];if(Math.abs(o)<1e-12&&Math.abs(r)<1e-12)return null;const s=i[0]-n[0],a=i[1]-n[1],c=n[0]-e[0],l=n[1]-e[1],h=o*a-r*s;if(Math.abs(h)<1e-12)return null;const f=(c*a-l*s)/h,u=(c*r-l*o)/h;return f<=1e-10||u<-1e-10||u>1+1e-10?null:{t:f,point:[e[0]+f*o,e[1]+f*r]}}function Cr(e,t,n){const i=n.length;let o=-1/0,r=null;for(let s=0;s<i;s++){const a=(s+1)%i,c=Tr(e,t,n[s].bakw,n[a].bakw);c&&c.t>o&&(o=c.t,r=c.point)}return r}function Rn(e,t){const i=Math.atan2(e[0]-t[0],e[1]-t[1])*(180/Math.PI);return i<0?i+360:i}function Yn(e,t,n,i,o,r){const s=t[0]-e[0],a=t[1]-e[1];if(s===0&&a===0)return null;const c=[];if(s!==0)for(const h of[n,i]){const f=(h-e[0])/s;if(f>0){const u=e[1]+f*a;u>=o&&u<=r&&c.push({t:f,x:h,y:u})}}if(a!==0)for(const h of[o,r]){const f=(h-e[1])/a;if(f>0){const u=e[0]+f*s;u>=n&&u<=i&&c.push({t:f,x:u,y:h})}}if(c.length===0)return null;c.sort((h,f)=>h.t-f.t);const l=c[0];return[l.x,l.y]}function Ln(e,t,n){const i=e.length,o=new Array(i).fill(1);for(const r of t)for(let s=0;s<i;s++){const a=(s+1)%i,c=Ze([e[s].bakw,e[a].bakw]),l=Ze([n.bakw,r.bakw]),h=Oi(c,l);if(h.features.length>0&&h.features[0].geometry){const f=h.features[0],u=Math.sqrt(Math.pow(r.bakw[0]-n.bakw[0],2)+Math.pow(r.bakw[1]-n.bakw[1],2)),p=Math.sqrt(Math.pow(f.geometry.coordinates[0]-n.bakw[0],2)+Math.pow(f.geometry.coordinates[1]-n.bakw[1],2)),_=u/p;_>o[s]&&(o[s]=_),_>o[a]&&(o[a]=_)}}e.forEach((r,s)=>{const a=o[s];r.bakw=[(r.bakw[0]-n.bakw[0])*a+n.bakw[0],(r.bakw[1]-n.bakw[1])*a+n.bakw[1]]})}function Vn(e,t,n){const{convexBuf:i,centroid:o,allGcps:r,minx:s,maxx:a,miny:c,maxy:l}=e,h=Pr(i,o,t),u=[[s,c],[a,c],[a,l],[s,l]].map(g=>({forw:g,bakw:Br(g,o,h[Nr(g,o.forw)])}));if(u.sort((g,E)=>Math.atan2(g.forw[0]-o.forw[0],g.forw[1]-o.forw[1])-Math.atan2(E.forw[0]-o.forw[0],E.forw[1]-o.forw[1])),Ln(u,r,o),!n)return u;const p=4,_=u.map(g=>Math.atan2(g.forw[0]-o.forw[0],g.forw[1]-o.forw[1])),w=u.map(g=>Math.atan2(g.bakw[0]-o.bakw[0],-(g.bakw[1]-o.bakw[1])));function O(g){for(let E=0;E<p;E++){const S=(E+1)%p,k=_[E],P=E<p-1?_[S]:_[S]+2*Math.PI;let N=g;for(;N<k;)N+=2*Math.PI;for(;N>=k+2*Math.PI;)N-=2*Math.PI;if(N>=k&&N<P)return{i:E,j:S,frac:(N-k)/(P-k)}}return{i:0,j:1,frac:0}}function M(g){const{i:E,j:S,frac:k}=O(g),P=w[E];let C=w[S]-P;for(;C>Math.PI;)C-=2*Math.PI;for(;C<-Math.PI;)C+=2*Math.PI;return P+k*C}const m=new Set(u.map(g=>Math.floor(Rn(g.forw,o.forw)/10)%36)),v=r.map(g=>({forw:g.forw,bakw:g.bakw,angleDeg:Rn(g.forw,o.forw),forwDist:Math.hypot(g.forw[0]-o.forw[0],g.forw[1]-o.forw[1])})),d=[];for(let g=0;g<36;g++){if(m.has(g))continue;const E=g*10,S=v.filter(I=>I.angleDeg>=E&&I.angleDeg<E+10);let k=null;if(S.length>0){const I=S.reduce((A,T)=>T.forwDist>A.forwDist?T:A);k=Yn(o.forw,I.forw,s,a,c,l)}if(!k){const I=(E+5)%360*(Math.PI/180),A=[o.forw[0]+Math.sin(I),o.forw[1]+Math.cos(I)];k=Yn(o.forw,A,s,a,c,l)}if(!k)continue;const P=[k[0]-o.forw[0],k[1]-o.forw[1]],N=Math.atan2(P[0],P[1]),C=M(N),F=[o.bakw[0]+Math.sin(C),o.bakw[1]-Math.cos(C)],y=Cr(o.bakw,F,u);y&&d.push({forw:k,bakw:y})}const b=[...u,...d];return b.sort((g,E)=>Math.atan2(g.forw[0]-o.forw[0],g.forw[1]-o.forw[1])-Math.atan2(E.forw[0]-o.forw[0],E.forw[1]-o.forw[1])),Ln(b,r,o),b}function Xr(e,t=!1){return Vn(e,"plain",t)}function $r(e,t=!1){return Vn(e,"birdeye",t)}function Dr(e){return Un(e,1/0)}const jn=1e5,Fr=16;function Un(e,t){return Rr(e),new Yr(e).findSegmentIntersections(t).map(o=>$t([o.x,o.y]))}function Rr(e){for(let t=0,n=e.length;t<n;t++){const i=e[t];fe(i)||Jt("findIntersections() received invalid coordinates:",`line=${t}`,`points=${i}`);for(let o=0,r=i.length;o<r;o++){const s=i[o];(!fe(s)||!Number.isFinite(s[0])||!Number.isFinite(s[1]))&&Jt("findIntersections() received non-finite coordinates:",`line=${t}`,`point=${o}`,`coordinates=${JSON.stringify(s)}`)}}}class Yr{_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 n=[],i=[],o=t.map(r=>{const s=r?r.length:0;for(let a=0;a<s;a++)n.push(r[a][0]),i.push(r[a][1]);return s});this.initXYData(o,n,i)}initXYData(t,n,i){const o=t.length;this._xx=new Float64Array(n),this._yy=new Float64Array(i),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(o);let r=0;for(let s=0;s<o;s++)this._ii[s]=r,r+=t[s];(r!=this._xx.length||this._xx.length!=this._yy.length)&&Jt("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new so(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,n,i){const o=i.length,r=new Float64Array(o*4),s=new he;let a=0,c,l,h;for(let f=0;f<o;f++)c=i[f],c>0&&(l=f*4,h=ao(t,n,a,c),r[l++]=h[0],r[l++]=h[1],r[l++]=h[2],r[l]=h[3],a+=c,s.mergeBounds(h));return{bb:r,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new he}forEachSegment(t){let n=0;for(let i=0,o=this.size();i<o;i++)n+=this.forEachArcSegment(i,t);return n}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,n){const i=t>=0,o=i?t:~t,r=this.getRetainedInterval(),s=this._nn[o],a=i?1:-1;let c=i?this._ii[o]:this._ii[o]+s-1,l=c,h=0;for(let f=1;f<s;f++)l+=a,(r===0||this._zz[l]>=r)&&(n(c,l,this._xx,this._yy),c=l,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(t){const n=t*4;return(!this.buf||this.buf.byteLength<n)&&(this.buf=new ArrayBuffer(n)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,n=0;const i=this.forEachSegment((o,r,s,a)=>{t+=Math.abs(s[o]-s[r]),n+=Math.abs(a[o]-a[r])});return[t/i||0,n/i||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),n=this.getAvgSegment2()[1];let i=1;return n>0&&t>0&&(i=Math.ceil(t/n/20)),i||1}findSegmentIntersections(t=1/0){const n=this.getBounds(),i=n.ymin||0,o=(n.ymax||0)-i,r=this.calcSegmentIntersectionStripeCount(),s=new Uint32Array(r),a=r>1?v=>Math.floor((r-1)*(v-i)/o):()=>0,c=r+1;let l;this.forEachSegment((v,d,b,g)=>{let E=a(g[v]);const S=a(g[d]);let k=0;for(;s[E]=s[E]+2,E!=S;)k++,k>c&&Jt("findSegmentIntersections() exceeded the stripe iteration limit:",`stripeCount=${r}`,`s1=${E}`,`s2=${S}`),E+=S>E?1:-1});const h=this.getUint32Array(jr(s));let f=0;const u=[];Ur(s,v=>{const d=f;f+=v,u.push(h.subarray(d,f))}),qr(s,0),this.forEachSegment((v,d,b,g)=>{let E=a(g[v]);const S=a(g[d]);let k,P,N=0;for(;k=s[E],s[E]=k+2,P=u[E],P[k]=v,P[k+1]=d,E!=S;)N++,N>c&&Jt("findSegmentIntersections() exceeded the stripe iteration limit:",`stripeCount=${r}`,`s1=${E}`,`s2=${S}`),E+=S>E?1:-1});const p=this.getVertexData(),_=t*Fr;let w=0;const O=new Set,M=new Map,m=v=>{w++;const d=oo(v);return O.has(d)||(O.add(d),M.set(`${v.x}:${v.y}`,v)),M.size>=t||w>=_};if(p.xx&&p.yy)for(l=0;l<r&&!zr(u[l],p.xx,p.yy,m);l++);return Array.from(M.values())}}function Jt(...e){const t=e.join(" ");throw new Error(t)}function fe(e){return e?Vr(e)?!0:Lr(e)?!1:e.length===0?!0:e.length>0:!1}function Lr(e){return e!=null&&e.toString===String.prototype.toString}function Vr(e){return Array.isArray(e)}function jr(e,t){fe(e)||Jt("utils.sum() expects an array, received:",e);let n=0,i;for(let o=0,r=e.length;o<r;o++)i=e[o],i&&(n+=i);return n}function Ur(e,t,n){if(!fe(e))throw new Error(`#forEach() takes an array-like argument. ${e}`);for(let i=0,o=e.length;i<o;i++)t.call(n,e[i],i)}function qr(e,t){for(let n=0,i=e.length;n<i;n++)e[n]=t;return e}function zr(e,t,n,i){const o=e.length-2;let r,s,a,c,l,h,f,u,p,_,w,O,M,m,v,d,b;for(no(t,e),d=0;d<o;){for(r=e[d],s=e[d+1],l=t[r],h=t[s],p=n[r],_=n[s],b=d;b<o&&(b+=2,a=e[b],f=t[a],!(h<f));){if(w=n[a],c=e[b+1],u=t[c],O=n[c],p>=w){if(p>O&&_>w&&_>O)continue}else if(p<O&&_<w&&_<O)continue;if(!(r==a||r==c||s==a||s==c)&&(M=Jr(l,p,h,_,f,w,u,O),M&&(m=[r,s],v=[a,c],i(Gn(M,m,v,t,n))||M.length==4&&i(Gn(M.slice(2),m,v,t,n)))))return!0}d+=2}return!1}function Jr(e,t,n,i,o,r,s,a){const c=Gr(e,t,n,i,o,r,s,a);let l=null;return c&&(l=Kr(e,t,n,i,o,r,s,a),l?eo(e,t,n,i,o,r,s,a)&&(l=null):l=to(e,t,n,i,o,r,s,a)),l}function Gr(e,t,n,i,o,r,s,a){return le(e,t,n,i,o,r)*le(e,t,n,i,s,a)<=0&&le(o,r,s,a,e,t)*le(o,r,s,a,n,i)<=0}function le(e,t,n,i,o,r){return qn(e-o,t-r,n-o,i-r)}function qn(e,t,n,i){return e*i-t*n}function Kr(e,t,n,i,o,r,s,a){let c=Ee(e,t,n,i,o,r,s,a),l;return c&&(l=Hr(c[0],c[1],e,t,n,i,o,r,s,a),l==1?c=Ee(n,i,e,t,o,r,s,a):l==2?c=Ee(o,r,s,a,e,t,n,i):l==3&&(c=Ee(s,a,o,r,e,t,n,i))),c&&Zr(c,e,t,n,i,o,r,s,a),c}function Ee(e,t,n,i,o,r,s,a){const c=qn(n-e,i-t,s-o,a-r),l=1e-18;let h;if(c===0)return null;const f=le(o,r,s,a,e,t)/c;return c<=l&&c>=-l?h=Qr(e,t,n,i,o,r,s,a):h=[e+f*(n-e),t+f*(i-t)],h}function Qr(e,t,n,i,o,r,s,a){let c=null;return!Xt(e,o,s)&&!Xt(t,r,a)?c=[e,t]:!Xt(n,o,s)&&!Xt(i,r,a)?c=[n,i]:!Xt(o,e,n)&&!Xt(r,t,i)?c=[o,r]:!Xt(s,e,n)&&!Xt(a,t,i)&&(c=[s,a]),c}function Xt(e,t,n){let i;return t<n?i=e<t||e>n:t>n?i=e>t||e<n:i=e!=t,i}function Hr(e,t,...n){let i=-1,o=1/0,r;for(let s=0,a=0,c=n.length;a<c;s++,a+=2)r=Wr(e,t,n[a],n[a+1]),r<o&&(o=r,i=s);return i}function Wr(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function Zr(e,t,n,i,o,r,s,a,c){let l=e[0],h=e[1];l=ke(l,t,i),l=ke(l,r,a),h=ke(h,n,o),h=ke(h,s,c),e[0]=l,e[1]=h}function ke(e,t,n){let i;return Xt(e,t,n)&&(i=Math.abs(e-t)<Math.abs(e-n)?t:n,e=i),e}function to(e,t,n,i,o,r,s,a){const c=Math.min(e,n,o,s),l=Math.max(e,n,o,s),h=Math.min(t,i,r,a),f=Math.max(t,i,r,a),u=f-h>l-c;let p=[];return(u?Lt(t,h,f):Lt(e,c,l))&&p.push(e,t),(u?Lt(i,h,f):Lt(n,c,l))&&p.push(n,i),(u?Lt(r,h,f):Lt(o,c,l))&&p.push(o,r),(u?Lt(a,h,f):Lt(s,c,l))&&p.push(s,a),(p.length!=2&&p.length!=4||p.length==4&&p[0]==p[2]&&p[1]==p[3])&&(p=null),p}function eo(e,t,n,i,o,r,s,a){return e==o&&t==r||e==s&&t==a||n==o&&i==r||n==s&&i==a}function Lt(e,t,n){return e>t&&e<n}function no(e,t){io(e,t),zn(e,t,0,t.length-2)}function io(e,t){for(let n=0,i=t.length;n<i;n+=2)e[t[n]]>e[t[n+1]]&&ro(t,n,n+1)}function ro(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function zn(e,t,n,i){let o=n,r=i,s,a;for(;o<i;){for(s=e[t[n+i>>2<<1]];o<=r;){for(;e[t[o]]<s;)o+=2;for(;e[t[r]]>s;)r-=2;o<=r&&(a=t[o],t[o]=t[r],t[r]=a,a=t[o+1],t[o+1]=t[r+1],t[r+1]=a,o+=2,r-=2)}if(r-n<40?Jn(e,t,n,r):zn(e,t,n,r),i-o<40){Jn(e,t,o,i);return}n=o,r=i}}function Jn(e,t,n,i){let o,r;for(let s=n+2;s<=i;s+=2){o=t[s],r=t[s+1];let a;for(a=s-2;a>=n&&e[o]<e[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=o,t[a+3]=r}}function Gn(e,t,n,i,o){const r=e[0],s=e[1];t=Kn(r,s,t[0],t[1],i,o),n=Kn(r,s,n[0],n[1],i,o);const a=t[0]<n[0]?t:n,c=a==t?n:t;return{x:r,y:s,a,b:c}}function Kn(e,t,n,i,o,r){let s=n<i?n:i,a=s===n?i:n;return o[s]==e&&r[s]==t?a=s:o[a]==e&&r[a]==t&&(s=a),[s,a]}function oo(e){return`${e.a.join(",")};${e.b.join(",")}`}class so{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,n){this._xx=t,this._yy=n}}function ao(e,t,n,i){let o=n|0;const r=isNaN(i)?e.length-o:i+o;let s,a,c,l,h,f;if(r>0)c=h=e[o],l=f=t[o];else return[void 0,void 0,void 0,void 0];for(o++;o<r;o++)s=e[o],a=t[o],s<c&&(c=s),s>h&&(h=s),a<l&&(l=a),a>f&&(f=a);return[c,l,h,f]}class he{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new he(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,n,i,o){let r,s,a,c;if(arguments.length==1)if(fe(t)){const l=t;r=l[0],s=l[1],a=l[2],c=l[3]}else{const l=t;r=l.xmin,s=l.ymin,a=l.xmax,c=l.ymax}else r=t,s=n,a=i,c=o;return this.xmin=r,this.ymin=s,this.xmax=a,this.ymax=c,(r>a||s>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,...n){let i,o,r,s;return t instanceof he?(i=t.xmin,o=t.ymin,r=t.xmax,s=t.ymax):n.length==3?(i=t,o=n[0],r=n[1],s=n[2]):t.length==4?(i=t[0],o=t[1],r=t[2],s=t[3]):Jt("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(i,o,r,s):(i<this.xmin&&(this.xmin=i),o<this.ymin&&(this.ymin=o),r>this.xmax&&(this.xmax=r),s>this.ymax&&(this.ymax=s)),this}}function Ae(e){const t=["a","b","c"].map(n=>e.properties[n].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(n=>n.map(i=>t[i]).sort().join("-")).sort()}function Ge(e,t,n){const i=Ae(t.forw),o=Ae(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
|
|
2
2
|
${JSON.stringify(i)}
|
|
3
|
-
${JSON.stringify(o)}`;for(let r=0;r<i.length;r++){const s=i[r];e[s]||(e[s]=[]),e[s].push(t)}n&&(n.forw.features.push(t.forw),n.bakw.features.push(t.bakw))}function
|
|
3
|
+
${JSON.stringify(o)}`;for(let r=0;r<i.length;r++){const s=i[r];e[s]||(e[s]=[]),e[s].push(t)}n&&(n.forw.features.push(t.forw),n.bakw.features.push(t.bakw))}function Qn(e,t,n){const i=Ae(t.forw),o=Ae(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
|
|
4
4
|
${JSON.stringify(i)}
|
|
5
|
-
${JSON.stringify(o)}`;if(i.forEach(r=>{const s=e[r];if(!s)return;const a=s.filter(f=>f!==t);a.length===0?delete e[r]:e[r]=a}),n){const r=(s,a)=>{!s||!a||(s.features=s.features.filter(f=>f!==a))};r(n.forw,t.forw),r(n.bakw,t.bakw)}}function ue(e,t,n){return Dt(e,{target:{geom:t,index:n}})}function de(e){return Dt(e.properties.target.geom,{target:{geom:e.geometry.coordinates,index:e.properties.target.index}})}function Ke(e,t){const n=e.length,i=t.geometry.coordinates;return Array.from({length:n},(o,r)=>r).map(o=>{const r=(o+1)%n,s=e[o],a=e[r],f=s.geometry.coordinates,l=Math.atan2(f[0]-i[0],f[1]-i[1]),u=[t,s,a,t].map(p=>p.geometry.coordinates),c={a:{geom:t.properties.target.geom,index:t.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}},h=St([te([u],c)]);return[l,h]}).reduce((o,r)=>(o[0].push(r[0]),o[1].push(r[1]),o),[[],[]])}function Ie(e,t=1e-6){const[n,i]=e[0],[o,r]=e[1],[s,a]=e[2];return Math.abs((o-n)*(a-i)-(s-n)*(r-i))<t}function eo(e,t){const n=new Set;return e.forEach(i=>{if(i.length!==2)return;const o=i.map(r=>`${t?.[r]??r}`);n.add(o.sort().join("-"))}),n}function pe(e){return["a","b","c"].map((t,n)=>({prop:e.properties[t],geom:e.geometry.coordinates[0][n]}))}const no=10;function io(e,t,n,i,o,r){if(!e&&!t)return!1;const s=e?0:1,a=1-s,f=n[s],l=n[a];if(!f||!l)return!1;const u=_t(l.geom);let c=!1,h=!1;for(let p=0;p<=1;p++){const M=i[p];if(!M)continue;const w=[String(M.prop.index),String(f.prop.index)].sort().join("-"),I=o[w];if(!I||I.length<2)continue;const x=I.find(B=>B.bakw!==r[s].bakw);if(!x)continue;const _=pe(x.bakw).find(B=>String(B.prop.index)!==String(M.prop.index)&&String(B.prop.index)!==String(f.prop.index));if(!_)continue;c=!0;const d=_t(_.geom),v=_t(M.geom),g=_t(f.geom),k=g[0]-v[0],S=g[1]-v[1],A=k*(u[1]-v[1])-S*(u[0]-v[0]),O=k*(d[1]-v[1])-S*(d[0]-v[0]);if(A*O>0){h=!0;break}}return c&&!h}function ro(e,t,n,i){if(!e&&!t)return!1;if(n[0]&&n[1]&&i[0]&&i[1]){const o=i.map(u=>_t(u.geom)),r=n.map(u=>_t(u.geom)),s=o[1][0]-o[0][0],a=o[1][1]-o[0][1],f=s*(r[0][1]-o[0][1])-a*(r[0][0]-o[0][0]),l=s*(r[1][1]-o[0][1])-a*(r[1][0]-o[0][0]);return f*l<0}return!1}function oo(e,t,n,i){const o=eo(n,i),r=new Set;let s=!1;for(let a=0;a<no;a++){let f=!1;for(const l of Object.keys(t)){if(r.has(l))continue;r.add(l);const u=t[l];if(!u||u.length<2)continue;const c=l.split("-");if(c.length!==2||o.has(l))continue;const h=pe(u[0].bakw),p=pe(u[1].bakw),M=pe(u[0].forw),w=pe(u[1].forw),I=c.map(b=>h.find(N=>`${N.prop.index}`===b)||p.find(N=>`${N.prop.index}`===b)),x=c.map(b=>M.find(N=>`${N.prop.index}`===b)||w.find(N=>`${N.prop.index}`===b));if(I.some(b=>!b)||x.some(b=>!b))continue;const m=[h,p].map(b=>b.find(N=>!c.includes(`${N.prop.index}`))),_=[M,w].map(b=>b.find(N=>!c.includes(`${N.prop.index}`)));if(m.some(b=>!b)||_.some(b=>!b))continue;const d=u[0].bakw.geometry.coordinates[0].slice(0,3).map(b=>_t(b)),v=u[1].bakw.geometry.coordinates[0].slice(0,3).map(b=>_t(b)),g=u[0].forw.geometry.coordinates[0].slice(0,3).map(b=>_t(b)),k=u[1].forw.geometry.coordinates[0].slice(0,3).map(b=>_t(b)),S=Ie(d),A=Ie(v),O=Ie(g),B=Ie(k),C=io(S,A,m,I,t,u),Y=ro(O,B,m,I);if(!(C||Y||Kn(_t(m[0].geom),v)||Kn(_t(m[1].geom),d)))continue;const P=x.map(b=>_t(b.geom)),E=_.map(b=>_t(b.geom)),T=so([...P,...E]),X=ao(T),F=Qn(P[0],P[1],E[0])+Qn(P[0],P[1],E[1]);Qe(X,F)&&(Jn(t,u[0],e),Jn(t,u[1],e),I.forEach(b=>{if(!b)return;const N=[b.geom,m[0].geom,m[1].geom,b.geom],D={a:b.prop,b:m[0].prop,c:m[1].prop},R=te([N],D),L=Bn(R);Je(t,{forw:L,bakw:R},e)}),f=!0,s=!0)}if(!f)break}return s}function _t(e){return[e[0],e[1]]}function Kn(e,t){const[n,i]=t[0],[o,r]=t[1],[s,a]=t[2],f=s-n,l=a-i,u=o-n,c=r-i,h=e[0]-n,p=e[1]-i,M=f*f+l*l,w=f*u+l*c,I=f*h+l*p,x=u*u+c*c,m=u*h+c*p,_=M*x-w*w;if(_===0)return!1;const d=1/_,v=(x*I-w*m)*d,g=(M*m-w*I)*d,k=1e-9;return v>=-k&&g>=-k&&v+g<=1+k}function so(e){const t=e.map(s=>s.slice()).filter((s,a,f)=>f.findIndex(l=>Qe(l[0],s[0])&&Qe(l[1],s[1]))===a);if(t.length<=1)return t;const n=t.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),i=(s,a,f)=>(a[0]-s[0])*(f[1]-s[1])-(a[1]-s[1])*(f[0]-s[0]),o=[];for(const s of n){for(;o.length>=2&&i(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}const r=[];for(let s=n.length-1;s>=0;s--){const a=n[s];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}return r.pop(),o.pop(),o.concat(r)}function ao(e){if(e.length<3)return 0;let t=0;for(let n=0;n<e.length;n++){const[i,o]=e[n],[r,s]=e[(n+1)%e.length];t+=i*s-r*o}return Math.abs(t)/2}function Qn(e,t,n){return Math.abs((e[0]*(t[1]-n[1])+t[0]*(n[1]-e[1])+n[0]*(e[1]-t[1]))/2)}function Qe(e,t,n=1e-9){return Math.abs(e-t)<=n}const He=2.00704,Hn=3.00001;class lt extends kt{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||lt.VERTEX_PLAIN),this.strictMode=t.strictMode||lt.MODE_AUTO,this.yaxisMode=t.yaxisMode||lt.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?He:Hn}setPoints(t){this.yaxisMode===lt.YAXIS_FOLLOW&&(t=t.map(n=>[n[0],[n[1][0],-1*n[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Nn(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let n=t[0][0],i=n,o=t[0][1],r=o;const s=[t[0]];for(let a=1;a<t.length;a++){const f=t[a];f[0]<n&&(n=f[0]),f[0]>i&&(i=f[0]),f[1]<o&&(o=f[1]),f[1]>r&&(r=f[1]),s.push(f)}s.push(t[0]),this.boundsPolygon=te([s]),this.xy=[n,o],this.wh=[i-n,r-o],this.vertexMode=lt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?He:Hn,t.points=this.points,t.weight_buffer={},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 n=this.vertices_params.forw[1];if(n)for(let i=0;i<n.length;i++){const o=n[i].features[0],r=o.geometry.coordinates[0][1],s=o.properties.b.geom;t.vertices_points[i]=[r,s]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(i=>{t.tins_points[0].push(["a","b","c"].map(o=>i.properties[o].index))}),this.strict_status===lt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(i=>{t.tins_points[1].push(["a","b","c"].map(o=>i.properties[o].index))})):this.strict_status===lt.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(i=>i.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}calculateStrictTin(){const t=this.tins.forw.features.map(r=>Bn(r));this.tins.bakw=St(t);const n={};this.tins.forw.features.forEach((r,s)=>{const a=this.tins.bakw.features[s];Je(n,{forw:r,bakw:a})});const i=(this.pointsSet?.forw.features??[]).map(r=>r.properties.target.index);oo(this.tins,n,this.pointsSet?.edges||[],i);const o=["forw","bakw"].map(r=>{const s=this.tins[r].features.map(a=>a.geometry.coordinates[0]);return Ln(s)});o[0].length===0&&o[1].length===0?(this.strict_status=lt.STATUS_STRICT,delete this.kinks):(this.strict_status=lt.STATUS_ERROR,this.kinks={forw:St(o[0]),bakw:St(o[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let o=0;o<this.points.length;o++){const r=this.points[o][0],s=this.points[o][1],a=ue(r,s,o);t.forw.push(a),t.bakw.push(de(a))}const n=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let o=0;o<this.edges.length;o++){const r=this.edges[o][2],s=Object.assign([],this.edges[o][0]),a=Object.assign([],this.edges[o][1]);if(s.length===0&&a.length===0){n.push(r);continue}s.unshift(this.points[r[0]][0]),s.push(this.points[r[1]][0]),a.unshift(this.points[r[0]][1]),a.push(this.points[r[1]][1]);const f=[s,a].map(l=>{const u=l.map((h,p,M)=>{if(p===0)return 0;const w=M[p-1];return Math.sqrt(Math.pow(h[0]-w[0],2)+Math.pow(h[1]-w[1],2))}),c=u.reduce((h,p,M)=>M===0?[0]:(h.push(h[M-1]+p),h),[]);return c.map((h,p,M)=>{const w=h/M[M.length-1];return[l[p],u[p],c[p],w]})});f.map((l,u)=>{const c=f[u?0:1];return l.filter((h,p)=>!(p===0||p===l.length-1||h[4]==="handled")).flatMap(h=>{const p=h[0],M=h[3],w=c.reduce((I,x,m,_)=>{if(I)return I;const d=_[m+1];if(x[3]===M)return x[4]="handled",[x];if(x[3]<M&&d&&d[3]>M)return[x,d]},void 0);if(w&&w.length===1)return u===0?[[p,w[0][0],M]]:[[w[0][0],p,M]];if(w&&w.length===2){const I=w[0],x=w[1],m=(M-I[3])/(x[3]-I[3]),_=[(x[0][0]-I[0][0])*m+I[0][0],(x[0][1]-I[0][1])*m+I[0][1]];return u===0?[[p,_,M]]:[[_,p,M]]}return[]})}).reduce((l,u)=>l.concat(u),[]).sort((l,u)=>l[2]<u[2]?-1:1).map((l,u,c)=>{this.edgeNodes[i]=[l[0],l[1]];const h=ue(l[0],l[1],`e${i}`);i++,t.forw.push(h),t.bakw.push(de(h)),u===0?n.push([r[0],t.forw.length-1]):n.push([t.forw.length-2,t.forw.length-1]),u===c.length-1&&n.push([t.forw.length-1,r[1]])})}return{forw:t.forw,bakw:t.bakw,edges:n}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],n=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],o=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 r=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((f,l)=>f&&(r?Fe(l[0],r):l[0][0]>=t&&l[0][0]<=n&&l[0][1]>=i&&l[0][1]<=o),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[n,i],[t,o],[n,o]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:n,miny:i,maxy:o}}computeGcpBbox(){let t=1/0,n=-1/0,i=1/0,o=-1/0;for(const a of this.points){const f=a[0][0],l=a[0][1];f<t&&(t=f),f>n&&(n=f),l<i&&(i=l),l>o&&(o=l)}const r=n-t,s=o-i;return{minx:t-.05*r,maxx:n+.05*r,miny:i-.05*s,maxy:o+.05*s}}updateTin(){let t=this.strictMode;t!==lt.MODE_STRICT&&t!==lt.MODE_LOOSE&&(t=lt.MODE_AUTO);const n=!this.useV2Algorithm;let i,o,r,s,a;if(n){if(this.bounds){const S=this.boundsPolygon;if(!S)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(O=>Fe(O[0],S)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:o,maxx:r,miny:s,maxy:a}=this.computeGcpBbox()}else{const S=this.validateAndPrepareInputs();i=S.pointsSet,o=S.minx,r=S.maxx,s=S.miny,a=S.maxy}const f={forw:St(i.forw),bakw:St(i.bakw)},l=ce(f.forw,i.edges,"target"),u=ce(f.bakw,i.edges,"target");if(l.features.length===0||u.features.length===0)throw"TOO LINEAR1";const c=Oi(f.forw),h=bn(f.forw);if(!h)throw"TOO LINEAR2";const p={},M=h.geometry.coordinates[0];let w;try{w=M.map(S=>({forw:S,bakw:se(Dt(S),l)})),w.forEach(S=>{p[`${S.forw[0]}:${S.forw[1]}`]=S})}catch{throw"TOO LINEAR2"}const I=bn(f.bakw);if(!I)throw"TOO LINEAR2";const x=I.geometry.coordinates[0];try{w=x.map(S=>({bakw:S,forw:se(Dt(S),u)})),w.forEach(S=>{p[`${S.forw[0]}:${S.forw[1]}`]=S})}catch{throw"TOO LINEAR2"}let m;if(n){const S=c.geometry.coordinates,A=l.features.find(O=>Fe(Dt(S),O));if(A){const O=A.geometry.coordinates[0],B=A.properties.a.geom,C=A.properties.b.geom,Y=A.properties.c.geom;m={forw:[(O[0][0]+O[1][0]+O[2][0])/3,(O[0][1]+O[1][1]+O[2][1])/3],bakw:[(B[0]+C[0]+Y[0])/3,(B[1]+C[1]+Y[1])/3]}}else m={forw:S,bakw:se(c,l)}}else m={forw:c.geometry.coordinates,bakw:se(c,l)};const _=ue(m.forw,m.bakw,"c");this.centroid={forw:_,bakw:de(_)};const d=[...this.points.map(S=>({forw:S[0],bakw:S[1]})),...(this.edgeNodes??[]).map(S=>({forw:S[0],bakw:S[1]}))],v={convexBuf:p,centroid:m,allGcps:d,minx:o,maxx:r,miny:s,maxy:a},g=this.vertexMode===lt.VERTEX_BIRDEYE?Br(v,n):Or(v,n),k={forw:[],bakw:[]};for(let S=0;S<g.length;S++){const A=g[S].forw,O=g[S].bakw,B=ue(A,O,`b${S}`),C=de(B);i.forw.push(B),i.bakw.push(C),k.forw.push(B),k.bakw.push(C)}this.pointsSet={forw:St(i.forw),bakw:St(i.bakw),edges:i.edges},this.tins={forw:On(ce(this.pointsSet.forw,i.edges,"target"))},(t===lt.MODE_STRICT||t===lt.MODE_AUTO)&&this.calculateStrictTin(),(t===lt.MODE_LOOSE||t===lt.MODE_AUTO&&this.strict_status===lt.STATUS_ERROR)&&(this.tins.bakw=On(ce(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=lt.STATUS_LOOSE),this.vertices_params={forw:Ke(k.forw,this.centroid.forw),bakw:Ke(k.bakw,this.centroid.bakw)},this.addIndexedTin(),this.pointsWeightBuffer={}}async updateTinAsync(){this.updateTin()}}bt.Tin=lt,bt.constrainedTin=ce,bt.counterPoint=de,bt.createPoint=ue,bt.default=lt,bt.findIntersections=Ln,bt.format_version=He,bt.insertSearchIndex=Je,bt.vertexCalc=Ke,Object.defineProperties(bt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
5
|
+
${JSON.stringify(o)}`;if(i.forEach(r=>{const s=e[r];if(!s)return;const a=s.filter(c=>c!==t);a.length===0?delete e[r]:e[r]=a}),n){const r=(s,a)=>{!s||!a||(s.features=s.features.filter(c=>c!==a))};r(n.forw,t.forw),r(n.bakw,t.bakw)}}function ue(e,t,n){return $t(e,{target:{geom:t,index:n}})}function de(e){return $t(e.properties.target.geom,{target:{geom:e.geometry.coordinates,index:e.properties.target.index}})}function Ke(e,t){const n=e.length,i=t.geometry.coordinates;return Array.from({length:n},(o,r)=>r).map(o=>{const r=(o+1)%n,s=e[o],a=e[r],c=s.geometry.coordinates,l=Math.atan2(c[0]-i[0],c[1]-i[1]),h=[t,s,a,t].map(p=>p.geometry.coordinates),f={a:{geom:t.properties.target.geom,index:t.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}},u=Et([te([h],f)]);return[l,u]}).reduce((o,r)=>(o[0].push(r[0]),o[1].push(r[1]),o),[[],[]])}function Ie(e,t=1e-6){const[n,i]=e[0],[o,r]=e[1],[s,a]=e[2];return Math.abs((o-n)*(a-i)-(s-n)*(r-i))<t}function co(e,t){const n=new Set;return e.forEach(i=>{if(i.length!==2)return;const o=i.map(r=>`${t?.[r]??r}`);n.add(o.sort().join("-"))}),n}function pe(e){return["a","b","c"].map((t,n)=>({prop:e.properties[t],geom:e.geometry.coordinates[0][n]}))}const fo=10;function lo(e,t,n,i,o,r){if(!e&&!t)return!1;const s=e?0:1,a=1-s,c=n[s],l=n[a];if(!c||!l)return!1;const h=Mt(l.geom);let f=!1,u=!1;for(let p=0;p<=1;p++){const _=i[p];if(!_)continue;const w=[String(_.prop.index),String(c.prop.index)].sort().join("-"),O=o[w];if(!O||O.length<2)continue;const M=O.find(N=>N.bakw!==r[s].bakw);if(!M)continue;const v=pe(M.bakw).find(N=>String(N.prop.index)!==String(_.prop.index)&&String(N.prop.index)!==String(c.prop.index));if(!v)continue;f=!0;const d=Mt(v.geom),b=Mt(_.geom),g=Mt(c.geom),E=g[0]-b[0],S=g[1]-b[1],k=E*(h[1]-b[1])-S*(h[0]-b[0]),P=E*(d[1]-b[1])-S*(d[0]-b[0]);if(k*P>0){u=!0;break}}return f&&!u}function ho(e,t,n,i){if(!e&&!t)return!1;if(n[0]&&n[1]&&i[0]&&i[1]){const o=i.map(h=>Mt(h.geom)),r=n.map(h=>Mt(h.geom)),s=o[1][0]-o[0][0],a=o[1][1]-o[0][1],c=s*(r[0][1]-o[0][1])-a*(r[0][0]-o[0][0]),l=s*(r[1][1]-o[0][1])-a*(r[1][0]-o[0][0]);return c*l<0}return!1}function uo(e,t,n,i){const o=co(n,i),r=new Set;let s=!1;for(let a=0;a<fo;a++){let c=!1;for(const l of Object.keys(t)){if(r.has(l))continue;r.add(l);const h=t[l];if(!h||h.length<2)continue;const f=l.split("-");if(f.length!==2||o.has(l))continue;const u=pe(h[0].bakw),p=pe(h[1].bakw),_=pe(h[0].forw),w=pe(h[1].forw),O=f.map(x=>u.find(B=>`${B.prop.index}`===x)||p.find(B=>`${B.prop.index}`===x)),M=f.map(x=>_.find(B=>`${B.prop.index}`===x)||w.find(B=>`${B.prop.index}`===x));if(O.some(x=>!x)||M.some(x=>!x))continue;const m=[u,p].map(x=>x.find(B=>!f.includes(`${B.prop.index}`))),v=[_,w].map(x=>x.find(B=>!f.includes(`${B.prop.index}`)));if(m.some(x=>!x)||v.some(x=>!x))continue;const d=h[0].bakw.geometry.coordinates[0].slice(0,3).map(x=>Mt(x)),b=h[1].bakw.geometry.coordinates[0].slice(0,3).map(x=>Mt(x)),g=h[0].forw.geometry.coordinates[0].slice(0,3).map(x=>Mt(x)),E=h[1].forw.geometry.coordinates[0].slice(0,3).map(x=>Mt(x)),S=Ie(d),k=Ie(b),P=Ie(g),N=Ie(E),C=lo(S,k,m,O,t,h),F=ho(P,N,m,O);if(!(C||F||Hn(Mt(m[0].geom),b)||Hn(Mt(m[1].geom),d)))continue;const I=M.map(x=>Mt(x.geom)),A=v.map(x=>Mt(x.geom)),T=po([...I,...A]),X=mo(T),D=Wn(I[0],I[1],A[0])+Wn(I[0],I[1],A[1]);Qe(X,D)&&(Qn(t,h[0],e),Qn(t,h[1],e),O.forEach(x=>{if(!x)return;const B=[x.geom,m[0].geom,m[1].geom,x.geom],$={a:x.prop,b:m[0].prop,c:m[1].prop},R=te([B],$),L=Bn(R);Ge(t,{forw:L,bakw:R},e)}),c=!0,s=!0)}if(!c)break}return s}function Mt(e){return[e[0],e[1]]}function Hn(e,t){const[n,i]=t[0],[o,r]=t[1],[s,a]=t[2],c=s-n,l=a-i,h=o-n,f=r-i,u=e[0]-n,p=e[1]-i,_=c*c+l*l,w=c*h+l*f,O=c*u+l*p,M=h*h+f*f,m=h*u+f*p,v=_*M-w*w;if(v===0)return!1;const d=1/v,b=(M*O-w*m)*d,g=(_*m-w*O)*d,E=1e-9;return b>=-E&&g>=-E&&b+g<=1+E}function po(e){const t=e.map(s=>s.slice()).filter((s,a,c)=>c.findIndex(l=>Qe(l[0],s[0])&&Qe(l[1],s[1]))===a);if(t.length<=1)return t;const n=t.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),i=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),o=[];for(const s of n){for(;o.length>=2&&i(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}const r=[];for(let s=n.length-1;s>=0;s--){const a=n[s];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}return r.pop(),o.pop(),o.concat(r)}function mo(e){if(e.length<3)return 0;let t=0;for(let n=0;n<e.length;n++){const[i,o]=e[n],[r,s]=e[(n+1)%e.length];t+=i*s-r*o}return Math.abs(t)/2}function Wn(e,t,n){return Math.abs((e[0]*(t[1]-n[1])+t[0]*(n[1]-e[1])+n[0]*(e[1]-t[1]))/2)}function Qe(e,t,n=1e-9){return Math.abs(e-t)<=n}const He=2.00704,Zn=3.00001;class ft extends kt{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||ft.VERTEX_PLAIN),this.strictMode=t.strictMode||ft.MODE_AUTO,this.yaxisMode=t.yaxisMode||ft.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?He:Zn}setPoints(t){this.yaxisMode===ft.YAXIS_FOLLOW&&(t=t.map(n=>[n[0],[n[1][0],-1*n[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Tn(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let n=t[0][0],i=n,o=t[0][1],r=o;const s=[t[0]];for(let a=1;a<t.length;a++){const c=t[a];c[0]<n&&(n=c[0]),c[0]>i&&(i=c[0]),c[1]<o&&(o=c[1]),c[1]>r&&(r=c[1]),s.push(c)}s.push(t[0]),this.boundsPolygon=te([s]),this.xy=[n,o],this.wh=[i-n,r-o],this.vertexMode=ft.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?He:Zn,t.points=this.points,t.weight_buffer={},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 n=this.vertices_params.forw[1];if(n)for(let i=0;i<n.length;i++){const o=n[i].features[0],r=o.geometry.coordinates[0][1],s=o.properties.b.geom;t.vertices_points[i]=[r,s]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(i=>{t.tins_points[0].push(["a","b","c"].map(o=>i.properties[o].index))}),this.strict_status===ft.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(i=>{t.tins_points[1].push(["a","b","c"].map(o=>i.properties[o].index))})):this.strict_status===ft.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(i=>i.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}calculateStrictTin(t=jn){const n=this.tins.forw.features.map(s=>Bn(s));this.tins.bakw=Et(n);const i={};this.tins.forw.features.forEach((s,a)=>{const c=this.tins.bakw.features[a];Ge(i,{forw:s,bakw:c})});const o=(this.pointsSet?.forw.features??[]).map(s=>s.properties.target.index);uo(this.tins,i,this.pointsSet?.edges||[],o);const r=["forw","bakw"].map(s=>{const a=this.tins[s].features.map(c=>c.geometry.coordinates[0]);return Un(a,t)});r[0].length===0&&r[1].length===0?(this.strict_status=ft.STATUS_STRICT,delete this.kinks):(this.strict_status=ft.STATUS_ERROR,this.kinks={forw:Et(r[0]),bakw:Et(r[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let o=0;o<this.points.length;o++){const r=this.points[o][0],s=this.points[o][1],a=ue(r,s,o);t.forw.push(a),t.bakw.push(de(a))}const n=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let o=0;o<this.edges.length;o++){const r=this.edges[o][2],s=Object.assign([],this.edges[o][0]),a=Object.assign([],this.edges[o][1]);if(go(r,this.points.length,o),s.length===0&&a.length===0){n.push(r);continue}s.unshift(this.points[r[0]][0]),s.push(this.points[r[1]][0]),a.unshift(this.points[r[0]][1]),a.push(this.points[r[1]][1]),Ar(s,a).map((c,l,h)=>{this.edgeNodes[i]=[c[0],c[1]];const f=ue(c[0],c[1],`e${i}`);i++,t.forw.push(f),t.bakw.push(de(f)),l===0?n.push([r[0],t.forw.length-1]):n.push([t.forw.length-2,t.forw.length-1]),l===h.length-1&&n.push([t.forw.length-1,r[1]])})}return{forw:t.forw,bakw:t.bakw,edges:n}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],n=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],o=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 r=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((c,l)=>c&&(r?De(l[0],r):l[0][0]>=t&&l[0][0]<=n&&l[0][1]>=i&&l[0][1]<=o),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[n,i],[t,o],[n,o]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:n,miny:i,maxy:o}}computeGcpBbox(){let t=1/0,n=-1/0,i=1/0,o=-1/0;for(const a of this.points){const c=a[0][0],l=a[0][1];c<t&&(t=c),c>n&&(n=c),l<i&&(i=l),l>o&&(o=l)}const r=n-t,s=o-i;return{minx:t-.05*r,maxx:n+.05*r,miny:i-.05*s,maxy:o+.05*s}}updateTin(){let t=this.strictMode;t!==ft.MODE_STRICT&&t!==ft.MODE_LOOSE&&(t=ft.MODE_AUTO);const n=!this.useV2Algorithm;let i,o,r,s,a;if(n){if(this.bounds){const S=this.boundsPolygon;if(!S)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(P=>De(P[0],S)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:o,maxx:r,miny:s,maxy:a}=this.computeGcpBbox()}else{const S=this.validateAndPrepareInputs();i=S.pointsSet,o=S.minx,r=S.maxx,s=S.miny,a=S.maxy}const c={forw:Et(i.forw),bakw:Et(i.bakw)},l=ce(c.forw,i.edges,"target"),h=ce(c.bakw,i.edges,"target");if(l.features.length===0||h.features.length===0)throw"TOO LINEAR1";const f=Bi(c.forw),u=bn(c.forw);if(!u)throw"TOO LINEAR2";const p={},_=u.geometry.coordinates[0];let w;try{w=_.map(S=>({forw:S,bakw:se($t(S),l)})),w.forEach(S=>{p[`${S.forw[0]}:${S.forw[1]}`]=S})}catch{throw"TOO LINEAR2"}const O=bn(c.bakw);if(!O)throw"TOO LINEAR2";const M=O.geometry.coordinates[0];try{w=M.map(S=>({bakw:S,forw:se($t(S),h)})),w.forEach(S=>{p[`${S.forw[0]}:${S.forw[1]}`]=S})}catch{throw"TOO LINEAR2"}let m;if(n){const S=f.geometry.coordinates,k=l.features.find(P=>De($t(S),P));if(k){const P=k.geometry.coordinates[0],N=k.properties.a.geom,C=k.properties.b.geom,F=k.properties.c.geom;m={forw:[(P[0][0]+P[1][0]+P[2][0])/3,(P[0][1]+P[1][1]+P[2][1])/3],bakw:[(N[0]+C[0]+F[0])/3,(N[1]+C[1]+F[1])/3]}}else m={forw:S,bakw:se(f,l)}}else m={forw:f.geometry.coordinates,bakw:se(f,l)};const v=ue(m.forw,m.bakw,"c");this.centroid={forw:v,bakw:de(v)};const d=[...this.points.map(S=>({forw:S[0],bakw:S[1]})),...(this.edgeNodes??[]).map(S=>({forw:S[0],bakw:S[1]}))],b={convexBuf:p,centroid:m,allGcps:d,minx:o,maxx:r,miny:s,maxy:a},g=this.vertexMode===ft.VERTEX_BIRDEYE?$r(b,n):Xr(b,n),E={forw:[],bakw:[]};for(let S=0;S<g.length;S++){const k=g[S].forw,P=g[S].bakw,N=ue(k,P,`b${S}`),C=de(N);i.forw.push(N),i.bakw.push(C),E.forw.push(N),E.bakw.push(C)}this.pointsSet={forw:Et(i.forw),bakw:Et(i.bakw),edges:i.edges},this.tins={forw:Nn(ce(this.pointsSet.forw,i.edges,"target"))},(t===ft.MODE_STRICT||t===ft.MODE_AUTO)&&this.calculateStrictTin(t===ft.MODE_AUTO?1:jn),(t===ft.MODE_LOOSE||t===ft.MODE_AUTO&&this.strict_status===ft.STATUS_ERROR)&&(this.tins.bakw=Nn(ce(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=ft.STATUS_LOOSE),this.vertices_params={forw:Ke(E.forw,this.centroid.forw),bakw:Ke(E.bakw,this.centroid.bakw)},this.addIndexedTin(),this.pointsWeightBuffer={}}async updateTinAsync(){this.updateTin()}}function go(e,t,n){const i=o=>Number.isInteger(o)&&o>=0&&o<t;if(!Array.isArray(e)||!i(e[0])||!i(e[1]))throw new Error(`Invalid edge at edges[${n}]: start/end ${JSON.stringify(e)} must be integer indices of points (0 to ${t-1})`)}bt.Tin=ft,bt.constrainedTin=ce,bt.counterPoint=de,bt.createPoint=ue,bt.default=ft,bt.findIntersections=Dr,bt.format_version=He,bt.insertSearchIndex=Ge,bt.vertexCalc=Ke,Object.defineProperties(bt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/dist/strict-overlap.d.ts
CHANGED
package/dist/tin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Feature, Point, Position } from 'geojson';
|
|
2
2
|
import { Transform, Compiled, CompiledLegacy, Edge, EdgeSet, EdgeSetLegacy, PointSet, StrictMode, VertexMode, YaxisMode } from '@maplat/transform';
|
|
3
|
-
import { PointsSetBD } from "./types/tin.
|
|
3
|
+
import { PointsSetBD } from "./types/tin.js";
|
|
4
4
|
export declare const FORMAT_VERSION_V2 = 2.00704;
|
|
5
5
|
export declare const FORMAT_VERSION_V3 = 3.00001;
|
|
6
6
|
/**
|
|
@@ -77,8 +77,11 @@ export declare class Tin extends Transform {
|
|
|
77
77
|
setStrictMode(mode: StrictMode): void;
|
|
78
78
|
/**
|
|
79
79
|
* 厳密なTINを計算します
|
|
80
|
+
*
|
|
81
|
+
* @param kinkLimit - forw / bakw それぞれで残す交差(kinks)の件数の上限
|
|
82
|
+
* (同じ位置の交差を 1 件に数えた件数)。届いた時点で数え上げをやめます
|
|
80
83
|
*/
|
|
81
|
-
calculateStrictTin(): void;
|
|
84
|
+
calculateStrictTin(kinkLimit?: number): void;
|
|
82
85
|
/**
|
|
83
86
|
* 点群セットを生成します。
|
|
84
87
|
* GCP と中間エッジノードを GeoJSON Point に変換し、後続の三角分割に備えます。
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface IntersectionPoint {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
a: number[];
|
|
5
|
+
b: number[];
|
|
6
|
+
}
|
|
7
|
+
export type ArcCallback = (i: number, j: number, xx: Float64Array, yy: Float64Array) => void;
|
|
8
|
+
export type ForEachSegmentCallback = (v1: number, v2: number, xx: Float64Array, yy: Float64Array) => void;
|
|
9
|
+
export interface Arc {
|
|
10
|
+
i: number;
|
|
11
|
+
j: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FeatureCollection, Point, Polygon, Position } from 'geojson';
|
|
2
|
+
export interface PointsSetBD {
|
|
3
|
+
forw: FeatureCollection<Point>;
|
|
4
|
+
bakw: FeatureCollection<Point>;
|
|
5
|
+
edges: number[][];
|
|
6
|
+
}
|
|
7
|
+
export interface VertexDelta {
|
|
8
|
+
forw: [number, number];
|
|
9
|
+
bakw?: [number, number];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 三角形ごとの重み付き補間のバッファ(旧 compiled の weight_buffer の中身の形)。
|
|
13
|
+
*
|
|
14
|
+
* @deprecated 1.1.0(compiled 2.00704/3.00001)で weight_buffer の算出を廃止したため、Tin はこの型を使わない(MaplatTin#48)。代わりの型は無い。2.0.0 で削除する
|
|
15
|
+
*/
|
|
16
|
+
export interface WeightBuffer {
|
|
17
|
+
[target: string]: {
|
|
18
|
+
[vertexKey: string]: {
|
|
19
|
+
[edgeKey: string]: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export type LengthItem = [Position, number, number, number, string?];
|
|
24
|
+
export interface EdgeProperties {
|
|
25
|
+
a?: unknown;
|
|
26
|
+
b?: unknown;
|
|
27
|
+
c?: unknown;
|
|
28
|
+
index?: string | number;
|
|
29
|
+
geom?: Position;
|
|
30
|
+
target?: {
|
|
31
|
+
geom: Position;
|
|
32
|
+
index: string | number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export type VertexParams = [number[], FeatureCollection<Polygon>[]];
|
|
36
|
+
export interface TriangleProperties {
|
|
37
|
+
a?: unknown;
|
|
38
|
+
b?: unknown;
|
|
39
|
+
c?: unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface VertexPosition {
|
|
42
|
+
forw: Position;
|
|
43
|
+
bakw: Position;
|
|
44
|
+
}
|
|
45
|
+
export interface ExpandConvexItem {
|
|
46
|
+
forw: Position;
|
|
47
|
+
bakw: Position;
|
|
48
|
+
}
|
|
49
|
+
export type ExpandConvexArray = ExpandConvexItem[][];
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.1.
|
|
7
|
+
"version": "1.1.2-rc.2",
|
|
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,8 +49,9 @@
|
|
|
49
49
|
"deno"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@maplat/transform": "^1.1.
|
|
52
|
+
"@maplat/transform": "^1.1.1-rc.1",
|
|
53
53
|
"@turf/turf": "^7.4.0",
|
|
54
|
+
"@types/geojson": "^7946.0.16",
|
|
54
55
|
"delaunator": "^5.0.1",
|
|
55
56
|
"robust-predicates": "^3.0.2"
|
|
56
57
|
},
|
|
@@ -59,7 +60,6 @@
|
|
|
59
60
|
"@testing-library/jest-dom": "^7.0.1",
|
|
60
61
|
"@types/delaunator": "^5.0.3",
|
|
61
62
|
"@types/estree": "^1.0.8",
|
|
62
|
-
"@types/geojson": "^7946.0.16",
|
|
63
63
|
"@types/node": "^26.6.5",
|
|
64
64
|
"@typescript-eslint/eslint-plugin": "^8.66.0",
|
|
65
65
|
"@typescript-eslint/parser": "^8.66.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"robust-segment-intersect": "^1.0.1",
|
|
77
77
|
"typescript": "^6.0.3",
|
|
78
78
|
"typescript-eslint": "^8.66.0",
|
|
79
|
-
"vite": "^7.3.
|
|
79
|
+
"vite": "^7.3.7",
|
|
80
80
|
"vite-plugin-dts": "^5.1.0",
|
|
81
81
|
"vitest": "^5.0.4"
|
|
82
82
|
},
|
|
@@ -88,10 +88,9 @@
|
|
|
88
88
|
"test": "vitest run",
|
|
89
89
|
"test:watch": "vitest",
|
|
90
90
|
"coverage": "vitest run --coverage",
|
|
91
|
+
"smoke:consumer": "node scripts/consumer-smoke.mjs",
|
|
91
92
|
"lint": "eslint src tests",
|
|
92
93
|
"version:bump": "node scripts/bump-version.js",
|
|
93
|
-
"version:sync": "node scripts/sync-version.js"
|
|
94
|
-
"publish:npm": "node scripts/publish-npm.js",
|
|
95
|
-
"publish:npm:dry": "node scripts/publish-npm.js --dry-run"
|
|
94
|
+
"version:sync": "node scripts/sync-version.js"
|
|
96
95
|
}
|
|
97
96
|
}
|
package/src/boundary-vertices.ts
CHANGED