define(["exports","./when-b60132fc","./Check-7b2a090c","./RuntimeError-4a5c8994","./BoundingSphere-561b54d0","./BoundingRectangle-01b3e970","./Cartesian2-47311507","./Cartographic-3309dd0d","./Cartesian4-3ca25aab","./ComponentDatatype-c140a87d","./PrimitiveType-39acab88","./IndexDatatype-8a5eead4","./WebGLConstants-4ae0db90"],(function(e,t,r,n,a,i,o,s,f,u,y,c,p){"use strict";function d(e,r,n,a){return r=t.defaultValue(r,0),n=t.defaultValue(n,e.byteLength-r),a=t.defaultValue(a,"utf-8"),e=e.subarray(r,r+n),d.decode(e,a)}function l(e,t,r){return t<=e&&e<=r}d.decodeWithTextDecoder=function(e,t){return new TextDecoder(t).decode(e)},d.decodeWithFromCharCode=function(e){for(var t="",r=function(e){for(var t=0,r=0,a=0,i=128,o=191,s=[],f=e.length,u=0;u<f;++u){var y=e[u];if(0===a){if(l(y,0,127)){s.push(y);continue}if(l(y,194,223)){a=1,t=31&y;continue}if(l(y,224,239)){224===y&&(i=160),237===y&&(o=159),a=2,t=15&y;continue}if(l(y,240,244)){240===y&&(i=144),244===y&&(o=143),a=3,t=7&y;continue}throw new n.RuntimeError("String decoding failed.")}l(y,i,o)?(i=128,o=191,t=t<<6|63&y,++r===a&&(s.push(t),t=a=r=0)):(t=a=r=0,i=128,o=191,--u)}return s}(e),a=r.length,i=0;i<a;++i){var o=r[i];o<=65535?t+=String.fromCharCode(o):(o-=65536,t+=String.fromCharCode(55296+(o>>10),56320+(1023&o)))}return t},"undefined"!=typeof TextDecoder?d.decode=d.decodeWithTextDecoder:d.decode=d.decodeWithFromCharCode;var A=Object.freeze({LUMINANCE_8:1,LUMINANCE_16:2,ALPHA:3,ALPHA_4_LUMINANCE_4:4,LUMINANCE_ALPHA:5,RGB_565:6,BGR565:7,RGB:10,BGR:11,ARGB:12,ABGR:13,BGRA:14,WEBP:25,RGBA:28,DXT1:17,DXT2:18,DXT3:19,DXT4:20,DXT5:21,CRN_DXT5:26,STANDARD_CRN:27,KTX2:31});function C(e,t,r,n){var a=e|t<<8,i=a>>11&31,o=a>>5&63,s=31&a;return r[n+0]=i<<3|i>>2,r[n+1]=o<<2|o>>4,r[n+2]=s<<3|s>>2,r[n+3]=255,a}function v(e,t,r,n){var a=0;0!=(6&n)&&(a=8),function(e,t,r,n){for(var a=new Uint8Array(16),i=C(t[r+0],t[r+1],a,0),o=C(t[r+2],t[r+3],a,4),s=0;s<3;s++){var f=a[s],u=a[4+s];n&&i<=o?(a[8+s]=(f+u)/2,a[12+s]=0):(a[8+s]=(2*f+u)/3,a[12+s]=(f+2*u)/3)}a[11]=255,a[15]=n&&i<=o?0:255;var y=new Uint8Array(16);for(s=0;s<4;++s){var c=t[r+4+s];y[4*s+0]=3&c,y[4*s+1]=c>>2&3,y[4*s+2]=c>>4&3,y[4*s+3]=c>>6&3}for(s=0;s<16;++s)for(var p=4*y[s],d=0;d<4;++d)e[4*s+d]=a[p+d]}(e,t,r+a,0!=(1&n)),0!=(2&n)?function(e,t,r){for(var n=0;n<8;++n){var a=bytes[r+n],i=15&a,o=240&a;e[8*n+3]=i|i<<4,e[8*n+7]=o|o>>4}}(e,0,r):0!=(4&n)&&function(e,t,r){var n=t[r+0],a=t[r+1],i=new Uint8Array(8);if(i[0]=n,i[1]=a,n<=a){for(var o=1;o<5;++o)i[1+o]=((5-o)*n+o*a)/5;i[6]=0,i[7]=255}else for(o=1;o<7;++o)i[1+o]=((7-o)*n+o*a)/7;var s=new Uint8Array(16),f=(r+=2,0);for(o=0;o<2;++o){for(var u=0,y=0;y<3;++y)u|=t[r++]<<8*y;for(y=0;y<8;++y){var c=u>>3*y&7;s[f++]=c}}for(o=0;o<16;++o)e[4*o+3]=i[s[o]]}(e,t,r)}function m(e){}m.decode=function(e,t,r,n,a){if(null!=e&&null!=n&&0!=r&&0!=t){var i=0;1&(i=a>A.BGR||a===A.LUMINANCE_ALPHA?4:33)&&32&i?function(e,t,r,n){for(var a=new Uint16Array(4),i=e,o=0,s=0,f=0,u=0,y=0,c=0,p=0,d=0,l=0,A=t/4,C=r/4,v=0;v<C;v++)for(var m=0;m<A;m++)f=4*((C-v)*A+m),a[0]=n[f],a[1]=n[f+1],u=31&a[0],y=2016&a[0],c=63488&a[0],p=31&a[1],d=2016&a[1],l=63488&a[1],a[2]=5*u+3*p>>3|5*y+3*d>>3&2016|5*c+3*l>>3&63488,a[3]=5*p+3*u>>3|5*d+3*y>>3&2016|5*l+3*c>>3&63488,o=n[f+2],i[s=4*v*t+4*m]=a[3&o],i[s+1]=a[o>>2&3],i[s+2]=a[o>>4&3],i[s+3]=a[o>>6&3],i[s+=t]=a[o>>8&3],i[s+1]=a[o>>10&3],i[s+2]=a[o>>12&3],i[s+3]=a[o>>14],o=n[f+3],i[s+=t]=a[3&o],i[s+1]=a[o>>2&3],i[s+2]=a[o>>4&3],i[s+3]=a[o>>6&3],i[s+=t]=a[o>>8&3],i[s+1]=a[o>>10&3],i[s+2]=a[o>>12&3],i[s+3]=a[o>>14]}
/*! @brief Decompresses an image in memory.

     @param rgba		Storage for the decompressed pixels.
     @param width	The width of the source image.
     @param height	The height of the source image.
     @param blocks	The compressed DXT blocks.
     @param flags	Compression flags.

     The decompressed pixels will be written as a contiguous array of width*height
     16 rgba values, with each component as 1 byte each. In memory this is:

     { r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height

     The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression,
     however, DXT1 will be used by default if none is specified. All other flags
     are ignored.

     Internally this function calls squish::Decompress for each block.
     */(e,t,r,n):function(e,t,r,n,a){for(var i=0!=(1&a)?8:16,o=0,s=0;s<r;s+=4)for(var f=0;f<t;f+=4){var u=new Uint8Array(64);v(u,n,o,a);for(var y=0,c=0;c<4;++c)for(var p=0;p<4;++p){var d=f+p,l=s+c;if(d<t&&l<r)for(var A=4*(t*(r-l)+d),C=0;C<4;++C)e[A++]=u[y++];else y+=4}o+=i}}(e,t,r,n,i)}};var h=Object.freeze({SVC_Vertex:1,SVC_Normal:2,SVC_VertexColor:4,SVC_SecondColor:8,SVC_TexutreCoord:16,SVC_TexutreCoordIsW:32}),x=Object.freeze({OSGBFile:0,OSGBCacheFile:1,ClampGroundPolygon:2,ClampObjectPolygon:3,ClampGroundLine:4,ClampObjectLine:5,IconPoint:6,Text:7,PointCloudFile:8,ExtendRegion3D:9,ExtendClampPolygonCache:10,PolylineEffect:11,RegionEffect:12,ClampGroundAndObjectLineCache:13,ClampGroundRealtimeRasterCache:14});function b(){}function g(e){var r=new a.BoundingSphere,n=e.instanceBounds;if(!t.defined(n))return r;var i=new s.Cartesian3(n[0],n[1],n[2]),o=new s.Cartesian3(n[3],n[4],n[5]),f=s.Cartesian3.lerp(i,o,.5,new s.Cartesian3),u=s.Cartesian3.distance(f,i);return r.center=f,r.radius=u,r}function T(e){var r,n,i=new a.BoundingSphere,o=new s.Cartesian3,f=e.vertexAttributes[0],u=f.componentsPerAttribute,y=t.defined(e.nCompressOptions)&&(e.nCompressOptions&h.SVC_Vertex)===h.SVC_Vertex,c=1;y?(c=e.vertCompressConstant,r=new s.Cartesian3(e.minVerticesValue.x,e.minVerticesValue.y,e.minVerticesValue.z),n=new Uint16Array(f.typedArray.buffer,f.typedArray.byteOffset,f.typedArray.byteLength/2)):n=new Float32Array(f.typedArray.buffer,f.typedArray.byteOffset,f.typedArray.byteLength/4);for(var p=[],d=0;d<e.verticesCount;d++)s.Cartesian3.fromArray(n,u*d,o),y&&(o=s.Cartesian3.multiplyByScalar(o,c,o),o=s.Cartesian3.add(o,r,o)),p.push(s.Cartesian3.clone(o));return a.BoundingSphere.fromPoints(p,i),p.length=0,i}function B(e){var r,n,i=new a.BoundingSphere,o=new s.Cartesian3,f=t.defined(e.nCompressOptions)&&(e.nCompressOptions&h.SVC_Vertex)===h.SVC_Vertex,u=e.vertexAttributes[0],y=u.componentsPerAttribute,c=1;f?(c=e.vertCompressConstant,n=new s.Cartesian3(e.minVerticesValue.x,e.minVerticesValue.y,e.minVerticesValue.z),r=new Uint16Array(u.typedArray.buffer,u.typedArray.byteOffset,u.typedArray.byteLength/2)):r=new Float32Array(u.typedArray.buffer,u.typedArray.byteOffset,u.typedArray.byteLength/4);for(var p=[],d=0;d<e.verticesCount;d++)s.Cartesian3.fromArray(r,y*d,o),f&&(o=s.Cartesian3.multiplyByScalar(o,c,o),o=s.Cartesian3.add(o,n,o)),p.push(s.Cartesian3.clone(o));return a.BoundingSphere.fromPoints(p,i),p.length=0,i}function D(e){var r,n,i=t.defined(e.nCompressOptions)&&(e.nCompressOptions&h.SVC_Vertex)===h.SVC_Vertex,o=new a.BoundingSphere,u=new s.Cartesian3,y=new s.Cartesian3,c=e.vertexAttributes[0],p=c.componentsPerAttribute,d=e.attrLocation.aPosition,l=e.vertexAttributes[d],A=e.attrLocation.aTexCoord5,C=e.vertexAttributes[A],v=C.componentsPerAttribute;i?(p=3,v=3,r=S(e,l),n=function(e,t,r){for(var n,a,i,o=t.componentsPerAttribute,s=e.texCoordCompressConstant[r],u=new f.Cartesian4(e.minTexCoordValue[r].x,e.minTexCoordValue[r].y,e.minTexCoordValue[r].z,e.minTexCoordValue[r].w),y=new Uint16Array(t.typedArray.buffer,t.typedArray.byteOffset,t.typedArray.byteLength/2),c=new Float32Array(3*e.verticesCount),p=0;p<e.verticesCount;p++)n=y[o*p]*s+u.x,a=y[o*p+1]*s+u.y,i=y[o*p+2]*s+u.z,c[3*p]=n,c[3*p+1]=a,c[3*p+2]=i;return c}(e,C,5)):(r=new Float32Array(c.typedArray.buffer,c.typedArray.byteOffset,c.typedArray.byteLength/4),n=new Float32Array(C.typedArray.buffer,C.typedArray.byteOffset,C.typedArray.byteLength/4));for(var m=[],x=0;x<e.verticesCount;x++)s.Cartesian3.fromArray(r,p*x,u),s.Cartesian3.fromArray(n,v*x,y),s.Cartesian3.add(u,y,u),m.push(s.Cartesian3.clone(u));return a.BoundingSphere.fromPoints(m,o),m.length=0,o}function I(e){var t=y.PrimitiveType.TRIANGLES;switch(e){case 1:t=y.PrimitiveType.POINTS;break;case 2:t=y.PrimitiveType.LINES;break;case 3:t=y.PrimitiveType.LINE_STRIP;break;case 4:t=y.PrimitiveType.TRIANGLES}return t}function S(e,t){for(var r,n,a,i=t.componentsPerAttribute,o=e.vertCompressConstant,f=new s.Cartesian3(e.minVerticesValue.x,e.minVerticesValue.y,e.minVerticesValue.z),u=new Uint16Array(t.typedArray.buffer,t.typedArray.byteOffset,t.typedArray.byteLength/2),y=new Float32Array(3*e.verticesCount),c=0;c<e.verticesCount;c++)r=u[i*c]*o+f.x,n=u[i*c+1]*o+f.y,a=u[i*c+2]*o+f.z,y[3*c]=r,y[3*c+1]=n,y[3*c+2]=a;return y}function w(){return!0}b.calcBoundingSphereInWorker=function(e,r){return r.instanceIndex>-1?g(r):t.defined(r.clampRegionEdge)?D(r):e>=x.ClampGroundPolygon&&e<=x.ClampObjectLine?B(r):e==x.ClampGroundAndObjectLineCache?D(r):T(r)},b.calcBoundingSphere=function(e,r,n){var i,o=e._fileType;return i=r.instanceIndex>-1?g(r):t.defined(r.clampRegionEdge)?D(r):o>=x.ClampGroundPolygon&&o<=x.ClampObjectLine?B(r):o==x.ClampGroundAndObjectLineCache?D(r):T(r),a.BoundingSphere.transform(i,n,i),i},b.calcBoundingRectangle=function(e,r){var n;return e._fileType===x.ClampGroundPolygon&&(n=function(e){var r,n,a=t.defined(e.nCompressOptions)&&(e.nCompressOptions&h.SVC_Vertex)===h.SVC_Vertex,f=new i.BoundingRectangle,u=e.vertexAttributes[0],y=u.componentsPerAttribute,c=1;a?(c=e.vertCompressConstant,n=new s.Cartesian3(e.minVerticesValue.x,e.minVerticesValue.y,e.minVerticesValue.z),r=new Uint16Array(u.typedArray.buffer,u.typedArray.byteOffset,u.typedArray.byteLength/2)):r=new Float32Array(u.typedArray.buffer,u.typedArray.byteOffset,u.typedArray.byteLength/4);for(var p=[],d=0;d<e.verticesCount;d++){var l=r[y*d],A=r[y*d+1];a&&(l=c*l+n.x,A=c*A+n.y),p.push(new o.Cartesian2(l,A))}return i.BoundingRectangle.fromPoints(p,f),p.length=0,f}(r)),n},b.createEdge=function(e,r){if(!(r.length<1)){var n=function(e){for(var t=[],r=e.length,n=0;n<r;n++){var a=I(e[n].primitiveType);a!==y.PrimitiveType.LINES&&a!==y.PrimitiveType.LINE_STRIP||t.push(e[n])}return t}(r);if(0!=n.length){var a,i=function(e){for(var t=0,r=e.length,n=0;n<r;n++){var a=e[n],i=I(a.primitiveType);i==y.PrimitiveType.LINES?t+=a.indicesCount/2:i==y.PrimitiveType.LINE_STRIP&&t++}return t}(n),o=e.attrLocation.aPosition,f=e.vertexAttributes[o],c=t.defined(e.nCompressOptions)&&(e.nCompressOptions&h.SVC_Vertex)===h.SVC_Vertex,p=f.componentsPerAttribute;c?(p=3,a=S(e,f)):a=new Float32Array(f.typedArray.buffer,f.typedArray.byteOffset,f.typedArray.byteLength/4);for(var d=function(e){for(var t=0,r=e.length,n=0;n<r;n++)t+=e[n].indicesCount;return t}(n),l=function(e,t,r){for(var n,a=[],i=r.length,o=0;o<i;o++){var f,u=r[o];f=0===u.indexType?new Uint16Array(u.indicesTypedArray.buffer,u.indicesTypedArray.byteOffset,u.indicesTypedArray.byteLength/2):new Uint32Array(u.indicesTypedArray.buffer,u.indicesTypedArray.byteOffset,u.indicesTypedArray.byteLength/4);var c=I(u.primitiveType);if(c==y.PrimitiveType.LINES)for(n=0;n<u.indicesCount;n+=2){var p=[],d=new s.Cartesian3;d.x=e[f[n]*t],d.y=e[f[n]*t+1],d.z=e[f[n]*t+2],p.push(d);var l=new s.Cartesian3;l.x=e[f[n+1]*t],l.y=e[f[n+1]*t+1],l.z=e[f[n+1]*t+2],p.push(l),a.push(p)}else if(c==y.PrimitiveType.LINE_STRIP){for(p=[],n=0;n<u.indicesCount;n++){var A=new s.Cartesian3;A.x=e[f[n]*t],A.y=e[f[n]*t+1],A.z=e[f[n]*t+2],p.push(A)}a.push(p)}}return a}(a,p,n),A=4*d-4*i,C=new Float32Array(3*A),v=new Float32Array(3*A),m=new Float32Array(3*A),x=new Int8Array(2*A),b=0,g=0;g<i;g++){for(var T=l[g].length,B=0;B<T;B++){var D=4*b-4*g,w=3*D+12*B,P=l[g][B];0!=B&&(C[w-6]=P.x,C[w-5]=P.y,C[w-4]=P.z,C[w-3]=P.x,C[w-2]=P.y,C[w-1]=P.z),B!=T-1&&(C[w]=P.x,C[w+1]=P.y,C[w+2]=P.z,C[w+3]=P.x,C[w+4]=P.y,C[w+5]=P.z);var V=P;B+1<T&&(V=l[g][B+1]),0!=B&&(m[w-6]=V.x,m[w-5]=V.y,m[w-4]=V.z,m[w-3]=V.x,m[w-2]=V.y,m[w-1]=V.z),B!=T-1&&(m[w]=V.x,m[w+1]=V.y,m[w+2]=V.z,m[w+3]=V.x,m[w+4]=V.y,m[w+5]=V.z);var z=P;B>=1&&(z=l[g][B-1]),0!=B&&(v[w-6]=z.x,v[w-5]=z.y,v[w-4]=z.z,v[w-3]=z.x,v[w-2]=z.y,v[w-1]=z.z),B!=T-1&&(v[w]=z.x,v[w+1]=z.y,v[w+2]=z.z,v[w+3]=z.x,v[w+4]=z.y,v[w+5]=z.z),w=2*D+8*B,0!=B&&(x[w-4]=-1,x[w-3]=-1,x[w-2]=1,x[w-1]=-1),B!=T-1&&(x[w]=-1,x[w+1]=1,x[w+2]=1,x[w+3]=1)}b+=l[g].length}var L={vertexAttributes:[],attrLocation:{}},_=L.vertexAttributes,E=L.attrLocation;L.instanceCount=0,L.instanceMode=0,E.aPosition=0,_.push({index:E.aPosition,typedArray:C,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:3*Float32Array.BYTES_PER_ELEMENT,normalize:!1}),E.aNormal=1,_.push({index:E.aNormal,typedArray:v,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:3*Float32Array.BYTES_PER_ELEMENT,normalize:!1}),E.aTexCoord0=2,_.push({index:E.aTexCoord0,typedArray:m,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:3*Float32Array.BYTES_PER_ELEMENT,normalize:!1}),E.aTexCoord1=3,_.push({index:E.aTexCoord1,typedArray:x,componentsPerAttribute:2,componentDatatype:u.ComponentDatatype.BYTE,offsetInBytes:0,strideInBytes:2*Int8Array.BYTES_PER_ELEMENT,normalize:!1});for(var O=[],R=0;R<l.length;R++)O.push(l[R].length);var F=function(e,t,r,n){var a,i={};i.indicesCount=6*(e-t),i.indexType=n>65535?1:0,i.primitiveType=y.PrimitiveType.TRIANGLES,a=0===i.indexType?new Uint16Array(i.indicesCount):new Uint32Array(i.indicesCount);for(var o=0,s=0;s<t;s++){for(var f=0;f<r[s]-1;f++)a[6*(o-s+f)]=4*(o-s+f),a[6*(o-s+f)+1]=4*(o-s+f)+2,a[6*(o-s+f)+2]=4*(o-s+f)+1,a[6*(o-s+f)+3]=4*(o-s+f)+1,a[6*(o-s+f)+4]=4*(o-s+f)+2,a[6*(o-s+f)+5]=4*(o-s+f)+3;o+=r[s]}return i.indicesTypedArray=a,i}(d,i,O,A);return{vertexPackage:L,indexPackage:F}}}};var P={STREAM_DRAW:p.WebGLConstants.STREAM_DRAW,STATIC_DRAW:p.WebGLConstants.STATIC_DRAW,DYNAMIC_DRAW:p.WebGLConstants.DYNAMIC_DRAW,validate:function(e){return e===P.STREAM_DRAW||e===P.STATIC_DRAW||e===P.DYNAMIC_DRAW}};function V(e){var r=(e=t.defaultValue(e,t.defaultValue.EMPTY_OBJECT)).context._gl,n=e.bufferTarget,a=e.typedArray,i=e.sizeInBytes,o=e.usage,s=t.defined(a);s&&(i=a.byteLength);var f=r.createBuffer();r.bindBuffer(n,f),r.bufferData(n,s?a:i,o),r.bindBuffer(n,null),this._gl=r,this._webgl2=e.context._webgl2,this._bufferTarget=n,this._sizeInBytes=i,this._usage=o,this._buffer=f,this.vertexArrayDestroyable=!0,this.context=e.context,e.context.memorySize+=i}function z(){}V.createVertexBuffer=function(e){return new V({context:e.context,bufferTarget:p.WebGLConstants.ARRAY_BUFFER,typedArray:e.typedArray,sizeInBytes:e.sizeInBytes,usage:e.usage})},V.createIndexBuffer=function(e){var t=e.context,r=e.indexDatatype,n=c.IndexDatatype.getSizeInBytes(r),a=new V({context:t,bufferTarget:p.WebGLConstants.ELEMENT_ARRAY_BUFFER,typedArray:e.typedArray,sizeInBytes:e.sizeInBytes,usage:e.usage}),i=a.sizeInBytes/n;return Object.defineProperties(a,{indexDatatype:{get:function(){return r}},bytesPerIndex:{get:function(){return n}},numberOfIndices:{get:function(){return i}}}),a},Object.defineProperties(V.prototype,{sizeInBytes:{get:function(){return this._sizeInBytes}},usage:{get:function(){return this._usage}}}),V.prototype._getBuffer=function(){return this._buffer},V.prototype.copyFromArrayView=function(e,r){r=t.defaultValue(r,0);var n=this._gl,a=this._bufferTarget;n.bindBuffer(a,this._buffer),n.bufferSubData(a,r,e),n.bindBuffer(a,null)},V.prototype.copyFromBuffer=function(e,t,r,n){var a=p.WebGLConstants.COPY_READ_BUFFER,i=p.WebGLConstants.COPY_WRITE_BUFFER,o=this._gl;o.bindBuffer(i,this._buffer),o.bindBuffer(a,e._buffer),o.copyBufferSubData(a,i,t,r,n),o.bindBuffer(i,null),o.bindBuffer(a,null)},V.prototype.getBufferData=function(e,r,n,a){r=t.defaultValue(r,0),n=t.defaultValue(n,0);var i=this._gl,o=p.WebGLConstants.COPY_READ_BUFFER;i.bindBuffer(o,this._buffer),i.getBufferSubData(o,r,e,n,a),i.bindBuffer(o,null)},V.prototype.isDestroyed=function(){return!1},V.prototype.destroy=function(){return this._gl.deleteBuffer(this._buffer),this.context.memorySize-=this.sizeInBytes,function(e,t){function r(){}for(var n in e)"function"==typeof e[n]&&(e[n]=r);e.isDestroyed=w}(this)},z.computeNeighbors=function(e,t){for(var r=e.length/3,n=new Uint32Array(t+1),a=new Uint32Array(t+1),i=function(e,t){e<t?n[e+1]++:a[t+1]++},o=0;o<r;o++){var s=e[3*o],f=e[3*o+1],u=e[3*o+2];i(s,f),i(f,u),i(u,s)}for(o=f=s=0;o<t;o++)u=n[o+1],i=a[o+1],n[o+1]=s,a[o+1]=f,s+=u,f+=i;var y=new Uint32Array(6*r),c=n[t];for(i=function(e,t,r){if(e<t){var i=n[e+1]++;y[2*i]=t,y[2*i+1]=r}else i=a[t+1]++,y[2*c+2*i]=e,y[2*c+2*i+1]=r},o=0;o<r;o++)s=e[3*o],f=e[3*o+1],u=e[3*o+2],i(s,f,o),i(f,u,o),i(u,s,o);for(s=function(e,t){var r=2*e;for(e=t-e,t=1;t<e;t++){for(var n=y[r+2*t],a=y[r+2*t+1],i=t-1;0<=i&&y[r+2*i]>n;i--)y[r+2*i+2]=y[r+2*i],y[r+2*i+3]=y[r+2*i+1];y[r+2*i+2]=n,y[r+2*i+3]=a}},o=0;o<t;o++)s(n[o],n[o+1]),s(c+a[o],c+a[o+1]);var p=new Int32Array(3*r),d=function(t,r){return t===e[3*r]?0:t===e[3*r+1]?1:t===e[3*r+2]?2:-1};for(r=function(e,t){e=d(e,t),p[3*t+e]=-1},s=function(e,t,r,n){e=d(e,t),p[3*t+e]=n,r=d(r,n),p[3*n+r]=t},o=0;o<t;o++){f=n[o],u=n[o+1],i=a[o];for(var l=a[o+1];f<u&&i<l;){var A=y[2*f],C=y[2*c+2*i];A===C?(s(o,y[2*f+1],C,y[2*c+2*i+1]),f++,i++):A<C?(r(o,y[2*f+1]),f++):(r(C,y[2*c+2*i+1]),i++)}for(;f<u;)r(o,y[2*f+1]),f++;for(;i<l;)r(C=y[2*c+2*i],y[2*c+2*i+1]),i++}return p};var L=null;function _(){}function E(e){return e*Math.PI/180}z.deduplicate=function(e,t,r,n,a){void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=e.byteLength/(4*t)),e=new Uint32Array(e,n,a*t),n=new Uint32Array(a);var i=Math.floor(1.1*a)+1;(null==L||L.length<2*i)&&(L=new Uint32Array(function(e){--e;for(var t=1;32>t;t<<=1)e|=e>>t;return e+1}(2*i)));for(var o=0;o<2*i;o++)L[o]=0;var s=0,f=0!==r?Math.ceil(7.84*1.96/(r*r)*r*(1-r)):a;for(o=0;o<a;o++){if(o===f){if((y=1-s/o)+1.96*Math.sqrt(y*(1-y)/o)<r)return null;f*=2}for(var u,y=o*t,c=u=0;c<t;c++)u=(u=e[y+c]+u|0)+(u<<11)+(u>>>2)|0;c=(u>>>=0)%i;for(var p=s;0!==L[2*c+1];){if(L[2*c]===u){var d=L[2*c+1]-1,l=d*t;e:{for(var A=0;A<t;A++)if(e[y+A]!==e[l+A]){l=!1;break e}l=!0}if(l){p=n[d];break}}++c>=i&&(c-=i)}p===s&&(L[2*c]=u,L[2*c+1]=o+1,s++),n[o]=p}if(0!==r&&1-s/a<r)return null;for(r=new Uint32Array(t*s),o=s=0;o<a;o++)if(n[o]===s){for(i=e,f=o*t,y=r,u=s*t,c=t,p=0;p<c;p++)y[u+p]=i[f+p];s++}return{buffer:r.buffer,indices:n,uniqueCount:s}};var O=E(4),R=E(35),F=Math.cos(R),N=Math.cos(O);var U={position0:new s.Cartesian3,position1:new s.Cartesian3,faceNormal0:new s.Cartesian3,faceNormal1:new s.Cartesian3,cosAngle:0},M=new s.Cartesian3,G=new s.Cartesian3;function W(e,t){var r,n=(r=e.cosAngle,Math.acos(1<r?1:-1>r?-1:r));return function(e,t,r){var n=r.x-t.x,a=r.y-t.y;(r=n*n+a*a+(t=r.z-t.z)*t)?(r=1/Math.sqrt(r),e.x=n*r,e.y=a*r,e.z=t*r):(e.x=0,e.y=0,e.z=0)}(G,e.position1,e.position0),s.Cartesian3.cross(e.faceNormal0,e.faceNormal1,M),n*(0<s.Cartesian3.dot(M,G)?-1:1)>t}var k=new s.Cartesian3,Y=new s.Cartesian3,j=new s.Cartesian3;function q(e){var t=e.x*e.x+e.y*e.y+e.z*e.z;t>0&&(t=1/Math.sqrt(t),e.x*=t,e.y*=t,e.z*=t)}function X(e){}function H(e){if(t.defined(e.cachedSidenessVertexBuffer))return e.cachedSidenessVertexBuffer;var r=new Float32Array(8),n=0;return r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=1,r[n++]=1,r[n++]=1,r[n++]=1,r[n++]=0,e.cachedSidenessVertexBuffer=V.createVertexBuffer({context:e,typedArray:r,usage:P.STATIC_DRAW}),e.cachedSidenessVertexBuffer.vertexArrayDestroyable=!1,e.cachedSidenessVertexBuffer}function Z(e,t){for(var r,n,a,i=t.componentsPerAttribute,o=e.vertCompressConstant,f=new s.Cartesian3(e.minVerticesValue.x,e.minVerticesValue.y,e.minVerticesValue.z),u=new Uint16Array(t.typedArray.buffer,t.typedArray.byteOffset,t.typedArray.byteLength/2),y=new Float32Array(3*e.verticesCount),c=0;c<e.verticesCount;c++)r=u[i*c]*o+f.x,n=u[i*c+1]*o+f.y,a=u[i*c+2]*o+f.z,y[3*c]=r,y[3*c+1]=n,y[3*c+2]=a;return y}_.extractEdges=function(e){var t=e.vertices,r=e.dim,n=U,a=n.position0,i=n.position1,o=n.faceNormal0,f=n.faceNormal1,u=function(e){for(var t=e.faces.length/3,r=e.vertices,n=e.dim,a=e.faces,i=new Float32Array(3*t),o=0;o<t;o++){var f=a[3*o+0],u=a[3*o+1],y=a[3*o+2];k.x=r[n*f],k.y=r[n*f+1],k.z=r[n*f+2],Y.x=r[n*u],Y.y=r[n*u+1],Y.z=r[n*u+2],j.x=r[n*y],j.y=r[n*y+1],j.z=r[n*y+2],s.Cartesian3.subtract(Y,k,Y),s.Cartesian3.subtract(j,k,j),s.Cartesian3.cross(Y,j,k),q(k),i[3*o+0]=k.x,i[3*o+1]=k.y,i[3*o+2]=k.z}return i}(e),y=function(e){var t=e.faces.length/3,r=e.faces,n=e.neighbors,a=0,i=0;for(i=0;i<t;i++){var o=n[3*i+0],s=n[3*i+1],f=n[3*i+2],u=r[3*i+0],y=r[3*i+1],c=r[3*i+2];a+=-1===o||u<y?1:0,a+=-1===s||y<c?1:0,a+=-1===f||c<u?1:0}var p=new Int32Array(4*a),d=0;for(i=0;i<t;i++)o=n[3*i+0],s=n[3*i+1],f=n[3*i+2],u=r[3*i+0],y=r[3*i+1],c=r[3*i+2],(-1===o||u<y)&&(p[d++]=u,p[d++]=y,p[d++]=i,p[d++]=o),(-1===s||y<c)&&(p[d++]=y,p[d++]=c,p[d++]=i,p[d++]=s),(-1===f||c<u)&&(p[d++]=c,p[d++]=u,p[d++]=i,p[d++]=f);return p}(e),c=y.length/4,p=new Float32Array(9*c),d=0,l=new Float32Array(12*c),A=0,C=0,v=0,m=function(e,t){0===t&&(t=e,e=0);for(var r=Array(t-e),n=e;n<t;n++)r[n-e]=n;return r}(0,c),h=new Float32Array(c);h.forEach((function(e,n,o){var f=y[4*n+0],u=y[4*n+1];a.x=t[f*r],a.y=t[f*r+1],a.z=t[f*r+2],i.x=t[u*r],i.y=t[u*r+1],i.z=t[u*r+2],o[n]=s.Cartesian3.distance(a,i)})),m.sort((function(e,t){return h[t]-h[e]}));for(var x=[],b=[],g=0;g<c;g++){var T=m[g],B=h[T],D=y[4*T+0],I=y[4*T+1],S=y[4*T+2],w=y[4*T+3],P=-1===w;if(a.x=t[D*r],a.y=t[D*r+1],a.z=t[D*r+2],i.x=t[I*r],i.y=t[I*r+1],i.z=t[I*r+2],P)o.x=u[3*S],o.y=u[3*S+1],o.z=u[3*S+2],f.x=o.x,f.y=o.y,f.z=o.z,n.cosAngle=s.Cartesian3.dot(o,f);else if(o.x=u[3*S],o.y=u[3*S+1],o.z=u[3*S+2],f.x=u[3*w],f.y=u[3*w+1],f.z=u[3*w+2],n.cosAngle=s.Cartesian3.dot(o,f),n.cosAngle>N)continue;C+=B,v++,P||n.cosAngle<F?(p[d++]=n.position0.x,p[d++]=n.position0.y,p[d++]=n.position0.z,p[d++]=n.position1.x,p[d++]=n.position1.y,p[d++]=n.position1.z,p[d++]=n.faceNormal0.x,p[d++]=n.faceNormal0.y,p[d++]=n.faceNormal0.z,x.push(B)):W(n,O)&&(l[A++]=n.position0.x,l[A++]=n.position0.y,l[A++]=n.position0.z,l[A++]=n.position1.x,l[A++]=n.position1.y,l[A++]=n.position1.z,l[A++]=n.faceNormal0.x,l[A++]=n.faceNormal0.y,l[A++]=n.faceNormal0.z,l[A++]=n.faceNormal1.x,l[A++]=n.faceNormal1.y,l[A++]=n.faceNormal1.z,b.push(B))}p=p.slice(0,d),l=l.slice(0,A);var V=C/v,z=x.length,L=b.length;return{regular:{instancesData:p,instanceCount:z,edgeLength:z*V},silhouette:{instancesData:l,instanceCount:L,edgeLength:L*V},averageEdgeLength:V}},X.RegularInstanceStride=11,X.createEdgeData=function(e,r,n){if(0==r.length)return null;var a,i=r[0];a=0===i.indexType?new Uint16Array(i.indicesTypedArray.buffer,i.indicesTypedArray.byteOffset,i.indicesTypedArray.byteLength/2):new Uint32Array(i.indicesTypedArray.buffer,i.indicesTypedArray.byteOffset,i.indicesTypedArray.byteLength/4);var o=X.extractEdgeInformation(e,!1,a),s=_.extractEdges(o);return t.defined(n)&&(t.defined(s.regular.instancesData)&&n.push(s.regular.instancesData.buffer),t.defined(s.silhouette.instancesData)&&n.push(s.silhouette.instancesData.buffer)),s},X.createIndexBuffer=function(e){return t.defined(e.cachedSidenessIndexBuffer)||(e.cachedSidenessIndexBuffer=V.createIndexBuffer({context:e,typedArray:(r=new Uint16Array(6),n=0,r[n++]=2,r[n++]=1,r[n++]=0,r[n++]=3,r[n++]=2,r[n++]=0,r),usage:P.STATIC_DRAW,indexDatatype:c.IndexDatatype.UNSIGNED_SHORT}),e.cachedSidenessIndexBuffer.vertexArrayDestroyable=!1),e.cachedSidenessIndexBuffer;var r,n},X.createRegularEdgeAttributes=function(e,r){if(t.defined(r.instancesData)&&0!=r.instancesData.length){var n={},a=[];r.attributeLocations=n,r.attributes=a;var i=V.createVertexBuffer({context:e,typedArray:r.instancesData,usage:P.STATIC_DRAW});r.instancesData=null;var o=u.ComponentDatatype.getSizeInBytes(u.ComponentDatatype.FLOAT),s=H(e),f=0;n.aSideness=f++,a.push({index:n.aSideness,vertexBuffer:s,componentsPerAttribute:2,componentDatatype:u.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:2*u.ComponentDatatype.getSizeInBytes(u.ComponentDatatype.FLOAT),normalize:!1});var y=X.RegularInstanceStride,c=0;n.aPosition0=f++,a.push({index:n.aPosition0,vertexBuffer:i,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:o*c,strideInBytes:o*y,instanceDivisor:1}),c+=3,n.aPosition1=f++,a.push({index:n.aPosition1,vertexBuffer:i,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:o*c,strideInBytes:o*y,instanceDivisor:1}),c+=3,n.aNormal=f++,a.push({index:n.aNormal,vertexBuffer:i,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!0,offsetInBytes:o*c,strideInBytes:o*y,instanceDivisor:1}),c+=3,n.aVariantStroke=f++,a.push({index:n.aVariantStroke,vertexBuffer:i,componentsPerAttribute:1,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!0,offsetInBytes:o*c,strideInBytes:o*y,instanceDivisor:1}),c+=1,n.aVariantExtension=f++,a.push({index:n.aVariantExtension,vertexBuffer:i,componentsPerAttribute:1,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!0,offsetInBytes:o*c,strideInBytes:o*y,instanceDivisor:1}),c+=1}},X.createSilhouetteEdgeAttributes=function(e,r){if(t.defined(r.instancesData)&&0!=r.instancesData.length){var n={},a=[];r.attributeLocations=n,r.attributes=a;var i=V.createVertexBuffer({context:e,typedArray:r.instancesData,usage:P.STATIC_DRAW});r.instancesData=null;var o=u.ComponentDatatype.getSizeInBytes(u.ComponentDatatype.FLOAT),s=0;n.aSideness=s++,a.push({index:n.aSideness,vertexBuffer:H(e),componentsPerAttribute:2,componentDatatype:u.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:2*o,normalize:!1});var f=14,y=0;n.aPosition0=s++,a.push({index:n.aPosition0,vertexBuffer:i,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:o*y,strideInBytes:o*f,instanceDivisor:1}),y+=3,n.aPosition1=s++,a.push({index:n.aPosition1,vertexBuffer:i,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:o*y,strideInBytes:o*f,instanceDivisor:1}),y+=3,n.aNormalA=s++,a.push({index:n.aNormalA,vertexBuffer:i,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!0,offsetInBytes:o*y,strideInBytes:o*f,instanceDivisor:1}),y+=3,n.aNormalB=s++,a.push({index:n.aNormalB,vertexBuffer:i,componentsPerAttribute:3,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!0,offsetInBytes:o*y,strideInBytes:o*f,instanceDivisor:1}),y+=3,n.aVariantStroke=s++,a.push({index:n.aVariantStroke,vertexBuffer:i,componentsPerAttribute:1,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!0,offsetInBytes:o*y,strideInBytes:o*f,instanceDivisor:1}),y+=1,n.aVariantExtension=s++,a.push({index:n.aVariantExtension,vertexBuffer:i,componentsPerAttribute:1,componentDatatype:u.ComponentDatatype.FLOAT,normalize:!0,offsetInBytes:o*y,strideInBytes:o*f,instanceDivisor:1}),y+=1}},X.extractEdgeInformation=function(e,r,n){var a,i=e.attrLocation.aPosition,o=e.vertexAttributes[i],s=t.defined(e.nCompressOptions)&&(e.nCompressOptions&h.SVC_Vertex)===h.SVC_Vertex,f=o.componentsPerAttribute;s?(f=3,a=Z(e,o)):a=new Float32Array(o.typedArray.buffer,o.typedArray.byteOffset,o.typedArray.byteLength/4);var u=a.length/f;if(r&&n)return{faces:n,neighbors:z.computeNeighbors(n,u),vertices:a,dim:f};var y,c=o.typedArray.buffer;y=s?a.buffer:c.slice(o.typedArray.byteOffset,o.typedArray.byteOffset+o.typedArray.byteLength);var p=z.deduplicate(y,f),d=X.selectIndexData(p.indices,n);return{faces:d,neighbors:z.computeNeighbors(d,p.uniqueCount),vertices:new Float32Array(p.buffer),dim:f}},X.selectIndexData=function(e,t){if(t){t=t.slice();for(var r=0;r<t.length;r++)t[r]=e[t[r]];return t}return e};var J=new s.Cartesian3,K=new s.Cartesian3,Q=new s.Cartesian3,$=new s.Cartesian3,ee=new s.Cartesian3,te=new s.Cartesian3,re=new s.Cartesian3,ne=new s.Cartesian3;function ae(e,r){function n(e,t,r){var n=48217*e%2147483647,a=t+n/2147483647*(r-=t);return{seed:n,result:Math.round(a)}}var a=function(e,t){var r=new Float32Array(6),n=new Uint32Array(r.buffer),a=new Uint32Array(1);r[0]=e.x,r[1]=e.y,r[2]=e.z,r[3]=t.x,r[4]=t.y,r[5]=t.z,a[0]=5381;for(var i=0;i<n.length;i++)a[0]=31*a[0]+n[i];return a[0]}(e,r);t.defined(a)||(a=2147483647*Math.random());var i=n(a,0,255);a=i.seed,i.result,a=(i=n(a,0,5)).seed;var o=i.result;i=function(e){var t=48217*e%2147483647;return{seed:t,result:t/2147483646}}(a),a=i.seed;var s=i.result;return s=-(1-Math.min(s/.7,1))+Math.max(0,s-.7)/(1-.7),{variantStroke:o,variantExtension:s=255*(Math.abs(s)**1.2*(0>s?-1:1)*.5+.5)}}X.createEdgeDataByIndices=function(e,r){var n,a,i=e.attrLocation.aPosition,o=e.vertexAttributes[i],f=t.defined(e.nCompressOptions)&&(e.nCompressOptions&h.SVC_Vertex)===h.SVC_Vertex,u=o.componentsPerAttribute;f?(u=3,n=Z(e,o)):n=new Float32Array(o.typedArray.buffer,o.typedArray.byteOffset,o.typedArray.byteLength/4);for(var y=[],c=[],p=(a=0===r.indexType?new Uint16Array(r.indicesTypedArray.buffer,r.indicesTypedArray.byteOffset,r.indicesTypedArray.byteLength/2):new Uint32Array(r.indicesTypedArray.buffer,r.indicesTypedArray.byteOffset,r.indicesTypedArray.byteLength/4)).length,d=0,l=0,A=4*Math.floor(p/4);l<A;l+=4){var C=a[l],v=a[l+1],m=a[l+2],x=a[l+3];if(J.x=n[u*C],J.y=n[u*C+1],J.z=n[u*C+2],K.x=n[u*v],K.y=n[u*v+1],K.z=n[u*v+2],Q.x=n[u*m],Q.y=n[u*m+1],Q.z=n[u*m+2],$.x=n[u*x],$.y=n[u*x+1],$.z=n[u*x+2],!(s.Cartesian3.equals(K,Q)||s.Cartesian3.equals(K,$)||s.Cartesian3.equals(K,J)||s.Cartesian3.equals(Q,J)||s.Cartesian3.equals($,J))){if(m===x){if(s.Cartesian3.subtract(K,J,ee),s.Cartesian3.subtract(Q,J,te),s.Cartesian3.cross(ee,te,ee),s.Cartesian3.equals(ee,s.Cartesian3.ZERO))continue;s.Cartesian3.normalize(ee,ee),y.push(J.x),y.push(J.y),y.push(J.z),y.push(K.x),y.push(K.y),y.push(K.z),y.push(ee.x),y.push(ee.y),y.push(ee.z);var b=(T=ae(J,K)).variantStroke,g=T.variantExtension;y.push(b),y.push(g)}else{if(s.Cartesian3.subtract(K,J,ee),s.Cartesian3.subtract(Q,J,te),s.Cartesian3.cross(ee,te,ee),s.Cartesian3.equals(ee,s.Cartesian3.ZERO))continue;if(s.Cartesian3.normalize(ee,ee),s.Cartesian3.subtract(K,J,re),s.Cartesian3.subtract($,J,ne),s.Cartesian3.cross(re,ne,re),s.Cartesian3.equals(re,s.Cartesian3.ZERO))continue;s.Cartesian3.normalize(re,re),c.push(J.x),c.push(J.y),c.push(J.z),c.push(K.x),c.push(K.y),c.push(K.z),c.push(ee.x),c.push(ee.y),c.push(ee.z),c.push(re.x),c.push(re.y),c.push(re.z);var T;b=(T=ae(J,K)).variantStroke,g=T.variantExtension;c.push(b),c.push(g)}d+=s.Cartesian3.distance(J,K)}}var B=d/(p/4),D=y.length/X.RegularInstanceStride,I=c.length/12;return{regular:{instancesData:new Float32Array(y),instanceCount:D,edgeLength:D*B},silhouette:{instancesData:new Float32Array(c),instanceCount:I,edgeLength:I},averageEdgeLength:B}};var ie=Object.freeze({encNONE:0,enrS3TCDXTN:14,enrPVRTPF_PVRTC2:19,enrPVRTPF_PVRTC:20,enrPVRTPF_PVRTC_4bpp:21,enrPVRTPF_ETC1:22});e.DXTTextureDecode=m,e.S3MCompressType=ie,e.S3MEdgeProcessor=X,e.S3MPixelFormat=A,e.S3MVertexPackage=b,e.VertexCompressOption=h,e.getStringFromTypedArray=d}));
