@maplat/tin 0.11.4 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +30 -35
- package/README.md +30 -35
- package/dist/boundary-vertices.d.ts +27 -0
- package/dist/edgebound/base.d.ts +31 -0
- package/dist/edgebound/bitset.d.ts +58 -0
- package/dist/edgebound/constrain.d.ts +68 -0
- package/dist/edgebound/index.d.ts +4 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.html +19 -12
- package/dist/maplat_tin.cjs +4 -2
- package/dist/maplat_tin.js +2641 -1592
- package/dist/maplat_tin.umd.js +4 -2
- package/dist/searchutils.d.ts +11 -2
- package/dist/strict-overlap.d.ts +5 -0
- package/dist/tin.d.ts +12 -18
- package/dist/weight-buffer.d.ts +11 -0
- package/package.json +40 -41
- package/src/boundary-vertices.ts +284 -0
- package/src/constrained-tin.ts +1 -1
- package/src/edgebound/base.ts +65 -0
- package/src/edgebound/bitset.ts +109 -0
- package/src/edgebound/constrain.license.txt +15 -0
- package/src/edgebound/constrain.ts +498 -0
- package/src/edgebound/index.ts +10 -0
- package/src/index.ts +1 -0
- package/src/kinks.ts +13 -16
- package/src/searchutils.ts +36 -2
- package/src/strict-overlap.ts +281 -0
- package/src/tin.ts +50 -382
- package/src/weight-buffer.ts +111 -0
package/dist/maplat_tin.umd.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
(function(ot,xt){typeof exports=="object"&&typeof module<"u"?xt(exports,require("@turf/boolean-point-in-polygon"),require("@turf/centroid"),require("@turf/convex"),require("@turf/helpers"),require("@turf/line-intersect"),require("delaunator")):typeof define=="function"&&define.amd?define(["exports","@turf/boolean-point-in-polygon","@turf/centroid","@turf/convex","@turf/helpers","@turf/line-intersect","delaunator"],xt):(ot=typeof globalThis<"u"?globalThis:ot||self,xt(ot.tin={},ot.turf.booleanPointInPolygon,ot.turf.centroid,ot.turf.convex,ot.turf.helpers,ot.turf.lineIntersect,ot.Delaunator))})(this,function(ot,xt,Wt,_e,ut,tn,en){"use strict";var ni=Object.defineProperty;var ii=(ot,xt,Wt)=>xt in ot?ni(ot,xt,{enumerable:!0,configurable:!0,writable:!0,value:Wt}):ot[xt]=Wt;var rt=(ot,xt,Wt)=>ii(ot,typeof xt!="symbol"?xt+"":xt,Wt);var nn=Object.defineProperty,sn=(o,t,e)=>t in o?nn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,et=(o,t,e)=>sn(o,typeof t!="symbol"?t+"":t,e);const Tt=11102230246251565e-32,gt=134217729,rn=(3+8*Tt)*Tt;function fe(o,t,e,n,s){let i,r,a,f,h=t[0],u=n[0],c=0,l=0;u>h==u>-h?(i=h,h=t[++c]):(i=u,u=n[++l]);let p=0;if(c<o&&l<e)for(u>h==u>-h?(r=h+i,a=i-(r-h),h=t[++c]):(r=u+i,a=i-(r-u),u=n[++l]),i=r,a!==0&&(s[p++]=a);c<o&&l<e;)u>h==u>-h?(r=i+h,f=r-i,a=i-(r-f)+(h-f),h=t[++c]):(r=i+u,f=r-i,a=i-(r-f)+(u-f),u=n[++l]),i=r,a!==0&&(s[p++]=a);for(;c<o;)r=i+h,f=r-i,a=i-(r-f)+(h-f),h=t[++c],i=r,a!==0&&(s[p++]=a);for(;l<e;)r=i+u,f=r-i,a=i-(r-f)+(u-f),u=n[++l],i=r,a!==0&&(s[p++]=a);return(i!==0||p===0)&&(s[p++]=i),p}function on(o,t){let e=t[0];for(let n=1;n<o;n++)e+=t[n];return e}function Yt(o){return new Float64Array(o)}const an=(3+16*Tt)*Tt,cn=(2+12*Tt)*Tt,hn=(9+64*Tt)*Tt*Tt,zt=Yt(4),Se=Yt(8),Me=Yt(12),Ae=Yt(16),wt=Yt(4);function fn(o,t,e,n,s,i,r){let a,f,h,u,c,l,p,y,g,b,w,M,_,v,T,I,N,V;const W=o-s,K=e-s,tt=t-i,z=n-i;v=W*z,l=gt*W,p=l-(l-W),y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v=a*u,l=gt*a,p=l-(l-a),y=a-p,l=gt*u,g=l-(l-u),b=u-g,T=y*b-(v-p*g-y*g-p*b),I=f*h,l=gt*f,p=l-(l-f),y=f-p,l=gt*h,g=l-(l-h),b=h-g,N=y*b-(I-p*g-y*g-p*b),w=T-N,c=T-w,wt[0]=T-(w+c)+(c-N),M=v+w,c=M-v,_=v-(M-c)+(w-c),w=_-I,c=_-w,wt[1]=_-(w+c)+(c-I),V=M+w,c=V-M,wt[2]=M-(V-c)+(w-c),wt[3]=V;const A=fe(x,Me,4,wt,Ae);return Ae[A-1]}function un(o,t,e,n,s,i){const r=(t-i)*(e-s),a=(o-s)*(n-i),f=r-a,h=Math.abs(r+a);return Math.abs(f)>=an*h?f:-fn(o,t,e,n,s,i,h)}function ln(o,t){var e,n,s=0,i,r,a,f,h,u,c,l=o[0],p=o[1],y=t.length;for(e=0;e<y;e++){n=0;var g=t[e],b=g.length-1;if(u=g[0],u[0]!==g[b][0]&&u[1]!==g[b][1])throw new Error("First and last coordinates in a ring must be the same");for(r=u[0]-l,a=u[1]-p,n;n<b;n++){if(c=g[n+1],f=c[0]-l,h=c[1]-p,a===0&&h===0){if(f<=0&&r>=0||r<=0&&f>=0)return 0}else if(h>=0&&a<=0||h<=0&&a>=0){if(i=un(r,f,a,h,0,0),i===0)return 0;(i>0&&h>0&&a<=0||i<0&&h<=0&&a>0)&&s++}u=c,a=h,r=f}}return s%2!==0}function Ee(o,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=o,n}function Jt(o,t,e={}){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(!Oe(o[0])||!Oe(o[1]))throw new Error("coordinates must contain numbers");return Ee({type:"Point",coordinates:o},t,e)}function ve(o,t,e={}){for(const n of o){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 s=0;s<n[n.length-1].length;s++)if(n[n.length-1][s]!==n[0][s])throw new Error("First and last Position are not equivalent.")}return Ee({type:"Polygon",coordinates:o},t,e)}function Dt(o,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=o,e}function Oe(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function dn(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 Te(o){if(Array.isArray(o))return o;if(o.type==="Feature"){if(o.geometry!==null)return o.geometry.coordinates}else if(o.coordinates)return o.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function gn(o){return o.type==="Feature"?o.geometry:o}function pn(o,t,e={}){if(!o)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=dn(o),s=gn(t),i=s.type,r=t.bbox;let a=s.coordinates;if(r&&wn(n,r)===!1)return!1;i==="Polygon"&&(a=[a]);let f=!1;for(var h=0;h<a.length;++h){const u=ln(n,a[h]);if(u===0)return!e.ignoreBoundary;u&&(f=!0)}return f}function wn(o,t){return t[0]<=o[0]&&t[1]<=o[1]&&t[2]>=o[0]&&t[3]>=o[1]}var ue=pn;function Ie(o){const t=o.features;for(let e=0;e<t.length;e++){const n=t[e];`${n.properties.a.index}`.substring(0,1)==="b"&&`${n.properties.b.index}`.substring(0,1)==="b"?t[e]={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"&&(t[e]={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 o}function mn(o){const t=["a","b","c","a"].map(i=>o.properties[i].geom),e=o.geometry.coordinates[0],n=o.properties,s={a:{geom:e[0],index:n.a.index},b:{geom:e[1],index:n.b.index},c:{geom:e[2],index:n.c.index}};return ve([t],s)}function bn(o){const t=[0,1,2,0].map(n=>o[n][0][0]),e={a:{geom:o[0][0][1],index:o[0][1]},b:{geom:o[1][0][1],index:o[1][1]},c:{geom:o[2][0][1],index:o[2][1]}};return ve([t],e)}function ee(o,t,e,n,s,i=!1,r){const a=o.map(f=>{(!r||r<2.00703)&&(f=Pe(f));const h=isFinite(f)?t[f]:f==="c"?n:f==="b0"?s[0]:f==="b1"?s[1]:f==="b2"?s[2]:f==="b3"?s[3]:function(){const u=f.match(/e(\d+)/);if(u){const c=parseInt(u[1]);return e[c]}throw"Bad index value for indexesToTri"}();return i?[[h[1],h[0]],f]:[[h[0],h[1]],f]});return bn(a)}function Pe(o){return typeof o=="number"?o:o.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function $e(o,t){return t&&t>=2.00703||Array.isArray(o[0])?o:o.map(e=>[e.illstNodes,e.mercNodes,e.startEnd])}function Re(o,t){for(let e=0;e<t.features.length;e++)if(ue(o,t.features[e]))return t.features[e]}function Ne(o,t,e){const n=t.geometry.coordinates[0][0],s=t.geometry.coordinates[0][1],i=t.geometry.coordinates[0][2],r=o.geometry.coordinates,a=t.properties.a.geom,f=t.properties.b.geom,h=t.properties.c.geom,u=[s[0]-n[0],s[1]-n[1]],c=[i[0]-n[0],i[1]-n[1]],l=[r[0]-n[0],r[1]-n[1]],p=[f[0]-a[0],f[1]-a[1]],y=[h[0]-a[0],h[1]-a[1]];let g=(c[1]*l[0]-c[0]*l[1])/(u[0]*c[1]-u[1]*c[0]),b=(u[0]*l[1]-u[1]*l[0])/(u[0]*c[1]-u[1]*c[0]);if(e){const w=e[t.properties.a.index],M=e[t.properties.b.index],_=e[t.properties.c.index];let v;if(g<0||b<0||1-g-b<0){const T=g/(g+b),I=b/(g+b);v=g/M/(T/M+I/_),b=b/_/(T/M+I/_)}else v=g/M/(g/M+b/_+(1-g-b)/w),b=b/_/(g/M+b/_+(1-g-b)/w);g=v}return[g*p[0]+b*y[0]+a[0],g*p[1]+b*y[1]+a[1]]}function yn(o,t,e,n){const s=o.geometry.coordinates,i=e.geometry.coordinates,r=Math.atan2(s[0]-i[0],s[1]-i[1]),a=kn(r,t[0]);if(a===void 0)throw new Error("Unable to determine vertex index");const f=t[1][a];return Ne(o,f.features[0],n)}function ne(o,t,e,n,s,i,r,a){let f;if(r&&(f=Re(o,Dt([r]))),!f){if(e){const h=o.geometry.coordinates,u=e.gridNum,c=e.xOrigin,l=e.yOrigin,p=e.xUnit,y=e.yUnit,g=e.gridCache,b=At(h[0],c,p,u),w=At(h[1],l,y,u),M=g[b]?g[b][w]?g[b][w]:[]:[];t=Dt(M.map(_=>t.features[_]))}f=Re(o,t)}return a&&a(f),f?Ne(o,f,i):yn(o,n,s,i)}function At(o,t,e,n){let s=Math.floor((o-t)/e);return s>=n&&(s=n-1),s}function kn(o,t){let e=Ue(o-t[0]),n=Math.PI*2,s;for(let i=0;i<t.length;i++){const r=(i+1)%t.length,a=Ue(o-t[r]),f=Math.min(Math.abs(e),Math.abs(a));e*a<=0&&f<n&&(n=f,s=i),e=a}return s}function Ue(o,t=!1){const e=t?function(n){return!(n>=0&&n<Math.PI*2)}:function(n){return!(n>-1*Math.PI&&n<=Math.PI)};for(;e(o);)o=o+2*Math.PI*(o>0?-1:1);return o}const ie=2.00703,St=class Mt{constructor(){et(this,"points",[]),et(this,"pointsWeightBuffer"),et(this,"strict_status"),et(this,"vertices_params"),et(this,"centroid"),et(this,"edgeNodes"),et(this,"edges"),et(this,"tins"),et(this,"kinks"),et(this,"yaxisMode",Mt.YAXIS_INVERT),et(this,"strictMode",Mt.MODE_AUTO),et(this,"vertexMode",Mt.VERTEX_PLAIN),et(this,"bounds"),et(this,"boundsPolygon"),et(this,"wh"),et(this,"xy"),et(this,"indexedTins"),et(this,"stateFull",!1),et(this,"stateTriangle"),et(this,"stateBackward")}setCompiled(t){if(t.version||!t.tins&&t.points&&t.tins_points){this.points=t.points,this.pointsWeightBuffer=!t.version||t.version<2.00703?["forw","bakw"].reduce((n,s)=>{const i=t.weight_buffer[s];return i&&(n[s]=Object.keys(i).reduce((r,a)=>{const f=Pe(a);return r[f]=i[a],r},{})),n},{}):t.weight_buffer,t.strict_status?this.strict_status=t.strict_status:t.kinks_points?this.strict_status=Mt.STATUS_ERROR:t.tins_points.length==2?this.strict_status=Mt.STATUS_LOOSE:this.strict_status=Mt.STATUS_STRICT,this.vertices_params={forw:[t.vertices_params[0]],bakw:[t.vertices_params[1]]},this.vertices_params.forw[1]=[0,1,2,3].map(n=>{const s=(n+1)%4,i=ee(["c",`b${n}`,`b${s}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,ie);return Dt([i])}),this.vertices_params.bakw[1]=[0,1,2,3].map(n=>{const s=(n+1)%4,i=ee(["c",`b${n}`,`b${s}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,ie);return Dt([i])}),this.centroid={forw:Jt(t.centroid_point[0],{target:{geom:t.centroid_point[1],index:"c"}}),bakw:Jt(t.centroid_point[1],{target:{geom:t.centroid_point[0],index:"c"}})},this.edges=$e(t.edges||[]),this.edgeNodes=t.edgeNodes||[];const e=t.tins_points.length==1?0:1;this.tins={forw:Dt(t.tins_points[0].map(n=>ee(n,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,t.version))),bakw:Dt(t.tins_points[e].map(n=>ee(n,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,t.version)))},this.addIndexedTin(),t.kinks_points&&(this.kinks={bakw:Dt(t.kinks_points.map(n=>Jt(n)))}),t.yaxisMode?this.yaxisMode=t.yaxisMode:this.yaxisMode=Mt.YAXIS_INVERT,t.vertexMode&&(this.vertexMode=t.vertexMode),t.strictMode&&(this.strictMode=t.strictMode),t.bounds?(this.bounds=t.bounds,this.boundsPolygon=t.boundsPolygon,this.xy=t.xy,this.wh=t.wh):(this.xy=[0,0],t.wh&&(this.wh=t.wh),this.bounds=void 0,this.boundsPolygon=void 0)}else{t=JSON.parse(JSON.stringify(t).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"')),this.tins=t.tins,this.addIndexedTin(),this.strict_status=t.strict_status,this.pointsWeightBuffer=t.weight_buffer,this.vertices_params=t.vertices_params,this.centroid=t.centroid,this.kinks=t.kinks;const e=[];for(let n=0;n<this.tins.forw.features.length;n++){const s=this.tins.forw.features[n];["a","b","c"].map((i,r)=>{const a=s.geometry.coordinates[0][r],f=s.properties[i].geom,h=s.properties[i].index;typeof h=="number"&&(e[h]=[a,f])})}this.points=e}}addIndexedTin(){const t=this.tins,e=t.forw,n=t.bakw,s=Math.ceil(Math.sqrt(e.features.length));if(s<3){this.indexedTins=void 0;return}let i=[],r=[];const a=e.features.map(g=>{let b=[];return Te(g)[0].map(w=>{i.length===0?i=[Array.from(w),Array.from(w)]:(w[0]<i[0][0]&&(i[0][0]=w[0]),w[0]>i[1][0]&&(i[1][0]=w[0]),w[1]<i[0][1]&&(i[0][1]=w[1]),w[1]>i[1][1]&&(i[1][1]=w[1])),b.length===0?b=[Array.from(w),Array.from(w)]:(w[0]<b[0][0]&&(b[0][0]=w[0]),w[0]>b[1][0]&&(b[1][0]=w[0]),w[1]<b[0][1]&&(b[0][1]=w[1]),w[1]>b[1][1]&&(b[1][1]=w[1]))}),b}),f=(i[1][0]-i[0][0])/s,h=(i[1][1]-i[0][1])/s,u=a.reduce((g,b,w)=>{const M=At(b[0][0],i[0][0],f,s),_=At(b[1][0],i[0][0],f,s),v=At(b[0][1],i[0][1],h,s),T=At(b[1][1],i[0][1],h,s);for(let I=M;I<=_;I++){g[I]||(g[I]=[]);for(let N=v;N<=T;N++)g[I][N]||(g[I][N]=[]),g[I][N].push(w)}return g},[]),c=n.features.map(g=>{let b=[];return Te(g)[0].map(w=>{r.length===0?r=[Array.from(w),Array.from(w)]:(w[0]<r[0][0]&&(r[0][0]=w[0]),w[0]>r[1][0]&&(r[1][0]=w[0]),w[1]<r[0][1]&&(r[0][1]=w[1]),w[1]>r[1][1]&&(r[1][1]=w[1])),b.length===0?b=[Array.from(w),Array.from(w)]:(w[0]<b[0][0]&&(b[0][0]=w[0]),w[0]>b[1][0]&&(b[1][0]=w[0]),w[1]<b[0][1]&&(b[0][1]=w[1]),w[1]>b[1][1]&&(b[1][1]=w[1]))}),b}),l=(r[1][0]-r[0][0])/s,p=(r[1][1]-r[0][1])/s,y=c.reduce((g,b,w)=>{const M=At(b[0][0],r[0][0],l,s),_=At(b[1][0],r[0][0],l,s),v=At(b[0][1],r[0][1],p,s),T=At(b[1][1],r[0][1],p,s);for(let I=M;I<=_;I++){g[I]||(g[I]=[]);for(let N=v;N<=T;N++)g[I][N]||(g[I][N]=[]),g[I][N].push(w)}return g},[]);this.indexedTins={forw:{gridNum:s,xOrigin:i[0][0],yOrigin:i[0][1],xUnit:f,yUnit:h,gridCache:u},bakw:{gridNum:s,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:l,yUnit:p,gridCache:y}}}transform(t,e,n){if(e&&this.strict_status==Mt.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==Mt.YAXIS_FOLLOW&&e&&(t=[t[0],-1*t[1]]);const s=Jt(t);if(this.bounds&&!e&&!n&&!ue(s,this.boundsPolygon))return!1;const i=e?this.tins.bakw:this.tins.forw,r=e?this.indexedTins.bakw:this.indexedTins.forw,a=e?this.vertices_params.bakw:this.vertices_params.forw,f=e?this.centroid.bakw:this.centroid.forw,h=e?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let u,c;this.stateFull&&(this.stateBackward==e?u=this.stateTriangle:(this.stateBackward=e,this.stateTriangle=void 0),c=p=>{this.stateTriangle=p});let l=ne(s,i,r,a,f,h,u,c);if(this.bounds&&e&&!n){const p=Jt(l);if(!ue(p,this.boundsPolygon))return!1}else this.yaxisMode==Mt.YAXIS_FOLLOW&&!e&&(l=[l[0],-1*l[1]]);return l}};et(St,"VERTEX_PLAIN","plain"),et(St,"VERTEX_BIRDEYE","birdeye"),et(St,"MODE_STRICT","strict"),et(St,"MODE_AUTO","auto"),et(St,"MODE_LOOSE","loose"),et(St,"STATUS_STRICT","strict"),et(St,"STATUS_ERROR","strict_error"),et(St,"STATUS_LOOSE","loose"),et(St,"YAXIS_FOLLOW","follow"),et(St,"YAXIS_INVERT","invert");let xn=St;const pt=11102230246251565e-32,$=134217729,Be=(3+8*pt)*pt;function ft(o,t,e,n,s){let i,r,a,f,h=t[0],u=n[0],c=0,l=0;u>h==u>-h?(i=h,h=t[++c]):(i=u,u=n[++l]);let p=0;if(c<o&&l<e)for(u>h==u>-h?(r=h+i,a=i-(r-h),h=t[++c]):(r=u+i,a=i-(r-u),u=n[++l]),i=r,a!==0&&(s[p++]=a);c<o&&l<e;)u>h==u>-h?(r=i+h,f=r-i,a=i-(r-f)+(h-f),h=t[++c]):(r=i+u,f=r-i,a=i-(r-f)+(u-f),u=n[++l]),i=r,a!==0&&(s[p++]=a);for(;c<o;)r=i+h,f=r-i,a=i-(r-f)+(h-f),h=t[++c],i=r,a!==0&&(s[p++]=a);for(;l<e;)r=i+u,f=r-i,a=i-(r-f)+(u-f),u=n[++l],i=r,a!==0&&(s[p++]=a);return(i!==0||p===0)&&(s[p++]=i),p}function _t(o,t,e,n,s,i,r,a){return ft(ft(o,t,e,n,r),r,s,i,a)}function S(o,t,e,n){let s,i,r,a,f,h,u,c,l,p,y;u=$*e,p=u-(u-e),y=e-p;let g=t[0];s=g*e,u=$*g,c=u-(u-g),l=g-c,r=l*y-(s-c*p-l*p-c*y);let b=0;r!==0&&(n[b++]=r);for(let w=1;w<o;w++)g=t[w],a=g*e,u=$*g,c=u-(u-g),l=g-c,f=l*y-(a-c*p-l*p-c*y),i=s+f,h=i-s,r=s-(i-h)+(f-h),r!==0&&(n[b++]=r),s=a+i,r=i-(s-a),r!==0&&(n[b++]=r);return(s!==0||b===0)&&(n[b++]=s),b}function De(o,t){let e=t[0];for(let n=1;n<o;n++)e+=t[n];return e}function H(o){return new Float64Array(o)}const _n=(3+16*pt)*pt,Sn=(2+12*pt)*pt,Mn=(9+64*pt)*pt*pt,Xt=H(4),Fe=H(8),je=H(12),Le=H(16),mt=H(4);function An(o,t,e,n,s,i,r){let a,f,h,u,c,l,p,y,g,b,w,M,_,v,T,I,N,V;const W=o-s,K=e-s,tt=t-i,z=n-i;v=W*z,l=$*W,p=l-(l-W),y=W-p,l=$*z,g=l-(l-z),b=z-g,T=y*b-(v-p*g-y*g-p*b),I=tt*K,l=$*tt,p=l-(l-tt),y=tt-p,l=$*K,g=l-(l-K),b=K-g,N=y*b-(I-p*g-y*g-p*b),w=T-N,c=T-w,Xt[0]=T-(w+c)+(c-N),M=v+w,c=M-v,_=v-(M-c)+(w-c),w=_-I,c=_-w,Xt[1]=_-(w+c)+(c-I),V=M+w,c=V-M,Xt[2]=M-(V-c)+(w-c),Xt[3]=V;let st=De(4,Xt),d=Sn*r;if(st>=d||-st>=d||(c=o-W,a=o-(W+c)+(c-s),c=e-K,h=e-(K+c)+(c-s),c=t-tt,f=t-(tt+c)+(c-i),c=n-z,u=n-(z+c)+(c-i),a===0&&f===0&&h===0&&u===0)||(d=Mn*r+Be*Math.abs(st),st+=W*u+z*a-(tt*h+K*f),st>=d||-st>=d))return st;v=a*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A*E-x*R),k=D+C,d=k-D,yt[0]=D-(k-d)+(C-d),O=P+k,d=O-P,B=P-(O-d)+(k-d),k=B+F,d=k-B,yt[1]=B-(k-d)+(F-d),j=O+k,d=j-O,yt[2]=O-(j-d)+(k-d),yt[3]=j,I=ft(4,bt,4,yt,se),P=u*y,m=$*u,x=m-(m-u),A=u-x,m=$*y,E=m-(m-y),R=y-E,D=A*R-(P-x*E-A*E-x*R),F=c*p,m=$*c,x=m-(m-c),A=c-x,m=$*p,E=m-(m-p),R=p-E,C=A*R-(F-x*E-A*E-x*R),k=D-C,d=D-k,Ft[0]=D-(k+d)+(d-C),O=P+k,d=O-P,B=P-(O-d)+(k-d),k=B-F,d=B-k,Ft[1]=B-(k+d)+(d-F),j=O+k,d=j-O,Ft[2]=O-(j-d)+(k-d),Ft[3]=j,W=4):(se[0]=0,I=1,Ft[0]=0,W=1),l!==0){const lt=S(I,se,l,it);h=ht(h,ft(S(v,we,l,L),L,S(lt,it,2*Y,G),G,ct),ct);const dt=S(W,Ft,l,U);h=ht(h,_t(S(dt,U,2*Y,L),L,S(dt,U,l,nt),nt,S(lt,it,l,G),G,Ut,kt),kt),p!==0&&(h=ht(h,S(S(4,vt,l,U),U,p,L),L)),y!==0&&(h=ht(h,S(S(4,Et,-l,U),U,y,L),L))}if(g!==0){const lt=S(I,se,g,it);h=ht(h,ft(S(T,me,g,L),L,S(lt,it,2*Z,G),G,ct),ct);const dt=S(W,Ft,g,U);h=ht(h,_t(S(dt,U,2*Z,L),L,S(dt,U,g,nt),nt,S(lt,it,g,G),G,Ut,kt),kt)}}return qt[h-1]}function In(o,t,e,n,s,i,r,a){const f=o-r,h=e-r,u=s-r,c=t-a,l=n-a,p=i-a,y=h*p,g=u*l,b=f*f+c*c,w=u*c,M=f*p,_=h*h+l*l,v=f*l,T=h*c,I=u*u+p*p,N=b*(y-g)+_*(w-M)+I*(v-T),V=(Math.abs(y)+Math.abs(g))*b+(Math.abs(w)+Math.abs(M))*_+(Math.abs(v)+Math.abs(T))*I,W=En*V;return N>W||-N>W?N:Tn(o,t,e,n,s,i,r,a,V)}class Pn{constructor(t,e){this.W=t,this.bs=e}add(t){const e=this.W,n=t/e|0,s=t%e;return this.bs[n]|=1<<s,this}delete(t){const e=this.W,n=t/e|0,s=t%e;return this.bs[n]&=~(1<<s),this}set(t,e){const n=this.W,s=t/n|0,i=t%n,r=1<<i;return this.bs[s]^=(-e^this.bs[s])&r,e}has(t){const e=this.W,n=t/e|0,s=t%e;return!!(this.bs[n]&1<<s)}forEach(t){const e=this.W,n=this.bs,s=n.length;for(let i=0;i<s;i++){let r=0;for(;n[i]&&r<e;)n[i]&1<<r&&t(i*e+r),r++}return this}}class Ve extends Pn{constructor(t){const e=new Uint8Array(Math.ceil(t/8)).fill(0);super(8,e)}}function Vt(o){return o%3===2?o-2:o+1}function It(o){return o%3===0?o+2:o-1}function Ce(o,t,e,n,s,i,r,a){const f=Ht(o,t,s,i,r,a),h=Ht(e,n,s,i,r,a);if(f>0&&h>0||f<0&&h<0)return!1;const u=Ht(s,i,o,t,e,n),c=Ht(r,a,o,t,e,n);return u>0&&c>0||u<0&&c<0?!1:f===0&&h===0&&u===0&&c===0?!(Math.max(s,r)<Math.min(o,e)||Math.max(o,e)<Math.min(s,r)||Math.max(i,a)<Math.min(t,n)||Math.max(t,n)<Math.min(i,a)):!0}class $n{constructor(t){this.del=t}}const We=class extends $n{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,s=t.coords.length>>1,i=t.triangles.length;this.vertMap=new Uint32Array(s).fill(n),this.flips=new Ve(i),this.consd=new Ve(i);for(let r=0;r<i;r++){const a=t.triangles[r];this.vertMap[a]===n&&this.updateVert(r)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:n,halfedges:s}=this.del,i=this.vertMap[t];let r=i;do{const h=n[r],u=Vt(r);if(h===e)return this.protect(r);const c=It(r),l=n[c];if(l===e)return this.protect(u),u;if(this.intersectSegments(t,e,l,h)){r=c;break}r=s[u]}while(r!==-1&&r!==i);let a=r,f=-1;for(;r!==-1;){const h=s[r],u=It(r),c=It(h),l=Vt(h);if(h===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(r))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,e,n[r])||this.isCollinear(t,e,n[h]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(n[r],n[h],n[u],n[c])){if(f===-1&&(f=r),n[c]===e){if(r===f)throw new Error("Infinite loop: non-convex quadrilateral");r=f,f=-1;continue}if(this.intersectSegments(t,e,n[c],n[h]))r=c;else if(this.intersectSegments(t,e,n[l],n[c]))r=l;else if(f===r)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(r),this.intersectSegments(t,e,n[u],n[c])&&(f===-1&&(f=u),f===u))throw new Error("Infinite loop: flipped diagonal still intersects");n[c]===e?(a=c,r=f,f=-1):this.intersectSegments(t,e,n[l],n[c])&&(r=l)}return this.protect(a),this.delaunify(!0),this.findEdge(t,e)}delaunify(t=!1){const{halfedges:e}=this.del,n=this.flips,s=this.consd,i=e.length;do{var r=0;for(let a=0;a<i;a++){if(s.has(a))continue;n.delete(a);const f=e[a];f!==-1&&(n.delete(f),this.isDelaunay(a)||(this.flipDiagonal(a),r++))}}while(t&&r>0);return this}constrainAll(t){const e=t.length;for(let n=0;n<e;n++){const s=t[n];this.constrainOne(s[0],s[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const n=this.vertMap[e],{triangles:s,halfedges:i}=this.del;let r=n,a=-1;do{if(s[r]===t)return r;a=Vt(r),r=i[a]}while(r!==-1&&r!==n);return s[Vt(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],n=this.flips,s=this.consd;return n.delete(t),s.add(t),e!==-1?(n.delete(e),s.add(e),e):-t}markFlip(t){const e=this.del.halfedges,n=this.flips;if(this.consd.has(t))return!1;const s=e[t];return s!==-1&&(n.add(t),n.add(s)),!0}flipDiagonal(t){const{triangles:e,halfedges:n}=this.del,s=this.flips,i=this.consd,r=n[t],a=It(t),f=Vt(t),h=It(r),u=Vt(r),c=n[a],l=n[h];if(i.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[h],n[t]=l,s.set(t,s.has(h))||i.set(t,i.has(h)),l!==-1&&(n[l]=t),n[a]=h,e[r]=e[a],n[r]=c,s.set(r,s.has(a))||i.set(r,i.has(a)),c!==-1&&(n[c]=r),n[h]=a,this.markFlip(t),this.markFlip(f),this.markFlip(r),this.markFlip(u),s.add(a),i.delete(a),s.add(h),i.delete(h),this.updateVert(t),this.updateVert(f),this.updateVert(r),this.updateVert(u),a}isCollinear(t,e,n){const s=this.del.coords;return Ht(s[t*2],s[t*2+1],s[e*2],s[e*2+1],s[n*2],s[n*2+1])===0}inCircle(t,e,n,s){const i=this.del.coords;return In(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[s*2],i[s*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:n}=this.del,s=n[t];if(s===-1)return!0;const i=e[It(t)],r=e[t],a=e[Vt(t)],f=e[It(s)];return!this.inCircle(i,r,a,f)}updateVert(t){const{triangles:e,halfedges:n}=this.del,s=this.vertMap,i=e[t];let r=It(t),a=n[r];for(;a!==-1&&a!==t;)r=It(a),a=n[r];return s[i]=r,r}intersectSegments(t,e,n,s){const i=this.del.coords;return t===n||t===s||e===n||e===s?!1:Ce(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[s*2],i[s*2+1])}};We.intersectSegments=Ce;let Rn=We;function Gt(o,t,e){if(t||(t=[]),typeof o!="object"||o.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const n=o.features.map(f=>f.geometry.coordinates),s=en.from(n);let i;const r=[];s.triangles.length!==0&&t.length!==0&&(i=new Rn(s),i.constrainAll(t));for(let f=0;f<s.triangles.length;f+=3)r.push([s.triangles[f],s.triangles[f+1],s.triangles[f+2]]);const a=["a","b","c"];return ut.featureCollection(r.map(f=>{const h={},u=f.map((c,l)=>{const p=o.features[c],y=p.geometry.coordinates,g=[y[0],y[1]];return y.length===3?g[2]=y[2]:h[a[l]]=p.properties[e],g});return u[3]=u[0],ut.polygon([u],h)}))}function ze(o){const e=new Nn(o).findSegmentIntersections();return Ge(e).reduce((n,s,i,r)=>Array.isArray(n)||(n||(n={}),n[`${s.x}:${s.y}`]=s,i!=r.length-1)?n:Object.keys(n).map(a=>ut.point([n[a].x,n[a].y])),{})}class Nn{constructor(t){rt(this,"_xx");rt(this,"_yy");rt(this,"_ii");rt(this,"_nn");rt(this,"_zz");rt(this,"_zlimit",0);rt(this,"_bb");rt(this,"_allBounds");rt(this,"_arcIter");rt(this,"_filteredArcIter");rt(this,"buf");this.initArcs(t)}initArcs(t){const e=[],n=[],s=t.map(i=>{const r=i?i.length:0;for(let a=0;a<r;a++)e.push(i[a][0]),n.push(i[a][1]);return r});this.initXYData(s,e,n)}initXYData(t,e,n){const s=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(s);let i=0;for(let r=0;r<s;r++)this._ii[r]=i,i+=t[r];(i!=this._xx.length||this._xx.length!=this._yy.length)&&ye("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new ti(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 s=n.length,i=new Float64Array(s*4),r=new he;let a=0,f,h,u;for(let c=0;c<s;c++)f=n[c],f>0&&(h=c*4,u=ei(t,e,a,f),i[h++]=u[0],i[h++]=u[1],i[h++]=u[2],i[h]=u[3],a+=f,r.mergeBounds(u));return{bb:i,bounds:r}}getBounds(){return this._allBounds.clone()}forEachSegment(t){let e=0;for(let n=0,s=this.size();n<s;n++)e+=this.forEachArcSegment(n,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const n=t>=0,s=n?t:~t,i=this.getRetainedInterval(),r=this._nn[s],a=n?1:-1;let f=n?this._ii[s]:this._ii[s]+r-1,h=f,u=0;for(let c=1;c<r;c++)h+=a,(i===0||this._zz[h]>=i)&&(e(f,h,this._xx,this._yy),f=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(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((s,i,r,a)=>{t+=Math.abs(r[s]-r[i]),e+=Math.abs(a[s]-a[i])});return[t/n||0,e/n||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),e=this.getAvgSegment2()[1];let n=1;return e>0&&t>0&&(n=Math.ceil(t/e/20)),n||1}findSegmentIntersections(){const t=this.getBounds(),e=t.ymin,n=t.ymax-e,s=this.calcSegmentIntersectionStripeCount(),i=new Uint32Array(s),r=s>1?g=>Math.floor((s-1)*(g-e)/n):()=>0;let a,f;this.forEachSegment((g,b,w,M)=>{let _=r(M[g]);const v=r(M[b]);for(;i[_]=i[_]+2,_!=v;)_+=v>_?1:-1});const h=this.getUint32Array(Dn(i));let u=0;const c=[];Fn(i,g=>{const b=u;u+=g,c.push(h.subarray(b,u))}),jn(i,0),this.forEachSegment((g,b,w,M)=>{let _=r(M[g]);const v=r(M[b]);let T,I;for(;T=i[_],i[_]=T+2,I=c[_],I[T]=g,I[T+1]=b,_!=v;)_+=v>_?1:-1});const l=this.getVertexData(),p=[];let y;for(a=0;a<s;a++)for(y=Ln(c[a],l.xx,l.yy),f=0;f<y.length;f++)p.push(y[f]);return Ge(p)}}function ye(...o){const t=o.join(" ");throw new Error(t)}function ke(o){return o?Bn(o)?!0:Un(o)?!1:o.length===0?!0:o.length>0:!1}function Un(o){return o!=null&&o.toString===String.prototype.toString}function Bn(o){return Array.isArray(o)}function Dn(o,t){ke(o)||ye("utils.sum() expects an array, received:",o);let e=0,n;for(let s=0,i=o.length;s<i;s++)n=o[s],n&&(e+=n);return e}function Fn(o,t,e){if(!ke(o))throw new Error(`#forEach() takes an array-like argument. ${o}`);for(let n=0,s=o.length;n<s;n++)t.call(e,o[n],n)}function jn(o,t){for(let e=0,n=o.length;e<n;e++)o[e]=t;return o}function Ln(o,t,e){const n=o.length-2,s=[];let i,r,a,f,h,u,c,l,p,y,g,b,w,M,_,v,T;for(Gn(t,o),v=0;v<n;){for(i=o[v],r=o[v+1],h=t[i],u=t[r],p=e[i],y=e[r],T=v;T<n&&(T+=2,a=o[T],c=t[a],!(u<c));){if(g=e[a],f=o[T+1],l=t[f],b=e[f],p>=g){if(p>b&&y>g&&y>b)continue}else if(p<b&&y<g&&y<b)continue;i==a||i==f||r==a||r==f||(w=Vn(h,p,u,y,c,g,l,b),w&&(M=[i,r],_=[a,f],s.push(Je(w,M,_,t,e)),w.length==4&&s.push(Je(w.slice(2),M,_,t,e))))}v+=2}return s}function Vn(o,t,e,n,s,i,r,a){const f=Cn(o,t,e,n,s,i,r,a);let h=null;return f&&(h=Wn(o,t,e,n,s,i,r,a),h?Hn(o,t,e,n,s,i,r,a)&&(h=null):h=Jn(o,t,e,n,s,i,r,a)),h}function Cn(o,t,e,n,s,i,r,a){return Kt(o,t,e,n,s,i)*Kt(o,t,e,n,r,a)<=0&&Kt(s,i,r,a,o,t)*Kt(s,i,r,a,e,n)<=0}function Kt(o,t,e,n,s,i){return Xe(o-s,t-i,e-s,n-i)}function Xe(o,t,e,n){return o*n-t*e}function Wn(o,t,e,n,s,i,r,a){let f=ae(o,t,e,n,s,i,r,a),h;return f&&(h=Xn(f[0],f[1],o,t,e,n,s,i,r,a),h==1?f=ae(e,n,o,t,s,i,r,a):h==2?f=ae(s,i,r,a,o,t,e,n):h==3&&(f=ae(r,a,s,i,o,t,e,n))),f&&Yn(f,o,t,e,n,s,i,r,a),f}function ae(o,t,e,n,s,i,r,a){const f=Xe(e-o,n-t,r-s,a-i),h=1e-18;let u;if(f===0)return null;const c=Kt(s,i,r,a,o,t)/f;return f<=h&&f>=-h?u=zn(o,t,e,n,s,i,r,a):u=[o+c*(e-o),t+c*(n-t)],u}function zn(o,t,e,n,s,i,r,a){let f=null;return!Pt(o,s,r)&&!Pt(t,i,a)?f=[o,t]:!Pt(e,s,r)&&!Pt(n,i,a)?f=[e,n]:!Pt(s,o,e)&&!Pt(i,t,n)?f=[s,i]:!Pt(r,o,e)&&!Pt(a,t,n)&&(f=[r,a]),f}function Pt(o,t,e){let n;return t<e?n=o<t||o>e:t>e?n=o>t||o<e:n=o!=t,n}function Xn(o,t,...e){let n=-1,s=1/0,i;for(let r=0,a=0,f=e.length;a<f;r++,a+=2)i=qn(o,t,e[a],e[a+1]),i<s&&(s=i,n=r);return n}function qn(o,t,e,n){const s=o-e,i=t-n;return s*s+i*i}function Yn(o,t,e,n,s,i,r,a,f){let h=o[0],u=o[1];h=ce(h,t,n),h=ce(h,i,a),u=ce(u,e,s),u=ce(u,r,f),o[0]=h,o[1]=u}function ce(o,t,e){let n;return Pt(o,t,e)&&(n=Math.abs(o-t)<Math.abs(o-e)?t:e,o=n),o}function Jn(o,t,e,n,s,i,r,a){const f=Math.min(o,e,s,r),h=Math.max(o,e,s,r),u=Math.min(t,n,i,a),c=Math.max(t,n,i,a),l=c-u>h-f;let p=[];return(l?Bt(t,u,c):Bt(o,f,h))&&p.push(o,t),(l?Bt(n,u,c):Bt(e,f,h))&&p.push(e,n),(l?Bt(i,u,c):Bt(s,f,h))&&p.push(s,i),(l?Bt(a,u,c):Bt(r,f,h))&&p.push(r,a),(p.length!=2&&p.length!=4||p.length==4&&p[0]==p[2]&&p[1]==p[3])&&(p=null),p}function Hn(o,t,e,n,s,i,r,a){return o==s&&t==i||o==r&&t==a||e==s&&n==i||e==r&&n==a}function Bt(o,t,e){return o>t&&o<e}function Gn(o,t){Kn(o,t),qe(o,t,0,t.length-2)}function Kn(o,t){for(let e=0,n=t.length;e<n;e+=2)o[t[e]]>o[t[e+1]]&&Qn(t,e,e+1)}function Qn(o,t,e){const n=o[t];o[t]=o[e],o[e]=n}function qe(o,t,e,n){let s=e,i=n,r,a;for(;s<n;){for(r=o[t[e+n>>2<<1]];s<=i;){for(;o[t[s]]<r;)s+=2;for(;o[t[i]]>r;)i-=2;s<=i&&(a=t[s],t[s]=t[i],t[i]=a,a=t[s+1],t[s+1]=t[i+1],t[i+1]=a,s+=2,i-=2)}if(i-e<40?Ye(o,t,e,i):qe(o,t,e,i),n-s<40){Ye(o,t,s,n);return}e=s,i=n}}function Ye(o,t,e,n){let s,i;for(let r=e+2;r<=n;r+=2){s=t[r],i=t[r+1];let a;for(a=r-2;a>=e&&o[s]<o[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=s,t[a+3]=i}}function Je(o,t,e,n,s){const i=o[0],r=o[1];t=He(i,r,t[0],t[1],n,s),e=He(i,r,e[0],e[1],n,s);const a=t[0]<e[0]?t:e,f=a==t?e:t;return{x:i,y:r,a,b:f}}function He(o,t,e,n,s,i){let r=e<n?e:n,a=r===e?n:e;return s[r]==o&&i[r]==t?a=r:s[a]==o&&i[a]==t&&(r=a),[r,a]}function Ge(o){const t={};return o.filter(e=>{const n=Zn(e);return n in t?!1:(t[n]=!0,!0)})}function Zn(o){return`${o.a.join(",")};${o.b.join(",")}`}class ti{constructor(t,e){rt(this,"_i",0);rt(this,"_n",0);rt(this,"_inc",1);rt(this,"_xx");rt(this,"_yy");rt(this,"i",0);rt(this,"x",0);rt(this,"y",0);this._xx=t,this._yy=e}}function ei(o,t,e,n){let s=e|0;const i=isNaN(n)?o.length-s:n+s;let r,a,f,h,u,c;if(i>0)f=u=o[s],h=c=t[s];else return[void 0,void 0,void 0,void 0];for(s++;s<i;s++)r=o[s],a=t[s],r<f&&(f=r),r>u&&(u=r),a<h&&(h=a),a>c&&(c=a);return[f,h,u,c]}class he{constructor(...t){rt(this,"xmin");rt(this,"ymin");rt(this,"xmax");rt(this,"ymax");t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new he(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,e,n,s){return arguments.length==1&&(ke(t)?(e=t[1],n=t[2],s=t[3],t=t[0]):(e=t.ymin,n=t.xmax,s=t.ymax,t=t.xmin)),this.xmin=t,this.ymin=e,this.xmax=n,this.ymax=s,(t>n||e>s)&&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,s,i,r;return t instanceof he?(n=t.xmin,s=t.ymin,i=t.xmax,r=t.ymax):e.length==3?(n=t,s=e[0],i=e[1],r=e[2]):t.length==4?(n=t[0],s=t[1],i=t[2],r=t[3]):ye("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(n,s,i,r):(n<this.xmin&&(this.xmin=n),s<this.ymin&&(this.ymin=s),i>this.xmax&&(this.xmax=i),r>this.ymax&&(this.ymax=r)),this}}function Ke(o){const t=["a","b","c"].map(e=>o.properties[e].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(e=>e.map(n=>t[n]).sort().join("-")).sort()}function Qe(o,t,e){const n=Ke(t.forw),s=Ke(t.bakw);if(JSON.stringify(n)!=JSON.stringify(s))throw`${JSON.stringify(t,null,2)}
|
|
1
|
+
(function($t,Rt){typeof exports=="object"&&typeof module<"u"?Rt(exports):typeof define=="function"&&define.amd?define(["exports"],Rt):($t=typeof globalThis<"u"?globalThis:$t||self,Rt($t.tin={}))})(this,(function($t){"use strict";const Rt=11102230246251565e-32,rt=134217729,un=(3+8*Rt)*Rt;function Yt(s,t,e,n,r){let i,o,a,c,f=t[0],u=n[0],h=0,p=0;u>f==u>-f?(i=f,f=t[++h]):(i=u,u=n[++p]);let y=0;if(h<s&&p<e)for(u>f==u>-f?(o=f+i,a=i-(o-f),f=t[++h]):(o=u+i,a=i-(o-u),u=n[++p]),i=o,a!==0&&(r[y++]=a);h<s&&p<e;)u>f==u>-f?(o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h]):(o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p]),i=o,a!==0&&(r[y++]=a);for(;h<s;)o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h],i=o,a!==0&&(r[y++]=a);for(;p<e;)o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p],i=o,a!==0&&(r[y++]=a);return(i!==0||y===0)&&(r[y++]=i),y}function Ut(s,t,e,n,r,i,o,a){return Yt(Yt(s,t,e,n,o),o,r,i,a)}function q(s,t,e,n){let r,i,o,a,c,f,u,h,p,y,E;u=rt*e,y=u-(u-e),E=e-y;let k=t[0];r=k*e,u=rt*k,h=u-(u-k),p=k-h,o=p*E-(r-h*y-p*y-h*E);let X=0;o!==0&&(n[X++]=o);for(let C=1;C<s;C++)k=t[C],a=k*e,u=rt*k,h=u-(u-k),p=k-h,c=p*E-(a-h*y-p*y-h*E),i=r+c,f=i-r,o=r-(i-f)+(c-f),o!==0&&(n[X++]=o),r=a+i,o=i-(r-a),o!==0&&(n[X++]=o);return(r!==0||X===0)&&(n[X++]=r),X}function ln(s,t){let e=t[0];for(let n=1;n<s;n++)e+=t[n];return e}function yt(s){return new Float64Array(s)}const Wn=(3+16*Rt)*Rt,Jn=(2+12*Rt)*Rt,Kn=(9+64*Rt)*Rt*Rt,ge=yt(4),dn=yt(8),pn=yt(12),mn=yt(16),Ft=yt(4);function Gn(s,t,e,n,r,i,o){let a,c,f,u,h,p,y,E,k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x,h=v-C,Ft[1]=v-(C+h)+(h-x),I=m+C,h=I-m,Ft[2]=m-(I-h)+(C-h),Ft[3]=I;const _=Yt(M,dn,4,Ft,pn);l=a*u,p=rt*a,y=p-(p-a),E=a-y,p=rt*u,k=p-(p-u),X=u-k,g=E*X-(l-y*k-E*k-y*X),x=c*f,p=rt*c,y=p-(p-c),E=c-y,p=rt*f,k=p-(p-f),X=f-k,A=E*X-(x-y*k-E*k-y*X),C=g-A,h=g-C,Ft[0]=g-(C+h)+(h-A),m=l+C,h=m-l,v=l-(m-h)+(C-h),C=v-x,h=v-C,Ft[1]=v-(C+h)+(h-x),I=m+C,h=I-m,Ft[2]=m-(I-h)+(C-h),Ft[3]=I;const B=Yt(_,pn,4,Ft,mn);return mn[B-1]}function Qt(s,t,e,n,r,i){const o=(t-i)*(e-r),a=(s-r)*(n-i),c=o-a,f=Math.abs(o+a);return Math.abs(c)>=Wn*f?c:-Gn(s,t,e,n,r,i,f)}const Qn=(10+96*Rt)*Rt,Hn=(4+48*Rt)*Rt,Zn=(44+576*Rt)*Rt*Rt,ie=yt(4),oe=yt(4),se=yt(4),Ht=yt(4),Zt=yt(4),te=yt(4),Lt=yt(4),Dt=yt(4),ze=yt(8),Ve=yt(8),We=yt(8),Je=yt(8),Ke=yt(8),Ge=yt(8),Ie=yt(8),Te=yt(8),Ne=yt(8),fe=yt(4),he=yt(4),ue=yt(4),st=yt(8),lt=yt(16),kt=yt(16),St=yt(16),bt=yt(32),ae=yt(32),Bt=yt(48),qt=yt(64);let we=yt(1152),Qe=yt(1152);function Ot(s,t,e){s=Yt(s,we,t,e,Qe);const n=we;return we=Qe,Qe=n,s}function tr(s,t,e,n,r,i,o,a,c){let f,u,h,p,y,E,k,X,C,m,v,l,g,x,A,I,b,T,Y,D,Q,d,M,_,B,N,R,w,O,$,j,V,z,K,U;const ct=s-o,ft=e-o,dt=r-o,pt=t-a,gt=n-a,mt=i-a;j=ft*mt,M=rt*ft,_=M-(M-ft),B=ft-_,M=r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:tr(s,t,e,n,r,i,o,a,I)}function nr(s,t){var e,n,r=0,i,o,a,c,f,u,h,p=s[0],y=s[1],E=t.length;for(e=0;e<E;e++){n=0;var k=t[e],X=k.length-1;if(u=k[0],u[0]!==k[X][0]&&u[1]!==k[X][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-p,a=u[1]-y,n;n<X;n++){if(h=k[n+1],c=h[0]-p,f=h[1]-y,a===0&&f===0){if(c<=0&&o>=0||o<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(i=Qt(o,c,a,f,0,0),i===0)return 0;(i>0&&f>0&&a<=0||i<0&&f<=0&&a>0)&&r++}u=h,a=f,o=c}}return r%2!==0}function be(s,t,e={}){const n={type:"Feature"};return(e.id===0||e.id)&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.properties=t||{},n.geometry=s,n}function le(s,t,e={}){if(!s)throw new Error("coordinates is required");if(!Array.isArray(s))throw new Error("coordinates must be an Array");if(s.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!wn(s[0])||!wn(s[1]))throw new Error("coordinates must contain numbers");return be({type:"Point",coordinates:s},t,e)}function _e(s,t,e={}){for(const r of s){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let i=0;i<r[r.length-1].length;i++)if(r[r.length-1][i]!==r[0][i])throw new Error("First and last Position are not equivalent.")}return be({type:"Polygon",coordinates:s},t,e)}function gn(s,t,e={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return be({type:"LineString",coordinates:s},t,e)}function Vt(s,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=s,e}function wn(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}function rr(s){if(!s)throw new Error("coord is required");if(!Array.isArray(s)){if(s.type==="Feature"&&s.geometry!==null&&s.geometry.type==="Point")return[...s.geometry.coordinates];if(s.type==="Point")return[...s.coordinates]}if(Array.isArray(s)&&s.length>=2&&!Array.isArray(s[0])&&!Array.isArray(s[1]))return[...s];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ir(s){return s.type==="Feature"?s.geometry:s}function or(s,t,e={}){if(!s)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=rr(s),r=ir(t),i=r.type,o=t.bbox;let a=r.coordinates;if(o&&sr(n,o)===!1)return!1;i==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const u=nr(n,a[f]);if(u===0)return!e.ignoreBoundary;u&&(c=!0)}return c}function sr(s,t){return t[0]<=s[0]&&t[1]<=s[1]&&t[2]>=s[0]&&t[3]>=s[1]}var ar=or;function He(s,t,e){if(s!==null)for(var n,r,i,o,a,c,f,u=0,h=0,p,y=s.type,E=y==="FeatureCollection",k=y==="Feature",X=E?s.features.length:1,C=0;C<X;C++){f=E?s.features[C].geometry:k?s.geometry:s,p=f?f.type==="GeometryCollection":!1,a=p?f.geometries.length:1;for(var m=0;m<a;m++){var v=0,l=0;if(o=p?f.geometries[m]:f,o!==null){c=o.coordinates;var g=o.type;switch(u=e&&(g==="Polygon"||g==="MultiPolygon")?1:0,g){case null:break;case"Point":if(t(c,h,C,v,l)===!1)return!1;h++,v++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,C,v,l)===!1)return!1;h++,g==="MultiPoint"&&v++}g==="LineString"&&v++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(r=0;r<c[n].length-u;r++){if(t(c[n][r],h,C,v,l)===!1)return!1;h++}g==="MultiLineString"&&v++,g==="Polygon"&&l++}g==="Polygon"&&v++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(l=0,r=0;r<c[n].length;r++){for(i=0;i<c[n][r].length-u;i++){if(t(c[n][r][i],h,C,v,l)===!1)return!1;h++}l++}v++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(He(o.geometries[n],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function cr(s,t={}){let e=0,n=0,r=0;return He(s,function(i){e+=i[0],n+=i[1],r++},!0),le([e/r,n/r],t.properties)}var fr=cr;function hr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function ur(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var e=function n(){var r=!1;try{r=this instanceof n}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(n){var r=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return s[n]}})}),e}var Xe={exports:{}},Re={exports:{}},lr=Re.exports,yn;function dr(){return yn||(yn=1,(function(s,t){(function(e,n){s.exports=n()})(lr,function(){function e(m,v,l,g,x){(function A(I,b,T,Y,D){for(;Y>T;){if(Y-T>600){var Q=Y-T+1,d=b-T+1,M=Math.log(Q),_=.5*Math.exp(2*M/3),B=.5*Math.sqrt(M*_*(Q-_)/Q)*(d-Q/2<0?-1:1),N=Math.max(T,Math.floor(b-d*_/Q+B)),R=Math.min(Y,Math.floor(b+(Q-d)*_/Q+B));A(I,b,N,R,D)}var w=I[b],O=T,$=Y;for(n(I,T,b),D(I[Y],w)>0&&n(I,T,Y);O<$;){for(n(I,O,$),O++,$--;D(I[O],w)<0;)O++;for(;D(I[$],w)>0;)$--}D(I[T],w)===0?n(I,T,$):n(I,++$,Y),$<=b&&(T=$+1),b<=$&&(Y=$-1)}})(m,v,l||0,g||m.length-1,x||r)}function n(m,v,l){var g=m[v];m[v]=m[l],m[l]=g}function r(m,v){return m<v?-1:m>v?1:0}var i=function(m){m===void 0&&(m=9),this._maxEntries=Math.max(4,m),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(m,v,l){if(!l)return v.indexOf(m);for(var g=0;g<v.length;g++)if(l(m,v[g]))return g;return-1}function a(m,v){c(m,0,m.children.length,v,m)}function c(m,v,l,g,x){x||(x=X(null)),x.minX=1/0,x.minY=1/0,x.maxX=-1/0,x.maxY=-1/0;for(var A=v;A<l;A++){var I=m.children[A];f(x,m.leaf?g(I):I)}return x}function f(m,v){return m.minX=Math.min(m.minX,v.minX),m.minY=Math.min(m.minY,v.minY),m.maxX=Math.max(m.maxX,v.maxX),m.maxY=Math.max(m.maxY,v.maxY),m}function u(m,v){return m.minX-v.minX}function h(m,v){return m.minY-v.minY}function p(m){return(m.maxX-m.minX)*(m.maxY-m.minY)}function y(m){return m.maxX-m.minX+(m.maxY-m.minY)}function E(m,v){return m.minX<=v.minX&&m.minY<=v.minY&&v.maxX<=m.maxX&&v.maxY<=m.maxY}function k(m,v){return v.minX<=m.maxX&&v.minY<=m.maxY&&v.maxX>=m.minX&&v.maxY>=m.minY}function X(m){return{children:m,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function C(m,v,l,g,x){for(var A=[v,l];A.length;)if(!((l=A.pop())-(v=A.pop())<=g)){var I=v+Math.ceil((l-v)/g/2)*g;e(m,I,v,l,x),A.push(v,I,I,l)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(m){var v=this.data,l=[];if(!k(m,v))return l;for(var g=this.toBBox,x=[];v;){for(var A=0;A<v.children.length;A++){var I=v.children[A],b=v.leaf?g(I):I;k(m,b)&&(v.leaf?l.push(I):E(m,b)?this._all(I,l):x.push(I))}v=x.pop()}return l},i.prototype.collides=function(m){var v=this.data;if(!k(m,v))return!1;for(var l=[];v;){for(var g=0;g<v.children.length;g++){var x=v.children[g],A=v.leaf?this.toBBox(x):x;if(k(m,A)){if(v.leaf||E(m,A))return!0;l.push(x)}}v=l.pop()}return!1},i.prototype.load=function(m){if(!m||!m.length)return this;if(m.length<this._minEntries){for(var v=0;v<m.length;v++)this.insert(m[v]);return this}var l=this._build(m.slice(),0,m.length-1,0);if(this.data.children.length)if(this.data.height===l.height)this._splitRoot(this.data,l);else{if(this.data.height<l.height){var g=this.data;this.data=l,l=g}this._insert(l,this.data.height-l.height-1,!0)}else this.data=l;return this},i.prototype.insert=function(m){return m&&this._insert(m,this.data.height-1),this},i.prototype.clear=function(){return this.data=X([]),this},i.prototype.remove=function(m,v){if(!m)return this;for(var l,g,x,A=this.data,I=this.toBBox(m),b=[],T=[];A||b.length;){if(A||(A=b.pop(),g=b[b.length-1],l=T.pop(),x=!0),A.leaf){var Y=o(m,A.children,v);if(Y!==-1)return A.children.splice(Y,1),b.push(A),this._condense(b),this}x||A.leaf||!E(A,I)?g?(l++,A=g.children[l],x=!1):A=null:(b.push(A),T.push(l),l=0,g=A,A=A.children[0])}return this},i.prototype.toBBox=function(m){return m},i.prototype.compareMinX=function(m,v){return m.minX-v.minX},i.prototype.compareMinY=function(m,v){return m.minY-v.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(m){return this.data=m,this},i.prototype._all=function(m,v){for(var l=[];m;)m.leaf?v.push.apply(v,m.children):l.push.apply(l,m.children),m=l.pop();return v},i.prototype._build=function(m,v,l,g){var x,A=l-v+1,I=this._maxEntries;if(A<=I)return a(x=X(m.slice(v,l+1)),this.toBBox),x;g||(g=Math.ceil(Math.log(A)/Math.log(I)),I=Math.ceil(A/Math.pow(I,g-1))),(x=X([])).leaf=!1,x.height=g;var b=Math.ceil(A/I),T=b*Math.ceil(Math.sqrt(I));C(m,v,l,T,this.compareMinX);for(var Y=v;Y<=l;Y+=T){var D=Math.min(Y+T-1,l);C(m,Y,D,b,this.compareMinY);for(var Q=Y;Q<=D;Q+=b){var d=Math.min(Q+b-1,D);x.children.push(this._build(m,Q,d,g-1))}}return a(x,this.toBBox),x},i.prototype._chooseSubtree=function(m,v,l,g){for(;g.push(v),!v.leaf&&g.length-1!==l;){for(var x=1/0,A=1/0,I=void 0,b=0;b<v.children.length;b++){var T=v.children[b],Y=p(T),D=(Q=m,d=T,(Math.max(d.maxX,Q.maxX)-Math.min(d.minX,Q.minX))*(Math.max(d.maxY,Q.maxY)-Math.min(d.minY,Q.minY))-Y);D<A?(A=D,x=Y<x?Y:x,I=T):D===A&&Y<x&&(x=Y,I=T)}v=I||v.children[0]}var Q,d;return v},i.prototype._insert=function(m,v,l){var g=l?m:this.toBBox(m),x=[],A=this._chooseSubtree(g,this.data,v,x);for(A.children.push(m),f(A,g);v>=0&&x[v].children.length>this._maxEntries;)this._split(x,v),v--;this._adjustParentBBoxes(g,x,v)},i.prototype._split=function(m,v){var l=m[v],g=l.children.length,x=this._minEntries;this._chooseSplitAxis(l,x,g);var A=this._chooseSplitIndex(l,x,g),I=X(l.children.splice(A,l.children.length-A));I.height=l.height,I.leaf=l.leaf,a(l,this.toBBox),a(I,this.toBBox),v?m[v-1].children.push(I):this._splitRoot(l,I)},i.prototype._splitRoot=function(m,v){this.data=X([m,v]),this.data.height=m.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(m,v,l){for(var g,x,A,I,b,T,Y,D=1/0,Q=1/0,d=v;d<=l-v;d++){var M=c(m,0,d,this.toBBox),_=c(m,d,l,this.toBBox),B=(x=M,A=_,I=void 0,b=void 0,T=void 0,Y=void 0,I=Math.max(x.minX,A.minX),b=Math.max(x.minY,A.minY),T=Math.min(x.maxX,A.maxX),Y=Math.min(x.maxY,A.maxY),Math.max(0,T-I)*Math.max(0,Y-b)),N=p(M)+p(_);B<D?(D=B,g=d,Q=N<Q?N:Q):B===D&&N<Q&&(Q=N,g=d)}return g||l-v},i.prototype._chooseSplitAxis=function(m,v,l){var g=m.leaf?this.compareMinX:u,x=m.leaf?this.compareMinY:h;this._allDistMargin(m,v,l,g)<this._allDistMargin(m,v,l,x)&&m.children.sort(g)},i.prototype._allDistMargin=function(m,v,l,g){m.children.sort(g);for(var x=this.toBBox,A=c(m,0,v,x),I=c(m,l-v,l,x),b=y(A)+y(I),T=v;T<l-v;T++){var Y=m.children[T];f(A,m.leaf?x(Y):Y),b+=y(A)}for(var D=l-v-1;D>=v;D--){var Q=m.children[D];f(I,m.leaf?x(Q):Q),b+=y(I)}return b},i.prototype._adjustParentBBoxes=function(m,v,l){for(var g=l;g>=0;g--)f(v[g],m)},i.prototype._condense=function(m){for(var v=m.length-1,l=void 0;v>=0;v--)m[v].children.length===0?v>0?(l=m[v-1].children).splice(l.indexOf(m[v]),1):this.clear():a(m[v],this.toBBox)},i})})(Re)),Re.exports}let pr=class{constructor(t=[],e=mr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}};function mr(s,t){return s<t?-1:s>t?1:0}const gr=ur(Object.freeze(Object.defineProperty({__proto__:null,default:pr},Symbol.toStringTag,{value:"Module"})));var xe={exports:{}},Ze,vn;function wr(){return vn||(vn=1,Ze=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=(r-n)/2,f=0,u=c-1;f<c;u=f++){var h=e[n+f*2+0],p=e[n+f*2+1],y=e[n+u*2+0],E=e[n+u*2+1],k=p>o!=E>o&&i<(y-h)*(o-p)/(E-p)+h;k&&(a=!a)}return a}),Ze}var tn,bn;function yr(){return bn||(bn=1,tn=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=r-n,f=0,u=c-1;f<c;u=f++){var h=e[f+n][0],p=e[f+n][1],y=e[u+n][0],E=e[u+n][1],k=p>o!=E>o&&i<(y-h)*(o-p)/(E-p)+h;k&&(a=!a)}return a}),tn}var _n;function vr(){if(_n)return xe.exports;_n=1;var s=wr(),t=yr();return xe.exports=function(n,r,i,o){return r.length>0&&Array.isArray(r[0])?t(n,r,i,o):s(n,r,i,o)},xe.exports.nested=t,xe.exports.flat=s,xe.exports}var Me={exports:{}},br=Me.exports,xn;function _r(){return xn||(xn=1,(function(s,t){(function(e,n){n(t)})(br,function(e){const r=33306690738754706e-32;function i(k,X,C,m,v){let l,g,x,A,I=X[0],b=m[0],T=0,Y=0;b>I==b>-I?(l=I,I=X[++T]):(l=b,b=m[++Y]);let D=0;if(T<k&&Y<C)for(b>I==b>-I?(x=l-((g=I+l)-I),I=X[++T]):(x=l-((g=b+l)-b),b=m[++Y]),l=g,x!==0&&(v[D++]=x);T<k&&Y<C;)b>I==b>-I?(x=l-((g=l+I)-(A=g-l))+(I-A),I=X[++T]):(x=l-((g=l+b)-(A=g-l))+(b-A),b=m[++Y]),l=g,x!==0&&(v[D++]=x);for(;T<k;)x=l-((g=l+I)-(A=g-l))+(I-A),I=X[++T],l=g,x!==0&&(v[D++]=x);for(;Y<C;)x=l-((g=l+b)-(A=g-l))+(b-A),b=m[++Y],l=g,x!==0&&(v[D++]=x);return l===0&&D!==0||(v[D++]=l),D}function o(k){return new Float64Array(k)}const a=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,u=o(4),h=o(8),p=o(12),y=o(16),E=o(4);e.orient2d=function(k,X,C,m,v,l){const g=(X-l)*(C-v),x=(k-v)*(m-l),A=g-x;if(g===0||x===0||g>0!=x>0)return A;const I=Math.abs(g+x);return Math.abs(A)>=a*I?A:-(function(b,T,Y,D,Q,d,M){let _,B,N,R,w,O,$,j,V,z,K,U,ct,ft,dt,pt,gt,mt;const Pt=b-Q,Nt=Y-Q,xt=T-d,Mt=D-d;w=(dt=(j=Pt-($=(O=134217729*Pt)-(O-Pt)))*(z=Mt-(V=(O=134217729*Mt)-(O-Mt)))-((ft=Pt*Mt)-$*V-j*V-$*z))-(K=dt-(gt=(j=xt-($=(O=134217729*xt)-(O-xt)))*(z=Nt-(V=(O=134217729*Nt)-(O-Nt)))-((pt=xt*Nt)-$*V-j*V-$*z))),u[0]=dt-(K+w)+(w-gt),w=(ct=ft-((U=ft+K)-(w=U-ft))+(K-w))-(K=ct-pt),u[1]=ct-(K+w)+(w-pt),w=(mt=U+K)-U,u[2]=U-(mt-w)+(K-w),u[3]=mt;let ee=(function(S,P){let F=P[0];for(let L=1;L<S;L++)F+=P[L];return F})(4,u),pe=c*M;if(ee>=pe||-ee>=pe||(_=b-(Pt+(w=b-Pt))+(w-Q),N=Y-(Nt+(w=Y-Nt))+(w-Q),B=T-(xt+(w=T-xt))+(w-d),R=D-(Mt+(w=D-Mt))+(w-d),_===0&&B===0&&N===0&&R===0)||(pe=f*M+r*Math.abs(ee),(ee+=Pt*R+Mt*_-(xt*N+Nt*B))>=pe||-ee>=pe))return ee;w=(dt=(j=_-($=(O=134217729*_)-(O-_)))*(z=Mt-(V=(O=134217729*Mt)-(O-Mt)))-((ft=_*Mt)-$*V-j*V-$*z))-(K=dt-(gt=(j=B-($=(O=134217729*B)-(O-B)))*(z=Nt-(V=(O=134217729*Nt)-(O-Nt)))-((pt=B*Nt)-$*V-j*V-$*z))),E[0]=dt-(K+w)+(w-gt),w=(ct=ft-((U=ft+K)-(w=U-ft))+(K-w))-(K=ct-pt),E[1]=ct-(K+w)+(w-pt),w=(mt=U+K)-U,E[2]=U-(mt-w)+(K-w),E[3]=mt;const fn=i(4,u,4,E,h);w=(dt=(j=Pt-($=(O=134217729*Pt)-(O-Pt)))*(z=R-(V=(O=134217729*R)-(O-R)))-((ft=Pt*R)-$*V-j*V-$*z))-(K=dt-(gt=(j=xt-($=(O=134217729*xt)-(O-xt)))*(z=N-(V=(O=134217729*N)-(O-N)))-((pt=xt*N)-$*V-j*V-$*z))),E[0]=dt-(K+w)+(w-gt),w=(ct=ft-((U=ft+K)-(w=U-ft))+(K-w))-(K=ct-pt),E[1]=ct-(K+w)+(w-pt),w=(mt=U+K)-U,E[2]=U-(mt-w)+(K-w),E[3]=mt;const hn=i(fn,h,4,E,p);w=(dt=(j=_-($=(O=134217729*_)-(O-_)))*(z=R-(V=(O=134217729*R)-(O-R)))-((ft=_*R)-$*V-j*V-$*z))-(K=dt-(gt=(j=B-($=(O=134217729*B)-(O-B)))*(z=N-(V=(O=134217729*N)-(O-N)))-((pt=B*N)-$*V-j*V-$*z))),E[0]=dt-(K+w)+(w-gt),w=(ct=ft-((U=ft+K)-(w=U-ft))+(K-w))-(K=ct-pt),E[1]=ct-(K+w)+(w-pt),w=(mt=U+K)-U,E[2]=U-(mt-w)+(K-w),E[3]=mt;const jt=i(hn,p,4,E,y);return y[jt-1]})(k,X,C,m,v,l,I)},e.orient2dfast=function(k,X,C,m,v,l){return(X-l)*(C-v)-(k-v)*(m-l)},Object.defineProperty(e,"__esModule",{value:!0})})})(Me,Me.exports)),Me.exports}var Mn;function xr(){if(Mn)return Xe.exports;Mn=1;var s=dr(),t=gr,e=vr(),n=_r().orient2d;t.default&&(t=t.default),Xe.exports=r,Xe.exports.default=r;function r(l,g,x){g=Math.max(0,g===void 0?2:g),x=x||0;var A=y(l),I=new s(16);I.toBBox=function($){return{minX:$[0],minY:$[1],maxX:$[0],maxY:$[1]}},I.compareMinX=function($,j){return $[0]-j[0]},I.compareMinY=function($,j){return $[1]-j[1]},I.load(l);for(var b=[],T=0,Y;T<A.length;T++){var D=A[T];I.remove(D),Y=E(D,Y),b.push(Y)}var Q=new s(16);for(T=0;T<b.length;T++)Q.insert(p(b[T]));for(var d=g*g,M=x*x;b.length;){var _=b.shift(),B=_.p,N=_.next.p,R=k(B,N);if(!(R<M)){var w=R/d;D=i(I,_.prev.p,B,N,_.next.next.p,w,Q),D&&Math.min(k(D,B),k(D,N))<=w&&(b.push(_),b.push(E(D,_)),I.remove(D),Q.remove(_),Q.insert(p(_)),Q.insert(p(_.next)))}}_=Y;var O=[];do O.push(_.p),_=_.next;while(_!==Y);return O.push(_.p),O}function i(l,g,x,A,I,b,T){for(var Y=new t([],o),D=l.data;D;){for(var Q=0;Q<D.children.length;Q++){var d=D.children[Q],M=D.leaf?X(d,x,A):a(x,A,d);M>b||Y.push({node:d,dist:M})}for(;Y.length&&!Y.peek().node.children;){var _=Y.pop(),B=_.node,N=X(B,g,x),R=X(B,A,I);if(_.dist<N&&_.dist<R&&f(x,B,T)&&f(A,B,T))return B}D=Y.pop(),D&&(D=D.node)}return null}function o(l,g){return l.dist-g.dist}function a(l,g,x){if(c(l,x)||c(g,x))return 0;var A=C(l[0],l[1],g[0],g[1],x.minX,x.minY,x.maxX,x.minY);if(A===0)return 0;var I=C(l[0],l[1],g[0],g[1],x.minX,x.minY,x.minX,x.maxY);if(I===0)return 0;var b=C(l[0],l[1],g[0],g[1],x.maxX,x.minY,x.maxX,x.maxY);if(b===0)return 0;var T=C(l[0],l[1],g[0],g[1],x.minX,x.maxY,x.maxX,x.maxY);return T===0?0:Math.min(A,I,b,T)}function c(l,g){return l[0]>=g.minX&&l[0]<=g.maxX&&l[1]>=g.minY&&l[1]<=g.maxY}function f(l,g,x){for(var A=Math.min(l[0],g[0]),I=Math.min(l[1],g[1]),b=Math.max(l[0],g[0]),T=Math.max(l[1],g[1]),Y=x.search({minX:A,minY:I,maxX:b,maxY:T}),D=0;D<Y.length;D++)if(h(Y[D].p,Y[D].next.p,l,g))return!1;return!0}function u(l,g,x){return n(l[0],l[1],g[0],g[1],x[0],x[1])}function h(l,g,x,A){return l!==A&&g!==x&&u(l,g,x)>0!=u(l,g,A)>0&&u(x,A,l)>0!=u(x,A,g)>0}function p(l){var g=l.p,x=l.next.p;return l.minX=Math.min(g[0],x[0]),l.minY=Math.min(g[1],x[1]),l.maxX=Math.max(g[0],x[0]),l.maxY=Math.max(g[1],x[1]),l}function y(l){for(var g=l[0],x=l[0],A=l[0],I=l[0],b=0;b<l.length;b++){var T=l[b];T[0]<g[0]&&(g=T),T[0]>A[0]&&(A=T),T[1]<x[1]&&(x=T),T[1]>I[1]&&(I=T)}var Y=[g,x,A,I],D=Y.slice();for(b=0;b<l.length;b++)e(l[b],Y)||D.push(l[b]);return v(D)}function E(l,g){var x={p:l,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return g?(x.next=g.next,x.prev=g,g.next.prev=x,g.next=x):(x.prev=x,x.next=x),x}function k(l,g){var x=l[0]-g[0],A=l[1]-g[1];return x*x+A*A}function X(l,g,x){var A=g[0],I=g[1],b=x[0]-A,T=x[1]-I;if(b!==0||T!==0){var Y=((l[0]-A)*b+(l[1]-I)*T)/(b*b+T*T);Y>1?(A=x[0],I=x[1]):Y>0&&(A+=b*Y,I+=T*Y)}return b=l[0]-A,T=l[1]-I,b*b+T*T}function C(l,g,x,A,I,b,T,Y){var D=x-l,Q=A-g,d=T-I,M=Y-b,_=l-I,B=g-b,N=D*D+Q*Q,R=D*d+Q*M,w=d*d+M*M,O=D*_+Q*B,$=d*_+M*B,j=N*w-R*R,V,z,K,U,ct=j,ft=j;j===0?(z=0,ct=1,U=$,ft=w):(z=R*$-w*O,U=N*$-R*O,z<0?(z=0,U=$,ft=w):z>ct&&(z=ct,U=$+R,ft=w)),U<0?(U=0,-O<0?z=0:-O>N?z=ct:(z=-O,ct=N)):U>ft&&(U=ft,-O+R<0?z=0:-O+R>N?z=ct:(z=-O+R,ct=N)),V=z===0?0:z/ct,K=U===0?0:U/ft;var dt=(1-V)*l+V*x,pt=(1-V)*g+V*A,gt=(1-K)*I+K*T,mt=(1-K)*b+K*Y,Pt=gt-dt,Nt=mt-pt;return Pt*Pt+Nt*Nt}function m(l,g){return l[0]===g[0]?l[1]-g[1]:l[0]-g[0]}function v(l){l.sort(m);for(var g=[],x=0;x<l.length;x++){for(;g.length>=2&&u(g[g.length-2],g[g.length-1],l[x])<=0;)g.pop();g.push(l[x])}for(var A=[],I=l.length-1;I>=0;I--){for(;A.length>=2&&u(A[A.length-2],A[A.length-1],l[I])<=0;)A.pop();A.push(l[I])}return A.pop(),g.pop(),g.concat(A)}return Xe.exports}var Mr=xr();const kr=hr(Mr);function Sr(s,t={}){t.concavity=t.concavity||1/0;const e=[];if(He(s,r=>{e.push([r[0],r[1]])}),!e.length)return null;const n=kr(e,t.concavity);return n.length>3?_e([n]):null}var kn=Sr,ke={exports:{}},Er=ke.exports,Sn;function Ar(){return Sn||(Sn=1,(function(s,t){(function(e,n){n(t)})(Er,function(e){const n=11102230246251565e-32,r=134217729,i=(3+8*n)*n;function o(S,P,F,L,tt){let G,et,ot,it,at=P[0],ht=L[0],J=0,Z=0;ht>at==ht>-at?(G=at,at=P[++J]):(G=ht,ht=L[++Z]);let ut=0;if(J<S&&Z<F)for(ht>at==ht>-at?(et=at+G,ot=G-(et-at),at=P[++J]):(et=ht+G,ot=G-(et-ht),ht=L[++Z]),G=et,ot!==0&&(tt[ut++]=ot);J<S&&Z<F;)ht>at==ht>-at?(et=G+at,it=et-G,ot=G-(et-it)+(at-it),at=P[++J]):(et=G+ht,it=et-G,ot=G-(et-it)+(ht-it),ht=L[++Z]),G=et,ot!==0&&(tt[ut++]=ot);for(;J<S;)et=G+at,it=et-G,ot=G-(et-it)+(at-it),at=P[++J],G=et,ot!==0&&(tt[ut++]=ot);for(;Z<F;)et=G+ht,it=et-G,ot=G-(et-it)+(ht-it),ht=L[++Z],G=et,ot!==0&&(tt[ut++]=ot);return(G!==0||ut===0)&&(tt[ut++]=G),ut}function a(S,P){let F=P[0];for(let L=1;L<S;L++)F+=P[L];return F}function c(S){return new Float64Array(S)}const f=(3+16*n)*n,u=(2+12*n)*n,h=(9+64*n)*n*n,p=c(4),y=c(8),E=c(12),k=c(16),X=c(4);function C(S,P,F,L,tt,G,et){let ot,it,at,ht,J,Z,ut,_t,nt,H,W,wt,Et,At,Xt,vt,Tt,Ct;const Wt=S-tt,Jt=F-tt,Kt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t=Z-(Z-ht),H=ht-nt,Xt=_t*H-(At-ut*nt-_t*nt-ut*H),vt=Kt*at,Z=r*Kt,ut=Z-(Z-Kt),_t=Kt-ut,Z=r*at,nt=Z-(Z-at),H=at-nt,Tt=_t*H-(vt-ut*nt-_t*nt-ut*H),W=Xt-Tt,J=Xt-W,X[0]=Xt-(W+J)+(J-Tt),wt=At+W,J=wt-At,Et=At-(wt-J)+(W-J),W=Et-vt,J=Et-W,X[1]=Et-(W+J)+(J-vt),Ct=wt+W,J=Ct-wt,X[2]=wt-(Ct-J)+(W-J),X[3]=Ct;const Ei=o(Si,y,4,X,E);At=ot*ht,Z=r*ot,ut=Z-(Z-ot),_t=ot-ut,Z=r*ht,nt=Z-(Z-ht),H=ht-nt,Xt=_t*H-(At-ut*nt-_t*nt-ut*H),vt=it*at,Z=r*it,ut=Z-(Z-it),_t=it-ut,Z=r*at,nt=Z-(Z-at),H=at-nt,Tt=_t*H-(vt-ut*nt-_t*nt-ut*H),W=Xt-Tt,J=Xt-W,X[0]=Xt-(W+J)+(J-Tt),wt=At+W,J=wt-At,Et=At-(wt-J)+(W-J),W=Et-vt,J=Et-W,X[1]=Et-(W+J)+(J-vt),Ct=wt+W,J=Ct-wt,X[2]=wt-(Ct-J)+(W-J),X[3]=Ct;const Ai=o(Ei,E,4,X,k);return k[Ai-1]}function m(S,P,F,L,tt,G){const et=(P-G)*(F-tt),ot=(S-tt)*(L-G),it=et-ot,at=Math.abs(et+ot);return Math.abs(it)>=f*at?it:-C(S,P,F,L,tt,G,at)}function v(S,P){var F,L,tt=0,G,et,ot,it,at,ht,J,Z=S[0],ut=S[1],_t=P.length;for(F=0;F<_t;F++){L=0;var nt=P[F],H=nt.length-1;if(ht=nt[0],ht[0]!==nt[H][0]&&ht[1]!==nt[H][1])throw new Error("First and last coordinates in a ring must be the same");for(et=ht[0]-Z,ot=ht[1]-ut,L;L<H;L++){if(J=nt[L+1],it=J[0]-Z,at=J[1]-ut,ot===0&&at===0){if(it<=0&&et>=0||et<=0&&it>=0)return 0}else if(at>=0&&ot<=0||at<=0&&ot>=0){if(G=m(et,it,ot,at,0,0),G===0)return 0;(G>0&&at>0&&ot<=0||G<0&&at<=0&&ot>0)&&tt++}ht=J,ot=at,et=it}}return tt%2!==0}function l(S,P,F={}){const L={type:"Feature"};return(F.id===0||F.id)&&(L.id=F.id),F.bbox&&(L.bbox=F.bbox),L.properties=P||{},L.geometry=S,L}function g(S,P,F={}){if(!S)throw new Error("coordinates is required");if(!Array.isArray(S))throw new Error("coordinates must be an Array");if(S.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!I(S[0])||!I(S[1]))throw new Error("coordinates must contain numbers");return l({type:"Point",coordinates:S},P,F)}function x(S,P,F={}){for(const L of S){if(L.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(L[L.length-1].length!==L[0].length)throw new Error("First and last Position are not equivalent.");for(let tt=0;tt<L[L.length-1].length;tt++)if(L[L.length-1][tt]!==L[0][tt])throw new Error("First and last Position are not equivalent.")}return l({type:"Polygon",coordinates:S},P,F)}function A(S,P={}){const F={type:"FeatureCollection"};return P.id&&(F.id=P.id),P.bbox&&(F.bbox=P.bbox),F.features=S,F}function I(S){return!isNaN(S)&&S!==null&&!Array.isArray(S)}function b(S){if(!S)throw new Error("coord is required");if(!Array.isArray(S)){if(S.type==="Feature"&&S.geometry!==null&&S.geometry.type==="Point")return[...S.geometry.coordinates];if(S.type==="Point")return[...S.coordinates]}if(Array.isArray(S)&&S.length>=2&&!Array.isArray(S[0])&&!Array.isArray(S[1]))return[...S];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function T(S){if(Array.isArray(S))return S;if(S.type==="Feature"){if(S.geometry!==null)return S.geometry.coordinates}else if(S.coordinates)return S.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Y(S){return S.type==="Feature"?S.geometry:S}function D(S,P,F={}){if(!S)throw new Error("point is required");if(!P)throw new Error("polygon is required");const L=b(S),tt=Y(P),G=tt.type,et=P.bbox;let ot=tt.coordinates;if(et&&Q(L,et)===!1)return!1;G==="Polygon"&&(ot=[ot]);let it=!1;for(var at=0;at<ot.length;++at){const ht=v(L,ot[at]);if(ht===0)return!F.ignoreBoundary;ht&&(it=!0)}return it}function Q(S,P){return P[0]<=S[0]&&P[1]<=S[1]&&P[2]>=S[0]&&P[3]>=S[1]}var d=D;function M(S,P){for(let F=0;F<P.features.length;F++)if(d(S,P.features[F]))return P.features[F]}function _(S,P,F){const L=P.geometry.coordinates[0][0],tt=P.geometry.coordinates[0][1],G=P.geometry.coordinates[0][2],et=S.geometry.coordinates,ot=P.properties.a.geom,it=P.properties.b.geom,at=P.properties.c.geom,ht=[tt[0]-L[0],tt[1]-L[1]],J=[G[0]-L[0],G[1]-L[1]],Z=[et[0]-L[0],et[1]-L[1]],ut=[it[0]-ot[0],it[1]-ot[1]],_t=[at[0]-ot[0],at[1]-ot[1]];let nt=(J[1]*Z[0]-J[0]*Z[1])/(ht[0]*J[1]-ht[1]*J[0]),H=(ht[0]*Z[1]-ht[1]*Z[0])/(ht[0]*J[1]-ht[1]*J[0]);if(F){const W=F[P.properties.a.index],wt=F[P.properties.b.index],Et=F[P.properties.c.index];let At;if(nt<0||H<0||1-nt-H<0){const Xt=nt/(nt+H),vt=H/(nt+H);At=nt/wt/(Xt/wt+vt/Et),H=H/Et/(Xt/wt+vt/Et)}else At=nt/wt/(nt/wt+H/Et+(1-nt-H)/W),H=H/Et/(nt/wt+H/Et+(1-nt-H)/W);nt=At}return[nt*ut[0]+H*_t[0]+ot[0],nt*ut[1]+H*_t[1]+ot[1]]}function B(S,P,F,L){const tt=S.geometry.coordinates,G=F.geometry.coordinates,et=Math.atan2(tt[0]-G[0],tt[1]-G[1]),ot=w(et,P[0]);if(ot===void 0)throw new Error("Unable to determine vertex index");const it=P[1][ot];return _(S,it.features[0],L)}function N(S,P,F,L,tt,G,et,ot){let it;if(et&&(it=M(S,A([et]))),!it){if(F){const at=S.geometry.coordinates,ht=F.gridNum,J=F.xOrigin,Z=F.yOrigin,ut=F.xUnit,_t=F.yUnit,nt=F.gridCache,H=R(at[0],J,ut,ht),W=R(at[1],Z,_t,ht),wt=nt[H]?nt[H][W]?nt[H][W]:[]:[];P=A(wt.map(Et=>P.features[Et]))}it=M(S,P)}return ot&&ot(it),it?_(S,it,G):B(S,L,tt,G)}function R(S,P,F,L){let tt=Math.floor((S-P)/F);return tt>=L&&(tt=L-1),tt}function w(S,P){let F=O(S-P[0]),L=Math.PI*2,tt;for(let G=0;G<P.length;G++){const et=(G+1)%P.length,ot=O(S-P[et]),it=Math.min(Math.abs(F),Math.abs(ot));F*ot<=0&&it<L&&(L=it,tt=G),F=ot}return tt}function O(S,P=!1){const F=P?function(L){return!(L>=0&&L<Math.PI*2)}:function(L){return!(L>-1*Math.PI&&L<=Math.PI)};for(;F(S);)S=S+2*Math.PI*(S>0?-1:1);return S}function $(S,P){return P&&P>=2.00703||Array.isArray(S[0])?S:S.map(F=>[F.illstNodes,F.mercNodes,F.startEnd])}function j(S){const P=S.features;for(let F=0;F<P.length;F++){const L=P[F];`${L.properties.a.index}`.substring(0,1)==="b"&&`${L.properties.b.index}`.substring(0,1)==="b"?P[F]={geometry:{type:"Polygon",coordinates:[[L.geometry.coordinates[0][2],L.geometry.coordinates[0][0],L.geometry.coordinates[0][1],L.geometry.coordinates[0][2]]]},properties:{a:{geom:L.properties.c.geom,index:L.properties.c.index},b:{geom:L.properties.a.geom,index:L.properties.a.index},c:{geom:L.properties.b.geom,index:L.properties.b.index}},type:"Feature"}:`${L.properties.c.index}`.substring(0,1)==="b"&&`${L.properties.a.index}`.substring(0,1)==="b"&&(P[F]={geometry:{type:"Polygon",coordinates:[[L.geometry.coordinates[0][1],L.geometry.coordinates[0][2],L.geometry.coordinates[0][0],L.geometry.coordinates[0][1]]]},properties:{a:{geom:L.properties.b.geom,index:L.properties.b.index},b:{geom:L.properties.c.geom,index:L.properties.c.index},c:{geom:L.properties.a.geom,index:L.properties.a.index}},type:"Feature"})}return S}function V(S){const P=["a","b","c","a"].map(G=>S.properties[G].geom),F=S.geometry.coordinates[0],L=S.properties,tt={a:{geom:F[0],index:L.a.index},b:{geom:F[1],index:L.b.index},c:{geom:F[2],index:L.c.index}};return x([P],tt)}function z(S){const P=[0,1,2,0].map(L=>S[L][0][0]),F={a:{geom:S[0][0][1],index:S[0][1]},b:{geom:S[1][0][1],index:S[1][1]},c:{geom:S[2][0][1],index:S[2][1]}};return x([P],F)}function K(S,P,F,L,tt,G=!1,et){const ot=S.map(it=>{(!et||et<2.00703)&&(it=U(it));const at=isFinite(it)?P[it]:it==="c"?L:it==="b0"?tt[0]:it==="b1"?tt[1]:it==="b2"?tt[2]:it==="b3"?tt[3]:(function(){const ht=it.match(/e(\d+)/);if(ht){const J=parseInt(ht[1]);return F[J]}throw"Bad index value for indexesToTri"})();return G?[[at[1],at[0]],it]:[[at[0],at[1]],it]});return z(ot)}function U(S){return typeof S=="number"?S:S.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}const ct=2.00703;function ft(S){return!!(S.version||!S.tins&&S.points&&S.tins_points)}function dt(S){return{points:S.points,pointsWeightBuffer:gt(S),strictStatus:mt(S),verticesParams:Pt(S),centroid:xt(S),edges:$(S.edges||[]),edgeNodes:S.edgeNodes||[],tins:Mt(S),kinks:ee(S.kinks_points),yaxisMode:S.yaxisMode??"invert",strictMode:S.strictMode??"auto",vertexMode:S.vertexMode,bounds:S.bounds,boundsPolygon:S.boundsPolygon,wh:S.wh,xy:S.bounds?S.xy:[0,0]}}function pt(S){const P=pe(S),F=P.tins;return{compiled:P,tins:F,points:fn(F),strictStatus:P.strict_status,pointsWeightBuffer:P.weight_buffer,verticesParams:P.vertices_params,centroid:P.centroid,kinks:P.kinks}}function gt(S){return!S.version||S.version<ct?["forw","bakw"].reduce((P,F)=>{const L=S.weight_buffer[F];return L&&(P[F]=Object.keys(L).reduce((tt,G)=>{const et=U(G);return tt[et]=L[G],tt},{})),P},{}):S.weight_buffer}function mt(S){return S.strict_status?S.strict_status:S.kinks_points?"strict_error":S.tins_points.length===2?"loose":"strict"}function Pt(S){const P={forw:[S.vertices_params[0]],bakw:[S.vertices_params[1]]};return P.forw[1]=Nt(S,!1),P.bakw[1]=Nt(S,!0),P}function Nt(S,P){return[0,1,2,3].map(F=>{const L=(F+1)%4,tt=K(["c",`b${F}`,`b${L}`],S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,P,ct);return A([tt])})}function xt(S){return{forw:g(S.centroid_point[0],{target:{geom:S.centroid_point[1],index:"c"}}),bakw:g(S.centroid_point[1],{target:{geom:S.centroid_point[0],index:"c"}})}}function Mt(S){const P=S.tins_points.length===1?0:1;return{forw:A(S.tins_points[0].map(F=>K(F,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!1,S.version))),bakw:A(S.tins_points[P].map(F=>K(F,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!0,S.version)))}}function ee(S){if(S)return{bakw:A(S.map(P=>g(P)))}}function pe(S){return JSON.parse(JSON.stringify(S).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function fn(S){const P=[],F=S.forw.features;for(let L=0;L<F.length;L++){const tt=F[L];["a","b","c"].map((G,et)=>{const ot=tt.geometry.coordinates[0][et],it=tt.properties[G].geom,at=tt.properties[G].index;typeof at=="number"&&(P[at]=[ot,it])})}return P}const hn=ct;class jt{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=jt.YAXIS_INVERT;strictMode=jt.MODE_AUTO;vertexMode=jt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;constructor(){}setCompiled(P){if(ft(P)){this.applyModernState(dt(P));return}this.applyLegacyState(pt(P))}applyModernState(P){this.points=P.points,this.pointsWeightBuffer=P.pointsWeightBuffer,this.strict_status=P.strictStatus,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.edges=P.edges,this.edgeNodes=P.edgeNodes||[],this.tins=P.tins,this.addIndexedTin(),this.kinks=P.kinks,this.yaxisMode=P.yaxisMode??jt.YAXIS_INVERT,this.vertexMode=P.vertexMode??jt.VERTEX_PLAIN,this.strictMode=P.strictMode??jt.MODE_AUTO,P.bounds?(this.bounds=P.bounds,this.boundsPolygon=P.boundsPolygon,this.xy=P.xy,this.wh=P.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=P.xy??[0,0],P.wh&&(this.wh=P.wh))}applyLegacyState(P){this.tins=P.tins,this.addIndexedTin(),this.strict_status=P.strictStatus,this.pointsWeightBuffer=P.pointsWeightBuffer,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.kinks=P.kinks,this.points=P.points}addIndexedTin(){const P=this.tins,F=P.forw,L=P.bakw,tt=Math.ceil(Math.sqrt(F.features.length));if(tt<3){this.indexedTins=void 0;return}let G=[],et=[];const ot=F.features.map(nt=>{let H=[];return T(nt)[0].map(W=>{G.length===0?G=[Array.from(W),Array.from(W)]:(W[0]<G[0][0]&&(G[0][0]=W[0]),W[0]>G[1][0]&&(G[1][0]=W[0]),W[1]<G[0][1]&&(G[0][1]=W[1]),W[1]>G[1][1]&&(G[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),it=(G[1][0]-G[0][0])/tt,at=(G[1][1]-G[0][1])/tt,ht=ot.reduce((nt,H,W)=>{const wt=R(H[0][0],G[0][0],it,tt),Et=R(H[1][0],G[0][0],it,tt),At=R(H[0][1],G[0][1],at,tt),Xt=R(H[1][1],G[0][1],at,tt);for(let vt=wt;vt<=Et;vt++){nt[vt]||(nt[vt]=[]);for(let Tt=At;Tt<=Xt;Tt++)nt[vt][Tt]||(nt[vt][Tt]=[]),nt[vt][Tt].push(W)}return nt},[]),J=L.features.map(nt=>{let H=[];return T(nt)[0].map(W=>{et.length===0?et=[Array.from(W),Array.from(W)]:(W[0]<et[0][0]&&(et[0][0]=W[0]),W[0]>et[1][0]&&(et[1][0]=W[0]),W[1]<et[0][1]&&(et[0][1]=W[1]),W[1]>et[1][1]&&(et[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),Z=(et[1][0]-et[0][0])/tt,ut=(et[1][1]-et[0][1])/tt,_t=J.reduce((nt,H,W)=>{const wt=R(H[0][0],et[0][0],Z,tt),Et=R(H[1][0],et[0][0],Z,tt),At=R(H[0][1],et[0][1],ut,tt),Xt=R(H[1][1],et[0][1],ut,tt);for(let vt=wt;vt<=Et;vt++){nt[vt]||(nt[vt]=[]);for(let Tt=At;Tt<=Xt;Tt++)nt[vt][Tt]||(nt[vt][Tt]=[]),nt[vt][Tt].push(W)}return nt},[]);this.indexedTins={forw:{gridNum:tt,xOrigin:G[0][0],yOrigin:G[0][1],xUnit:it,yUnit:at,gridCache:ht},bakw:{gridNum:tt,xOrigin:et[0][0],yOrigin:et[0][1],xUnit:Z,yUnit:ut,gridCache:_t}}}transform(P,F,L){if(F&&this.strict_status==jt.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==jt.YAXIS_FOLLOW&&F&&(P=[P[0],-1*P[1]]);const tt=g(P);if(this.bounds&&!F&&!L&&!d(tt,this.boundsPolygon))return!1;const G=F?this.tins.bakw:this.tins.forw,et=F?this.indexedTins.bakw:this.indexedTins.forw,ot=F?this.vertices_params.bakw:this.vertices_params.forw,it=F?this.centroid.bakw:this.centroid.forw,at=F?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let ht,J;this.stateFull&&(this.stateBackward==F?ht=this.stateTriangle:(this.stateBackward=F,this.stateTriangle=void 0),J=ut=>{this.stateTriangle=ut});let Z=N(tt,G,et,ot,it,at,ht,J);if(this.bounds&&F&&!L){const ut=g(Z);if(!d(ut,this.boundsPolygon))return!1}else this.yaxisMode==jt.YAXIS_FOLLOW&&!F&&(Z=[Z[0],-1*Z[1]]);return Z}}e.Transform=jt,e.counterTri=V,e.format_version=hn,e.normalizeEdges=$,e.rotateVerticesTriangle=j,e.transformArr=N,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})})})(ke,ke.exports)),ke.exports}var zt=Ar();const En=Math.pow(2,-52),Ye=new Uint32Array(512);class en{static from(t,e=Tr,n=Nr){const r=t.length,i=new Float64Array(r*2);for(let o=0;o<r;o++){const a=t[o];i[2*o]=e(a),i[2*o+1]=n(a)}return new en(i)}constructor(t){const e=t.length>>1;if(e>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const n=Math.max(2*e-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:n,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let a=1/0,c=1/0,f=-1/0,u=-1/0;for(let b=0;b<o;b++){const T=t[2*b],Y=t[2*b+1];T<a&&(a=T),Y<c&&(c=Y),T>f&&(f=T),Y>u&&(u=Y),this._ids[b]=b}const h=(a+f)/2,p=(c+u)/2;let y,E,k;for(let b=0,T=1/0;b<o;b++){const Y=nn(h,p,t[2*b],t[2*b+1]);Y<T&&(y=b,T=Y)}const X=t[2*y],C=t[2*y+1];for(let b=0,T=1/0;b<o;b++){if(b===y)continue;const Y=nn(X,C,t[2*b],t[2*b+1]);Y<T&&Y>0&&(E=b,T=Y)}let m=t[2*E],v=t[2*E+1],l=1/0;for(let b=0;b<o;b++){if(b===y||b===E)continue;const T=Or(X,C,m,v,t[2*b],t[2*b+1]);T<l&&(k=b,l=T)}let g=t[2*k],x=t[2*k+1];if(l===1/0){for(let Y=0;Y<o;Y++)this._dists[Y]=t[2*Y]-t[0]||t[2*Y+1]-t[1];ye(this._ids,this._dists,0,o-1);const b=new Uint32Array(o);let T=0;for(let Y=0,D=-1/0;Y<o;Y++){const Q=this._ids[Y],d=this._dists[Q];d>D&&(b[T++]=Q,D=d)}this.hull=b.subarray(0,T),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Qt(X,C,m,v,g,x)<0){const b=E,T=m,Y=v;E=k,m=g,v=x,k=b,g=T,x=Y}const A=Ir(X,C,m,v,g,x);this._cx=A.x,this._cy=A.y;for(let b=0;b<o;b++)this._dists[b]=nn(t[2*b],t[2*b+1],A.x,A.y);ye(this._ids,this._dists,0,o-1),this._hullStart=y;let I=3;n[y]=e[k]=E,n[E]=e[y]=k,n[k]=e[E]=y,r[y]=0,r[E]=1,r[k]=2,i.fill(-1),i[this._hashKey(X,C)]=y,i[this._hashKey(m,v)]=E,i[this._hashKey(g,x)]=k,this.trianglesLen=0,this._addTriangle(y,E,k,-1,-1,-1);for(let b=0,T,Y;b<this._ids.length;b++){const D=this._ids[b],Q=t[2*D],d=t[2*D+1];if(b>0&&Math.abs(Q-T)<=En&&Math.abs(d-Y)<=En||(T=Q,Y=d,D===y||D===E||D===k))continue;let M=0;for(let w=0,O=this._hashKey(Q,d);w<this._hashSize&&(M=i[(O+w)%this._hashSize],!(M!==-1&&M!==n[M]));w++);M=e[M];let _=M,B;for(;B=n[_],Qt(Q,d,t[2*_],t[2*_+1],t[2*B],t[2*B+1])>=0;)if(_=B,_===M){_=-1;break}if(_===-1)continue;let N=this._addTriangle(_,D,n[_],-1,-1,r[_]);r[D]=this._legalize(N+2),r[_]=N,I++;let R=n[_];for(;B=n[R],Qt(Q,d,t[2*R],t[2*R+1],t[2*B],t[2*B+1])<0;)N=this._addTriangle(R,D,B,r[D],-1,r[R]),r[D]=this._legalize(N+2),n[R]=R,I--,R=B;if(_===M)for(;B=e[_],Qt(Q,d,t[2*B],t[2*B+1],t[2*_],t[2*_+1])<0;)N=this._addTriangle(B,D,_,-1,r[_],r[B]),this._legalize(N+2),r[B]=N,n[_]=_,I--,_=B;this._hullStart=e[D]=_,n[_]=e[R]=D,n[D]=R,i[this._hashKey(Q,d)]=D,i[this._hashKey(t[2*_],t[2*_+1])]=_}this.hull=new Uint32Array(I);for(let b=0,T=this._hullStart;b<I;b++)this.hull[b]=T,T=n[T];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(Pr(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:n,coords:r}=this;let i=0,o=0;for(;;){const a=n[t],c=t-t%3;if(o=c+(t+2)%3,a===-1){if(i===0)break;t=Ye[--i];continue}const f=a-a%3,u=c+(t+1)%3,h=f+(a+2)%3,p=e[o],y=e[t],E=e[u],k=e[h];if(Br(r[2*p],r[2*p+1],r[2*y],r[2*y+1],r[2*E],r[2*E+1],r[2*k],r[2*k+1])){e[t]=k,e[a]=p;const C=n[h];if(C===-1){let v=this._hullStart;do{if(this._hullTri[v]===h){this._hullTri[v]=t;break}v=this._hullPrev[v]}while(v!==this._hullStart)}this._link(t,C),this._link(a,n[o]),this._link(o,h);const m=f+(a+1)%3;i<Ye.length&&(Ye[i++]=m)}else{if(i===0)break;t=Ye[--i]}}return o}_link(t,e){this._halfedges[t]=e,e!==-1&&(this._halfedges[e]=t)}_addTriangle(t,e,n,r,i,o){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=e,this._triangles[a+2]=n,this._link(a,r),this._link(a+1,i),this._link(a+2,o),this.trianglesLen+=3,a}}function Pr(s,t){const e=s/(Math.abs(s)+Math.abs(t));return(t>0?3-e:1+e)/4}function nn(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function Br(s,t,e,n,r,i,o,a){const c=s-o,f=t-a,u=e-o,h=n-a,p=r-o,y=i-a,E=c*c+f*f,k=u*u+h*h,X=p*p+y*y;return c*(h*X-k*y)-f*(u*X-k*p)+E*(u*y-h*p)<0}function Or(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),y=(f*u-a*h)*p,E=(o*h-c*u)*p;return y*y+E*E}function Ir(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),y=s+(f*u-a*h)*p,E=t+(o*h-c*u)*p;return{x:y,y:E}}function ye(s,t,e,n){if(n-e<=20)for(let r=e+1;r<=n;r++){const i=s[r],o=t[i];let a=r-1;for(;a>=e&&t[s[a]]>o;)s[a+1]=s[a--];s[a+1]=i}else{const r=e+n>>1;let i=e+1,o=n;Se(s,r,i),t[s[e]]>t[s[n]]&&Se(s,e,n),t[s[i]]>t[s[n]]&&Se(s,i,n),t[s[e]]>t[s[i]]&&Se(s,e,i);const a=s[i],c=t[a];for(;;){do i++;while(t[s[i]]<c);do o--;while(t[s[o]]>c);if(o<i)break;Se(s,i,o)}s[e+1]=s[o],s[o]=a,n-i+1>=o-e?(ye(s,t,i,n),ye(s,t,e,o-1)):(ye(s,t,e,o-1),ye(s,t,i,n))}}function Se(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Tr(s){return s[0]}function Nr(s){return s[1]}class Xr{bs;width;constructor(t,e){this.width=t,this.bs=e}add(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]|=1<<n,this}delete(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]&=~(1<<n),this}set(t,e){const n=Math.floor(t/this.width),i=1<<t%this.width;return this.bs[n]^=(-Number(e)^this.bs[n])&i,e}has(t){const e=Math.floor(t/this.width),n=t%this.width;return(this.bs[e]&1<<n)!==0}forEach(t){const e=this.bs.length;for(let n=0;n<e;n++){let r=0;for(;this.bs[n]&&r<this.width;)this.bs[n]&1<<r&&t(n*this.width+r),r++}return this}}class An extends Xr{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function de(s){return s%3===2?s-2:s+1}function ne(s){return s%3===0?s+2:s-1}function Pn(s,t,e,n,r,i,o,a){const c=Qt(s,t,r,i,o,a),f=Qt(e,n,r,i,o,a);if(c>0&&f>0||c<0&&f<0)return!1;const u=Qt(r,i,s,t,e,n),h=Qt(o,a,s,t,e,n);return u>0&&h>0||u<0&&h<0?!1:c===0&&f===0&&u===0&&h===0?!(Math.max(r,o)<Math.min(s,e)||Math.max(s,e)<Math.min(r,o)||Math.max(i,a)<Math.min(t,n)||Math.max(t,n)<Math.min(i,a)):!0}class Rr{del;constructor(t){this.del=t}}class Yr extends Rr{vertMap;flips;consd;constructor(t,e){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);const n=2**32-1,r=t.coords.length>>1,i=t.triangles.length;this.vertMap=new Uint32Array(r).fill(n),this.flips=new An(i),this.consd=new An(i);for(let o=0;o<i;o++){const a=t.triangles[o];this.vertMap[a]===n&&this.updateVert(o)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:n,halfedges:r}=this.del,i=this.vertMap[t];let o=i;do{const f=n[o],u=de(o);if(f===e)return this.protect(o);const h=ne(o),p=n[h];if(p===e)return this.protect(u),u;if(this.intersectSegments(t,e,p,f)){o=h;break}o=r[u]}while(o!==-1&&o!==i);let a=o,c=-1;for(;o!==-1;){const f=r[o],u=ne(o),h=ne(f),p=de(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(o))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,e,n[o])||this.isCollinear(t,e,n[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(n[o],n[f],n[u],n[h])){if(c===-1&&(c=o),n[h]===e){if(o===c)throw new Error("Infinite loop: non-convex quadrilateral");o=c,c=-1;continue}if(this.intersectSegments(t,e,n[h],n[f]))o=h;else if(this.intersectSegments(t,e,n[p],n[h]))o=p;else if(c===o)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(o),this.intersectSegments(t,e,n[u],n[h])&&(c===-1&&(c=u),c===u))throw new Error("Infinite loop: flipped diagonal still intersects");n[h]===e?(a=h,o=c,c=-1):this.intersectSegments(t,e,n[p],n[h])&&(o=p)}return this.protect(a),this.delaunify(!0),this.findEdge(t,e)}delaunify(t=!1){const{halfedges:e}=this.del,n=this.flips,r=this.consd,i=e.length;let o;do{o=0;for(let a=0;a<i;a++){if(r.has(a))continue;n.delete(a);const c=e[a];c!==-1&&(n.delete(c),this.isDelaunay(a)||(this.flipDiagonal(a),o++))}}while(t&&o>0);return this}constrainAll(t){const e=t.length;for(let n=0;n<e;n++){const r=t[n];this.constrainOne(r[0],r[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const n=this.vertMap[e],{triangles:r,halfedges:i}=this.del;let o=n,a=-1;do{if(r[o]===t)return o;a=de(o),o=i[a]}while(o!==-1&&o!==n);return r[de(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],n=this.flips,r=this.consd;return n.delete(t),r.add(t),e!==-1?(n.delete(e),r.add(e),e):-t}markFlip(t){const e=this.del.halfedges,n=this.flips;if(this.consd.has(t))return!1;const i=e[t];return i!==-1&&(n.add(t),n.add(i)),!0}flipDiagonal(t){const{triangles:e,halfedges:n}=this.del,r=this.flips,i=this.consd,o=n[t],a=ne(t),c=de(t),f=ne(o),u=de(o),h=n[a],p=n[f];if(i.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[f],n[t]=p,r.set(t,r.has(f))||i.set(t,i.has(f)),p!==-1&&(n[p]=t),n[a]=f,e[o]=e[a],n[o]=h,r.set(o,r.has(a))||i.set(o,i.has(a)),h!==-1&&(n[h]=o),n[f]=a,this.markFlip(t),this.markFlip(c),this.markFlip(o),this.markFlip(u),r.add(a),i.delete(a),r.add(f),i.delete(f),this.updateVert(t),this.updateVert(c),this.updateVert(o),this.updateVert(u),a}isCollinear(t,e,n){const r=this.del.coords;return Qt(r[t*2],r[t*2+1],r[e*2],r[e*2+1],r[n*2],r[n*2+1])===0}inCircle(t,e,n,r){const i=this.del.coords;return er(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:n}=this.del,r=n[t];if(r===-1)return!0;const i=e[ne(t)],o=e[t],a=e[de(t)],c=e[ne(r)];return!this.inCircle(i,o,a,c)}updateVert(t){const{triangles:e,halfedges:n}=this.del,r=this.vertMap,i=e[t];let o=ne(t),a=n[o];for(;a!==-1&&a!==t;)o=ne(a),a=n[o];return r[i]=o,o}intersectSegments(t,e,n,r){const i=this.del.coords;return t===n||t===r||e===n||e===r?!1:Pn(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])}static intersectSegments=Pn}function Ee(s,t,e){if(t||(t=[]),typeof s!="object"||s.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const n=s.features.map(c=>c.geometry.coordinates),r=en.from(n);let i;const o=[];r.triangles.length!==0&&t.length!==0&&(i=new Yr(r),i.constrainAll(t));for(let c=0;c<r.triangles.length;c+=3)o.push([r.triangles[c],r.triangles[c+1],r.triangles[c+2]]);const a=["a","b","c"];return Vt(o.map(c=>{const f={},u=c.map((h,p)=>{const y=s.features[h],E=y.geometry.coordinates,k=[E[0],E[1]];return E.length===3?k[2]=E[2]:f[a[p]]=y.properties[e],k});return u[3]=u[0],_e([u],f)}))}class Bn{constructor(t=[],e=Cr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}}function Cr(s,t){return s<t?-1:s>t?1:0}function On(s,t){return s.p.x>t.p.x?1:s.p.x<t.p.x?-1:s.p.y!==t.p.y?s.p.y>t.p.y?1:-1:1}function Fr(s,t){return s.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:s.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:s.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?s.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class In{constructor(t,e,n,r){this.p={x:t[0],y:t[1]},this.featureId=e,this.ringId=n,this.eventId=r,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(t){return this.p.x===t.p.x&&this.p.y===t.p.y}}function Lr(s,t){if(s.type==="FeatureCollection"){const e=s.features;for(let n=0;n<e.length;n++)Tn(e[n],t)}else Tn(s,t)}let Ce=0,Fe=0,Le=0;function Tn(s,t){const e=s.type==="Feature"?s.geometry:s;let n=e.coordinates;(e.type==="Polygon"||e.type==="MultiLineString")&&(n=[n]),e.type==="LineString"&&(n=[[n]]);for(let r=0;r<n.length;r++)for(let i=0;i<n[r].length;i++){let o=n[r][i][0],a=null;Fe=Fe+1;for(let c=0;c<n[r][i].length-1;c++){a=n[r][i][c+1];const f=new In(o,Ce,Fe,Le),u=new In(a,Ce,Fe,Le+1);f.otherEvent=u,u.otherEvent=f,On(f,u)>0?(u.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(f),t.push(u),o=a,Le=Le+1}}Ce=Ce+1}class Dr{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}}function $r(s,t){if(s===null||t===null||s.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.rightSweepEvent)||s.leftSweepEvent.isSamePoint(t.leftSweepEvent)||s.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const e=s.leftSweepEvent.p.x,n=s.leftSweepEvent.p.y,r=s.rightSweepEvent.p.x,i=s.rightSweepEvent.p.y,o=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,c=t.rightSweepEvent.p.x,f=t.rightSweepEvent.p.y,u=(f-a)*(r-e)-(c-o)*(i-n),h=(c-o)*(n-a)-(f-a)*(e-o),p=(r-e)*(n-a)-(i-n)*(e-o);if(u===0)return!1;const y=h/u,E=p/u;if(y>=0&&y<=1&&E>=0&&E<=1){const k=e+y*(r-e),X=n+y*(i-n);return[k,X]}return!1}function qr(s,t){t=t||!1;const e=[],n=new Bn([],Fr);for(;s.length;){const r=s.pop();if(r.isLeftEndpoint){const i=new Dr(r);for(let o=0;o<n.data.length;o++){const a=n.data[o];if(t&&a.leftSweepEvent.featureId===r.featureId)continue;const c=$r(i,a);c!==!1&&e.push(c)}n.push(i)}else r.isLeftEndpoint===!1&&n.pop()}return e}function jr(s,t){const e=new Bn([],On);return Lr(s,e),qr(e,t)}var Ur=jr;function zr(s,t,e={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:r=!0}=e;let i=[];s.type==="FeatureCollection"?i=i.concat(s.features):s.type==="Feature"?i.push(s):(s.type==="LineString"||s.type==="Polygon"||s.type==="MultiLineString"||s.type==="MultiPolygon")&&i.push(be(s)),t.type==="FeatureCollection"?i=i.concat(t.features):t.type==="Feature"?i.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&i.push(be(t));const o=Ur(Vt(i),r);let a=[];if(n){const c={};o.forEach(f=>{const u=f.join(",");c[u]||(c[u]=!0,a.push(f))})}else a=o;return Vt(a.map(c=>le(c)))}var Vr=zr;function Nn(s,t,e,n,r,i){return Object.keys(s).reduce((o,a)=>{const c=s[a],f=c.forw,u=c.bakw,h={forw:[f[0]-t.forw[0],f[1]-t.forw[1]],bakw:[u[0]-t.bakw[0],u[1]-t.bakw[1]]},p=h.forw[0]===0?1/0:((h.forw[0]<0?e:n)-t.forw[0])/h.forw[0],y=h.forw[1]===0?1/0:((h.forw[1]<0?r:i)-t.forw[1])/h.forw[1];if(Math.abs(p)/Math.abs(y)<1.1){const E={forw:[h.forw[0]*p+t.forw[0],h.forw[1]*p+t.forw[1]],bakw:[h.bakw[0]*p+t.bakw[0],h.bakw[1]*p+t.bakw[1]]};h.forw[0]<0?o[3].push(E):o[1].push(E)}if(Math.abs(y)/Math.abs(p)<1.1){const E={forw:[h.forw[0]*y+t.forw[0],h.forw[1]*y+t.forw[1]],bakw:[h.bakw[0]*y+t.bakw[0],h.bakw[1]*y+t.bakw[1]]};h.forw[1]<0?o[0].push(E):o[2].push(E)}return o},[[],[],[],[]])}function Wr(s,t){const e=[[],[],[],[]],n=[];return Object.keys(s).forEach(r=>{const i=s[r],o=i.forw,a=i.bakw,c=[o[0]-t.forw[0],o[1]-t.forw[1]],f=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:c,bakw:f};if(n.push(u),c[0]===0||c[1]===0)return;let h=0;c[0]>0&&(h+=1),c[1]>0&&(h+=2),e[h].push(u)}),{perQuad:e,aggregate:n}}function Jr(s){let t=1/0,e=0,n=0;return s.forEach(r=>{const{forw:i,bakw:o}=r,a=Math.hypot(i[0],i[1]),c=Math.hypot(o[0],o[1]);if(c===0)return;const f=a/c,u=Math.atan2(i[0],i[1])-Math.atan2(o[0],o[1]);t=Math.min(t,f),e+=Math.cos(u),n+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(n,e)]:[1,0]}function Xn(s,t,e){const{perQuad:n,aggregate:r}=Wr(s,t),i=n.every(c=>c.length>0),a=(e==="birdeye"?i?n:[r]:[r]).map(c=>Jr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Kr(s,t,e){const n=[1,1,1,1];for(let r=0;r<4;r++){const i=(r+1)%4,o=gn([s[r].bakw,s[i].bakw]);t[r].map(a=>{const c=gn([e.bakw,a.bakw]),f=Vr(o,c);if(f.features.length>0&&f.features[0].geometry){const u=f.features[0],h=Math.sqrt(Math.pow(a.bakw[0]-e.bakw[0],2)+Math.pow(a.bakw[1]-e.bakw[1],2)),p=Math.sqrt(Math.pow(u.geometry.coordinates[0]-e.bakw[0],2)+Math.pow(u.geometry.coordinates[1]-e.bakw[1],2)),y=h/p;y>n[r]&&(n[r]=y),y>n[i]&&(n[i]=y)}})}s.forEach((r,i)=>{const o=n[i],a=[(r.bakw[0]-e.bakw[0])*o+e.bakw[0],(r.bakw[1]-e.bakw[1])*o+e.bakw[1]];r.bakw=a})}function Rn(s,t,e,n){const r=s.map((o,a)=>{const c=t[a],f=[c[0]-e.forw[0],c[1]-e.forw[1]],h=Math.sqrt(Math.pow(f[0],2)+Math.pow(f[1],2))/o[0],p=Math.atan2(f[0],f[1])-o[1],y=[e.bakw[0]+h*Math.sin(p),e.bakw[1]-h*Math.cos(p)];return{forw:c,bakw:y}}),i=r[2];return r[2]=r[3],r[3]=i,Kr(r,n,e),r}function Gr(s){const{convexBuf:t,centroid:e,bbox:n,minx:r,maxx:i,miny:o,maxy:a}=s,c=Nn(t,e,r,i,o,a),f=Xn(t,e,"plain");return Rn(f,n,e,c)}function Qr(s){const{convexBuf:t,centroid:e,bbox:n,minx:r,maxx:i,miny:o,maxy:a}=s,c=Nn(t,e,r,i,o,a),f=Xn(t,e,"birdeye");return Rn(f,n,e,c)}function Yn(s){const e=new Hr(s).findSegmentIntersections(),n=qn(e),r=new Map;return n.forEach(i=>{r.set(`${i.x}:${i.y}`,i)}),Array.from(r.values()).map(i=>le([i.x,i.y]))}class Hr{_xx;_yy;_ii;_nn;_zz;_zlimit=0;_bb;_allBounds;_arcIter;_filteredArcIter;buf;constructor(t){this.initArcs(t)}initArcs(t){const e=[],n=[],r=t.map(i=>{const o=i?i.length:0;for(let a=0;a<o;a++)e.push(i[a][0]),n.push(i[a][1]);return o});this.initXYData(r,e,n)}initXYData(t,e,n){const r=t.length;this._xx=new Float64Array(e),this._yy=new Float64Array(n),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(r);let i=0;for(let o=0;o<r;o++)this._ii[o]=i,i+=t[o];(i!=this._xx.length||this._xx.length!=this._yy.length)&&rn("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new yi(this._xx,this._yy)}initBounds(){const t=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=t.bb,this._allBounds=t.bounds}calcArcBounds_(t,e,n){const r=n.length,i=new Float64Array(r*4),o=new qe;let a=0,c,f,u;for(let h=0;h<r;h++)c=n[h],c>0&&(f=h*4,u=vi(t,e,a,c),i[f++]=u[0],i[f++]=u[1],i[f++]=u[2],i[f]=u[3],a+=c,o.mergeBounds(u));return{bb:i,bounds:o}}getBounds(){return this._allBounds.clone()}forEachSegment(t){let e=0;for(let n=0,r=this.size();n<r;n++)e+=this.forEachArcSegment(n,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const n=t>=0,r=n?t:~t,i=this.getRetainedInterval(),o=this._nn[r],a=n?1:-1;let c=n?this._ii[r]:this._ii[r]+o-1,f=c,u=0;for(let h=1;h<o;h++)f+=a,(i===0||this._zz[f]>=i)&&(e(c,f,this._xx,this._yy),c=f,u++);return u}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(t){const e=t*4;return(!this.buf||this.buf.byteLength<e)&&(this.buf=new ArrayBuffer(e)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,e=0;const n=this.forEachSegment((r,i,o,a)=>{t+=Math.abs(o[r]-o[i]),e+=Math.abs(a[r]-a[i])});return[t/n||0,e/n||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),e=this.getAvgSegment2()[1];let n=1;return e>0&&t>0&&(n=Math.ceil(t/e/20)),n||1}findSegmentIntersections(){const t=this.getBounds(),e=t.ymin,n=t.ymax-e,r=this.calcSegmentIntersectionStripeCount(),i=new Uint32Array(r),o=r>1?k=>Math.floor((r-1)*(k-e)/n):()=>0;let a,c;this.forEachSegment((k,X,C,m)=>{let v=o(m[k]);const l=o(m[X]);for(;i[v]=i[v]+2,v!=l;)v+=l>v?1:-1});const f=this.getUint32Array(ei(i));let u=0;const h=[];ni(i,k=>{const X=u;u+=k,h.push(f.subarray(X,u))}),ri(i,0),this.forEachSegment((k,X,C,m)=>{let v=o(m[k]);const l=o(m[X]);let g,x;for(;g=i[v],i[v]=g+2,x=h[v],x[g]=k,x[g+1]=X,v!=l;)v+=l>v?1:-1});const p=this.getVertexData(),y=[];let E;for(a=0;a<r;a++)for(E=ii(h[a],p.xx,p.yy),c=0;c<E.length;c++)y.push(E[c]);return qn(y)}}function rn(...s){const t=s.join(" ");throw new Error(t)}function on(s){return s?ti(s)?!0:Zr(s)?!1:s.length===0?!0:s.length>0:!1}function Zr(s){return s!=null&&s.toString===String.prototype.toString}function ti(s){return Array.isArray(s)}function ei(s,t){on(s)||rn("utils.sum() expects an array, received:",s);let e=0,n;for(let r=0,i=s.length;r<i;r++)n=s[r],n&&(e+=n);return e}function ni(s,t,e){if(!on(s))throw new Error(`#forEach() takes an array-like argument. ${s}`);for(let n=0,r=s.length;n<r;n++)t.call(e,s[n],n)}function ri(s,t){for(let e=0,n=s.length;e<n;e++)s[e]=t;return s}function ii(s,t,e){const n=s.length-2,r=[];let i,o,a,c,f,u,h,p,y,E,k,X,C,m,v,l,g;for(pi(t,s),l=0;l<n;){for(i=s[l],o=s[l+1],f=t[i],u=t[o],y=e[i],E=e[o],g=l;g<n&&(g+=2,a=s[g],h=t[a],!(u<h));){if(k=e[a],c=s[g+1],p=t[c],X=e[c],y>=k){if(y>X&&E>k&&E>X)continue}else if(y<X&&E<k&&E<X)continue;i==a||i==c||o==a||o==c||(C=oi(f,y,u,E,h,k,p,X),C&&(m=[i,o],v=[a,c],r.push(Dn(C,m,v,t,e)),C.length==4&&r.push(Dn(C.slice(2),m,v,t,e))))}l+=2}return r}function oi(s,t,e,n,r,i,o,a){const c=si(s,t,e,n,r,i,o,a);let f=null;return c&&(f=ai(s,t,e,n,r,i,o,a),f?di(s,t,e,n,r,i,o,a)&&(f=null):f=li(s,t,e,n,r,i,o,a)),f}function si(s,t,e,n,r,i,o,a){return Ae(s,t,e,n,r,i)*Ae(s,t,e,n,o,a)<=0&&Ae(r,i,o,a,s,t)*Ae(r,i,o,a,e,n)<=0}function Ae(s,t,e,n,r,i){return Cn(s-r,t-i,e-r,n-i)}function Cn(s,t,e,n){return s*n-t*e}function ai(s,t,e,n,r,i,o,a){let c=De(s,t,e,n,r,i,o,a),f;return c&&(f=fi(c[0],c[1],s,t,e,n,r,i,o,a),f==1?c=De(e,n,s,t,r,i,o,a):f==2?c=De(r,i,o,a,s,t,e,n):f==3&&(c=De(o,a,r,i,s,t,e,n))),c&&ui(c,s,t,e,n,r,i,o,a),c}function De(s,t,e,n,r,i,o,a){const c=Cn(e-s,n-t,o-r,a-i),f=1e-18;let u;if(c===0)return null;const h=Ae(r,i,o,a,s,t)/c;return c<=f&&c>=-f?u=ci(s,t,e,n,r,i,o,a):u=[s+h*(e-s),t+h*(n-t)],u}function ci(s,t,e,n,r,i,o,a){let c=null;return!re(s,r,o)&&!re(t,i,a)?c=[s,t]:!re(e,r,o)&&!re(n,i,a)?c=[e,n]:!re(r,s,e)&&!re(i,t,n)?c=[r,i]:!re(o,s,e)&&!re(a,t,n)&&(c=[o,a]),c}function re(s,t,e){let n;return t<e?n=s<t||s>e:t>e?n=s>t||s<e:n=s!=t,n}function fi(s,t,...e){let n=-1,r=1/0,i;for(let o=0,a=0,c=e.length;a<c;o++,a+=2)i=hi(s,t,e[a],e[a+1]),i<r&&(r=i,n=o);return n}function hi(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function ui(s,t,e,n,r,i,o,a,c){let f=s[0],u=s[1];f=$e(f,t,n),f=$e(f,i,a),u=$e(u,e,r),u=$e(u,o,c),s[0]=f,s[1]=u}function $e(s,t,e){let n;return re(s,t,e)&&(n=Math.abs(s-t)<Math.abs(s-e)?t:e,s=n),s}function li(s,t,e,n,r,i,o,a){const c=Math.min(s,e,r,o),f=Math.max(s,e,r,o),u=Math.min(t,n,i,a),h=Math.max(t,n,i,a),p=h-u>f-c;let y=[];return(p?ce(t,u,h):ce(s,c,f))&&y.push(s,t),(p?ce(n,u,h):ce(e,c,f))&&y.push(e,n),(p?ce(i,u,h):ce(r,c,f))&&y.push(r,i),(p?ce(a,u,h):ce(o,c,f))&&y.push(o,a),(y.length!=2&&y.length!=4||y.length==4&&y[0]==y[2]&&y[1]==y[3])&&(y=null),y}function di(s,t,e,n,r,i,o,a){return s==r&&t==i||s==o&&t==a||e==r&&n==i||e==o&&n==a}function ce(s,t,e){return s>t&&s<e}function pi(s,t){mi(s,t),Fn(s,t,0,t.length-2)}function mi(s,t){for(let e=0,n=t.length;e<n;e+=2)s[t[e]]>s[t[e+1]]&&gi(t,e,e+1)}function gi(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Fn(s,t,e,n){let r=e,i=n,o,a;for(;r<n;){for(o=s[t[e+n>>2<<1]];r<=i;){for(;s[t[r]]<o;)r+=2;for(;s[t[i]]>o;)i-=2;r<=i&&(a=t[r],t[r]=t[i],t[i]=a,a=t[r+1],t[r+1]=t[i+1],t[i+1]=a,r+=2,i-=2)}if(i-e<40?Ln(s,t,e,i):Fn(s,t,e,i),n-r<40){Ln(s,t,r,n);return}e=r,i=n}}function Ln(s,t,e,n){let r,i;for(let o=e+2;o<=n;o+=2){r=t[o],i=t[o+1];let a;for(a=o-2;a>=e&&s[r]<s[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=r,t[a+3]=i}}function Dn(s,t,e,n,r){const i=s[0],o=s[1];t=$n(i,o,t[0],t[1],n,r),e=$n(i,o,e[0],e[1],n,r);const a=t[0]<e[0]?t:e,c=a==t?e:t;return{x:i,y:o,a,b:c}}function $n(s,t,e,n,r,i){let o=e<n?e:n,a=o===e?n:e;return r[o]==s&&i[o]==t?a=o:r[a]==s&&i[a]==t&&(o=a),[o,a]}function qn(s){const t={};return s.filter(e=>{const n=wi(e);return n in t?!1:(t[n]=!0,!0)})}function wi(s){return`${s.a.join(",")};${s.b.join(",")}`}class yi{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,e){this._xx=t,this._yy=e}}function vi(s,t,e,n){let r=e|0;const i=isNaN(n)?s.length-r:n+r;let o,a,c,f,u,h;if(i>0)c=u=s[r],f=h=t[r];else return[void 0,void 0,void 0,void 0];for(r++;r<i;r++)o=s[r],a=t[r],o<c&&(c=o),o>u&&(u=o),a<f&&(f=a),a>h&&(h=a);return[c,f,u,h]}class qe{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new qe(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,e,n,r){return arguments.length==1&&(on(t)?(e=t[1],n=t[2],r=t[3],t=t[0]):(e=t.ymin,n=t.xmax,r=t.ymax,t=t.xmin)),this.xmin=t,this.ymin=e,this.xmax=n,this.ymax=r,(t>n||e>r)&&this.update(),this}update(){let t;this.xmin>this.xmax&&(t=this.xmin,this.xmin=this.xmax,this.xmax=t),this.ymin>this.ymax&&(t=this.ymin,this.ymin=this.ymax,this.ymax=t)}mergeBounds(t,...e){let n,r,i,o;return t instanceof qe?(n=t.xmin,r=t.ymin,i=t.xmax,o=t.ymax):e.length==3?(n=t,r=e[0],i=e[1],o=e[2]):t.length==4?(n=t[0],r=t[1],i=t[2],o=t[3]):rn("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(n,r,i,o):(n<this.xmin&&(this.xmin=n),r<this.ymin&&(this.ymin=r),i>this.xmax&&(this.xmax=i),o>this.ymax&&(this.ymax=o)),this}}function je(s){const t=["a","b","c"].map(e=>s.properties[e].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(e=>e.map(n=>t[n]).sort().join("-")).sort()}function sn(s,t,e){const n=je(t.forw),r=je(t.bakw);if(JSON.stringify(n)!=JSON.stringify(r))throw`${JSON.stringify(t,null,2)}
|
|
2
2
|
${JSON.stringify(n)}
|
|
3
|
-
${JSON.stringify(s)}`;for(let i=0;i<n.length;i++){const r=n[i];o[r]||(o[r]=[]),o[r].push(t)}e&&(e.forw.features.push(t.forw),e.bakw.features.push(t.bakw))}function Qt(o,t,e){return ut.point(o,{target:{geom:t,index:e}})}function Zt(o){return ut.point(o.properties.target.geom,{target:{geom:o.geometry.coordinates,index:o.properties.target.index}})}function xe(o,t){const e=t.geometry.coordinates;return[0,1,2,3].map(n=>{const s=(n+1)%4,i=o[n],r=o[s],a=i.geometry.coordinates,f=Math.atan2(a[0]-e[0],a[1]-e[1]),h=[t,i,r,t].map(l=>l.geometry.coordinates),u={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:i.properties.target.geom,index:i.properties.target.index},c:{geom:r.properties.target.geom,index:r.properties.target.index}},c=ut.featureCollection([ut.polygon([h],u)]);return[f,c]}).reduce((n,s)=>(n[0].push(s[0]),n[1].push(s[1]),n),[[],[]])}const Ze=ie;class at extends xn{constructor(e={}){super();rt(this,"importance");rt(this,"priority");rt(this,"pointsSet");e.bounds?this.setBounds(e.bounds):(this.setWh(e.wh),this.vertexMode=e.vertexMode||at.VERTEX_PLAIN),this.strictMode=e.strictMode||at.MODE_AUTO,this.yaxisMode=e.yaxisMode||at.YAXIS_INVERT,this.importance=e.importance||0,this.priority=e.priority||0,this.stateFull=e.stateFull||!1,e.points&&this.setPoints(e.points),e.edges&&this.setEdges(e.edges)}getFormatVersion(){return Ze}setPoints(e){this.yaxisMode===at.YAXIS_FOLLOW&&(e=e.map(n=>[n[0],[n[1][0],-1*n[1][1]]])),this.points=e,this.tins=void 0,this.indexedTins=void 0}setEdges(e=[]){this.edges=$e(e),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(e){this.bounds=e;let n=e[0][0],s=n,i=e[0][1],r=i;const a=[e[0]];for(let f=1;f<e.length;f++){const h=e[f];h[0]<n&&(n=h[0]),h[0]>s&&(s=h[0]),h[1]<i&&(i=h[1]),h[1]>r&&(r=h[1]),a.push(h)}a.push(e[0]),this.boundsPolygon=ut.polygon([a]),this.xy=[n,i],this.wh=[s-n,r-i],this.vertexMode=at.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){var s;const e={};e.version=Ze,e.points=this.points,e.weight_buffer=this.pointsWeightBuffer,e.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],e.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],e.vertices_points=[];const n=this.vertices_params.forw[1];return n&&[0,1,2,3].map(i=>{const r=n[i].features[0],a=r.geometry.coordinates[0][1],f=r.properties.b.geom;e.vertices_points[i]=[a,f]}),e.strict_status=this.strict_status,e.tins_points=[[]],this.tins.forw.features.map(i=>{e.tins_points[0].push(["a","b","c"].map(r=>i.properties[r].index))}),this.strict_status===at.STATUS_LOOSE?(e.tins_points[1]=[],this.tins.bakw.features.map(i=>{e.tins_points[1].push(["a","b","c"].map(r=>i.properties[r].index))})):this.strict_status===at.STATUS_ERROR&&((s=this.kinks)!=null&&s.bakw)&&(e.kinks_points=this.kinks.bakw.features.map(i=>i.geometry.coordinates)),e.yaxisMode=this.yaxisMode,e.vertexMode=this.vertexMode,e.strictMode=this.strictMode,this.bounds?(e.bounds=this.bounds,e.boundsPolygon=this.boundsPolygon,e.xy=this.xy,e.wh=this.wh):e.wh=this.wh,e.edges=this.edges,e.edgeNodes=this.edgeNodes,e}setWh(e){this.wh=e||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(e){this.vertexMode=e,this.tins=void 0,this.indexedTins=void 0}setStrictMode(e){this.strictMode=e,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){const e=this.tins.forw.features.map(i=>mn(i));this.tins.bakw=ut.featureCollection(e);const n={};this.tins.forw.features.forEach((i,r)=>{const a=this.tins.bakw.features[r];Qe(n,{forw:i,bakw:a})});const s=["forw","bakw"].map(i=>{const r=this.tins[i].features.map(a=>a.geometry.coordinates[0]);return ze(r)});s[0].length===0&&s[1].length===0?(this.strict_status=at.STATUS_STRICT,delete this.kinks):(this.strict_status=at.STATUS_ERROR,this.kinks={},s[0].length>0&&(this.kinks.forw=ut.featureCollection(s[0])),s[1].length>0&&(this.kinks.bakw=ut.featureCollection(s[1])))}generatePointsSet(){const e={forw:[],bakw:[]};for(let i=0;i<this.points.length;i++){const r=this.points[i][0],a=this.points[i][1],f=Qt(r,a,i);e.forw.push(f),e.bakw.push(Zt(f))}const n=[];let s=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let i=0;i<this.edges.length;i++){const r=this.edges[i][2],a=Object.assign([],this.edges[i][0]),f=Object.assign([],this.edges[i][1]);if(a.length===0&&f.length===0){n.push(r);continue}a.unshift(this.points[r[0]][0]),a.push(this.points[r[1]][0]),f.unshift(this.points[r[0]][1]),f.push(this.points[r[1]][1]);const h=[a,f].map(u=>{const c=u.map((p,y,g)=>{if(y===0)return 0;const b=g[y-1];return Math.sqrt(Math.pow(p[0]-b[0],2)+Math.pow(p[1]-b[1],2))}),l=c.reduce((p,y,g)=>g===0?[0]:(p.push(p[g-1]+y),p),[]);return l.map((p,y,g)=>{const b=p/g[g.length-1];return[u[y],c[y],l[y],b]})});h.map((u,c)=>{const l=h[c?0:1];return u.filter((p,y)=>!(y===0||y===u.length-1||p[4]==="handled")).map(p=>{const y=p[0],g=p[3],b=l.reduce((w,M,_,v)=>{if(w)return w;const T=v[_+1];if(M[3]===g)return M[4]="handled",[M];if(M[3]<g&&T&&T[3]>g)return[M,T]},void 0);if(b&&b.length===1)return c===0?[y,b[0][0],g]:[b[0][0],y,g];if(b&&b.length===2){const w=b[0],M=b[1],_=(g-w[3])/(M[3]-w[3]),v=[(M[0][0]-w[0][0])*_+w[0][0],(M[0][1]-w[0][1])*_+w[0][1]];return c===0?[y,v,g]:[v,y,g]}return[]})}).reduce((u,c)=>u.concat(c),[]).sort((u,c)=>u[2]<c[2]?-1:1).map((u,c,l)=>{this.edgeNodes[s]=[u[0],u[1]];const p=Qt(u[0],u[1],`e${s}`);s++,e.forw.push(p),e.bakw.push(Zt(p)),c===0?n.push([r[0],e.forw.length-1]):n.push([e.forw.length-2,e.forw.length-1]),c===l.length-1&&n.push([e.forw.length-1,r[1]])})}return{forw:e.forw,bakw:e.bakw,edges:n}}validateAndPrepareInputs(){const e=this.xy[0]-.05*this.wh[0],n=this.xy[0]+1.05*this.wh[0],s=this.xy[1]-.05*this.wh[1],i=this.xy[1]+1.05*this.wh[1];if(!this.points.reduce((f,h)=>f&&(this.bounds?xt(h[0],this.boundsPolygon):h[0][0]>=e&&h[0][0]<=n&&h[0][1]>=s&&h[0][1]<=i),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[e,s],[n,s],[e,i],[n,i]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:e,maxx:n,miny:s,maxy:i}}updateTin(){let e=this.strictMode;e!==at.MODE_STRICT&&e!==at.MODE_LOOSE&&(e=at.MODE_AUTO);const{pointsSet:n,bbox:s,minx:i,maxx:r,miny:a,maxy:f}=this.validateAndPrepareInputs(),h={forw:ut.featureCollection(n.forw),bakw:ut.featureCollection(n.bakw)},u=Gt(h.forw,n.edges,"target"),c=Gt(h.bakw,n.edges,"target");if(u.features.length===0||c.features.length===0)throw"TOO LINEAR1";const l=Wt(h.forw),p=_e(h.forw);if(!p)throw"TOO LINEAR2";const y={},g=p.geometry.coordinates[0];let b;try{b=g.map(N=>({forw:N,bakw:ne(ut.point(N),u)})),b.forEach(N=>{y[`${N.forw[0]}:${N.forw[1]}`]=N})}catch{throw"TOO LINEAR2"}const w=_e(h.bakw);if(!w)throw"TOO LINEAR2";const M=w.geometry.coordinates[0];try{b=M.map(N=>({bakw:N,forw:ne(ut.point(N),c)})),b.forEach(N=>{y[`${N.forw[0]}:${N.forw[1]}`]=N})}catch{throw"TOO LINEAR2"}const _={forw:l.geometry.coordinates,bakw:ne(l,u)},v=Qt(_.forw,_.bakw,"c");this.centroid={forw:v,bakw:Zt(v)};const T=this.vertexMode===at.VERTEX_BIRDEYE?this.calculateBirdeyeVertices(y,_,s,i,r,a,f):this.calculatePlainVertices(y,_,s,i,r,a,f),I={forw:[],bakw:[]};for(let N=0;N<T.length;N++){const V=T[N].forw,W=T[N].bakw,K=Qt(V,W,`b${N}`),tt=Zt(K);n.forw.push(K),n.bakw.push(tt),I.forw.push(K),I.bakw.push(tt)}this.pointsSet={forw:ut.featureCollection(n.forw),bakw:ut.featureCollection(n.bakw),edges:[]},this.tins={forw:Ie(Gt(this.pointsSet.forw,n.edges,"target"))},(e===at.MODE_STRICT||e===at.MODE_AUTO)&&this.calcurateStrictTin(),(e===at.MODE_LOOSE||e===at.MODE_AUTO&&this.strict_status===at.STATUS_ERROR)&&(this.tins.bakw=Ie(Gt(this.pointsSet.bakw,n.edges,"target")),delete this.kinks,this.strict_status=at.STATUS_LOOSE),this.vertices_params={forw:xe(I.forw,this.centroid.forw),bakw:xe(I.bakw,this.centroid.bakw)},this.addIndexedTin(),this.calculatePointsWeight()}calculatePlainVertices(e,n,s,i,r,a,f){const h=Object.keys(e).reduce((y,g)=>{const b=e[g],w=b.forw,M=b.bakw,_={forw:[w[0]-n.forw[0],w[1]-n.forw[1]],bakw:[M[0]-n.bakw[0],M[1]-n.bakw[1]]},v=_.forw[0]===0?1/0:((_.forw[0]<0?i:r)-n.forw[0])/_.forw[0],T=_.forw[1]===0?1/0:((_.forw[1]<0?a:f)-n.forw[1])/_.forw[1];if(Math.abs(v)/Math.abs(T)<1.1){const I={forw:[_.forw[0]*v+n.forw[0],_.forw[1]*v+n.forw[1]],bakw:[_.bakw[0]*v+n.bakw[0],_.bakw[1]*v+n.bakw[1]]};_.forw[0]<0?y[3].push(I):y[1].push(I)}if(Math.abs(T)/Math.abs(v)<1.1){const I={forw:[_.forw[0]*T+n.forw[0],_.forw[1]*T+n.forw[1]],bakw:[_.bakw[0]*T+n.bakw[0],_.bakw[1]*T+n.bakw[1]]};_.forw[1]<0?y[0].push(I):y[2].push(I)}return y},[[],[],[],[]]);let c=Object.keys(e).reduce((y,g,b,w)=>{const M=e[g],_=M.forw,v=M.bakw,T={forw:[_[0]-n.forw[0],_[1]-n.forw[1]],bakw:[v[0]-n.bakw[0],n.bakw[1]-v[1]]};if(T.forw[0]===0||T.forw[1]===0)return y;let I=0;return T.forw[0]>0&&(I+=1),T.forw[1]>0&&(I+=2),y[I].push([T.forw,T.bakw]),b===w.length-1?y.map(N=>N.reduce((V,W,K,tt)=>{V||(V=[1/0,0,0]);let z=Math.sqrt(Math.pow(W[0][0],2)+Math.pow(W[0][1],2))/Math.sqrt(Math.pow(W[1][0],2)+Math.pow(W[1][1],2));z=z<V[0]?z:V[0];const st=Math.atan2(W[0][0],W[0][1])-Math.atan2(W[1][0],W[1][1]),d=V[1]+Math.cos(st),m=V[2]+Math.sin(st);return K===tt.length-1?[z,Math.atan2(m,d)]:[z,d,m]},null)):y},[[],[],[],[]]);c.length===1&&(c=[c[0],c[0],c[0],c[0]]);const l=c.map((y,g)=>{const b=s[g],w=[b[0]-n.forw[0],b[1]-n.forw[1]],_=Math.sqrt(Math.pow(w[0],2)+Math.pow(w[1],2))/y[0],v=Math.atan2(w[0],w[1])-y[1],T=[n.bakw[0]+_*Math.sin(v),n.bakw[1]-_*Math.cos(v)];return{forw:b,bakw:T}}),p=l[2];return l[2]=l[3],l[3]=p,this.checkAndAdjustVertices(l,h,n),l}calculateBirdeyeVertices(e,n,s,i,r,a,f){return this.calculatePlainVertices(e,n,s,i,r,a,f)}checkAndAdjustVertices(e,n,s){const i=[1,1,1,1];for(let r=0;r<4;r++){const a=(r+1)%4,f=ut.lineString([e[r].bakw,e[a].bakw]);n[r].map(h=>{const u=ut.lineString([s.bakw,h.bakw]),c=tn(f,u);if(c.features.length>0&&c.features[0].geometry){const l=c.features[0],p=Math.sqrt(Math.pow(h.bakw[0]-s.bakw[0],2)+Math.pow(h.bakw[1]-s.bakw[1],2)),y=Math.sqrt(Math.pow(l.geometry.coordinates[0]-s.bakw[0],2)+Math.pow(l.geometry.coordinates[1]-s.bakw[1],2)),g=p/y;g>i[r]&&(i[r]=g),g>i[a]&&(i[a]=g)}})}e.forEach((r,a)=>{const f=i[a],h=[(r.bakw[0]-s.bakw[0])*f+s.bakw[0],(r.bakw[1]-s.bakw[1])*f+s.bakw[1]];r.bakw=h})}calculatePointsWeight(){const e=["forw"];this.strict_status===at.STATUS_LOOSE&&e.push("bakw");const n={};e.forEach(i=>{n[i]={};const r={};this.tins[i].features.map(a=>{const f=["a","b","c"];for(let h=0;h<3;h++){const u=(h+1)%3,c=f[h],l=f[u],p=a.properties[c].index,y=a.properties[l].index,g=[p,y].sort().join("-");if(!r[g]){const b=a.geometry.coordinates[0][h],w=a.geometry.coordinates[0][u],M=a.properties[c].geom,_=a.properties[l].geom;r[g]=1;const v=Math.sqrt(Math.pow(M[0]-_[0],2)+Math.pow(M[1]-_[1],2))/Math.sqrt(Math.pow(b[0]-w[0],2)+Math.pow(b[1]-w[1],2));n[i]||(n[i]={});const T=n[i];T[`${p}:${g}`]=v,T[`${y}:${g}`]=v}}})});const s={};e.map(i=>{s[i]={},this.strict_status===at.STATUS_STRICT&&(s.bakw={});const r=n[i],a={};Object.keys(r).forEach(h=>{const[u]=h.split(":");a[u]||(a[u]=[]),a[u].push(r[h])}),Object.keys(a).forEach(h=>{const u=a[h],c=u.reduce((l,p)=>l+p,0)/u.length;s[i]||(s[i]={}),s[i][h]=c,this.strict_status===at.STATUS_STRICT&&(s.bakw||(s.bakw={}),s.bakw[h]=1/c)});let f=0;for(let h=0;h<4;h++){const u=`b${h}`,c=s[i][u]||0;f+=c}s[i].c=f/4,this.strict_status===at.STATUS_STRICT&&s.bakw&&(s.bakw.c=1/s[i].c)}),this.pointsWeightBuffer=s}}ot.Tin=at,ot.constrainedTin=Gt,ot.counterPoint=Zt,ot.createPoint=Qt,ot.findIntersections=ze,ot.format_version=ie,ot.insertSearchIndex=Qe,ot.vertexCalc=xe,Object.defineProperty(ot,Symbol.toStringTag,{value:"Module"})});
|
|
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 jn(s,t,e){const n=je(t.forw),r=je(t.bakw);if(JSON.stringify(n)!=JSON.stringify(r))throw`${JSON.stringify(t,null,2)}
|
|
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 Pe(s,t,e){return le(s,{target:{geom:t,index:e}})}function Be(s){return le(s.properties.target.geom,{target:{geom:s.geometry.coordinates,index:s.properties.target.index}})}function an(s,t){const e=t.geometry.coordinates;return[0,1,2,3].map(n=>{const r=(n+1)%4,i=s[n],o=s[r],a=i.geometry.coordinates,c=Math.atan2(a[0]-e[0],a[1]-e[1]),f=[t,i,o,t].map(p=>p.geometry.coordinates),u={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:i.properties.target.geom,index:i.properties.target.index},c:{geom:o.properties.target.geom,index:o.properties.target.index}},h=Vt([_e([f],u)]);return[c,h]}).reduce((n,r)=>(n[0].push(r[0]),n[1].push(r[1]),n),[[],[]])}function bi(s){const{tins:t,targets:e,includeReciprocals:n}=s,r={};e.forEach(o=>{const a=t[o];if(!a||!a.features)return;r[o]={};const c={};a.features.forEach(f=>{const u=["a","b","c"];for(let h=0;h<3;h++){const p=(h+1)%3,y=u[h],E=u[p],k=f.properties[y].index,X=f.properties[E].index,C=[k,X].sort().join("-");if(c[C])continue;c[C]=!0;const m=f.geometry.coordinates[0][h],v=f.geometry.coordinates[0][p],l=f.properties[y].geom,g=f.properties[E].geom,x=Math.sqrt(Math.pow(l[0]-g[0],2)+Math.pow(l[1]-g[1],2))/Math.sqrt(Math.pow(m[0]-v[0],2)+Math.pow(m[1]-v[1],2)),A=r[o];A[`${k}:${C}`]=x,A[`${X}:${C}`]=x}})});const i={};return n&&(i.bakw={}),e.forEach(o=>{const a=r[o];if(i[o]={},!a)return;const c={};Object.keys(a).forEach(u=>{const[h]=u.split(":");c[h]||(c[h]=[]),c[h].push(a[u])}),Object.keys(c).forEach(u=>{const h=c[u],p=h.reduce((y,E)=>y+E,0)/h.length;i[o][u]=p,n&&i.bakw&&(i.bakw[u]=1/p)});let f=0;for(let u=0;u<4;u++){const h=`b${u}`,p=i[o][h]||0;f+=p}i[o].c=f/4,n&&i.bakw&&(i.bakw.c=1/i[o].c)}),i}function _i(s,t){const e=s.split("-");if(e.length!==2||!e.every(i=>/^-?\d+$/.test(i)))return!1;const[n,r]=e.map(i=>parseInt(i,10)).sort((i,o)=>i-o);return t.some(i=>{if(i.length!==2)return!1;const o=i.map(c=>parseInt(`${c}`,10));if(o.some(c=>Number.isNaN(c)))return!1;const a=o.sort((c,f)=>c-f);return a[0]===n&&a[1]===r})}function Ue(s){return["a","b","c"].map((t,e)=>({prop:s.properties[t],geom:s.geometry.coordinates[0][e]}))}function xi(s,t,e){const n=new Set;let r=!1;const i=Object.keys(t);for(const o of i){if(n.has(o))continue;n.add(o);const a=t[o];if(!a||a.length<2)continue;const c=o.split("-");if(c.length!==2||_i(o,e))continue;const f=Ue(a[0].bakw),u=Ue(a[1].bakw),h=Ue(a[0].forw),p=Ue(a[1].forw),y=c.map(b=>f.find(T=>`${T.prop.index}`===b)||u.find(T=>`${T.prop.index}`===b)),E=c.map(b=>h.find(T=>`${T.prop.index}`===b)||p.find(T=>`${T.prop.index}`===b));if(y.some(b=>!b)||E.some(b=>!b))continue;const k=[f,u].map(b=>b.find(T=>!c.includes(`${T.prop.index}`))),X=[h,p].map(b=>b.find(T=>!c.includes(`${T.prop.index}`)));if(k.some(b=>!b)||X.some(b=>!b))continue;const C=a[0].bakw.geometry.coordinates[0].slice(0,3).map(b=>ve(b)),m=a[1].bakw.geometry.coordinates[0].slice(0,3).map(b=>ve(b));if(!(Un(ve(k[0].geom),m)||Un(ve(k[1].geom),C)))continue;const l=E.map(b=>ve(b.geom)),g=X.map(b=>ve(b.geom)),x=Mi([...l,...g]),A=ki(x),I=zn(l[0],l[1],g[0])+zn(l[0],l[1],g[1]);cn(A,I)&&(jn(t,a[0],s),jn(t,a[1],s),y.forEach(b=>{if(!b)return;const T=[b.geom,k[0].geom,k[1].geom,b.geom],Y={a:b.prop,b:k[0].prop,c:k[1].prop},D=_e([T],Y),Q=zt.counterTri(D);sn(t,{forw:Q,bakw:D},s)}),r=!0)}return r}function ve(s){return[s[0],s[1]]}function Un(s,t){const[e,n]=t[0],[r,i]=t[1],[o,a]=t[2],c=o-e,f=a-n,u=r-e,h=i-n,p=s[0]-e,y=s[1]-n,E=c*c+f*f,k=c*u+f*h,X=c*p+f*y,C=u*u+h*h,m=u*p+h*y,v=E*C-k*k;if(v===0)return!1;const l=1/v,g=(C*X-k*m)*l,x=(E*m-k*X)*l,A=1e-9;return g>=-A&&x>=-A&&g+x<=1+A}function Mi(s){const t=s.map(o=>o.slice()).filter((o,a,c)=>c.findIndex(f=>cn(f[0],o[0])&&cn(f[1],o[1]))===a);if(t.length<=1)return t;const e=t.sort((o,a)=>o[0]===a[0]?o[1]-a[1]:o[0]-a[0]),n=(o,a,c)=>(a[0]-o[0])*(c[1]-o[1])-(a[1]-o[1])*(c[0]-o[0]),r=[];for(const o of e){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const a=e[o];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),r.pop(),r.concat(i)}function ki(s){if(s.length<3)return 0;let t=0;for(let e=0;e<s.length;e++){const[n,r]=s[e],[i,o]=s[(e+1)%s.length];t+=n*o-i*r}return Math.abs(t)/2}function zn(s,t,e){return Math.abs((s[0]*(t[1]-e[1])+t[0]*(e[1]-s[1])+e[0]*(s[1]-t[1]))/2)}function cn(s,t,e=1e-9){return Math.abs(s-t)<=e}const Vn=typeof zt.format_version<"u"?zt.format_version:2.00703;class It extends zt.Transform{importance;priority;pointsSet;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||It.VERTEX_PLAIN),this.strictMode=t.strictMode||It.MODE_AUTO,this.yaxisMode=t.yaxisMode||It.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return Vn}setPoints(t){this.yaxisMode===It.YAXIS_FOLLOW&&(t=t.map(e=>[e[0],[e[1][0],-1*e[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=zt.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let e=t[0][0],n=e,r=t[0][1],i=r;const o=[t[0]];for(let a=1;a<t.length;a++){const c=t[a];c[0]<e&&(e=c[0]),c[0]>n&&(n=c[0]),c[1]<r&&(r=c[1]),c[1]>i&&(i=c[1]),o.push(c)}o.push(t[0]),this.boundsPolygon=_e([o]),this.xy=[e,r],this.wh=[n-e,i-r],this.vertexMode=It.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=Vn,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer,t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const e=this.vertices_params.forw[1];return e&&[0,1,2,3].map(n=>{const r=e[n].features[0],i=r.geometry.coordinates[0][1],o=r.properties.b.geom;t.vertices_points[n]=[i,o]}),t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(n=>{t.tins_points[0].push(["a","b","c"].map(r=>n.properties[r].index))}),this.strict_status===It.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(r=>n.properties[r].index))})):this.strict_status===It.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(n=>n.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,t.xy=this.xy,t.wh=this.wh):t.wh=this.wh,t.edges=this.edges,t.edgeNodes=this.edgeNodes,t}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){const t=this.tins.forw.features.map(r=>zt.counterTri(r));this.tins.bakw=Vt(t);const e={};this.tins.forw.features.forEach((r,i)=>{const o=this.tins.bakw.features[i];sn(e,{forw:r,bakw:o})}),xi(this.tins,e,this.pointsSet?.edges||[]);const n=["forw","bakw"].map(r=>{const i=this.tins[r].features.map(o=>o.geometry.coordinates[0]);return Yn(i)});n[0].length===0&&n[1].length===0?(this.strict_status=It.STATUS_STRICT,delete this.kinks):(this.strict_status=It.STATUS_ERROR,this.kinks={forw:Vt(n[0]),bakw:Vt(n[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let r=0;r<this.points.length;r++){const i=this.points[r][0],o=this.points[r][1],a=Pe(i,o,r);t.forw.push(a),t.bakw.push(Be(a))}const e=[];let n=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let r=0;r<this.edges.length;r++){const i=this.edges[r][2],o=Object.assign([],this.edges[r][0]),a=Object.assign([],this.edges[r][1]);if(o.length===0&&a.length===0){e.push(i);continue}o.unshift(this.points[i[0]][0]),o.push(this.points[i[1]][0]),a.unshift(this.points[i[0]][1]),a.push(this.points[i[1]][1]);const c=[o,a].map(f=>{const u=f.map((p,y,E)=>{if(y===0)return 0;const k=E[y-1];return Math.sqrt(Math.pow(p[0]-k[0],2)+Math.pow(p[1]-k[1],2))}),h=u.reduce((p,y,E)=>E===0?[0]:(p.push(p[E-1]+y),p),[]);return h.map((p,y,E)=>{const k=p/E[E.length-1];return[f[y],u[y],h[y],k]})});c.map((f,u)=>{const h=c[u?0:1];return f.filter((p,y)=>!(y===0||y===f.length-1||p[4]==="handled")).map(p=>{const y=p[0],E=p[3],k=h.reduce((X,C,m,v)=>{if(X)return X;const l=v[m+1];if(C[3]===E)return C[4]="handled",[C];if(C[3]<E&&l&&l[3]>E)return[C,l]},void 0);if(k&&k.length===1)return u===0?[y,k[0][0],E]:[k[0][0],y,E];if(k&&k.length===2){const X=k[0],C=k[1],m=(E-X[3])/(C[3]-X[3]),v=[(C[0][0]-X[0][0])*m+X[0][0],(C[0][1]-X[0][1])*m+X[0][1]];return u===0?[y,v,E]:[v,y,E]}return[]})}).reduce((f,u)=>f.concat(u),[]).sort((f,u)=>f[2]<u[2]?-1:1).map((f,u,h)=>{this.edgeNodes[n]=[f[0],f[1]];const p=Pe(f[0],f[1],`e${n}`);n++,t.forw.push(p),t.bakw.push(Be(p)),u===0?e.push([i[0],t.forw.length-1]):e.push([t.forw.length-2,t.forw.length-1]),u===h.length-1&&e.push([t.forw.length-1,i[1]])})}return{forw:t.forw,bakw:t.bakw,edges:e}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],e=this.xy[0]+1.05*this.wh[0],n=this.xy[1]-.05*this.wh[1],r=this.xy[1]+1.05*this.wh[1];if(!this.points.reduce((a,c)=>a&&(this.bounds?ar(c[0],this.boundsPolygon):c[0][0]>=t&&c[0][0]<=e&&c[0][1]>=n&&c[0][1]<=r),!0))throw"SOME POINTS OUTSIDE";let o=[];return this.wh&&(o=[[t,n],[e,n],[t,r],[e,r]]),{pointsSet:this.generatePointsSet(),bbox:o,minx:t,maxx:e,miny:n,maxy:r}}updateTin(){let t=this.strictMode;t!==It.MODE_STRICT&&t!==It.MODE_LOOSE&&(t=It.MODE_AUTO);const{pointsSet:e,bbox:n,minx:r,maxx:i,miny:o,maxy:a}=this.validateAndPrepareInputs(),c={forw:Vt(e.forw),bakw:Vt(e.bakw)},f=Ee(c.forw,e.edges,"target"),u=Ee(c.bakw,e.edges,"target");if(f.features.length===0||u.features.length===0)throw"TOO LINEAR1";const h=fr(c.forw),p=kn(c.forw);if(!p)throw"TOO LINEAR2";const y={},E=p.geometry.coordinates[0];let k;try{k=E.map(b=>({forw:b,bakw:zt.transformArr(le(b),f)})),k.forEach(b=>{y[`${b.forw[0]}:${b.forw[1]}`]=b})}catch{throw"TOO LINEAR2"}const X=kn(c.bakw);if(!X)throw"TOO LINEAR2";const C=X.geometry.coordinates[0];try{k=C.map(b=>({bakw:b,forw:zt.transformArr(le(b),u)})),k.forEach(b=>{y[`${b.forw[0]}:${b.forw[1]}`]=b})}catch{throw"TOO LINEAR2"}const m={forw:h.geometry.coordinates,bakw:zt.transformArr(h,f)},v=Pe(m.forw,m.bakw,"c");this.centroid={forw:v,bakw:Be(v)};const l={convexBuf:y,centroid:m,bbox:n,minx:r,maxx:i,miny:o,maxy:a},g=this.vertexMode===It.VERTEX_BIRDEYE?Qr(l):Gr(l),x={forw:[],bakw:[]};for(let b=0;b<g.length;b++){const T=g[b].forw,Y=g[b].bakw,D=Pe(T,Y,`b${b}`),Q=Be(D);e.forw.push(D),e.bakw.push(Q),x.forw.push(D),x.bakw.push(Q)}this.pointsSet={forw:Vt(e.forw),bakw:Vt(e.bakw),edges:e.edges},this.tins={forw:zt.rotateVerticesTriangle(Ee(this.pointsSet.forw,e.edges,"target"))},(t===It.MODE_STRICT||t===It.MODE_AUTO)&&this.calcurateStrictTin(),(t===It.MODE_LOOSE||t===It.MODE_AUTO&&this.strict_status===It.STATUS_ERROR)&&(this.tins.bakw=zt.rotateVerticesTriangle(Ee(this.pointsSet.bakw,e.edges,"target")),delete this.kinks,this.strict_status=It.STATUS_LOOSE),this.vertices_params={forw:an(x.forw,this.centroid.forw),bakw:an(x.bakw,this.centroid.bakw)},this.addIndexedTin();const A=["forw"];this.strict_status===It.STATUS_LOOSE&&A.push("bakw");const I=this.strict_status===It.STATUS_STRICT;this.pointsWeightBuffer=bi({tins:this.tins,targets:A,includeReciprocals:I})}async updateTinAsync(){this.updateTin()}}$t.Tin=It,$t.constrainedTin=Ee,$t.counterPoint=Be,$t.createPoint=Pe,$t.default=It,$t.findIntersections=Yn,$t.format_version=zt.format_version,$t.insertSearchIndex=sn,$t.vertexCalc=an,Object.defineProperties($t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/dist/searchutils.d.ts
CHANGED
|
@@ -3,12 +3,20 @@ type BiDirectionKey = "forw" | "bakw";
|
|
|
3
3
|
type TinsBD = {
|
|
4
4
|
[key in BiDirectionKey]?: Tins;
|
|
5
5
|
};
|
|
6
|
-
type SearchTris = {
|
|
6
|
+
export type SearchTris = {
|
|
7
7
|
[key in BiDirectionKey]: Tri;
|
|
8
8
|
};
|
|
9
9
|
export type SearchIndex = {
|
|
10
10
|
[key: string]: SearchTris[];
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* 三角形のインデックスキーを計算する
|
|
14
|
+
* 三つの頂点のインデックスから、ソートされたキー配列を生成
|
|
15
|
+
*
|
|
16
|
+
* @param tri インデックスキーを計算する三角形
|
|
17
|
+
* @returns ソートされたキー配列
|
|
18
|
+
*/
|
|
19
|
+
declare function calcSearchKeys(tri: Tri): string[];
|
|
12
20
|
/**
|
|
13
21
|
* 検索インデックスに三角形を追加する
|
|
14
22
|
*
|
|
@@ -18,4 +26,5 @@ export type SearchIndex = {
|
|
|
18
26
|
* @throws キーの不一致エラー
|
|
19
27
|
*/
|
|
20
28
|
declare function insertSearchIndex(searchIndex: SearchIndex, tris: SearchTris, tins?: TinsBD): void;
|
|
21
|
-
|
|
29
|
+
declare function removeSearchIndex(searchIndex: SearchIndex, tris: SearchTris, tins?: TinsBD): void;
|
|
30
|
+
export { calcSearchKeys, insertSearchIndex, removeSearchIndex };
|
package/dist/tin.d.ts
CHANGED
|
@@ -34,11 +34,13 @@ export declare class Tin extends Transform {
|
|
|
34
34
|
*/
|
|
35
35
|
getFormatVersion(): number;
|
|
36
36
|
/**
|
|
37
|
-
* 制御点(GCP: Ground Control Points
|
|
37
|
+
* 制御点(GCP: Ground Control Points)を設定します。
|
|
38
|
+
* 指定した点群に合わせて内部のTINキャッシュをリセットします。
|
|
38
39
|
*/
|
|
39
40
|
setPoints(points: PointSet[]): void;
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* エッジ(制約線)を設定します。
|
|
43
|
+
* 制約線を正規化した上で、依存するキャッシュをリセットします。
|
|
42
44
|
*/
|
|
43
45
|
setEdges(edges?: EdgeSet[] | EdgeSetLegacy[]): void;
|
|
44
46
|
/**
|
|
@@ -66,7 +68,8 @@ export declare class Tin extends Transform {
|
|
|
66
68
|
*/
|
|
67
69
|
calcurateStrictTin(): void;
|
|
68
70
|
/**
|
|
69
|
-
*
|
|
71
|
+
* 点群セットを生成します。
|
|
72
|
+
* GCP と中間エッジノードを GeoJSON Point に変換し、後続の三角分割に備えます。
|
|
70
73
|
*/
|
|
71
74
|
generatePointsSet(): {
|
|
72
75
|
forw: Feature<Point>[];
|
|
@@ -78,23 +81,14 @@ export declare class Tin extends Transform {
|
|
|
78
81
|
*/
|
|
79
82
|
private validateAndPrepareInputs;
|
|
80
83
|
/**
|
|
81
|
-
* TIN
|
|
84
|
+
* TINネットワークを同期的に更新し、座標変換の準備を行います。
|
|
85
|
+
* 重めの計算を伴うため、呼び出し側が非同期制御を行いたい場合は
|
|
86
|
+
* {@link updateTinAsync} を利用してください。
|
|
82
87
|
*/
|
|
83
88
|
updateTin(): void;
|
|
84
89
|
/**
|
|
85
|
-
*
|
|
90
|
+
* 非同期ラッパーを提供します。
|
|
91
|
+
* 互換性のために Promise ベースの API を維持しますが、内部処理は同期的です。
|
|
86
92
|
*/
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 鳥瞰図モードの頂点を計算
|
|
90
|
-
*/
|
|
91
|
-
private calculateBirdeyeVertices;
|
|
92
|
-
/**
|
|
93
|
-
* 頂点の位置を調整
|
|
94
|
-
*/
|
|
95
|
-
private checkAndAdjustVertices;
|
|
96
|
-
/**
|
|
97
|
-
* 点の重み付けを計算します
|
|
98
|
-
*/
|
|
99
|
-
calculatePointsWeight(): void;
|
|
93
|
+
updateTinAsync(): Promise<void>;
|
|
100
94
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TinsBD, WeightBufferBD } from '@maplat/transform';
|
|
2
|
+
interface WeightBufferOptions {
|
|
3
|
+
tins: TinsBD;
|
|
4
|
+
targets: Array<keyof TinsBD>;
|
|
5
|
+
includeReciprocals: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Calculate per-point stretch ratios used for non-linear interpolation.
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildPointsWeightBuffer(options: WeightBufferOptions): WeightBufferBD;
|
|
11
|
+
export {};
|
package/package.json
CHANGED
|
@@ -4,18 +4,21 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.12.0",
|
|
8
8
|
"description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
|
|
9
9
|
"type": "module",
|
|
10
|
-
"main": "./dist/
|
|
10
|
+
"main": "./dist/index.cjs",
|
|
11
11
|
"module": "./dist/maplat_tin.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"browser": "./dist/maplat_tin.
|
|
16
|
+
"browser": "./dist/maplat_tin.js",
|
|
17
17
|
"import": "./dist/maplat_tin.js",
|
|
18
|
-
"require": "./dist/
|
|
18
|
+
"require": "./dist/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./umd": {
|
|
21
|
+
"default": "./dist/maplat_tin.umd.js"
|
|
19
22
|
}
|
|
20
23
|
},
|
|
21
24
|
"files": [
|
|
@@ -25,24 +28,6 @@
|
|
|
25
28
|
"README.ja.md",
|
|
26
29
|
"LICENSE"
|
|
27
30
|
],
|
|
28
|
-
"scripts": {
|
|
29
|
-
"dev": "vite",
|
|
30
|
-
"build": "npm run typecheck && cross-env BUILD_MODE=package vite build",
|
|
31
|
-
"typecheck": "tsc --noEmit --allowImportingTsExtensions",
|
|
32
|
-
"test": "vitest run",
|
|
33
|
-
"test:watch": "vitest",
|
|
34
|
-
"coverage": "vitest run --coverage",
|
|
35
|
-
"lint": "eslint src tests",
|
|
36
|
-
"prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build",
|
|
37
|
-
"version:bump": "node scripts/bump-version.js",
|
|
38
|
-
"version:sync": "node scripts/sync-version.js",
|
|
39
|
-
"publish:npm": "node scripts/publish-npm.js",
|
|
40
|
-
"publish:npm:dry": "node scripts/publish-npm.js --dry-run",
|
|
41
|
-
"publish:deno": "node scripts/publish-deno.js",
|
|
42
|
-
"publish:deno:dry": "node scripts/publish-deno.js --dry-run",
|
|
43
|
-
"publish:all": "node scripts/publish-all.js",
|
|
44
|
-
"publish:all:dry": "node scripts/publish-all.js --dry-run"
|
|
45
|
-
},
|
|
46
31
|
"repository": {
|
|
47
32
|
"type": "git",
|
|
48
33
|
"url": "git+https://github.com/code4history/MaplatTin.git"
|
|
@@ -62,8 +47,8 @@
|
|
|
62
47
|
"deno"
|
|
63
48
|
],
|
|
64
49
|
"dependencies": {
|
|
65
|
-
"@maplat/
|
|
66
|
-
"
|
|
50
|
+
"@maplat/transform": "^0.3.0",
|
|
51
|
+
"robust-predicates": "^3.0.2"
|
|
67
52
|
},
|
|
68
53
|
"peerDependencies": {
|
|
69
54
|
"@turf/boolean-point-in-polygon": "^7.2.0",
|
|
@@ -74,27 +59,41 @@
|
|
|
74
59
|
"delaunator": "^5.0.0"
|
|
75
60
|
},
|
|
76
61
|
"devDependencies": {
|
|
77
|
-
"@eslint/js": "^9.
|
|
78
|
-
"@testing-library/jest-dom": "^6.
|
|
62
|
+
"@eslint/js": "^9.39.1",
|
|
63
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
79
64
|
"@types/delaunator": "^5.0.3",
|
|
80
65
|
"@types/estree": "^1.0.8",
|
|
81
66
|
"@types/geojson": "^7946.0.15",
|
|
82
|
-
"@types/node": "^
|
|
83
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
84
|
-
"@typescript-eslint/parser": "^8.
|
|
85
|
-
"@vitest/coverage-v8": "^
|
|
86
|
-
"cross-env": "^
|
|
87
|
-
"dotenv": "^
|
|
88
|
-
"dotenv-cli": "^
|
|
89
|
-
"eslint": "^9.
|
|
90
|
-
"eslint-config-prettier": "^
|
|
67
|
+
"@types/node": "^24.10.0",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^8.46.3",
|
|
69
|
+
"@typescript-eslint/parser": "^8.46.3",
|
|
70
|
+
"@vitest/coverage-v8": "^4.0.8",
|
|
71
|
+
"cross-env": "^10.1.0",
|
|
72
|
+
"dotenv": "^17.2.3",
|
|
73
|
+
"dotenv-cli": "^11.0.0",
|
|
74
|
+
"eslint": "^9.39.1",
|
|
75
|
+
"eslint-config-prettier": "^10.1.8",
|
|
91
76
|
"jest-matcher-deep-close-to": "^3.0.2",
|
|
92
|
-
"jsdom": "^
|
|
77
|
+
"jsdom": "^27.1.0",
|
|
93
78
|
"prettier": "^3.4.2",
|
|
94
|
-
"
|
|
95
|
-
"typescript
|
|
96
|
-
"
|
|
79
|
+
"robust-segment-intersect": "^1.0.1",
|
|
80
|
+
"typescript": "^5.9.3",
|
|
81
|
+
"typescript-eslint": "^8.46.3",
|
|
82
|
+
"vite": "^7.2.2",
|
|
97
83
|
"vite-plugin-dts": "^4.4.0",
|
|
98
|
-
"vitest": "^
|
|
84
|
+
"vitest": "^4.0.8"
|
|
85
|
+
},
|
|
86
|
+
"scripts": {
|
|
87
|
+
"dev": "vite",
|
|
88
|
+
"build": "npm run typecheck && cross-env BUILD_MODE=package vite build",
|
|
89
|
+
"typecheck": "tsc --noEmit --allowImportingTsExtensions",
|
|
90
|
+
"test": "vitest run",
|
|
91
|
+
"test:watch": "vitest",
|
|
92
|
+
"coverage": "vitest run --coverage",
|
|
93
|
+
"lint": "eslint src tests",
|
|
94
|
+
"version:bump": "node scripts/bump-version.js",
|
|
95
|
+
"version:sync": "node scripts/sync-version.js",
|
|
96
|
+
"publish:npm": "node scripts/publish-npm.js",
|
|
97
|
+
"publish:npm:dry": "node scripts/publish-npm.js --dry-run"
|
|
99
98
|
}
|
|
100
|
-
}
|
|
99
|
+
}
|