import{aasK}from"./chunk-P73YILG6.js";import{aasL}from"./chunk-SACP225T.js";import{basv,casJ,dasZ}from"./chunk-2NIQ5ECB.js";import{basB,hask}from"./chunk-7YEOLR2L.js";import{aast,basS,casI,dasG,easd}from"./chunk-RH3GFHG2.js";import{aasg}from"./chunk-FRWNWNYJ.js";import{aasW}from"./chunk-TA3RE4KQ.js";import{aasb,basz}from"./chunk-RTY3VPG6.js";import{easp}from"./chunk-LRNH5AEO.js";functionm(n,e){this.center=t.clone(W(n,t.ZERO)),this.halfAxes=d.clone(W(e,d.ZERO))}m.packedLength=t.packedLength+d.packedLength;m.pack=function(n,e,c){returnz.typeOf.object("value",n),z.defined("array",e),c=W(c,0),t.pack(n.center,e,c),d.pack(n.halfAxes,e,c+t.packedLength),e};m.unpack=function(n,e,c){returnz.defined("array",n),e=W(e,0),p(c)||(c=newm),t.unpack(n,e,c.center),d.unpack(n,e+t.packedLength,c.halfAxes),c};varCt=newt,ut=newt,Pt=newt,xt=newt,yt=newt,At=newt,Nt=newd,Mt={unitary:newd,diagonal:newd};m.fromPoints=function(n,e){if(p(e)||(e=newm),!p(n)||n.length===0)returne.halfAxes=d.ZERO,e.center=t.ZERO,e;letc,h=n.length,r=t.clone(n[0],Ct);for(c=1;c<h;c++)t.add(r,n[c],r);leto=1/h;t.multiplyByScalar(r,o,r);leti=0,C=0,w=0,l=0,u=0,a=0,s;for(c=0;c<h;c++)s=t.subtract(n[c],r,ut),i+=s.x*s.x,C+=s.x*s.y,w+=s.x*s.z,l+=s.y*s.y,u+=s.y*s.z,a+=s.z*s.z;i*=o,C*=o,w*=o,l*=o,u*=o,a*=o;letf=Nt;f[0]=i,f[1]=C,f[2]=w,f[3]=C,f[4]=l,f[5]=u,f[6]=w,f[7]=u,f[8]=a;letA=d.computeEigenDecomposition(f,Mt),M=d.clone(A.unitary,e.halfAxes),x=d.getColumn(M,0,xt),y=d.getColumn(M,1,yt),N=d.getColumn(M,2,At),P=-Number.MAX_VALUE,O=-Number.MAX_VALUE,U=-Number.MAX_VALUE,q=Number.MAX_VALUE,R=Number.MAX_VALUE,j=Number.MAX_VALUE;for(c=0;c<h;c++)s=n[c],P=Math.max(t.dot(x,s),P),O=Math.max(t.dot(y,s),O),U=Math.max(t.dot(N,s),U),q=Math.min(t.dot(x,s),q),R=Math.min(t.dot(y,s),R),j=Math.min(t.dot(N,s),j);x=t.multiplyByScalar(x,.5*(q+P),x),y=t.multiplyByScalar(y,.5*(R+O),y),N=t.multiplyByScalar(N,.5*(j+U),N);letT=t.add(x,y,e.center);t.add(T,N,T);letE=Pt;returnE.x=P-q,E.y=O-R,E.z=U-j,t.multiplyByScalar(E,.5,E),d.multiplyByScale(e.halfAxes,E,e.halfAxes),e};varnt=newt,Ot=newt;functionQ(n,e,c,h,r,o,i,C,w,l,u){if(!p(r)||!p(o)||!p(i)||!p(C)||!p(w)||!p(l))thrownewb("all extents (minimum/maximum X/Y/Z) are required.");p(u)||(u=newm);leta=u.halfAxes;d.setColumn(a,0,e,a),d.setColumn(a,1,c,a),d.setColumn(a,2,h,a);lets=nt;s.x=(r+o)/2,s.y=(i+C)/2,s.z=(w+l)/2;letf=Ot;f.x=(o-r)/2,f.y=(C-i)/2,f.z=(l-w)/2;letA=u.center;returns=d.multiplyByVector(a,s,s),t.add(n,s,A),d.multiplyByScale(a,f,a),u}var$=newS,bt=newt,Tt=newS,St=newS,gt=newS,Et=newS,Rt=newS,Wt=newt,H=newt,zt=newt,tt=newt,It=newt,Lt=newI,Ut=newI,qt=newI,jt=newI,Bt=newI,vt=newt,Vt=newt,_t=newt,Dt=newt,Xt=newI,kt=newt,Zt=newt,Yt=newt,Ft=newL(t.UNIT_X,0);m.fromRectangle=function(n,e,c,h,r){if(!p(n))thrownewb("rectangle is required");if(n.width<0||n.width>g.TWO_PI)thrownewb("Rectangle width must be between 0 and 2 * pi");if(n.height<0||n.height>g.PI)thrownewb("Rectangle height must be between 0 and pi");if(p(h)&&!g.equalsEpsilon(h.radii.x,h.radii.y,g.EPSILON15))thrownewb("Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)");e=W(e,0),c=W(c,0),h=W(h,G.default);leto,i,C,w,l,u,a;if(n.width<=g.PI){letR=k.center(n,$),j=h.cartographicToCartesian(R,bt),T=newK(j,h);a=T.plane;letE=R.longitude,ot=n.south<0&&n.north>0?0:R.latitude,st=S.fromRadians(E,n.north,c,Tt),V=S.fromRadians(n.west,n.north,c,St),it=S.fromRadians(n.west,ot,c,gt),_=S.fromRadians(n.west,n.south,c,Et),ht=S.fromRadians(E,n.south,c,Rt),ft=h.cartographicToCartesian(st,Wt),D=h.cartographicToCartesian(V,H),dt=h.cartographicToCartesian(it,zt),X=h.cartographicToCartesian(_,tt),mt=h.cartographicToCartesian(ht,It),wt=T.projectPointToNearestOnPlane(ft,Lt),Y=T.projectPointToNearestOnPlane(D,Ut),lt=T.projectPointToNearestOnPlane(dt,qt),F=T.projectPointToNearestOnPlane(X,jt),pt=T.projectPointToNearestOnPlane(mt,Bt);returno=Math.min(Y.x,lt.x,F.x),i=-o,w=Math.max(Y.y,wt.y),C=Math.min(F.y,pt.y),V.height=_.height=e,D=h.cartographicToCartesian(V,H),X=h.cartographicToCartesian(_,tt),l=Math.min(L.g