/**
 * @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 m}from"./chunk-GKS4EDRQ.js";import{a as N}from"./chunk-VSCNOKDU.js";import{a as U}from"./chunk-AUO2K2B5.js";import"./chunk-55B3WQ6I.js";import{a as k}from"./chunk-HZQ2LRMY.js";import{a as le}from"./chunk-K4QHJFYW.js";import"./chunk-CZ6DDD6J.js";import"./chunk-26PPBGHW.js";import"./chunk-FMJWH3RL.js";import{a as se}from"./chunk-E25VRLIZ.js";import{a as ce}from"./chunk-FZEJ65E6.js";import{a as ne,b as re,c as ie,d as O}from"./chunk-SPFUTSGC.js";import{d as oe}from"./chunk-E2NX4UJ2.js";import"./chunk-JBPQP6LH.js";import{a as x}from"./chunk-NLPIV6OK.js";import{a as p,d as u}from"./chunk-IIT3SHXK.js";import{a as J}from"./chunk-DLCTHPIV.js";import"./chunk-GMF7KJHC.js";import"./chunk-NYFH7JC3.js";import{a as A}from"./chunk-I2ICH2LD.js";import{a as V}from"./chunk-R6A52HT4.js";import{e as h}from"./chunk-D32DZSEC.js";var me=[];function Ae(e,t,r,o,n){let a=me;a.length=n;let i,s=r.red,l=r.green,p=r.blue,c=r.alpha,h=o.red,u=o.green,d=o.blue,f=o.alpha;if(m.equals(r,o)){for(i=0;i<n;i++)a[i]=m.clone(r);return a}let k=(h-s)/n,g=(u-l)/n,w=(d-p)/n,y=(f-c)/n;for(i=0;i<n;i++)a[i]=new m(s+i*k,l+i*g,p+i*w,c+i*y);return a}function G(e){e=A(e,A.EMPTY_OBJECT);let t=e.positions,r=e.colors,o=A(e.width,1),n=A(e.colorsPerVertex,!1);if(!h(t)||t.length<2)throw new V("At least two positions are required.");if("number"!=typeof o)throw new V("width must be a number");if(h(r)&&(n&&r.length<t.length||!n&&r.length<t.length-1))throw new V("colors has an invalid length.");this._positions=t,this._colors=r,this._width=o,this._colorsPerVertex=n,this._vertexFormat=k.clone(A(e.vertexFormat,k.DEFAULT)),this._arcType=A(e.arcType,N.GEODESIC),this._granularity=A(e.granularity,J.RADIANS_PER_DEGREE),this._ellipsoid=u.clone(A(e.ellipsoid,u.default)),this._workerName="createPolylineGeometry";let a=1+t.length*p.packedLength;a+=h(r)?1+r.length*m.packedLength:1,this.packedLength=a+u.packedLength+k.packedLength+4}G.pack=function(e,t,r){if(!h(e))throw new V("value is required");if(!h(t))throw new V("array is required");r=A(r,0);let o,n=e._positions,a=n.length;for(t[r++]=a,o=0;o<a;++o,r+=p.packedLength)p.pack(n[o],t,r);let i=e._colors;for(a=h(i)?i.length:0,t[r++]=a,o=0;o<a;++o,r+=m.packedLength)m.pack(i[o],t,r);return u.pack(e._ellipsoid,t,r),r+=u.packedLength,k.pack(e._vertexFormat,t,r),r+=k.packedLength,t[r++]=e._width,t[r++]=e._colorsPerVertex?1:0,t[r++]=e._arcType,t[r]=e._granularity,t};var de=u.clone(u.UNIT_SPHERE),ue=new k,S={positions:void 0,colors:void 0,ellipsoid:de,vertexFormat:ue,width:void 0,colorsPerVertex:void 0,arcType:void 0,granularity:void 0};G.unpack=function(e,t,r){if(!h(e))throw new V("array is required");t=A(t,0);let o,n=e[t++],a=new Array(n);for(o=0;o<n;++o,t+=p.packedLength)a[o]=p.unpack(e,t);n=e[t++];let i=n>0?new Array(n):void 0;for(o=0;o<n;++o,t+=m.packedLength)i[o]=m.unpack(e,t);let s=u.unpack(e,t,de);t+=u.packedLength;let l=k.unpack(e,t,ue);t+=k.packedLength;let c=e[t++],d=1===e[t++],f=e[t++],g=e[t];return h(r)?(r._positions=a,r._colors=i,r._ellipsoid=u.clone(s,r._ellipsoid),r._vertexFormat=k.clone(l,r._vertexFormat),r._width=c,r._colorsPerVertex=d,r._arcType=f,r._granularity=g,r):(S.positions=a,S.colors=i,S.width=c,S.colorsPerVertex=d,S.arcType=f,S.granularity=g,new G(S))};var pe=new p,ae=new p,fe=new p,he=new p;G.createGeometry=function(e){let t,r,o,n=e._width,a=e._vertexFormat,i=e._colors,s=e._colorsPerVertex,l=e._arcType,c=e._granularity,u=e._ellipsoid,d=[],f=le(e._positions,p.equalsEpsilon,!1,d);if(h(i)&&d.length>0){let e=0,t=d[0];i=i.filter((function(r,o){let n=!1;return n=s?o===t||0===o&&1===t:o+1===t,!n||(e++,t=d[e],!1)}))}let k=f.length;if(k<2||n<=0)return;if(l===N.GEODESIC||l===N.RHUMB){let e,o;l===N.GEODESIC?(e=J.chordLength(c,u.maximumRadius),o=U.numberOfPoints):(e=c,o=U.numberOfPointsRhumbLine);let n=U.extractHeights(f,u);if(h(i)){let n=1;for(t=0;t<k-1;++t)n+=o(f[t],f[t+1],e);let a=new Array(n),l=0;for(t=0;t<k-1;++t){let p=f[t],c=f[t+1],h=i[t],u=o(p,c,e);if(s&&t<n){let e=i[t+1],o=Ae(p,c,h,e,u),n=o.length;for(r=0;r<n;++r)a[l++]=o[r]}else for(r=0;r<u;++r)a[l++]=m.clone(h)}a[l]=m.clone(i[i.length-1]),i=a,me.length=0}f=l===N.GEODESIC?U.generateCartesianArc({positions:f,minDistance:e,ellipsoid:u,height:n}):U.generateCartesianRhumbArc({positions:f,granularity:e,ellipsoid:u,height:n})}k=f.length;let g,w=4*k-4,y=new Float64Array(3*w),_=new Float64Array(3*w),A=new Float64Array(3*w),v=new Float32Array(2*w),E=a.st?new Float32Array(2*w):void 0,L=h(i)?new Uint8Array(4*w):void 0,P=0,D=0,T=0,S=0;for(r=0;r<k;++r){let e,t;0===r?(g=pe,p.subtract(f[0],f[1],g),p.add(f[0],g,g)):g=f[r-1],p.clone(g,fe),p.clone(f[r],ae),r===k-1?(g=pe,p.subtract(f[k-1],f[k-2],g),p.add(f[k-1],g,g)):g=f[r+1],p.clone(g,he),h(L)&&(e=0===r||s?i[r]:i[r-1],r!==k-1&&(t=i[r]));let l=0===r?2:0,c=r===k-1?2:4;for(o=l;o<c;++o){p.pack(ae,y,P),p.pack(fe,_,P),p.pack(he,A,P),P+=3;let i=o-2<0?-1:1;if(v[D++]=o%2*2-1,v[D++]=i*n,a.st&&(E[T++]=r/(k-1),E[T++]=Math.max(v[D-2],0)),h(L)){let r=o<2?e:t;L[S++]=m.floatToByte(r.red),L[S++]=m.floatToByte(r.green),L[S++]=m.floatToByte(r.blue),L[S++]=m.floatToByte(r.alpha)}}}let j=new ce;j.position=new O({componentDatatype:x.DOUBLE,componentsPerAttribute:3,values:y}),j.prevPosition=new O({componentDatatype:x.DOUBLE,componentsPerAttribute:3,values:_}),j.nextPosition=new O({componentDatatype:x.DOUBLE,componentsPerAttribute:3,values:A}),j.expandAndWidth=new O({componentDatatype:x.FLOAT,componentsPerAttribute:2,values:v}),a.st&&(j.st=new O({componentDatatype:x.FLOAT,componentsPerAttribute:2,values:E})),h(L)&&(j.color=new O({componentDatatype:x.UNSIGNED_BYTE,componentsPerAttribute:4,values:L,normalize:!0}));let b=se.createTypedArray(w,6*k-6),F=0,G=0,V=k-1;for(r=0;r<V;++r)b[G++]=F,b[G++]=F+2,b[G++]=F+1,b[G++]=F+1,b[G++]=F+2,b[G++]=F+3,F+=4;return new ie({attributes:j,indices:b,primitiveType:re.TRIANGLES,boundingSphere:oe.fromPoints(f),geometryType:ne.POLYLINES})};var Q=G;function ge(e,t){return h(t)&&(e=Q.unpack(e,t)),e._ellipsoid=u.clone(e._ellipsoid),Q.createGeometry(e)}var We=ge;export{We as default};