@maplat/tin 1.0.0-rc1 → 1.0.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.
@@ -1,5 +1,5 @@
1
- (function(yt,It){typeof exports=="object"&&typeof module<"u"?It(exports):typeof define=="function"&&define.amd?define(["exports"],It):(yt=typeof globalThis<"u"?globalThis:yt||self,It(yt.tin={}))})(this,(function(yt){"use strict";function It(n,t,e={}){const i={type:"Feature"};return(e.id===0||e.id)&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.properties=t||{},i.geometry=n,i}function Nt(n,t,e={}){if(!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ge(n[0])||!Ge(n[1]))throw new Error("coordinates must contain numbers");return It({type:"Point",coordinates:n},t,e)}function Jt(n,t,e={}){for(const o of n){if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(o[o.length-1].length!==o[0].length)throw new Error("First and last Position are not equivalent.");for(let r=0;r<o[o.length-1].length;r++)if(o[o.length-1][r]!==o[0][r])throw new Error("First and last Position are not equivalent.")}return It({type:"Polygon",coordinates:n},t,e)}function We(n,t,e={}){if(n.length<2)throw new Error("coordinates must be an array of two or more positions");return It({type:"LineString",coordinates:n},t,e)}function _t(n,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=n,e}function Ge(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function zn(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return[...n.geometry.coordinates];if(n.type==="Point")return[...n.coordinates]}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return[...n];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Wn(n){return n.type==="Feature"?n.geometry:n}function _e(n,t,e){if(n!==null)for(var i,o,r,s,a,c,f,l=0,h=0,u,p=n.type,x=p==="FeatureCollection",y=p==="Feature",k=x?n.features.length:1,S=0;S<k;S++){f=x?n.features[S].geometry:y?n.geometry:n,u=f?f.type==="GeometryCollection":!1,a=u?f.geometries.length:1;for(var g=0;g<a;g++){var v=0,d=0;if(s=u?f.geometries[g]:f,s!==null){c=s.coordinates;var b=s.type;switch(l=e&&(b==="Polygon"||b==="MultiPolygon")?1:0,b){case null:break;case"Point":if(t(c,h,S,v,d)===!1)return!1;h++,v++;break;case"LineString":case"MultiPoint":for(i=0;i<c.length;i++){if(t(c[i],h,S,v,d)===!1)return!1;h++,b==="MultiPoint"&&v++}b==="LineString"&&v++;break;case"Polygon":case"MultiLineString":for(i=0;i<c.length;i++){for(o=0;o<c[i].length-l;o++){if(t(c[i][o],h,S,v,d)===!1)return!1;h++}b==="MultiLineString"&&v++,b==="Polygon"&&d++}b==="Polygon"&&v++;break;case"MultiPolygon":for(i=0;i<c.length;i++){for(d=0,o=0;o<c[i].length;o++){for(r=0;r<c[i][o].length-l;r++){if(t(c[i][o][r],h,S,v,d)===!1)return!1;h++}d++}v++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(_e(s.geometries[i],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const ut=11102230246251565e-32,U=134217729,Je=(3+8*ut)*ut;function ht(n,t,e,i,o){let r,s,a,c,f=t[0],l=i[0],h=0,u=0;l>f==l>-f?(r=f,f=t[++h]):(r=l,l=i[++u]);let p=0;if(h<n&&u<e)for(l>f==l>-f?(s=f+r,a=r-(s-f),f=t[++h]):(s=l+r,a=r-(s-l),l=i[++u]),r=s,a!==0&&(o[p++]=a);h<n&&u<e;)l>f==l>-f?(s=r+f,c=s-r,a=r-(s-c)+(f-c),f=t[++h]):(s=r+l,c=s-r,a=r-(s-c)+(l-c),l=i[++u]),r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+f,c=s-r,a=r-(s-c)+(f-c),f=t[++h],r=s,a!==0&&(o[p++]=a);for(;u<e;)s=r+l,c=s-r,a=r-(s-c)+(l-c),l=i[++u],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function xt(n,t,e,i,o,r,s,a){return ht(ht(n,t,e,i,s),s,o,r,a)}function Y(n,t,e,i){let o,r,s,a,c,f,l,h,u,p,x;l=U*e,p=l-(l-e),x=e-p;let y=t[0];o=y*e,l=U*y,h=l-(l-y),u=y-h,s=u*x-(o-h*p-u*p-h*x);let k=0;s!==0&&(i[k++]=s);for(let S=1;S<n;S++)y=t[S],a=y*e,l=U*y,h=l-(l-y),u=y-h,c=u*x-(a-h*p-u*p-h*x),r=o+c,f=r-o,s=o-(r-f)+(c-f),s!==0&&(i[k++]=s),o=a+r,s=r-(o-a),s!==0&&(i[k++]=s);return(o!==0||k===0)&&(i[k++]=o),k}function Ke(n,t){let e=t[0];for(let i=1;i<n;i++)e+=t[i];return e}function tt(n){return new Float64Array(n)}const Gn=(3+16*ut)*ut,Jn=(2+12*ut)*ut,Kn=(9+64*ut)*ut*ut,Vt=tt(4),Qe=tt(8),He=tt(12),Ze=tt(16),pt=tt(4);function Qn(n,t,e,i,o,r,s){let a,c,f,l,h,u,p,x,y,k,S,g,v,d,b,m,A,B;const P=n-o,I=e-o,N=t-r,X=i-r;d=P*X,u=U*P,p=u-(u-P),x=P-p,u=U*X,y=u-(u-X),k=X-y,b=x*k-(d-p*y-x*y-p*k),m=N*I,u=U*N,p=u-(u-N),x=N-p,u=U*I,y=u-(u-I),k=I-y,A=x*k-(m-p*y-x*y-p*k),S=b-A,h=b-S,Vt[0]=b-(S+h)+(h-A),g=d+S,h=g-d,v=d-(g-h)+(S-h),S=v-m,h=v-S,Vt[1]=v-(S+h)+(h-m),B=g+S,h=B-g,Vt[2]=g-(B-h)+(S-h),Vt[3]=B;let F=Ke(4,Vt),w=Jn*s;if(F>=w||-F>=w||(h=n-P,a=n-(P+h)+(h-o),h=e-I,f=e-(I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a){const c=n-s,f=e-s,l=o-s,h=t-a,u=i-a,p=r-a,x=f*p,y=l*u,k=c*c+h*h,S=l*h,g=c*p,v=f*f+u*u,d=c*u,b=f*h,m=l*l+p*p,A=k*(x-y)+v*(S-g)+m*(d-b),B=(Math.abs(x)+Math.abs(y))*k+(Math.abs(S)+Math.abs(g))*v+(Math.abs(d)+Math.abs(b))*m,P=Hn*B;return A>P||-A>P?A:ei(n,t,e,i,o,r,s,a,B)}function ii(n,t){var e,i,o=0,r,s,a,c,f,l,h,u=n[0],p=n[1],x=t.length;for(e=0;e<x;e++){i=0;var y=t[e],k=y.length-1;if(l=y[0],l[0]!==y[k][0]&&l[1]!==y[k][1])throw new Error("First and last coordinates in a ring must be the same");for(s=l[0]-u,a=l[1]-p,i;i<k;i++){if(h=y[i+1],c=h[0]-u,f=h[1]-p,a===0&&f===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(r=St(s,c,a,f,0,0),r===0)return 0;(r>0&&f>0&&a<=0||r<0&&f<=0&&a>0)&&o++}l=h,a=f,s=c}}return o%2!==0}function Be(n,t,e={}){if(!n)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=zn(n),o=Wn(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&ri(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const l=ii(i,a[f]);if(l===0)return!e.ignoreBoundary;l&&(c=!0)}return c}function ri(n,t){return t[0]<=n[0]&&t[1]<=n[1]&&t[2]>=n[0]&&t[3]>=n[1]}let tn=class{constructor(t=[],e=oi){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,o=e[t];for(;t>0;){const r=t-1>>1,s=e[r];if(i(o,s)>=0)break;e[t]=s,t=r}e[t]=o}_down(t){const{data:e,compare:i}=this,o=this.length>>1,r=e[t];for(;t<o;){let s=(t<<1)+1,a=e[s];const c=s+1;if(c<this.length&&i(e[c],a)<0&&(s=c,a=e[c]),i(a,r)>=0)break;e[t]=a,t=s}e[t]=r}};function oi(n,t){return n<t?-1:n>t?1:0}function en(n,t){return n.p.x>t.p.x?1:n.p.x<t.p.x?-1:n.p.y!==t.p.y?n.p.y>t.p.y?1:-1:1}function si(n,t){return n.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:n.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:n.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?n.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class nn{constructor(t,e,i,o){this.p={x:t[0],y:t[1]},this.featureId=e,this.ringId=i,this.eventId=o,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(t){return this.p.x===t.p.x&&this.p.y===t.p.y}}function ai(n,t){if(n.type==="FeatureCollection"){const e=n.features;for(let i=0;i<e.length;i++)rn(e[i],t)}else rn(n,t)}let ue=0,de=0,pe=0;function rn(n,t){const e=n.type==="Feature"?n.geometry:n;let i=e.coordinates;(e.type==="Polygon"||e.type==="MultiLineString")&&(i=[i]),e.type==="LineString"&&(i=[[i]]);for(let o=0;o<i.length;o++)for(let r=0;r<i[o].length;r++){let s=i[o][r][0],a=null;de=de+1;for(let c=0;c<i[o][r].length-1;c++){a=i[o][r][c+1];const f=new nn(s,ue,de,pe),l=new nn(a,ue,de,pe+1);f.otherEvent=l,l.otherEvent=f,en(f,l)>0?(l.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,l.isLeftEndpoint=!1),t.push(f),t.push(l),s=a,pe=pe+1}}ue=ue+1}class ci{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}}function fi(n,t){if(n===null||t===null||n.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(n.rightSweepEvent.isSamePoint(t.leftSweepEvent)||n.rightSweepEvent.isSamePoint(t.leftSweepEvent)||n.rightSweepEvent.isSamePoint(t.rightSweepEvent)||n.leftSweepEvent.isSamePoint(t.leftSweepEvent)||n.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const e=n.leftSweepEvent.p.x,i=n.leftSweepEvent.p.y,o=n.rightSweepEvent.p.x,r=n.rightSweepEvent.p.y,s=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,c=t.rightSweepEvent.p.x,f=t.rightSweepEvent.p.y,l=(f-a)*(o-e)-(c-s)*(r-i),h=(c-s)*(i-a)-(f-a)*(e-s),u=(o-e)*(i-a)-(r-i)*(e-s);if(l===0)return!1;const p=h/l,x=u/l;if(p>=0&&p<=1&&x>=0&&x<=1){const y=e+p*(o-e),k=i+p*(r-i);return[y,k]}return!1}function hi(n,t){t=t||!1;const e=[],i=new tn([],si);for(;n.length;){const o=n.pop();if(o.isLeftEndpoint){const r=new ci(o);for(let s=0;s<i.data.length;s++){const a=i.data[s];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const c=fi(r,a);c!==!1&&e.push(c)}i.push(r)}else o.isLeftEndpoint===!1&&i.pop()}return e}function li(n,t){const e=new tn([],en);return ai(n,e),hi(e,t)}var ui=li;function di(n,t,e={}){const{removeDuplicates:i=!0,ignoreSelfIntersections:o=!0}=e;let r=[];n.type==="FeatureCollection"?r=r.concat(n.features):n.type==="Feature"?r.push(n):(n.type==="LineString"||n.type==="Polygon"||n.type==="MultiLineString"||n.type==="MultiPolygon")&&r.push(It(n)),t.type==="FeatureCollection"?r=r.concat(t.features):t.type==="Feature"?r.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&r.push(It(t));const s=ui(_t(r),o);let a=[];if(i){const c={};s.forEach(f=>{const l=f.join(",");c[l]||(c[l]=!0,a.push(f))})}else a=s;return _t(a.map(c=>Nt(c)))}function pi(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function gi(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var t=n.default;if(typeof t=="function"){var e=function i(){var o=!1;try{o=this instanceof i}catch{}return o?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var o=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return n[i]}})}),e}function mi(n,t={}){let e=0,i=0,o=0;return _e(n,function(r){e+=r[0],i+=r[1],o++},!0),Nt([e/o,i/o],t.properties)}var ge={exports:{}},me={exports:{}},wi=me.exports,on;function yi(){return on||(on=1,(function(n,t){(function(e,i){n.exports=i()})(wi,function(){function e(g,v,d,b,m){(function A(B,P,I,N,X){for(;N>I;){if(N-I>600){var F=N-I+1,w=P-I+1,E=Math.log(F),M=.5*Math.exp(2*E/3),T=.5*Math.sqrt(E*M*(F-M)/F)*(w-F/2<0?-1:1),O=Math.max(I,Math.floor(P-w*M/F+T)),D=Math.min(N,Math.floor(P+(F-w)*M/F+T));A(B,P,O,D,X)}var _=B[P],C=I,R=N;for(i(B,I,P),X(B[N],_)>0&&i(B,I,N);C<R;){for(i(B,C,R),C++,R--;X(B[C],_)<0;)C++;for(;X(B[R],_)>0;)R--}X(B[I],_)===0?i(B,I,R):i(B,++R,N),R<=P&&(I=R+1),P<=R&&(N=R-1)}})(g,v,d||0,b||g.length-1,m||o)}function i(g,v,d){var b=g[v];g[v]=g[d],g[d]=b}function o(g,v){return g<v?-1:g>v?1:0}var r=function(g){g===void 0&&(g=9),this._maxEntries=Math.max(4,g),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(g,v,d){if(!d)return v.indexOf(g);for(var b=0;b<v.length;b++)if(d(g,v[b]))return b;return-1}function a(g,v){c(g,0,g.children.length,v,g)}function c(g,v,d,b,m){m||(m=k(null)),m.minX=1/0,m.minY=1/0,m.maxX=-1/0,m.maxY=-1/0;for(var A=v;A<d;A++){var B=g.children[A];f(m,g.leaf?b(B):B)}return m}function f(g,v){return g.minX=Math.min(g.minX,v.minX),g.minY=Math.min(g.minY,v.minY),g.maxX=Math.max(g.maxX,v.maxX),g.maxY=Math.max(g.maxY,v.maxY),g}function l(g,v){return g.minX-v.minX}function h(g,v){return g.minY-v.minY}function u(g){return(g.maxX-g.minX)*(g.maxY-g.minY)}function p(g){return g.maxX-g.minX+(g.maxY-g.minY)}function x(g,v){return g.minX<=v.minX&&g.minY<=v.minY&&v.maxX<=g.maxX&&v.maxY<=g.maxY}function y(g,v){return v.minX<=g.maxX&&v.minY<=g.maxY&&v.maxX>=g.minX&&v.maxY>=g.minY}function k(g){return{children:g,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function S(g,v,d,b,m){for(var A=[v,d];A.length;)if(!((d=A.pop())-(v=A.pop())<=b)){var B=v+Math.ceil((d-v)/b/2)*b;e(g,B,v,d,m),A.push(v,B,B,d)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(g){var v=this.data,d=[];if(!y(g,v))return d;for(var b=this.toBBox,m=[];v;){for(var A=0;A<v.children.length;A++){var B=v.children[A],P=v.leaf?b(B):B;y(g,P)&&(v.leaf?d.push(B):x(g,P)?this._all(B,d):m.push(B))}v=m.pop()}return d},r.prototype.collides=function(g){var v=this.data;if(!y(g,v))return!1;for(var d=[];v;){for(var b=0;b<v.children.length;b++){var m=v.children[b],A=v.leaf?this.toBBox(m):m;if(y(g,A)){if(v.leaf||x(g,A))return!0;d.push(m)}}v=d.pop()}return!1},r.prototype.load=function(g){if(!g||!g.length)return this;if(g.length<this._minEntries){for(var v=0;v<g.length;v++)this.insert(g[v]);return this}var d=this._build(g.slice(),0,g.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var b=this.data;this.data=d,d=b}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},r.prototype.insert=function(g){return g&&this._insert(g,this.data.height-1),this},r.prototype.clear=function(){return this.data=k([]),this},r.prototype.remove=function(g,v){if(!g)return this;for(var d,b,m,A=this.data,B=this.toBBox(g),P=[],I=[];A||P.length;){if(A||(A=P.pop(),b=P[P.length-1],d=I.pop(),m=!0),A.leaf){var N=s(g,A.children,v);if(N!==-1)return A.children.splice(N,1),P.push(A),this._condense(P),this}m||A.leaf||!x(A,B)?b?(d++,A=b.children[d],m=!1):A=null:(P.push(A),I.push(d),d=0,b=A,A=A.children[0])}return this},r.prototype.toBBox=function(g){return g},r.prototype.compareMinX=function(g,v){return g.minX-v.minX},r.prototype.compareMinY=function(g,v){return g.minY-v.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(g){return this.data=g,this},r.prototype._all=function(g,v){for(var d=[];g;)g.leaf?v.push.apply(v,g.children):d.push.apply(d,g.children),g=d.pop();return v},r.prototype._build=function(g,v,d,b){var m,A=d-v+1,B=this._maxEntries;if(A<=B)return a(m=k(g.slice(v,d+1)),this.toBBox),m;b||(b=Math.ceil(Math.log(A)/Math.log(B)),B=Math.ceil(A/Math.pow(B,b-1))),(m=k([])).leaf=!1,m.height=b;var P=Math.ceil(A/B),I=P*Math.ceil(Math.sqrt(B));S(g,v,d,I,this.compareMinX);for(var N=v;N<=d;N+=I){var X=Math.min(N+I-1,d);S(g,N,X,P,this.compareMinY);for(var F=N;F<=X;F+=P){var w=Math.min(F+P-1,X);m.children.push(this._build(g,F,w,b-1))}}return a(m,this.toBBox),m},r.prototype._chooseSubtree=function(g,v,d,b){for(;b.push(v),!v.leaf&&b.length-1!==d;){for(var m=1/0,A=1/0,B=void 0,P=0;P<v.children.length;P++){var I=v.children[P],N=u(I),X=(F=g,w=I,(Math.max(w.maxX,F.maxX)-Math.min(w.minX,F.minX))*(Math.max(w.maxY,F.maxY)-Math.min(w.minY,F.minY))-N);X<A?(A=X,m=N<m?N:m,B=I):X===A&&N<m&&(m=N,B=I)}v=B||v.children[0]}var F,w;return v},r.prototype._insert=function(g,v,d){var b=d?g:this.toBBox(g),m=[],A=this._chooseSubtree(b,this.data,v,m);for(A.children.push(g),f(A,b);v>=0&&m[v].children.length>this._maxEntries;)this._split(m,v),v--;this._adjustParentBBoxes(b,m,v)},r.prototype._split=function(g,v){var d=g[v],b=d.children.length,m=this._minEntries;this._chooseSplitAxis(d,m,b);var A=this._chooseSplitIndex(d,m,b),B=k(d.children.splice(A,d.children.length-A));B.height=d.height,B.leaf=d.leaf,a(d,this.toBBox),a(B,this.toBBox),v?g[v-1].children.push(B):this._splitRoot(d,B)},r.prototype._splitRoot=function(g,v){this.data=k([g,v]),this.data.height=g.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(g,v,d){for(var b,m,A,B,P,I,N,X=1/0,F=1/0,w=v;w<=d-v;w++){var E=c(g,0,w,this.toBBox),M=c(g,w,d,this.toBBox),T=(m=E,A=M,B=void 0,P=void 0,I=void 0,N=void 0,B=Math.max(m.minX,A.minX),P=Math.max(m.minY,A.minY),I=Math.min(m.maxX,A.maxX),N=Math.min(m.maxY,A.maxY),Math.max(0,I-B)*Math.max(0,N-P)),O=u(E)+u(M);T<X?(X=T,b=w,F=O<F?O:F):T===X&&O<F&&(F=O,b=w)}return b||d-v},r.prototype._chooseSplitAxis=function(g,v,d){var b=g.leaf?this.compareMinX:l,m=g.leaf?this.compareMinY:h;this._allDistMargin(g,v,d,b)<this._allDistMargin(g,v,d,m)&&g.children.sort(b)},r.prototype._allDistMargin=function(g,v,d,b){g.children.sort(b);for(var m=this.toBBox,A=c(g,0,v,m),B=c(g,d-v,d,m),P=p(A)+p(B),I=v;I<d-v;I++){var N=g.children[I];f(A,g.leaf?m(N):N),P+=p(A)}for(var X=d-v-1;X>=v;X--){var F=g.children[X];f(B,g.leaf?m(F):F),P+=p(B)}return P},r.prototype._adjustParentBBoxes=function(g,v,d){for(var b=d;b>=0;b--)f(v[b],g)},r.prototype._condense=function(g){for(var v=g.length-1,d=void 0;v>=0;v--)g[v].children.length===0?v>0?(d=g[v-1].children).splice(d.indexOf(g[v]),1):this.clear():a(g[v],this.toBBox)},r})})(me)),me.exports}class vi{constructor(t=[],e=bi){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,o=e[t];for(;t>0;){const r=t-1>>1,s=e[r];if(i(o,s)>=0)break;e[t]=s,t=r}e[t]=o}_down(t){const{data:e,compare:i}=this,o=this.length>>1,r=e[t];for(;t<o;){let s=(t<<1)+1,a=e[s];const c=s+1;if(c<this.length&&i(e[c],a)<0&&(s=c,a=e[c]),i(a,r)>=0)break;e[t]=a,t=s}e[t]=r}}function bi(n,t){return n<t?-1:n>t?1:0}const xi=gi(Object.freeze(Object.defineProperty({__proto__:null,default:vi},Symbol.toStringTag,{value:"Module"})));var Kt={exports:{}},Oe,sn;function _i(){return sn||(sn=1,Oe=function(t,e,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=e.length);for(var c=(o-i)/2,f=0,l=c-1;f<c;l=f++){var h=e[i+f*2+0],u=e[i+f*2+1],p=e[i+l*2+0],x=e[i+l*2+1],y=u>s!=x>s&&r<(p-h)*(s-u)/(x-u)+h;y&&(a=!a)}return a}),Oe}var Te,an;function Mi(){return an||(an=1,Te=function(t,e,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=e.length);for(var c=o-i,f=0,l=c-1;f<c;l=f++){var h=e[f+i][0],u=e[f+i][1],p=e[l+i][0],x=e[l+i][1],y=u>s!=x>s&&r<(p-h)*(s-u)/(x-u)+h;y&&(a=!a)}return a}),Te}var cn;function Si(){if(cn)return Kt.exports;cn=1;var n=_i(),t=Mi();return Kt.exports=function(i,o,r,s){return o.length>0&&Array.isArray(o[0])?t(i,o,r,s):n(i,o,r,s)},Kt.exports.nested=t,Kt.exports.flat=n,Kt.exports}var Qt={exports:{}},ki=Qt.exports,fn;function Ei(){return fn||(fn=1,(function(n,t){(function(e,i){i(t)})(ki,function(e){const o=33306690738754706e-32;function r(y,k,S,g,v){let d,b,m,A,B=k[0],P=g[0],I=0,N=0;P>B==P>-B?(d=B,B=k[++I]):(d=P,P=g[++N]);let X=0;if(I<y&&N<S)for(P>B==P>-B?(m=d-((b=B+d)-B),B=k[++I]):(m=d-((b=P+d)-P),P=g[++N]),d=b,m!==0&&(v[X++]=m);I<y&&N<S;)P>B==P>-B?(m=d-((b=d+B)-(A=b-d))+(B-A),B=k[++I]):(m=d-((b=d+P)-(A=b-d))+(P-A),P=g[++N]),d=b,m!==0&&(v[X++]=m);for(;I<y;)m=d-((b=d+B)-(A=b-d))+(B-A),B=k[++I],d=b,m!==0&&(v[X++]=m);for(;N<S;)m=d-((b=d+P)-(A=b-d))+(P-A),P=g[++N],d=b,m!==0&&(v[X++]=m);return d===0&&X!==0||(v[X++]=d),X}function s(y){return new Float64Array(y)}const a=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,l=s(4),h=s(8),u=s(12),p=s(16),x=s(4);e.orient2d=function(y,k,S,g,v,d){const b=(k-d)*(S-v),m=(y-v)*(g-d),A=b-m;if(b===0||m===0||b>0!=m>0)return A;const B=Math.abs(b+m);return Math.abs(A)>=a*B?A:-(function(P,I,N,X,F,w,E){let M,T,O,D,_,C,R,L,q,j,V,$,G,W,K,Q,Z,H;const ft=P-F,lt=N-F,rt=I-w,ot=X-w;_=(K=(L=ft-(R=(C=134217729*ft)-(C-ft)))*(j=ot-(q=(C=134217729*ot)-(C-ot)))-((W=ft*ot)-R*q-L*q-R*j))-(V=K-(Z=(L=rt-(R=(C=134217729*rt)-(C-rt)))*(j=lt-(q=(C=134217729*lt)-(C-lt)))-((Q=rt*lt)-R*q-L*q-R*j))),l[0]=K-(V+_)+(_-Z),_=(G=W-(($=W+V)-(_=$-W))+(V-_))-(V=G-Q),l[1]=G-(V+_)+(_-Q),_=(H=$+V)-$,l[2]=$-(H-_)+(V-_),l[3]=H;let Ft=(function(Hr,Vn){let Un=Vn[0];for(let ze=1;ze<Hr;ze++)Un+=Vn[ze];return Un})(4,l),ce=c*E;if(Ft>=ce||-Ft>=ce||(M=P-(ft+(_=P-ft))+(_-F),O=N-(lt+(_=N-lt))+(_-F),T=I-(rt+(_=I-rt))+(_-w),D=X-(ot+(_=X-ot))+(_-w),M===0&&T===0&&O===0&&D===0)||(ce=f*E+o*Math.abs(Ft),(Ft+=ft*D+ot*M-(rt*O+lt*T))>=ce||-Ft>=ce))return Ft;_=(K=(L=M-(R=(C=134217729*M)-(C-M)))*(j=ot-(q=(C=134217729*ot)-(C-ot)))-((W=M*ot)-R*q-L*q-R*j))-(V=K-(Z=(L=T-(R=(C=134217729*T)-(C-T)))*(j=lt-(q=(C=134217729*lt)-(C-lt)))-((Q=T*lt)-R*q-L*q-R*j))),x[0]=K-(V+_)+(_-Z),_=(G=W-(($=W+V)-(_=$-W))+(V-_))-(V=G-Q),x[1]=G-(V+_)+(_-Q),_=(H=$+V)-$,x[2]=$-(H-_)+(V-_),x[3]=H;const Jr=r(4,l,4,x,h);_=(K=(L=ft-(R=(C=134217729*ft)-(C-ft)))*(j=D-(q=(C=134217729*D)-(C-D)))-((W=ft*D)-R*q-L*q-R*j))-(V=K-(Z=(L=rt-(R=(C=134217729*rt)-(C-rt)))*(j=O-(q=(C=134217729*O)-(C-O)))-((Q=rt*O)-R*q-L*q-R*j))),x[0]=K-(V+_)+(_-Z),_=(G=W-(($=W+V)-(_=$-W))+(V-_))-(V=G-Q),x[1]=G-(V+_)+(_-Q),_=(H=$+V)-$,x[2]=$-(H-_)+(V-_),x[3]=H;const Kr=r(Jr,h,4,x,u);_=(K=(L=M-(R=(C=134217729*M)-(C-M)))*(j=D-(q=(C=134217729*D)-(C-D)))-((W=M*D)-R*q-L*q-R*j))-(V=K-(Z=(L=T-(R=(C=134217729*T)-(C-T)))*(j=O-(q=(C=134217729*O)-(C-O)))-((Q=T*O)-R*q-L*q-R*j))),x[0]=K-(V+_)+(_-Z),_=(G=W-(($=W+V)-(_=$-W))+(V-_))-(V=G-Q),x[1]=G-(V+_)+(_-Q),_=(H=$+V)-$,x[2]=$-(H-_)+(V-_),x[3]=H;const Qr=r(Kr,u,4,x,p);return p[Qr-1]})(y,k,S,g,v,d,B)},e.orient2dfast=function(y,k,S,g,v,d){return(k-d)*(S-v)-(y-v)*(g-d)},Object.defineProperty(e,"__esModule",{value:!0})})})(Qt,Qt.exports)),Qt.exports}var hn;function Ai(){if(hn)return ge.exports;hn=1;var n=yi(),t=xi,e=Si(),i=Ei().orient2d;t.default&&(t=t.default),ge.exports=o,ge.exports.default=o;function o(d,b,m){b=Math.max(0,b===void 0?2:b),m=m||0;var A=p(d),B=new n(16);B.toBBox=function(R){return{minX:R[0],minY:R[1],maxX:R[0],maxY:R[1]}},B.compareMinX=function(R,L){return R[0]-L[0]},B.compareMinY=function(R,L){return R[1]-L[1]},B.load(d);for(var P=[],I=0,N;I<A.length;I++){var X=A[I];B.remove(X),N=x(X,N),P.push(N)}var F=new n(16);for(I=0;I<P.length;I++)F.insert(u(P[I]));for(var w=b*b,E=m*m;P.length;){var M=P.shift(),T=M.p,O=M.next.p,D=y(T,O);if(!(D<E)){var _=D/w;X=r(B,M.prev.p,T,O,M.next.next.p,_,F),X&&Math.min(y(X,T),y(X,O))<=_&&(P.push(M),P.push(x(X,M)),B.remove(X),F.remove(M),F.insert(u(M)),F.insert(u(M.next)))}}M=N;var C=[];do C.push(M.p),M=M.next;while(M!==N);return C.push(M.p),C}function r(d,b,m,A,B,P,I){for(var N=new t([],s),X=d.data;X;){for(var F=0;F<X.children.length;F++){var w=X.children[F],E=X.leaf?k(w,m,A):a(m,A,w);E>P||N.push({node:w,dist:E})}for(;N.length&&!N.peek().node.children;){var M=N.pop(),T=M.node,O=k(T,b,m),D=k(T,A,B);if(M.dist<O&&M.dist<D&&f(m,T,I)&&f(A,T,I))return T}X=N.pop(),X&&(X=X.node)}return null}function s(d,b){return d.dist-b.dist}function a(d,b,m){if(c(d,m)||c(b,m))return 0;var A=S(d[0],d[1],b[0],b[1],m.minX,m.minY,m.maxX,m.minY);if(A===0)return 0;var B=S(d[0],d[1],b[0],b[1],m.minX,m.minY,m.minX,m.maxY);if(B===0)return 0;var P=S(d[0],d[1],b[0],b[1],m.maxX,m.minY,m.maxX,m.maxY);if(P===0)return 0;var I=S(d[0],d[1],b[0],b[1],m.minX,m.maxY,m.maxX,m.maxY);return I===0?0:Math.min(A,B,P,I)}function c(d,b){return d[0]>=b.minX&&d[0]<=b.maxX&&d[1]>=b.minY&&d[1]<=b.maxY}function f(d,b,m){for(var A=Math.min(d[0],b[0]),B=Math.min(d[1],b[1]),P=Math.max(d[0],b[0]),I=Math.max(d[1],b[1]),N=m.search({minX:A,minY:B,maxX:P,maxY:I}),X=0;X<N.length;X++)if(h(N[X].p,N[X].next.p,d,b))return!1;return!0}function l(d,b,m){return i(d[0],d[1],b[0],b[1],m[0],m[1])}function h(d,b,m,A){return d!==A&&b!==m&&l(d,b,m)>0!=l(d,b,A)>0&&l(m,A,d)>0!=l(m,A,b)>0}function u(d){var b=d.p,m=d.next.p;return d.minX=Math.min(b[0],m[0]),d.minY=Math.min(b[1],m[1]),d.maxX=Math.max(b[0],m[0]),d.maxY=Math.max(b[1],m[1]),d}function p(d){for(var b=d[0],m=d[0],A=d[0],B=d[0],P=0;P<d.length;P++){var I=d[P];I[0]<b[0]&&(b=I),I[0]>A[0]&&(A=I),I[1]<m[1]&&(m=I),I[1]>B[1]&&(B=I)}var N=[b,m,A,B],X=N.slice();for(P=0;P<d.length;P++)e(d[P],N)||X.push(d[P]);return v(X)}function x(d,b){var m={p:d,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return b?(m.next=b.next,m.prev=b,b.next.prev=m,b.next=m):(m.prev=m,m.next=m),m}function y(d,b){var m=d[0]-b[0],A=d[1]-b[1];return m*m+A*A}function k(d,b,m){var A=b[0],B=b[1],P=m[0]-A,I=m[1]-B;if(P!==0||I!==0){var N=((d[0]-A)*P+(d[1]-B)*I)/(P*P+I*I);N>1?(A=m[0],B=m[1]):N>0&&(A+=P*N,B+=I*N)}return P=d[0]-A,I=d[1]-B,P*P+I*I}function S(d,b,m,A,B,P,I,N){var X=m-d,F=A-b,w=I-B,E=N-P,M=d-B,T=b-P,O=X*X+F*F,D=X*w+F*E,_=w*w+E*E,C=X*M+F*T,R=w*M+E*T,L=O*_-D*D,q,j,V,$,G=L,W=L;L===0?(j=0,G=1,$=R,W=_):(j=D*R-_*C,$=O*R-D*C,j<0?(j=0,$=R,W=_):j>G&&(j=G,$=R+D,W=_)),$<0?($=0,-C<0?j=0:-C>O?j=G:(j=-C,G=O)):$>W&&($=W,-C+D<0?j=0:-C+D>O?j=G:(j=-C+D,G=O)),q=j===0?0:j/G,V=$===0?0:$/W;var K=(1-q)*d+q*m,Q=(1-q)*b+q*A,Z=(1-V)*B+V*I,H=(1-V)*P+V*N,ft=Z-K,lt=H-Q;return ft*ft+lt*lt}function g(d,b){return d[0]===b[0]?d[1]-b[1]:d[0]-b[0]}function v(d){d.sort(g);for(var b=[],m=0;m<d.length;m++){for(;b.length>=2&&l(b[b.length-2],b[b.length-1],d[m])<=0;)b.pop();b.push(d[m])}for(var A=[],B=d.length-1;B>=0;B--){for(;A.length>=2&&l(A[A.length-2],A[A.length-1],d[B])<=0;)A.pop();A.push(d[B])}return A.pop(),b.pop(),b.concat(A)}return ge.exports}var Pi=Ai();const Ii=pi(Pi);function ln(n,t={}){t.concavity=t.concavity||1/0;const e=[];if(_e(n,o=>{e.push([o[0],o[1]])}),!e.length)return null;const i=Ii(e,t.concavity);return i.length>3?Jt([i]):null}function un(n,t,e={}){const i={type:"Feature"};return(e.id===0||e.id)&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.properties=t||{},i.geometry=n,i}function Ht(n,t,e={}){if(!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!pn(n[0])||!pn(n[1]))throw new Error("coordinates must contain numbers");return un({type:"Point",coordinates:n},t,e)}function dn(n,t,e={}){for(const i of n){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let o=0;o<i[i.length-1].length;o++)if(i[i.length-1][o]!==i[0][o])throw new Error("First and last Position are not equivalent.")}return un({type:"Polygon",coordinates:n},t,e)}function zt(n,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=n,e}function pn(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function Bi(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return[...n.geometry.coordinates];if(n.type==="Point")return[...n.coordinates]}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return[...n];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function gn(n){if(Array.isArray(n))return n;if(n.type==="Feature"){if(n.geometry!==null)return n.geometry.coordinates}else if(n.coordinates)return n.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Oi(n){return n.type==="Feature"?n.geometry:n}const Bt=11102230246251565e-32,dt=134217729,Ti=(3+8*Bt)*Bt;function Ne(n,t,e,i,o){let r,s,a,c,f=t[0],l=i[0],h=0,u=0;l>f==l>-f?(r=f,f=t[++h]):(r=l,l=i[++u]);let p=0;if(h<n&&u<e)for(l>f==l>-f?(s=f+r,a=r-(s-f),f=t[++h]):(s=l+r,a=r-(s-l),l=i[++u]),r=s,a!==0&&(o[p++]=a);h<n&&u<e;)l>f==l>-f?(s=r+f,c=s-r,a=r-(s-c)+(f-c),f=t[++h]):(s=r+l,c=s-r,a=r-(s-c)+(l-c),l=i[++u]),r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+f,c=s-r,a=r-(s-c)+(f-c),f=t[++h],r=s,a!==0&&(o[p++]=a);for(;u<e;)s=r+l,c=s-r,a=r-(s-c)+(l-c),l=i[++u],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Ni(n,t){let e=t[0];for(let i=1;i<n;i++)e+=t[i];return e}function Zt(n){return new Float64Array(n)}const Ci=(3+16*Bt)*Bt,Xi=(2+12*Bt)*Bt,Di=(9+64*Bt)*Bt*Bt,Wt=Zt(4),mn=Zt(8),wn=Zt(12),yn=Zt(16),wt=Zt(4);function Ri(n,t,e,i,o,r,s){let a,c,f,l,h,u,p,x,y,k,S,g,v,d,b,m,A,B;const P=n-o,I=e-o,N=t-r,X=i-r;d=P*X,u=dt*P,p=u-(u-P),x=P-p,u=dt*X,y=u-(u-X),k=X-y,b=x*k-(d-p*y-x*y-p*k),m=N*I,u=dt*N,p=u-(u-N),x=N-p,u=dt*I,y=u-(u-I),k=I-y,A=x*k-(m-p*y-x*y-p*k),S=b-A,h=b-S,Wt[0]=b-(S+h)+(h-A),g=d+S,h=g-d,v=d-(g-h)+(S-h),S=v-m,h=v-S,Wt[1]=v-(S+h)+(h-m),B=g+S,h=B-g,Wt[2]=g-(B-h)+(S-h),Wt[3]=B;let F=Ni(4,Wt),w=Xi*s;if(F>=w||-F>=w||(h=n-P,a=n-(P+h)+(h-o),h=e-I,f=e-(I+h)+(h-o),h=t-N,c=t-(N+h)+(h-r),h=i-X,l=i-(X+h)+(h-r),a===0&&c===0&&f===0&&l===0)||(w=Di*s+Ti*Math.abs(F),F+=P*l+X*a-(N*f+I*c),F>=w||-F>=w))return F;d=a*X,u=dt*a,p=u-(u-a),x=a-p,u=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],k=y.length-1;if(l=y[0],l[0]!==y[k][0]&&l[1]!==y[k][1])throw new Error("First and last coordinates in a ring must be the same");for(s=l[0]-u,a=l[1]-p,i;i<k;i++){if(h=y[i+1],c=h[0]-u,f=h[1]-p,a===0&&f===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(r=Yi(s,c,a,f,0,0),r===0)return 0;(r>0&&f>0&&a<=0||r<0&&f<=0&&a>0)&&o++}l=h,a=f,s=c}}return o%2!==0}function Ce(n,t,e={}){if(!n)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=Bi(n),o=Oi(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&Li(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const l=Fi(i,a[f]);if(l===0)return!e.ignoreBoundary;l&&(c=!0)}return c}function Li(n,t){return t[0]<=n[0]&&t[1]<=n[1]&&t[2]>=n[0]&&t[3]>=n[1]}function Xe(n,t){for(let e=0;e<t.features.length;e++)if(Ce(n,t.features[e]))return t.features[e]}function vn(n,t,e){const i=t.geometry.coordinates[0][0],o=t.geometry.coordinates[0][1],r=t.geometry.coordinates[0][2],s=n.geometry.coordinates,a=t.properties.a.geom,c=t.properties.b.geom,f=t.properties.c.geom,l=[o[0]-i[0],o[1]-i[1]],h=[r[0]-i[0],r[1]-i[1]],u=[s[0]-i[0],s[1]-i[1]],p=[c[0]-a[0],c[1]-a[1]],x=[f[0]-a[0],f[1]-a[1]];let y=(h[1]*u[0]-h[0]*u[1])/(l[0]*h[1]-l[1]*h[0]),k=(l[0]*u[1]-l[1]*u[0])/(l[0]*h[1]-l[1]*h[0]);if(e){const S=e[t.properties.a.index],g=e[t.properties.b.index],v=e[t.properties.c.index];let d;if(y<0||k<0||1-y-k<0){const b=y/(y+k),m=k/(y+k);d=y/g/(b/g+m/v),k=k/v/(b/g+m/v)}else d=y/g/(y/g+k/v+(1-y-k)/S),k=k/v/(y/g+k/v+(1-y-k)/S);y=d}return[y*p[0]+k*x[0]+a[0],y*p[1]+k*x[1]+a[1]]}function ji(n,t,e,i){const o=n.geometry.coordinates,r=e.geometry.coordinates,s=Math.atan2(o[0]-r[0],o[1]-r[1]),a=$i(s,t[0]);if(a===void 0)throw new Error("Unable to determine vertex index");const c=t[1][a];return vn(n,c.features[0],i)}function te(n,t,e,i,o,r,s,a){let c;if(s&&(c=Xe(n,zt([s]))),!c)if(e){const f=n.geometry.coordinates,l=e.gridNum,h=e.xOrigin,u=e.yOrigin,p=e.xUnit,x=e.yUnit,y=e.gridCache,k=Pt(f[0],h,p,l),S=Pt(f[1],u,x,l),g=y[k]?y[k][S]?y[k][S]:[]:[],v=zt(g.map(d=>t.features[d]));c=Xe(n,v)}else c=Xe(n,t);return a&&a(c),c?vn(n,c,r):ji(n,i,o,r)}function Pt(n,t,e,i){let o=Math.floor((n-t)/e);return o<0&&(o=0),o>=i&&(o=i-1),o}function $i(n,t){let e=bn(n-t[0]),i=Math.PI*2,o;for(let r=0;r<t.length;r++){const s=(r+1)%t.length,a=bn(n-t[s]),c=Math.min(Math.abs(e),Math.abs(a));e*a<=0&&c<i&&(i=c,o=r),e=a}return o}function bn(n,t=!1){const e=2*Math.PI,i=n-Math.floor(n/e)*e;return t?i:i>Math.PI?i-e:i}function xn(n){const t=n.features;for(let e=0;e<t.length;e++){const i=t[e];`${i.properties.a.index}`.substring(0,1)==="b"&&`${i.properties.b.index}`.substring(0,1)==="b"?t[e]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1],i.geometry.coordinates[0][2]]]},properties:{a:{geom:i.properties.c.geom,index:i.properties.c.index},b:{geom:i.properties.a.geom,index:i.properties.a.index},c:{geom:i.properties.b.geom,index:i.properties.b.index}},type:"Feature"}:`${i.properties.c.index}`.substring(0,1)==="b"&&`${i.properties.a.index}`.substring(0,1)==="b"&&(t[e]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][1],i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1]]]},properties:{a:{geom:i.properties.b.geom,index:i.properties.b.index},b:{geom:i.properties.c.geom,index:i.properties.c.index},c:{geom:i.properties.a.geom,index:i.properties.a.index}},type:"Feature"})}return n}function _n(n){const t=["a","b","c","a"].map(r=>n.properties[r].geom),e=n.geometry.coordinates[0],i=n.properties,o={a:{geom:e[0],index:i.a.index},b:{geom:e[1],index:i.b.index},c:{geom:e[2],index:i.c.index}};return dn([t],o)}function qi(n){const t=[0,1,2,0].map(i=>n[i][0][0]),e={a:{geom:n[0][0][1],index:n[0][1]},b:{geom:n[1][0][1],index:n[1][1]},c:{geom:n[2][0][1],index:n[2][1]}};return dn([t],e)}function De(n,t,e,i,o,r=!1,s){const a=n.map(c=>{(!s||s<2.00703)&&(c=Mn(c));const f=isFinite(c)?t[c]:c==="c"?i:(function(){const l=c.match(/^b(\d+)$/);if(l)return o[parseInt(l[1])];const h=c.match(/^e(\d+)$/);if(h)return e[parseInt(h[1])];throw new Error("Bad index value for indexesToTri")})();return r?[[f[1],f[0]],c]:[[f[0],f[1]],c]});return qi(a)}function Mn(n){return typeof n=="number"?n:n.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function Sn(n,t){return t&&t>=2.00703||Array.isArray(n[0])?n:n.map(e=>[e.illstNodes,e.mercNodes,e.startEnd])}const Re=2.00703;function Vi(n){return!!(n.version!==void 0||!n.tins&&n.points&&n.tins_points)}function Ui(n){return{points:n.points,pointsWeightBuffer:Wi(n),strictStatus:Gi(n),verticesParams:Ji(n),centroid:Ki(n),edges:Sn(n.edges||[]),edgeNodes:n.edgeNodes||[],tins:Qi(n),kinks:Hi(n.kinks_points),yaxisMode:n.yaxisMode??"invert",strictMode:n.strictMode??"auto",vertexMode:n.vertexMode,bounds:n.bounds,boundsPolygon:n.boundsPolygon,wh:n.wh,xy:n.xy??[0,0]}}function zi(n){const t=Zi(n),e=t.tins;return{compiled:t,tins:e,points:tr(e),strictStatus:t.strict_status,pointsWeightBuffer:t.weight_buffer,verticesParams:t.vertices_params,centroid:t.centroid,kinks:t.kinks}}function Wi(n){return!n.version||n.version<Re?["forw","bakw"].reduce((t,e)=>{const i=n.weight_buffer[e];return i&&(t[e]=Object.keys(i).reduce((o,r)=>{const s=Mn(r);return o[s]=i[r],o},{})),t},{}):n.weight_buffer}function Gi(n){return n.strict_status?n.strict_status:n.kinks_points?"strict_error":n.tins_points.length===2?"loose":"strict"}function Ji(n){const t={forw:[n.vertices_params[0]],bakw:[n.vertices_params[1]]};return t.forw[1]=kn(n,!1),t.bakw[1]=kn(n,!0),t}function kn(n,t){const e=n.vertices_points.length;return Array.from({length:e},(i,o)=>{const r=(o+1)%e,s=De(["c",`b${o}`,`b${r}`],n.points,n.edgeNodes||[],n.centroid_point,n.vertices_points,t,Re);return zt([s])})}function Ki(n){return{forw:Ht(n.centroid_point[0],{target:{geom:n.centroid_point[1],index:"c"}}),bakw:Ht(n.centroid_point[1],{target:{geom:n.centroid_point[0],index:"c"}})}}function Qi(n){const t=n.tins_points.length===1?0:1;return{forw:zt(n.tins_points[0].map(e=>De(e,n.points,n.edgeNodes||[],n.centroid_point,n.vertices_points,!1,n.version))),bakw:zt(n.tins_points[t].map(e=>De(e,n.points,n.edgeNodes||[],n.centroid_point,n.vertices_points,!0,n.version)))}}function Hi(n){if(n)return{bakw:zt(n.map(t=>Ht(t)))}}function Zi(n){return JSON.parse(JSON.stringify(n).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function tr(n){const t=[],e=n.forw.features;for(let i=0;i<e.length;i++){const o=e[i];["a","b","c"].forEach((r,s)=>{const a=o.geometry.coordinates[0][s],c=o.properties[r].geom,f=o.properties[r].index;typeof f=="number"&&(t[f]=[a,c])})}return t}const Ye=Re;class Mt{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=Mt.YAXIS_INVERT;strictMode=Mt.MODE_AUTO;vertexMode=Mt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(t){if(Vi(t)){this.applyModernState(Ui(t));return}this.applyLegacyState(zi(t))}applyModernState(t){this.points=t.points,this.pointsWeightBuffer=t.pointsWeightBuffer,this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.edges=t.edges,this.edgeNodes=t.edgeNodes||[],this.tins=t.tins,this.addIndexedTin(),this.kinks=t.kinks,this.yaxisMode=t.yaxisMode??Mt.YAXIS_INVERT,this.vertexMode=t.vertexMode??Mt.VERTEX_PLAIN,this.strictMode=t.strictMode??Mt.MODE_AUTO,t.bounds?(this.bounds=t.bounds,this.boundsPolygon=t.boundsPolygon,this.xy=t.xy,this.wh=t.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=t.xy??[0,0],t.wh&&(this.wh=t.wh))}applyLegacyState(t){this.tins=t.tins,this.addIndexedTin(),this.strict_status=t.strictStatus,this.pointsWeightBuffer=t.pointsWeightBuffer,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.kinks=t.kinks,this.points=t.points}addIndexedTin(){const t=this.tins,e=t.forw,i=t.bakw,o=Math.ceil(Math.sqrt(e.features.length));if(o<3){this.indexedTins=void 0;return}let r=[],s=[];const a=e.features.map(y=>{let k=[];return gn(y)[0].map(S=>{r.length===0?r=[Array.from(S),Array.from(S)]:(S[0]<r[0][0]&&(r[0][0]=S[0]),S[0]>r[1][0]&&(r[1][0]=S[0]),S[1]<r[0][1]&&(r[0][1]=S[1]),S[1]>r[1][1]&&(r[1][1]=S[1])),k.length===0?k=[Array.from(S),Array.from(S)]:(S[0]<k[0][0]&&(k[0][0]=S[0]),S[0]>k[1][0]&&(k[1][0]=S[0]),S[1]<k[0][1]&&(k[0][1]=S[1]),S[1]>k[1][1]&&(k[1][1]=S[1]))}),k}),c=(r[1][0]-r[0][0])/o,f=(r[1][1]-r[0][1])/o,l=a.reduce((y,k,S)=>{const g=Pt(k[0][0],r[0][0],c,o),v=Pt(k[1][0],r[0][0],c,o),d=Pt(k[0][1],r[0][1],f,o),b=Pt(k[1][1],r[0][1],f,o);for(let m=g;m<=v;m++){y[m]||(y[m]=[]);for(let A=d;A<=b;A++)y[m][A]||(y[m][A]=[]),y[m][A].push(S)}return y},[]),h=i.features.map(y=>{let k=[];return gn(y)[0].map(S=>{s.length===0?s=[Array.from(S),Array.from(S)]:(S[0]<s[0][0]&&(s[0][0]=S[0]),S[0]>s[1][0]&&(s[1][0]=S[0]),S[1]<s[0][1]&&(s[0][1]=S[1]),S[1]>s[1][1]&&(s[1][1]=S[1])),k.length===0?k=[Array.from(S),Array.from(S)]:(S[0]<k[0][0]&&(k[0][0]=S[0]),S[0]>k[1][0]&&(k[1][0]=S[0]),S[1]<k[0][1]&&(k[0][1]=S[1]),S[1]>k[1][1]&&(k[1][1]=S[1]))}),k}),u=(s[1][0]-s[0][0])/o,p=(s[1][1]-s[0][1])/o,x=h.reduce((y,k,S)=>{const g=Pt(k[0][0],s[0][0],u,o),v=Pt(k[1][0],s[0][0],u,o),d=Pt(k[0][1],s[0][1],p,o),b=Pt(k[1][1],s[0][1],p,o);for(let m=g;m<=v;m++){y[m]||(y[m]=[]);for(let A=d;A<=b;A++)y[m][A]||(y[m][A]=[]),y[m][A].push(S)}return y},[]);this.indexedTins={forw:{gridNum:o,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:c,yUnit:f,gridCache:l},bakw:{gridNum:o,xOrigin:s[0][0],yOrigin:s[0][1],xUnit:u,yUnit:p,gridCache:x}}}transform(t,e,i){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(e&&this.strict_status==Mt.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==Mt.YAXIS_FOLLOW&&e&&(t=[t[0],-1*t[1]]);const o=Ht(t);if(this.bounds&&!e&&!i&&!Ce(o,this.boundsPolygon))return!1;const r=e?this.tins.bakw:this.tins.forw,s=e?this.indexedTins.bakw:this.indexedTins.forw,a=e?this.vertices_params.bakw:this.vertices_params.forw,c=e?this.centroid.bakw:this.centroid.forw,f=e?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let l,h;this.stateFull&&(this.stateBackward==e?l=this.stateTriangle:(this.stateBackward=e,this.stateTriangle=void 0),h=p=>{this.stateTriangle=p});let u=te(o,r,s,a,c,f,l,h);if(this.bounds&&e&&!i){const p=Ht(u);if(!Ce(p,this.boundsPolygon))return!1}else this.yaxisMode==Mt.YAXIS_FOLLOW&&!e&&(u=[u[0],-1*u[1]]);return u}}const En=Math.pow(2,-52),we=new Uint32Array(512);class Fe{static from(t,e=or,i=sr){const o=t.length,r=new Float64Array(o*2);for(let s=0;s<o;s++){const a=t[s];r[2*s]=e(a),r[2*s+1]=i(a)}return new Fe(r)}constructor(t){const e=t.length>>1;if(e>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const i=Math.max(2*e-5,0);this._triangles=new Uint32Array(i*3),this._halfedges=new Int32Array(i*3),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:i,_hullTri:o,_hullHash:r}=this,s=t.length>>1;let a=1/0,c=1/0,f=-1/0,l=-1/0;for(let P=0;P<s;P++){const I=t[2*P],N=t[2*P+1];I<a&&(a=I),N<c&&(c=N),I>f&&(f=I),N>l&&(l=N),this._ids[P]=P}const h=(a+f)/2,u=(c+l)/2;let p=0,x=0,y=0;for(let P=0,I=1/0;P<s;P++){const N=Le(h,u,t[2*P],t[2*P+1]);N<I&&(p=P,I=N)}const k=t[2*p],S=t[2*p+1];for(let P=0,I=1/0;P<s;P++){if(P===p)continue;const N=Le(k,S,t[2*P],t[2*P+1]);N<I&&N>0&&(x=P,I=N)}let g=t[2*x],v=t[2*x+1],d=1/0;for(let P=0;P<s;P++){if(P===p||P===x)continue;const I=ir(k,S,g,v,t[2*P],t[2*P+1]);I<d&&(y=P,d=I)}let b=t[2*y],m=t[2*y+1];if(d===1/0){for(let N=0;N<s;N++)this._dists[N]=t[2*N]-t[0]||t[2*N+1]-t[1];Gt(this._ids,this._dists,0,s-1);const P=new Uint32Array(s);let I=0;for(let N=0,X=-1/0;N<s;N++){const F=this._ids[N],w=this._dists[F];w>X&&(P[I++]=F,X=w)}this.hull=P.subarray(0,I),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(St(k,S,g,v,b,m)<0){const P=x,I=g,N=v;x=y,g=b,v=m,y=P,b=I,m=N}const A=rr(k,S,g,v,b,m);this._cx=A.x,this._cy=A.y;for(let P=0;P<s;P++)this._dists[P]=Le(t[2*P],t[2*P+1],A.x,A.y);Gt(this._ids,this._dists,0,s-1),this._hullStart=p;let B=3;i[p]=e[y]=x,i[x]=e[p]=y,i[y]=e[x]=p,o[p]=0,o[x]=1,o[y]=2,r.fill(-1),r[this._hashKey(k,S)]=p,r[this._hashKey(g,v)]=x,r[this._hashKey(b,m)]=y,this.trianglesLen=0,this._addTriangle(p,x,y,-1,-1,-1);for(let P=0,I=0,N=0;P<this._ids.length;P++){const X=this._ids[P],F=t[2*X],w=t[2*X+1];if(P>0&&Math.abs(F-I)<=En&&Math.abs(w-N)<=En||(I=F,N=w,X===p||X===x||X===y))continue;let E=0;for(let _=0,C=this._hashKey(F,w);_<this._hashSize&&(E=r[(C+_)%this._hashSize],!(E!==-1&&E!==i[E]));_++);E=e[E];let M=E,T;for(;T=i[M],St(F,w,t[2*M],t[2*M+1],t[2*T],t[2*T+1])>=0;)if(M=T,M===E){M=-1;break}if(M===-1)continue;let O=this._addTriangle(M,X,i[M],-1,-1,o[M]);o[X]=this._legalize(O+2),o[M]=O,B++;let D=i[M];for(;T=i[D],St(F,w,t[2*D],t[2*D+1],t[2*T],t[2*T+1])<0;)O=this._addTriangle(D,X,T,o[X],-1,o[D]),o[X]=this._legalize(O+2),i[D]=D,B--,D=T;if(M===E)for(;T=e[M],St(F,w,t[2*T],t[2*T+1],t[2*M],t[2*M+1])<0;)O=this._addTriangle(T,X,M,-1,o[M],o[T]),this._legalize(O+2),o[T]=O,i[M]=M,B--,M=T;this._hullStart=e[X]=M,i[M]=e[D]=X,i[X]=D,r[this._hashKey(F,w)]=X,r[this._hashKey(t[2*M],t[2*M+1])]=M}this.hull=new Uint32Array(B);for(let P=0,I=this._hullStart;P<B;P++)this.hull[P]=I,I=i[I];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(er(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:i,coords:o}=this;let r=0,s=0;for(;;){const a=i[t],c=t-t%3;if(s=c+(t+2)%3,a===-1){if(r===0)break;t=we[--r];continue}const f=a-a%3,l=c+(t+1)%3,h=f+(a+2)%3,u=e[s],p=e[t],x=e[l],y=e[h];if(nr(o[2*u],o[2*u+1],o[2*p],o[2*p+1],o[2*x],o[2*x+1],o[2*y],o[2*y+1])){e[t]=y,e[a]=u;const S=i[h];if(S===-1){let v=this._hullStart;do{if(this._hullTri[v]===h){this._hullTri[v]=t;break}v=this._hullPrev[v]}while(v!==this._hullStart)}this._link(t,S),this._link(a,i[s]),this._link(s,h);const g=f+(a+1)%3;r<we.length&&(we[r++]=g)}else{if(r===0)break;t=we[--r]}}return s}_link(t,e){this._halfedges[t]=e,e!==-1&&(this._halfedges[e]=t)}_addTriangle(t,e,i,o,r,s){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=e,this._triangles[a+2]=i,this._link(a,o),this._link(a+1,r),this._link(a+2,s),this.trianglesLen+=3,a}}function er(n,t){const e=n/(Math.abs(n)+Math.abs(t));return(t>0?3-e:1+e)/4}function Le(n,t,e,i){const o=n-e,r=t-i;return o*o+r*r}function nr(n,t,e,i,o,r,s,a){const c=n-s,f=t-a,l=e-s,h=i-a,u=o-s,p=r-a,x=c*c+f*f,y=l*l+h*h,k=u*u+p*p;return c*(h*k-y*p)-f*(l*k-y*u)+x*(l*p-h*u)<0}function ir(n,t,e,i,o,r){const s=e-n,a=i-t,c=o-n,f=r-t,l=s*s+a*a,h=c*c+f*f,u=.5/(s*f-a*c),p=(f*l-a*h)*u,x=(s*h-c*l)*u;return p*p+x*x}function rr(n,t,e,i,o,r){const s=e-n,a=i-t,c=o-n,f=r-t,l=s*s+a*a,h=c*c+f*f,u=.5/(s*f-a*c),p=n+(f*l-a*h)*u,x=t+(s*h-c*l)*u;return{x:p,y:x}}function Gt(n,t,e,i){if(i-e<=20)for(let o=e+1;o<=i;o++){const r=n[o],s=t[r];let a=o-1;for(;a>=e&&t[n[a]]>s;)n[a+1]=n[a--];n[a+1]=r}else{const o=e+i>>1;let r=e+1,s=i;ee(n,o,r),t[n[e]]>t[n[i]]&&ee(n,e,i),t[n[r]]>t[n[i]]&&ee(n,r,i),t[n[e]]>t[n[r]]&&ee(n,e,r);const a=n[r],c=t[a];for(;;){do r++;while(t[n[r]]<c);do s--;while(t[n[s]]>c);if(s<r)break;ee(n,r,s)}n[e+1]=n[s],n[s]=a,i-r+1>=s-e?(Gt(n,t,r,i),Gt(n,t,e,s-1)):(Gt(n,t,e,s-1),Gt(n,t,r,i))}}function ee(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function or(n){return n[0]}function sr(n){return n[1]}class ar{bs;width;constructor(t,e){this.width=t,this.bs=e}add(t){const e=Math.floor(t/this.width),i=t%this.width;return this.bs[e]|=1<<i,this}delete(t){const e=Math.floor(t/this.width),i=t%this.width;return this.bs[e]&=~(1<<i),this}set(t,e){const i=Math.floor(t/this.width),r=1<<t%this.width;return this.bs[i]^=(-Number(e)^this.bs[i])&r,e}has(t){const e=Math.floor(t/this.width),i=t%this.width;return(this.bs[e]&1<<i)!==0}forEach(t){const e=this.bs.length;for(let i=0;i<e;i++){let o=0;for(;this.bs[i]&&o<this.width;)this.bs[i]&1<<o&&t(i*this.width+o),o++}return this}}class An extends ar{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function qt(n){return n%3===2?n-2:n+1}function Ot(n){return n%3===0?n+2:n-1}function Pn(n,t,e,i,o,r,s,a){const c=St(n,t,o,r,s,a),f=St(e,i,o,r,s,a);if(c>0&&f>0||c<0&&f<0)return!1;const l=St(o,r,n,t,e,i),h=St(s,a,n,t,e,i);return l>0&&h>0||l<0&&h<0?!1:c===0&&f===0&&l===0&&h===0?!(Math.max(o,s)<Math.min(n,e)||Math.max(n,e)<Math.min(o,s)||Math.max(r,a)<Math.min(t,i)||Math.max(t,i)<Math.min(r,a)):!0}class cr{del;constructor(t){this.del=t}}class fr extends cr{vertMap;flips;consd;constructor(t,e){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);const i=2**32-1,o=t.coords.length>>1,r=t.triangles.length;this.vertMap=new Uint32Array(o).fill(i),this.flips=new An(r),this.consd=new An(r);for(let s=0;s<r;s++){const a=t.triangles[s];this.vertMap[a]===i&&this.updateVert(s)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:i,halfedges:o}=this.del,r=this.vertMap[t];let s=r;do{const f=i[s],l=qt(s);if(f===e)return this.protect(s);const h=Ot(s),u=i[h];if(u===e)return this.protect(l),l;if(this.intersectSegments(t,e,u,f)){s=h;break}s=o[l]}while(s!==-1&&s!==r);let a=s,c=-1;for(;s!==-1;){const f=o[s],l=Ot(s),h=Ot(f),u=qt(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(s))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,e,i[s])||this.isCollinear(t,e,i[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[s],i[f],i[l],i[h])){if(c===-1&&(c=s),i[h]===e){if(s===c)throw new Error("Infinite loop: non-convex quadrilateral");s=c,c=-1;continue}if(this.intersectSegments(t,e,i[h],i[f]))s=h;else if(this.intersectSegments(t,e,i[u],i[h]))s=u;else if(c===s)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(s),this.intersectSegments(t,e,i[l],i[h])&&(c===-1&&(c=l),c===l))throw new Error("Infinite loop: flipped diagonal still intersects");i[h]===e?(a=h,s=c,c=-1):this.intersectSegments(t,e,i[u],i[h])&&(s=u)}return this.protect(a),this.delaunify(!0),this.findEdge(t,e)}delaunify(t=!1){const{halfedges:e}=this.del,i=this.flips,o=this.consd,r=e.length;let s;do{s=0;for(let a=0;a<r;a++){if(o.has(a))continue;i.delete(a);const c=e[a];c!==-1&&(i.delete(c),this.isDelaunay(a)||(this.flipDiagonal(a),s++))}}while(t&&s>0);return this}constrainAll(t){const e=t.length;for(let i=0;i<e;i++){const o=t[i];this.constrainOne(o[0],o[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const i=this.vertMap[e],{triangles:o,halfedges:r}=this.del;let s=i,a=-1;do{if(o[s]===t)return s;a=qt(s),s=r[a]}while(s!==-1&&s!==i);return o[qt(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],i=this.flips,o=this.consd;return i.delete(t),o.add(t),e!==-1?(i.delete(e),o.add(e),e):-t}markFlip(t){const e=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const r=e[t];return r!==-1&&(i.add(t),i.add(r)),!0}flipDiagonal(t){const{triangles:e,halfedges:i}=this.del,o=this.flips,r=this.consd,s=i[t],a=Ot(t),c=qt(t),f=Ot(s),l=qt(s),h=i[a],u=i[f];if(r.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[f],i[t]=u,o.set(t,o.has(f))||r.set(t,r.has(f)),u!==-1&&(i[u]=t),i[a]=f,e[s]=e[a],i[s]=h,o.set(s,o.has(a))||r.set(s,r.has(a)),h!==-1&&(i[h]=s),i[f]=a,this.markFlip(t),this.markFlip(c),this.markFlip(s),this.markFlip(l),o.add(a),r.delete(a),o.add(f),r.delete(f),this.updateVert(t),this.updateVert(c),this.updateVert(s),this.updateVert(l),a}isCollinear(t,e,i){const o=this.del.coords;return St(o[t*2],o[t*2+1],o[e*2],o[e*2+1],o[i*2],o[i*2+1])===0}inCircle(t,e,i,o){const r=this.del.coords;return ni(r[t*2],r[t*2+1],r[e*2],r[e*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:i}=this.del,o=i[t];if(o===-1)return!0;const r=e[Ot(t)],s=e[t],a=e[qt(t)],c=e[Ot(o)];return!this.inCircle(r,s,a,c)}updateVert(t){const{triangles:e,halfedges:i}=this.del,o=this.vertMap,r=e[t];let s=Ot(t),a=i[s];for(;a!==-1&&a!==t;)s=Ot(a),a=i[s];return o[r]=s,s}intersectSegments(t,e,i,o){const r=this.del.coords;return t===i||t===o||e===i||e===o?!1:Pn(r[t*2],r[t*2+1],r[e*2],r[e*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])}static intersectSegments=Pn}function ne(n,t,e){if(t||(t=[]),typeof n!="object"||n.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const i=n.features.map(c=>c.geometry.coordinates),o=Fe.from(i);let r;const s=[];o.triangles.length!==0&&t.length!==0&&(r=new fr(o),r.constrainAll(t));for(let c=0;c<o.triangles.length;c+=3)s.push([o.triangles[c],o.triangles[c+1],o.triangles[c+2]]);const a=["a","b","c"];return _t(s.map(c=>{const f={},l=c.map((h,u)=>{const p=n.features[h],x=p.geometry.coordinates,y=[x[0],x[1]];return x.length===3?y[2]=x[2]:f[a[u]]=p.properties[e],y});return l[3]=l[0],Jt([l],f)}))}function hr(n,t){const e=[[],[],[],[]],i=[];return Object.keys(n).forEach(o=>{const r=n[o],s=r.forw,a=r.bakw,c=[s[0]-t.forw[0],s[1]-t.forw[1]],f=[a[0]-t.bakw[0],t.bakw[1]-a[1]],l={forw:c,bakw:f};if(i.push(l),c[0]===0||c[1]===0)return;let h=0;c[0]>0&&(h+=1),c[1]>0&&(h+=2),e[h].push(l)}),{perQuad:e,aggregate:i}}function lr(n){let t=1/0,e=0,i=0;return n.forEach(o=>{const{forw:r,bakw:s}=o,a=Math.hypot(r[0],r[1]),c=Math.hypot(s[0],s[1]);if(c===0)return;const f=a/c,l=Math.atan2(r[0],r[1])-Math.atan2(s[0],s[1]);t=Math.min(t,f),e+=Math.cos(l),i+=Math.sin(l)}),isFinite(t)?[t,Math.atan2(i,e)]:[1,0]}function ur(n,t,e){const{perQuad:i,aggregate:o}=hr(n,t),r=i.every(c=>c.length>0),a=(e==="birdeye"?r?i:[o]:[o]).map(c=>lr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function dr(n,t){let e=0;return n[0]>t[0]&&(e+=1),n[1]>t[1]&&(e+=2),e}function pr(n,t,e){const i=[n[0]-t.forw[0],n[1]-t.forw[1]],r=Math.sqrt(i[0]**2+i[1]**2)/e[0],s=Math.atan2(i[0],i[1])-e[1];return[t.bakw[0]+r*Math.sin(s),t.bakw[1]-r*Math.cos(s)]}function gr(n,t,e,i){const o=t[0]-n[0],r=t[1]-n[1];if(Math.abs(o)<1e-12&&Math.abs(r)<1e-12)return null;const s=i[0]-e[0],a=i[1]-e[1],c=e[0]-n[0],f=e[1]-n[1],l=o*a-r*s;if(Math.abs(l)<1e-12)return null;const h=(c*a-f*s)/l,u=(c*r-f*o)/l;return h<=1e-10||u<-1e-10||u>1+1e-10?null:{t:h,point:[n[0]+h*o,n[1]+h*r]}}function mr(n,t,e){const i=e.length;let o=-1/0,r=null;for(let s=0;s<i;s++){const a=(s+1)%i,c=gr(n,t,e[s].bakw,e[a].bakw);c&&c.t>o&&(o=c.t,r=c.point)}return r}function In(n,t){const i=Math.atan2(n[0]-t[0],n[1]-t[1])*(180/Math.PI);return i<0?i+360:i}function Bn(n,t,e,i,o,r){const s=t[0]-n[0],a=t[1]-n[1];if(s===0&&a===0)return null;const c=[];if(s!==0)for(const l of[e,i]){const h=(l-n[0])/s;if(h>0){const u=n[1]+h*a;u>=o&&u<=r&&c.push({t:h,x:l,y:u})}}if(a!==0)for(const l of[o,r]){const h=(l-n[1])/a;if(h>0){const u=n[0]+h*s;u>=e&&u<=i&&c.push({t:h,x:u,y:l})}}if(c.length===0)return null;c.sort((l,h)=>l.t-h.t);const f=c[0];return[f.x,f.y]}function On(n,t,e){const i=n.length,o=new Array(i).fill(1);for(const r of t)for(let s=0;s<i;s++){const a=(s+1)%i,c=We([n[s].bakw,n[a].bakw]),f=We([e.bakw,r.bakw]),l=di(c,f);if(l.features.length>0&&l.features[0].geometry){const h=l.features[0],u=Math.sqrt(Math.pow(r.bakw[0]-e.bakw[0],2)+Math.pow(r.bakw[1]-e.bakw[1],2)),p=Math.sqrt(Math.pow(h.geometry.coordinates[0]-e.bakw[0],2)+Math.pow(h.geometry.coordinates[1]-e.bakw[1],2)),x=u/p;x>o[s]&&(o[s]=x),x>o[a]&&(o[a]=x)}}n.forEach((r,s)=>{const a=o[s];r.bakw=[(r.bakw[0]-e.bakw[0])*a+e.bakw[0],(r.bakw[1]-e.bakw[1])*a+e.bakw[1]]})}function Tn(n,t,e){const{convexBuf:i,centroid:o,allGcps:r,minx:s,maxx:a,miny:c,maxy:f}=n,l=ur(i,o,t),u=[[s,c],[a,c],[a,f],[s,f]].map(m=>({forw:m,bakw:pr(m,o,l[dr(m,o.forw)])}));if(u.sort((m,A)=>Math.atan2(m.forw[0]-o.forw[0],m.forw[1]-o.forw[1])-Math.atan2(A.forw[0]-o.forw[0],A.forw[1]-o.forw[1])),On(u,r,o),!e)return u;const p=4,x=u.map(m=>Math.atan2(m.forw[0]-o.forw[0],m.forw[1]-o.forw[1])),y=u.map(m=>Math.atan2(m.bakw[0]-o.bakw[0],-(m.bakw[1]-o.bakw[1])));function k(m){for(let A=0;A<p;A++){const B=(A+1)%p,P=x[A],I=A<p-1?x[B]:x[B]+2*Math.PI;let N=m;for(;N<P;)N+=2*Math.PI;for(;N>=P+2*Math.PI;)N-=2*Math.PI;if(N>=P&&N<I)return{i:A,j:B,frac:(N-P)/(I-P)}}return{i:0,j:1,frac:0}}function S(m){const{i:A,j:B,frac:P}=k(m),I=y[A];let X=y[B]-I;for(;X>Math.PI;)X-=2*Math.PI;for(;X<-Math.PI;)X+=2*Math.PI;return I+P*X}const g=new Set(u.map(m=>Math.floor(In(m.forw,o.forw)/10)%36)),v=r.map(m=>({forw:m.forw,bakw:m.bakw,angleDeg:In(m.forw,o.forw),forwDist:Math.hypot(m.forw[0]-o.forw[0],m.forw[1]-o.forw[1])})),d=[];for(let m=0;m<36;m++){if(g.has(m))continue;const A=m*10,B=v.filter(E=>E.angleDeg>=A&&E.angleDeg<A+10);let P=null;if(B.length>0){const E=B.reduce((M,T)=>T.forwDist>M.forwDist?T:M);P=Bn(o.forw,E.forw,s,a,c,f)}if(!P){const E=(A+5)%360*(Math.PI/180),M=[o.forw[0]+Math.sin(E),o.forw[1]+Math.cos(E)];P=Bn(o.forw,M,s,a,c,f)}if(!P)continue;const I=[P[0]-o.forw[0],P[1]-o.forw[1]],N=Math.atan2(I[0],I[1]),X=S(N),F=[o.bakw[0]+Math.sin(X),o.bakw[1]-Math.cos(X)],w=mr(o.bakw,F,u);w&&d.push({forw:P,bakw:w})}const b=[...u,...d];return b.sort((m,A)=>Math.atan2(m.forw[0]-o.forw[0],m.forw[1]-o.forw[1])-Math.atan2(A.forw[0]-o.forw[0],A.forw[1]-o.forw[1])),On(b,r,o),b}function wr(n,t=!1){return Tn(n,"plain",t)}function yr(n,t=!1){return Tn(n,"birdeye",t)}function Nn(n){const e=new vr(n).findSegmentIntersections(),i=Fn(e),o=new Map;return i.forEach(r=>{o.set(`${r.x}:${r.y}`,r)}),Array.from(o.values()).map(r=>Nt([r.x,r.y]))}class vr{_xx;_yy;_ii;_nn;_zz=null;_zlimit=0;_bb=null;_allBounds=null;_arcIter=null;_filteredArcIter=null;buf;constructor(t){this.initArcs(t)}initArcs(t){const e=[],i=[],o=t.map(r=>{const s=r?r.length:0;for(let a=0;a<s;a++)e.push(r[a][0]),i.push(r[a][1]);return s});this.initXYData(o,e,i)}initXYData(t,e,i){const o=t.length;this._xx=new Float64Array(e),this._yy=new Float64Array(i),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(o);let r=0;for(let s=0;s<o;s++)this._ii[s]=r,r+=t[s];(r!=this._xx.length||this._xx.length!=this._yy.length)&&je("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Fr(this._xx,this._yy)}initBounds(){const t=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=t.bb,this._allBounds=t.bounds}calcArcBounds_(t,e,i){const o=i.length,r=new Float64Array(o*4),s=new re;let a=0,c,f,l;for(let h=0;h<o;h++)c=i[h],c>0&&(f=h*4,l=Lr(t,e,a,c),r[f++]=l[0],r[f++]=l[1],r[f++]=l[2],r[f]=l[3],a+=c,s.mergeBounds(l));return{bb:r,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new re}forEachSegment(t){let e=0;for(let i=0,o=this.size();i<o;i++)e+=this.forEachArcSegment(i,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const i=t>=0,o=i?t:~t,r=this.getRetainedInterval(),s=this._nn[o],a=i?1:-1;let c=i?this._ii[o]:this._ii[o]+s-1,f=c,l=0;for(let h=1;h<s;h++)f+=a,(r===0||this._zz[f]>=r)&&(e(c,f,this._xx,this._yy),c=f,l++);return l}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(t){const e=t*4;return(!this.buf||this.buf.byteLength<e)&&(this.buf=new ArrayBuffer(e)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,e=0;const i=this.forEachSegment((o,r,s,a)=>{t+=Math.abs(s[o]-s[r]),e+=Math.abs(a[o]-a[r])});return[t/i||0,e/i||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),e=this.getAvgSegment2()[1];let i=1;return e>0&&t>0&&(i=Math.ceil(t/e/20)),i||1}findSegmentIntersections(){const t=this.getBounds(),e=t.ymin||0,i=(t.ymax||0)-e,o=this.calcSegmentIntersectionStripeCount(),r=new Uint32Array(o),s=o>1?y=>Math.floor((o-1)*(y-e)/i):()=>0;let a,c;this.forEachSegment((y,k,S,g)=>{let v=s(g[y]);const d=s(g[k]);for(;r[v]=r[v]+2,v!=d;)v+=d>v?1:-1});const f=this.getUint32Array(_r(r));let l=0;const h=[];Mr(r,y=>{const k=l;l+=y,h.push(f.subarray(k,l))}),Sr(r,0),this.forEachSegment((y,k,S,g)=>{let v=s(g[y]);const d=s(g[k]);let b,m;for(;b=r[v],r[v]=b+2,m=h[v],m[b]=y,m[b+1]=k,v!=d;)v+=d>v?1:-1});const u=this.getVertexData(),p=[];let x;for(a=0;a<o;a++)if(u.xx&&u.yy)for(x=kr(h[a],u.xx,u.yy),c=0;c<x.length;c++)p.push(x[c]);return Fn(p)}}function je(...n){const t=n.join(" ");throw new Error(t)}function $e(n){return n?xr(n)?!0:br(n)?!1:n.length===0?!0:n.length>0:!1}function br(n){return n!=null&&n.toString===String.prototype.toString}function xr(n){return Array.isArray(n)}function _r(n,t){$e(n)||je("utils.sum() expects an array, received:",n);let e=0,i;for(let o=0,r=n.length;o<r;o++)i=n[o],i&&(e+=i);return e}function Mr(n,t,e){if(!$e(n))throw new Error(`#forEach() takes an array-like argument. ${n}`);for(let i=0,o=n.length;i<o;i++)t.call(e,n[i],i)}function Sr(n,t){for(let e=0,i=n.length;e<i;e++)n[e]=t;return n}function kr(n,t,e){const i=n.length-2,o=[];let r,s,a,c,f,l,h,u,p,x,y,k,S,g,v,d,b;for(Xr(t,n),d=0;d<i;){for(r=n[d],s=n[d+1],f=t[r],l=t[s],p=e[r],x=e[s],b=d;b<i&&(b+=2,a=n[b],h=t[a],!(l<h));){if(y=e[a],c=n[b+1],u=t[c],k=e[c],p>=y){if(p>k&&x>y&&x>k)continue}else if(p<k&&x<y&&x<k)continue;r==a||r==c||s==a||s==c||(S=Er(f,p,l,x,h,y,u,k),S&&(g=[r,s],v=[a,c],o.push(Rn(S,g,v,t,e)),S.length==4&&o.push(Rn(S.slice(2),g,v,t,e))))}d+=2}return o}function Er(n,t,e,i,o,r,s,a){const c=Ar(n,t,e,i,o,r,s,a);let f=null;return c&&(f=Pr(n,t,e,i,o,r,s,a),f?Cr(n,t,e,i,o,r,s,a)&&(f=null):f=Nr(n,t,e,i,o,r,s,a)),f}function Ar(n,t,e,i,o,r,s,a){return ie(n,t,e,i,o,r)*ie(n,t,e,i,s,a)<=0&&ie(o,r,s,a,n,t)*ie(o,r,s,a,e,i)<=0}function ie(n,t,e,i,o,r){return Cn(n-o,t-r,e-o,i-r)}function Cn(n,t,e,i){return n*i-t*e}function Pr(n,t,e,i,o,r,s,a){let c=ye(n,t,e,i,o,r,s,a),f;return c&&(f=Br(c[0],c[1],n,t,e,i,o,r,s,a),f==1?c=ye(e,i,n,t,o,r,s,a):f==2?c=ye(o,r,s,a,n,t,e,i):f==3&&(c=ye(s,a,o,r,n,t,e,i))),c&&Tr(c,n,t,e,i,o,r,s,a),c}function ye(n,t,e,i,o,r,s,a){const c=Cn(e-n,i-t,s-o,a-r),f=1e-18;let l;if(c===0)return null;const h=ie(o,r,s,a,n,t)/c;return c<=f&&c>=-f?l=Ir(n,t,e,i,o,r,s,a):l=[n+h*(e-n),t+h*(i-t)],l}function Ir(n,t,e,i,o,r,s,a){let c=null;return!Tt(n,o,s)&&!Tt(t,r,a)?c=[n,t]:!Tt(e,o,s)&&!Tt(i,r,a)?c=[e,i]:!Tt(o,n,e)&&!Tt(r,t,i)?c=[o,r]:!Tt(s,n,e)&&!Tt(a,t,i)&&(c=[s,a]),c}function Tt(n,t,e){let i;return t<e?i=n<t||n>e:t>e?i=n>t||n<e:i=n!=t,i}function Br(n,t,...e){let i=-1,o=1/0,r;for(let s=0,a=0,c=e.length;a<c;s++,a+=2)r=Or(n,t,e[a],e[a+1]),r<o&&(o=r,i=s);return i}function Or(n,t,e,i){const o=n-e,r=t-i;return o*o+r*r}function Tr(n,t,e,i,o,r,s,a,c){let f=n[0],l=n[1];f=ve(f,t,i),f=ve(f,r,a),l=ve(l,e,o),l=ve(l,s,c),n[0]=f,n[1]=l}function ve(n,t,e){let i;return Tt(n,t,e)&&(i=Math.abs(n-t)<Math.abs(n-e)?t:e,n=i),n}function Nr(n,t,e,i,o,r,s,a){const c=Math.min(n,e,o,s),f=Math.max(n,e,o,s),l=Math.min(t,i,r,a),h=Math.max(t,i,r,a),u=h-l>f-c;let p=[];return(u?Yt(t,l,h):Yt(n,c,f))&&p.push(n,t),(u?Yt(i,l,h):Yt(e,c,f))&&p.push(e,i),(u?Yt(r,l,h):Yt(o,c,f))&&p.push(o,r),(u?Yt(a,l,h):Yt(s,c,f))&&p.push(s,a),(p.length!=2&&p.length!=4||p.length==4&&p[0]==p[2]&&p[1]==p[3])&&(p=null),p}function Cr(n,t,e,i,o,r,s,a){return n==o&&t==r||n==s&&t==a||e==o&&i==r||e==s&&i==a}function Yt(n,t,e){return n>t&&n<e}function Xr(n,t){Dr(n,t),Xn(n,t,0,t.length-2)}function Dr(n,t){for(let e=0,i=t.length;e<i;e+=2)n[t[e]]>n[t[e+1]]&&Rr(t,e,e+1)}function Rr(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function Xn(n,t,e,i){let o=e,r=i,s,a;for(;o<i;){for(s=n[t[e+i>>2<<1]];o<=r;){for(;n[t[o]]<s;)o+=2;for(;n[t[r]]>s;)r-=2;o<=r&&(a=t[o],t[o]=t[r],t[r]=a,a=t[o+1],t[o+1]=t[r+1],t[r+1]=a,o+=2,r-=2)}if(r-e<40?Dn(n,t,e,r):Xn(n,t,e,r),i-o<40){Dn(n,t,o,i);return}e=o,r=i}}function Dn(n,t,e,i){let o,r;for(let s=e+2;s<=i;s+=2){o=t[s],r=t[s+1];let a;for(a=s-2;a>=e&&n[o]<n[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=o,t[a+3]=r}}function Rn(n,t,e,i,o){const r=n[0],s=n[1];t=Yn(r,s,t[0],t[1],i,o),e=Yn(r,s,e[0],e[1],i,o);const a=t[0]<e[0]?t:e,c=a==t?e:t;return{x:r,y:s,a,b:c}}function Yn(n,t,e,i,o,r){let s=e<i?e:i,a=s===e?i:e;return o[s]==n&&r[s]==t?a=s:o[a]==n&&r[a]==t&&(s=a),[s,a]}function Fn(n){const t={};return n.filter(e=>{const i=Yr(e);return i in t?!1:(t[i]=!0,!0)})}function Yr(n){return`${n.a.join(",")};${n.b.join(",")}`}class Fr{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,e){this._xx=t,this._yy=e}}function Lr(n,t,e,i){let o=e|0;const r=isNaN(i)?n.length-o:i+o;let s,a,c,f,l,h;if(r>0)c=l=n[o],f=h=t[o];else return[void 0,void 0,void 0,void 0];for(o++;o<r;o++)s=n[o],a=t[o],s<c&&(c=s),s>l&&(l=s),a<f&&(f=a),a>h&&(h=a);return[c,f,l,h]}class re{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new re(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,e,i,o){let r,s,a,c;if(arguments.length==1)if($e(t)){const f=t;r=f[0],s=f[1],a=f[2],c=f[3]}else{const f=t;r=f.xmin,s=f.ymin,a=f.xmax,c=f.ymax}else r=t,s=e,a=i,c=o;return this.xmin=r,this.ymin=s,this.xmax=a,this.ymax=c,(r>a||s>c)&&this.update(),this}update(){let t;this.xmin>this.xmax&&(t=this.xmin,this.xmin=this.xmax,this.xmax=t),this.ymin>this.ymax&&(t=this.ymin,this.ymin=this.ymax,this.ymax=t)}mergeBounds(t,...e){let i,o,r,s;return t instanceof re?(i=t.xmin,o=t.ymin,r=t.xmax,s=t.ymax):e.length==3?(i=t,o=e[0],r=e[1],s=e[2]):t.length==4?(i=t[0],o=t[1],r=t[2],s=t[3]):je("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(i,o,r,s):(i<this.xmin&&(this.xmin=i),o<this.ymin&&(this.ymin=o),r>this.xmax&&(this.xmax=r),s>this.ymax&&(this.ymax=s)),this}}function be(n){const t=["a","b","c"].map(e=>n.properties[e].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(e=>e.map(i=>t[i]).sort().join("-")).sort()}function qe(n,t,e){const i=be(t.forw),o=be(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
1
+ (function(bt,Ot){typeof exports=="object"&&typeof module<"u"?Ot(exports):typeof define=="function"&&define.amd?define(["exports"],Ot):(bt=typeof globalThis<"u"?globalThis:bt||self,Ot(bt.tin={}))})(this,(function(bt){"use strict";function Ot(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function Dt(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!en(e[0])||!en(e[1]))throw new Error("coordinates must contain numbers");return Ot({type:"Point",coordinates:e},t,n)}function Zt(e,t,n={}){for(const o of e){if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(o[o.length-1].length!==o[0].length)throw new Error("First and last Position are not equivalent.");for(let r=0;r<o[o.length-1].length;r++)if(o[o.length-1][r]!==o[0][r])throw new Error("First and last Position are not equivalent.")}return Ot({type:"Polygon",coordinates:e},t,n)}function tn(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Ot({type:"LineString",coordinates:e},t,n)}function St(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function en(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ni(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ii(e){return e.type==="Feature"?e.geometry:e}function Ae(e,t,n){if(e!==null)for(var i,o,r,s,a,l,f,u=0,c=0,h,p=e.type,M=p==="FeatureCollection",m=p==="Feature",S=M?e.features.length:1,_=0;_<S;_++){f=M?e.features[_].geometry:m?e.geometry:e,h=f?f.type==="GeometryCollection":!1,a=h?f.geometries.length:1;for(var g=0;g<a;g++){var v=0,d=0;if(s=h?f.geometries[g]:f,s!==null){l=s.coordinates;var b=s.type;switch(u=n&&(b==="Polygon"||b==="MultiPolygon")?1:0,b){case null:break;case"Point":if(t(l,c,_,v,d)===!1)return!1;c++,v++;break;case"LineString":case"MultiPoint":for(i=0;i<l.length;i++){if(t(l[i],c,_,v,d)===!1)return!1;c++,b==="MultiPoint"&&v++}b==="LineString"&&v++;break;case"Polygon":case"MultiLineString":for(i=0;i<l.length;i++){for(o=0;o<l[i].length-u;o++){if(t(l[i][o],c,_,v,d)===!1)return!1;c++}b==="MultiLineString"&&v++,b==="Polygon"&&d++}b==="Polygon"&&v++;break;case"MultiPolygon":for(i=0;i<l.length;i++){for(d=0,o=0;o<l[i].length;o++){for(r=0;r<l[i][o].length-u;r++){if(t(l[i][o][r],c,_,v,d)===!1)return!1;c++}d++}v++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(Ae(s.geometries[i],t,n)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const ut=11102230246251565e-32,U=134217729,nn=(3+8*ut)*ut;function lt(e,t,n,i,o){let r,s,a,l,f=t[0],u=i[0],c=0,h=0;u>f==u>-f?(r=f,f=t[++c]):(r=u,u=i[++h]);let p=0;if(c<e&&h<n)for(u>f==u>-f?(s=f+r,a=r-(s-f),f=t[++c]):(s=u+r,a=r-(s-u),u=i[++h]),r=s,a!==0&&(o[p++]=a);c<e&&h<n;)u>f==u>-f?(s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c]):(s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c],r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Mt(e,t,n,i,o,r,s,a){return lt(lt(e,t,n,i,s),s,o,r,a)}function $(e,t,n,i){let o,r,s,a,l,f,u,c,h,p,M;u=U*n,p=u-(u-n),M=n-p;let m=t[0];o=m*n,u=U*m,c=u-(u-m),h=m-c,s=h*M-(o-c*p-h*p-c*M);let S=0;s!==0&&(i[S++]=s);for(let _=1;_<e;_++)m=t[_],a=m*n,u=U*m,c=u-(u-m),h=m-c,l=h*M-(a-c*p-h*p-c*M),r=o+l,f=r-o,s=o-(r-f)+(l-f),s!==0&&(i[S++]=s),o=a+r,s=r-(o-a),s!==0&&(i[S++]=s);return(o!==0||S===0)&&(i[S++]=o),S}function rn(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function tt(e){return new Float64Array(e)}const ri=(3+16*ut)*ut,oi=(2+12*ut)*ut,si=(9+64*ut)*ut*ut,Wt=tt(4),on=tt(8),sn=tt(12),an=tt(16),gt=tt(4);function ai(e,t,n,i,o,r,s){let a,l,f,u,c,h,p,M,m,S,_,g,v,d,b,w,E,B;const P=e-o,I=n-o,O=t-r,X=i-r;d=P*X,h=U*P,p=h-(h-P),M=P-p,h=U*X,m=h-(h-X),S=X-m,b=M*S-(d-p*m-M*m-p*S),w=O*I,h=U*O,p=h-(h-O),M=O-p,h=U*I,m=h-(h-I),S=I-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,Wt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,Wt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,Wt[2]=g-(B-c)+(_-c),Wt[3]=B;let R=rn(4,Wt),y=oi*s;if(R>=y||-R>=y||(c=e-P,a=e-(P+c)+(c-o),c=n-I,f=n-(I+c)+(c-o),c=t-O,l=t-(O+c)+(c-r),c=i-X,u=i-(X+c)+(c-r),a===0&&l===0&&f===0&&u===0)||(y=si*s+nn*Math.abs(R),R+=P*u+X*a-(O*f+I*l),R>=y||-R>=y))return R;d=a*X,h=U*a,p=h-(h-a),M=a-p,h=U*X,m=h-(h-X),S=X-m,b=M*S-(d-p*m-M*m-p*S),w=l*I,h=U*l,p=h-(h-l),M=l-p,h=U*I,m=h-(h-I),S=I-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,gt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,gt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,gt[2]=g-(B-c)+(_-c),gt[3]=B;const A=lt(4,Wt,4,gt,on);d=P*u,h=U*P,p=h-(h-P),M=P-p,h=U*u,m=h-(h-u),S=u-m,b=M*S-(d-p*m-M*m-p*S),w=O*f,h=U*O,p=h-(h-O),M=O-p,h=U*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,gt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,gt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,gt[2]=g-(B-c)+(_-c),gt[3]=B;const k=lt(A,on,4,gt,sn);d=a*u,h=U*a,p=h-(h-a),M=a-p,h=U*u,m=h-(h-u),S=u-m,b=M*S-(d-p*m-M*m-p*S),w=l*f,h=U*l,p=h-(h-l),M=l-p,h=U*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,gt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,gt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,gt[2]=g-(B-c)+(_-c),gt[3]=B;const T=lt(k,sn,4,gt,an);return an[T-1]}function Et(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),l=s-a,f=Math.abs(s+a);return Math.abs(l)>=ri*f?l:-ai(e,t,n,i,o,r,f)}const ci=(10+96*ut)*ut,fi=(4+48*ut)*ut,li=(44+576*ut)*ut*ut,Yt=tt(4),Rt=tt(4),Ft=tt(4),At=tt(4),Pt=tt(4),It=tt(4),mt=tt(4),wt=tt(4),Pe=tt(8),Ie=tt(8),Be=tt(8),Oe=tt(8),Ne=tt(8),Te=tt(8),pe=tt(8),ge=tt(8),me=tt(8),Vt=tt(4),qt=tt(4),Ut=tt(4),z=tt(8),J=tt(16),nt=tt(16),it=tt(16),et=tt(32),$t=tt(32),st=tt(48),xt=tt(64);let Gt=tt(1152),Xe=tt(1152);function at(e,t,n){e=lt(e,Gt,t,n,Xe);const i=Gt;return Gt=Xe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pt[2]=N-(V-y)+(x-y),Pt[3]=V),(u!==0||p!==0||c!==0||M!==0)&&(F=K*K,A=U*K,k=A-(A-K),T=K-k,L=T*T-(F-k*k-(k+k)*T),j=H*H,A=U*H,k=A-(A-H),T=H-k,q=T*T-(j-k*k-(k+k)*T),x=L+q,y=x-L,It[0]=L-(x-y)+(q-y),N=F+x,y=N-F,D=F-(N-y)+(x-y),x=D+j,y=x-D,It[1]=D-(x-y)+(j-y),V=N+x,y=V-N,It[2]=N-(V-y)+(x-y),It[3]=V),u!==0&&(S=$(4,Yt,u,Pe),f=at(f,Mt($(S,Pe,2*G,J),J,$($(4,It,u,z),z,Z,nt),nt,$($(4,Pt,u,z),z,-H,it),it,et,st),st)),p!==0&&(_=$(4,Yt,p,Ie),f=at(f,Mt($(_,Ie,2*Q,J),J,$($(4,Pt,p,z),z,K,nt),nt,$($(4,It,p,z),z,-W,it),it,et,st),st)),c!==0&&(g=$(4,Rt,c,Be),f=at(f,Mt($(g,Be,2*W,J),J,$($(4,At,c,z),z,H,nt),nt,$($(4,It,c,z),z,-Q,it),it,et,st),st)),M!==0&&(v=$(4,Rt,M,Oe),f=at(f,Mt($(v,Oe,2*Z,J),J,$($(4,It,M,z),z,G,nt),nt,$($(4,At,M,z),z,-K,it),it,et,st),st)),h!==0&&(d=$(4,Ft,h,Ne),f=at(f,Mt($(d,Ne,2*K,J),J,$($(4,Pt,h,z),z,Q,nt),nt,$($(4,At,h,z),z,-Z,it),it,et,st),st)),m!==0&&(b=$(4,Ft,m,Te),f=at(f,Mt($(b,Te,2*H,J),J,$($(4,At,m,z),z,W,nt),nt,$($(4,Pt,m,z),z,-G,it),it,et,st),st)),u!==0||p!==0){if(c!==0||M!==0||h!==0||m!==0?(F=c*H,A=U*c,k=A-(A-c),T=c-k,A=U*H,C=A-(A-H),Y=H-C,L=T*Y-(F-k*C-T*C-k*Y),j=W*m,A=U*W,k=A-(A-W),T=W-k,A=U*m,C=A-(A-m),Y=m-C,q=T*Y-(j-k*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-(A-p),Y=p-C,q=T*Y-(j-k*C-T*C-k*Y),x=L-q,y=L-x,Vt[0]=L-(x+y)+(y-q),N=F+x,y=N-F,D=F-(N-y)+(x-y),x=D-j,y=D-x,Vt[1]=D-(x+y)+(y-j),V=N+x,y=V-N,Vt[2]=N-(V-y)+(x-y),Vt[3]=V,P=4):(pe[0]=0,w=1,Vt[0]=0,P=1),h!==0){const rt=$(w,pe,h,it);f=at(f,lt($(d,Ne,h,J),J,$(rt,it,2*K,et),et,st),st);const ot=$(P,Vt,h,z);f=at(f,Mt($(ot,z,2*K,J),J,$(ot,z,h,nt),nt,$(rt,it,h,et),et,$t,xt),xt),p!==0&&(f=at(f,$($(4,Pt,h,z),z,p,J),J)),M!==0&&(f=at(f,$($(4,At,-h,z),z,M,J),J))}if(m!==0){const rt=$(w,pe,m,it);f=at(f,lt($(b,Te,m,J),J,$(rt,it,2*H,et),et,st),st);const ot=$(P,Vt,m,z);f=at(f,Mt($(ot,z,2*H,J),J,$(ot,z,m,nt),nt,$(rt,it,m,et),et,$t,xt),xt)}}return Gt[f-1]}function ui(e,t,n,i,o,r,s,a){const l=e-s,f=n-s,u=o-s,c=t-a,h=i-a,p=r-a,M=f*p,m=u*h,S=l*l+c*c,_=u*c,g=l*p,v=f*f+h*h,d=l*h,b=f*c,w=u*u+p*p,E=S*(M-m)+v*(_-g)+w*(d-b),B=(Math.abs(M)+Math.abs(m))*S+(Math.abs(_)+Math.abs(g))*v+(Math.abs(d)+Math.abs(b))*w,P=ci*B;return E>P||-E>P?E:hi(e,t,n,i,o,r,s,a,B)}function di(e,t){var n,i,o=0,r,s,a,l,f,u,c,h=e[0],p=e[1],M=t.length;for(n=0;n<M;n++){i=0;var m=t[n],S=m.length-1;if(u=m[0],u[0]!==m[S][0]&&u[1]!==m[S][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-h,a=u[1]-p,i;i<S;i++){if(c=m[i+1],l=c[0]-h,f=c[1]-p,a===0&&f===0){if(l<=0&&s>=0||s<=0&&l>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(r=Et(s,l,a,f,0,0),r===0)return 0;(r>0&&f>0&&a<=0||r<0&&f<=0&&a>0)&&o++}u=c,a=f,s=l}}return o%2!==0}function Ce(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ni(e),o=ii(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&pi(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var l=0;l<a.length;++l){const f=di(i,a[l]);if(f===0&&!n.ignoreBoundary)return!0;if(f)return!0}return!1}function pi(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}class De{constructor(t=[],n=gi){if(this.data=t,this.length=this.data.length,this.compare=n,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:n,compare:i}=this,o=n[t];for(;t>0;){const r=t-1>>1,s=n[r];if(i(o,s)>=0)break;n[t]=s,t=r}n[t]=o}_down(t){const{data:n,compare:i}=this,o=this.length>>1,r=n[t];for(;t<o;){let s=(t<<1)+1,a=n[s];const l=s+1;if(l<this.length&&i(n[l],a)<0&&(s=l,a=n[l]),i(a,r)>=0)break;n[t]=a,t=s}n[t]=r}}function gi(e,t){return e<t?-1:e>t?1:0}const mi=Object.freeze(Object.defineProperty({__proto__:null,default:De},Symbol.toStringTag,{value:"Module"})),Nt=11102230246251565e-32,dt=134217729,wi=(3+8*Nt)*Nt;function Ye(e,t,n,i,o){let r,s,a,l,f=t[0],u=i[0],c=0,h=0;u>f==u>-f?(r=f,f=t[++c]):(r=u,u=i[++h]);let p=0;if(c<e&&h<n)for(u>f==u>-f?(s=f+r,a=r-(s-f),f=t[++c]):(s=u+r,a=r-(s-u),u=i[++h]),r=s,a!==0&&(o[p++]=a);c<e&&h<n;)u>f==u>-f?(s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c]):(s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c],r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function yi(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function te(e){return new Float64Array(e)}const vi=(3+16*Nt)*Nt,bi=(2+12*Nt)*Nt,xi=(9+64*Nt)*Nt*Nt,Jt=te(4),cn=te(8),fn=te(12),ln=te(16),yt=te(4);function _i(e,t,n,i,o,r,s){let a,l,f,u,c,h,p,M,m,S,_,g,v,d,b,w,E,B;const P=e-o,I=n-o,O=t-r,X=i-r;d=P*X,h=dt*P,p=h-(h-P),M=P-p,h=dt*X,m=h-(h-X),S=X-m,b=M*S-(d-p*m-M*m-p*S),w=O*I,h=dt*O,p=h-(h-O),M=O-p,h=dt*I,m=h-(h-I),S=I-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,Jt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,Jt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,Jt[2]=g-(B-c)+(_-c),Jt[3]=B;let R=yi(4,Jt),y=bi*s;if(R>=y||-R>=y||(c=e-P,a=e-(P+c)+(c-o),c=n-I,f=n-(I+c)+(c-o),c=t-O,l=t-(O+c)+(c-r),c=i-X,u=i-(X+c)+(c-r),a===0&&l===0&&f===0&&u===0)||(y=xi*s+wi*Math.abs(R),R+=P*u+X*a-(O*f+I*l),R>=y||-R>=y))return R;d=a*X,h=dt*a,p=h-(h-a),M=a-p,h=dt*X,m=h-(h-X),S=X-m,b=M*S-(d-p*m-M*m-p*S),w=l*I,h=dt*l,p=h-(h-l),M=l-p,h=dt*I,m=h-(h-I),S=I-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,yt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,yt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,yt[2]=g-(B-c)+(_-c),yt[3]=B;const A=Ye(4,Jt,4,yt,cn);d=P*u,h=dt*P,p=h-(h-P),M=P-p,h=dt*u,m=h-(h-u),S=u-m,b=M*S-(d-p*m-M*m-p*S),w=O*f,h=dt*O,p=h-(h-O),M=O-p,h=dt*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,yt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,yt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,yt[2]=g-(B-c)+(_-c),yt[3]=B;const k=Ye(A,cn,4,yt,fn);d=a*u,h=dt*a,p=h-(h-a),M=a-p,h=dt*u,m=h-(h-u),S=u-m,b=M*S-(d-p*m-M*m-p*S),w=l*f,h=dt*l,p=h-(h-l),M=l-p,h=dt*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,yt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,yt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,yt[2]=g-(B-c)+(_-c),yt[3]=B;const T=Ye(k,fn,4,yt,ln);return ln[T-1]}function hn(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),l=s-a;if(s===0||a===0||s>0!=a>0)return l;const f=Math.abs(s+a);return Math.abs(l)>=vi*f?l:-_i(e,t,n,i,o,r,f)}function Mi(e,t){const n=new De([],un);return ki(e,n),Ei(n,t)}function un(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x||e.p.x===t.p.x&&(e.featureId!==t.featureId||e.ringId!==t.ringId)&&e.isLeftEndpoint&&!t.isLeftEndpoint?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function Si(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}function ki(e,t){if(e.type==="FeatureCollection"){const n=e.features;for(let i=0;i<n.length;i++)dn(n[i],t)}else dn(e,t)}var we=0,ye=0,ve=0;function dn(e,t){const n=e.type==="Feature"?e.geometry:e;let i=n.coordinates;(n.type==="Polygon"||n.type==="MultiLineString")&&(i=[i]),n.type==="LineString"&&(i=[[i]]);for(let o=0;o<i.length;o++)for(let r=0;r<i[o].length;r++){let s=i[o][r][0],a=null;ye=ye+1;for(let l=0;l<i[o][r].length-1;l++){a=i[o][r][l+1];const f=new pn(s,we,ye,ve),u=new pn(a,we,ye,ve+1);f.otherEvent=u,u.otherEvent=f,un(f,u)>0?(u.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(f),t.push(u),s=a,ve=ve+1}}we=we+1}var pn=class{constructor(e,t,n,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=n,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}asNewXY(){return[this.p.x,this.p.y]}};function Ei(e,t=!1){const n=[],i=new De([],Si);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const r=new Ai(o);for(let s=0;s<i.data.length;s++){const a=i.data[s];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const l=Pi(r,a);l!==!1&&n.push(l)}i.push(r)}else o.isLeftEndpoint===!1&&i.pop()}return n}var Ai=class{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}};function Pi(e,t){if(e===null||t===null)return!1;const n=e.leftSweepEvent.p.x,i=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,r=e.rightSweepEvent.p.y,s=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,l=t.rightSweepEvent.p.x,f=t.rightSweepEvent.p.y,u=hn(n,i,o,r,s,a),c=hn(n,i,o,r,l,f);if(u>0&&c>0)return!1;if(u<0&&c<0)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId){if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return!1}else{if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.rightSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY()}const h=(f-a)*(o-n)-(l-s)*(r-i),p=(l-s)*(i-a)-(f-a)*(n-s),M=(o-n)*(i-a)-(r-i)*(n-s);if(h===0)return!1;const m=p/h,S=M/h;if(m>=0&&m<=1&&S>=0&&S<=1){const _=n+m*(o-n),g=i+m*(r-i);return[_,g]}return!1}function Ii(e,t,n={}){const{removeDuplicates:i=!0,ignoreSelfIntersections:o=!0}=n;let r=[];e.type==="FeatureCollection"?r=r.concat(e.features):e.type==="Feature"?r.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&r.push(Ot(e)),t.type==="FeatureCollection"?r=r.concat(t.features):t.type==="Feature"?r.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&r.push(Ot(t));const s=Mi(St(r),o);let a=[];if(i){const l={};s.forEach(f=>{const u=f.join(",");l[u]||(l[u]=!0,a.push(f))})}else a=s;return St(a.map(l=>Dt(l)))}function Bi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Oi(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function i(){var o=!1;try{o=this instanceof i}catch{}return o?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}),n}function Ni(e,t={}){let n=0,i=0,o=0;return Ae(e,function(r){n+=r[0],i+=r[1],o++},!0),Dt([n/o,i/o],t.properties)}var be={exports:{}},xe={exports:{}},Ti=xe.exports,gn;function Xi(){return gn||(gn=1,(function(e,t){(function(n,i){e.exports=i()})(Ti,function(){function n(g,v,d,b,w){(function E(B,P,I,O,X){for(;O>I;){if(O-I>600){var R=O-I+1,y=P-I+1,A=Math.log(R),k=.5*Math.exp(2*A/3),T=.5*Math.sqrt(A*k*(R-k)/R)*(y-R/2<0?-1:1),C=Math.max(I,Math.floor(P-y*k/R+T)),Y=Math.min(O,Math.floor(P+(R-y)*k/R+T));E(B,P,C,Y,X)}var x=B[P],N=I,D=O;for(i(B,I,P),X(B[O],x)>0&&i(B,I,O);N<D;){for(i(B,N,D),N++,D--;X(B[N],x)<0;)N++;for(;X(B[D],x)>0;)D--}X(B[I],x)===0?i(B,I,D):i(B,++D,O),D<=P&&(I=D+1),P<=D&&(O=D-1)}})(g,v,d||0,b||g.length-1,w||o)}function i(g,v,d){var b=g[v];g[v]=g[d],g[d]=b}function o(g,v){return g<v?-1:g>v?1:0}var r=function(g){g===void 0&&(g=9),this._maxEntries=Math.max(4,g),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(g,v,d){if(!d)return v.indexOf(g);for(var b=0;b<v.length;b++)if(d(g,v[b]))return b;return-1}function a(g,v){l(g,0,g.children.length,v,g)}function l(g,v,d,b,w){w||(w=S(null)),w.minX=1/0,w.minY=1/0,w.maxX=-1/0,w.maxY=-1/0;for(var E=v;E<d;E++){var B=g.children[E];f(w,g.leaf?b(B):B)}return w}function f(g,v){return g.minX=Math.min(g.minX,v.minX),g.minY=Math.min(g.minY,v.minY),g.maxX=Math.max(g.maxX,v.maxX),g.maxY=Math.max(g.maxY,v.maxY),g}function u(g,v){return g.minX-v.minX}function c(g,v){return g.minY-v.minY}function h(g){return(g.maxX-g.minX)*(g.maxY-g.minY)}function p(g){return g.maxX-g.minX+(g.maxY-g.minY)}function M(g,v){return g.minX<=v.minX&&g.minY<=v.minY&&v.maxX<=g.maxX&&v.maxY<=g.maxY}function m(g,v){return v.minX<=g.maxX&&v.minY<=g.maxY&&v.maxX>=g.minX&&v.maxY>=g.minY}function S(g){return{children:g,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function _(g,v,d,b,w){for(var E=[v,d];E.length;)if(!((d=E.pop())-(v=E.pop())<=b)){var B=v+Math.ceil((d-v)/b/2)*b;n(g,B,v,d,w),E.push(v,B,B,d)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(g){var v=this.data,d=[];if(!m(g,v))return d;for(var b=this.toBBox,w=[];v;){for(var E=0;E<v.children.length;E++){var B=v.children[E],P=v.leaf?b(B):B;m(g,P)&&(v.leaf?d.push(B):M(g,P)?this._all(B,d):w.push(B))}v=w.pop()}return d},r.prototype.collides=function(g){var v=this.data;if(!m(g,v))return!1;for(var d=[];v;){for(var b=0;b<v.children.length;b++){var w=v.children[b],E=v.leaf?this.toBBox(w):w;if(m(g,E)){if(v.leaf||M(g,E))return!0;d.push(w)}}v=d.pop()}return!1},r.prototype.load=function(g){if(!g||!g.length)return this;if(g.length<this._minEntries){for(var v=0;v<g.length;v++)this.insert(g[v]);return this}var d=this._build(g.slice(),0,g.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var b=this.data;this.data=d,d=b}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},r.prototype.insert=function(g){return g&&this._insert(g,this.data.height-1),this},r.prototype.clear=function(){return this.data=S([]),this},r.prototype.remove=function(g,v){if(!g)return this;for(var d,b,w,E=this.data,B=this.toBBox(g),P=[],I=[];E||P.length;){if(E||(E=P.pop(),b=P[P.length-1],d=I.pop(),w=!0),E.leaf){var O=s(g,E.children,v);if(O!==-1)return E.children.splice(O,1),P.push(E),this._condense(P),this}w||E.leaf||!M(E,B)?b?(d++,E=b.children[d],w=!1):E=null:(P.push(E),I.push(d),d=0,b=E,E=E.children[0])}return this},r.prototype.toBBox=function(g){return g},r.prototype.compareMinX=function(g,v){return g.minX-v.minX},r.prototype.compareMinY=function(g,v){return g.minY-v.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(g){return this.data=g,this},r.prototype._all=function(g,v){for(var d=[];g;)g.leaf?v.push.apply(v,g.children):d.push.apply(d,g.children),g=d.pop();return v},r.prototype._build=function(g,v,d,b){var w,E=d-v+1,B=this._maxEntries;if(E<=B)return a(w=S(g.slice(v,d+1)),this.toBBox),w;b||(b=Math.ceil(Math.log(E)/Math.log(B)),B=Math.ceil(E/Math.pow(B,b-1))),(w=S([])).leaf=!1,w.height=b;var P=Math.ceil(E/B),I=P*Math.ceil(Math.sqrt(B));_(g,v,d,I,this.compareMinX);for(var O=v;O<=d;O+=I){var X=Math.min(O+I-1,d);_(g,O,X,P,this.compareMinY);for(var R=O;R<=X;R+=P){var y=Math.min(R+P-1,X);w.children.push(this._build(g,R,y,b-1))}}return a(w,this.toBBox),w},r.prototype._chooseSubtree=function(g,v,d,b){for(;b.push(v),!v.leaf&&b.length-1!==d;){for(var w=1/0,E=1/0,B=void 0,P=0;P<v.children.length;P++){var I=v.children[P],O=h(I),X=(R=g,y=I,(Math.max(y.maxX,R.maxX)-Math.min(y.minX,R.minX))*(Math.max(y.maxY,R.maxY)-Math.min(y.minY,R.minY))-O);X<E?(E=X,w=O<w?O:w,B=I):X===E&&O<w&&(w=O,B=I)}v=B||v.children[0]}var R,y;return v},r.prototype._insert=function(g,v,d){var b=d?g:this.toBBox(g),w=[],E=this._chooseSubtree(b,this.data,v,w);for(E.children.push(g),f(E,b);v>=0&&w[v].children.length>this._maxEntries;)this._split(w,v),v--;this._adjustParentBBoxes(b,w,v)},r.prototype._split=function(g,v){var d=g[v],b=d.children.length,w=this._minEntries;this._chooseSplitAxis(d,w,b);var E=this._chooseSplitIndex(d,w,b),B=S(d.children.splice(E,d.children.length-E));B.height=d.height,B.leaf=d.leaf,a(d,this.toBBox),a(B,this.toBBox),v?g[v-1].children.push(B):this._splitRoot(d,B)},r.prototype._splitRoot=function(g,v){this.data=S([g,v]),this.data.height=g.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(g,v,d){for(var b,w,E,B,P,I,O,X=1/0,R=1/0,y=v;y<=d-v;y++){var A=l(g,0,y,this.toBBox),k=l(g,y,d,this.toBBox),T=(w=A,E=k,B=void 0,P=void 0,I=void 0,O=void 0,B=Math.max(w.minX,E.minX),P=Math.max(w.minY,E.minY),I=Math.min(w.maxX,E.maxX),O=Math.min(w.maxY,E.maxY),Math.max(0,I-B)*Math.max(0,O-P)),C=h(A)+h(k);T<X?(X=T,b=y,R=C<R?C:R):T===X&&C<R&&(R=C,b=y)}return b||d-v},r.prototype._chooseSplitAxis=function(g,v,d){var b=g.leaf?this.compareMinX:u,w=g.leaf?this.compareMinY:c;this._allDistMargin(g,v,d,b)<this._allDistMargin(g,v,d,w)&&g.children.sort(b)},r.prototype._allDistMargin=function(g,v,d,b){g.children.sort(b);for(var w=this.toBBox,E=l(g,0,v,w),B=l(g,d-v,d,w),P=p(E)+p(B),I=v;I<d-v;I++){var O=g.children[I];f(E,g.leaf?w(O):O),P+=p(E)}for(var X=d-v-1;X>=v;X--){var R=g.children[X];f(B,g.leaf?w(R):R),P+=p(B)}return P},r.prototype._adjustParentBBoxes=function(g,v,d){for(var b=d;b>=0;b--)f(v[b],g)},r.prototype._condense=function(g){for(var v=g.length-1,d=void 0;v>=0;v--)g[v].children.length===0?v>0?(d=g[v-1].children).splice(d.indexOf(g[v]),1):this.clear():a(g[v],this.toBBox)},r})})(xe)),xe.exports}const Ci=Oi(mi);var ee={exports:{}},Re,mn;function Di(){return mn||(mn=1,Re=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var l=(o-i)/2,f=0,u=l-1;f<l;u=f++){var c=n[i+f*2+0],h=n[i+f*2+1],p=n[i+u*2+0],M=n[i+u*2+1],m=h>s!=M>s&&r<(p-c)*(s-h)/(M-h)+c;m&&(a=!a)}return a}),Re}var Fe,wn;function Yi(){return wn||(wn=1,Fe=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var l=o-i,f=0,u=l-1;f<l;u=f++){var c=n[f+i][0],h=n[f+i][1],p=n[u+i][0],M=n[u+i][1],m=h>s!=M>s&&r<(p-c)*(s-h)/(M-h)+c;m&&(a=!a)}return a}),Fe}var yn;function Ri(){if(yn)return ee.exports;yn=1;var e=Di(),t=Yi();return ee.exports=function(i,o,r,s){return o.length>0&&Array.isArray(o[0])?t(i,o,r,s):e(i,o,r,s)},ee.exports.nested=t,ee.exports.flat=e,ee.exports}var ne={exports:{}},Fi=ne.exports,vn;function $i(){return vn||(vn=1,(function(e,t){(function(n,i){i(t)})(Fi,function(n){const o=33306690738754706e-32;function r(m,S,_,g,v){let d,b,w,E,B=S[0],P=g[0],I=0,O=0;P>B==P>-B?(d=B,B=S[++I]):(d=P,P=g[++O]);let X=0;if(I<m&&O<_)for(P>B==P>-B?(w=d-((b=B+d)-B),B=S[++I]):(w=d-((b=P+d)-P),P=g[++O]),d=b,w!==0&&(v[X++]=w);I<m&&O<_;)P>B==P>-B?(w=d-((b=d+B)-(E=b-d))+(B-E),B=S[++I]):(w=d-((b=d+P)-(E=b-d))+(P-E),P=g[++O]),d=b,w!==0&&(v[X++]=w);for(;I<m;)w=d-((b=d+B)-(E=b-d))+(B-E),B=S[++I],d=b,w!==0&&(v[X++]=w);for(;O<_;)w=d-((b=d+P)-(E=b-d))+(P-E),P=g[++O],d=b,w!==0&&(v[X++]=w);return d===0&&X!==0||(v[X++]=d),X}function s(m){return new Float64Array(m)}const a=33306690738754716e-32,l=22204460492503146e-32,f=11093356479670487e-47,u=s(4),c=s(8),h=s(12),p=s(16),M=s(4);n.orient2d=function(m,S,_,g,v,d){const b=(S-d)*(_-v),w=(m-v)*(g-d),E=b-w;if(b===0||w===0||b>0!=w>0)return E;const B=Math.abs(b+w);return Math.abs(E)>=a*B?E:-(function(P,I,O,X,R,y,A){let k,T,C,Y,x,N,D,F,L,j,q,V,G,W,K,Q,Z,H;const ft=P-R,ht=O-R,rt=I-y,ot=X-y;x=(K=(F=ft-(D=(N=134217729*ft)-(N-ft)))*(j=ot-(L=(N=134217729*ot)-(N-ot)))-((W=ft*ot)-D*L-F*L-D*j))-(q=K-(Z=(F=rt-(D=(N=134217729*rt)-(N-rt)))*(j=ht-(L=(N=134217729*ht)-(N-ht)))-((Q=rt*ht)-D*L-F*L-D*j))),u[0]=K-(q+x)+(x-Z),x=(G=W-((V=W+q)-(x=V-W))+(q-x))-(q=G-Q),u[1]=G-(q+x)+(x-Q),x=(H=V+q)-V,u[2]=V-(H-x)+(q-x),u[3]=H;let jt=(function(uo,ti){let ei=ti[0];for(let Ze=1;Ze<uo;Ze++)ei+=ti[Ze];return ei})(4,u),de=l*A;if(jt>=de||-jt>=de||(k=P-(ft+(x=P-ft))+(x-R),C=O-(ht+(x=O-ht))+(x-R),T=I-(rt+(x=I-rt))+(x-y),Y=X-(ot+(x=X-ot))+(x-y),k===0&&T===0&&C===0&&Y===0)||(de=f*A+o*Math.abs(jt),(jt+=ft*Y+ot*k-(rt*C+ht*T))>=de||-jt>=de))return jt;x=(K=(F=k-(D=(N=134217729*k)-(N-k)))*(j=ot-(L=(N=134217729*ot)-(N-ot)))-((W=k*ot)-D*L-F*L-D*j))-(q=K-(Z=(F=T-(D=(N=134217729*T)-(N-T)))*(j=ht-(L=(N=134217729*ht)-(N-ht)))-((Q=T*ht)-D*L-F*L-D*j))),M[0]=K-(q+x)+(x-Z),x=(G=W-((V=W+q)-(x=V-W))+(q-x))-(q=G-Q),M[1]=G-(q+x)+(x-Q),x=(H=V+q)-V,M[2]=V-(H-x)+(q-x),M[3]=H;const fo=r(4,u,4,M,c);x=(K=(F=ft-(D=(N=134217729*ft)-(N-ft)))*(j=Y-(L=(N=134217729*Y)-(N-Y)))-((W=ft*Y)-D*L-F*L-D*j))-(q=K-(Z=(F=rt-(D=(N=134217729*rt)-(N-rt)))*(j=C-(L=(N=134217729*C)-(N-C)))-((Q=rt*C)-D*L-F*L-D*j))),M[0]=K-(q+x)+(x-Z),x=(G=W-((V=W+q)-(x=V-W))+(q-x))-(q=G-Q),M[1]=G-(q+x)+(x-Q),x=(H=V+q)-V,M[2]=V-(H-x)+(q-x),M[3]=H;const lo=r(fo,c,4,M,h);x=(K=(F=k-(D=(N=134217729*k)-(N-k)))*(j=Y-(L=(N=134217729*Y)-(N-Y)))-((W=k*Y)-D*L-F*L-D*j))-(q=K-(Z=(F=T-(D=(N=134217729*T)-(N-T)))*(j=C-(L=(N=134217729*C)-(N-C)))-((Q=T*C)-D*L-F*L-D*j))),M[0]=K-(q+x)+(x-Z),x=(G=W-((V=W+q)-(x=V-W))+(q-x))-(q=G-Q),M[1]=G-(q+x)+(x-Q),x=(H=V+q)-V,M[2]=V-(H-x)+(q-x),M[3]=H;const ho=r(lo,h,4,M,p);return p[ho-1]})(m,S,_,g,v,d,B)},n.orient2dfast=function(m,S,_,g,v,d){return(S-d)*(_-v)-(m-v)*(g-d)},Object.defineProperty(n,"__esModule",{value:!0})})})(ne,ne.exports)),ne.exports}var bn;function Li(){if(bn)return be.exports;bn=1;var e=Xi(),t=Ci,n=Ri(),i=$i().orient2d;t.default&&(t=t.default),be.exports=o,be.exports.default=o;function o(d,b,w){b=Math.max(0,b===void 0?2:b),w=w||0;var E=p(d),B=new e(16);B.toBBox=function(D){return{minX:D[0],minY:D[1],maxX:D[0],maxY:D[1]}},B.compareMinX=function(D,F){return D[0]-F[0]},B.compareMinY=function(D,F){return D[1]-F[1]},B.load(d);for(var P=[],I=0,O;I<E.length;I++){var X=E[I];B.remove(X),O=M(X,O),P.push(O)}var R=new e(16);for(I=0;I<P.length;I++)R.insert(h(P[I]));for(var y=b*b,A=w*w;P.length;){var k=P.shift(),T=k.p,C=k.next.p,Y=m(T,C);if(!(Y<A)){var x=Y/y;X=r(B,k.prev.p,T,C,k.next.next.p,x,R),X&&Math.min(m(X,T),m(X,C))<=x&&(P.push(k),P.push(M(X,k)),B.remove(X),R.remove(k),R.insert(h(k)),R.insert(h(k.next)))}}k=O;var N=[];do N.push(k.p),k=k.next;while(k!==O);return N.push(k.p),N}function r(d,b,w,E,B,P,I){for(var O=new t([],s),X=d.data;X;){for(var R=0;R<X.children.length;R++){var y=X.children[R],A=X.leaf?S(y,w,E):a(w,E,y);A>P||O.push({node:y,dist:A})}for(;O.length&&!O.peek().node.children;){var k=O.pop(),T=k.node,C=S(T,b,w),Y=S(T,E,B);if(k.dist<C&&k.dist<Y&&f(w,T,I)&&f(E,T,I))return T}X=O.pop(),X&&(X=X.node)}return null}function s(d,b){return d.dist-b.dist}function a(d,b,w){if(l(d,w)||l(b,w))return 0;var E=_(d[0],d[1],b[0],b[1],w.minX,w.minY,w.maxX,w.minY);if(E===0)return 0;var B=_(d[0],d[1],b[0],b[1],w.minX,w.minY,w.minX,w.maxY);if(B===0)return 0;var P=_(d[0],d[1],b[0],b[1],w.maxX,w.minY,w.maxX,w.maxY);if(P===0)return 0;var I=_(d[0],d[1],b[0],b[1],w.minX,w.maxY,w.maxX,w.maxY);return I===0?0:Math.min(E,B,P,I)}function l(d,b){return d[0]>=b.minX&&d[0]<=b.maxX&&d[1]>=b.minY&&d[1]<=b.maxY}function f(d,b,w){for(var E=Math.min(d[0],b[0]),B=Math.min(d[1],b[1]),P=Math.max(d[0],b[0]),I=Math.max(d[1],b[1]),O=w.search({minX:E,minY:B,maxX:P,maxY:I}),X=0;X<O.length;X++)if(c(O[X].p,O[X].next.p,d,b))return!1;return!0}function u(d,b,w){return i(d[0],d[1],b[0],b[1],w[0],w[1])}function c(d,b,w,E){return d!==E&&b!==w&&u(d,b,w)>0!=u(d,b,E)>0&&u(w,E,d)>0!=u(w,E,b)>0}function h(d){var b=d.p,w=d.next.p;return d.minX=Math.min(b[0],w[0]),d.minY=Math.min(b[1],w[1]),d.maxX=Math.max(b[0],w[0]),d.maxY=Math.max(b[1],w[1]),d}function p(d){for(var b=d[0],w=d[0],E=d[0],B=d[0],P=0;P<d.length;P++){var I=d[P];I[0]<b[0]&&(b=I),I[0]>E[0]&&(E=I),I[1]<w[1]&&(w=I),I[1]>B[1]&&(B=I)}var O=[b,w,E,B],X=O.slice();for(P=0;P<d.length;P++)n(d[P],O)||X.push(d[P]);return v(X)}function M(d,b){var w={p:d,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return b?(w.next=b.next,w.prev=b,b.next.prev=w,b.next=w):(w.prev=w,w.next=w),w}function m(d,b){var w=d[0]-b[0],E=d[1]-b[1];return w*w+E*E}function S(d,b,w){var E=b[0],B=b[1],P=w[0]-E,I=w[1]-B;if(P!==0||I!==0){var O=((d[0]-E)*P+(d[1]-B)*I)/(P*P+I*I);O>1?(E=w[0],B=w[1]):O>0&&(E+=P*O,B+=I*O)}return P=d[0]-E,I=d[1]-B,P*P+I*I}function _(d,b,w,E,B,P,I,O){var X=w-d,R=E-b,y=I-B,A=O-P,k=d-B,T=b-P,C=X*X+R*R,Y=X*y+R*A,x=y*y+A*A,N=X*k+R*T,D=y*k+A*T,F=C*x-Y*Y,L,j,q,V,G=F,W=F;F===0?(j=0,G=1,V=D,W=x):(j=Y*D-x*N,V=C*D-Y*N,j<0?(j=0,V=D,W=x):j>G&&(j=G,V=D+Y,W=x)),V<0?(V=0,-N<0?j=0:-N>C?j=G:(j=-N,G=C)):V>W&&(V=W,-N+Y<0?j=0:-N+Y>C?j=G:(j=-N+Y,G=C)),L=j===0?0:j/G,q=V===0?0:V/W;var K=(1-L)*d+L*w,Q=(1-L)*b+L*E,Z=(1-q)*B+q*I,H=(1-q)*P+q*O,ft=Z-K,ht=H-Q;return ft*ft+ht*ht}function g(d,b){return d[0]===b[0]?d[1]-b[1]:d[0]-b[0]}function v(d){d.sort(g);for(var b=[],w=0;w<d.length;w++){for(;b.length>=2&&u(b[b.length-2],b[b.length-1],d[w])<=0;)b.pop();b.push(d[w])}for(var E=[],B=d.length-1;B>=0;B--){for(;E.length>=2&&u(E[E.length-2],E[E.length-1],d[B])<=0;)E.pop();E.push(d[B])}return E.pop(),b.pop(),b.concat(E)}return be.exports}var ji=Li();const Vi=Bi(ji);function xn(e,t={}){t.concavity=t.concavity||1/0;const n=[];if(Ae(e,o=>{n.push([o[0],o[1]])}),!n.length)return null;const i=Vi(n,t.concavity);return i.length>3?Zt([i],t.properties):null}function _n(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function ie(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Sn(e[0])||!Sn(e[1]))throw new Error("coordinates must contain numbers");return _n({type:"Point",coordinates:e},t,n)}function Mn(e,t,n={}){for(const i of e){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let o=0;o<i[i.length-1].length;o++)if(i[i.length-1][o]!==i[0][o])throw new Error("First and last Position are not equivalent.")}return _n({type:"Polygon",coordinates:e},t,n)}function Kt(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function Sn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function qi(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function kn(e){if(Array.isArray(e))return e;if(e.type==="Feature"){if(e.geometry!==null)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Ui(e){return e.type==="Feature"?e.geometry:e}const Tt=11102230246251565e-32,pt=134217729,zi=(3+8*Tt)*Tt;function $e(e,t,n,i,o){let r,s,a,l,f=t[0],u=i[0],c=0,h=0;u>f==u>-f?(r=f,f=t[++c]):(r=u,u=i[++h]);let p=0;if(c<e&&h<n)for(u>f==u>-f?(s=f+r,a=r-(s-f),f=t[++c]):(s=u+r,a=r-(s-u),u=i[++h]),r=s,a!==0&&(o[p++]=a);c<e&&h<n;)u>f==u>-f?(s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c]):(s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c],r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Wi(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function re(e){return new Float64Array(e)}const Gi=(3+16*Tt)*Tt,Ji=(2+12*Tt)*Tt,Ki=(9+64*Tt)*Tt*Tt,Q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vt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,vt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,vt[2]=g-(B-c)+(_-c),vt[3]=B;const k=$e(A,En,4,vt,An);d=a*u,h=pt*a,p=h-(h-a),M=a-p,h=pt*u,m=h-(h-u),S=u-m,b=M*S-(d-p*m-M*m-p*S),w=l*f,h=pt*l,p=h-(h-l),M=l-p,h=pt*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,vt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,vt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,vt[2]=g-(B-c)+(_-c),vt[3]=B;const T=$e(k,An,4,vt,Pn);return Pn[T-1]}function Hi(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),l=s-a,f=Math.abs(s+a);return Math.abs(l)>=Gi*f?l:-Qi(e,t,n,i,o,r,f)}function Zi(e,t){var n,i,o=0,r,s,a,l,f,u,c,h=e[0],p=e[1],M=t.length;for(n=0;n<M;n++){i=0;var m=t[n],S=m.length-1;if(u=m[0],u[0]!==m[S][0]&&u[1]!==m[S][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-h,a=u[1]-p,i;i<S;i++){if(c=m[i+1],l=c[0]-h,f=c[1]-p,a===0&&f===0){if(l<=0&&s>=0||s<=0&&l>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(r=Hi(s,l,a,f,0,0),r===0)return 0;(r>0&&f>0&&a<=0||r<0&&f<=0&&a>0)&&o++}u=c,a=f,s=l}}return o%2!==0}function Le(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=qi(e),o=Ui(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&tr(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);let l=!1;for(var f=0;f<a.length;++f){const u=Zi(i,a[f]);if(u===0)return!n.ignoreBoundary;u&&(l=!0)}return l}function tr(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}function je(e,t){for(let n=0;n<t.features.length;n++)if(Le(e,t.features[n]))return t.features[n]}function In(e,t,n){const i=t.geometry.coordinates[0][0],o=t.geometry.coordinates[0][1],r=t.geometry.coordinates[0][2],s=e.geometry.coordinates,a=t.properties.a.geom,l=t.properties.b.geom,f=t.properties.c.geom,u=[o[0]-i[0],o[1]-i[1]],c=[r[0]-i[0],r[1]-i[1]],h=[s[0]-i[0],s[1]-i[1]],p=[l[0]-a[0],l[1]-a[1]],M=[f[0]-a[0],f[1]-a[1]];let m=(c[1]*h[0]-c[0]*h[1])/(u[0]*c[1]-u[1]*c[0]),S=(u[0]*h[1]-u[1]*h[0])/(u[0]*c[1]-u[1]*c[0]);if(n){const _=n[t.properties.a.index],g=n[t.properties.b.index],v=n[t.properties.c.index];let d;if(m<0||S<0||1-m-S<0){const b=m/(m+S),w=S/(m+S);d=m/g/(b/g+w/v),S=S/v/(b/g+w/v)}else d=m/g/(m/g+S/v+(1-m-S)/_),S=S/v/(m/g+S/v+(1-m-S)/_);m=d}return[m*p[0]+S*M[0]+a[0],m*p[1]+S*M[1]+a[1]]}function er(e,t,n,i){const o=e.geometry.coordinates,r=n.geometry.coordinates,s=Math.atan2(o[0]-r[0],o[1]-r[1]),a=nr(s,t[0]);if(a===void 0)throw new Error("Unable to determine vertex index");const l=t[1][a];return In(e,l.features[0],i)}function oe(e,t,n,i,o,r,s,a){let l;if(s&&(l=je(e,Kt([s]))),!l)if(n){const f=e.geometry.coordinates,u=n.gridNum,c=n.xOrigin,h=n.yOrigin,p=n.xUnit,M=n.yUnit,m=n.gridCache,S=Bt(f[0],c,p,u),_=Bt(f[1],h,M,u),g=m[S]?m[S][_]?m[S][_]:[]:[],v=Kt(g.map(d=>t.features[d]));l=je(e,v)}else l=je(e,t);return a&&a(l),l?In(e,l,r):er(e,i,o,r)}function Bt(e,t,n,i){let o=Math.floor((e-t)/n);return o<0&&(o=0),o>=i&&(o=i-1),o}function nr(e,t){let n=Bn(e-t[0]),i=Math.PI*2,o;for(let r=0;r<t.length;r++){const s=(r+1)%t.length,a=Bn(e-t[s]),l=Math.min(Math.abs(n),Math.abs(a));n*a<=0&&l<i&&(i=l,o=r),n=a}return o}function Bn(e,t=!1){const n=2*Math.PI,i=e-Math.floor(e/n)*n;return t?i:i>Math.PI?i-n:i}function On(e){const t=e.features;for(let n=0;n<t.length;n++){const i=t[n];`${i.properties.a.index}`.substring(0,1)==="b"&&`${i.properties.b.index}`.substring(0,1)==="b"?t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1],i.geometry.coordinates[0][2]]]},properties:{a:{geom:i.properties.c.geom,index:i.properties.c.index},b:{geom:i.properties.a.geom,index:i.properties.a.index},c:{geom:i.properties.b.geom,index:i.properties.b.index}},type:"Feature"}:`${i.properties.c.index}`.substring(0,1)==="b"&&`${i.properties.a.index}`.substring(0,1)==="b"&&(t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][1],i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1]]]},properties:{a:{geom:i.properties.b.geom,index:i.properties.b.index},b:{geom:i.properties.c.geom,index:i.properties.c.index},c:{geom:i.properties.a.geom,index:i.properties.a.index}},type:"Feature"})}return e}function Nn(e){const t=["a","b","c","a"].map(r=>e.properties[r].geom),n=e.geometry.coordinates[0],i=e.properties,o={a:{geom:n[0],index:i.a.index},b:{geom:n[1],index:i.b.index},c:{geom:n[2],index:i.c.index}};return Mn([t],o)}function ir(e){const t=[0,1,2,0].map(i=>e[i][0][0]),n={a:{geom:e[0][0][1],index:e[0][1]},b:{geom:e[1][0][1],index:e[1][1]},c:{geom:e[2][0][1],index:e[2][1]}};return Mn([t],n)}function Ve(e,t,n,i,o,r=!1,s){const a=e.map(l=>{(!s||s<2.00703)&&(l=Tn(l));const f=isFinite(l)?t[l]:l==="c"?i:(function(){const u=l.match(/^b(\d+)$/);if(u)return o[parseInt(u[1])];const c=l.match(/^e(\d+)$/);if(c)return n[parseInt(c[1])];throw new Error("Bad index value for indexesToTri")})();return r?[[f[1],f[0]],l]:[[f[0],f[1]],l]});return ir(a)}function Tn(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function Xn(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(n=>[n.illstNodes,n.mercNodes,n.startEnd])}const qe=2.00703;function rr(e){return!!(e.version!==void 0||!e.tins&&e.points&&e.tins_points)}function or(e){return{points:e.points,pointsWeightBuffer:ar(e),strictStatus:cr(e),verticesParams:fr(e),centroid:lr(e),edges:Xn(e.edges||[]),edgeNodes:e.edgeNodes||[],tins:hr(e),kinks:ur(e.kinks_points),yaxisMode:e.yaxisMode??"invert",strictMode:e.strictMode??"auto",vertexMode:e.vertexMode,bounds:e.bounds,boundsPolygon:e.boundsPolygon,wh:e.wh,xy:e.xy??[0,0]}}function sr(e){const t=dr(e),n=t.tins;return{compiled:t,tins:n,points:pr(n),strictStatus:t.strict_status,pointsWeightBuffer:t.weight_buffer,verticesParams:t.vertices_params,centroid:t.centroid,kinks:t.kinks}}function ar(e){return!e.version||e.version<qe?["forw","bakw"].reduce((t,n)=>{const i=e.weight_buffer[n];return i&&(t[n]=Object.keys(i).reduce((o,r)=>{const s=Tn(r);return o[s]=i[r],o},{})),t},{}):e.weight_buffer}function cr(e){return e.strict_status?e.strict_status:e.kinks_points?"strict_error":e.tins_points.length===2?"loose":"strict"}function fr(e){const t={forw:[e.vertices_params[0]],bakw:[e.vertices_params[1]]};return t.forw[1]=Cn(e,!1),t.bakw[1]=Cn(e,!0),t}function Cn(e,t){const n=e.vertices_points.length;return Array.from({length:n},(i,o)=>{const r=(o+1)%n,s=Ve(["c",`b${o}`,`b${r}`],e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,t,qe);return Kt([s])})}function lr(e){return{forw:ie(e.centroid_point[0],{target:{geom:e.centroid_point[1],index:"c"}}),bakw:ie(e.centroid_point[1],{target:{geom:e.centroid_point[0],index:"c"}})}}function hr(e){const t=e.tins_points.length===1?0:1;return{forw:Kt(e.tins_points[0].map(n=>Ve(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!1,e.version))),bakw:Kt(e.tins_points[t].map(n=>Ve(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!0,e.version)))}}function ur(e){if(e)return{bakw:Kt(e.map(t=>ie(t)))}}function dr(e){return JSON.parse(JSON.stringify(e).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function pr(e){const t=[],n=e.forw.features;for(let i=0;i<n.length;i++){const o=n[i];["a","b","c"].forEach((r,s)=>{const a=o.geometry.coordinates[0][s],l=o.properties[r].geom,f=o.properties[r].index;typeof f=="number"&&(t[f]=[a,l])})}return t}const Ue=qe;class kt{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=kt.YAXIS_INVERT;strictMode=kt.MODE_AUTO;vertexMode=kt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(t){if(rr(t)){this.applyModernState(or(t));return}this.applyLegacyState(sr(t))}applyModernState(t){this.points=t.points,this.pointsWeightBuffer=t.pointsWeightBuffer,this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.edges=t.edges,this.edgeNodes=t.edgeNodes||[],this.tins=t.tins,this.addIndexedTin(),this.kinks=t.kinks,this.yaxisMode=t.yaxisMode??kt.YAXIS_INVERT,this.vertexMode=t.vertexMode??kt.VERTEX_PLAIN,this.strictMode=t.strictMode??kt.MODE_AUTO,t.bounds?(this.bounds=t.bounds,this.boundsPolygon=t.boundsPolygon,this.xy=t.xy,this.wh=t.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=t.xy??[0,0],t.wh&&(this.wh=t.wh))}applyLegacyState(t){this.tins=t.tins,this.addIndexedTin(),this.strict_status=t.strictStatus,this.pointsWeightBuffer=t.pointsWeightBuffer,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.kinks=t.kinks,this.points=t.points}addIndexedTin(){const t=this.tins,n=t.forw,i=t.bakw,o=Math.ceil(Math.sqrt(n.features.length));if(o<3){this.indexedTins=void 0;return}let r=[],s=[];const a=n.features.map(m=>{let S=[];return kn(m)[0].map(_=>{r.length===0?r=[Array.from(_),Array.from(_)]:(_[0]<r[0][0]&&(r[0][0]=_[0]),_[0]>r[1][0]&&(r[1][0]=_[0]),_[1]<r[0][1]&&(r[0][1]=_[1]),_[1]>r[1][1]&&(r[1][1]=_[1])),S.length===0?S=[Array.from(_),Array.from(_)]:(_[0]<S[0][0]&&(S[0][0]=_[0]),_[0]>S[1][0]&&(S[1][0]=_[0]),_[1]<S[0][1]&&(S[0][1]=_[1]),_[1]>S[1][1]&&(S[1][1]=_[1]))}),S}),l=(r[1][0]-r[0][0])/o,f=(r[1][1]-r[0][1])/o,u=a.reduce((m,S,_)=>{const g=Bt(S[0][0],r[0][0],l,o),v=Bt(S[1][0],r[0][0],l,o),d=Bt(S[0][1],r[0][1],f,o),b=Bt(S[1][1],r[0][1],f,o);for(let w=g;w<=v;w++){m[w]||(m[w]=[]);for(let E=d;E<=b;E++)m[w][E]||(m[w][E]=[]),m[w][E].push(_)}return m},[]),c=i.features.map(m=>{let S=[];return kn(m)[0].map(_=>{s.length===0?s=[Array.from(_),Array.from(_)]:(_[0]<s[0][0]&&(s[0][0]=_[0]),_[0]>s[1][0]&&(s[1][0]=_[0]),_[1]<s[0][1]&&(s[0][1]=_[1]),_[1]>s[1][1]&&(s[1][1]=_[1])),S.length===0?S=[Array.from(_),Array.from(_)]:(_[0]<S[0][0]&&(S[0][0]=_[0]),_[0]>S[1][0]&&(S[1][0]=_[0]),_[1]<S[0][1]&&(S[0][1]=_[1]),_[1]>S[1][1]&&(S[1][1]=_[1]))}),S}),h=(s[1][0]-s[0][0])/o,p=(s[1][1]-s[0][1])/o,M=c.reduce((m,S,_)=>{const g=Bt(S[0][0],s[0][0],h,o),v=Bt(S[1][0],s[0][0],h,o),d=Bt(S[0][1],s[0][1],p,o),b=Bt(S[1][1],s[0][1],p,o);for(let w=g;w<=v;w++){m[w]||(m[w]=[]);for(let E=d;E<=b;E++)m[w][E]||(m[w][E]=[]),m[w][E].push(_)}return m},[]);this.indexedTins={forw:{gridNum:o,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:l,yUnit:f,gridCache:u},bakw:{gridNum:o,xOrigin:s[0][0],yOrigin:s[0][1],xUnit:h,yUnit:p,gridCache:M}}}transform(t,n,i){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(n&&this.strict_status==kt.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==kt.YAXIS_FOLLOW&&n&&(t=[t[0],-1*t[1]]);const o=ie(t);if(this.bounds&&!n&&!i&&!Le(o,this.boundsPolygon))return!1;const r=n?this.tins.bakw:this.tins.forw,s=n?this.indexedTins.bakw:this.indexedTins.forw,a=n?this.vertices_params.bakw:this.vertices_params.forw,l=n?this.centroid.bakw:this.centroid.forw,f=n?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let u,c;this.stateFull&&(this.stateBackward==n?u=this.stateTriangle:(this.stateBackward=n,this.stateTriangle=void 0),c=p=>{this.stateTriangle=p});let h=oe(o,r,s,a,l,f,u,c);if(this.bounds&&n&&!i){const p=ie(h);if(!Le(p,this.boundsPolygon))return!1}else this.yaxisMode==kt.YAXIS_FOLLOW&&!n&&(h=[h[0],-1*h[1]]);return h}}const Dn=Math.pow(2,-52),_e=new Uint32Array(512);class ze{static from(t,n=vr,i=br){const o=t.length,r=new Float64Array(o*2);for(let s=0;s<o;s++){const a=t[s];r[2*s]=n(a),r[2*s+1]=i(a)}return new ze(r)}constructor(t){const n=t.length>>1;if(n>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const i=Math.max(2*n-5,0);this._triangles=new Uint32Array(i*3),this._halfedges=new Int32Array(i*3),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:i,_hullTri:o,_hullHash:r}=this,s=t.length>>1;let a=1/0,l=1/0,f=-1/0,u=-1/0;for(let P=0;P<s;P++){const I=t[2*P],O=t[2*P+1];I<a&&(a=I),O<l&&(l=O),I>f&&(f=I),O>u&&(u=O),this._ids[P]=P}const c=(a+f)/2,h=(l+u)/2;let p=0,M=0,m=0;for(let P=0,I=1/0;P<s;P++){const O=We(c,h,t[2*P],t[2*P+1]);O<I&&(p=P,I=O)}const S=t[2*p],_=t[2*p+1];for(let P=0,I=1/0;P<s;P++){if(P===p)continue;const O=We(S,_,t[2*P],t[2*P+1]);O<I&&O>0&&(M=P,I=O)}let g=t[2*M],v=t[2*M+1],d=1/0;for(let P=0;P<s;P++){if(P===p||P===M)continue;const I=wr(S,_,g,v,t[2*P],t[2*P+1]);I<d&&(m=P,d=I)}let b=t[2*m],w=t[2*m+1];if(d===1/0){for(let O=0;O<s;O++)this._dists[O]=t[2*O]-t[0]||t[2*O+1]-t[1];Ht(this._ids,this._dists,0,s-1);const P=new Uint32Array(s);let I=0;for(let O=0,X=-1/0;O<s;O++){const R=this._ids[O],y=this._dists[R];y>X&&(P[I++]=R,X=y)}this.hull=P.subarray(0,I),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(Et(S,_,g,v,b,w)<0){const P=M,I=g,O=v;M=m,g=b,v=w,m=P,b=I,w=O}const E=yr(S,_,g,v,b,w);this._cx=E.x,this._cy=E.y;for(let P=0;P<s;P++)this._dists[P]=We(t[2*P],t[2*P+1],E.x,E.y);Ht(this._ids,this._dists,0,s-1),this._hullStart=p;let B=3;i[p]=n[m]=M,i[M]=n[p]=m,i[m]=n[M]=p,o[p]=0,o[M]=1,o[m]=2,r.fill(-1),r[this._hashKey(S,_)]=p,r[this._hashKey(g,v)]=M,r[this._hashKey(b,w)]=m,this.trianglesLen=0,this._addTriangle(p,M,m,-1,-1,-1);for(let P=0,I=0,O=0;P<this._ids.length;P++){const X=this._ids[P],R=t[2*X],y=t[2*X+1];if(P>0&&Math.abs(R-I)<=Dn&&Math.abs(y-O)<=Dn||(I=R,O=y,X===p||X===M||X===m))continue;let A=0;for(let x=0,N=this._hashKey(R,y);x<this._hashSize&&(A=r[(N+x)%this._hashSize],!(A!==-1&&A!==i[A]));x++);A=n[A];let k=A,T;for(;T=i[k],Et(R,y,t[2*k],t[2*k+1],t[2*T],t[2*T+1])>=0;)if(k=T,k===A){k=-1;break}if(k===-1)continue;let C=this._addTriangle(k,X,i[k],-1,-1,o[k]);o[X]=this._legalize(C+2),o[k]=C,B++;let Y=i[k];for(;T=i[Y],Et(R,y,t[2*Y],t[2*Y+1],t[2*T],t[2*T+1])<0;)C=this._addTriangle(Y,X,T,o[X],-1,o[Y]),o[X]=this._legalize(C+2),i[Y]=Y,B--,Y=T;if(k===A)for(;T=n[k],Et(R,y,t[2*T],t[2*T+1],t[2*k],t[2*k+1])<0;)C=this._addTriangle(T,X,k,-1,o[k],o[T]),this._legalize(C+2),o[T]=C,i[k]=k,B--,k=T;this._hullStart=n[X]=k,i[k]=n[Y]=X,i[X]=Y,r[this._hashKey(R,y)]=X,r[this._hashKey(t[2*k],t[2*k+1])]=k}this.hull=new Uint32Array(B);for(let P=0,I=this._hullStart;P<B;P++)this.hull[P]=I,I=i[I];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,n){return Math.floor(gr(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:i,coords:o}=this;let r=0,s=0;for(;;){const a=i[t],l=t-t%3;if(s=l+(t+2)%3,a===-1){if(r===0)break;t=_e[--r];continue}const f=a-a%3,u=l+(t+1)%3,c=f+(a+2)%3,h=n[s],p=n[t],M=n[u],m=n[c];if(mr(o[2*h],o[2*h+1],o[2*p],o[2*p+1],o[2*M],o[2*M+1],o[2*m],o[2*m+1])){n[t]=m,n[a]=h;const _=i[c];if(_===-1){let v=this._hullStart;do{if(this._hullTri[v]===c){this._hullTri[v]=t;break}v=this._hullPrev[v]}while(v!==this._hullStart)}this._link(t,_),this._link(a,i[s]),this._link(s,c);const g=f+(a+1)%3;r<_e.length&&(_e[r++]=g)}else{if(r===0)break;t=_e[--r]}}return s}_link(t,n){this._halfedges[t]=n,n!==-1&&(this._halfedges[n]=t)}_addTriangle(t,n,i,o,r,s){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=n,this._triangles[a+2]=i,this._link(a,o),this._link(a+1,r),this._link(a+2,s),this.trianglesLen+=3,a}}function gr(e,t){const n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function We(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function mr(e,t,n,i,o,r,s,a){const l=e-s,f=t-a,u=n-s,c=i-a,h=o-s,p=r-a,M=l*l+f*f,m=u*u+c*c,S=h*h+p*p;return l*(c*S-m*p)-f*(u*S-m*h)+M*(u*p-c*h)<0}function wr(e,t,n,i,o,r){const s=n-e,a=i-t,l=o-e,f=r-t,u=s*s+a*a,c=l*l+f*f,h=.5/(s*f-a*l),p=(f*u-a*c)*h,M=(s*c-l*u)*h;return p*p+M*M}function yr(e,t,n,i,o,r){const s=n-e,a=i-t,l=o-e,f=r-t,u=s*s+a*a,c=l*l+f*f,h=.5/(s*f-a*l),p=e+(f*u-a*c)*h,M=t+(s*c-l*u)*h;return{x:p,y:M}}function Ht(e,t,n,i){if(i-n<=20)for(let o=n+1;o<=i;o++){const r=e[o],s=t[r];let a=o-1;for(;a>=n&&t[e[a]]>s;)e[a+1]=e[a--];e[a+1]=r}else{const o=n+i>>1;let r=n+1,s=i;se(e,o,r),t[e[n]]>t[e[i]]&&se(e,n,i),t[e[r]]>t[e[i]]&&se(e,r,i),t[e[n]]>t[e[r]]&&se(e,n,r);const a=e[r],l=t[a];for(;;){do r++;while(t[e[r]]<l);do s--;while(t[e[s]]>l);if(s<r)break;se(e,r,s)}e[n+1]=e[s],e[s]=a,i-r+1>=s-n?(Ht(e,t,r,i),Ht(e,t,n,s-1)):(Ht(e,t,n,s-1),Ht(e,t,r,i))}}function se(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function vr(e){return e[0]}function br(e){return e[1]}class xr{bs;width;constructor(t,n){this.width=t,this.bs=n}add(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]|=1<<i,this}delete(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]&=~(1<<i),this}set(t,n){const i=Math.floor(t/this.width),r=1<<t%this.width;return this.bs[i]^=(-Number(n)^this.bs[i])&r,n}has(t){const n=Math.floor(t/this.width),i=t%this.width;return(this.bs[n]&1<<i)!==0}forEach(t){const n=this.bs.length;for(let i=0;i<n;i++){let o=0;for(;this.bs[i]&&o<this.width;)this.bs[i]&1<<o&&t(i*this.width+o),o++}return this}}class Yn extends xr{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function zt(e){return e%3===2?e-2:e+1}function Xt(e){return e%3===0?e+2:e-1}function Rn(e,t,n,i,o,r,s,a){const l=Et(e,t,o,r,s,a),f=Et(n,i,o,r,s,a);if(l>0&&f>0||l<0&&f<0)return!1;const u=Et(o,r,e,t,n,i),c=Et(s,a,e,t,n,i);return u>0&&c>0||u<0&&c<0?!1:l===0&&f===0&&u===0&&c===0?!(Math.max(o,s)<Math.min(e,n)||Math.max(e,n)<Math.min(o,s)||Math.max(r,a)<Math.min(t,i)||Math.max(t,i)<Math.min(r,a)):!0}class _r{del;constructor(t){this.del=t}}class Mr extends _r{vertMap;flips;consd;constructor(t,n){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);const i=2**32-1,o=t.coords.length>>1,r=t.triangles.length;this.vertMap=new Uint32Array(o).fill(i),this.flips=new Yn(r),this.consd=new Yn(r);for(let s=0;s<r;s++){const a=t.triangles[s];this.vertMap[a]===i&&this.updateVert(s)}n&&this.constrainAll(n)}constrainOne(t,n){const{triangles:i,halfedges:o}=this.del,r=this.vertMap[t];let s=r;do{const f=i[s],u=zt(s);if(f===n)return this.protect(s);const c=Xt(s),h=i[c];if(h===n)return this.protect(u),u;if(this.intersectSegments(t,n,h,f)){s=c;break}s=o[u]}while(s!==-1&&s!==r);let a=s,l=-1;for(;s!==-1;){const f=o[s],u=Xt(s),c=Xt(f),h=zt(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(s))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,n,i[s])||this.isCollinear(t,n,i[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[s],i[f],i[u],i[c])){if(l===-1&&(l=s),i[c]===n){if(s===l)throw new Error("Infinite loop: non-convex quadrilateral");s=l,l=-1;continue}if(this.intersectSegments(t,n,i[c],i[f]))s=c;else if(this.intersectSegments(t,n,i[h],i[c]))s=h;else if(l===s)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(s),this.intersectSegments(t,n,i[u],i[c])&&(l===-1&&(l=u),l===u))throw new Error("Infinite loop: flipped diagonal still intersects");i[c]===n?(a=c,s=l,l=-1):this.intersectSegments(t,n,i[h],i[c])&&(s=h)}return this.protect(a),this.delaunify(!0),this.findEdge(t,n)}delaunify(t=!1){const{halfedges:n}=this.del,i=this.flips,o=this.consd,r=n.length;let s;do{s=0;for(let a=0;a<r;a++){if(o.has(a))continue;i.delete(a);const l=n[a];l!==-1&&(i.delete(l),this.isDelaunay(a)||(this.flipDiagonal(a),s++))}}while(t&&s>0);return this}constrainAll(t){const n=t.length;for(let i=0;i<n;i++){const o=t[i];this.constrainOne(o[0],o[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,n){const i=this.vertMap[n],{triangles:o,halfedges:r}=this.del;let s=i,a=-1;do{if(o[s]===t)return s;a=zt(s),s=r[a]}while(s!==-1&&s!==i);return o[zt(a)]===t?-a:1/0}protect(t){const n=this.del.halfedges[t],i=this.flips,o=this.consd;return i.delete(t),o.add(t),n!==-1?(i.delete(n),o.add(n),n):-t}markFlip(t){const n=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const r=n[t];return r!==-1&&(i.add(t),i.add(r)),!0}flipDiagonal(t){const{triangles:n,halfedges:i}=this.del,o=this.flips,r=this.consd,s=i[t],a=Xt(t),l=zt(t),f=Xt(s),u=zt(s),c=i[a],h=i[f];if(r.has(t))throw new Error("Trying to flip a constrained edge");return n[t]=n[f],i[t]=h,o.set(t,o.has(f))||r.set(t,r.has(f)),h!==-1&&(i[h]=t),i[a]=f,n[s]=n[a],i[s]=c,o.set(s,o.has(a))||r.set(s,r.has(a)),c!==-1&&(i[c]=s),i[f]=a,this.markFlip(t),this.markFlip(l),this.markFlip(s),this.markFlip(u),o.add(a),r.delete(a),o.add(f),r.delete(f),this.updateVert(t),this.updateVert(l),this.updateVert(s),this.updateVert(u),a}isCollinear(t,n,i){const o=this.del.coords;return Et(o[t*2],o[t*2+1],o[n*2],o[n*2+1],o[i*2],o[i*2+1])===0}inCircle(t,n,i,o){const r=this.del.coords;return ui(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])<0}isDelaunay(t){const{triangles:n,halfedges:i}=this.del,o=i[t];if(o===-1)return!0;const r=n[Xt(t)],s=n[t],a=n[zt(t)],l=n[Xt(o)];return!this.inCircle(r,s,a,l)}updateVert(t){const{triangles:n,halfedges:i}=this.del,o=this.vertMap,r=n[t];let s=Xt(t),a=i[s];for(;a!==-1&&a!==t;)s=Xt(a),a=i[s];return o[r]=s,s}intersectSegments(t,n,i,o){const r=this.del.coords;return t===i||t===o||n===i||n===o?!1:Rn(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])}static intersectSegments=Rn}function ae(e,t,n){if(t||(t=[]),typeof e!="object"||e.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const i=e.features.map(l=>l.geometry.coordinates),o=ze.from(i);let r;const s=[];o.triangles.length!==0&&t.length!==0&&(r=new Mr(o),r.constrainAll(t));for(let l=0;l<o.triangles.length;l+=3)s.push([o.triangles[l],o.triangles[l+1],o.triangles[l+2]]);const a=["a","b","c"];return St(s.map(l=>{const f={},u=l.map((c,h)=>{const p=e.features[c],M=p.geometry.coordinates,m=[M[0],M[1]];return M.length===3?m[2]=M[2]:f[a[h]]=p.properties[n],m});return u[3]=u[0],Zt([u],f)}))}function Sr(e,t){const n=[[],[],[],[]],i=[];return Object.keys(e).forEach(o=>{const r=e[o],s=r.forw,a=r.bakw,l=[s[0]-t.forw[0],s[1]-t.forw[1]],f=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:l,bakw:f};if(i.push(u),l[0]===0||l[1]===0)return;let c=0;l[0]>0&&(c+=1),l[1]>0&&(c+=2),n[c].push(u)}),{perQuad:n,aggregate:i}}function kr(e){let t=1/0,n=0,i=0;return e.forEach(o=>{const{forw:r,bakw:s}=o,a=Math.hypot(r[0],r[1]),l=Math.hypot(s[0],s[1]);if(l===0)return;const f=a/l,u=Math.atan2(r[0],r[1])-Math.atan2(s[0],s[1]);t=Math.min(t,f),n+=Math.cos(u),i+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(i,n)]:[1,0]}function Er(e,t,n){const{perQuad:i,aggregate:o}=Sr(e,t),r=i.every(l=>l.length>0),a=(n==="birdeye"?r?i:[o]:[o]).map(l=>kr(l));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Ar(e,t){let n=0;return e[0]>t[0]&&(n+=1),e[1]>t[1]&&(n+=2),n}function Pr(e,t,n){const i=[e[0]-t.forw[0],e[1]-t.forw[1]],r=Math.sqrt(i[0]**2+i[1]**2)/n[0],s=Math.atan2(i[0],i[1])-n[1];return[t.bakw[0]+r*Math.sin(s),t.bakw[1]-r*Math.cos(s)]}function Ir(e,t,n,i){const o=t[0]-e[0],r=t[1]-e[1];if(Math.abs(o)<1e-12&&Math.abs(r)<1e-12)return null;const s=i[0]-n[0],a=i[1]-n[1],l=n[0]-e[0],f=n[1]-e[1],u=o*a-r*s;if(Math.abs(u)<1e-12)return null;const c=(l*a-f*s)/u,h=(l*r-f*o)/u;return c<=1e-10||h<-1e-10||h>1+1e-10?null:{t:c,point:[e[0]+c*o,e[1]+c*r]}}function Br(e,t,n){const i=n.length;let o=-1/0,r=null;for(let s=0;s<i;s++){const a=(s+1)%i,l=Ir(e,t,n[s].bakw,n[a].bakw);l&&l.t>o&&(o=l.t,r=l.point)}return r}function Fn(e,t){const i=Math.atan2(e[0]-t[0],e[1]-t[1])*(180/Math.PI);return i<0?i+360:i}function $n(e,t,n,i,o,r){const s=t[0]-e[0],a=t[1]-e[1];if(s===0&&a===0)return null;const l=[];if(s!==0)for(const u of[n,i]){const c=(u-e[0])/s;if(c>0){const h=e[1]+c*a;h>=o&&h<=r&&l.push({t:c,x:u,y:h})}}if(a!==0)for(const u of[o,r]){const c=(u-e[1])/a;if(c>0){const h=e[0]+c*s;h>=n&&h<=i&&l.push({t:c,x:h,y:u})}}if(l.length===0)return null;l.sort((u,c)=>u.t-c.t);const f=l[0];return[f.x,f.y]}function Ln(e,t,n){const i=e.length,o=new Array(i).fill(1);for(const r of t)for(let s=0;s<i;s++){const a=(s+1)%i,l=tn([e[s].bakw,e[a].bakw]),f=tn([n.bakw,r.bakw]),u=Ii(l,f);if(u.features.length>0&&u.features[0].geometry){const c=u.features[0],h=Math.sqrt(Math.pow(r.bakw[0]-n.bakw[0],2)+Math.pow(r.bakw[1]-n.bakw[1],2)),p=Math.sqrt(Math.pow(c.geometry.coordinates[0]-n.bakw[0],2)+Math.pow(c.geometry.coordinates[1]-n.bakw[1],2)),M=h/p;M>o[s]&&(o[s]=M),M>o[a]&&(o[a]=M)}}e.forEach((r,s)=>{const a=o[s];r.bakw=[(r.bakw[0]-n.bakw[0])*a+n.bakw[0],(r.bakw[1]-n.bakw[1])*a+n.bakw[1]]})}function jn(e,t,n){const{convexBuf:i,centroid:o,allGcps:r,minx:s,maxx:a,miny:l,maxy:f}=e,u=Er(i,o,t),h=[[s,l],[a,l],[a,f],[s,f]].map(w=>({forw:w,bakw:Pr(w,o,u[Ar(w,o.forw)])}));if(h.sort((w,E)=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])-Math.atan2(E.forw[0]-o.forw[0],E.forw[1]-o.forw[1])),Ln(h,r,o),!n)return h;const p=4,M=h.map(w=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])),m=h.map(w=>Math.atan2(w.bakw[0]-o.bakw[0],-(w.bakw[1]-o.bakw[1])));function S(w){for(let E=0;E<p;E++){const B=(E+1)%p,P=M[E],I=E<p-1?M[B]:M[B]+2*Math.PI;let O=w;for(;O<P;)O+=2*Math.PI;for(;O>=P+2*Math.PI;)O-=2*Math.PI;if(O>=P&&O<I)return{i:E,j:B,frac:(O-P)/(I-P)}}return{i:0,j:1,frac:0}}function _(w){const{i:E,j:B,frac:P}=S(w),I=m[E];let X=m[B]-I;for(;X>Math.PI;)X-=2*Math.PI;for(;X<-Math.PI;)X+=2*Math.PI;return I+P*X}const g=new Set(h.map(w=>Math.floor(Fn(w.forw,o.forw)/10)%36)),v=r.map(w=>({forw:w.forw,bakw:w.bakw,angleDeg:Fn(w.forw,o.forw),forwDist:Math.hypot(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])})),d=[];for(let w=0;w<36;w++){if(g.has(w))continue;const E=w*10,B=v.filter(A=>A.angleDeg>=E&&A.angleDeg<E+10);let P=null;if(B.length>0){const A=B.reduce((k,T)=>T.forwDist>k.forwDist?T:k);P=$n(o.forw,A.forw,s,a,l,f)}if(!P){const A=(E+5)%360*(Math.PI/180),k=[o.forw[0]+Math.sin(A),o.forw[1]+Math.cos(A)];P=$n(o.forw,k,s,a,l,f)}if(!P)continue;const I=[P[0]-o.forw[0],P[1]-o.forw[1]],O=Math.atan2(I[0],I[1]),X=_(O),R=[o.bakw[0]+Math.sin(X),o.bakw[1]-Math.cos(X)],y=Br(o.bakw,R,h);y&&d.push({forw:P,bakw:y})}const b=[...h,...d];return b.sort((w,E)=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])-Math.atan2(E.forw[0]-o.forw[0],E.forw[1]-o.forw[1])),Ln(b,r,o),b}function Or(e,t=!1){return jn(e,"plain",t)}function Nr(e,t=!1){return jn(e,"birdeye",t)}function Vn(e){const n=new Tr(e).findSegmentIntersections(),i=Jn(n),o=new Map;return i.forEach(r=>{o.set(`${r.x}:${r.y}`,r)}),Array.from(o.values()).map(r=>Dt([r.x,r.y]))}class Tr{_xx;_yy;_ii;_nn;_zz=null;_zlimit=0;_bb=null;_allBounds=null;_arcIter=null;_filteredArcIter=null;buf;constructor(t){this.initArcs(t)}initArcs(t){const n=[],i=[],o=t.map(r=>{const s=r?r.length:0;for(let a=0;a<s;a++)n.push(r[a][0]),i.push(r[a][1]);return s});this.initXYData(o,n,i)}initXYData(t,n,i){const o=t.length;this._xx=new Float64Array(n),this._yy=new Float64Array(i),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(o);let r=0;for(let s=0;s<o;s++)this._ii[s]=r,r+=t[s];(r!=this._xx.length||this._xx.length!=this._yy.length)&&Ge("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Zr(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,n,i){const o=i.length,r=new Float64Array(o*4),s=new fe;let a=0,l,f,u;for(let c=0;c<o;c++)l=i[c],l>0&&(f=c*4,u=to(t,n,a,l),r[f++]=u[0],r[f++]=u[1],r[f++]=u[2],r[f]=u[3],a+=l,s.mergeBounds(u));return{bb:r,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new fe}forEachSegment(t){let n=0;for(let i=0,o=this.size();i<o;i++)n+=this.forEachArcSegment(i,t);return n}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,n){const i=t>=0,o=i?t:~t,r=this.getRetainedInterval(),s=this._nn[o],a=i?1:-1;let l=i?this._ii[o]:this._ii[o]+s-1,f=l,u=0;for(let c=1;c<s;c++)f+=a,(r===0||this._zz[f]>=r)&&(n(l,f,this._xx,this._yy),l=f,u++);return u}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(t){const n=t*4;return(!this.buf||this.buf.byteLength<n)&&(this.buf=new ArrayBuffer(n)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,n=0;const i=this.forEachSegment((o,r,s,a)=>{t+=Math.abs(s[o]-s[r]),n+=Math.abs(a[o]-a[r])});return[t/i||0,n/i||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),n=this.getAvgSegment2()[1];let i=1;return n>0&&t>0&&(i=Math.ceil(t/n/20)),i||1}findSegmentIntersections(){const t=this.getBounds(),n=t.ymin||0,i=(t.ymax||0)-n,o=this.calcSegmentIntersectionStripeCount(),r=new Uint32Array(o),s=o>1?m=>Math.floor((o-1)*(m-n)/i):()=>0;let a,l;this.forEachSegment((m,S,_,g)=>{let v=s(g[m]);const d=s(g[S]);for(;r[v]=r[v]+2,v!=d;)v+=d>v?1:-1});const f=this.getUint32Array(Dr(r));let u=0;const c=[];Yr(r,m=>{const S=u;u+=m,c.push(f.subarray(S,u))}),Rr(r,0),this.forEachSegment((m,S,_,g)=>{let v=s(g[m]);const d=s(g[S]);let b,w;for(;b=r[v],r[v]=b+2,w=c[v],w[b]=m,w[b+1]=S,v!=d;)v+=d>v?1:-1});const h=this.getVertexData(),p=[];let M;for(a=0;a<o;a++)if(h.xx&&h.yy)for(M=Fr(c[a],h.xx,h.yy),l=0;l<M.length;l++)p.push(M[l]);return Jn(p)}}function Ge(...e){const t=e.join(" ");throw new Error(t)}function Je(e){return e?Cr(e)?!0:Xr(e)?!1:e.length===0?!0:e.length>0:!1}function Xr(e){return e!=null&&e.toString===String.prototype.toString}function Cr(e){return Array.isArray(e)}function Dr(e,t){Je(e)||Ge("utils.sum() expects an array, received:",e);let n=0,i;for(let o=0,r=e.length;o<r;o++)i=e[o],i&&(n+=i);return n}function Yr(e,t,n){if(!Je(e))throw new Error(`#forEach() takes an array-like argument. ${e}`);for(let i=0,o=e.length;i<o;i++)t.call(n,e[i],i)}function Rr(e,t){for(let n=0,i=e.length;n<i;n++)e[n]=t;return e}function Fr(e,t,n){const i=e.length-2,o=[];let r,s,a,l,f,u,c,h,p,M,m,S,_,g,v,d,b;for(Jr(t,e),d=0;d<i;){for(r=e[d],s=e[d+1],f=t[r],u=t[s],p=n[r],M=n[s],b=d;b<i&&(b+=2,a=e[b],c=t[a],!(u<c));){if(m=n[a],l=e[b+1],h=t[l],S=n[l],p>=m){if(p>S&&M>m&&M>S)continue}else if(p<S&&M<m&&M<S)continue;r==a||r==l||s==a||s==l||(_=$r(f,p,u,M,c,m,h,S),_&&(g=[r,s],v=[a,l],o.push(Wn(_,g,v,t,n)),_.length==4&&o.push(Wn(_.slice(2),g,v,t,n))))}d+=2}return o}function $r(e,t,n,i,o,r,s,a){const l=Lr(e,t,n,i,o,r,s,a);let f=null;return l&&(f=jr(e,t,n,i,o,r,s,a),f?Gr(e,t,n,i,o,r,s,a)&&(f=null):f=Wr(e,t,n,i,o,r,s,a)),f}function Lr(e,t,n,i,o,r,s,a){return ce(e,t,n,i,o,r)*ce(e,t,n,i,s,a)<=0&&ce(o,r,s,a,e,t)*ce(o,r,s,a,n,i)<=0}function ce(e,t,n,i,o,r){return qn(e-o,t-r,n-o,i-r)}function qn(e,t,n,i){return e*i-t*n}function jr(e,t,n,i,o,r,s,a){let l=Me(e,t,n,i,o,r,s,a),f;return l&&(f=qr(l[0],l[1],e,t,n,i,o,r,s,a),f==1?l=Me(n,i,e,t,o,r,s,a):f==2?l=Me(o,r,s,a,e,t,n,i):f==3&&(l=Me(s,a,o,r,e,t,n,i))),l&&zr(l,e,t,n,i,o,r,s,a),l}function Me(e,t,n,i,o,r,s,a){const l=qn(n-e,i-t,s-o,a-r),f=1e-18;let u;if(l===0)return null;const c=ce(o,r,s,a,e,t)/l;return l<=f&&l>=-f?u=Vr(e,t,n,i,o,r,s,a):u=[e+c*(n-e),t+c*(i-t)],u}function Vr(e,t,n,i,o,r,s,a){let l=null;return!Ct(e,o,s)&&!Ct(t,r,a)?l=[e,t]:!Ct(n,o,s)&&!Ct(i,r,a)?l=[n,i]:!Ct(o,e,n)&&!Ct(r,t,i)?l=[o,r]:!Ct(s,e,n)&&!Ct(a,t,i)&&(l=[s,a]),l}function Ct(e,t,n){let i;return t<n?i=e<t||e>n:t>n?i=e>t||e<n:i=e!=t,i}function qr(e,t,...n){let i=-1,o=1/0,r;for(let s=0,a=0,l=n.length;a<l;s++,a+=2)r=Ur(e,t,n[a],n[a+1]),r<o&&(o=r,i=s);return i}function Ur(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function zr(e,t,n,i,o,r,s,a,l){let f=e[0],u=e[1];f=Se(f,t,i),f=Se(f,r,a),u=Se(u,n,o),u=Se(u,s,l),e[0]=f,e[1]=u}function Se(e,t,n){let i;return Ct(e,t,n)&&(i=Math.abs(e-t)<Math.abs(e-n)?t:n,e=i),e}function Wr(e,t,n,i,o,r,s,a){const l=Math.min(e,n,o,s),f=Math.max(e,n,o,s),u=Math.min(t,i,r,a),c=Math.max(t,i,r,a),h=c-u>f-l;let p=[];return(h?Lt(t,u,c):Lt(e,l,f))&&p.push(e,t),(h?Lt(i,u,c):Lt(n,l,f))&&p.push(n,i),(h?Lt(r,u,c):Lt(o,l,f))&&p.push(o,r),(h?Lt(a,u,c):Lt(s,l,f))&&p.push(s,a),(p.length!=2&&p.length!=4||p.length==4&&p[0]==p[2]&&p[1]==p[3])&&(p=null),p}function Gr(e,t,n,i,o,r,s,a){return e==o&&t==r||e==s&&t==a||n==o&&i==r||n==s&&i==a}function Lt(e,t,n){return e>t&&e<n}function Jr(e,t){Kr(e,t),Un(e,t,0,t.length-2)}function Kr(e,t){for(let n=0,i=t.length;n<i;n+=2)e[t[n]]>e[t[n+1]]&&Qr(t,n,n+1)}function Qr(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function Un(e,t,n,i){let o=n,r=i,s,a;for(;o<i;){for(s=e[t[n+i>>2<<1]];o<=r;){for(;e[t[o]]<s;)o+=2;for(;e[t[r]]>s;)r-=2;o<=r&&(a=t[o],t[o]=t[r],t[r]=a,a=t[o+1],t[o+1]=t[r+1],t[r+1]=a,o+=2,r-=2)}if(r-n<40?zn(e,t,n,r):Un(e,t,n,r),i-o<40){zn(e,t,o,i);return}n=o,r=i}}function zn(e,t,n,i){let o,r;for(let s=n+2;s<=i;s+=2){o=t[s],r=t[s+1];let a;for(a=s-2;a>=n&&e[o]<e[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=o,t[a+3]=r}}function Wn(e,t,n,i,o){const r=e[0],s=e[1];t=Gn(r,s,t[0],t[1],i,o),n=Gn(r,s,n[0],n[1],i,o);const a=t[0]<n[0]?t:n,l=a==t?n:t;return{x:r,y:s,a,b:l}}function Gn(e,t,n,i,o,r){let s=n<i?n:i,a=s===n?i:n;return o[s]==e&&r[s]==t?a=s:o[a]==e&&r[a]==t&&(s=a),[s,a]}function Jn(e){const t={};return e.filter(n=>{const i=Hr(n);return i in t?!1:(t[i]=!0,!0)})}function Hr(e){return`${e.a.join(",")};${e.b.join(",")}`}class Zr{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,n){this._xx=t,this._yy=n}}function to(e,t,n,i){let o=n|0;const r=isNaN(i)?e.length-o:i+o;let s,a,l,f,u,c;if(r>0)l=u=e[o],f=c=t[o];else return[void 0,void 0,void 0,void 0];for(o++;o<r;o++)s=e[o],a=t[o],s<l&&(l=s),s>u&&(u=s),a<f&&(f=a),a>c&&(c=a);return[l,f,u,c]}class fe{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new fe(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,n,i,o){let r,s,a,l;if(arguments.length==1)if(Je(t)){const f=t;r=f[0],s=f[1],a=f[2],l=f[3]}else{const f=t;r=f.xmin,s=f.ymin,a=f.xmax,l=f.ymax}else r=t,s=n,a=i,l=o;return this.xmin=r,this.ymin=s,this.xmax=a,this.ymax=l,(r>a||s>l)&&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,...n){let i,o,r,s;return t instanceof fe?(i=t.xmin,o=t.ymin,r=t.xmax,s=t.ymax):n.length==3?(i=t,o=n[0],r=n[1],s=n[2]):t.length==4?(i=t[0],o=t[1],r=t[2],s=t[3]):Ge("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(i,o,r,s):(i<this.xmin&&(this.xmin=i),o<this.ymin&&(this.ymin=o),r>this.xmax&&(this.xmax=r),s>this.ymax&&(this.ymax=s)),this}}function ke(e){const t=["a","b","c"].map(n=>e.properties[n].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(n=>n.map(i=>t[i]).sort().join("-")).sort()}function Ke(e,t,n){const i=ke(t.forw),o=ke(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
2
2
  ${JSON.stringify(i)}
3
- ${JSON.stringify(o)}`;for(let r=0;r<i.length;r++){const s=i[r];n[s]||(n[s]=[]),n[s].push(t)}e&&(e.forw.features.push(t.forw),e.bakw.features.push(t.bakw))}function Ln(n,t,e){const i=be(t.forw),o=be(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
3
+ ${JSON.stringify(o)}`;for(let r=0;r<i.length;r++){const s=i[r];e[s]||(e[s]=[]),e[s].push(t)}n&&(n.forw.features.push(t.forw),n.bakw.features.push(t.bakw))}function Kn(e,t,n){const i=ke(t.forw),o=ke(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
4
4
  ${JSON.stringify(i)}
5
- ${JSON.stringify(o)}`;if(i.forEach(r=>{const s=n[r];if(!s)return;const a=s.filter(c=>c!==t);a.length===0?delete n[r]:n[r]=a}),e){const r=(s,a)=>{!s||!a||(s.features=s.features.filter(c=>c!==a))};r(e.forw,t.forw),r(e.bakw,t.bakw)}}function oe(n,t,e){return Nt(n,{target:{geom:t,index:e}})}function se(n){return Nt(n.properties.target.geom,{target:{geom:n.geometry.coordinates,index:n.properties.target.index}})}function Ve(n,t){const e=n.length,i=t.geometry.coordinates;return Array.from({length:e},(o,r)=>r).map(o=>{const r=(o+1)%e,s=n[o],a=n[r],c=s.geometry.coordinates,f=Math.atan2(c[0]-i[0],c[1]-i[1]),l=[t,s,a,t].map(p=>p.geometry.coordinates),h={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:s.properties.target.geom,index:s.properties.target.index},c:{geom:a.properties.target.geom,index:a.properties.target.index}},u=_t([Jt([l],h)]);return[f,u]}).reduce((o,r)=>(o[0].push(r[0]),o[1].push(r[1]),o),[[],[]])}function jr(n){const{tins:t,targets:e,includeReciprocals:i,numBoundaryVertices:o=4}=n,r={};e.forEach(a=>{const c=t[a];if(!c||!c.features)return;r[a]={};const f={};c.features.forEach(l=>{const h=["a","b","c"];for(let u=0;u<3;u++){const p=(u+1)%3,x=h[u],y=h[p],k=l.properties[x].index,S=l.properties[y].index,g=[k,S].sort().join("-");if(f[g])continue;f[g]=!0;const v=l.geometry.coordinates[0][u],d=l.geometry.coordinates[0][p],b=l.properties[x].geom,m=l.properties[y].geom,A=Math.sqrt(Math.pow(b[0]-m[0],2)+Math.pow(b[1]-m[1],2))/Math.sqrt(Math.pow(v[0]-d[0],2)+Math.pow(v[1]-d[1],2)),B=r[a];B[`${k}:${g}`]=A,B[`${S}:${g}`]=A}})});const s={};return i&&(s.bakw={}),e.forEach(a=>{const c=r[a];if(s[a]={},!c)return;const f={};Object.keys(c).forEach(h=>{const[u]=h.split(":");f[u]||(f[u]=[]),f[u].push(c[h])}),Object.keys(f).forEach(h=>{const u=f[h],p=u.reduce((x,y)=>x+y,0)/u.length;s[a][h]=p,i&&s.bakw&&(s.bakw[h]=1/p)});let l=0;for(let h=0;h<o;h++){const u=`b${h}`,p=s[a][u]||0;l+=p}s[a].c=l/o,i&&s.bakw&&(s.bakw.c=1/s[a].c)}),s}function xe(n,t=1e-6){const[e,i]=n[0],[o,r]=n[1],[s,a]=n[2];return Math.abs((o-e)*(a-i)-(s-e)*(r-i))<t}function $r(n,t){const e=n.split("-");if(e.length!==2||!e.every(r=>/^-?\d+$/.test(r)))return!1;const[i,o]=e.map(r=>parseInt(r,10)).sort((r,s)=>r-s);return t.some(r=>{if(r.length!==2)return!1;const s=r.map(c=>parseInt(`${c}`,10));if(s.some(c=>Number.isNaN(c)))return!1;const a=s.sort((c,f)=>c-f);return a[0]===i&&a[1]===o})}function ae(n){return["a","b","c"].map((t,e)=>({prop:n.properties[t],geom:n.geometry.coordinates[0][e]}))}const qr=10;function Vr(n,t,e,i,o,r){if(!n&&!t)return!1;const s=n?0:1,a=1-s,c=e[s],f=e[a];if(!c||!f)return!1;const l=bt(f.geom);let h=!1,u=!1;for(let p=0;p<=1;p++){const x=i[p];if(!x)continue;const y=[String(x.prop.index),String(c.prop.index)].sort().join("-"),k=o[y];if(!k||k.length<2)continue;const S=k.find(N=>N.bakw!==r[s].bakw);if(!S)continue;const v=ae(S.bakw).find(N=>String(N.prop.index)!==String(x.prop.index)&&String(N.prop.index)!==String(c.prop.index));if(!v)continue;h=!0;const d=bt(v.geom),b=bt(x.geom),m=bt(c.geom),A=m[0]-b[0],B=m[1]-b[1],P=A*(l[1]-b[1])-B*(l[0]-b[0]),I=A*(d[1]-b[1])-B*(d[0]-b[0]);if(P*I>0){u=!0;break}}return h&&!u}function Ur(n,t,e,i){if(!n&&!t)return!1;if(e[0]&&e[1]&&i[0]&&i[1]){const o=i.map(l=>bt(l.geom)),r=e.map(l=>bt(l.geom)),s=o[1][0]-o[0][0],a=o[1][1]-o[0][1],c=s*(r[0][1]-o[0][1])-a*(r[0][0]-o[0][0]),f=s*(r[1][1]-o[0][1])-a*(r[1][0]-o[0][0]);return c*f<0}return!1}function zr(n,t,e){const i=new Set;let o=!1;for(let r=0;r<qr;r++){let s=!1;for(const a of Object.keys(t)){if(i.has(a))continue;i.add(a);const c=t[a];if(!c||c.length<2)continue;const f=a.split("-");if(f.length!==2||$r(a,e))continue;const l=ae(c[0].bakw),h=ae(c[1].bakw),u=ae(c[0].forw),p=ae(c[1].forw),x=f.map(O=>l.find(D=>`${D.prop.index}`===O)||h.find(D=>`${D.prop.index}`===O)),y=f.map(O=>u.find(D=>`${D.prop.index}`===O)||p.find(D=>`${D.prop.index}`===O));if(x.some(O=>!O)||y.some(O=>!O))continue;const k=[l,h].map(O=>O.find(D=>!f.includes(`${D.prop.index}`))),S=[u,p].map(O=>O.find(D=>!f.includes(`${D.prop.index}`)));if(k.some(O=>!O)||S.some(O=>!O))continue;const g=c[0].bakw.geometry.coordinates[0].slice(0,3).map(O=>bt(O)),v=c[1].bakw.geometry.coordinates[0].slice(0,3).map(O=>bt(O)),d=c[0].forw.geometry.coordinates[0].slice(0,3).map(O=>bt(O)),b=c[1].forw.geometry.coordinates[0].slice(0,3).map(O=>bt(O)),m=xe(g),A=xe(v),B=xe(d),P=xe(b),I=Vr(m,A,k,x,t,c),N=Ur(B,P,k,x);if(!(I||N||jn(bt(k[0].geom),v)||jn(bt(k[1].geom),g)))continue;const F=y.map(O=>bt(O.geom)),w=S.map(O=>bt(O.geom)),E=Wr([...F,...w]),M=Gr(E),T=$n(F[0],F[1],w[0])+$n(F[0],F[1],w[1]);Ue(M,T)&&(Ln(t,c[0],n),Ln(t,c[1],n),x.forEach(O=>{if(!O)return;const D=[O.geom,k[0].geom,k[1].geom,O.geom],_={a:O.prop,b:k[0].prop,c:k[1].prop},C=Jt([D],_),R=_n(C);qe(t,{forw:R,bakw:C},n)}),s=!0,o=!0)}if(!s)break}return o}function bt(n){return[n[0],n[1]]}function jn(n,t){const[e,i]=t[0],[o,r]=t[1],[s,a]=t[2],c=s-e,f=a-i,l=o-e,h=r-i,u=n[0]-e,p=n[1]-i,x=c*c+f*f,y=c*l+f*h,k=c*u+f*p,S=l*l+h*h,g=l*u+h*p,v=x*S-y*y;if(v===0)return!1;const d=1/v,b=(S*k-y*g)*d,m=(x*g-y*k)*d,A=1e-9;return b>=-A&&m>=-A&&b+m<=1+A}function Wr(n){const t=n.map(s=>s.slice()).filter((s,a,c)=>c.findIndex(f=>Ue(f[0],s[0])&&Ue(f[1],s[1]))===a);if(t.length<=1)return t;const e=t.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),i=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),o=[];for(const s of e){for(;o.length>=2&&i(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}const r=[];for(let s=e.length-1;s>=0;s--){const a=e[s];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}return r.pop(),o.pop(),o.concat(r)}function Gr(n){if(n.length<3)return 0;let t=0;for(let e=0;e<n.length;e++){const[i,o]=n[e],[r,s]=n[(e+1)%n.length];t+=i*s-r*o}return Math.abs(t)/2}function $n(n,t,e){return Math.abs((n[0]*(t[1]-e[1])+t[0]*(e[1]-n[1])+e[0]*(n[1]-t[1]))/2)}function Ue(n,t,e=1e-9){return Math.abs(n-t)<=e}const qn=3;class ct extends Mt{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||ct.VERTEX_PLAIN),this.strictMode=t.strictMode||ct.MODE_AUTO,this.yaxisMode=t.yaxisMode||ct.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,this.useV2Algorithm=t.useV2Algorithm??!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return this.useV2Algorithm?Ye:qn}setPoints(t){this.yaxisMode===ct.YAXIS_FOLLOW&&(t=t.map(e=>[e[0],[e[1][0],-1*e[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Sn(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let e=t[0][0],i=e,o=t[0][1],r=o;const s=[t[0]];for(let a=1;a<t.length;a++){const c=t[a];c[0]<e&&(e=c[0]),c[0]>i&&(i=c[0]),c[1]<o&&(o=c[1]),c[1]>r&&(r=c[1]),s.push(c)}s.push(t[0]),this.boundsPolygon=Jt([s]),this.xy=[e,o],this.wh=[i-e,r-o],this.vertexMode=ct.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?Ye:qn,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer??{},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const e=this.vertices_params.forw[1];if(e)for(let i=0;i<e.length;i++){const o=e[i].features[0],r=o.geometry.coordinates[0][1],s=o.properties.b.geom;t.vertices_points[i]=[r,s]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(i=>{t.tins_points[0].push(["a","b","c"].map(o=>i.properties[o].index))}),this.strict_status===ct.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(i=>{t.tins_points[1].push(["a","b","c"].map(o=>i.properties[o].index))})):this.strict_status===ct.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(i=>i.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,this.useV2Algorithm&&(t.xy=this.xy,t.wh=this.wh)):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setCompiled(t){super.setCompiled(t)}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){const t=this.tins.forw.features.map(o=>_n(o));this.tins.bakw=_t(t);const e={};this.tins.forw.features.forEach((o,r)=>{const s=this.tins.bakw.features[r];qe(e,{forw:o,bakw:s})}),zr(this.tins,e,this.pointsSet?.edges||[]);const i=["forw","bakw"].map(o=>{const r=this.tins[o].features.map(s=>s.geometry.coordinates[0]);return Nn(r)});i[0].length===0&&i[1].length===0?(this.strict_status=ct.STATUS_STRICT,delete this.kinks):(this.strict_status=ct.STATUS_ERROR,this.kinks={forw:_t(i[0]),bakw:_t(i[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let o=0;o<this.points.length;o++){const r=this.points[o][0],s=this.points[o][1],a=oe(r,s,o);t.forw.push(a),t.bakw.push(se(a))}const e=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let o=0;o<this.edges.length;o++){const r=this.edges[o][2],s=Object.assign([],this.edges[o][0]),a=Object.assign([],this.edges[o][1]);if(s.length===0&&a.length===0){e.push(r);continue}s.unshift(this.points[r[0]][0]),s.push(this.points[r[1]][0]),a.unshift(this.points[r[0]][1]),a.push(this.points[r[1]][1]);const c=[s,a].map(f=>{const l=f.map((u,p,x)=>{if(p===0)return 0;const y=x[p-1];return Math.sqrt(Math.pow(u[0]-y[0],2)+Math.pow(u[1]-y[1],2))}),h=l.reduce((u,p,x)=>x===0?[0]:(u.push(u[x-1]+p),u),[]);return h.map((u,p,x)=>{const y=u/x[x.length-1];return[f[p],l[p],h[p],y]})});c.map((f,l)=>{const h=c[l?0:1];return f.filter((u,p)=>!(p===0||p===f.length-1||u[4]==="handled")).flatMap(u=>{const p=u[0],x=u[3],y=h.reduce((k,S,g,v)=>{if(k)return k;const d=v[g+1];if(S[3]===x)return S[4]="handled",[S];if(S[3]<x&&d&&d[3]>x)return[S,d]},void 0);if(y&&y.length===1)return l===0?[[p,y[0][0],x]]:[[y[0][0],p,x]];if(y&&y.length===2){const k=y[0],S=y[1],g=(x-k[3])/(S[3]-k[3]),v=[(S[0][0]-k[0][0])*g+k[0][0],(S[0][1]-k[0][1])*g+k[0][1]];return l===0?[[p,v,x]]:[[v,p,x]]}return[]})}).reduce((f,l)=>f.concat(l),[]).sort((f,l)=>f[2]<l[2]?-1:1).map((f,l,h)=>{this.edgeNodes[i]=[f[0],f[1]];const u=oe(f[0],f[1],`e${i}`);i++,t.forw.push(u),t.bakw.push(se(u)),l===0?e.push([r[0],t.forw.length-1]):e.push([t.forw.length-2,t.forw.length-1]),l===h.length-1&&e.push([t.forw.length-1,r[1]])})}return{forw:t.forw,bakw:t.bakw,edges:e}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],e=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],o=this.xy[1]+1.05*this.wh[1];if(this.bounds&&!this.boundsPolygon)throw new Error("Internal error: bounds is set but boundsPolygon is missing");const r=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((c,f)=>c&&(r?Be(f[0],r):f[0][0]>=t&&f[0][0]<=e&&f[0][1]>=i&&f[0][1]<=o),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[e,i],[t,o],[e,o]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:e,miny:i,maxy:o}}computeGcpBbox(){let t=1/0,e=-1/0,i=1/0,o=-1/0;for(const a of this.points){const c=a[0][0],f=a[0][1];c<t&&(t=c),c>e&&(e=c),f<i&&(i=f),f>o&&(o=f)}const r=e-t,s=o-i;return{minx:t-.05*r,maxx:e+.05*r,miny:i-.05*s,maxy:o+.05*s}}updateTin(){let t=this.strictMode;t!==ct.MODE_STRICT&&t!==ct.MODE_LOOSE&&(t=ct.MODE_AUTO);const e=!this.useV2Algorithm;let i,o,r,s,a;if(e){if(this.bounds){const I=this.boundsPolygon;if(!I)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(X=>Be(X[0],I)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:o,maxx:r,miny:s,maxy:a}=this.computeGcpBbox()}else{const I=this.validateAndPrepareInputs();i=I.pointsSet,o=I.minx,r=I.maxx,s=I.miny,a=I.maxy}const c={forw:_t(i.forw),bakw:_t(i.bakw)},f=ne(c.forw,i.edges,"target"),l=ne(c.bakw,i.edges,"target");if(f.features.length===0||l.features.length===0)throw"TOO LINEAR1";const h=mi(c.forw),u=ln(c.forw);if(!u)throw"TOO LINEAR2";const p={},x=u.geometry.coordinates[0];let y;try{y=x.map(I=>({forw:I,bakw:te(Nt(I),f)})),y.forEach(I=>{p[`${I.forw[0]}:${I.forw[1]}`]=I})}catch{throw"TOO LINEAR2"}const k=ln(c.bakw);if(!k)throw"TOO LINEAR2";const S=k.geometry.coordinates[0];try{y=S.map(I=>({bakw:I,forw:te(Nt(I),l)})),y.forEach(I=>{p[`${I.forw[0]}:${I.forw[1]}`]=I})}catch{throw"TOO LINEAR2"}let g;if(e){const I=h.geometry.coordinates,N=f.features.find(X=>Be(Nt(I),X));if(N){const X=N.geometry.coordinates[0],F=N.properties.a.geom,w=N.properties.b.geom,E=N.properties.c.geom;g={forw:[(X[0][0]+X[1][0]+X[2][0])/3,(X[0][1]+X[1][1]+X[2][1])/3],bakw:[(F[0]+w[0]+E[0])/3,(F[1]+w[1]+E[1])/3]}}else g={forw:I,bakw:te(h,f)}}else g={forw:h.geometry.coordinates,bakw:te(h,f)};const v=oe(g.forw,g.bakw,"c");this.centroid={forw:v,bakw:se(v)};const d=[...this.points.map(I=>({forw:I[0],bakw:I[1]})),...(this.edgeNodes??[]).map(I=>({forw:I[0],bakw:I[1]}))],b={convexBuf:p,centroid:g,allGcps:d,minx:o,maxx:r,miny:s,maxy:a},m=this.vertexMode===ct.VERTEX_BIRDEYE?yr(b,e):wr(b,e),A={forw:[],bakw:[]};for(let I=0;I<m.length;I++){const N=m[I].forw,X=m[I].bakw,F=oe(N,X,`b${I}`),w=se(F);i.forw.push(F),i.bakw.push(w),A.forw.push(F),A.bakw.push(w)}this.pointsSet={forw:_t(i.forw),bakw:_t(i.bakw),edges:i.edges},this.tins={forw:xn(ne(this.pointsSet.forw,i.edges,"target"))},(t===ct.MODE_STRICT||t===ct.MODE_AUTO)&&this.calcurateStrictTin(),(t===ct.MODE_LOOSE||t===ct.MODE_AUTO&&this.strict_status===ct.STATUS_ERROR)&&(this.tins.bakw=xn(ne(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=ct.STATUS_LOOSE),this.vertices_params={forw:Ve(A.forw,this.centroid.forw),bakw:Ve(A.bakw,this.centroid.bakw)},this.addIndexedTin();const B=["forw"];this.strict_status===ct.STATUS_LOOSE&&B.push("bakw");const P=this.strict_status===ct.STATUS_STRICT;this.pointsWeightBuffer=jr({tins:this.tins,targets:B,includeReciprocals:P,numBoundaryVertices:m.length})}async updateTinAsync(){this.updateTin()}}yt.Tin=ct,yt.constrainedTin=ne,yt.counterPoint=se,yt.createPoint=oe,yt.default=ct,yt.findIntersections=Nn,yt.format_version=Ye,yt.insertSearchIndex=qe,yt.vertexCalc=Ve,Object.defineProperties(yt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
5
+ ${JSON.stringify(o)}`;if(i.forEach(r=>{const s=e[r];if(!s)return;const a=s.filter(l=>l!==t);a.length===0?delete e[r]:e[r]=a}),n){const r=(s,a)=>{!s||!a||(s.features=s.features.filter(l=>l!==a))};r(n.forw,t.forw),r(n.bakw,t.bakw)}}function le(e,t,n){return Dt(e,{target:{geom:t,index:n}})}function he(e){return Dt(e.properties.target.geom,{target:{geom:e.geometry.coordinates,index:e.properties.target.index}})}function Qe(e,t){const n=e.length,i=t.geometry.coordinates;return Array.from({length:n},(o,r)=>r).map(o=>{const r=(o+1)%n,s=e[o],a=e[r],l=s.geometry.coordinates,f=Math.atan2(l[0]-i[0],l[1]-i[1]),u=[t,s,a,t].map(p=>p.geometry.coordinates),c={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:s.properties.target.geom,index:s.properties.target.index},c:{geom:a.properties.target.geom,index:a.properties.target.index}},h=St([Zt([u],c)]);return[f,h]}).reduce((o,r)=>(o[0].push(r[0]),o[1].push(r[1]),o),[[],[]])}function eo(e){const{tins:t,targets:n,includeReciprocals:i,numBoundaryVertices:o=4}=e,r={};n.forEach(a=>{const l=t[a];if(!l||!l.features)return;r[a]={};const f={};l.features.forEach(u=>{const c=["a","b","c"];for(let h=0;h<3;h++){const p=(h+1)%3,M=c[h],m=c[p],S=u.properties[M].index,_=u.properties[m].index,g=[S,_].sort().join("-");if(f[g])continue;f[g]=!0;const v=u.geometry.coordinates[0][h],d=u.geometry.coordinates[0][p],b=u.properties[M].geom,w=u.properties[m].geom,E=Math.sqrt(Math.pow(b[0]-w[0],2)+Math.pow(b[1]-w[1],2))/Math.sqrt(Math.pow(v[0]-d[0],2)+Math.pow(v[1]-d[1],2)),B=r[a];B[`${S}:${g}`]=E,B[`${_}:${g}`]=E}})});const s={};return i&&(s.bakw={}),n.forEach(a=>{const l=r[a];if(s[a]={},!l)return;const f={};Object.keys(l).forEach(c=>{const[h]=c.split(":");f[h]||(f[h]=[]),f[h].push(l[c])}),Object.keys(f).forEach(c=>{const h=f[c],p=h.reduce((M,m)=>M+m,0)/h.length;s[a][c]=p,i&&s.bakw&&(s.bakw[c]=1/p)});let u=0;for(let c=0;c<o;c++){const h=`b${c}`,p=s[a][h]||0;u+=p}s[a].c=u/o,i&&s.bakw&&(s.bakw.c=1/s[a].c)}),s}function Ee(e,t=1e-6){const[n,i]=e[0],[o,r]=e[1],[s,a]=e[2];return Math.abs((o-n)*(a-i)-(s-n)*(r-i))<t}function no(e,t){const n=new Set;return e.forEach(i=>{if(i.length!==2)return;const o=i.map(r=>`${t?.[r]??r}`);n.add(o.sort().join("-"))}),n}function ue(e){return["a","b","c"].map((t,n)=>({prop:e.properties[t],geom:e.geometry.coordinates[0][n]}))}const io=10;function ro(e,t,n,i,o,r){if(!e&&!t)return!1;const s=e?0:1,a=1-s,l=n[s],f=n[a];if(!l||!f)return!1;const u=_t(f.geom);let c=!1,h=!1;for(let p=0;p<=1;p++){const M=i[p];if(!M)continue;const m=[String(M.prop.index),String(l.prop.index)].sort().join("-"),S=o[m];if(!S||S.length<2)continue;const _=S.find(O=>O.bakw!==r[s].bakw);if(!_)continue;const v=ue(_.bakw).find(O=>String(O.prop.index)!==String(M.prop.index)&&String(O.prop.index)!==String(l.prop.index));if(!v)continue;c=!0;const d=_t(v.geom),b=_t(M.geom),w=_t(l.geom),E=w[0]-b[0],B=w[1]-b[1],P=E*(u[1]-b[1])-B*(u[0]-b[0]),I=E*(d[1]-b[1])-B*(d[0]-b[0]);if(P*I>0){h=!0;break}}return c&&!h}function oo(e,t,n,i){if(!e&&!t)return!1;if(n[0]&&n[1]&&i[0]&&i[1]){const o=i.map(u=>_t(u.geom)),r=n.map(u=>_t(u.geom)),s=o[1][0]-o[0][0],a=o[1][1]-o[0][1],l=s*(r[0][1]-o[0][1])-a*(r[0][0]-o[0][0]),f=s*(r[1][1]-o[0][1])-a*(r[1][0]-o[0][0]);return l*f<0}return!1}function so(e,t,n,i){const o=no(n,i),r=new Set;let s=!1;for(let a=0;a<io;a++){let l=!1;for(const f of Object.keys(t)){if(r.has(f))continue;r.add(f);const u=t[f];if(!u||u.length<2)continue;const c=f.split("-");if(c.length!==2||o.has(f))continue;const h=ue(u[0].bakw),p=ue(u[1].bakw),M=ue(u[0].forw),m=ue(u[1].forw),S=c.map(x=>h.find(N=>`${N.prop.index}`===x)||p.find(N=>`${N.prop.index}`===x)),_=c.map(x=>M.find(N=>`${N.prop.index}`===x)||m.find(N=>`${N.prop.index}`===x));if(S.some(x=>!x)||_.some(x=>!x))continue;const g=[h,p].map(x=>x.find(N=>!c.includes(`${N.prop.index}`))),v=[M,m].map(x=>x.find(N=>!c.includes(`${N.prop.index}`)));if(g.some(x=>!x)||v.some(x=>!x))continue;const d=u[0].bakw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),b=u[1].bakw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),w=u[0].forw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),E=u[1].forw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),B=Ee(d),P=Ee(b),I=Ee(w),O=Ee(E),X=ro(B,P,g,S,t,u),R=oo(I,O,g,S);if(!(X||R||Qn(_t(g[0].geom),b)||Qn(_t(g[1].geom),d)))continue;const A=_.map(x=>_t(x.geom)),k=v.map(x=>_t(x.geom)),T=ao([...A,...k]),C=co(T),Y=Hn(A[0],A[1],k[0])+Hn(A[0],A[1],k[1]);He(C,Y)&&(Kn(t,u[0],e),Kn(t,u[1],e),S.forEach(x=>{if(!x)return;const N=[x.geom,g[0].geom,g[1].geom,x.geom],D={a:x.prop,b:g[0].prop,c:g[1].prop},F=Zt([N],D),L=Nn(F);Ke(t,{forw:L,bakw:F},e)}),l=!0,s=!0)}if(!l)break}return s}function _t(e){return[e[0],e[1]]}function Qn(e,t){const[n,i]=t[0],[o,r]=t[1],[s,a]=t[2],l=s-n,f=a-i,u=o-n,c=r-i,h=e[0]-n,p=e[1]-i,M=l*l+f*f,m=l*u+f*c,S=l*h+f*p,_=u*u+c*c,g=u*h+c*p,v=M*_-m*m;if(v===0)return!1;const d=1/v,b=(_*S-m*g)*d,w=(M*g-m*S)*d,E=1e-9;return b>=-E&&w>=-E&&b+w<=1+E}function ao(e){const t=e.map(s=>s.slice()).filter((s,a,l)=>l.findIndex(f=>He(f[0],s[0])&&He(f[1],s[1]))===a);if(t.length<=1)return t;const n=t.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),i=(s,a,l)=>(a[0]-s[0])*(l[1]-s[1])-(a[1]-s[1])*(l[0]-s[0]),o=[];for(const s of n){for(;o.length>=2&&i(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}const r=[];for(let s=n.length-1;s>=0;s--){const a=n[s];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}return r.pop(),o.pop(),o.concat(r)}function co(e){if(e.length<3)return 0;let t=0;for(let n=0;n<e.length;n++){const[i,o]=e[n],[r,s]=e[(n+1)%e.length];t+=i*s-r*o}return Math.abs(t)/2}function Hn(e,t,n){return Math.abs((e[0]*(t[1]-n[1])+t[0]*(n[1]-e[1])+n[0]*(e[1]-t[1]))/2)}function He(e,t,n=1e-9){return Math.abs(e-t)<=n}const Zn=3;class ct extends kt{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||ct.VERTEX_PLAIN),this.strictMode=t.strictMode||ct.MODE_AUTO,this.yaxisMode=t.yaxisMode||ct.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,this.useV2Algorithm=t.useV2Algorithm??!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return this.useV2Algorithm?Ue:Zn}setPoints(t){this.yaxisMode===ct.YAXIS_FOLLOW&&(t=t.map(n=>[n[0],[n[1][0],-1*n[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Xn(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let n=t[0][0],i=n,o=t[0][1],r=o;const s=[t[0]];for(let a=1;a<t.length;a++){const l=t[a];l[0]<n&&(n=l[0]),l[0]>i&&(i=l[0]),l[1]<o&&(o=l[1]),l[1]>r&&(r=l[1]),s.push(l)}s.push(t[0]),this.boundsPolygon=Zt([s]),this.xy=[n,o],this.wh=[i-n,r-o],this.vertexMode=ct.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?Ue:Zn,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 n=this.vertices_params.forw[1];if(n)for(let i=0;i<n.length;i++){const o=n[i].features[0],r=o.geometry.coordinates[0][1],s=o.properties.b.geom;t.vertices_points[i]=[r,s]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(i=>{t.tins_points[0].push(["a","b","c"].map(o=>i.properties[o].index))}),this.strict_status===ct.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(i=>{t.tins_points[1].push(["a","b","c"].map(o=>i.properties[o].index))})):this.strict_status===ct.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(i=>i.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,this.useV2Algorithm&&(t.xy=this.xy,t.wh=this.wh)):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setCompiled(t){super.setCompiled(t)}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calculateStrictTin(){const t=this.tins.forw.features.map(r=>Nn(r));this.tins.bakw=St(t);const n={};this.tins.forw.features.forEach((r,s)=>{const a=this.tins.bakw.features[s];Ke(n,{forw:r,bakw:a})});const i=(this.pointsSet?.forw.features??[]).map(r=>r.properties.target.index);so(this.tins,n,this.pointsSet?.edges||[],i);const o=["forw","bakw"].map(r=>{const s=this.tins[r].features.map(a=>a.geometry.coordinates[0]);return Vn(s)});o[0].length===0&&o[1].length===0?(this.strict_status=ct.STATUS_STRICT,delete this.kinks):(this.strict_status=ct.STATUS_ERROR,this.kinks={forw:St(o[0]),bakw:St(o[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let o=0;o<this.points.length;o++){const r=this.points[o][0],s=this.points[o][1],a=le(r,s,o);t.forw.push(a),t.bakw.push(he(a))}const n=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let o=0;o<this.edges.length;o++){const r=this.edges[o][2],s=Object.assign([],this.edges[o][0]),a=Object.assign([],this.edges[o][1]);if(s.length===0&&a.length===0){n.push(r);continue}s.unshift(this.points[r[0]][0]),s.push(this.points[r[1]][0]),a.unshift(this.points[r[0]][1]),a.push(this.points[r[1]][1]);const l=[s,a].map(f=>{const u=f.map((h,p,M)=>{if(p===0)return 0;const m=M[p-1];return Math.sqrt(Math.pow(h[0]-m[0],2)+Math.pow(h[1]-m[1],2))}),c=u.reduce((h,p,M)=>M===0?[0]:(h.push(h[M-1]+p),h),[]);return c.map((h,p,M)=>{const m=h/M[M.length-1];return[f[p],u[p],c[p],m]})});l.map((f,u)=>{const c=l[u?0:1];return f.filter((h,p)=>!(p===0||p===f.length-1||h[4]==="handled")).flatMap(h=>{const p=h[0],M=h[3],m=c.reduce((S,_,g,v)=>{if(S)return S;const d=v[g+1];if(_[3]===M)return _[4]="handled",[_];if(_[3]<M&&d&&d[3]>M)return[_,d]},void 0);if(m&&m.length===1)return u===0?[[p,m[0][0],M]]:[[m[0][0],p,M]];if(m&&m.length===2){const S=m[0],_=m[1],g=(M-S[3])/(_[3]-S[3]),v=[(_[0][0]-S[0][0])*g+S[0][0],(_[0][1]-S[0][1])*g+S[0][1]];return u===0?[[p,v,M]]:[[v,p,M]]}return[]})}).reduce((f,u)=>f.concat(u),[]).sort((f,u)=>f[2]<u[2]?-1:1).map((f,u,c)=>{this.edgeNodes[i]=[f[0],f[1]];const h=le(f[0],f[1],`e${i}`);i++,t.forw.push(h),t.bakw.push(he(h)),u===0?n.push([r[0],t.forw.length-1]):n.push([t.forw.length-2,t.forw.length-1]),u===c.length-1&&n.push([t.forw.length-1,r[1]])})}return{forw:t.forw,bakw:t.bakw,edges:n}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],n=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],o=this.xy[1]+1.05*this.wh[1];if(this.bounds&&!this.boundsPolygon)throw new Error("Internal error: bounds is set but boundsPolygon is missing");const r=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((l,f)=>l&&(r?Ce(f[0],r):f[0][0]>=t&&f[0][0]<=n&&f[0][1]>=i&&f[0][1]<=o),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[n,i],[t,o],[n,o]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:n,miny:i,maxy:o}}computeGcpBbox(){let t=1/0,n=-1/0,i=1/0,o=-1/0;for(const a of this.points){const l=a[0][0],f=a[0][1];l<t&&(t=l),l>n&&(n=l),f<i&&(i=f),f>o&&(o=f)}const r=n-t,s=o-i;return{minx:t-.05*r,maxx:n+.05*r,miny:i-.05*s,maxy:o+.05*s}}updateTin(){let t=this.strictMode;t!==ct.MODE_STRICT&&t!==ct.MODE_LOOSE&&(t=ct.MODE_AUTO);const n=!this.useV2Algorithm;let i,o,r,s,a;if(n){if(this.bounds){const I=this.boundsPolygon;if(!I)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(X=>Ce(X[0],I)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:o,maxx:r,miny:s,maxy:a}=this.computeGcpBbox()}else{const I=this.validateAndPrepareInputs();i=I.pointsSet,o=I.minx,r=I.maxx,s=I.miny,a=I.maxy}const l={forw:St(i.forw),bakw:St(i.bakw)},f=ae(l.forw,i.edges,"target"),u=ae(l.bakw,i.edges,"target");if(f.features.length===0||u.features.length===0)throw"TOO LINEAR1";const c=Ni(l.forw),h=xn(l.forw);if(!h)throw"TOO LINEAR2";const p={},M=h.geometry.coordinates[0];let m;try{m=M.map(I=>({forw:I,bakw:oe(Dt(I),f)})),m.forEach(I=>{p[`${I.forw[0]}:${I.forw[1]}`]=I})}catch{throw"TOO LINEAR2"}const S=xn(l.bakw);if(!S)throw"TOO LINEAR2";const _=S.geometry.coordinates[0];try{m=_.map(I=>({bakw:I,forw:oe(Dt(I),u)})),m.forEach(I=>{p[`${I.forw[0]}:${I.forw[1]}`]=I})}catch{throw"TOO LINEAR2"}let g;if(n){const I=c.geometry.coordinates,O=f.features.find(X=>Ce(Dt(I),X));if(O){const X=O.geometry.coordinates[0],R=O.properties.a.geom,y=O.properties.b.geom,A=O.properties.c.geom;g={forw:[(X[0][0]+X[1][0]+X[2][0])/3,(X[0][1]+X[1][1]+X[2][1])/3],bakw:[(R[0]+y[0]+A[0])/3,(R[1]+y[1]+A[1])/3]}}else g={forw:I,bakw:oe(c,f)}}else g={forw:c.geometry.coordinates,bakw:oe(c,f)};const v=le(g.forw,g.bakw,"c");this.centroid={forw:v,bakw:he(v)};const d=[...this.points.map(I=>({forw:I[0],bakw:I[1]})),...(this.edgeNodes??[]).map(I=>({forw:I[0],bakw:I[1]}))],b={convexBuf:p,centroid:g,allGcps:d,minx:o,maxx:r,miny:s,maxy:a},w=this.vertexMode===ct.VERTEX_BIRDEYE?Nr(b,n):Or(b,n),E={forw:[],bakw:[]};for(let I=0;I<w.length;I++){const O=w[I].forw,X=w[I].bakw,R=le(O,X,`b${I}`),y=he(R);i.forw.push(R),i.bakw.push(y),E.forw.push(R),E.bakw.push(y)}this.pointsSet={forw:St(i.forw),bakw:St(i.bakw),edges:i.edges},this.tins={forw:On(ae(this.pointsSet.forw,i.edges,"target"))},(t===ct.MODE_STRICT||t===ct.MODE_AUTO)&&this.calculateStrictTin(),(t===ct.MODE_LOOSE||t===ct.MODE_AUTO&&this.strict_status===ct.STATUS_ERROR)&&(this.tins.bakw=On(ae(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=ct.STATUS_LOOSE),this.vertices_params={forw:Qe(E.forw,this.centroid.forw),bakw:Qe(E.bakw,this.centroid.bakw)},this.addIndexedTin();const B=["forw"];this.strict_status===ct.STATUS_LOOSE&&B.push("bakw");const P=this.strict_status===ct.STATUS_STRICT;this.pointsWeightBuffer=eo({tins:this.tins,targets:B,includeReciprocals:P,numBoundaryVertices:w.length})}async updateTinAsync(){this.updateTin()}}bt.Tin=ct,bt.constrainedTin=ae,bt.counterPoint=he,bt.createPoint=le,bt.default=ct,bt.findIntersections=Vn,bt.format_version=Ue,bt.insertSearchIndex=Ke,bt.vertexCalc=Qe,Object.defineProperties(bt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
@@ -1,5 +1,26 @@
1
1
  import { TinsBD } from '@maplat/transform';
2
2
  import { SearchIndex } from "./searchutils";
3
3
  type ConstraintEdges = number[][];
4
- export declare function resolveOverlaps(tins: TinsBD, searchIndex: SearchIndex, edges: ConstraintEdges): boolean;
4
+ /**
5
+ * pointsSet 内の配列位置 → 頂点 index(properties.target.index)の対応表。
6
+ * GCP は数値、エッジ中間ノードは "e12"、境界頂点は "b3" のような文字列。
7
+ */
8
+ export type PointIndices = readonly (number | string)[];
9
+ /**
10
+ * 制約エッジを searchIndex のキー形式へ正規化した集合を作る。
11
+ *
12
+ * 二つの名前空間が混在している点に注意すること:
13
+ * - `edges` の要素は **pointsSet 内の配列位置**(数値)
14
+ * - searchIndex のキーは **頂点 index**(properties.target.index。
15
+ * GCP は数値だがエッジ中間ノードは "e58" のような文字列)
16
+ *
17
+ * GCP は「配列位置 == index」なので偶然一致するが、エッジ中間ノードは
18
+ * 配列位置と `e` の連番が別物であり、対応表なしでは一致しない。
19
+ * そのため pointIndices で配列位置を頂点 index へ引き直してからキー化する。
20
+ *
21
+ * キーの作り方は searchutils.ts の calcSearchKeys と厳密に揃える
22
+ * (String 化 → sort(既定の文字列比較)→ "-" 連結)。
23
+ */
24
+ export declare function buildConstraintEdgeKeys(edges: ConstraintEdges, pointIndices?: PointIndices): Set<string>;
25
+ export declare function resolveOverlaps(tins: TinsBD, searchIndex: SearchIndex, edges: ConstraintEdges, pointIndices?: PointIndices): boolean;
5
26
  export {};
package/dist/tin.d.ts CHANGED
@@ -76,7 +76,7 @@ export declare class Tin extends Transform {
76
76
  /**
77
77
  * 厳密なTINを計算します
78
78
  */
79
- calcurateStrictTin(): void;
79
+ calculateStrictTin(): void;
80
80
  /**
81
81
  * 点群セットを生成します。
82
82
  * GCP と中間エッジノードを GeoJSON Point に変換し、後続の三角分割に備えます。
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "1.0.0-rc1",
7
+ "version": "1.0.0",
8
8
  "description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
9
9
  "type": "module",
10
10
  "module": "./dist/maplat_tin.js",
@@ -49,33 +49,33 @@
49
49
  "deno"
50
50
  ],
51
51
  "dependencies": {
52
- "@maplat/transform": "^1.0.0-rc1",
53
- "@turf/turf": "^7.3.1",
52
+ "@maplat/transform": "^1.0.0",
53
+ "@turf/turf": "^7.4.0",
54
54
  "delaunator": "^5.0.1",
55
55
  "robust-predicates": "^3.0.2"
56
56
  },
57
57
  "devDependencies": {
58
- "@eslint/js": "^9.39.2",
58
+ "@eslint/js": "^9.39.5",
59
59
  "@testing-library/jest-dom": "^6.9.1",
60
60
  "@types/delaunator": "^5.0.3",
61
61
  "@types/estree": "^1.0.8",
62
62
  "@types/geojson": "^7946.0.16",
63
63
  "@types/node": "^25.5.2",
64
- "@typescript-eslint/eslint-plugin": "^8.58.0",
65
- "@typescript-eslint/parser": "^8.58.0",
64
+ "@typescript-eslint/eslint-plugin": "^8.66.0",
65
+ "@typescript-eslint/parser": "^8.66.0",
66
66
  "@vitest/coverage-v8": "^3.2.6",
67
67
  "cross-env": "^10.1.0",
68
68
  "dotenv": "^17.4.0",
69
69
  "dotenv-cli": "^11.0.0",
70
- "eslint": "^9.39.2",
70
+ "eslint": "^9.39.5",
71
71
  "eslint-config-prettier": "^10.1.8",
72
72
  "globals": "^16.5.0",
73
73
  "jest-matcher-deep-close-to": "^3.0.2",
74
- "jsdom": "^27.4.0",
75
- "prettier": "^3.7.4",
74
+ "jsdom": "^30.0.1",
75
+ "prettier": "^3.9.6",
76
76
  "robust-segment-intersect": "^1.0.1",
77
77
  "typescript": "^5.9.3",
78
- "typescript-eslint": "^8.58.0",
78
+ "typescript-eslint": "^8.66.0",
79
79
  "vite": "^7.3.5",
80
80
  "vite-plugin-dts": "^4.5.4",
81
81
  "vitest": "^3.2.6"