import{bas_,hasI}from"./chunk-7YEOLR2L.js";import{aasn,basN,dasZ,easA}from"./chunk-RH3GFHG2.js";import{aascn}from"./chunk-FRWNWNYJ.js";import{aasT}from"./chunk-TA3RE4KQ.js";import{aason,bash}from"./chunk-RTY3VPG6.js";import{easx}from"./chunk-LRNH5AEO.js";functionV(e){this._ellipsoid=T(e,Z.default),this._semimajorAxis=this._ellipsoid.maximumRadius,this._oneOverSemimajorAxis=1/this._semimajorAxis}Object.defineProperties(V.prototype,{ellipsoid:{get:function(){returnthis._ellipsoid}}});V.prototype.project=function(e,t){leto=this._semimajorAxis,c=e.longitude*o,r=e.latitude*o,d=e.height;returnx(t)?(t.x=c,t.y=r,t.z=d,t):newn(c,r,d)};V.prototype.unproject=function(e,t){if(!x(e))thrownewon("cartesian is required");leto=this._oneOverSemimajorAxis,c=e.x*o,r=e.y*o,d=e.z;returnx(t)?(t.longitude=c,t.latitude=r,t.height=d,t):newN(c,r,d)};vark=V;varmn={OUTSIDE:-1,INTERSECTING:0,INSIDE:1},U=Object.freeze(mn);functionun(e,t){this.start=T(e,0),this.stop=T(t,0)}varrn=un;functiona(e,t){this.center=n.clone(T(e,n.ZERO)),this.radius=T(t,0)}varF=newn,Y=newn,J=newn,K=newn,Q=newn,$=newn,L=newn,b=newn,H=newn,nn=newn,tn=newn,en=newn,xn=4/3*cn.PI;a.fromPoints=function(e,t){if(x(t)||(t=newa),!x(e)||e.length===0)returnt.center=n.clone(n.ZERO,t.center),t.radius=0,t;leto=n.clone(e[0],L),c=n.clone(o,F),r=n.clone(o,Y),d=n.clone(o,J),f=n.clone(o,K),s=n.clone(o,Q),m=n.clone(o,$),z=e.length,y;for(y=1;y<z;y++){n.clone(e[y],o);letR=o.x,M=o.y,w=o.z;R<c.x&&n.clone(o,c),R>f.x&&n.clone(o,f),M<r.y&&n.clone(o,r),M>s.y&&n.clone(o,s),w<d.z&&n.clone(o,d),w>m.z&&n.clone(o,m)}letu=n.magnitudeSquared(n.subtract(f,c,b)),i=n.magnitudeSquared(n.subtract(s,r,b)),v=n.magnitudeSquared(n.subtract(m,d,b)),C=c,q=f,O=u;i>O&&(O=i,C=r,q=s),v>O&&(O=v,C=d,q=m);letp=H;p.x=(C.x+q.x)*.5,p.y=(C.y+q.y)*.5,p.z=(C.z+q.z)*.5;letS=n.magnitudeSquared(n.subtract(q,p,b)),l=Math.sqrt(S),j=nn;j.x=c.x,j.y=r.y,j.z=d.z;letP=tn;P.x=f.x,P.y=s.y,P.z=m.z;letD=n.midpoint(j,P,en),B=0;for(y=0;y<z;y++){n.clone(e[y],o);letR=n.magnitude(n.subtract(o,D,b));R>B&&(B=R);letM=n.magnitudeSquared(n.subtract(o,p,b));if(M>S){letw=Math.sqrt(M);l=(l+w)*.5,S=l*l;letg=w-l;p.x=(l*p.x+g*o.x)/w,p.y=(l*p.y+g*o.y)/w,p.z=(l*p.z+g*o.z)/w}}returnl<B?(n.clone(p,t.center),t.radius=l):(n.clone(D,t.center),t.radius=B),t};varan=newk,yn=newn,ln=newn,G=newN,X=newN;a.fromRectangle2D=function(e,t,o){returna.fromRectangleWithHeights2D(e,t,0,0,o)};a.fromRectangleWithHeights2D=function(e,t,o,c,r){if(x(r)||(r=newa),!x(e))returnr.center=n.clone(n.ZERO,r.center),r.radius=0,r;an._ellipsoid=Z.default,t=T(t,an),I.southwest(e,G),G.height=o,I.northeast(e,X),X.height=c;letd=t.project(G,yn),f=t.project(X,ln),s=f.x-d.x,m=f.y-d.y,z=f.z-d.z;r.radius=Math.sqrt(s*s+m*m+z*z)*.5;lety=r.center;returny.x=d.x+s*.5,y.y=d.y+m*.5,y.z=d.z+z*.5,r};varpn=[];a.fromRectangle3D=function(e,t,o,c){if(t=T(t,Z.default),o=T(o,0),x(c)||(c=newa),!x(e))returnc.center=n.clone(n.ZERO,c.center),c.radius=0,c;letr=I.subsample(e,t,o,pn);returna.fromPoints(r,c)};a.fromVertices=function(e,t,o,c){if(x(c)||(c=newa),!x(e)||e.length===0)returnc.center=n.clone(n.ZERO,c.center),c.radius=0,c;t=T(t,n.ZERO),o=T(o,3),h.typeOf.number.greaterThanOrEquals("stride",o,3);letr=L;r.x=e[0]+t.x,r.y=e[1]+t.y,r.z=e[2]+t.z;letd=n.clone(r,F),f=n.clone(r,Y),s=n.clone(r,J),m=n.clone(r,K),z=n.clone(r,Q),y=n.clone(r,$),u=e.length,i;for(i=0;i<u;i+=o){letw=e[i]+t.x,g=e[i+1]+t.y,E=e[i+2]+t.z;r.x=w,r.y=g,r.z=E,w<d.x&&n.clone(r,d),w>m.x&&n.clone(r,m),g<f.y&&n.clone(r,f),g>z.y&&n.clone(r,z),E<s.z&&n.clone(r,s),E>y.z&&n.clone(r,y)}letv=n.magnitudeSquared(n.subtract(m,d,b)),C=n.magnitudeSquared(n.subtract(z,f,b)),q=n.magnitudeSquared(n.subtract(y,s,b)),O=d,p=m,S=v;C>S&&(S=C,O=f,p=z),q>S&&(S=q,O=s,p=y);letl=H;l.x=(O.x+p.x)*.5,l.y=(O.y+p.y)*.5,l.z=(O.z+p.z)*.5;letj=n.magnitudeSquared(n.subtract(p,l,b)),P=Math.sqrt(j),D=nn;D.x=d.x,D.y=f.y,D.z=s.z;letB=tn;B.x=m.x,B.y=z.y,B.z=y.z;letR=n.midpoint(D,B,en),M=0;for(i=0;i<u;i+=o){r.x=e[i]+t.x,r.y=e[i+1]+t.y,r.z=e[i+2]+t.z;letw=n.magnitude(n.subtract(r,R,b));w>M&&(M=w);letg=n.magnitudeSquared