define(["./when-54c2dc71","./Check-6c0211bc","./Math-fc8cecf5","./Cartesian2-bddc1162","./Transforms-ec27f304","./RuntimeError-2109023a","./WebGLConstants-76bb35d1","./ComponentDatatype-6d99a1ee","./GeometryAttribute-44fb48f1","./EncodedCartesian3-e9c71cf0","./IntersectionTests-2626c9e9","./Plane-231f1723","./WebMercatorProjection-df58d479","./arrayRemoveDuplicates-ebc732b0","./ArcType-dc1c5aee","./EllipsoidRhumbLine-c704bf4c","./EllipsoidGeodesic-30fae80b"],function(j,e,He,Be,je,a,t,Ge,Ve,Ye,G,i,n,V,Y,F,E){"use strict";function r(e){e=j.defaultValue(e,j.defaultValue.EMPTY_OBJECT),this._ellipsoid=j.defaultValue(e.ellipsoid,Be.Ellipsoid.WGS84),this._rectangle=j.defaultValue(e.rectangle,Be.Rectangle.MAX_VALUE),this._projection=new je.GeographicProjection(this._ellipsoid),this._numberOfLevelZeroTilesX=j.defaultValue(e.numberOfLevelZeroTilesX,2),this._numberOfLevelZeroTilesY=j.defaultValue(e.numberOfLevelZeroTilesY,1)}Object.defineProperties(r.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}}),r.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<qe?(q=Ue(a,P,ne,Y,da),X=Ue(a,k,G,F,ha)):1===$?(X=Ue(a,k,G,F,ha),q.x=0,q.y=He.CesiumMath.sign(P.longitude-Math.abs(k.longitude)),q.z=0):(q=Ue(a,P,ne,Y,da),X.x=0,X.y=He.CesiumMath.sign(P.longitude-k.longitude),X.z=0));var re=Be.Cartesian3.distance(te,j),ie=Ye.EncodedCartesian3.fromCartesian(ae,Ma),se=Be.Cartesian3.subtract(B,ae,ga),oe=Be.Cartesian3.normalize(se,wa),le=Be.Cartesian3.subtract(te,ae,fa);le=Be.Cartesian3.normalize(le,le);var ue=Be.Cartesian3.cross(oe,le,wa);ue=Be.Cartesian3.normalize(ue,ue);var ce=Be.Cartesian3.cross(le,ne,va);ce=Be.Cartesian3.normalize(ce,ce);var Ce=Be.Cartesian3.subtract(j,B,ma);Ce=Be.Cartesian3.normalize(Ce,Ce);var pe=Be.Cartesian3.cross(G,Ce,ya);pe=Be.Cartesian3.normalize(pe,pe);var de,he=re/x,ge=J/x,fe=0,me=0,we=0;for(s&&(fe=Be.Cartesian3.distance(Y,F),W=Ye.EncodedCartesian3.fromCartesian(Y,Ta),U=Be.Cartesian3.subtract(F,Y,Ea),de=(Z=Be.Cartesian3.normalize(U,_a)).x,Z.x=Z.y,Z.y=-de,me=fe/b,we=Q/b),I=0;I<8;I++){var ve=z+4*I,ye=R+2*I,Me=ve+3,Te=I<4?1:-1,Ee=2===I||3===I||6===I||7===I?1:-1;Be.Cartesian3.pack(ie.high,y,ve),y[Me]=se.x,Be.Cartesian3.pack(ie.low,M,ve),M[Me]=se.y,Be.Cartesian3.pack(ce,T,ve),T[Me]=se.z,Be.Cartesian3.pack(pe,E,ve),E[Me]=he*Te,Be.Cartesian3.pack(ue,_,ve);var _e=ge*Ee;0===_e&&Ee<0&&(_e=9),_[Me]=_e,s&&(u[ve]=W.high.x,u[ve+1]=W.high.y,u[ve+2]=W.low.x,u[ve+3]=W.low.y,C[ve]=-q.y,C[ve+1]=q.x,C[ve+2]=X.y,C[ve+3]=-X.x,c[ve]=U.x,c[ve+1]=U.y,c[ve+2]=Z.x,c[ve+3]=Z.y,p[ye]=me*Te,0===(_e=we*Ee)&&Ee<0&&(_e=9),p[ye+1]=_e)}var Oe=ua,be=ca,Pe=oa,ke=la,Ae=Be.Rectangle.fromCartographicArray(ia,sa),Le=Fe.getMinimumMaximumHeights(Ae,d),Se=Le.minimumTerrainHeight,Ie=Le.maximumTerrainHeight;K+=Se,K+=Ie,Ze(ae,te,Se,Ie,Oe,Pe),Ze(B,j,Se,Ie,be,ke);var xe=Be.Cartesian3.multiplyByScalar(ue,He.CesiumMath.EPSILON5,Oa);Be.Cartesian3.add(Oe,xe,Oe),Be.Cartesian3.add(be,xe,be),Be.Cartesian3.add(Pe,xe,Pe),Be.Cartesian3.add(ke,xe,ke),Je(Oe,be),Je(Pe,ke),Be.Cartesian3.pack(Oe,v,D),Be.Cartesian3.pack(be,v,D+3),Be.Cartesian3.pack(ke,v,D+6),Be.Cartesian3.pack(Pe,v,D+9),xe=Be.Cartesian3.multiplyByScalar(ue,-2*He.CesiumMath.EPSILON5,Oa),Be.Cartesian3.add(Oe,xe,Oe),Be.Cartesian3.add(be,xe,be),Be.Cartesian3.add(Pe,xe,Pe),Be.Cartesian3.add(ke,xe,ke),Je(Oe,be),Je(Pe,ke),Be.Cartesian3.pack(Oe,v,D+12),Be.Cartesian3.pack(be,v,D+15),Be.Cartesian3.pack(ke,v,D+18),Be.Cartesian3.pack(Pe,v,D+21),N+=2,l+=3,R+=16,D+=24,z+=32,J+=re,Q+=fe}var Ne=l=0;for(o=0;oHe.CesiumMath.PI_OVER_TWO&&(o=!0,s=Be.Cartesian3.subtract(i,t,H),u=l.cartesianToCartographic(s,D)),u.height=0;var c=e.project(u,r);return(r=Be.Cartesian3.subtract(c,n,r)).z=0,r=Be.Cartesian3.normalize(r,r),o&&Be.Cartesian3.negate(r,r),r}var B=new Be.Cartesian3,le=new Be.Cartesian3;function Ze(e,a,t,n,r,i){var s=Be.Cartesian3.subtract(a,e,B);Be.Cartesian3.normalize(s,s);var o=t-X,l=Be.Cartesian3.multiplyByScalar(s,o,le);Be.Cartesian3.add(e,l,r);var u=n-W,l=Be.Cartesian3.multiplyByScalar(s,u,le);Be.Cartesian3.add(a,l,i)}var ue=new Be.Cartesian3;function Je(e,a){var t=i.Plane.getPointDistance(K,e),n=i.Plane.getPointDistance(K,a),r=ue;He.CesiumMath.equalsEpsilon(t,0,He.CesiumMath.EPSILON2)?(r=Xe(a,e,r),Be.Cartesian3.multiplyByScalar(r,He.CesiumMath.EPSILON2,r),Be.Cartesian3.add(e,r,e)):He.CesiumMath.equalsEpsilon(n,0,He.CesiumMath.EPSILON2)&&(r=Xe(e,a,r),Be.Cartesian3.multiplyByScalar(r,He.CesiumMath.EPSILON2,r),Be.Cartesian3.add(a,r,a))}var Qe=new Be.Cartographic,Ke=new Be.Cartographic,$e=new Be.Cartesian3,ea=new Be.Cartesian3,aa=new Be.Cartesian3,ta=new Be.Cartesian3,na=new Be.Cartesian3,ra=new Be.Cartesian3,ia=[Qe,Ke],sa=new Be.Rectangle,oa=new Be.Cartesian3,la=new Be.Cartesian3,ua=new Be.Cartesian3,ca=new Be.Cartesian3,Ca=new Be.Cartesian3,pa=new Be.Cartesian3,da=new Be.Cartesian3,ha=new Be.Cartesian3,ga=new Be.Cartesian3,fa=new Be.Cartesian3,ma=new Be.Cartesian3,wa=new Be.Cartesian3,va=new Be.Cartesian3,ya=new Be.Cartesian3,Ma=new Ye.EncodedCartesian3,Ta=new Ye.EncodedCartesian3,Ea=new Be.Cartesian3,_a=new Be.Cartesian3,Oa=new Be.Cartesian3,ba=[new je.BoundingSphere,new je.BoundingSphere],Pa=[0,2,1,0,3,2,0,7,3,0,4,7,0,5,4,0,1,5,5,7,4,5,6,7,5,2,6,5,1,2,3,6,2,3,7,6],ka=Pa.length;function Aa(e){return new Ve.GeometryAttribute({componentDatatype:Ge.ComponentDatatype.FLOAT,componentsPerAttribute:4,normalize:!1,values:e})}return v._projectNormal=Ue,function(e,a){return Fe.initialize().then(function(){return j.defined(a)&&(e=v.unpack(e,a)),v.createGeometry(e)})}});