@maplat/tin 0.14.1 → 1.0.0-rc1

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