@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.cjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
"use strict";var Ke=Object.defineProperty;var Qe=(o,t,e)=>t in o?Ke(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var rt=(o,t,e)=>Qe(o,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ze=require("@turf/boolean-point-in-polygon"),tn=require("@turf/centroid"),ye=require("@turf/convex"),ft=require("@turf/helpers"),en=require("@turf/line-intersect"),nn=require("delaunator");var sn=Object.defineProperty,rn=(o,t,e)=>t in o?sn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,st=(o,t,e)=>rn(o,typeof t!="symbol"?t+"":t,e);const Tt=11102230246251565e-32,dt=134217729,on=(3+8*Tt)*Tt;function ae(o,t,e,n,i){let s,r,a,f,h=t[0],u=n[0],c=0,l=0;u>h==u>-h?(s=h,h=t[++c]):(s=u,u=n[++l]);let p=0;if(c<o&&l<e)for(u>h==u>-h?(r=h+s,a=s-(r-h),h=t[++c]):(r=u+s,a=s-(r-u),u=n[++l]),s=r,a!==0&&(i[p++]=a);c<o&&l<e;)u>h==u>-h?(r=s+h,f=r-s,a=s-(r-f)+(h-f),h=t[++c]):(r=s+u,f=r-s,a=s-(r-f)+(u-f),u=n[++l]),s=r,a!==0&&(i[p++]=a);for(;c<o;)r=s+h,f=r-s,a=s-(r-f)+(h-f),h=t[++c],s=r,a!==0&&(i[p++]=a);for(;l<e;)r=s+u,f=r-s,a=s-(r-f)+(u-f),u=n[++l],s=r,a!==0&&(i[p++]=a);return(s!==0||p===0)&&(i[p++]=s),p}function an(o,t){let e=t[0];for(let n=1;n<o;n++)e+=t[n];return e}function Kt(o){return new Float64Array(o)}const cn=(3+16*Tt)*Tt,hn=(2+12*Tt)*Tt,fn=(9+64*Tt)*Tt*Tt,Vt=Kt(4),ke=Kt(8),xe=Kt(12),_e=Kt(16),pt=Kt(4);function un(o,t,e,n,i,s,r){let a,f,h,u,c,l,p,y,g,b,w,M,_,v,T,I,N,V;const W=o-i,G=e-i,tt=t-s,z=n-s;v=W*z,l=dt*W,p=l-(l-W),y=W-p,l=dt*z,g=l-(l-z),b=z-g,T=y*b-(v-p*g-y*g-p*b),I=tt*G,l=dt*tt,p=l-(l-tt),y=tt-p,l=dt*G,g=l-(l-G),b=G-g,N=y*b-(I-p*g-y*g-p*b),w=T-N,c=T-w,Vt[0]=T-(w+c)+(c-N),M=v+w,c=M-v,_=v-(M-c)+(w-c),w=_-I,c=_-w,Vt[1]=_-(w+c)+(c-I),V=M+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t[1]=_-(w+c)+(c-I),V=M+w,c=V-M,pt[2]=M-(V-c)+(w-c),pt[3]=V;const A=ae(x,xe,4,pt,_e);return _e[A-1]}function ln(o,t,e,n,i,s){const r=(t-s)*(e-i),a=(o-i)*(n-s),f=r-a,h=Math.abs(r+a);return Math.abs(f)>=cn*h?f:-un(o,t,e,n,i,s,h)}function dn(o,t){var e,n,i=0,s,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(s=ln(r,f,a,h,0,0),s===0)return 0;(s>0&&h>0&&a<=0||s<0&&h<=0&&a>0)&&i++}u=c,a=h,r=f}}return i%2!==0}function De(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 Xt(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(!Se(o[0])||!Se(o[1]))throw new Error("coordinates must contain numbers");return De({type:"Point",coordinates:o},t,e)}function Fe(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 i=0;i<n[n.length-1].length;i++)if(n[n.length-1][i]!==n[0][i])throw new Error("First and last Position are not equivalent.")}return De({type:"Polygon",coordinates:o},t,e)}function Lt(o,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=o,e}function Se(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function gn(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 Me(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 pn(o){return o.type==="Feature"?o.geometry:o}function wn(o,t,e={}){if(!o)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=gn(o),i=pn(t),s=i.type,r=t.bbox;let a=i.coordinates;if(r&&mn(n,r)===!1)return!1;s==="Polygon"&&(a=[a]);let f=!1;for(var h=0;h<a.length;++h){const u=dn(n,a[h]);if(u===0)return!e.ignoreBoundary;u&&(f=!0)}return f}function mn(o,t){return t[0]<=o[0]&&t[1]<=o[1]&&t[2]>=o[0]&&t[3]>=o[1]}var pe=wn;function Ae(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 bn(o){const t=["a","b","c","a"].map(s=>o.properties[s].geom),e=o.geometry.coordinates[0],n=o.properties,i={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 Fe([t],i)}function yn(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 Fe([t],e)}function Qt(o,t,e,n,i,s=!1,r){const a=o.map(f=>{(!r||r<2.00703)&&(f=je(f));const h=isFinite(f)?t[f]:f==="c"?n:f==="b0"?i[0]:f==="b1"?i[1]:f==="b2"?i[2]:f==="b3"?i[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 s?[[h[1],h[0]],f]:[[h[0],h[1]],f]});return yn(a)}function je(o){return typeof o=="number"?o:o.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function Le(o,t){return t&&t>=2.00703||Array.isArray(o[0])?o:o.map(e=>[e.illstNodes,e.mercNodes,e.startEnd])}function Ee(o,t){for(let e=0;e<t.features.length;e++)if(pe(o,t.features[e]))return t.features[e]}function Ve(o,t,e){const n=t.geometry.coordinates[0][0],i=t.geometry.coordinates[0][1],s=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=[i[0]-n[0],i[1]-n[1]],c=[s[0]-n[0],s[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 kn(o,t,e,n){const i=o.geometry.coordinates,s=e.geometry.coordinates,r=Math.atan2(i[0]-s[0],i[1]-s[1]),a=xn(r,t[0]);if(a===void 0)throw new Error("Unable to determine vertex index");const f=t[1][a];return Ve(o,f.features[0],n)}function ie(o,t,e,n,i,s,r,a){let f;if(r&&(f=Ee(o,Lt([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=Et(h[0],c,p,u),w=Et(h[1],l,y,u),M=g[b]?g[b][w]?g[b][w]:[]:[];t=Lt(M.map(_=>t.features[_]))}f=Ee(o,t)}return a&&a(f),f?Ve(o,f,s):kn(o,n,i,s)}function Et(o,t,e,n){let i=Math.floor((o-t)/e);return i>=n&&(i=n-1),i}function xn(o,t){let e=ve(o-t[0]),n=Math.PI*2,i;for(let s=0;s<t.length;s++){const r=(s+1)%t.length,a=ve(o-t[r]),f=Math.min(Math.abs(e),Math.abs(a));e*a<=0&&f<n&&(n=f,i=s),e=a}return i}function ve(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 re=2.00703,xt=class _t{constructor(){st(this,"points",[]),st(this,"pointsWeightBuffer"),st(this,"strict_status"),st(this,"vertices_params"),st(this,"centroid"),st(this,"edgeNodes"),st(this,"edges"),st(this,"tins"),st(this,"kinks"),st(this,"yaxisMode",_t.YAXIS_INVERT),st(this,"strictMode",_t.MODE_AUTO),st(this,"vertexMode",_t.VERTEX_PLAIN),st(this,"bounds"),st(this,"boundsPolygon"),st(this,"wh"),st(this,"xy"),st(this,"indexedTins"),st(this,"stateFull",!1),st(this,"stateTriangle"),st(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,i)=>{const s=t.weight_buffer[i];return s&&(n[i]=Object.keys(s).reduce((r,a)=>{const f=je(a);return r[f]=s[a],r},{})),n},{}):t.weight_buffer,t.strict_status?this.strict_status=t.strict_status:t.kinks_points?this.strict_status=_t.STATUS_ERROR:t.tins_points.length==2?this.strict_status=_t.STATUS_LOOSE:this.strict_status=_t.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 i=(n+1)%4,s=Qt(["c",`b${n}`,`b${i}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,re);return Lt([s])}),this.vertices_params.bakw[1]=[0,1,2,3].map(n=>{const i=(n+1)%4,s=Qt(["c",`b${n}`,`b${i}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,re);return Lt([s])}),this.centroid={forw:Xt(t.centroid_point[0],{target:{geom:t.centroid_point[1],index:"c"}}),bakw:Xt(t.centroid_point[1],{target:{geom:t.centroid_point[0],index:"c"}})},this.edges=Le(t.edges||[]),this.edgeNodes=t.edgeNodes||[];const e=t.tins_points.length==1?0:1;this.tins={forw:Lt(t.tins_points[0].map(n=>Qt(n,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,t.version))),bakw:Lt(t.tins_points[e].map(n=>Qt(n,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,t.version)))},this.addIndexedTin(),t.kinks_points&&(this.kinks={bakw:Lt(t.kinks_points.map(n=>Xt(n)))}),t.yaxisMode?this.yaxisMode=t.yaxisMode:this.yaxisMode=_t.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 i=this.tins.forw.features[n];["a","b","c"].map((s,r)=>{const a=i.geometry.coordinates[0][r],f=i.properties[s].geom,h=i.properties[s].index;typeof h=="number"&&(e[h]=[a,f])})}this.points=e}}addIndexedTin(){const t=this.tins,e=t.forw,n=t.bakw,i=Math.ceil(Math.sqrt(e.features.length));if(i<3){this.indexedTins=void 0;return}let s=[],r=[];const a=e.features.map(g=>{let b=[];return Me(g)[0].map(w=>{s.length===0?s=[Array.from(w),Array.from(w)]:(w[0]<s[0][0]&&(s[0][0]=w[0]),w[0]>s[1][0]&&(s[1][0]=w[0]),w[1]<s[0][1]&&(s[0][1]=w[1]),w[1]>s[1][1]&&(s[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=(s[1][0]-s[0][0])/i,h=(s[1][1]-s[0][1])/i,u=a.reduce((g,b,w)=>{const M=Et(b[0][0],s[0][0],f,i),_=Et(b[1][0],s[0][0],f,i),v=Et(b[0][1],s[0][1],h,i),T=Et(b[1][1],s[0][1],h,i);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 Me(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])/i,p=(r[1][1]-r[0][1])/i,y=c.reduce((g,b,w)=>{const M=Et(b[0][0],r[0][0],l,i),_=Et(b[1][0],r[0][0],l,i),v=Et(b[0][1],r[0][1],p,i),T=Et(b[1][1],r[0][1],p,i);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:i,xOrigin:s[0][0],yOrigin:s[0][1],xUnit:f,yUnit:h,gridCache:u},bakw:{gridNum:i,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:l,yUnit:p,gridCache:y}}}transform(t,e,n){if(e&&this.strict_status==_t.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==_t.YAXIS_FOLLOW&&e&&(t=[t[0],-1*t[1]]);const i=Xt(t);if(this.bounds&&!e&&!n&&!pe(i,this.boundsPolygon))return!1;const s=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=ie(i,s,r,a,f,h,u,c);if(this.bounds&&e&&!n){const p=Xt(l);if(!pe(p,this.boundsPolygon))return!1}else this.yaxisMode==_t.YAXIS_FOLLOW&&!e&&(l=[l[0],-1*l[1]]);return l}};st(xt,"VERTEX_PLAIN","plain"),st(xt,"VERTEX_BIRDEYE","birdeye"),st(xt,"MODE_STRICT","strict"),st(xt,"MODE_AUTO","auto"),st(xt,"MODE_LOOSE","loose"),st(xt,"STATUS_STRICT","strict"),st(xt,"STATUS_ERROR","strict_error"),st(xt,"STATUS_LOOSE","loose"),st(xt,"YAXIS_FOLLOW","follow"),st(xt,"YAXIS_INVERT","invert");let _n=xt;const gt=11102230246251565e-32,$=134217729,Ce=(3+8*gt)*gt;function ht(o,t,e,n,i){let s,r,a,f,h=t[0],u=n[0],c=0,l=0;u>h==u>-h?(s=h,h=t[++c]):(s=u,u=n[++l]);let p=0;if(c<o&&l<e)for(u>h==u>-h?(r=h+s,a=s-(r-h),h=t[++c]):(r=u+s,a=s-(r-u),u=n[++l]),s=r,a!==0&&(i[p++]=a);c<o&&l<e;)u>h==u>-h?(r=s+h,f=r-s,a=s-(r-f)+(h-f),h=t[++c]):(r=s+u,f=r-s,a=s-(r-f)+(u-f),u=n[++l]),s=r,a!==0&&(i[p++]=a);for(;c<o;)r=s+h,f=r-s,a=s-(r-f)+(h-f),h=t[++c],s=r,a!==0&&(i[p++]=a);for(;l<e;)r=s+u,f=r-s,a=s-(r-f)+(u-f),u=n[++l],s=r,a!==0&&(i[p++]=a);return(s!==0||p===0)&&(i[p++]=s),p}function kt(o,t,e,n,i,s,r,a){return ht(ht(o,t,e,n,r),r,i,s,a)}function S(o,t,e,n){let i,s,r,a,f,h,u,c,l,p,y;u=$*e,p=u-(u-e),y=e-p;let g=t[0];i=g*e,u=$*g,c=u-(u-g),l=g-c,r=l*y-(i-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),s=i+f,h=s-i,r=i-(s-h)+(f-h),r!==0&&(n[b++]=r),i=a+s,r=s-(i-a),r!==0&&(n[b++]=r);return(i!==0||b===0)&&(n[b++]=i),b}function We(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 Sn=(3+16*gt)*gt,Mn=(2+12*gt)*gt,An=(9+64*gt)*gt*gt,Ct=H(4),Oe=H(8),Te=H(12),Ie=H(16),wt=H(4);function En(o,t,e,n,i,s,r){let a,f,h,u,c,l,p,y,g,b,w,M,_,v,T,I,N,V;const W=o-i,G=e-i,tt=t-s,z=n-s;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*G,l=$*tt,p=l-(l-tt),y=tt-p,l=$*G,g=l-(l-G),b=G-g,N=y*b-(I-p*g-y*g-p*b),w=T-N,c=T-w,Ct[0]=T-(w+c)+(c-N),M=v+w,c=M-v,_=v-(M-c)+(w-c),w=_-I,c=_-w,Ct[1]=_-(w+c)+(c-I),V=M+w,c=V-M,Ct[2]=M-(V-c)+(w-c),Ct[3]=V;let it=We(4,Ct),d=Mn*r;if(it>=d||-it>=d||(c=o-W,a=o-(W+c)+(c-i),c=e-G,h=e-(G+c)+(c-i),c=t-tt,f=t-(tt+c)+(c-s),c=n-z,u=n-(z+c)+(c-s),a===0&&f===0&&h===0&&u===0)||(d=An*r+Ce*Math.abs(it),it+=W*u+z*a-(tt*h+G*f),it>=d||-it>=d))return it;v=a*z,l=$*a,p=l-(l-a),y=a-p,l=$*z,g=l-(l-z),b=z-g,T=y*b-(v-p*g-y*g-p*b),I=f*G,l=$*f,p=l-(l-f),y=f-p,l=$*G,g=l-(l-G),b=G-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 m=ht(4,Ct,4,wt,Oe);v=W*u,l=$*W,p=l-(l-W),y=W-p,l=$*u,g=l-(l-u),b=u-g,T=y*b-(v-p*g-y*g-p*b),I=tt*h,l=$*tt,p=l-(l-tt),y=tt-p,l=$*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 x=ht(m,Oe,4,wt,Te);v=a*u,l=$*a,p=l-(l-a),y=a-p,l=$*u,g=l-(l-u),b=u-g,T=y*b-(v-p*g-y*g-p*b),I=f*h,l=$*f,p=l-(l-f),y=f-p,l=$*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=ht(x,Te,4,wt,Ie);return Ie[A-1]}function qt(o,t,e,n,i,s){const r=(t-s)*(e-i),a=(o-i)*(n-s),f=r-a,h=Math.abs(r+a);return Math.abs(f)>=Sn*h?f:-En(o,t,e,n,i,s,h)}const vn=(10+96*gt)*gt,On=(4+48*gt)*gt,Tn=(44+576*gt)*gt*gt,It=H(4),Pt=H(4),$t=H(4),St=H(4),Mt=H(4),At=H(4),mt=H(4),bt=H(4),ce=H(8),he=H(8),fe=H(8),ue=H(8),le=H(8),de=H(8),Zt=H(8),te=H(8),ee=H(8),Bt=H(4),Dt=H(4),Ft=H(4),U=H(8),L=H(16),et=H(16),nt=H(16),Z=H(32),Rt=H(32),at=H(48),yt=H(64);let Wt=H(1152),ge=H(1152);function ct(o,t,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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,Bt[0]=D-(k+d)+(d-C),O=P+k,d=O-P,B=P-(O-d)+(k-d),k=B-F,d=B-k,Bt[1]=B-(k+d)+(d-F),j=O+k,d=j-O,Bt[2]=O-(j-d)+(k-d),Bt[3]=j,W=4):(Zt[0]=0,I=1,Bt[0]=0,W=1),l!==0){const ut=S(I,Zt,l,nt);h=ct(h,ht(S(v,le,l,L),L,S(ut,nt,2*Y,Z),Z,at),at);const lt=S(W,Bt,l,U);h=ct(h,kt(S(lt,U,2*Y,L),L,S(lt,U,l,et),et,S(ut,nt,l,Z),Z,Rt,yt),yt),p!==0&&(h=ct(h,S(S(4,Mt,l,U),U,p,L),L)),y!==0&&(h=ct(h,S(S(4,St,-l,U),U,y,L),L))}if(g!==0){const ut=S(I,Zt,g,nt);h=ct(h,ht(S(T,de,g,L),L,S(ut,nt,2*Q,Z),Z,at),at);const lt=S(W,Bt,g,U);h=ct(h,kt(S(lt,U,2*Q,L),L,S(lt,U,g,et),et,S(ut,nt,g,Z),Z,Rt,yt),yt)}}return Wt[h-1]}function Pn(o,t,e,n,i,s,r,a){const f=o-r,h=e-r,u=i-r,c=t-a,l=n-a,p=s-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=vn*V;return N>W||-N>W?N:In(o,t,e,n,i,s,r,a,V)}class $n{constructor(t,e){this.W=t,this.bs=e}add(t){const e=this.W,n=t/e|0,i=t%e;return this.bs[n]|=1<<i,this}delete(t){const e=this.W,n=t/e|0,i=t%e;return this.bs[n]&=~(1<<i),this}set(t,e){const n=this.W,i=t/n|0,s=t%n,r=1<<s;return this.bs[i]^=(-e^this.bs[i])&r,e}has(t){const e=this.W,n=t/e|0,i=t%e;return!!(this.bs[n]&1<<i)}forEach(t){const e=this.W,n=this.bs,i=n.length;for(let s=0;s<i;s++){let r=0;for(;n[s]&&r<e;)n[s]&1<<r&&t(s*e+r),r++}return this}}class Pe extends $n{constructor(t){const e=new Uint8Array(Math.ceil(t/8)).fill(0);super(8,e)}}function jt(o){return o%3===2?o-2:o+1}function vt(o){return o%3===0?o+2:o-1}function ze(o,t,e,n,i,s,r,a){const f=qt(o,t,i,s,r,a),h=qt(e,n,i,s,r,a);if(f>0&&h>0||f<0&&h<0)return!1;const u=qt(i,s,o,t,e,n),c=qt(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(i,r)<Math.min(o,e)||Math.max(o,e)<Math.min(i,r)||Math.max(s,a)<Math.min(t,n)||Math.max(t,n)<Math.min(s,a)):!0}class Rn{constructor(t){this.del=t}}const Xe=class extends Rn{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,i=t.coords.length>>1,s=t.triangles.length;this.vertMap=new Uint32Array(i).fill(n),this.flips=new Pe(s),this.consd=new Pe(s);for(let r=0;r<s;r++){const a=t.triangles[r];this.vertMap[a]===n&&this.updateVert(r)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:n,halfedges:i}=this.del,s=this.vertMap[t];let r=s;do{const h=n[r],u=jt(r);if(h===e)return this.protect(r);const c=vt(r),l=n[c];if(l===e)return this.protect(u),u;if(this.intersectSegments(t,e,l,h)){r=c;break}r=i[u]}while(r!==-1&&r!==s);let a=r,f=-1;for(;r!==-1;){const h=i[r],u=vt(r),c=vt(h),l=jt(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,i=this.consd,s=e.length;do{var r=0;for(let a=0;a<s;a++){if(i.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 i=t[n];this.constrainOne(i[0],i[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const n=this.vertMap[e],{triangles:i,halfedges:s}=this.del;let r=n,a=-1;do{if(i[r]===t)return r;a=jt(r),r=s[a]}while(r!==-1&&r!==n);return i[jt(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],n=this.flips,i=this.consd;return n.delete(t),i.add(t),e!==-1?(n.delete(e),i.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,i=this.flips,s=this.consd,r=n[t],a=vt(t),f=jt(t),h=vt(r),u=jt(r),c=n[a],l=n[h];if(s.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[h],n[t]=l,i.set(t,i.has(h))||s.set(t,s.has(h)),l!==-1&&(n[l]=t),n[a]=h,e[r]=e[a],n[r]=c,i.set(r,i.has(a))||s.set(r,s.has(a)),c!==-1&&(n[c]=r),n[h]=a,this.markFlip(t),this.markFlip(f),this.markFlip(r),this.markFlip(u),i.add(a),s.delete(a),i.add(h),s.delete(h),this.updateVert(t),this.updateVert(f),this.updateVert(r),this.updateVert(u),a}isCollinear(t,e,n){const i=this.del.coords;return qt(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1])===0}inCircle(t,e,n,i){const s=this.del.coords;return Pn(s[t*2],s[t*2+1],s[e*2],s[e*2+1],s[n*2],s[n*2+1],s[i*2],s[i*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:n}=this.del,i=n[t];if(i===-1)return!0;const s=e[vt(t)],r=e[t],a=e[jt(t)],f=e[vt(i)];return!this.inCircle(s,r,a,f)}updateVert(t){const{triangles:e,halfedges:n}=this.del,i=this.vertMap,s=e[t];let r=vt(t),a=n[r];for(;a!==-1&&a!==t;)r=vt(a),a=n[r];return i[s]=r,r}intersectSegments(t,e,n,i){const s=this.del.coords;return t===n||t===i||e===n||e===i?!1:ze(s[t*2],s[t*2+1],s[e*2],s[e*2+1],s[n*2],s[n*2+1],s[i*2],s[i*2+1])}};Xe.intersectSegments=ze;let Nn=Xe;function Yt(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),i=nn.from(n);let s;const r=[];i.triangles.length!==0&&t.length!==0&&(s=new Nn(i),s.constrainAll(t));for(let f=0;f<i.triangles.length;f+=3)r.push([i.triangles[f],i.triangles[f+1],i.triangles[f+2]]);const a=["a","b","c"];return ft.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],ft.polygon([u],h)}))}function qe(o){const e=new Un(o).findSegmentIntersections();return He(e).reduce((n,i,s,r)=>Array.isArray(n)||(n||(n={}),n[`${i.x}:${i.y}`]=i,s!=r.length-1)?n:Object.keys(n).map(a=>ft.point([n[a].x,n[a].y])),{})}class Un{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=[],i=t.map(s=>{const r=s?s.length:0;for(let a=0;a<r;a++)e.push(s[a][0]),n.push(s[a][1]);return r});this.initXYData(i,e,n)}initXYData(t,e,n){const i=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(i);let s=0;for(let r=0;r<i;r++)this._ii[r]=s,s+=t[r];(s!=this._xx.length||this._xx.length!=this._yy.length)&&me("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new es(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 i=n.length,s=new Float64Array(i*4),r=new oe;let a=0,f,h,u;for(let c=0;c<i;c++)f=n[c],f>0&&(h=c*4,u=ns(t,e,a,f),s[h++]=u[0],s[h++]=u[1],s[h++]=u[2],s[h]=u[3],a+=f,r.mergeBounds(u));return{bb:s,bounds:r}}getBounds(){return this._allBounds.clone()}forEachSegment(t){let e=0;for(let n=0,i=this.size();n<i;n++)e+=this.forEachArcSegment(n,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const n=t>=0,i=n?t:~t,s=this.getRetainedInterval(),r=this._nn[i],a=n?1:-1;let f=n?this._ii[i]:this._ii[i]+r-1,h=f,u=0;for(let c=1;c<r;c++)h+=a,(s===0||this._zz[h]>=s)&&(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((i,s,r,a)=>{t+=Math.abs(r[i]-r[s]),e+=Math.abs(a[i]-a[s])});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,i=this.calcSegmentIntersectionStripeCount(),s=new Uint32Array(i),r=i>1?g=>Math.floor((i-1)*(g-e)/n):()=>0;let a,f;this.forEachSegment((g,b,w,M)=>{let _=r(M[g]);const v=r(M[b]);for(;s[_]=s[_]+2,_!=v;)_+=v>_?1:-1});const h=this.getUint32Array(Fn(s));let u=0;const c=[];jn(s,g=>{const b=u;u+=g,c.push(h.subarray(b,u))}),Ln(s,0),this.forEachSegment((g,b,w,M)=>{let _=r(M[g]);const v=r(M[b]);let T,I;for(;T=s[_],s[_]=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<i;a++)for(y=Vn(c[a],l.xx,l.yy),f=0;f<y.length;f++)p.push(y[f]);return He(p)}}function me(...o){const t=o.join(" ");throw new Error(t)}function be(o){return o?Dn(o)?!0:Bn(o)?!1:o.length===0?!0:o.length>0:!1}function Bn(o){return o!=null&&o.toString===String.prototype.toString}function Dn(o){return Array.isArray(o)}function Fn(o,t){be(o)||me("utils.sum() expects an array, received:",o);let e=0,n;for(let i=0,s=o.length;i<s;i++)n=o[i],n&&(e+=n);return e}function jn(o,t,e){if(!be(o))throw new Error(`#forEach() takes an array-like argument. ${o}`);for(let n=0,i=o.length;n<i;n++)t.call(e,o[n],n)}function Ln(o,t){for(let e=0,n=o.length;e<n;e++)o[e]=t;return o}function Vn(o,t,e){const n=o.length-2,i=[];let s,r,a,f,h,u,c,l,p,y,g,b,w,M,_,v,T;for(Kn(t,o),v=0;v<n;){for(s=o[v],r=o[v+1],h=t[s],u=t[r],p=e[s],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;s==a||s==f||r==a||r==f||(w=Cn(h,p,u,y,c,g,l,b),w&&(M=[s,r],_=[a,f],i.push(Re(w,M,_,t,e)),w.length==4&&i.push(Re(w.slice(2),M,_,t,e))))}v+=2}return i}function Cn(o,t,e,n,i,s,r,a){const f=Wn(o,t,e,n,i,s,r,a);let h=null;return f&&(h=zn(o,t,e,n,i,s,r,a),h?Gn(o,t,e,n,i,s,r,a)&&(h=null):h=Hn(o,t,e,n,i,s,r,a)),h}function Wn(o,t,e,n,i,s,r,a){return Jt(o,t,e,n,i,s)*Jt(o,t,e,n,r,a)<=0&&Jt(i,s,r,a,o,t)*Jt(i,s,r,a,e,n)<=0}function Jt(o,t,e,n,i,s){return Ye(o-i,t-s,e-i,n-s)}function Ye(o,t,e,n){return o*n-t*e}function zn(o,t,e,n,i,s,r,a){let f=ne(o,t,e,n,i,s,r,a),h;return f&&(h=qn(f[0],f[1],o,t,e,n,i,s,r,a),h==1?f=ne(e,n,o,t,i,s,r,a):h==2?f=ne(i,s,r,a,o,t,e,n):h==3&&(f=ne(r,a,i,s,o,t,e,n))),f&&Jn(f,o,t,e,n,i,s,r,a),f}function ne(o,t,e,n,i,s,r,a){const f=Ye(e-o,n-t,r-i,a-s),h=1e-18;let u;if(f===0)return null;const c=Jt(i,s,r,a,o,t)/f;return f<=h&&f>=-h?u=Xn(o,t,e,n,i,s,r,a):u=[o+c*(e-o),t+c*(n-t)],u}function Xn(o,t,e,n,i,s,r,a){let f=null;return!Ot(o,i,r)&&!Ot(t,s,a)?f=[o,t]:!Ot(e,i,r)&&!Ot(n,s,a)?f=[e,n]:!Ot(i,o,e)&&!Ot(s,t,n)?f=[i,s]:!Ot(r,o,e)&&!Ot(a,t,n)&&(f=[r,a]),f}function Ot(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 qn(o,t,...e){let n=-1,i=1/0,s;for(let r=0,a=0,f=e.length;a<f;r++,a+=2)s=Yn(o,t,e[a],e[a+1]),s<i&&(i=s,n=r);return n}function Yn(o,t,e,n){const i=o-e,s=t-n;return i*i+s*s}function Jn(o,t,e,n,i,s,r,a,f){let h=o[0],u=o[1];h=se(h,t,n),h=se(h,s,a),u=se(u,e,i),u=se(u,r,f),o[0]=h,o[1]=u}function se(o,t,e){let n;return Ot(o,t,e)&&(n=Math.abs(o-t)<Math.abs(o-e)?t:e,o=n),o}function Hn(o,t,e,n,i,s,r,a){const f=Math.min(o,e,i,r),h=Math.max(o,e,i,r),u=Math.min(t,n,s,a),c=Math.max(t,n,s,a),l=c-u>h-f;let p=[];return(l?Nt(t,u,c):Nt(o,f,h))&&p.push(o,t),(l?Nt(n,u,c):Nt(e,f,h))&&p.push(e,n),(l?Nt(s,u,c):Nt(i,f,h))&&p.push(i,s),(l?Nt(a,u,c):Nt(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 Gn(o,t,e,n,i,s,r,a){return o==i&&t==s||o==r&&t==a||e==i&&n==s||e==r&&n==a}function Nt(o,t,e){return o>t&&o<e}function Kn(o,t){Qn(o,t),Je(o,t,0,t.length-2)}function Qn(o,t){for(let e=0,n=t.length;e<n;e+=2)o[t[e]]>o[t[e+1]]&&Zn(t,e,e+1)}function Zn(o,t,e){const n=o[t];o[t]=o[e],o[e]=n}function Je(o,t,e,n){let i=e,s=n,r,a;for(;i<n;){for(r=o[t[e+n>>2<<1]];i<=s;){for(;o[t[i]]<r;)i+=2;for(;o[t[s]]>r;)s-=2;i<=s&&(a=t[i],t[i]=t[s],t[s]=a,a=t[i+1],t[i+1]=t[s+1],t[s+1]=a,i+=2,s-=2)}if(s-e<40?$e(o,t,e,s):Je(o,t,e,s),n-i<40){$e(o,t,i,n);return}e=i,s=n}}function $e(o,t,e,n){let i,s;for(let r=e+2;r<=n;r+=2){i=t[r],s=t[r+1];let a;for(a=r-2;a>=e&&o[i]<o[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=i,t[a+3]=s}}function Re(o,t,e,n,i){const s=o[0],r=o[1];t=Ne(s,r,t[0],t[1],n,i),e=Ne(s,r,e[0],e[1],n,i);const a=t[0]<e[0]?t:e,f=a==t?e:t;return{x:s,y:r,a,b:f}}function Ne(o,t,e,n,i,s){let r=e<n?e:n,a=r===e?n:e;return i[r]==o&&s[r]==t?a=r:i[a]==o&&s[a]==t&&(r=a),[r,a]}function He(o){const t={};return o.filter(e=>{const n=ts(e);return n in t?!1:(t[n]=!0,!0)})}function ts(o){return`${o.a.join(",")};${o.b.join(",")}`}class es{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 ns(o,t,e,n){let i=e|0;const s=isNaN(n)?o.length-i:n+i;let r,a,f,h,u,c;if(s>0)f=u=o[i],h=c=t[i];else return[void 0,void 0,void 0,void 0];for(i++;i<s;i++)r=o[i],a=t[i],r<f&&(f=r),r>u&&(u=r),a<h&&(h=a),a>c&&(c=a);return[f,h,u,c]}class oe{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 oe(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,i){return arguments.length==1&&(be(t)?(e=t[1],n=t[2],i=t[3],t=t[0]):(e=t.ymin,n=t.xmax,i=t.ymax,t=t.xmin)),this.xmin=t,this.ymin=e,this.xmax=n,this.ymax=i,(t>n||e>i)&&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,i,s,r;return t instanceof oe?(n=t.xmin,i=t.ymin,s=t.xmax,r=t.ymax):e.length==3?(n=t,i=e[0],s=e[1],r=e[2]):t.length==4?(n=t[0],i=t[1],s=t[2],r=t[3]):me("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(n,i,s,r):(n<this.xmin&&(this.xmin=n),i<this.ymin&&(this.ymin=i),s>this.xmax&&(this.xmax=s),r>this.ymax&&(this.ymax=r)),this}}function Ue(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 Ge(o,t,e){const n=Ue(t.forw),i=Ue(t.bakw);if(JSON.stringify(n)!=JSON.stringify(i))throw`${JSON.stringify(t,null,2)}
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Ct=11102230246251565e-32,rt=134217729,Yn=(3+8*Ct)*Ct;function Yt(s,t,e,n,r){let i,o,a,c,h=t[0],u=n[0],f=0,d=0;u>h==u>-h?(i=h,h=t[++f]):(i=u,u=n[++d]);let y=0;if(f<s&&d<e)for(u>h==u>-h?(o=h+i,a=i-(o-h),h=t[++f]):(o=u+i,a=i-(o-u),u=n[++d]),i=o,a!==0&&(r[y++]=a);f<s&&d<e;)u>h==u>-h?(o=i+h,c=o-i,a=i-(o-c)+(h-c),h=t[++f]):(o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++d]),i=o,a!==0&&(r[y++]=a);for(;f<s;)o=i+h,c=o-i,a=i-(o-c)+(h-c),h=t[++f],i=o,a!==0&&(r[y++]=a);for(;d<e;)o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++d],i=o,a!==0&&(r[y++]=a);return(i!==0||y===0)&&(r[y++]=i),y}function jt(s,t,e,n,r,i,o,a){return Yt(Yt(s,t,e,n,o),o,r,i,a)}function j(s,t,e,n){let r,i,o,a,c,h,u,f,d,y,E;u=rt*e,y=u-(u-e),E=e-y;let k=t[0];r=k*e,u=rt*k,f=u-(u-k),d=k-f,o=d*E-(r-f*y-d*y-f*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,f=u-(u-k),d=k-f,c=d*E-(a-f*y-d*y-f*E),i=r+c,h=i-r,o=r-(i-h)+(c-h),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 Rn(s,t){let e=t[0];for(let n=1;n<s;n++)e+=t[n];return e}function vt(s){return new Float64Array(s)}const Kn=(3+16*Ct)*Ct,Gn=(2+12*Ct)*Ct,Qn=(9+64*Ct)*Ct*Ct,me=vt(4),fn=vt(8),un=vt(12),ln=vt(16),Ft=vt(4);function Hn(s,t,e,n,r,i,o){let a,c,h,u,f,d,y,E,k,X,C,m,v,l,g,x,A,I;const b=s-r,T=e-r,R=t-i,D=n-i;l=b*D,d=rt*b,y=d-(d-b),E=b-y,d=rt*D,k=d-(d-D),X=D-k,g=E*X-(l-y*k-E*k-y*X),x=R*T,d=rt*R,y=d-(d-R),E=R-y,d=rt*T,k=d-(d-T),X=T-k,A=E*X-(x-y*k-E*k-y*X),C=g-A,f=g-C,me[0]=g-(C+f)+(f-A),m=l+C,f=m-l,v=l-(m-f)+(C-f),C=v-x,f=v-C,me[1]=v-(C+f)+(f-x),I=m+C,f=I-m,me[2]=m-(I-f)+(C-f),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f-x),I=m+C,f=I-m,Ft[2]=m-(I-f)+(C-f),Ft[3]=I;const B=Yt(_,un,4,Ft,ln);return ln[B-1]}function te(s,t,e,n,r,i){const o=(t-i)*(e-r),a=(s-r)*(n-i),c=o-a,h=Math.abs(o+a);return Math.abs(c)>=Kn*h?c:-Hn(s,t,e,n,r,i,h)}const Zn=(10+96*Ct)*Ct,tr=(4+48*Ct)*Ct,er=(44+576*Ct)*Ct*Ct,re=vt(4),ie=vt(4),oe=vt(4),Qt=vt(4),Ht=vt(4),Zt=vt(4),Lt=vt(4),Dt=vt(4),Ve=vt(8),We=vt(8),Je=vt(8),Ke=vt(8),Ge=vt(8),Qe=vt(8),Oe=vt(8),Ie=vt(8),Te=vt(8),fe=vt(4),ue=vt(4),le=vt(4),st=vt(8),pt=vt(16),kt=vt(16),St=vt(16),bt=vt(32),se=vt(32),Ot=vt(48),$t=vt(64);let ye=vt(1152),He=vt(1152);function It(s,t,e){s=Yt(s,ye,t,e,He);const n=ye;return ye=He,He=n,s}function nr(s,t,e,n,r,i,o,a,c){let h,u,f,d,y,E,k,X,C,m,v,l,g,x,A,I,b,T,R,D,Q,p,M,_,B,N,Y,w,O,$,q,V,z,K,U;const ct=s-o,ht=e-o,lt=r-o,dt=t-a,gt=n-a,mt=i-a;q=ht*mt,M=rt*ht,_=M-(M-ht),B=ht-_,M=rt*mt,N=M-(M-mt),Y=mt-N,V=B*Y-(q-_*N-B*N-_*Y),z=lt*gt,M=rt*lt,_=M-(M-lt),B=lt-_,M=rt*gt,N=M-(M-gt),Y=gt-N,K=B*Y-(z-_*N-B*N-_*Y),w=V-K,p=V-w,re[0]=V-(w+p)+(p-K),O=q+w,p=O-q,$=q-(O-p)+(w-p),w=$-z,p=$-w,re[1]=$-(w+p)+(p-z),U=O+w,p=U-O,re[2]=O-(U-p)+(w-p),re[3]=U,q=lt*dt,M=rt*lt,_=M-(M-lt),B=lt-_,M=rt*dt,N=M-(M-dt),Y=dt-N,V=B*Y-(q-_*N-B*N-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fe[1]=$-(w+p)+(p-z),U=O+w,p=U-O,fe[2]=O-(U-p)+(w-p),fe[3]=U,b=4):(Oe[0]=0,x=1,fe[0]=0,b=1),d!==0){const xt=j(x,Oe,d,St);h=It(h,Yt(j(l,Ge,d,pt),pt,j(xt,St,2*lt,bt),bt,Ot),Ot);const Mt=j(b,fe,d,st);h=It(h,jt(j(Mt,st,2*lt,pt),pt,j(Mt,st,d,kt),kt,j(xt,St,d,bt),bt,se,$t),$t),y!==0&&(h=It(h,j(j(4,Ht,d,st),st,y,pt),pt)),E!==0&&(h=It(h,j(j(4,Qt,-d,st),st,E,pt),pt))}if(k!==0){const xt=j(x,Oe,k,St);h=It(h,Yt(j(g,Qe,k,pt),pt,j(xt,St,2*mt,bt),bt,Ot),Ot);const Mt=j(b,fe,k,st);h=It(h,jt(j(Mt,st,2*mt,pt),pt,j(Mt,st,k,kt),kt,j(xt,St,k,bt),bt,se,$t),$t)}}return ye[h-1]}function rr(s,t,e,n,r,i,o,a){const c=s-o,h=e-o,u=r-o,f=t-a,d=n-a,y=i-a,E=h*y,k=u*d,X=c*c+f*f,C=u*f,m=c*y,v=h*h+d*d,l=c*d,g=h*f,x=u*u+y*y,A=X*(E-k)+v*(C-m)+x*(l-g),I=(Math.abs(E)+Math.abs(k))*X+(Math.abs(C)+Math.abs(m))*v+(Math.abs(l)+Math.abs(g))*x,b=Zn*I;return A>b||-A>b?A:nr(s,t,e,n,r,i,o,a,I)}function ir(s,t){var e,n,r=0,i,o,a,c,h,u,f,d=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]-d,a=u[1]-y,n;n<X;n++){if(f=k[n+1],c=f[0]-d,h=f[1]-y,a===0&&h===0){if(c<=0&&o>=0||o<=0&&c>=0)return 0}else if(h>=0&&a<=0||h<=0&&a>=0){if(i=te(o,c,a,h,0,0),i===0)return 0;(i>0&&h>0&&a<=0||i<0&&h<=0&&a>0)&&r++}u=f,a=h,o=c}}return r%2!==0}function Pe(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 de(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(!dn(s[0])||!dn(s[1]))throw new Error("coordinates must contain numbers");return Pe({type:"Point",coordinates:s},t,e)}function Be(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 Pe({type:"Polygon",coordinates:s},t,e)}function pn(s,t,e={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return Pe({type:"LineString",coordinates:s},t,e)}function Kt(s,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=s,e}function dn(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}function or(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 sr(s){return s.type==="Feature"?s.geometry:s}function ar(s,t,e={}){if(!s)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=or(s),r=sr(t),i=r.type,o=t.bbox;let a=r.coordinates;if(o&&cr(n,o)===!1)return!1;i==="Polygon"&&(a=[a]);let c=!1;for(var h=0;h<a.length;++h){const u=ir(n,a[h]);if(u===0)return!e.ignoreBoundary;u&&(c=!0)}return c}function cr(s,t){return t[0]<=s[0]&&t[1]<=s[1]&&t[2]>=s[0]&&t[3]>=s[1]}var hr=ar;function on(s,t,e){if(s!==null)for(var n,r,i,o,a,c,h,u=0,f=0,d,y=s.type,E=y==="FeatureCollection",k=y==="Feature",X=E?s.features.length:1,C=0;C<X;C++){h=E?s.features[C].geometry:k?s.geometry:s,d=h?h.type==="GeometryCollection":!1,a=d?h.geometries.length:1;for(var m=0;m<a;m++){var v=0,l=0;if(o=d?h.geometries[m]:h,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,f,C,v,l)===!1)return!1;f++,v++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],f,C,v,l)===!1)return!1;f++,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],f,C,v,l)===!1)return!1;f++}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],f,C,v,l)===!1)return!1;f++}l++}v++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(on(o.geometries[n],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function fr(s,t={}){let e=0,n=0,r=0;return on(s,function(i){e+=i[0],n+=i[1],r++},!0),de([e/r,n/r],t.properties)}var ur=fr;function lr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function pr(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 Ne={exports:{}},$e={exports:{}},dr=$e.exports,mn;function mr(){return mn||(mn=1,(function(s,t){(function(e,n){s.exports=n()})(dr,function(){function e(m,v,l,g,x){(function A(I,b,T,R,D){for(;R>T;){if(R-T>600){var Q=R-T+1,p=b-T+1,M=Math.log(Q),_=.5*Math.exp(2*M/3),B=.5*Math.sqrt(M*_*(Q-_)/Q)*(p-Q/2<0?-1:1),N=Math.max(T,Math.floor(b-p*_/Q+B)),Y=Math.min(R,Math.floor(b+(Q-p)*_/Q+B));A(I,b,N,Y,D)}var w=I[b],O=T,$=R;for(n(I,T,b),D(I[R],w)>0&&n(I,T,R);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,++$,R),$<=b&&(T=$+1),b<=$&&(R=$-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];h(x,m.leaf?g(I):I)}return x}function h(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 f(m,v){return m.minY-v.minY}function d(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 R=o(m,A.children,v);if(R!==-1)return A.children.splice(R,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 R=v;R<=l;R+=T){var D=Math.min(R+T-1,l);C(m,R,D,b,this.compareMinY);for(var Q=R;Q<=D;Q+=b){var p=Math.min(Q+b-1,D);x.children.push(this._build(m,Q,p,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],R=d(T),D=(Q=m,p=T,(Math.max(p.maxX,Q.maxX)-Math.min(p.minX,Q.minX))*(Math.max(p.maxY,Q.maxY)-Math.min(p.minY,Q.minY))-R);D<A?(A=D,x=R<x?R:x,I=T):D===A&&R<x&&(x=R,I=T)}v=I||v.children[0]}var Q,p;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),h(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,R,D=1/0,Q=1/0,p=v;p<=l-v;p++){var M=c(m,0,p,this.toBBox),_=c(m,p,l,this.toBBox),B=(x=M,A=_,I=void 0,b=void 0,T=void 0,R=void 0,I=Math.max(x.minX,A.minX),b=Math.max(x.minY,A.minY),T=Math.min(x.maxX,A.maxX),R=Math.min(x.maxY,A.maxY),Math.max(0,T-I)*Math.max(0,R-b)),N=d(M)+d(_);B<D?(D=B,g=p,Q=N<Q?N:Q):B===D&&N<Q&&(Q=N,g=p)}return g||l-v},i.prototype._chooseSplitAxis=function(m,v,l){var g=m.leaf?this.compareMinX:u,x=m.leaf?this.compareMinY:f;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 R=m.children[T];h(A,m.leaf?x(R):R),b+=y(A)}for(var D=l-v-1;D>=v;D--){var Q=m.children[D];h(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--)h(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})})($e)),$e.exports}let gr=class{constructor(t=[],e=wr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}};function wr(s,t){return s<t?-1:s>t?1:0}const yr=Object.freeze(Object.defineProperty({__proto__:null,default:gr},Symbol.toStringTag,{value:"Module"})),vr=pr(yr);var be={exports:{}},Ze,gn;function br(){return gn||(gn=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,h=0,u=c-1;h<c;u=h++){var f=e[n+h*2+0],d=e[n+h*2+1],y=e[n+u*2+0],E=e[n+u*2+1],k=d>o!=E>o&&i<(y-f)*(o-d)/(E-d)+f;k&&(a=!a)}return a}),Ze}var tn,wn;function _r(){return wn||(wn=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,h=0,u=c-1;h<c;u=h++){var f=e[h+n][0],d=e[h+n][1],y=e[u+n][0],E=e[u+n][1],k=d>o!=E>o&&i<(y-f)*(o-d)/(E-d)+f;k&&(a=!a)}return a}),tn}var yn;function xr(){if(yn)return be.exports;yn=1;var s=br(),t=_r();return be.exports=function(n,r,i,o){return r.length>0&&Array.isArray(r[0])?t(n,r,i,o):s(n,r,i,o)},be.exports.nested=t,be.exports.flat=s,be.exports}var xe={exports:{}},Mr=xe.exports,vn;function kr(){return vn||(vn=1,(function(s,t){(function(e,n){n(t)})(Mr,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,R=0;b>I==b>-I?(l=I,I=X[++T]):(l=b,b=m[++R]);let D=0;if(T<k&&R<C)for(b>I==b>-I?(x=l-((g=I+l)-I),I=X[++T]):(x=l-((g=b+l)-b),b=m[++R]),l=g,x!==0&&(v[D++]=x);T<k&&R<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[++R]),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(;R<C;)x=l-((g=l+b)-(A=g-l))+(b-A),b=m[++R],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,h=11093356479670487e-47,u=o(4),f=o(8),d=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,R,D,Q,p,M){let _,B,N,Y,w,O,$,q,V,z,K,U,ct,ht,lt,dt,gt,mt;const Pt=b-Q,Nt=R-Q,xt=T-p,Mt=D-p;w=(lt=(q=Pt-($=(O=134217729*Pt)-(O-Pt)))*(z=Mt-(V=(O=134217729*Mt)-(O-Mt)))-((ht=Pt*Mt)-$*V-q*V-$*z))-(K=lt-(gt=(q=xt-($=(O=134217729*xt)-(O-xt)))*(z=Nt-(V=(O=134217729*Nt)-(O-Nt)))-((dt=xt*Nt)-$*V-q*V-$*z))),u[0]=lt-(K+w)+(w-gt),w=(ct=ht-((U=ht+K)-(w=U-ht))+(K-w))-(K=ct-dt),u[1]=ct-(K+w)+(w-dt),w=(mt=U+K)-U,u[2]=U-(mt-w)+(K-w),u[3]=mt;let Gt=(function(S,P){let F=P[0];for(let L=1;L<S;L++)F+=P[L];return F})(4,u),ce=c*M;if(Gt>=ce||-Gt>=ce||(_=b-(Pt+(w=b-Pt))+(w-Q),N=R-(Nt+(w=R-Nt))+(w-Q),B=T-(xt+(w=T-xt))+(w-p),Y=D-(Mt+(w=D-Mt))+(w-p),_===0&&B===0&&N===0&&Y===0)||(ce=h*M+r*Math.abs(Gt),(Gt+=Pt*Y+Mt*_-(xt*N+Nt*B))>=ce||-Gt>=ce))return Gt;w=(lt=(q=_-($=(O=134217729*_)-(O-_)))*(z=Mt-(V=(O=134217729*Mt)-(O-Mt)))-((ht=_*Mt)-$*V-q*V-$*z))-(K=lt-(gt=(q=B-($=(O=134217729*B)-(O-B)))*(z=Nt-(V=(O=134217729*Nt)-(O-Nt)))-((dt=B*Nt)-$*V-q*V-$*z))),E[0]=lt-(K+w)+(w-gt),w=(ct=ht-((U=ht+K)-(w=U-ht))+(K-w))-(K=ct-dt),E[1]=ct-(K+w)+(w-dt),w=(mt=U+K)-U,E[2]=U-(mt-w)+(K-w),E[3]=mt;const Ue=i(4,u,4,E,f);w=(lt=(q=Pt-($=(O=134217729*Pt)-(O-Pt)))*(z=Y-(V=(O=134217729*Y)-(O-Y)))-((ht=Pt*Y)-$*V-q*V-$*z))-(K=lt-(gt=(q=xt-($=(O=134217729*xt)-(O-xt)))*(z=N-(V=(O=134217729*N)-(O-N)))-((dt=xt*N)-$*V-q*V-$*z))),E[0]=lt-(K+w)+(w-gt),w=(ct=ht-((U=ht+K)-(w=U-ht))+(K-w))-(K=ct-dt),E[1]=ct-(K+w)+(w-dt),w=(mt=U+K)-U,E[2]=U-(mt-w)+(K-w),E[3]=mt;const ze=i(Ue,f,4,E,d);w=(lt=(q=_-($=(O=134217729*_)-(O-_)))*(z=Y-(V=(O=134217729*Y)-(O-Y)))-((ht=_*Y)-$*V-q*V-$*z))-(K=lt-(gt=(q=B-($=(O=134217729*B)-(O-B)))*(z=N-(V=(O=134217729*N)-(O-N)))-((dt=B*N)-$*V-q*V-$*z))),E[0]=lt-(K+w)+(w-gt),w=(ct=ht-((U=ht+K)-(w=U-ht))+(K-w))-(K=ct-dt),E[1]=ct-(K+w)+(w-dt),w=(mt=U+K)-U,E[2]=U-(mt-w)+(K-w),E[3]=mt;const qt=i(ze,d,4,E,y);return y[qt-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})})})(xe,xe.exports)),xe.exports}var bn;function Sr(){if(bn)return Ne.exports;bn=1;var s=mr(),t=vr,e=xr(),n=kr().orient2d;t.default&&(t=t.default),Ne.exports=r,Ne.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($,q){return $[0]-q[0]},I.compareMinY=function($,q){return $[1]-q[1]},I.load(l);for(var b=[],T=0,R;T<A.length;T++){var D=A[T];I.remove(D),R=E(D,R),b.push(R)}var Q=new s(16);for(T=0;T<b.length;T++)Q.insert(d(b[T]));for(var p=g*g,M=x*x;b.length;){var _=b.shift(),B=_.p,N=_.next.p,Y=k(B,N);if(!(Y<M)){var w=Y/p;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(d(_)),Q.insert(d(_.next)))}}_=R;var O=[];do O.push(_.p),_=_.next;while(_!==R);return O.push(_.p),O}function i(l,g,x,A,I,b,T){for(var R=new t([],o),D=l.data;D;){for(var Q=0;Q<D.children.length;Q++){var p=D.children[Q],M=D.leaf?X(p,x,A):a(x,A,p);M>b||R.push({node:p,dist:M})}for(;R.length&&!R.peek().node.children;){var _=R.pop(),B=_.node,N=X(B,g,x),Y=X(B,A,I);if(_.dist<N&&_.dist<Y&&h(x,B,T)&&h(A,B,T))return B}D=R.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 h(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]),R=x.search({minX:A,minY:I,maxX:b,maxY:T}),D=0;D<R.length;D++)if(f(R[D].p,R[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 f(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 d(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 R=[g,x,A,I],D=R.slice();for(b=0;b<l.length;b++)e(l[b],R)||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 R=((l[0]-A)*b+(l[1]-I)*T)/(b*b+T*T);R>1?(A=x[0],I=x[1]):R>0&&(A+=b*R,I+=T*R)}return b=l[0]-A,T=l[1]-I,b*b+T*T}function C(l,g,x,A,I,b,T,R){var D=x-l,Q=A-g,p=T-I,M=R-b,_=l-I,B=g-b,N=D*D+Q*Q,Y=D*p+Q*M,w=p*p+M*M,O=D*_+Q*B,$=p*_+M*B,q=N*w-Y*Y,V,z,K,U,ct=q,ht=q;q===0?(z=0,ct=1,U=$,ht=w):(z=Y*$-w*O,U=N*$-Y*O,z<0?(z=0,U=$,ht=w):z>ct&&(z=ct,U=$+Y,ht=w)),U<0?(U=0,-O<0?z=0:-O>N?z=ct:(z=-O,ct=N)):U>ht&&(U=ht,-O+Y<0?z=0:-O+Y>N?z=ct:(z=-O+Y,ct=N)),V=z===0?0:z/ct,K=U===0?0:U/ht;var lt=(1-V)*l+V*x,dt=(1-V)*g+V*A,gt=(1-K)*I+K*T,mt=(1-K)*b+K*R,Pt=gt-lt,Nt=mt-dt;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 Ne.exports}var Er=Sr();const Ar=lr(Er);function Pr(s,t={}){t.concavity=t.concavity||1/0;const e=[];if(on(s,r=>{e.push([r[0],r[1]])}),!e.length)return null;const n=Ar(e,t.concavity);return n.length>3?Be([n]):null}var _n=Pr,Me={exports:{}},Br=Me.exports,xn;function Or(){return xn||(xn=1,(function(s,t){(function(e,n){n(t)})(Br,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],ft=L[0],J=0,Z=0;ft>at==ft>-at?(G=at,at=P[++J]):(G=ft,ft=L[++Z]);let ut=0;if(J<S&&Z<F)for(ft>at==ft>-at?(et=at+G,ot=G-(et-at),at=P[++J]):(et=ft+G,ot=G-(et-ft),ft=L[++Z]),G=et,ot!==0&&(tt[ut++]=ot);J<S&&Z<F;)ft>at==ft>-at?(et=G+at,it=et-G,ot=G-(et-it)+(at-it),at=P[++J]):(et=G+ft,it=et-G,ot=G-(et-it)+(ft-it),ft=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+ft,it=et-G,ot=G-(et-it)+(ft-it),ft=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 h=(3+16*n)*n,u=(2+12*n)*n,f=(9+64*n)*n*n,d=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,ft,J,Z,ut,_t,nt,H,W,wt,Et,At,Xt,yt,Bt,Rt;const zt=S-tt,Vt=F-tt,Wt=P-G,Jt=L-G;At=zt*Jt,Z=r*zt,ut=Z-(Z-zt),_t=zt-ut,Z=r*Jt,nt=Z-(Z-Jt),H=Jt-nt,Xt=_t*H-(At-ut*nt-_t*nt-ut*H),yt=Wt*Vt,Z=r*Wt,ut=Z-(Z-Wt),_t=Wt-ut,Z=r*Vt,nt=Z-(Z-Vt),H=Vt-nt,Bt=_t*H-(yt-ut*nt-_t*nt-ut*H),W=Xt-Bt,J=Xt-W,d[0]=Xt-(W+J)+(J-Bt),wt=At+W,J=wt-At,Et=At-(wt-J)+(W-J),W=Et-yt,J=Et-W,d[1]=Et-(W+J)+(J-yt),Rt=wt+W,J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=ot-ut,Z=r*ft,nt=Z-(Z-ft),H=ft-nt,Xt=_t*H-(At-ut*nt-_t*nt-ut*H),yt=it*at,Z=r*it,ut=Z-(Z-it),_t=it-ut,Z=r*at,nt=Z-(Z-at),H=at-nt,Bt=_t*H-(yt-ut*nt-_t*nt-ut*H),W=Xt-Bt,J=Xt-W,X[0]=Xt-(W+J)+(J-Bt),wt=At+W,J=wt-At,Et=At-(wt-J)+(W-J),W=Et-yt,J=Et-W,X[1]=Et-(W+J)+(J-yt),Rt=wt+W,J=Rt-wt,X[2]=wt-(Rt-J)+(W-J),X[3]=Rt;const Jn=o(Wn,E,4,X,k);return k[Jn-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)>=h*at?it:-C(S,P,F,L,tt,G,at)}function v(S,P){var F,L,tt=0,G,et,ot,it,at,ft,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(ft=nt[0],ft[0]!==nt[H][0]&&ft[1]!==nt[H][1])throw new Error("First and last coordinates in a ring must be the same");for(et=ft[0]-Z,ot=ft[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++}ft=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 R(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=R(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 ft=v(L,ot[at]);if(ft===0)return!F.ignoreBoundary;ft&&(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 p=D;function M(S,P){for(let F=0;F<P.features.length;F++)if(p(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,ft=[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])/(ft[0]*J[1]-ft[1]*J[0]),H=(ft[0]*Z[1]-ft[1]*Z[0])/(ft[0]*J[1]-ft[1]*J[0]);if(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),yt=H/(nt+H);At=nt/wt/(Xt/wt+yt/Et),H=H/Et/(Xt/wt+yt/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,ft=F.gridNum,J=F.xOrigin,Z=F.yOrigin,ut=F.xUnit,_t=F.yUnit,nt=F.gridCache,H=Y(at[0],J,ut,ft),W=Y(at[1],Z,_t,ft),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 Y(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 q(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 ft=it.match(/e(\d+)/);if(ft){const J=parseInt(ft[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 ht(S){return!!(S.version||!S.tins&&S.points&&S.tins_points)}function lt(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:Gt(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 dt(S){const P=ce(S),F=P.tins;return{compiled:P,tins:F,points:Ue(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 Gt(S){if(S)return{bakw:A(S.map(P=>g(P)))}}function ce(S){return JSON.parse(JSON.stringify(S).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function Ue(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 ze=ct;class qt{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=qt.YAXIS_INVERT;strictMode=qt.MODE_AUTO;vertexMode=qt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;constructor(){}setCompiled(P){if(ht(P)){this.applyModernState(lt(P));return}this.applyLegacyState(dt(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??qt.YAXIS_INVERT,this.vertexMode=P.vertexMode??qt.VERTEX_PLAIN,this.strictMode=P.strictMode??qt.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,ft=ot.reduce((nt,H,W)=>{const wt=Y(H[0][0],G[0][0],it,tt),Et=Y(H[1][0],G[0][0],it,tt),At=Y(H[0][1],G[0][1],at,tt),Xt=Y(H[1][1],G[0][1],at,tt);for(let yt=wt;yt<=Et;yt++){nt[yt]||(nt[yt]=[]);for(let Bt=At;Bt<=Xt;Bt++)nt[yt][Bt]||(nt[yt][Bt]=[]),nt[yt][Bt].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=Y(H[0][0],et[0][0],Z,tt),Et=Y(H[1][0],et[0][0],Z,tt),At=Y(H[0][1],et[0][1],ut,tt),Xt=Y(H[1][1],et[0][1],ut,tt);for(let yt=wt;yt<=Et;yt++){nt[yt]||(nt[yt]=[]);for(let Bt=At;Bt<=Xt;Bt++)nt[yt][Bt]||(nt[yt][Bt]=[]),nt[yt][Bt].push(W)}return nt},[]);this.indexedTins={forw:{gridNum:tt,xOrigin:G[0][0],yOrigin:G[0][1],xUnit:it,yUnit:at,gridCache:ft},bakw:{gridNum:tt,xOrigin:et[0][0],yOrigin:et[0][1],xUnit:Z,yUnit:ut,gridCache:_t}}}transform(P,F,L){if(F&&this.strict_status==qt.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==qt.YAXIS_FOLLOW&&F&&(P=[P[0],-1*P[1]]);const tt=g(P);if(this.bounds&&!F&&!L&&!p(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 ft,J;this.stateFull&&(this.stateBackward==F?ft=this.stateTriangle:(this.stateBackward=F,this.stateTriangle=void 0),J=ut=>{this.stateTriangle=ut});let Z=N(tt,G,et,ot,it,at,ft,J);if(this.bounds&&F&&!L){const ut=g(Z);if(!p(ut,this.boundsPolygon))return!1}else this.yaxisMode==qt.YAXIS_FOLLOW&&!F&&(Z=[Z[0],-1*Z[1]]);return Z}}e.Transform=qt,e.counterTri=V,e.format_version=ze,e.normalizeEdges=$,e.rotateVerticesTriangle=q,e.transformArr=N,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})})})(Me,Me.exports)),Me.exports}var Ut=Or();const Mn=Math.pow(2,-52),Xe=new Uint32Array(512);class sn{static from(t,e=Yr,n=Rr){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 sn(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,h=-1/0,u=-1/0;for(let b=0;b<o;b++){const T=t[2*b],R=t[2*b+1];T<a&&(a=T),R<c&&(c=R),T>h&&(h=T),R>u&&(u=R),this._ids[b]=b}const f=(a+h)/2,d=(c+u)/2;let y,E,k;for(let b=0,T=1/0;b<o;b++){const R=en(f,d,t[2*b],t[2*b+1]);R<T&&(y=b,T=R)}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 R=en(X,C,t[2*b],t[2*b+1]);R<T&&R>0&&(E=b,T=R)}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=Nr(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 R=0;R<o;R++)this._dists[R]=t[2*R]-t[0]||t[2*R+1]-t[1];we(this._ids,this._dists,0,o-1);const b=new Uint32Array(o);let T=0;for(let R=0,D=-1/0;R<o;R++){const Q=this._ids[R],p=this._dists[Q];p>D&&(b[T++]=Q,D=p)}this.hull=b.subarray(0,T),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(te(X,C,m,v,g,x)<0){const b=E,T=m,R=v;E=k,m=g,v=x,k=b,g=T,x=R}const A=Xr(X,C,m,v,g,x);this._cx=A.x,this._cy=A.y;for(let b=0;b<o;b++)this._dists[b]=en(t[2*b],t[2*b+1],A.x,A.y);we(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,R;b<this._ids.length;b++){const D=this._ids[b],Q=t[2*D],p=t[2*D+1];if(b>0&&Math.abs(Q-T)<=Mn&&Math.abs(p-R)<=Mn||(T=Q,R=p,D===y||D===E||D===k))continue;let M=0;for(let w=0,O=this._hashKey(Q,p);w<this._hashSize&&(M=i[(O+w)%this._hashSize],!(M!==-1&&M!==n[M]));w++);M=e[M];let _=M,B;for(;B=n[_],te(Q,p,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 Y=n[_];for(;B=n[Y],te(Q,p,t[2*Y],t[2*Y+1],t[2*B],t[2*B+1])<0;)N=this._addTriangle(Y,D,B,r[D],-1,r[Y]),r[D]=this._legalize(N+2),n[Y]=Y,I--,Y=B;if(_===M)for(;B=e[_],te(Q,p,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[Y]=D,n[D]=Y,i[this._hashKey(Q,p)]=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(Ir(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=Xe[--i];continue}const h=a-a%3,u=c+(t+1)%3,f=h+(a+2)%3,d=e[o],y=e[t],E=e[u],k=e[f];if(Tr(r[2*d],r[2*d+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]=d;const C=n[f];if(C===-1){let v=this._hullStart;do{if(this._hullTri[v]===f){this._hullTri[v]=t;break}v=this._hullPrev[v]}while(v!==this._hullStart)}this._link(t,C),this._link(a,n[o]),this._link(o,f);const m=h+(a+1)%3;i<Xe.length&&(Xe[i++]=m)}else{if(i===0)break;t=Xe[--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 Ir(s,t){const e=s/(Math.abs(s)+Math.abs(t));return(t>0?3-e:1+e)/4}function en(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function Tr(s,t,e,n,r,i,o,a){const c=s-o,h=t-a,u=e-o,f=n-a,d=r-o,y=i-a,E=c*c+h*h,k=u*u+f*f,X=d*d+y*y;return c*(f*X-k*y)-h*(u*X-k*d)+E*(u*y-f*d)<0}function Nr(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,h=i-t,u=o*o+a*a,f=c*c+h*h,d=.5/(o*h-a*c),y=(h*u-a*f)*d,E=(o*f-c*u)*d;return y*y+E*E}function Xr(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,h=i-t,u=o*o+a*a,f=c*c+h*h,d=.5/(o*h-a*c),y=s+(h*u-a*f)*d,E=t+(o*f-c*u)*d;return{x:y,y:E}}function we(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;_e(s,r,i),t[s[e]]>t[s[n]]&&_e(s,e,n),t[s[i]]>t[s[n]]&&_e(s,i,n),t[s[e]]>t[s[i]]&&_e(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;_e(s,i,o)}s[e+1]=s[o],s[o]=a,n-i+1>=o-e?(we(s,t,i,n),we(s,t,e,o-1)):(we(s,t,e,o-1),we(s,t,i,n))}}function _e(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Yr(s){return s[0]}function Rr(s){return s[1]}class Cr{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 kn extends Cr{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function pe(s){return s%3===2?s-2:s+1}function ee(s){return s%3===0?s+2:s-1}function Sn(s,t,e,n,r,i,o,a){const c=te(s,t,r,i,o,a),h=te(e,n,r,i,o,a);if(c>0&&h>0||c<0&&h<0)return!1;const u=te(r,i,s,t,e,n),f=te(o,a,s,t,e,n);return u>0&&f>0||u<0&&f<0?!1:c===0&&h===0&&u===0&&f===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 Fr{del;constructor(t){this.del=t}}class Lr extends Fr{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 kn(i),this.consd=new kn(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 h=n[o],u=pe(o);if(h===e)return this.protect(o);const f=ee(o),d=n[f];if(d===e)return this.protect(u),u;if(this.intersectSegments(t,e,d,h)){o=f;break}o=r[u]}while(o!==-1&&o!==i);let a=o,c=-1;for(;o!==-1;){const h=r[o],u=ee(o),f=ee(h),d=pe(h);if(h===-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[h]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(n[o],n[h],n[u],n[f])){if(c===-1&&(c=o),n[f]===e){if(o===c)throw new Error("Infinite loop: non-convex quadrilateral");o=c,c=-1;continue}if(this.intersectSegments(t,e,n[f],n[h]))o=f;else if(this.intersectSegments(t,e,n[d],n[f]))o=d;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[f])&&(c===-1&&(c=u),c===u))throw new Error("Infinite loop: flipped diagonal still intersects");n[f]===e?(a=f,o=c,c=-1):this.intersectSegments(t,e,n[d],n[f])&&(o=d)}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=pe(o),o=i[a]}while(o!==-1&&o!==n);return r[pe(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=ee(t),c=pe(t),h=ee(o),u=pe(o),f=n[a],d=n[h];if(i.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[h],n[t]=d,r.set(t,r.has(h))||i.set(t,i.has(h)),d!==-1&&(n[d]=t),n[a]=h,e[o]=e[a],n[o]=f,r.set(o,r.has(a))||i.set(o,i.has(a)),f!==-1&&(n[f]=o),n[h]=a,this.markFlip(t),this.markFlip(c),this.markFlip(o),this.markFlip(u),r.add(a),i.delete(a),r.add(h),i.delete(h),this.updateVert(t),this.updateVert(c),this.updateVert(o),this.updateVert(u),a}isCollinear(t,e,n){const r=this.del.coords;return te(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 rr(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[ee(t)],o=e[t],a=e[pe(t)],c=e[ee(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=ee(t),a=n[o];for(;a!==-1&&a!==t;)o=ee(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:Sn(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=Sn}function ke(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=sn.from(n);let i;const o=[];r.triangles.length!==0&&t.length!==0&&(i=new Lr(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 Kt(o.map(c=>{const h={},u=c.map((f,d)=>{const y=s.features[f],E=y.geometry.coordinates,k=[E[0],E[1]];return E.length===3?k[2]=E[2]:h[a[d]]=y.properties[e],k});return u[3]=u[0],Be([u],h)}))}class Cn{constructor(t=[],e=Dr){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 Dr(s,t){return s<t?-1:s>t?1:0}function Fn(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 $r(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 En{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 qr(s,t){if(s.type==="FeatureCollection"){const e=s.features;for(let n=0;n<e.length;n++)An(e[n],t)}else An(s,t)}let Ye=0,Re=0,Ce=0;function An(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;Re=Re+1;for(let c=0;c<n[r][i].length-1;c++){a=n[r][i][c+1];const h=new En(o,Ye,Re,Ce),u=new En(a,Ye,Re,Ce+1);h.otherEvent=u,u.otherEvent=h,Fn(h,u)>0?(u.isLeftEndpoint=!0,h.isLeftEndpoint=!1):(h.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(h),t.push(u),o=a,Ce=Ce+1}}Ye=Ye+1}class jr{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}}function Ur(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,h=t.rightSweepEvent.p.y,u=(h-a)*(r-e)-(c-o)*(i-n),f=(c-o)*(n-a)-(h-a)*(e-o),d=(r-e)*(n-a)-(i-n)*(e-o);if(u===0)return!1;const y=f/u,E=d/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 zr(s,t){t=t||!1;const e=[],n=new Cn([],$r);for(;s.length;){const r=s.pop();if(r.isLeftEndpoint){const i=new jr(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=Ur(i,a);c!==!1&&e.push(c)}n.push(i)}else r.isLeftEndpoint===!1&&n.pop()}return e}function Vr(s,t){const e=new Cn([],Fn);return qr(s,e),zr(e,t)}var Wr=Vr;function Jr(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(Pe(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(Pe(t));const o=Wr(Kt(i),r);let a=[];if(n){const c={};o.forEach(h=>{const u=h.join(",");c[u]||(c[u]=!0,a.push(h))})}else a=o;return Kt(a.map(c=>de(c)))}var Kr=Jr;function Ln(s,t,e,n,r,i){return Object.keys(s).reduce((o,a)=>{const c=s[a],h=c.forw,u=c.bakw,f={forw:[h[0]-t.forw[0],h[1]-t.forw[1]],bakw:[u[0]-t.bakw[0],u[1]-t.bakw[1]]},d=f.forw[0]===0?1/0:((f.forw[0]<0?e:n)-t.forw[0])/f.forw[0],y=f.forw[1]===0?1/0:((f.forw[1]<0?r:i)-t.forw[1])/f.forw[1];if(Math.abs(d)/Math.abs(y)<1.1){const E={forw:[f.forw[0]*d+t.forw[0],f.forw[1]*d+t.forw[1]],bakw:[f.bakw[0]*d+t.bakw[0],f.bakw[1]*d+t.bakw[1]]};f.forw[0]<0?o[3].push(E):o[1].push(E)}if(Math.abs(y)/Math.abs(d)<1.1){const E={forw:[f.forw[0]*y+t.forw[0],f.forw[1]*y+t.forw[1]],bakw:[f.bakw[0]*y+t.bakw[0],f.bakw[1]*y+t.bakw[1]]};f.forw[1]<0?o[0].push(E):o[2].push(E)}return o},[[],[],[],[]])}function Gr(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]],h=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:c,bakw:h};if(n.push(u),c[0]===0||c[1]===0)return;let f=0;c[0]>0&&(f+=1),c[1]>0&&(f+=2),e[f].push(u)}),{perQuad:e,aggregate:n}}function Qr(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 h=a/c,u=Math.atan2(i[0],i[1])-Math.atan2(o[0],o[1]);t=Math.min(t,h),e+=Math.cos(u),n+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(n,e)]:[1,0]}function Dn(s,t,e){const{perQuad:n,aggregate:r}=Gr(s,t),i=n.every(c=>c.length>0),a=(e==="birdeye"?i?n:[r]:[r]).map(c=>Qr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Hr(s,t,e){const n=[1,1,1,1];for(let r=0;r<4;r++){const i=(r+1)%4,o=pn([s[r].bakw,s[i].bakw]);t[r].map(a=>{const c=pn([e.bakw,a.bakw]),h=Kr(o,c);if(h.features.length>0&&h.features[0].geometry){const u=h.features[0],f=Math.sqrt(Math.pow(a.bakw[0]-e.bakw[0],2)+Math.pow(a.bakw[1]-e.bakw[1],2)),d=Math.sqrt(Math.pow(u.geometry.coordinates[0]-e.bakw[0],2)+Math.pow(u.geometry.coordinates[1]-e.bakw[1],2)),y=f/d;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 $n(s,t,e,n){const r=s.map((o,a)=>{const c=t[a],h=[c[0]-e.forw[0],c[1]-e.forw[1]],f=Math.sqrt(Math.pow(h[0],2)+Math.pow(h[1],2))/o[0],d=Math.atan2(h[0],h[1])-o[1],y=[e.bakw[0]+f*Math.sin(d),e.bakw[1]-f*Math.cos(d)];return{forw:c,bakw:y}}),i=r[2];return r[2]=r[3],r[3]=i,Hr(r,n,e),r}function Zr(s){const{convexBuf:t,centroid:e,bbox:n,minx:r,maxx:i,miny:o,maxy:a}=s,c=Ln(t,e,r,i,o,a),h=Dn(t,e,"plain");return $n(h,n,e,c)}function ti(s){const{convexBuf:t,centroid:e,bbox:n,minx:r,maxx:i,miny:o,maxy:a}=s,c=Ln(t,e,r,i,o,a),h=Dn(t,e,"birdeye");return $n(h,n,e,c)}function qn(s){const e=new ei(s).findSegmentIntersections(),n=zn(e),r=new Map;return n.forEach(i=>{r.set(`${i.x}:${i.y}`,i)}),Array.from(r.values()).map(i=>de([i.x,i.y]))}class ei{_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)&&an("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new _i(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,h,u;for(let f=0;f<r;f++)c=n[f],c>0&&(h=f*4,u=xi(t,e,a,c),i[h++]=u[0],i[h++]=u[1],i[h++]=u[2],i[h]=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,h=c,u=0;for(let f=1;f<o;f++)h+=a,(i===0||this._zz[h]>=i)&&(e(c,h,this._xx,this._yy),c=h,u++);return u}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(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 h=this.getUint32Array(ii(i));let u=0;const f=[];oi(i,k=>{const X=u;u+=k,f.push(h.subarray(X,u))}),si(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=f[v],x[g]=k,x[g+1]=X,v!=l;)v+=l>v?1:-1});const d=this.getVertexData(),y=[];let E;for(a=0;a<r;a++)for(E=ai(f[a],d.xx,d.yy),c=0;c<E.length;c++)y.push(E[c]);return zn(y)}}function an(...s){const t=s.join(" ");throw new Error(t)}function cn(s){return s?ri(s)?!0:ni(s)?!1:s.length===0?!0:s.length>0:!1}function ni(s){return s!=null&&s.toString===String.prototype.toString}function ri(s){return Array.isArray(s)}function ii(s,t){cn(s)||an("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 oi(s,t,e){if(!cn(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 si(s,t){for(let e=0,n=s.length;e<n;e++)s[e]=t;return s}function ai(s,t,e){const n=s.length-2,r=[];let i,o,a,c,h,u,f,d,y,E,k,X,C,m,v,l,g;for(wi(t,s),l=0;l<n;){for(i=s[l],o=s[l+1],h=t[i],u=t[o],y=e[i],E=e[o],g=l;g<n&&(g+=2,a=s[g],f=t[a],!(u<f));){if(k=e[a],c=s[g+1],d=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=ci(h,y,u,E,f,k,d,X),C&&(m=[i,o],v=[a,c],r.push(Bn(C,m,v,t,e)),C.length==4&&r.push(Bn(C.slice(2),m,v,t,e))))}l+=2}return r}function ci(s,t,e,n,r,i,o,a){const c=hi(s,t,e,n,r,i,o,a);let h=null;return c&&(h=fi(s,t,e,n,r,i,o,a),h?gi(s,t,e,n,r,i,o,a)&&(h=null):h=mi(s,t,e,n,r,i,o,a)),h}function hi(s,t,e,n,r,i,o,a){return Se(s,t,e,n,r,i)*Se(s,t,e,n,o,a)<=0&&Se(r,i,o,a,s,t)*Se(r,i,o,a,e,n)<=0}function Se(s,t,e,n,r,i){return jn(s-r,t-i,e-r,n-i)}function jn(s,t,e,n){return s*n-t*e}function fi(s,t,e,n,r,i,o,a){let c=Fe(s,t,e,n,r,i,o,a),h;return c&&(h=li(c[0],c[1],s,t,e,n,r,i,o,a),h==1?c=Fe(e,n,s,t,r,i,o,a):h==2?c=Fe(r,i,o,a,s,t,e,n):h==3&&(c=Fe(o,a,r,i,s,t,e,n))),c&&di(c,s,t,e,n,r,i,o,a),c}function Fe(s,t,e,n,r,i,o,a){const c=jn(e-s,n-t,o-r,a-i),h=1e-18;let u;if(c===0)return null;const f=Se(r,i,o,a,s,t)/c;return c<=h&&c>=-h?u=ui(s,t,e,n,r,i,o,a):u=[s+f*(e-s),t+f*(n-t)],u}function ui(s,t,e,n,r,i,o,a){let c=null;return!ne(s,r,o)&&!ne(t,i,a)?c=[s,t]:!ne(e,r,o)&&!ne(n,i,a)?c=[e,n]:!ne(r,s,e)&&!ne(i,t,n)?c=[r,i]:!ne(o,s,e)&&!ne(a,t,n)&&(c=[o,a]),c}function ne(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 li(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=pi(s,t,e[a],e[a+1]),i<r&&(r=i,n=o);return n}function pi(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function di(s,t,e,n,r,i,o,a,c){let h=s[0],u=s[1];h=Le(h,t,n),h=Le(h,i,a),u=Le(u,e,r),u=Le(u,o,c),s[0]=h,s[1]=u}function Le(s,t,e){let n;return ne(s,t,e)&&(n=Math.abs(s-t)<Math.abs(s-e)?t:e,s=n),s}function mi(s,t,e,n,r,i,o,a){const c=Math.min(s,e,r,o),h=Math.max(s,e,r,o),u=Math.min(t,n,i,a),f=Math.max(t,n,i,a),d=f-u>h-c;let y=[];return(d?ae(t,u,f):ae(s,c,h))&&y.push(s,t),(d?ae(n,u,f):ae(e,c,h))&&y.push(e,n),(d?ae(i,u,f):ae(r,c,h))&&y.push(r,i),(d?ae(a,u,f):ae(o,c,h))&&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 gi(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 ae(s,t,e){return s>t&&s<e}function wi(s,t){yi(s,t),Un(s,t,0,t.length-2)}function yi(s,t){for(let e=0,n=t.length;e<n;e+=2)s[t[e]]>s[t[e+1]]&&vi(t,e,e+1)}function vi(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Un(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?Pn(s,t,e,i):Un(s,t,e,i),n-r<40){Pn(s,t,r,n);return}e=r,i=n}}function Pn(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 Bn(s,t,e,n,r){const i=s[0],o=s[1];t=On(i,o,t[0],t[1],n,r),e=On(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 On(s,t,e,n,r,i){let o=e<n?e:n,a=o===e?n:e;return r[o]==s&&i[o]==t?a=o:r[a]==s&&i[a]==t&&(o=a),[o,a]}function zn(s){const t={};return s.filter(e=>{const n=bi(e);return n in t?!1:(t[n]=!0,!0)})}function bi(s){return`${s.a.join(",")};${s.b.join(",")}`}class _i{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,e){this._xx=t,this._yy=e}}function xi(s,t,e,n){let r=e|0;const i=isNaN(n)?s.length-r:n+r;let o,a,c,h,u,f;if(i>0)c=u=s[r],h=f=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<h&&(h=a),a>f&&(f=a);return[c,h,u,f]}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&&(cn(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]):an("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 hn(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(i)}`;for(let s=0;s<n.length;s++){const r=n[s];o[r]||(o[r]=[]),o[r].push(t)}e&&(e.forw.features.push(t.forw),e.bakw.features.push(t.bakw))}function Ht(o,t,e){return ft.point(o,{target:{geom:t,index:e}})}function Gt(o){return ft.point(o.properties.target.geom,{target:{geom:o.geometry.coordinates,index:o.properties.target.index}})}function we(o,t){const e=t.geometry.coordinates;return[0,1,2,3].map(n=>{const i=(n+1)%4,s=o[n],r=o[i],a=s.geometry.coordinates,f=Math.atan2(a[0]-e[0],a[1]-e[1]),h=[t,s,r,t].map(l=>l.geometry.coordinates),u={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:s.properties.target.geom,index:s.properties.target.index},c:{geom:r.properties.target.geom,index:r.properties.target.index}},c=ft.featureCollection([ft.polygon([h],u)]);return[f,c]}).reduce((n,i)=>(n[0].push(i[0]),n[1].push(i[1]),n),[[],[]])}const Be=re;class ot extends _n{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||ot.VERTEX_PLAIN),this.strictMode=e.strictMode||ot.MODE_AUTO,this.yaxisMode=e.yaxisMode||ot.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 Be}setPoints(e){this.yaxisMode===ot.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=Le(e),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(e){this.bounds=e;let n=e[0][0],i=n,s=e[0][1],r=s;const a=[e[0]];for(let f=1;f<e.length;f++){const h=e[f];h[0]<n&&(n=h[0]),h[0]>i&&(i=h[0]),h[1]<s&&(s=h[1]),h[1]>r&&(r=h[1]),a.push(h)}a.push(e[0]),this.boundsPolygon=ft.polygon([a]),this.xy=[n,s],this.wh=[i-n,r-s],this.vertexMode=ot.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){var i;const e={};e.version=Be,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(s=>{const r=n[s].features[0],a=r.geometry.coordinates[0][1],f=r.properties.b.geom;e.vertices_points[s]=[a,f]}),e.strict_status=this.strict_status,e.tins_points=[[]],this.tins.forw.features.map(s=>{e.tins_points[0].push(["a","b","c"].map(r=>s.properties[r].index))}),this.strict_status===ot.STATUS_LOOSE?(e.tins_points[1]=[],this.tins.bakw.features.map(s=>{e.tins_points[1].push(["a","b","c"].map(r=>s.properties[r].index))})):this.strict_status===ot.STATUS_ERROR&&((i=this.kinks)!=null&&i.bakw)&&(e.kinks_points=this.kinks.bakw.features.map(s=>s.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(s=>bn(s));this.tins.bakw=ft.featureCollection(e);const n={};this.tins.forw.features.forEach((s,r)=>{const a=this.tins.bakw.features[r];Ge(n,{forw:s,bakw:a})});const i=["forw","bakw"].map(s=>{const r=this.tins[s].features.map(a=>a.geometry.coordinates[0]);return qe(r)});i[0].length===0&&i[1].length===0?(this.strict_status=ot.STATUS_STRICT,delete this.kinks):(this.strict_status=ot.STATUS_ERROR,this.kinks={},i[0].length>0&&(this.kinks.forw=ft.featureCollection(i[0])),i[1].length>0&&(this.kinks.bakw=ft.featureCollection(i[1])))}generatePointsSet(){const e={forw:[],bakw:[]};for(let s=0;s<this.points.length;s++){const r=this.points[s][0],a=this.points[s][1],f=Ht(r,a,s);e.forw.push(f),e.bakw.push(Gt(f))}const n=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let s=0;s<this.edges.length;s++){const r=this.edges[s][2],a=Object.assign([],this.edges[s][0]),f=Object.assign([],this.edges[s][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[i]=[u[0],u[1]];const p=Ht(u[0],u[1],`e${i}`);i++,e.forw.push(p),e.bakw.push(Gt(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],i=this.xy[1]-.05*this.wh[1],s=this.xy[1]+1.05*this.wh[1];if(!this.points.reduce((f,h)=>f&&(this.bounds?Ze(h[0],this.boundsPolygon):h[0][0]>=e&&h[0][0]<=n&&h[0][1]>=i&&h[0][1]<=s),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[e,i],[n,i],[e,s],[n,s]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:e,maxx:n,miny:i,maxy:s}}updateTin(){let e=this.strictMode;e!==ot.MODE_STRICT&&e!==ot.MODE_LOOSE&&(e=ot.MODE_AUTO);const{pointsSet:n,bbox:i,minx:s,maxx:r,miny:a,maxy:f}=this.validateAndPrepareInputs(),h={forw:ft.featureCollection(n.forw),bakw:ft.featureCollection(n.bakw)},u=Yt(h.forw,n.edges,"target"),c=Yt(h.bakw,n.edges,"target");if(u.features.length===0||c.features.length===0)throw"TOO LINEAR1";const l=tn(h.forw),p=ye(h.forw);if(!p)throw"TOO LINEAR2";const y={},g=p.geometry.coordinates[0];let b;try{b=g.map(N=>({forw:N,bakw:ie(ft.point(N),u)})),b.forEach(N=>{y[`${N.forw[0]}:${N.forw[1]}`]=N})}catch{throw"TOO LINEAR2"}const w=ye(h.bakw);if(!w)throw"TOO LINEAR2";const M=w.geometry.coordinates[0];try{b=M.map(N=>({bakw:N,forw:ie(ft.point(N),c)})),b.forEach(N=>{y[`${N.forw[0]}:${N.forw[1]}`]=N})}catch{throw"TOO LINEAR2"}const _={forw:l.geometry.coordinates,bakw:ie(l,u)},v=Ht(_.forw,_.bakw,"c");this.centroid={forw:v,bakw:Gt(v)};const T=this.vertexMode===ot.VERTEX_BIRDEYE?this.calculateBirdeyeVertices(y,_,i,s,r,a,f):this.calculatePlainVertices(y,_,i,s,r,a,f),I={forw:[],bakw:[]};for(let N=0;N<T.length;N++){const V=T[N].forw,W=T[N].bakw,G=Ht(V,W,`b${N}`),tt=Gt(G);n.forw.push(G),n.bakw.push(tt),I.forw.push(G),I.bakw.push(tt)}this.pointsSet={forw:ft.featureCollection(n.forw),bakw:ft.featureCollection(n.bakw),edges:[]},this.tins={forw:Ae(Yt(this.pointsSet.forw,n.edges,"target"))},(e===ot.MODE_STRICT||e===ot.MODE_AUTO)&&this.calcurateStrictTin(),(e===ot.MODE_LOOSE||e===ot.MODE_AUTO&&this.strict_status===ot.STATUS_ERROR)&&(this.tins.bakw=Ae(Yt(this.pointsSet.bakw,n.edges,"target")),delete this.kinks,this.strict_status=ot.STATUS_LOOSE),this.vertices_params={forw:we(I.forw,this.centroid.forw),bakw:we(I.bakw,this.centroid.bakw)},this.addIndexedTin(),this.calculatePointsWeight()}calculatePlainVertices(e,n,i,s,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?s: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,G,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 it=Math.atan2(W[0][0],W[0][1])-Math.atan2(W[1][0],W[1][1]),d=V[1]+Math.cos(it),m=V[2]+Math.sin(it);return G===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=i[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,i,s,r,a,f){return this.calculatePlainVertices(e,n,i,s,r,a,f)}checkAndAdjustVertices(e,n,i){const s=[1,1,1,1];for(let r=0;r<4;r++){const a=(r+1)%4,f=ft.lineString([e[r].bakw,e[a].bakw]);n[r].map(h=>{const u=ft.lineString([i.bakw,h.bakw]),c=en(f,u);if(c.features.length>0&&c.features[0].geometry){const l=c.features[0],p=Math.sqrt(Math.pow(h.bakw[0]-i.bakw[0],2)+Math.pow(h.bakw[1]-i.bakw[1],2)),y=Math.sqrt(Math.pow(l.geometry.coordinates[0]-i.bakw[0],2)+Math.pow(l.geometry.coordinates[1]-i.bakw[1],2)),g=p/y;g>s[r]&&(s[r]=g),g>s[a]&&(s[a]=g)}})}e.forEach((r,a)=>{const f=s[a],h=[(r.bakw[0]-i.bakw[0])*f+i.bakw[0],(r.bakw[1]-i.bakw[1])*f+i.bakw[1]];r.bakw=h})}calculatePointsWeight(){const e=["forw"];this.strict_status===ot.STATUS_LOOSE&&e.push("bakw");const n={};e.forEach(s=>{n[s]={};const r={};this.tins[s].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[s]||(n[s]={});const T=n[s];T[`${p}:${g}`]=v,T[`${y}:${g}`]=v}}})});const i={};e.map(s=>{i[s]={},this.strict_status===ot.STATUS_STRICT&&(i.bakw={});const r=n[s],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;i[s]||(i[s]={}),i[s][h]=c,this.strict_status===ot.STATUS_STRICT&&(i.bakw||(i.bakw={}),i.bakw[h]=1/c)});let f=0;for(let h=0;h<4;h++){const u=`b${h}`,c=i[s][u]||0;f+=c}i[s].c=f/4,this.strict_status===ot.STATUS_STRICT&&i.bakw&&(i.bakw.c=1/i[s].c)}),this.pointsWeightBuffer=i}}exports.Tin=ot;exports.constrainedTin=Yt;exports.counterPoint=Gt;exports.createPoint=Ht;exports.findIntersections=qe;exports.format_version=re;exports.insertSearchIndex=Ge;exports.vertexCalc=we;
|
|
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 In(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 Ee(s,t,e){return de(s,{target:{geom:t,index:e}})}function Ae(s){return de(s.properties.target.geom,{target:{geom:s.geometry.coordinates,index:s.properties.target.index}})}function nn(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]),h=[t,i,o,t].map(d=>d.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}},f=Kt([Be([h],u)]);return[c,f]}).reduce((n,r)=>(n[0].push(r[0]),n[1].push(r[1]),n),[[],[]])}function Mi(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(h=>{const u=["a","b","c"];for(let f=0;f<3;f++){const d=(f+1)%3,y=u[f],E=u[d],k=h.properties[y].index,X=h.properties[E].index,C=[k,X].sort().join("-");if(c[C])continue;c[C]=!0;const m=h.geometry.coordinates[0][f],v=h.geometry.coordinates[0][d],l=h.properties[y].geom,g=h.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[f]=u.split(":");c[f]||(c[f]=[]),c[f].push(a[u])}),Object.keys(c).forEach(u=>{const f=c[u],d=f.reduce((y,E)=>y+E,0)/f.length;i[o][u]=d,n&&i.bakw&&(i.bakw[u]=1/d)});let h=0;for(let u=0;u<4;u++){const f=`b${u}`,d=i[o][f]||0;h+=d}i[o].c=h/4,n&&i.bakw&&(i.bakw.c=1/i[o].c)}),i}function ki(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,h)=>c-h);return a[0]===n&&a[1]===r})}function De(s){return["a","b","c"].map((t,e)=>({prop:s.properties[t],geom:s.geometry.coordinates[0][e]}))}function Si(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||ki(o,e))continue;const h=De(a[0].bakw),u=De(a[1].bakw),f=De(a[0].forw),d=De(a[1].forw),y=c.map(b=>h.find(T=>`${T.prop.index}`===b)||u.find(T=>`${T.prop.index}`===b)),E=c.map(b=>f.find(T=>`${T.prop.index}`===b)||d.find(T=>`${T.prop.index}`===b));if(y.some(b=>!b)||E.some(b=>!b))continue;const k=[h,u].map(b=>b.find(T=>!c.includes(`${T.prop.index}`))),X=[f,d].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=>ge(b)),m=a[1].bakw.geometry.coordinates[0].slice(0,3).map(b=>ge(b));if(!(Tn(ge(k[0].geom),m)||Tn(ge(k[1].geom),C)))continue;const l=E.map(b=>ge(b.geom)),g=X.map(b=>ge(b.geom)),x=Ei([...l,...g]),A=Ai(x),I=Nn(l[0],l[1],g[0])+Nn(l[0],l[1],g[1]);rn(A,I)&&(In(t,a[0],s),In(t,a[1],s),y.forEach(b=>{if(!b)return;const T=[b.geom,k[0].geom,k[1].geom,b.geom],R={a:b.prop,b:k[0].prop,c:k[1].prop},D=Be([T],R),Q=Ut.counterTri(D);hn(t,{forw:Q,bakw:D},s)}),r=!0)}return r}function ge(s){return[s[0],s[1]]}function Tn(s,t){const[e,n]=t[0],[r,i]=t[1],[o,a]=t[2],c=o-e,h=a-n,u=r-e,f=i-n,d=s[0]-e,y=s[1]-n,E=c*c+h*h,k=c*u+h*f,X=c*d+h*y,C=u*u+f*f,m=u*d+f*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 Ei(s){const t=s.map(o=>o.slice()).filter((o,a,c)=>c.findIndex(h=>rn(h[0],o[0])&&rn(h[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 Ai(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 Nn(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 rn(s,t,e=1e-9){return Math.abs(s-t)<=e}const Pi=2.00703,Xn=typeof Ut.format_version<"u"?Ut.format_version:Pi;class Tt extends Ut.Transform{importance;priority;pointsSet;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||Tt.VERTEX_PLAIN),this.strictMode=t.strictMode||Tt.MODE_AUTO,this.yaxisMode=t.yaxisMode||Tt.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return Xn}setPoints(t){this.yaxisMode===Tt.YAXIS_FOLLOW&&(t=t.map(e=>[e[0],[e[1][0],-1*e[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Ut.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let e=t[0][0],n=e,r=t[0][1],i=r;const o=[t[0]];for(let a=1;a<t.length;a++){const c=t[a];c[0]<e&&(e=c[0]),c[0]>n&&(n=c[0]),c[1]<r&&(r=c[1]),c[1]>i&&(i=c[1]),o.push(c)}o.push(t[0]),this.boundsPolygon=Be([o]),this.xy=[e,r],this.wh=[n-e,i-r],this.vertexMode=Tt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=Xn,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===Tt.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===Tt.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=>Ut.counterTri(r));this.tins.bakw=Kt(t);const e={};this.tins.forw.features.forEach((r,i)=>{const o=this.tins.bakw.features[i];hn(e,{forw:r,bakw:o})}),Si(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 qn(i)});n[0].length===0&&n[1].length===0?(this.strict_status=Tt.STATUS_STRICT,delete this.kinks):(this.strict_status=Tt.STATUS_ERROR,this.kinks={forw:Kt(n[0]),bakw:Kt(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=Ee(i,o,r);t.forw.push(a),t.bakw.push(Ae(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(h=>{const u=h.map((d,y,E)=>{if(y===0)return 0;const k=E[y-1];return Math.sqrt(Math.pow(d[0]-k[0],2)+Math.pow(d[1]-k[1],2))}),f=u.reduce((d,y,E)=>E===0?[0]:(d.push(d[E-1]+y),d),[]);return f.map((d,y,E)=>{const k=d/E[E.length-1];return[h[y],u[y],f[y],k]})});c.map((h,u)=>{const f=c[u?0:1];return h.filter((d,y)=>!(y===0||y===h.length-1||d[4]==="handled")).map(d=>{const y=d[0],E=d[3],k=f.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((h,u)=>h.concat(u),[]).sort((h,u)=>h[2]<u[2]?-1:1).map((h,u,f)=>{this.edgeNodes[n]=[h[0],h[1]];const d=Ee(h[0],h[1],`e${n}`);n++,t.forw.push(d),t.bakw.push(Ae(d)),u===0?e.push([i[0],t.forw.length-1]):e.push([t.forw.length-2,t.forw.length-1]),u===f.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?hr(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!==Tt.MODE_STRICT&&t!==Tt.MODE_LOOSE&&(t=Tt.MODE_AUTO);const{pointsSet:e,bbox:n,minx:r,maxx:i,miny:o,maxy:a}=this.validateAndPrepareInputs(),c={forw:Kt(e.forw),bakw:Kt(e.bakw)},h=ke(c.forw,e.edges,"target"),u=ke(c.bakw,e.edges,"target");if(h.features.length===0||u.features.length===0)throw"TOO LINEAR1";const f=ur(c.forw),d=_n(c.forw);if(!d)throw"TOO LINEAR2";const y={},E=d.geometry.coordinates[0];let k;try{k=E.map(b=>({forw:b,bakw:Ut.transformArr(de(b),h)})),k.forEach(b=>{y[`${b.forw[0]}:${b.forw[1]}`]=b})}catch{throw"TOO LINEAR2"}const X=_n(c.bakw);if(!X)throw"TOO LINEAR2";const C=X.geometry.coordinates[0];try{k=C.map(b=>({bakw:b,forw:Ut.transformArr(de(b),u)})),k.forEach(b=>{y[`${b.forw[0]}:${b.forw[1]}`]=b})}catch{throw"TOO LINEAR2"}const m={forw:f.geometry.coordinates,bakw:Ut.transformArr(f,h)},v=Ee(m.forw,m.bakw,"c");this.centroid={forw:v,bakw:Ae(v)};const l={convexBuf:y,centroid:m,bbox:n,minx:r,maxx:i,miny:o,maxy:a},g=this.vertexMode===Tt.VERTEX_BIRDEYE?ti(l):Zr(l),x={forw:[],bakw:[]};for(let b=0;b<g.length;b++){const T=g[b].forw,R=g[b].bakw,D=Ee(T,R,`b${b}`),Q=Ae(D);e.forw.push(D),e.bakw.push(Q),x.forw.push(D),x.bakw.push(Q)}this.pointsSet={forw:Kt(e.forw),bakw:Kt(e.bakw),edges:e.edges},this.tins={forw:Ut.rotateVerticesTriangle(ke(this.pointsSet.forw,e.edges,"target"))},(t===Tt.MODE_STRICT||t===Tt.MODE_AUTO)&&this.calcurateStrictTin(),(t===Tt.MODE_LOOSE||t===Tt.MODE_AUTO&&this.strict_status===Tt.STATUS_ERROR)&&(this.tins.bakw=Ut.rotateVerticesTriangle(ke(this.pointsSet.bakw,e.edges,"target")),delete this.kinks,this.strict_status=Tt.STATUS_LOOSE),this.vertices_params={forw:nn(x.forw,this.centroid.forw),bakw:nn(x.bakw,this.centroid.bakw)},this.addIndexedTin();const A=["forw"];this.strict_status===Tt.STATUS_LOOSE&&A.push("bakw");const I=this.strict_status===Tt.STATUS_STRICT;this.pointsWeightBuffer=Mi({tins:this.tins,targets:A,includeReciprocals:I})}async updateTinAsync(){this.updateTin()}}exports.Tin=Tt;exports.constrainedTin=ke;exports.counterPoint=Ae;exports.createPoint=Ee;exports.default=Tt;exports.findIntersections=qn;exports.format_version=Ut.format_version;exports.insertSearchIndex=hn;exports.vertexCalc=nn;
|