/**
 * @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 S}from"./chunk-2653NLLU.js";import{a as W}from"./chunk-T74SMR2Q.js";import"./chunk-S4UG323U.js";import"./chunk-ZYB4DKDQ.js";import{a as K}from"./chunk-IFAARW2T.js";import"./chunk-5ONJK4IB.js";import"./chunk-6IAPD5DZ.js";import{b as Q}from"./chunk-HCBPQXHZ.js";import{a as it}from"./chunk-ZIUWYBT3.js";import"./chunk-45FCQ3FJ.js";import"./chunk-354SKS6C.js";import"./chunk-H5GL2A6Z.js";import{a as Z}from"./chunk-UGB43LJM.js";import{a as et}from"./chunk-WFZLZ2P5.js";import{b as I,c as tt,d as J}from"./chunk-N72XKOXM.js";import{d as x}from"./chunk-EWTFJ46X.js";import"./chunk-5IUXF6I3.js";import{a as z}from"./chunk-27UWHT4D.js";import{a as A,d as P}from"./chunk-RFPX772U.js";import{a as q}from"./chunk-RAYRECQS.js";import"./chunk-2NAI7YQ3.js";import"./chunk-QE3ZUOZY.js";import{a as H}from"./chunk-6KLVDWWE.js";import{b as M}from"./chunk-6P5KAIBX.js";import{e as C}from"./chunk-4FSVUTPL.js";var ot=new A,nt=new A,rt=new A;function ft(t,e){for(let i=0;i<t.length;i++)t[i]=e.scaleToGeodeticSurface(t[i],t[i]);return t}function st(t,e){let i,r,o,s=[],n=t.positions,l=t.corners,a=t.endPositions,h=new et,u=0,p=0,f=0;for(r=0;r<n.length;r+=2)o=n[r].length-3,u+=o,f+=o/3*4,p+=n[r+1].length-3;for(u+=3,p+=3,r=0;r<l.length;r++){i=l[r];let t=l[r].leftPositions;C(t)?(o=t.length,u+=o,f+=o/3*2):(o=l[r].rightPositions.length,p+=o,f+=o/3*2)}let c,d=C(a);d&&(c=a[0].length-3,u+=c,p+=c,c/=3,f+=4*c);let g,m,y,_,b,k,P=u+p,E=new Float64Array(P),j=0,v=P-1,T=c/2,H=Z.createTypedArray(P/3,f+4),w=0;if(H[w++]=j/3,H[w++]=(v-2)/3,d){s.push(j/3),k=ot,b=nt;let t=a[0];for(r=0;r<T;r++)k=A.fromArray(t,3*(T-1-r),k),b=A.fromArray(t,3*(T+r),b),S.addAttribute(E,b,j),S.addAttribute(E,k,void 0,v),m=j/3,_=m+1,g=(v-2)/3,y=g-1,H[w++]=g,H[w++]=y,H[w++]=m,H[w++]=_,j+=3,v-=3}let O=0,L=n[O++],R=n[O++];for(E.set(L,j),E.set(R,v-R.length+1),o=R.length-3,s.push(j/3,(v-2)/3),r=0;r<o;r+=3)m=j/3,_=m+1,g=(v-2)/3,y=g-1,H[w++]=g,H[w++]=y,H[w++]=m,H[w++]=_,j+=3,v-=3;for(r=0;r<l.length;r++){let t;i=l[r];let a,h=i.leftPositions,u=i.rightPositions,p=rt;if(C(h)){for(v-=3,a=y,s.push(_),t=0;t<h.length/3;t++)p=A.fromArray(h,3*t,p),H[w++]=a-t-1,H[w++]=a-t,S.addAttribute(E,p,void 0,v),v-=3;s.push(a-Math.floor(h.length/6)),e===W.BEVELED&&s.push((v-2)/3+1),j+=3}else{for(j+=3,a=_,s.push(y),t=0;t<u.length/3;t++)p=A.fromArray(u,3*t,p),H[w++]=a+t,H[w++]=a+t+1,S.addAttribute(E,p,j),j+=3;s.push(a+Math.floor(u.length/6)),e===W.BEVELED&&s.push(j/3-1),v-=3}for(L=n[O++],R=n[O++],L.splice(0,3),R.splice(R.length-3,3),E.set(L,j),E.set(R,v-R.length+1),o=R.length-3,t=0;t<R.length;t+=3)_=j/3,m=_-1,y=(v-2)/3,g=y+1,H[w++]=g,H[w++]=y,H[w++]=m,H[w++]=_,j+=3,v-=3;j-=3,v+=3,s.push(j/3,(v-2)/3)}if(d){j+=3,v-=3,k=ot,b=nt;let t=a[1];for(r=0;r<T;r++)k=A.fromArray(t,3*(c-r-1),k),b=A.fromArray(t,3*r,b),S.addAttribute(E,k,void 0,v),S.addAttribute(E,b,j),_=j/3,m=_-1,y=(v-2)/3,g=y+1,H[w++]=g,H[w++]=y,H[w++]=m,H[w++]=_,j+=3,v-=3;s.push(j/3)}else s.push(j/3,(v-2)/3);return H[w++]=j/3,H[w++]=(v-2)/3,h.position=new J({componentDatatype:z.DOUBLE,componentsPerAttribute:3,values:E}),{attributes:h,indices:H,wallIndices:s}}function ct(t){let e=t.ellipsoid,i=st(S.computePositions(t),t.cornerType),r=i.wallIndices,o=t.height,s=t.extrudedHeight,n=i.attributes,l=i.indices,a=n.position.values,h=a.length,u=new Float64Array(h);u.set(a);let p=new Float64Array(2*h);if(a=Q.scaleToGeodeticHeight(a,o,e),u=Q.scaleToGeodeticHeight(u,s,e),p.set(a),p.set(u,h),n.position.values=p,h/=3,C(t.offsetAttribute)){let e=new Uint8Array(2*h);if(t.offsetAttribute===K.TOP)e=e.fill(1,0,h);else{let i=t.offsetAttribute===K.NONE?0:1;e=e.fill(i)}n.applyOffset=new J({componentDatatype:z.UNSIGNED_BYTE,componentsPerAttribute:1,values:e})}let f,c=l.length,d=Z.createTypedArray(p.length/3,2*(c+r.length));d.set(l);let g,A,m=c;for(f=0;f<c;f+=2){let t=l[f],e=l[f+1];d[m++]=t+h,d[m++]=e+h}for(f=0;f<r.length;f++)g=r[f],A=g+h,d[m++]=g,d[m++]=A;return{attributes:n,indices:d}}function V(t){let e=(t=H(t,H.EMPTY_OBJECT)).positions,i=t.width;M.typeOf.object("options.positions",e),M.typeOf.number("options.width",i);let r=H(t.height,0),o=H(t.extrudedHeight,r);this._positions=e,this._ellipsoid=P.clone(H(t.ellipsoid,P.default)),this._width=i,this._height=Math.max(r,o),this._extrudedHeight=Math.min(r,o),this._cornerType=H(t.cornerType,W.ROUNDED),this._granularity=H(t.granularity,q.RADIANS_PER_DEGREE),this._offsetAttribute=t.offsetAttribute,this._workerName="createCorridorOutlineGeometry",this.packedLength=1+e.length*A.packedLength+P.packedLength+6}V.pack=function(t,e,i){M.typeOf.object("value",t),M.typeOf.object("array",e),i=H(i,0);let r=t._positions,o=r.length;e[i++]=o;for(let t=0;t<o;++t,i+=A.packedLength)A.pack(r[t],e,i);return P.pack(t._ellipsoid,e,i),i+=P.packedLength,e[i++]=t._width,e[i++]=t._height,e[i++]=t._extrudedHeight,e[i++]=t._cornerType,e[i++]=t._granularity,e[i]=H(t._offsetAttribute,-1),e};var lt=P.clone(P.UNIT_SPHERE),R={positions:void 0,ellipsoid:lt,width:void 0,height:void 0,extrudedHeight:void 0,cornerType:void 0,granularity:void 0,offsetAttribute:void 0};V.unpack=function(t,e,i){M.typeOf.object("array",t),e=H(e,0);let r=t[e++],o=new Array(r);for(let i=0;i<r;++i,e+=A.packedLength)o[i]=A.unpack(t,e);let s=P.unpack(t,e,lt);e+=P.packedLength;let n=t[e++],l=t[e++],a=t[e++],h=t[e++],u=t[e++],p=t[e];return C(i)?(i._positions=o,i._ellipsoid=P.clone(s,i._ellipsoid),i._width=n,i._height=l,i._extrudedHeight=a,i._cornerType=h,i._granularity=u,i._offsetAttribute=-1===p?void 0:p,i):(R.positions=o,R.width=n,R.height=l,R.extrudedHeight=a,R.cornerType=h,R.granularity=u,R.offsetAttribute=-1===p?void 0:p,new V(R))},V.createGeometry=function(t){let e=t._positions,i=t._width,r=t._ellipsoid;e=ft(e,r);let o=it(e,A.equalsEpsilon);if(o.length<2||i<=0)return;let s,n=t._height,l=t._extrudedHeight,a=!q.equalsEpsilon(n,l,0,q.EPSILON2),h={ellipsoid:r,positions:o,width:i,cornerType:t._cornerType,granularity:t._granularity,saveAttributes:!1};if(a)h.height=n,h.extrudedHeight=l,h.offsetAttribute=t._offsetAttribute,s=ct(h);else{if(s=st(S.computePositions(h),h.cornerType),s.attributes.position.values=Q.scaleToGeodeticHeight(s.attributes.position.values,n,r),C(t._offsetAttribute)){let e=s.attributes.position.values.length,i=t._offsetAttribute===K.NONE?0:1,r=new Uint8Array(e/3).fill(i);s.attributes.applyOffset=new J({componentDatatype:z.UNSIGNED_BYTE,componentsPerAttribute:1,values:r})}}let u=s.attributes,p=x.fromVertices(u.position.values,void 0,3);return new tt({attributes:u,indices:s.indices,primitiveType:I.LINES,boundingSphere:p,offsetAttribute:t._offsetAttribute})};var $=V;function ht(t,e){return C(e)&&(t=$.unpack(t,e)),t._ellipsoid=P.clone(t._ellipsoid),$.createGeometry(t)}var Ot=ht;export{Ot as default};