define(["./buildModuleUrl-3d15f25c","./Cartesian2-6033fa5d","./Cartographic-67e73ef9","./Check-52a7d806","./when-92c6cf3c","./Rectangle-bab7abf0","./GeographicTilingScheme-c09d40dc","./ArcType-31298545","./arrayRemoveDuplicates-f7eaafa2","./ComponentDatatype-81047f82","./EllipsoidGeodesic-04ac0e77","./EllipsoidRhumbLine-8847d1a1","./EncodedCartesian3-b86c8d65","./Intersect-b97e930a","./GeometryAttribute-ef657318","./IntersectionTests-a42760d9","./Math-92c3b5f7","./PrimitiveType-cdfe443e","./Plane-f8d22530","./WebMercatorProjection-39906b85","./Event-3390cd7d","./RuntimeError-c6a62a80","./WebGLConstants-71f10989","./FeatureDetection-067cb23c","./Cartesian4-ad128b5d"],(function(t,e,n,a,r,i,o,s,l,c,u,p,d,h,f,g,w,m,v,y,E,T,_,I,O){"use strict";var k=new n.t,P=new n.t,S=new n.t$1,L=new n.t,b=new n.t,x=new t.i,A=new o.g,C=[new n.t$1,new n.t$1,new n.t$1,new n.t$1],N=new e.o,D={};function H(t){n.t$1.fromRadians(t.east,t.north,0,C[0]),n.t$1.fromRadians(t.west,t.north,0,C[1]),n.t$1.fromRadians(t.east,t.south,0,C[2]),n.t$1.fromRadians(t.west,t.south,0,C[3]);var e,a=0,r=0,i=0,o=0,s=D._terrainHeightsMaxLevel;for(e=0;e<=s;++e){for(var l=!1,c=0;c<4;++c){var u=C[c];if(A.positionToTileXY(u,e,N),0===c)i=N.x,o=N.y;else if(i!==N.x||o!==N.y){l=!0;break}}if(l)break;a=i,r=o}if(0!==e)return{x:a,y:r,level:e>s?s:e-1}}D.initialize=function(){var e=D._initPromise;return r.e(e)||(e=t.t.fetchJson(t.n("Assets/approximateTerrainHeights.json")).then((function(t){D._terrainHeights=t})),D._initPromise=e),e},D.getMinimumMaximumHeights=function(t,e){if(a.o.defined("rectangle",t),!r.e(D._terrainHeights))throw new a.t("You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function");e=r.u(e,i.t.WGS84);var o=H(t),s=D._defaultMinTerrainHeight,l=D._defaultMaxTerrainHeight;if(r.e(o)){var c=o.level+"-"+o.x+"-"+o.y,u=D._terrainHeights[c];r.e(u)&&(s=u[0],l=u[1]),e.cartographicToCartesian(i.h.northeast(t,S),k),e.cartographicToCartesian(i.h.southwest(t,S),P),n.t.midpoint(P,k,L);var p=e.scaleToGeodeticSurface(L,b);if(r.e(p)){var d=n.t.distance(L,p);s=Math.min(s,-d)}else s=D._defaultMinTerrainHeight}return{minimumTerrainHeight:s=Math.max(D._defaultMinTerrainHeight,s),maximumTerrainHeight:l}},D.getBoundingSphere=function(e,n){if(a.o.defined("rectangle",e),!r.e(D._terrainHeights))throw new a.t("You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function");n=r.u(n,i.t.WGS84);var o=H(e),s=D._defaultMaxTerrainHeight;if(r.e(o)){var l=o.level+"-"+o.x+"-"+o.y,c=D._terrainHeights[l];r.e(c)&&(s=c[1])}var u=t.i.fromRectangle3D(e,n,0);return t.i.fromRectangle3D(e,n,s,x),t.i.union(u,x,u)},D._terrainHeightsMaxLevel=6,D._defaultMaxTerrainHeight=9e3,D._defaultMinTerrainHeight=-1e5,D._terrainHeights=void 0,D._initPromise=void 0,Object.defineProperties(D,{initialized:{get:function(){return r.e(D._terrainHeights)}}});var M=[h.n,y.t],z=M.length,R=Math.cos(w.e.toRadians(30)),$=Math.cos(w.e.toRadians(150));function j(t){var e=(t=r.u(t,r.u.EMPTY_OBJECT)).positions;if(!r.e(e)||e.length<2)throw new a.t("At least two positions are required.");if(r.e(t.arcType)&&t.arcType!==s.L.GEODESIC&&t.arcType!==s.L.RHUMB)throw new a.t("Valid options for arcType are ArcType.GEODESIC and ArcType.RHUMB.");this.width=r.u(t.width,1),this._positions=e,this.granularity=r.u(t.granularity,9999),this.loop=r.u(t.loop,!1),this.arcType=r.u(t.arcType,s.L.GEODESIC),this._ellipsoid=r.u(t.ellipsoid,i.t.WGS84),this._projectionIndex=0,this._workerName="createGroundPolylineGeometry",this._scene3DOnly=!1}Object.defineProperties(j.prototype,{packedLength:{get:function(){return 1+3*this._positions.length+1+1+1+i.t.packedLength+1+1}}}),j.setProjectionAndEllipsoid=function(t,e){for(var n=0,a=0;aR||o<$){var s=Q(r,a,at),l=o<$?w.e.PI_OVER_TWO:-w.e.PI_OVER_TWO,c=f.n.fromAxisAngle(s,l,mt),u=m.p.fromQuaternion(c,wt);return m.p.multiplyByVector(u,t,t),!0}return!1}var yt=new n.t$1,Et=new n.t,Tt=new n.t;function _t(t,e,a,r,i){var o=n.t$1.toCartesian(e,t._ellipsoid,Et),s=n.t.add(o,a,Tt),l=!1,c=t._ellipsoid,u=c.cartesianToCartographic(s,yt);Math.abs(e.longitude-u.longitude)>w.e.PI_OVER_TWO&&(l=!0,s=n.t.subtract(o,a,Tt),u=c.cartesianToCartographic(s,yt)),u.height=0;var p=t.project(u,i);return(i=n.t.subtract(p,r,i)).z=0,i=n.t.normalize(i,i),l&&n.t.negate(i,i),i}var It=new n.t,Ot=new n.t;function kt(t,e,a,r,i,o){var s=n.t.subtract(e,t,It);n.t.normalize(s,s);var l=a-0,c=n.t.multiplyByScalar(s,l,Ot);n.t.add(t,c,i);var u=r-1e3;c=n.t.multiplyByScalar(s,u,Ot),n.t.add(e,c,o)}var Pt=new n.t;function St(t,e){var a=v.o.getPointDistance(it,t),r=v.o.getPointDistance(it,e),i=Pt;w.e.equalsEpsilon(a,0,w.e.EPSILON2)?(i=Q(e,t,i),n.t.multiplyByScalar(i,w.e.EPSILON2,i),n.t.add(t,i,t)):w.e.equalsEpsilon(r,0,w.e.EPSILON2)&&(i=Q(t,e,i),n.t.multiplyByScalar(i,w.e.EPSILON2,i),n.t.add(e,i,e))}function Lt(t,e){var n=Math.abs(t.longitude),a=Math.abs(e.longitude);if(w.e.equalsEpsilon(n,w.e.PI,w.e.EPSILON11)){var r=w.e.sign(e.longitude);return t.longitude=r*(n-w.e.EPSILON11),1}if(w.e.equalsEpsilon(a,w.e.PI,w.e.EPSILON11)){var i=w.e.sign(t.longitude);return e.longitude=i*(a-w.e.EPSILON11),2}return 0}var bt=new n.t$1,xt=new n.t$1,At=new n.t,Ct=new n.t,Nt=new n.t,Dt=new n.t,Ht=new n.t,Mt=new n.t,zt=[bt,xt],Rt=new i.h,$t=new n.t,jt=new n.t,Ft=new n.t,Gt=new n.t,Bt=new n.t,qt=new n.t,Ut=new n.t,Wt=new n.t,Yt=new n.t,Vt=new n.t,Zt=new n.t,Xt=new n.t,Jt=new n.t,Qt=new n.t,Kt=new d.i,te=new d.i,ee=new n.t,ne=new n.t,ae=new n.t,re=[new t.i,new t.i],ie=[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],oe=ie.length;function se(e,a,r,o,s,l,u){var p,h,g,m,v,y,E=a._ellipsoid,T=r.length/3-1,_=8*T,I=4*_,O=36*T,k=_>65535?new Uint32Array(O):new Uint16Array(O),P=new Float64Array(3*_),S=new Float32Array(I),L=new Float32Array(I),b=new Float32Array(I),x=new Float32Array(I),A=new Float32Array(I);u&&(g=new Float32Array(I),m=new Float32Array(I),v=new Float32Array(I),y=new Float32Array(2*_));var C=l.length/2,N=0,H=bt;H.height=0;var M=xt;M.height=0;var z=At,$=Ct;if(u)for(h=0,p=1;pR?(at=_t(a,H,st,et,Ut),rt=_t(a,M,X,nt,Wt)):1===lt?(rt=_t(a,M,X,nt,Wt),at.x=0,at.y=w.e.sign(H.longitude-Math.abs(M.longitude)),at.z=0):(at=_t(a,H,st,et,Ut),rt.x=0,rt.y=w.e.sign(H.longitude-M.longitude),rt.z=0)}var ut=n.t.distance(ot,Z),pt=d.i.fromCartesian(it,Kt),dt=n.t.subtract(V,it,Yt),ht=n.t.normalize(dt,Xt),ft=n.t.subtract(ot,it,Vt);ft=n.t.normalize(ft,ft);var gt=n.t.cross(ht,ft,Xt);gt=n.t.normalize(gt,gt);var wt=n.t.cross(ft,st,Jt);wt=n.t.normalize(wt,wt);var mt=n.t.subtract(Z,V,Zt);mt=n.t.normalize(mt,mt);var yt=n.t.cross(X,mt,Qt);yt=n.t.normalize(yt,yt);var Et,Tt,It,Ot=ut/G,Pt=J/G,se=0,ce=0,ue=0;if(u){se=n.t.distance(et,nt),Et=d.i.fromCartesian(et,te),Tt=n.t.subtract(nt,et,ee);var pe=(It=n.t.normalize(Tt,ne)).x;It.x=It.y,It.y=-pe,ce=se/N,ue=K/N}for(F=0;F<8;F++){var de=W+4*F,he=q+2*F,fe=de+3,ge=F<4?1:-1,we=2===F||3===F||6===F||7===F?1:-1;n.t.pack(pt.high,S,de),S[fe]=dt.x,n.t.pack(pt.low,L,de),L[fe]=dt.y,n.t.pack(wt,b,de),b[fe]=dt.z,n.t.pack(yt,x,de),x[fe]=Ot*ge,n.t.pack(gt,A,de);var me=Pt*we;0===me&&we<0&&(me=Number.POSITIVE_INFINITY),A[fe]=me,u&&(g[de]=Et.high.x,g[de+1]=Et.high.y,g[de+2]=Et.low.x,g[de+3]=Et.low.y,v[de]=-at.y,v[de+1]=at.x,v[de+2]=rt.y,v[de+3]=-rt.x,m[de]=Tt.x,m[de+1]=Tt.y,m[de+2]=It.x,m[de+3]=It.y,y[he]=ce*ge,0===(me=ue*we)&&we<0&&(me=Number.POSITIVE_INFINITY),y[he+1]=me)}var ve=Ft,ye=Gt,Ee=$t,Te=jt,_e=i.h.fromCartographicArray(zt,Rt),Ie=D.getMinimumMaximumHeights(_e,E),Oe=Ie.minimumTerrainHeight,ke=Ie.maximumTerrainHeight;tt+=Oe,tt+=ke,kt(it,ot,Oe,ke,ve,Ee),kt(V,Z,Oe,ke,ye,Te);var Pe=n.t.multiplyByScalar(gt,w.e.EPSILON5,ae);n.t.add(ve,Pe,ve),n.t.add(ye,Pe,ye),n.t.add(Ee,Pe,Ee),n.t.add(Te,Pe,Te),St(ve,ye),St(Ee,Te),n.t.pack(ve,P,U),n.t.pack(ye,P,U+3),n.t.pack(Te,P,U+6),n.t.pack(Ee,P,U+9),Pe=n.t.multiplyByScalar(gt,-2*w.e.EPSILON5,ae),n.t.add(ve,Pe,ve),n.t.add(ye,Pe,ye),n.t.add(Ee,Pe,Ee),n.t.add(Te,Pe,Te),St(ve,ye),St(Ee,Te),n.t.pack(ve,P,U+12),n.t.pack(ye,P,U+15),n.t.pack(Te,P,U+18),n.t.pack(Ee,P,U+21),B+=2,h+=3,q+=16,U+=24,W+=32,J+=ut,K+=se}h=0;var Se=0;for(p=0;p