@maplat/tin 0.13.1 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +224 -224
- package/README.ja.md +220 -220
- package/README.md +221 -221
- package/dist/boundary-vertices.d.ts +33 -6
- package/dist/maplat_tin.js +2669 -2228
- package/dist/maplat_tin.umd.js +5 -5
- package/dist/tin.d.ts +16 -1
- package/dist/vertexutils.d.ts +6 -2
- package/dist/weight-buffer.d.ts +2 -0
- package/package.json +8 -8
- package/src/boundary-vertices.ts +557 -283
- package/src/constrained-tin.ts +84 -84
- package/src/edgebound/base.ts +65 -65
- package/src/edgebound/bitset.ts +109 -109
- package/src/edgebound/constrain.license.txt +15 -15
- package/src/edgebound/constrain.ts +498 -498
- package/src/edgebound/index.ts +10 -10
- package/src/index.ts +42 -42
- package/src/kinks.ts +1092 -1092
- package/src/searchutils.ts +102 -102
- package/src/strict-overlap.ts +461 -281
- package/src/tin.ts +821 -703
- package/src/types/cdt2d.d.ts +4 -4
- package/src/types/constrainautor.d.ts +6 -6
- package/src/types/kinks.d.ts +51 -51
- package/src/types/tin.d.ts +54 -54
- package/src/vertexutils.ts +92 -87
- package/src/weight-buffer.ts +114 -111
package/dist/maplat_tin.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(Yt,Ft){typeof exports=="object"&&typeof module<"u"?Ft(exports):typeof define=="function"&&define.amd?define(["exports"],Ft):(Yt=typeof globalThis<"u"?globalThis:Yt||self,Ft(Yt.tin={}))})(this,(function(Yt){"use strict";var Bi=Object.defineProperty;var Pi=(Yt,Ft,Vt)=>Ft in Yt?Bi(Yt,Ft,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):Yt[Ft]=Vt;var _t=(Yt,Ft,Vt)=>Pi(Yt,typeof Ft!="symbol"?Ft+"":Ft,Vt);function Ft(o,e,t={}){const r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=o,r}function Vt(o,e,t={}){if(!o)throw new Error("coordinates is required");if(!Array.isArray(o))throw new Error("coordinates must be an Array");if(o.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!wn(o[0])||!wn(o[1]))throw new Error("coordinates must contain numbers");return Ft({type:"Point",coordinates:o},e,t)}function Me(o,e,t={}){for(const i of o){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let n=0;n<i[i.length-1].length;n++)if(i[i.length-1][n]!==i[0][n])throw new Error("First and last Position are not equivalent.")}return Ft({type:"Polygon",coordinates:o},e,t)}function gn(o,e,t={}){if(o.length<2)throw new Error("coordinates must be an array of two or more positions");return Ft({type:"LineString",coordinates:o},e,t)}function Kt(o,e={}){const t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=o,t}function wn(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function Zn(o){if(!o)throw new Error("coord is required");if(!Array.isArray(o)){if(o.type==="Feature"&&o.geometry!==null&&o.geometry.type==="Point")return[...o.geometry.coordinates];if(o.type==="Point")return[...o.coordinates]}if(Array.isArray(o)&&o.length>=2&&!Array.isArray(o[0])&&!Array.isArray(o[1]))return[...o];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function tr(o){return o.type==="Feature"?o.geometry:o}function Je(o,e,t){if(o!==null)for(var r,i,n,s,a,c,h,u=0,f=0,g,m=o.type,x=m==="FeatureCollection",b=m==="Feature",R=x?o.features.length:1,Y=0;Y<R;Y++){h=x?o.features[Y].geometry:b?o.geometry:o,g=h?h.type==="GeometryCollection":!1,a=g?h.geometries.length:1;for(var p=0;p<a;p++){var y=0,l=0;if(s=g?h.geometries[p]:h,s!==null){c=s.coordinates;var v=s.type;switch(u=t&&(v==="Polygon"||v==="MultiPolygon")?1:0,v){case null:break;case"Point":if(e(c,f,Y,y,l)===!1)return!1;f++,y++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(e(c[r],f,Y,y,l)===!1)return!1;f++,v==="MultiPoint"&&y++}v==="LineString"&&y++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(i=0;i<c[r].length-u;i++){if(e(c[r][i],f,Y,y,l)===!1)return!1;f++}v==="MultiLineString"&&y++,v==="Polygon"&&l++}v==="Polygon"&&y++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(l=0,i=0;i<c[r].length;i++){for(n=0;n<c[r][i].length-u;n++){if(e(c[r][i][n],f,Y,y,l)===!1)return!1;f++}l++}y++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(Je(s.geometries[r],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const Lt=11102230246251565e-32,rt=134217729,yn=(3+8*Lt)*Lt;function Ct(o,e,t,r,i){let n,s,a,c,h=e[0],u=r[0],f=0,g=0;u>h==u>-h?(n=h,h=e[++f]):(n=u,u=r[++g]);let m=0;if(f<o&&g<t)for(u>h==u>-h?(s=h+n,a=n-(s-h),h=e[++f]):(s=u+n,a=n-(s-u),u=r[++g]),n=s,a!==0&&(i[m++]=a);f<o&&g<t;)u>h==u>-h?(s=n+h,c=s-n,a=n-(s-c)+(h-c),h=e[++f]):(s=n+u,c=s-n,a=n-(s-c)+(u-c),u=r[++g]),n=s,a!==0&&(i[m++]=a);for(;f<o;)s=n+h,c=s-n,a=n-(s-c)+(h-c),h=e[++f],n=s,a!==0&&(i[m++]=a);for(;g<t;)s=n+u,c=s-n,a=n-(s-c)+(u-c),u=r[++g],n=s,a!==0&&(i[m++]=a);return(n!==0||m===0)&&(i[m++]=n),m}function Wt(o,e,t,r,i,n,s,a){return Ct(Ct(o,e,t,r,s),s,i,n,a)}function q(o,e,t,r){let i,n,s,a,c,h,u,f,g,m,x;u=rt*t,m=u-(u-t),x=t-m;let b=e[0];i=b*t,u=rt*b,f=u-(u-b),g=b-f,s=g*x-(i-f*m-g*m-f*x);let R=0;s!==0&&(r[R++]=s);for(let Y=1;Y<o;Y++)b=e[Y],a=b*t,u=rt*b,f=u-(u-b),g=b-f,c=g*x-(a-f*m-g*m-f*x),n=i+c,h=n-i,s=i-(n-h)+(c-h),s!==0&&(r[R++]=s),i=a+n,s=n-(i-a),s!==0&&(r[R++]=s);return(i!==0||R===0)&&(r[R++]=i),R}function vn(o,e){let t=e[0];for(let r=1;r<o;r++)t+=e[r];return t}function yt(o){return new Float64Array(o)}const er=(3+16*Lt)*Lt,nr=(2+12*Lt)*Lt,rr=(9+64*Lt)*Lt*Lt,ve=yt(4),bn=yt(8),_n=yt(12),xn=yt(16),$t=yt(4);function ir(o,e,t,r,i,n,s){let a,c,h,u,f,g,m,x,b,R,Y,p,y,l,v,M,A,T;const S=o-i,O=t-i,X=e-n,L=r-n;l=S*L,g=rt*S,m=g-(g-S),x=S-m,g=rt*L,b=g-(g-L),R=L-b,v=x*R-(l-m*b-x*b-m*R),M=X*O,g=rt*X,m=g-(g-X),x=X-m,g=rt*O,b=g-(g-O),R=O-b,A=x*R-(M-m*b-x*b-m*R),Y=v-A,f=v-Y,ve[0]=v-(Y+f)+(f-A),p=l+Y,f=p-l,y=l-(p-f)+(Y-f),Y=y-M,f=y-Y,ve[1]=y-(Y+f)+(f-M),T=p+Y,f=T-p,ve[2]=p-(T-f)+(Y-f),ve[3]=T;let K=vn(4,ve),d=nr*s;if(K>=d||-K>=d||(f=o-S,a=o-(S+f)+(f-i),f=t-O,h=t-(O+f)+(f-i),f=e-X,c=e-(X+f)+(f-n),f=r-L,u=r-(L+f)+(f-n),a===0&&c===0&&h===0&&u===0)||(d=rr*s+yn*Math.abs(K),K+=S*u+L*a-(X*h+O*c),K>=d||-K>=d))return K;l=a*L,g=rt*a,m=g-(g-a),x=a-m,g=rt*L,b=g-(g-L),R=L-b,v=x*R-(l-m*b-x*b-m*R),M=c*O,g=rt*c,m=g-(g-c),x=c-m,g=rt*O,b=g-(g-O),R=O-b,A=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q(M,Xe,b,Et);h=It(h,Ct(q(v,tn,b,dt),dt,q(St,Et,2*mt,bt),bt,Pt),Pt);const Mt=q(S,de,b,ot);h=It(h,Wt(q(Mt,ot,2*mt,dt),dt,q(Mt,ot,b,kt),kt,q(St,Et,b,bt),bt,ue,Ut),Ut)}}return be[h-1]}function hr(o,e,t,r,i,n,s,a){const c=o-s,h=t-s,u=i-s,f=e-a,g=r-a,m=n-a,x=h*m,b=u*g,R=c*c+f*f,Y=u*f,p=c*m,y=h*h+g*g,l=c*g,v=h*f,M=u*u+m*m,A=R*(x-b)+y*(Y-p)+M*(l-v),T=(Math.abs(x)+Math.abs(b))*R+(Math.abs(Y)+Math.abs(p))*y+(Math.abs(l)+Math.abs(v))*M,S=sr*T;return A>S||-A>S?A:cr(o,e,t,r,i,n,s,a,T)}function fr(o,e){var t,r,i=0,n,s,a,c,h,u,f,g=o[0],m=o[1],x=e.length;for(t=0;t<x;t++){r=0;var b=e[t],R=b.length-1;if(u=b[0],u[0]!==b[R][0]&&u[1]!==b[R][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-g,a=u[1]-m,r;r<R;r++){if(f=b[r+1],c=f[0]-g,h=f[1]-m,a===0&&h===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(h>=0&&a<=0||h<=0&&a>=0){if(n=te(s,c,a,h,0,0),n===0)return 0;(n>0&&h>0&&a<=0||n<0&&h<=0&&a>0)&&i++}u=f,a=h,s=c}}return i%2!==0}function ur(o,e,t={}){if(!o)throw new Error("point is required");if(!e)throw new Error("polygon is required");const r=Zn(o),i=tr(e),n=i.type,s=e.bbox;let a=i.coordinates;if(s&&lr(r,s)===!1)return!1;n==="Polygon"&&(a=[a]);let c=!1;for(var h=0;h<a.length;++h){const u=fr(r,a[h]);if(u===0)return!t.ignoreBoundary;u&&(c=!0)}return c}function lr(o,e){return e[0]<=o[0]&&e[1]<=o[1]&&e[2]>=o[0]&&e[3]>=o[1]}let Mn=class{constructor(e=[],t=dr){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}};function dr(o,e){return o<e?-1:o>e?1:0}function Sn(o,e){return o.p.x>e.p.x?1:o.p.x<e.p.x?-1:o.p.y!==e.p.y?o.p.y>e.p.y?1:-1:1}function pr(o,e){return o.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:o.rightSweepEvent.p.x<e.rightSweepEvent.p.x?-1:o.rightSweepEvent.p.y!==e.rightSweepEvent.p.y?o.rightSweepEvent.p.y<e.rightSweepEvent.p.y?1:-1:1}class kn{constructor(e,t,r,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}function mr(o,e){if(o.type==="FeatureCollection"){const t=o.features;for(let r=0;r<t.length;r++)En(t[r],e)}else En(o,e)}let Ce=0,Fe=0,Le=0;function En(o,e){const t=o.type==="Feature"?o.geometry:o;let r=t.coordinates;(t.type==="Polygon"||t.type==="MultiLineString")&&(r=[r]),t.type==="LineString"&&(r=[[r]]);for(let i=0;i<r.length;i++)for(let n=0;n<r[i].length;n++){let s=r[i][n][0],a=null;Fe=Fe+1;for(let c=0;c<r[i][n].length-1;c++){a=r[i][n][c+1];const h=new kn(s,Ce,Fe,Le),u=new kn(a,Ce,Fe,Le+1);h.otherEvent=u,u.otherEvent=h,Sn(h,u)>0?(u.isLeftEndpoint=!0,h.isLeftEndpoint=!1):(h.isLeftEndpoint=!0,u.isLeftEndpoint=!1),e.push(h),e.push(u),s=a,Le=Le+1}}Ce=Ce+1}class gr{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function wr(o,e){if(o===null||e===null||o.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.rightSweepEvent)||o.leftSweepEvent.isSamePoint(e.leftSweepEvent)||o.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;const t=o.leftSweepEvent.p.x,r=o.leftSweepEvent.p.y,i=o.rightSweepEvent.p.x,n=o.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,c=e.rightSweepEvent.p.x,h=e.rightSweepEvent.p.y,u=(h-a)*(i-t)-(c-s)*(n-r),f=(c-s)*(r-a)-(h-a)*(t-s),g=(i-t)*(r-a)-(n-r)*(t-s);if(u===0)return!1;const m=f/u,x=g/u;if(m>=0&&m<=1&&x>=0&&x<=1){const b=t+m*(i-t),R=r+m*(n-r);return[b,R]}return!1}function yr(o,e){e=e||!1;const t=[],r=new Mn([],pr);for(;o.length;){const i=o.pop();if(i.isLeftEndpoint){const n=new gr(i);for(let s=0;s<r.data.length;s++){const a=r.data[s];if(e&&a.leftSweepEvent.featureId===i.featureId)continue;const c=wr(n,a);c!==!1&&t.push(c)}r.push(n)}else i.isLeftEndpoint===!1&&r.pop()}return t}function vr(o,e){const t=new Mn([],Sn);return mr(o,t),yr(t,e)}var br=vr;function _r(o,e,t={}){const{removeDuplicates:r=!0,ignoreSelfIntersections:i=!0}=t;let n=[];o.type==="FeatureCollection"?n=n.concat(o.features):o.type==="Feature"?n.push(o):(o.type==="LineString"||o.type==="Polygon"||o.type==="MultiLineString"||o.type==="MultiPolygon")&&n.push(Ft(o)),e.type==="FeatureCollection"?n=n.concat(e.features):e.type==="Feature"?n.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&n.push(Ft(e));const s=br(Kt(n),i);let a=[];if(r){const c={};s.forEach(h=>{const u=h.join(",");c[u]||(c[u]=!0,a.push(h))})}else a=s;return Kt(a.map(c=>Vt(c)))}function xr(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Mr(o){if(Object.prototype.hasOwnProperty.call(o,"__esModule"))return o;var e=o.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(o).forEach(function(r){var i=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return o[r]}})}),t}function Sr(o,e={}){let t=0,r=0,i=0;return Je(o,function(n){t+=n[0],r+=n[1],i++},!0),Vt([t/i,r/i],e.properties)}var De={exports:{}},$e={exports:{}},kr=$e.exports,An;function Er(){return An||(An=1,(function(o,e){(function(t,r){o.exports=r()})(kr,function(){function t(p,y,l,v,M){(function A(T,S,O,X,L){for(;X>O;){if(X-O>600){var K=X-O+1,d=S-O+1,E=Math.log(K),_=.5*Math.exp(2*E/3),I=.5*Math.sqrt(E*_*(K-_)/K)*(d-K/2<0?-1:1),N=Math.max(O,Math.floor(S-d*_/K+I)),D=Math.min(X,Math.floor(S+(K-d)*_/K+I));A(T,S,N,D,L)}var w=T[S],B=O,F=X;for(r(T,O,S),L(T[X],w)>0&&r(T,O,X);B<F;){for(r(T,B,F),B++,F--;L(T[B],w)<0;)B++;for(;L(T[F],w)>0;)F--}L(T[O],w)===0?r(T,O,F):r(T,++F,X),F<=S&&(O=F+1),S<=F&&(X=F-1)}})(p,y,l||0,v||p.length-1,M||i)}function r(p,y,l){var v=p[y];p[y]=p[l],p[l]=v}function i(p,y){return p<y?-1:p>y?1:0}var n=function(p){p===void 0&&(p=9),this._maxEntries=Math.max(4,p),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(p,y,l){if(!l)return y.indexOf(p);for(var v=0;v<y.length;v++)if(l(p,y[v]))return v;return-1}function a(p,y){c(p,0,p.children.length,y,p)}function c(p,y,l,v,M){M||(M=R(null)),M.minX=1/0,M.minY=1/0,M.maxX=-1/0,M.maxY=-1/0;for(var A=y;A<l;A++){var T=p.children[A];h(M,p.leaf?v(T):T)}return M}function h(p,y){return p.minX=Math.min(p.minX,y.minX),p.minY=Math.min(p.minY,y.minY),p.maxX=Math.max(p.maxX,y.maxX),p.maxY=Math.max(p.maxY,y.maxY),p}function u(p,y){return p.minX-y.minX}function f(p,y){return p.minY-y.minY}function g(p){return(p.maxX-p.minX)*(p.maxY-p.minY)}function m(p){return p.maxX-p.minX+(p.maxY-p.minY)}function x(p,y){return p.minX<=y.minX&&p.minY<=y.minY&&y.maxX<=p.maxX&&y.maxY<=p.maxY}function b(p,y){return y.minX<=p.maxX&&y.minY<=p.maxY&&y.maxX>=p.minX&&y.maxY>=p.minY}function R(p){return{children:p,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Y(p,y,l,v,M){for(var A=[y,l];A.length;)if(!((l=A.pop())-(y=A.pop())<=v)){var T=y+Math.ceil((l-y)/v/2)*v;t(p,T,y,l,M),A.push(y,T,T,l)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(p){var y=this.data,l=[];if(!b(p,y))return l;for(var v=this.toBBox,M=[];y;){for(var A=0;A<y.children.length;A++){var T=y.children[A],S=y.leaf?v(T):T;b(p,S)&&(y.leaf?l.push(T):x(p,S)?this._all(T,l):M.push(T))}y=M.pop()}return l},n.prototype.collides=function(p){var y=this.data;if(!b(p,y))return!1;for(var l=[];y;){for(var v=0;v<y.children.length;v++){var M=y.children[v],A=y.leaf?this.toBBox(M):M;if(b(p,A)){if(y.leaf||x(p,A))return!0;l.push(M)}}y=l.pop()}return!1},n.prototype.load=function(p){if(!p||!p.length)return this;if(p.length<this._minEntries){for(var y=0;y<p.length;y++)this.insert(p[y]);return this}var l=this._build(p.slice(),0,p.length-1,0);if(this.data.children.length)if(this.data.height===l.height)this._splitRoot(this.data,l);else{if(this.data.height<l.height){var v=this.data;this.data=l,l=v}this._insert(l,this.data.height-l.height-1,!0)}else this.data=l;return this},n.prototype.insert=function(p){return p&&this._insert(p,this.data.height-1),this},n.prototype.clear=function(){return this.data=R([]),this},n.prototype.remove=function(p,y){if(!p)return this;for(var l,v,M,A=this.data,T=this.toBBox(p),S=[],O=[];A||S.length;){if(A||(A=S.pop(),v=S[S.length-1],l=O.pop(),M=!0),A.leaf){var X=s(p,A.children,y);if(X!==-1)return A.children.splice(X,1),S.push(A),this._condense(S),this}M||A.leaf||!x(A,T)?v?(l++,A=v.children[l],M=!1):A=null:(S.push(A),O.push(l),l=0,v=A,A=A.children[0])}return this},n.prototype.toBBox=function(p){return p},n.prototype.compareMinX=function(p,y){return p.minX-y.minX},n.prototype.compareMinY=function(p,y){return p.minY-y.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(p){return this.data=p,this},n.prototype._all=function(p,y){for(var l=[];p;)p.leaf?y.push.apply(y,p.children):l.push.apply(l,p.children),p=l.pop();return y},n.prototype._build=function(p,y,l,v){var M,A=l-y+1,T=this._maxEntries;if(A<=T)return a(M=R(p.slice(y,l+1)),this.toBBox),M;v||(v=Math.ceil(Math.log(A)/Math.log(T)),T=Math.ceil(A/Math.pow(T,v-1))),(M=R([])).leaf=!1,M.height=v;var S=Math.ceil(A/T),O=S*Math.ceil(Math.sqrt(T));Y(p,y,l,O,this.compareMinX);for(var X=y;X<=l;X+=O){var L=Math.min(X+O-1,l);Y(p,X,L,S,this.compareMinY);for(var K=X;K<=L;K+=S){var d=Math.min(K+S-1,L);M.children.push(this._build(p,K,d,v-1))}}return a(M,this.toBBox),M},n.prototype._chooseSubtree=function(p,y,l,v){for(;v.push(y),!y.leaf&&v.length-1!==l;){for(var M=1/0,A=1/0,T=void 0,S=0;S<y.children.length;S++){var O=y.children[S],X=g(O),L=(K=p,d=O,(Math.max(d.maxX,K.maxX)-Math.min(d.minX,K.minX))*(Math.max(d.maxY,K.maxY)-Math.min(d.minY,K.minY))-X);L<A?(A=L,M=X<M?X:M,T=O):L===A&&X<M&&(M=X,T=O)}y=T||y.children[0]}var K,d;return y},n.prototype._insert=function(p,y,l){var v=l?p:this.toBBox(p),M=[],A=this._chooseSubtree(v,this.data,y,M);for(A.children.push(p),h(A,v);y>=0&&M[y].children.length>this._maxEntries;)this._split(M,y),y--;this._adjustParentBBoxes(v,M,y)},n.prototype._split=function(p,y){var l=p[y],v=l.children.length,M=this._minEntries;this._chooseSplitAxis(l,M,v);var A=this._chooseSplitIndex(l,M,v),T=R(l.children.splice(A,l.children.length-A));T.height=l.height,T.leaf=l.leaf,a(l,this.toBBox),a(T,this.toBBox),y?p[y-1].children.push(T):this._splitRoot(l,T)},n.prototype._splitRoot=function(p,y){this.data=R([p,y]),this.data.height=p.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(p,y,l){for(var v,M,A,T,S,O,X,L=1/0,K=1/0,d=y;d<=l-y;d++){var E=c(p,0,d,this.toBBox),_=c(p,d,l,this.toBBox),I=(M=E,A=_,T=void 0,S=void 0,O=void 0,X=void 0,T=Math.max(M.minX,A.minX),S=Math.max(M.minY,A.minY),O=Math.min(M.maxX,A.maxX),X=Math.min(M.maxY,A.maxY),Math.max(0,O-T)*Math.max(0,X-S)),N=g(E)+g(_);I<L?(L=I,v=d,K=N<K?N:K):I===L&&N<K&&(K=N,v=d)}return v||l-y},n.prototype._chooseSplitAxis=function(p,y,l){var v=p.leaf?this.compareMinX:u,M=p.leaf?this.compareMinY:f;this._allDistMargin(p,y,l,v)<this._allDistMargin(p,y,l,M)&&p.children.sort(v)},n.prototype._allDistMargin=function(p,y,l,v){p.children.sort(v);for(var M=this.toBBox,A=c(p,0,y,M),T=c(p,l-y,l,M),S=m(A)+m(T),O=y;O<l-y;O++){var X=p.children[O];h(A,p.leaf?M(X):X),S+=m(A)}for(var L=l-y-1;L>=y;L--){var K=p.children[L];h(T,p.leaf?M(K):K),S+=m(T)}return S},n.prototype._adjustParentBBoxes=function(p,y,l){for(var v=l;v>=0;v--)h(y[v],p)},n.prototype._condense=function(p){for(var y=p.length-1,l=void 0;y>=0;y--)p[y].children.length===0?y>0?(l=p[y-1].children).splice(l.indexOf(p[y]),1):this.clear():a(p[y],this.toBBox)},n})})($e)),$e.exports}class Ar{constructor(e=[],t=Or){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}}function Or(o,e){return o<e?-1:o>e?1:0}const Br=Mr(Object.freeze(Object.defineProperty({__proto__:null,default:Ar},Symbol.toStringTag,{value:"Module"})));var Se={exports:{}},nn,On;function Pr(){return On||(On=1,nn=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=(i-r)/2,h=0,u=c-1;h<c;u=h++){var f=t[r+h*2+0],g=t[r+h*2+1],m=t[r+u*2+0],x=t[r+u*2+1],b=g>s!=x>s&&n<(m-f)*(s-g)/(x-g)+f;b&&(a=!a)}return a}),nn}var rn,Bn;function Ir(){return Bn||(Bn=1,rn=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=i-r,h=0,u=c-1;h<c;u=h++){var f=t[h+r][0],g=t[h+r][1],m=t[u+r][0],x=t[u+r][1],b=g>s!=x>s&&n<(m-f)*(s-g)/(x-g)+f;b&&(a=!a)}return a}),rn}var Pn;function Tr(){if(Pn)return Se.exports;Pn=1;var o=Pr(),e=Ir();return Se.exports=function(r,i,n,s){return i.length>0&&Array.isArray(i[0])?e(r,i,n,s):o(r,i,n,s)},Se.exports.nested=e,Se.exports.flat=o,Se.exports}var ke={exports:{}},Nr=ke.exports,In;function Xr(){return In||(In=1,(function(o,e){(function(t,r){r(e)})(Nr,function(t){const i=33306690738754706e-32;function n(b,R,Y,p,y){let l,v,M,A,T=R[0],S=p[0],O=0,X=0;S>T==S>-T?(l=T,T=R[++O]):(l=S,S=p[++X]);let L=0;if(O<b&&X<Y)for(S>T==S>-T?(M=l-((v=T+l)-T),T=R[++O]):(M=l-((v=S+l)-S),S=p[++X]),l=v,M!==0&&(y[L++]=M);O<b&&X<Y;)S>T==S>-T?(M=l-((v=l+T)-(A=v-l))+(T-A),T=R[++O]):(M=l-((v=l+S)-(A=v-l))+(S-A),S=p[++X]),l=v,M!==0&&(y[L++]=M);for(;O<b;)M=l-((v=l+T)-(A=v-l))+(T-A),T=R[++O],l=v,M!==0&&(y[L++]=M);for(;X<Y;)M=l-((v=l+S)-(A=v-l))+(S-A),S=p[++X],l=v,M!==0&&(y[L++]=M);return l===0&&L!==0||(y[L++]=l),L}function s(b){return new Float64Array(b)}const a=33306690738754716e-32,c=22204460492503146e-32,h=11093356479670487e-47,u=s(4),f=s(8),g=s(12),m=s(16),x=s(4);t.orient2d=function(b,R,Y,p,y,l){const v=(R-l)*(Y-y),M=(b-y)*(p-l),A=v-M;if(v===0||M===0||v>0!=M>0)return A;const T=Math.abs(v+M);return Math.abs(A)>=a*T?A:-(function(S,O,X,L,K,d,E){let _,I,N,D,w,B,F,j,U,z,Q,V,ht,ct,ut,pt,gt,mt;const Bt=S-K,Rt=X-K,St=O-d,Mt=L-d;w=(ut=(j=Bt-(F=(B=134217729*Bt)-(B-Bt)))*(z=Mt-(U=(B=134217729*Mt)-(B-Mt)))-((ct=Bt*Mt)-F*U-j*U-F*z))-(Q=ut-(gt=(j=St-(F=(B=134217729*St)-(B-St)))*(z=Rt-(U=(B=134217729*Rt)-(B-Rt)))-((pt=St*Rt)-F*U-j*U-F*z))),u[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),u[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,u[2]=V-(mt-w)+(Q-w),u[3]=mt;let ie=(function(mn,zt){let We=zt[0];for(let k=1;k<mn;k++)We+=zt[k];return We})(4,u),we=c*E;if(ie>=we||-ie>=we||(_=S-(Bt+(w=S-Bt))+(w-K),N=X-(Rt+(w=X-Rt))+(w-K),I=O-(St+(w=O-St))+(w-d),D=L-(Mt+(w=L-Mt))+(w-d),_===0&&I===0&&N===0&&D===0)||(we=h*E+i*Math.abs(ie),(ie+=Bt*D+Mt*_-(St*N+Rt*I))>=we||-ie>=we))return ie;w=(ut=(j=_-(F=(B=134217729*_)-(B-_)))*(z=Mt-(U=(B=134217729*Mt)-(B-Mt)))-((ct=_*Mt)-F*U-j*U-F*z))-(Q=ut-(gt=(j=I-(F=(B=134217729*I)-(B-I)))*(z=Rt-(U=(B=134217729*Rt)-(B-Rt)))-((pt=I*Rt)-F*U-j*U-F*z))),x[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),x[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,x[2]=V-(mt-w)+(Q-w),x[3]=mt;const ln=n(4,u,4,x,f);w=(ut=(j=Bt-(F=(B=134217729*Bt)-(B-Bt)))*(z=D-(U=(B=134217729*D)-(B-D)))-((ct=Bt*D)-F*U-j*U-F*z))-(Q=ut-(gt=(j=St-(F=(B=134217729*St)-(B-St)))*(z=N-(U=(B=134217729*N)-(B-N)))-((pt=St*N)-F*U-j*U-F*z))),x[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),x[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,x[2]=V-(mt-w)+(Q-w),x[3]=mt;const dn=n(ln,f,4,x,g);w=(ut=(j=_-(F=(B=134217729*_)-(B-_)))*(z=D-(U=(B=134217729*D)-(B-D)))-((ct=_*D)-F*U-j*U-F*z))-(Q=ut-(gt=(j=I-(F=(B=134217729*I)-(B-I)))*(z=N-(U=(B=134217729*N)-(B-N)))-((pt=I*N)-F*U-j*U-F*z))),x[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),x[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,x[2]=V-(mt-w)+(Q-w),x[3]=mt;const pn=n(dn,g,4,x,m);return m[pn-1]})(b,R,Y,p,y,l,T)},t.orient2dfast=function(b,R,Y,p,y,l){return(R-l)*(Y-y)-(b-y)*(p-l)},Object.defineProperty(t,"__esModule",{value:!0})})})(ke,ke.exports)),ke.exports}var Tn;function Rr(){if(Tn)return De.exports;Tn=1;var o=Er(),e=Br,t=Tr(),r=Xr().orient2d;e.default&&(e=e.default),De.exports=i,De.exports.default=i;function i(l,v,M){v=Math.max(0,v===void 0?2:v),M=M||0;var A=m(l),T=new o(16);T.toBBox=function(F){return{minX:F[0],minY:F[1],maxX:F[0],maxY:F[1]}},T.compareMinX=function(F,j){return F[0]-j[0]},T.compareMinY=function(F,j){return F[1]-j[1]},T.load(l);for(var S=[],O=0,X;O<A.length;O++){var L=A[O];T.remove(L),X=x(L,X),S.push(X)}var K=new o(16);for(O=0;O<S.length;O++)K.insert(g(S[O]));for(var d=v*v,E=M*M;S.length;){var _=S.shift(),I=_.p,N=_.next.p,D=b(I,N);if(!(D<E)){var w=D/d;L=n(T,_.prev.p,I,N,_.next.next.p,w,K),L&&Math.min(b(L,I),b(L,N))<=w&&(S.push(_),S.push(x(L,_)),T.remove(L),K.remove(_),K.insert(g(_)),K.insert(g(_.next)))}}_=X;var B=[];do B.push(_.p),_=_.next;while(_!==X);return B.push(_.p),B}function n(l,v,M,A,T,S,O){for(var X=new e([],s),L=l.data;L;){for(var K=0;K<L.children.length;K++){var d=L.children[K],E=L.leaf?R(d,M,A):a(M,A,d);E>S||X.push({node:d,dist:E})}for(;X.length&&!X.peek().node.children;){var _=X.pop(),I=_.node,N=R(I,v,M),D=R(I,A,T);if(_.dist<N&&_.dist<D&&h(M,I,O)&&h(A,I,O))return I}L=X.pop(),L&&(L=L.node)}return null}function s(l,v){return l.dist-v.dist}function a(l,v,M){if(c(l,M)||c(v,M))return 0;var A=Y(l[0],l[1],v[0],v[1],M.minX,M.minY,M.maxX,M.minY);if(A===0)return 0;var T=Y(l[0],l[1],v[0],v[1],M.minX,M.minY,M.minX,M.maxY);if(T===0)return 0;var S=Y(l[0],l[1],v[0],v[1],M.maxX,M.minY,M.maxX,M.maxY);if(S===0)return 0;var O=Y(l[0],l[1],v[0],v[1],M.minX,M.maxY,M.maxX,M.maxY);return O===0?0:Math.min(A,T,S,O)}function c(l,v){return l[0]>=v.minX&&l[0]<=v.maxX&&l[1]>=v.minY&&l[1]<=v.maxY}function h(l,v,M){for(var A=Math.min(l[0],v[0]),T=Math.min(l[1],v[1]),S=Math.max(l[0],v[0]),O=Math.max(l[1],v[1]),X=M.search({minX:A,minY:T,maxX:S,maxY:O}),L=0;L<X.length;L++)if(f(X[L].p,X[L].next.p,l,v))return!1;return!0}function u(l,v,M){return r(l[0],l[1],v[0],v[1],M[0],M[1])}function f(l,v,M,A){return l!==A&&v!==M&&u(l,v,M)>0!=u(l,v,A)>0&&u(M,A,l)>0!=u(M,A,v)>0}function g(l){var v=l.p,M=l.next.p;return l.minX=Math.min(v[0],M[0]),l.minY=Math.min(v[1],M[1]),l.maxX=Math.max(v[0],M[0]),l.maxY=Math.max(v[1],M[1]),l}function m(l){for(var v=l[0],M=l[0],A=l[0],T=l[0],S=0;S<l.length;S++){var O=l[S];O[0]<v[0]&&(v=O),O[0]>A[0]&&(A=O),O[1]<M[1]&&(M=O),O[1]>T[1]&&(T=O)}var X=[v,M,A,T],L=X.slice();for(S=0;S<l.length;S++)t(l[S],X)||L.push(l[S]);return y(L)}function x(l,v){var M={p:l,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return v?(M.next=v.next,M.prev=v,v.next.prev=M,v.next=M):(M.prev=M,M.next=M),M}function b(l,v){var M=l[0]-v[0],A=l[1]-v[1];return M*M+A*A}function R(l,v,M){var A=v[0],T=v[1],S=M[0]-A,O=M[1]-T;if(S!==0||O!==0){var X=((l[0]-A)*S+(l[1]-T)*O)/(S*S+O*O);X>1?(A=M[0],T=M[1]):X>0&&(A+=S*X,T+=O*X)}return S=l[0]-A,O=l[1]-T,S*S+O*O}function Y(l,v,M,A,T,S,O,X){var L=M-l,K=A-v,d=O-T,E=X-S,_=l-T,I=v-S,N=L*L+K*K,D=L*d+K*E,w=d*d+E*E,B=L*_+K*I,F=d*_+E*I,j=N*w-D*D,U,z,Q,V,ht=j,ct=j;j===0?(z=0,ht=1,V=F,ct=w):(z=D*F-w*B,V=N*F-D*B,z<0?(z=0,V=F,ct=w):z>ht&&(z=ht,V=F+D,ct=w)),V<0?(V=0,-B<0?z=0:-B>N?z=ht:(z=-B,ht=N)):V>ct&&(V=ct,-B+D<0?z=0:-B+D>N?z=ht:(z=-B+D,ht=N)),U=z===0?0:z/ht,Q=V===0?0:V/ct;var ut=(1-U)*l+U*M,pt=(1-U)*v+U*A,gt=(1-Q)*T+Q*O,mt=(1-Q)*S+Q*X,Bt=gt-ut,Rt=mt-pt;return Bt*Bt+Rt*Rt}function p(l,v){return l[0]===v[0]?l[1]-v[1]:l[0]-v[0]}function y(l){l.sort(p);for(var v=[],M=0;M<l.length;M++){for(;v.length>=2&&u(v[v.length-2],v[v.length-1],l[M])<=0;)v.pop();v.push(l[M])}for(var A=[],T=l.length-1;T>=0;T--){for(;A.length>=2&&u(A[A.length-2],A[A.length-1],l[T])<=0;)A.pop();A.push(l[T])}return A.pop(),v.pop(),v.concat(A)}return De.exports}var Yr=Rr();const Cr=xr(Yr);function Nn(o,e={}){e.concavity=e.concavity||1/0;const t=[];if(Je(o,i=>{t.push([i[0],i[1]])}),!t.length)return null;const r=Cr(t,e.concavity);return r.length>3?Me([r]):null}var Ee={exports:{}},Fr=Ee.exports,Xn;function Lr(){return Xn||(Xn=1,(function(o,e){(function(t,r){r(e)})(Fr,(function(t){var r=Object.defineProperty,i=(k,P,C)=>P in k?r(k,P,{enumerable:!0,configurable:!0,writable:!0,value:C}):k[P]=C,n=(k,P,C)=>i(k,typeof P!="symbol"?P+"":P,C);function s(k,P,C={}){const $={type:"Feature"};return(C.id===0||C.id)&&($.id=C.id),C.bbox&&($.bbox=C.bbox),$.properties=P||{},$.geometry=k,$}function a(k,P,C={}){if(!k)throw new Error("coordinates is required");if(!Array.isArray(k))throw new Error("coordinates must be an Array");if(k.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!u(k[0])||!u(k[1]))throw new Error("coordinates must contain numbers");return s({type:"Point",coordinates:k},P,C)}function c(k,P,C={}){for(const $ of k){if($.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if($[$.length-1].length!==$[0].length)throw new Error("First and last Position are not equivalent.");for(let tt=0;tt<$[$.length-1].length;tt++)if($[$.length-1][tt]!==$[0][tt])throw new Error("First and last Position are not equivalent.")}return s({type:"Polygon",coordinates:k},P,C)}function h(k,P={}){const C={type:"FeatureCollection"};return P.id&&(C.id=P.id),P.bbox&&(C.bbox=P.bbox),C.features=k,C}function u(k){return!isNaN(k)&&k!==null&&!Array.isArray(k)}function f(k){if(!k)throw new Error("coord is required");if(!Array.isArray(k)){if(k.type==="Feature"&&k.geometry!==null&&k.geometry.type==="Point")return[...k.geometry.coordinates];if(k.type==="Point")return[...k.coordinates]}if(Array.isArray(k)&&k.length>=2&&!Array.isArray(k[0])&&!Array.isArray(k[1]))return[...k];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function g(k){if(Array.isArray(k))return k;if(k.type==="Feature"){if(k.geometry!==null)return k.geometry.coordinates}else if(k.coordinates)return k.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function m(k){return k.type==="Feature"?k.geometry:k}const x=11102230246251565e-32,b=134217729,R=(3+8*x)*x;function Y(k,P,C,$,tt){let G,et,st,it,at=P[0],ft=$[0],J=0,Z=0;ft>at==ft>-at?(G=at,at=P[++J]):(G=ft,ft=$[++Z]);let lt=0;if(J<k&&Z<C)for(ft>at==ft>-at?(et=at+G,st=G-(et-at),at=P[++J]):(et=ft+G,st=G-(et-ft),ft=$[++Z]),G=et,st!==0&&(tt[lt++]=st);J<k&&Z<C;)ft>at==ft>-at?(et=G+at,it=et-G,st=G-(et-it)+(at-it),at=P[++J]):(et=G+ft,it=et-G,st=G-(et-it)+(ft-it),ft=$[++Z]),G=et,st!==0&&(tt[lt++]=st);for(;J<k;)et=G+at,it=et-G,st=G-(et-it)+(at-it),at=P[++J],G=et,st!==0&&(tt[lt++]=st);for(;Z<C;)et=G+ft,it=et-G,st=G-(et-it)+(ft-it),ft=$[++Z],G=et,st!==0&&(tt[lt++]=st);return(G!==0||lt===0)&&(tt[lt++]=G),lt}function p(k,P){let C=P[0];for(let $=1;$<k;$++)C+=P[$];return C}function y(k){return new Float64Array(k)}const l=(3+16*x)*x,v=(2+12*x)*x,M=(9+64*x)*x*x,A=y(4),T=y(8),S=y(12),O=y(16),X=y(4);function L(k,P,C,$,tt,G,et){let st,it,at,ft,J,Z,lt,xt,nt,H,W,wt,At,Ot,Xt,vt,Nt,Dt;const Gt=k-tt,Qt=C-tt,Ht=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Gt-lt,Z=b*ft,nt=Z-(Z-ft),H=ft-nt,Xt=xt*H-(Ot-lt*nt-xt*nt-lt*H),vt=Ht*at,Z=b*Ht,lt=Z-(Z-Ht),xt=Ht-lt,Z=b*at,nt=Z-(Z-at),H=at-nt,Nt=xt*H-(vt-lt*nt-xt*nt-lt*H),W=Xt-Nt,J=Xt-W,X[0]=Xt-(W+J)+(J-Nt),wt=Ot+W,J=wt-Ot,At=Ot-(wt-J)+(W-J),W=At-vt,J=At-W,X[1]=At-(W+J)+(J-vt),Dt=wt+W,J=Dt-wt,X[2]=wt-(Dt-J)+(W-J),X[3]=Dt;const Ai=Y(Ei,T,4,X,S);Ot=st*ft,Z=b*st,lt=Z-(Z-st),xt=st-lt,Z=b*ft,nt=Z-(Z-ft),H=ft-nt,Xt=xt*H-(Ot-lt*nt-xt*nt-lt*H),vt=it*at,Z=b*it,lt=Z-(Z-it),xt=it-lt,Z=b*at,nt=Z-(Z-at),H=at-nt,Nt=xt*H-(vt-lt*nt-xt*nt-lt*H),W=Xt-Nt,J=Xt-W,X[0]=Xt-(W+J)+(J-Nt),wt=Ot+W,J=wt-Ot,At=Ot-(wt-J)+(W-J),W=At-vt,J=At-W,X[1]=At-(W+J)+(J-vt),Dt=wt+W,J=Dt-wt,X[2]=wt-(Dt-J)+(W-J),X[3]=Dt;const Oi=Y(Ai,S,4,X,O);return O[Oi-1]}function K(k,P,C,$,tt,G){const et=(P-G)*(C-tt),st=(k-tt)*($-G),it=et-st,at=Math.abs(et+st);return Math.abs(it)>=l*at?it:-L(k,P,C,$,tt,G,at)}function d(k,P){var C,$,tt=0,G,et,st,it,at,ft,J,Z=k[0],lt=k[1],xt=P.length;for(C=0;C<xt;C++){$=0;var nt=P[C],H=nt.length-1;if(ft=nt[0],ft[0]!==nt[H][0]&&ft[1]!==nt[H][1])throw new Error("First and last coordinates in a ring must be the same");for(et=ft[0]-Z,st=ft[1]-lt,$;$<H;$++){if(J=nt[$+1],it=J[0]-Z,at=J[1]-lt,st===0&&at===0){if(it<=0&&et>=0||et<=0&&it>=0)return 0}else if(at>=0&&st<=0||at<=0&&st>=0){if(G=K(et,it,st,at,0,0),G===0)return 0;(G>0&&at>0&&st<=0||G<0&&at<=0&&st>0)&&tt++}ft=J,st=at,et=it}}return tt%2!==0}function E(k,P,C={}){if(!k)throw new Error("point is required");if(!P)throw new Error("polygon is required");const $=f(k),tt=m(P),G=tt.type,et=P.bbox;let st=tt.coordinates;if(et&&_($,et)===!1)return!1;G==="Polygon"&&(st=[st]);let it=!1;for(var at=0;at<st.length;++at){const ft=d($,st[at]);if(ft===0)return!C.ignoreBoundary;ft&&(it=!0)}return it}function _(k,P){return P[0]<=k[0]&&P[1]<=k[1]&&P[2]>=k[0]&&P[3]>=k[1]}function I(k,P){for(let C=0;C<P.features.length;C++)if(E(k,P.features[C]))return P.features[C]}function N(k,P,C){const $=P.geometry.coordinates[0][0],tt=P.geometry.coordinates[0][1],G=P.geometry.coordinates[0][2],et=k.geometry.coordinates,st=P.properties.a.geom,it=P.properties.b.geom,at=P.properties.c.geom,ft=[tt[0]-$[0],tt[1]-$[1]],J=[G[0]-$[0],G[1]-$[1]],Z=[et[0]-$[0],et[1]-$[1]],lt=[it[0]-st[0],it[1]-st[1]],xt=[at[0]-st[0],at[1]-st[1]];let nt=(J[1]*Z[0]-J[0]*Z[1])/(ft[0]*J[1]-ft[1]*J[0]),H=(ft[0]*Z[1]-ft[1]*Z[0])/(ft[0]*J[1]-ft[1]*J[0]);if(C){const W=C[P.properties.a.index],wt=C[P.properties.b.index],At=C[P.properties.c.index];let Ot;if(nt<0||H<0||1-nt-H<0){const Xt=nt/(nt+H),vt=H/(nt+H);Ot=nt/wt/(Xt/wt+vt/At),H=H/At/(Xt/wt+vt/At)}else Ot=nt/wt/(nt/wt+H/At+(1-nt-H)/W),H=H/At/(nt/wt+H/At+(1-nt-H)/W);nt=Ot}return[nt*lt[0]+H*xt[0]+st[0],nt*lt[1]+H*xt[1]+st[1]]}function D(k,P,C,$){const tt=k.geometry.coordinates,G=C.geometry.coordinates,et=Math.atan2(tt[0]-G[0],tt[1]-G[1]),st=F(et,P[0]);if(st===void 0)throw new Error("Unable to determine vertex index");const it=P[1][st];return N(k,it.features[0],$)}function w(k,P,C,$,tt,G,et,st){let it;if(et&&(it=I(k,h([et]))),!it){if(C){const at=k.geometry.coordinates,ft=C.gridNum,J=C.xOrigin,Z=C.yOrigin,lt=C.xUnit,xt=C.yUnit,nt=C.gridCache,H=B(at[0],J,lt,ft),W=B(at[1],Z,xt,ft),wt=nt[H]?nt[H][W]?nt[H][W]:[]:[];P=h(wt.map(At=>P.features[At]))}it=I(k,P)}return st&&st(it),it?N(k,it,G):D(k,$,tt,G)}function B(k,P,C,$){let tt=Math.floor((k-P)/C);return tt>=$&&(tt=$-1),tt}function F(k,P){let C=j(k-P[0]),$=Math.PI*2,tt;for(let G=0;G<P.length;G++){const et=(G+1)%P.length,st=j(k-P[et]),it=Math.min(Math.abs(C),Math.abs(st));C*st<=0&&it<$&&($=it,tt=G),C=st}return tt}function j(k,P=!1){const C=P?function($){return!($>=0&&$<Math.PI*2)}:function($){return!($>-1*Math.PI&&$<=Math.PI)};for(;C(k);)k=k+2*Math.PI*(k>0?-1:1);return k}function U(k,P){return P&&P>=2.00703||Array.isArray(k[0])?k:k.map(C=>[C.illstNodes,C.mercNodes,C.startEnd])}function z(k){const P=k.features;for(let C=0;C<P.length;C++){const $=P[C];`${$.properties.a.index}`.substring(0,1)==="b"&&`${$.properties.b.index}`.substring(0,1)==="b"?P[C]={geometry:{type:"Polygon",coordinates:[[$.geometry.coordinates[0][2],$.geometry.coordinates[0][0],$.geometry.coordinates[0][1],$.geometry.coordinates[0][2]]]},properties:{a:{geom:$.properties.c.geom,index:$.properties.c.index},b:{geom:$.properties.a.geom,index:$.properties.a.index},c:{geom:$.properties.b.geom,index:$.properties.b.index}},type:"Feature"}:`${$.properties.c.index}`.substring(0,1)==="b"&&`${$.properties.a.index}`.substring(0,1)==="b"&&(P[C]={geometry:{type:"Polygon",coordinates:[[$.geometry.coordinates[0][1],$.geometry.coordinates[0][2],$.geometry.coordinates[0][0],$.geometry.coordinates[0][1]]]},properties:{a:{geom:$.properties.b.geom,index:$.properties.b.index},b:{geom:$.properties.c.geom,index:$.properties.c.index},c:{geom:$.properties.a.geom,index:$.properties.a.index}},type:"Feature"})}return k}function Q(k){const P=["a","b","c","a"].map(G=>k.properties[G].geom),C=k.geometry.coordinates[0],$=k.properties,tt={a:{geom:C[0],index:$.a.index},b:{geom:C[1],index:$.b.index},c:{geom:C[2],index:$.c.index}};return c([P],tt)}function V(k){const P=[0,1,2,0].map($=>k[$][0][0]),C={a:{geom:k[0][0][1],index:k[0][1]},b:{geom:k[1][0][1],index:k[1][1]},c:{geom:k[2][0][1],index:k[2][1]}};return c([P],C)}function ht(k,P,C,$,tt,G=!1,et){const st=k.map(it=>{(!et||et<2.00703)&&(it=ct(it));const at=isFinite(it)?P[it]:it==="c"?$:it==="b0"?tt[0]:it==="b1"?tt[1]:it==="b2"?tt[2]:it==="b3"?tt[3]:(function(){const ft=it.match(/e(\d+)/);if(ft){const J=parseInt(ft[1]);return C[J]}throw"Bad index value for indexesToTri"})();return G?[[at[1],at[0]],it]:[[at[0],at[1]],it]});return V(st)}function ct(k){return typeof k=="number"?k:k.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}const ut=2.00703;function pt(k){return!!(k.version||!k.tins&&k.points&&k.tins_points)}function gt(k){return{points:k.points,pointsWeightBuffer:Bt(k),strictStatus:Rt(k),verticesParams:St(k),centroid:ie(k),edges:U(k.edges||[]),edgeNodes:k.edgeNodes||[],tins:we(k),kinks:ln(k.kinks_points),yaxisMode:k.yaxisMode??"invert",strictMode:k.strictMode??"auto",vertexMode:k.vertexMode,bounds:k.bounds,boundsPolygon:k.boundsPolygon,wh:k.wh,xy:k.bounds?k.xy:[0,0]}}function mt(k){const P=dn(k),C=P.tins;return{compiled:P,tins:C,points:pn(C),strictStatus:P.strict_status,pointsWeightBuffer:P.weight_buffer,verticesParams:P.vertices_params,centroid:P.centroid,kinks:P.kinks}}function Bt(k){return!k.version||k.version<ut?["forw","bakw"].reduce((P,C)=>{const $=k.weight_buffer[C];return $&&(P[C]=Object.keys($).reduce((tt,G)=>{const et=ct(G);return tt[et]=$[G],tt},{})),P},{}):k.weight_buffer}function Rt(k){return k.strict_status?k.strict_status:k.kinks_points?"strict_error":k.tins_points.length===2?"loose":"strict"}function St(k){const P={forw:[k.vertices_params[0]],bakw:[k.vertices_params[1]]};return P.forw[1]=Mt(k,!1),P.bakw[1]=Mt(k,!0),P}function Mt(k,P){return[0,1,2,3].map(C=>{const $=(C+1)%4,tt=ht(["c",`b${C}`,`b${$}`],k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,P,ut);return h([tt])})}function ie(k){return{forw:a(k.centroid_point[0],{target:{geom:k.centroid_point[1],index:"c"}}),bakw:a(k.centroid_point[1],{target:{geom:k.centroid_point[0],index:"c"}})}}function we(k){const P=k.tins_points.length===1?0:1;return{forw:h(k.tins_points[0].map(C=>ht(C,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!1,k.version))),bakw:h(k.tins_points[P].map(C=>ht(C,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!0,k.version)))}}function ln(k){if(k)return{bakw:h(k.map(P=>a(P)))}}function dn(k){return JSON.parse(JSON.stringify(k).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function pn(k){const P=[],C=k.forw.features;for(let $=0;$<C.length;$++){const tt=C[$];["a","b","c"].map((G,et)=>{const st=tt.geometry.coordinates[0][et],it=tt.properties[G].geom,at=tt.properties[G].index;typeof at=="number"&&(P[at]=[st,it])})}return P}const mn=ut,zt=class se{constructor(){n(this,"points",[]),n(this,"pointsWeightBuffer"),n(this,"strict_status"),n(this,"vertices_params"),n(this,"centroid"),n(this,"edgeNodes"),n(this,"edges"),n(this,"tins"),n(this,"kinks"),n(this,"yaxisMode",se.YAXIS_INVERT),n(this,"strictMode",se.MODE_AUTO),n(this,"vertexMode",se.VERTEX_PLAIN),n(this,"bounds"),n(this,"boundsPolygon"),n(this,"wh"),n(this,"xy"),n(this,"indexedTins"),n(this,"stateFull",!1),n(this,"stateTriangle"),n(this,"stateBackward"),n(this,"priority"),n(this,"importance"),n(this,"xyBounds"),n(this,"mercBounds")}setCompiled(P){if(pt(P)){this.applyModernState(gt(P));return}this.applyLegacyState(mt(P))}applyModernState(P){this.points=P.points,this.pointsWeightBuffer=P.pointsWeightBuffer,this.strict_status=P.strictStatus,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.edges=P.edges,this.edgeNodes=P.edgeNodes||[],this.tins=P.tins,this.addIndexedTin(),this.kinks=P.kinks,this.yaxisMode=P.yaxisMode??se.YAXIS_INVERT,this.vertexMode=P.vertexMode??se.VERTEX_PLAIN,this.strictMode=P.strictMode??se.MODE_AUTO,P.bounds?(this.bounds=P.bounds,this.boundsPolygon=P.boundsPolygon,this.xy=P.xy,this.wh=P.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=P.xy??[0,0],P.wh&&(this.wh=P.wh))}applyLegacyState(P){this.tins=P.tins,this.addIndexedTin(),this.strict_status=P.strictStatus,this.pointsWeightBuffer=P.pointsWeightBuffer,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.kinks=P.kinks,this.points=P.points}addIndexedTin(){const P=this.tins,C=P.forw,$=P.bakw,tt=Math.ceil(Math.sqrt(C.features.length));if(tt<3){this.indexedTins=void 0;return}let G=[],et=[];const st=C.features.map(nt=>{let H=[];return g(nt)[0].map(W=>{G.length===0?G=[Array.from(W),Array.from(W)]:(W[0]<G[0][0]&&(G[0][0]=W[0]),W[0]>G[1][0]&&(G[1][0]=W[0]),W[1]<G[0][1]&&(G[0][1]=W[1]),W[1]>G[1][1]&&(G[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),it=(G[1][0]-G[0][0])/tt,at=(G[1][1]-G[0][1])/tt,ft=st.reduce((nt,H,W)=>{const wt=B(H[0][0],G[0][0],it,tt),At=B(H[1][0],G[0][0],it,tt),Ot=B(H[0][1],G[0][1],at,tt),Xt=B(H[1][1],G[0][1],at,tt);for(let vt=wt;vt<=At;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=Ot;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(W)}return nt},[]),J=$.features.map(nt=>{let H=[];return g(nt)[0].map(W=>{et.length===0?et=[Array.from(W),Array.from(W)]:(W[0]<et[0][0]&&(et[0][0]=W[0]),W[0]>et[1][0]&&(et[1][0]=W[0]),W[1]<et[0][1]&&(et[0][1]=W[1]),W[1]>et[1][1]&&(et[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),Z=(et[1][0]-et[0][0])/tt,lt=(et[1][1]-et[0][1])/tt,xt=J.reduce((nt,H,W)=>{const wt=B(H[0][0],et[0][0],Z,tt),At=B(H[1][0],et[0][0],Z,tt),Ot=B(H[0][1],et[0][1],lt,tt),Xt=B(H[1][1],et[0][1],lt,tt);for(let vt=wt;vt<=At;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=Ot;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(W)}return nt},[]);this.indexedTins={forw:{gridNum:tt,xOrigin:G[0][0],yOrigin:G[0][1],xUnit:it,yUnit:at,gridCache:ft},bakw:{gridNum:tt,xOrigin:et[0][0],yOrigin:et[0][1],xUnit:Z,yUnit:lt,gridCache:xt}}}transform(P,C,$){if(C&&this.strict_status==se.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==se.YAXIS_FOLLOW&&C&&(P=[P[0],-1*P[1]]);const tt=a(P);if(this.bounds&&!C&&!$&&!E(tt,this.boundsPolygon))return!1;const G=C?this.tins.bakw:this.tins.forw,et=C?this.indexedTins.bakw:this.indexedTins.forw,st=C?this.vertices_params.bakw:this.vertices_params.forw,it=C?this.centroid.bakw:this.centroid.forw,at=C?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let ft,J;this.stateFull&&(this.stateBackward==C?ft=this.stateTriangle:(this.stateBackward=C,this.stateTriangle=void 0),J=lt=>{this.stateTriangle=lt});let Z=w(tt,G,et,st,it,at,ft,J);if(this.bounds&&C&&!$){const lt=a(Z);if(!E(lt,this.boundsPolygon))return!1}else this.yaxisMode==se.YAXIS_FOLLOW&&!C&&(Z=[Z[0],-1*Z[1]]);return Z}};n(zt,"VERTEX_PLAIN","plain"),n(zt,"VERTEX_BIRDEYE","birdeye"),n(zt,"MODE_STRICT","strict"),n(zt,"MODE_AUTO","auto"),n(zt,"MODE_LOOSE","loose"),n(zt,"STATUS_STRICT","strict"),n(zt,"STATUS_ERROR","strict_error"),n(zt,"STATUS_LOOSE","loose"),n(zt,"YAXIS_FOLLOW","follow"),n(zt,"YAXIS_INVERT","invert");let We=zt;t.Transform=We,t.counterTri=Q,t.format_version=mn,t.normalizeEdges=U,t.rotateVerticesTriangle=z,t.transformArr=w,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}))})(Ee,Ee.exports)),Ee.exports}var Jt=Lr();const Rn=Math.pow(2,-52),je=new Uint32Array(512);class sn{static from(e,t=Ur,r=zr){const i=e.length,n=new Float64Array(i*2);for(let s=0;s<i;s++){const a=e[s];n[2*s]=t(a),n[2*s+1]=r(a)}return new sn(n)}constructor(e){const t=e.length>>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const r=Math.max(2*t-5,0);this._triangles=new Uint32Array(r*3),this._halfedges=new Int32Array(r*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:r,_hullTri:i,_hullHash:n}=this,s=e.length>>1;let a=1/0,c=1/0,h=-1/0,u=-1/0;for(let S=0;S<s;S++){const O=e[2*S],X=e[2*S+1];O<a&&(a=O),X<c&&(c=X),O>h&&(h=O),X>u&&(u=X),this._ids[S]=S}const f=(a+h)/2,g=(c+u)/2;let m,x,b;for(let S=0,O=1/0;S<s;S++){const X=on(f,g,e[2*S],e[2*S+1]);X<O&&(m=S,O=X)}const R=e[2*m],Y=e[2*m+1];for(let S=0,O=1/0;S<s;S++){if(S===m)continue;const X=on(R,Y,e[2*S],e[2*S+1]);X<O&&X>0&&(x=S,O=X)}let p=e[2*x],y=e[2*x+1],l=1/0;for(let S=0;S<s;S++){if(S===m||S===x)continue;const O=jr(R,Y,p,y,e[2*S],e[2*S+1]);O<l&&(b=S,l=O)}let v=e[2*b],M=e[2*b+1];if(l===1/0){for(let X=0;X<s;X++)this._dists[X]=e[2*X]-e[0]||e[2*X+1]-e[1];_e(this._ids,this._dists,0,s-1);const S=new Uint32Array(s);let O=0;for(let X=0,L=-1/0;X<s;X++){const K=this._ids[X],d=this._dists[K];d>L&&(S[O++]=K,L=d)}this.hull=S.subarray(0,O),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(te(R,Y,p,y,v,M)<0){const S=x,O=p,X=y;x=b,p=v,y=M,b=S,v=O,M=X}const A=qr(R,Y,p,y,v,M);this._cx=A.x,this._cy=A.y;for(let S=0;S<s;S++)this._dists[S]=on(e[2*S],e[2*S+1],A.x,A.y);_e(this._ids,this._dists,0,s-1),this._hullStart=m;let T=3;r[m]=t[b]=x,r[x]=t[m]=b,r[b]=t[x]=m,i[m]=0,i[x]=1,i[b]=2,n.fill(-1),n[this._hashKey(R,Y)]=m,n[this._hashKey(p,y)]=x,n[this._hashKey(v,M)]=b,this.trianglesLen=0,this._addTriangle(m,x,b,-1,-1,-1);for(let S=0,O,X;S<this._ids.length;S++){const L=this._ids[S],K=e[2*L],d=e[2*L+1];if(S>0&&Math.abs(K-O)<=Rn&&Math.abs(d-X)<=Rn||(O=K,X=d,L===m||L===x||L===b))continue;let E=0;for(let w=0,B=this._hashKey(K,d);w<this._hashSize&&(E=n[(B+w)%this._hashSize],!(E!==-1&&E!==r[E]));w++);E=t[E];let _=E,I;for(;I=r[_],te(K,d,e[2*_],e[2*_+1],e[2*I],e[2*I+1])>=0;)if(_=I,_===E){_=-1;break}if(_===-1)continue;let N=this._addTriangle(_,L,r[_],-1,-1,i[_]);i[L]=this._legalize(N+2),i[_]=N,T++;let D=r[_];for(;I=r[D],te(K,d,e[2*D],e[2*D+1],e[2*I],e[2*I+1])<0;)N=this._addTriangle(D,L,I,i[L],-1,i[D]),i[L]=this._legalize(N+2),r[D]=D,T--,D=I;if(_===E)for(;I=t[_],te(K,d,e[2*I],e[2*I+1],e[2*_],e[2*_+1])<0;)N=this._addTriangle(I,L,_,-1,i[_],i[I]),this._legalize(N+2),i[I]=N,r[_]=_,T--,_=I;this._hullStart=t[L]=_,r[_]=t[D]=L,r[L]=D,n[this._hashKey(K,d)]=L,n[this._hashKey(e[2*_],e[2*_+1])]=_}this.hull=new Uint32Array(T);for(let S=0,O=this._hullStart;S<T;S++)this.hull[S]=O,O=r[O];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(Dr(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:r,coords:i}=this;let n=0,s=0;for(;;){const a=r[e],c=e-e%3;if(s=c+(e+2)%3,a===-1){if(n===0)break;e=je[--n];continue}const h=a-a%3,u=c+(e+1)%3,f=h+(a+2)%3,g=t[s],m=t[e],x=t[u],b=t[f];if($r(i[2*g],i[2*g+1],i[2*m],i[2*m+1],i[2*x],i[2*x+1],i[2*b],i[2*b+1])){t[e]=b,t[a]=g;const Y=r[f];if(Y===-1){let y=this._hullStart;do{if(this._hullTri[y]===f){this._hullTri[y]=e;break}y=this._hullPrev[y]}while(y!==this._hullStart)}this._link(e,Y),this._link(a,r[s]),this._link(s,f);const p=h+(a+1)%3;n<je.length&&(je[n++]=p)}else{if(n===0)break;e=je[--n]}}return s}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,r,i,n,s){const a=this.trianglesLen;return this._triangles[a]=e,this._triangles[a+1]=t,this._triangles[a+2]=r,this._link(a,i),this._link(a+1,n),this._link(a+2,s),this.trianglesLen+=3,a}}function Dr(o,e){const t=o/(Math.abs(o)+Math.abs(e));return(e>0?3-t:1+t)/4}function on(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function $r(o,e,t,r,i,n,s,a){const c=o-s,h=e-a,u=t-s,f=r-a,g=i-s,m=n-a,x=c*c+h*h,b=u*u+f*f,R=g*g+m*m;return c*(f*R-b*m)-h*(u*R-b*g)+x*(u*m-f*g)<0}function jr(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,h=n-e,u=s*s+a*a,f=c*c+h*h,g=.5/(s*h-a*c),m=(h*u-a*f)*g,x=(s*f-c*u)*g;return m*m+x*x}function qr(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,h=n-e,u=s*s+a*a,f=c*c+h*h,g=.5/(s*h-a*c),m=o+(h*u-a*f)*g,x=e+(s*f-c*u)*g;return{x:m,y:x}}function _e(o,e,t,r){if(r-t<=20)for(let i=t+1;i<=r;i++){const n=o[i],s=e[n];let a=i-1;for(;a>=t&&e[o[a]]>s;)o[a+1]=o[a--];o[a+1]=n}else{const i=t+r>>1;let n=t+1,s=r;Ae(o,i,n),e[o[t]]>e[o[r]]&&Ae(o,t,r),e[o[n]]>e[o[r]]&&Ae(o,n,r),e[o[t]]>e[o[n]]&&Ae(o,t,n);const a=o[n],c=e[a];for(;;){do n++;while(e[o[n]]<c);do s--;while(e[o[s]]>c);if(s<n)break;Ae(o,n,s)}o[t+1]=o[s],o[s]=a,r-n+1>=s-t?(_e(o,e,n,r),_e(o,e,t,s-1)):(_e(o,e,t,s-1),_e(o,e,n,r))}}function Ae(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function Ur(o){return o[0]}function zr(o){return o[1]}class Vr{constructor(e,t){_t(this,"bs");_t(this,"width");this.width=e,this.bs=t}add(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]|=1<<r,this}delete(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]&=~(1<<r),this}set(e,t){const r=Math.floor(e/this.width),n=1<<e%this.width;return this.bs[r]^=(-Number(t)^this.bs[r])&n,t}has(e){const t=Math.floor(e/this.width),r=e%this.width;return(this.bs[t]&1<<r)!==0}forEach(e){const t=this.bs.length;for(let r=0;r<t;r++){let i=0;for(;this.bs[r]&&i<this.width;)this.bs[r]&1<<i&&e(r*this.width+i),i++}return this}}class Yn extends Vr{constructor(e){super(8,new Uint8Array(Math.ceil(e/8)).fill(0))}}function ge(o){return o%3===2?o-2:o+1}function oe(o){return o%3===0?o+2:o-1}function Cn(o,e,t,r,i,n,s,a){const c=te(o,e,i,n,s,a),h=te(t,r,i,n,s,a);if(c>0&&h>0||c<0&&h<0)return!1;const u=te(i,n,o,e,t,r),f=te(s,a,o,e,t,r);return u>0&&f>0||u<0&&f<0?!1:c===0&&h===0&&u===0&&f===0?!(Math.max(i,s)<Math.min(o,t)||Math.max(o,t)<Math.min(i,s)||Math.max(n,a)<Math.min(e,r)||Math.max(e,r)<Math.min(n,a)):!0}class Wr{constructor(e){_t(this,"del");this.del=e}}class Fn extends Wr{constructor(t,r){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);_t(this,"vertMap");_t(this,"flips");_t(this,"consd");const i=2**32-1,n=t.coords.length>>1,s=t.triangles.length;this.vertMap=new Uint32Array(n).fill(i),this.flips=new Yn(s),this.consd=new Yn(s);for(let a=0;a<s;a++){const c=t.triangles[a];this.vertMap[c]===i&&this.updateVert(a)}r&&this.constrainAll(r)}constrainOne(t,r){const{triangles:i,halfedges:n}=this.del,s=this.vertMap[t];let a=s;do{const u=i[a],f=ge(a);if(u===r)return this.protect(a);const g=oe(a),m=i[g];if(m===r)return this.protect(f),f;if(this.intersectSegments(t,r,m,u)){a=g;break}a=n[f]}while(a!==-1&&a!==s);let c=a,h=-1;for(;a!==-1;){const u=n[a],f=oe(a),g=oe(u),m=ge(u);if(u===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(a))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,r,i[a])||this.isCollinear(t,r,i[u]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[a],i[u],i[f],i[g])){if(h===-1&&(h=a),i[g]===r){if(a===h)throw new Error("Infinite loop: non-convex quadrilateral");a=h,h=-1;continue}if(this.intersectSegments(t,r,i[g],i[u]))a=g;else if(this.intersectSegments(t,r,i[m],i[g]))a=m;else if(h===a)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(a),this.intersectSegments(t,r,i[f],i[g])&&(h===-1&&(h=f),h===f))throw new Error("Infinite loop: flipped diagonal still intersects");i[g]===r?(c=g,a=h,h=-1):this.intersectSegments(t,r,i[m],i[g])&&(a=m)}return this.protect(c),this.delaunify(!0),this.findEdge(t,r)}delaunify(t=!1){const{halfedges:r}=this.del,i=this.flips,n=this.consd,s=r.length;let a;do{a=0;for(let c=0;c<s;c++){if(n.has(c))continue;i.delete(c);const h=r[c];h!==-1&&(i.delete(h),this.isDelaunay(c)||(this.flipDiagonal(c),a++))}}while(t&&a>0);return this}constrainAll(t){const r=t.length;for(let i=0;i<r;i++){const n=t[i];this.constrainOne(n[0],n[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,r){const i=this.vertMap[r],{triangles:n,halfedges:s}=this.del;let a=i,c=-1;do{if(n[a]===t)return a;c=ge(a),a=s[c]}while(a!==-1&&a!==i);return n[ge(c)]===t?-c:1/0}protect(t){const r=this.del.halfedges[t],i=this.flips,n=this.consd;return i.delete(t),n.add(t),r!==-1?(i.delete(r),n.add(r),r):-t}markFlip(t){const r=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const s=r[t];return s!==-1&&(i.add(t),i.add(s)),!0}flipDiagonal(t){const{triangles:r,halfedges:i}=this.del,n=this.flips,s=this.consd,a=i[t],c=oe(t),h=ge(t),u=oe(a),f=ge(a),g=i[c],m=i[u];if(s.has(t))throw new Error("Trying to flip a constrained edge");return r[t]=r[u],i[t]=m,n.set(t,n.has(u))||s.set(t,s.has(u)),m!==-1&&(i[m]=t),i[c]=u,r[a]=r[c],i[a]=g,n.set(a,n.has(c))||s.set(a,s.has(c)),g!==-1&&(i[g]=a),i[u]=c,this.markFlip(t),this.markFlip(h),this.markFlip(a),this.markFlip(f),n.add(c),s.delete(c),n.add(u),s.delete(u),this.updateVert(t),this.updateVert(h),this.updateVert(a),this.updateVert(f),c}isCollinear(t,r,i){const n=this.del.coords;return te(n[t*2],n[t*2+1],n[r*2],n[r*2+1],n[i*2],n[i*2+1])===0}inCircle(t,r,i,n){const s=this.del.coords;return hr(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])<0}isDelaunay(t){const{triangles:r,halfedges:i}=this.del,n=i[t];if(n===-1)return!0;const s=r[oe(t)],a=r[t],c=r[ge(t)],h=r[oe(n)];return!this.inCircle(s,a,c,h)}updateVert(t){const{triangles:r,halfedges:i}=this.del,n=this.vertMap,s=r[t];let a=oe(t),c=i[a];for(;c!==-1&&c!==t;)a=oe(c),c=i[a];return n[s]=a,a}intersectSegments(t,r,i,n){const s=this.del.coords;return t===i||t===n||r===i||r===n?!1:Cn(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])}}_t(Fn,"intersectSegments",Cn);function Oe(o,e,t){if(e||(e=[]),typeof o!="object"||o.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(e))throw"Argument points must be Array of Array";const r=o.features.map(c=>c.geometry.coordinates),i=sn.from(r);let n;const s=[];i.triangles.length!==0&&e.length!==0&&(n=new Fn(i),n.constrainAll(e));for(let c=0;c<i.triangles.length;c+=3)s.push([i.triangles[c],i.triangles[c+1],i.triangles[c+2]]);const a=["a","b","c"];return Kt(s.map(c=>{const h={},u=c.map((f,g)=>{const m=o.features[f],x=m.geometry.coordinates,b=[x[0],x[1]];return x.length===3?b[2]=x[2]:h[a[g]]=m.properties[t],b});return u[3]=u[0],Me([u],h)}))}function Ln(o,e,t,r,i,n){return Object.keys(o).reduce((s,a)=>{const c=o[a],h=c.forw,u=c.bakw,f={forw:[h[0]-e.forw[0],h[1]-e.forw[1]],bakw:[u[0]-e.bakw[0],u[1]-e.bakw[1]]},g=f.forw[0]===0?1/0:((f.forw[0]<0?t:r)-e.forw[0])/f.forw[0],m=f.forw[1]===0?1/0:((f.forw[1]<0?i:n)-e.forw[1])/f.forw[1];if(Math.abs(g)/Math.abs(m)<1.1){const x={forw:[f.forw[0]*g+e.forw[0],f.forw[1]*g+e.forw[1]],bakw:[f.bakw[0]*g+e.bakw[0],f.bakw[1]*g+e.bakw[1]]};f.forw[0]<0?s[3].push(x):s[1].push(x)}if(Math.abs(m)/Math.abs(g)<1.1){const x={forw:[f.forw[0]*m+e.forw[0],f.forw[1]*m+e.forw[1]],bakw:[f.bakw[0]*m+e.bakw[0],f.bakw[1]*m+e.bakw[1]]};f.forw[1]<0?s[0].push(x):s[2].push(x)}return s},[[],[],[],[]])}function Jr(o,e){const t=[[],[],[],[]],r=[];return Object.keys(o).forEach(i=>{const n=o[i],s=n.forw,a=n.bakw,c=[s[0]-e.forw[0],s[1]-e.forw[1]],h=[a[0]-e.bakw[0],e.bakw[1]-a[1]],u={forw:c,bakw:h};if(r.push(u),c[0]===0||c[1]===0)return;let f=0;c[0]>0&&(f+=1),c[1]>0&&(f+=2),t[f].push(u)}),{perQuad:t,aggregate:r}}function Kr(o){let e=1/0,t=0,r=0;return o.forEach(i=>{const{forw:n,bakw:s}=i,a=Math.hypot(n[0],n[1]),c=Math.hypot(s[0],s[1]);if(c===0)return;const h=a/c,u=Math.atan2(n[0],n[1])-Math.atan2(s[0],s[1]);e=Math.min(e,h),t+=Math.cos(u),r+=Math.sin(u)}),isFinite(e)?[e,Math.atan2(r,t)]:[1,0]}function Dn(o,e,t){const{perQuad:r,aggregate:i}=Jr(o,e),n=r.every(c=>c.length>0),a=(t==="birdeye"?n?r:[i]:[i]).map(c=>Kr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Gr(o,e,t){const r=[1,1,1,1];for(let i=0;i<4;i++){const n=(i+1)%4,s=gn([o[i].bakw,o[n].bakw]);e[i].map(a=>{const c=gn([t.bakw,a.bakw]),h=_r(s,c);if(h.features.length>0&&h.features[0].geometry){const u=h.features[0],f=Math.sqrt(Math.pow(a.bakw[0]-t.bakw[0],2)+Math.pow(a.bakw[1]-t.bakw[1],2)),g=Math.sqrt(Math.pow(u.geometry.coordinates[0]-t.bakw[0],2)+Math.pow(u.geometry.coordinates[1]-t.bakw[1],2)),m=f/g;m>r[i]&&(r[i]=m),m>r[n]&&(r[n]=m)}})}o.forEach((i,n)=>{const s=r[n],a=[(i.bakw[0]-t.bakw[0])*s+t.bakw[0],(i.bakw[1]-t.bakw[1])*s+t.bakw[1]];i.bakw=a})}function $n(o,e,t,r){const i=o.map((s,a)=>{const c=e[a],h=[c[0]-t.forw[0],c[1]-t.forw[1]],f=Math.sqrt(Math.pow(h[0],2)+Math.pow(h[1],2))/s[0],g=Math.atan2(h[0],h[1])-s[1],m=[t.bakw[0]+f*Math.sin(g),t.bakw[1]-f*Math.cos(g)];return{forw:c,bakw:m}}),n=i[2];return i[2]=i[3],i[3]=n,Gr(i,r,t),i}function Qr(o){const{convexBuf:e,centroid:t,bbox:r,minx:i,maxx:n,miny:s,maxy:a}=o,c=Ln(e,t,i,n,s,a),h=Dn(e,t,"plain");return $n(h,r,t,c)}function Hr(o){const{convexBuf:e,centroid:t,bbox:r,minx:i,maxx:n,miny:s,maxy:a}=o,c=Ln(e,t,i,n,s,a),h=Dn(e,t,"birdeye");return $n(h,r,t,c)}function jn(o){const t=new Zr(o).findSegmentIntersections(),r=Jn(t),i=new Map;return r.forEach(n=>{i.set(`${n.x}:${n.y}`,n)}),Array.from(i.values()).map(n=>Vt([n.x,n.y]))}class Zr{constructor(e){_t(this,"_xx");_t(this,"_yy");_t(this,"_ii");_t(this,"_nn");_t(this,"_zz",null);_t(this,"_zlimit",0);_t(this,"_bb",null);_t(this,"_allBounds",null);_t(this,"_arcIter",null);_t(this,"_filteredArcIter",null);_t(this,"buf");this.initArcs(e)}initArcs(e){const t=[],r=[],i=e.map(n=>{const s=n?n.length:0;for(let a=0;a<s;a++)t.push(n[a][0]),r.push(n[a][1]);return s});this.initXYData(i,t,r)}initXYData(e,t,r){const i=e.length;this._xx=new Float64Array(t),this._yy=new Float64Array(r),this._nn=new Uint32Array(e),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(i);let n=0;for(let s=0;s<i;s++)this._ii[s]=n,n+=e[s];(n!=this._xx.length||this._xx.length!=this._yy.length)&&an("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new vi(this._xx,this._yy)}initBounds(){const e=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=e.bb,this._allBounds=e.bounds}calcArcBounds_(e,t,r){const i=r.length,n=new Float64Array(i*4),s=new Pe;let a=0,c,h,u;for(let f=0;f<i;f++)c=r[f],c>0&&(h=f*4,u=bi(e,t,a,c),n[h++]=u[0],n[h++]=u[1],n[h++]=u[2],n[h]=u[3],a+=c,s.mergeBounds(u));return{bb:n,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new Pe}forEachSegment(e){let t=0;for(let r=0,i=this.size();r<i;r++)t+=this.forEachArcSegment(r,e);return t}size(){return this._ii&&this._ii.length||0}forEachArcSegment(e,t){const r=e>=0,i=r?e:~e,n=this.getRetainedInterval(),s=this._nn[i],a=r?1:-1;let c=r?this._ii[i]:this._ii[i]+s-1,h=c,u=0;for(let f=1;f<s;f++)h+=a,(n===0||this._zz[h]>=n)&&(t(c,h,this._xx,this._yy),c=h,u++);return u}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(e){const t=e*4;return(!this.buf||this.buf.byteLength<t)&&(this.buf=new ArrayBuffer(t)),new Uint32Array(this.buf,0,e)}getAvgSegment2(){let e=0,t=0;const r=this.forEachSegment((i,n,s,a)=>{e+=Math.abs(s[i]-s[n]),t+=Math.abs(a[i]-a[n])});return[e/r||0,t/r||0]}calcSegmentIntersectionStripeCount(){const e=this.getBounds().height(),t=this.getAvgSegment2()[1];let r=1;return t>0&&e>0&&(r=Math.ceil(e/t/20)),r||1}findSegmentIntersections(){const e=this.getBounds(),t=e.ymin||0,r=(e.ymax||0)-t,i=this.calcSegmentIntersectionStripeCount(),n=new Uint32Array(i),s=i>1?b=>Math.floor((i-1)*(b-t)/r):()=>0;let a,c;this.forEachSegment((b,R,Y,p)=>{let y=s(p[b]);const l=s(p[R]);for(;n[y]=n[y]+2,y!=l;)y+=l>y?1:-1});const h=this.getUint32Array(ni(n));let u=0;const f=[];ri(n,b=>{const R=u;u+=b,f.push(h.subarray(R,u))}),ii(n,0),this.forEachSegment((b,R,Y,p)=>{let y=s(p[b]);const l=s(p[R]);let v,M;for(;v=n[y],n[y]=v+2,M=f[y],M[v]=b,M[v+1]=R,y!=l;)y+=l>y?1:-1});const g=this.getVertexData(),m=[];let x;for(a=0;a<i;a++)if(g.xx&&g.yy)for(x=si(f[a],g.xx,g.yy),c=0;c<x.length;c++)m.push(x[c]);return Jn(m)}}function an(...o){const e=o.join(" ");throw new Error(e)}function cn(o){return o?ei(o)?!0:ti(o)?!1:o.length===0?!0:o.length>0:!1}function ti(o){return o!=null&&o.toString===String.prototype.toString}function ei(o){return Array.isArray(o)}function ni(o,e){cn(o)||an("utils.sum() expects an array, received:",o);let t=0,r;for(let i=0,n=o.length;i<n;i++)r=o[i],r&&(t+=r);return t}function ri(o,e,t){if(!cn(o))throw new Error(`#forEach() takes an array-like argument. ${o}`);for(let r=0,i=o.length;r<i;r++)e.call(t,o[r],r)}function ii(o,e){for(let t=0,r=o.length;t<r;t++)o[t]=e;return o}function si(o,e,t){const r=o.length-2,i=[];let n,s,a,c,h,u,f,g,m,x,b,R,Y,p,y,l,v;for(mi(e,o),l=0;l<r;){for(n=o[l],s=o[l+1],h=e[n],u=e[s],m=t[n],x=t[s],v=l;v<r&&(v+=2,a=o[v],f=e[a],!(u<f));){if(b=t[a],c=o[v+1],g=e[c],R=t[c],m>=b){if(m>R&&x>b&&x>R)continue}else if(m<R&&x<b&&x<R)continue;n==a||n==c||s==a||s==c||(Y=oi(h,m,u,x,f,b,g,R),Y&&(p=[n,s],y=[a,c],i.push(Vn(Y,p,y,e,t)),Y.length==4&&i.push(Vn(Y.slice(2),p,y,e,t))))}l+=2}return i}function oi(o,e,t,r,i,n,s,a){const c=ai(o,e,t,r,i,n,s,a);let h=null;return c&&(h=ci(o,e,t,r,i,n,s,a),h?pi(o,e,t,r,i,n,s,a)&&(h=null):h=di(o,e,t,r,i,n,s,a)),h}function ai(o,e,t,r,i,n,s,a){return Be(o,e,t,r,i,n)*Be(o,e,t,r,s,a)<=0&&Be(i,n,s,a,o,e)*Be(i,n,s,a,t,r)<=0}function Be(o,e,t,r,i,n){return qn(o-i,e-n,t-i,r-n)}function qn(o,e,t,r){return o*r-e*t}function ci(o,e,t,r,i,n,s,a){let c=qe(o,e,t,r,i,n,s,a),h;return c&&(h=fi(c[0],c[1],o,e,t,r,i,n,s,a),h==1?c=qe(t,r,o,e,i,n,s,a):h==2?c=qe(i,n,s,a,o,e,t,r):h==3&&(c=qe(s,a,i,n,o,e,t,r))),c&&li(c,o,e,t,r,i,n,s,a),c}function qe(o,e,t,r,i,n,s,a){const c=qn(t-o,r-e,s-i,a-n),h=1e-18;let u;if(c===0)return null;const f=Be(i,n,s,a,o,e)/c;return c<=h&&c>=-h?u=hi(o,e,t,r,i,n,s,a):u=[o+f*(t-o),e+f*(r-e)],u}function hi(o,e,t,r,i,n,s,a){let c=null;return!ae(o,i,s)&&!ae(e,n,a)?c=[o,e]:!ae(t,i,s)&&!ae(r,n,a)?c=[t,r]:!ae(i,o,t)&&!ae(n,e,r)?c=[i,n]:!ae(s,o,t)&&!ae(a,e,r)&&(c=[s,a]),c}function ae(o,e,t){let r;return e<t?r=o<e||o>t:e>t?r=o>e||o<t:r=o!=e,r}function fi(o,e,...t){let r=-1,i=1/0,n;for(let s=0,a=0,c=t.length;a<c;s++,a+=2)n=ui(o,e,t[a],t[a+1]),n<i&&(i=n,r=s);return r}function ui(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function li(o,e,t,r,i,n,s,a,c){let h=o[0],u=o[1];h=Ue(h,e,r),h=Ue(h,n,a),u=Ue(u,t,i),u=Ue(u,s,c),o[0]=h,o[1]=u}function Ue(o,e,t){let r;return ae(o,e,t)&&(r=Math.abs(o-e)<Math.abs(o-t)?e:t,o=r),o}function di(o,e,t,r,i,n,s,a){const c=Math.min(o,t,i,s),h=Math.max(o,t,i,s),u=Math.min(e,r,n,a),f=Math.max(e,r,n,a),g=f-u>h-c;let m=[];return(g?le(e,u,f):le(o,c,h))&&m.push(o,e),(g?le(r,u,f):le(t,c,h))&&m.push(t,r),(g?le(n,u,f):le(i,c,h))&&m.push(i,n),(g?le(a,u,f):le(s,c,h))&&m.push(s,a),(m.length!=2&&m.length!=4||m.length==4&&m[0]==m[2]&&m[1]==m[3])&&(m=null),m}function pi(o,e,t,r,i,n,s,a){return o==i&&e==n||o==s&&e==a||t==i&&r==n||t==s&&r==a}function le(o,e,t){return o>e&&o<t}function mi(o,e){gi(o,e),Un(o,e,0,e.length-2)}function gi(o,e){for(let t=0,r=e.length;t<r;t+=2)o[e[t]]>o[e[t+1]]&&wi(e,t,t+1)}function wi(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function Un(o,e,t,r){let i=t,n=r,s,a;for(;i<r;){for(s=o[e[t+r>>2<<1]];i<=n;){for(;o[e[i]]<s;)i+=2;for(;o[e[n]]>s;)n-=2;i<=n&&(a=e[i],e[i]=e[n],e[n]=a,a=e[i+1],e[i+1]=e[n+1],e[n+1]=a,i+=2,n-=2)}if(n-t<40?zn(o,e,t,n):Un(o,e,t,n),r-i<40){zn(o,e,i,r);return}t=i,n=r}}function zn(o,e,t,r){let i,n;for(let s=t+2;s<=r;s+=2){i=e[s],n=e[s+1];let a;for(a=s-2;a>=t&&o[i]<o[e[a]];a-=2)e[a+2]=e[a],e[a+3]=e[a+1];e[a+2]=i,e[a+3]=n}}function Vn(o,e,t,r,i){const n=o[0],s=o[1];e=Wn(n,s,e[0],e[1],r,i),t=Wn(n,s,t[0],t[1],r,i);const a=e[0]<t[0]?e:t,c=a==e?t:e;return{x:n,y:s,a,b:c}}function Wn(o,e,t,r,i,n){let s=t<r?t:r,a=s===t?r:t;return i[s]==o&&n[s]==e?a=s:i[a]==o&&n[a]==e&&(s=a),[s,a]}function Jn(o){const e={};return o.filter(t=>{const r=yi(t);return r in e?!1:(e[r]=!0,!0)})}function yi(o){return`${o.a.join(",")};${o.b.join(",")}`}class vi{constructor(e,t){_t(this,"_i",0);_t(this,"_n",0);_t(this,"_inc",1);_t(this,"_xx");_t(this,"_yy");_t(this,"i",0);_t(this,"x",0);_t(this,"y",0);this._xx=e,this._yy=t}}function bi(o,e,t,r){let i=t|0;const n=isNaN(r)?o.length-i:r+i;let s,a,c,h,u,f;if(n>0)c=u=o[i],h=f=e[i];else return[void 0,void 0,void 0,void 0];for(i++;i<n;i++)s=o[i],a=e[i],s<c&&(c=s),s>u&&(u=s),a<h&&(h=a),a>f&&(f=a);return[c,h,u,f]}class Pe{constructor(...e){_t(this,"xmin");_t(this,"ymin");_t(this,"xmax");_t(this,"ymax");e.length>0&&this.setBounds(e)}cloneBounds(){return this.clone()}clone(){return new Pe(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(e,t,r,i){let n,s,a,c;if(arguments.length==1)if(cn(e)){const h=e;n=h[0],s=h[1],a=h[2],c=h[3]}else{const h=e;n=h.xmin,s=h.ymin,a=h.xmax,c=h.ymax}else n=e,s=t,a=r,c=i;return this.xmin=n,this.ymin=s,this.xmax=a,this.ymax=c,(n>a||s>c)&&this.update(),this}update(){let e;this.xmin>this.xmax&&(e=this.xmin,this.xmin=this.xmax,this.xmax=e),this.ymin>this.ymax&&(e=this.ymin,this.ymin=this.ymax,this.ymax=e)}mergeBounds(e,...t){let r,i,n,s;return e instanceof Pe?(r=e.xmin,i=e.ymin,n=e.xmax,s=e.ymax):t.length==3?(r=e,i=t[0],n=t[1],s=t[2]):e.length==4?(r=e[0],i=e[1],n=e[2],s=e[3]):an("Bounds#mergeBounds() invalid argument:",e),this.xmin===void 0?this.setBounds(r,i,n,s):(r<this.xmin&&(this.xmin=r),i<this.ymin&&(this.ymin=i),n>this.xmax&&(this.xmax=n),s>this.ymax&&(this.ymax=s)),this}}function ze(o){const e=["a","b","c"].map(t=>o.properties[t].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(t=>t.map(r=>e[r]).sort().join("-")).sort()}function hn(o,e,t){const r=ze(e.forw),i=ze(e.bakw);if(JSON.stringify(r)!=JSON.stringify(i))throw`${JSON.stringify(e,null,2)}
|
|
2
|
-
${JSON.stringify(
|
|
3
|
-
${JSON.stringify(
|
|
4
|
-
${JSON.stringify(
|
|
5
|
-
${JSON.stringify(i)}`;if(r.forEach(n=>{const s=o[n];if(!s)return;const a=s.filter(c=>c!==e);a.length===0?delete o[n]:o[n]=a}),t){const n=(s,a)=>{!s||!a||(s.features=s.features.filter(c=>c!==a))};n(t.forw,e.forw),n(t.bakw,e.bakw)}}function Ie(o,e,t){return Vt(o,{target:{geom:e,index:t}})}function Te(o){return Vt(o.properties.target.geom,{target:{geom:o.geometry.coordinates,index:o.properties.target.index}})}function fn(o,e){const t=e.geometry.coordinates;return[0,1,2,3].map(r=>{const i=(r+1)%4,n=o[r],s=o[i],a=n.geometry.coordinates,c=Math.atan2(a[0]-t[0],a[1]-t[1]),h=[e,n,s,e].map(g=>g.geometry.coordinates),u={a:{geom:e.properties.target.geom,index:e.properties.target.index},b:{geom:n.properties.target.geom,index:n.properties.target.index},c:{geom:s.properties.target.geom,index:s.properties.target.index}},f=Kt([Me([h],u)]);return[c,f]}).reduce((r,i)=>(r[0].push(i[0]),r[1].push(i[1]),r),[[],[]])}function _i(o){const{tins:e,targets:t,includeReciprocals:r}=o,i={};t.forEach(s=>{const a=e[s];if(!a||!a.features)return;i[s]={};const c={};a.features.forEach(h=>{const u=["a","b","c"];for(let f=0;f<3;f++){const g=(f+1)%3,m=u[f],x=u[g],b=h.properties[m].index,R=h.properties[x].index,Y=[b,R].sort().join("-");if(c[Y])continue;c[Y]=!0;const p=h.geometry.coordinates[0][f],y=h.geometry.coordinates[0][g],l=h.properties[m].geom,v=h.properties[x].geom,M=Math.sqrt(Math.pow(l[0]-v[0],2)+Math.pow(l[1]-v[1],2))/Math.sqrt(Math.pow(p[0]-y[0],2)+Math.pow(p[1]-y[1],2)),A=i[s];A[`${b}:${Y}`]=M,A[`${R}:${Y}`]=M}})});const n={};return r&&(n.bakw={}),t.forEach(s=>{const a=i[s];if(n[s]={},!a)return;const c={};Object.keys(a).forEach(u=>{const[f]=u.split(":");c[f]||(c[f]=[]),c[f].push(a[u])}),Object.keys(c).forEach(u=>{const f=c[u],g=f.reduce((m,x)=>m+x,0)/f.length;n[s][u]=g,r&&n.bakw&&(n.bakw[u]=1/g)});let h=0;for(let u=0;u<4;u++){const f=`b${u}`,g=n[s][f]||0;h+=g}n[s].c=h/4,r&&n.bakw&&(n.bakw.c=1/n[s].c)}),n}function xi(o,e){const t=o.split("-");if(t.length!==2||!t.every(n=>/^-?\d+$/.test(n)))return!1;const[r,i]=t.map(n=>parseInt(n,10)).sort((n,s)=>n-s);return e.some(n=>{if(n.length!==2)return!1;const s=n.map(c=>parseInt(`${c}`,10));if(s.some(c=>Number.isNaN(c)))return!1;const a=s.sort((c,h)=>c-h);return a[0]===r&&a[1]===i})}function Ve(o){return["a","b","c"].map((e,t)=>({prop:o.properties[e],geom:o.geometry.coordinates[0][t]}))}function Mi(o,e,t){const r=new Set;let i=!1;const n=Object.keys(e);for(const s of n){if(r.has(s))continue;r.add(s);const a=e[s];if(!a||a.length<2)continue;const c=s.split("-");if(c.length!==2||xi(s,t))continue;const h=Ve(a[0].bakw),u=Ve(a[1].bakw),f=Ve(a[0].forw),g=Ve(a[1].forw),m=c.map(S=>h.find(O=>`${O.prop.index}`===S)||u.find(O=>`${O.prop.index}`===S)),x=c.map(S=>f.find(O=>`${O.prop.index}`===S)||g.find(O=>`${O.prop.index}`===S));if(m.some(S=>!S)||x.some(S=>!S))continue;const b=[h,u].map(S=>S.find(O=>!c.includes(`${O.prop.index}`))),R=[f,g].map(S=>S.find(O=>!c.includes(`${O.prop.index}`)));if(b.some(S=>!S)||R.some(S=>!S))continue;const Y=a[0].bakw.geometry.coordinates[0].slice(0,3).map(S=>xe(S)),p=a[1].bakw.geometry.coordinates[0].slice(0,3).map(S=>xe(S));if(!(Gn(xe(b[0].geom),p)||Gn(xe(b[1].geom),Y)))continue;const l=x.map(S=>xe(S.geom)),v=R.map(S=>xe(S.geom)),M=Si([...l,...v]),A=ki(M),T=Qn(l[0],l[1],v[0])+Qn(l[0],l[1],v[1]);un(A,T)&&(Kn(e,a[0],o),Kn(e,a[1],o),m.forEach(S=>{if(!S)return;const O=[S.geom,b[0].geom,b[1].geom,S.geom],X={a:S.prop,b:b[0].prop,c:b[1].prop},L=Me([O],X),K=Jt.counterTri(L);hn(e,{forw:K,bakw:L},o)}),i=!0)}return i}function xe(o){return[o[0],o[1]]}function Gn(o,e){const[t,r]=e[0],[i,n]=e[1],[s,a]=e[2],c=s-t,h=a-r,u=i-t,f=n-r,g=o[0]-t,m=o[1]-r,x=c*c+h*h,b=c*u+h*f,R=c*g+h*m,Y=u*u+f*f,p=u*g+f*m,y=x*Y-b*b;if(y===0)return!1;const l=1/y,v=(Y*R-b*p)*l,M=(x*p-b*R)*l,A=1e-9;return v>=-A&&M>=-A&&v+M<=1+A}function Si(o){const e=o.map(s=>s.slice()).filter((s,a,c)=>c.findIndex(h=>un(h[0],s[0])&&un(h[1],s[1]))===a);if(e.length<=1)return e;const t=e.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),i=[];for(const s of t){for(;i.length>=2&&r(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}const n=[];for(let s=t.length-1;s>=0;s--){const a=t[s];for(;n.length>=2&&r(n[n.length-2],n[n.length-1],a)<=0;)n.pop();n.push(a)}return n.pop(),i.pop(),i.concat(n)}function ki(o){if(o.length<3)return 0;let e=0;for(let t=0;t<o.length;t++){const[r,i]=o[t],[n,s]=o[(t+1)%o.length];e+=r*s-n*i}return Math.abs(e)/2}function Qn(o,e,t){return Math.abs((o[0]*(e[1]-t[1])+e[0]*(t[1]-o[1])+t[0]*(o[1]-e[1]))/2)}function un(o,e,t=1e-9){return Math.abs(o-e)<=t}const Hn=typeof Jt.format_version<"u"?Jt.format_version:2.00703;class Tt extends Jt.Transform{constructor(t={}){super();_t(this,"importance");_t(this,"priority");_t(this,"pointsSet");t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||Tt.VERTEX_PLAIN),this.strictMode=t.strictMode||Tt.MODE_AUTO,this.yaxisMode=t.yaxisMode||Tt.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return Hn}setPoints(t){this.yaxisMode===Tt.YAXIS_FOLLOW&&(t=t.map(r=>[r[0],[r[1][0],-1*r[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Jt.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let r=t[0][0],i=r,n=t[0][1],s=n;const a=[t[0]];for(let c=1;c<t.length;c++){const h=t[c];h[0]<r&&(r=h[0]),h[0]>i&&(i=h[0]),h[1]<n&&(n=h[1]),h[1]>s&&(s=h[1]),a.push(h)}a.push(t[0]),this.boundsPolygon=Me([a]),this.xy=[r,n],this.wh=[i-r,s-n],this.vertexMode=Tt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){var i;const t={};t.version=Hn,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer??{},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const r=this.vertices_params.forw[1];return r&&[0,1,2,3].map(n=>{const s=r[n].features[0],a=s.geometry.coordinates[0][1],c=s.properties.b.geom;t.vertices_points[n]=[a,c]}),t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(n=>{t.tins_points[0].push(["a","b","c"].map(s=>n.properties[s].index))}),this.strict_status===Tt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(s=>n.properties[s].index))})):this.strict_status===Tt.STATUS_ERROR&&((i=this.kinks)!=null&&i.bakw)&&(t.kinks_points=this.kinks.bakw.features.map(n=>n.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,t.xy=this.xy,t.wh=this.wh):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){var n;const t=this.tins.forw.features.map(s=>Jt.counterTri(s));this.tins.bakw=Kt(t);const r={};this.tins.forw.features.forEach((s,a)=>{const c=this.tins.bakw.features[a];hn(r,{forw:s,bakw:c})}),Mi(this.tins,r,((n=this.pointsSet)==null?void 0:n.edges)||[]);const i=["forw","bakw"].map(s=>{const a=this.tins[s].features.map(c=>c.geometry.coordinates[0]);return jn(a)});i[0].length===0&&i[1].length===0?(this.strict_status=Tt.STATUS_STRICT,delete this.kinks):(this.strict_status=Tt.STATUS_ERROR,this.kinks={forw:Kt(i[0]),bakw:Kt(i[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let n=0;n<this.points.length;n++){const s=this.points[n][0],a=this.points[n][1],c=Ie(s,a,n);t.forw.push(c),t.bakw.push(Te(c))}const r=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let n=0;n<this.edges.length;n++){const s=this.edges[n][2],a=Object.assign([],this.edges[n][0]),c=Object.assign([],this.edges[n][1]);if(a.length===0&&c.length===0){r.push(s);continue}a.unshift(this.points[s[0]][0]),a.push(this.points[s[1]][0]),c.unshift(this.points[s[0]][1]),c.push(this.points[s[1]][1]);const h=[a,c].map(u=>{const f=u.map((m,x,b)=>{if(x===0)return 0;const R=b[x-1];return Math.sqrt(Math.pow(m[0]-R[0],2)+Math.pow(m[1]-R[1],2))}),g=f.reduce((m,x,b)=>b===0?[0]:(m.push(m[b-1]+x),m),[]);return g.map((m,x,b)=>{const R=m/b[b.length-1];return[u[x],f[x],g[x],R]})});h.map((u,f)=>{const g=h[f?0:1];return u.filter((m,x)=>!(x===0||x===u.length-1||m[4]==="handled")).flatMap(m=>{const x=m[0],b=m[3],R=g.reduce((Y,p,y,l)=>{if(Y)return Y;const v=l[y+1];if(p[3]===b)return p[4]="handled",[p];if(p[3]<b&&v&&v[3]>b)return[p,v]},void 0);if(R&&R.length===1)return f===0?[[x,R[0][0],b]]:[[R[0][0],x,b]];if(R&&R.length===2){const Y=R[0],p=R[1],y=(b-Y[3])/(p[3]-Y[3]),l=[(p[0][0]-Y[0][0])*y+Y[0][0],(p[0][1]-Y[0][1])*y+Y[0][1]];return f===0?[[x,l,b]]:[[l,x,b]]}return[]})}).reduce((u,f)=>u.concat(f),[]).sort((u,f)=>u[2]<f[2]?-1:1).map((u,f,g)=>{this.edgeNodes[i]=[u[0],u[1]];const m=Ie(u[0],u[1],`e${i}`);i++,t.forw.push(m),t.bakw.push(Te(m)),f===0?r.push([s[0],t.forw.length-1]):r.push([t.forw.length-2,t.forw.length-1]),f===g.length-1&&r.push([t.forw.length-1,s[1]])})}return{forw:t.forw,bakw:t.bakw,edges:r}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],r=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],n=this.xy[1]+1.05*this.wh[1];if(!this.points.reduce((c,h)=>c&&(this.bounds?ur(h[0],this.boundsPolygon):h[0][0]>=t&&h[0][0]<=r&&h[0][1]>=i&&h[0][1]<=n),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[r,i],[t,n],[r,n]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:r,miny:i,maxy:n}}updateTin(){let t=this.strictMode;t!==Tt.MODE_STRICT&&t!==Tt.MODE_LOOSE&&(t=Tt.MODE_AUTO);const{pointsSet:r,bbox:i,minx:n,maxx:s,miny:a,maxy:c}=this.validateAndPrepareInputs(),h={forw:Kt(r.forw),bakw:Kt(r.bakw)},u=Oe(h.forw,r.edges,"target"),f=Oe(h.bakw,r.edges,"target");if(u.features.length===0||f.features.length===0)throw"TOO LINEAR1";const g=Sr(h.forw),m=Nn(h.forw);if(!m)throw"TOO LINEAR2";const x={},b=m.geometry.coordinates[0];let R;try{R=b.map(O=>({forw:O,bakw:Jt.transformArr(Vt(O),u)})),R.forEach(O=>{x[`${O.forw[0]}:${O.forw[1]}`]=O})}catch{throw"TOO LINEAR2"}const Y=Nn(h.bakw);if(!Y)throw"TOO LINEAR2";const p=Y.geometry.coordinates[0];try{R=p.map(O=>({bakw:O,forw:Jt.transformArr(Vt(O),f)})),R.forEach(O=>{x[`${O.forw[0]}:${O.forw[1]}`]=O})}catch{throw"TOO LINEAR2"}const y={forw:g.geometry.coordinates,bakw:Jt.transformArr(g,u)},l=Ie(y.forw,y.bakw,"c");this.centroid={forw:l,bakw:Te(l)};const v={convexBuf:x,centroid:y,bbox:i,minx:n,maxx:s,miny:a,maxy:c},M=this.vertexMode===Tt.VERTEX_BIRDEYE?Hr(v):Qr(v),A={forw:[],bakw:[]};for(let O=0;O<M.length;O++){const X=M[O].forw,L=M[O].bakw,K=Ie(X,L,`b${O}`),d=Te(K);r.forw.push(K),r.bakw.push(d),A.forw.push(K),A.bakw.push(d)}this.pointsSet={forw:Kt(r.forw),bakw:Kt(r.bakw),edges:r.edges},this.tins={forw:Jt.rotateVerticesTriangle(Oe(this.pointsSet.forw,r.edges,"target"))},(t===Tt.MODE_STRICT||t===Tt.MODE_AUTO)&&this.calcurateStrictTin(),(t===Tt.MODE_LOOSE||t===Tt.MODE_AUTO&&this.strict_status===Tt.STATUS_ERROR)&&(this.tins.bakw=Jt.rotateVerticesTriangle(Oe(this.pointsSet.bakw,r.edges,"target")),delete this.kinks,this.strict_status=Tt.STATUS_LOOSE),this.vertices_params={forw:fn(A.forw,this.centroid.forw),bakw:fn(A.bakw,this.centroid.bakw)},this.addIndexedTin();const T=["forw"];this.strict_status===Tt.STATUS_LOOSE&&T.push("bakw");const S=this.strict_status===Tt.STATUS_STRICT;this.pointsWeightBuffer=_i({tins:this.tins,targets:T,includeReciprocals:S})}async updateTinAsync(){this.updateTin()}}Yt.Tin=Tt,Yt.constrainedTin=Oe,Yt.counterPoint=Te,Yt.createPoint=Ie,Yt.default=Tt,Yt.findIntersections=jn,Yt.format_version=Jt.format_version,Yt.insertSearchIndex=hn,Yt.vertexCalc=fn,Object.defineProperties(Yt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
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-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u),F=u-E,w=k*F-(l-x*E-k*E-x*F),m=c*f,p=st*c,x=p-(p-c),k=c-x,p=st*f,E=p-(p-f),F=f-E,B=k*F-(m-x*E-k*E-x*F),L=w-B,h=w-L,Ft[0]=w-(L+h)+(h-B),g=l+L,h=g-l,b=l-(g-h)+(L-h),L=b-m,h=b-L,Ft[1]=b-(L+h)+(h-m),O=g+L,h=O-g,Ft[2]=g-(O-h)+(L-h),Ft[3]=O;const X=Ct(_,En,4,Ft,An);return An[X-1]}function Zt(s,t,e,n,r,i){const o=(t-i)*(e-r),a=(s-r)*(n-i),c=o-a,f=Math.abs(o+a);return Math.abs(c)>=sr*f?c:-fr(s,t,e,n,r,i,f)}const hr=(10+96*Dt)*Dt,ur=(4+48*Dt)*Dt,lr=(44+576*Dt)*Dt*Dt,ce=bt(4),fe=bt(4),he=bt(4),te=bt(4),ee=bt(4),ne=bt(4),Yt=bt(4),Lt=bt(4),Ze=bt(8),tn=bt(8),en=bt(8),nn=bt(8),rn=bt(8),on=bt(8),Re=bt(8),Fe=bt(8),Ye=bt(8),de=bt(4),pe=bt(4),me=bt(4),ct=bt(8),lt=bt(16),St=bt(16),kt=bt(16),vt=bt(32),ue=bt(32),Tt=bt(48),jt=bt(64);let ve=bt(1152),sn=bt(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]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,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+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=wt*nt-(xt-ft*ot-wt*ot-ft*nt),W=Nt-Ot,K=Nt-W,O[0]=Nt-(W+K)+(K-Ot),yt=Et+W,K=yt-Et,At=Et-(yt-K)+(W-K),W=At-xt,K=At-W,O[1]=At-(W+K)+(K-xt),Rt=yt+W,K=Rt-yt,O[2]=yt-(Rt-K)+(W-K),O[3]=Rt;const $i=k(Li,m,4,O,B);return B[$i-1]}function P(S,v,A,N,$,V){const z=(v-V)*(A-$),et=(S-$)*(N-V),Z=z-et,it=Math.abs(z+et);return Math.abs(Z)>=L*it?Z:-I(S,v,A,N,$,V,it)}function D(S,v){var A,N,$=0,V,z,et,Z,it,at,K,tt=S[0],ft=S[1],wt=v.length;for(A=0;A<wt;A++){N=0;var ot=v[A],nt=ot.length-1;if(at=ot[0],at[0]!==ot[nt][0]&&at[1]!==ot[nt][1])throw new Error("First and last coordinates in a ring must be the same");for(z=at[0]-tt,et=at[1]-ft,N;N<nt;N++){if(K=ot[N+1],Z=K[0]-tt,it=K[1]-ft,et===0&&it===0){if(Z<=0&&z>=0||z<=0&&Z>=0)return 0}else if(it>=0&&et<=0||it<=0&&et>=0){if(V=P(z,Z,et,it,0,0),V===0)return 0;(V>0&&it>0&&et<=0||V<0&&it<=0&&et>0)&&$++}at=K,et=it,z=Z}}return $%2!==0}function R(S,v,A={}){if(!S)throw new Error("point is required");if(!v)throw new Error("polygon is required");const N=c(S),$=u(v),V=$.type,z=v.bbox;let et=$.coordinates;if(z&&G(N,z)===!1)return!1;V==="Polygon"&&(et=[et]);let Z=!1;for(var it=0;it<et.length;++it){const at=D(N,et[it]);if(at===0)return!A.ignoreBoundary;at&&(Z=!0)}return Z}function G(S,v){return v[0]<=S[0]&&v[1]<=S[1]&&v[2]>=S[0]&&v[3]>=S[1]}function d(S,v){for(let A=0;A<v.features.length;A++)if(R(S,v.features[A]))return v.features[A]}function M(S,v,A){const N=v.geometry.coordinates[0][0],$=v.geometry.coordinates[0][1],V=v.geometry.coordinates[0][2],z=S.geometry.coordinates,et=v.properties.a.geom,Z=v.properties.b.geom,it=v.properties.c.geom,at=[$[0]-N[0],$[1]-N[1]],K=[V[0]-N[0],V[1]-N[1]],tt=[z[0]-N[0],z[1]-N[1]],ft=[Z[0]-et[0],Z[1]-et[1]],wt=[it[0]-et[0],it[1]-et[1]];let ot=(K[1]*tt[0]-K[0]*tt[1])/(at[0]*K[1]-at[1]*K[0]),nt=(at[0]*tt[1]-at[1]*tt[0])/(at[0]*K[1]-at[1]*K[0]);if(A){const W=A[v.properties.a.index],yt=A[v.properties.b.index],At=A[v.properties.c.index];let Et;if(ot<0||nt<0||1-ot-nt<0){const Nt=ot/(ot+nt),xt=nt/(ot+nt);Et=ot/yt/(Nt/yt+xt/At),nt=nt/At/(Nt/yt+xt/At)}else Et=ot/yt/(ot/yt+nt/At+(1-ot-nt)/W),nt=nt/At/(ot/yt+nt/At+(1-ot-nt)/W);ot=Et}return[ot*ft[0]+nt*wt[0]+et[0],ot*ft[1]+nt*wt[1]+et[1]]}function _(S,v,A,N){const $=S.geometry.coordinates,V=A.geometry.coordinates,z=Math.atan2($[0]-V[0],$[1]-V[1]),et=Y(z,v[0]);if(et===void 0)throw new Error("Unable to determine vertex index");const Z=v[1][et];return M(S,Z.features[0],N)}function X(S,v,A,N,$,V,z,et){let Z;if(z&&(Z=d(S,o([z]))),!Z)if(A){const it=S.geometry.coordinates,at=A.gridNum,K=A.xOrigin,tt=A.yOrigin,ft=A.xUnit,wt=A.yUnit,ot=A.gridCache,nt=T(it[0],K,ft,at),W=T(it[1],tt,wt,at),yt=ot[nt]?ot[nt][W]?ot[nt][W]:[]:[],At=o(yt.map(Et=>v.features[Et]));Z=d(S,At)}else Z=d(S,v);return et&&et(Z),Z?M(S,Z,V):_(S,N,$,V)}function T(S,v,A,N){let $=Math.floor((S-v)/A);return $<0&&($=0),$>=N&&($=N-1),$}function Y(S,v){let A=y(S-v[0]),N=Math.PI*2,$;for(let V=0;V<v.length;V++){const z=(V+1)%v.length,et=y(S-v[z]),Z=Math.min(Math.abs(A),Math.abs(et));A*et<=0&&Z<N&&(N=Z,$=V),A=et}return $}function y(S,v=!1){const A=2*Math.PI,N=S-Math.floor(S/A)*A;return v?N:N>Math.PI?N-A:N}function C(S){const v=S.features;for(let A=0;A<v.length;A++){const N=v[A];`${N.properties.a.index}`.substring(0,1)==="b"&&`${N.properties.b.index}`.substring(0,1)==="b"?v[A]={geometry:{type:"Polygon",coordinates:[[N.geometry.coordinates[0][2],N.geometry.coordinates[0][0],N.geometry.coordinates[0][1],N.geometry.coordinates[0][2]]]},properties:{a:{geom:N.properties.c.geom,index:N.properties.c.index},b:{geom:N.properties.a.geom,index:N.properties.a.index},c:{geom:N.properties.b.geom,index:N.properties.b.index}},type:"Feature"}:`${N.properties.c.index}`.substring(0,1)==="b"&&`${N.properties.a.index}`.substring(0,1)==="b"&&(v[A]={geometry:{type:"Polygon",coordinates:[[N.geometry.coordinates[0][1],N.geometry.coordinates[0][2],N.geometry.coordinates[0][0],N.geometry.coordinates[0][1]]]},properties:{a:{geom:N.properties.b.geom,index:N.properties.b.index},b:{geom:N.properties.c.geom,index:N.properties.c.index},c:{geom:N.properties.a.geom,index:N.properties.a.index}},type:"Feature"})}return S}function j(S){const v=["a","b","c","a"].map(V=>S.properties[V].geom),A=S.geometry.coordinates[0],N=S.properties,$={a:{geom:A[0],index:N.a.index},b:{geom:A[1],index:N.b.index},c:{geom:A[2],index:N.c.index}};return i([v],$)}function U(S){const v=[0,1,2,0].map(N=>S[N][0][0]),A={a:{geom:S[0][0][1],index:S[0][1]},b:{geom:S[1][0][1],index:S[1][1]},c:{geom:S[2][0][1],index:S[2][1]}};return i([v],A)}function Q(S,v,A,N,$,V=!1,z){const et=S.map(Z=>{(!z||z<2.00703)&&(Z=H(Z));const it=isFinite(Z)?v[Z]:Z==="c"?N:(function(){const at=Z.match(/^b(\d+)$/);if(at)return $[parseInt(at[1])];const K=Z.match(/^e(\d+)$/);if(K)return A[parseInt(K[1])];throw new Error("Bad index value for indexesToTri")})();return V?[[it[1],it[0]],Z]:[[it[0],it[1]],Z]});return U(et)}function H(S){return typeof S=="number"?S:S.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function rt(S,v){return v&&v>=2.00703||Array.isArray(S[0])?S:S.map(A=>[A.illstNodes,A.mercNodes,A.startEnd])}const J=2.00703;function ut(S){return!!(S.version!==void 0||!S.tins&&S.points&&S.tins_points)}function ht(S){return{points:S.points,pointsWeightBuffer:pt(S),strictStatus:gt(S),verticesParams:mt(S),centroid:Xt(S),edges:rt(S.edges||[]),edgeNodes:S.edgeNodes||[],tins:_t(S),kinks:Mt(S.kinks_points),yaxisMode:S.yaxisMode??"invert",strictMode:S.strictMode??"auto",vertexMode:S.vertexMode,bounds:S.bounds,boundsPolygon:S.boundsPolygon,wh:S.wh,xy:S.xy??[0,0]}}function dt(S){const v=re(S),A=v.tins;return{compiled:v,tins:A,points:we(A),strictStatus:v.strict_status,pointsWeightBuffer:v.weight_buffer,verticesParams:v.vertices_params,centroid:v.centroid,kinks:v.kinks}}function pt(S){return!S.version||S.version<J?["forw","bakw"].reduce((v,A)=>{const N=S.weight_buffer[A];return N&&(v[A]=Object.keys(N).reduce(($,V)=>{const z=H(V);return $[z]=N[V],$},{})),v},{}):S.weight_buffer}function gt(S){return S.strict_status?S.strict_status:S.kinks_points?"strict_error":S.tins_points.length===2?"loose":"strict"}function mt(S){const v={forw:[S.vertices_params[0]],bakw:[S.vertices_params[1]]};return v.forw[1]=It(S,!1),v.bakw[1]=It(S,!0),v}function It(S,v){const A=S.vertices_points.length;return Array.from({length:A},(N,$)=>{const V=($+1)%A,z=Q(["c",`b${$}`,`b${V}`],S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,v,J);return o([z])})}function Xt(S){return{forw:r(S.centroid_point[0],{target:{geom:S.centroid_point[1],index:"c"}}),bakw:r(S.centroid_point[1],{target:{geom:S.centroid_point[0],index:"c"}})}}function _t(S){const v=S.tins_points.length===1?0:1;return{forw:o(S.tins_points[0].map(A=>Q(A,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!1,S.version))),bakw:o(S.tins_points[v].map(A=>Q(A,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!0,S.version)))}}function Mt(S){if(S)return{bakw:o(S.map(v=>r(v)))}}function re(S){return JSON.parse(JSON.stringify(S).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function we(S){const v=[],A=S.forw.features;for(let N=0;N<A.length;N++){const $=A[N];["a","b","c"].forEach((V,z)=>{const et=$.geometry.coordinates[0][z],Z=$.properties[V].geom,it=$.properties[V].index;typeof it=="number"&&(v[it]=[et,Z])})}return v}const wn=J;class $t{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=$t.YAXIS_INVERT;strictMode=$t.MODE_AUTO;vertexMode=$t.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(v){if(ut(v)){this.applyModernState(ht(v));return}this.applyLegacyState(dt(v))}applyModernState(v){this.points=v.points,this.pointsWeightBuffer=v.pointsWeightBuffer,this.strict_status=v.strictStatus,this.vertices_params=v.verticesParams,this.centroid=v.centroid,this.edges=v.edges,this.edgeNodes=v.edgeNodes||[],this.tins=v.tins,this.addIndexedTin(),this.kinks=v.kinks,this.yaxisMode=v.yaxisMode??$t.YAXIS_INVERT,this.vertexMode=v.vertexMode??$t.VERTEX_PLAIN,this.strictMode=v.strictMode??$t.MODE_AUTO,v.bounds?(this.bounds=v.bounds,this.boundsPolygon=v.boundsPolygon,this.xy=v.xy,this.wh=v.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=v.xy??[0,0],v.wh&&(this.wh=v.wh))}applyLegacyState(v){this.tins=v.tins,this.addIndexedTin(),this.strict_status=v.strictStatus,this.pointsWeightBuffer=v.pointsWeightBuffer,this.vertices_params=v.verticesParams,this.centroid=v.centroid,this.kinks=v.kinks,this.points=v.points}addIndexedTin(){const v=this.tins,A=v.forw,N=v.bakw,$=Math.ceil(Math.sqrt(A.features.length));if($<3){this.indexedTins=void 0;return}let V=[],z=[];const et=A.features.map(ot=>{let nt=[];return f(ot)[0].map(W=>{V.length===0?V=[Array.from(W),Array.from(W)]:(W[0]<V[0][0]&&(V[0][0]=W[0]),W[0]>V[1][0]&&(V[1][0]=W[0]),W[1]<V[0][1]&&(V[0][1]=W[1]),W[1]>V[1][1]&&(V[1][1]=W[1])),nt.length===0?nt=[Array.from(W),Array.from(W)]:(W[0]<nt[0][0]&&(nt[0][0]=W[0]),W[0]>nt[1][0]&&(nt[1][0]=W[0]),W[1]<nt[0][1]&&(nt[0][1]=W[1]),W[1]>nt[1][1]&&(nt[1][1]=W[1]))}),nt}),Z=(V[1][0]-V[0][0])/$,it=(V[1][1]-V[0][1])/$,at=et.reduce((ot,nt,W)=>{const yt=T(nt[0][0],V[0][0],Z,$),At=T(nt[1][0],V[0][0],Z,$),Et=T(nt[0][1],V[0][1],it,$),Nt=T(nt[1][1],V[0][1],it,$);for(let xt=yt;xt<=At;xt++){ot[xt]||(ot[xt]=[]);for(let Ot=Et;Ot<=Nt;Ot++)ot[xt][Ot]||(ot[xt][Ot]=[]),ot[xt][Ot].push(W)}return ot},[]),K=N.features.map(ot=>{let nt=[];return f(ot)[0].map(W=>{z.length===0?z=[Array.from(W),Array.from(W)]:(W[0]<z[0][0]&&(z[0][0]=W[0]),W[0]>z[1][0]&&(z[1][0]=W[0]),W[1]<z[0][1]&&(z[0][1]=W[1]),W[1]>z[1][1]&&(z[1][1]=W[1])),nt.length===0?nt=[Array.from(W),Array.from(W)]:(W[0]<nt[0][0]&&(nt[0][0]=W[0]),W[0]>nt[1][0]&&(nt[1][0]=W[0]),W[1]<nt[0][1]&&(nt[0][1]=W[1]),W[1]>nt[1][1]&&(nt[1][1]=W[1]))}),nt}),tt=(z[1][0]-z[0][0])/$,ft=(z[1][1]-z[0][1])/$,wt=K.reduce((ot,nt,W)=>{const yt=T(nt[0][0],z[0][0],tt,$),At=T(nt[1][0],z[0][0],tt,$),Et=T(nt[0][1],z[0][1],ft,$),Nt=T(nt[1][1],z[0][1],ft,$);for(let xt=yt;xt<=At;xt++){ot[xt]||(ot[xt]=[]);for(let Ot=Et;Ot<=Nt;Ot++)ot[xt][Ot]||(ot[xt][Ot]=[]),ot[xt][Ot].push(W)}return ot},[]);this.indexedTins={forw:{gridNum:$,xOrigin:V[0][0],yOrigin:V[0][1],xUnit:Z,yUnit:it,gridCache:at},bakw:{gridNum:$,xOrigin:z[0][0],yOrigin:z[0][1],xUnit:tt,yUnit:ft,gridCache:wt}}}transform(v,A,N){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(A&&this.strict_status==$t.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==$t.YAXIS_FOLLOW&&A&&(v=[v[0],-1*v[1]]);const $=r(v);if(this.bounds&&!A&&!N&&!R($,this.boundsPolygon))return!1;const V=A?this.tins.bakw:this.tins.forw,z=A?this.indexedTins.bakw:this.indexedTins.forw,et=A?this.vertices_params.bakw:this.vertices_params.forw,Z=A?this.centroid.bakw:this.centroid.forw,it=A?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let at,K;this.stateFull&&(this.stateBackward==A?at=this.stateTriangle:(this.stateBackward=A,this.stateTriangle=void 0),K=ft=>{this.stateTriangle=ft});let tt=X($,V,z,et,Z,it,at,K);if(this.bounds&&A&&!N){const ft=r(tt);if(!R(ft,this.boundsPolygon))return!1}else this.yaxisMode==$t.YAXIS_FOLLOW&&!A&&(tt=[tt[0],-1*tt[1]]);return tt}}const zt=20037508342789244e-9,Ke=[[0,0],[0,1],[1,0],[0,-1],[-1,0]];function Me(S,v){return Math.floor(Math.min(S[0],S[1])/4)*zt/128/Math.pow(2,v)}function Ce(S,v){const A=[];for(let N=0;N<S.length;N++){const $=S[N],V=$[0]*Math.cos(v)-$[1]*Math.sin(v),z=$[0]*Math.sin(v)+$[1]*Math.cos(v);A.push([V,z])}return A}function ye(S,v,A,N){const $=Me(N,v);return Ce(Ke,A).map(V=>[V[0]*$+S[0],V[1]*$+S[1]])}function yn(S,v){const A=S[0],N=S.slice(1,5).map(tt=>[tt[0]-A[0],tt[1]-A[1]]),$=[[0,1],[1,0],[0,-1],[-1,0]];let V=0,z=0,et=0;for(let tt=0;tt<4;tt++){const ft=N[tt],wt=$[tt],ot=Math.sqrt(Math.pow(ft[0],2)+Math.pow(ft[1],2));V+=ot;const nt=ft[0]*wt[1]-ft[1]*wt[0],W=Math.acos((ft[0]*wt[0]+ft[1]*wt[1])/ot),yt=nt>0?-1*W:W;z+=Math.cos(yt),et+=Math.sin(yt)}const Z=V/4,it=Math.atan2(et,z),at=Math.floor(Math.min(v[0],v[1])/4),K=Math.log(at*zt/128/Z)/Math.log(2);return{center:A,zoom:K,rotation:it}}function Qe(S,v){const A=S[0]*(2*zt)/v-zt,N=-1*(S[1]*(2*zt)/v-zt);return[A,N]}function bn(S,v){const A=(S[0]+zt)*v/(2*zt),N=(-S[1]+zt)*v/(2*zt);return[A,N]}const xn=256;class Fi{mainTin=null;subTins=[];_maxxy=0;setMapData(v){const A=new $t;if(A.setCompiled(v.compiled),this.mainTin=A,v.maxZoom!==void 0)this._maxxy=Math.pow(2,v.maxZoom)*xn;else if(v.compiled.wh){const N=Math.max(v.compiled.wh[0],v.compiled.wh[1]),$=Math.ceil(Math.log2(N/xn));this._maxxy=Math.pow(2,$)*xn}if(this.subTins=[],v.sub_maps)for(const N of v.sub_maps){const $=new $t;$.setCompiled(N.compiled);const V=N.bounds??N.compiled.bounds;if(!V)throw new Error("SubMapData must have bounds or compiled.bounds to create xyBounds polygon");const z=[...V,V[0]],et=z.map(Z=>{const it=$.transform(Z,!1);if(!it)throw new Error("Failed to transform sub-map bounds to mercator");return it});this.subTins.push({tin:$,priority:N.priority,importance:N.importance,xyBounds:i([z]),mercBounds:i([et])})}}xy2Merc(v){const A=this.xy2MercWithLayer(v);return A?A[1]:!1}merc2Xy(v){const A=this.merc2XyWithLayer(v),N=A[0]||A[1];return N?N[1]:!1}xy2MercWithLayer(v){this._assertMapData();const A=this._getTinsSortedByPriority();for(let N=0;N<A.length;N++){const{index:$,isMain:V}=A[N];if(V||R(r(v),this.subTins[$-1].xyBounds)){const z=this._transformByIndex(v,$,!1);if(z===!1)continue;return[$,z]}}return!1}merc2XyWithLayer(v){return this._assertMapData(),this._getAllTinsWithIndex().map(({index:A,tin:N,isMain:$})=>{const V=this._transformByIndex(v,A,!0);return V===!1?[N,A]:$||R(r(V),this.subTins[A-1].xyBounds)?[N,A,V]:[N,A]}).sort((A,N)=>{const $=A[0].priority??0,V=N[0].priority??0;return $<V?1:-1}).reduce((A,N,$,V)=>{const z=N[0],et=N[1],Z=N[2];if(!Z)return A;for(let it=0;it<$;it++){const at=V[it][1],K=at===0;if(V[it][2]&&(K||R(r(Z),this.subTins[at-1].xyBounds)))if(A.length){const tt=!A[0],ft=tt?A[1][2]:A[0][2],wt=z.importance??0,ot=ft.importance??0;return tt?wt<ot?A:[void 0,[et,Z,z]]:[...A.filter(nt=>nt!==void 0),[et,Z,z]].sort((nt,W)=>(nt[2].importance??0)<(W[2].importance??0)?1:-1).slice(0,2)}else return[[et,Z,z]]}return!A.length||!A[0]?[[et,Z,z]]:(A.push([et,Z,z]),A.sort((it,at)=>{const K=it[2].importance??0,tt=at[2].importance??0;return K<tt?1:-1}).filter((it,at)=>at<2))},[]).map(A=>{if(A)return[A[0],A[1]]})}mercs2SysCoords(v){this._assertMapData();const A=this.merc2XyWithLayer(v[0]);let N=!1;return A.map(($,V)=>{if(!$){N=!0;return}const z=$[0],et=$[1];return V!==0&&!N?[this.xy2SysCoordInternal(et)]:v.map((Z,it)=>it===0?et:this._transformByIndex(Z,z,!0)).map(Z=>this.xy2SysCoordInternal(Z))})}viewpoint2Mercs(v,A){this._assertMapData(),this._assertMaxxy();const N=ye(v.center,v.zoom,v.rotation,A).map(et=>bn(et,this._maxxy)),$=this.xy2MercWithLayer(N[0]);if(!$)throw new Error("viewpoint2Mercs: center point is out of bounds");const V=$[0],z=$[1];return N.map((et,Z)=>{if(Z===0)return z;const it=this._transformByIndex(et,V,!1);if(it===!1)throw new Error(`viewpoint2Mercs: point ${Z} is out of bounds`);return it})}mercs2Viewpoint(v,A){this._assertMapData(),this._assertMaxxy();const N=this.merc2XyWithLayer(v[0]),$=N[0]||N[1];if(!$)throw new Error("mercs2Viewpoint: center point is out of bounds");const V=$[0],z=$[1],et=v.map((Z,it)=>{if(it===0)return z;const at=this._transformByIndex(Z,V,!0);if(at===!1)throw new Error(`mercs2Viewpoint: point ${it} is out of bounds`);return at}).map(Z=>Qe(Z,this._maxxy));return yn(et,A)}static zoom2Radius(v,A){return Me(v,A)}static mercViewpoint2Mercs(v,A,N,$){return ye(v,A,N,$)}static mercs2MercViewpoint(v,A){return yn(v,A)}static xy2SysCoord(v,A){return Qe(v,A)}static sysCoord2Xy(v,A){return bn(v,A)}_assertMapData(){if(!this.mainTin)throw new Error("setMapData() must be called before transformation")}_assertMaxxy(){if(this._maxxy===0)throw new Error("MapData.maxZoom or compiled.wh must be set for viewpoint conversion (xy2SysCoord / sysCoord2Xy)")}getLayerTransform(v){if(v===0)return this.mainTin;const A=this.subTins[v-1];return A?A.tin:null}get layerCount(){return 1+this.subTins.length}get maxxy(){return this._maxxy}_getTinsSortedByPriority(){return this._getAllTinsWithIndex().sort((v,A)=>{const N=v.tin.priority??0,$=A.tin.priority??0;return N<$?1:-1})}_getAllTinsWithIndex(){const v=[{index:0,tin:this.mainTin,isMain:!0}];return this.subTins.forEach((A,N)=>{A.tin.priority=A.priority,A.tin.importance=A.importance,v.push({index:N+1,tin:A.tin,isMain:!1})}),v}_transformByIndex(v,A,N){if(A===0)return this.mainTin.transform(v,N);const $=this.subTins[A-1];return $?$.tin.transform(v,N,!0):!1}xy2SysCoordInternal(v){return Qe(v,this._maxxy)}}e.MERC_CROSSMATRIX=Ke,e.MERC_MAX=zt,e.MapTransform=Fi,e.Transform=$t,e.counterTri=j,e.format_version=wn,e.mercViewpoint2Mercs=ye,e.mercs2MercViewpoint=yn,e.normalizeEdges=rt,e.rotateMatrix=Ce,e.rotateVerticesTriangle=C,e.sysCoord2Xy=bn,e.transformArr=X,e.xy2SysCoord=Qe,e.zoom2Radius=Me,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}))})(Ae,Ae.exports)),Ae.exports}var Ut=jr();const Ln=Math.pow(2,-52),Ue=new Uint32Array(512);class hn{static from(t,e=Gr,n=Jr){const r=t.length,i=new Float64Array(r*2);for(let o=0;o<r;o++){const a=t[o];i[2*o]=e(a),i[2*o+1]=n(a)}return new hn(i)}constructor(t){const e=t.length>>1;if(e>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const n=Math.max(2*e-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:n,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let a=1/0,c=1/0,f=-1/0,u=-1/0;for(let I=0;I<o;I++){const P=t[2*I],D=t[2*I+1];P<a&&(a=P),D<c&&(c=D),P>f&&(f=P),D>u&&(u=D),this._ids[I]=I}const h=(a+f)/2,p=(c+u)/2;let x,k,E;for(let I=0,P=1/0;I<o;I++){const D=un(h,p,t[2*I],t[2*I+1]);D<P&&(x=I,P=D)}const F=t[2*x],L=t[2*x+1];for(let I=0,P=1/0;I<o;I++){if(I===x)continue;const D=un(F,L,t[2*I],t[2*I+1]);D<P&&D>0&&(k=I,P=D)}let g=t[2*k],b=t[2*k+1],l=1/0;for(let I=0;I<o;I++){if(I===x||I===k)continue;const P=zr(F,L,g,b,t[2*I],t[2*I+1]);P<l&&(E=I,l=P)}let w=t[2*E],m=t[2*E+1];if(l===1/0){for(let D=0;D<o;D++)this._dists[D]=t[2*D]-t[0]||t[2*D+1]-t[1];_e(this._ids,this._dists,0,o-1);const I=new Uint32Array(o);let P=0;for(let D=0,R=-1/0;D<o;D++){const G=this._ids[D],d=this._dists[G];d>R&&(I[P++]=G,R=d)}this.hull=I.subarray(0,P),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Zt(F,L,g,b,w,m)<0){const I=k,P=g,D=b;k=E,g=w,b=m,E=I,w=P,m=D}const B=Wr(F,L,g,b,w,m);this._cx=B.x,this._cy=B.y;for(let I=0;I<o;I++)this._dists[I]=un(t[2*I],t[2*I+1],B.x,B.y);_e(this._ids,this._dists,0,o-1),this._hullStart=x;let O=3;n[x]=e[E]=k,n[k]=e[x]=E,n[E]=e[k]=x,r[x]=0,r[k]=1,r[E]=2,i.fill(-1),i[this._hashKey(F,L)]=x,i[this._hashKey(g,b)]=k,i[this._hashKey(w,m)]=E,this.trianglesLen=0,this._addTriangle(x,k,E,-1,-1,-1);for(let I=0,P,D;I<this._ids.length;I++){const R=this._ids[I],G=t[2*R],d=t[2*R+1];if(I>0&&Math.abs(G-P)<=Ln&&Math.abs(d-D)<=Ln||(P=G,D=d,R===x||R===k||R===E))continue;let M=0;for(let y=0,C=this._hashKey(G,d);y<this._hashSize&&(M=i[(C+y)%this._hashSize],!(M!==-1&&M!==n[M]));y++);M=e[M];let _=M,X;for(;X=n[_],Zt(G,d,t[2*_],t[2*_+1],t[2*X],t[2*X+1])>=0;)if(_=X,_===M){_=-1;break}if(_===-1)continue;let T=this._addTriangle(_,R,n[_],-1,-1,r[_]);r[R]=this._legalize(T+2),r[_]=T,O++;let Y=n[_];for(;X=n[Y],Zt(G,d,t[2*Y],t[2*Y+1],t[2*X],t[2*X+1])<0;)T=this._addTriangle(Y,R,X,r[R],-1,r[Y]),r[R]=this._legalize(T+2),n[Y]=Y,O--,Y=X;if(_===M)for(;X=e[_],Zt(G,d,t[2*X],t[2*X+1],t[2*_],t[2*_+1])<0;)T=this._addTriangle(X,R,_,-1,r[_],r[X]),this._legalize(T+2),r[X]=T,n[_]=_,O--,_=X;this._hullStart=e[R]=_,n[_]=e[Y]=R,n[R]=Y,i[this._hashKey(G,d)]=R,i[this._hashKey(t[2*_],t[2*_+1])]=_}this.hull=new Uint32Array(O);for(let I=0,P=this._hullStart;I<O;I++)this.hull[I]=P,P=n[P];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(qr(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:n,coords:r}=this;let i=0,o=0;for(;;){const a=n[t],c=t-t%3;if(o=c+(t+2)%3,a===-1){if(i===0)break;t=Ue[--i];continue}const f=a-a%3,u=c+(t+1)%3,h=f+(a+2)%3,p=e[o],x=e[t],k=e[u],E=e[h];if(Ur(r[2*p],r[2*p+1],r[2*x],r[2*x+1],r[2*k],r[2*k+1],r[2*E],r[2*E+1])){e[t]=E,e[a]=p;const L=n[h];if(L===-1){let b=this._hullStart;do{if(this._hullTri[b]===h){this._hullTri[b]=t;break}b=this._hullPrev[b]}while(b!==this._hullStart)}this._link(t,L),this._link(a,n[o]),this._link(o,h);const g=f+(a+1)%3;i<Ue.length&&(Ue[i++]=g)}else{if(i===0)break;t=Ue[--i]}}return o}_link(t,e){this._halfedges[t]=e,e!==-1&&(this._halfedges[e]=t)}_addTriangle(t,e,n,r,i,o){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=e,this._triangles[a+2]=n,this._link(a,r),this._link(a+1,i),this._link(a+2,o),this.trianglesLen+=3,a}}function qr(s,t){const e=s/(Math.abs(s)+Math.abs(t));return(t>0?3-e:1+e)/4}function un(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function Ur(s,t,e,n,r,i,o,a){const c=s-o,f=t-a,u=e-o,h=n-a,p=r-o,x=i-a,k=c*c+f*f,E=u*u+h*h,F=p*p+x*x;return c*(h*F-E*x)-f*(u*F-E*p)+k*(u*x-h*p)<0}function zr(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),x=(f*u-a*h)*p,k=(o*h-c*u)*p;return x*x+k*k}function Wr(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),x=s+(f*u-a*h)*p,k=t+(o*h-c*u)*p;return{x,y:k}}function _e(s,t,e,n){if(n-e<=20)for(let r=e+1;r<=n;r++){const i=s[r],o=t[i];let a=r-1;for(;a>=e&&t[s[a]]>o;)s[a+1]=s[a--];s[a+1]=i}else{const r=e+n>>1;let i=e+1,o=n;Ie(s,r,i),t[s[e]]>t[s[n]]&&Ie(s,e,n),t[s[i]]>t[s[n]]&&Ie(s,i,n),t[s[e]]>t[s[i]]&&Ie(s,e,i);const a=s[i],c=t[a];for(;;){do i++;while(t[s[i]]<c);do o--;while(t[s[o]]>c);if(o<i)break;Ie(s,i,o)}s[e+1]=s[o],s[o]=a,n-i+1>=o-e?(_e(s,t,i,n),_e(s,t,e,o-1)):(_e(s,t,e,o-1),_e(s,t,i,n))}}function Ie(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Gr(s){return s[0]}function Jr(s){return s[1]}class Kr{bs;width;constructor(t,e){this.width=t,this.bs=e}add(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]|=1<<n,this}delete(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]&=~(1<<n),this}set(t,e){const n=Math.floor(t/this.width),i=1<<t%this.width;return this.bs[n]^=(-Number(e)^this.bs[n])&i,e}has(t){const e=Math.floor(t/this.width),n=t%this.width;return(this.bs[e]&1<<n)!==0}forEach(t){const e=this.bs.length;for(let n=0;n<e;n++){let r=0;for(;this.bs[n]&&r<this.width;)this.bs[n]&1<<r&&t(n*this.width+r),r++}return this}}class $n extends Kr{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function ge(s){return s%3===2?s-2:s+1}function oe(s){return s%3===0?s+2:s-1}function Vn(s,t,e,n,r,i,o,a){const c=Zt(s,t,r,i,o,a),f=Zt(e,n,r,i,o,a);if(c>0&&f>0||c<0&&f<0)return!1;const u=Zt(r,i,s,t,e,n),h=Zt(o,a,s,t,e,n);return u>0&&h>0||u<0&&h<0?!1:c===0&&f===0&&u===0&&h===0?!(Math.max(r,o)<Math.min(s,e)||Math.max(s,e)<Math.min(r,o)||Math.max(i,a)<Math.min(t,n)||Math.max(t,n)<Math.min(i,a)):!0}class Qr{del;constructor(t){this.del=t}}class Hr extends Qr{vertMap;flips;consd;constructor(t,e){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);const n=2**32-1,r=t.coords.length>>1,i=t.triangles.length;this.vertMap=new Uint32Array(r).fill(n),this.flips=new $n(i),this.consd=new $n(i);for(let o=0;o<i;o++){const a=t.triangles[o];this.vertMap[a]===n&&this.updateVert(o)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:n,halfedges:r}=this.del,i=this.vertMap[t];let o=i;do{const f=n[o],u=ge(o);if(f===e)return this.protect(o);const h=oe(o),p=n[h];if(p===e)return this.protect(u),u;if(this.intersectSegments(t,e,p,f)){o=h;break}o=r[u]}while(o!==-1&&o!==i);let a=o,c=-1;for(;o!==-1;){const f=r[o],u=oe(o),h=oe(f),p=ge(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(o))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,e,n[o])||this.isCollinear(t,e,n[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(n[o],n[f],n[u],n[h])){if(c===-1&&(c=o),n[h]===e){if(o===c)throw new Error("Infinite loop: non-convex quadrilateral");o=c,c=-1;continue}if(this.intersectSegments(t,e,n[h],n[f]))o=h;else if(this.intersectSegments(t,e,n[p],n[h]))o=p;else if(c===o)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(o),this.intersectSegments(t,e,n[u],n[h])&&(c===-1&&(c=u),c===u))throw new Error("Infinite loop: flipped diagonal still intersects");n[h]===e?(a=h,o=c,c=-1):this.intersectSegments(t,e,n[p],n[h])&&(o=p)}return this.protect(a),this.delaunify(!0),this.findEdge(t,e)}delaunify(t=!1){const{halfedges:e}=this.del,n=this.flips,r=this.consd,i=e.length;let o;do{o=0;for(let a=0;a<i;a++){if(r.has(a))continue;n.delete(a);const c=e[a];c!==-1&&(n.delete(c),this.isDelaunay(a)||(this.flipDiagonal(a),o++))}}while(t&&o>0);return this}constrainAll(t){const e=t.length;for(let n=0;n<e;n++){const r=t[n];this.constrainOne(r[0],r[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const n=this.vertMap[e],{triangles:r,halfedges:i}=this.del;let o=n,a=-1;do{if(r[o]===t)return o;a=ge(o),o=i[a]}while(o!==-1&&o!==n);return r[ge(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],n=this.flips,r=this.consd;return n.delete(t),r.add(t),e!==-1?(n.delete(e),r.add(e),e):-t}markFlip(t){const e=this.del.halfedges,n=this.flips;if(this.consd.has(t))return!1;const i=e[t];return i!==-1&&(n.add(t),n.add(i)),!0}flipDiagonal(t){const{triangles:e,halfedges:n}=this.del,r=this.flips,i=this.consd,o=n[t],a=oe(t),c=ge(t),f=oe(o),u=ge(o),h=n[a],p=n[f];if(i.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[f],n[t]=p,r.set(t,r.has(f))||i.set(t,i.has(f)),p!==-1&&(n[p]=t),n[a]=f,e[o]=e[a],n[o]=h,r.set(o,r.has(a))||i.set(o,i.has(a)),h!==-1&&(n[h]=o),n[f]=a,this.markFlip(t),this.markFlip(c),this.markFlip(o),this.markFlip(u),r.add(a),i.delete(a),r.add(f),i.delete(f),this.updateVert(t),this.updateVert(c),this.updateVert(o),this.updateVert(u),a}isCollinear(t,e,n){const r=this.del.coords;return Zt(r[t*2],r[t*2+1],r[e*2],r[e*2+1],r[n*2],r[n*2+1])===0}inCircle(t,e,n,r){const i=this.del.coords;return pr(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:n}=this.del,r=n[t];if(r===-1)return!0;const i=e[oe(t)],o=e[t],a=e[ge(t)],c=e[oe(r)];return!this.inCircle(i,o,a,c)}updateVert(t){const{triangles:e,halfedges:n}=this.del,r=this.vertMap,i=e[t];let o=oe(t),a=n[o];for(;a!==-1&&a!==t;)o=oe(a),a=n[o];return r[i]=o,o}intersectSegments(t,e,n,r){const i=this.del.coords;return t===n||t===r||e===n||e===r?!1:Vn(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])}static intersectSegments=Vn}function Te(s,t,e){if(t||(t=[]),typeof s!="object"||s.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const n=s.features.map(c=>c.geometry.coordinates),r=hn.from(n);let i;const o=[];r.triangles.length!==0&&t.length!==0&&(i=new Hr(r),i.constrainAll(t));for(let c=0;c<r.triangles.length;c+=3)o.push([r.triangles[c],r.triangles[c+1],r.triangles[c+2]]);const a=["a","b","c"];return Gt(o.map(c=>{const f={},u=c.map((h,p)=>{const x=s.features[h],k=x.geometry.coordinates,E=[k[0],k[1]];return k.length===3?E[2]=k[2]:f[a[p]]=x.properties[e],E});return u[3]=u[0],Se([u],f)}))}function Zr(s,t){const e=[[],[],[],[]],n=[];return Object.keys(s).forEach(r=>{const i=s[r],o=i.forw,a=i.bakw,c=[o[0]-t.forw[0],o[1]-t.forw[1]],f=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:c,bakw:f};if(n.push(u),c[0]===0||c[1]===0)return;let h=0;c[0]>0&&(h+=1),c[1]>0&&(h+=2),e[h].push(u)}),{perQuad:e,aggregate:n}}function ti(s){let t=1/0,e=0,n=0;return s.forEach(r=>{const{forw:i,bakw:o}=r,a=Math.hypot(i[0],i[1]),c=Math.hypot(o[0],o[1]);if(c===0)return;const f=a/c,u=Math.atan2(i[0],i[1])-Math.atan2(o[0],o[1]);t=Math.min(t,f),e+=Math.cos(u),n+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(n,e)]:[1,0]}function ei(s,t,e){const{perQuad:n,aggregate:r}=Zr(s,t),i=n.every(c=>c.length>0),a=(e==="birdeye"?i?n:[r]:[r]).map(c=>ti(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function ni(s,t){let e=0;return s[0]>t[0]&&(e+=1),s[1]>t[1]&&(e+=2),e}function ri(s,t,e){const n=[s[0]-t.forw[0],s[1]-t.forw[1]],i=Math.sqrt(n[0]**2+n[1]**2)/e[0],o=Math.atan2(n[0],n[1])-e[1];return[t.bakw[0]+i*Math.sin(o),t.bakw[1]-i*Math.cos(o)]}function ii(s,t,e,n){const r=t[0]-s[0],i=t[1]-s[1];if(Math.abs(r)<1e-12&&Math.abs(i)<1e-12)return null;const o=n[0]-e[0],a=n[1]-e[1],c=e[0]-s[0],f=e[1]-s[1],u=r*a-i*o;if(Math.abs(u)<1e-12)return null;const h=(c*a-f*o)/u,p=(c*i-f*r)/u;return h<=1e-10||p<-1e-10||p>1+1e-10?null:{t:h,point:[s[0]+h*r,s[1]+h*i]}}function oi(s,t,e){const n=e.length;let r=-1/0,i=null;for(let o=0;o<n;o++){const a=(o+1)%n,c=ii(s,t,e[o].bakw,e[a].bakw);c&&c.t>r&&(r=c.t,i=c.point)}return i}function jn(s,t){const n=Math.atan2(s[0]-t[0],s[1]-t[1])*(180/Math.PI);return n<0?n+360:n}function qn(s,t,e,n,r,i){const o=t[0]-s[0],a=t[1]-s[1];if(o===0&&a===0)return null;const c=[];if(o!==0)for(const u of[e,n]){const h=(u-s[0])/o;if(h>0){const p=s[1]+h*a;p>=r&&p<=i&&c.push({t:h,x:u,y:p})}}if(a!==0)for(const u of[r,i]){const h=(u-s[1])/a;if(h>0){const p=s[0]+h*o;p>=e&&p<=n&&c.push({t:h,x:p,y:u})}}if(c.length===0)return null;c.sort((u,h)=>u.t-h.t);const f=c[0];return[f.x,f.y]}function Un(s,t,e){const n=s.length,r=new Array(n).fill(1);for(const i of t)for(let o=0;o<n;o++){const a=(o+1)%n,c=vn([s[o].bakw,s[a].bakw]),f=vn([e.bakw,i.bakw]),u=kr(c,f);if(u.features.length>0&&u.features[0].geometry){const h=u.features[0],p=Math.sqrt(Math.pow(i.bakw[0]-e.bakw[0],2)+Math.pow(i.bakw[1]-e.bakw[1],2)),x=Math.sqrt(Math.pow(h.geometry.coordinates[0]-e.bakw[0],2)+Math.pow(h.geometry.coordinates[1]-e.bakw[1],2)),k=p/x;k>r[o]&&(r[o]=k),k>r[a]&&(r[a]=k)}}s.forEach((i,o)=>{const a=r[o];i.bakw=[(i.bakw[0]-e.bakw[0])*a+e.bakw[0],(i.bakw[1]-e.bakw[1])*a+e.bakw[1]]})}function zn(s,t,e){const{convexBuf:n,centroid:r,allGcps:i,minx:o,maxx:a,miny:c,maxy:f}=s,u=ei(n,r,t),p=[[o,c],[a,c],[a,f],[o,f]].map(m=>({forw:m,bakw:ri(m,r,u[ni(m,r.forw)])}));if(p.sort((m,B)=>Math.atan2(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])-Math.atan2(B.forw[0]-r.forw[0],B.forw[1]-r.forw[1])),Un(p,i,r),!e)return p;const x=4,k=p.map(m=>Math.atan2(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])),E=p.map(m=>Math.atan2(m.bakw[0]-r.bakw[0],-(m.bakw[1]-r.bakw[1])));function F(m){for(let B=0;B<x;B++){const O=(B+1)%x,I=k[B],P=B<x-1?k[O]:k[O]+2*Math.PI;let D=m;for(;D<I;)D+=2*Math.PI;for(;D>=I+2*Math.PI;)D-=2*Math.PI;if(D>=I&&D<P)return{i:B,j:O,frac:(D-I)/(P-I)}}return{i:0,j:1,frac:0}}function L(m){const{i:B,j:O,frac:I}=F(m),P=E[B];let R=E[O]-P;for(;R>Math.PI;)R-=2*Math.PI;for(;R<-Math.PI;)R+=2*Math.PI;return P+I*R}const g=new Set(p.map(m=>Math.floor(jn(m.forw,r.forw)/10)%36)),b=i.map(m=>({forw:m.forw,bakw:m.bakw,angleDeg:jn(m.forw,r.forw),forwDist:Math.hypot(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])})),l=[];for(let m=0;m<36;m++){if(g.has(m))continue;const B=m*10,O=b.filter(M=>M.angleDeg>=B&&M.angleDeg<B+10);let I=null;if(O.length>0){const M=O.reduce((_,X)=>X.forwDist>_.forwDist?X:_);I=qn(r.forw,M.forw,o,a,c,f)}if(!I){const M=(B+5)%360*(Math.PI/180),_=[r.forw[0]+Math.sin(M),r.forw[1]+Math.cos(M)];I=qn(r.forw,_,o,a,c,f)}if(!I)continue;const P=[I[0]-r.forw[0],I[1]-r.forw[1]],D=Math.atan2(P[0],P[1]),R=L(D),G=[r.bakw[0]+Math.sin(R),r.bakw[1]-Math.cos(R)],d=oi(r.bakw,G,p);d&&l.push({forw:I,bakw:d})}const w=[...p,...l];return w.sort((m,B)=>Math.atan2(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])-Math.atan2(B.forw[0]-r.forw[0],B.forw[1]-r.forw[1])),Un(w,i,r),w}function si(s,t=!1){return zn(s,"plain",t)}function ai(s,t=!1){return zn(s,"birdeye",t)}function Wn(s){const e=new ci(s).findSegmentIntersections(),n=Zn(e),r=new Map;return n.forEach(i=>{r.set(`${i.x}:${i.y}`,i)}),Array.from(r.values()).map(i=>ae([i.x,i.y]))}class ci{_xx;_yy;_ii;_nn;_zz=null;_zlimit=0;_bb=null;_allBounds=null;_arcIter=null;_filteredArcIter=null;buf;constructor(t){this.initArcs(t)}initArcs(t){const e=[],n=[],r=t.map(i=>{const o=i?i.length:0;for(let a=0;a<o;a++)e.push(i[a][0]),n.push(i[a][1]);return o});this.initXYData(r,e,n)}initXYData(t,e,n){const r=t.length;this._xx=new Float64Array(e),this._yy=new Float64Array(n),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(r);let i=0;for(let o=0;o<r;o++)this._ii[o]=i,i+=t[o];(i!=this._xx.length||this._xx.length!=this._yy.length)&&ln("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Ii(this._xx,this._yy)}initBounds(){const t=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=t.bb,this._allBounds=t.bounds}calcArcBounds_(t,e,n){const r=n.length,i=new Float64Array(r*4),o=new Pe;let a=0,c,f,u;for(let h=0;h<r;h++)c=n[h],c>0&&(f=h*4,u=Ti(t,e,a,c),i[f++]=u[0],i[f++]=u[1],i[f++]=u[2],i[f]=u[3],a+=c,o.mergeBounds(u));return{bb:i,bounds:o}}getBounds(){return this._allBounds?this._allBounds.clone():new Pe}forEachSegment(t){let e=0;for(let n=0,r=this.size();n<r;n++)e+=this.forEachArcSegment(n,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const n=t>=0,r=n?t:~t,i=this.getRetainedInterval(),o=this._nn[r],a=n?1:-1;let c=n?this._ii[r]:this._ii[r]+o-1,f=c,u=0;for(let h=1;h<o;h++)f+=a,(i===0||this._zz[f]>=i)&&(e(c,f,this._xx,this._yy),c=f,u++);return u}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(t){const e=t*4;return(!this.buf||this.buf.byteLength<e)&&(this.buf=new ArrayBuffer(e)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,e=0;const n=this.forEachSegment((r,i,o,a)=>{t+=Math.abs(o[r]-o[i]),e+=Math.abs(a[r]-a[i])});return[t/n||0,e/n||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),e=this.getAvgSegment2()[1];let n=1;return e>0&&t>0&&(n=Math.ceil(t/e/20)),n||1}findSegmentIntersections(){const t=this.getBounds(),e=t.ymin||0,n=(t.ymax||0)-e,r=this.calcSegmentIntersectionStripeCount(),i=new Uint32Array(r),o=r>1?E=>Math.floor((r-1)*(E-e)/n):()=>0;let a,c;this.forEachSegment((E,F,L,g)=>{let b=o(g[E]);const l=o(g[F]);for(;i[b]=i[b]+2,b!=l;)b+=l>b?1:-1});const f=this.getUint32Array(ui(i));let u=0;const h=[];li(i,E=>{const F=u;u+=E,h.push(f.subarray(F,u))}),di(i,0),this.forEachSegment((E,F,L,g)=>{let b=o(g[E]);const l=o(g[F]);let w,m;for(;w=i[b],i[b]=w+2,m=h[b],m[w]=E,m[w+1]=F,b!=l;)b+=l>b?1:-1});const p=this.getVertexData(),x=[];let k;for(a=0;a<r;a++)if(p.xx&&p.yy)for(k=pi(h[a],p.xx,p.yy),c=0;c<k.length;c++)x.push(k[c]);return Zn(x)}}function ln(...s){const t=s.join(" ");throw new Error(t)}function dn(s){return s?hi(s)?!0:fi(s)?!1:s.length===0?!0:s.length>0:!1}function fi(s){return s!=null&&s.toString===String.prototype.toString}function hi(s){return Array.isArray(s)}function ui(s,t){dn(s)||ln("utils.sum() expects an array, received:",s);let e=0,n;for(let r=0,i=s.length;r<i;r++)n=s[r],n&&(e+=n);return e}function li(s,t,e){if(!dn(s))throw new Error(`#forEach() takes an array-like argument. ${s}`);for(let n=0,r=s.length;n<r;n++)t.call(e,s[n],n)}function di(s,t){for(let e=0,n=s.length;e<n;e++)s[e]=t;return s}function pi(s,t,e){const n=s.length-2,r=[];let i,o,a,c,f,u,h,p,x,k,E,F,L,g,b,l,w;for(Si(t,s),l=0;l<n;){for(i=s[l],o=s[l+1],f=t[i],u=t[o],x=e[i],k=e[o],w=l;w<n&&(w+=2,a=s[w],h=t[a],!(u<h));){if(E=e[a],c=s[w+1],p=t[c],F=e[c],x>=E){if(x>F&&k>E&&k>F)continue}else if(x<F&&k<E&&k<F)continue;i==a||i==c||o==a||o==c||(L=mi(f,x,u,k,h,E,p,F),L&&(g=[i,o],b=[a,c],r.push(Qn(L,g,b,t,e)),L.length==4&&r.push(Qn(L.slice(2),g,b,t,e))))}l+=2}return r}function mi(s,t,e,n,r,i,o,a){const c=gi(s,t,e,n,r,i,o,a);let f=null;return c&&(f=wi(s,t,e,n,r,i,o,a),f?Mi(s,t,e,n,r,i,o,a)&&(f=null):f=_i(s,t,e,n,r,i,o,a)),f}function gi(s,t,e,n,r,i,o,a){return Be(s,t,e,n,r,i)*Be(s,t,e,n,o,a)<=0&&Be(r,i,o,a,s,t)*Be(r,i,o,a,e,n)<=0}function Be(s,t,e,n,r,i){return Gn(s-r,t-i,e-r,n-i)}function Gn(s,t,e,n){return s*n-t*e}function wi(s,t,e,n,r,i,o,a){let c=ze(s,t,e,n,r,i,o,a),f;return c&&(f=bi(c[0],c[1],s,t,e,n,r,i,o,a),f==1?c=ze(e,n,s,t,r,i,o,a):f==2?c=ze(r,i,o,a,s,t,e,n):f==3&&(c=ze(o,a,r,i,s,t,e,n))),c&&vi(c,s,t,e,n,r,i,o,a),c}function ze(s,t,e,n,r,i,o,a){const c=Gn(e-s,n-t,o-r,a-i),f=1e-18;let u;if(c===0)return null;const h=Be(r,i,o,a,s,t)/c;return c<=f&&c>=-f?u=yi(s,t,e,n,r,i,o,a):u=[s+h*(e-s),t+h*(n-t)],u}function yi(s,t,e,n,r,i,o,a){let c=null;return!se(s,r,o)&&!se(t,i,a)?c=[s,t]:!se(e,r,o)&&!se(n,i,a)?c=[e,n]:!se(r,s,e)&&!se(i,t,n)?c=[r,i]:!se(o,s,e)&&!se(a,t,n)&&(c=[o,a]),c}function se(s,t,e){let n;return t<e?n=s<t||s>e:t>e?n=s>t||s<e:n=s!=t,n}function bi(s,t,...e){let n=-1,r=1/0,i;for(let o=0,a=0,c=e.length;a<c;o++,a+=2)i=xi(s,t,e[a],e[a+1]),i<r&&(r=i,n=o);return n}function xi(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function vi(s,t,e,n,r,i,o,a,c){let f=s[0],u=s[1];f=We(f,t,n),f=We(f,i,a),u=We(u,e,r),u=We(u,o,c),s[0]=f,s[1]=u}function We(s,t,e){let n;return se(s,t,e)&&(n=Math.abs(s-t)<Math.abs(s-e)?t:e,s=n),s}function _i(s,t,e,n,r,i,o,a){const c=Math.min(s,e,r,o),f=Math.max(s,e,r,o),u=Math.min(t,n,i,a),h=Math.max(t,n,i,a),p=h-u>f-c;let x=[];return(p?le(t,u,h):le(s,c,f))&&x.push(s,t),(p?le(n,u,h):le(e,c,f))&&x.push(e,n),(p?le(i,u,h):le(r,c,f))&&x.push(r,i),(p?le(a,u,h):le(o,c,f))&&x.push(o,a),(x.length!=2&&x.length!=4||x.length==4&&x[0]==x[2]&&x[1]==x[3])&&(x=null),x}function Mi(s,t,e,n,r,i,o,a){return s==r&&t==i||s==o&&t==a||e==r&&n==i||e==o&&n==a}function le(s,t,e){return s>t&&s<e}function Si(s,t){ki(s,t),Jn(s,t,0,t.length-2)}function ki(s,t){for(let e=0,n=t.length;e<n;e+=2)s[t[e]]>s[t[e+1]]&&Ei(t,e,e+1)}function Ei(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Jn(s,t,e,n){let r=e,i=n,o,a;for(;r<n;){for(o=s[t[e+n>>2<<1]];r<=i;){for(;s[t[r]]<o;)r+=2;for(;s[t[i]]>o;)i-=2;r<=i&&(a=t[r],t[r]=t[i],t[i]=a,a=t[r+1],t[r+1]=t[i+1],t[i+1]=a,r+=2,i-=2)}if(i-e<40?Kn(s,t,e,i):Jn(s,t,e,i),n-r<40){Kn(s,t,r,n);return}e=r,i=n}}function Kn(s,t,e,n){let r,i;for(let o=e+2;o<=n;o+=2){r=t[o],i=t[o+1];let a;for(a=o-2;a>=e&&s[r]<s[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=r,t[a+3]=i}}function Qn(s,t,e,n,r){const i=s[0],o=s[1];t=Hn(i,o,t[0],t[1],n,r),e=Hn(i,o,e[0],e[1],n,r);const a=t[0]<e[0]?t:e,c=a==t?e:t;return{x:i,y:o,a,b:c}}function Hn(s,t,e,n,r,i){let o=e<n?e:n,a=o===e?n:e;return r[o]==s&&i[o]==t?a=o:r[a]==s&&i[a]==t&&(o=a),[o,a]}function Zn(s){const t={};return s.filter(e=>{const n=Ai(e);return n in t?!1:(t[n]=!0,!0)})}function Ai(s){return`${s.a.join(",")};${s.b.join(",")}`}class Ii{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,e){this._xx=t,this._yy=e}}function Ti(s,t,e,n){let r=e|0;const i=isNaN(n)?s.length-r:n+r;let o,a,c,f,u,h;if(i>0)c=u=s[r],f=h=t[r];else return[void 0,void 0,void 0,void 0];for(r++;r<i;r++)o=s[r],a=t[r],o<c&&(c=o),o>u&&(u=o),a<f&&(f=a),a>h&&(h=a);return[c,f,u,h]}class Pe{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new Pe(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,e,n,r){let i,o,a,c;if(arguments.length==1)if(dn(t)){const f=t;i=f[0],o=f[1],a=f[2],c=f[3]}else{const f=t;i=f.xmin,o=f.ymin,a=f.xmax,c=f.ymax}else i=t,o=e,a=n,c=r;return this.xmin=i,this.ymin=o,this.xmax=a,this.ymax=c,(i>a||o>c)&&this.update(),this}update(){let t;this.xmin>this.xmax&&(t=this.xmin,this.xmin=this.xmax,this.xmax=t),this.ymin>this.ymax&&(t=this.ymin,this.ymin=this.ymax,this.ymax=t)}mergeBounds(t,...e){let n,r,i,o;return t instanceof Pe?(n=t.xmin,r=t.ymin,i=t.xmax,o=t.ymax):e.length==3?(n=t,r=e[0],i=e[1],o=e[2]):t.length==4?(n=t[0],r=t[1],i=t[2],o=t[3]):ln("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(n,r,i,o):(n<this.xmin&&(this.xmin=n),r<this.ymin&&(this.ymin=r),i>this.xmax&&(this.xmax=i),o>this.ymax&&(this.ymax=o)),this}}function Ge(s){const t=["a","b","c"].map(e=>s.properties[e].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(e=>e.map(n=>t[n]).sort().join("-")).sort()}function pn(s,t,e){const n=Ge(t.forw),r=Ge(t.bakw);if(JSON.stringify(n)!=JSON.stringify(r))throw`${JSON.stringify(t,null,2)}
|
|
2
|
+
${JSON.stringify(n)}
|
|
3
|
+
${JSON.stringify(r)}`;for(let i=0;i<n.length;i++){const o=n[i];s[o]||(s[o]=[]),s[o].push(t)}e&&(e.forw.features.push(t.forw),e.bakw.features.push(t.bakw))}function tr(s,t,e){const n=Ge(t.forw),r=Ge(t.bakw);if(JSON.stringify(n)!=JSON.stringify(r))throw`${JSON.stringify(t,null,2)}
|
|
4
|
+
${JSON.stringify(n)}
|
|
5
|
+
${JSON.stringify(r)}`;if(n.forEach(i=>{const o=s[i];if(!o)return;const a=o.filter(c=>c!==t);a.length===0?delete s[i]:s[i]=a}),e){const i=(o,a)=>{!o||!a||(o.features=o.features.filter(c=>c!==a))};i(e.forw,t.forw),i(e.bakw,t.bakw)}}function Oe(s,t,e){return ae(s,{target:{geom:t,index:e}})}function Ne(s){return ae(s.properties.target.geom,{target:{geom:s.geometry.coordinates,index:s.properties.target.index}})}function mn(s,t){const e=s.length,n=t.geometry.coordinates;return Array.from({length:e},(r,i)=>i).map(r=>{const i=(r+1)%e,o=s[r],a=s[i],c=o.geometry.coordinates,f=Math.atan2(c[0]-n[0],c[1]-n[1]),u=[t,o,a,t].map(x=>x.geometry.coordinates),h={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:o.properties.target.geom,index:o.properties.target.index},c:{geom:a.properties.target.geom,index:a.properties.target.index}},p=Gt([Se([u],h)]);return[f,p]}).reduce((r,i)=>(r[0].push(i[0]),r[1].push(i[1]),r),[[],[]])}function Bi(s){const{tins:t,targets:e,includeReciprocals:n,numBoundaryVertices:r=4}=s,i={};e.forEach(a=>{const c=t[a];if(!c||!c.features)return;i[a]={};const f={};c.features.forEach(u=>{const h=["a","b","c"];for(let p=0;p<3;p++){const x=(p+1)%3,k=h[p],E=h[x],F=u.properties[k].index,L=u.properties[E].index,g=[F,L].sort().join("-");if(f[g])continue;f[g]=!0;const b=u.geometry.coordinates[0][p],l=u.geometry.coordinates[0][x],w=u.properties[k].geom,m=u.properties[E].geom,B=Math.sqrt(Math.pow(w[0]-m[0],2)+Math.pow(w[1]-m[1],2))/Math.sqrt(Math.pow(b[0]-l[0],2)+Math.pow(b[1]-l[1],2)),O=i[a];O[`${F}:${g}`]=B,O[`${L}:${g}`]=B}})});const o={};return n&&(o.bakw={}),e.forEach(a=>{const c=i[a];if(o[a]={},!c)return;const f={};Object.keys(c).forEach(h=>{const[p]=h.split(":");f[p]||(f[p]=[]),f[p].push(c[h])}),Object.keys(f).forEach(h=>{const p=f[h],x=p.reduce((k,E)=>k+E,0)/p.length;o[a][h]=x,n&&o.bakw&&(o.bakw[h]=1/x)});let u=0;for(let h=0;h<r;h++){const p=`b${h}`,x=o[a][p]||0;u+=x}o[a].c=u/r,n&&o.bakw&&(o.bakw.c=1/o[a].c)}),o}function Je(s,t=1e-6){const[e,n]=s[0],[r,i]=s[1],[o,a]=s[2];return Math.abs((r-e)*(a-n)-(o-e)*(i-n))<t}function Pi(s,t){const e=s.split("-");if(e.length!==2||!e.every(i=>/^-?\d+$/.test(i)))return!1;const[n,r]=e.map(i=>parseInt(i,10)).sort((i,o)=>i-o);return t.some(i=>{if(i.length!==2)return!1;const o=i.map(c=>parseInt(`${c}`,10));if(o.some(c=>Number.isNaN(c)))return!1;const a=o.sort((c,f)=>c-f);return a[0]===n&&a[1]===r})}function Xe(s){return["a","b","c"].map((t,e)=>({prop:s.properties[t],geom:s.geometry.coordinates[0][e]}))}const Oi=10;function Ni(s,t,e,n,r,i){if(!s&&!t)return!1;const o=s?0:1,a=1-o,c=e[o],f=e[a];if(!c||!f)return!1;const u=qt(f.geom);let h=!1,p=!1;for(let x=0;x<=1;x++){const k=n[x];if(!k)continue;const E=[String(k.prop.index),String(c.prop.index)].sort().join("-"),F=r[E];if(!F||F.length<2)continue;const L=F.find(D=>D.bakw!==i[o].bakw);if(!L)continue;const b=Xe(L.bakw).find(D=>String(D.prop.index)!==String(k.prop.index)&&String(D.prop.index)!==String(c.prop.index));if(!b)continue;h=!0;const l=qt(b.geom),w=qt(k.geom),m=qt(c.geom),B=m[0]-w[0],O=m[1]-w[1],I=B*(u[1]-w[1])-O*(u[0]-w[0]),P=B*(l[1]-w[1])-O*(l[0]-w[0]);if(I*P>0){p=!0;break}}return h&&!p}function Xi(s,t,e,n){if(!s&&!t)return!1;if(e[0]&&e[1]&&n[0]&&n[1]){const r=n.map(u=>qt(u.geom)),i=e.map(u=>qt(u.geom)),o=r[1][0]-r[0][0],a=r[1][1]-r[0][1],c=o*(i[0][1]-r[0][1])-a*(i[0][0]-r[0][0]),f=o*(i[1][1]-r[0][1])-a*(i[1][0]-r[0][0]);return c*f<0}return!1}function Ci(s,t,e){const n=new Set;let r=!1;for(let i=0;i<Oi;i++){let o=!1;for(const a of Object.keys(t)){if(n.has(a))continue;n.add(a);const c=t[a];if(!c||c.length<2)continue;const f=a.split("-");if(f.length!==2||Pi(a,e))continue;const u=Xe(c[0].bakw),h=Xe(c[1].bakw),p=Xe(c[0].forw),x=Xe(c[1].forw),k=f.map(T=>u.find(Y=>`${Y.prop.index}`===T)||h.find(Y=>`${Y.prop.index}`===T)),E=f.map(T=>p.find(Y=>`${Y.prop.index}`===T)||x.find(Y=>`${Y.prop.index}`===T));if(k.some(T=>!T)||E.some(T=>!T))continue;const F=[u,h].map(T=>T.find(Y=>!f.includes(`${Y.prop.index}`))),L=[p,x].map(T=>T.find(Y=>!f.includes(`${Y.prop.index}`)));if(F.some(T=>!T)||L.some(T=>!T))continue;const g=c[0].bakw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),b=c[1].bakw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),l=c[0].forw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),w=c[1].forw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),m=Je(g),B=Je(b),O=Je(l),I=Je(w),P=Ni(m,B,F,k,t,c),D=Xi(O,I,F,k);if(!(P||D||er(qt(F[0].geom),b)||er(qt(F[1].geom),g)))continue;const G=E.map(T=>qt(T.geom)),d=L.map(T=>qt(T.geom)),M=Di([...G,...d]),_=Ri(M),X=nr(G[0],G[1],d[0])+nr(G[0],G[1],d[1]);gn(_,X)&&(tr(t,c[0],s),tr(t,c[1],s),k.forEach(T=>{if(!T)return;const Y=[T.geom,F[0].geom,F[1].geom,T.geom],y={a:T.prop,b:F[0].prop,c:F[1].prop},C=Se([Y],y),j=Ut.counterTri(C);pn(t,{forw:j,bakw:C},s)}),o=!0,r=!0)}if(!o)break}return r}function qt(s){return[s[0],s[1]]}function er(s,t){const[e,n]=t[0],[r,i]=t[1],[o,a]=t[2],c=o-e,f=a-n,u=r-e,h=i-n,p=s[0]-e,x=s[1]-n,k=c*c+f*f,E=c*u+f*h,F=c*p+f*x,L=u*u+h*h,g=u*p+h*x,b=k*L-E*E;if(b===0)return!1;const l=1/b,w=(L*F-E*g)*l,m=(k*g-E*F)*l,B=1e-9;return w>=-B&&m>=-B&&w+m<=1+B}function Di(s){const t=s.map(o=>o.slice()).filter((o,a,c)=>c.findIndex(f=>gn(f[0],o[0])&&gn(f[1],o[1]))===a);if(t.length<=1)return t;const e=t.sort((o,a)=>o[0]===a[0]?o[1]-a[1]:o[0]-a[0]),n=(o,a,c)=>(a[0]-o[0])*(c[1]-o[1])-(a[1]-o[1])*(c[0]-o[0]),r=[];for(const o of e){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const a=e[o];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),r.pop(),r.concat(i)}function Ri(s){if(s.length<3)return 0;let t=0;for(let e=0;e<s.length;e++){const[n,r]=s[e],[i,o]=s[(e+1)%s.length];t+=n*o-i*r}return Math.abs(t)/2}function nr(s,t,e){return Math.abs((s[0]*(t[1]-e[1])+t[0]*(e[1]-s[1])+e[0]*(s[1]-t[1]))/2)}function gn(s,t,e=1e-9){return Math.abs(s-t)<=e}const rr=3;class Pt extends Ut.Transform{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||Pt.VERTEX_PLAIN),this.strictMode=t.strictMode||Pt.MODE_AUTO,this.yaxisMode=t.yaxisMode||Pt.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,this.useV2Algorithm=t.useV2Algorithm??!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return this.useV2Algorithm?Ut.format_version:rr}setPoints(t){this.yaxisMode===Pt.YAXIS_FOLLOW&&(t=t.map(e=>[e[0],[e[1][0],-1*e[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Ut.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let e=t[0][0],n=e,r=t[0][1],i=r;const o=[t[0]];for(let a=1;a<t.length;a++){const c=t[a];c[0]<e&&(e=c[0]),c[0]>n&&(n=c[0]),c[1]<r&&(r=c[1]),c[1]>i&&(i=c[1]),o.push(c)}o.push(t[0]),this.boundsPolygon=Se([o]),this.xy=[e,r],this.wh=[n-e,i-r],this.vertexMode=Pt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?Ut.format_version:rr,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer??{},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const e=this.vertices_params.forw[1];if(e)for(let n=0;n<e.length;n++){const r=e[n].features[0],i=r.geometry.coordinates[0][1],o=r.properties.b.geom;t.vertices_points[n]=[i,o]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(n=>{t.tins_points[0].push(["a","b","c"].map(r=>n.properties[r].index))}),this.strict_status===Pt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(r=>n.properties[r].index))})):this.strict_status===Pt.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(n=>n.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,this.useV2Algorithm&&(t.xy=this.xy,t.wh=this.wh)):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setCompiled(t){super.setCompiled(t)}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){const t=this.tins.forw.features.map(r=>Ut.counterTri(r));this.tins.bakw=Gt(t);const e={};this.tins.forw.features.forEach((r,i)=>{const o=this.tins.bakw.features[i];pn(e,{forw:r,bakw:o})}),Ci(this.tins,e,this.pointsSet?.edges||[]);const n=["forw","bakw"].map(r=>{const i=this.tins[r].features.map(o=>o.geometry.coordinates[0]);return Wn(i)});n[0].length===0&&n[1].length===0?(this.strict_status=Pt.STATUS_STRICT,delete this.kinks):(this.strict_status=Pt.STATUS_ERROR,this.kinks={forw:Gt(n[0]),bakw:Gt(n[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let r=0;r<this.points.length;r++){const i=this.points[r][0],o=this.points[r][1],a=Oe(i,o,r);t.forw.push(a),t.bakw.push(Ne(a))}const e=[];let n=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let r=0;r<this.edges.length;r++){const i=this.edges[r][2],o=Object.assign([],this.edges[r][0]),a=Object.assign([],this.edges[r][1]);if(o.length===0&&a.length===0){e.push(i);continue}o.unshift(this.points[i[0]][0]),o.push(this.points[i[1]][0]),a.unshift(this.points[i[0]][1]),a.push(this.points[i[1]][1]);const c=[o,a].map(f=>{const u=f.map((p,x,k)=>{if(x===0)return 0;const E=k[x-1];return Math.sqrt(Math.pow(p[0]-E[0],2)+Math.pow(p[1]-E[1],2))}),h=u.reduce((p,x,k)=>k===0?[0]:(p.push(p[k-1]+x),p),[]);return h.map((p,x,k)=>{const E=p/k[k.length-1];return[f[x],u[x],h[x],E]})});c.map((f,u)=>{const h=c[u?0:1];return f.filter((p,x)=>!(x===0||x===f.length-1||p[4]==="handled")).flatMap(p=>{const x=p[0],k=p[3],E=h.reduce((F,L,g,b)=>{if(F)return F;const l=b[g+1];if(L[3]===k)return L[4]="handled",[L];if(L[3]<k&&l&&l[3]>k)return[L,l]},void 0);if(E&&E.length===1)return u===0?[[x,E[0][0],k]]:[[E[0][0],x,k]];if(E&&E.length===2){const F=E[0],L=E[1],g=(k-F[3])/(L[3]-F[3]),b=[(L[0][0]-F[0][0])*g+F[0][0],(L[0][1]-F[0][1])*g+F[0][1]];return u===0?[[x,b,k]]:[[b,x,k]]}return[]})}).reduce((f,u)=>f.concat(u),[]).sort((f,u)=>f[2]<u[2]?-1:1).map((f,u,h)=>{this.edgeNodes[n]=[f[0],f[1]];const p=Oe(f[0],f[1],`e${n}`);n++,t.forw.push(p),t.bakw.push(Ne(p)),u===0?e.push([i[0],t.forw.length-1]):e.push([t.forw.length-2,t.forw.length-1]),u===h.length-1&&e.push([t.forw.length-1,i[1]])})}return{forw:t.forw,bakw:t.bakw,edges:e}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],e=this.xy[0]+1.05*this.wh[0],n=this.xy[1]-.05*this.wh[1],r=this.xy[1]+1.05*this.wh[1];if(this.bounds&&!this.boundsPolygon)throw new Error("Internal error: bounds is set but boundsPolygon is missing");const i=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((c,f)=>c&&(i?an(f[0],i):f[0][0]>=t&&f[0][0]<=e&&f[0][1]>=n&&f[0][1]<=r),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,n],[e,n],[t,r],[e,r]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:e,miny:n,maxy:r}}computeGcpBbox(){let t=1/0,e=-1/0,n=1/0,r=-1/0;for(const a of this.points){const c=a[0][0],f=a[0][1];c<t&&(t=c),c>e&&(e=c),f<n&&(n=f),f>r&&(r=f)}const i=e-t,o=r-n;return{minx:t-.05*i,maxx:e+.05*i,miny:n-.05*o,maxy:r+.05*o}}updateTin(){let t=this.strictMode;t!==Pt.MODE_STRICT&&t!==Pt.MODE_LOOSE&&(t=Pt.MODE_AUTO);const e=!this.useV2Algorithm;let n,r,i,o,a;if(e){if(this.bounds){const P=this.boundsPolygon;if(!P)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(R=>an(R[0],P)))throw"SOME POINTS OUTSIDE"}n=this.generatePointsSet(),{minx:r,maxx:i,miny:o,maxy:a}=this.computeGcpBbox()}else{const P=this.validateAndPrepareInputs();n=P.pointsSet,r=P.minx,i=P.maxx,o=P.miny,a=P.maxy}const c={forw:Gt(n.forw),bakw:Gt(n.bakw)},f=Te(c.forw,n.edges,"target"),u=Te(c.bakw,n.edges,"target");if(f.features.length===0||u.features.length===0)throw"TOO LINEAR1";const h=Ir(c.forw),p=Fn(c.forw);if(!p)throw"TOO LINEAR2";const x={},k=p.geometry.coordinates[0];let E;try{E=k.map(P=>({forw:P,bakw:Ut.transformArr(ae(P),f)})),E.forEach(P=>{x[`${P.forw[0]}:${P.forw[1]}`]=P})}catch{throw"TOO LINEAR2"}const F=Fn(c.bakw);if(!F)throw"TOO LINEAR2";const L=F.geometry.coordinates[0];try{E=L.map(P=>({bakw:P,forw:Ut.transformArr(ae(P),u)})),E.forEach(P=>{x[`${P.forw[0]}:${P.forw[1]}`]=P})}catch{throw"TOO LINEAR2"}let g;if(e){const P=h.geometry.coordinates,D=f.features.find(R=>an(ae(P),R));if(D){const R=D.geometry.coordinates[0],G=D.properties.a.geom,d=D.properties.b.geom,M=D.properties.c.geom;g={forw:[(R[0][0]+R[1][0]+R[2][0])/3,(R[0][1]+R[1][1]+R[2][1])/3],bakw:[(G[0]+d[0]+M[0])/3,(G[1]+d[1]+M[1])/3]}}else g={forw:P,bakw:Ut.transformArr(h,f)}}else g={forw:h.geometry.coordinates,bakw:Ut.transformArr(h,f)};const b=Oe(g.forw,g.bakw,"c");this.centroid={forw:b,bakw:Ne(b)};const l=[...this.points.map(P=>({forw:P[0],bakw:P[1]})),...(this.edgeNodes??[]).map(P=>({forw:P[0],bakw:P[1]}))],w={convexBuf:x,centroid:g,allGcps:l,minx:r,maxx:i,miny:o,maxy:a},m=this.vertexMode===Pt.VERTEX_BIRDEYE?ai(w,e):si(w,e),B={forw:[],bakw:[]};for(let P=0;P<m.length;P++){const D=m[P].forw,R=m[P].bakw,G=Oe(D,R,`b${P}`),d=Ne(G);n.forw.push(G),n.bakw.push(d),B.forw.push(G),B.bakw.push(d)}this.pointsSet={forw:Gt(n.forw),bakw:Gt(n.bakw),edges:n.edges},this.tins={forw:Ut.rotateVerticesTriangle(Te(this.pointsSet.forw,n.edges,"target"))},(t===Pt.MODE_STRICT||t===Pt.MODE_AUTO)&&this.calcurateStrictTin(),(t===Pt.MODE_LOOSE||t===Pt.MODE_AUTO&&this.strict_status===Pt.STATUS_ERROR)&&(this.tins.bakw=Ut.rotateVerticesTriangle(Te(this.pointsSet.bakw,n.edges,"target")),delete this.kinks,this.strict_status=Pt.STATUS_LOOSE),this.vertices_params={forw:mn(B.forw,this.centroid.forw),bakw:mn(B.bakw,this.centroid.bakw)},this.addIndexedTin();const O=["forw"];this.strict_status===Pt.STATUS_LOOSE&&O.push("bakw");const I=this.strict_status===Pt.STATUS_STRICT;this.pointsWeightBuffer=Bi({tins:this.tins,targets:O,includeReciprocals:I,numBoundaryVertices:m.length})}async updateTinAsync(){this.updateTin()}}Vt.Tin=Pt,Vt.constrainedTin=Te,Vt.counterPoint=Ne,Vt.createPoint=Oe,Vt.default=Pt,Vt.findIntersections=Wn,Vt.format_version=Ut.format_version,Vt.insertSearchIndex=pn,Vt.vertexCalc=mn,Object.defineProperties(Vt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/dist/tin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Feature, Point, Position } from 'geojson';
|
|
2
|
-
import { Transform, Compiled, Edge, EdgeSet, EdgeSetLegacy, PointSet, StrictMode, VertexMode, YaxisMode } from '@maplat/transform';
|
|
2
|
+
import { Transform, Compiled, CompiledLegacy, Edge, EdgeSet, EdgeSetLegacy, PointSet, StrictMode, VertexMode, YaxisMode } from '@maplat/transform';
|
|
3
3
|
import { PointsSetBD } from "./types/tin.d";
|
|
4
4
|
/**
|
|
5
5
|
* Tinクラスの初期化オプション
|
|
@@ -15,6 +15,8 @@ export interface Options {
|
|
|
15
15
|
stateFull?: boolean;
|
|
16
16
|
points?: PointSet[];
|
|
17
17
|
edges?: EdgeSet[];
|
|
18
|
+
/** true にすると v2 アルゴリズム(wh bbox・turf 重心・4 境界頂点)で build する */
|
|
19
|
+
useV2Algorithm?: boolean;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Tin (Triangulated Irregular Network) クラス
|
|
@@ -24,6 +26,7 @@ export declare class Tin extends Transform {
|
|
|
24
26
|
importance: number;
|
|
25
27
|
priority: number;
|
|
26
28
|
pointsSet: PointsSetBD | undefined;
|
|
29
|
+
useV2Algorithm: boolean;
|
|
27
30
|
/**
|
|
28
31
|
* Tinクラスのインスタンスを生成します
|
|
29
32
|
* @param options - 初期化オプション
|
|
@@ -51,6 +54,13 @@ export declare class Tin extends Transform {
|
|
|
51
54
|
* 現在の設定を永続化可能な形式にコンパイルします
|
|
52
55
|
*/
|
|
53
56
|
getCompiled(): Compiled;
|
|
57
|
+
/**
|
|
58
|
+
* コンパイルされた設定を適用します(v3+フォーマット対応)
|
|
59
|
+
*
|
|
60
|
+
* バージョン3以上のコンパイル済みデータが渡された場合は restoreV3State() を
|
|
61
|
+
* 使用してN頂点対応の復元を行います。それ以外は基底クラスの実装に委譲します。
|
|
62
|
+
*/
|
|
63
|
+
setCompiled(compiled: Compiled | CompiledLegacy): void;
|
|
54
64
|
/**
|
|
55
65
|
* 幅と高さを設定します
|
|
56
66
|
*/
|
|
@@ -80,6 +90,11 @@ export declare class Tin extends Transform {
|
|
|
80
90
|
* 入力データの検証と初期データの準備
|
|
81
91
|
*/
|
|
82
92
|
private validateAndPrepareInputs;
|
|
93
|
+
/**
|
|
94
|
+
* Compute a bounding box derived from GCP coordinates with a 5% margin.
|
|
95
|
+
* Used in V3 plain mode where no explicit image bounds are available.
|
|
96
|
+
*/
|
|
97
|
+
private computeGcpBbox;
|
|
83
98
|
/**
|
|
84
99
|
* TINネットワークを同期的に更新し、座標変換の準備を行います。
|
|
85
100
|
* 重めの計算を伴うため、呼び出し側が非同期制御を行いたい場合は
|
package/dist/vertexutils.d.ts
CHANGED
|
@@ -16,9 +16,13 @@ declare function createPoint(xy: Position, geom: Position, index: string | numbe
|
|
|
16
16
|
declare function counterPoint(apoint: Feature<Point>): Feature<Point>;
|
|
17
17
|
/**
|
|
18
18
|
* 頂点リストから頂点パラメータを計算する
|
|
19
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* N 個の境界頂点(v2 では常に 4 個、v3 では任意)に対応した汎用版。
|
|
21
|
+
* 各頂点について (重心, b_i, b_{(i+1)%N}) の扇形三角形と角度を計算する。
|
|
22
|
+
*
|
|
23
|
+
* @param list 境界頂点リスト(N 個)
|
|
20
24
|
* @param centroid 重心点
|
|
21
|
-
* @returns [
|
|
25
|
+
* @returns [角度リスト(N 個), 三角形リスト(N 個)]
|
|
22
26
|
*/
|
|
23
27
|
declare function vertexCalc(list: Feature<Point>[], centroid: Feature<Point>): [number[], Tins[]?];
|
|
24
28
|
export { counterPoint, createPoint, vertexCalc };
|
package/dist/weight-buffer.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ interface WeightBufferOptions {
|
|
|
3
3
|
tins: TinsBD;
|
|
4
4
|
targets: Array<keyof TinsBD>;
|
|
5
5
|
includeReciprocals: boolean;
|
|
6
|
+
/** Number of boundary vertices (b0..b{N-1}). Defaults to 4 for v2 format. */
|
|
7
|
+
numBoundaryVertices?: number;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* Calculate per-point stretch ratios used for non-linear interpolation.
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.14.1",
|
|
8
8
|
"description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"module": "./dist/maplat_tin.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"deno"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@maplat/transform": "0.
|
|
52
|
+
"@maplat/transform": "0.5.2",
|
|
53
53
|
"@turf/turf": "^7.3.1",
|
|
54
54
|
"delaunator": "^5.0.1",
|
|
55
55
|
"robust-predicates": "^3.0.2"
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"@types/delaunator": "^5.0.3",
|
|
61
61
|
"@types/estree": "^1.0.8",
|
|
62
62
|
"@types/geojson": "^7946.0.16",
|
|
63
|
-
"@types/node": "^
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
65
|
-
"@typescript-eslint/parser": "^8.
|
|
63
|
+
"@types/node": "^25.5.1",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
|
65
|
+
"@typescript-eslint/parser": "^8.58.0",
|
|
66
66
|
"@vitest/coverage-v8": "^3.2.4",
|
|
67
67
|
"cross-env": "^10.1.0",
|
|
68
|
-
"dotenv": "^17.
|
|
68
|
+
"dotenv": "^17.4.0",
|
|
69
69
|
"dotenv-cli": "^11.0.0",
|
|
70
70
|
"eslint": "^9.39.2",
|
|
71
71
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"prettier": "^3.7.4",
|
|
76
76
|
"robust-segment-intersect": "^1.0.1",
|
|
77
77
|
"typescript": "^5.9.3",
|
|
78
|
-
"typescript-eslint": "^8.
|
|
79
|
-
"vite": "^
|
|
78
|
+
"typescript-eslint": "^8.58.0",
|
|
79
|
+
"vite": "^7.3.0",
|
|
80
80
|
"vite-plugin-dts": "^4.5.4",
|
|
81
81
|
"vitest": "^3.2.4"
|
|
82
82
|
},
|