/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.126
 *
 * 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-OWZATOOT.js";import{a as W}from"./chunk-2H32TJK3.js";import"./chunk-AUO2K2B5.js";import"./chunk-55B3WQ6I.js";import{a as K}from"./chunk-WDSHVSF7.js";import"./chunk-EP544XEE.js";import"./chunk-MDIGQ5JT.js";import{b as Q}from"./chunk-WV3AQKZG.js";import{a as it}from"./chunk-K4QHJFYW.js";import"./chunk-CZ6DDD6J.js";import"./chunk-26PPBGHW.js";import"./chunk-FMJWH3RL.js";import{a as Z}from"./chunk-E25VRLIZ.js";import{a as et}from"./chunk-FZEJ65E6.js";import{b as I,c as tt,d as J}from"./chunk-SPFUTSGC.js";import{d as x}from"./chunk-E2NX4UJ2.js";import"./chunk-JBPQP6LH.js";import{a as z}from"./chunk-NLPIV6OK.js";import{a as A,d as P}from"./chunk-IIT3SHXK.js";import{a as q}from"./chunk-DLCTHPIV.js";import"./chunk-GMF7KJHC.js";import"./chunk-NYFH7JC3.js";import{a as H}from"./chunk-I2ICH2LD.js";import{b as M}from"./chunk-R6A52HT4.js";import{e as C}from"./chunk-D32DZSEC.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,H=u+p,P=new Float64Array(H),E=0,T=H-1,j=c/2,v=Z.createTypedArray(H/3,f+4),w=0;if(v[w++]=E/3,v[w++]=(T-2)/3,d){s.push(E/3),k=ot,b=nt;let t=a[0];for(r=0;r<j;r++)k=A.fromArray(t,3*(j-1-r),k),b=A.fromArray(t,3*(j+r),b),S.addAttribute(P,b,E),S.addAttribute(P,k,void 0,T),m=E/3,_=m+1,g=(T-2)/3,y=g-1,v[w++]=g,v[w++]=y,v[w++]=m,v[w++]=_,E+=3,T-=3}let O=0,D=n[O++],I=n[O++];for(P.set(D,E),P.set(I,T-I.length+1),o=I.length-3,s.push(E/3,(T-2)/3),r=0;r<o;r+=3)m=E/3,_=m+1,g=(T-2)/3,y=g-1,v[w++]=g,v[w++]=y,v[w++]=m,v[w++]=_,E+=3,T-=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(T-=3,a=y,s.push(_),t=0;t<h.length/3;t++)p=A.fromArray(h,3*t,p),v[w++]=a-t-1,v[w++]=a-t,S.addAttribute(P,p,void 0,T),T-=3;s.push(a-Math.floor(h.length/6)),e===W.BEVELED&&s.push((T-2)/3+1),E+=3}else{for(E+=3,a=_,s.push(y),t=0;t<u.length/3;t++)p=A.fromArray(u,3*t,p),v[w++]=a+t,v[w++]=a+t+1,S.addAttribute(P,p,E),E+=3;s.push(a+Math.floor(u.length/6)),e===W.BEVELED&&s.push(E/3-1),T-=3}for(D=n[O++],I=n[O++],D.splice(0,3),I.splice(I.length-3,3),P.set(D,E),P.set(I,T-I.length+1),o=I.length-3,t=0;t<I.length;t+=3)_=E/3,m=_-1,y=(T-2)/3,g=y+1,v[w++]=g,v[w++]=y,v[w++]=m,v[w++]=_,E+=3,T-=3;E-=3,T+=3,s.push(E/3,(T-2)/3)}if(d){E+=3,T-=3,k=ot,b=nt;let t=a[1];for(r=0;r<j;r++)k=A.fromArray(t,3*(c-r-1),k),b=A.fromArray(t,3*r,b),S.addAttribute(P,k,void 0,T),S.addAttribute(P,b,E),_=E/3,m=_-1,y=(T-2)/3,g=y+1,v[w++]=g,v[w++]=y,v[w++]=m,v[w++]=_,E+=3,T-=3;s.push(E/3)}else s.push(E/3,(T-2)/3);return v[w++]=E/3,v[w++]=(T-2)/3,h.position=new J({componentDatatype:z.DOUBLE,componentsPerAttribute:3,values:P}),{attributes:h,indices:v,wallIndices:s}}function ct(t){let e=t.ellipsoid,i=S.computePositions(t),r=st(i,t.cornerType),o=r.wallIndices,s=t.height,n=t.extrudedHeight,l=r.attributes,a=r.indices,h=l.position.values,u=h.length,p=new Float64Array(u);p.set(h);let f=new Float64Array(2*u);if(h=Q.scaleToGeodeticHeight(h,s,e),p=Q.scaleToGeodeticHeight(p,n,e),f.set(h),f.set(p,u),l.position.values=f,u/=3,C(t.offsetAttribute)){let e=new Uint8Array(2*u);if(t.offsetAttribute===K.TOP)e=e.fill(1,0,u);else{let i=t.offsetAttribute===K.NONE?0:1;e=e.fill(i)}l.applyOffset=new J({componentDatatype:z.UNSIGNED_BYTE,componentsPerAttribute:1,values:e})}let c,d=a.length,g=Z.createTypedArray(f.length/3,2*(d+o.length));g.set(a);let m,A,y=d;for(c=0;c<d;c+=2){let t=a[c],e=a[c+1];g[y++]=t+u,g[y++]=e+u}for(c=0;c<o.length;c++)m=o[c],A=m+u,g[y++]=m,g[y++]=A;return{attributes:l,indices:g}}function V(t){t=H(t,H.EMPTY_OBJECT);let e=t.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 s=0;s<o;++s,i+=A.packedLength)A.pack(r[s],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 f=0;f<r;++f,e+=A.packedLength)o[f]=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{let e=S.computePositions(h);if(s=st(e,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};