/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.122
 *
 * Copyright 2011-2022 Cesium Contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Columbus View (Pat. Pend.)
 *
 * Portions licensed separately.
 * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
 */
import{a as W}from"./chunk-IFAARW2T.js";import{a as Z}from"./chunk-UGB43LJM.js";import{a as X}from"./chunk-WFZLZ2P5.js";import{b as K,c as Q,d as V}from"./chunk-N72XKOXM.js";import{d as H}from"./chunk-EWTFJ46X.js";import{a as U}from"./chunk-27UWHT4D.js";import{a as r,d as J}from"./chunk-RFPX772U.js";import{a as B}from"./chunk-RAYRECQS.js";import{a as u}from"./chunk-6KLVDWWE.js";import{a as P}from"./chunk-6P5KAIBX.js";import{e as T}from"./chunk-4FSVUTPL.js";var ii=new r(1,1,1),S=Math.cos,q=Math.sin;function x(i){i=u(i,u.EMPTY_OBJECT);let t=u(i.radii,ii),e=u(i.innerRadii,t),o=u(i.minimumClock,0),n=u(i.maximumClock,B.TWO_PI),a=u(i.minimumCone,0),s=u(i.maximumCone,B.PI),m=Math.round(u(i.stackPartitions,10)),f=Math.round(u(i.slicePartitions,8)),c=Math.round(u(i.subdivisions,128));if(m<1)throw new P("options.stackPartitions cannot be less than 1");if(f<0)throw new P("options.slicePartitions cannot be less than 0");if(c<0)throw new P("options.subdivisions must be greater than or equal to zero.");if(T(i.offsetAttribute)&&i.offsetAttribute===W.TOP)throw new P("GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.");this._radii=r.clone(t),this._innerRadii=r.clone(e),this._minimumClock=o,this._maximumClock=n,this._minimumCone=a,this._maximumCone=s,this._stackPartitions=m,this._slicePartitions=f,this._subdivisions=c,this._offsetAttribute=i.offsetAttribute,this._workerName="createEllipsoidOutlineGeometry"}x.packedLength=2*r.packedLength+8,x.pack=function(i,t,e){if(!T(i))throw new P("value is required");if(!T(t))throw new P("array is required");return e=u(e,0),r.pack(i._radii,t,e),e+=r.packedLength,r.pack(i._innerRadii,t,e),e+=r.packedLength,t[e++]=i._minimumClock,t[e++]=i._maximumClock,t[e++]=i._minimumCone,t[e++]=i._maximumCone,t[e++]=i._stackPartitions,t[e++]=i._slicePartitions,t[e++]=i._subdivisions,t[e]=u(i._offsetAttribute,-1),t};var $=new r,G=new r,b={radii:$,innerRadii:G,minimumClock:void 0,maximumClock:void 0,minimumCone:void 0,maximumCone:void 0,stackPartitions:void 0,slicePartitions:void 0,subdivisions:void 0,offsetAttribute:void 0};x.unpack=function(i,t,e){if(!T(i))throw new P("array is required");t=u(t,0);let o=r.unpack(i,t,$);t+=r.packedLength;let n=r.unpack(i,t,G);t+=r.packedLength;let a=i[t++],s=i[t++],m=i[t++],f=i[t++],c=i[t++],l=i[t++],d=i[t++],h=i[t];return T(e)?(e._radii=r.clone(o,e._radii),e._innerRadii=r.clone(n,e._innerRadii),e._minimumClock=a,e._maximumClock=s,e._minimumCone=m,e._maximumCone=f,e._stackPartitions=c,e._slicePartitions=l,e._subdivisions=d,e._offsetAttribute=-1===h?void 0:h,e):(b.minimumClock=a,b.maximumClock=s,b.minimumCone=m,b.maximumCone=f,b.stackPartitions=c,b.slicePartitions=l,b.subdivisions=d,b.offsetAttribute=-1===h?void 0:h,new x(b))},x.createGeometry=function(i){let t=i._radii;if(t.x<=0||t.y<=0||t.z<=0)return;let r=i._innerRadii;if(r.x<=0||r.y<=0||r.z<=0)return;let e=i._minimumClock,o=i._maximumClock,n=i._minimumCone,a=i._maximumCone,s=i._subdivisions,m=J.fromCartesian3(t),u=i._slicePartitions+1,f=i._stackPartitions+1;u=Math.round(u*Math.abs(o-e)/B.TWO_PI),f=Math.round(f*Math.abs(a-n)/B.PI),u<2&&(u=2),f<2&&(f=2);let c=0,l=1,d=r.x!==t.x||r.y!==t.y||r.z!==t.z,h=!1,_=!1;d&&(l=2,n>0&&(h=!0,c+=u),a<Math.PI&&(_=!0,c+=u));let k,p,b,P,C=s*l*(f+u),x=new Float64Array(3*C),w=2*(C+c-(u+f)*l),A=Z.createTypedArray(C,w),y=0,v=new Array(f),g=new Array(f);for(k=0;k<f;k++)P=n+k*(a-n)/(f-1),v[k]=q(P),g[k]=S(P);let M=new Array(s),E=new Array(s);for(k=0;k<s;k++)b=e+k*(o-e)/(s-1),M[k]=q(b),E[k]=S(b);for(k=0;k<f;k++)for(p=0;p<s;p++)x[y++]=t.x*v[k]*E[p],x[y++]=t.y*v[k]*M[p],x[y++]=t.z*g[k];if(d)for(k=0;k<f;k++)for(p=0;p<s;p++)x[y++]=r.x*v[k]*E[p],x[y++]=r.y*v[k]*M[p],x[y++]=r.z*g[k];for(v.length=s,g.length=s,k=0;k<s;k++)P=n+k*(a-n)/(s-1),v[k]=q(P),g[k]=S(P);for(M.length=u,E.length=u,k=0;k<u;k++)b=e+k*(o-e)/(u-1),M[k]=q(b),E[k]=S(b);for(k=0;k<s;k++)for(p=0;p<u;p++)x[y++]=t.x*v[k]*E[p],x[y++]=t.y*v[k]*M[p],x[y++]=t.z*g[k];if(d)for(k=0;k<s;k++)for(p=0;p<u;p++)x[y++]=r.x*v[k]*E[p],x[y++]=r.y*v[k]*M[p],x[y++]=r.z*g[k];for(y=0,k=0;k<f*l;k++){let i=k*s;for(p=0;p<s-1;p++)A[y++]=i+p,A[y++]=i+p+1}let L=f*s*l;for(k=0;k<u;k++)for(p=0;p<s-1;p++)A[y++]=L+k+p*u,A[y++]=L+k+(p+1)*u;if(d)for(L=f*s*l+u*s,k=0;k<u;k++)for(p=0;p<s-1;p++)A[y++]=L+k+p*u,A[y++]=L+k+(p+1)*u;if(d){let i=f*s*l,t=i+s*u;if(h)for(k=0;k<u;k++)A[y++]=i+k,A[y++]=t+k;if(_)for(i+=s*u-u,t+=s*u-u,k=0;k<u;k++)A[y++]=i+k,A[y++]=t+k}let j=new X({position:new V({componentDatatype:U.DOUBLE,componentsPerAttribute:3,values:x})});if(T(i._offsetAttribute)){let t=x.length,r=i._offsetAttribute===W.NONE?0:1,e=new Uint8Array(t/3).fill(r);j.applyOffset=new V({componentDatatype:U.UNSIGNED_BYTE,componentsPerAttribute:1,values:e})}return new Q({attributes:j,indices:A,primitiveType:K.LINES,boundingSphere:H.fromEllipsoid(m),offsetAttribute:i._offsetAttribute})};var Ci=x;export{Ci as a};