@maplat/tin 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +224 -224
- package/README.ja.md +220 -214
- package/README.md +221 -215
- package/dist/maplat_tin.js +2286 -2299
- package/dist/maplat_tin.umd.js +5 -5
- package/package.json +26 -28
- package/src/boundary-vertices.ts +283 -284
- package/src/constrained-tin.ts +84 -84
- package/src/edgebound/base.ts +65 -65
- package/src/edgebound/bitset.ts +109 -109
- package/src/edgebound/constrain.license.txt +15 -15
- package/src/edgebound/constrain.ts +498 -498
- package/src/edgebound/index.ts +10 -10
- package/src/index.ts +42 -42
- package/src/kinks.ts +1092 -1036
- package/src/searchutils.ts +102 -102
- package/src/strict-overlap.ts +281 -281
- package/src/tin.ts +703 -695
- package/src/types/cdt2d.d.ts +4 -4
- package/src/types/constrainautor.d.ts +6 -6
- package/src/types/kinks.d.ts +51 -49
- package/src/types/tin.d.ts +54 -54
- package/src/vertexutils.ts +87 -88
- package/src/weight-buffer.ts +111 -111
- package/dist/index.cjs +0 -7
- package/dist/index.html +0 -49
- package/dist/maplat_tin.cjs +0 -5
package/dist/maplat_tin.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function($t,Rt){typeof exports=="object"&&typeof module<"u"?Rt(exports):typeof define=="function"&&define.amd?define(["exports"],Rt):($t=typeof globalThis<"u"?globalThis:$t||self,Rt($t.tin={}))})(this,(function($t){"use strict";const Rt=11102230246251565e-32,rt=134217729,un=(3+8*Rt)*Rt;function Yt(s,t,e,n,r){let i,o,a,c,f=t[0],u=n[0],h=0,p=0;u>f==u>-f?(i=f,f=t[++h]):(i=u,u=n[++p]);let y=0;if(h<s&&p<e)for(u>f==u>-f?(o=f+i,a=i-(o-f),f=t[++h]):(o=u+i,a=i-(o-u),u=n[++p]),i=o,a!==0&&(r[y++]=a);h<s&&p<e;)u>f==u>-f?(o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h]):(o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p]),i=o,a!==0&&(r[y++]=a);for(;h<s;)o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h],i=o,a!==0&&(r[y++]=a);for(;p<e;)o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p],i=o,a!==0&&(r[y++]=a);return(i!==0||y===0)&&(r[y++]=i),y}function Ut(s,t,e,n,r,i,o,a){return Yt(Yt(s,t,e,n,o),o,r,i,a)}function q(s,t,e,n){let r,i,o,a,c,f,u,h,p,y,E;u=rt*e,y=u-(u-e),E=e-y;let k=t[0];r=k*e,u=rt*k,h=u-(u-k),p=k-h,o=p*E-(r-h*y-p*y-h*E);let X=0;o!==0&&(n[X++]=o);for(let C=1;C<s;C++)k=t[C],a=k*e,u=rt*k,h=u-(u-k),p=k-h,c=p*E-(a-h*y-p*y-h*E),i=r+c,f=i-r,o=r-(i-f)+(c-f),o!==0&&(n[X++]=o),r=a+i,o=i-(r-a),o!==0&&(n[X++]=o);return(r!==0||X===0)&&(n[X++]=r),X}function ln(s,t){let e=t[0];for(let n=1;n<s;n++)e+=t[n];return e}function yt(s){return new Float64Array(s)}const Wn=(3+16*Rt)*Rt,Jn=(2+12*Rt)*Rt,Kn=(9+64*Rt)*Rt*Rt,ge=yt(4),dn=yt(8),pn=yt(12),mn=yt(16),Ft=yt(4);function Gn(s,t,e,n,r,i,o){let a,c,f,u,h,p,y,E,k,X,C,m,v,l,g,x,A,I;const b=s-r,T=e-r,Y=t-i,D=n-i;l=b*D,p=rt*b,y=p-(p-b),E=b-y,p=rt*D,k=p-(p-D),X=D-k,g=E*X-(l-y*k-E*k-y*X),x=Y*T,p=rt*Y,y=p-(p-Y),E=Y-y,p=rt*T,k=p-(p-T),X=T-k,A=E*X-(x-y*k-E*k-y*X),C=g-A,h=g-C,ge[0]=g-(C+h)+(h-A),m=l+C,h=m-l,v=l-(m-h)+(C-h),C=v-x,h=v-C,ge[1]=v-(C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=m-l,v=l-(m-h)+(C-h),C=v-x,h=v-C,Ft[1]=v-(C+h)+(h-x),I=m+C,h=I-m,Ft[2]=m-(I-h)+(C-h),Ft[3]=I;const B=Yt(_,pn,4,Ft,mn);return mn[B-1]}function Qt(s,t,e,n,r,i){const o=(t-i)*(e-r),a=(s-r)*(n-i),c=o-a,f=Math.abs(o+a);return Math.abs(c)>=Wn*f?c:-Gn(s,t,e,n,r,i,f)}const Qn=(10+96*Rt)*Rt,Hn=(4+48*Rt)*Rt,Zn=(44+576*Rt)*Rt*Rt,ie=yt(4),oe=yt(4),se=yt(4),Ht=yt(4),Zt=yt(4),te=yt(4),Lt=yt(4),Dt=yt(4),ze=yt(8),Ve=yt(8),We=yt(8),Je=yt(8),Ke=yt(8),Ge=yt(8),Ie=yt(8),Te=yt(8),Ne=yt(8),fe=yt(4),he=yt(4),ue=yt(4),st=yt(8),lt=yt(16),kt=yt(16),St=yt(16),bt=yt(32),ae=yt(32),Bt=yt(48),qt=yt(64);let we=yt(1152),Qe=yt(1152);function Ot(s,t,e){s=Yt(s,we,t,e,Qe);const n=we;return we=Qe,Qe=n,s}function tr(s,t,e,n,r,i,o,a,c){let f,u,h,p,y,E,k,X,C,m,v,l,g,x,A,I,b,T,Y,D,Q,d,M,_,B,N,R,w,O,$,j,V,z,K,U;const ct=s-o,ft=e-o,dt=r-o,pt=t-a,gt=n-a,mt=i-a;j=ft*mt,M=rt*ft,_=M-(M-ft),B=ft-_,M=rt*mt,N=M-(M-mt),R=mt-N,V=B*R-(j-_*N-B*N-_*R),z=dt*gt,M=rt*dt,_=M-(M-dt),B=dt-_,M=rt*gt,N=M-(M-gt),R=gt-N,K=B*R-(z-_*N-B*N-_*R),w=V-K,d=V-w,ie[0]=V-(w+d)+(d-K),O=j+w,d=O-j,$=j-(O-d)+(w-d),w=$-z,d=$-w,ie[1]=$-(w+d)+(d-z),U=O+w,d=U-O,ie[2]=O-(U-d)+(w-d),ie[3]=U,j=dt*pt,M=rt*dt,_=M-(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(w-d),w=$-z,d=$-w,fe[1]=$-(w+d)+(d-z),U=O+w,d=U-O,fe[2]=O-(U-d)+(w-d),fe[3]=U,b=4):(Ie[0]=0,x=1,fe[0]=0,b=1),p!==0){const xt=q(x,Ie,p,St);f=Ot(f,Yt(q(l,Ke,p,lt),lt,q(xt,St,2*dt,bt),bt,Bt),Bt);const Mt=q(b,fe,p,st);f=Ot(f,Ut(q(Mt,st,2*dt,lt),lt,q(Mt,st,p,kt),kt,q(xt,St,p,bt),bt,ae,qt),qt),y!==0&&(f=Ot(f,q(q(4,Zt,p,st),st,y,lt),lt)),E!==0&&(f=Ot(f,q(q(4,Ht,-p,st),st,E,lt),lt))}if(k!==0){const xt=q(x,Ie,k,St);f=Ot(f,Yt(q(g,Ge,k,lt),lt,q(xt,St,2*mt,bt),bt,Bt),Bt);const Mt=q(b,fe,k,st);f=Ot(f,Ut(q(Mt,st,2*mt,lt),lt,q(Mt,st,k,kt),kt,q(xt,St,k,bt),bt,ae,qt),qt)}}return we[f-1]}function er(s,t,e,n,r,i,o,a){const c=s-o,f=e-o,u=r-o,h=t-a,p=n-a,y=i-a,E=f*y,k=u*p,X=c*c+h*h,C=u*h,m=c*y,v=f*f+p*p,l=c*p,g=f*h,x=u*u+y*y,A=X*(E-k)+v*(C-m)+x*(l-g),I=(Math.abs(E)+Math.abs(k))*X+(Math.abs(C)+Math.abs(m))*v+(Math.abs(l)+Math.abs(g))*x,b=Qn*I;return A>b||-A>b?A:tr(s,t,e,n,r,i,o,a,I)}function nr(s,t){var e,n,r=0,i,o,a,c,f,u,h,p=s[0],y=s[1],E=t.length;for(e=0;e<E;e++){n=0;var k=t[e],X=k.length-1;if(u=k[0],u[0]!==k[X][0]&&u[1]!==k[X][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-p,a=u[1]-y,n;n<X;n++){if(h=k[n+1],c=h[0]-p,f=h[1]-y,a===0&&f===0){if(c<=0&&o>=0||o<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(i=Qt(o,c,a,f,0,0),i===0)return 0;(i>0&&f>0&&a<=0||i<0&&f<=0&&a>0)&&r++}u=h,a=f,o=c}}return r%2!==0}function be(s,t,e={}){const n={type:"Feature"};return(e.id===0||e.id)&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.properties=t||{},n.geometry=s,n}function le(s,t,e={}){if(!s)throw new Error("coordinates is required");if(!Array.isArray(s))throw new Error("coordinates must be an Array");if(s.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!wn(s[0])||!wn(s[1]))throw new Error("coordinates must contain numbers");return be({type:"Point",coordinates:s},t,e)}function _e(s,t,e={}){for(const r of s){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let i=0;i<r[r.length-1].length;i++)if(r[r.length-1][i]!==r[0][i])throw new Error("First and last Position are not equivalent.")}return be({type:"Polygon",coordinates:s},t,e)}function gn(s,t,e={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return be({type:"LineString",coordinates:s},t,e)}function Vt(s,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=s,e}function wn(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}function rr(s){if(!s)throw new Error("coord is required");if(!Array.isArray(s)){if(s.type==="Feature"&&s.geometry!==null&&s.geometry.type==="Point")return[...s.geometry.coordinates];if(s.type==="Point")return[...s.coordinates]}if(Array.isArray(s)&&s.length>=2&&!Array.isArray(s[0])&&!Array.isArray(s[1]))return[...s];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ir(s){return s.type==="Feature"?s.geometry:s}function or(s,t,e={}){if(!s)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=rr(s),r=ir(t),i=r.type,o=t.bbox;let a=r.coordinates;if(o&&sr(n,o)===!1)return!1;i==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const u=nr(n,a[f]);if(u===0)return!e.ignoreBoundary;u&&(c=!0)}return c}function sr(s,t){return t[0]<=s[0]&&t[1]<=s[1]&&t[2]>=s[0]&&t[3]>=s[1]}var ar=or;function He(s,t,e){if(s!==null)for(var n,r,i,o,a,c,f,u=0,h=0,p,y=s.type,E=y==="FeatureCollection",k=y==="Feature",X=E?s.features.length:1,C=0;C<X;C++){f=E?s.features[C].geometry:k?s.geometry:s,p=f?f.type==="GeometryCollection":!1,a=p?f.geometries.length:1;for(var m=0;m<a;m++){var v=0,l=0;if(o=p?f.geometries[m]:f,o!==null){c=o.coordinates;var g=o.type;switch(u=e&&(g==="Polygon"||g==="MultiPolygon")?1:0,g){case null:break;case"Point":if(t(c,h,C,v,l)===!1)return!1;h++,v++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,C,v,l)===!1)return!1;h++,g==="MultiPoint"&&v++}g==="LineString"&&v++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(r=0;r<c[n].length-u;r++){if(t(c[n][r],h,C,v,l)===!1)return!1;h++}g==="MultiLineString"&&v++,g==="Polygon"&&l++}g==="Polygon"&&v++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(l=0,r=0;r<c[n].length;r++){for(i=0;i<c[n][r].length-u;i++){if(t(c[n][r][i],h,C,v,l)===!1)return!1;h++}l++}v++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(He(o.geometries[n],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function cr(s,t={}){let e=0,n=0,r=0;return He(s,function(i){e+=i[0],n+=i[1],r++},!0),le([e/r,n/r],t.properties)}var fr=cr;function hr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function ur(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var e=function n(){var r=!1;try{r=this instanceof n}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(n){var r=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return s[n]}})}),e}var Xe={exports:{}},Re={exports:{}},lr=Re.exports,yn;function dr(){return yn||(yn=1,(function(s,t){(function(e,n){s.exports=n()})(lr,function(){function e(m,v,l,g,x){(function A(I,b,T,Y,D){for(;Y>T;){if(Y-T>600){var Q=Y-T+1,d=b-T+1,M=Math.log(Q),_=.5*Math.exp(2*M/3),B=.5*Math.sqrt(M*_*(Q-_)/Q)*(d-Q/2<0?-1:1),N=Math.max(T,Math.floor(b-d*_/Q+B)),R=Math.min(Y,Math.floor(b+(Q-d)*_/Q+B));A(I,b,N,R,D)}var w=I[b],O=T,$=Y;for(n(I,T,b),D(I[Y],w)>0&&n(I,T,Y);O<$;){for(n(I,O,$),O++,$--;D(I[O],w)<0;)O++;for(;D(I[$],w)>0;)$--}D(I[T],w)===0?n(I,T,$):n(I,++$,Y),$<=b&&(T=$+1),b<=$&&(Y=$-1)}})(m,v,l||0,g||m.length-1,x||r)}function n(m,v,l){var g=m[v];m[v]=m[l],m[l]=g}function r(m,v){return m<v?-1:m>v?1:0}var i=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 o(m,v,l){if(!l)return v.indexOf(m);for(var g=0;g<v.length;g++)if(l(m,v[g]))return g;return-1}function a(m,v){c(m,0,m.children.length,v,m)}function c(m,v,l,g,x){x||(x=X(null)),x.minX=1/0,x.minY=1/0,x.maxX=-1/0,x.maxY=-1/0;for(var A=v;A<l;A++){var I=m.children[A];f(x,m.leaf?g(I):I)}return x}function f(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 u(m,v){return m.minX-v.minX}function h(m,v){return m.minY-v.minY}function p(m){return(m.maxX-m.minX)*(m.maxY-m.minY)}function y(m){return m.maxX-m.minX+(m.maxY-m.minY)}function E(m,v){return m.minX<=v.minX&&m.minY<=v.minY&&v.maxX<=m.maxX&&v.maxY<=m.maxY}function k(m,v){return v.minX<=m.maxX&&v.minY<=m.maxY&&v.maxX>=m.minX&&v.maxY>=m.minY}function X(m){return{children:m,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function C(m,v,l,g,x){for(var A=[v,l];A.length;)if(!((l=A.pop())-(v=A.pop())<=g)){var I=v+Math.ceil((l-v)/g/2)*g;e(m,I,v,l,x),A.push(v,I,I,l)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(m){var v=this.data,l=[];if(!k(m,v))return l;for(var g=this.toBBox,x=[];v;){for(var A=0;A<v.children.length;A++){var I=v.children[A],b=v.leaf?g(I):I;k(m,b)&&(v.leaf?l.push(I):E(m,b)?this._all(I,l):x.push(I))}v=x.pop()}return l},i.prototype.collides=function(m){var v=this.data;if(!k(m,v))return!1;for(var l=[];v;){for(var g=0;g<v.children.length;g++){var x=v.children[g],A=v.leaf?this.toBBox(x):x;if(k(m,A)){if(v.leaf||E(m,A))return!0;l.push(x)}}v=l.pop()}return!1},i.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 l=this._build(m.slice(),0,m.length-1,0);if(this.data.children.length)if(this.data.height===l.height)this._splitRoot(this.data,l);else{if(this.data.height<l.height){var g=this.data;this.data=l,l=g}this._insert(l,this.data.height-l.height-1,!0)}else this.data=l;return this},i.prototype.insert=function(m){return m&&this._insert(m,this.data.height-1),this},i.prototype.clear=function(){return this.data=X([]),this},i.prototype.remove=function(m,v){if(!m)return this;for(var l,g,x,A=this.data,I=this.toBBox(m),b=[],T=[];A||b.length;){if(A||(A=b.pop(),g=b[b.length-1],l=T.pop(),x=!0),A.leaf){var Y=o(m,A.children,v);if(Y!==-1)return A.children.splice(Y,1),b.push(A),this._condense(b),this}x||A.leaf||!E(A,I)?g?(l++,A=g.children[l],x=!1):A=null:(b.push(A),T.push(l),l=0,g=A,A=A.children[0])}return this},i.prototype.toBBox=function(m){return m},i.prototype.compareMinX=function(m,v){return m.minX-v.minX},i.prototype.compareMinY=function(m,v){return m.minY-v.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(m){return this.data=m,this},i.prototype._all=function(m,v){for(var l=[];m;)m.leaf?v.push.apply(v,m.children):l.push.apply(l,m.children),m=l.pop();return v},i.prototype._build=function(m,v,l,g){var x,A=l-v+1,I=this._maxEntries;if(A<=I)return a(x=X(m.slice(v,l+1)),this.toBBox),x;g||(g=Math.ceil(Math.log(A)/Math.log(I)),I=Math.ceil(A/Math.pow(I,g-1))),(x=X([])).leaf=!1,x.height=g;var b=Math.ceil(A/I),T=b*Math.ceil(Math.sqrt(I));C(m,v,l,T,this.compareMinX);for(var Y=v;Y<=l;Y+=T){var D=Math.min(Y+T-1,l);C(m,Y,D,b,this.compareMinY);for(var Q=Y;Q<=D;Q+=b){var d=Math.min(Q+b-1,D);x.children.push(this._build(m,Q,d,g-1))}}return a(x,this.toBBox),x},i.prototype._chooseSubtree=function(m,v,l,g){for(;g.push(v),!v.leaf&&g.length-1!==l;){for(var x=1/0,A=1/0,I=void 0,b=0;b<v.children.length;b++){var T=v.children[b],Y=p(T),D=(Q=m,d=T,(Math.max(d.maxX,Q.maxX)-Math.min(d.minX,Q.minX))*(Math.max(d.maxY,Q.maxY)-Math.min(d.minY,Q.minY))-Y);D<A?(A=D,x=Y<x?Y:x,I=T):D===A&&Y<x&&(x=Y,I=T)}v=I||v.children[0]}var Q,d;return v},i.prototype._insert=function(m,v,l){var g=l?m:this.toBBox(m),x=[],A=this._chooseSubtree(g,this.data,v,x);for(A.children.push(m),f(A,g);v>=0&&x[v].children.length>this._maxEntries;)this._split(x,v),v--;this._adjustParentBBoxes(g,x,v)},i.prototype._split=function(m,v){var l=m[v],g=l.children.length,x=this._minEntries;this._chooseSplitAxis(l,x,g);var A=this._chooseSplitIndex(l,x,g),I=X(l.children.splice(A,l.children.length-A));I.height=l.height,I.leaf=l.leaf,a(l,this.toBBox),a(I,this.toBBox),v?m[v-1].children.push(I):this._splitRoot(l,I)},i.prototype._splitRoot=function(m,v){this.data=X([m,v]),this.data.height=m.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(m,v,l){for(var g,x,A,I,b,T,Y,D=1/0,Q=1/0,d=v;d<=l-v;d++){var M=c(m,0,d,this.toBBox),_=c(m,d,l,this.toBBox),B=(x=M,A=_,I=void 0,b=void 0,T=void 0,Y=void 0,I=Math.max(x.minX,A.minX),b=Math.max(x.minY,A.minY),T=Math.min(x.maxX,A.maxX),Y=Math.min(x.maxY,A.maxY),Math.max(0,T-I)*Math.max(0,Y-b)),N=p(M)+p(_);B<D?(D=B,g=d,Q=N<Q?N:Q):B===D&&N<Q&&(Q=N,g=d)}return g||l-v},i.prototype._chooseSplitAxis=function(m,v,l){var g=m.leaf?this.compareMinX:u,x=m.leaf?this.compareMinY:h;this._allDistMargin(m,v,l,g)<this._allDistMargin(m,v,l,x)&&m.children.sort(g)},i.prototype._allDistMargin=function(m,v,l,g){m.children.sort(g);for(var x=this.toBBox,A=c(m,0,v,x),I=c(m,l-v,l,x),b=y(A)+y(I),T=v;T<l-v;T++){var Y=m.children[T];f(A,m.leaf?x(Y):Y),b+=y(A)}for(var D=l-v-1;D>=v;D--){var Q=m.children[D];f(I,m.leaf?x(Q):Q),b+=y(I)}return b},i.prototype._adjustParentBBoxes=function(m,v,l){for(var g=l;g>=0;g--)f(v[g],m)},i.prototype._condense=function(m){for(var v=m.length-1,l=void 0;v>=0;v--)m[v].children.length===0?v>0?(l=m[v-1].children).splice(l.indexOf(m[v]),1):this.clear():a(m[v],this.toBBox)},i})})(Re)),Re.exports}let pr=class{constructor(t=[],e=mr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}};function mr(s,t){return s<t?-1:s>t?1:0}const gr=ur(Object.freeze(Object.defineProperty({__proto__:null,default:pr},Symbol.toStringTag,{value:"Module"})));var xe={exports:{}},Ze,vn;function wr(){return vn||(vn=1,Ze=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=(r-n)/2,f=0,u=c-1;f<c;u=f++){var h=e[n+f*2+0],p=e[n+f*2+1],y=e[n+u*2+0],E=e[n+u*2+1],k=p>o!=E>o&&i<(y-h)*(o-p)/(E-p)+h;k&&(a=!a)}return a}),Ze}var tn,bn;function yr(){return bn||(bn=1,tn=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=r-n,f=0,u=c-1;f<c;u=f++){var h=e[f+n][0],p=e[f+n][1],y=e[u+n][0],E=e[u+n][1],k=p>o!=E>o&&i<(y-h)*(o-p)/(E-p)+h;k&&(a=!a)}return a}),tn}var _n;function vr(){if(_n)return xe.exports;_n=1;var s=wr(),t=yr();return xe.exports=function(n,r,i,o){return r.length>0&&Array.isArray(r[0])?t(n,r,i,o):s(n,r,i,o)},xe.exports.nested=t,xe.exports.flat=s,xe.exports}var Me={exports:{}},br=Me.exports,xn;function _r(){return xn||(xn=1,(function(s,t){(function(e,n){n(t)})(br,function(e){const r=33306690738754706e-32;function i(k,X,C,m,v){let l,g,x,A,I=X[0],b=m[0],T=0,Y=0;b>I==b>-I?(l=I,I=X[++T]):(l=b,b=m[++Y]);let D=0;if(T<k&&Y<C)for(b>I==b>-I?(x=l-((g=I+l)-I),I=X[++T]):(x=l-((g=b+l)-b),b=m[++Y]),l=g,x!==0&&(v[D++]=x);T<k&&Y<C;)b>I==b>-I?(x=l-((g=l+I)-(A=g-l))+(I-A),I=X[++T]):(x=l-((g=l+b)-(A=g-l))+(b-A),b=m[++Y]),l=g,x!==0&&(v[D++]=x);for(;T<k;)x=l-((g=l+I)-(A=g-l))+(I-A),I=X[++T],l=g,x!==0&&(v[D++]=x);for(;Y<C;)x=l-((g=l+b)-(A=g-l))+(b-A),b=m[++Y],l=g,x!==0&&(v[D++]=x);return l===0&&D!==0||(v[D++]=l),D}function o(k){return new Float64Array(k)}const a=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,u=o(4),h=o(8),p=o(12),y=o(16),E=o(4);e.orient2d=function(k,X,C,m,v,l){const g=(X-l)*(C-v),x=(k-v)*(m-l),A=g-x;if(g===0||x===0||g>0!=x>0)return A;const I=Math.abs(g+x);return Math.abs(A)>=a*I?A:-(function(b,T,Y,D,Q,d,M){let _,B,N,R,w,O,$,j,V,z,K,U,ct,ft,dt,pt,gt,mt;const Pt=b-Q,Nt=Y-Q,xt=T-d,Mt=D-d;w=(dt=(j=Pt-($=(O=134217729*Pt)-(O-Pt)))*(z=Mt-(V=(O=134217729*Mt)-(O-Mt)))-((ft=Pt*Mt)-$*V-j*V-$*z))-(K=dt-(gt=(j=xt-($=(O=134217729*xt)-(O-xt)))*(z=Nt-(V=(O=134217729*Nt)-(O-Nt)))-((pt=xt*Nt)-$*V-j*V-$*z))),u[0]=dt-(K+w)+(w-gt),w=(ct=ft-((U=ft+K)-(w=U-ft))+(K-w))-(K=ct-pt),u[1]=ct-(K+w)+(w-pt),w=(mt=U+K)-U,u[2]=U-(mt-w)+(K-w),u[3]=mt;let ee=(function(S,P){let F=P[0];for(let L=1;L<S;L++)F+=P[L];return F})(4,u),pe=c*M;if(ee>=pe||-ee>=pe||(_=b-(Pt+(w=b-Pt))+(w-Q),N=Y-(Nt+(w=Y-Nt))+(w-Q),B=T-(xt+(w=T-xt))+(w-d),R=D-(Mt+(w=D-Mt))+(w-d),_===0&&B===0&&N===0&&R===0)||(pe=f*M+r*Math.abs(ee),(ee+=Pt*R+Mt*_-(xt*N+Nt*B))>=pe||-ee>=pe))return ee;w=(dt=(j=_-($=(O=134217729*_)-(O-_)))*(z=Mt-(V=(O=134217729*Mt)-(O-Mt)))-((ft=_*Mt)-$*V-j*V-$*z))-(K=dt-(gt=(j=B-($=(O=134217729*B)-(O-B)))*(z=Nt-(V=(O=134217729*Nt)-(O-Nt)))-((pt=B*Nt)-$*V-j*V-$*z))),E[0]=dt-(K+w)+(w-gt),w=(ct=ft-((U=ft+K)-(w=U-ft))+(K-w))-(K=ct-pt),E[1]=ct-(K+w)+(w-pt),w=(mt=U+K)-U,E[2]=U-(mt-w)+(K-w),E[3]=mt;const fn=i(4,u,4,E,h);w=(dt=(j=Pt-($=(O=134217729*Pt)-(O-Pt)))*(z=R-(V=(O=134217729*R)-(O-R)))-((ft=Pt*R)-$*V-j*V-$*z))-(K=dt-(gt=(j=xt-($=(O=134217729*xt)-(O-xt)))*(z=N-(V=(O=134217729*N)-(O-N)))-((pt=xt*N)-$*V-j*V-$*z))),E[0]=dt-(K+w)+(w-gt),w=(ct=ft-((U=ft+K)-(w=U-ft))+(K-w))-(K=ct-pt),E[1]=ct-(K+w)+(w-pt),w=(mt=U+K)-U,E[2]=U-(mt-w)+(K-w),E[3]=mt;const hn=i(fn,h,4,E,p);w=(dt=(j=_-($=(O=134217729*_)-(O-_)))*(z=R-(V=(O=134217729*R)-(O-R)))-((ft=_*R)-$*V-j*V-$*z))-(K=dt-(gt=(j=B-($=(O=134217729*B)-(O-B)))*(z=N-(V=(O=134217729*N)-(O-N)))-((pt=B*N)-$*V-j*V-$*z))),E[0]=dt-(K+w)+(w-gt),w=(ct=ft-((U=ft+K)-(w=U-ft))+(K-w))-(K=ct-pt),E[1]=ct-(K+w)+(w-pt),w=(mt=U+K)-U,E[2]=U-(mt-w)+(K-w),E[3]=mt;const jt=i(hn,p,4,E,y);return y[jt-1]})(k,X,C,m,v,l,I)},e.orient2dfast=function(k,X,C,m,v,l){return(X-l)*(C-v)-(k-v)*(m-l)},Object.defineProperty(e,"__esModule",{value:!0})})})(Me,Me.exports)),Me.exports}var Mn;function xr(){if(Mn)return Xe.exports;Mn=1;var s=dr(),t=gr,e=vr(),n=_r().orient2d;t.default&&(t=t.default),Xe.exports=r,Xe.exports.default=r;function r(l,g,x){g=Math.max(0,g===void 0?2:g),x=x||0;var A=y(l),I=new s(16);I.toBBox=function($){return{minX:$[0],minY:$[1],maxX:$[0],maxY:$[1]}},I.compareMinX=function($,j){return $[0]-j[0]},I.compareMinY=function($,j){return $[1]-j[1]},I.load(l);for(var b=[],T=0,Y;T<A.length;T++){var D=A[T];I.remove(D),Y=E(D,Y),b.push(Y)}var Q=new s(16);for(T=0;T<b.length;T++)Q.insert(p(b[T]));for(var d=g*g,M=x*x;b.length;){var _=b.shift(),B=_.p,N=_.next.p,R=k(B,N);if(!(R<M)){var w=R/d;D=i(I,_.prev.p,B,N,_.next.next.p,w,Q),D&&Math.min(k(D,B),k(D,N))<=w&&(b.push(_),b.push(E(D,_)),I.remove(D),Q.remove(_),Q.insert(p(_)),Q.insert(p(_.next)))}}_=Y;var O=[];do O.push(_.p),_=_.next;while(_!==Y);return O.push(_.p),O}function i(l,g,x,A,I,b,T){for(var Y=new t([],o),D=l.data;D;){for(var Q=0;Q<D.children.length;Q++){var d=D.children[Q],M=D.leaf?X(d,x,A):a(x,A,d);M>b||Y.push({node:d,dist:M})}for(;Y.length&&!Y.peek().node.children;){var _=Y.pop(),B=_.node,N=X(B,g,x),R=X(B,A,I);if(_.dist<N&&_.dist<R&&f(x,B,T)&&f(A,B,T))return B}D=Y.pop(),D&&(D=D.node)}return null}function o(l,g){return l.dist-g.dist}function a(l,g,x){if(c(l,x)||c(g,x))return 0;var A=C(l[0],l[1],g[0],g[1],x.minX,x.minY,x.maxX,x.minY);if(A===0)return 0;var I=C(l[0],l[1],g[0],g[1],x.minX,x.minY,x.minX,x.maxY);if(I===0)return 0;var b=C(l[0],l[1],g[0],g[1],x.maxX,x.minY,x.maxX,x.maxY);if(b===0)return 0;var T=C(l[0],l[1],g[0],g[1],x.minX,x.maxY,x.maxX,x.maxY);return T===0?0:Math.min(A,I,b,T)}function c(l,g){return l[0]>=g.minX&&l[0]<=g.maxX&&l[1]>=g.minY&&l[1]<=g.maxY}function f(l,g,x){for(var A=Math.min(l[0],g[0]),I=Math.min(l[1],g[1]),b=Math.max(l[0],g[0]),T=Math.max(l[1],g[1]),Y=x.search({minX:A,minY:I,maxX:b,maxY:T}),D=0;D<Y.length;D++)if(h(Y[D].p,Y[D].next.p,l,g))return!1;return!0}function u(l,g,x){return n(l[0],l[1],g[0],g[1],x[0],x[1])}function h(l,g,x,A){return l!==A&&g!==x&&u(l,g,x)>0!=u(l,g,A)>0&&u(x,A,l)>0!=u(x,A,g)>0}function p(l){var g=l.p,x=l.next.p;return l.minX=Math.min(g[0],x[0]),l.minY=Math.min(g[1],x[1]),l.maxX=Math.max(g[0],x[0]),l.maxY=Math.max(g[1],x[1]),l}function y(l){for(var g=l[0],x=l[0],A=l[0],I=l[0],b=0;b<l.length;b++){var T=l[b];T[0]<g[0]&&(g=T),T[0]>A[0]&&(A=T),T[1]<x[1]&&(x=T),T[1]>I[1]&&(I=T)}var Y=[g,x,A,I],D=Y.slice();for(b=0;b<l.length;b++)e(l[b],Y)||D.push(l[b]);return v(D)}function E(l,g){var x={p:l,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return g?(x.next=g.next,x.prev=g,g.next.prev=x,g.next=x):(x.prev=x,x.next=x),x}function k(l,g){var x=l[0]-g[0],A=l[1]-g[1];return x*x+A*A}function X(l,g,x){var A=g[0],I=g[1],b=x[0]-A,T=x[1]-I;if(b!==0||T!==0){var Y=((l[0]-A)*b+(l[1]-I)*T)/(b*b+T*T);Y>1?(A=x[0],I=x[1]):Y>0&&(A+=b*Y,I+=T*Y)}return b=l[0]-A,T=l[1]-I,b*b+T*T}function C(l,g,x,A,I,b,T,Y){var D=x-l,Q=A-g,d=T-I,M=Y-b,_=l-I,B=g-b,N=D*D+Q*Q,R=D*d+Q*M,w=d*d+M*M,O=D*_+Q*B,$=d*_+M*B,j=N*w-R*R,V,z,K,U,ct=j,ft=j;j===0?(z=0,ct=1,U=$,ft=w):(z=R*$-w*O,U=N*$-R*O,z<0?(z=0,U=$,ft=w):z>ct&&(z=ct,U=$+R,ft=w)),U<0?(U=0,-O<0?z=0:-O>N?z=ct:(z=-O,ct=N)):U>ft&&(U=ft,-O+R<0?z=0:-O+R>N?z=ct:(z=-O+R,ct=N)),V=z===0?0:z/ct,K=U===0?0:U/ft;var dt=(1-V)*l+V*x,pt=(1-V)*g+V*A,gt=(1-K)*I+K*T,mt=(1-K)*b+K*Y,Pt=gt-dt,Nt=mt-pt;return Pt*Pt+Nt*Nt}function m(l,g){return l[0]===g[0]?l[1]-g[1]:l[0]-g[0]}function v(l){l.sort(m);for(var g=[],x=0;x<l.length;x++){for(;g.length>=2&&u(g[g.length-2],g[g.length-1],l[x])<=0;)g.pop();g.push(l[x])}for(var A=[],I=l.length-1;I>=0;I--){for(;A.length>=2&&u(A[A.length-2],A[A.length-1],l[I])<=0;)A.pop();A.push(l[I])}return A.pop(),g.pop(),g.concat(A)}return Xe.exports}var Mr=xr();const kr=hr(Mr);function Sr(s,t={}){t.concavity=t.concavity||1/0;const e=[];if(He(s,r=>{e.push([r[0],r[1]])}),!e.length)return null;const n=kr(e,t.concavity);return n.length>3?_e([n]):null}var kn=Sr,ke={exports:{}},Er=ke.exports,Sn;function Ar(){return Sn||(Sn=1,(function(s,t){(function(e,n){n(t)})(Er,function(e){const n=11102230246251565e-32,r=134217729,i=(3+8*n)*n;function o(S,P,F,L,tt){let G,et,ot,it,at=P[0],ht=L[0],J=0,Z=0;ht>at==ht>-at?(G=at,at=P[++J]):(G=ht,ht=L[++Z]);let ut=0;if(J<S&&Z<F)for(ht>at==ht>-at?(et=at+G,ot=G-(et-at),at=P[++J]):(et=ht+G,ot=G-(et-ht),ht=L[++Z]),G=et,ot!==0&&(tt[ut++]=ot);J<S&&Z<F;)ht>at==ht>-at?(et=G+at,it=et-G,ot=G-(et-it)+(at-it),at=P[++J]):(et=G+ht,it=et-G,ot=G-(et-it)+(ht-it),ht=L[++Z]),G=et,ot!==0&&(tt[ut++]=ot);for(;J<S;)et=G+at,it=et-G,ot=G-(et-it)+(at-it),at=P[++J],G=et,ot!==0&&(tt[ut++]=ot);for(;Z<F;)et=G+ht,it=et-G,ot=G-(et-it)+(ht-it),ht=L[++Z],G=et,ot!==0&&(tt[ut++]=ot);return(G!==0||ut===0)&&(tt[ut++]=G),ut}function a(S,P){let F=P[0];for(let L=1;L<S;L++)F+=P[L];return F}function c(S){return new Float64Array(S)}const f=(3+16*n)*n,u=(2+12*n)*n,h=(9+64*n)*n*n,p=c(4),y=c(8),E=c(12),k=c(16),X=c(4);function C(S,P,F,L,tt,G,et){let ot,it,at,ht,J,Z,ut,_t,nt,H,W,wt,Et,At,Xt,vt,Tt,Ct;const Wt=S-tt,Jt=F-tt,Kt=P-G,Gt=L-G;At=Wt*Gt,Z=r*Wt,ut=Z-(Z-Wt),_t=Wt-ut,Z=r*Gt,nt=Z-(Z-Gt),H=Gt-nt,Xt=_t*H-(At-ut*nt-_t*nt-ut*H),vt=Kt*Jt,Z=r*Kt,ut=Z-(Z-Kt),_t=Kt-ut,Z=r*Jt,nt=Z-(Z-Jt),H=Jt-nt,Tt=_t*H-(vt-ut*nt-_t*nt-ut*H),W=Xt-Tt,J=Xt-W,p[0]=Xt-(W+J)+(J-Tt),wt=At+W,J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X[2]=wt-(Ct-J)+(W-J),X[3]=Ct;const Ei=o(Si,y,4,X,E);At=ot*ht,Z=r*ot,ut=Z-(Z-ot),_t=ot-ut,Z=r*ht,nt=Z-(Z-ht),H=ht-nt,Xt=_t*H-(At-ut*nt-_t*nt-ut*H),vt=it*at,Z=r*it,ut=Z-(Z-it),_t=it-ut,Z=r*at,nt=Z-(Z-at),H=at-nt,Tt=_t*H-(vt-ut*nt-_t*nt-ut*H),W=Xt-Tt,J=Xt-W,X[0]=Xt-(W+J)+(J-Tt),wt=At+W,J=wt-At,Et=At-(wt-J)+(W-J),W=Et-vt,J=Et-W,X[1]=Et-(W+J)+(J-vt),Ct=wt+W,J=Ct-wt,X[2]=wt-(Ct-J)+(W-J),X[3]=Ct;const Ai=o(Ei,E,4,X,k);return k[Ai-1]}function m(S,P,F,L,tt,G){const et=(P-G)*(F-tt),ot=(S-tt)*(L-G),it=et-ot,at=Math.abs(et+ot);return Math.abs(it)>=f*at?it:-C(S,P,F,L,tt,G,at)}function v(S,P){var F,L,tt=0,G,et,ot,it,at,ht,J,Z=S[0],ut=S[1],_t=P.length;for(F=0;F<_t;F++){L=0;var nt=P[F],H=nt.length-1;if(ht=nt[0],ht[0]!==nt[H][0]&&ht[1]!==nt[H][1])throw new Error("First and last coordinates in a ring must be the same");for(et=ht[0]-Z,ot=ht[1]-ut,L;L<H;L++){if(J=nt[L+1],it=J[0]-Z,at=J[1]-ut,ot===0&&at===0){if(it<=0&&et>=0||et<=0&&it>=0)return 0}else if(at>=0&&ot<=0||at<=0&&ot>=0){if(G=m(et,it,ot,at,0,0),G===0)return 0;(G>0&&at>0&&ot<=0||G<0&&at<=0&&ot>0)&&tt++}ht=J,ot=at,et=it}}return tt%2!==0}function l(S,P,F={}){const L={type:"Feature"};return(F.id===0||F.id)&&(L.id=F.id),F.bbox&&(L.bbox=F.bbox),L.properties=P||{},L.geometry=S,L}function g(S,P,F={}){if(!S)throw new Error("coordinates is required");if(!Array.isArray(S))throw new Error("coordinates must be an Array");if(S.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!I(S[0])||!I(S[1]))throw new Error("coordinates must contain numbers");return l({type:"Point",coordinates:S},P,F)}function x(S,P,F={}){for(const L of S){if(L.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(L[L.length-1].length!==L[0].length)throw new Error("First and last Position are not equivalent.");for(let tt=0;tt<L[L.length-1].length;tt++)if(L[L.length-1][tt]!==L[0][tt])throw new Error("First and last Position are not equivalent.")}return l({type:"Polygon",coordinates:S},P,F)}function A(S,P={}){const F={type:"FeatureCollection"};return P.id&&(F.id=P.id),P.bbox&&(F.bbox=P.bbox),F.features=S,F}function I(S){return!isNaN(S)&&S!==null&&!Array.isArray(S)}function b(S){if(!S)throw new Error("coord is required");if(!Array.isArray(S)){if(S.type==="Feature"&&S.geometry!==null&&S.geometry.type==="Point")return[...S.geometry.coordinates];if(S.type==="Point")return[...S.coordinates]}if(Array.isArray(S)&&S.length>=2&&!Array.isArray(S[0])&&!Array.isArray(S[1]))return[...S];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function T(S){if(Array.isArray(S))return S;if(S.type==="Feature"){if(S.geometry!==null)return S.geometry.coordinates}else if(S.coordinates)return S.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Y(S){return S.type==="Feature"?S.geometry:S}function D(S,P,F={}){if(!S)throw new Error("point is required");if(!P)throw new Error("polygon is required");const L=b(S),tt=Y(P),G=tt.type,et=P.bbox;let ot=tt.coordinates;if(et&&Q(L,et)===!1)return!1;G==="Polygon"&&(ot=[ot]);let it=!1;for(var at=0;at<ot.length;++at){const ht=v(L,ot[at]);if(ht===0)return!F.ignoreBoundary;ht&&(it=!0)}return it}function Q(S,P){return P[0]<=S[0]&&P[1]<=S[1]&&P[2]>=S[0]&&P[3]>=S[1]}var d=D;function M(S,P){for(let F=0;F<P.features.length;F++)if(d(S,P.features[F]))return P.features[F]}function _(S,P,F){const L=P.geometry.coordinates[0][0],tt=P.geometry.coordinates[0][1],G=P.geometry.coordinates[0][2],et=S.geometry.coordinates,ot=P.properties.a.geom,it=P.properties.b.geom,at=P.properties.c.geom,ht=[tt[0]-L[0],tt[1]-L[1]],J=[G[0]-L[0],G[1]-L[1]],Z=[et[0]-L[0],et[1]-L[1]],ut=[it[0]-ot[0],it[1]-ot[1]],_t=[at[0]-ot[0],at[1]-ot[1]];let nt=(J[1]*Z[0]-J[0]*Z[1])/(ht[0]*J[1]-ht[1]*J[0]),H=(ht[0]*Z[1]-ht[1]*Z[0])/(ht[0]*J[1]-ht[1]*J[0]);if(F){const W=F[P.properties.a.index],wt=F[P.properties.b.index],Et=F[P.properties.c.index];let At;if(nt<0||H<0||1-nt-H<0){const Xt=nt/(nt+H),vt=H/(nt+H);At=nt/wt/(Xt/wt+vt/Et),H=H/Et/(Xt/wt+vt/Et)}else At=nt/wt/(nt/wt+H/Et+(1-nt-H)/W),H=H/Et/(nt/wt+H/Et+(1-nt-H)/W);nt=At}return[nt*ut[0]+H*_t[0]+ot[0],nt*ut[1]+H*_t[1]+ot[1]]}function B(S,P,F,L){const tt=S.geometry.coordinates,G=F.geometry.coordinates,et=Math.atan2(tt[0]-G[0],tt[1]-G[1]),ot=w(et,P[0]);if(ot===void 0)throw new Error("Unable to determine vertex index");const it=P[1][ot];return _(S,it.features[0],L)}function N(S,P,F,L,tt,G,et,ot){let it;if(et&&(it=M(S,A([et]))),!it){if(F){const at=S.geometry.coordinates,ht=F.gridNum,J=F.xOrigin,Z=F.yOrigin,ut=F.xUnit,_t=F.yUnit,nt=F.gridCache,H=R(at[0],J,ut,ht),W=R(at[1],Z,_t,ht),wt=nt[H]?nt[H][W]?nt[H][W]:[]:[];P=A(wt.map(Et=>P.features[Et]))}it=M(S,P)}return ot&&ot(it),it?_(S,it,G):B(S,L,tt,G)}function R(S,P,F,L){let tt=Math.floor((S-P)/F);return tt>=L&&(tt=L-1),tt}function w(S,P){let F=O(S-P[0]),L=Math.PI*2,tt;for(let G=0;G<P.length;G++){const et=(G+1)%P.length,ot=O(S-P[et]),it=Math.min(Math.abs(F),Math.abs(ot));F*ot<=0&&it<L&&(L=it,tt=G),F=ot}return tt}function O(S,P=!1){const F=P?function(L){return!(L>=0&&L<Math.PI*2)}:function(L){return!(L>-1*Math.PI&&L<=Math.PI)};for(;F(S);)S=S+2*Math.PI*(S>0?-1:1);return S}function $(S,P){return P&&P>=2.00703||Array.isArray(S[0])?S:S.map(F=>[F.illstNodes,F.mercNodes,F.startEnd])}function j(S){const P=S.features;for(let F=0;F<P.length;F++){const L=P[F];`${L.properties.a.index}`.substring(0,1)==="b"&&`${L.properties.b.index}`.substring(0,1)==="b"?P[F]={geometry:{type:"Polygon",coordinates:[[L.geometry.coordinates[0][2],L.geometry.coordinates[0][0],L.geometry.coordinates[0][1],L.geometry.coordinates[0][2]]]},properties:{a:{geom:L.properties.c.geom,index:L.properties.c.index},b:{geom:L.properties.a.geom,index:L.properties.a.index},c:{geom:L.properties.b.geom,index:L.properties.b.index}},type:"Feature"}:`${L.properties.c.index}`.substring(0,1)==="b"&&`${L.properties.a.index}`.substring(0,1)==="b"&&(P[F]={geometry:{type:"Polygon",coordinates:[[L.geometry.coordinates[0][1],L.geometry.coordinates[0][2],L.geometry.coordinates[0][0],L.geometry.coordinates[0][1]]]},properties:{a:{geom:L.properties.b.geom,index:L.properties.b.index},b:{geom:L.properties.c.geom,index:L.properties.c.index},c:{geom:L.properties.a.geom,index:L.properties.a.index}},type:"Feature"})}return S}function V(S){const P=["a","b","c","a"].map(G=>S.properties[G].geom),F=S.geometry.coordinates[0],L=S.properties,tt={a:{geom:F[0],index:L.a.index},b:{geom:F[1],index:L.b.index},c:{geom:F[2],index:L.c.index}};return x([P],tt)}function z(S){const P=[0,1,2,0].map(L=>S[L][0][0]),F={a:{geom:S[0][0][1],index:S[0][1]},b:{geom:S[1][0][1],index:S[1][1]},c:{geom:S[2][0][1],index:S[2][1]}};return x([P],F)}function K(S,P,F,L,tt,G=!1,et){const ot=S.map(it=>{(!et||et<2.00703)&&(it=U(it));const at=isFinite(it)?P[it]:it==="c"?L:it==="b0"?tt[0]:it==="b1"?tt[1]:it==="b2"?tt[2]:it==="b3"?tt[3]:(function(){const ht=it.match(/e(\d+)/);if(ht){const J=parseInt(ht[1]);return F[J]}throw"Bad index value for indexesToTri"})();return G?[[at[1],at[0]],it]:[[at[0],at[1]],it]});return z(ot)}function U(S){return typeof S=="number"?S:S.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}const ct=2.00703;function ft(S){return!!(S.version||!S.tins&&S.points&&S.tins_points)}function dt(S){return{points:S.points,pointsWeightBuffer:gt(S),strictStatus:mt(S),verticesParams:Pt(S),centroid:xt(S),edges:$(S.edges||[]),edgeNodes:S.edgeNodes||[],tins:Mt(S),kinks:ee(S.kinks_points),yaxisMode:S.yaxisMode??"invert",strictMode:S.strictMode??"auto",vertexMode:S.vertexMode,bounds:S.bounds,boundsPolygon:S.boundsPolygon,wh:S.wh,xy:S.bounds?S.xy:[0,0]}}function pt(S){const P=pe(S),F=P.tins;return{compiled:P,tins:F,points:fn(F),strictStatus:P.strict_status,pointsWeightBuffer:P.weight_buffer,verticesParams:P.vertices_params,centroid:P.centroid,kinks:P.kinks}}function gt(S){return!S.version||S.version<ct?["forw","bakw"].reduce((P,F)=>{const L=S.weight_buffer[F];return L&&(P[F]=Object.keys(L).reduce((tt,G)=>{const et=U(G);return tt[et]=L[G],tt},{})),P},{}):S.weight_buffer}function mt(S){return S.strict_status?S.strict_status:S.kinks_points?"strict_error":S.tins_points.length===2?"loose":"strict"}function Pt(S){const P={forw:[S.vertices_params[0]],bakw:[S.vertices_params[1]]};return P.forw[1]=Nt(S,!1),P.bakw[1]=Nt(S,!0),P}function Nt(S,P){return[0,1,2,3].map(F=>{const L=(F+1)%4,tt=K(["c",`b${F}`,`b${L}`],S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,P,ct);return A([tt])})}function xt(S){return{forw:g(S.centroid_point[0],{target:{geom:S.centroid_point[1],index:"c"}}),bakw:g(S.centroid_point[1],{target:{geom:S.centroid_point[0],index:"c"}})}}function Mt(S){const P=S.tins_points.length===1?0:1;return{forw:A(S.tins_points[0].map(F=>K(F,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!1,S.version))),bakw:A(S.tins_points[P].map(F=>K(F,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!0,S.version)))}}function ee(S){if(S)return{bakw:A(S.map(P=>g(P)))}}function pe(S){return JSON.parse(JSON.stringify(S).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function fn(S){const P=[],F=S.forw.features;for(let L=0;L<F.length;L++){const tt=F[L];["a","b","c"].map((G,et)=>{const ot=tt.geometry.coordinates[0][et],it=tt.properties[G].geom,at=tt.properties[G].index;typeof at=="number"&&(P[at]=[ot,it])})}return P}const hn=ct;class jt{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=jt.YAXIS_INVERT;strictMode=jt.MODE_AUTO;vertexMode=jt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;constructor(){}setCompiled(P){if(ft(P)){this.applyModernState(dt(P));return}this.applyLegacyState(pt(P))}applyModernState(P){this.points=P.points,this.pointsWeightBuffer=P.pointsWeightBuffer,this.strict_status=P.strictStatus,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.edges=P.edges,this.edgeNodes=P.edgeNodes||[],this.tins=P.tins,this.addIndexedTin(),this.kinks=P.kinks,this.yaxisMode=P.yaxisMode??jt.YAXIS_INVERT,this.vertexMode=P.vertexMode??jt.VERTEX_PLAIN,this.strictMode=P.strictMode??jt.MODE_AUTO,P.bounds?(this.bounds=P.bounds,this.boundsPolygon=P.boundsPolygon,this.xy=P.xy,this.wh=P.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=P.xy??[0,0],P.wh&&(this.wh=P.wh))}applyLegacyState(P){this.tins=P.tins,this.addIndexedTin(),this.strict_status=P.strictStatus,this.pointsWeightBuffer=P.pointsWeightBuffer,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.kinks=P.kinks,this.points=P.points}addIndexedTin(){const P=this.tins,F=P.forw,L=P.bakw,tt=Math.ceil(Math.sqrt(F.features.length));if(tt<3){this.indexedTins=void 0;return}let G=[],et=[];const ot=F.features.map(nt=>{let H=[];return T(nt)[0].map(W=>{G.length===0?G=[Array.from(W),Array.from(W)]:(W[0]<G[0][0]&&(G[0][0]=W[0]),W[0]>G[1][0]&&(G[1][0]=W[0]),W[1]<G[0][1]&&(G[0][1]=W[1]),W[1]>G[1][1]&&(G[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),it=(G[1][0]-G[0][0])/tt,at=(G[1][1]-G[0][1])/tt,ht=ot.reduce((nt,H,W)=>{const wt=R(H[0][0],G[0][0],it,tt),Et=R(H[1][0],G[0][0],it,tt),At=R(H[0][1],G[0][1],at,tt),Xt=R(H[1][1],G[0][1],at,tt);for(let vt=wt;vt<=Et;vt++){nt[vt]||(nt[vt]=[]);for(let Tt=At;Tt<=Xt;Tt++)nt[vt][Tt]||(nt[vt][Tt]=[]),nt[vt][Tt].push(W)}return nt},[]),J=L.features.map(nt=>{let H=[];return T(nt)[0].map(W=>{et.length===0?et=[Array.from(W),Array.from(W)]:(W[0]<et[0][0]&&(et[0][0]=W[0]),W[0]>et[1][0]&&(et[1][0]=W[0]),W[1]<et[0][1]&&(et[0][1]=W[1]),W[1]>et[1][1]&&(et[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),Z=(et[1][0]-et[0][0])/tt,ut=(et[1][1]-et[0][1])/tt,_t=J.reduce((nt,H,W)=>{const wt=R(H[0][0],et[0][0],Z,tt),Et=R(H[1][0],et[0][0],Z,tt),At=R(H[0][1],et[0][1],ut,tt),Xt=R(H[1][1],et[0][1],ut,tt);for(let vt=wt;vt<=Et;vt++){nt[vt]||(nt[vt]=[]);for(let Tt=At;Tt<=Xt;Tt++)nt[vt][Tt]||(nt[vt][Tt]=[]),nt[vt][Tt].push(W)}return nt},[]);this.indexedTins={forw:{gridNum:tt,xOrigin:G[0][0],yOrigin:G[0][1],xUnit:it,yUnit:at,gridCache:ht},bakw:{gridNum:tt,xOrigin:et[0][0],yOrigin:et[0][1],xUnit:Z,yUnit:ut,gridCache:_t}}}transform(P,F,L){if(F&&this.strict_status==jt.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==jt.YAXIS_FOLLOW&&F&&(P=[P[0],-1*P[1]]);const tt=g(P);if(this.bounds&&!F&&!L&&!d(tt,this.boundsPolygon))return!1;const G=F?this.tins.bakw:this.tins.forw,et=F?this.indexedTins.bakw:this.indexedTins.forw,ot=F?this.vertices_params.bakw:this.vertices_params.forw,it=F?this.centroid.bakw:this.centroid.forw,at=F?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let ht,J;this.stateFull&&(this.stateBackward==F?ht=this.stateTriangle:(this.stateBackward=F,this.stateTriangle=void 0),J=ut=>{this.stateTriangle=ut});let Z=N(tt,G,et,ot,it,at,ht,J);if(this.bounds&&F&&!L){const ut=g(Z);if(!d(ut,this.boundsPolygon))return!1}else this.yaxisMode==jt.YAXIS_FOLLOW&&!F&&(Z=[Z[0],-1*Z[1]]);return Z}}e.Transform=jt,e.counterTri=V,e.format_version=hn,e.normalizeEdges=$,e.rotateVerticesTriangle=j,e.transformArr=N,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})})})(ke,ke.exports)),ke.exports}var zt=Ar();const En=Math.pow(2,-52),Ye=new Uint32Array(512);class en{static from(t,e=Tr,n=Nr){const r=t.length,i=new Float64Array(r*2);for(let o=0;o<r;o++){const a=t[o];i[2*o]=e(a),i[2*o+1]=n(a)}return new en(i)}constructor(t){const e=t.length>>1;if(e>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const n=Math.max(2*e-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:n,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let a=1/0,c=1/0,f=-1/0,u=-1/0;for(let b=0;b<o;b++){const T=t[2*b],Y=t[2*b+1];T<a&&(a=T),Y<c&&(c=Y),T>f&&(f=T),Y>u&&(u=Y),this._ids[b]=b}const h=(a+f)/2,p=(c+u)/2;let y,E,k;for(let b=0,T=1/0;b<o;b++){const Y=nn(h,p,t[2*b],t[2*b+1]);Y<T&&(y=b,T=Y)}const X=t[2*y],C=t[2*y+1];for(let b=0,T=1/0;b<o;b++){if(b===y)continue;const Y=nn(X,C,t[2*b],t[2*b+1]);Y<T&&Y>0&&(E=b,T=Y)}let m=t[2*E],v=t[2*E+1],l=1/0;for(let b=0;b<o;b++){if(b===y||b===E)continue;const T=Or(X,C,m,v,t[2*b],t[2*b+1]);T<l&&(k=b,l=T)}let g=t[2*k],x=t[2*k+1];if(l===1/0){for(let Y=0;Y<o;Y++)this._dists[Y]=t[2*Y]-t[0]||t[2*Y+1]-t[1];ye(this._ids,this._dists,0,o-1);const b=new Uint32Array(o);let T=0;for(let Y=0,D=-1/0;Y<o;Y++){const Q=this._ids[Y],d=this._dists[Q];d>D&&(b[T++]=Q,D=d)}this.hull=b.subarray(0,T),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Qt(X,C,m,v,g,x)<0){const b=E,T=m,Y=v;E=k,m=g,v=x,k=b,g=T,x=Y}const A=Ir(X,C,m,v,g,x);this._cx=A.x,this._cy=A.y;for(let b=0;b<o;b++)this._dists[b]=nn(t[2*b],t[2*b+1],A.x,A.y);ye(this._ids,this._dists,0,o-1),this._hullStart=y;let I=3;n[y]=e[k]=E,n[E]=e[y]=k,n[k]=e[E]=y,r[y]=0,r[E]=1,r[k]=2,i.fill(-1),i[this._hashKey(X,C)]=y,i[this._hashKey(m,v)]=E,i[this._hashKey(g,x)]=k,this.trianglesLen=0,this._addTriangle(y,E,k,-1,-1,-1);for(let b=0,T,Y;b<this._ids.length;b++){const D=this._ids[b],Q=t[2*D],d=t[2*D+1];if(b>0&&Math.abs(Q-T)<=En&&Math.abs(d-Y)<=En||(T=Q,Y=d,D===y||D===E||D===k))continue;let M=0;for(let w=0,O=this._hashKey(Q,d);w<this._hashSize&&(M=i[(O+w)%this._hashSize],!(M!==-1&&M!==n[M]));w++);M=e[M];let _=M,B;for(;B=n[_],Qt(Q,d,t[2*_],t[2*_+1],t[2*B],t[2*B+1])>=0;)if(_=B,_===M){_=-1;break}if(_===-1)continue;let N=this._addTriangle(_,D,n[_],-1,-1,r[_]);r[D]=this._legalize(N+2),r[_]=N,I++;let R=n[_];for(;B=n[R],Qt(Q,d,t[2*R],t[2*R+1],t[2*B],t[2*B+1])<0;)N=this._addTriangle(R,D,B,r[D],-1,r[R]),r[D]=this._legalize(N+2),n[R]=R,I--,R=B;if(_===M)for(;B=e[_],Qt(Q,d,t[2*B],t[2*B+1],t[2*_],t[2*_+1])<0;)N=this._addTriangle(B,D,_,-1,r[_],r[B]),this._legalize(N+2),r[B]=N,n[_]=_,I--,_=B;this._hullStart=e[D]=_,n[_]=e[R]=D,n[D]=R,i[this._hashKey(Q,d)]=D,i[this._hashKey(t[2*_],t[2*_+1])]=_}this.hull=new Uint32Array(I);for(let b=0,T=this._hullStart;b<I;b++)this.hull[b]=T,T=n[T];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(Pr(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:n,coords:r}=this;let i=0,o=0;for(;;){const a=n[t],c=t-t%3;if(o=c+(t+2)%3,a===-1){if(i===0)break;t=Ye[--i];continue}const f=a-a%3,u=c+(t+1)%3,h=f+(a+2)%3,p=e[o],y=e[t],E=e[u],k=e[h];if(Br(r[2*p],r[2*p+1],r[2*y],r[2*y+1],r[2*E],r[2*E+1],r[2*k],r[2*k+1])){e[t]=k,e[a]=p;const C=n[h];if(C===-1){let v=this._hullStart;do{if(this._hullTri[v]===h){this._hullTri[v]=t;break}v=this._hullPrev[v]}while(v!==this._hullStart)}this._link(t,C),this._link(a,n[o]),this._link(o,h);const m=f+(a+1)%3;i<Ye.length&&(Ye[i++]=m)}else{if(i===0)break;t=Ye[--i]}}return o}_link(t,e){this._halfedges[t]=e,e!==-1&&(this._halfedges[e]=t)}_addTriangle(t,e,n,r,i,o){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=e,this._triangles[a+2]=n,this._link(a,r),this._link(a+1,i),this._link(a+2,o),this.trianglesLen+=3,a}}function Pr(s,t){const e=s/(Math.abs(s)+Math.abs(t));return(t>0?3-e:1+e)/4}function nn(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function Br(s,t,e,n,r,i,o,a){const c=s-o,f=t-a,u=e-o,h=n-a,p=r-o,y=i-a,E=c*c+f*f,k=u*u+h*h,X=p*p+y*y;return c*(h*X-k*y)-f*(u*X-k*p)+E*(u*y-h*p)<0}function Or(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),y=(f*u-a*h)*p,E=(o*h-c*u)*p;return y*y+E*E}function Ir(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),y=s+(f*u-a*h)*p,E=t+(o*h-c*u)*p;return{x:y,y:E}}function ye(s,t,e,n){if(n-e<=20)for(let r=e+1;r<=n;r++){const i=s[r],o=t[i];let a=r-1;for(;a>=e&&t[s[a]]>o;)s[a+1]=s[a--];s[a+1]=i}else{const r=e+n>>1;let i=e+1,o=n;Se(s,r,i),t[s[e]]>t[s[n]]&&Se(s,e,n),t[s[i]]>t[s[n]]&&Se(s,i,n),t[s[e]]>t[s[i]]&&Se(s,e,i);const a=s[i],c=t[a];for(;;){do i++;while(t[s[i]]<c);do o--;while(t[s[o]]>c);if(o<i)break;Se(s,i,o)}s[e+1]=s[o],s[o]=a,n-i+1>=o-e?(ye(s,t,i,n),ye(s,t,e,o-1)):(ye(s,t,e,o-1),ye(s,t,i,n))}}function Se(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Tr(s){return s[0]}function Nr(s){return s[1]}class Xr{bs;width;constructor(t,e){this.width=t,this.bs=e}add(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]|=1<<n,this}delete(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]&=~(1<<n),this}set(t,e){const n=Math.floor(t/this.width),i=1<<t%this.width;return this.bs[n]^=(-Number(e)^this.bs[n])&i,e}has(t){const e=Math.floor(t/this.width),n=t%this.width;return(this.bs[e]&1<<n)!==0}forEach(t){const e=this.bs.length;for(let n=0;n<e;n++){let r=0;for(;this.bs[n]&&r<this.width;)this.bs[n]&1<<r&&t(n*this.width+r),r++}return this}}class An extends Xr{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function de(s){return s%3===2?s-2:s+1}function ne(s){return s%3===0?s+2:s-1}function Pn(s,t,e,n,r,i,o,a){const c=Qt(s,t,r,i,o,a),f=Qt(e,n,r,i,o,a);if(c>0&&f>0||c<0&&f<0)return!1;const u=Qt(r,i,s,t,e,n),h=Qt(o,a,s,t,e,n);return u>0&&h>0||u<0&&h<0?!1:c===0&&f===0&&u===0&&h===0?!(Math.max(r,o)<Math.min(s,e)||Math.max(s,e)<Math.min(r,o)||Math.max(i,a)<Math.min(t,n)||Math.max(t,n)<Math.min(i,a)):!0}class Rr{del;constructor(t){this.del=t}}class Yr extends Rr{vertMap;flips;consd;constructor(t,e){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);const n=2**32-1,r=t.coords.length>>1,i=t.triangles.length;this.vertMap=new Uint32Array(r).fill(n),this.flips=new An(i),this.consd=new An(i);for(let o=0;o<i;o++){const a=t.triangles[o];this.vertMap[a]===n&&this.updateVert(o)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:n,halfedges:r}=this.del,i=this.vertMap[t];let o=i;do{const f=n[o],u=de(o);if(f===e)return this.protect(o);const h=ne(o),p=n[h];if(p===e)return this.protect(u),u;if(this.intersectSegments(t,e,p,f)){o=h;break}o=r[u]}while(o!==-1&&o!==i);let a=o,c=-1;for(;o!==-1;){const f=r[o],u=ne(o),h=ne(f),p=de(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(o))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,e,n[o])||this.isCollinear(t,e,n[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(n[o],n[f],n[u],n[h])){if(c===-1&&(c=o),n[h]===e){if(o===c)throw new Error("Infinite loop: non-convex quadrilateral");o=c,c=-1;continue}if(this.intersectSegments(t,e,n[h],n[f]))o=h;else if(this.intersectSegments(t,e,n[p],n[h]))o=p;else if(c===o)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(o),this.intersectSegments(t,e,n[u],n[h])&&(c===-1&&(c=u),c===u))throw new Error("Infinite loop: flipped diagonal still intersects");n[h]===e?(a=h,o=c,c=-1):this.intersectSegments(t,e,n[p],n[h])&&(o=p)}return this.protect(a),this.delaunify(!0),this.findEdge(t,e)}delaunify(t=!1){const{halfedges:e}=this.del,n=this.flips,r=this.consd,i=e.length;let o;do{o=0;for(let a=0;a<i;a++){if(r.has(a))continue;n.delete(a);const c=e[a];c!==-1&&(n.delete(c),this.isDelaunay(a)||(this.flipDiagonal(a),o++))}}while(t&&o>0);return this}constrainAll(t){const e=t.length;for(let n=0;n<e;n++){const r=t[n];this.constrainOne(r[0],r[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const n=this.vertMap[e],{triangles:r,halfedges:i}=this.del;let o=n,a=-1;do{if(r[o]===t)return o;a=de(o),o=i[a]}while(o!==-1&&o!==n);return r[de(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],n=this.flips,r=this.consd;return n.delete(t),r.add(t),e!==-1?(n.delete(e),r.add(e),e):-t}markFlip(t){const e=this.del.halfedges,n=this.flips;if(this.consd.has(t))return!1;const i=e[t];return i!==-1&&(n.add(t),n.add(i)),!0}flipDiagonal(t){const{triangles:e,halfedges:n}=this.del,r=this.flips,i=this.consd,o=n[t],a=ne(t),c=de(t),f=ne(o),u=de(o),h=n[a],p=n[f];if(i.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[f],n[t]=p,r.set(t,r.has(f))||i.set(t,i.has(f)),p!==-1&&(n[p]=t),n[a]=f,e[o]=e[a],n[o]=h,r.set(o,r.has(a))||i.set(o,i.has(a)),h!==-1&&(n[h]=o),n[f]=a,this.markFlip(t),this.markFlip(c),this.markFlip(o),this.markFlip(u),r.add(a),i.delete(a),r.add(f),i.delete(f),this.updateVert(t),this.updateVert(c),this.updateVert(o),this.updateVert(u),a}isCollinear(t,e,n){const r=this.del.coords;return Qt(r[t*2],r[t*2+1],r[e*2],r[e*2+1],r[n*2],r[n*2+1])===0}inCircle(t,e,n,r){const i=this.del.coords;return er(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:n}=this.del,r=n[t];if(r===-1)return!0;const i=e[ne(t)],o=e[t],a=e[de(t)],c=e[ne(r)];return!this.inCircle(i,o,a,c)}updateVert(t){const{triangles:e,halfedges:n}=this.del,r=this.vertMap,i=e[t];let o=ne(t),a=n[o];for(;a!==-1&&a!==t;)o=ne(a),a=n[o];return r[i]=o,o}intersectSegments(t,e,n,r){const i=this.del.coords;return t===n||t===r||e===n||e===r?!1:Pn(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])}static intersectSegments=Pn}function Ee(s,t,e){if(t||(t=[]),typeof s!="object"||s.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const n=s.features.map(c=>c.geometry.coordinates),r=en.from(n);let i;const o=[];r.triangles.length!==0&&t.length!==0&&(i=new Yr(r),i.constrainAll(t));for(let c=0;c<r.triangles.length;c+=3)o.push([r.triangles[c],r.triangles[c+1],r.triangles[c+2]]);const a=["a","b","c"];return Vt(o.map(c=>{const f={},u=c.map((h,p)=>{const y=s.features[h],E=y.geometry.coordinates,k=[E[0],E[1]];return E.length===3?k[2]=E[2]:f[a[p]]=y.properties[e],k});return u[3]=u[0],_e([u],f)}))}class Bn{constructor(t=[],e=Cr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}}function Cr(s,t){return s<t?-1:s>t?1:0}function On(s,t){return s.p.x>t.p.x?1:s.p.x<t.p.x?-1:s.p.y!==t.p.y?s.p.y>t.p.y?1:-1:1}function Fr(s,t){return s.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:s.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:s.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?s.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class In{constructor(t,e,n,r){this.p={x:t[0],y:t[1]},this.featureId=e,this.ringId=n,this.eventId=r,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(t){return this.p.x===t.p.x&&this.p.y===t.p.y}}function Lr(s,t){if(s.type==="FeatureCollection"){const e=s.features;for(let n=0;n<e.length;n++)Tn(e[n],t)}else Tn(s,t)}let Ce=0,Fe=0,Le=0;function Tn(s,t){const e=s.type==="Feature"?s.geometry:s;let n=e.coordinates;(e.type==="Polygon"||e.type==="MultiLineString")&&(n=[n]),e.type==="LineString"&&(n=[[n]]);for(let r=0;r<n.length;r++)for(let i=0;i<n[r].length;i++){let o=n[r][i][0],a=null;Fe=Fe+1;for(let c=0;c<n[r][i].length-1;c++){a=n[r][i][c+1];const f=new In(o,Ce,Fe,Le),u=new In(a,Ce,Fe,Le+1);f.otherEvent=u,u.otherEvent=f,On(f,u)>0?(u.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(f),t.push(u),o=a,Le=Le+1}}Ce=Ce+1}class Dr{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}}function $r(s,t){if(s===null||t===null||s.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.rightSweepEvent)||s.leftSweepEvent.isSamePoint(t.leftSweepEvent)||s.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const e=s.leftSweepEvent.p.x,n=s.leftSweepEvent.p.y,r=s.rightSweepEvent.p.x,i=s.rightSweepEvent.p.y,o=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,c=t.rightSweepEvent.p.x,f=t.rightSweepEvent.p.y,u=(f-a)*(r-e)-(c-o)*(i-n),h=(c-o)*(n-a)-(f-a)*(e-o),p=(r-e)*(n-a)-(i-n)*(e-o);if(u===0)return!1;const y=h/u,E=p/u;if(y>=0&&y<=1&&E>=0&&E<=1){const k=e+y*(r-e),X=n+y*(i-n);return[k,X]}return!1}function qr(s,t){t=t||!1;const e=[],n=new Bn([],Fr);for(;s.length;){const r=s.pop();if(r.isLeftEndpoint){const i=new Dr(r);for(let o=0;o<n.data.length;o++){const a=n.data[o];if(t&&a.leftSweepEvent.featureId===r.featureId)continue;const c=$r(i,a);c!==!1&&e.push(c)}n.push(i)}else r.isLeftEndpoint===!1&&n.pop()}return e}function jr(s,t){const e=new Bn([],On);return Lr(s,e),qr(e,t)}var Ur=jr;function zr(s,t,e={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:r=!0}=e;let i=[];s.type==="FeatureCollection"?i=i.concat(s.features):s.type==="Feature"?i.push(s):(s.type==="LineString"||s.type==="Polygon"||s.type==="MultiLineString"||s.type==="MultiPolygon")&&i.push(be(s)),t.type==="FeatureCollection"?i=i.concat(t.features):t.type==="Feature"?i.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&i.push(be(t));const o=Ur(Vt(i),r);let a=[];if(n){const c={};o.forEach(f=>{const u=f.join(",");c[u]||(c[u]=!0,a.push(f))})}else a=o;return Vt(a.map(c=>le(c)))}var Vr=zr;function Nn(s,t,e,n,r,i){return Object.keys(s).reduce((o,a)=>{const c=s[a],f=c.forw,u=c.bakw,h={forw:[f[0]-t.forw[0],f[1]-t.forw[1]],bakw:[u[0]-t.bakw[0],u[1]-t.bakw[1]]},p=h.forw[0]===0?1/0:((h.forw[0]<0?e:n)-t.forw[0])/h.forw[0],y=h.forw[1]===0?1/0:((h.forw[1]<0?r:i)-t.forw[1])/h.forw[1];if(Math.abs(p)/Math.abs(y)<1.1){const E={forw:[h.forw[0]*p+t.forw[0],h.forw[1]*p+t.forw[1]],bakw:[h.bakw[0]*p+t.bakw[0],h.bakw[1]*p+t.bakw[1]]};h.forw[0]<0?o[3].push(E):o[1].push(E)}if(Math.abs(y)/Math.abs(p)<1.1){const E={forw:[h.forw[0]*y+t.forw[0],h.forw[1]*y+t.forw[1]],bakw:[h.bakw[0]*y+t.bakw[0],h.bakw[1]*y+t.bakw[1]]};h.forw[1]<0?o[0].push(E):o[2].push(E)}return o},[[],[],[],[]])}function Wr(s,t){const e=[[],[],[],[]],n=[];return Object.keys(s).forEach(r=>{const i=s[r],o=i.forw,a=i.bakw,c=[o[0]-t.forw[0],o[1]-t.forw[1]],f=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:c,bakw:f};if(n.push(u),c[0]===0||c[1]===0)return;let h=0;c[0]>0&&(h+=1),c[1]>0&&(h+=2),e[h].push(u)}),{perQuad:e,aggregate:n}}function Jr(s){let t=1/0,e=0,n=0;return s.forEach(r=>{const{forw:i,bakw:o}=r,a=Math.hypot(i[0],i[1]),c=Math.hypot(o[0],o[1]);if(c===0)return;const f=a/c,u=Math.atan2(i[0],i[1])-Math.atan2(o[0],o[1]);t=Math.min(t,f),e+=Math.cos(u),n+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(n,e)]:[1,0]}function Xn(s,t,e){const{perQuad:n,aggregate:r}=Wr(s,t),i=n.every(c=>c.length>0),a=(e==="birdeye"?i?n:[r]:[r]).map(c=>Jr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Kr(s,t,e){const n=[1,1,1,1];for(let r=0;r<4;r++){const i=(r+1)%4,o=gn([s[r].bakw,s[i].bakw]);t[r].map(a=>{const c=gn([e.bakw,a.bakw]),f=Vr(o,c);if(f.features.length>0&&f.features[0].geometry){const u=f.features[0],h=Math.sqrt(Math.pow(a.bakw[0]-e.bakw[0],2)+Math.pow(a.bakw[1]-e.bakw[1],2)),p=Math.sqrt(Math.pow(u.geometry.coordinates[0]-e.bakw[0],2)+Math.pow(u.geometry.coordinates[1]-e.bakw[1],2)),y=h/p;y>n[r]&&(n[r]=y),y>n[i]&&(n[i]=y)}})}s.forEach((r,i)=>{const o=n[i],a=[(r.bakw[0]-e.bakw[0])*o+e.bakw[0],(r.bakw[1]-e.bakw[1])*o+e.bakw[1]];r.bakw=a})}function Rn(s,t,e,n){const r=s.map((o,a)=>{const c=t[a],f=[c[0]-e.forw[0],c[1]-e.forw[1]],h=Math.sqrt(Math.pow(f[0],2)+Math.pow(f[1],2))/o[0],p=Math.atan2(f[0],f[1])-o[1],y=[e.bakw[0]+h*Math.sin(p),e.bakw[1]-h*Math.cos(p)];return{forw:c,bakw:y}}),i=r[2];return r[2]=r[3],r[3]=i,Kr(r,n,e),r}function Gr(s){const{convexBuf:t,centroid:e,bbox:n,minx:r,maxx:i,miny:o,maxy:a}=s,c=Nn(t,e,r,i,o,a),f=Xn(t,e,"plain");return Rn(f,n,e,c)}function Qr(s){const{convexBuf:t,centroid:e,bbox:n,minx:r,maxx:i,miny:o,maxy:a}=s,c=Nn(t,e,r,i,o,a),f=Xn(t,e,"birdeye");return Rn(f,n,e,c)}function Yn(s){const e=new Hr(s).findSegmentIntersections(),n=qn(e),r=new Map;return n.forEach(i=>{r.set(`${i.x}:${i.y}`,i)}),Array.from(r.values()).map(i=>le([i.x,i.y]))}class Hr{_xx;_yy;_ii;_nn;_zz;_zlimit=0;_bb;_allBounds;_arcIter;_filteredArcIter;buf;constructor(t){this.initArcs(t)}initArcs(t){const e=[],n=[],r=t.map(i=>{const o=i?i.length:0;for(let a=0;a<o;a++)e.push(i[a][0]),n.push(i[a][1]);return o});this.initXYData(r,e,n)}initXYData(t,e,n){const r=t.length;this._xx=new Float64Array(e),this._yy=new Float64Array(n),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(r);let i=0;for(let o=0;o<r;o++)this._ii[o]=i,i+=t[o];(i!=this._xx.length||this._xx.length!=this._yy.length)&&rn("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new yi(this._xx,this._yy)}initBounds(){const t=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=t.bb,this._allBounds=t.bounds}calcArcBounds_(t,e,n){const r=n.length,i=new Float64Array(r*4),o=new qe;let a=0,c,f,u;for(let h=0;h<r;h++)c=n[h],c>0&&(f=h*4,u=vi(t,e,a,c),i[f++]=u[0],i[f++]=u[1],i[f++]=u[2],i[f]=u[3],a+=c,o.mergeBounds(u));return{bb:i,bounds:o}}getBounds(){return this._allBounds.clone()}forEachSegment(t){let e=0;for(let n=0,r=this.size();n<r;n++)e+=this.forEachArcSegment(n,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const n=t>=0,r=n?t:~t,i=this.getRetainedInterval(),o=this._nn[r],a=n?1:-1;let c=n?this._ii[r]:this._ii[r]+o-1,f=c,u=0;for(let h=1;h<o;h++)f+=a,(i===0||this._zz[f]>=i)&&(e(c,f,this._xx,this._yy),c=f,u++);return u}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(t){const e=t*4;return(!this.buf||this.buf.byteLength<e)&&(this.buf=new ArrayBuffer(e)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,e=0;const n=this.forEachSegment((r,i,o,a)=>{t+=Math.abs(o[r]-o[i]),e+=Math.abs(a[r]-a[i])});return[t/n||0,e/n||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),e=this.getAvgSegment2()[1];let n=1;return e>0&&t>0&&(n=Math.ceil(t/e/20)),n||1}findSegmentIntersections(){const t=this.getBounds(),e=t.ymin,n=t.ymax-e,r=this.calcSegmentIntersectionStripeCount(),i=new Uint32Array(r),o=r>1?k=>Math.floor((r-1)*(k-e)/n):()=>0;let a,c;this.forEachSegment((k,X,C,m)=>{let v=o(m[k]);const l=o(m[X]);for(;i[v]=i[v]+2,v!=l;)v+=l>v?1:-1});const f=this.getUint32Array(ei(i));let u=0;const h=[];ni(i,k=>{const X=u;u+=k,h.push(f.subarray(X,u))}),ri(i,0),this.forEachSegment((k,X,C,m)=>{let v=o(m[k]);const l=o(m[X]);let g,x;for(;g=i[v],i[v]=g+2,x=h[v],x[g]=k,x[g+1]=X,v!=l;)v+=l>v?1:-1});const p=this.getVertexData(),y=[];let E;for(a=0;a<r;a++)for(E=ii(h[a],p.xx,p.yy),c=0;c<E.length;c++)y.push(E[c]);return qn(y)}}function rn(...s){const t=s.join(" ");throw new Error(t)}function on(s){return s?ti(s)?!0:Zr(s)?!1:s.length===0?!0:s.length>0:!1}function Zr(s){return s!=null&&s.toString===String.prototype.toString}function ti(s){return Array.isArray(s)}function ei(s,t){on(s)||rn("utils.sum() expects an array, received:",s);let e=0,n;for(let r=0,i=s.length;r<i;r++)n=s[r],n&&(e+=n);return e}function ni(s,t,e){if(!on(s))throw new Error(`#forEach() takes an array-like argument. ${s}`);for(let n=0,r=s.length;n<r;n++)t.call(e,s[n],n)}function ri(s,t){for(let e=0,n=s.length;e<n;e++)s[e]=t;return s}function ii(s,t,e){const n=s.length-2,r=[];let i,o,a,c,f,u,h,p,y,E,k,X,C,m,v,l,g;for(pi(t,s),l=0;l<n;){for(i=s[l],o=s[l+1],f=t[i],u=t[o],y=e[i],E=e[o],g=l;g<n&&(g+=2,a=s[g],h=t[a],!(u<h));){if(k=e[a],c=s[g+1],p=t[c],X=e[c],y>=k){if(y>X&&E>k&&E>X)continue}else if(y<X&&E<k&&E<X)continue;i==a||i==c||o==a||o==c||(C=oi(f,y,u,E,h,k,p,X),C&&(m=[i,o],v=[a,c],r.push(Dn(C,m,v,t,e)),C.length==4&&r.push(Dn(C.slice(2),m,v,t,e))))}l+=2}return r}function oi(s,t,e,n,r,i,o,a){const c=si(s,t,e,n,r,i,o,a);let f=null;return c&&(f=ai(s,t,e,n,r,i,o,a),f?di(s,t,e,n,r,i,o,a)&&(f=null):f=li(s,t,e,n,r,i,o,a)),f}function si(s,t,e,n,r,i,o,a){return Ae(s,t,e,n,r,i)*Ae(s,t,e,n,o,a)<=0&&Ae(r,i,o,a,s,t)*Ae(r,i,o,a,e,n)<=0}function Ae(s,t,e,n,r,i){return Cn(s-r,t-i,e-r,n-i)}function Cn(s,t,e,n){return s*n-t*e}function ai(s,t,e,n,r,i,o,a){let c=De(s,t,e,n,r,i,o,a),f;return c&&(f=fi(c[0],c[1],s,t,e,n,r,i,o,a),f==1?c=De(e,n,s,t,r,i,o,a):f==2?c=De(r,i,o,a,s,t,e,n):f==3&&(c=De(o,a,r,i,s,t,e,n))),c&&ui(c,s,t,e,n,r,i,o,a),c}function De(s,t,e,n,r,i,o,a){const c=Cn(e-s,n-t,o-r,a-i),f=1e-18;let u;if(c===0)return null;const h=Ae(r,i,o,a,s,t)/c;return c<=f&&c>=-f?u=ci(s,t,e,n,r,i,o,a):u=[s+h*(e-s),t+h*(n-t)],u}function ci(s,t,e,n,r,i,o,a){let c=null;return!re(s,r,o)&&!re(t,i,a)?c=[s,t]:!re(e,r,o)&&!re(n,i,a)?c=[e,n]:!re(r,s,e)&&!re(i,t,n)?c=[r,i]:!re(o,s,e)&&!re(a,t,n)&&(c=[o,a]),c}function re(s,t,e){let n;return t<e?n=s<t||s>e:t>e?n=s>t||s<e:n=s!=t,n}function fi(s,t,...e){let n=-1,r=1/0,i;for(let o=0,a=0,c=e.length;a<c;o++,a+=2)i=hi(s,t,e[a],e[a+1]),i<r&&(r=i,n=o);return n}function hi(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function ui(s,t,e,n,r,i,o,a,c){let f=s[0],u=s[1];f=$e(f,t,n),f=$e(f,i,a),u=$e(u,e,r),u=$e(u,o,c),s[0]=f,s[1]=u}function $e(s,t,e){let n;return re(s,t,e)&&(n=Math.abs(s-t)<Math.abs(s-e)?t:e,s=n),s}function li(s,t,e,n,r,i,o,a){const c=Math.min(s,e,r,o),f=Math.max(s,e,r,o),u=Math.min(t,n,i,a),h=Math.max(t,n,i,a),p=h-u>f-c;let y=[];return(p?ce(t,u,h):ce(s,c,f))&&y.push(s,t),(p?ce(n,u,h):ce(e,c,f))&&y.push(e,n),(p?ce(i,u,h):ce(r,c,f))&&y.push(r,i),(p?ce(a,u,h):ce(o,c,f))&&y.push(o,a),(y.length!=2&&y.length!=4||y.length==4&&y[0]==y[2]&&y[1]==y[3])&&(y=null),y}function di(s,t,e,n,r,i,o,a){return s==r&&t==i||s==o&&t==a||e==r&&n==i||e==o&&n==a}function ce(s,t,e){return s>t&&s<e}function pi(s,t){mi(s,t),Fn(s,t,0,t.length-2)}function mi(s,t){for(let e=0,n=t.length;e<n;e+=2)s[t[e]]>s[t[e+1]]&&gi(t,e,e+1)}function gi(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Fn(s,t,e,n){let r=e,i=n,o,a;for(;r<n;){for(o=s[t[e+n>>2<<1]];r<=i;){for(;s[t[r]]<o;)r+=2;for(;s[t[i]]>o;)i-=2;r<=i&&(a=t[r],t[r]=t[i],t[i]=a,a=t[r+1],t[r+1]=t[i+1],t[i+1]=a,r+=2,i-=2)}if(i-e<40?Ln(s,t,e,i):Fn(s,t,e,i),n-r<40){Ln(s,t,r,n);return}e=r,i=n}}function Ln(s,t,e,n){let r,i;for(let o=e+2;o<=n;o+=2){r=t[o],i=t[o+1];let a;for(a=o-2;a>=e&&s[r]<s[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=r,t[a+3]=i}}function Dn(s,t,e,n,r){const i=s[0],o=s[1];t=$n(i,o,t[0],t[1],n,r),e=$n(i,o,e[0],e[1],n,r);const a=t[0]<e[0]?t:e,c=a==t?e:t;return{x:i,y:o,a,b:c}}function $n(s,t,e,n,r,i){let o=e<n?e:n,a=o===e?n:e;return r[o]==s&&i[o]==t?a=o:r[a]==s&&i[a]==t&&(o=a),[o,a]}function qn(s){const t={};return s.filter(e=>{const n=wi(e);return n in t?!1:(t[n]=!0,!0)})}function wi(s){return`${s.a.join(",")};${s.b.join(",")}`}class yi{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,e){this._xx=t,this._yy=e}}function vi(s,t,e,n){let r=e|0;const i=isNaN(n)?s.length-r:n+r;let o,a,c,f,u,h;if(i>0)c=u=s[r],f=h=t[r];else return[void 0,void 0,void 0,void 0];for(r++;r<i;r++)o=s[r],a=t[r],o<c&&(c=o),o>u&&(u=o),a<f&&(f=a),a>h&&(h=a);return[c,f,u,h]}class qe{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new qe(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,e,n,r){return arguments.length==1&&(on(t)?(e=t[1],n=t[2],r=t[3],t=t[0]):(e=t.ymin,n=t.xmax,r=t.ymax,t=t.xmin)),this.xmin=t,this.ymin=e,this.xmax=n,this.ymax=r,(t>n||e>r)&&this.update(),this}update(){let t;this.xmin>this.xmax&&(t=this.xmin,this.xmin=this.xmax,this.xmax=t),this.ymin>this.ymax&&(t=this.ymin,this.ymin=this.ymax,this.ymax=t)}mergeBounds(t,...e){let n,r,i,o;return t instanceof qe?(n=t.xmin,r=t.ymin,i=t.xmax,o=t.ymax):e.length==3?(n=t,r=e[0],i=e[1],o=e[2]):t.length==4?(n=t[0],r=t[1],i=t[2],o=t[3]):rn("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(n,r,i,o):(n<this.xmin&&(this.xmin=n),r<this.ymin&&(this.ymin=r),i>this.xmax&&(this.xmax=i),o>this.ymax&&(this.ymax=o)),this}}function je(s){const t=["a","b","c"].map(e=>s.properties[e].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(e=>e.map(n=>t[n]).sort().join("-")).sort()}function sn(s,t,e){const n=je(t.forw),r=je(t.bakw);if(JSON.stringify(n)!=JSON.stringify(r))throw`${JSON.stringify(t,null,2)}
|
|
2
|
-
${JSON.stringify(
|
|
3
|
-
${JSON.stringify(
|
|
4
|
-
${JSON.stringify(
|
|
5
|
-
${JSON.stringify(r)}`;if(n.forEach(i=>{const o=s[i];if(!o)return;const a=o.filter(c=>c!==t);a.length===0?delete s[i]:s[i]=a}),e){const i=(o,a)=>{!o||!a||(o.features=o.features.filter(c=>c!==a))};i(e.forw,t.forw),i(e.bakw,t.bakw)}}function Pe(s,t,e){return le(s,{target:{geom:t,index:e}})}function Be(s){return le(s.properties.target.geom,{target:{geom:s.geometry.coordinates,index:s.properties.target.index}})}function an(s,t){const e=t.geometry.coordinates;return[0,1,2,3].map(n=>{const r=(n+1)%4,i=s[n],o=s[r],a=i.geometry.coordinates,c=Math.atan2(a[0]-e[0],a[1]-e[1]),f=[t,i,o,t].map(p=>p.geometry.coordinates),u={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:i.properties.target.geom,index:i.properties.target.index},c:{geom:o.properties.target.geom,index:o.properties.target.index}},h=Vt([_e([f],u)]);return[c,h]}).reduce((n,r)=>(n[0].push(r[0]),n[1].push(r[1]),n),[[],[]])}function bi(s){const{tins:t,targets:e,includeReciprocals:n}=s,r={};e.forEach(o=>{const a=t[o];if(!a||!a.features)return;r[o]={};const c={};a.features.forEach(f=>{const u=["a","b","c"];for(let h=0;h<3;h++){const p=(h+1)%3,y=u[h],E=u[p],k=f.properties[y].index,X=f.properties[E].index,C=[k,X].sort().join("-");if(c[C])continue;c[C]=!0;const m=f.geometry.coordinates[0][h],v=f.geometry.coordinates[0][p],l=f.properties[y].geom,g=f.properties[E].geom,x=Math.sqrt(Math.pow(l[0]-g[0],2)+Math.pow(l[1]-g[1],2))/Math.sqrt(Math.pow(m[0]-v[0],2)+Math.pow(m[1]-v[1],2)),A=r[o];A[`${k}:${C}`]=x,A[`${X}:${C}`]=x}})});const i={};return n&&(i.bakw={}),e.forEach(o=>{const a=r[o];if(i[o]={},!a)return;const c={};Object.keys(a).forEach(u=>{const[h]=u.split(":");c[h]||(c[h]=[]),c[h].push(a[u])}),Object.keys(c).forEach(u=>{const h=c[u],p=h.reduce((y,E)=>y+E,0)/h.length;i[o][u]=p,n&&i.bakw&&(i.bakw[u]=1/p)});let f=0;for(let u=0;u<4;u++){const h=`b${u}`,p=i[o][h]||0;f+=p}i[o].c=f/4,n&&i.bakw&&(i.bakw.c=1/i[o].c)}),i}function _i(s,t){const e=s.split("-");if(e.length!==2||!e.every(i=>/^-?\d+$/.test(i)))return!1;const[n,r]=e.map(i=>parseInt(i,10)).sort((i,o)=>i-o);return t.some(i=>{if(i.length!==2)return!1;const o=i.map(c=>parseInt(`${c}`,10));if(o.some(c=>Number.isNaN(c)))return!1;const a=o.sort((c,f)=>c-f);return a[0]===n&&a[1]===r})}function Ue(s){return["a","b","c"].map((t,e)=>({prop:s.properties[t],geom:s.geometry.coordinates[0][e]}))}function xi(s,t,e){const n=new Set;let r=!1;const i=Object.keys(t);for(const o of i){if(n.has(o))continue;n.add(o);const a=t[o];if(!a||a.length<2)continue;const c=o.split("-");if(c.length!==2||_i(o,e))continue;const f=Ue(a[0].bakw),u=Ue(a[1].bakw),h=Ue(a[0].forw),p=Ue(a[1].forw),y=c.map(b=>f.find(T=>`${T.prop.index}`===b)||u.find(T=>`${T.prop.index}`===b)),E=c.map(b=>h.find(T=>`${T.prop.index}`===b)||p.find(T=>`${T.prop.index}`===b));if(y.some(b=>!b)||E.some(b=>!b))continue;const k=[f,u].map(b=>b.find(T=>!c.includes(`${T.prop.index}`))),X=[h,p].map(b=>b.find(T=>!c.includes(`${T.prop.index}`)));if(k.some(b=>!b)||X.some(b=>!b))continue;const C=a[0].bakw.geometry.coordinates[0].slice(0,3).map(b=>ve(b)),m=a[1].bakw.geometry.coordinates[0].slice(0,3).map(b=>ve(b));if(!(Un(ve(k[0].geom),m)||Un(ve(k[1].geom),C)))continue;const l=E.map(b=>ve(b.geom)),g=X.map(b=>ve(b.geom)),x=Mi([...l,...g]),A=ki(x),I=zn(l[0],l[1],g[0])+zn(l[0],l[1],g[1]);cn(A,I)&&(jn(t,a[0],s),jn(t,a[1],s),y.forEach(b=>{if(!b)return;const T=[b.geom,k[0].geom,k[1].geom,b.geom],Y={a:b.prop,b:k[0].prop,c:k[1].prop},D=_e([T],Y),Q=zt.counterTri(D);sn(t,{forw:Q,bakw:D},s)}),r=!0)}return r}function ve(s){return[s[0],s[1]]}function Un(s,t){const[e,n]=t[0],[r,i]=t[1],[o,a]=t[2],c=o-e,f=a-n,u=r-e,h=i-n,p=s[0]-e,y=s[1]-n,E=c*c+f*f,k=c*u+f*h,X=c*p+f*y,C=u*u+h*h,m=u*p+h*y,v=E*C-k*k;if(v===0)return!1;const l=1/v,g=(C*X-k*m)*l,x=(E*m-k*X)*l,A=1e-9;return g>=-A&&x>=-A&&g+x<=1+A}function Mi(s){const t=s.map(o=>o.slice()).filter((o,a,c)=>c.findIndex(f=>cn(f[0],o[0])&&cn(f[1],o[1]))===a);if(t.length<=1)return t;const e=t.sort((o,a)=>o[0]===a[0]?o[1]-a[1]:o[0]-a[0]),n=(o,a,c)=>(a[0]-o[0])*(c[1]-o[1])-(a[1]-o[1])*(c[0]-o[0]),r=[];for(const o of e){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const a=e[o];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),r.pop(),r.concat(i)}function ki(s){if(s.length<3)return 0;let t=0;for(let e=0;e<s.length;e++){const[n,r]=s[e],[i,o]=s[(e+1)%s.length];t+=n*o-i*r}return Math.abs(t)/2}function zn(s,t,e){return Math.abs((s[0]*(t[1]-e[1])+t[0]*(e[1]-s[1])+e[0]*(s[1]-t[1]))/2)}function cn(s,t,e=1e-9){return Math.abs(s-t)<=e}const Vn=typeof zt.format_version<"u"?zt.format_version:2.00703;class It extends zt.Transform{importance;priority;pointsSet;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||It.VERTEX_PLAIN),this.strictMode=t.strictMode||It.MODE_AUTO,this.yaxisMode=t.yaxisMode||It.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return Vn}setPoints(t){this.yaxisMode===It.YAXIS_FOLLOW&&(t=t.map(e=>[e[0],[e[1][0],-1*e[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=zt.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let e=t[0][0],n=e,r=t[0][1],i=r;const o=[t[0]];for(let a=1;a<t.length;a++){const c=t[a];c[0]<e&&(e=c[0]),c[0]>n&&(n=c[0]),c[1]<r&&(r=c[1]),c[1]>i&&(i=c[1]),o.push(c)}o.push(t[0]),this.boundsPolygon=_e([o]),this.xy=[e,r],this.wh=[n-e,i-r],this.vertexMode=It.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=Vn,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer,t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const e=this.vertices_params.forw[1];return e&&[0,1,2,3].map(n=>{const r=e[n].features[0],i=r.geometry.coordinates[0][1],o=r.properties.b.geom;t.vertices_points[n]=[i,o]}),t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(n=>{t.tins_points[0].push(["a","b","c"].map(r=>n.properties[r].index))}),this.strict_status===It.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(r=>n.properties[r].index))})):this.strict_status===It.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(n=>n.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,t.xy=this.xy,t.wh=this.wh):t.wh=this.wh,t.edges=this.edges,t.edgeNodes=this.edgeNodes,t}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){const t=this.tins.forw.features.map(r=>zt.counterTri(r));this.tins.bakw=Vt(t);const e={};this.tins.forw.features.forEach((r,i)=>{const o=this.tins.bakw.features[i];sn(e,{forw:r,bakw:o})}),xi(this.tins,e,this.pointsSet?.edges||[]);const n=["forw","bakw"].map(r=>{const i=this.tins[r].features.map(o=>o.geometry.coordinates[0]);return Yn(i)});n[0].length===0&&n[1].length===0?(this.strict_status=It.STATUS_STRICT,delete this.kinks):(this.strict_status=It.STATUS_ERROR,this.kinks={forw:Vt(n[0]),bakw:Vt(n[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let r=0;r<this.points.length;r++){const i=this.points[r][0],o=this.points[r][1],a=Pe(i,o,r);t.forw.push(a),t.bakw.push(Be(a))}const e=[];let n=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let r=0;r<this.edges.length;r++){const i=this.edges[r][2],o=Object.assign([],this.edges[r][0]),a=Object.assign([],this.edges[r][1]);if(o.length===0&&a.length===0){e.push(i);continue}o.unshift(this.points[i[0]][0]),o.push(this.points[i[1]][0]),a.unshift(this.points[i[0]][1]),a.push(this.points[i[1]][1]);const c=[o,a].map(f=>{const u=f.map((p,y,E)=>{if(y===0)return 0;const k=E[y-1];return Math.sqrt(Math.pow(p[0]-k[0],2)+Math.pow(p[1]-k[1],2))}),h=u.reduce((p,y,E)=>E===0?[0]:(p.push(p[E-1]+y),p),[]);return h.map((p,y,E)=>{const k=p/E[E.length-1];return[f[y],u[y],h[y],k]})});c.map((f,u)=>{const h=c[u?0:1];return f.filter((p,y)=>!(y===0||y===f.length-1||p[4]==="handled")).map(p=>{const y=p[0],E=p[3],k=h.reduce((X,C,m,v)=>{if(X)return X;const l=v[m+1];if(C[3]===E)return C[4]="handled",[C];if(C[3]<E&&l&&l[3]>E)return[C,l]},void 0);if(k&&k.length===1)return u===0?[y,k[0][0],E]:[k[0][0],y,E];if(k&&k.length===2){const X=k[0],C=k[1],m=(E-X[3])/(C[3]-X[3]),v=[(C[0][0]-X[0][0])*m+X[0][0],(C[0][1]-X[0][1])*m+X[0][1]];return u===0?[y,v,E]:[v,y,E]}return[]})}).reduce((f,u)=>f.concat(u),[]).sort((f,u)=>f[2]<u[2]?-1:1).map((f,u,h)=>{this.edgeNodes[n]=[f[0],f[1]];const p=Pe(f[0],f[1],`e${n}`);n++,t.forw.push(p),t.bakw.push(Be(p)),u===0?e.push([i[0],t.forw.length-1]):e.push([t.forw.length-2,t.forw.length-1]),u===h.length-1&&e.push([t.forw.length-1,i[1]])})}return{forw:t.forw,bakw:t.bakw,edges:e}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],e=this.xy[0]+1.05*this.wh[0],n=this.xy[1]-.05*this.wh[1],r=this.xy[1]+1.05*this.wh[1];if(!this.points.reduce((a,c)=>a&&(this.bounds?ar(c[0],this.boundsPolygon):c[0][0]>=t&&c[0][0]<=e&&c[0][1]>=n&&c[0][1]<=r),!0))throw"SOME POINTS OUTSIDE";let o=[];return this.wh&&(o=[[t,n],[e,n],[t,r],[e,r]]),{pointsSet:this.generatePointsSet(),bbox:o,minx:t,maxx:e,miny:n,maxy:r}}updateTin(){let t=this.strictMode;t!==It.MODE_STRICT&&t!==It.MODE_LOOSE&&(t=It.MODE_AUTO);const{pointsSet:e,bbox:n,minx:r,maxx:i,miny:o,maxy:a}=this.validateAndPrepareInputs(),c={forw:Vt(e.forw),bakw:Vt(e.bakw)},f=Ee(c.forw,e.edges,"target"),u=Ee(c.bakw,e.edges,"target");if(f.features.length===0||u.features.length===0)throw"TOO LINEAR1";const h=fr(c.forw),p=kn(c.forw);if(!p)throw"TOO LINEAR2";const y={},E=p.geometry.coordinates[0];let k;try{k=E.map(b=>({forw:b,bakw:zt.transformArr(le(b),f)})),k.forEach(b=>{y[`${b.forw[0]}:${b.forw[1]}`]=b})}catch{throw"TOO LINEAR2"}const X=kn(c.bakw);if(!X)throw"TOO LINEAR2";const C=X.geometry.coordinates[0];try{k=C.map(b=>({bakw:b,forw:zt.transformArr(le(b),u)})),k.forEach(b=>{y[`${b.forw[0]}:${b.forw[1]}`]=b})}catch{throw"TOO LINEAR2"}const m={forw:h.geometry.coordinates,bakw:zt.transformArr(h,f)},v=Pe(m.forw,m.bakw,"c");this.centroid={forw:v,bakw:Be(v)};const l={convexBuf:y,centroid:m,bbox:n,minx:r,maxx:i,miny:o,maxy:a},g=this.vertexMode===It.VERTEX_BIRDEYE?Qr(l):Gr(l),x={forw:[],bakw:[]};for(let b=0;b<g.length;b++){const T=g[b].forw,Y=g[b].bakw,D=Pe(T,Y,`b${b}`),Q=Be(D);e.forw.push(D),e.bakw.push(Q),x.forw.push(D),x.bakw.push(Q)}this.pointsSet={forw:Vt(e.forw),bakw:Vt(e.bakw),edges:e.edges},this.tins={forw:zt.rotateVerticesTriangle(Ee(this.pointsSet.forw,e.edges,"target"))},(t===It.MODE_STRICT||t===It.MODE_AUTO)&&this.calcurateStrictTin(),(t===It.MODE_LOOSE||t===It.MODE_AUTO&&this.strict_status===It.STATUS_ERROR)&&(this.tins.bakw=zt.rotateVerticesTriangle(Ee(this.pointsSet.bakw,e.edges,"target")),delete this.kinks,this.strict_status=It.STATUS_LOOSE),this.vertices_params={forw:an(x.forw,this.centroid.forw),bakw:an(x.bakw,this.centroid.bakw)},this.addIndexedTin();const A=["forw"];this.strict_status===It.STATUS_LOOSE&&A.push("bakw");const I=this.strict_status===It.STATUS_STRICT;this.pointsWeightBuffer=bi({tins:this.tins,targets:A,includeReciprocals:I})}async updateTinAsync(){this.updateTin()}}$t.Tin=It,$t.constrainedTin=Ee,$t.counterPoint=Be,$t.createPoint=Pe,$t.default=It,$t.findIntersections=Yn,$t.format_version=zt.format_version,$t.insertSearchIndex=sn,$t.vertexCalc=an,Object.defineProperties($t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(Yt,Ft){typeof exports=="object"&&typeof module<"u"?Ft(exports):typeof define=="function"&&define.amd?define(["exports"],Ft):(Yt=typeof globalThis<"u"?globalThis:Yt||self,Ft(Yt.tin={}))})(this,(function(Yt){"use strict";var Bi=Object.defineProperty;var Pi=(Yt,Ft,Vt)=>Ft in Yt?Bi(Yt,Ft,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):Yt[Ft]=Vt;var _t=(Yt,Ft,Vt)=>Pi(Yt,typeof Ft!="symbol"?Ft+"":Ft,Vt);function Ft(o,e,t={}){const r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=o,r}function Vt(o,e,t={}){if(!o)throw new Error("coordinates is required");if(!Array.isArray(o))throw new Error("coordinates must be an Array");if(o.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!wn(o[0])||!wn(o[1]))throw new Error("coordinates must contain numbers");return Ft({type:"Point",coordinates:o},e,t)}function Me(o,e,t={}){for(const i of o){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let n=0;n<i[i.length-1].length;n++)if(i[i.length-1][n]!==i[0][n])throw new Error("First and last Position are not equivalent.")}return Ft({type:"Polygon",coordinates:o},e,t)}function gn(o,e,t={}){if(o.length<2)throw new Error("coordinates must be an array of two or more positions");return Ft({type:"LineString",coordinates:o},e,t)}function Kt(o,e={}){const t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=o,t}function wn(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function Zn(o){if(!o)throw new Error("coord is required");if(!Array.isArray(o)){if(o.type==="Feature"&&o.geometry!==null&&o.geometry.type==="Point")return[...o.geometry.coordinates];if(o.type==="Point")return[...o.coordinates]}if(Array.isArray(o)&&o.length>=2&&!Array.isArray(o[0])&&!Array.isArray(o[1]))return[...o];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function tr(o){return o.type==="Feature"?o.geometry:o}function Je(o,e,t){if(o!==null)for(var r,i,n,s,a,c,h,u=0,f=0,g,m=o.type,x=m==="FeatureCollection",b=m==="Feature",R=x?o.features.length:1,Y=0;Y<R;Y++){h=x?o.features[Y].geometry:b?o.geometry:o,g=h?h.type==="GeometryCollection":!1,a=g?h.geometries.length:1;for(var p=0;p<a;p++){var y=0,l=0;if(s=g?h.geometries[p]:h,s!==null){c=s.coordinates;var v=s.type;switch(u=t&&(v==="Polygon"||v==="MultiPolygon")?1:0,v){case null:break;case"Point":if(e(c,f,Y,y,l)===!1)return!1;f++,y++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(e(c[r],f,Y,y,l)===!1)return!1;f++,v==="MultiPoint"&&y++}v==="LineString"&&y++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(i=0;i<c[r].length-u;i++){if(e(c[r][i],f,Y,y,l)===!1)return!1;f++}v==="MultiLineString"&&y++,v==="Polygon"&&l++}v==="Polygon"&&y++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(l=0,i=0;i<c[r].length;i++){for(n=0;n<c[r][i].length-u;n++){if(e(c[r][i][n],f,Y,y,l)===!1)return!1;f++}l++}y++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(Je(s.geometries[r],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const Lt=11102230246251565e-32,rt=134217729,yn=(3+8*Lt)*Lt;function Ct(o,e,t,r,i){let n,s,a,c,h=e[0],u=r[0],f=0,g=0;u>h==u>-h?(n=h,h=e[++f]):(n=u,u=r[++g]);let m=0;if(f<o&&g<t)for(u>h==u>-h?(s=h+n,a=n-(s-h),h=e[++f]):(s=u+n,a=n-(s-u),u=r[++g]),n=s,a!==0&&(i[m++]=a);f<o&&g<t;)u>h==u>-h?(s=n+h,c=s-n,a=n-(s-c)+(h-c),h=e[++f]):(s=n+u,c=s-n,a=n-(s-c)+(u-c),u=r[++g]),n=s,a!==0&&(i[m++]=a);for(;f<o;)s=n+h,c=s-n,a=n-(s-c)+(h-c),h=e[++f],n=s,a!==0&&(i[m++]=a);for(;g<t;)s=n+u,c=s-n,a=n-(s-c)+(u-c),u=r[++g],n=s,a!==0&&(i[m++]=a);return(n!==0||m===0)&&(i[m++]=n),m}function Wt(o,e,t,r,i,n,s,a){return Ct(Ct(o,e,t,r,s),s,i,n,a)}function q(o,e,t,r){let i,n,s,a,c,h,u,f,g,m,x;u=rt*t,m=u-(u-t),x=t-m;let b=e[0];i=b*t,u=rt*b,f=u-(u-b),g=b-f,s=g*x-(i-f*m-g*m-f*x);let R=0;s!==0&&(r[R++]=s);for(let Y=1;Y<o;Y++)b=e[Y],a=b*t,u=rt*b,f=u-(u-b),g=b-f,c=g*x-(a-f*m-g*m-f*x),n=i+c,h=n-i,s=i-(n-h)+(c-h),s!==0&&(r[R++]=s),i=a+n,s=n-(i-a),s!==0&&(r[R++]=s);return(i!==0||R===0)&&(r[R++]=i),R}function vn(o,e){let t=e[0];for(let r=1;r<o;r++)t+=e[r];return t}function yt(o){return new Float64Array(o)}const er=(3+16*Lt)*Lt,nr=(2+12*Lt)*Lt,rr=(9+64*Lt)*Lt*Lt,ve=yt(4),bn=yt(8),_n=yt(12),xn=yt(16),$t=yt(4);function ir(o,e,t,r,i,n,s){let a,c,h,u,f,g,m,x,b,R,Y,p,y,l,v,M,A,T;const S=o-i,O=t-i,X=e-n,L=r-n;l=S*L,g=rt*S,m=g-(g-S),x=S-m,g=rt*L,b=g-(g-L),R=L-b,v=x*R-(l-m*b-x*b-m*R),M=X*O,g=rt*X,m=g-(g-X),x=X-m,g=rt*O,b=g-(g-O),R=O-b,A=x*R-(M-m*b-x*b-m*R),Y=v-A,f=v-Y,ve[0]=v-(Y+f)+(f-A),p=l+Y,f=p-l,y=l-(p-f)+(Y-f),Y=y-M,f=y-Y,ve[1]=y-(Y+f)+(f-M),T=p+Y,f=T-p,ve[2]=p-(T-f)+(Y-f),ve[3]=T;let K=vn(4,ve),d=nr*s;if(K>=d||-K>=d||(f=o-S,a=o-(S+f)+(f-i),f=t-O,h=t-(O+f)+(f-i),f=e-X,c=e-(X+f)+(f-n),f=r-L,u=r-(L+f)+(f-n),a===0&&c===0&&h===0&&u===0)||(d=rr*s+yn*Math.abs(K),K+=S*u+L*a-(X*h+O*c),K>=d||-K>=d))return K;l=a*L,g=rt*a,m=g-(g-a),x=a-m,g=rt*L,b=g-(g-L),R=L-b,v=x*R-(l-m*b-x*b-m*R),M=c*O,g=rt*c,m=g-(g-c),x=c-m,g=rt*O,b=g-(g-O),R=O-b,A=x*R-(M-m*b-x*b-m*R),Y=v-A,f=v-Y,$t[0]=v-(Y+f)+(f-A),p=l+Y,f=p-l,y=l-(p-f)+(Y-f),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It(h,Wt(q(Mt,ot,2*mt,dt),dt,q(Mt,ot,b,kt),kt,q(St,Et,b,bt),bt,ue,Ut),Ut)}}return be[h-1]}function hr(o,e,t,r,i,n,s,a){const c=o-s,h=t-s,u=i-s,f=e-a,g=r-a,m=n-a,x=h*m,b=u*g,R=c*c+f*f,Y=u*f,p=c*m,y=h*h+g*g,l=c*g,v=h*f,M=u*u+m*m,A=R*(x-b)+y*(Y-p)+M*(l-v),T=(Math.abs(x)+Math.abs(b))*R+(Math.abs(Y)+Math.abs(p))*y+(Math.abs(l)+Math.abs(v))*M,S=sr*T;return A>S||-A>S?A:cr(o,e,t,r,i,n,s,a,T)}function fr(o,e){var t,r,i=0,n,s,a,c,h,u,f,g=o[0],m=o[1],x=e.length;for(t=0;t<x;t++){r=0;var b=e[t],R=b.length-1;if(u=b[0],u[0]!==b[R][0]&&u[1]!==b[R][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-g,a=u[1]-m,r;r<R;r++){if(f=b[r+1],c=f[0]-g,h=f[1]-m,a===0&&h===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(h>=0&&a<=0||h<=0&&a>=0){if(n=te(s,c,a,h,0,0),n===0)return 0;(n>0&&h>0&&a<=0||n<0&&h<=0&&a>0)&&i++}u=f,a=h,s=c}}return i%2!==0}function ur(o,e,t={}){if(!o)throw new Error("point is required");if(!e)throw new Error("polygon is required");const r=Zn(o),i=tr(e),n=i.type,s=e.bbox;let a=i.coordinates;if(s&&lr(r,s)===!1)return!1;n==="Polygon"&&(a=[a]);let c=!1;for(var h=0;h<a.length;++h){const u=fr(r,a[h]);if(u===0)return!t.ignoreBoundary;u&&(c=!0)}return c}function lr(o,e){return e[0]<=o[0]&&e[1]<=o[1]&&e[2]>=o[0]&&e[3]>=o[1]}let Mn=class{constructor(e=[],t=dr){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}};function dr(o,e){return o<e?-1:o>e?1:0}function Sn(o,e){return o.p.x>e.p.x?1:o.p.x<e.p.x?-1:o.p.y!==e.p.y?o.p.y>e.p.y?1:-1:1}function pr(o,e){return o.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:o.rightSweepEvent.p.x<e.rightSweepEvent.p.x?-1:o.rightSweepEvent.p.y!==e.rightSweepEvent.p.y?o.rightSweepEvent.p.y<e.rightSweepEvent.p.y?1:-1:1}class kn{constructor(e,t,r,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}function mr(o,e){if(o.type==="FeatureCollection"){const t=o.features;for(let r=0;r<t.length;r++)En(t[r],e)}else En(o,e)}let Ce=0,Fe=0,Le=0;function En(o,e){const t=o.type==="Feature"?o.geometry:o;let r=t.coordinates;(t.type==="Polygon"||t.type==="MultiLineString")&&(r=[r]),t.type==="LineString"&&(r=[[r]]);for(let i=0;i<r.length;i++)for(let n=0;n<r[i].length;n++){let s=r[i][n][0],a=null;Fe=Fe+1;for(let c=0;c<r[i][n].length-1;c++){a=r[i][n][c+1];const h=new kn(s,Ce,Fe,Le),u=new kn(a,Ce,Fe,Le+1);h.otherEvent=u,u.otherEvent=h,Sn(h,u)>0?(u.isLeftEndpoint=!0,h.isLeftEndpoint=!1):(h.isLeftEndpoint=!0,u.isLeftEndpoint=!1),e.push(h),e.push(u),s=a,Le=Le+1}}Ce=Ce+1}class gr{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function wr(o,e){if(o===null||e===null||o.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.rightSweepEvent)||o.leftSweepEvent.isSamePoint(e.leftSweepEvent)||o.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;const t=o.leftSweepEvent.p.x,r=o.leftSweepEvent.p.y,i=o.rightSweepEvent.p.x,n=o.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,c=e.rightSweepEvent.p.x,h=e.rightSweepEvent.p.y,u=(h-a)*(i-t)-(c-s)*(n-r),f=(c-s)*(r-a)-(h-a)*(t-s),g=(i-t)*(r-a)-(n-r)*(t-s);if(u===0)return!1;const m=f/u,x=g/u;if(m>=0&&m<=1&&x>=0&&x<=1){const b=t+m*(i-t),R=r+m*(n-r);return[b,R]}return!1}function yr(o,e){e=e||!1;const t=[],r=new Mn([],pr);for(;o.length;){const i=o.pop();if(i.isLeftEndpoint){const n=new gr(i);for(let s=0;s<r.data.length;s++){const a=r.data[s];if(e&&a.leftSweepEvent.featureId===i.featureId)continue;const c=wr(n,a);c!==!1&&t.push(c)}r.push(n)}else i.isLeftEndpoint===!1&&r.pop()}return t}function vr(o,e){const t=new Mn([],Sn);return mr(o,t),yr(t,e)}var br=vr;function _r(o,e,t={}){const{removeDuplicates:r=!0,ignoreSelfIntersections:i=!0}=t;let n=[];o.type==="FeatureCollection"?n=n.concat(o.features):o.type==="Feature"?n.push(o):(o.type==="LineString"||o.type==="Polygon"||o.type==="MultiLineString"||o.type==="MultiPolygon")&&n.push(Ft(o)),e.type==="FeatureCollection"?n=n.concat(e.features):e.type==="Feature"?n.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&n.push(Ft(e));const s=br(Kt(n),i);let a=[];if(r){const c={};s.forEach(h=>{const u=h.join(",");c[u]||(c[u]=!0,a.push(h))})}else a=s;return Kt(a.map(c=>Vt(c)))}function xr(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Mr(o){if(Object.prototype.hasOwnProperty.call(o,"__esModule"))return o;var e=o.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(o).forEach(function(r){var i=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return o[r]}})}),t}function Sr(o,e={}){let t=0,r=0,i=0;return Je(o,function(n){t+=n[0],r+=n[1],i++},!0),Vt([t/i,r/i],e.properties)}var De={exports:{}},$e={exports:{}},kr=$e.exports,An;function Er(){return An||(An=1,(function(o,e){(function(t,r){o.exports=r()})(kr,function(){function t(p,y,l,v,M){(function A(T,S,O,X,L){for(;X>O;){if(X-O>600){var K=X-O+1,d=S-O+1,E=Math.log(K),_=.5*Math.exp(2*E/3),I=.5*Math.sqrt(E*_*(K-_)/K)*(d-K/2<0?-1:1),N=Math.max(O,Math.floor(S-d*_/K+I)),D=Math.min(X,Math.floor(S+(K-d)*_/K+I));A(T,S,N,D,L)}var w=T[S],B=O,F=X;for(r(T,O,S),L(T[X],w)>0&&r(T,O,X);B<F;){for(r(T,B,F),B++,F--;L(T[B],w)<0;)B++;for(;L(T[F],w)>0;)F--}L(T[O],w)===0?r(T,O,F):r(T,++F,X),F<=S&&(O=F+1),S<=F&&(X=F-1)}})(p,y,l||0,v||p.length-1,M||i)}function r(p,y,l){var v=p[y];p[y]=p[l],p[l]=v}function i(p,y){return p<y?-1:p>y?1:0}var n=function(p){p===void 0&&(p=9),this._maxEntries=Math.max(4,p),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(p,y,l){if(!l)return y.indexOf(p);for(var v=0;v<y.length;v++)if(l(p,y[v]))return v;return-1}function a(p,y){c(p,0,p.children.length,y,p)}function c(p,y,l,v,M){M||(M=R(null)),M.minX=1/0,M.minY=1/0,M.maxX=-1/0,M.maxY=-1/0;for(var A=y;A<l;A++){var T=p.children[A];h(M,p.leaf?v(T):T)}return M}function h(p,y){return p.minX=Math.min(p.minX,y.minX),p.minY=Math.min(p.minY,y.minY),p.maxX=Math.max(p.maxX,y.maxX),p.maxY=Math.max(p.maxY,y.maxY),p}function u(p,y){return p.minX-y.minX}function f(p,y){return p.minY-y.minY}function g(p){return(p.maxX-p.minX)*(p.maxY-p.minY)}function m(p){return p.maxX-p.minX+(p.maxY-p.minY)}function x(p,y){return p.minX<=y.minX&&p.minY<=y.minY&&y.maxX<=p.maxX&&y.maxY<=p.maxY}function b(p,y){return y.minX<=p.maxX&&y.minY<=p.maxY&&y.maxX>=p.minX&&y.maxY>=p.minY}function R(p){return{children:p,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Y(p,y,l,v,M){for(var A=[y,l];A.length;)if(!((l=A.pop())-(y=A.pop())<=v)){var T=y+Math.ceil((l-y)/v/2)*v;t(p,T,y,l,M),A.push(y,T,T,l)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(p){var y=this.data,l=[];if(!b(p,y))return l;for(var v=this.toBBox,M=[];y;){for(var A=0;A<y.children.length;A++){var T=y.children[A],S=y.leaf?v(T):T;b(p,S)&&(y.leaf?l.push(T):x(p,S)?this._all(T,l):M.push(T))}y=M.pop()}return l},n.prototype.collides=function(p){var y=this.data;if(!b(p,y))return!1;for(var l=[];y;){for(var v=0;v<y.children.length;v++){var M=y.children[v],A=y.leaf?this.toBBox(M):M;if(b(p,A)){if(y.leaf||x(p,A))return!0;l.push(M)}}y=l.pop()}return!1},n.prototype.load=function(p){if(!p||!p.length)return this;if(p.length<this._minEntries){for(var y=0;y<p.length;y++)this.insert(p[y]);return this}var l=this._build(p.slice(),0,p.length-1,0);if(this.data.children.length)if(this.data.height===l.height)this._splitRoot(this.data,l);else{if(this.data.height<l.height){var v=this.data;this.data=l,l=v}this._insert(l,this.data.height-l.height-1,!0)}else this.data=l;return this},n.prototype.insert=function(p){return p&&this._insert(p,this.data.height-1),this},n.prototype.clear=function(){return this.data=R([]),this},n.prototype.remove=function(p,y){if(!p)return this;for(var l,v,M,A=this.data,T=this.toBBox(p),S=[],O=[];A||S.length;){if(A||(A=S.pop(),v=S[S.length-1],l=O.pop(),M=!0),A.leaf){var X=s(p,A.children,y);if(X!==-1)return A.children.splice(X,1),S.push(A),this._condense(S),this}M||A.leaf||!x(A,T)?v?(l++,A=v.children[l],M=!1):A=null:(S.push(A),O.push(l),l=0,v=A,A=A.children[0])}return this},n.prototype.toBBox=function(p){return p},n.prototype.compareMinX=function(p,y){return p.minX-y.minX},n.prototype.compareMinY=function(p,y){return p.minY-y.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(p){return this.data=p,this},n.prototype._all=function(p,y){for(var l=[];p;)p.leaf?y.push.apply(y,p.children):l.push.apply(l,p.children),p=l.pop();return y},n.prototype._build=function(p,y,l,v){var M,A=l-y+1,T=this._maxEntries;if(A<=T)return a(M=R(p.slice(y,l+1)),this.toBBox),M;v||(v=Math.ceil(Math.log(A)/Math.log(T)),T=Math.ceil(A/Math.pow(T,v-1))),(M=R([])).leaf=!1,M.height=v;var S=Math.ceil(A/T),O=S*Math.ceil(Math.sqrt(T));Y(p,y,l,O,this.compareMinX);for(var X=y;X<=l;X+=O){var L=Math.min(X+O-1,l);Y(p,X,L,S,this.compareMinY);for(var K=X;K<=L;K+=S){var d=Math.min(K+S-1,L);M.children.push(this._build(p,K,d,v-1))}}return a(M,this.toBBox),M},n.prototype._chooseSubtree=function(p,y,l,v){for(;v.push(y),!y.leaf&&v.length-1!==l;){for(var M=1/0,A=1/0,T=void 0,S=0;S<y.children.length;S++){var O=y.children[S],X=g(O),L=(K=p,d=O,(Math.max(d.maxX,K.maxX)-Math.min(d.minX,K.minX))*(Math.max(d.maxY,K.maxY)-Math.min(d.minY,K.minY))-X);L<A?(A=L,M=X<M?X:M,T=O):L===A&&X<M&&(M=X,T=O)}y=T||y.children[0]}var K,d;return y},n.prototype._insert=function(p,y,l){var v=l?p:this.toBBox(p),M=[],A=this._chooseSubtree(v,this.data,y,M);for(A.children.push(p),h(A,v);y>=0&&M[y].children.length>this._maxEntries;)this._split(M,y),y--;this._adjustParentBBoxes(v,M,y)},n.prototype._split=function(p,y){var l=p[y],v=l.children.length,M=this._minEntries;this._chooseSplitAxis(l,M,v);var A=this._chooseSplitIndex(l,M,v),T=R(l.children.splice(A,l.children.length-A));T.height=l.height,T.leaf=l.leaf,a(l,this.toBBox),a(T,this.toBBox),y?p[y-1].children.push(T):this._splitRoot(l,T)},n.prototype._splitRoot=function(p,y){this.data=R([p,y]),this.data.height=p.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(p,y,l){for(var v,M,A,T,S,O,X,L=1/0,K=1/0,d=y;d<=l-y;d++){var E=c(p,0,d,this.toBBox),_=c(p,d,l,this.toBBox),I=(M=E,A=_,T=void 0,S=void 0,O=void 0,X=void 0,T=Math.max(M.minX,A.minX),S=Math.max(M.minY,A.minY),O=Math.min(M.maxX,A.maxX),X=Math.min(M.maxY,A.maxY),Math.max(0,O-T)*Math.max(0,X-S)),N=g(E)+g(_);I<L?(L=I,v=d,K=N<K?N:K):I===L&&N<K&&(K=N,v=d)}return v||l-y},n.prototype._chooseSplitAxis=function(p,y,l){var v=p.leaf?this.compareMinX:u,M=p.leaf?this.compareMinY:f;this._allDistMargin(p,y,l,v)<this._allDistMargin(p,y,l,M)&&p.children.sort(v)},n.prototype._allDistMargin=function(p,y,l,v){p.children.sort(v);for(var M=this.toBBox,A=c(p,0,y,M),T=c(p,l-y,l,M),S=m(A)+m(T),O=y;O<l-y;O++){var X=p.children[O];h(A,p.leaf?M(X):X),S+=m(A)}for(var L=l-y-1;L>=y;L--){var K=p.children[L];h(T,p.leaf?M(K):K),S+=m(T)}return S},n.prototype._adjustParentBBoxes=function(p,y,l){for(var v=l;v>=0;v--)h(y[v],p)},n.prototype._condense=function(p){for(var y=p.length-1,l=void 0;y>=0;y--)p[y].children.length===0?y>0?(l=p[y-1].children).splice(l.indexOf(p[y]),1):this.clear():a(p[y],this.toBBox)},n})})($e)),$e.exports}class Ar{constructor(e=[],t=Or){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}}function Or(o,e){return o<e?-1:o>e?1:0}const Br=Mr(Object.freeze(Object.defineProperty({__proto__:null,default:Ar},Symbol.toStringTag,{value:"Module"})));var Se={exports:{}},nn,On;function Pr(){return On||(On=1,nn=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=(i-r)/2,h=0,u=c-1;h<c;u=h++){var f=t[r+h*2+0],g=t[r+h*2+1],m=t[r+u*2+0],x=t[r+u*2+1],b=g>s!=x>s&&n<(m-f)*(s-g)/(x-g)+f;b&&(a=!a)}return a}),nn}var rn,Bn;function Ir(){return Bn||(Bn=1,rn=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=i-r,h=0,u=c-1;h<c;u=h++){var f=t[h+r][0],g=t[h+r][1],m=t[u+r][0],x=t[u+r][1],b=g>s!=x>s&&n<(m-f)*(s-g)/(x-g)+f;b&&(a=!a)}return a}),rn}var Pn;function Tr(){if(Pn)return Se.exports;Pn=1;var o=Pr(),e=Ir();return Se.exports=function(r,i,n,s){return i.length>0&&Array.isArray(i[0])?e(r,i,n,s):o(r,i,n,s)},Se.exports.nested=e,Se.exports.flat=o,Se.exports}var ke={exports:{}},Nr=ke.exports,In;function Xr(){return In||(In=1,(function(o,e){(function(t,r){r(e)})(Nr,function(t){const i=33306690738754706e-32;function n(b,R,Y,p,y){let l,v,M,A,T=R[0],S=p[0],O=0,X=0;S>T==S>-T?(l=T,T=R[++O]):(l=S,S=p[++X]);let L=0;if(O<b&&X<Y)for(S>T==S>-T?(M=l-((v=T+l)-T),T=R[++O]):(M=l-((v=S+l)-S),S=p[++X]),l=v,M!==0&&(y[L++]=M);O<b&&X<Y;)S>T==S>-T?(M=l-((v=l+T)-(A=v-l))+(T-A),T=R[++O]):(M=l-((v=l+S)-(A=v-l))+(S-A),S=p[++X]),l=v,M!==0&&(y[L++]=M);for(;O<b;)M=l-((v=l+T)-(A=v-l))+(T-A),T=R[++O],l=v,M!==0&&(y[L++]=M);for(;X<Y;)M=l-((v=l+S)-(A=v-l))+(S-A),S=p[++X],l=v,M!==0&&(y[L++]=M);return l===0&&L!==0||(y[L++]=l),L}function s(b){return new Float64Array(b)}const a=33306690738754716e-32,c=22204460492503146e-32,h=11093356479670487e-47,u=s(4),f=s(8),g=s(12),m=s(16),x=s(4);t.orient2d=function(b,R,Y,p,y,l){const v=(R-l)*(Y-y),M=(b-y)*(p-l),A=v-M;if(v===0||M===0||v>0!=M>0)return A;const T=Math.abs(v+M);return Math.abs(A)>=a*T?A:-(function(S,O,X,L,K,d,E){let _,I,N,D,w,B,F,j,U,z,Q,V,ht,ct,ut,pt,gt,mt;const Bt=S-K,Rt=X-K,St=O-d,Mt=L-d;w=(ut=(j=Bt-(F=(B=134217729*Bt)-(B-Bt)))*(z=Mt-(U=(B=134217729*Mt)-(B-Mt)))-((ct=Bt*Mt)-F*U-j*U-F*z))-(Q=ut-(gt=(j=St-(F=(B=134217729*St)-(B-St)))*(z=Rt-(U=(B=134217729*Rt)-(B-Rt)))-((pt=St*Rt)-F*U-j*U-F*z))),u[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),u[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,u[2]=V-(mt-w)+(Q-w),u[3]=mt;let ie=(function(mn,zt){let We=zt[0];for(let k=1;k<mn;k++)We+=zt[k];return We})(4,u),we=c*E;if(ie>=we||-ie>=we||(_=S-(Bt+(w=S-Bt))+(w-K),N=X-(Rt+(w=X-Rt))+(w-K),I=O-(St+(w=O-St))+(w-d),D=L-(Mt+(w=L-Mt))+(w-d),_===0&&I===0&&N===0&&D===0)||(we=h*E+i*Math.abs(ie),(ie+=Bt*D+Mt*_-(St*N+Rt*I))>=we||-ie>=we))return ie;w=(ut=(j=_-(F=(B=134217729*_)-(B-_)))*(z=Mt-(U=(B=134217729*Mt)-(B-Mt)))-((ct=_*Mt)-F*U-j*U-F*z))-(Q=ut-(gt=(j=I-(F=(B=134217729*I)-(B-I)))*(z=Rt-(U=(B=134217729*Rt)-(B-Rt)))-((pt=I*Rt)-F*U-j*U-F*z))),x[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),x[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,x[2]=V-(mt-w)+(Q-w),x[3]=mt;const ln=n(4,u,4,x,f);w=(ut=(j=Bt-(F=(B=134217729*Bt)-(B-Bt)))*(z=D-(U=(B=134217729*D)-(B-D)))-((ct=Bt*D)-F*U-j*U-F*z))-(Q=ut-(gt=(j=St-(F=(B=134217729*St)-(B-St)))*(z=N-(U=(B=134217729*N)-(B-N)))-((pt=St*N)-F*U-j*U-F*z))),x[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),x[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,x[2]=V-(mt-w)+(Q-w),x[3]=mt;const dn=n(ln,f,4,x,g);w=(ut=(j=_-(F=(B=134217729*_)-(B-_)))*(z=D-(U=(B=134217729*D)-(B-D)))-((ct=_*D)-F*U-j*U-F*z))-(Q=ut-(gt=(j=I-(F=(B=134217729*I)-(B-I)))*(z=N-(U=(B=134217729*N)-(B-N)))-((pt=I*N)-F*U-j*U-F*z))),x[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),x[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,x[2]=V-(mt-w)+(Q-w),x[3]=mt;const pn=n(dn,g,4,x,m);return m[pn-1]})(b,R,Y,p,y,l,T)},t.orient2dfast=function(b,R,Y,p,y,l){return(R-l)*(Y-y)-(b-y)*(p-l)},Object.defineProperty(t,"__esModule",{value:!0})})})(ke,ke.exports)),ke.exports}var Tn;function Rr(){if(Tn)return De.exports;Tn=1;var o=Er(),e=Br,t=Tr(),r=Xr().orient2d;e.default&&(e=e.default),De.exports=i,De.exports.default=i;function i(l,v,M){v=Math.max(0,v===void 0?2:v),M=M||0;var A=m(l),T=new o(16);T.toBBox=function(F){return{minX:F[0],minY:F[1],maxX:F[0],maxY:F[1]}},T.compareMinX=function(F,j){return F[0]-j[0]},T.compareMinY=function(F,j){return F[1]-j[1]},T.load(l);for(var S=[],O=0,X;O<A.length;O++){var L=A[O];T.remove(L),X=x(L,X),S.push(X)}var K=new o(16);for(O=0;O<S.length;O++)K.insert(g(S[O]));for(var d=v*v,E=M*M;S.length;){var _=S.shift(),I=_.p,N=_.next.p,D=b(I,N);if(!(D<E)){var w=D/d;L=n(T,_.prev.p,I,N,_.next.next.p,w,K),L&&Math.min(b(L,I),b(L,N))<=w&&(S.push(_),S.push(x(L,_)),T.remove(L),K.remove(_),K.insert(g(_)),K.insert(g(_.next)))}}_=X;var B=[];do B.push(_.p),_=_.next;while(_!==X);return B.push(_.p),B}function n(l,v,M,A,T,S,O){for(var X=new e([],s),L=l.data;L;){for(var K=0;K<L.children.length;K++){var d=L.children[K],E=L.leaf?R(d,M,A):a(M,A,d);E>S||X.push({node:d,dist:E})}for(;X.length&&!X.peek().node.children;){var _=X.pop(),I=_.node,N=R(I,v,M),D=R(I,A,T);if(_.dist<N&&_.dist<D&&h(M,I,O)&&h(A,I,O))return I}L=X.pop(),L&&(L=L.node)}return null}function s(l,v){return l.dist-v.dist}function a(l,v,M){if(c(l,M)||c(v,M))return 0;var A=Y(l[0],l[1],v[0],v[1],M.minX,M.minY,M.maxX,M.minY);if(A===0)return 0;var T=Y(l[0],l[1],v[0],v[1],M.minX,M.minY,M.minX,M.maxY);if(T===0)return 0;var S=Y(l[0],l[1],v[0],v[1],M.maxX,M.minY,M.maxX,M.maxY);if(S===0)return 0;var O=Y(l[0],l[1],v[0],v[1],M.minX,M.maxY,M.maxX,M.maxY);return O===0?0:Math.min(A,T,S,O)}function c(l,v){return l[0]>=v.minX&&l[0]<=v.maxX&&l[1]>=v.minY&&l[1]<=v.maxY}function h(l,v,M){for(var A=Math.min(l[0],v[0]),T=Math.min(l[1],v[1]),S=Math.max(l[0],v[0]),O=Math.max(l[1],v[1]),X=M.search({minX:A,minY:T,maxX:S,maxY:O}),L=0;L<X.length;L++)if(f(X[L].p,X[L].next.p,l,v))return!1;return!0}function u(l,v,M){return r(l[0],l[1],v[0],v[1],M[0],M[1])}function f(l,v,M,A){return l!==A&&v!==M&&u(l,v,M)>0!=u(l,v,A)>0&&u(M,A,l)>0!=u(M,A,v)>0}function g(l){var v=l.p,M=l.next.p;return l.minX=Math.min(v[0],M[0]),l.minY=Math.min(v[1],M[1]),l.maxX=Math.max(v[0],M[0]),l.maxY=Math.max(v[1],M[1]),l}function m(l){for(var v=l[0],M=l[0],A=l[0],T=l[0],S=0;S<l.length;S++){var O=l[S];O[0]<v[0]&&(v=O),O[0]>A[0]&&(A=O),O[1]<M[1]&&(M=O),O[1]>T[1]&&(T=O)}var X=[v,M,A,T],L=X.slice();for(S=0;S<l.length;S++)t(l[S],X)||L.push(l[S]);return y(L)}function x(l,v){var M={p:l,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return v?(M.next=v.next,M.prev=v,v.next.prev=M,v.next=M):(M.prev=M,M.next=M),M}function b(l,v){var M=l[0]-v[0],A=l[1]-v[1];return M*M+A*A}function R(l,v,M){var A=v[0],T=v[1],S=M[0]-A,O=M[1]-T;if(S!==0||O!==0){var X=((l[0]-A)*S+(l[1]-T)*O)/(S*S+O*O);X>1?(A=M[0],T=M[1]):X>0&&(A+=S*X,T+=O*X)}return S=l[0]-A,O=l[1]-T,S*S+O*O}function Y(l,v,M,A,T,S,O,X){var L=M-l,K=A-v,d=O-T,E=X-S,_=l-T,I=v-S,N=L*L+K*K,D=L*d+K*E,w=d*d+E*E,B=L*_+K*I,F=d*_+E*I,j=N*w-D*D,U,z,Q,V,ht=j,ct=j;j===0?(z=0,ht=1,V=F,ct=w):(z=D*F-w*B,V=N*F-D*B,z<0?(z=0,V=F,ct=w):z>ht&&(z=ht,V=F+D,ct=w)),V<0?(V=0,-B<0?z=0:-B>N?z=ht:(z=-B,ht=N)):V>ct&&(V=ct,-B+D<0?z=0:-B+D>N?z=ht:(z=-B+D,ht=N)),U=z===0?0:z/ht,Q=V===0?0:V/ct;var ut=(1-U)*l+U*M,pt=(1-U)*v+U*A,gt=(1-Q)*T+Q*O,mt=(1-Q)*S+Q*X,Bt=gt-ut,Rt=mt-pt;return Bt*Bt+Rt*Rt}function p(l,v){return l[0]===v[0]?l[1]-v[1]:l[0]-v[0]}function y(l){l.sort(p);for(var v=[],M=0;M<l.length;M++){for(;v.length>=2&&u(v[v.length-2],v[v.length-1],l[M])<=0;)v.pop();v.push(l[M])}for(var A=[],T=l.length-1;T>=0;T--){for(;A.length>=2&&u(A[A.length-2],A[A.length-1],l[T])<=0;)A.pop();A.push(l[T])}return A.pop(),v.pop(),v.concat(A)}return De.exports}var Yr=Rr();const Cr=xr(Yr);function Nn(o,e={}){e.concavity=e.concavity||1/0;const t=[];if(Je(o,i=>{t.push([i[0],i[1]])}),!t.length)return null;const r=Cr(t,e.concavity);return r.length>3?Me([r]):null}var Ee={exports:{}},Fr=Ee.exports,Xn;function Lr(){return Xn||(Xn=1,(function(o,e){(function(t,r){r(e)})(Fr,(function(t){var r=Object.defineProperty,i=(k,P,C)=>P in k?r(k,P,{enumerable:!0,configurable:!0,writable:!0,value:C}):k[P]=C,n=(k,P,C)=>i(k,typeof P!="symbol"?P+"":P,C);function s(k,P,C={}){const $={type:"Feature"};return(C.id===0||C.id)&&($.id=C.id),C.bbox&&($.bbox=C.bbox),$.properties=P||{},$.geometry=k,$}function a(k,P,C={}){if(!k)throw new Error("coordinates is required");if(!Array.isArray(k))throw new Error("coordinates must be an Array");if(k.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!u(k[0])||!u(k[1]))throw new Error("coordinates must contain numbers");return s({type:"Point",coordinates:k},P,C)}function c(k,P,C={}){for(const $ of k){if($.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if($[$.length-1].length!==$[0].length)throw new Error("First and last Position are not equivalent.");for(let tt=0;tt<$[$.length-1].length;tt++)if($[$.length-1][tt]!==$[0][tt])throw new Error("First and last Position are not equivalent.")}return s({type:"Polygon",coordinates:k},P,C)}function h(k,P={}){const C={type:"FeatureCollection"};return P.id&&(C.id=P.id),P.bbox&&(C.bbox=P.bbox),C.features=k,C}function u(k){return!isNaN(k)&&k!==null&&!Array.isArray(k)}function f(k){if(!k)throw new Error("coord is required");if(!Array.isArray(k)){if(k.type==="Feature"&&k.geometry!==null&&k.geometry.type==="Point")return[...k.geometry.coordinates];if(k.type==="Point")return[...k.coordinates]}if(Array.isArray(k)&&k.length>=2&&!Array.isArray(k[0])&&!Array.isArray(k[1]))return[...k];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function g(k){if(Array.isArray(k))return k;if(k.type==="Feature"){if(k.geometry!==null)return k.geometry.coordinates}else if(k.coordinates)return k.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function m(k){return k.type==="Feature"?k.geometry:k}const x=11102230246251565e-32,b=134217729,R=(3+8*x)*x;function Y(k,P,C,$,tt){let G,et,st,it,at=P[0],ft=$[0],J=0,Z=0;ft>at==ft>-at?(G=at,at=P[++J]):(G=ft,ft=$[++Z]);let lt=0;if(J<k&&Z<C)for(ft>at==ft>-at?(et=at+G,st=G-(et-at),at=P[++J]):(et=ft+G,st=G-(et-ft),ft=$[++Z]),G=et,st!==0&&(tt[lt++]=st);J<k&&Z<C;)ft>at==ft>-at?(et=G+at,it=et-G,st=G-(et-it)+(at-it),at=P[++J]):(et=G+ft,it=et-G,st=G-(et-it)+(ft-it),ft=$[++Z]),G=et,st!==0&&(tt[lt++]=st);for(;J<k;)et=G+at,it=et-G,st=G-(et-it)+(at-it),at=P[++J],G=et,st!==0&&(tt[lt++]=st);for(;Z<C;)et=G+ft,it=et-G,st=G-(et-it)+(ft-it),ft=$[++Z],G=et,st!==0&&(tt[lt++]=st);return(G!==0||lt===0)&&(tt[lt++]=G),lt}function p(k,P){let C=P[0];for(let $=1;$<k;$++)C+=P[$];return C}function y(k){return new Float64Array(k)}const l=(3+16*x)*x,v=(2+12*x)*x,M=(9+64*x)*x*x,A=y(4),T=y(8),S=y(12),O=y(16),X=y(4);function L(k,P,C,$,tt,G,et){let st,it,at,ft,J,Z,lt,xt,nt,H,W,wt,At,Ot,Xt,vt,Nt,Dt;const Gt=k-tt,Qt=C-tt,Ht=P-G,Zt=$-G;Ot=Gt*Zt,Z=b*Gt,lt=Z-(Z-Gt),xt=Gt-lt,Z=b*Zt,nt=Z-(Z-Zt),H=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ht,lt=Z-(Z-Ht),xt=Ht-lt,Z=b*at,nt=Z-(Z-at),H=at-nt,Nt=xt*H-(vt-lt*nt-xt*nt-lt*H),W=Xt-Nt,J=Xt-W,X[0]=Xt-(W+J)+(J-Nt),wt=Ot+W,J=wt-Ot,At=Ot-(wt-J)+(W-J),W=At-vt,J=At-W,X[1]=At-(W+J)+(J-vt),Dt=wt+W,J=Dt-wt,X[2]=wt-(Dt-J)+(W-J),X[3]=Dt;const Ai=Y(Ei,T,4,X,S);Ot=st*ft,Z=b*st,lt=Z-(Z-st),xt=st-lt,Z=b*ft,nt=Z-(Z-ft),H=ft-nt,Xt=xt*H-(Ot-lt*nt-xt*nt-lt*H),vt=it*at,Z=b*it,lt=Z-(Z-it),xt=it-lt,Z=b*at,nt=Z-(Z-at),H=at-nt,Nt=xt*H-(vt-lt*nt-xt*nt-lt*H),W=Xt-Nt,J=Xt-W,X[0]=Xt-(W+J)+(J-Nt),wt=Ot+W,J=wt-Ot,At=Ot-(wt-J)+(W-J),W=At-vt,J=At-W,X[1]=At-(W+J)+(J-vt),Dt=wt+W,J=Dt-wt,X[2]=wt-(Dt-J)+(W-J),X[3]=Dt;const Oi=Y(Ai,S,4,X,O);return O[Oi-1]}function K(k,P,C,$,tt,G){const et=(P-G)*(C-tt),st=(k-tt)*($-G),it=et-st,at=Math.abs(et+st);return Math.abs(it)>=l*at?it:-L(k,P,C,$,tt,G,at)}function d(k,P){var C,$,tt=0,G,et,st,it,at,ft,J,Z=k[0],lt=k[1],xt=P.length;for(C=0;C<xt;C++){$=0;var nt=P[C],H=nt.length-1;if(ft=nt[0],ft[0]!==nt[H][0]&&ft[1]!==nt[H][1])throw new Error("First and last coordinates in a ring must be the same");for(et=ft[0]-Z,st=ft[1]-lt,$;$<H;$++){if(J=nt[$+1],it=J[0]-Z,at=J[1]-lt,st===0&&at===0){if(it<=0&&et>=0||et<=0&&it>=0)return 0}else if(at>=0&&st<=0||at<=0&&st>=0){if(G=K(et,it,st,at,0,0),G===0)return 0;(G>0&&at>0&&st<=0||G<0&&at<=0&&st>0)&&tt++}ft=J,st=at,et=it}}return tt%2!==0}function E(k,P,C={}){if(!k)throw new Error("point is required");if(!P)throw new Error("polygon is required");const $=f(k),tt=m(P),G=tt.type,et=P.bbox;let st=tt.coordinates;if(et&&_($,et)===!1)return!1;G==="Polygon"&&(st=[st]);let it=!1;for(var at=0;at<st.length;++at){const ft=d($,st[at]);if(ft===0)return!C.ignoreBoundary;ft&&(it=!0)}return it}function _(k,P){return P[0]<=k[0]&&P[1]<=k[1]&&P[2]>=k[0]&&P[3]>=k[1]}function I(k,P){for(let C=0;C<P.features.length;C++)if(E(k,P.features[C]))return P.features[C]}function N(k,P,C){const $=P.geometry.coordinates[0][0],tt=P.geometry.coordinates[0][1],G=P.geometry.coordinates[0][2],et=k.geometry.coordinates,st=P.properties.a.geom,it=P.properties.b.geom,at=P.properties.c.geom,ft=[tt[0]-$[0],tt[1]-$[1]],J=[G[0]-$[0],G[1]-$[1]],Z=[et[0]-$[0],et[1]-$[1]],lt=[it[0]-st[0],it[1]-st[1]],xt=[at[0]-st[0],at[1]-st[1]];let nt=(J[1]*Z[0]-J[0]*Z[1])/(ft[0]*J[1]-ft[1]*J[0]),H=(ft[0]*Z[1]-ft[1]*Z[0])/(ft[0]*J[1]-ft[1]*J[0]);if(C){const W=C[P.properties.a.index],wt=C[P.properties.b.index],At=C[P.properties.c.index];let Ot;if(nt<0||H<0||1-nt-H<0){const Xt=nt/(nt+H),vt=H/(nt+H);Ot=nt/wt/(Xt/wt+vt/At),H=H/At/(Xt/wt+vt/At)}else Ot=nt/wt/(nt/wt+H/At+(1-nt-H)/W),H=H/At/(nt/wt+H/At+(1-nt-H)/W);nt=Ot}return[nt*lt[0]+H*xt[0]+st[0],nt*lt[1]+H*xt[1]+st[1]]}function D(k,P,C,$){const tt=k.geometry.coordinates,G=C.geometry.coordinates,et=Math.atan2(tt[0]-G[0],tt[1]-G[1]),st=F(et,P[0]);if(st===void 0)throw new Error("Unable to determine vertex index");const it=P[1][st];return N(k,it.features[0],$)}function w(k,P,C,$,tt,G,et,st){let it;if(et&&(it=I(k,h([et]))),!it){if(C){const at=k.geometry.coordinates,ft=C.gridNum,J=C.xOrigin,Z=C.yOrigin,lt=C.xUnit,xt=C.yUnit,nt=C.gridCache,H=B(at[0],J,lt,ft),W=B(at[1],Z,xt,ft),wt=nt[H]?nt[H][W]?nt[H][W]:[]:[];P=h(wt.map(At=>P.features[At]))}it=I(k,P)}return st&&st(it),it?N(k,it,G):D(k,$,tt,G)}function B(k,P,C,$){let tt=Math.floor((k-P)/C);return tt>=$&&(tt=$-1),tt}function F(k,P){let C=j(k-P[0]),$=Math.PI*2,tt;for(let G=0;G<P.length;G++){const et=(G+1)%P.length,st=j(k-P[et]),it=Math.min(Math.abs(C),Math.abs(st));C*st<=0&&it<$&&($=it,tt=G),C=st}return tt}function j(k,P=!1){const C=P?function($){return!($>=0&&$<Math.PI*2)}:function($){return!($>-1*Math.PI&&$<=Math.PI)};for(;C(k);)k=k+2*Math.PI*(k>0?-1:1);return k}function U(k,P){return P&&P>=2.00703||Array.isArray(k[0])?k:k.map(C=>[C.illstNodes,C.mercNodes,C.startEnd])}function z(k){const P=k.features;for(let C=0;C<P.length;C++){const $=P[C];`${$.properties.a.index}`.substring(0,1)==="b"&&`${$.properties.b.index}`.substring(0,1)==="b"?P[C]={geometry:{type:"Polygon",coordinates:[[$.geometry.coordinates[0][2],$.geometry.coordinates[0][0],$.geometry.coordinates[0][1],$.geometry.coordinates[0][2]]]},properties:{a:{geom:$.properties.c.geom,index:$.properties.c.index},b:{geom:$.properties.a.geom,index:$.properties.a.index},c:{geom:$.properties.b.geom,index:$.properties.b.index}},type:"Feature"}:`${$.properties.c.index}`.substring(0,1)==="b"&&`${$.properties.a.index}`.substring(0,1)==="b"&&(P[C]={geometry:{type:"Polygon",coordinates:[[$.geometry.coordinates[0][1],$.geometry.coordinates[0][2],$.geometry.coordinates[0][0],$.geometry.coordinates[0][1]]]},properties:{a:{geom:$.properties.b.geom,index:$.properties.b.index},b:{geom:$.properties.c.geom,index:$.properties.c.index},c:{geom:$.properties.a.geom,index:$.properties.a.index}},type:"Feature"})}return k}function Q(k){const P=["a","b","c","a"].map(G=>k.properties[G].geom),C=k.geometry.coordinates[0],$=k.properties,tt={a:{geom:C[0],index:$.a.index},b:{geom:C[1],index:$.b.index},c:{geom:C[2],index:$.c.index}};return c([P],tt)}function V(k){const P=[0,1,2,0].map($=>k[$][0][0]),C={a:{geom:k[0][0][1],index:k[0][1]},b:{geom:k[1][0][1],index:k[1][1]},c:{geom:k[2][0][1],index:k[2][1]}};return c([P],C)}function ht(k,P,C,$,tt,G=!1,et){const st=k.map(it=>{(!et||et<2.00703)&&(it=ct(it));const at=isFinite(it)?P[it]:it==="c"?$:it==="b0"?tt[0]:it==="b1"?tt[1]:it==="b2"?tt[2]:it==="b3"?tt[3]:(function(){const ft=it.match(/e(\d+)/);if(ft){const J=parseInt(ft[1]);return C[J]}throw"Bad index value for indexesToTri"})();return G?[[at[1],at[0]],it]:[[at[0],at[1]],it]});return V(st)}function ct(k){return typeof k=="number"?k:k.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}const ut=2.00703;function pt(k){return!!(k.version||!k.tins&&k.points&&k.tins_points)}function gt(k){return{points:k.points,pointsWeightBuffer:Bt(k),strictStatus:Rt(k),verticesParams:St(k),centroid:ie(k),edges:U(k.edges||[]),edgeNodes:k.edgeNodes||[],tins:we(k),kinks:ln(k.kinks_points),yaxisMode:k.yaxisMode??"invert",strictMode:k.strictMode??"auto",vertexMode:k.vertexMode,bounds:k.bounds,boundsPolygon:k.boundsPolygon,wh:k.wh,xy:k.bounds?k.xy:[0,0]}}function mt(k){const P=dn(k),C=P.tins;return{compiled:P,tins:C,points:pn(C),strictStatus:P.strict_status,pointsWeightBuffer:P.weight_buffer,verticesParams:P.vertices_params,centroid:P.centroid,kinks:P.kinks}}function Bt(k){return!k.version||k.version<ut?["forw","bakw"].reduce((P,C)=>{const $=k.weight_buffer[C];return $&&(P[C]=Object.keys($).reduce((tt,G)=>{const et=ct(G);return tt[et]=$[G],tt},{})),P},{}):k.weight_buffer}function Rt(k){return k.strict_status?k.strict_status:k.kinks_points?"strict_error":k.tins_points.length===2?"loose":"strict"}function St(k){const P={forw:[k.vertices_params[0]],bakw:[k.vertices_params[1]]};return P.forw[1]=Mt(k,!1),P.bakw[1]=Mt(k,!0),P}function Mt(k,P){return[0,1,2,3].map(C=>{const $=(C+1)%4,tt=ht(["c",`b${C}`,`b${$}`],k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,P,ut);return h([tt])})}function ie(k){return{forw:a(k.centroid_point[0],{target:{geom:k.centroid_point[1],index:"c"}}),bakw:a(k.centroid_point[1],{target:{geom:k.centroid_point[0],index:"c"}})}}function we(k){const P=k.tins_points.length===1?0:1;return{forw:h(k.tins_points[0].map(C=>ht(C,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!1,k.version))),bakw:h(k.tins_points[P].map(C=>ht(C,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!0,k.version)))}}function ln(k){if(k)return{bakw:h(k.map(P=>a(P)))}}function dn(k){return JSON.parse(JSON.stringify(k).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function pn(k){const P=[],C=k.forw.features;for(let $=0;$<C.length;$++){const tt=C[$];["a","b","c"].map((G,et)=>{const st=tt.geometry.coordinates[0][et],it=tt.properties[G].geom,at=tt.properties[G].index;typeof at=="number"&&(P[at]=[st,it])})}return P}const mn=ut,zt=class se{constructor(){n(this,"points",[]),n(this,"pointsWeightBuffer"),n(this,"strict_status"),n(this,"vertices_params"),n(this,"centroid"),n(this,"edgeNodes"),n(this,"edges"),n(this,"tins"),n(this,"kinks"),n(this,"yaxisMode",se.YAXIS_INVERT),n(this,"strictMode",se.MODE_AUTO),n(this,"vertexMode",se.VERTEX_PLAIN),n(this,"bounds"),n(this,"boundsPolygon"),n(this,"wh"),n(this,"xy"),n(this,"indexedTins"),n(this,"stateFull",!1),n(this,"stateTriangle"),n(this,"stateBackward"),n(this,"priority"),n(this,"importance"),n(this,"xyBounds"),n(this,"mercBounds")}setCompiled(P){if(pt(P)){this.applyModernState(gt(P));return}this.applyLegacyState(mt(P))}applyModernState(P){this.points=P.points,this.pointsWeightBuffer=P.pointsWeightBuffer,this.strict_status=P.strictStatus,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.edges=P.edges,this.edgeNodes=P.edgeNodes||[],this.tins=P.tins,this.addIndexedTin(),this.kinks=P.kinks,this.yaxisMode=P.yaxisMode??se.YAXIS_INVERT,this.vertexMode=P.vertexMode??se.VERTEX_PLAIN,this.strictMode=P.strictMode??se.MODE_AUTO,P.bounds?(this.bounds=P.bounds,this.boundsPolygon=P.boundsPolygon,this.xy=P.xy,this.wh=P.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=P.xy??[0,0],P.wh&&(this.wh=P.wh))}applyLegacyState(P){this.tins=P.tins,this.addIndexedTin(),this.strict_status=P.strictStatus,this.pointsWeightBuffer=P.pointsWeightBuffer,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.kinks=P.kinks,this.points=P.points}addIndexedTin(){const P=this.tins,C=P.forw,$=P.bakw,tt=Math.ceil(Math.sqrt(C.features.length));if(tt<3){this.indexedTins=void 0;return}let G=[],et=[];const st=C.features.map(nt=>{let H=[];return g(nt)[0].map(W=>{G.length===0?G=[Array.from(W),Array.from(W)]:(W[0]<G[0][0]&&(G[0][0]=W[0]),W[0]>G[1][0]&&(G[1][0]=W[0]),W[1]<G[0][1]&&(G[0][1]=W[1]),W[1]>G[1][1]&&(G[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),it=(G[1][0]-G[0][0])/tt,at=(G[1][1]-G[0][1])/tt,ft=st.reduce((nt,H,W)=>{const wt=B(H[0][0],G[0][0],it,tt),At=B(H[1][0],G[0][0],it,tt),Ot=B(H[0][1],G[0][1],at,tt),Xt=B(H[1][1],G[0][1],at,tt);for(let vt=wt;vt<=At;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=Ot;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(W)}return nt},[]),J=$.features.map(nt=>{let H=[];return g(nt)[0].map(W=>{et.length===0?et=[Array.from(W),Array.from(W)]:(W[0]<et[0][0]&&(et[0][0]=W[0]),W[0]>et[1][0]&&(et[1][0]=W[0]),W[1]<et[0][1]&&(et[0][1]=W[1]),W[1]>et[1][1]&&(et[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),Z=(et[1][0]-et[0][0])/tt,lt=(et[1][1]-et[0][1])/tt,xt=J.reduce((nt,H,W)=>{const wt=B(H[0][0],et[0][0],Z,tt),At=B(H[1][0],et[0][0],Z,tt),Ot=B(H[0][1],et[0][1],lt,tt),Xt=B(H[1][1],et[0][1],lt,tt);for(let vt=wt;vt<=At;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=Ot;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(W)}return nt},[]);this.indexedTins={forw:{gridNum:tt,xOrigin:G[0][0],yOrigin:G[0][1],xUnit:it,yUnit:at,gridCache:ft},bakw:{gridNum:tt,xOrigin:et[0][0],yOrigin:et[0][1],xUnit:Z,yUnit:lt,gridCache:xt}}}transform(P,C,$){if(C&&this.strict_status==se.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==se.YAXIS_FOLLOW&&C&&(P=[P[0],-1*P[1]]);const tt=a(P);if(this.bounds&&!C&&!$&&!E(tt,this.boundsPolygon))return!1;const G=C?this.tins.bakw:this.tins.forw,et=C?this.indexedTins.bakw:this.indexedTins.forw,st=C?this.vertices_params.bakw:this.vertices_params.forw,it=C?this.centroid.bakw:this.centroid.forw,at=C?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let ft,J;this.stateFull&&(this.stateBackward==C?ft=this.stateTriangle:(this.stateBackward=C,this.stateTriangle=void 0),J=lt=>{this.stateTriangle=lt});let Z=w(tt,G,et,st,it,at,ft,J);if(this.bounds&&C&&!$){const lt=a(Z);if(!E(lt,this.boundsPolygon))return!1}else this.yaxisMode==se.YAXIS_FOLLOW&&!C&&(Z=[Z[0],-1*Z[1]]);return Z}};n(zt,"VERTEX_PLAIN","plain"),n(zt,"VERTEX_BIRDEYE","birdeye"),n(zt,"MODE_STRICT","strict"),n(zt,"MODE_AUTO","auto"),n(zt,"MODE_LOOSE","loose"),n(zt,"STATUS_STRICT","strict"),n(zt,"STATUS_ERROR","strict_error"),n(zt,"STATUS_LOOSE","loose"),n(zt,"YAXIS_FOLLOW","follow"),n(zt,"YAXIS_INVERT","invert");let We=zt;t.Transform=We,t.counterTri=Q,t.format_version=mn,t.normalizeEdges=U,t.rotateVerticesTriangle=z,t.transformArr=w,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}))})(Ee,Ee.exports)),Ee.exports}var Jt=Lr();const Rn=Math.pow(2,-52),je=new Uint32Array(512);class sn{static from(e,t=Ur,r=zr){const i=e.length,n=new Float64Array(i*2);for(let s=0;s<i;s++){const a=e[s];n[2*s]=t(a),n[2*s+1]=r(a)}return new sn(n)}constructor(e){const t=e.length>>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const r=Math.max(2*t-5,0);this._triangles=new Uint32Array(r*3),this._halfedges=new Int32Array(r*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:r,_hullTri:i,_hullHash:n}=this,s=e.length>>1;let a=1/0,c=1/0,h=-1/0,u=-1/0;for(let S=0;S<s;S++){const O=e[2*S],X=e[2*S+1];O<a&&(a=O),X<c&&(c=X),O>h&&(h=O),X>u&&(u=X),this._ids[S]=S}const f=(a+h)/2,g=(c+u)/2;let m,x,b;for(let S=0,O=1/0;S<s;S++){const X=on(f,g,e[2*S],e[2*S+1]);X<O&&(m=S,O=X)}const R=e[2*m],Y=e[2*m+1];for(let S=0,O=1/0;S<s;S++){if(S===m)continue;const X=on(R,Y,e[2*S],e[2*S+1]);X<O&&X>0&&(x=S,O=X)}let p=e[2*x],y=e[2*x+1],l=1/0;for(let S=0;S<s;S++){if(S===m||S===x)continue;const O=jr(R,Y,p,y,e[2*S],e[2*S+1]);O<l&&(b=S,l=O)}let v=e[2*b],M=e[2*b+1];if(l===1/0){for(let X=0;X<s;X++)this._dists[X]=e[2*X]-e[0]||e[2*X+1]-e[1];_e(this._ids,this._dists,0,s-1);const S=new Uint32Array(s);let O=0;for(let X=0,L=-1/0;X<s;X++){const K=this._ids[X],d=this._dists[K];d>L&&(S[O++]=K,L=d)}this.hull=S.subarray(0,O),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(te(R,Y,p,y,v,M)<0){const S=x,O=p,X=y;x=b,p=v,y=M,b=S,v=O,M=X}const A=qr(R,Y,p,y,v,M);this._cx=A.x,this._cy=A.y;for(let S=0;S<s;S++)this._dists[S]=on(e[2*S],e[2*S+1],A.x,A.y);_e(this._ids,this._dists,0,s-1),this._hullStart=m;let T=3;r[m]=t[b]=x,r[x]=t[m]=b,r[b]=t[x]=m,i[m]=0,i[x]=1,i[b]=2,n.fill(-1),n[this._hashKey(R,Y)]=m,n[this._hashKey(p,y)]=x,n[this._hashKey(v,M)]=b,this.trianglesLen=0,this._addTriangle(m,x,b,-1,-1,-1);for(let S=0,O,X;S<this._ids.length;S++){const L=this._ids[S],K=e[2*L],d=e[2*L+1];if(S>0&&Math.abs(K-O)<=Rn&&Math.abs(d-X)<=Rn||(O=K,X=d,L===m||L===x||L===b))continue;let E=0;for(let w=0,B=this._hashKey(K,d);w<this._hashSize&&(E=n[(B+w)%this._hashSize],!(E!==-1&&E!==r[E]));w++);E=t[E];let _=E,I;for(;I=r[_],te(K,d,e[2*_],e[2*_+1],e[2*I],e[2*I+1])>=0;)if(_=I,_===E){_=-1;break}if(_===-1)continue;let N=this._addTriangle(_,L,r[_],-1,-1,i[_]);i[L]=this._legalize(N+2),i[_]=N,T++;let D=r[_];for(;I=r[D],te(K,d,e[2*D],e[2*D+1],e[2*I],e[2*I+1])<0;)N=this._addTriangle(D,L,I,i[L],-1,i[D]),i[L]=this._legalize(N+2),r[D]=D,T--,D=I;if(_===E)for(;I=t[_],te(K,d,e[2*I],e[2*I+1],e[2*_],e[2*_+1])<0;)N=this._addTriangle(I,L,_,-1,i[_],i[I]),this._legalize(N+2),i[I]=N,r[_]=_,T--,_=I;this._hullStart=t[L]=_,r[_]=t[D]=L,r[L]=D,n[this._hashKey(K,d)]=L,n[this._hashKey(e[2*_],e[2*_+1])]=_}this.hull=new Uint32Array(T);for(let S=0,O=this._hullStart;S<T;S++)this.hull[S]=O,O=r[O];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(Dr(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:r,coords:i}=this;let n=0,s=0;for(;;){const a=r[e],c=e-e%3;if(s=c+(e+2)%3,a===-1){if(n===0)break;e=je[--n];continue}const h=a-a%3,u=c+(e+1)%3,f=h+(a+2)%3,g=t[s],m=t[e],x=t[u],b=t[f];if($r(i[2*g],i[2*g+1],i[2*m],i[2*m+1],i[2*x],i[2*x+1],i[2*b],i[2*b+1])){t[e]=b,t[a]=g;const Y=r[f];if(Y===-1){let y=this._hullStart;do{if(this._hullTri[y]===f){this._hullTri[y]=e;break}y=this._hullPrev[y]}while(y!==this._hullStart)}this._link(e,Y),this._link(a,r[s]),this._link(s,f);const p=h+(a+1)%3;n<je.length&&(je[n++]=p)}else{if(n===0)break;e=je[--n]}}return s}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,r,i,n,s){const a=this.trianglesLen;return this._triangles[a]=e,this._triangles[a+1]=t,this._triangles[a+2]=r,this._link(a,i),this._link(a+1,n),this._link(a+2,s),this.trianglesLen+=3,a}}function Dr(o,e){const t=o/(Math.abs(o)+Math.abs(e));return(e>0?3-t:1+t)/4}function on(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function $r(o,e,t,r,i,n,s,a){const c=o-s,h=e-a,u=t-s,f=r-a,g=i-s,m=n-a,x=c*c+h*h,b=u*u+f*f,R=g*g+m*m;return c*(f*R-b*m)-h*(u*R-b*g)+x*(u*m-f*g)<0}function jr(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,h=n-e,u=s*s+a*a,f=c*c+h*h,g=.5/(s*h-a*c),m=(h*u-a*f)*g,x=(s*f-c*u)*g;return m*m+x*x}function qr(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,h=n-e,u=s*s+a*a,f=c*c+h*h,g=.5/(s*h-a*c),m=o+(h*u-a*f)*g,x=e+(s*f-c*u)*g;return{x:m,y:x}}function _e(o,e,t,r){if(r-t<=20)for(let i=t+1;i<=r;i++){const n=o[i],s=e[n];let a=i-1;for(;a>=t&&e[o[a]]>s;)o[a+1]=o[a--];o[a+1]=n}else{const i=t+r>>1;let n=t+1,s=r;Ae(o,i,n),e[o[t]]>e[o[r]]&&Ae(o,t,r),e[o[n]]>e[o[r]]&&Ae(o,n,r),e[o[t]]>e[o[n]]&&Ae(o,t,n);const a=o[n],c=e[a];for(;;){do n++;while(e[o[n]]<c);do s--;while(e[o[s]]>c);if(s<n)break;Ae(o,n,s)}o[t+1]=o[s],o[s]=a,r-n+1>=s-t?(_e(o,e,n,r),_e(o,e,t,s-1)):(_e(o,e,t,s-1),_e(o,e,n,r))}}function Ae(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function Ur(o){return o[0]}function zr(o){return o[1]}class Vr{constructor(e,t){_t(this,"bs");_t(this,"width");this.width=e,this.bs=t}add(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]|=1<<r,this}delete(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]&=~(1<<r),this}set(e,t){const r=Math.floor(e/this.width),n=1<<e%this.width;return this.bs[r]^=(-Number(t)^this.bs[r])&n,t}has(e){const t=Math.floor(e/this.width),r=e%this.width;return(this.bs[t]&1<<r)!==0}forEach(e){const t=this.bs.length;for(let r=0;r<t;r++){let i=0;for(;this.bs[r]&&i<this.width;)this.bs[r]&1<<i&&e(r*this.width+i),i++}return this}}class Yn extends Vr{constructor(e){super(8,new Uint8Array(Math.ceil(e/8)).fill(0))}}function ge(o){return o%3===2?o-2:o+1}function oe(o){return o%3===0?o+2:o-1}function Cn(o,e,t,r,i,n,s,a){const c=te(o,e,i,n,s,a),h=te(t,r,i,n,s,a);if(c>0&&h>0||c<0&&h<0)return!1;const u=te(i,n,o,e,t,r),f=te(s,a,o,e,t,r);return u>0&&f>0||u<0&&f<0?!1:c===0&&h===0&&u===0&&f===0?!(Math.max(i,s)<Math.min(o,t)||Math.max(o,t)<Math.min(i,s)||Math.max(n,a)<Math.min(e,r)||Math.max(e,r)<Math.min(n,a)):!0}class Wr{constructor(e){_t(this,"del");this.del=e}}class Fn extends Wr{constructor(t,r){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);_t(this,"vertMap");_t(this,"flips");_t(this,"consd");const i=2**32-1,n=t.coords.length>>1,s=t.triangles.length;this.vertMap=new Uint32Array(n).fill(i),this.flips=new Yn(s),this.consd=new Yn(s);for(let a=0;a<s;a++){const c=t.triangles[a];this.vertMap[c]===i&&this.updateVert(a)}r&&this.constrainAll(r)}constrainOne(t,r){const{triangles:i,halfedges:n}=this.del,s=this.vertMap[t];let a=s;do{const u=i[a],f=ge(a);if(u===r)return this.protect(a);const g=oe(a),m=i[g];if(m===r)return this.protect(f),f;if(this.intersectSegments(t,r,m,u)){a=g;break}a=n[f]}while(a!==-1&&a!==s);let c=a,h=-1;for(;a!==-1;){const u=n[a],f=oe(a),g=oe(u),m=ge(u);if(u===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(a))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,r,i[a])||this.isCollinear(t,r,i[u]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[a],i[u],i[f],i[g])){if(h===-1&&(h=a),i[g]===r){if(a===h)throw new Error("Infinite loop: non-convex quadrilateral");a=h,h=-1;continue}if(this.intersectSegments(t,r,i[g],i[u]))a=g;else if(this.intersectSegments(t,r,i[m],i[g]))a=m;else if(h===a)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(a),this.intersectSegments(t,r,i[f],i[g])&&(h===-1&&(h=f),h===f))throw new Error("Infinite loop: flipped diagonal still intersects");i[g]===r?(c=g,a=h,h=-1):this.intersectSegments(t,r,i[m],i[g])&&(a=m)}return this.protect(c),this.delaunify(!0),this.findEdge(t,r)}delaunify(t=!1){const{halfedges:r}=this.del,i=this.flips,n=this.consd,s=r.length;let a;do{a=0;for(let c=0;c<s;c++){if(n.has(c))continue;i.delete(c);const h=r[c];h!==-1&&(i.delete(h),this.isDelaunay(c)||(this.flipDiagonal(c),a++))}}while(t&&a>0);return this}constrainAll(t){const r=t.length;for(let i=0;i<r;i++){const n=t[i];this.constrainOne(n[0],n[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,r){const i=this.vertMap[r],{triangles:n,halfedges:s}=this.del;let a=i,c=-1;do{if(n[a]===t)return a;c=ge(a),a=s[c]}while(a!==-1&&a!==i);return n[ge(c)]===t?-c:1/0}protect(t){const r=this.del.halfedges[t],i=this.flips,n=this.consd;return i.delete(t),n.add(t),r!==-1?(i.delete(r),n.add(r),r):-t}markFlip(t){const r=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const s=r[t];return s!==-1&&(i.add(t),i.add(s)),!0}flipDiagonal(t){const{triangles:r,halfedges:i}=this.del,n=this.flips,s=this.consd,a=i[t],c=oe(t),h=ge(t),u=oe(a),f=ge(a),g=i[c],m=i[u];if(s.has(t))throw new Error("Trying to flip a constrained edge");return r[t]=r[u],i[t]=m,n.set(t,n.has(u))||s.set(t,s.has(u)),m!==-1&&(i[m]=t),i[c]=u,r[a]=r[c],i[a]=g,n.set(a,n.has(c))||s.set(a,s.has(c)),g!==-1&&(i[g]=a),i[u]=c,this.markFlip(t),this.markFlip(h),this.markFlip(a),this.markFlip(f),n.add(c),s.delete(c),n.add(u),s.delete(u),this.updateVert(t),this.updateVert(h),this.updateVert(a),this.updateVert(f),c}isCollinear(t,r,i){const n=this.del.coords;return te(n[t*2],n[t*2+1],n[r*2],n[r*2+1],n[i*2],n[i*2+1])===0}inCircle(t,r,i,n){const s=this.del.coords;return hr(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])<0}isDelaunay(t){const{triangles:r,halfedges:i}=this.del,n=i[t];if(n===-1)return!0;const s=r[oe(t)],a=r[t],c=r[ge(t)],h=r[oe(n)];return!this.inCircle(s,a,c,h)}updateVert(t){const{triangles:r,halfedges:i}=this.del,n=this.vertMap,s=r[t];let a=oe(t),c=i[a];for(;c!==-1&&c!==t;)a=oe(c),c=i[a];return n[s]=a,a}intersectSegments(t,r,i,n){const s=this.del.coords;return t===i||t===n||r===i||r===n?!1:Cn(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])}}_t(Fn,"intersectSegments",Cn);function Oe(o,e,t){if(e||(e=[]),typeof o!="object"||o.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(e))throw"Argument points must be Array of Array";const r=o.features.map(c=>c.geometry.coordinates),i=sn.from(r);let n;const s=[];i.triangles.length!==0&&e.length!==0&&(n=new Fn(i),n.constrainAll(e));for(let c=0;c<i.triangles.length;c+=3)s.push([i.triangles[c],i.triangles[c+1],i.triangles[c+2]]);const a=["a","b","c"];return Kt(s.map(c=>{const h={},u=c.map((f,g)=>{const m=o.features[f],x=m.geometry.coordinates,b=[x[0],x[1]];return x.length===3?b[2]=x[2]:h[a[g]]=m.properties[t],b});return u[3]=u[0],Me([u],h)}))}function Ln(o,e,t,r,i,n){return Object.keys(o).reduce((s,a)=>{const c=o[a],h=c.forw,u=c.bakw,f={forw:[h[0]-e.forw[0],h[1]-e.forw[1]],bakw:[u[0]-e.bakw[0],u[1]-e.bakw[1]]},g=f.forw[0]===0?1/0:((f.forw[0]<0?t:r)-e.forw[0])/f.forw[0],m=f.forw[1]===0?1/0:((f.forw[1]<0?i:n)-e.forw[1])/f.forw[1];if(Math.abs(g)/Math.abs(m)<1.1){const x={forw:[f.forw[0]*g+e.forw[0],f.forw[1]*g+e.forw[1]],bakw:[f.bakw[0]*g+e.bakw[0],f.bakw[1]*g+e.bakw[1]]};f.forw[0]<0?s[3].push(x):s[1].push(x)}if(Math.abs(m)/Math.abs(g)<1.1){const x={forw:[f.forw[0]*m+e.forw[0],f.forw[1]*m+e.forw[1]],bakw:[f.bakw[0]*m+e.bakw[0],f.bakw[1]*m+e.bakw[1]]};f.forw[1]<0?s[0].push(x):s[2].push(x)}return s},[[],[],[],[]])}function Jr(o,e){const t=[[],[],[],[]],r=[];return Object.keys(o).forEach(i=>{const n=o[i],s=n.forw,a=n.bakw,c=[s[0]-e.forw[0],s[1]-e.forw[1]],h=[a[0]-e.bakw[0],e.bakw[1]-a[1]],u={forw:c,bakw:h};if(r.push(u),c[0]===0||c[1]===0)return;let f=0;c[0]>0&&(f+=1),c[1]>0&&(f+=2),t[f].push(u)}),{perQuad:t,aggregate:r}}function Kr(o){let e=1/0,t=0,r=0;return o.forEach(i=>{const{forw:n,bakw:s}=i,a=Math.hypot(n[0],n[1]),c=Math.hypot(s[0],s[1]);if(c===0)return;const h=a/c,u=Math.atan2(n[0],n[1])-Math.atan2(s[0],s[1]);e=Math.min(e,h),t+=Math.cos(u),r+=Math.sin(u)}),isFinite(e)?[e,Math.atan2(r,t)]:[1,0]}function Dn(o,e,t){const{perQuad:r,aggregate:i}=Jr(o,e),n=r.every(c=>c.length>0),a=(t==="birdeye"?n?r:[i]:[i]).map(c=>Kr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Gr(o,e,t){const r=[1,1,1,1];for(let i=0;i<4;i++){const n=(i+1)%4,s=gn([o[i].bakw,o[n].bakw]);e[i].map(a=>{const c=gn([t.bakw,a.bakw]),h=_r(s,c);if(h.features.length>0&&h.features[0].geometry){const u=h.features[0],f=Math.sqrt(Math.pow(a.bakw[0]-t.bakw[0],2)+Math.pow(a.bakw[1]-t.bakw[1],2)),g=Math.sqrt(Math.pow(u.geometry.coordinates[0]-t.bakw[0],2)+Math.pow(u.geometry.coordinates[1]-t.bakw[1],2)),m=f/g;m>r[i]&&(r[i]=m),m>r[n]&&(r[n]=m)}})}o.forEach((i,n)=>{const s=r[n],a=[(i.bakw[0]-t.bakw[0])*s+t.bakw[0],(i.bakw[1]-t.bakw[1])*s+t.bakw[1]];i.bakw=a})}function $n(o,e,t,r){const i=o.map((s,a)=>{const c=e[a],h=[c[0]-t.forw[0],c[1]-t.forw[1]],f=Math.sqrt(Math.pow(h[0],2)+Math.pow(h[1],2))/s[0],g=Math.atan2(h[0],h[1])-s[1],m=[t.bakw[0]+f*Math.sin(g),t.bakw[1]-f*Math.cos(g)];return{forw:c,bakw:m}}),n=i[2];return i[2]=i[3],i[3]=n,Gr(i,r,t),i}function Qr(o){const{convexBuf:e,centroid:t,bbox:r,minx:i,maxx:n,miny:s,maxy:a}=o,c=Ln(e,t,i,n,s,a),h=Dn(e,t,"plain");return $n(h,r,t,c)}function Hr(o){const{convexBuf:e,centroid:t,bbox:r,minx:i,maxx:n,miny:s,maxy:a}=o,c=Ln(e,t,i,n,s,a),h=Dn(e,t,"birdeye");return $n(h,r,t,c)}function jn(o){const t=new Zr(o).findSegmentIntersections(),r=Jn(t),i=new Map;return r.forEach(n=>{i.set(`${n.x}:${n.y}`,n)}),Array.from(i.values()).map(n=>Vt([n.x,n.y]))}class Zr{constructor(e){_t(this,"_xx");_t(this,"_yy");_t(this,"_ii");_t(this,"_nn");_t(this,"_zz",null);_t(this,"_zlimit",0);_t(this,"_bb",null);_t(this,"_allBounds",null);_t(this,"_arcIter",null);_t(this,"_filteredArcIter",null);_t(this,"buf");this.initArcs(e)}initArcs(e){const t=[],r=[],i=e.map(n=>{const s=n?n.length:0;for(let a=0;a<s;a++)t.push(n[a][0]),r.push(n[a][1]);return s});this.initXYData(i,t,r)}initXYData(e,t,r){const i=e.length;this._xx=new Float64Array(t),this._yy=new Float64Array(r),this._nn=new Uint32Array(e),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(i);let n=0;for(let s=0;s<i;s++)this._ii[s]=n,n+=e[s];(n!=this._xx.length||this._xx.length!=this._yy.length)&&an("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new vi(this._xx,this._yy)}initBounds(){const e=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=e.bb,this._allBounds=e.bounds}calcArcBounds_(e,t,r){const i=r.length,n=new Float64Array(i*4),s=new Pe;let a=0,c,h,u;for(let f=0;f<i;f++)c=r[f],c>0&&(h=f*4,u=bi(e,t,a,c),n[h++]=u[0],n[h++]=u[1],n[h++]=u[2],n[h]=u[3],a+=c,s.mergeBounds(u));return{bb:n,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new Pe}forEachSegment(e){let t=0;for(let r=0,i=this.size();r<i;r++)t+=this.forEachArcSegment(r,e);return t}size(){return this._ii&&this._ii.length||0}forEachArcSegment(e,t){const r=e>=0,i=r?e:~e,n=this.getRetainedInterval(),s=this._nn[i],a=r?1:-1;let c=r?this._ii[i]:this._ii[i]+s-1,h=c,u=0;for(let f=1;f<s;f++)h+=a,(n===0||this._zz[h]>=n)&&(t(c,h,this._xx,this._yy),c=h,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(e){const t=e*4;return(!this.buf||this.buf.byteLength<t)&&(this.buf=new ArrayBuffer(t)),new Uint32Array(this.buf,0,e)}getAvgSegment2(){let e=0,t=0;const r=this.forEachSegment((i,n,s,a)=>{e+=Math.abs(s[i]-s[n]),t+=Math.abs(a[i]-a[n])});return[e/r||0,t/r||0]}calcSegmentIntersectionStripeCount(){const e=this.getBounds().height(),t=this.getAvgSegment2()[1];let r=1;return t>0&&e>0&&(r=Math.ceil(e/t/20)),r||1}findSegmentIntersections(){const e=this.getBounds(),t=e.ymin||0,r=(e.ymax||0)-t,i=this.calcSegmentIntersectionStripeCount(),n=new Uint32Array(i),s=i>1?b=>Math.floor((i-1)*(b-t)/r):()=>0;let a,c;this.forEachSegment((b,R,Y,p)=>{let y=s(p[b]);const l=s(p[R]);for(;n[y]=n[y]+2,y!=l;)y+=l>y?1:-1});const h=this.getUint32Array(ni(n));let u=0;const f=[];ri(n,b=>{const R=u;u+=b,f.push(h.subarray(R,u))}),ii(n,0),this.forEachSegment((b,R,Y,p)=>{let y=s(p[b]);const l=s(p[R]);let v,M;for(;v=n[y],n[y]=v+2,M=f[y],M[v]=b,M[v+1]=R,y!=l;)y+=l>y?1:-1});const g=this.getVertexData(),m=[];let x;for(a=0;a<i;a++)if(g.xx&&g.yy)for(x=si(f[a],g.xx,g.yy),c=0;c<x.length;c++)m.push(x[c]);return Jn(m)}}function an(...o){const e=o.join(" ");throw new Error(e)}function cn(o){return o?ei(o)?!0:ti(o)?!1:o.length===0?!0:o.length>0:!1}function ti(o){return o!=null&&o.toString===String.prototype.toString}function ei(o){return Array.isArray(o)}function ni(o,e){cn(o)||an("utils.sum() expects an array, received:",o);let t=0,r;for(let i=0,n=o.length;i<n;i++)r=o[i],r&&(t+=r);return t}function ri(o,e,t){if(!cn(o))throw new Error(`#forEach() takes an array-like argument. ${o}`);for(let r=0,i=o.length;r<i;r++)e.call(t,o[r],r)}function ii(o,e){for(let t=0,r=o.length;t<r;t++)o[t]=e;return o}function si(o,e,t){const r=o.length-2,i=[];let n,s,a,c,h,u,f,g,m,x,b,R,Y,p,y,l,v;for(mi(e,o),l=0;l<r;){for(n=o[l],s=o[l+1],h=e[n],u=e[s],m=t[n],x=t[s],v=l;v<r&&(v+=2,a=o[v],f=e[a],!(u<f));){if(b=t[a],c=o[v+1],g=e[c],R=t[c],m>=b){if(m>R&&x>b&&x>R)continue}else if(m<R&&x<b&&x<R)continue;n==a||n==c||s==a||s==c||(Y=oi(h,m,u,x,f,b,g,R),Y&&(p=[n,s],y=[a,c],i.push(Vn(Y,p,y,e,t)),Y.length==4&&i.push(Vn(Y.slice(2),p,y,e,t))))}l+=2}return i}function oi(o,e,t,r,i,n,s,a){const c=ai(o,e,t,r,i,n,s,a);let h=null;return c&&(h=ci(o,e,t,r,i,n,s,a),h?pi(o,e,t,r,i,n,s,a)&&(h=null):h=di(o,e,t,r,i,n,s,a)),h}function ai(o,e,t,r,i,n,s,a){return Be(o,e,t,r,i,n)*Be(o,e,t,r,s,a)<=0&&Be(i,n,s,a,o,e)*Be(i,n,s,a,t,r)<=0}function Be(o,e,t,r,i,n){return qn(o-i,e-n,t-i,r-n)}function qn(o,e,t,r){return o*r-e*t}function ci(o,e,t,r,i,n,s,a){let c=qe(o,e,t,r,i,n,s,a),h;return c&&(h=fi(c[0],c[1],o,e,t,r,i,n,s,a),h==1?c=qe(t,r,o,e,i,n,s,a):h==2?c=qe(i,n,s,a,o,e,t,r):h==3&&(c=qe(s,a,i,n,o,e,t,r))),c&&li(c,o,e,t,r,i,n,s,a),c}function qe(o,e,t,r,i,n,s,a){const c=qn(t-o,r-e,s-i,a-n),h=1e-18;let u;if(c===0)return null;const f=Be(i,n,s,a,o,e)/c;return c<=h&&c>=-h?u=hi(o,e,t,r,i,n,s,a):u=[o+f*(t-o),e+f*(r-e)],u}function hi(o,e,t,r,i,n,s,a){let c=null;return!ae(o,i,s)&&!ae(e,n,a)?c=[o,e]:!ae(t,i,s)&&!ae(r,n,a)?c=[t,r]:!ae(i,o,t)&&!ae(n,e,r)?c=[i,n]:!ae(s,o,t)&&!ae(a,e,r)&&(c=[s,a]),c}function ae(o,e,t){let r;return e<t?r=o<e||o>t:e>t?r=o>e||o<t:r=o!=e,r}function fi(o,e,...t){let r=-1,i=1/0,n;for(let s=0,a=0,c=t.length;a<c;s++,a+=2)n=ui(o,e,t[a],t[a+1]),n<i&&(i=n,r=s);return r}function ui(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function li(o,e,t,r,i,n,s,a,c){let h=o[0],u=o[1];h=Ue(h,e,r),h=Ue(h,n,a),u=Ue(u,t,i),u=Ue(u,s,c),o[0]=h,o[1]=u}function Ue(o,e,t){let r;return ae(o,e,t)&&(r=Math.abs(o-e)<Math.abs(o-t)?e:t,o=r),o}function di(o,e,t,r,i,n,s,a){const c=Math.min(o,t,i,s),h=Math.max(o,t,i,s),u=Math.min(e,r,n,a),f=Math.max(e,r,n,a),g=f-u>h-c;let m=[];return(g?le(e,u,f):le(o,c,h))&&m.push(o,e),(g?le(r,u,f):le(t,c,h))&&m.push(t,r),(g?le(n,u,f):le(i,c,h))&&m.push(i,n),(g?le(a,u,f):le(s,c,h))&&m.push(s,a),(m.length!=2&&m.length!=4||m.length==4&&m[0]==m[2]&&m[1]==m[3])&&(m=null),m}function pi(o,e,t,r,i,n,s,a){return o==i&&e==n||o==s&&e==a||t==i&&r==n||t==s&&r==a}function le(o,e,t){return o>e&&o<t}function mi(o,e){gi(o,e),Un(o,e,0,e.length-2)}function gi(o,e){for(let t=0,r=e.length;t<r;t+=2)o[e[t]]>o[e[t+1]]&&wi(e,t,t+1)}function wi(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function Un(o,e,t,r){let i=t,n=r,s,a;for(;i<r;){for(s=o[e[t+r>>2<<1]];i<=n;){for(;o[e[i]]<s;)i+=2;for(;o[e[n]]>s;)n-=2;i<=n&&(a=e[i],e[i]=e[n],e[n]=a,a=e[i+1],e[i+1]=e[n+1],e[n+1]=a,i+=2,n-=2)}if(n-t<40?zn(o,e,t,n):Un(o,e,t,n),r-i<40){zn(o,e,i,r);return}t=i,n=r}}function zn(o,e,t,r){let i,n;for(let s=t+2;s<=r;s+=2){i=e[s],n=e[s+1];let a;for(a=s-2;a>=t&&o[i]<o[e[a]];a-=2)e[a+2]=e[a],e[a+3]=e[a+1];e[a+2]=i,e[a+3]=n}}function Vn(o,e,t,r,i){const n=o[0],s=o[1];e=Wn(n,s,e[0],e[1],r,i),t=Wn(n,s,t[0],t[1],r,i);const a=e[0]<t[0]?e:t,c=a==e?t:e;return{x:n,y:s,a,b:c}}function Wn(o,e,t,r,i,n){let s=t<r?t:r,a=s===t?r:t;return i[s]==o&&n[s]==e?a=s:i[a]==o&&n[a]==e&&(s=a),[s,a]}function Jn(o){const e={};return o.filter(t=>{const r=yi(t);return r in e?!1:(e[r]=!0,!0)})}function yi(o){return`${o.a.join(",")};${o.b.join(",")}`}class vi{constructor(e,t){_t(this,"_i",0);_t(this,"_n",0);_t(this,"_inc",1);_t(this,"_xx");_t(this,"_yy");_t(this,"i",0);_t(this,"x",0);_t(this,"y",0);this._xx=e,this._yy=t}}function bi(o,e,t,r){let i=t|0;const n=isNaN(r)?o.length-i:r+i;let s,a,c,h,u,f;if(n>0)c=u=o[i],h=f=e[i];else return[void 0,void 0,void 0,void 0];for(i++;i<n;i++)s=o[i],a=e[i],s<c&&(c=s),s>u&&(u=s),a<h&&(h=a),a>f&&(f=a);return[c,h,u,f]}class Pe{constructor(...e){_t(this,"xmin");_t(this,"ymin");_t(this,"xmax");_t(this,"ymax");e.length>0&&this.setBounds(e)}cloneBounds(){return this.clone()}clone(){return new Pe(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(e,t,r,i){let n,s,a,c;if(arguments.length==1)if(cn(e)){const h=e;n=h[0],s=h[1],a=h[2],c=h[3]}else{const h=e;n=h.xmin,s=h.ymin,a=h.xmax,c=h.ymax}else n=e,s=t,a=r,c=i;return this.xmin=n,this.ymin=s,this.xmax=a,this.ymax=c,(n>a||s>c)&&this.update(),this}update(){let e;this.xmin>this.xmax&&(e=this.xmin,this.xmin=this.xmax,this.xmax=e),this.ymin>this.ymax&&(e=this.ymin,this.ymin=this.ymax,this.ymax=e)}mergeBounds(e,...t){let r,i,n,s;return e instanceof Pe?(r=e.xmin,i=e.ymin,n=e.xmax,s=e.ymax):t.length==3?(r=e,i=t[0],n=t[1],s=t[2]):e.length==4?(r=e[0],i=e[1],n=e[2],s=e[3]):an("Bounds#mergeBounds() invalid argument:",e),this.xmin===void 0?this.setBounds(r,i,n,s):(r<this.xmin&&(this.xmin=r),i<this.ymin&&(this.ymin=i),n>this.xmax&&(this.xmax=n),s>this.ymax&&(this.ymax=s)),this}}function ze(o){const e=["a","b","c"].map(t=>o.properties[t].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(t=>t.map(r=>e[r]).sort().join("-")).sort()}function hn(o,e,t){const r=ze(e.forw),i=ze(e.bakw);if(JSON.stringify(r)!=JSON.stringify(i))throw`${JSON.stringify(e,null,2)}
|
|
2
|
+
${JSON.stringify(r)}
|
|
3
|
+
${JSON.stringify(i)}`;for(let n=0;n<r.length;n++){const s=r[n];o[s]||(o[s]=[]),o[s].push(e)}t&&(t.forw.features.push(e.forw),t.bakw.features.push(e.bakw))}function Kn(o,e,t){const r=ze(e.forw),i=ze(e.bakw);if(JSON.stringify(r)!=JSON.stringify(i))throw`${JSON.stringify(e,null,2)}
|
|
4
|
+
${JSON.stringify(r)}
|
|
5
|
+
${JSON.stringify(i)}`;if(r.forEach(n=>{const s=o[n];if(!s)return;const a=s.filter(c=>c!==e);a.length===0?delete o[n]:o[n]=a}),t){const n=(s,a)=>{!s||!a||(s.features=s.features.filter(c=>c!==a))};n(t.forw,e.forw),n(t.bakw,e.bakw)}}function Ie(o,e,t){return Vt(o,{target:{geom:e,index:t}})}function Te(o){return Vt(o.properties.target.geom,{target:{geom:o.geometry.coordinates,index:o.properties.target.index}})}function fn(o,e){const t=e.geometry.coordinates;return[0,1,2,3].map(r=>{const i=(r+1)%4,n=o[r],s=o[i],a=n.geometry.coordinates,c=Math.atan2(a[0]-t[0],a[1]-t[1]),h=[e,n,s,e].map(g=>g.geometry.coordinates),u={a:{geom:e.properties.target.geom,index:e.properties.target.index},b:{geom:n.properties.target.geom,index:n.properties.target.index},c:{geom:s.properties.target.geom,index:s.properties.target.index}},f=Kt([Me([h],u)]);return[c,f]}).reduce((r,i)=>(r[0].push(i[0]),r[1].push(i[1]),r),[[],[]])}function _i(o){const{tins:e,targets:t,includeReciprocals:r}=o,i={};t.forEach(s=>{const a=e[s];if(!a||!a.features)return;i[s]={};const c={};a.features.forEach(h=>{const u=["a","b","c"];for(let f=0;f<3;f++){const g=(f+1)%3,m=u[f],x=u[g],b=h.properties[m].index,R=h.properties[x].index,Y=[b,R].sort().join("-");if(c[Y])continue;c[Y]=!0;const p=h.geometry.coordinates[0][f],y=h.geometry.coordinates[0][g],l=h.properties[m].geom,v=h.properties[x].geom,M=Math.sqrt(Math.pow(l[0]-v[0],2)+Math.pow(l[1]-v[1],2))/Math.sqrt(Math.pow(p[0]-y[0],2)+Math.pow(p[1]-y[1],2)),A=i[s];A[`${b}:${Y}`]=M,A[`${R}:${Y}`]=M}})});const n={};return r&&(n.bakw={}),t.forEach(s=>{const a=i[s];if(n[s]={},!a)return;const c={};Object.keys(a).forEach(u=>{const[f]=u.split(":");c[f]||(c[f]=[]),c[f].push(a[u])}),Object.keys(c).forEach(u=>{const f=c[u],g=f.reduce((m,x)=>m+x,0)/f.length;n[s][u]=g,r&&n.bakw&&(n.bakw[u]=1/g)});let h=0;for(let u=0;u<4;u++){const f=`b${u}`,g=n[s][f]||0;h+=g}n[s].c=h/4,r&&n.bakw&&(n.bakw.c=1/n[s].c)}),n}function xi(o,e){const t=o.split("-");if(t.length!==2||!t.every(n=>/^-?\d+$/.test(n)))return!1;const[r,i]=t.map(n=>parseInt(n,10)).sort((n,s)=>n-s);return e.some(n=>{if(n.length!==2)return!1;const s=n.map(c=>parseInt(`${c}`,10));if(s.some(c=>Number.isNaN(c)))return!1;const a=s.sort((c,h)=>c-h);return a[0]===r&&a[1]===i})}function Ve(o){return["a","b","c"].map((e,t)=>({prop:o.properties[e],geom:o.geometry.coordinates[0][t]}))}function Mi(o,e,t){const r=new Set;let i=!1;const n=Object.keys(e);for(const s of n){if(r.has(s))continue;r.add(s);const a=e[s];if(!a||a.length<2)continue;const c=s.split("-");if(c.length!==2||xi(s,t))continue;const h=Ve(a[0].bakw),u=Ve(a[1].bakw),f=Ve(a[0].forw),g=Ve(a[1].forw),m=c.map(S=>h.find(O=>`${O.prop.index}`===S)||u.find(O=>`${O.prop.index}`===S)),x=c.map(S=>f.find(O=>`${O.prop.index}`===S)||g.find(O=>`${O.prop.index}`===S));if(m.some(S=>!S)||x.some(S=>!S))continue;const b=[h,u].map(S=>S.find(O=>!c.includes(`${O.prop.index}`))),R=[f,g].map(S=>S.find(O=>!c.includes(`${O.prop.index}`)));if(b.some(S=>!S)||R.some(S=>!S))continue;const Y=a[0].bakw.geometry.coordinates[0].slice(0,3).map(S=>xe(S)),p=a[1].bakw.geometry.coordinates[0].slice(0,3).map(S=>xe(S));if(!(Gn(xe(b[0].geom),p)||Gn(xe(b[1].geom),Y)))continue;const l=x.map(S=>xe(S.geom)),v=R.map(S=>xe(S.geom)),M=Si([...l,...v]),A=ki(M),T=Qn(l[0],l[1],v[0])+Qn(l[0],l[1],v[1]);un(A,T)&&(Kn(e,a[0],o),Kn(e,a[1],o),m.forEach(S=>{if(!S)return;const O=[S.geom,b[0].geom,b[1].geom,S.geom],X={a:S.prop,b:b[0].prop,c:b[1].prop},L=Me([O],X),K=Jt.counterTri(L);hn(e,{forw:K,bakw:L},o)}),i=!0)}return i}function xe(o){return[o[0],o[1]]}function Gn(o,e){const[t,r]=e[0],[i,n]=e[1],[s,a]=e[2],c=s-t,h=a-r,u=i-t,f=n-r,g=o[0]-t,m=o[1]-r,x=c*c+h*h,b=c*u+h*f,R=c*g+h*m,Y=u*u+f*f,p=u*g+f*m,y=x*Y-b*b;if(y===0)return!1;const l=1/y,v=(Y*R-b*p)*l,M=(x*p-b*R)*l,A=1e-9;return v>=-A&&M>=-A&&v+M<=1+A}function Si(o){const e=o.map(s=>s.slice()).filter((s,a,c)=>c.findIndex(h=>un(h[0],s[0])&&un(h[1],s[1]))===a);if(e.length<=1)return e;const t=e.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),i=[];for(const s of t){for(;i.length>=2&&r(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}const n=[];for(let s=t.length-1;s>=0;s--){const a=t[s];for(;n.length>=2&&r(n[n.length-2],n[n.length-1],a)<=0;)n.pop();n.push(a)}return n.pop(),i.pop(),i.concat(n)}function ki(o){if(o.length<3)return 0;let e=0;for(let t=0;t<o.length;t++){const[r,i]=o[t],[n,s]=o[(t+1)%o.length];e+=r*s-n*i}return Math.abs(e)/2}function Qn(o,e,t){return Math.abs((o[0]*(e[1]-t[1])+e[0]*(t[1]-o[1])+t[0]*(o[1]-e[1]))/2)}function un(o,e,t=1e-9){return Math.abs(o-e)<=t}const Hn=typeof Jt.format_version<"u"?Jt.format_version:2.00703;class Tt extends Jt.Transform{constructor(t={}){super();_t(this,"importance");_t(this,"priority");_t(this,"pointsSet");t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||Tt.VERTEX_PLAIN),this.strictMode=t.strictMode||Tt.MODE_AUTO,this.yaxisMode=t.yaxisMode||Tt.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return Hn}setPoints(t){this.yaxisMode===Tt.YAXIS_FOLLOW&&(t=t.map(r=>[r[0],[r[1][0],-1*r[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Jt.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let r=t[0][0],i=r,n=t[0][1],s=n;const a=[t[0]];for(let c=1;c<t.length;c++){const h=t[c];h[0]<r&&(r=h[0]),h[0]>i&&(i=h[0]),h[1]<n&&(n=h[1]),h[1]>s&&(s=h[1]),a.push(h)}a.push(t[0]),this.boundsPolygon=Me([a]),this.xy=[r,n],this.wh=[i-r,s-n],this.vertexMode=Tt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){var i;const t={};t.version=Hn,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer??{},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const r=this.vertices_params.forw[1];return r&&[0,1,2,3].map(n=>{const s=r[n].features[0],a=s.geometry.coordinates[0][1],c=s.properties.b.geom;t.vertices_points[n]=[a,c]}),t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(n=>{t.tins_points[0].push(["a","b","c"].map(s=>n.properties[s].index))}),this.strict_status===Tt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(s=>n.properties[s].index))})):this.strict_status===Tt.STATUS_ERROR&&((i=this.kinks)!=null&&i.bakw)&&(t.kinks_points=this.kinks.bakw.features.map(n=>n.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,t.xy=this.xy,t.wh=this.wh):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){var n;const t=this.tins.forw.features.map(s=>Jt.counterTri(s));this.tins.bakw=Kt(t);const r={};this.tins.forw.features.forEach((s,a)=>{const c=this.tins.bakw.features[a];hn(r,{forw:s,bakw:c})}),Mi(this.tins,r,((n=this.pointsSet)==null?void 0:n.edges)||[]);const i=["forw","bakw"].map(s=>{const a=this.tins[s].features.map(c=>c.geometry.coordinates[0]);return jn(a)});i[0].length===0&&i[1].length===0?(this.strict_status=Tt.STATUS_STRICT,delete this.kinks):(this.strict_status=Tt.STATUS_ERROR,this.kinks={forw:Kt(i[0]),bakw:Kt(i[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let n=0;n<this.points.length;n++){const s=this.points[n][0],a=this.points[n][1],c=Ie(s,a,n);t.forw.push(c),t.bakw.push(Te(c))}const r=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let n=0;n<this.edges.length;n++){const s=this.edges[n][2],a=Object.assign([],this.edges[n][0]),c=Object.assign([],this.edges[n][1]);if(a.length===0&&c.length===0){r.push(s);continue}a.unshift(this.points[s[0]][0]),a.push(this.points[s[1]][0]),c.unshift(this.points[s[0]][1]),c.push(this.points[s[1]][1]);const h=[a,c].map(u=>{const f=u.map((m,x,b)=>{if(x===0)return 0;const R=b[x-1];return Math.sqrt(Math.pow(m[0]-R[0],2)+Math.pow(m[1]-R[1],2))}),g=f.reduce((m,x,b)=>b===0?[0]:(m.push(m[b-1]+x),m),[]);return g.map((m,x,b)=>{const R=m/b[b.length-1];return[u[x],f[x],g[x],R]})});h.map((u,f)=>{const g=h[f?0:1];return u.filter((m,x)=>!(x===0||x===u.length-1||m[4]==="handled")).flatMap(m=>{const x=m[0],b=m[3],R=g.reduce((Y,p,y,l)=>{if(Y)return Y;const v=l[y+1];if(p[3]===b)return p[4]="handled",[p];if(p[3]<b&&v&&v[3]>b)return[p,v]},void 0);if(R&&R.length===1)return f===0?[[x,R[0][0],b]]:[[R[0][0],x,b]];if(R&&R.length===2){const Y=R[0],p=R[1],y=(b-Y[3])/(p[3]-Y[3]),l=[(p[0][0]-Y[0][0])*y+Y[0][0],(p[0][1]-Y[0][1])*y+Y[0][1]];return f===0?[[x,l,b]]:[[l,x,b]]}return[]})}).reduce((u,f)=>u.concat(f),[]).sort((u,f)=>u[2]<f[2]?-1:1).map((u,f,g)=>{this.edgeNodes[i]=[u[0],u[1]];const m=Ie(u[0],u[1],`e${i}`);i++,t.forw.push(m),t.bakw.push(Te(m)),f===0?r.push([s[0],t.forw.length-1]):r.push([t.forw.length-2,t.forw.length-1]),f===g.length-1&&r.push([t.forw.length-1,s[1]])})}return{forw:t.forw,bakw:t.bakw,edges:r}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],r=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],n=this.xy[1]+1.05*this.wh[1];if(!this.points.reduce((c,h)=>c&&(this.bounds?ur(h[0],this.boundsPolygon):h[0][0]>=t&&h[0][0]<=r&&h[0][1]>=i&&h[0][1]<=n),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[r,i],[t,n],[r,n]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:r,miny:i,maxy:n}}updateTin(){let t=this.strictMode;t!==Tt.MODE_STRICT&&t!==Tt.MODE_LOOSE&&(t=Tt.MODE_AUTO);const{pointsSet:r,bbox:i,minx:n,maxx:s,miny:a,maxy:c}=this.validateAndPrepareInputs(),h={forw:Kt(r.forw),bakw:Kt(r.bakw)},u=Oe(h.forw,r.edges,"target"),f=Oe(h.bakw,r.edges,"target");if(u.features.length===0||f.features.length===0)throw"TOO LINEAR1";const g=Sr(h.forw),m=Nn(h.forw);if(!m)throw"TOO LINEAR2";const x={},b=m.geometry.coordinates[0];let R;try{R=b.map(O=>({forw:O,bakw:Jt.transformArr(Vt(O),u)})),R.forEach(O=>{x[`${O.forw[0]}:${O.forw[1]}`]=O})}catch{throw"TOO LINEAR2"}const Y=Nn(h.bakw);if(!Y)throw"TOO LINEAR2";const p=Y.geometry.coordinates[0];try{R=p.map(O=>({bakw:O,forw:Jt.transformArr(Vt(O),f)})),R.forEach(O=>{x[`${O.forw[0]}:${O.forw[1]}`]=O})}catch{throw"TOO LINEAR2"}const y={forw:g.geometry.coordinates,bakw:Jt.transformArr(g,u)},l=Ie(y.forw,y.bakw,"c");this.centroid={forw:l,bakw:Te(l)};const v={convexBuf:x,centroid:y,bbox:i,minx:n,maxx:s,miny:a,maxy:c},M=this.vertexMode===Tt.VERTEX_BIRDEYE?Hr(v):Qr(v),A={forw:[],bakw:[]};for(let O=0;O<M.length;O++){const X=M[O].forw,L=M[O].bakw,K=Ie(X,L,`b${O}`),d=Te(K);r.forw.push(K),r.bakw.push(d),A.forw.push(K),A.bakw.push(d)}this.pointsSet={forw:Kt(r.forw),bakw:Kt(r.bakw),edges:r.edges},this.tins={forw:Jt.rotateVerticesTriangle(Oe(this.pointsSet.forw,r.edges,"target"))},(t===Tt.MODE_STRICT||t===Tt.MODE_AUTO)&&this.calcurateStrictTin(),(t===Tt.MODE_LOOSE||t===Tt.MODE_AUTO&&this.strict_status===Tt.STATUS_ERROR)&&(this.tins.bakw=Jt.rotateVerticesTriangle(Oe(this.pointsSet.bakw,r.edges,"target")),delete this.kinks,this.strict_status=Tt.STATUS_LOOSE),this.vertices_params={forw:fn(A.forw,this.centroid.forw),bakw:fn(A.bakw,this.centroid.bakw)},this.addIndexedTin();const T=["forw"];this.strict_status===Tt.STATUS_LOOSE&&T.push("bakw");const S=this.strict_status===Tt.STATUS_STRICT;this.pointsWeightBuffer=_i({tins:this.tins,targets:T,includeReciprocals:S})}async updateTinAsync(){this.updateTin()}}Yt.Tin=Tt,Yt.constrainedTin=Oe,Yt.counterPoint=Te,Yt.createPoint=Ie,Yt.default=Tt,Yt.findIntersections=jn,Yt.format_version=Jt.format_version,Yt.insertSearchIndex=hn,Yt.vertexCalc=fn,Object.defineProperties(Yt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED
|
@@ -4,18 +4,16 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.1",
|
|
8
8
|
"description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
|
|
9
9
|
"type": "module",
|
|
10
|
-
"main": "./dist/index.cjs",
|
|
11
10
|
"module": "./dist/maplat_tin.js",
|
|
12
11
|
"types": "./dist/index.d.ts",
|
|
13
12
|
"exports": {
|
|
14
13
|
".": {
|
|
15
14
|
"types": "./dist/index.d.ts",
|
|
16
15
|
"browser": "./dist/maplat_tin.js",
|
|
17
|
-
"import": "./dist/maplat_tin.js"
|
|
18
|
-
"require": "./dist/index.cjs"
|
|
16
|
+
"import": "./dist/maplat_tin.js"
|
|
19
17
|
},
|
|
20
18
|
"./umd": {
|
|
21
19
|
"default": "./dist/maplat_tin.umd.js"
|
|
@@ -28,6 +26,10 @@
|
|
|
28
26
|
"README.ja.md",
|
|
29
27
|
"LICENSE"
|
|
30
28
|
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=20.0.0",
|
|
31
|
+
"pnpm": ">=9.0.0"
|
|
32
|
+
},
|
|
31
33
|
"repository": {
|
|
32
34
|
"type": "git",
|
|
33
35
|
"url": "git+https://github.com/code4history/MaplatTin.git"
|
|
@@ -47,45 +49,41 @@
|
|
|
47
49
|
"deno"
|
|
48
50
|
],
|
|
49
51
|
"dependencies": {
|
|
50
|
-
"@maplat/transform": "
|
|
52
|
+
"@maplat/transform": "0.4.1",
|
|
53
|
+
"@turf/turf": "^7.3.1",
|
|
54
|
+
"delaunator": "^5.0.1",
|
|
51
55
|
"robust-predicates": "^3.0.2"
|
|
52
56
|
},
|
|
53
|
-
"peerDependencies": {
|
|
54
|
-
"@turf/boolean-point-in-polygon": "^7.2.0",
|
|
55
|
-
"@turf/centroid": "^7.2.0",
|
|
56
|
-
"@turf/convex": "^7.2.0",
|
|
57
|
-
"@turf/helpers": "^7.2.0",
|
|
58
|
-
"@turf/line-intersect": "^7.2.0",
|
|
59
|
-
"delaunator": "^5.0.0"
|
|
60
|
-
},
|
|
61
57
|
"devDependencies": {
|
|
62
|
-
"@eslint/js": "^9.39.
|
|
58
|
+
"@eslint/js": "^9.39.2",
|
|
63
59
|
"@testing-library/jest-dom": "^6.9.1",
|
|
64
60
|
"@types/delaunator": "^5.0.3",
|
|
65
61
|
"@types/estree": "^1.0.8",
|
|
66
|
-
"@types/geojson": "^7946.0.
|
|
67
|
-
"@types/node": "^24.10.
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
69
|
-
"@typescript-eslint/parser": "^8.
|
|
70
|
-
"@vitest/coverage-v8": "^
|
|
62
|
+
"@types/geojson": "^7946.0.16",
|
|
63
|
+
"@types/node": "^24.10.4",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^8.51.0",
|
|
65
|
+
"@typescript-eslint/parser": "^8.51.0",
|
|
66
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
71
67
|
"cross-env": "^10.1.0",
|
|
72
68
|
"dotenv": "^17.2.3",
|
|
73
69
|
"dotenv-cli": "^11.0.0",
|
|
74
|
-
"eslint": "^9.39.
|
|
70
|
+
"eslint": "^9.39.2",
|
|
75
71
|
"eslint-config-prettier": "^10.1.8",
|
|
72
|
+
"globals": "^16.5.0",
|
|
76
73
|
"jest-matcher-deep-close-to": "^3.0.2",
|
|
77
|
-
"jsdom": "^27.
|
|
78
|
-
"prettier": "^3.4
|
|
74
|
+
"jsdom": "^27.4.0",
|
|
75
|
+
"prettier": "^3.7.4",
|
|
79
76
|
"robust-segment-intersect": "^1.0.1",
|
|
80
77
|
"typescript": "^5.9.3",
|
|
81
|
-
"typescript-eslint": "^8.
|
|
82
|
-
"vite": "^
|
|
83
|
-
"vite-plugin-dts": "^4.4
|
|
84
|
-
"vitest": "^
|
|
78
|
+
"typescript-eslint": "^8.51.0",
|
|
79
|
+
"vite": "^6.4.1",
|
|
80
|
+
"vite-plugin-dts": "^4.5.4",
|
|
81
|
+
"vitest": "^3.2.4"
|
|
85
82
|
},
|
|
86
83
|
"scripts": {
|
|
87
|
-
"dev": "vite",
|
|
88
|
-
"build": "
|
|
84
|
+
"dev": "vite --host",
|
|
85
|
+
"build": "pnpm run typecheck && cross-env BUILD_MODE=package vite build",
|
|
86
|
+
"build:demo": "vite build --outDir dist-demo",
|
|
89
87
|
"typecheck": "tsc --noEmit --allowImportingTsExtensions",
|
|
90
88
|
"test": "vitest run",
|
|
91
89
|
"test:watch": "vitest",
|