define(["./arrayRemoveDuplicates-47b233f1","./BoundingRectangle-df67ecf0","./Transforms-a7d32f6c","./Cartesian2-40b13f31","./Check-3917d765","./ComponentDatatype-6c2e43c1","./CoplanarPolygonGeometryLibrary-c86d51c7","./when-7b580518","./GeometryAttribute-8f00b923","./GeometryAttributes-fbd9a3fb","./GeometryInstance-e5765c46","./GeometryPipeline-06778f23","./IndexDatatype-b42089ce","./Math-87254c13","./PolygonGeometryLibrary-3364a920","./PolygonPipeline-4cefc824","./VertexFormat-8d463a4f","./combine-83aa7971","./RuntimeError-fad4d3c6","./WebGLConstants-4e26b85a","./OrientedBoundingBox-714102d2","./EllipsoidTangentPlane-b7b148bd","./AxisAlignedBoundingBox-14881a9b","./IntersectionTests-2dece3b4","./Plane-69fa3eea","./AttributeCompression-56959beb","./EncodedCartesian3-942c4568","./ArcType-1da7fdca","./EllipsoidRhumbLine-6baec512"],function(h,e,L,E,t,T,f,l,D,_,C,v,k,V,x,R,s,n,a,r,o,i,p,c,y,m,u,d,g){"use strict";var I=new E.Cartesian3,P=new e.BoundingRectangle,M=new E.Cartesian2,B=new E.Cartesian2,A=new E.Cartesian3,w=new E.Cartesian3,F=new E.Cartesian3,G=new E.Cartesian3,H=new E.Cartesian3,O=new E.Cartesian3,z=new L.Quaternion,S=new L.Matrix3,N=new L.Matrix3,Q=new E.Cartesian3;function b(e){var t=(e=l.defaultValue(e,l.defaultValue.EMPTY_OBJECT)).polygonHierarchy,n=l.defaultValue(e.vertexFormat,s.VertexFormat.DEFAULT);this._vertexFormat=s.VertexFormat.clone(n),this._polygonHierarchy=t,this._stRotation=l.defaultValue(e.stRotation,0),this._ellipsoid=E.Ellipsoid.clone(l.defaultValue(e.ellipsoid,E.Ellipsoid.WGS84)),this._workerName="createCoplanarPolygonGeometry",this.packedLength=x.PolygonGeometryLibrary.computeHierarchyPackedLength(t)+s.VertexFormat.packedLength+E.Ellipsoid.packedLength+2}b.fromPositions=function(e){return new b({polygonHierarchy:{positions:(e=l.defaultValue(e,l.defaultValue.EMPTY_OBJECT)).positions},vertexFormat:e.vertexFormat,stRotation:e.stRotation,ellipsoid:e.ellipsoid})},b.pack=function(e,t,n){return n=l.defaultValue(n,0),n=x.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,n),E.Ellipsoid.pack(e._ellipsoid,t,n),n+=E.Ellipsoid.packedLength,s.VertexFormat.pack(e._vertexFormat,t,n),n+=s.VertexFormat.packedLength,t[n++]=e._stRotation,t[n]=e.packedLength,t};var j=E.Ellipsoid.clone(E.Ellipsoid.UNIT_SPHERE),U=new s.VertexFormat,Y={polygonHierarchy:{}};return b.unpack=function(e,t,n){t=l.defaultValue(t,0);var a=x.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=a.startingIndex,delete a.startingIndex;var r=E.Ellipsoid.unpack(e,t,j);t+=E.Ellipsoid.packedLength;var o=s.VertexFormat.unpack(e,t,U);t+=s.VertexFormat.packedLength;var i=e[t++],t=e[t];return(n=!l.defined(n)?new b(Y):n)._polygonHierarchy=a,n._ellipsoid=E.Ellipsoid.clone(r,n._ellipsoid),n._vertexFormat=s.VertexFormat.clone(o,n._vertexFormat),n._stRotation=i,n.packedLength=t,n},b.createGeometry=function(e){var t=e._vertexFormat,n=e._polygonHierarchy,a=e._stRotation,r=n.positions;if(!((r=h.arrayRemoveDuplicates(r,E.Cartesian3.equalsEpsilon,!0)).length<3)){var o=A,i=w,l=F,s=H,p=O;if(f.CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments(r,G,s,p)){o=E.Cartesian3.cross(s,p,o);o=E.Cartesian3.normalize(o,o),E.Cartesian3.equalsEpsilon(G,E.Cartesian3.ZERO,V.CesiumMath.EPSILON6)||(c=e._ellipsoid.geodeticSurfaceNormal(G,Q),E.Cartesian3.dot(o,c)<0&&(o=E.Cartesian3.negate(o,o),s=E.Cartesian3.negate(s,s)));var c=f.CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction(G,s,p),y=f.CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction(G,s,p);t.tangent&&(i=E.Cartesian3.clone(s,i)),t.bitangent&&(l=E.Cartesian3.clone(p,l));var n=x.PolygonGeometryLibrary.polygonsFromHierarchy(n,c,!1),c=n.hierarchy,m=n.polygons;if(0!==c.length){for(var r=c[0].outerRing,n=L.BoundingSphere.fromPoints(r),u=x.PolygonGeometryLibrary.computeBoundingRectangle(o,y,r,a,P),d=[],g=0;g