/**
 * @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 J}from"./chunk-ACEBT5DP.js";import{a as Nt}from"./chunk-JCB2M6SL.js";import{a as zt}from"./chunk-6NIX77PU.js";import"./chunk-FG53NUCJ.js";import"./chunk-QTX6TFJQ.js";import{a as ut}from"./chunk-IFAARW2T.js";import{a as X}from"./chunk-6YAFAZVV.js";import{b as Rt}from"./chunk-HCBPQXHZ.js";import"./chunk-45FCQ3FJ.js";import"./chunk-354SKS6C.js";import"./chunk-H5GL2A6Z.js";import{a as yt}from"./chunk-UGB43LJM.js";import{a as Vt}from"./chunk-WFZLZ2P5.js";import{b as Mt,c as Pt,d as q}from"./chunk-N72XKOXM.js";import{d as st}from"./chunk-EWTFJ46X.js";import{f as Lt,i as E,j as At}from"./chunk-5IUXF6I3.js";import{a as Y}from"./chunk-27UWHT4D.js";import{a as w,b as _t,c as G,d as H,e as ft}from"./chunk-RFPX772U.js";import{a as W}from"./chunk-RAYRECQS.js";import"./chunk-2NAI7YQ3.js";import"./chunk-QE3ZUOZY.js";import{a as L}from"./chunk-6KLVDWWE.js";import{a as St,b as lt}from"./chunk-6P5KAIBX.js";import{e as $}from"./chunk-4FSVUTPL.js";var Tt=new w,Bt=new w,Ut=new w,Yt=new w,qt=new E,Zt=new G,Kt=new st,$t=new st;function Xt(t,e){let n=new Pt({attributes:new Vt,primitiveType:Mt.TRIANGLES});return n.attributes.position=new q({componentDatatype:Y.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(n.attributes.normal=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(n.attributes.tangent=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(n.attributes.bitangent=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:e.bitangents})),n}function Gt(t,e,n,o){let a=t.length,r=e.normal?new Float32Array(a):void 0,i=e.tangent?new Float32Array(a):void 0,s=e.bitangent?new Float32Array(a):void 0,l=0,u=Yt,c=Ut,m=Bt;if(e.normal||e.tangent||e.bitangent)for(let p=0;p<a;p+=3){let a=w.fromArray(t,p,Tt),h=l+1,f=l+2;m=n.geodeticSurfaceNormal(a,m),(e.tangent||e.bitangent)&&(w.cross(w.UNIT_Z,m,c),ft.multiplyByVector(o,c,c),w.normalize(c,c),e.bitangent&&w.normalize(w.cross(m,c,u),u)),e.normal&&(r[l]=m.x,r[h]=m.y,r[f]=m.z),e.tangent&&(i[l]=c.x,i[h]=c.y,i[f]=c.z),e.bitangent&&(s[l]=u.x,s[h]=u.y,s[f]=u.z),l+=3}return Xt(e,{positions:t,normals:r,tangents:i,bitangents:s})}var Ct=new w,jt=new w;function te(t,e,n){let o=t.length,a=e.normal?new Float32Array(o):void 0,r=e.tangent?new Float32Array(o):void 0,i=e.bitangent?new Float32Array(o):void 0,s=0,l=0,u=0,c=!0,m=Yt,p=Ut,h=Bt;if(e.normal||e.tangent||e.bitangent)for(let f=0;f<o;f+=6){let g=w.fromArray(t,f,Tt),d=w.fromArray(t,(f+6)%o,Ct);if(c){let e=w.fromArray(t,(f+3)%o,jt);w.subtract(d,g,d),w.subtract(e,g,e),h=w.normalize(w.cross(e,d,h),h),c=!1}w.equalsEpsilon(d,g,W.EPSILON10)&&(c=!0),(e.tangent||e.bitangent)&&(m=n.geodeticSurfaceNormal(g,m),e.tangent&&(p=w.normalize(w.cross(m,h,p),p))),e.normal&&(a[s++]=h.x,a[s++]=h.y,a[s++]=h.z,a[s++]=h.x,a[s++]=h.y,a[s++]=h.z),e.tangent&&(r[l++]=p.x,r[l++]=p.y,r[l++]=p.z,r[l++]=p.x,r[l++]=p.y,r[l++]=p.z),e.bitangent&&(i[u++]=m.x,i[u++]=m.y,i[u++]=m.z,i[u++]=m.x,i[u++]=m.y,i[u++]=m.z)}return Xt(e,{positions:t,normals:a,tangents:r,bitangents:i})}function It(t,e){let n=t._vertexFormat,o=t._ellipsoid,a=e.height,r=e.width,i=e.northCap,s=e.southCap,l=0,u=a,c=a,m=0;i&&(l=1,c-=1,m+=1),s&&(u-=1,c-=1,m+=1),m+=r*c;let p=n.position?new Float64Array(3*m):void 0,h=n.st?new Float32Array(2*m):void 0,f=0,g=0,d=Tt,w=Zt,_=Number.MAX_VALUE,y=Number.MAX_VALUE,A=-Number.MAX_VALUE,b=-Number.MAX_VALUE;for(let t=l;t<u;++t)for(let a=0;a<r;++a)J.computePosition(e,o,n.st,t,a,d,w),p[f++]=d.x,p[f++]=d.y,p[f++]=d.z,n.st&&(h[g++]=w.x,h[g++]=w.y,_=Math.min(_,w.x),y=Math.min(y,w.y),A=Math.max(A,w.x),b=Math.max(b,w.y));if(i&&(J.computePosition(e,o,n.st,0,0,d,w),p[f++]=d.x,p[f++]=d.y,p[f++]=d.z,n.st&&(h[g++]=w.x,h[g++]=w.y,_=w.x,y=w.y,A=w.x,b=w.y)),s&&(J.computePosition(e,o,n.st,a-1,0,d,w),p[f++]=d.x,p[f++]=d.y,p[f]=d.z,n.st&&(h[g++]=w.x,h[g]=w.y,_=Math.min(_,w.x),y=Math.min(y,w.y),A=Math.max(A,w.x),b=Math.max(b,w.y))),n.st&&(_<0||y<0||A>1||b>1))for(let t=0;t<h.length;t+=2)h[t]=(h[t]-_)/(A-_),h[t+1]=(h[t+1]-y)/(b-y);let v=Gt(p,n,o,e.tangentRotationMatrix),x=6*(r-1)*(c-1);i&&(x+=3*(r-1)),s&&(x+=3*(r-1));let E,L=yt.createTypedArray(m,x),F=0,k=0;for(E=0;E<c-1;++E){for(let t=0;t<r-1;++t){let t=F,e=t+r,n=e+1,o=t+1;L[k++]=t,L[k++]=e,L[k++]=o,L[k++]=o,L[k++]=e,L[k++]=n,++F}++F}if(i||s){let t,e,n=m-1,o=m-1;if(i&&s&&(n=m-2),F=0,i)for(E=0;E<r-1;E++)t=F,e=t+1,L[k++]=n,L[k++]=t,L[k++]=e,++F;if(s)for(F=(c-1)*r,E=0;E<r-1;E++)t=F,e=t+1,L[k++]=t,L[k++]=o,L[k++]=e,++F}return v.indices=L,n.st&&(v.attributes.st=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:2,values:h})),v}function ht(t,e,n,o,a){return t[e++]=o[n],t[e++]=o[n+1],t[e++]=o[n+2],t[e++]=a[n],t[e++]=a[n+1],t[e]=a[n+2],t}function dt(t,e,n,o){return t[e++]=o[n],t[e++]=o[n+1],t[e++]=o[n],t[e]=o[n+1],t}var Dt=new X;function ee(t,e){let n,o=t._shadowVolume,a=t._offsetAttribute,r=t._vertexFormat,i=t._extrudedHeight,s=t._surfaceHeight,l=t._ellipsoid,u=e.height,c=e.width;if(o){let e=X.clone(r,Dt);e.normal=!0,t._vertexFormat=e}let m=It(t,e);o&&(t._vertexFormat=r);let p=Rt.scaleToGeodeticHeight(m.attributes.position.values,s,l,!1);p=new Float64Array(p);let h=p.length,f=2*h,g=new Float64Array(f);g.set(p);let d=Rt.scaleToGeodeticHeight(m.attributes.position.values,i,l);g.set(d,h),m.attributes.position.values=g;let _,y,A=r.normal?new Float32Array(f):void 0,b=r.tangent?new Float32Array(f):void 0,v=r.bitangent?new Float32Array(f):void 0,x=r.st?new Float32Array(f/3*2):void 0;if(r.normal){for(y=m.attributes.normal.values,A.set(y),n=0;n<h;n++)y[n]=-y[n];A.set(y,h),m.attributes.normal.values=A}if(o){y=m.attributes.normal.values,r.normal||(m.attributes.normal=void 0);let t=new Float32Array(f);for(n=0;n<h;n++)y[n]=-y[n];t.set(y,h),m.attributes.extrudeDirection=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:t})}let E,L=$(a);if(L){let t=h/3*2,e=new Uint8Array(t);a===ut.TOP?e=e.fill(1,0,t/2):(E=a===ut.NONE?0:1,e=e.fill(E)),m.attributes.applyOffset=new q({componentDatatype:Y.UNSIGNED_BYTE,componentsPerAttribute:1,values:e})}if(r.tangent){let t=m.attributes.tangent.values;for(b.set(t),n=0;n<h;n++)t[n]=-t[n];b.set(t,h),m.attributes.tangent.values=b}if(r.bitangent){let t=m.attributes.bitangent.values;v.set(t),v.set(t,h),m.attributes.bitangent.values=v}r.st&&(_=m.attributes.st.values,x.set(_),x.set(_,h/3*2),m.attributes.st.values=x);let F=m.indices,k=F.length,P=h/3,R=yt.createTypedArray(f/3,2*k);for(R.set(F),n=0;n<k;n+=3)R[n+k]=F[n+2]+P,R[n+1+k]=F[n+1]+P,R[n+2+k]=F[n]+P;m.indices=R;let T=e.northCap,H=e.southCap,N=u,O=2,D=0,j=4,S=4;T&&(O-=1,N-=1,D+=1,j-=2,S-=1),H&&(O-=1,N-=1,D+=1,j-=2,S-=1),D+=O*c+2*N-j;let I=2*(D+S),G=new Float64Array(3*I),U=o?new Float32Array(3*I):void 0,C=L?new Uint8Array(I):void 0,M=r.st?new Float32Array(2*I):void 0,Q=a===ut.TOP;L&&!Q&&(E=a===ut.ALL?1:0,C=C.fill(E));let J,V=0,z=0,B=0,Z=0,K=c*N;for(n=0;n<K;n+=c)J=3*n,G=ht(G,V,J,p,d),V+=6,r.st&&(M=dt(M,z,2*n,_),z+=4),o&&(B+=3,U[B++]=y[J],U[B++]=y[J+1],U[B++]=y[J+2]),Q&&(C[Z++]=1,Z+=1);if(H){let t=T?K+1:K;for(J=3*t,n=0;n<2;n++)G=ht(G,V,J,p,d),V+=6,r.st&&(M=dt(M,z,2*t,_),z+=4),o&&(B+=3,U[B++]=y[J],U[B++]=y[J+1],U[B++]=y[J+2]),Q&&(C[Z++]=1,Z+=1)}else for(n=K-c;n<K;n++)J=3*n,G=ht(G,V,J,p,d),V+=6,r.st&&(M=dt(M,z,2*n,_),z+=4),o&&(B+=3,U[B++]=y[J],U[B++]=y[J+1],U[B++]=y[J+2]),Q&&(C[Z++]=1,Z+=1);for(n=K-1;n>0;n-=c)J=3*n,G=ht(G,V,J,p,d),V+=6,r.st&&(M=dt(M,z,2*n,_),z+=4),o&&(B+=3,U[B++]=y[J],U[B++]=y[J+1],U[B++]=y[J+2]),Q&&(C[Z++]=1,Z+=1);if(T){let t=K;for(J=3*t,n=0;n<2;n++)G=ht(G,V,J,p,d),V+=6,r.st&&(M=dt(M,z,2*t,_),z+=4),o&&(B+=3,U[B++]=y[J],U[B++]=y[J+1],U[B++]=y[J+2]),Q&&(C[Z++]=1,Z+=1)}else for(n=c-1;n>=0;n--)J=3*n,G=ht(G,V,J,p,d),V+=6,r.st&&(M=dt(M,z,2*n,_),z+=4),o&&(B+=3,U[B++]=y[J],U[B++]=y[J+1],U[B++]=y[J+2]),Q&&(C[Z++]=1,Z+=1);let tt=te(G,r,l);r.st&&(tt.attributes.st=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:2,values:M})),o&&(tt.attributes.extrudeDirection=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:U})),L&&(tt.attributes.applyOffset=new q({componentDatatype:Y.UNSIGNED_BYTE,componentsPerAttribute:1,values:C}));let et,nt,ot,at,rt=yt.createTypedArray(I,6*D);h=G.length/3;let it=0;for(n=0;n<h-1;n+=2){et=n,at=(et+2)%h;let t=w.fromArray(G,3*et,Ct),e=w.fromArray(G,3*at,jt);w.equalsEpsilon(t,e,W.EPSILON10)||(nt=(et+1)%h,ot=(nt+2)%h,rt[it++]=et,rt[it++]=nt,rt[it++]=at,rt[it++]=at,rt[it++]=nt,rt[it++]=ot)}return tt.indices=rt,tt=zt.combineInstances([new Nt({geometry:m}),new Nt({geometry:tt})]),tt[0]}var ne=[new w,new w,new w,new w],Wt=new _t,oe=new _t;function Ht(t,e,n,o,a){if(0===n)return E.clone(t,a);let r=J.computeOptions(t,e,n,0,qt,Wt),i=r.height,s=r.width,l=ne;return J.computePosition(r,o,!1,0,0,l[0]),J.computePosition(r,o,!1,0,s-1,l[1]),J.computePosition(r,o,!1,i-1,0,l[2]),J.computePosition(r,o,!1,i-1,s-1,l[3]),E.fromCartesianArray(l,o,a)}function Q(t){let e=(t=L(t,L.EMPTY_OBJECT)).rectangle;if(lt.typeOf.object("rectangle",e),E._validate(e),e.north<e.south)throw new St("options.rectangle.north must be greater than or equal to options.rectangle.south");let n=L(t.height,0),o=L(t.extrudedHeight,n);this._rectangle=E.clone(e),this._granularity=L(t.granularity,W.RADIANS_PER_DEGREE),this._ellipsoid=H.clone(L(t.ellipsoid,H.default)),this._surfaceHeight=Math.max(n,o),this._rotation=L(t.rotation,0),this._stRotation=L(t.stRotation,0),this._vertexFormat=X.clone(L(t.vertexFormat,X.DEFAULT)),this._extrudedHeight=Math.min(n,o),this._shadowVolume=L(t.shadowVolume,!1),this._workerName="createRectangleGeometry",this._offsetAttribute=t.offsetAttribute,this._rotatedRectangle=void 0,this._textureCoordinateRotationPoints=void 0}Q.packedLength=E.packedLength+H.packedLength+X.packedLength+7,Q.pack=function(t,e,n){return lt.typeOf.object("value",t),lt.defined("array",e),n=L(n,0),E.pack(t._rectangle,e,n),n+=E.packedLength,H.pack(t._ellipsoid,e,n),n+=H.packedLength,X.pack(t._vertexFormat,e,n),n+=X.packedLength,e[n++]=t._granularity,e[n++]=t._surfaceHeight,e[n++]=t._rotation,e[n++]=t._stRotation,e[n++]=t._extrudedHeight,e[n++]=t._shadowVolume?1:0,e[n]=L(t._offsetAttribute,-1),e};var Jt=new E,Qt=H.clone(H.UNIT_SPHERE),tt={rectangle:Jt,ellipsoid:Qt,vertexFormat:Dt,granularity:void 0,height:void 0,rotation:void 0,stRotation:void 0,extrudedHeight:void 0,shadowVolume:void 0,offsetAttribute:void 0};Q.unpack=function(t,e,n){lt.defined("array",t),e=L(e,0);let o=E.unpack(t,e,Jt);e+=E.packedLength;let a=H.unpack(t,e,Qt);e+=H.packedLength;let r=X.unpack(t,e,Dt);e+=X.packedLength;let i=t[e++],s=t[e++],l=t[e++],u=t[e++],c=t[e++],m=1===t[e++],p=t[e];return $(n)?(n._rectangle=E.clone(o,n._rectangle),n._ellipsoid=H.clone(a,n._ellipsoid),n._vertexFormat=X.clone(r,n._vertexFormat),n._granularity=i,n._surfaceHeight=s,n._rotation=l,n._stRotation=u,n._extrudedHeight=c,n._shadowVolume=m,n._offsetAttribute=-1===p?void 0:p,n):(tt.granularity=i,tt.height=s,tt.rotation=l,tt.stRotation=u,tt.extrudedHeight=c,tt.shadowVolume=m,tt.offsetAttribute=-1===p?void 0:p,new Q(tt))},Q.computeRectangle=function(t,e){let n=(t=L(t,L.EMPTY_OBJECT)).rectangle;if(lt.typeOf.object("rectangle",n),E._validate(n),n.north<n.south)throw new St("options.rectangle.north must be greater than or equal to options.rectangle.south");let o=L(t.granularity,W.RADIANS_PER_DEGREE),a=L(t.ellipsoid,H.default);return Ht(n,o,L(t.rotation,0),a,e)};var ie=new ft,Ft=new Lt,ae=new _t;Q.createGeometry=function(t){if(W.equalsEpsilon(t._rectangle.north,t._rectangle.south,W.EPSILON10)||W.equalsEpsilon(t._rectangle.east,t._rectangle.west,W.EPSILON10))return;let e=t._rectangle,n=t._ellipsoid,o=t._rotation,a=t._stRotation,r=t._vertexFormat,i=J.computeOptions(e,t._granularity,o,a,qt,Wt,oe),s=ie;if(0!==a||0!==o){let t=E.center(e,ae),o=n.geodeticSurfaceNormalCartographic(t,Ct);Lt.fromAxisAngle(o,-a,Ft),ft.fromQuaternion(Ft,s)}else ft.clone(ft.IDENTITY,s);let l,u,c=t._surfaceHeight,m=t._extrudedHeight,p=!W.equalsEpsilon(c,m,0,W.EPSILON2);if(i.lonScalar=1/t._rectangle.width,i.latScalar=1/t._rectangle.height,i.tangentRotationMatrix=s,e=t._rectangle,p){l=ee(t,i);let o=st.fromRectangle3D(e,n,c,$t),a=st.fromRectangle3D(e,n,m,Kt);u=st.union(o,a)}else{if(l=It(t,i),l.attributes.position.values=Rt.scaleToGeodeticHeight(l.attributes.position.values,c,n,!1),$(t._offsetAttribute)){let e=l.attributes.position.values.length,n=t._offsetAttribute===ut.NONE?0:1,o=new Uint8Array(e/3).fill(n);l.attributes.applyOffset=new q({componentDatatype:Y.UNSIGNED_BYTE,componentsPerAttribute:1,values:o})}u=st.fromRectangle3D(e,n,c)}return r.position||delete l.attributes.position,new Pt({attributes:l.attributes,indices:l.indices,primitiveType:l.primitiveType,boundingSphere:u,offsetAttribute:t._offsetAttribute})},Q.createShadowVolume=function(t,e,n){let o=t._granularity,a=t._ellipsoid,r=e(o,a),i=n(o,a);return new Q({rectangle:t._rectangle,rotation:t._rotation,ellipsoid:a,stRotation:t._stRotation,granularity:o,extrudedHeight:i,height:r,vertexFormat:X.POSITION_ONLY,shadowVolume:!0})};var vt=new E,se=[new G,new G,new G],re=new At,ce=new _t;function le(t){if(0===t._stRotation)return[0,0,0,1,1,0];let e=E.clone(t._rectangle,vt),n=t._granularity,o=t._ellipsoid,a=Ht(e,n,t._rotation-t._stRotation,o,vt),r=se;r[0].x=a.west,r[0].y=a.south,r[1].x=a.west,r[1].y=a.north,r[2].x=a.east,r[2].y=a.south;let i=t.rectangle,s=At.fromRotation(t._stRotation,re),l=E.center(i,ce);for(let t=0;t<3;++t){let e=r[t];e.x-=l.longitude,e.y-=l.latitude,At.multiplyByVector(s,e,e),e.x+=l.longitude,e.y+=l.latitude,e.x=(e.x-i.west)/i.width,e.y=(e.y-i.south)/i.height}let u=r[0],c=r[1],m=r[2],p=new Array(6);return G.pack(u,p),G.pack(c,p,2),G.pack(m,p,4),p}Object.defineProperties(Q.prototype,{rectangle:{get:function(){return $(this._rotatedRectangle)||(this._rotatedRectangle=Ht(this._rectangle,this._granularity,this._rotation,this._ellipsoid)),this._rotatedRectangle}},textureCoordinateRotationPoints:{get:function(){return $(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=le(this)),this._textureCoordinateRotationPoints}}});var Ot=Q;function fe(t,e){return $(e)&&(t=Ot.unpack(t,e)),t._ellipsoid=H.clone(t._ellipsoid),t._rectangle=E.clone(t._rectangle),Ot.createGeometry(t)}var Ye=fe;export{Ye as default};