worldorbit 3.0.5 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var WorldOrbitEditor=(()=>{var Ju=Object.defineProperty;var lx=Object.getOwnPropertyDescriptor;var ux=Object.getOwnPropertyNames;var dx=Object.prototype.hasOwnProperty;var hx=(n,e)=>()=>(n&&(e=n(n=0)),e);var Xp=(n,e)=>{for(var t in e)Ju(n,t,{get:e[t],enumerable:!0})},fx=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ux(e))!dx.call(n,r)&&r!==t&&Ju(n,r,{get:()=>e[r],enumerable:!(i=lx(e,r))||i.enumerable});return n};var px=n=>fx(Ju({},"__esModule",{value:!0}),n);var Iv={};Xp(Iv,{ACESFilmicToneMapping:()=>Oy,AddEquation:()=>Wi,AddOperation:()=>Ry,AdditiveAnimationBlendMode:()=>Ip,AdditiveBlending:()=>wh,AgXToneMapping:()=>Ny,AlphaFormat:()=>$y,AlwaysCompare:()=>ov,AlwaysDepth:()=>My,AlwaysStencilFunc:()=>Kh,AmbientLight:()=>Su,AnimationAction:()=>Ou,AnimationClip:()=>Hr,AnimationLoader:()=>Cf,AnimationMixer:()=>Wf,AnimationObjectGroup:()=>jf,AnimationUtils:()=>XI,ArcCurve:()=>$l,ArrayCamera:()=>Il,ArrowHelper:()=>pp,AttachedBindMode:()=>Eh,Audio:()=>Lu,AudioAnalyser:()=>Hf,AudioContext:()=>Da,AudioListener:()=>Vf,AudioLoader:()=>Bf,AxesHelper:()=>mp,BackSide:()=>on,BasicDepthPacking:()=>Jy,BasicShadowMap:()=>EM,BatchedMesh:()=>Fl,Bone:()=>pa,BooleanKeyframeTrack:()=>Ei,Box2:()=>tp,Box3:()=>Gt,Box3Helper:()=>hp,BoxGeometry:()=>Or,BoxHelper:()=>dp,BufferAttribute:()=>ut,BufferGeometry:()=>it,BufferGeometryLoader:()=>Ru,ByteType:()=>By,Cache:()=>vi,Camera:()=>Bs,CameraHelper:()=>up,CanvasTexture:()=>Sf,CapsuleGeometry:()=>Yl,CatmullRomCurve3:()=>Hl,CineonToneMapping:()=>Dy,CircleGeometry:()=>ql,ClampToEdgeWrapping:()=>In,Clock:()=>Pu,Color:()=>Ce,ColorKeyframeTrack:()=>Ca,ColorManagement:()=>mt,CompressedArrayTexture:()=>wf,CompressedCubeTexture:()=>Mf,CompressedTexture:()=>Hs,CompressedTextureLoader:()=>Rf,ConeGeometry:()=>Zl,ConstantAlphaFactor:()=>by,ConstantColorFactor:()=>vy,CubeCamera:()=>Al,CubeReflectionMapping:()=>Mi,CubeRefractionMapping:()=>Yi,CubeTexture:()=>Ur,CubeTextureLoader:()=>Pf,CubeUVReflectionMapping:()=>Ws,CubicBezierCurve:()=>ga,CubicBezierCurve3:()=>Gl,CubicInterpolant:()=>yu,CullFaceBack:()=>_h,CullFaceFront:()=>ny,CullFaceFrontBack:()=>SM,CullFaceNone:()=>ty,Curve:()=>bn,CurvePath:()=>Xl,CustomBlending:()=>ry,CustomToneMapping:()=>Uy,CylinderGeometry:()=>js,Cylindrical:()=>ep,Data3DTexture:()=>oa,DataArrayTexture:()=>Ns,DataTexture:()=>Yn,DataTextureLoader:()=>Lf,DataUtils:()=>LS,DecrementStencilOp:()=>NM,DecrementWrapStencilOp:()=>kM,DefaultLoadingManager:()=>Av,DepthFormat:()=>Pr,DepthStencilFormat:()=>Os,DepthTexture:()=>ua,DetachedBindMode:()=>ky,DirectionalLight:()=>Mu,DirectionalLightHelper:()=>lp,DiscreteInterpolant:()=>vu,DisplayP3ColorSpace:()=>Fu,DodecahedronGeometry:()=>Jl,DoubleSide:()=>jn,DstAlphaFactor:()=>fy,DstColorFactor:()=>my,DynamicCopyUsage:()=>QM,DynamicDrawUsage:()=>XM,DynamicReadUsage:()=>ZM,EdgesGeometry:()=>Kl,EllipseCurve:()=>Gs,EqualCompare:()=>nv,EqualDepth:()=>Ey,EqualStencilFunc:()=>$M,EquirectangularReflectionMapping:()=>Xo,EquirectangularRefractionMapping:()=>Yo,Euler:()=>vn,EventDispatcher:()=>Bn,ExtrudeGeometry:()=>Ql,FileLoader:()=>zn,Float16BufferAttribute:()=>cf,Float32BufferAttribute:()=>Le,FloatType:()=>Cn,Fog:()=>Rl,FogExp2:()=>Cl,FramebufferTexture:()=>_f,FrontSide:()=>wi,Frustum:()=>Nr,GLBufferAttribute:()=>Zf,GLSL1:()=>tS,GLSL3:()=>Qh,GreaterCompare:()=>iv,GreaterDepth:()=>Ty,GreaterEqualCompare:()=>sv,GreaterEqualDepth:()=>Ay,GreaterEqualStencilFunc:()=>WM,GreaterStencilFunc:()=>GM,GridHelper:()=>ap,Group:()=>Xi,HalfFloatType:()=>Ua,HemisphereLight:()=>bu,HemisphereLightHelper:()=>op,IcosahedronGeometry:()=>eu,ImageBitmapLoader:()=>kf,ImageLoader:()=>Gr,ImageUtils:()=>Sl,IncrementStencilOp:()=>UM,IncrementWrapStencilOp:()=>FM,InstancedBufferAttribute:()=>Zi,InstancedBufferGeometry:()=>Cu,InstancedInterleavedBuffer:()=>qf,InstancedMesh:()=>Nl,Int16BufferAttribute:()=>of,Int32BufferAttribute:()=>af,Int8BufferAttribute:()=>nf,IntType:()=>_p,InterleavedBuffer:()=>$s,InterleavedBufferAttribute:()=>Fr,Interpolant:()=>zr,InterpolateDiscrete:()=>Jo,InterpolateLinear:()=>Ko,InterpolateSmooth:()=>_l,InvertStencilOp:()=>BM,KeepStencilOp:()=>Sr,KeyframeTrack:()=>_n,LOD:()=>Dl,LatheGeometry:()=>_a,Layers:()=>Fs,LessCompare:()=>tv,LessDepth:()=>Sy,LessEqualCompare:()=>Cp,LessEqualDepth:()=>Wo,LessEqualStencilFunc:()=>HM,LessStencilFunc:()=>VM,Light:()=>Kn,LightProbe:()=>Tu,Line:()=>Jn,Line3:()=>np,LineBasicMaterial:()=>jt,LineCurve:()=>ya,LineCurve3:()=>jl,LineDashedMaterial:()=>gu,LineLoop:()=>zl,LineSegments:()=>Rn,LinearDisplayP3ColorSpace:()=>Na,LinearFilter:()=>Lt,LinearInterpolant:()=>Ia,LinearMipMapLinearFilter:()=>CM,LinearMipMapNearestFilter:()=>IM,LinearMipmapLinearFilter:()=>Wn,LinearMipmapNearestFilter:()=>Vo,LinearSRGBColorSpace:()=>Ti,LinearToneMapping:()=>Py,LinearTransfer:()=>ea,Loader:()=>en,LoaderUtils:()=>La,LoadingManager:()=>Ra,LoopOnce:()=>Yy,LoopPingPong:()=>Zy,LoopRepeat:()=>qy,LuminanceAlphaFormat:()=>jy,LuminanceFormat:()=>Gy,MOUSE:()=>wM,Material:()=>$t,MaterialLoader:()=>Iu,MathUtils:()=>vS,Matrix3:()=>Qe,Matrix4:()=>ze,MaxEquation:()=>cy,Mesh:()=>It,MeshBasicMaterial:()=>Zn,MeshDepthMaterial:()=>da,MeshDistanceMaterial:()=>ha,MeshLambertMaterial:()=>pu,MeshMatcapMaterial:()=>mu,MeshNormalMaterial:()=>fu,MeshPhongMaterial:()=>du,MeshPhysicalMaterial:()=>uu,MeshStandardMaterial:()=>Ta,MeshToonMaterial:()=>hu,MinEquation:()=>ay,MirroredRepeatWrapping:()=>Zo,MixOperation:()=>Cy,MultiplyBlending:()=>Sh,MultiplyOperation:()=>Oa,NearestFilter:()=>zt,NearestMipMapLinearFilter:()=>TM,NearestMipMapNearestFilter:()=>AM,NearestMipmapLinearFilter:()=>Is,NearestMipmapNearestFilter:()=>xp,NeutralToneMapping:()=>Fy,NeverCompare:()=>ev,NeverDepth:()=>wy,NeverStencilFunc:()=>zM,NoBlending:()=>xi,NoColorSpace:()=>pi,NoToneMapping:()=>bi,NormalAnimationBlendMode:()=>Nu,NormalBlending:()=>Rr,NotEqualCompare:()=>rv,NotEqualDepth:()=>Iy,NotEqualStencilFunc:()=>jM,NumberKeyframeTrack:()=>Vr,Object3D:()=>ht,ObjectLoader:()=>Ff,ObjectSpaceNormalMap:()=>Qy,OctahedronGeometry:()=>Ea,OneFactor:()=>uy,OneMinusConstantAlphaFactor:()=>_y,OneMinusConstantColorFactor:()=>xy,OneMinusDstAlphaFactor:()=>py,OneMinusDstColorFactor:()=>gy,OneMinusSrcAlphaFactor:()=>Ml,OneMinusSrcColorFactor:()=>hy,OrthographicCamera:()=>Vs,P3Primaries:()=>na,PCFShadowMap:()=>vp,PCFSoftShadowMap:()=>iy,PMREMGenerator:()=>la,Path:()=>kr,PerspectiveCamera:()=>Ut,Plane:()=>Gn,PlaneGeometry:()=>zs,PlaneHelper:()=>fp,PointLight:()=>wu,PointLightHelper:()=>sp,Points:()=>Vl,PointsMaterial:()=>ma,PolarGridHelper:()=>cp,PolyhedronGeometry:()=>Ji,PositionalAudio:()=>$f,PropertyBinding:()=>pt,PropertyMixer:()=>Du,QuadraticBezierCurve:()=>va,QuadraticBezierCurve3:()=>xa,Quaternion:()=>Qt,QuaternionKeyframeTrack:()=>Ki,QuaternionLinearInterpolant:()=>xu,RED_GREEN_RGTC2_Format:()=>Zh,RED_RGTC1_Format:()=>Xy,REVISION:()=>_M,RGBADepthPacking:()=>Ky,RGBAFormat:()=>mn,RGBAIntegerFormat:()=>Tp,RGBA_ASTC_10x10_Format:()=>Gh,RGBA_ASTC_10x5_Format:()=>Vh,RGBA_ASTC_10x6_Format:()=>$h,RGBA_ASTC_10x8_Format:()=>Hh,RGBA_ASTC_12x10_Format:()=>jh,RGBA_ASTC_12x12_Format:()=>Wh,RGBA_ASTC_4x4_Format:()=>Dh,RGBA_ASTC_5x4_Format:()=>Oh,RGBA_ASTC_5x5_Format:()=>Uh,RGBA_ASTC_6x5_Format:()=>Nh,RGBA_ASTC_6x6_Format:()=>Fh,RGBA_ASTC_8x5_Format:()=>kh,RGBA_ASTC_8x6_Format:()=>Bh,RGBA_ASTC_8x8_Format:()=>zh,RGBA_BPTC_Format:()=>bl,RGBA_ETC2_EAC_Format:()=>Lh,RGBA_PVRTC_2BPPV1_Format:()=>Ch,RGBA_PVRTC_4BPPV1_Format:()=>Ih,RGBA_S3TC_DXT1_Format:()=>yl,RGBA_S3TC_DXT3_Format:()=>vl,RGBA_S3TC_DXT5_Format:()=>xl,RGBFormat:()=>Hy,RGB_BPTC_SIGNED_Format:()=>Xh,RGB_BPTC_UNSIGNED_Format:()=>Yh,RGB_ETC1_Format:()=>Rh,RGB_ETC2_Format:()=>Ph,RGB_PVRTC_2BPPV1_Format:()=>Th,RGB_PVRTC_4BPPV1_Format:()=>Ah,RGB_S3TC_DXT1_Format:()=>gl,RGFormat:()=>Wy,RGIntegerFormat:()=>Ap,RawShaderMaterial:()=>lu,Ray:()=>qi,Raycaster:()=>Jf,Rec709Primaries:()=>ta,RectAreaLight:()=>Eu,RedFormat:()=>Sp,RedIntegerFormat:()=>Ep,ReinhardToneMapping:()=>Ly,RenderTarget:()=>El,RepeatWrapping:()=>qo,ReplaceStencilOp:()=>OM,ReverseSubtractEquation:()=>oy,RingGeometry:()=>tu,SIGNED_RED_GREEN_RGTC2_Format:()=>Jh,SIGNED_RED_RGTC1_Format:()=>qh,SRGBColorSpace:()=>Tn,SRGBTransfer:()=>wt,Scene:()=>Pl,ShaderChunk:()=>tt,ShaderLib:()=>kn,ShaderMaterial:()=>xn,ShadowMaterial:()=>cu,Shape:()=>_i,ShapeGeometry:()=>nu,ShapePath:()=>gp,ShapeUtils:()=>qn,ShortType:()=>zy,Skeleton:()=>Ul,SkeletonHelper:()=>rp,SkinnedMesh:()=>Ol,Source:()=>gi,Sphere:()=>Vt,SphereGeometry:()=>Aa,Spherical:()=>Qf,SphericalHarmonics3:()=>Au,SplineCurve:()=>ba,SpotLight:()=>_u,SpotLightHelper:()=>ip,Sprite:()=>Ll,SpriteMaterial:()=>fa,SrcAlphaFactor:()=>wl,SrcAlphaSaturateFactor:()=>yy,SrcColorFactor:()=>dy,StaticCopyUsage:()=>KM,StaticDrawUsage:()=>ia,StaticReadUsage:()=>qM,StereoCamera:()=>zf,StreamCopyUsage:()=>eS,StreamDrawUsage:()=>YM,StreamReadUsage:()=>JM,StringKeyframeTrack:()=>Ai,SubtractEquation:()=>sy,SubtractiveBlending:()=>Mh,TOUCH:()=>MM,TangentSpaceNormalMap:()=>Qi,TetrahedronGeometry:()=>iu,Texture:()=>Dt,TextureLoader:()=>Df,TorusGeometry:()=>ru,TorusKnotGeometry:()=>su,Triangle:()=>yi,TriangleFanDrawMode:()=>LM,TriangleStripDrawMode:()=>PM,TrianglesDrawMode:()=>RM,TubeGeometry:()=>ou,UVMapping:()=>Uu,Uint16BufferAttribute:()=>aa,Uint32BufferAttribute:()=>ca,Uint8BufferAttribute:()=>rf,Uint8ClampedBufferAttribute:()=>sf,Uniform:()=>Xf,UniformsGroup:()=>Yf,UniformsLib:()=>Ee,UniformsUtils:()=>hv,UnsignedByteType:()=>Si,UnsignedInt248Type:()=>Xs,UnsignedInt5999Type:()=>Vy,UnsignedIntType:()=>Dr,UnsignedShort4444Type:()=>wp,UnsignedShort5551Type:()=>Mp,UnsignedShortType:()=>bp,VSMShadowMap:()=>Hn,Vector2:()=>oe,Vector3:()=>P,Vector4:()=>gt,VectorKeyframeTrack:()=>$r,VideoTexture:()=>bf,WebGL3DRenderTarget:()=>tf,WebGLArrayRenderTarget:()=>ef,WebGLCoordinateSystem:()=>Xn,WebGLCubeRenderTarget:()=>Tl,WebGLMultipleRenderTargets:()=>yp,WebGLRenderTarget:()=>yn,WebGLRenderer:()=>yf,WebGLUtils:()=>xv,WebGPUCoordinateSystem:()=>ra,WireframeGeometry:()=>au,WrapAroundEnding:()=>Qo,ZeroCurvatureEnding:()=>Tr,ZeroFactor:()=>ly,ZeroSlopeEnding:()=>Ir,ZeroStencilOp:()=>DM,createCanvasElement:()=>cv});function gn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Zt[n&255]+Zt[n>>8&255]+Zt[n>>16&255]+Zt[n>>24&255]+"-"+Zt[e&255]+Zt[e>>8&255]+"-"+Zt[e>>16&15|64]+Zt[e>>24&255]+"-"+Zt[t&63|128]+Zt[t>>8&255]+"-"+Zt[t>>16&255]+Zt[t>>24&255]+Zt[i&255]+Zt[i>>8&255]+Zt[i>>16&255]+Zt[i>>24&255]).toLowerCase()}function Tt(n,e,t){return Math.max(e,Math.min(t,n))}function Rp(n,e){return(n%e+e)%e}function nS(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function iS(n,e,t){return n!==e?(t-n)/(e-n):0}function $o(n,e,t){return(1-t)*n+t*e}function rS(n,e,t,i){return $o(n,e,1-Math.exp(-t*i))}function sS(n,e=1){return e-Math.abs(Rp(n,e*2)-e)}function oS(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function aS(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function cS(n,e){return n+Math.floor(Math.random()*(e-n+1))}function lS(n,e){return n+Math.random()*(e-n)}function uS(n){return n*(.5-Math.random())}function dS(n){n!==void 0&&(Mg=n);let e=Mg+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function hS(n){return n*Lr}function fS(n){return n*Us}function pS(n){return(n&n-1)===0&&n!==0}function mS(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function gS(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function yS(n,e,t,i,r){let s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+i)/2),u=o((e+i)/2),d=s((e-i)/2),h=o((e-i)/2),f=s((i-e)/2),p=o((i-e)/2);switch(r){case"XYX":n.set(a*u,c*d,c*h,a*l);break;case"YZY":n.set(c*h,a*u,c*d,a*l);break;case"ZXZ":n.set(c*d,c*h,a*u,a*l);break;case"XZX":n.set(a*u,c*p,c*f,a*l);break;case"YXY":n.set(c*f,a*u,c*p,a*l);break;case"ZYZ":n.set(c*p,c*f,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function sn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function et(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}function av(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Cs(n,e){return new xS[n](e)}function sa(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function cv(){let n=sa("canvas");return n.style.display="block",n}function lv(n){n in Sg||(Sg[n]=!0,console.warn(n))}function Ls(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function kd(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}function Bd(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Sl.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}function Vd(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){fr.fromArray(n,s);let a=r.x*Math.abs(fr.x)+r.y*Math.abs(fr.y)+r.z*Math.abs(fr.z),c=e.dot(fr),l=t.dot(fr),u=i.dot(fr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}function Jd(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function PS(){let n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(i[c]=0,i[c|256]=32768,r[c]=24,r[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,r[c]=-l-1,r[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,r[c]=13,r[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,r[c]=24,r[c|256]=24):(i[c]=31744,i[c|256]=64512,r[c]=13,r[c|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function un(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Tt(n,-65504,65504),mi.floatView[0]=n;let e=mi.uint32View[0],t=e>>23&511;return mi.baseTable[t]+((e&8388607)>>mi.shiftTable[t])}function Bo(n){let e=n>>10;return mi.uint32View[0]=mi.mantissaTable[mi.offsetTable[e]+(n&1023)]+mi.exponentTable[e],mi.floatView[0]}function OS(n,e,t,i,r,s,o,a){let c;if(e.side===on?c=i.intersectTriangle(o,s,r,!0,a):c=i.intersectTriangle(r,s,o,e.side===wi,a),c===null)return null;zc.copy(a),zc.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(zc);return l<t.near||l>t.far?null:{distance:l,point:zc.clone(),object:n}}function Vc(n,e,t,i,r,s,o,a,c,l){n.getVertexPosition(a,gs),n.getVertexPosition(c,ys),n.getVertexPosition(l,vs);let u=OS(n,e,t,i,gs,ys,vs,Bc);if(u){r&&(Nc.fromBufferAttribute(r,a),Fc.fromBufferAttribute(r,c),kc.fromBufferAttribute(r,l),u.uv=yi.getInterpolation(Bc,gs,ys,vs,Nc,Fc,kc,new oe)),s&&(Nc.fromBufferAttribute(s,a),Fc.fromBufferAttribute(s,c),kc.fromBufferAttribute(s,l),u.uv1=yi.getInterpolation(Bc,gs,ys,vs,Nc,Fc,kc,new oe)),o&&(kg.fromBufferAttribute(o,a),Bg.fromBufferAttribute(o,c),zg.fromBufferAttribute(o,l),u.normal=yi.getInterpolation(Bc,gs,ys,vs,kg,Bg,zg,new P),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new P,materialIndex:0};yi.getNormal(gs,ys,vs,d.normal),u.face=d}return u}function ks(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function rn(n){let e={};for(let t=0;t<n.length;t++){let i=ks(n[t]);for(let r in i)e[r]=i[r]}return e}function US(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function dv(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:mt.workingColorSpace}function fv(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function zS(n){let e=new WeakMap;function t(a,c){let l=a.array,u=a.usage,d=l.byteLength,h=n.createBuffer();n.bindBuffer(c,h),n.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=n.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=n.SHORT;else if(l instanceof Uint32Array)f=n.UNSIGNED_INT;else if(l instanceof Int32Array)f=n.INT;else if(l instanceof Int8Array)f=n.BYTE;else if(l instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,c,l){let u=c.array,d=c._updateRange,h=c.updateRanges;if(n.bindBuffer(l,a),d.count===-1&&h.length===0&&n.bufferSubData(l,0,u),h.length!==0){for(let f=0,p=h.length;f<p;f++){let y=h[f];n.bufferSubData(l,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}c.clearUpdateRanges()}d.count!==-1&&(n.bufferSubData(l,d.offset*u.BYTES_PER_ELEMENT,u,d.offset,d.count),d.count=-1),c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(n.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isGLBufferAttribute){let u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}function _A(n,e,t,i,r,s,o){let a=new Ce(0),c=s===!0?0:1,l,u,d=null,h=0,f=null;function p(v){let x=v.isScene===!0?v.background:null;return x&&x.isTexture&&(x=(v.backgroundBlurriness>0?t:e).get(x)),x}function y(v){let x=!1,w=p(v);w===null?m(a,c):w&&w.isColor&&(m(w,1),x=!0);let O=n.xr.getEnvironmentBlendMode();O==="additive"?i.buffers.color.setClear(0,0,0,1,o):O==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||x)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil)}function g(v,x){let w=p(x);w&&(w.isCubeTexture||w.mapping===Ws)?(u===void 0&&(u=new It(new Or(1,1,1),new xn({name:"BackgroundCubeMaterial",uniforms:ks(kn.backgroundCube.uniforms),vertexShader:kn.backgroundCube.vertexShader,fragmentShader:kn.backgroundCube.fragmentShader,side:on,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(O,I,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),gr.copy(x.backgroundRotation),gr.x*=-1,gr.y*=-1,gr.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(gr.y*=-1,gr.z*=-1),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(bA.makeRotationFromEuler(gr)),u.material.toneMapped=mt.getTransfer(w.colorSpace)!==wt,(d!==w||h!==w.version||f!==n.toneMapping)&&(u.material.needsUpdate=!0,d=w,h=w.version,f=n.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(l===void 0&&(l=new It(new zs(2,2),new xn({name:"BackgroundMaterial",uniforms:ks(kn.background.uniforms),vertexShader:kn.background.vertexShader,fragmentShader:kn.background.fragmentShader,side:wi,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=w,l.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,l.material.toneMapped=mt.getTransfer(w.colorSpace)!==wt,w.matrixAutoUpdate===!0&&w.updateMatrix(),l.material.uniforms.uvTransform.value.copy(w.matrix),(d!==w||h!==w.version||f!==n.toneMapping)&&(l.material.needsUpdate=!0,d=w,h=w.version,f=n.toneMapping),l.layers.enableAll(),v.unshift(l,l.geometry,l.material,0,0,null))}function m(v,x){v.getRGB(Hc,dv(n)),i.buffers.color.setClear(Hc.r,Hc.g,Hc.b,x,o)}return{getClearColor:function(){return a},setClearColor:function(v,x=1){a.set(v),c=x,m(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(v){c=v,m(a,c)},render:y,addToRenderList:g}}function wA(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(b,D,z,F,$){let W=!1,ne=d(F,z,D);s!==ne&&(s=ne,l(s.object)),W=f(b,F,z,$),W&&p(b,F,z,$),$!==null&&e.update($,n.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,w(b,D,z,F),$!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get($).buffer))}function c(){return n.createVertexArray()}function l(b){return n.bindVertexArray(b)}function u(b){return n.deleteVertexArray(b)}function d(b,D,z){let F=z.wireframe===!0,$=i[b.id];$===void 0&&($={},i[b.id]=$);let W=$[D.id];W===void 0&&(W={},$[D.id]=W);let ne=W[F];return ne===void 0&&(ne=h(c()),W[F]=ne),ne}function h(b){let D=[],z=[],F=[];for(let $=0;$<t;$++)D[$]=0,z[$]=0,F[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:z,attributeDivisors:F,object:b,attributes:{},index:null}}function f(b,D,z,F){let $=s.attributes,W=D.attributes,ne=0,J=z.getAttributes();for(let V in J)if(J[V].location>=0){let fe=$[V],Te=W[V];if(Te===void 0&&(V==="instanceMatrix"&&b.instanceMatrix&&(Te=b.instanceMatrix),V==="instanceColor"&&b.instanceColor&&(Te=b.instanceColor)),fe===void 0||fe.attribute!==Te||Te&&fe.data!==Te.data)return!0;ne++}return s.attributesNum!==ne||s.index!==F}function p(b,D,z,F){let $={},W=D.attributes,ne=0,J=z.getAttributes();for(let V in J)if(J[V].location>=0){let fe=W[V];fe===void 0&&(V==="instanceMatrix"&&b.instanceMatrix&&(fe=b.instanceMatrix),V==="instanceColor"&&b.instanceColor&&(fe=b.instanceColor));let Te={};Te.attribute=fe,fe&&fe.data&&(Te.data=fe.data),$[V]=Te,ne++}s.attributes=$,s.attributesNum=ne,s.index=F}function y(){let b=s.newAttributes;for(let D=0,z=b.length;D<z;D++)b[D]=0}function g(b){m(b,0)}function m(b,D){let z=s.newAttributes,F=s.enabledAttributes,$=s.attributeDivisors;z[b]=1,F[b]===0&&(n.enableVertexAttribArray(b),F[b]=1),$[b]!==D&&(n.vertexAttribDivisor(b,D),$[b]=D)}function v(){let b=s.newAttributes,D=s.enabledAttributes;for(let z=0,F=D.length;z<F;z++)D[z]!==b[z]&&(n.disableVertexAttribArray(z),D[z]=0)}function x(b,D,z,F,$,W,ne){ne===!0?n.vertexAttribIPointer(b,D,z,$,W):n.vertexAttribPointer(b,D,z,F,$,W)}function w(b,D,z,F){y();let $=F.attributes,W=z.getAttributes(),ne=D.defaultAttributeValues;for(let J in W){let V=W[J];if(V.location>=0){let ce=$[J];if(ce===void 0&&(J==="instanceMatrix"&&b.instanceMatrix&&(ce=b.instanceMatrix),J==="instanceColor"&&b.instanceColor&&(ce=b.instanceColor)),ce!==void 0){let fe=ce.normalized,Te=ce.itemSize,ve=e.get(ce);if(ve===void 0)continue;let He=ve.buffer,q=ve.type,Z=ve.bytesPerElement,ye=q===n.INT||q===n.UNSIGNED_INT||ce.gpuType===_p;if(ce.isInterleavedBufferAttribute){let ae=ce.data,Ie=ae.stride,Re=ce.offset;if(ae.isInstancedInterleavedBuffer){for(let B=0;B<V.locationSize;B++)m(V.location+B,ae.meshPerAttribute);b.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let B=0;B<V.locationSize;B++)g(V.location+B);n.bindBuffer(n.ARRAY_BUFFER,He);for(let B=0;B<V.locationSize;B++)x(V.location+B,Te/V.locationSize,q,fe,Ie*Z,(Re+Te/V.locationSize*B)*Z,ye)}else{if(ce.isInstancedBufferAttribute){for(let ae=0;ae<V.locationSize;ae++)m(V.location+ae,ce.meshPerAttribute);b.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=ce.meshPerAttribute*ce.count)}else for(let ae=0;ae<V.locationSize;ae++)g(V.location+ae);n.bindBuffer(n.ARRAY_BUFFER,He);for(let ae=0;ae<V.locationSize;ae++)x(V.location+ae,Te/V.locationSize,q,fe,Te*Z,Te/V.locationSize*ae*Z,ye)}}else if(ne!==void 0){let fe=ne[J];if(fe!==void 0)switch(fe.length){case 2:n.vertexAttrib2fv(V.location,fe);break;case 3:n.vertexAttrib3fv(V.location,fe);break;case 4:n.vertexAttrib4fv(V.location,fe);break;default:n.vertexAttrib1fv(V.location,fe)}}}}v()}function O(){U();for(let b in i){let D=i[b];for(let z in D){let F=D[z];for(let $ in F)u(F[$].object),delete F[$];delete D[z]}delete i[b]}}function I(b){if(i[b.id]===void 0)return;let D=i[b.id];for(let z in D){let F=D[z];for(let $ in F)u(F[$].object),delete F[$];delete D[z]}delete i[b.id]}function R(b){for(let D in i){let z=i[D];if(z[b.id]===void 0)continue;let F=z[b.id];for(let $ in F)u(F[$].object),delete F[$];delete z[b.id]}}function U(){_(),o=!0,s!==r&&(s=r,l(s.object))}function _(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:U,resetDefaultState:_,dispose:O,releaseStatesOfGeometry:I,releaseStatesOfProgram:R,initAttributes:y,enableAttribute:g,disableUnusedAttributes:v}}function MA(n,e,t){let i;function r(l){i=l}function s(l,u){n.drawArrays(i,l,u),t.update(u,i,1)}function o(l,u,d){d!==0&&(n.drawArraysInstanced(i,l,u,d),t.update(u,i,d))}function a(l,u,d){if(d===0)return;let h=e.get("WEBGL_multi_draw");if(h===null)for(let f=0;f<d;f++)this.render(l[f],u[f]);else{h.multiDrawArraysWEBGL(i,l,0,u,0,d);let f=0;for(let p=0;p<d;p++)f+=u[p];t.update(f,i,1)}}function c(l,u,d,h){if(d===0)return;let f=e.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<l.length;p++)o(l[p],u[p],h[p]);else{f.multiDrawArraysInstancedWEBGL(i,l,0,u,0,h,0,d);let p=0;for(let y=0;y<d;y++)p+=u[y];for(let y=0;y<h.length;y++)t.update(p,i,h[y])}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function SA(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let I=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(I.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(I){return!(I!==mn&&i.convert(I)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(I){let R=I===Ua&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(I!==Si&&i.convert(I)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&I!==Cn&&!R)}function c(I){if(I==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";I="mediump"}return I==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let d=t.logarithmicDepthBuffer===!0,h=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),f=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_TEXTURE_SIZE),y=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),m=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),v=n.getParameter(n.MAX_VARYING_VECTORS),x=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),w=f>0,O=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:y,maxAttributes:g,maxVertexUniforms:m,maxVaryings:v,maxFragmentUniforms:x,vertexTextures:w,maxSamples:O}}function EA(n){let e=this,t=null,i=0,r=!1,s=!1,o=new Gn,a=new Qe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){let p=d.clippingPlanes,y=d.clipIntersection,g=d.clipShadows,m=n.get(d);if(!r||p===null||p.length===0||s&&!g)s?u(null):l();else{let v=s?0:i,x=v*4,w=m.clippingState||null;c.value=w,w=u(p,h,x,f);for(let O=0;O!==x;++O)w[O]=t[O];m.clippingState=w,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=v}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){let y=d!==null?d.length:0,g=null;if(y!==0){if(g=c.value,p!==!0||g===null){let m=f+y*4,v=h.matrixWorldInverse;a.getNormalMatrix(v),(g===null||g.length<m)&&(g=new Float32Array(m));for(let x=0,w=f;x!==y;++x,w+=4)o.copy(d[x]).applyMatrix4(v,a),o.normal.toArray(g,w),g[w+3]=o.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}function AA(n){let e=new WeakMap;function t(o,a){return a===Xo?o.mapping=Mi:a===Yo&&(o.mapping=Yi),o}function i(o){if(o&&o.isTexture){let a=o.mapping;if(a===Xo||a===Yo)if(e.has(o)){let c=e.get(o).texture;return t(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new Tl(c.height);return l.fromEquirectangularTexture(n,o),e.set(o,l),o.addEventListener("dispose",r),t(l.texture,o.mapping)}else return null}}return o}function r(o){let a=o.target;a.removeEventListener("dispose",r);let c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}function TA(n){let e=[],t=[],i=[],r=n,s=n-Rs+1+Hg.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let c=1/a;o>n-Rs?c=Hg[o-n+Rs-1]:o===0&&(c=0),i.push(c);let l=1/(a-2),u=-l,d=1+l,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,y=3,g=2,m=1,v=new Float32Array(y*p*f),x=new Float32Array(g*p*f),w=new Float32Array(m*p*f);for(let I=0;I<f;I++){let R=I%3*2/3-1,U=I>2?0:-1,_=[R,U,0,R+2/3,U,0,R+2/3,U+1,0,R,U,0,R+2/3,U+1,0,R,U+1,0];v.set(_,y*p*I),x.set(h,g*p*I);let b=[I,I,I,I,I,I];w.set(b,m*p*I)}let O=new it;O.setAttribute("position",new ut(v,y)),O.setAttribute("uv",new ut(x,g)),O.setAttribute("faceIndex",new ut(w,m)),e.push(O),r>Rs&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Wg(n,e,t){let i=new yn(n,e,t);return i.texture.mapping=Ws,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Gc(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function IA(n,e,t){let i=new Float32Array(Ar),r=new P(0,1,0);return new xn({name:"SphericalGaussianBlur",defines:{n:Ar,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Pp(),fragmentShader:`
1
+ "use strict";var WorldOrbitEditor=(()=>{var Ju=Object.defineProperty;var lx=Object.getOwnPropertyDescriptor;var ux=Object.getOwnPropertyNames;var dx=Object.prototype.hasOwnProperty;var hx=(n,e)=>()=>(n&&(e=n(n=0)),e);var Xp=(n,e)=>{for(var t in e)Ju(n,t,{get:e[t],enumerable:!0})},fx=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ux(e))!dx.call(n,r)&&r!==t&&Ju(n,r,{get:()=>e[r],enumerable:!(i=lx(e,r))||i.enumerable});return n};var px=n=>fx(Ju({},"__esModule",{value:!0}),n);var Iv={};Xp(Iv,{ACESFilmicToneMapping:()=>O0,AddEquation:()=>ji,AddOperation:()=>R0,AdditiveAnimationBlendMode:()=>Ip,AdditiveBlending:()=>wh,AgXToneMapping:()=>N0,AlphaFormat:()=>$0,AlwaysCompare:()=>ov,AlwaysDepth:()=>S0,AlwaysStencilFunc:()=>Kh,AmbientLight:()=>Mu,AnimationAction:()=>Ou,AnimationClip:()=>$r,AnimationLoader:()=>Cf,AnimationMixer:()=>Wf,AnimationObjectGroup:()=>Gf,AnimationUtils:()=>XI,ArcCurve:()=>$l,ArrayCamera:()=>Il,ArrowHelper:()=>pp,AttachedBindMode:()=>Eh,Audio:()=>Lu,AudioAnalyser:()=>Hf,AudioContext:()=>Da,AudioListener:()=>Vf,AudioLoader:()=>Bf,AxesHelper:()=>mp,BackSide:()=>nn,BasicDepthPacking:()=>J0,BasicShadowMap:()=>ES,BatchedMesh:()=>Fl,Bone:()=>pa,BooleanKeyframeTrack:()=>Si,Box2:()=>tp,Box3:()=>zt,Box3Helper:()=>hp,BoxGeometry:()=>Dr,BoxHelper:()=>dp,BufferAttribute:()=>at,BufferGeometry:()=>tt,BufferGeometryLoader:()=>Ru,ByteType:()=>B0,Cache:()=>gi,Camera:()=>Vs,CameraHelper:()=>up,CanvasTexture:()=>Mf,CapsuleGeometry:()=>Yl,CatmullRomCurve3:()=>Hl,CineonToneMapping:()=>D0,CircleGeometry:()=>ql,ClampToEdgeWrapping:()=>Mn,Clock:()=>Pu,Color:()=>Ce,ColorKeyframeTrack:()=>Ca,ColorManagement:()=>ht,CompressedArrayTexture:()=>wf,CompressedCubeTexture:()=>Sf,CompressedTexture:()=>Gs,CompressedTextureLoader:()=>Rf,ConeGeometry:()=>Zl,ConstantAlphaFactor:()=>b0,ConstantColorFactor:()=>v0,CubeCamera:()=>Al,CubeReflectionMapping:()=>_i,CubeRefractionMapping:()=>Wi,CubeTexture:()=>Or,CubeTextureLoader:()=>Pf,CubeUVReflectionMapping:()=>Ys,CubicBezierCurve:()=>ga,CubicBezierCurve3:()=>jl,CubicInterpolant:()=>yu,CullFaceBack:()=>_h,CullFaceFront:()=>n0,CullFaceFrontBack:()=>MS,CullFaceNone:()=>t0,Curve:()=>gn,CurvePath:()=>Xl,CustomBlending:()=>r0,CustomToneMapping:()=>U0,CylinderGeometry:()=>Xs,Cylindrical:()=>ep,Data3DTexture:()=>oa,DataArrayTexture:()=>ks,DataTexture:()=>Wn,DataTextureLoader:()=>Lf,DataUtils:()=>LM,DecrementStencilOp:()=>NS,DecrementWrapStencilOp:()=>kS,DefaultLoadingManager:()=>Av,DepthFormat:()=>Rr,DepthStencilFormat:()=>Ns,DepthTexture:()=>ua,DetachedBindMode:()=>k0,DirectionalLight:()=>Su,DirectionalLightHelper:()=>lp,DiscreteInterpolant:()=>vu,DisplayP3ColorSpace:()=>Fu,DodecahedronGeometry:()=>Jl,DoubleSide:()=>Hn,DstAlphaFactor:()=>f0,DstColorFactor:()=>m0,DynamicCopyUsage:()=>QS,DynamicDrawUsage:()=>XS,DynamicReadUsage:()=>ZS,EdgesGeometry:()=>Kl,EllipseCurve:()=>Ws,EqualCompare:()=>nv,EqualDepth:()=>E0,EqualStencilFunc:()=>$S,EquirectangularReflectionMapping:()=>Xo,EquirectangularRefractionMapping:()=>Yo,Euler:()=>pn,EventDispatcher:()=>Nn,ExtrudeGeometry:()=>Ql,FileLoader:()=>Fn,Float16BufferAttribute:()=>cf,Float32BufferAttribute:()=>De,FloatType:()=>En,Fog:()=>Rl,FogExp2:()=>Cl,FramebufferTexture:()=>_f,FrontSide:()=>bi,Frustum:()=>Ur,GLBufferAttribute:()=>Zf,GLSL1:()=>tM,GLSL3:()=>Qh,GreaterCompare:()=>iv,GreaterDepth:()=>T0,GreaterEqualCompare:()=>sv,GreaterEqualDepth:()=>A0,GreaterEqualStencilFunc:()=>WS,GreaterStencilFunc:()=>jS,GridHelper:()=>ap,Group:()=>Gi,HalfFloatType:()=>Ua,HemisphereLight:()=>bu,HemisphereLightHelper:()=>op,IcosahedronGeometry:()=>eu,ImageBitmapLoader:()=>kf,ImageLoader:()=>Hr,ImageUtils:()=>Ml,IncrementStencilOp:()=>US,IncrementWrapStencilOp:()=>FS,InstancedBufferAttribute:()=>Yi,InstancedBufferGeometry:()=>Cu,InstancedInterleavedBuffer:()=>qf,InstancedMesh:()=>Nl,Int16BufferAttribute:()=>of,Int32BufferAttribute:()=>af,Int8BufferAttribute:()=>nf,IntType:()=>_p,InterleavedBuffer:()=>js,InterleavedBufferAttribute:()=>Nr,Interpolant:()=>Br,InterpolateDiscrete:()=>Jo,InterpolateLinear:()=>Ko,InterpolateSmooth:()=>_l,InvertStencilOp:()=>BS,KeepStencilOp:()=>Sr,KeyframeTrack:()=>yn,LOD:()=>Dl,LatheGeometry:()=>_a,Layers:()=>Bs,LessCompare:()=>tv,LessDepth:()=>M0,LessEqualCompare:()=>Cp,LessEqualDepth:()=>Wo,LessEqualStencilFunc:()=>HS,LessStencilFunc:()=>VS,Light:()=>Zn,LightProbe:()=>Tu,Line:()=>qn,Line3:()=>np,LineBasicMaterial:()=>Vt,LineCurve:()=>ya,LineCurve3:()=>Gl,LineDashedMaterial:()=>gu,LineLoop:()=>zl,LineSegments:()=>An,LinearDisplayP3ColorSpace:()=>Na,LinearFilter:()=>It,LinearInterpolant:()=>Ia,LinearMipMapLinearFilter:()=>CS,LinearMipMapNearestFilter:()=>IS,LinearMipmapLinearFilter:()=>jn,LinearMipmapNearestFilter:()=>Vo,LinearSRGBColorSpace:()=>Ei,LinearToneMapping:()=>P0,LinearTransfer:()=>ea,Loader:()=>Jt,LoaderUtils:()=>La,LoadingManager:()=>Ra,LoopOnce:()=>Y0,LoopPingPong:()=>Z0,LoopRepeat:()=>q0,LuminanceAlphaFormat:()=>G0,LuminanceFormat:()=>j0,MOUSE:()=>wS,Material:()=>kt,MaterialLoader:()=>Iu,MathUtils:()=>vM,Matrix3:()=>Je,Matrix4:()=>$e,MaxEquation:()=>c0,Mesh:()=>Mt,MeshBasicMaterial:()=>Yn,MeshDepthMaterial:()=>da,MeshDistanceMaterial:()=>ha,MeshLambertMaterial:()=>pu,MeshMatcapMaterial:()=>mu,MeshNormalMaterial:()=>fu,MeshPhongMaterial:()=>du,MeshPhysicalMaterial:()=>uu,MeshStandardMaterial:()=>Ta,MeshToonMaterial:()=>hu,MinEquation:()=>a0,MirroredRepeatWrapping:()=>Zo,MixOperation:()=>C0,MultiplyBlending:()=>Mh,MultiplyOperation:()=>Oa,NearestFilter:()=>Nt,NearestMipMapLinearFilter:()=>TS,NearestMipMapNearestFilter:()=>AS,NearestMipmapLinearFilter:()=>Rs,NearestMipmapNearestFilter:()=>xp,NeutralToneMapping:()=>F0,NeverCompare:()=>ev,NeverDepth:()=>w0,NeverStencilFunc:()=>zS,NoBlending:()=>yi,NoColorSpace:()=>hi,NoToneMapping:()=>vi,NormalAnimationBlendMode:()=>Nu,NormalBlending:()=>Cr,NotEqualCompare:()=>rv,NotEqualDepth:()=>I0,NotEqualStencilFunc:()=>GS,NumberKeyframeTrack:()=>zr,Object3D:()=>lt,ObjectLoader:()=>Ff,ObjectSpaceNormalMap:()=>Q0,OctahedronGeometry:()=>Ea,OneFactor:()=>u0,OneMinusConstantAlphaFactor:()=>_0,OneMinusConstantColorFactor:()=>x0,OneMinusDstAlphaFactor:()=>p0,OneMinusDstColorFactor:()=>g0,OneMinusSrcAlphaFactor:()=>Sl,OneMinusSrcColorFactor:()=>h0,OrthographicCamera:()=>Hs,P3Primaries:()=>na,PCFShadowMap:()=>vp,PCFSoftShadowMap:()=>i0,PMREMGenerator:()=>la,Path:()=>Fr,PerspectiveCamera:()=>Pt,Plane:()=>$n,PlaneGeometry:()=>$s,PlaneHelper:()=>fp,PointLight:()=>wu,PointLightHelper:()=>sp,Points:()=>Vl,PointsMaterial:()=>ma,PolarGridHelper:()=>cp,PolyhedronGeometry:()=>qi,PositionalAudio:()=>$f,PropertyBinding:()=>dt,PropertyMixer:()=>Du,QuadraticBezierCurve:()=>va,QuadraticBezierCurve3:()=>xa,Quaternion:()=>Zt,QuaternionKeyframeTrack:()=>Zi,QuaternionLinearInterpolant:()=>xu,RED_GREEN_RGTC2_Format:()=>Zh,RED_RGTC1_Format:()=>X0,REVISION:()=>_S,RGBADepthPacking:()=>K0,RGBAFormat:()=>dn,RGBAIntegerFormat:()=>Tp,RGBA_ASTC_10x10_Format:()=>jh,RGBA_ASTC_10x5_Format:()=>Vh,RGBA_ASTC_10x6_Format:()=>$h,RGBA_ASTC_10x8_Format:()=>Hh,RGBA_ASTC_12x10_Format:()=>Gh,RGBA_ASTC_12x12_Format:()=>Wh,RGBA_ASTC_4x4_Format:()=>Dh,RGBA_ASTC_5x4_Format:()=>Oh,RGBA_ASTC_5x5_Format:()=>Uh,RGBA_ASTC_6x5_Format:()=>Nh,RGBA_ASTC_6x6_Format:()=>Fh,RGBA_ASTC_8x5_Format:()=>kh,RGBA_ASTC_8x6_Format:()=>Bh,RGBA_ASTC_8x8_Format:()=>zh,RGBA_BPTC_Format:()=>bl,RGBA_ETC2_EAC_Format:()=>Lh,RGBA_PVRTC_2BPPV1_Format:()=>Ch,RGBA_PVRTC_4BPPV1_Format:()=>Ih,RGBA_S3TC_DXT1_Format:()=>yl,RGBA_S3TC_DXT3_Format:()=>vl,RGBA_S3TC_DXT5_Format:()=>xl,RGBFormat:()=>H0,RGB_BPTC_SIGNED_Format:()=>Xh,RGB_BPTC_UNSIGNED_Format:()=>Yh,RGB_ETC1_Format:()=>Rh,RGB_ETC2_Format:()=>Ph,RGB_PVRTC_2BPPV1_Format:()=>Th,RGB_PVRTC_4BPPV1_Format:()=>Ah,RGB_S3TC_DXT1_Format:()=>gl,RGFormat:()=>W0,RGIntegerFormat:()=>Ap,RawShaderMaterial:()=>lu,Ray:()=>Xi,Raycaster:()=>Jf,Rec709Primaries:()=>ta,RectAreaLight:()=>Eu,RedFormat:()=>Mp,RedIntegerFormat:()=>Ep,ReinhardToneMapping:()=>L0,RenderTarget:()=>El,RepeatWrapping:()=>qo,ReplaceStencilOp:()=>OS,ReverseSubtractEquation:()=>o0,RingGeometry:()=>tu,SIGNED_RED_GREEN_RGTC2_Format:()=>Jh,SIGNED_RED_RGTC1_Format:()=>qh,SRGBColorSpace:()=>Sn,SRGBTransfer:()=>vt,Scene:()=>Pl,ShaderChunk:()=>Qe,ShaderLib:()=>Un,ShaderMaterial:()=>mn,ShadowMaterial:()=>cu,Shape:()=>xi,ShapeGeometry:()=>nu,ShapePath:()=>gp,ShapeUtils:()=>Xn,ShortType:()=>z0,Skeleton:()=>Ul,SkeletonHelper:()=>rp,SkinnedMesh:()=>Ol,Source:()=>pi,Sphere:()=>Ft,SphereGeometry:()=>Aa,Spherical:()=>Qf,SphericalHarmonics3:()=>Au,SplineCurve:()=>ba,SpotLight:()=>_u,SpotLightHelper:()=>ip,Sprite:()=>Ll,SpriteMaterial:()=>fa,SrcAlphaFactor:()=>wl,SrcAlphaSaturateFactor:()=>y0,SrcColorFactor:()=>d0,StaticCopyUsage:()=>KS,StaticDrawUsage:()=>ia,StaticReadUsage:()=>qS,StereoCamera:()=>zf,StreamCopyUsage:()=>eM,StreamDrawUsage:()=>YS,StreamReadUsage:()=>JS,StringKeyframeTrack:()=>Mi,SubtractEquation:()=>s0,SubtractiveBlending:()=>Sh,TOUCH:()=>SS,TangentSpaceNormalMap:()=>Ji,TetrahedronGeometry:()=>iu,Texture:()=>Ct,TextureLoader:()=>Df,TorusGeometry:()=>ru,TorusKnotGeometry:()=>su,Triangle:()=>mi,TriangleFanDrawMode:()=>LS,TriangleStripDrawMode:()=>PS,TrianglesDrawMode:()=>RS,TubeGeometry:()=>ou,UVMapping:()=>Uu,Uint16BufferAttribute:()=>aa,Uint32BufferAttribute:()=>ca,Uint8BufferAttribute:()=>rf,Uint8ClampedBufferAttribute:()=>sf,Uniform:()=>Xf,UniformsGroup:()=>Yf,UniformsLib:()=>Ee,UniformsUtils:()=>hv,UnsignedByteType:()=>wi,UnsignedInt248Type:()=>qs,UnsignedInt5999Type:()=>V0,UnsignedIntType:()=>Lr,UnsignedShort4444Type:()=>wp,UnsignedShort5551Type:()=>Sp,UnsignedShortType:()=>bp,VSMShadowMap:()=>Vn,Vector2:()=>se,Vector3:()=>L,Vector4:()=>ft,VectorKeyframeTrack:()=>Vr,VideoTexture:()=>bf,WebGL3DRenderTarget:()=>tf,WebGLArrayRenderTarget:()=>ef,WebGLCoordinateSystem:()=>Gn,WebGLCubeRenderTarget:()=>Tl,WebGLMultipleRenderTargets:()=>yp,WebGLRenderTarget:()=>fn,WebGLRenderer:()=>yf,WebGLUtils:()=>xv,WebGPUCoordinateSystem:()=>ra,WireframeGeometry:()=>au,WrapAroundEnding:()=>Qo,ZeroCurvatureEnding:()=>Ar,ZeroFactor:()=>l0,ZeroSlopeEnding:()=>Tr,ZeroStencilOp:()=>DS,createCanvasElement:()=>cv});function hn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Xt[n&255]+Xt[n>>8&255]+Xt[n>>16&255]+Xt[n>>24&255]+"-"+Xt[e&255]+Xt[e>>8&255]+"-"+Xt[e>>16&15|64]+Xt[e>>24&255]+"-"+Xt[t&63|128]+Xt[t>>8&255]+"-"+Xt[t>>16&255]+Xt[t>>24&255]+Xt[i&255]+Xt[i>>8&255]+Xt[i>>16&255]+Xt[i>>24&255]).toLowerCase()}function St(n,e,t){return Math.max(e,Math.min(t,n))}function Rp(n,e){return(n%e+e)%e}function nM(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function iM(n,e,t){return n!==e?(t-n)/(e-n):0}function $o(n,e,t){return(1-t)*n+t*e}function rM(n,e,t,i){return $o(n,e,1-Math.exp(-t*i))}function sM(n,e=1){return e-Math.abs(Rp(n,e*2)-e)}function oM(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function aM(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function cM(n,e){return n+Math.floor(Math.random()*(e-n+1))}function lM(n,e){return n+Math.random()*(e-n)}function uM(n){return n*(.5-Math.random())}function dM(n){n!==void 0&&(Sg=n);let e=Sg+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function hM(n){return n*Pr}function fM(n){return n*Fs}function pM(n){return(n&n-1)===0&&n!==0}function mM(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function gM(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function yM(n,e,t,i,r){let s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+i)/2),u=o((e+i)/2),d=s((e-i)/2),h=o((e-i)/2),f=s((i-e)/2),p=o((i-e)/2);switch(r){case"XYX":n.set(a*u,c*d,c*h,a*l);break;case"YZY":n.set(c*h,a*u,c*d,a*l);break;case"ZXZ":n.set(c*d,c*h,a*u,a*l);break;case"XZX":n.set(a*u,c*p,c*f,a*l);break;case"YXY":n.set(c*f,a*u,c*p,a*l);break;case"ZYZ":n.set(c*p,c*f,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function tn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Ke(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}function av(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Ps(n,e){return new xM[n](e)}function sa(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function cv(){let n=sa("canvas");return n.style.display="block",n}function lv(n){n in Mg||(Mg[n]=!0,console.warn(n))}function Os(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function kd(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}function Bd(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Ml.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}function Vd(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){hr.fromArray(n,s);let a=r.x*Math.abs(hr.x)+r.y*Math.abs(hr.y)+r.z*Math.abs(hr.z),c=e.dot(hr),l=t.dot(hr),u=i.dot(hr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}function Jd(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function PM(){let n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(i[c]=0,i[c|256]=32768,r[c]=24,r[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,r[c]=-l-1,r[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,r[c]=13,r[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,r[c]=24,r[c|256]=24):(i[c]=31744,i[c|256]=64512,r[c]=13,r[c|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function on(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=St(n,-65504,65504),fi.floatView[0]=n;let e=fi.uint32View[0],t=e>>23&511;return fi.baseTable[t]+((e&8388607)>>fi.shiftTable[t])}function Bo(n){let e=n>>10;return fi.uint32View[0]=fi.mantissaTable[fi.offsetTable[e]+(n&1023)]+fi.exponentTable[e],fi.floatView[0]}function OM(n,e,t,i,r,s,o,a){let c;if(e.side===nn?c=i.intersectTriangle(o,s,r,!0,a):c=i.intersectTriangle(r,s,o,e.side===bi,a),c===null)return null;zc.copy(a),zc.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(zc);return l<t.near||l>t.far?null:{distance:l,point:zc.clone(),object:n}}function Vc(n,e,t,i,r,s,o,a,c,l){n.getVertexPosition(a,vs),n.getVertexPosition(c,xs),n.getVertexPosition(l,bs);let u=OM(n,e,t,i,vs,xs,bs,Bc);if(u){r&&(Nc.fromBufferAttribute(r,a),Fc.fromBufferAttribute(r,c),kc.fromBufferAttribute(r,l),u.uv=mi.getInterpolation(Bc,vs,xs,bs,Nc,Fc,kc,new se)),s&&(Nc.fromBufferAttribute(s,a),Fc.fromBufferAttribute(s,c),kc.fromBufferAttribute(s,l),u.uv1=mi.getInterpolation(Bc,vs,xs,bs,Nc,Fc,kc,new se)),o&&(kg.fromBufferAttribute(o,a),Bg.fromBufferAttribute(o,c),zg.fromBufferAttribute(o,l),u.normal=mi.getInterpolation(Bc,vs,xs,bs,kg,Bg,zg,new L),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new L,materialIndex:0};mi.getNormal(vs,xs,bs,d.normal),u.face=d}return u}function zs(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function en(n){let e={};for(let t=0;t<n.length;t++){let i=zs(n[t]);for(let r in i)e[r]=i[r]}return e}function UM(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function dv(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ht.workingColorSpace}function fv(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function zM(n){let e=new WeakMap;function t(a,c){let l=a.array,u=a.usage,d=l.byteLength,h=n.createBuffer();n.bindBuffer(c,h),n.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=n.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=n.SHORT;else if(l instanceof Uint32Array)f=n.UNSIGNED_INT;else if(l instanceof Int32Array)f=n.INT;else if(l instanceof Int8Array)f=n.BYTE;else if(l instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,c,l){let u=c.array,d=c._updateRange,h=c.updateRanges;if(n.bindBuffer(l,a),d.count===-1&&h.length===0&&n.bufferSubData(l,0,u),h.length!==0){for(let f=0,p=h.length;f<p;f++){let y=h[f];n.bufferSubData(l,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}c.clearUpdateRanges()}d.count!==-1&&(n.bufferSubData(l,d.offset*u.BYTES_PER_ELEMENT,u,d.offset,d.count),d.count=-1),c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(n.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isGLBufferAttribute){let u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}function _A(n,e,t,i,r,s,o){let a=new Ce(0),c=s===!0?0:1,l,u,d=null,h=0,f=null;function p(x){let v=x.isScene===!0?x.background:null;return v&&v.isTexture&&(v=(x.backgroundBlurriness>0?t:e).get(v)),v}function y(x){let v=!1,M=p(x);M===null?m(a,c):M&&M.isColor&&(m(M,1),v=!0);let U=n.xr.getEnvironmentBlendMode();U==="additive"?i.buffers.color.setClear(0,0,0,1,o):U==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil)}function g(x,v){let M=p(v);M&&(M.isCubeTexture||M.mapping===Ys)?(u===void 0&&(u=new Mt(new Dr(1,1,1),new mn({name:"BackgroundCubeMaterial",uniforms:zs(Un.backgroundCube.uniforms),vertexShader:Un.backgroundCube.vertexShader,fragmentShader:Un.backgroundCube.fragmentShader,side:nn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(U,C,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),mr.copy(v.backgroundRotation),mr.x*=-1,mr.y*=-1,mr.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(mr.y*=-1,mr.z*=-1),u.material.uniforms.envMap.value=M,u.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(bA.makeRotationFromEuler(mr)),u.material.toneMapped=ht.getTransfer(M.colorSpace)!==vt,(d!==M||h!==M.version||f!==n.toneMapping)&&(u.material.needsUpdate=!0,d=M,h=M.version,f=n.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new Mt(new $s(2,2),new mn({name:"BackgroundMaterial",uniforms:zs(Un.background.uniforms),vertexShader:Un.background.vertexShader,fragmentShader:Un.background.fragmentShader,side:bi,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=ht.getTransfer(M.colorSpace)!==vt,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(d!==M||h!==M.version||f!==n.toneMapping)&&(l.material.needsUpdate=!0,d=M,h=M.version,f=n.toneMapping),l.layers.enableAll(),x.unshift(l,l.geometry,l.material,0,0,null))}function m(x,v){x.getRGB(Hc,dv(n)),i.buffers.color.setClear(Hc.r,Hc.g,Hc.b,v,o)}return{getClearColor:function(){return a},setClearColor:function(x,v=1){a.set(x),c=v,m(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(x){c=x,m(a,c)},render:y,addToRenderList:g}}function wA(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(b,O,B,F,H){let X=!1,ee=d(F,B,O);s!==ee&&(s=ee,l(s.object)),X=f(b,F,B,H),X&&p(b,F,B,H),H!==null&&e.update(H,n.ELEMENT_ARRAY_BUFFER),(X||o)&&(o=!1,M(b,O,B,F),H!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function c(){return n.createVertexArray()}function l(b){return n.bindVertexArray(b)}function u(b){return n.deleteVertexArray(b)}function d(b,O,B){let F=B.wireframe===!0,H=i[b.id];H===void 0&&(H={},i[b.id]=H);let X=H[O.id];X===void 0&&(X={},H[O.id]=X);let ee=X[F];return ee===void 0&&(ee=h(c()),X[F]=ee),ee}function h(b){let O=[],B=[],F=[];for(let H=0;H<t;H++)O[H]=0,B[H]=0,F[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:B,attributeDivisors:F,object:b,attributes:{},index:null}}function f(b,O,B,F){let H=s.attributes,X=O.attributes,ee=0,ce=B.getAttributes();for(let k in ce)if(ce[k].location>=0){let he=H[k],Te=X[k];if(Te===void 0&&(k==="instanceMatrix"&&b.instanceMatrix&&(Te=b.instanceMatrix),k==="instanceColor"&&b.instanceColor&&(Te=b.instanceColor)),he===void 0||he.attribute!==Te||Te&&he.data!==Te.data)return!0;ee++}return s.attributesNum!==ee||s.index!==F}function p(b,O,B,F){let H={},X=O.attributes,ee=0,ce=B.getAttributes();for(let k in ce)if(ce[k].location>=0){let he=X[k];he===void 0&&(k==="instanceMatrix"&&b.instanceMatrix&&(he=b.instanceMatrix),k==="instanceColor"&&b.instanceColor&&(he=b.instanceColor));let Te={};Te.attribute=he,he&&he.data&&(Te.data=he.data),H[k]=Te,ee++}s.attributes=H,s.attributesNum=ee,s.index=F}function y(){let b=s.newAttributes;for(let O=0,B=b.length;O<B;O++)b[O]=0}function g(b){m(b,0)}function m(b,O){let B=s.newAttributes,F=s.enabledAttributes,H=s.attributeDivisors;B[b]=1,F[b]===0&&(n.enableVertexAttribArray(b),F[b]=1),H[b]!==O&&(n.vertexAttribDivisor(b,O),H[b]=O)}function x(){let b=s.newAttributes,O=s.enabledAttributes;for(let B=0,F=O.length;B<F;B++)O[B]!==b[B]&&(n.disableVertexAttribArray(B),O[B]=0)}function v(b,O,B,F,H,X,ee){ee===!0?n.vertexAttribIPointer(b,O,B,H,X):n.vertexAttribPointer(b,O,B,F,H,X)}function M(b,O,B,F){y();let H=F.attributes,X=B.getAttributes(),ee=O.defaultAttributeValues;for(let ce in X){let k=X[ce];if(k.location>=0){let le=H[ce];if(le===void 0&&(ce==="instanceMatrix"&&b.instanceMatrix&&(le=b.instanceMatrix),ce==="instanceColor"&&b.instanceColor&&(le=b.instanceColor)),le!==void 0){let he=le.normalized,Te=le.itemSize,ve=e.get(le);if(ve===void 0)continue;let He=ve.buffer,Z=ve.type,J=ve.bytesPerElement,ye=Z===n.INT||Z===n.UNSIGNED_INT||le.gpuType===_p;if(le.isInterleavedBufferAttribute){let oe=le.data,ze=oe.stride,xe=le.offset;if(oe.isInstancedInterleavedBuffer){for(let V=0;V<k.locationSize;V++)m(k.location+V,oe.meshPerAttribute);b.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let V=0;V<k.locationSize;V++)g(k.location+V);n.bindBuffer(n.ARRAY_BUFFER,He);for(let V=0;V<k.locationSize;V++)v(k.location+V,Te/k.locationSize,Z,he,ze*J,(xe+Te/k.locationSize*V)*J,ye)}else{if(le.isInstancedBufferAttribute){for(let oe=0;oe<k.locationSize;oe++)m(k.location+oe,le.meshPerAttribute);b.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let oe=0;oe<k.locationSize;oe++)g(k.location+oe);n.bindBuffer(n.ARRAY_BUFFER,He);for(let oe=0;oe<k.locationSize;oe++)v(k.location+oe,Te/k.locationSize,Z,he,Te*J,Te/k.locationSize*oe*J,ye)}}else if(ee!==void 0){let he=ee[ce];if(he!==void 0)switch(he.length){case 2:n.vertexAttrib2fv(k.location,he);break;case 3:n.vertexAttrib3fv(k.location,he);break;case 4:n.vertexAttrib4fv(k.location,he);break;default:n.vertexAttrib1fv(k.location,he)}}}}x()}function U(){N();for(let b in i){let O=i[b];for(let B in O){let F=O[B];for(let H in F)u(F[H].object),delete F[H];delete O[B]}delete i[b]}}function C(b){if(i[b.id]===void 0)return;let O=i[b.id];for(let B in O){let F=O[B];for(let H in F)u(F[H].object),delete F[H];delete O[B]}delete i[b.id]}function R(b){for(let O in i){let B=i[O];if(B[b.id]===void 0)continue;let F=B[b.id];for(let H in F)u(F[H].object),delete F[H];delete B[b.id]}}function N(){w(),o=!0,s!==r&&(s=r,l(s.object))}function w(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:N,resetDefaultState:w,dispose:U,releaseStatesOfGeometry:C,releaseStatesOfProgram:R,initAttributes:y,enableAttribute:g,disableUnusedAttributes:x}}function SA(n,e,t){let i;function r(l){i=l}function s(l,u){n.drawArrays(i,l,u),t.update(u,i,1)}function o(l,u,d){d!==0&&(n.drawArraysInstanced(i,l,u,d),t.update(u,i,d))}function a(l,u,d){if(d===0)return;let h=e.get("WEBGL_multi_draw");if(h===null)for(let f=0;f<d;f++)this.render(l[f],u[f]);else{h.multiDrawArraysWEBGL(i,l,0,u,0,d);let f=0;for(let p=0;p<d;p++)f+=u[p];t.update(f,i,1)}}function c(l,u,d,h){if(d===0)return;let f=e.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<l.length;p++)o(l[p],u[p],h[p]);else{f.multiDrawArraysInstancedWEBGL(i,l,0,u,0,h,0,d);let p=0;for(let y=0;y<d;y++)p+=u[y];for(let y=0;y<h.length;y++)t.update(p,i,h[y])}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function MA(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let C=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(C){return!(C!==dn&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(C){let R=C===Ua&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==wi&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==En&&!R)}function c(C){if(C==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let d=t.logarithmicDepthBuffer===!0,h=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),f=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_TEXTURE_SIZE),y=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),m=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),x=n.getParameter(n.MAX_VARYING_VECTORS),v=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),M=f>0,U=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:y,maxAttributes:g,maxVertexUniforms:m,maxVaryings:x,maxFragmentUniforms:v,vertexTextures:M,maxSamples:U}}function EA(n){let e=this,t=null,i=0,r=!1,s=!1,o=new $n,a=new Je,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){let p=d.clippingPlanes,y=d.clipIntersection,g=d.clipShadows,m=n.get(d);if(!r||p===null||p.length===0||s&&!g)s?u(null):l();else{let x=s?0:i,v=x*4,M=m.clippingState||null;c.value=M,M=u(p,h,v,f);for(let U=0;U!==v;++U)M[U]=t[U];m.clippingState=M,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=x}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){let y=d!==null?d.length:0,g=null;if(y!==0){if(g=c.value,p!==!0||g===null){let m=f+y*4,x=h.matrixWorldInverse;a.getNormalMatrix(x),(g===null||g.length<m)&&(g=new Float32Array(m));for(let v=0,M=f;v!==y;++v,M+=4)o.copy(d[v]).applyMatrix4(x,a),o.normal.toArray(g,M),g[M+3]=o.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}function AA(n){let e=new WeakMap;function t(o,a){return a===Xo?o.mapping=_i:a===Yo&&(o.mapping=Wi),o}function i(o){if(o&&o.isTexture){let a=o.mapping;if(a===Xo||a===Yo)if(e.has(o)){let c=e.get(o).texture;return t(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new Tl(c.height);return l.fromEquirectangularTexture(n,o),e.set(o,l),o.addEventListener("dispose",r),t(l.texture,o.mapping)}else return null}}return o}function r(o){let a=o.target;a.removeEventListener("dispose",r);let c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}function TA(n){let e=[],t=[],i=[],r=n,s=n-Ls+1+Hg.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let c=1/a;o>n-Ls?c=Hg[o-n+Ls-1]:o===0&&(c=0),i.push(c);let l=1/(a-2),u=-l,d=1+l,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,y=3,g=2,m=1,x=new Float32Array(y*p*f),v=new Float32Array(g*p*f),M=new Float32Array(m*p*f);for(let C=0;C<f;C++){let R=C%3*2/3-1,N=C>2?0:-1,w=[R,N,0,R+2/3,N,0,R+2/3,N+1,0,R,N,0,R+2/3,N+1,0,R,N+1,0];x.set(w,y*p*C),v.set(h,g*p*C);let b=[C,C,C,C,C,C];M.set(b,m*p*C)}let U=new tt;U.setAttribute("position",new at(x,y)),U.setAttribute("uv",new at(v,g)),U.setAttribute("faceIndex",new at(M,m)),e.push(U),r>Ls&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Wg(n,e,t){let i=new fn(n,e,t);return i.texture.mapping=Ys,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function jc(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function IA(n,e,t){let i=new Float32Array(Er),r=new L(0,1,0);return new mn({name:"SphericalGaussianBlur",defines:{n:Er,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Pp(),fragmentShader:`
2
2
 
3
3
  precision mediump float;
4
4
  precision mediump int;
@@ -58,7 +58,7 @@
58
58
  }
59
59
 
60
60
  }
61
- `,blending:xi,depthTest:!1,depthWrite:!1})}function Xg(){return new xn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Pp(),fragmentShader:`
61
+ `,blending:yi,depthTest:!1,depthWrite:!1})}function Xg(){return new mn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Pp(),fragmentShader:`
62
62
 
63
63
  precision mediump float;
64
64
  precision mediump int;
@@ -77,7 +77,7 @@
77
77
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
78
78
 
79
79
  }
80
- `,blending:xi,depthTest:!1,depthWrite:!1})}function Yg(){return new xn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Pp(),fragmentShader:`
80
+ `,blending:yi,depthTest:!1,depthWrite:!1})}function Yg(){return new mn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Pp(),fragmentShader:`
81
81
 
82
82
  precision mediump float;
83
83
  precision mediump int;
@@ -93,7 +93,7 @@
93
93
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
94
94
 
95
95
  }
96
- `,blending:xi,depthTest:!1,depthWrite:!1})}function Pp(){return`
96
+ `,blending:yi,depthTest:!1,depthWrite:!1})}function Pp(){return`
97
97
 
98
98
  precision mediump float;
99
99
  precision mediump int;
@@ -148,15 +148,15 @@
148
148
  gl_Position = vec4( position, 1.0 );
149
149
 
150
150
  }
151
- `}function CA(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let c=a.mapping,l=c===Xo||c===Yo,u=c===Mi||c===Yi;if(l||u){let d=e.get(a),h=d!==void 0?d.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==h)return t===null&&(t=new la(n)),d=l?t.fromEquirectangular(a,d):t.fromCubemap(a,d),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),d.texture;if(d!==void 0)return d.texture;{let f=a.image;return l&&f&&f.height>0||u&&f&&r(f)?(t===null&&(t=new la(n)),d=l?t.fromEquirectangular(a):t.fromCubemap(a),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),a.addEventListener("dispose",s),d.texture):null}}}return a}function r(a){let c=0,l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){let c=a.target;c.removeEventListener("dispose",s);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function RA(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let r=t(i);return r===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function PA(n,e,t,i){let r={},s=new WeakMap;function o(d){let h=d.target;h.index!==null&&e.remove(h.index);for(let p in h.attributes)e.remove(h.attributes[p]);for(let p in h.morphAttributes){let y=h.morphAttributes[p];for(let g=0,m=y.length;g<m;g++)e.remove(y[g])}h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);f&&(e.remove(f),s.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function a(d,h){return r[h.id]===!0||(h.addEventListener("dispose",o),r[h.id]=!0,t.memory.geometries++),h}function c(d){let h=d.attributes;for(let p in h)e.update(h[p],n.ARRAY_BUFFER);let f=d.morphAttributes;for(let p in f){let y=f[p];for(let g=0,m=y.length;g<m;g++)e.update(y[g],n.ARRAY_BUFFER)}}function l(d){let h=[],f=d.index,p=d.attributes.position,y=0;if(f!==null){let v=f.array;y=f.version;for(let x=0,w=v.length;x<w;x+=3){let O=v[x+0],I=v[x+1],R=v[x+2];h.push(O,I,I,R,R,O)}}else if(p!==void 0){let v=p.array;y=p.version;for(let x=0,w=v.length/3-1;x<w;x+=3){let O=x+0,I=x+1,R=x+2;h.push(O,I,I,R,R,O)}}else return;let g=new(av(h)?ca:aa)(h,1);g.version=y;let m=s.get(d);m&&e.remove(m),s.set(d,g)}function u(d){let h=s.get(d);if(h){let f=d.index;f!==null&&h.version<f.version&&l(d)}else l(d);return s.get(d)}return{get:a,update:c,getWireframeAttribute:u}}function LA(n,e,t){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function c(h,f){n.drawElements(i,f,s,h*o),t.update(f,i,1)}function l(h,f,p){p!==0&&(n.drawElementsInstanced(i,f,s,h*o,p),t.update(f,i,p))}function u(h,f,p){if(p===0)return;let y=e.get("WEBGL_multi_draw");if(y===null)for(let g=0;g<p;g++)this.render(h[g]/o,f[g]);else{y.multiDrawElementsWEBGL(i,f,0,s,h,0,p);let g=0;for(let m=0;m<p;m++)g+=f[m];t.update(g,i,1)}}function d(h,f,p,y){if(p===0)return;let g=e.get("WEBGL_multi_draw");if(g===null)for(let m=0;m<h.length;m++)l(h[m]/o,f[m],y[m]);else{g.multiDrawElementsInstancedWEBGL(i,f,0,s,h,0,y,0,p);let m=0;for(let v=0;v<p;v++)m+=f[v];for(let v=0;v<y.length;v++)t.update(m,i,y[v])}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=d}function DA(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(s/3);break;case n.LINES:t.lines+=a*(s/2);break;case n.LINE_STRIP:t.lines+=a*(s-1);break;case n.LINE_LOOP:t.lines+=a*s;break;case n.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function OA(n,e,t){let i=new WeakMap,r=new gt;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let b=function(){U.dispose(),i.delete(a),a.removeEventListener("dispose",b)};var f=b;h!==void 0&&h.texture.dispose();let p=a.morphAttributes.position!==void 0,y=a.morphAttributes.normal!==void 0,g=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],v=a.morphAttributes.normal||[],x=a.morphAttributes.color||[],w=0;p===!0&&(w=1),y===!0&&(w=2),g===!0&&(w=3);let O=a.attributes.position.count*w,I=1;O>e.maxTextureSize&&(I=Math.ceil(O/e.maxTextureSize),O=e.maxTextureSize);let R=new Float32Array(O*I*4*d),U=new Ns(R,O,I,d);U.type=Cn,U.needsUpdate=!0;let _=w*4;for(let D=0;D<d;D++){let z=m[D],F=v[D],$=x[D],W=O*I*4*D;for(let ne=0;ne<z.count;ne++){let J=ne*_;p===!0&&(r.fromBufferAttribute(z,ne),R[W+J+0]=r.x,R[W+J+1]=r.y,R[W+J+2]=r.z,R[W+J+3]=0),y===!0&&(r.fromBufferAttribute(F,ne),R[W+J+4]=r.x,R[W+J+5]=r.y,R[W+J+6]=r.z,R[W+J+7]=0),g===!0&&(r.fromBufferAttribute($,ne),R[W+J+8]=r.x,R[W+J+9]=r.y,R[W+J+10]=r.z,R[W+J+11]=$.itemSize===4?r.w:1)}}h={count:d,texture:U,size:new oe(O,I)},i.set(a,h),a.addEventListener("dispose",b)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let p=0;for(let g=0;g<l.length;g++)p+=l[g];let y=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(n,"morphTargetBaseInfluence",y),c.getUniforms().setValue(n,"morphTargetInfluences",l)}c.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),c.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:s}}function UA(n,e,t,i){let r=new WeakMap;function s(c){let l=i.render.frame,u=c.geometry,d=e.get(c,u);if(r.get(d)!==l&&(e.update(d),r.set(d,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){let h=c.skeleton;r.get(h)!==l&&(h.update(),r.set(h,l))}return d}function o(){r=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}function Ys(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=qg[r];if(s===void 0&&(s=new Float32Array(r),qg[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function Nt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Ft(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function ku(n,e){let t=Zg[e];t===void 0&&(t=new Int32Array(e),Zg[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function NA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function FA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Nt(t,e))return;n.uniform2fv(this.addr,e),Ft(t,e)}}function kA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Nt(t,e))return;n.uniform3fv(this.addr,e),Ft(t,e)}}function BA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Nt(t,e))return;n.uniform4fv(this.addr,e),Ft(t,e)}}function zA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Nt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Ft(t,e)}else{if(Nt(t,i))return;Qg.set(i),n.uniformMatrix2fv(this.addr,!1,Qg),Ft(t,i)}}function VA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Nt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Ft(t,e)}else{if(Nt(t,i))return;Kg.set(i),n.uniformMatrix3fv(this.addr,!1,Kg),Ft(t,i)}}function $A(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Nt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Ft(t,e)}else{if(Nt(t,i))return;Jg.set(i),n.uniformMatrix4fv(this.addr,!1,Jg),Ft(t,i)}}function HA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function GA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Nt(t,e))return;n.uniform2iv(this.addr,e),Ft(t,e)}}function jA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Nt(t,e))return;n.uniform3iv(this.addr,e),Ft(t,e)}}function WA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Nt(t,e))return;n.uniform4iv(this.addr,e),Ft(t,e)}}function XA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function YA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Nt(t,e))return;n.uniform2uiv(this.addr,e),Ft(t,e)}}function qA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Nt(t,e))return;n.uniform3uiv(this.addr,e),Ft(t,e)}}function ZA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Nt(t,e))return;n.uniform4uiv(this.addr,e),Ft(t,e)}}function JA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s=this.type===n.SAMPLER_2D_SHADOW?mv:pv;t.setTexture2D(e||s,r)}function KA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||yv,r)}function QA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||vv,r)}function eT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||gv,r)}function tT(n){switch(n){case 5126:return NA;case 35664:return FA;case 35665:return kA;case 35666:return BA;case 35674:return zA;case 35675:return VA;case 35676:return $A;case 5124:case 35670:return HA;case 35667:case 35671:return GA;case 35668:case 35672:return jA;case 35669:case 35673:return WA;case 5125:return XA;case 36294:return YA;case 36295:return qA;case 36296:return ZA;case 35678:case 36198:case 36298:case 36306:case 35682:return JA;case 35679:case 36299:case 36307:return KA;case 35680:case 36300:case 36308:case 36293:return QA;case 36289:case 36303:case 36311:case 36292:return eT}}function nT(n,e){n.uniform1fv(this.addr,e)}function iT(n,e){let t=Ys(e,this.size,2);n.uniform2fv(this.addr,t)}function rT(n,e){let t=Ys(e,this.size,3);n.uniform3fv(this.addr,t)}function sT(n,e){let t=Ys(e,this.size,4);n.uniform4fv(this.addr,t)}function oT(n,e){let t=Ys(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function aT(n,e){let t=Ys(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function cT(n,e){let t=Ys(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function lT(n,e){n.uniform1iv(this.addr,e)}function uT(n,e){n.uniform2iv(this.addr,e)}function dT(n,e){n.uniform3iv(this.addr,e)}function hT(n,e){n.uniform4iv(this.addr,e)}function fT(n,e){n.uniform1uiv(this.addr,e)}function pT(n,e){n.uniform2uiv(this.addr,e)}function mT(n,e){n.uniform3uiv(this.addr,e)}function gT(n,e){n.uniform4uiv(this.addr,e)}function yT(n,e,t){let i=this.cache,r=e.length,s=ku(t,r);Nt(i,s)||(n.uniform1iv(this.addr,s),Ft(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||pv,s[o])}function vT(n,e,t){let i=this.cache,r=e.length,s=ku(t,r);Nt(i,s)||(n.uniform1iv(this.addr,s),Ft(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||yv,s[o])}function xT(n,e,t){let i=this.cache,r=e.length,s=ku(t,r);Nt(i,s)||(n.uniform1iv(this.addr,s),Ft(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||vv,s[o])}function bT(n,e,t){let i=this.cache,r=e.length,s=ku(t,r);Nt(i,s)||(n.uniform1iv(this.addr,s),Ft(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||gv,s[o])}function _T(n){switch(n){case 5126:return nT;case 35664:return iT;case 35665:return rT;case 35666:return sT;case 35674:return oT;case 35675:return aT;case 35676:return cT;case 5124:case 35670:return lT;case 35667:case 35671:return uT;case 35668:case 35672:return dT;case 35669:case 35673:return hT;case 5125:return fT;case 36294:return pT;case 36295:return mT;case 36296:return gT;case 35678:case 36198:case 36298:case 36306:case 35682:return yT;case 35679:case 36299:case 36307:return vT;case 35680:case 36300:case 36308:case 36293:return xT;case 36289:case 36303:case 36311:case 36292:return bT}}function e0(n,e){n.seq.push(e),n.map[e.id]=e}function wT(n,e,t){let i=n.name,r=i.length;for(oh.lastIndex=0;;){let s=oh.exec(i),o=oh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){e0(t,l===void 0?new lf(a,n,e):new uf(a,n,e));break}else{let d=t.map[a];d===void 0&&(d=new df(a),e0(t,d)),t=d}}}function t0(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function ET(n,e){let t=n.split(`
151
+ `}function CA(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let c=a.mapping,l=c===Xo||c===Yo,u=c===_i||c===Wi;if(l||u){let d=e.get(a),h=d!==void 0?d.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==h)return t===null&&(t=new la(n)),d=l?t.fromEquirectangular(a,d):t.fromCubemap(a,d),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),d.texture;if(d!==void 0)return d.texture;{let f=a.image;return l&&f&&f.height>0||u&&f&&r(f)?(t===null&&(t=new la(n)),d=l?t.fromEquirectangular(a):t.fromCubemap(a),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),a.addEventListener("dispose",s),d.texture):null}}}return a}function r(a){let c=0,l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){let c=a.target;c.removeEventListener("dispose",s);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function RA(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let r=t(i);return r===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function PA(n,e,t,i){let r={},s=new WeakMap;function o(d){let h=d.target;h.index!==null&&e.remove(h.index);for(let p in h.attributes)e.remove(h.attributes[p]);for(let p in h.morphAttributes){let y=h.morphAttributes[p];for(let g=0,m=y.length;g<m;g++)e.remove(y[g])}h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);f&&(e.remove(f),s.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function a(d,h){return r[h.id]===!0||(h.addEventListener("dispose",o),r[h.id]=!0,t.memory.geometries++),h}function c(d){let h=d.attributes;for(let p in h)e.update(h[p],n.ARRAY_BUFFER);let f=d.morphAttributes;for(let p in f){let y=f[p];for(let g=0,m=y.length;g<m;g++)e.update(y[g],n.ARRAY_BUFFER)}}function l(d){let h=[],f=d.index,p=d.attributes.position,y=0;if(f!==null){let x=f.array;y=f.version;for(let v=0,M=x.length;v<M;v+=3){let U=x[v+0],C=x[v+1],R=x[v+2];h.push(U,C,C,R,R,U)}}else if(p!==void 0){let x=p.array;y=p.version;for(let v=0,M=x.length/3-1;v<M;v+=3){let U=v+0,C=v+1,R=v+2;h.push(U,C,C,R,R,U)}}else return;let g=new(av(h)?ca:aa)(h,1);g.version=y;let m=s.get(d);m&&e.remove(m),s.set(d,g)}function u(d){let h=s.get(d);if(h){let f=d.index;f!==null&&h.version<f.version&&l(d)}else l(d);return s.get(d)}return{get:a,update:c,getWireframeAttribute:u}}function LA(n,e,t){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function c(h,f){n.drawElements(i,f,s,h*o),t.update(f,i,1)}function l(h,f,p){p!==0&&(n.drawElementsInstanced(i,f,s,h*o,p),t.update(f,i,p))}function u(h,f,p){if(p===0)return;let y=e.get("WEBGL_multi_draw");if(y===null)for(let g=0;g<p;g++)this.render(h[g]/o,f[g]);else{y.multiDrawElementsWEBGL(i,f,0,s,h,0,p);let g=0;for(let m=0;m<p;m++)g+=f[m];t.update(g,i,1)}}function d(h,f,p,y){if(p===0)return;let g=e.get("WEBGL_multi_draw");if(g===null)for(let m=0;m<h.length;m++)l(h[m]/o,f[m],y[m]);else{g.multiDrawElementsInstancedWEBGL(i,f,0,s,h,0,y,0,p);let m=0;for(let x=0;x<p;x++)m+=f[x];for(let x=0;x<y.length;x++)t.update(m,i,y[x])}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=d}function DA(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(s/3);break;case n.LINES:t.lines+=a*(s/2);break;case n.LINE_STRIP:t.lines+=a*(s-1);break;case n.LINE_LOOP:t.lines+=a*s;break;case n.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function OA(n,e,t){let i=new WeakMap,r=new ft;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let b=function(){N.dispose(),i.delete(a),a.removeEventListener("dispose",b)};var f=b;h!==void 0&&h.texture.dispose();let p=a.morphAttributes.position!==void 0,y=a.morphAttributes.normal!==void 0,g=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],x=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],M=0;p===!0&&(M=1),y===!0&&(M=2),g===!0&&(M=3);let U=a.attributes.position.count*M,C=1;U>e.maxTextureSize&&(C=Math.ceil(U/e.maxTextureSize),U=e.maxTextureSize);let R=new Float32Array(U*C*4*d),N=new ks(R,U,C,d);N.type=En,N.needsUpdate=!0;let w=M*4;for(let O=0;O<d;O++){let B=m[O],F=x[O],H=v[O],X=U*C*4*O;for(let ee=0;ee<B.count;ee++){let ce=ee*w;p===!0&&(r.fromBufferAttribute(B,ee),R[X+ce+0]=r.x,R[X+ce+1]=r.y,R[X+ce+2]=r.z,R[X+ce+3]=0),y===!0&&(r.fromBufferAttribute(F,ee),R[X+ce+4]=r.x,R[X+ce+5]=r.y,R[X+ce+6]=r.z,R[X+ce+7]=0),g===!0&&(r.fromBufferAttribute(H,ee),R[X+ce+8]=r.x,R[X+ce+9]=r.y,R[X+ce+10]=r.z,R[X+ce+11]=H.itemSize===4?r.w:1)}}h={count:d,texture:N,size:new se(U,C)},i.set(a,h),a.addEventListener("dispose",b)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let p=0;for(let g=0;g<l.length;g++)p+=l[g];let y=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(n,"morphTargetBaseInfluence",y),c.getUniforms().setValue(n,"morphTargetInfluences",l)}c.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),c.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:s}}function UA(n,e,t,i){let r=new WeakMap;function s(c){let l=i.render.frame,u=c.geometry,d=e.get(c,u);if(r.get(d)!==l&&(e.update(d),r.set(d,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){let h=c.skeleton;r.get(h)!==l&&(h.update(),r.set(h,l))}return d}function o(){r=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}function Zs(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=qg[r];if(s===void 0&&(s=new Float32Array(r),qg[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function Lt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Dt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function ku(n,e){let t=Zg[e];t===void 0&&(t=new Int32Array(e),Zg[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function NA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function FA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Lt(t,e))return;n.uniform2fv(this.addr,e),Dt(t,e)}}function kA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Lt(t,e))return;n.uniform3fv(this.addr,e),Dt(t,e)}}function BA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Lt(t,e))return;n.uniform4fv(this.addr,e),Dt(t,e)}}function zA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Lt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Dt(t,e)}else{if(Lt(t,i))return;Qg.set(i),n.uniformMatrix2fv(this.addr,!1,Qg),Dt(t,i)}}function VA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Lt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Dt(t,e)}else{if(Lt(t,i))return;Kg.set(i),n.uniformMatrix3fv(this.addr,!1,Kg),Dt(t,i)}}function $A(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Lt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Dt(t,e)}else{if(Lt(t,i))return;Jg.set(i),n.uniformMatrix4fv(this.addr,!1,Jg),Dt(t,i)}}function HA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function jA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Lt(t,e))return;n.uniform2iv(this.addr,e),Dt(t,e)}}function GA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Lt(t,e))return;n.uniform3iv(this.addr,e),Dt(t,e)}}function WA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Lt(t,e))return;n.uniform4iv(this.addr,e),Dt(t,e)}}function XA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function YA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Lt(t,e))return;n.uniform2uiv(this.addr,e),Dt(t,e)}}function qA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Lt(t,e))return;n.uniform3uiv(this.addr,e),Dt(t,e)}}function ZA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Lt(t,e))return;n.uniform4uiv(this.addr,e),Dt(t,e)}}function JA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s=this.type===n.SAMPLER_2D_SHADOW?mv:pv;t.setTexture2D(e||s,r)}function KA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||yv,r)}function QA(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||vv,r)}function eT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||gv,r)}function tT(n){switch(n){case 5126:return NA;case 35664:return FA;case 35665:return kA;case 35666:return BA;case 35674:return zA;case 35675:return VA;case 35676:return $A;case 5124:case 35670:return HA;case 35667:case 35671:return jA;case 35668:case 35672:return GA;case 35669:case 35673:return WA;case 5125:return XA;case 36294:return YA;case 36295:return qA;case 36296:return ZA;case 35678:case 36198:case 36298:case 36306:case 35682:return JA;case 35679:case 36299:case 36307:return KA;case 35680:case 36300:case 36308:case 36293:return QA;case 36289:case 36303:case 36311:case 36292:return eT}}function nT(n,e){n.uniform1fv(this.addr,e)}function iT(n,e){let t=Zs(e,this.size,2);n.uniform2fv(this.addr,t)}function rT(n,e){let t=Zs(e,this.size,3);n.uniform3fv(this.addr,t)}function sT(n,e){let t=Zs(e,this.size,4);n.uniform4fv(this.addr,t)}function oT(n,e){let t=Zs(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function aT(n,e){let t=Zs(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function cT(n,e){let t=Zs(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function lT(n,e){n.uniform1iv(this.addr,e)}function uT(n,e){n.uniform2iv(this.addr,e)}function dT(n,e){n.uniform3iv(this.addr,e)}function hT(n,e){n.uniform4iv(this.addr,e)}function fT(n,e){n.uniform1uiv(this.addr,e)}function pT(n,e){n.uniform2uiv(this.addr,e)}function mT(n,e){n.uniform3uiv(this.addr,e)}function gT(n,e){n.uniform4uiv(this.addr,e)}function yT(n,e,t){let i=this.cache,r=e.length,s=ku(t,r);Lt(i,s)||(n.uniform1iv(this.addr,s),Dt(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||pv,s[o])}function vT(n,e,t){let i=this.cache,r=e.length,s=ku(t,r);Lt(i,s)||(n.uniform1iv(this.addr,s),Dt(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||yv,s[o])}function xT(n,e,t){let i=this.cache,r=e.length,s=ku(t,r);Lt(i,s)||(n.uniform1iv(this.addr,s),Dt(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||vv,s[o])}function bT(n,e,t){let i=this.cache,r=e.length,s=ku(t,r);Lt(i,s)||(n.uniform1iv(this.addr,s),Dt(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||gv,s[o])}function _T(n){switch(n){case 5126:return nT;case 35664:return iT;case 35665:return rT;case 35666:return sT;case 35674:return oT;case 35675:return aT;case 35676:return cT;case 5124:case 35670:return lT;case 35667:case 35671:return uT;case 35668:case 35672:return dT;case 35669:case 35673:return hT;case 5125:return fT;case 36294:return pT;case 36295:return mT;case 36296:return gT;case 35678:case 36198:case 36298:case 36306:case 35682:return yT;case 35679:case 36299:case 36307:return vT;case 35680:case 36300:case 36308:case 36293:return xT;case 36289:case 36303:case 36311:case 36292:return bT}}function ey(n,e){n.seq.push(e),n.map[e.id]=e}function wT(n,e,t){let i=n.name,r=i.length;for(oh.lastIndex=0;;){let s=oh.exec(i),o=oh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){ey(t,l===void 0?new lf(a,n,e):new uf(a,n,e));break}else{let d=t.map[a];d===void 0&&(d=new df(a),ey(t,d)),t=d}}}function ty(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function ET(n,e){let t=n.split(`
152
152
  `),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(`
153
- `)}function AT(n){let e=mt.getPrimaries(mt.workingColorSpace),t=mt.getPrimaries(n),i;switch(e===t?i="":e===na&&t===ta?i="LinearDisplayP3ToLinearSRGB":e===ta&&t===na&&(i="LinearSRGBToLinearDisplayP3"),n){case Ti:case Na:return[i,"LinearTransferOETF"];case Tn:case Fu:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function n0(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
153
+ `)}function AT(n){let e=ht.getPrimaries(ht.workingColorSpace),t=ht.getPrimaries(n),i;switch(e===t?i="":e===na&&t===ta?i="LinearDisplayP3ToLinearSRGB":e===ta&&t===na&&(i="LinearSRGBToLinearDisplayP3"),n){case Ei:case Na:return[i,"LinearTransferOETF"];case Sn:case Fu:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function ny(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
154
154
 
155
155
  `+r+`
156
156
 
157
- `+ET(n.getShaderSource(e),o)}else return r}function TT(n,e){let t=AT(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function IT(n,e){let t;switch(e){case Py:t="Linear";break;case Ly:t="Reinhard";break;case Dy:t="OptimizedCineon";break;case Oy:t="ACESFilmic";break;case Ny:t="AgX";break;case Fy:t="Neutral";break;case Uy:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function CT(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(zo).join(`
157
+ `+ET(n.getShaderSource(e),o)}else return r}function TT(n,e){let t=AT(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function IT(n,e){let t;switch(e){case P0:t="Linear";break;case L0:t="Reinhard";break;case D0:t="OptimizedCineon";break;case O0:t="ACESFilmic";break;case N0:t="AgX";break;case F0:t="Neutral";break;case U0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function CT(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(zo).join(`
158
158
  `)}function RT(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
159
- `)}function PT(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=n.getActiveAttrib(e,r),o=s.name,a=1;s.type===n.FLOAT_MAT2&&(a=2),s.type===n.FLOAT_MAT3&&(a=3),s.type===n.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function zo(n){return n!==""}function i0(n,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function r0(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function hf(n){return n.replace(LT,OT)}function OT(n,e){let t=tt[e];if(t===void 0){let i=DT.get(e);if(i!==void 0)t=tt[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return hf(t)}function s0(n){return n.replace(UT,NT)}function NT(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function o0(n){let e=`precision ${n.precision} float;
159
+ `)}function PT(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=n.getActiveAttrib(e,r),o=s.name,a=1;s.type===n.FLOAT_MAT2&&(a=2),s.type===n.FLOAT_MAT3&&(a=3),s.type===n.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function zo(n){return n!==""}function iy(n,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function ry(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function hf(n){return n.replace(LT,OT)}function OT(n,e){let t=Qe[e];if(t===void 0){let i=DT.get(e);if(i!==void 0)t=Qe[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return hf(t)}function sy(n){return n.replace(UT,NT)}function NT(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function oy(n){let e=`precision ${n.precision} float;
160
160
  precision ${n.precision} int;
161
161
  precision ${n.precision} sampler2D;
162
162
  precision ${n.precision} samplerCube;
@@ -176,32 +176,32 @@
176
176
  `;return n.precision==="highp"?e+=`
177
177
  #define HIGH_PRECISION`:n.precision==="mediump"?e+=`
178
178
  #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
179
- #define LOW_PRECISION`),e}function FT(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===vp?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===iy?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Hn&&(e="SHADOWMAP_TYPE_VSM"),e}function kT(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case Mi:case Yi:e="ENVMAP_TYPE_CUBE";break;case Ws:e="ENVMAP_TYPE_CUBE_UV";break}return e}function BT(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===Yi&&(e="ENVMAP_MODE_REFRACTION"),e}function zT(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case Oa:e="ENVMAP_BLENDING_MULTIPLY";break;case Cy:e="ENVMAP_BLENDING_MIX";break;case Ry:e="ENVMAP_BLENDING_ADD";break}return e}function VT(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function $T(n,e,t,i){let r=n.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,c=FT(t),l=kT(t),u=BT(t),d=zT(t),h=VT(t),f=CT(t),p=RT(s),y=r.createProgram(),g,m,v=t.glslVersion?"#version "+t.glslVersion+`
179
+ #define LOW_PRECISION`),e}function FT(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===vp?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===i0?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Vn&&(e="SHADOWMAP_TYPE_VSM"),e}function kT(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case _i:case Wi:e="ENVMAP_TYPE_CUBE";break;case Ys:e="ENVMAP_TYPE_CUBE_UV";break}return e}function BT(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===Wi&&(e="ENVMAP_MODE_REFRACTION"),e}function zT(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case Oa:e="ENVMAP_BLENDING_MULTIPLY";break;case C0:e="ENVMAP_BLENDING_MIX";break;case R0:e="ENVMAP_BLENDING_ADD";break}return e}function VT(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function $T(n,e,t,i){let r=n.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,c=FT(t),l=kT(t),u=BT(t),d=zT(t),h=VT(t),f=CT(t),p=RT(s),y=r.createProgram(),g,m,x=t.glslVersion?"#version "+t.glslVersion+`
180
180
  `:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(zo).join(`
181
181
  `),g.length>0&&(g+=`
182
182
  `),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(zo).join(`
183
183
  `),m.length>0&&(m+=`
184
- `)):(g=[o0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
184
+ `)):(g=[oy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
185
185
  `].filter(zo).join(`
186
- `),m=[o0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==bi?"#define TONE_MAPPING":"",t.toneMapping!==bi?tt.tonemapping_pars_fragment:"",t.toneMapping!==bi?IT("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",tt.colorspace_pars_fragment,TT("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
186
+ `),m=[oy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==vi?"#define TONE_MAPPING":"",t.toneMapping!==vi?Qe.tonemapping_pars_fragment:"",t.toneMapping!==vi?IT("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Qe.colorspace_pars_fragment,TT("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
187
187
  `].filter(zo).join(`
188
- `)),o=hf(o),o=i0(o,t),o=r0(o,t),a=hf(a),a=i0(a,t),a=r0(a,t),o=s0(o),a=s0(a),t.isRawShaderMaterial!==!0&&(v=`#version 300 es
188
+ `)),o=hf(o),o=iy(o,t),o=ry(o,t),a=hf(a),a=iy(a,t),a=ry(a,t),o=sy(o),a=sy(a),t.isRawShaderMaterial!==!0&&(x=`#version 300 es
189
189
  `,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
190
190
  `)+`
191
191
  `+g,m=["#define varying in",t.glslVersion===Qh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Qh?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
192
192
  `)+`
193
- `+m);let x=v+g+o,w=v+m+a,O=t0(r,r.VERTEX_SHADER,x),I=t0(r,r.FRAGMENT_SHADER,w);r.attachShader(y,O),r.attachShader(y,I),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function R(D){if(n.debug.checkShaderErrors){let z=r.getProgramInfoLog(y).trim(),F=r.getShaderInfoLog(O).trim(),$=r.getShaderInfoLog(I).trim(),W=!0,ne=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(W=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,O,I);else{let J=n0(r,O,"vertex"),V=n0(r,I,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
193
+ `+m);let v=x+g+o,M=x+m+a,U=ty(r,r.VERTEX_SHADER,v),C=ty(r,r.FRAGMENT_SHADER,M);r.attachShader(y,U),r.attachShader(y,C),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function R(O){if(n.debug.checkShaderErrors){let B=r.getProgramInfoLog(y).trim(),F=r.getShaderInfoLog(U).trim(),H=r.getShaderInfoLog(C).trim(),X=!0,ee=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(X=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,U,C);else{let ce=ny(r,U,"vertex"),k=ny(r,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
194
194
 
195
- Material Name: `+D.name+`
196
- Material Type: `+D.type+`
195
+ Material Name: `+O.name+`
196
+ Material Type: `+O.type+`
197
197
 
198
- Program Info Log: `+z+`
199
- `+J+`
200
- `+V)}else z!==""?console.warn("THREE.WebGLProgram: Program Info Log:",z):(F===""||$==="")&&(ne=!1);ne&&(D.diagnostics={runnable:W,programLog:z,vertexShader:{log:F,prefix:g},fragmentShader:{log:$,prefix:m}})}r.deleteShader(O),r.deleteShader(I),U=new Ds(r,y),_=PT(r,y)}let U;this.getUniforms=function(){return U===void 0&&R(this),U};let _;this.getAttributes=function(){return _===void 0&&R(this),_};let b=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=r.getProgramParameter(y,MT)),b},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=ST++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=O,this.fragmentShader=I,this}function GT(n,e,t,i,r,s,o){let a=new Fs,c=new ff,l=new Set,u=[],d=r.logarithmicDepthBuffer,h=r.vertexTextures,f=r.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(_){return l.add(_),_===0?"uv":`uv${_}`}function g(_,b,D,z,F){let $=z.fog,W=F.geometry,ne=_.isMeshStandardMaterial?z.environment:null,J=(_.isMeshStandardMaterial?t:e).get(_.envMap||ne),V=J&&J.mapping===Ws?J.image.height:null,ce=p[_.type];_.precision!==null&&(f=r.getMaxPrecision(_.precision),f!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",f,"instead."));let fe=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Te=fe!==void 0?fe.length:0,ve=0;W.morphAttributes.position!==void 0&&(ve=1),W.morphAttributes.normal!==void 0&&(ve=2),W.morphAttributes.color!==void 0&&(ve=3);let He,q,Z,ye;if(ce){let ot=kn[ce];He=ot.vertexShader,q=ot.fragmentShader}else He=_.vertexShader,q=_.fragmentShader,c.update(_),Z=c.getVertexShaderID(_),ye=c.getFragmentShaderID(_);let ae=n.getRenderTarget(),Ie=F.isInstancedMesh===!0,Re=F.isBatchedMesh===!0,B=!!_.map,Je=!!_.matcap,X=!!J,he=!!_.aoMap,Q=!!_.lightMap,me=!!_.bumpMap,K=!!_.normalMap,we=!!_.displacementMap,De=!!_.emissiveMap,L=!!_.metalnessMap,E=!!_.roughnessMap,H=_.anisotropy>0,te=_.clearcoat>0,le=_.dispersion>0,re=_.iridescence>0,Ue=_.sheen>0,xe=_.transmission>0,be=H&&!!_.anisotropyMap,Ve=te&&!!_.clearcoatMap,pe=te&&!!_.clearcoatNormalMap,Oe=te&&!!_.clearcoatRoughnessMap,Ge=re&&!!_.iridescenceMap,Ne=re&&!!_.iridescenceThicknessMap,Me=Ue&&!!_.sheenColorMap,Ye=Ue&&!!_.sheenRoughnessMap,nt=!!_.specularMap,yt=!!_.specularColorMap,je=!!_.specularIntensityMap,k=xe&&!!_.transmissionMap,ue=xe&&!!_.thicknessMap,ee=!!_.gradientMap,de=!!_.alphaMap,Se=_.alphaTest>0,rt=!!_.alphaHash,at=!!_.extensions,vt=bi;_.toneMapped&&(ae===null||ae.isXRRenderTarget===!0)&&(vt=n.toneMapping);let Et={shaderID:ce,shaderType:_.type,shaderName:_.name,vertexShader:He,fragmentShader:q,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:ye,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:f,batching:Re,instancing:Ie,instancingColor:Ie&&F.instanceColor!==null,instancingMorph:Ie&&F.morphTexture!==null,supportsVertexTextures:h,outputColorSpace:ae===null?n.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:Ti,alphaToCoverage:!!_.alphaToCoverage,map:B,matcap:Je,envMap:X,envMapMode:X&&J.mapping,envMapCubeUVHeight:V,aoMap:he,lightMap:Q,bumpMap:me,normalMap:K,displacementMap:h&&we,emissiveMap:De,normalMapObjectSpace:K&&_.normalMapType===Qy,normalMapTangentSpace:K&&_.normalMapType===Qi,metalnessMap:L,roughnessMap:E,anisotropy:H,anisotropyMap:be,clearcoat:te,clearcoatMap:Ve,clearcoatNormalMap:pe,clearcoatRoughnessMap:Oe,dispersion:le,iridescence:re,iridescenceMap:Ge,iridescenceThicknessMap:Ne,sheen:Ue,sheenColorMap:Me,sheenRoughnessMap:Ye,specularMap:nt,specularColorMap:yt,specularIntensityMap:je,transmission:xe,transmissionMap:k,thicknessMap:ue,gradientMap:ee,opaque:_.transparent===!1&&_.blending===Rr&&_.alphaToCoverage===!1,alphaMap:de,alphaTest:Se,alphaHash:rt,combine:_.combine,mapUv:B&&y(_.map.channel),aoMapUv:he&&y(_.aoMap.channel),lightMapUv:Q&&y(_.lightMap.channel),bumpMapUv:me&&y(_.bumpMap.channel),normalMapUv:K&&y(_.normalMap.channel),displacementMapUv:we&&y(_.displacementMap.channel),emissiveMapUv:De&&y(_.emissiveMap.channel),metalnessMapUv:L&&y(_.metalnessMap.channel),roughnessMapUv:E&&y(_.roughnessMap.channel),anisotropyMapUv:be&&y(_.anisotropyMap.channel),clearcoatMapUv:Ve&&y(_.clearcoatMap.channel),clearcoatNormalMapUv:pe&&y(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Oe&&y(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Ge&&y(_.iridescenceMap.channel),iridescenceThicknessMapUv:Ne&&y(_.iridescenceThicknessMap.channel),sheenColorMapUv:Me&&y(_.sheenColorMap.channel),sheenRoughnessMapUv:Ye&&y(_.sheenRoughnessMap.channel),specularMapUv:nt&&y(_.specularMap.channel),specularColorMapUv:yt&&y(_.specularColorMap.channel),specularIntensityMapUv:je&&y(_.specularIntensityMap.channel),transmissionMapUv:k&&y(_.transmissionMap.channel),thicknessMapUv:ue&&y(_.thicknessMap.channel),alphaMapUv:de&&y(_.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(K||H),vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!W.attributes.uv&&(B||de),fog:!!$,useFog:_.fog===!0,fogExp2:!!$&&$.isFogExp2,flatShading:_.flatShading===!0,sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:F.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:Te,morphTextureStride:ve,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:_.dithering,shadowMapEnabled:n.shadowMap.enabled&&D.length>0,shadowMapType:n.shadowMap.type,toneMapping:vt,useLegacyLights:n._useLegacyLights,decodeVideoTexture:B&&_.map.isVideoTexture===!0&&mt.getTransfer(_.map.colorSpace)===wt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===jn,flipSided:_.side===on,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:at&&_.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:at&&_.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Et.vertexUv1s=l.has(1),Et.vertexUv2s=l.has(2),Et.vertexUv3s=l.has(3),l.clear(),Et}function m(_){let b=[];if(_.shaderID?b.push(_.shaderID):(b.push(_.customVertexShaderID),b.push(_.customFragmentShaderID)),_.defines!==void 0)for(let D in _.defines)b.push(D),b.push(_.defines[D]);return _.isRawShaderMaterial===!1&&(v(b,_),x(b,_),b.push(n.outputColorSpace)),b.push(_.customProgramCacheKey),b.join()}function v(_,b){_.push(b.precision),_.push(b.outputColorSpace),_.push(b.envMapMode),_.push(b.envMapCubeUVHeight),_.push(b.mapUv),_.push(b.alphaMapUv),_.push(b.lightMapUv),_.push(b.aoMapUv),_.push(b.bumpMapUv),_.push(b.normalMapUv),_.push(b.displacementMapUv),_.push(b.emissiveMapUv),_.push(b.metalnessMapUv),_.push(b.roughnessMapUv),_.push(b.anisotropyMapUv),_.push(b.clearcoatMapUv),_.push(b.clearcoatNormalMapUv),_.push(b.clearcoatRoughnessMapUv),_.push(b.iridescenceMapUv),_.push(b.iridescenceThicknessMapUv),_.push(b.sheenColorMapUv),_.push(b.sheenRoughnessMapUv),_.push(b.specularMapUv),_.push(b.specularColorMapUv),_.push(b.specularIntensityMapUv),_.push(b.transmissionMapUv),_.push(b.thicknessMapUv),_.push(b.combine),_.push(b.fogExp2),_.push(b.sizeAttenuation),_.push(b.morphTargetsCount),_.push(b.morphAttributeCount),_.push(b.numDirLights),_.push(b.numPointLights),_.push(b.numSpotLights),_.push(b.numSpotLightMaps),_.push(b.numHemiLights),_.push(b.numRectAreaLights),_.push(b.numDirLightShadows),_.push(b.numPointLightShadows),_.push(b.numSpotLightShadows),_.push(b.numSpotLightShadowsWithMaps),_.push(b.numLightProbes),_.push(b.shadowMapType),_.push(b.toneMapping),_.push(b.numClippingPlanes),_.push(b.numClipIntersection),_.push(b.depthPacking)}function x(_,b){a.disableAll(),b.supportsVertexTextures&&a.enable(0),b.instancing&&a.enable(1),b.instancingColor&&a.enable(2),b.instancingMorph&&a.enable(3),b.matcap&&a.enable(4),b.envMap&&a.enable(5),b.normalMapObjectSpace&&a.enable(6),b.normalMapTangentSpace&&a.enable(7),b.clearcoat&&a.enable(8),b.iridescence&&a.enable(9),b.alphaTest&&a.enable(10),b.vertexColors&&a.enable(11),b.vertexAlphas&&a.enable(12),b.vertexUv1s&&a.enable(13),b.vertexUv2s&&a.enable(14),b.vertexUv3s&&a.enable(15),b.vertexTangents&&a.enable(16),b.anisotropy&&a.enable(17),b.alphaHash&&a.enable(18),b.batching&&a.enable(19),b.dispersion&&a.enable(20),_.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.skinning&&a.enable(4),b.morphTargets&&a.enable(5),b.morphNormals&&a.enable(6),b.morphColors&&a.enable(7),b.premultipliedAlpha&&a.enable(8),b.shadowMapEnabled&&a.enable(9),b.useLegacyLights&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.alphaToCoverage&&a.enable(20),_.push(a.mask)}function w(_){let b=p[_.type],D;if(b){let z=kn[b];D=hv.clone(z.uniforms)}else D=_.uniforms;return D}function O(_,b){let D;for(let z=0,F=u.length;z<F;z++){let $=u[z];if($.cacheKey===b){D=$,++D.usedTimes;break}}return D===void 0&&(D=new $T(n,b,_,s),u.push(D)),D}function I(_){if(--_.usedTimes===0){let b=u.indexOf(_);u[b]=u[u.length-1],u.pop(),_.destroy()}}function R(_){c.remove(_)}function U(){c.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:w,acquireProgram:O,releaseProgram:I,releaseShaderCache:R,programs:u,dispose:U}}function jT(){let n=new WeakMap;function e(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function t(s){n.delete(s)}function i(s,o,a){n.get(s)[o]=a}function r(){n=new WeakMap}return{get:e,remove:t,update:i,dispose:r}}function WT(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function a0(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function c0(){let n=[],e=0,t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function o(d,h,f,p,y,g){let m=n[e];return m===void 0?(m={id:d.id,object:d,geometry:h,material:f,groupOrder:p,renderOrder:d.renderOrder,z:y,group:g},n[e]=m):(m.id=d.id,m.object=d,m.geometry=h,m.material=f,m.groupOrder=p,m.renderOrder=d.renderOrder,m.z=y,m.group=g),e++,m}function a(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.push(m):f.transparent===!0?r.push(m):t.push(m)}function c(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.unshift(m):f.transparent===!0?r.unshift(m):t.unshift(m)}function l(d,h){t.length>1&&t.sort(d||WT),i.length>1&&i.sort(h||a0),r.length>1&&r.sort(h||a0)}function u(){for(let d=e,h=n.length;d<h;d++){let f=n[d];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function XT(){let n=new WeakMap;function e(i,r){let s=n.get(i),o;return s===void 0?(o=new c0,n.set(i,[o])):r>=s.length?(o=new c0,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function YT(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new Ce};break;case"SpotLight":t={position:new P,direction:new P,color:new Ce,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new Ce,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new Ce,groundColor:new Ce};break;case"RectAreaLight":t={color:new Ce,position:new P,halfWidth:new P,halfHeight:new P};break}return n[e.id]=t,t}}}function qT(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}function JT(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function KT(n){let e=new YT,t=qT(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new P);let r=new P,s=new ze,o=new ze;function a(l,u){let d=0,h=0,f=0;for(let D=0;D<9;D++)i.probe[D].set(0,0,0);let p=0,y=0,g=0,m=0,v=0,x=0,w=0,O=0,I=0,R=0,U=0;l.sort(JT);let _=u===!0?Math.PI:1;for(let D=0,z=l.length;D<z;D++){let F=l[D],$=F.color,W=F.intensity,ne=F.distance,J=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=$.r*W*_,h+=$.g*W*_,f+=$.b*W*_;else if(F.isLightProbe){for(let V=0;V<9;V++)i.probe[V].addScaledVector(F.sh.coefficients[V],W);U++}else if(F.isDirectionalLight){let V=e.get(F);if(V.color.copy(F.color).multiplyScalar(F.intensity*_),F.castShadow){let ce=F.shadow,fe=t.get(F);fe.shadowBias=ce.bias,fe.shadowNormalBias=ce.normalBias,fe.shadowRadius=ce.radius,fe.shadowMapSize=ce.mapSize,i.directionalShadow[p]=fe,i.directionalShadowMap[p]=J,i.directionalShadowMatrix[p]=F.shadow.matrix,x++}i.directional[p]=V,p++}else if(F.isSpotLight){let V=e.get(F);V.position.setFromMatrixPosition(F.matrixWorld),V.color.copy($).multiplyScalar(W*_),V.distance=ne,V.coneCos=Math.cos(F.angle),V.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),V.decay=F.decay,i.spot[g]=V;let ce=F.shadow;if(F.map&&(i.spotLightMap[I]=F.map,I++,ce.updateMatrices(F),F.castShadow&&R++),i.spotLightMatrix[g]=ce.matrix,F.castShadow){let fe=t.get(F);fe.shadowBias=ce.bias,fe.shadowNormalBias=ce.normalBias,fe.shadowRadius=ce.radius,fe.shadowMapSize=ce.mapSize,i.spotShadow[g]=fe,i.spotShadowMap[g]=J,O++}g++}else if(F.isRectAreaLight){let V=e.get(F);V.color.copy($).multiplyScalar(W),V.halfWidth.set(F.width*.5,0,0),V.halfHeight.set(0,F.height*.5,0),i.rectArea[m]=V,m++}else if(F.isPointLight){let V=e.get(F);if(V.color.copy(F.color).multiplyScalar(F.intensity*_),V.distance=F.distance,V.decay=F.decay,F.castShadow){let ce=F.shadow,fe=t.get(F);fe.shadowBias=ce.bias,fe.shadowNormalBias=ce.normalBias,fe.shadowRadius=ce.radius,fe.shadowMapSize=ce.mapSize,fe.shadowCameraNear=ce.camera.near,fe.shadowCameraFar=ce.camera.far,i.pointShadow[y]=fe,i.pointShadowMap[y]=J,i.pointShadowMatrix[y]=F.shadow.matrix,w++}i.point[y]=V,y++}else if(F.isHemisphereLight){let V=e.get(F);V.skyColor.copy(F.color).multiplyScalar(W*_),V.groundColor.copy(F.groundColor).multiplyScalar(W*_),i.hemi[v]=V,v++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ee.LTC_FLOAT_1,i.rectAreaLTC2=Ee.LTC_FLOAT_2):(i.rectAreaLTC1=Ee.LTC_HALF_1,i.rectAreaLTC2=Ee.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=h,i.ambient[2]=f;let b=i.hash;(b.directionalLength!==p||b.pointLength!==y||b.spotLength!==g||b.rectAreaLength!==m||b.hemiLength!==v||b.numDirectionalShadows!==x||b.numPointShadows!==w||b.numSpotShadows!==O||b.numSpotMaps!==I||b.numLightProbes!==U)&&(i.directional.length=p,i.spot.length=g,i.rectArea.length=m,i.point.length=y,i.hemi.length=v,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=O,i.spotShadowMap.length=O,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=O+I-R,i.spotLightMap.length=I,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=U,b.directionalLength=p,b.pointLength=y,b.spotLength=g,b.rectAreaLength=m,b.hemiLength=v,b.numDirectionalShadows=x,b.numPointShadows=w,b.numSpotShadows=O,b.numSpotMaps=I,b.numLightProbes=U,i.version=ZT++)}function c(l,u){let d=0,h=0,f=0,p=0,y=0,g=u.matrixWorldInverse;for(let m=0,v=l.length;m<v;m++){let x=l[m];if(x.isDirectionalLight){let w=i.directional[d];w.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),d++}else if(x.isSpotLight){let w=i.spot[f];w.position.setFromMatrixPosition(x.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),f++}else if(x.isRectAreaLight){let w=i.rectArea[p];w.position.setFromMatrixPosition(x.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(x.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(x.width*.5,0,0),w.halfHeight.set(0,x.height*.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),p++}else if(x.isPointLight){let w=i.point[h];w.position.setFromMatrixPosition(x.matrixWorld),w.position.applyMatrix4(g),h++}else if(x.isHemisphereLight){let w=i.hemi[y];w.direction.setFromMatrixPosition(x.matrixWorld),w.direction.transformDirection(g),y++}}}return{setup:a,setupView:c,state:i}}function l0(n){let e=new KT(n),t=[],i=[];function r(u){l.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function o(u){i.push(u)}function a(u){e.setup(t,u)}function c(u){e.setupView(t,u)}let l={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function QT(n){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new l0(n),e.set(r,[a])):s>=o.length?(a=new l0(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}function nI(n,e,t){let i=new Nr,r=new oe,s=new oe,o=new gt,a=new da({depthPacking:Ky}),c=new ha,l={},u=t.maxTextureSize,d={[wi]:on,[on]:wi,[jn]:jn},h=new xn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new oe},radius:{value:4}},vertexShader:eI,fragmentShader:tI}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let p=new it;p.setAttribute("position",new ut(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new It(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=vp;let m=this.type;this.render=function(I,R,U){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||I.length===0)return;let _=n.getRenderTarget(),b=n.getActiveCubeFace(),D=n.getActiveMipmapLevel(),z=n.state;z.setBlending(xi),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);let F=m!==Hn&&this.type===Hn,$=m===Hn&&this.type!==Hn;for(let W=0,ne=I.length;W<ne;W++){let J=I[W],V=J.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",J,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;r.copy(V.mapSize);let ce=V.getFrameExtents();if(r.multiply(ce),s.copy(V.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ce.x),r.x=s.x*ce.x,V.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ce.y),r.y=s.y*ce.y,V.mapSize.y=s.y)),V.map===null||F===!0||$===!0){let Te=this.type!==Hn?{minFilter:zt,magFilter:zt}:{};V.map!==null&&V.map.dispose(),V.map=new yn(r.x,r.y,Te),V.map.texture.name=J.name+".shadowMap",V.camera.updateProjectionMatrix()}n.setRenderTarget(V.map),n.clear();let fe=V.getViewportCount();for(let Te=0;Te<fe;Te++){let ve=V.getViewport(Te);o.set(s.x*ve.x,s.y*ve.y,s.x*ve.z,s.y*ve.w),z.viewport(o),V.updateMatrices(J,Te),i=V.getFrustum(),w(R,U,V.camera,J,this.type)}V.isPointLightShadow!==!0&&this.type===Hn&&v(V,U),V.needsUpdate=!1}m=this.type,g.needsUpdate=!1,n.setRenderTarget(_,b,D)};function v(I,R){let U=e.update(y);h.defines.VSM_SAMPLES!==I.blurSamples&&(h.defines.VSM_SAMPLES=I.blurSamples,f.defines.VSM_SAMPLES=I.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),I.mapPass===null&&(I.mapPass=new yn(r.x,r.y)),h.uniforms.shadow_pass.value=I.map.texture,h.uniforms.resolution.value=I.mapSize,h.uniforms.radius.value=I.radius,n.setRenderTarget(I.mapPass),n.clear(),n.renderBufferDirect(R,null,U,h,y,null),f.uniforms.shadow_pass.value=I.mapPass.texture,f.uniforms.resolution.value=I.mapSize,f.uniforms.radius.value=I.radius,n.setRenderTarget(I.map),n.clear(),n.renderBufferDirect(R,null,U,f,y,null)}function x(I,R,U,_){let b=null,D=U.isPointLight===!0?I.customDistanceMaterial:I.customDepthMaterial;if(D!==void 0)b=D;else if(b=U.isPointLight===!0?c:a,n.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){let z=b.uuid,F=R.uuid,$=l[z];$===void 0&&($={},l[z]=$);let W=$[F];W===void 0&&(W=b.clone(),$[F]=W,R.addEventListener("dispose",O)),b=W}if(b.visible=R.visible,b.wireframe=R.wireframe,_===Hn?b.side=R.shadowSide!==null?R.shadowSide:R.side:b.side=R.shadowSide!==null?R.shadowSide:d[R.side],b.alphaMap=R.alphaMap,b.alphaTest=R.alphaTest,b.map=R.map,b.clipShadows=R.clipShadows,b.clippingPlanes=R.clippingPlanes,b.clipIntersection=R.clipIntersection,b.displacementMap=R.displacementMap,b.displacementScale=R.displacementScale,b.displacementBias=R.displacementBias,b.wireframeLinewidth=R.wireframeLinewidth,b.linewidth=R.linewidth,U.isPointLight===!0&&b.isMeshDistanceMaterial===!0){let z=n.properties.get(b);z.light=U}return b}function w(I,R,U,_,b){if(I.visible===!1)return;if(I.layers.test(R.layers)&&(I.isMesh||I.isLine||I.isPoints)&&(I.castShadow||I.receiveShadow&&b===Hn)&&(!I.frustumCulled||i.intersectsObject(I))){I.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,I.matrixWorld);let F=e.update(I),$=I.material;if(Array.isArray($)){let W=F.groups;for(let ne=0,J=W.length;ne<J;ne++){let V=W[ne],ce=$[V.materialIndex];if(ce&&ce.visible){let fe=x(I,ce,_,b);I.onBeforeShadow(n,I,R,U,F,fe,V),n.renderBufferDirect(U,null,F,fe,I,V),I.onAfterShadow(n,I,R,U,F,fe,V)}}}else if($.visible){let W=x(I,$,_,b);I.onBeforeShadow(n,I,R,U,F,W,null),n.renderBufferDirect(U,null,F,W,I,null),I.onAfterShadow(n,I,R,U,F,W,null)}}let z=I.children;for(let F=0,$=z.length;F<$;F++)w(z[F],R,U,_,b)}function O(I){I.target.removeEventListener("dispose",O);for(let U in l){let _=l[U],b=I.target.uuid;b in _&&(_[b].dispose(),delete _[b])}}}function iI(n){function e(){let k=!1,ue=new gt,ee=null,de=new gt(0,0,0,0);return{setMask:function(Se){ee!==Se&&!k&&(n.colorMask(Se,Se,Se,Se),ee=Se)},setLocked:function(Se){k=Se},setClear:function(Se,rt,at,vt,Et){Et===!0&&(Se*=vt,rt*=vt,at*=vt),ue.set(Se,rt,at,vt),de.equals(ue)===!1&&(n.clearColor(Se,rt,at,vt),de.copy(ue))},reset:function(){k=!1,ee=null,de.set(-1,0,0,0)}}}function t(){let k=!1,ue=null,ee=null,de=null;return{setTest:function(Se){Se?ye(n.DEPTH_TEST):ae(n.DEPTH_TEST)},setMask:function(Se){ue!==Se&&!k&&(n.depthMask(Se),ue=Se)},setFunc:function(Se){if(ee!==Se){switch(Se){case wy:n.depthFunc(n.NEVER);break;case My:n.depthFunc(n.ALWAYS);break;case Sy:n.depthFunc(n.LESS);break;case Wo:n.depthFunc(n.LEQUAL);break;case Ey:n.depthFunc(n.EQUAL);break;case Ay:n.depthFunc(n.GEQUAL);break;case Ty:n.depthFunc(n.GREATER);break;case Iy:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}ee=Se}},setLocked:function(Se){k=Se},setClear:function(Se){de!==Se&&(n.clearDepth(Se),de=Se)},reset:function(){k=!1,ue=null,ee=null,de=null}}}function i(){let k=!1,ue=null,ee=null,de=null,Se=null,rt=null,at=null,vt=null,Et=null;return{setTest:function(ot){k||(ot?ye(n.STENCIL_TEST):ae(n.STENCIL_TEST))},setMask:function(ot){ue!==ot&&!k&&(n.stencilMask(ot),ue=ot)},setFunc:function(ot,an,N){(ee!==ot||de!==an||Se!==N)&&(n.stencilFunc(ot,an,N),ee=ot,de=an,Se=N)},setOp:function(ot,an,N){(rt!==ot||at!==an||vt!==N)&&(n.stencilOp(ot,an,N),rt=ot,at=an,vt=N)},setLocked:function(ot){k=ot},setClear:function(ot){Et!==ot&&(n.clearStencil(ot),Et=ot)},reset:function(){k=!1,ue=null,ee=null,de=null,Se=null,rt=null,at=null,vt=null,Et=null}}}let r=new e,s=new t,o=new i,a=new WeakMap,c=new WeakMap,l={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,v=null,x=null,w=null,O=null,I=new Ce(0,0,0),R=0,U=!1,_=null,b=null,D=null,z=null,F=null,$=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),W=!1,ne=0,J=n.getParameter(n.VERSION);J.indexOf("WebGL")!==-1?(ne=parseFloat(/^WebGL (\d)/.exec(J)[1]),W=ne>=1):J.indexOf("OpenGL ES")!==-1&&(ne=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),W=ne>=2);let V=null,ce={},fe=n.getParameter(n.SCISSOR_BOX),Te=n.getParameter(n.VIEWPORT),ve=new gt().fromArray(fe),He=new gt().fromArray(Te);function q(k,ue,ee,de){let Se=new Uint8Array(4),rt=n.createTexture();n.bindTexture(k,rt),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let at=0;at<ee;at++)k===n.TEXTURE_3D||k===n.TEXTURE_2D_ARRAY?n.texImage3D(ue,0,n.RGBA,1,1,de,0,n.RGBA,n.UNSIGNED_BYTE,Se):n.texImage2D(ue+at,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Se);return rt}let Z={};Z[n.TEXTURE_2D]=q(n.TEXTURE_2D,n.TEXTURE_2D,1),Z[n.TEXTURE_CUBE_MAP]=q(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),Z[n.TEXTURE_2D_ARRAY]=q(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),Z[n.TEXTURE_3D]=q(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),ye(n.DEPTH_TEST),s.setFunc(Wo),me(!1),K(_h),ye(n.CULL_FACE),he(xi);function ye(k){l[k]!==!0&&(n.enable(k),l[k]=!0)}function ae(k){l[k]!==!1&&(n.disable(k),l[k]=!1)}function Ie(k,ue){return u[k]!==ue?(n.bindFramebuffer(k,ue),u[k]=ue,k===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=ue),k===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=ue),!0):!1}function Re(k,ue){let ee=h,de=!1;if(k){ee=d.get(ue),ee===void 0&&(ee=[],d.set(ue,ee));let Se=k.textures;if(ee.length!==Se.length||ee[0]!==n.COLOR_ATTACHMENT0){for(let rt=0,at=Se.length;rt<at;rt++)ee[rt]=n.COLOR_ATTACHMENT0+rt;ee.length=Se.length,de=!0}}else ee[0]!==n.BACK&&(ee[0]=n.BACK,de=!0);de&&n.drawBuffers(ee)}function B(k){return f!==k?(n.useProgram(k),f=k,!0):!1}let Je={[Wi]:n.FUNC_ADD,[sy]:n.FUNC_SUBTRACT,[oy]:n.FUNC_REVERSE_SUBTRACT};Je[ay]=n.MIN,Je[cy]=n.MAX;let X={[ly]:n.ZERO,[uy]:n.ONE,[dy]:n.SRC_COLOR,[wl]:n.SRC_ALPHA,[yy]:n.SRC_ALPHA_SATURATE,[my]:n.DST_COLOR,[fy]:n.DST_ALPHA,[hy]:n.ONE_MINUS_SRC_COLOR,[Ml]:n.ONE_MINUS_SRC_ALPHA,[gy]:n.ONE_MINUS_DST_COLOR,[py]:n.ONE_MINUS_DST_ALPHA,[vy]:n.CONSTANT_COLOR,[xy]:n.ONE_MINUS_CONSTANT_COLOR,[by]:n.CONSTANT_ALPHA,[_y]:n.ONE_MINUS_CONSTANT_ALPHA};function he(k,ue,ee,de,Se,rt,at,vt,Et,ot){if(k===xi){p===!0&&(ae(n.BLEND),p=!1);return}if(p===!1&&(ye(n.BLEND),p=!0),k!==ry){if(k!==y||ot!==U){if((g!==Wi||x!==Wi)&&(n.blendEquation(n.FUNC_ADD),g=Wi,x=Wi),ot)switch(k){case Rr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case wh:n.blendFunc(n.ONE,n.ONE);break;case Mh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Sh:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",k);break}else switch(k){case Rr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case wh:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Mh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Sh:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",k);break}m=null,v=null,w=null,O=null,I.set(0,0,0),R=0,y=k,U=ot}return}Se=Se||ue,rt=rt||ee,at=at||de,(ue!==g||Se!==x)&&(n.blendEquationSeparate(Je[ue],Je[Se]),g=ue,x=Se),(ee!==m||de!==v||rt!==w||at!==O)&&(n.blendFuncSeparate(X[ee],X[de],X[rt],X[at]),m=ee,v=de,w=rt,O=at),(vt.equals(I)===!1||Et!==R)&&(n.blendColor(vt.r,vt.g,vt.b,Et),I.copy(vt),R=Et),y=k,U=!1}function Q(k,ue){k.side===jn?ae(n.CULL_FACE):ye(n.CULL_FACE);let ee=k.side===on;ue&&(ee=!ee),me(ee),k.blending===Rr&&k.transparent===!1?he(xi):he(k.blending,k.blendEquation,k.blendSrc,k.blendDst,k.blendEquationAlpha,k.blendSrcAlpha,k.blendDstAlpha,k.blendColor,k.blendAlpha,k.premultipliedAlpha),s.setFunc(k.depthFunc),s.setTest(k.depthTest),s.setMask(k.depthWrite),r.setMask(k.colorWrite);let de=k.stencilWrite;o.setTest(de),de&&(o.setMask(k.stencilWriteMask),o.setFunc(k.stencilFunc,k.stencilRef,k.stencilFuncMask),o.setOp(k.stencilFail,k.stencilZFail,k.stencilZPass)),De(k.polygonOffset,k.polygonOffsetFactor,k.polygonOffsetUnits),k.alphaToCoverage===!0?ye(n.SAMPLE_ALPHA_TO_COVERAGE):ae(n.SAMPLE_ALPHA_TO_COVERAGE)}function me(k){_!==k&&(k?n.frontFace(n.CW):n.frontFace(n.CCW),_=k)}function K(k){k!==ty?(ye(n.CULL_FACE),k!==b&&(k===_h?n.cullFace(n.BACK):k===ny?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):ae(n.CULL_FACE),b=k}function we(k){k!==D&&(W&&n.lineWidth(k),D=k)}function De(k,ue,ee){k?(ye(n.POLYGON_OFFSET_FILL),(z!==ue||F!==ee)&&(n.polygonOffset(ue,ee),z=ue,F=ee)):ae(n.POLYGON_OFFSET_FILL)}function L(k){k?ye(n.SCISSOR_TEST):ae(n.SCISSOR_TEST)}function E(k){k===void 0&&(k=n.TEXTURE0+$-1),V!==k&&(n.activeTexture(k),V=k)}function H(k,ue,ee){ee===void 0&&(V===null?ee=n.TEXTURE0+$-1:ee=V);let de=ce[ee];de===void 0&&(de={type:void 0,texture:void 0},ce[ee]=de),(de.type!==k||de.texture!==ue)&&(V!==ee&&(n.activeTexture(ee),V=ee),n.bindTexture(k,ue||Z[k]),de.type=k,de.texture=ue)}function te(){let k=ce[V];k!==void 0&&k.type!==void 0&&(n.bindTexture(k.type,null),k.type=void 0,k.texture=void 0)}function le(){try{n.compressedTexImage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function re(){try{n.compressedTexImage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Ue(){try{n.texSubImage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function xe(){try{n.texSubImage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function be(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Ve(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Oe(){try{n.texStorage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Ge(){try{n.texImage2D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Ne(){try{n.texImage3D.apply(n,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Me(k){ve.equals(k)===!1&&(n.scissor(k.x,k.y,k.z,k.w),ve.copy(k))}function Ye(k){He.equals(k)===!1&&(n.viewport(k.x,k.y,k.z,k.w),He.copy(k))}function nt(k,ue){let ee=c.get(ue);ee===void 0&&(ee=new WeakMap,c.set(ue,ee));let de=ee.get(k);de===void 0&&(de=n.getUniformBlockIndex(ue,k.name),ee.set(k,de))}function yt(k,ue){let de=c.get(ue).get(k);a.get(ue)!==de&&(n.uniformBlockBinding(ue,de,k.__bindingPointIndex),a.set(ue,de))}function je(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),l={},V=null,ce={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,v=null,x=null,w=null,O=null,I=new Ce(0,0,0),R=0,U=!1,_=null,b=null,D=null,z=null,F=null,ve.set(0,0,n.canvas.width,n.canvas.height),He.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),o.reset()}return{buffers:{color:r,depth:s,stencil:o},enable:ye,disable:ae,bindFramebuffer:Ie,drawBuffers:Re,useProgram:B,setBlending:he,setMaterial:Q,setFlipSided:me,setCullFace:K,setLineWidth:we,setPolygonOffset:De,setScissorTest:L,activeTexture:E,bindTexture:H,unbindTexture:te,compressedTexImage2D:le,compressedTexImage3D:re,texImage2D:Ge,texImage3D:Ne,updateUBOMapping:nt,uniformBlockBinding:yt,texStorage2D:pe,texStorage3D:Oe,texSubImage2D:Ue,texSubImage3D:xe,compressedTexSubImage2D:be,compressedTexSubImage3D:Ve,scissor:Me,viewport:Ye,reset:je}}function rI(n,e,t,i,r,s,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new oe,u=new WeakMap,d,h=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(L,E){return f?new OffscreenCanvas(L,E):sa("canvas")}function y(L,E,H){let te=1,le=De(L);if((le.width>H||le.height>H)&&(te=H/Math.max(le.width,le.height)),te<1)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap||typeof VideoFrame<"u"&&L instanceof VideoFrame){let re=Math.floor(te*le.width),Ue=Math.floor(te*le.height);d===void 0&&(d=p(re,Ue));let xe=E?p(re,Ue):d;return xe.width=re,xe.height=Ue,xe.getContext("2d").drawImage(L,0,0,re,Ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+le.width+"x"+le.height+") to ("+re+"x"+Ue+")."),xe}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+le.width+"x"+le.height+")."),L;return L}function g(L){return L.generateMipmaps&&L.minFilter!==zt&&L.minFilter!==Lt}function m(L){n.generateMipmap(L)}function v(L,E,H,te,le=!1){if(L!==null){if(n[L]!==void 0)return n[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let re=E;if(E===n.RED&&(H===n.FLOAT&&(re=n.R32F),H===n.HALF_FLOAT&&(re=n.R16F),H===n.UNSIGNED_BYTE&&(re=n.R8)),E===n.RED_INTEGER&&(H===n.UNSIGNED_BYTE&&(re=n.R8UI),H===n.UNSIGNED_SHORT&&(re=n.R16UI),H===n.UNSIGNED_INT&&(re=n.R32UI),H===n.BYTE&&(re=n.R8I),H===n.SHORT&&(re=n.R16I),H===n.INT&&(re=n.R32I)),E===n.RG&&(H===n.FLOAT&&(re=n.RG32F),H===n.HALF_FLOAT&&(re=n.RG16F),H===n.UNSIGNED_BYTE&&(re=n.RG8)),E===n.RG_INTEGER&&(H===n.UNSIGNED_BYTE&&(re=n.RG8UI),H===n.UNSIGNED_SHORT&&(re=n.RG16UI),H===n.UNSIGNED_INT&&(re=n.RG32UI),H===n.BYTE&&(re=n.RG8I),H===n.SHORT&&(re=n.RG16I),H===n.INT&&(re=n.RG32I)),E===n.RGB&&H===n.UNSIGNED_INT_5_9_9_9_REV&&(re=n.RGB9_E5),E===n.RGBA){let Ue=le?ea:mt.getTransfer(te);H===n.FLOAT&&(re=n.RGBA32F),H===n.HALF_FLOAT&&(re=n.RGBA16F),H===n.UNSIGNED_BYTE&&(re=Ue===wt?n.SRGB8_ALPHA8:n.RGBA8),H===n.UNSIGNED_SHORT_4_4_4_4&&(re=n.RGBA4),H===n.UNSIGNED_SHORT_5_5_5_1&&(re=n.RGB5_A1)}return(re===n.R16F||re===n.R32F||re===n.RG16F||re===n.RG32F||re===n.RGBA16F||re===n.RGBA32F)&&e.get("EXT_color_buffer_float"),re}function x(L,E){return g(L)===!0||L.isFramebufferTexture&&L.minFilter!==zt&&L.minFilter!==Lt?Math.log2(Math.max(E.width,E.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?E.mipmaps.length:1}function w(L){let E=L.target;E.removeEventListener("dispose",w),I(E),E.isVideoTexture&&u.delete(E)}function O(L){let E=L.target;E.removeEventListener("dispose",O),U(E)}function I(L){let E=i.get(L);if(E.__webglInit===void 0)return;let H=L.source,te=h.get(H);if(te){let le=te[E.__cacheKey];le.usedTimes--,le.usedTimes===0&&R(L),Object.keys(te).length===0&&h.delete(H)}i.remove(L)}function R(L){let E=i.get(L);n.deleteTexture(E.__webglTexture);let H=L.source,te=h.get(H);delete te[E.__cacheKey],o.memory.textures--}function U(L){let E=i.get(L);if(L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let te=0;te<6;te++){if(Array.isArray(E.__webglFramebuffer[te]))for(let le=0;le<E.__webglFramebuffer[te].length;le++)n.deleteFramebuffer(E.__webglFramebuffer[te][le]);else n.deleteFramebuffer(E.__webglFramebuffer[te]);E.__webglDepthbuffer&&n.deleteRenderbuffer(E.__webglDepthbuffer[te])}else{if(Array.isArray(E.__webglFramebuffer))for(let te=0;te<E.__webglFramebuffer.length;te++)n.deleteFramebuffer(E.__webglFramebuffer[te]);else n.deleteFramebuffer(E.__webglFramebuffer);if(E.__webglDepthbuffer&&n.deleteRenderbuffer(E.__webglDepthbuffer),E.__webglMultisampledFramebuffer&&n.deleteFramebuffer(E.__webglMultisampledFramebuffer),E.__webglColorRenderbuffer)for(let te=0;te<E.__webglColorRenderbuffer.length;te++)E.__webglColorRenderbuffer[te]&&n.deleteRenderbuffer(E.__webglColorRenderbuffer[te]);E.__webglDepthRenderbuffer&&n.deleteRenderbuffer(E.__webglDepthRenderbuffer)}let H=L.textures;for(let te=0,le=H.length;te<le;te++){let re=i.get(H[te]);re.__webglTexture&&(n.deleteTexture(re.__webglTexture),o.memory.textures--),i.remove(H[te])}i.remove(L)}let _=0;function b(){_=0}function D(){let L=_;return L>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+r.maxTextures),_+=1,L}function z(L){let E=[];return E.push(L.wrapS),E.push(L.wrapT),E.push(L.wrapR||0),E.push(L.magFilter),E.push(L.minFilter),E.push(L.anisotropy),E.push(L.internalFormat),E.push(L.format),E.push(L.type),E.push(L.generateMipmaps),E.push(L.premultiplyAlpha),E.push(L.flipY),E.push(L.unpackAlignment),E.push(L.colorSpace),E.join()}function F(L,E){let H=i.get(L);if(L.isVideoTexture&&K(L),L.isRenderTargetTexture===!1&&L.version>0&&H.__version!==L.version){let te=L.image;if(te===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(te.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ve(H,L,E);return}}t.bindTexture(n.TEXTURE_2D,H.__webglTexture,n.TEXTURE0+E)}function $(L,E){let H=i.get(L);if(L.version>0&&H.__version!==L.version){ve(H,L,E);return}t.bindTexture(n.TEXTURE_2D_ARRAY,H.__webglTexture,n.TEXTURE0+E)}function W(L,E){let H=i.get(L);if(L.version>0&&H.__version!==L.version){ve(H,L,E);return}t.bindTexture(n.TEXTURE_3D,H.__webglTexture,n.TEXTURE0+E)}function ne(L,E){let H=i.get(L);if(L.version>0&&H.__version!==L.version){He(H,L,E);return}t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture,n.TEXTURE0+E)}let J={[qo]:n.REPEAT,[In]:n.CLAMP_TO_EDGE,[Zo]:n.MIRRORED_REPEAT},V={[zt]:n.NEAREST,[xp]:n.NEAREST_MIPMAP_NEAREST,[Is]:n.NEAREST_MIPMAP_LINEAR,[Lt]:n.LINEAR,[Vo]:n.LINEAR_MIPMAP_NEAREST,[Wn]:n.LINEAR_MIPMAP_LINEAR},ce={[ev]:n.NEVER,[ov]:n.ALWAYS,[tv]:n.LESS,[Cp]:n.LEQUAL,[nv]:n.EQUAL,[sv]:n.GEQUAL,[iv]:n.GREATER,[rv]:n.NOTEQUAL};function fe(L,E){if(E.type===Cn&&e.has("OES_texture_float_linear")===!1&&(E.magFilter===Lt||E.magFilter===Vo||E.magFilter===Is||E.magFilter===Wn||E.minFilter===Lt||E.minFilter===Vo||E.minFilter===Is||E.minFilter===Wn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(L,n.TEXTURE_WRAP_S,J[E.wrapS]),n.texParameteri(L,n.TEXTURE_WRAP_T,J[E.wrapT]),(L===n.TEXTURE_3D||L===n.TEXTURE_2D_ARRAY)&&n.texParameteri(L,n.TEXTURE_WRAP_R,J[E.wrapR]),n.texParameteri(L,n.TEXTURE_MAG_FILTER,V[E.magFilter]),n.texParameteri(L,n.TEXTURE_MIN_FILTER,V[E.minFilter]),E.compareFunction&&(n.texParameteri(L,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(L,n.TEXTURE_COMPARE_FUNC,ce[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(E.magFilter===zt||E.minFilter!==Is&&E.minFilter!==Wn||E.type===Cn&&e.has("OES_texture_float_linear")===!1)return;if(E.anisotropy>1||i.get(E).__currentAnisotropy){let H=e.get("EXT_texture_filter_anisotropic");n.texParameterf(L,H.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,r.getMaxAnisotropy())),i.get(E).__currentAnisotropy=E.anisotropy}}}function Te(L,E){let H=!1;L.__webglInit===void 0&&(L.__webglInit=!0,E.addEventListener("dispose",w));let te=E.source,le=h.get(te);le===void 0&&(le={},h.set(te,le));let re=z(E);if(re!==L.__cacheKey){le[re]===void 0&&(le[re]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,H=!0),le[re].usedTimes++;let Ue=le[L.__cacheKey];Ue!==void 0&&(le[L.__cacheKey].usedTimes--,Ue.usedTimes===0&&R(E)),L.__cacheKey=re,L.__webglTexture=le[re].texture}return H}function ve(L,E,H){let te=n.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(te=n.TEXTURE_2D_ARRAY),E.isData3DTexture&&(te=n.TEXTURE_3D);let le=Te(L,E),re=E.source;t.bindTexture(te,L.__webglTexture,n.TEXTURE0+H);let Ue=i.get(re);if(re.version!==Ue.__version||le===!0){t.activeTexture(n.TEXTURE0+H);let xe=mt.getPrimaries(mt.workingColorSpace),be=E.colorSpace===pi?null:mt.getPrimaries(E.colorSpace),Ve=E.colorSpace===pi||xe===be?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,E.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,E.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);let pe=y(E.image,!1,r.maxTextureSize);pe=we(E,pe);let Oe=s.convert(E.format,E.colorSpace),Ge=s.convert(E.type),Ne=v(E.internalFormat,Oe,Ge,E.colorSpace,E.isVideoTexture);fe(te,E);let Me,Ye=E.mipmaps,nt=E.isVideoTexture!==!0,yt=Ue.__version===void 0||le===!0,je=re.dataReady,k=x(E,pe);if(E.isDepthTexture)Ne=n.DEPTH_COMPONENT16,E.type===Cn?Ne=n.DEPTH_COMPONENT32F:E.type===Dr?Ne=n.DEPTH_COMPONENT24:E.type===Xs&&(Ne=n.DEPTH24_STENCIL8),yt&&(nt?t.texStorage2D(n.TEXTURE_2D,1,Ne,pe.width,pe.height):t.texImage2D(n.TEXTURE_2D,0,Ne,pe.width,pe.height,0,Oe,Ge,null));else if(E.isDataTexture)if(Ye.length>0){nt&&yt&&t.texStorage2D(n.TEXTURE_2D,k,Ne,Ye[0].width,Ye[0].height);for(let ue=0,ee=Ye.length;ue<ee;ue++)Me=Ye[ue],nt?je&&t.texSubImage2D(n.TEXTURE_2D,ue,0,0,Me.width,Me.height,Oe,Ge,Me.data):t.texImage2D(n.TEXTURE_2D,ue,Ne,Me.width,Me.height,0,Oe,Ge,Me.data);E.generateMipmaps=!1}else nt?(yt&&t.texStorage2D(n.TEXTURE_2D,k,Ne,pe.width,pe.height),je&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,pe.width,pe.height,Oe,Ge,pe.data)):t.texImage2D(n.TEXTURE_2D,0,Ne,pe.width,pe.height,0,Oe,Ge,pe.data);else if(E.isCompressedTexture)if(E.isCompressedArrayTexture){nt&&yt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,k,Ne,Ye[0].width,Ye[0].height,pe.depth);for(let ue=0,ee=Ye.length;ue<ee;ue++)Me=Ye[ue],E.format!==mn?Oe!==null?nt?je&&t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,Me.width,Me.height,pe.depth,Oe,Me.data,0,0):t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,Ne,Me.width,Me.height,pe.depth,0,Me.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):nt?je&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,Me.width,Me.height,pe.depth,Oe,Ge,Me.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,Ne,Me.width,Me.height,pe.depth,0,Oe,Ge,Me.data)}else{nt&&yt&&t.texStorage2D(n.TEXTURE_2D,k,Ne,Ye[0].width,Ye[0].height);for(let ue=0,ee=Ye.length;ue<ee;ue++)Me=Ye[ue],E.format!==mn?Oe!==null?nt?je&&t.compressedTexSubImage2D(n.TEXTURE_2D,ue,0,0,Me.width,Me.height,Oe,Me.data):t.compressedTexImage2D(n.TEXTURE_2D,ue,Ne,Me.width,Me.height,0,Me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):nt?je&&t.texSubImage2D(n.TEXTURE_2D,ue,0,0,Me.width,Me.height,Oe,Ge,Me.data):t.texImage2D(n.TEXTURE_2D,ue,Ne,Me.width,Me.height,0,Oe,Ge,Me.data)}else if(E.isDataArrayTexture)nt?(yt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,k,Ne,pe.width,pe.height,pe.depth),je&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,pe.width,pe.height,pe.depth,Oe,Ge,pe.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ne,pe.width,pe.height,pe.depth,0,Oe,Ge,pe.data);else if(E.isData3DTexture)nt?(yt&&t.texStorage3D(n.TEXTURE_3D,k,Ne,pe.width,pe.height,pe.depth),je&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,pe.width,pe.height,pe.depth,Oe,Ge,pe.data)):t.texImage3D(n.TEXTURE_3D,0,Ne,pe.width,pe.height,pe.depth,0,Oe,Ge,pe.data);else if(E.isFramebufferTexture){if(yt)if(nt)t.texStorage2D(n.TEXTURE_2D,k,Ne,pe.width,pe.height);else{let ue=pe.width,ee=pe.height;for(let de=0;de<k;de++)t.texImage2D(n.TEXTURE_2D,de,Ne,ue,ee,0,Oe,Ge,null),ue>>=1,ee>>=1}}else if(Ye.length>0){if(nt&&yt){let ue=De(Ye[0]);t.texStorage2D(n.TEXTURE_2D,k,Ne,ue.width,ue.height)}for(let ue=0,ee=Ye.length;ue<ee;ue++)Me=Ye[ue],nt?je&&t.texSubImage2D(n.TEXTURE_2D,ue,0,0,Oe,Ge,Me):t.texImage2D(n.TEXTURE_2D,ue,Ne,Oe,Ge,Me);E.generateMipmaps=!1}else if(nt){if(yt){let ue=De(pe);t.texStorage2D(n.TEXTURE_2D,k,Ne,ue.width,ue.height)}je&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Oe,Ge,pe)}else t.texImage2D(n.TEXTURE_2D,0,Ne,Oe,Ge,pe);g(E)&&m(te),Ue.__version=re.version,E.onUpdate&&E.onUpdate(E)}L.__version=E.version}function He(L,E,H){if(E.image.length!==6)return;let te=Te(L,E),le=E.source;t.bindTexture(n.TEXTURE_CUBE_MAP,L.__webglTexture,n.TEXTURE0+H);let re=i.get(le);if(le.version!==re.__version||te===!0){t.activeTexture(n.TEXTURE0+H);let Ue=mt.getPrimaries(mt.workingColorSpace),xe=E.colorSpace===pi?null:mt.getPrimaries(E.colorSpace),be=E.colorSpace===pi||Ue===xe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,E.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,E.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,be);let Ve=E.isCompressedTexture||E.image[0].isCompressedTexture,pe=E.image[0]&&E.image[0].isDataTexture,Oe=[];for(let ee=0;ee<6;ee++)!Ve&&!pe?Oe[ee]=y(E.image[ee],!0,r.maxCubemapSize):Oe[ee]=pe?E.image[ee].image:E.image[ee],Oe[ee]=we(E,Oe[ee]);let Ge=Oe[0],Ne=s.convert(E.format,E.colorSpace),Me=s.convert(E.type),Ye=v(E.internalFormat,Ne,Me,E.colorSpace),nt=E.isVideoTexture!==!0,yt=re.__version===void 0||te===!0,je=le.dataReady,k=x(E,Ge);fe(n.TEXTURE_CUBE_MAP,E);let ue;if(Ve){nt&&yt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,k,Ye,Ge.width,Ge.height);for(let ee=0;ee<6;ee++){ue=Oe[ee].mipmaps;for(let de=0;de<ue.length;de++){let Se=ue[de];E.format!==mn?Ne!==null?nt?je&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,de,0,0,Se.width,Se.height,Ne,Se.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,de,Ye,Se.width,Se.height,0,Se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):nt?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,de,0,0,Se.width,Se.height,Ne,Me,Se.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,de,Ye,Se.width,Se.height,0,Ne,Me,Se.data)}}}else{if(ue=E.mipmaps,nt&&yt){ue.length>0&&k++;let ee=De(Oe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,k,Ye,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(pe){nt?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Oe[ee].width,Oe[ee].height,Ne,Me,Oe[ee].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ye,Oe[ee].width,Oe[ee].height,0,Ne,Me,Oe[ee].data);for(let de=0;de<ue.length;de++){let rt=ue[de].image[ee].image;nt?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,de+1,0,0,rt.width,rt.height,Ne,Me,rt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,de+1,Ye,rt.width,rt.height,0,Ne,Me,rt.data)}}else{nt?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Ne,Me,Oe[ee]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ye,Ne,Me,Oe[ee]);for(let de=0;de<ue.length;de++){let Se=ue[de];nt?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,de+1,0,0,Ne,Me,Se.image[ee]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,de+1,Ye,Ne,Me,Se.image[ee])}}}g(E)&&m(n.TEXTURE_CUBE_MAP),re.__version=le.version,E.onUpdate&&E.onUpdate(E)}L.__version=E.version}function q(L,E,H,te,le,re){let Ue=s.convert(H.format,H.colorSpace),xe=s.convert(H.type),be=v(H.internalFormat,Ue,xe,H.colorSpace);if(!i.get(E).__hasExternalTextures){let pe=Math.max(1,E.width>>re),Oe=Math.max(1,E.height>>re);le===n.TEXTURE_3D||le===n.TEXTURE_2D_ARRAY?t.texImage3D(le,re,be,pe,Oe,E.depth,0,Ue,xe,null):t.texImage2D(le,re,be,pe,Oe,0,Ue,xe,null)}t.bindFramebuffer(n.FRAMEBUFFER,L),me(E)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,te,le,i.get(H).__webglTexture,0,Q(E)):(le===n.TEXTURE_2D||le>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&le<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,te,le,i.get(H).__webglTexture,re),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Z(L,E,H){if(n.bindRenderbuffer(n.RENDERBUFFER,L),E.depthBuffer&&!E.stencilBuffer){let te=n.DEPTH_COMPONENT24;if(H||me(E)){let le=E.depthTexture;le&&le.isDepthTexture&&(le.type===Cn?te=n.DEPTH_COMPONENT32F:le.type===Dr&&(te=n.DEPTH_COMPONENT24));let re=Q(E);me(E)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,re,te,E.width,E.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,re,te,E.width,E.height)}else n.renderbufferStorage(n.RENDERBUFFER,te,E.width,E.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,L)}else if(E.depthBuffer&&E.stencilBuffer){let te=Q(E);H&&me(E)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,te,n.DEPTH24_STENCIL8,E.width,E.height):me(E)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,te,n.DEPTH24_STENCIL8,E.width,E.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,E.width,E.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,L)}else{let te=E.textures;for(let le=0;le<te.length;le++){let re=te[le],Ue=s.convert(re.format,re.colorSpace),xe=s.convert(re.type),be=v(re.internalFormat,Ue,xe,re.colorSpace),Ve=Q(E);H&&me(E)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ve,be,E.width,E.height):me(E)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ve,be,E.width,E.height):n.renderbufferStorage(n.RENDERBUFFER,be,E.width,E.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function ye(L,E){if(E&&E.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,L),!(E.depthTexture&&E.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(E.depthTexture).__webglTexture||E.depthTexture.image.width!==E.width||E.depthTexture.image.height!==E.height)&&(E.depthTexture.image.width=E.width,E.depthTexture.image.height=E.height,E.depthTexture.needsUpdate=!0),F(E.depthTexture,0);let te=i.get(E.depthTexture).__webglTexture,le=Q(E);if(E.depthTexture.format===Pr)me(E)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,te,0,le):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,te,0);else if(E.depthTexture.format===Os)me(E)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,te,0,le):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,te,0);else throw new Error("Unknown depthTexture format")}function ae(L){let E=i.get(L),H=L.isWebGLCubeRenderTarget===!0;if(L.depthTexture&&!E.__autoAllocateDepthBuffer){if(H)throw new Error("target.depthTexture not supported in Cube render targets");ye(E.__webglFramebuffer,L)}else if(H){E.__webglDepthbuffer=[];for(let te=0;te<6;te++)t.bindFramebuffer(n.FRAMEBUFFER,E.__webglFramebuffer[te]),E.__webglDepthbuffer[te]=n.createRenderbuffer(),Z(E.__webglDepthbuffer[te],L,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,E.__webglFramebuffer),E.__webglDepthbuffer=n.createRenderbuffer(),Z(E.__webglDepthbuffer,L,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ie(L,E,H){let te=i.get(L);E!==void 0&&q(te.__webglFramebuffer,L,L.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),H!==void 0&&ae(L)}function Re(L){let E=L.texture,H=i.get(L),te=i.get(E);L.addEventListener("dispose",O);let le=L.textures,re=L.isWebGLCubeRenderTarget===!0,Ue=le.length>1;if(Ue||(te.__webglTexture===void 0&&(te.__webglTexture=n.createTexture()),te.__version=E.version,o.memory.textures++),re){H.__webglFramebuffer=[];for(let xe=0;xe<6;xe++)if(E.mipmaps&&E.mipmaps.length>0){H.__webglFramebuffer[xe]=[];for(let be=0;be<E.mipmaps.length;be++)H.__webglFramebuffer[xe][be]=n.createFramebuffer()}else H.__webglFramebuffer[xe]=n.createFramebuffer()}else{if(E.mipmaps&&E.mipmaps.length>0){H.__webglFramebuffer=[];for(let xe=0;xe<E.mipmaps.length;xe++)H.__webglFramebuffer[xe]=n.createFramebuffer()}else H.__webglFramebuffer=n.createFramebuffer();if(Ue)for(let xe=0,be=le.length;xe<be;xe++){let Ve=i.get(le[xe]);Ve.__webglTexture===void 0&&(Ve.__webglTexture=n.createTexture(),o.memory.textures++)}if(L.samples>0&&me(L)===!1){H.__webglMultisampledFramebuffer=n.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let xe=0;xe<le.length;xe++){let be=le[xe];H.__webglColorRenderbuffer[xe]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,H.__webglColorRenderbuffer[xe]);let Ve=s.convert(be.format,be.colorSpace),pe=s.convert(be.type),Oe=v(be.internalFormat,Ve,pe,be.colorSpace,L.isXRRenderTarget===!0),Ge=Q(L);n.renderbufferStorageMultisample(n.RENDERBUFFER,Ge,Oe,L.width,L.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+xe,n.RENDERBUFFER,H.__webglColorRenderbuffer[xe])}n.bindRenderbuffer(n.RENDERBUFFER,null),L.depthBuffer&&(H.__webglDepthRenderbuffer=n.createRenderbuffer(),Z(H.__webglDepthRenderbuffer,L,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(re){t.bindTexture(n.TEXTURE_CUBE_MAP,te.__webglTexture),fe(n.TEXTURE_CUBE_MAP,E);for(let xe=0;xe<6;xe++)if(E.mipmaps&&E.mipmaps.length>0)for(let be=0;be<E.mipmaps.length;be++)q(H.__webglFramebuffer[xe][be],L,E,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+xe,be);else q(H.__webglFramebuffer[xe],L,E,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+xe,0);g(E)&&m(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ue){for(let xe=0,be=le.length;xe<be;xe++){let Ve=le[xe],pe=i.get(Ve);t.bindTexture(n.TEXTURE_2D,pe.__webglTexture),fe(n.TEXTURE_2D,Ve),q(H.__webglFramebuffer,L,Ve,n.COLOR_ATTACHMENT0+xe,n.TEXTURE_2D,0),g(Ve)&&m(n.TEXTURE_2D)}t.unbindTexture()}else{let xe=n.TEXTURE_2D;if((L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(xe=L.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(xe,te.__webglTexture),fe(xe,E),E.mipmaps&&E.mipmaps.length>0)for(let be=0;be<E.mipmaps.length;be++)q(H.__webglFramebuffer[be],L,E,n.COLOR_ATTACHMENT0,xe,be);else q(H.__webglFramebuffer,L,E,n.COLOR_ATTACHMENT0,xe,0);g(E)&&m(xe),t.unbindTexture()}L.depthBuffer&&ae(L)}function B(L){let E=L.textures;for(let H=0,te=E.length;H<te;H++){let le=E[H];if(g(le)){let re=L.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,Ue=i.get(le).__webglTexture;t.bindTexture(re,Ue),m(re),t.unbindTexture()}}}let Je=[],X=[];function he(L){if(L.samples>0){if(me(L)===!1){let E=L.textures,H=L.width,te=L.height,le=n.COLOR_BUFFER_BIT,re=L.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ue=i.get(L),xe=E.length>1;if(xe)for(let be=0;be<E.length;be++)t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+be,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+be,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer);for(let be=0;be<E.length;be++){if(L.resolveDepthBuffer&&(L.depthBuffer&&(le|=n.DEPTH_BUFFER_BIT),L.stencilBuffer&&L.resolveStencilBuffer&&(le|=n.STENCIL_BUFFER_BIT)),xe){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ue.__webglColorRenderbuffer[be]);let Ve=i.get(E[be]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Ve,0)}n.blitFramebuffer(0,0,H,te,0,0,H,te,le,n.NEAREST),c===!0&&(Je.length=0,X.length=0,Je.push(n.COLOR_ATTACHMENT0+be),L.depthBuffer&&L.resolveDepthBuffer===!1&&(Je.push(re),X.push(re),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,X)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Je))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),xe)for(let be=0;be<E.length;be++){t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+be,n.RENDERBUFFER,Ue.__webglColorRenderbuffer[be]);let Ve=i.get(E[be]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+be,n.TEXTURE_2D,Ve,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer)}else if(L.depthBuffer&&L.resolveDepthBuffer===!1&&c){let E=L.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[E])}}}function Q(L){return Math.min(r.maxSamples,L.samples)}function me(L){let E=i.get(L);return L.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function K(L){let E=o.render.frame;u.get(L)!==E&&(u.set(L,E),L.update())}function we(L,E){let H=L.colorSpace,te=L.format,le=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||H!==Ti&&H!==pi&&(mt.getTransfer(H)===wt?(te!==mn||le!==Si)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",H)),E}function De(L){return typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement?(l.width=L.naturalWidth||L.width,l.height=L.naturalHeight||L.height):typeof VideoFrame<"u"&&L instanceof VideoFrame?(l.width=L.displayWidth,l.height=L.displayHeight):(l.width=L.width,l.height=L.height),l}this.allocateTextureUnit=D,this.resetTextureUnits=b,this.setTexture2D=F,this.setTexture2DArray=$,this.setTexture3D=W,this.setTextureCube=ne,this.rebindTextures=Ie,this.setupRenderTarget=Re,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=he,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=q,this.useMultisampledRTT=me}function xv(n,e){function t(i,r=pi){let s,o=mt.getTransfer(r);if(i===Si)return n.UNSIGNED_BYTE;if(i===wp)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Mp)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Vy)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===By)return n.BYTE;if(i===zy)return n.SHORT;if(i===bp)return n.UNSIGNED_SHORT;if(i===_p)return n.INT;if(i===Dr)return n.UNSIGNED_INT;if(i===Cn)return n.FLOAT;if(i===Ua)return n.HALF_FLOAT;if(i===$y)return n.ALPHA;if(i===Hy)return n.RGB;if(i===mn)return n.RGBA;if(i===Gy)return n.LUMINANCE;if(i===jy)return n.LUMINANCE_ALPHA;if(i===Pr)return n.DEPTH_COMPONENT;if(i===Os)return n.DEPTH_STENCIL;if(i===Sp)return n.RED;if(i===Ep)return n.RED_INTEGER;if(i===Wy)return n.RG;if(i===Ap)return n.RG_INTEGER;if(i===Tp)return n.RGBA_INTEGER;if(i===gl||i===yl||i===vl||i===xl)if(o===wt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===gl)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===yl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===vl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===xl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===gl)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===yl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===vl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===xl)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ah||i===Th||i===Ih||i===Ch)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Ah)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Th)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ih)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ch)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Rh||i===Ph||i===Lh)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Rh||i===Ph)return o===wt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Lh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Dh||i===Oh||i===Uh||i===Nh||i===Fh||i===kh||i===Bh||i===zh||i===Vh||i===$h||i===Hh||i===Gh||i===jh||i===Wh)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Dh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Oh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Uh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Nh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Fh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===kh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Bh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===zh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Vh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===$h)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Hh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Gh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===jh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Wh)return o===wt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===bl||i===Xh||i===Yh)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===bl)return o===wt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Xh)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Yh)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Xy||i===qh||i===Zh||i===Jh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===bl)return s.COMPRESSED_RED_RGTC1_EXT;if(i===qh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Zh)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Jh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Xs?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}function lI(n,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function i(g,m){m.color.getRGB(g.fogColor.value,dv(n)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,v,x,w){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),d(g,m)):m.isMeshPhongMaterial?(s(g,m),u(g,m)):m.isMeshStandardMaterial?(s(g,m),h(g,m),m.isMeshPhysicalMaterial&&f(g,m,w)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),y(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(o(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?c(g,m,v,x):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===on&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===on&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v=e.get(m),x=v.envMap,w=v.envMapRotation;if(x&&(g.envMap.value=x,yr.copy(w),yr.x*=-1,yr.y*=-1,yr.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(yr.y*=-1,yr.z*=-1),g.envMapRotation.value.setFromMatrix4(cI.makeRotationFromEuler(yr)),g.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let O=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*O,t(m.lightMap,g.lightMapTransform)}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function o(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function c(g,m,v,x){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*v,g.scale.value=x*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function u(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function d(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function h(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,v){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===on&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function y(g,m){let v=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function uI(n,e,t,i){let r={},s={},o=[],a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,x){let w=x.program;i.uniformBlockBinding(v,w)}function l(v,x){let w=r[v.id];w===void 0&&(p(v),w=u(v),r[v.id]=w,v.addEventListener("dispose",g));let O=x.program;i.updateUBOMapping(v,O);let I=e.render.frame;s[v.id]!==I&&(h(v),s[v.id]=I)}function u(v){let x=d();v.__bindingPointIndex=x;let w=n.createBuffer(),O=v.__size,I=v.usage;return n.bindBuffer(n.UNIFORM_BUFFER,w),n.bufferData(n.UNIFORM_BUFFER,O,I),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,x,w),w}function d(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let x=r[v.id],w=v.uniforms,O=v.__cache;n.bindBuffer(n.UNIFORM_BUFFER,x);for(let I=0,R=w.length;I<R;I++){let U=Array.isArray(w[I])?w[I]:[w[I]];for(let _=0,b=U.length;_<b;_++){let D=U[_];if(f(D,I,_,O)===!0){let z=D.__offset,F=Array.isArray(D.value)?D.value:[D.value],$=0;for(let W=0;W<F.length;W++){let ne=F[W],J=y(ne);typeof ne=="number"||typeof ne=="boolean"?(D.__data[0]=ne,n.bufferSubData(n.UNIFORM_BUFFER,z+$,D.__data)):ne.isMatrix3?(D.__data[0]=ne.elements[0],D.__data[1]=ne.elements[1],D.__data[2]=ne.elements[2],D.__data[3]=0,D.__data[4]=ne.elements[3],D.__data[5]=ne.elements[4],D.__data[6]=ne.elements[5],D.__data[7]=0,D.__data[8]=ne.elements[6],D.__data[9]=ne.elements[7],D.__data[10]=ne.elements[8],D.__data[11]=0):(ne.toArray(D.__data,$),$+=J.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,z,D.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(v,x,w,O){let I=v.value,R=x+"_"+w;if(O[R]===void 0)return typeof I=="number"||typeof I=="boolean"?O[R]=I:O[R]=I.clone(),!0;{let U=O[R];if(typeof I=="number"||typeof I=="boolean"){if(U!==I)return O[R]=I,!0}else if(U.equals(I)===!1)return U.copy(I),!0}return!1}function p(v){let x=v.uniforms,w=0,O=16;for(let R=0,U=x.length;R<U;R++){let _=Array.isArray(x[R])?x[R]:[x[R]];for(let b=0,D=_.length;b<D;b++){let z=_[b],F=Array.isArray(z.value)?z.value:[z.value];for(let $=0,W=F.length;$<W;$++){let ne=F[$],J=y(ne),V=w%O;V!==0&&O-V<J.boundary&&(w+=O-V),z.__data=new Float32Array(J.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=w,w+=J.storage}}}let I=w%O;return I>0&&(w+=O-I),v.__size=w,v.__cache={},this}function y(v){let x={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let w=o.indexOf(x.__bindingPointIndex);o.splice(w,1),n.deleteBuffer(r[x.id]),delete r[x.id],delete s[x.id]}function m(){for(let v in r)n.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:m}}function Xc(n,e,t,i,r,s){Es.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Lo.x=s*Es.x-r*Es.y,Lo.y=r*Es.x+s*Es.y):Lo.copy(Es),n.copy(e),n.x+=Lo.x,n.y+=Lo.y,n.applyMatrix4(bv)}function pI(n,e){return n.z-e.z}function mI(n,e){return e.z-n.z}function yI(n,e,t=0){let i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){let r=n.count;for(let s=0;s<r;s++)for(let o=0;o<i;o++)e.setComponent(s+t,o,n.getComponent(s,o))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function el(n,e,t,i,r,s){let o=n.geometry.attributes.position;if(kl.fromBufferAttribute(o,r),Bl.fromBufferAttribute(o,s),t.distanceSqToSegment(kl,Bl,hh,S0)>i)return;hh.applyMatrix4(n.matrixWorld);let c=e.ray.origin.distanceTo(hh);if(!(c<e.near||c>e.far))return{distance:c,point:S0.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}function I0(n,e,t,i,r,s,o){let a=xf.distanceSqToPoint(n);if(a<t){let c=new P;xf.closestPointToPoint(n,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}function Lp(){let n=0,e=0,t=0,i=0;function r(s,o,a,c){n=s,e=a,t=-3*s+3*o-2*a-c,i=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,d){let h=(o-s)/l-(a-s)/(l+u)+(a-o)/u,f=(a-o)/u-(c-o)/(u+d)+(c-a)/d;h*=u,f*=u,r(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return n+e*s+t*o+i*a}}}function C0(n,e,t,i,r){let s=(i-e)*.5,o=(r-t)*.5,a=n*n,c=n*a;return(2*t-2*i+s+o)*c+(-3*t+3*i-2*s-o)*a+s*n+t}function vI(n,e){let t=1-n;return t*t*e}function xI(n,e){return 2*(1-n)*n*e}function bI(n,e){return n*n*e}function Go(n,e,t,i){return vI(n,e)+xI(n,t)+bI(n,i)}function _I(n,e){let t=1-n;return t*t*t*e}function wI(n,e){let t=1-n;return 3*t*t*n*e}function MI(n,e){return 3*(1-n)*n*n*e}function SI(n,e){return n*n*n*e}function jo(n,e,t,i,r){return _I(n,e)+wI(n,t)+MI(n,i)+SI(n,r)}function _v(n,e,t,i,r){let s,o;if(r===VI(n,e,t,i)>0)for(s=e;s<t;s+=i)o=R0(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=R0(s,n[s],n[s+1],o);return o&&Bu(o,o.next)&&(Sa(o),o=o.next),o}function Br(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Bu(t,t.next)||St(t.prev,t,t.next)===0)){if(Sa(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function wa(n,e,t,i,r,s,o){if(!n)return;!o&&s&&UI(n,i,r,s);let a=n,c,l;for(;n.prev!==n.next;){if(c=n.prev,l=n.next,s?TI(n,i,r,s):AI(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Sa(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=II(Br(n),e,t),wa(n,e,t,i,r,s,2)):o===2&&CI(n,e,t,i,r,s):wa(Br(n),e,t,i,r,s,1);break}}}function AI(n){let e=n.prev,t=n,i=n.next;if(St(e,t,i)>=0)return!1;let r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=r<s?r<o?r:o:s<o?s:o,d=a<c?a<l?a:l:c<l?c:l,h=r>s?r>o?r:o:s>o?s:o,f=a>c?a>l?a:l:c>l?c:l,p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Ps(r,a,s,c,o,l,p.x,p.y)&&St(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function TI(n,e,t,i){let r=n.prev,s=n,o=n.next;if(St(r,s,o)>=0)return!1;let a=r.x,c=s.x,l=o.x,u=r.y,d=s.y,h=o.y,f=a<c?a<l?a:l:c<l?c:l,p=u<d?u<h?u:h:d<h?d:h,y=a>c?a>l?a:l:c>l?c:l,g=u>d?u>h?u:h:d>h?d:h,m=Ef(f,p,e,t,i),v=Ef(y,g,e,t,i),x=n.prevZ,w=n.nextZ;for(;x&&x.z>=m&&w&&w.z<=v;){if(x.x>=f&&x.x<=y&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Ps(a,u,c,d,l,h,x.x,x.y)&&St(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=f&&w.x<=y&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Ps(a,u,c,d,l,h,w.x,w.y)&&St(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=m;){if(x.x>=f&&x.x<=y&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Ps(a,u,c,d,l,h,x.x,x.y)&&St(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=v;){if(w.x>=f&&w.x<=y&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Ps(a,u,c,d,l,h,w.x,w.y)&&St(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function II(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!Bu(r,s)&&wv(r,i,i.next,s)&&Ma(r,s)&&Ma(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Sa(i),Sa(i.next),i=n=s),i=i.next}while(i!==n);return Br(i)}function CI(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&kI(o,a)){let c=Mv(o,a);o=Br(o,o.next),c=Br(c,c.next),wa(o,e,t,i,r,s,0),wa(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function RI(n,e,t,i){let r=[],s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*i,c=s<o-1?e[s+1]*i:n.length,l=_v(n,a,c,i,!1),l===l.next&&(l.steiner=!0),r.push(FI(l));for(r.sort(PI),s=0;s<r.length;s++)t=LI(r[s],t);return t}function PI(n,e){return n.x-e.x}function LI(n,e){let t=DI(n,e);if(!t)return e;let i=Mv(t,n);return Br(i,i.next),Br(t,t.next)}function DI(n,e){let t=e,i=-1/0,r,s=n.x,o=n.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let h=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=s&&h>i&&(i=h,r=t.x<t.next.x?t:t.next,h===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,c=r.x,l=r.y,u=1/0,d;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&Ps(o<l?s:i,o,c,l,o<l?i:s,o,t.x,t.y)&&(d=Math.abs(o-t.y)/(s-t.x),Ma(t,n)&&(d<u||d===u&&(t.x>r.x||t.x===r.x&&OI(r,t)))&&(r=t,u=d)),t=t.next;while(t!==a);return r}function OI(n,e){return St(n.prev,n,e.prev)<0&&St(e.next,n,n.next)<0}function UI(n,e,t,i){let r=n;do r.z===0&&(r.z=Ef(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,NI(r)}function NI(n){let e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<l&&(a++,i=i.nextZ,!!i);e++);for(c=l;a>0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function Ef(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function FI(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Ps(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function kI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!BI(n,e)&&(Ma(n,e)&&Ma(e,n)&&zI(n,e)&&(St(n.prev,n,e.prev)||St(n,e.prev,e))||Bu(n,e)&&St(n.prev,n,n.next)>0&&St(e.prev,e,e.next)>0)}function St(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Bu(n,e){return n.x===e.x&&n.y===e.y}function wv(n,e,t,i){let r=cl(St(n,e,t)),s=cl(St(n,e,i)),o=cl(St(t,i,n)),a=cl(St(t,i,e));return!!(r!==s&&o!==a||r===0&&al(n,t,e)||s===0&&al(n,i,e)||o===0&&al(t,n,i)||a===0&&al(t,e,i))}function al(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function cl(n){return n>0?1:n<0?-1:0}function BI(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&wv(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Ma(n,e){return St(n.prev,n,n.next)<0?St(n,e,n.next)>=0&&St(n,n.prev,e)>=0:St(n,e,n.prev)<0||St(n,n.next,e)<0}function zI(n,e){let t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function Mv(n,e){let t=new Af(n.i,n.x,n.y),i=new Af(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function R0(n,e,t,i){let r=new Af(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Sa(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Af(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function VI(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}function P0(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function L0(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}function HI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){let s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}function GI(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}function D0(n,e,t){let i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}function Cr(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Sv(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ev(n){function e(r,s){return n[r]-n[s]}let t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Tf(n,e,t){let i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){let a=t[s]*e;for(let c=0;c!==e;++c)r[o++]=n[a+c]}return r}function Dp(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function jI(n,e,t,i,r=30){let s=n.clone();s.name=e;let o=[];for(let c=0;c<s.tracks.length;++c){let l=s.tracks[c],u=l.getValueSize(),d=[],h=[];for(let f=0;f<l.times.length;++f){let p=l.times[f]*r;if(!(p<t||p>=i)){d.push(l.times[f]);for(let y=0;y<u;++y)h.push(l.values[f*u+y])}}d.length!==0&&(l.times=Cr(d,l.times.constructor),l.values=Cr(h,l.values.constructor),o.push(l))}s.tracks=o;let a=1/0;for(let c=0;c<s.tracks.length;++c)a>s.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c<s.tracks.length;++c)s.tracks[c].shift(-1*a);return s.resetDuration(),s}function WI(n,e=0,t=n,i=30){i<=0&&(i=30);let r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){let a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=n.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===c});if(l===void 0)continue;let u=0,d=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=d/3);let h=0,f=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=f/3);let p=a.times.length-1,y;if(s<=a.times[0]){let m=u,v=d-u;y=a.values.slice(m,v)}else if(s>=a.times[p]){let m=p*d+u,v=m+d-u;y=a.values.slice(m,v)}else{let m=a.createInterpolant(),v=u,x=d-u;m.evaluate(s),y=m.resultBuffer.slice(v,x)}c==="quaternion"&&new Qt().fromArray(y).normalize().conjugate().toArray(y);let g=l.times.length;for(let m=0;m<g;++m){let v=m*f+h;if(c==="quaternion")Qt.multiplyQuaternionsFlat(l.values,v,y,0,l.values,v);else{let x=f-h*2;for(let w=0;w<x;++w)l.values[v+w]-=y[w]}}}return n.blendMode=Ip,n}function YI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Vr;case"vector":case"vector2":case"vector3":case"vector4":return $r;case"color":return Ca;case"quaternion":return Ki;case"bool":case"boolean":return Ei;case"string":return Ai}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function qI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=YI(n.type);if(n.times===void 0){let t=[],i=[];Dp(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}function $0(){return(typeof performance>"u"?Date:performance).now()}function W0(n,e){return n.distance-e.distance}function Kf(n,e,t,i){if(n.layers.test(e.layers)&&n.raycast(e,t),i===!0){let r=n.children;for(let s=0,o=r.length;s<o;s++)Kf(r[s],e,t,!0)}}function Tv(n){let e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Tv(n.children[t]));return e}function Rt(n,e,t,i,r,s,o){fl.set(r,s,o).unproject(i);let a=e[n];if(a!==void 0){let c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],fl.x,fl.y,fl.z)}}var _M,wM,MM,ty,_h,ny,SM,EM,vp,iy,Hn,wi,on,jn,xi,Rr,wh,Mh,Sh,ry,Wi,sy,oy,ay,cy,ly,uy,dy,hy,wl,Ml,fy,py,my,gy,yy,vy,xy,by,_y,wy,My,Sy,Wo,Ey,Ay,Ty,Iy,Oa,Cy,Ry,bi,Py,Ly,Dy,Oy,Uy,Ny,Fy,Eh,ky,Uu,Mi,Yi,Xo,Yo,Ws,qo,In,Zo,zt,xp,AM,Is,TM,Lt,Vo,IM,Wn,CM,Si,By,zy,bp,_p,Dr,Cn,Ua,wp,Mp,Xs,Vy,$y,Hy,mn,Gy,jy,Pr,Os,Sp,Ep,Wy,Ap,Tp,gl,yl,vl,xl,Ah,Th,Ih,Ch,Rh,Ph,Lh,Dh,Oh,Uh,Nh,Fh,kh,Bh,zh,Vh,$h,Hh,Gh,jh,Wh,bl,Xh,Yh,Xy,qh,Zh,Jh,Yy,qy,Zy,Jo,Ko,_l,Tr,Ir,Qo,Nu,Ip,RM,PM,LM,Jy,Ky,Qi,Qy,pi,Tn,Ti,Fu,Na,ea,wt,ta,na,DM,Sr,OM,UM,NM,FM,kM,BM,zM,VM,$M,HM,GM,jM,WM,Kh,ev,tv,nv,Cp,iv,rv,sv,ov,ia,XM,YM,qM,ZM,JM,KM,QM,eS,tS,Qh,Xn,ra,Bn,Zt,Mg,Lr,Us,vS,oe,Qe,Fd,xS,Sg,Eg,Ag,Sc,bS,mt,os,Sl,_S,gi,wS,Dt,gt,El,yn,Ns,ef,oa,tf,Qt,P,zd,Tg,Gt,ci,Un,Ec,as,cs,ls,ki,Bi,hr,To,Ac,Tc,fr,MS,Io,$d,Vt,li,Hd,Ic,zi,Gd,Cc,jd,qi,ze,us,Nn,SS,ES,Vi,Rc,fn,Ig,Cg,vn,Fs,AS,Rg,ds,ui,Pc,Co,TS,IS,Pg,Lg,Dg,Og,CS,hs,Wd,ht,Fn,di,Xd,hi,fs,ps,Ug,Yd,qd,Zd,yi,uv,$i,Lc,Ce,Jt,RS,$t,Zn,mi,LS,Pt,Dc,ut,nf,rf,sf,of,aa,af,ca,cf,Le,DS,An,Kd,ms,pn,Ro,Bt,it,Ng,pr,Oc,Fg,gs,ys,vs,Qd,Uc,Nc,Fc,kc,kg,Bg,zg,Bc,zc,It,Or,hv,NS,FS,xn,Bs,Hi,Vg,$g,Ut,xs,bs,Al,Ur,Tl,eh,kS,BS,Gn,mr,$c,Nr,zs,VS,$S,HS,GS,jS,WS,XS,YS,qS,ZS,JS,KS,QS,e1,t1,n1,i1,r1,s1,o1,a1,c1,l1,u1,d1,h1,f1,p1,m1,g1,y1,v1,x1,b1,_1,w1,M1,S1,E1,A1,T1,I1,C1,R1,P1,L1,D1,O1,U1,N1,F1,k1,B1,z1,V1,$1,H1,G1,j1,W1,X1,Y1,q1,Z1,J1,K1,Q1,eE,tE,nE,iE,rE,sE,oE,aE,cE,lE,uE,dE,hE,fE,pE,mE,gE,yE,vE,xE,bE,_E,wE,ME,SE,EE,AE,TE,IE,CE,RE,PE,LE,DE,OE,UE,NE,FE,kE,BE,zE,VE,$E,HE,GE,jE,WE,XE,YE,qE,ZE,JE,KE,QE,eA,tA,nA,iA,rA,sA,oA,aA,cA,lA,uA,dA,hA,fA,pA,mA,gA,yA,vA,xA,tt,Ee,kn,Hc,gr,bA,Vs,Rs,Hg,Ar,th,Gg,nh,ih,rh,sh,Er,_s,jg,la,ua,pv,mv,gv,yv,vv,qg,Zg,Jg,Kg,Qg,lf,uf,df,oh,Ds,MT,ST,LT,DT,UT,HT,ff,pf,ZT,da,ha,eI,tI,Il,Xi,sI,Ho,oI,aI,mf,gf,yr,cI,yf,Cl,Rl,Pl,$s,nn,Fr,fa,ws,Po,Ms,Ss,Es,Lo,bv,jc,Do,Wc,u0,ah,d0,Ll,Yc,h0,Dl,f0,p0,m0,dI,g0,qc,ch,y0,lh,Ol,pa,Yn,v0,hI,Ul,Zi,As,x0,Zc,b0,fI,Oo,Uo,Nl,vf,Ts,Gi,_0,gI,w0,uh,Jc,vr,No,dh,Kt,Kc,Fl,jt,kl,Bl,M0,Fo,Qc,hh,S0,Jn,E0,A0,Rn,zl,ma,T0,xf,tl,nl,Vl,bf,_f,Hs,wf,Mf,Sf,bn,Gs,$l,il,fh,ph,mh,Hl,ga,Gl,ya,jl,va,xa,ba,Wl,Xl,kr,_a,Yl,ql,js,Zl,Ji,Jl,rl,sl,gh,ol,Kl,_i,EI,qn,Ql,$I,eu,Ea,tu,nu,Aa,iu,ru,su,ou,au,O0,cu,lu,Ta,uu,du,hu,fu,pu,mu,gu,XI,zr,yu,Ia,vu,_n,Ei,Ca,Vr,xu,Ki,Ai,$r,Hr,vi,Ra,Av,en,fi,If,zn,Cf,Rf,Gr,Pf,Lf,Df,Kn,bu,yh,U0,N0,Pa,Of,_u,F0,ko,vh,Uf,wu,Nf,Mu,Su,Eu,Au,Tu,Iu,La,Cu,Ru,Ff,ZI,k0,B0,kf,ll,Da,Bf,z0,V0,xr,zf,Pu,br,H0,JI,_r,Vf,Lu,wr,G0,KI,Mr,$f,Hf,Du,Op,QI,Up,e2,t2,n2,i2,r2,s2,o2,Gf,pt,jf,Ou,a2,Wf,Xf,c2,Yf,qf,Zf,j0,Jf,Qf,ep,X0,tp,Y0,ul,np,q0,ip,ji,dl,xh,rp,sp,l2,Z0,J0,op,ap,cp,K0,hl,Q0,lp,fl,At,up,pl,dp,hp,fp,ey,ml,bh,pp,mp,gp,yp,Cv=hx(()=>{"use strict";_M="164",wM={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},MM={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ty=0,_h=1,ny=2,SM=3,EM=0,vp=1,iy=2,Hn=3,wi=0,on=1,jn=2,xi=0,Rr=1,wh=2,Mh=3,Sh=4,ry=5,Wi=100,sy=101,oy=102,ay=103,cy=104,ly=200,uy=201,dy=202,hy=203,wl=204,Ml=205,fy=206,py=207,my=208,gy=209,yy=210,vy=211,xy=212,by=213,_y=214,wy=0,My=1,Sy=2,Wo=3,Ey=4,Ay=5,Ty=6,Iy=7,Oa=0,Cy=1,Ry=2,bi=0,Py=1,Ly=2,Dy=3,Oy=4,Uy=5,Ny=6,Fy=7,Eh="attached",ky="detached",Uu=300,Mi=301,Yi=302,Xo=303,Yo=304,Ws=306,qo=1e3,In=1001,Zo=1002,zt=1003,xp=1004,AM=1004,Is=1005,TM=1005,Lt=1006,Vo=1007,IM=1007,Wn=1008,CM=1008,Si=1009,By=1010,zy=1011,bp=1012,_p=1013,Dr=1014,Cn=1015,Ua=1016,wp=1017,Mp=1018,Xs=1020,Vy=35902,$y=1021,Hy=1022,mn=1023,Gy=1024,jy=1025,Pr=1026,Os=1027,Sp=1028,Ep=1029,Wy=1030,Ap=1031,Tp=1033,gl=33776,yl=33777,vl=33778,xl=33779,Ah=35840,Th=35841,Ih=35842,Ch=35843,Rh=36196,Ph=37492,Lh=37496,Dh=37808,Oh=37809,Uh=37810,Nh=37811,Fh=37812,kh=37813,Bh=37814,zh=37815,Vh=37816,$h=37817,Hh=37818,Gh=37819,jh=37820,Wh=37821,bl=36492,Xh=36494,Yh=36495,Xy=36283,qh=36284,Zh=36285,Jh=36286,Yy=2200,qy=2201,Zy=2202,Jo=2300,Ko=2301,_l=2302,Tr=2400,Ir=2401,Qo=2402,Nu=2500,Ip=2501,RM=0,PM=1,LM=2,Jy=3200,Ky=3201,Qi=0,Qy=1,pi="",Tn="srgb",Ti="srgb-linear",Fu="display-p3",Na="display-p3-linear",ea="linear",wt="srgb",ta="rec709",na="p3",DM=0,Sr=7680,OM=7681,UM=7682,NM=7683,FM=34055,kM=34056,BM=5386,zM=512,VM=513,$M=514,HM=515,GM=516,jM=517,WM=518,Kh=519,ev=512,tv=513,nv=514,Cp=515,iv=516,rv=517,sv=518,ov=519,ia=35044,XM=35048,YM=35040,qM=35045,ZM=35049,JM=35041,KM=35046,QM=35050,eS=35042,tS="100",Qh="300 es",Xn=2e3,ra=2001,Bn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}},Zt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Mg=1234567,Lr=Math.PI/180,Us=180/Math.PI;vS={DEG2RAD:Lr,RAD2DEG:Us,generateUUID:gn,clamp:Tt,euclideanModulo:Rp,mapLinear:nS,inverseLerp:iS,lerp:$o,damp:rS,pingpong:sS,smoothstep:oS,smootherstep:aS,randInt:cS,randFloat:lS,randFloatSpread:uS,seededRandom:dS,degToRad:hS,radToDeg:fS,isPowerOfTwo:pS,ceilPowerOfTwo:mS,floorPowerOfTwo:gS,setQuaternionFromProperEuler:yS,normalize:et,denormalize:sn},oe=class n{constructor(e=0,t=0){n.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Tt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Qe=class n{constructor(e,t,i,r,s,o,a,c,l){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l)}set(e,t,i,r,s,o,a,c,l){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=i,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],y=r[0],g=r[3],m=r[6],v=r[1],x=r[4],w=r[7],O=r[2],I=r[5],R=r[8];return s[0]=o*y+a*v+c*O,s[3]=o*g+a*x+c*I,s[6]=o*m+a*w+c*R,s[1]=l*y+u*v+d*O,s[4]=l*g+u*x+d*I,s[7]=l*m+u*w+d*R,s[2]=h*y+f*v+p*O,s[5]=h*g+f*x+p*I,s[8]=h*m+f*w+p*R,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-i*s*u+i*a*c+r*s*l-r*o*c}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=u*o-a*l,h=a*c-u*s,f=l*s-o*c,p=t*d+i*h+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/p;return e[0]=d*y,e[1]=(r*l-u*i)*y,e[2]=(a*i-r*o)*y,e[3]=h*y,e[4]=(u*t-r*c)*y,e[5]=(r*s-a*t)*y,e[6]=f*y,e[7]=(i*c-l*t)*y,e[8]=(o*t-i*s)*y,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){let c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*o+l*a)+o+e,-r*l,r*c,-r*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Fd.makeScale(e,t)),this}rotate(e){return this.premultiply(Fd.makeRotation(-e)),this}translate(e,t){return this.premultiply(Fd.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Fd=new Qe;xS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};Sg={};Eg=new Qe().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ag=new Qe().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Sc={[Ti]:{transfer:ea,primaries:ta,toReference:n=>n,fromReference:n=>n},[Tn]:{transfer:wt,primaries:ta,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[Na]:{transfer:ea,primaries:na,toReference:n=>n.applyMatrix3(Ag),fromReference:n=>n.applyMatrix3(Eg)},[Fu]:{transfer:wt,primaries:na,toReference:n=>n.convertSRGBToLinear().applyMatrix3(Ag),fromReference:n=>n.applyMatrix3(Eg).convertLinearToSRGB()}},bS=new Set([Ti,Na]),mt={enabled:!0,_workingColorSpace:Ti,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!bS.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;let i=Sc[e].toReference,r=Sc[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Sc[n].primaries},getTransfer:function(n){return n===pi?ea:Sc[n].transfer}};Sl=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{os===void 0&&(os=sa("canvas")),os.width=e.width,os.height=e.height;let i=os.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=os}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=sa("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Ls(s[o]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Ls(t[i]/255)*255):t[i]=Ls(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},_S=0,gi=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:_S++}),this.uuid=gn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Bd(r[o].image)):s.push(Bd(r[o]))}else s=Bd(r);i.url=s}return t||(e.images[this.uuid]=i),i}};wS=0,Dt=class n extends Bn{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=In,r=In,s=Lt,o=Wn,a=mn,c=Si,l=n.DEFAULT_ANISOTROPY,u=pi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:wS++}),this.uuid=gn(),this.name="",this.source=new gi(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new oe(0,0),this.repeat=new oe(1,1),this.center=new oe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Qe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Uu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case qo:e.x=e.x-Math.floor(e.x);break;case In:e.x=e.x<0?0:1;break;case Zo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case qo:e.y=e.y-Math.floor(e.y);break;case In:e.y=e.y<0?0:1;break;case Zo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Dt.DEFAULT_IMAGE=null;Dt.DEFAULT_MAPPING=Uu;Dt.DEFAULT_ANISOTROPY=1;gt=class n{constructor(e=0,t=0,i=0,r=1){n.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,c=e.elements,l=c[0],u=c[4],d=c[8],h=c[1],f=c[5],p=c[9],y=c[2],g=c[6],m=c[10];if(Math.abs(u-h)<.01&&Math.abs(d-y)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+y)<.1&&Math.abs(p+g)<.1&&Math.abs(l+f+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let x=(l+1)/2,w=(f+1)/2,O=(m+1)/2,I=(u+h)/4,R=(d+y)/4,U=(p+g)/4;return x>w&&x>O?x<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(x),r=I/i,s=R/i):w>O?w<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(w),i=I/r,s=U/r):O<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(O),i=R/s,r=U/s),this.set(i,r,s,t),this}let v=Math.sqrt((g-p)*(g-p)+(d-y)*(d-y)+(h-u)*(h-u));return Math.abs(v)<.001&&(v=1),this.x=(g-p)/v,this.y=(d-y)/v,this.z=(h-u)/v,this.w=Math.acos((l+f+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},El=class extends Bn{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new gt(0,0,e,t),this.scissorTest=!1,this.viewport=new gt(0,0,e,t);let r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Lt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);let s=new Dt(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];let o=i.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new gi(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},yn=class extends El{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},Ns=class extends Dt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=zt,this.minFilter=zt,this.wrapR=In,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ef=class extends yn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ns(null,e,t,i),this.texture.isRenderTargetTexture=!0}},oa=class extends Dt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=zt,this.minFilter=zt,this.wrapR=In,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tf=class extends yn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new oa(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Qt=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let c=i[r+0],l=i[r+1],u=i[r+2],d=i[r+3],h=s[o+0],f=s[o+1],p=s[o+2],y=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d;return}if(a===1){e[t+0]=h,e[t+1]=f,e[t+2]=p,e[t+3]=y;return}if(d!==y||c!==h||l!==f||u!==p){let g=1-a,m=c*h+l*f+u*p+d*y,v=m>=0?1:-1,x=1-m*m;if(x>Number.EPSILON){let O=Math.sqrt(x),I=Math.atan2(O,m*v);g=Math.sin(g*I)/O,a=Math.sin(a*I)/O}let w=a*v;if(c=c*g+h*w,l=l*g+f*w,u=u*g+p*w,d=d*g+y*w,g===1-a){let O=1/Math.sqrt(c*c+l*l+u*u+d*d);c*=O,l*=O,u*=O,d*=O}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,o){let a=i[r],c=i[r+1],l=i[r+2],u=i[r+3],d=s[o],h=s[o+1],f=s[o+2],p=s[o+3];return e[t]=a*p+u*d+c*f-l*h,e[t+1]=c*p+u*h+l*d-a*f,e[t+2]=l*p+u*f+a*h-c*d,e[t+3]=u*p-a*d-c*h-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(i/2),u=a(r/2),d=a(s/2),h=c(i/2),f=c(r/2),p=c(s/2);switch(o){case"XYZ":this._x=h*u*d+l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d+h*f*p;break;case"YZX":this._x=h*u*d+l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d-h*f*p;break;case"XZY":this._x=h*u*d-l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d+h*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],d=t[10],h=i+a+d;if(h>0){let f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-c)*f,this._y=(s-l)*f,this._z=(o-r)*f}else if(i>a&&i>d){let f=2*Math.sqrt(1+i-a-d);this._w=(u-c)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+l)/f}else if(a>d){let f=2*Math.sqrt(1+a-i-d);this._w=(s-l)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(c+u)/f}else{let f=2*Math.sqrt(1+d-i-a);this._w=(o-r)/f,this._x=(s+l)/f,this._y=(c+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Tt(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=i*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-i*l,this._z=s*u+o*l+i*c-r*a,this._w=o*u-i*a-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*i+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),d=Math.sin((1-t)*u)/l,h=Math.sin(t*u)/l;return this._w=o*d+this._w*h,this._x=i*d+this._x*h,this._y=r*d+this._y*h,this._z=s*d+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},P=class n{constructor(e=0,t=0,i=0){n.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Tg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Tg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*r-a*i),u=2*(a*t-s*r),d=2*(s*i-o*t);return this.x=t+c*l+o*d-a*u,this.y=i+c*u+a*l-s*d,this.z=r+c*d+s*u-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return zd.copy(this).projectOnVector(e),this.sub(zd)}reflect(e){return this.sub(zd.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Tt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},zd=new P,Tg=new Qt,Gt=class{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Un.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Un.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Un.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Un):Un.fromBufferAttribute(s,o),Un.applyMatrix4(e.matrixWorld),this.expandByPoint(Un);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ec.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ec.copy(i.boundingBox)),Ec.applyMatrix4(e.matrixWorld),this.union(Ec)}let r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Un),Un.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(To),Ac.subVectors(this.max,To),as.subVectors(e.a,To),cs.subVectors(e.b,To),ls.subVectors(e.c,To),ki.subVectors(cs,as),Bi.subVectors(ls,cs),hr.subVectors(as,ls);let t=[0,-ki.z,ki.y,0,-Bi.z,Bi.y,0,-hr.z,hr.y,ki.z,0,-ki.x,Bi.z,0,-Bi.x,hr.z,0,-hr.x,-ki.y,ki.x,0,-Bi.y,Bi.x,0,-hr.y,hr.x,0];return!Vd(t,as,cs,ls,Ac)||(t=[1,0,0,0,1,0,0,0,1],!Vd(t,as,cs,ls,Ac))?!1:(Tc.crossVectors(ki,Bi),t=[Tc.x,Tc.y,Tc.z],Vd(t,as,cs,ls,Ac))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Un).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Un).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ci[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ci[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ci[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ci[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ci[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ci[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ci[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ci[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ci),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},ci=[new P,new P,new P,new P,new P,new P,new P,new P],Un=new P,Ec=new Gt,as=new P,cs=new P,ls=new P,ki=new P,Bi=new P,hr=new P,To=new P,Ac=new P,Tc=new P,fr=new P;MS=new Gt,Io=new P,$d=new P,Vt=class{constructor(e=new P,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):MS.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Io.subVectors(e,this.center);let t=Io.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Io,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):($d.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Io.copy(e.center).add($d)),this.expandByPoint(Io.copy(e.center).sub($d))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},li=new P,Hd=new P,Ic=new P,zi=new P,Gd=new P,Cc=new P,jd=new P,qi=class{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Hd.copy(e).add(t).multiplyScalar(.5),Ic.copy(t).sub(e).normalize(),zi.copy(this.origin).sub(Hd);let s=e.distanceTo(t)*.5,o=-this.direction.dot(Ic),a=zi.dot(this.direction),c=-zi.dot(Ic),l=zi.lengthSq(),u=Math.abs(1-o*o),d,h,f,p;if(u>0)if(d=o*c-a,h=o*a-c,p=s*u,d>=0)if(h>=-p)if(h<=p){let y=1/u;d*=y,h*=y,f=d*(d+o*h+2*a)+h*(o*d+h+2*c)+l}else h=s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;else h=-s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;else h<=-p?(d=Math.max(0,-(-o*s+a)),h=d>0?-s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l):h<=p?(d=0,h=Math.min(Math.max(-s,-c),s),f=h*(h+2*c)+l):(d=Math.max(0,-(o*s+a)),h=d>0?s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l);else h=o>0?-s:s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Hd).addScaledVector(Ic,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);let i=li.dot(this.direction),r=li.dot(li)-i*i,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,c,l=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),u>=0?(s=(e.min.y-h.y)*u,o=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,o=(e.min.y-h.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),d>=0?(a=(e.min.z-h.z)*d,c=(e.max.z-h.z)*d):(a=(e.max.z-h.z)*d,c=(e.min.z-h.z)*d),i>c||a>r)||((a>i||i!==i)&&(i=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,r,s){Gd.subVectors(t,e),Cc.subVectors(i,e),jd.crossVectors(Gd,Cc);let o=this.direction.dot(jd),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;zi.subVectors(this.origin,e);let c=a*this.direction.dot(Cc.crossVectors(zi,Cc));if(c<0)return null;let l=a*this.direction.dot(Gd.cross(zi));if(l<0||c+l>o)return null;let u=-a*zi.dot(jd);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ze=class n{constructor(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g){n.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g)}set(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=s,m[5]=o,m[9]=a,m[13]=c,m[2]=l,m[6]=u,m[10]=d,m[14]=h,m[3]=f,m[7]=p,m[11]=y,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/us.setFromMatrixColumn(e,0).length(),s=1/us.setFromMatrixColumn(e,1).length(),o=1/us.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=c*u,t[4]=-c*d,t[8]=l,t[1]=f+p*l,t[5]=h-y*l,t[9]=-a*c,t[2]=y-h*l,t[6]=p+f*l,t[10]=o*c}else if(e.order==="YXZ"){let h=c*u,f=c*d,p=l*u,y=l*d;t[0]=h+y*a,t[4]=p*a-f,t[8]=o*l,t[1]=o*d,t[5]=o*u,t[9]=-a,t[2]=f*a-p,t[6]=y+h*a,t[10]=o*c}else if(e.order==="ZXY"){let h=c*u,f=c*d,p=l*u,y=l*d;t[0]=h-y*a,t[4]=-o*d,t[8]=p+f*a,t[1]=f+p*a,t[5]=o*u,t[9]=y-h*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=c*u,t[4]=p*l-f,t[8]=h*l+y,t[1]=c*d,t[5]=y*l+h,t[9]=f*l-p,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let h=o*c,f=o*l,p=a*c,y=a*l;t[0]=c*u,t[4]=y-h*d,t[8]=p*d+f,t[1]=d,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=f*d+p,t[10]=h-y*d}else if(e.order==="XZY"){let h=o*c,f=o*l,p=a*c,y=a*l;t[0]=c*u,t[4]=-d,t[8]=l*u,t[1]=h*d+y,t[5]=o*u,t[9]=f*d-p,t[2]=p*d-f,t[6]=a*u,t[10]=y*d+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(SS,e,ES)}lookAt(e,t,i){let r=this.elements;return fn.subVectors(e,t),fn.lengthSq()===0&&(fn.z=1),fn.normalize(),Vi.crossVectors(i,fn),Vi.lengthSq()===0&&(Math.abs(i.z)===1?fn.x+=1e-4:fn.z+=1e-4,fn.normalize(),Vi.crossVectors(i,fn)),Vi.normalize(),Rc.crossVectors(fn,Vi),r[0]=Vi.x,r[4]=Rc.x,r[8]=fn.x,r[1]=Vi.y,r[5]=Rc.y,r[9]=fn.y,r[2]=Vi.z,r[6]=Rc.z,r[10]=fn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],u=i[1],d=i[5],h=i[9],f=i[13],p=i[2],y=i[6],g=i[10],m=i[14],v=i[3],x=i[7],w=i[11],O=i[15],I=r[0],R=r[4],U=r[8],_=r[12],b=r[1],D=r[5],z=r[9],F=r[13],$=r[2],W=r[6],ne=r[10],J=r[14],V=r[3],ce=r[7],fe=r[11],Te=r[15];return s[0]=o*I+a*b+c*$+l*V,s[4]=o*R+a*D+c*W+l*ce,s[8]=o*U+a*z+c*ne+l*fe,s[12]=o*_+a*F+c*J+l*Te,s[1]=u*I+d*b+h*$+f*V,s[5]=u*R+d*D+h*W+f*ce,s[9]=u*U+d*z+h*ne+f*fe,s[13]=u*_+d*F+h*J+f*Te,s[2]=p*I+y*b+g*$+m*V,s[6]=p*R+y*D+g*W+m*ce,s[10]=p*U+y*z+g*ne+m*fe,s[14]=p*_+y*F+g*J+m*Te,s[3]=v*I+x*b+w*$+O*V,s[7]=v*R+x*D+w*W+O*ce,s[11]=v*U+x*z+w*ne+O*fe,s[15]=v*_+x*F+w*J+O*Te,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],d=e[6],h=e[10],f=e[14],p=e[3],y=e[7],g=e[11],m=e[15];return p*(+s*c*d-r*l*d-s*a*h+i*l*h+r*a*f-i*c*f)+y*(+t*c*f-t*l*h+s*o*h-r*o*f+r*l*u-s*c*u)+g*(+t*l*d-t*a*f-s*o*d+i*o*f+s*a*u-i*l*u)+m*(-r*a*u-t*c*d+t*a*h+r*o*d-i*o*h+i*c*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=e[9],h=e[10],f=e[11],p=e[12],y=e[13],g=e[14],m=e[15],v=d*g*l-y*h*l+y*c*f-a*g*f-d*c*m+a*h*m,x=p*h*l-u*g*l-p*c*f+o*g*f+u*c*m-o*h*m,w=u*y*l-p*d*l+p*a*f-o*y*f-u*a*m+o*d*m,O=p*d*c-u*y*c-p*a*h+o*y*h+u*a*g-o*d*g,I=t*v+i*x+r*w+s*O;if(I===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/I;return e[0]=v*R,e[1]=(y*h*s-d*g*s-y*r*f+i*g*f+d*r*m-i*h*m)*R,e[2]=(a*g*s-y*c*s+y*r*l-i*g*l-a*r*m+i*c*m)*R,e[3]=(d*c*s-a*h*s-d*r*l+i*h*l+a*r*f-i*c*f)*R,e[4]=x*R,e[5]=(u*g*s-p*h*s+p*r*f-t*g*f-u*r*m+t*h*m)*R,e[6]=(p*c*s-o*g*s-p*r*l+t*g*l+o*r*m-t*c*m)*R,e[7]=(o*h*s-u*c*s+u*r*l-t*h*l-o*r*f+t*c*f)*R,e[8]=w*R,e[9]=(p*d*s-u*y*s-p*i*f+t*y*f+u*i*m-t*d*m)*R,e[10]=(o*y*s-p*a*s+p*i*l-t*y*l-o*i*m+t*a*m)*R,e[11]=(u*a*s-o*d*s-u*i*l+t*d*l+o*i*f-t*a*f)*R,e[12]=O*R,e[13]=(u*y*r-p*d*r+p*i*h-t*y*h-u*i*g+t*d*g)*R,e[14]=(p*a*r-o*y*r-p*i*c+t*y*c+o*i*g-t*a*g)*R,e[15]=(o*d*r-u*a*r+u*i*c-t*d*c-o*i*h+t*a*h)*R,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+i,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,d=a+a,h=s*l,f=s*u,p=s*d,y=o*u,g=o*d,m=a*d,v=c*l,x=c*u,w=c*d,O=i.x,I=i.y,R=i.z;return r[0]=(1-(y+m))*O,r[1]=(f+w)*O,r[2]=(p-x)*O,r[3]=0,r[4]=(f-w)*I,r[5]=(1-(h+m))*I,r[6]=(g+v)*I,r[7]=0,r[8]=(p+x)*R,r[9]=(g-v)*R,r[10]=(1-(h+y))*R,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=us.set(r[0],r[1],r[2]).length(),o=us.set(r[4],r[5],r[6]).length(),a=us.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Nn.copy(this);let l=1/s,u=1/o,d=1/a;return Nn.elements[0]*=l,Nn.elements[1]*=l,Nn.elements[2]*=l,Nn.elements[4]*=u,Nn.elements[5]*=u,Nn.elements[6]*=u,Nn.elements[8]*=d,Nn.elements[9]*=d,Nn.elements[10]*=d,t.setFromRotationMatrix(Nn),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Xn){let c=this.elements,l=2*s/(t-e),u=2*s/(i-r),d=(t+e)/(t-e),h=(i+r)/(i-r),f,p;if(a===Xn)f=-(o+s)/(o-s),p=-2*o*s/(o-s);else if(a===ra)f=-o/(o-s),p=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=Xn){let c=this.elements,l=1/(t-e),u=1/(i-r),d=1/(o-s),h=(t+e)*l,f=(i+r)*u,p,y;if(a===Xn)p=(o+s)*d,y=-2*d;else if(a===ra)p=s*d,y=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-h,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=y,c[14]=-p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},us=new P,Nn=new ze,SS=new P(0,0,0),ES=new P(1,1,1),Vi=new P,Rc=new P,fn=new P,Ig=new ze,Cg=new Qt,vn=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],d=r[2],h=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(Tt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Tt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Tt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Tt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Tt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Tt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Ig.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ig,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Cg.setFromEuler(this),this.setFromQuaternion(Cg,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};vn.DEFAULT_ORDER="XYZ";Fs=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},AS=0,Rg=new P,ds=new Qt,ui=new ze,Pc=new P,Co=new P,TS=new P,IS=new Qt,Pg=new P(1,0,0),Lg=new P(0,1,0),Dg=new P(0,0,1),Og={type:"added"},CS={type:"removed"},hs={type:"childadded",child:null},Wd={type:"childremoved",child:null},ht=class n extends Bn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:AS++}),this.uuid=gn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new P,t=new vn,i=new Qt,r=new P(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ze},normalMatrix:{value:new Qe}}),this.matrix=new ze,this.matrixWorld=new ze,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Fs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ds.setFromAxisAngle(e,t),this.quaternion.multiply(ds),this}rotateOnWorldAxis(e,t){return ds.setFromAxisAngle(e,t),this.quaternion.premultiply(ds),this}rotateX(e){return this.rotateOnAxis(Pg,e)}rotateY(e){return this.rotateOnAxis(Lg,e)}rotateZ(e){return this.rotateOnAxis(Dg,e)}translateOnAxis(e,t){return Rg.copy(e).applyQuaternion(this.quaternion),this.position.add(Rg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Pg,e)}translateY(e){return this.translateOnAxis(Lg,e)}translateZ(e){return this.translateOnAxis(Dg,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ui.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Pc.copy(e):Pc.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Co.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ui.lookAt(Co,Pc,this.up):ui.lookAt(Pc,Co,this.up),this.quaternion.setFromRotationMatrix(ui),r&&(ui.extractRotation(r.matrixWorld),ds.setFromRotationMatrix(ui),this.quaternion.premultiply(ds.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Og),hs.child=e,this.dispatchEvent(hs),hs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(CS),Wd.child=e,this.dispatchEvent(Wd),Wd.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ui.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ui.multiply(e.parent.matrixWorld)),e.applyMatrix4(ui),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Og),hs.child=e,this.dispatchEvent(hs),hs.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Co,e,TS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Co,IS,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++){let s=t[i];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++){let a=r[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let d=c[l];s(e.shapes,d)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];r.animations.push(s(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),d=o(e.shapes),h=o(e.skeletons),f=o(e.animations),p=o(e.nodes);a.length>0&&(i.geometries=a),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=r,i;function o(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}};ht.DEFAULT_UP=new P(0,1,0);ht.DEFAULT_MATRIX_AUTO_UPDATE=!0;ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;Fn=new P,di=new P,Xd=new P,hi=new P,fs=new P,ps=new P,Ug=new P,Yd=new P,qd=new P,Zd=new P,yi=class n{constructor(e=new P,t=new P,i=new P){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Fn.subVectors(e,t),r.cross(Fn);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Fn.subVectors(r,t),di.subVectors(i,t),Xd.subVectors(e,t);let o=Fn.dot(Fn),a=Fn.dot(di),c=Fn.dot(Xd),l=di.dot(di),u=di.dot(Xd),d=o*l-a*a;if(d===0)return s.set(0,0,0),null;let h=1/d,f=(l*c-a*u)*h,p=(o*u-a*c)*h;return s.set(1-f-p,p,f)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,hi)===null?!1:hi.x>=0&&hi.y>=0&&hi.x+hi.y<=1}static getInterpolation(e,t,i,r,s,o,a,c){return this.getBarycoord(e,t,i,r,hi)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,hi.x),c.addScaledVector(o,hi.y),c.addScaledVector(a,hi.z),c)}static isFrontFacing(e,t,i,r){return Fn.subVectors(i,t),di.subVectors(e,t),Fn.cross(di).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Fn.subVectors(this.c,this.b),di.subVectors(this.a,this.b),Fn.cross(di).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,o,a;fs.subVectors(r,i),ps.subVectors(s,i),Yd.subVectors(e,i);let c=fs.dot(Yd),l=ps.dot(Yd);if(c<=0&&l<=0)return t.copy(i);qd.subVectors(e,r);let u=fs.dot(qd),d=ps.dot(qd);if(u>=0&&d<=u)return t.copy(r);let h=c*d-u*l;if(h<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(i).addScaledVector(fs,o);Zd.subVectors(e,s);let f=fs.dot(Zd),p=ps.dot(Zd);if(p>=0&&f<=p)return t.copy(s);let y=f*l-c*p;if(y<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(i).addScaledVector(ps,a);let g=u*p-f*d;if(g<=0&&d-u>=0&&f-p>=0)return Ug.subVectors(s,r),a=(d-u)/(d-u+(f-p)),t.copy(r).addScaledVector(Ug,a);let m=1/(g+y+h);return o=y*m,a=h*m,t.copy(i).addScaledVector(fs,o).addScaledVector(ps,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},uv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},$i={h:0,s:0,l:0},Lc={h:0,s:0,l:0};Ce=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Tn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=mt.workingColorSpace){return this.r=e,this.g=t,this.b=i,mt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=mt.workingColorSpace){if(e=Rp(e,1),t=Tt(t,0,1),i=Tt(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=Jd(o,s,e+1/3),this.g=Jd(o,s,e),this.b=Jd(o,s,e-1/3)}return mt.toWorkingColorSpace(this,r),this}setStyle(e,t=Tn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Tn){let i=uv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ls(e.r),this.g=Ls(e.g),this.b=Ls(e.b),this}copyLinearToSRGB(e){return this.r=kd(e.r),this.g=kd(e.g),this.b=kd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Tn){return mt.fromWorkingColorSpace(Jt.copy(this),e),Math.round(Tt(Jt.r*255,0,255))*65536+Math.round(Tt(Jt.g*255,0,255))*256+Math.round(Tt(Jt.b*255,0,255))}getHexString(e=Tn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mt.workingColorSpace){mt.fromWorkingColorSpace(Jt.copy(this),t);let i=Jt.r,r=Jt.g,s=Jt.b,o=Math.max(i,r,s),a=Math.min(i,r,s),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else{let d=o-a;switch(l=u<=.5?d/(o+a):d/(2-o-a),o){case i:c=(r-s)/d+(r<s?6:0);break;case r:c=(s-i)/d+2;break;case s:c=(i-r)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=mt.workingColorSpace){return mt.fromWorkingColorSpace(Jt.copy(this),t),e.r=Jt.r,e.g=Jt.g,e.b=Jt.b,e}getStyle(e=Tn){mt.fromWorkingColorSpace(Jt.copy(this),e);let t=Jt.r,i=Jt.g,r=Jt.b;return e!==Tn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL($i),this.setHSL($i.h+e,$i.s+t,$i.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL($i),e.getHSL(Lc);let i=$o($i.h,Lc.h,t),r=$o($i.s,Lc.s,t),s=$o($i.l,Lc.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Jt=new Ce;Ce.NAMES=uv;RS=0,$t=class extends Bn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:RS++}),this.uuid=gn(),this.name="",this.type="Material",this.blending=Rr,this.side=wi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=wl,this.blendDst=Ml,this.blendEquation=Wi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ce(0,0,0),this.blendAlpha=0,this.depthFunc=Wo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Kh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Sr,this.stencilZFail=Sr,this.stencilZPass=Sr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Rr&&(i.blending=this.blending),this.side!==wi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==wl&&(i.blendSrc=this.blendSrc),this.blendDst!==Ml&&(i.blendDst=this.blendDst),this.blendEquation!==Wi&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Wo&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Kh&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Sr&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Sr&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Sr&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let o=[];for(let a in s){let c=s[a];delete c.metadata,o.push(c)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Zn=class extends $t{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ce(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vn,this.combine=Oa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},mi=PS();LS={toHalfFloat:un,fromHalfFloat:Bo},Pt=new P,Dc=new oe,ut=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=ia,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Cn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return lv("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Dc.fromBufferAttribute(this,t),Dc.applyMatrix3(e),this.setXY(t,Dc.x,Dc.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix3(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix4(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Pt.fromBufferAttribute(this,t),Pt.applyNormalMatrix(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Pt.fromBufferAttribute(this,t),Pt.transformDirection(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=sn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=et(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=sn(t,this.array)),t}setX(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=sn(t,this.array)),t}setY(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=sn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=sn(t,this.array)),t}setW(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),i=et(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),i=et(i,this.array),r=et(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),i=et(i,this.array),r=et(r,this.array),s=et(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ia&&(e.usage=this.usage),e}},nf=class extends ut{constructor(e,t,i){super(new Int8Array(e),t,i)}},rf=class extends ut{constructor(e,t,i){super(new Uint8Array(e),t,i)}},sf=class extends ut{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},of=class extends ut{constructor(e,t,i){super(new Int16Array(e),t,i)}},aa=class extends ut{constructor(e,t,i){super(new Uint16Array(e),t,i)}},af=class extends ut{constructor(e,t,i){super(new Int32Array(e),t,i)}},ca=class extends ut{constructor(e,t,i){super(new Uint32Array(e),t,i)}},cf=class extends ut{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=Bo(this.array[e*this.itemSize]);return this.normalized&&(t=sn(t,this.array)),t}setX(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize]=un(t),this}getY(e){let t=Bo(this.array[e*this.itemSize+1]);return this.normalized&&(t=sn(t,this.array)),t}setY(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize+1]=un(t),this}getZ(e){let t=Bo(this.array[e*this.itemSize+2]);return this.normalized&&(t=sn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize+2]=un(t),this}getW(e){let t=Bo(this.array[e*this.itemSize+3]);return this.normalized&&(t=sn(t,this.array)),t}setW(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize+3]=un(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),i=et(i,this.array)),this.array[e+0]=un(t),this.array[e+1]=un(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),i=et(i,this.array),r=et(r,this.array)),this.array[e+0]=un(t),this.array[e+1]=un(i),this.array[e+2]=un(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),i=et(i,this.array),r=et(r,this.array),s=et(s,this.array)),this.array[e+0]=un(t),this.array[e+1]=un(i),this.array[e+2]=un(r),this.array[e+3]=un(s),this}},Le=class extends ut{constructor(e,t,i){super(new Float32Array(e),t,i)}},DS=0,An=new ze,Kd=new ht,ms=new P,pn=new Gt,Ro=new Gt,Bt=new P,it=class n extends Bn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:DS++}),this.uuid=gn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(av(e)?ca:aa)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let s=new Qe().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return An.makeRotationFromQuaternion(e),this.applyMatrix4(An),this}rotateX(e){return An.makeRotationX(e),this.applyMatrix4(An),this}rotateY(e){return An.makeRotationY(e),this.applyMatrix4(An),this}rotateZ(e){return An.makeRotationZ(e),this.applyMatrix4(An),this}translate(e,t,i){return An.makeTranslation(e,t,i),this.applyMatrix4(An),this}scale(e,t,i){return An.makeScale(e,t,i),this.applyMatrix4(An),this}lookAt(e){return Kd.lookAt(e),Kd.updateMatrix(),this.applyMatrix4(Kd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ms).negate(),this.translate(ms.x,ms.y,ms.z),this}setFromPoints(e){let t=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Le(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let s=t[i];pn.setFromBufferAttribute(s),this.morphTargetsRelative?(Bt.addVectors(this.boundingBox.min,pn.min),this.boundingBox.expandByPoint(Bt),Bt.addVectors(this.boundingBox.max,pn.max),this.boundingBox.expandByPoint(Bt)):(this.boundingBox.expandByPoint(pn.min),this.boundingBox.expandByPoint(pn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Vt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){let i=this.boundingSphere.center;if(pn.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];Ro.setFromBufferAttribute(a),this.morphTargetsRelative?(Bt.addVectors(pn.min,Ro.min),pn.expandByPoint(Bt),Bt.addVectors(pn.max,Ro.max),pn.expandByPoint(Bt)):(pn.expandByPoint(Ro.min),pn.expandByPoint(Ro.max))}pn.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Bt.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Bt));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)Bt.fromBufferAttribute(a,l),c&&(ms.fromBufferAttribute(e,l),Bt.add(ms)),r=Math.max(r,i.distanceToSquared(Bt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ut(new Float32Array(4*i.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let U=0;U<i.count;U++)a[U]=new P,c[U]=new P;let l=new P,u=new P,d=new P,h=new oe,f=new oe,p=new oe,y=new P,g=new P;function m(U,_,b){l.fromBufferAttribute(i,U),u.fromBufferAttribute(i,_),d.fromBufferAttribute(i,b),h.fromBufferAttribute(s,U),f.fromBufferAttribute(s,_),p.fromBufferAttribute(s,b),u.sub(l),d.sub(l),f.sub(h),p.sub(h);let D=1/(f.x*p.y-p.x*f.y);isFinite(D)&&(y.copy(u).multiplyScalar(p.y).addScaledVector(d,-f.y).multiplyScalar(D),g.copy(d).multiplyScalar(f.x).addScaledVector(u,-p.x).multiplyScalar(D),a[U].add(y),a[_].add(y),a[b].add(y),c[U].add(g),c[_].add(g),c[b].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let U=0,_=v.length;U<_;++U){let b=v[U],D=b.start,z=b.count;for(let F=D,$=D+z;F<$;F+=3)m(e.getX(F+0),e.getX(F+1),e.getX(F+2))}let x=new P,w=new P,O=new P,I=new P;function R(U){O.fromBufferAttribute(r,U),I.copy(O);let _=a[U];x.copy(_),x.sub(O.multiplyScalar(O.dot(_))).normalize(),w.crossVectors(I,_);let D=w.dot(c[U])<0?-1:1;o.setXYZW(U,x.x,x.y,x.z,D)}for(let U=0,_=v.length;U<_;++U){let b=v[U],D=b.start,z=b.count;for(let F=D,$=D+z;F<$;F+=3)R(e.getX(F+0)),R(e.getX(F+1)),R(e.getX(F+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new ut(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,f=i.count;h<f;h++)i.setXYZ(h,0,0,0);let r=new P,s=new P,o=new P,a=new P,c=new P,l=new P,u=new P,d=new P;if(e)for(let h=0,f=e.count;h<f;h+=3){let p=e.getX(h+0),y=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,g),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),a.fromBufferAttribute(i,p),c.fromBufferAttribute(i,y),l.fromBufferAttribute(i,g),a.add(u),c.add(u),l.add(u),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(y,c.x,c.y,c.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let h=0,f=t.count;h<f;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),o.fromBufferAttribute(t,h+2),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),i.setXYZ(h+0,u.x,u.y,u.z),i.setXYZ(h+1,u.x,u.y,u.z),i.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Bt.fromBufferAttribute(e,t),Bt.normalize(),e.setXYZ(t,Bt.x,Bt.y,Bt.z)}toNonIndexed(){function e(a,c){let l=a.array,u=a.itemSize,d=a.normalized,h=new l.constructor(c.length*u),f=0,p=0;for(let y=0,g=c.length;y<g;y++){a.isInterleavedBufferAttribute?f=c[y]*a.data.stride+a.offset:f=c[y]*u;for(let m=0;m<u;m++)h[p++]=l[f++]}return new ut(h,u,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let a in r){let c=r[a],l=e(c,i);t.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let c=[],l=s[a];for(let u=0,d=l.length;u<d;u++){let h=l[u],f=e(h,i);c.push(f)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let c in i){let l=i[c];e.data.attributes[c]=l.toJSON(e.data)}let r={},s=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let d=0,h=l.length;d<h;d++){let f=l[d];u.push(f.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let l in r){let u=r[l];this.setAttribute(l,u.clone(t))}let s=e.morphAttributes;for(let l in s){let u=[],d=s[l];for(let h=0,f=d.length;h<f;h++)u.push(d[h].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,u=o.length;l<u;l++){let d=o[l];this.addGroup(d.start,d.count,d.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ng=new ze,pr=new qi,Oc=new Vt,Fg=new P,gs=new P,ys=new P,vs=new P,Qd=new P,Uc=new P,Nc=new oe,Fc=new oe,kc=new oe,kg=new P,Bg=new P,zg=new P,Bc=new P,zc=new P,It=class extends ht{constructor(e=new it,t=new Zn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){Uc.set(0,0,0);for(let c=0,l=s.length;c<l;c++){let u=a[c],d=s[c];u!==0&&(Qd.fromBufferAttribute(d,e),o?Uc.addScaledVector(Qd,u):Uc.addScaledVector(Qd.sub(t),u))}t.add(Uc)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Oc.copy(i.boundingSphere),Oc.applyMatrix4(s),pr.copy(e.ray).recast(e.near),!(Oc.containsPoint(pr.origin)===!1&&(pr.intersectSphere(Oc,Fg)===null||pr.origin.distanceToSquared(Fg)>(e.far-e.near)**2))&&(Ng.copy(s).invert(),pr.copy(e.ray).applyMatrix4(Ng),!(i.boundingBox!==null&&pr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,pr)))}_computeIntersections(e,t,i){let r,s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,h=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],v=Math.max(g.start,f.start),x=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let w=v,O=x;w<O;w+=3){let I=a.getX(w),R=a.getX(w+1),U=a.getX(w+2);r=Vc(this,m,e,i,l,u,d,I,R,U),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let v=a.getX(g),x=a.getX(g+1),w=a.getX(g+2);r=Vc(this,o,e,i,l,u,d,v,x,w),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],v=Math.max(g.start,f.start),x=Math.min(c.count,Math.min(g.start+g.count,f.start+f.count));for(let w=v,O=x;w<O;w+=3){let I=w,R=w+1,U=w+2;r=Vc(this,m,e,i,l,u,d,I,R,U),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(c.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let v=g,x=g+1,w=g+2;r=Vc(this,o,e,i,l,u,d,v,x,w),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};Or=class n extends it{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let c=[],l=[],u=[],d=[],h=0,f=0;p("z","y","x",-1,-1,i,t,e,o,s,0),p("z","y","x",1,-1,i,t,-e,o,s,1),p("x","z","y",1,1,e,i,t,r,o,2),p("x","z","y",1,-1,e,i,-t,r,o,3),p("x","y","z",1,-1,e,t,i,r,s,4),p("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(c),this.setAttribute("position",new Le(l,3)),this.setAttribute("normal",new Le(u,3)),this.setAttribute("uv",new Le(d,2));function p(y,g,m,v,x,w,O,I,R,U,_){let b=w/R,D=O/U,z=w/2,F=O/2,$=I/2,W=R+1,ne=U+1,J=0,V=0,ce=new P;for(let fe=0;fe<ne;fe++){let Te=fe*D-F;for(let ve=0;ve<W;ve++){let He=ve*b-z;ce[y]=He*v,ce[g]=Te*x,ce[m]=$,l.push(ce.x,ce.y,ce.z),ce[y]=0,ce[g]=0,ce[m]=I>0?1:-1,u.push(ce.x,ce.y,ce.z),d.push(ve/R),d.push(1-fe/U),J+=1}}for(let fe=0;fe<U;fe++)for(let Te=0;Te<R;Te++){let ve=h+Te+W*fe,He=h+Te+W*(fe+1),q=h+(Te+1)+W*(fe+1),Z=h+(Te+1)+W*fe;c.push(ve,He,Z),c.push(He,q,Z),V+=6}a.addGroup(f,V,_),f+=V,h+=J}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};hv={clone:ks,merge:rn},NS=`void main() {
198
+ Program Info Log: `+B+`
199
+ `+ce+`
200
+ `+k)}else B!==""?console.warn("THREE.WebGLProgram: Program Info Log:",B):(F===""||H==="")&&(ee=!1);ee&&(O.diagnostics={runnable:X,programLog:B,vertexShader:{log:F,prefix:g},fragmentShader:{log:H,prefix:m}})}r.deleteShader(U),r.deleteShader(C),N=new Us(r,y),w=PT(r,y)}let N;this.getUniforms=function(){return N===void 0&&R(this),N};let w;this.getAttributes=function(){return w===void 0&&R(this),w};let b=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=r.getProgramParameter(y,ST)),b},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=MT++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=U,this.fragmentShader=C,this}function jT(n,e,t,i,r,s,o){let a=new Bs,c=new ff,l=new Set,u=[],d=r.logarithmicDepthBuffer,h=r.vertexTextures,f=r.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(w){return l.add(w),w===0?"uv":`uv${w}`}function g(w,b,O,B,F){let H=B.fog,X=F.geometry,ee=w.isMeshStandardMaterial?B.environment:null,ce=(w.isMeshStandardMaterial?t:e).get(w.envMap||ee),k=ce&&ce.mapping===Ys?ce.image.height:null,le=p[w.type];w.precision!==null&&(f=r.getMaxPrecision(w.precision),f!==w.precision&&console.warn("THREE.WebGLProgram.getParameters:",w.precision,"not supported, using",f,"instead."));let he=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Te=he!==void 0?he.length:0,ve=0;X.morphAttributes.position!==void 0&&(ve=1),X.morphAttributes.normal!==void 0&&(ve=2),X.morphAttributes.color!==void 0&&(ve=3);let He,Z,J,ye;if(le){let st=Un[le];He=st.vertexShader,Z=st.fragmentShader}else He=w.vertexShader,Z=w.fragmentShader,c.update(w),J=c.getVertexShaderID(w),ye=c.getFragmentShaderID(w);let oe=n.getRenderTarget(),ze=F.isInstancedMesh===!0,xe=F.isBatchedMesh===!0,V=!!w.map,Be=!!w.matcap,Y=!!ce,de=!!w.aoMap,K=!!w.lightMap,fe=!!w.bumpMap,ie=!!w.normalMap,ge=!!w.displacementMap,Ie=!!w.emissiveMap,D=!!w.metalnessMap,A=!!w.roughnessMap,j=w.anisotropy>0,te=w.clearcoat>0,ae=w.dispersion>0,re=w.iridescence>0,Ue=w.sheen>0,be=w.transmission>0,_e=j&&!!w.anisotropyMap,je=te&&!!w.clearcoatMap,pe=te&&!!w.clearcoatNormalMap,Oe=te&&!!w.clearcoatRoughnessMap,qe=re&&!!w.iridescenceMap,Ne=re&&!!w.iridescenceThicknessMap,Re=Ue&&!!w.sheenColorMap,Fe=Ue&&!!w.sheenRoughnessMap,et=!!w.specularMap,mt=!!w.specularColorMap,Ge=!!w.specularIntensityMap,z=be&&!!w.transmissionMap,ue=be&&!!w.thicknessMap,Q=!!w.gradientMap,Se=!!w.alphaMap,Ae=w.alphaTest>0,Pe=!!w.alphaHash,nt=!!w.extensions,pt=vi;w.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(pt=n.toneMapping);let xt={shaderID:le,shaderType:w.type,shaderName:w.name,vertexShader:He,fragmentShader:Z,defines:w.defines,customVertexShaderID:J,customFragmentShaderID:ye,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:f,batching:xe,instancing:ze,instancingColor:ze&&F.instanceColor!==null,instancingMorph:ze&&F.morphTexture!==null,supportsVertexTextures:h,outputColorSpace:oe===null?n.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:Ei,alphaToCoverage:!!w.alphaToCoverage,map:V,matcap:Be,envMap:Y,envMapMode:Y&&ce.mapping,envMapCubeUVHeight:k,aoMap:de,lightMap:K,bumpMap:fe,normalMap:ie,displacementMap:h&&ge,emissiveMap:Ie,normalMapObjectSpace:ie&&w.normalMapType===Q0,normalMapTangentSpace:ie&&w.normalMapType===Ji,metalnessMap:D,roughnessMap:A,anisotropy:j,anisotropyMap:_e,clearcoat:te,clearcoatMap:je,clearcoatNormalMap:pe,clearcoatRoughnessMap:Oe,dispersion:ae,iridescence:re,iridescenceMap:qe,iridescenceThicknessMap:Ne,sheen:Ue,sheenColorMap:Re,sheenRoughnessMap:Fe,specularMap:et,specularColorMap:mt,specularIntensityMap:Ge,transmission:be,transmissionMap:z,thicknessMap:ue,gradientMap:Q,opaque:w.transparent===!1&&w.blending===Cr&&w.alphaToCoverage===!1,alphaMap:Se,alphaTest:Ae,alphaHash:Pe,combine:w.combine,mapUv:V&&y(w.map.channel),aoMapUv:de&&y(w.aoMap.channel),lightMapUv:K&&y(w.lightMap.channel),bumpMapUv:fe&&y(w.bumpMap.channel),normalMapUv:ie&&y(w.normalMap.channel),displacementMapUv:ge&&y(w.displacementMap.channel),emissiveMapUv:Ie&&y(w.emissiveMap.channel),metalnessMapUv:D&&y(w.metalnessMap.channel),roughnessMapUv:A&&y(w.roughnessMap.channel),anisotropyMapUv:_e&&y(w.anisotropyMap.channel),clearcoatMapUv:je&&y(w.clearcoatMap.channel),clearcoatNormalMapUv:pe&&y(w.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Oe&&y(w.clearcoatRoughnessMap.channel),iridescenceMapUv:qe&&y(w.iridescenceMap.channel),iridescenceThicknessMapUv:Ne&&y(w.iridescenceThicknessMap.channel),sheenColorMapUv:Re&&y(w.sheenColorMap.channel),sheenRoughnessMapUv:Fe&&y(w.sheenRoughnessMap.channel),specularMapUv:et&&y(w.specularMap.channel),specularColorMapUv:mt&&y(w.specularColorMap.channel),specularIntensityMapUv:Ge&&y(w.specularIntensityMap.channel),transmissionMapUv:z&&y(w.transmissionMap.channel),thicknessMapUv:ue&&y(w.thicknessMap.channel),alphaMapUv:Se&&y(w.alphaMap.channel),vertexTangents:!!X.attributes.tangent&&(ie||j),vertexColors:w.vertexColors,vertexAlphas:w.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!X.attributes.uv&&(V||Se),fog:!!H,useFog:w.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:w.flatShading===!0,sizeAttenuation:w.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:F.isSkinnedMesh===!0,morphTargets:X.morphAttributes.position!==void 0,morphNormals:X.morphAttributes.normal!==void 0,morphColors:X.morphAttributes.color!==void 0,morphTargetsCount:Te,morphTextureStride:ve,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:w.dithering,shadowMapEnabled:n.shadowMap.enabled&&O.length>0,shadowMapType:n.shadowMap.type,toneMapping:pt,useLegacyLights:n._useLegacyLights,decodeVideoTexture:V&&w.map.isVideoTexture===!0&&ht.getTransfer(w.map.colorSpace)===vt,premultipliedAlpha:w.premultipliedAlpha,doubleSided:w.side===Hn,flipSided:w.side===nn,useDepthPacking:w.depthPacking>=0,depthPacking:w.depthPacking||0,index0AttributeName:w.index0AttributeName,extensionClipCullDistance:nt&&w.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:nt&&w.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:w.customProgramCacheKey()};return xt.vertexUv1s=l.has(1),xt.vertexUv2s=l.has(2),xt.vertexUv3s=l.has(3),l.clear(),xt}function m(w){let b=[];if(w.shaderID?b.push(w.shaderID):(b.push(w.customVertexShaderID),b.push(w.customFragmentShaderID)),w.defines!==void 0)for(let O in w.defines)b.push(O),b.push(w.defines[O]);return w.isRawShaderMaterial===!1&&(x(b,w),v(b,w),b.push(n.outputColorSpace)),b.push(w.customProgramCacheKey),b.join()}function x(w,b){w.push(b.precision),w.push(b.outputColorSpace),w.push(b.envMapMode),w.push(b.envMapCubeUVHeight),w.push(b.mapUv),w.push(b.alphaMapUv),w.push(b.lightMapUv),w.push(b.aoMapUv),w.push(b.bumpMapUv),w.push(b.normalMapUv),w.push(b.displacementMapUv),w.push(b.emissiveMapUv),w.push(b.metalnessMapUv),w.push(b.roughnessMapUv),w.push(b.anisotropyMapUv),w.push(b.clearcoatMapUv),w.push(b.clearcoatNormalMapUv),w.push(b.clearcoatRoughnessMapUv),w.push(b.iridescenceMapUv),w.push(b.iridescenceThicknessMapUv),w.push(b.sheenColorMapUv),w.push(b.sheenRoughnessMapUv),w.push(b.specularMapUv),w.push(b.specularColorMapUv),w.push(b.specularIntensityMapUv),w.push(b.transmissionMapUv),w.push(b.thicknessMapUv),w.push(b.combine),w.push(b.fogExp2),w.push(b.sizeAttenuation),w.push(b.morphTargetsCount),w.push(b.morphAttributeCount),w.push(b.numDirLights),w.push(b.numPointLights),w.push(b.numSpotLights),w.push(b.numSpotLightMaps),w.push(b.numHemiLights),w.push(b.numRectAreaLights),w.push(b.numDirLightShadows),w.push(b.numPointLightShadows),w.push(b.numSpotLightShadows),w.push(b.numSpotLightShadowsWithMaps),w.push(b.numLightProbes),w.push(b.shadowMapType),w.push(b.toneMapping),w.push(b.numClippingPlanes),w.push(b.numClipIntersection),w.push(b.depthPacking)}function v(w,b){a.disableAll(),b.supportsVertexTextures&&a.enable(0),b.instancing&&a.enable(1),b.instancingColor&&a.enable(2),b.instancingMorph&&a.enable(3),b.matcap&&a.enable(4),b.envMap&&a.enable(5),b.normalMapObjectSpace&&a.enable(6),b.normalMapTangentSpace&&a.enable(7),b.clearcoat&&a.enable(8),b.iridescence&&a.enable(9),b.alphaTest&&a.enable(10),b.vertexColors&&a.enable(11),b.vertexAlphas&&a.enable(12),b.vertexUv1s&&a.enable(13),b.vertexUv2s&&a.enable(14),b.vertexUv3s&&a.enable(15),b.vertexTangents&&a.enable(16),b.anisotropy&&a.enable(17),b.alphaHash&&a.enable(18),b.batching&&a.enable(19),b.dispersion&&a.enable(20),w.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.skinning&&a.enable(4),b.morphTargets&&a.enable(5),b.morphNormals&&a.enable(6),b.morphColors&&a.enable(7),b.premultipliedAlpha&&a.enable(8),b.shadowMapEnabled&&a.enable(9),b.useLegacyLights&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.alphaToCoverage&&a.enable(20),w.push(a.mask)}function M(w){let b=p[w.type],O;if(b){let B=Un[b];O=hv.clone(B.uniforms)}else O=w.uniforms;return O}function U(w,b){let O;for(let B=0,F=u.length;B<F;B++){let H=u[B];if(H.cacheKey===b){O=H,++O.usedTimes;break}}return O===void 0&&(O=new $T(n,b,w,s),u.push(O)),O}function C(w){if(--w.usedTimes===0){let b=u.indexOf(w);u[b]=u[u.length-1],u.pop(),w.destroy()}}function R(w){c.remove(w)}function N(){c.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:M,acquireProgram:U,releaseProgram:C,releaseShaderCache:R,programs:u,dispose:N}}function GT(){let n=new WeakMap;function e(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function t(s){n.delete(s)}function i(s,o,a){n.get(s)[o]=a}function r(){n=new WeakMap}return{get:e,remove:t,update:i,dispose:r}}function WT(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function ay(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function cy(){let n=[],e=0,t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function o(d,h,f,p,y,g){let m=n[e];return m===void 0?(m={id:d.id,object:d,geometry:h,material:f,groupOrder:p,renderOrder:d.renderOrder,z:y,group:g},n[e]=m):(m.id=d.id,m.object=d,m.geometry=h,m.material=f,m.groupOrder=p,m.renderOrder=d.renderOrder,m.z=y,m.group=g),e++,m}function a(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.push(m):f.transparent===!0?r.push(m):t.push(m)}function c(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.unshift(m):f.transparent===!0?r.unshift(m):t.unshift(m)}function l(d,h){t.length>1&&t.sort(d||WT),i.length>1&&i.sort(h||ay),r.length>1&&r.sort(h||ay)}function u(){for(let d=e,h=n.length;d<h;d++){let f=n[d];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function XT(){let n=new WeakMap;function e(i,r){let s=n.get(i),o;return s===void 0?(o=new cy,n.set(i,[o])):r>=s.length?(o=new cy,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function YT(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new L,color:new Ce};break;case"SpotLight":t={position:new L,direction:new L,color:new Ce,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new L,color:new Ce,distance:0,decay:0};break;case"HemisphereLight":t={direction:new L,skyColor:new Ce,groundColor:new Ce};break;case"RectAreaLight":t={color:new Ce,position:new L,halfWidth:new L,halfHeight:new L};break}return n[e.id]=t,t}}}function qT(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}function JT(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function KT(n){let e=new YT,t=qT(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new L);let r=new L,s=new $e,o=new $e;function a(l,u){let d=0,h=0,f=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let p=0,y=0,g=0,m=0,x=0,v=0,M=0,U=0,C=0,R=0,N=0;l.sort(JT);let w=u===!0?Math.PI:1;for(let O=0,B=l.length;O<B;O++){let F=l[O],H=F.color,X=F.intensity,ee=F.distance,ce=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=H.r*X*w,h+=H.g*X*w,f+=H.b*X*w;else if(F.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(F.sh.coefficients[k],X);N++}else if(F.isDirectionalLight){let k=e.get(F);if(k.color.copy(F.color).multiplyScalar(F.intensity*w),F.castShadow){let le=F.shadow,he=t.get(F);he.shadowBias=le.bias,he.shadowNormalBias=le.normalBias,he.shadowRadius=le.radius,he.shadowMapSize=le.mapSize,i.directionalShadow[p]=he,i.directionalShadowMap[p]=ce,i.directionalShadowMatrix[p]=F.shadow.matrix,v++}i.directional[p]=k,p++}else if(F.isSpotLight){let k=e.get(F);k.position.setFromMatrixPosition(F.matrixWorld),k.color.copy(H).multiplyScalar(X*w),k.distance=ee,k.coneCos=Math.cos(F.angle),k.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),k.decay=F.decay,i.spot[g]=k;let le=F.shadow;if(F.map&&(i.spotLightMap[C]=F.map,C++,le.updateMatrices(F),F.castShadow&&R++),i.spotLightMatrix[g]=le.matrix,F.castShadow){let he=t.get(F);he.shadowBias=le.bias,he.shadowNormalBias=le.normalBias,he.shadowRadius=le.radius,he.shadowMapSize=le.mapSize,i.spotShadow[g]=he,i.spotShadowMap[g]=ce,U++}g++}else if(F.isRectAreaLight){let k=e.get(F);k.color.copy(H).multiplyScalar(X),k.halfWidth.set(F.width*.5,0,0),k.halfHeight.set(0,F.height*.5,0),i.rectArea[m]=k,m++}else if(F.isPointLight){let k=e.get(F);if(k.color.copy(F.color).multiplyScalar(F.intensity*w),k.distance=F.distance,k.decay=F.decay,F.castShadow){let le=F.shadow,he=t.get(F);he.shadowBias=le.bias,he.shadowNormalBias=le.normalBias,he.shadowRadius=le.radius,he.shadowMapSize=le.mapSize,he.shadowCameraNear=le.camera.near,he.shadowCameraFar=le.camera.far,i.pointShadow[y]=he,i.pointShadowMap[y]=ce,i.pointShadowMatrix[y]=F.shadow.matrix,M++}i.point[y]=k,y++}else if(F.isHemisphereLight){let k=e.get(F);k.skyColor.copy(F.color).multiplyScalar(X*w),k.groundColor.copy(F.groundColor).multiplyScalar(X*w),i.hemi[x]=k,x++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ee.LTC_FLOAT_1,i.rectAreaLTC2=Ee.LTC_FLOAT_2):(i.rectAreaLTC1=Ee.LTC_HALF_1,i.rectAreaLTC2=Ee.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=h,i.ambient[2]=f;let b=i.hash;(b.directionalLength!==p||b.pointLength!==y||b.spotLength!==g||b.rectAreaLength!==m||b.hemiLength!==x||b.numDirectionalShadows!==v||b.numPointShadows!==M||b.numSpotShadows!==U||b.numSpotMaps!==C||b.numLightProbes!==N)&&(i.directional.length=p,i.spot.length=g,i.rectArea.length=m,i.point.length=y,i.hemi.length=x,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=U,i.spotShadowMap.length=U,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=U+C-R,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=N,b.directionalLength=p,b.pointLength=y,b.spotLength=g,b.rectAreaLength=m,b.hemiLength=x,b.numDirectionalShadows=v,b.numPointShadows=M,b.numSpotShadows=U,b.numSpotMaps=C,b.numLightProbes=N,i.version=ZT++)}function c(l,u){let d=0,h=0,f=0,p=0,y=0,g=u.matrixWorldInverse;for(let m=0,x=l.length;m<x;m++){let v=l[m];if(v.isDirectionalLight){let M=i.directional[d];M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),d++}else if(v.isSpotLight){let M=i.spot[f];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(g),M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),f++}else if(v.isRectAreaLight){let M=i.rectArea[p];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),M.halfWidth.set(v.width*.5,0,0),M.halfHeight.set(0,v.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),p++}else if(v.isPointLight){let M=i.point[h];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(g),h++}else if(v.isHemisphereLight){let M=i.hemi[y];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(g),y++}}}return{setup:a,setupView:c,state:i}}function ly(n){let e=new KT(n),t=[],i=[];function r(u){l.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function o(u){i.push(u)}function a(u){e.setup(t,u)}function c(u){e.setupView(t,u)}let l={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function QT(n){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new ly(n),e.set(r,[a])):s>=o.length?(a=new ly(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}function nI(n,e,t){let i=new Ur,r=new se,s=new se,o=new ft,a=new da({depthPacking:K0}),c=new ha,l={},u=t.maxTextureSize,d={[bi]:nn,[nn]:bi,[Hn]:Hn},h=new mn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new se},radius:{value:4}},vertexShader:eI,fragmentShader:tI}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let p=new tt;p.setAttribute("position",new at(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new Mt(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=vp;let m=this.type;this.render=function(C,R,N){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||C.length===0)return;let w=n.getRenderTarget(),b=n.getActiveCubeFace(),O=n.getActiveMipmapLevel(),B=n.state;B.setBlending(yi),B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);let F=m!==Vn&&this.type===Vn,H=m===Vn&&this.type!==Vn;for(let X=0,ee=C.length;X<ee;X++){let ce=C[X],k=ce.shadow;if(k===void 0){console.warn("THREE.WebGLShadowMap:",ce,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);let le=k.getFrameExtents();if(r.multiply(le),s.copy(k.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/le.x),r.x=s.x*le.x,k.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/le.y),r.y=s.y*le.y,k.mapSize.y=s.y)),k.map===null||F===!0||H===!0){let Te=this.type!==Vn?{minFilter:Nt,magFilter:Nt}:{};k.map!==null&&k.map.dispose(),k.map=new fn(r.x,r.y,Te),k.map.texture.name=ce.name+".shadowMap",k.camera.updateProjectionMatrix()}n.setRenderTarget(k.map),n.clear();let he=k.getViewportCount();for(let Te=0;Te<he;Te++){let ve=k.getViewport(Te);o.set(s.x*ve.x,s.y*ve.y,s.x*ve.z,s.y*ve.w),B.viewport(o),k.updateMatrices(ce,Te),i=k.getFrustum(),M(R,N,k.camera,ce,this.type)}k.isPointLightShadow!==!0&&this.type===Vn&&x(k,N),k.needsUpdate=!1}m=this.type,g.needsUpdate=!1,n.setRenderTarget(w,b,O)};function x(C,R){let N=e.update(y);h.defines.VSM_SAMPLES!==C.blurSamples&&(h.defines.VSM_SAMPLES=C.blurSamples,f.defines.VSM_SAMPLES=C.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new fn(r.x,r.y)),h.uniforms.shadow_pass.value=C.map.texture,h.uniforms.resolution.value=C.mapSize,h.uniforms.radius.value=C.radius,n.setRenderTarget(C.mapPass),n.clear(),n.renderBufferDirect(R,null,N,h,y,null),f.uniforms.shadow_pass.value=C.mapPass.texture,f.uniforms.resolution.value=C.mapSize,f.uniforms.radius.value=C.radius,n.setRenderTarget(C.map),n.clear(),n.renderBufferDirect(R,null,N,f,y,null)}function v(C,R,N,w){let b=null,O=N.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(O!==void 0)b=O;else if(b=N.isPointLight===!0?c:a,n.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){let B=b.uuid,F=R.uuid,H=l[B];H===void 0&&(H={},l[B]=H);let X=H[F];X===void 0&&(X=b.clone(),H[F]=X,R.addEventListener("dispose",U)),b=X}if(b.visible=R.visible,b.wireframe=R.wireframe,w===Vn?b.side=R.shadowSide!==null?R.shadowSide:R.side:b.side=R.shadowSide!==null?R.shadowSide:d[R.side],b.alphaMap=R.alphaMap,b.alphaTest=R.alphaTest,b.map=R.map,b.clipShadows=R.clipShadows,b.clippingPlanes=R.clippingPlanes,b.clipIntersection=R.clipIntersection,b.displacementMap=R.displacementMap,b.displacementScale=R.displacementScale,b.displacementBias=R.displacementBias,b.wireframeLinewidth=R.wireframeLinewidth,b.linewidth=R.linewidth,N.isPointLight===!0&&b.isMeshDistanceMaterial===!0){let B=n.properties.get(b);B.light=N}return b}function M(C,R,N,w,b){if(C.visible===!1)return;if(C.layers.test(R.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&b===Vn)&&(!C.frustumCulled||i.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,C.matrixWorld);let F=e.update(C),H=C.material;if(Array.isArray(H)){let X=F.groups;for(let ee=0,ce=X.length;ee<ce;ee++){let k=X[ee],le=H[k.materialIndex];if(le&&le.visible){let he=v(C,le,w,b);C.onBeforeShadow(n,C,R,N,F,he,k),n.renderBufferDirect(N,null,F,he,C,k),C.onAfterShadow(n,C,R,N,F,he,k)}}}else if(H.visible){let X=v(C,H,w,b);C.onBeforeShadow(n,C,R,N,F,X,null),n.renderBufferDirect(N,null,F,X,C,null),C.onAfterShadow(n,C,R,N,F,X,null)}}let B=C.children;for(let F=0,H=B.length;F<H;F++)M(B[F],R,N,w,b)}function U(C){C.target.removeEventListener("dispose",U);for(let N in l){let w=l[N],b=C.target.uuid;b in w&&(w[b].dispose(),delete w[b])}}}function iI(n){function e(){let z=!1,ue=new ft,Q=null,Se=new ft(0,0,0,0);return{setMask:function(Ae){Q!==Ae&&!z&&(n.colorMask(Ae,Ae,Ae,Ae),Q=Ae)},setLocked:function(Ae){z=Ae},setClear:function(Ae,Pe,nt,pt,xt){xt===!0&&(Ae*=pt,Pe*=pt,nt*=pt),ue.set(Ae,Pe,nt,pt),Se.equals(ue)===!1&&(n.clearColor(Ae,Pe,nt,pt),Se.copy(ue))},reset:function(){z=!1,Q=null,Se.set(-1,0,0,0)}}}function t(){let z=!1,ue=null,Q=null,Se=null;return{setTest:function(Ae){Ae?ye(n.DEPTH_TEST):oe(n.DEPTH_TEST)},setMask:function(Ae){ue!==Ae&&!z&&(n.depthMask(Ae),ue=Ae)},setFunc:function(Ae){if(Q!==Ae){switch(Ae){case w0:n.depthFunc(n.NEVER);break;case S0:n.depthFunc(n.ALWAYS);break;case M0:n.depthFunc(n.LESS);break;case Wo:n.depthFunc(n.LEQUAL);break;case E0:n.depthFunc(n.EQUAL);break;case A0:n.depthFunc(n.GEQUAL);break;case T0:n.depthFunc(n.GREATER);break;case I0:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}Q=Ae}},setLocked:function(Ae){z=Ae},setClear:function(Ae){Se!==Ae&&(n.clearDepth(Ae),Se=Ae)},reset:function(){z=!1,ue=null,Q=null,Se=null}}}function i(){let z=!1,ue=null,Q=null,Se=null,Ae=null,Pe=null,nt=null,pt=null,xt=null;return{setTest:function(st){z||(st?ye(n.STENCIL_TEST):oe(n.STENCIL_TEST))},setMask:function(st){ue!==st&&!z&&(n.stencilMask(st),ue=st)},setFunc:function(st,Ht,Et){(Q!==st||Se!==Ht||Ae!==Et)&&(n.stencilFunc(st,Ht,Et),Q=st,Se=Ht,Ae=Et)},setOp:function(st,Ht,Et){(Pe!==st||nt!==Ht||pt!==Et)&&(n.stencilOp(st,Ht,Et),Pe=st,nt=Ht,pt=Et)},setLocked:function(st){z=st},setClear:function(st){xt!==st&&(n.clearStencil(st),xt=st)},reset:function(){z=!1,ue=null,Q=null,Se=null,Ae=null,Pe=null,nt=null,pt=null,xt=null}}}let r=new e,s=new t,o=new i,a=new WeakMap,c=new WeakMap,l={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,x=null,v=null,M=null,U=null,C=new Ce(0,0,0),R=0,N=!1,w=null,b=null,O=null,B=null,F=null,H=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),X=!1,ee=0,ce=n.getParameter(n.VERSION);ce.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(ce)[1]),X=ee>=1):ce.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(ce)[1]),X=ee>=2);let k=null,le={},he=n.getParameter(n.SCISSOR_BOX),Te=n.getParameter(n.VIEWPORT),ve=new ft().fromArray(he),He=new ft().fromArray(Te);function Z(z,ue,Q,Se){let Ae=new Uint8Array(4),Pe=n.createTexture();n.bindTexture(z,Pe),n.texParameteri(z,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(z,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let nt=0;nt<Q;nt++)z===n.TEXTURE_3D||z===n.TEXTURE_2D_ARRAY?n.texImage3D(ue,0,n.RGBA,1,1,Se,0,n.RGBA,n.UNSIGNED_BYTE,Ae):n.texImage2D(ue+nt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ae);return Pe}let J={};J[n.TEXTURE_2D]=Z(n.TEXTURE_2D,n.TEXTURE_2D,1),J[n.TEXTURE_CUBE_MAP]=Z(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),J[n.TEXTURE_2D_ARRAY]=Z(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),J[n.TEXTURE_3D]=Z(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),ye(n.DEPTH_TEST),s.setFunc(Wo),fe(!1),ie(_h),ye(n.CULL_FACE),de(yi);function ye(z){l[z]!==!0&&(n.enable(z),l[z]=!0)}function oe(z){l[z]!==!1&&(n.disable(z),l[z]=!1)}function ze(z,ue){return u[z]!==ue?(n.bindFramebuffer(z,ue),u[z]=ue,z===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=ue),z===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=ue),!0):!1}function xe(z,ue){let Q=h,Se=!1;if(z){Q=d.get(ue),Q===void 0&&(Q=[],d.set(ue,Q));let Ae=z.textures;if(Q.length!==Ae.length||Q[0]!==n.COLOR_ATTACHMENT0){for(let Pe=0,nt=Ae.length;Pe<nt;Pe++)Q[Pe]=n.COLOR_ATTACHMENT0+Pe;Q.length=Ae.length,Se=!0}}else Q[0]!==n.BACK&&(Q[0]=n.BACK,Se=!0);Se&&n.drawBuffers(Q)}function V(z){return f!==z?(n.useProgram(z),f=z,!0):!1}let Be={[ji]:n.FUNC_ADD,[s0]:n.FUNC_SUBTRACT,[o0]:n.FUNC_REVERSE_SUBTRACT};Be[a0]=n.MIN,Be[c0]=n.MAX;let Y={[l0]:n.ZERO,[u0]:n.ONE,[d0]:n.SRC_COLOR,[wl]:n.SRC_ALPHA,[y0]:n.SRC_ALPHA_SATURATE,[m0]:n.DST_COLOR,[f0]:n.DST_ALPHA,[h0]:n.ONE_MINUS_SRC_COLOR,[Sl]:n.ONE_MINUS_SRC_ALPHA,[g0]:n.ONE_MINUS_DST_COLOR,[p0]:n.ONE_MINUS_DST_ALPHA,[v0]:n.CONSTANT_COLOR,[x0]:n.ONE_MINUS_CONSTANT_COLOR,[b0]:n.CONSTANT_ALPHA,[_0]:n.ONE_MINUS_CONSTANT_ALPHA};function de(z,ue,Q,Se,Ae,Pe,nt,pt,xt,st){if(z===yi){p===!0&&(oe(n.BLEND),p=!1);return}if(p===!1&&(ye(n.BLEND),p=!0),z!==r0){if(z!==y||st!==N){if((g!==ji||v!==ji)&&(n.blendEquation(n.FUNC_ADD),g=ji,v=ji),st)switch(z){case Cr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case wh:n.blendFunc(n.ONE,n.ONE);break;case Sh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Mh:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}else switch(z){case Cr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case wh:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Sh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Mh:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}m=null,x=null,M=null,U=null,C.set(0,0,0),R=0,y=z,N=st}return}Ae=Ae||ue,Pe=Pe||Q,nt=nt||Se,(ue!==g||Ae!==v)&&(n.blendEquationSeparate(Be[ue],Be[Ae]),g=ue,v=Ae),(Q!==m||Se!==x||Pe!==M||nt!==U)&&(n.blendFuncSeparate(Y[Q],Y[Se],Y[Pe],Y[nt]),m=Q,x=Se,M=Pe,U=nt),(pt.equals(C)===!1||xt!==R)&&(n.blendColor(pt.r,pt.g,pt.b,xt),C.copy(pt),R=xt),y=z,N=!1}function K(z,ue){z.side===Hn?oe(n.CULL_FACE):ye(n.CULL_FACE);let Q=z.side===nn;ue&&(Q=!Q),fe(Q),z.blending===Cr&&z.transparent===!1?de(yi):de(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),s.setFunc(z.depthFunc),s.setTest(z.depthTest),s.setMask(z.depthWrite),r.setMask(z.colorWrite);let Se=z.stencilWrite;o.setTest(Se),Se&&(o.setMask(z.stencilWriteMask),o.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),o.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),Ie(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?ye(n.SAMPLE_ALPHA_TO_COVERAGE):oe(n.SAMPLE_ALPHA_TO_COVERAGE)}function fe(z){w!==z&&(z?n.frontFace(n.CW):n.frontFace(n.CCW),w=z)}function ie(z){z!==t0?(ye(n.CULL_FACE),z!==b&&(z===_h?n.cullFace(n.BACK):z===n0?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):oe(n.CULL_FACE),b=z}function ge(z){z!==O&&(X&&n.lineWidth(z),O=z)}function Ie(z,ue,Q){z?(ye(n.POLYGON_OFFSET_FILL),(B!==ue||F!==Q)&&(n.polygonOffset(ue,Q),B=ue,F=Q)):oe(n.POLYGON_OFFSET_FILL)}function D(z){z?ye(n.SCISSOR_TEST):oe(n.SCISSOR_TEST)}function A(z){z===void 0&&(z=n.TEXTURE0+H-1),k!==z&&(n.activeTexture(z),k=z)}function j(z,ue,Q){Q===void 0&&(k===null?Q=n.TEXTURE0+H-1:Q=k);let Se=le[Q];Se===void 0&&(Se={type:void 0,texture:void 0},le[Q]=Se),(Se.type!==z||Se.texture!==ue)&&(k!==Q&&(n.activeTexture(Q),k=Q),n.bindTexture(z,ue||J[z]),Se.type=z,Se.texture=ue)}function te(){let z=le[k];z!==void 0&&z.type!==void 0&&(n.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function ae(){try{n.compressedTexImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function re(){try{n.compressedTexImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Ue(){try{n.texSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function be(){try{n.texSubImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function _e(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function je(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Oe(){try{n.texStorage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function qe(){try{n.texImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Ne(){try{n.texImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Re(z){ve.equals(z)===!1&&(n.scissor(z.x,z.y,z.z,z.w),ve.copy(z))}function Fe(z){He.equals(z)===!1&&(n.viewport(z.x,z.y,z.z,z.w),He.copy(z))}function et(z,ue){let Q=c.get(ue);Q===void 0&&(Q=new WeakMap,c.set(ue,Q));let Se=Q.get(z);Se===void 0&&(Se=n.getUniformBlockIndex(ue,z.name),Q.set(z,Se))}function mt(z,ue){let Se=c.get(ue).get(z);a.get(ue)!==Se&&(n.uniformBlockBinding(ue,Se,z.__bindingPointIndex),a.set(ue,Se))}function Ge(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),l={},k=null,le={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,x=null,v=null,M=null,U=null,C=new Ce(0,0,0),R=0,N=!1,w=null,b=null,O=null,B=null,F=null,ve.set(0,0,n.canvas.width,n.canvas.height),He.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),o.reset()}return{buffers:{color:r,depth:s,stencil:o},enable:ye,disable:oe,bindFramebuffer:ze,drawBuffers:xe,useProgram:V,setBlending:de,setMaterial:K,setFlipSided:fe,setCullFace:ie,setLineWidth:ge,setPolygonOffset:Ie,setScissorTest:D,activeTexture:A,bindTexture:j,unbindTexture:te,compressedTexImage2D:ae,compressedTexImage3D:re,texImage2D:qe,texImage3D:Ne,updateUBOMapping:et,uniformBlockBinding:mt,texStorage2D:pe,texStorage3D:Oe,texSubImage2D:Ue,texSubImage3D:be,compressedTexSubImage2D:_e,compressedTexSubImage3D:je,scissor:Re,viewport:Fe,reset:Ge}}function rI(n,e,t,i,r,s,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new se,u=new WeakMap,d,h=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(D,A){return f?new OffscreenCanvas(D,A):sa("canvas")}function y(D,A,j){let te=1,ae=Ie(D);if((ae.width>j||ae.height>j)&&(te=j/Math.max(ae.width,ae.height)),te<1)if(typeof HTMLImageElement<"u"&&D instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&D instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&D instanceof ImageBitmap||typeof VideoFrame<"u"&&D instanceof VideoFrame){let re=Math.floor(te*ae.width),Ue=Math.floor(te*ae.height);d===void 0&&(d=p(re,Ue));let be=A?p(re,Ue):d;return be.width=re,be.height=Ue,be.getContext("2d").drawImage(D,0,0,re,Ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ae.width+"x"+ae.height+") to ("+re+"x"+Ue+")."),be}else return"data"in D&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ae.width+"x"+ae.height+")."),D;return D}function g(D){return D.generateMipmaps&&D.minFilter!==Nt&&D.minFilter!==It}function m(D){n.generateMipmap(D)}function x(D,A,j,te,ae=!1){if(D!==null){if(n[D]!==void 0)return n[D];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+D+"'")}let re=A;if(A===n.RED&&(j===n.FLOAT&&(re=n.R32F),j===n.HALF_FLOAT&&(re=n.R16F),j===n.UNSIGNED_BYTE&&(re=n.R8)),A===n.RED_INTEGER&&(j===n.UNSIGNED_BYTE&&(re=n.R8UI),j===n.UNSIGNED_SHORT&&(re=n.R16UI),j===n.UNSIGNED_INT&&(re=n.R32UI),j===n.BYTE&&(re=n.R8I),j===n.SHORT&&(re=n.R16I),j===n.INT&&(re=n.R32I)),A===n.RG&&(j===n.FLOAT&&(re=n.RG32F),j===n.HALF_FLOAT&&(re=n.RG16F),j===n.UNSIGNED_BYTE&&(re=n.RG8)),A===n.RG_INTEGER&&(j===n.UNSIGNED_BYTE&&(re=n.RG8UI),j===n.UNSIGNED_SHORT&&(re=n.RG16UI),j===n.UNSIGNED_INT&&(re=n.RG32UI),j===n.BYTE&&(re=n.RG8I),j===n.SHORT&&(re=n.RG16I),j===n.INT&&(re=n.RG32I)),A===n.RGB&&j===n.UNSIGNED_INT_5_9_9_9_REV&&(re=n.RGB9_E5),A===n.RGBA){let Ue=ae?ea:ht.getTransfer(te);j===n.FLOAT&&(re=n.RGBA32F),j===n.HALF_FLOAT&&(re=n.RGBA16F),j===n.UNSIGNED_BYTE&&(re=Ue===vt?n.SRGB8_ALPHA8:n.RGBA8),j===n.UNSIGNED_SHORT_4_4_4_4&&(re=n.RGBA4),j===n.UNSIGNED_SHORT_5_5_5_1&&(re=n.RGB5_A1)}return(re===n.R16F||re===n.R32F||re===n.RG16F||re===n.RG32F||re===n.RGBA16F||re===n.RGBA32F)&&e.get("EXT_color_buffer_float"),re}function v(D,A){return g(D)===!0||D.isFramebufferTexture&&D.minFilter!==Nt&&D.minFilter!==It?Math.log2(Math.max(A.width,A.height))+1:D.mipmaps!==void 0&&D.mipmaps.length>0?D.mipmaps.length:D.isCompressedTexture&&Array.isArray(D.image)?A.mipmaps.length:1}function M(D){let A=D.target;A.removeEventListener("dispose",M),C(A),A.isVideoTexture&&u.delete(A)}function U(D){let A=D.target;A.removeEventListener("dispose",U),N(A)}function C(D){let A=i.get(D);if(A.__webglInit===void 0)return;let j=D.source,te=h.get(j);if(te){let ae=te[A.__cacheKey];ae.usedTimes--,ae.usedTimes===0&&R(D),Object.keys(te).length===0&&h.delete(j)}i.remove(D)}function R(D){let A=i.get(D);n.deleteTexture(A.__webglTexture);let j=D.source,te=h.get(j);delete te[A.__cacheKey],o.memory.textures--}function N(D){let A=i.get(D);if(D.depthTexture&&D.depthTexture.dispose(),D.isWebGLCubeRenderTarget)for(let te=0;te<6;te++){if(Array.isArray(A.__webglFramebuffer[te]))for(let ae=0;ae<A.__webglFramebuffer[te].length;ae++)n.deleteFramebuffer(A.__webglFramebuffer[te][ae]);else n.deleteFramebuffer(A.__webglFramebuffer[te]);A.__webglDepthbuffer&&n.deleteRenderbuffer(A.__webglDepthbuffer[te])}else{if(Array.isArray(A.__webglFramebuffer))for(let te=0;te<A.__webglFramebuffer.length;te++)n.deleteFramebuffer(A.__webglFramebuffer[te]);else n.deleteFramebuffer(A.__webglFramebuffer);if(A.__webglDepthbuffer&&n.deleteRenderbuffer(A.__webglDepthbuffer),A.__webglMultisampledFramebuffer&&n.deleteFramebuffer(A.__webglMultisampledFramebuffer),A.__webglColorRenderbuffer)for(let te=0;te<A.__webglColorRenderbuffer.length;te++)A.__webglColorRenderbuffer[te]&&n.deleteRenderbuffer(A.__webglColorRenderbuffer[te]);A.__webglDepthRenderbuffer&&n.deleteRenderbuffer(A.__webglDepthRenderbuffer)}let j=D.textures;for(let te=0,ae=j.length;te<ae;te++){let re=i.get(j[te]);re.__webglTexture&&(n.deleteTexture(re.__webglTexture),o.memory.textures--),i.remove(j[te])}i.remove(D)}let w=0;function b(){w=0}function O(){let D=w;return D>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+D+" texture units while this GPU supports only "+r.maxTextures),w+=1,D}function B(D){let A=[];return A.push(D.wrapS),A.push(D.wrapT),A.push(D.wrapR||0),A.push(D.magFilter),A.push(D.minFilter),A.push(D.anisotropy),A.push(D.internalFormat),A.push(D.format),A.push(D.type),A.push(D.generateMipmaps),A.push(D.premultiplyAlpha),A.push(D.flipY),A.push(D.unpackAlignment),A.push(D.colorSpace),A.join()}function F(D,A){let j=i.get(D);if(D.isVideoTexture&&ie(D),D.isRenderTargetTexture===!1&&D.version>0&&j.__version!==D.version){let te=D.image;if(te===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(te.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ve(j,D,A);return}}t.bindTexture(n.TEXTURE_2D,j.__webglTexture,n.TEXTURE0+A)}function H(D,A){let j=i.get(D);if(D.version>0&&j.__version!==D.version){ve(j,D,A);return}t.bindTexture(n.TEXTURE_2D_ARRAY,j.__webglTexture,n.TEXTURE0+A)}function X(D,A){let j=i.get(D);if(D.version>0&&j.__version!==D.version){ve(j,D,A);return}t.bindTexture(n.TEXTURE_3D,j.__webglTexture,n.TEXTURE0+A)}function ee(D,A){let j=i.get(D);if(D.version>0&&j.__version!==D.version){He(j,D,A);return}t.bindTexture(n.TEXTURE_CUBE_MAP,j.__webglTexture,n.TEXTURE0+A)}let ce={[qo]:n.REPEAT,[Mn]:n.CLAMP_TO_EDGE,[Zo]:n.MIRRORED_REPEAT},k={[Nt]:n.NEAREST,[xp]:n.NEAREST_MIPMAP_NEAREST,[Rs]:n.NEAREST_MIPMAP_LINEAR,[It]:n.LINEAR,[Vo]:n.LINEAR_MIPMAP_NEAREST,[jn]:n.LINEAR_MIPMAP_LINEAR},le={[ev]:n.NEVER,[ov]:n.ALWAYS,[tv]:n.LESS,[Cp]:n.LEQUAL,[nv]:n.EQUAL,[sv]:n.GEQUAL,[iv]:n.GREATER,[rv]:n.NOTEQUAL};function he(D,A){if(A.type===En&&e.has("OES_texture_float_linear")===!1&&(A.magFilter===It||A.magFilter===Vo||A.magFilter===Rs||A.magFilter===jn||A.minFilter===It||A.minFilter===Vo||A.minFilter===Rs||A.minFilter===jn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(D,n.TEXTURE_WRAP_S,ce[A.wrapS]),n.texParameteri(D,n.TEXTURE_WRAP_T,ce[A.wrapT]),(D===n.TEXTURE_3D||D===n.TEXTURE_2D_ARRAY)&&n.texParameteri(D,n.TEXTURE_WRAP_R,ce[A.wrapR]),n.texParameteri(D,n.TEXTURE_MAG_FILTER,k[A.magFilter]),n.texParameteri(D,n.TEXTURE_MIN_FILTER,k[A.minFilter]),A.compareFunction&&(n.texParameteri(D,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(D,n.TEXTURE_COMPARE_FUNC,le[A.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(A.magFilter===Nt||A.minFilter!==Rs&&A.minFilter!==jn||A.type===En&&e.has("OES_texture_float_linear")===!1)return;if(A.anisotropy>1||i.get(A).__currentAnisotropy){let j=e.get("EXT_texture_filter_anisotropic");n.texParameterf(D,j.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(A.anisotropy,r.getMaxAnisotropy())),i.get(A).__currentAnisotropy=A.anisotropy}}}function Te(D,A){let j=!1;D.__webglInit===void 0&&(D.__webglInit=!0,A.addEventListener("dispose",M));let te=A.source,ae=h.get(te);ae===void 0&&(ae={},h.set(te,ae));let re=B(A);if(re!==D.__cacheKey){ae[re]===void 0&&(ae[re]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,j=!0),ae[re].usedTimes++;let Ue=ae[D.__cacheKey];Ue!==void 0&&(ae[D.__cacheKey].usedTimes--,Ue.usedTimes===0&&R(A)),D.__cacheKey=re,D.__webglTexture=ae[re].texture}return j}function ve(D,A,j){let te=n.TEXTURE_2D;(A.isDataArrayTexture||A.isCompressedArrayTexture)&&(te=n.TEXTURE_2D_ARRAY),A.isData3DTexture&&(te=n.TEXTURE_3D);let ae=Te(D,A),re=A.source;t.bindTexture(te,D.__webglTexture,n.TEXTURE0+j);let Ue=i.get(re);if(re.version!==Ue.__version||ae===!0){t.activeTexture(n.TEXTURE0+j);let be=ht.getPrimaries(ht.workingColorSpace),_e=A.colorSpace===hi?null:ht.getPrimaries(A.colorSpace),je=A.colorSpace===hi||be===_e?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,A.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,A.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,A.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,je);let pe=y(A.image,!1,r.maxTextureSize);pe=ge(A,pe);let Oe=s.convert(A.format,A.colorSpace),qe=s.convert(A.type),Ne=x(A.internalFormat,Oe,qe,A.colorSpace,A.isVideoTexture);he(te,A);let Re,Fe=A.mipmaps,et=A.isVideoTexture!==!0,mt=Ue.__version===void 0||ae===!0,Ge=re.dataReady,z=v(A,pe);if(A.isDepthTexture)Ne=n.DEPTH_COMPONENT16,A.type===En?Ne=n.DEPTH_COMPONENT32F:A.type===Lr?Ne=n.DEPTH_COMPONENT24:A.type===qs&&(Ne=n.DEPTH24_STENCIL8),mt&&(et?t.texStorage2D(n.TEXTURE_2D,1,Ne,pe.width,pe.height):t.texImage2D(n.TEXTURE_2D,0,Ne,pe.width,pe.height,0,Oe,qe,null));else if(A.isDataTexture)if(Fe.length>0){et&&mt&&t.texStorage2D(n.TEXTURE_2D,z,Ne,Fe[0].width,Fe[0].height);for(let ue=0,Q=Fe.length;ue<Q;ue++)Re=Fe[ue],et?Ge&&t.texSubImage2D(n.TEXTURE_2D,ue,0,0,Re.width,Re.height,Oe,qe,Re.data):t.texImage2D(n.TEXTURE_2D,ue,Ne,Re.width,Re.height,0,Oe,qe,Re.data);A.generateMipmaps=!1}else et?(mt&&t.texStorage2D(n.TEXTURE_2D,z,Ne,pe.width,pe.height),Ge&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,pe.width,pe.height,Oe,qe,pe.data)):t.texImage2D(n.TEXTURE_2D,0,Ne,pe.width,pe.height,0,Oe,qe,pe.data);else if(A.isCompressedTexture)if(A.isCompressedArrayTexture){et&&mt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,z,Ne,Fe[0].width,Fe[0].height,pe.depth);for(let ue=0,Q=Fe.length;ue<Q;ue++)Re=Fe[ue],A.format!==dn?Oe!==null?et?Ge&&t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,Re.width,Re.height,pe.depth,Oe,Re.data,0,0):t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,Ne,Re.width,Re.height,pe.depth,0,Re.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):et?Ge&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,Re.width,Re.height,pe.depth,Oe,qe,Re.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,Ne,Re.width,Re.height,pe.depth,0,Oe,qe,Re.data)}else{et&&mt&&t.texStorage2D(n.TEXTURE_2D,z,Ne,Fe[0].width,Fe[0].height);for(let ue=0,Q=Fe.length;ue<Q;ue++)Re=Fe[ue],A.format!==dn?Oe!==null?et?Ge&&t.compressedTexSubImage2D(n.TEXTURE_2D,ue,0,0,Re.width,Re.height,Oe,Re.data):t.compressedTexImage2D(n.TEXTURE_2D,ue,Ne,Re.width,Re.height,0,Re.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):et?Ge&&t.texSubImage2D(n.TEXTURE_2D,ue,0,0,Re.width,Re.height,Oe,qe,Re.data):t.texImage2D(n.TEXTURE_2D,ue,Ne,Re.width,Re.height,0,Oe,qe,Re.data)}else if(A.isDataArrayTexture)et?(mt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,z,Ne,pe.width,pe.height,pe.depth),Ge&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,pe.width,pe.height,pe.depth,Oe,qe,pe.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ne,pe.width,pe.height,pe.depth,0,Oe,qe,pe.data);else if(A.isData3DTexture)et?(mt&&t.texStorage3D(n.TEXTURE_3D,z,Ne,pe.width,pe.height,pe.depth),Ge&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,pe.width,pe.height,pe.depth,Oe,qe,pe.data)):t.texImage3D(n.TEXTURE_3D,0,Ne,pe.width,pe.height,pe.depth,0,Oe,qe,pe.data);else if(A.isFramebufferTexture){if(mt)if(et)t.texStorage2D(n.TEXTURE_2D,z,Ne,pe.width,pe.height);else{let ue=pe.width,Q=pe.height;for(let Se=0;Se<z;Se++)t.texImage2D(n.TEXTURE_2D,Se,Ne,ue,Q,0,Oe,qe,null),ue>>=1,Q>>=1}}else if(Fe.length>0){if(et&&mt){let ue=Ie(Fe[0]);t.texStorage2D(n.TEXTURE_2D,z,Ne,ue.width,ue.height)}for(let ue=0,Q=Fe.length;ue<Q;ue++)Re=Fe[ue],et?Ge&&t.texSubImage2D(n.TEXTURE_2D,ue,0,0,Oe,qe,Re):t.texImage2D(n.TEXTURE_2D,ue,Ne,Oe,qe,Re);A.generateMipmaps=!1}else if(et){if(mt){let ue=Ie(pe);t.texStorage2D(n.TEXTURE_2D,z,Ne,ue.width,ue.height)}Ge&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Oe,qe,pe)}else t.texImage2D(n.TEXTURE_2D,0,Ne,Oe,qe,pe);g(A)&&m(te),Ue.__version=re.version,A.onUpdate&&A.onUpdate(A)}D.__version=A.version}function He(D,A,j){if(A.image.length!==6)return;let te=Te(D,A),ae=A.source;t.bindTexture(n.TEXTURE_CUBE_MAP,D.__webglTexture,n.TEXTURE0+j);let re=i.get(ae);if(ae.version!==re.__version||te===!0){t.activeTexture(n.TEXTURE0+j);let Ue=ht.getPrimaries(ht.workingColorSpace),be=A.colorSpace===hi?null:ht.getPrimaries(A.colorSpace),_e=A.colorSpace===hi||Ue===be?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,A.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,A.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,A.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,_e);let je=A.isCompressedTexture||A.image[0].isCompressedTexture,pe=A.image[0]&&A.image[0].isDataTexture,Oe=[];for(let Q=0;Q<6;Q++)!je&&!pe?Oe[Q]=y(A.image[Q],!0,r.maxCubemapSize):Oe[Q]=pe?A.image[Q].image:A.image[Q],Oe[Q]=ge(A,Oe[Q]);let qe=Oe[0],Ne=s.convert(A.format,A.colorSpace),Re=s.convert(A.type),Fe=x(A.internalFormat,Ne,Re,A.colorSpace),et=A.isVideoTexture!==!0,mt=re.__version===void 0||te===!0,Ge=ae.dataReady,z=v(A,qe);he(n.TEXTURE_CUBE_MAP,A);let ue;if(je){et&&mt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,z,Fe,qe.width,qe.height);for(let Q=0;Q<6;Q++){ue=Oe[Q].mipmaps;for(let Se=0;Se<ue.length;Se++){let Ae=ue[Se];A.format!==dn?Ne!==null?et?Ge&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Se,0,0,Ae.width,Ae.height,Ne,Ae.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Se,Fe,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):et?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Se,0,0,Ae.width,Ae.height,Ne,Re,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Se,Fe,Ae.width,Ae.height,0,Ne,Re,Ae.data)}}}else{if(ue=A.mipmaps,et&&mt){ue.length>0&&z++;let Q=Ie(Oe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,z,Fe,Q.width,Q.height)}for(let Q=0;Q<6;Q++)if(pe){et?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,Oe[Q].width,Oe[Q].height,Ne,Re,Oe[Q].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,Fe,Oe[Q].width,Oe[Q].height,0,Ne,Re,Oe[Q].data);for(let Se=0;Se<ue.length;Se++){let Pe=ue[Se].image[Q].image;et?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Se+1,0,0,Pe.width,Pe.height,Ne,Re,Pe.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Se+1,Fe,Pe.width,Pe.height,0,Ne,Re,Pe.data)}}else{et?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,Ne,Re,Oe[Q]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,Fe,Ne,Re,Oe[Q]);for(let Se=0;Se<ue.length;Se++){let Ae=ue[Se];et?Ge&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Se+1,0,0,Ne,Re,Ae.image[Q]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Se+1,Fe,Ne,Re,Ae.image[Q])}}}g(A)&&m(n.TEXTURE_CUBE_MAP),re.__version=ae.version,A.onUpdate&&A.onUpdate(A)}D.__version=A.version}function Z(D,A,j,te,ae,re){let Ue=s.convert(j.format,j.colorSpace),be=s.convert(j.type),_e=x(j.internalFormat,Ue,be,j.colorSpace);if(!i.get(A).__hasExternalTextures){let pe=Math.max(1,A.width>>re),Oe=Math.max(1,A.height>>re);ae===n.TEXTURE_3D||ae===n.TEXTURE_2D_ARRAY?t.texImage3D(ae,re,_e,pe,Oe,A.depth,0,Ue,be,null):t.texImage2D(ae,re,_e,pe,Oe,0,Ue,be,null)}t.bindFramebuffer(n.FRAMEBUFFER,D),fe(A)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,te,ae,i.get(j).__webglTexture,0,K(A)):(ae===n.TEXTURE_2D||ae>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&ae<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,te,ae,i.get(j).__webglTexture,re),t.bindFramebuffer(n.FRAMEBUFFER,null)}function J(D,A,j){if(n.bindRenderbuffer(n.RENDERBUFFER,D),A.depthBuffer&&!A.stencilBuffer){let te=n.DEPTH_COMPONENT24;if(j||fe(A)){let ae=A.depthTexture;ae&&ae.isDepthTexture&&(ae.type===En?te=n.DEPTH_COMPONENT32F:ae.type===Lr&&(te=n.DEPTH_COMPONENT24));let re=K(A);fe(A)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,re,te,A.width,A.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,re,te,A.width,A.height)}else n.renderbufferStorage(n.RENDERBUFFER,te,A.width,A.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,D)}else if(A.depthBuffer&&A.stencilBuffer){let te=K(A);j&&fe(A)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,te,n.DEPTH24_STENCIL8,A.width,A.height):fe(A)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,te,n.DEPTH24_STENCIL8,A.width,A.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,A.width,A.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,D)}else{let te=A.textures;for(let ae=0;ae<te.length;ae++){let re=te[ae],Ue=s.convert(re.format,re.colorSpace),be=s.convert(re.type),_e=x(re.internalFormat,Ue,be,re.colorSpace),je=K(A);j&&fe(A)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,je,_e,A.width,A.height):fe(A)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,je,_e,A.width,A.height):n.renderbufferStorage(n.RENDERBUFFER,_e,A.width,A.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function ye(D,A){if(A&&A.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,D),!(A.depthTexture&&A.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(A.depthTexture).__webglTexture||A.depthTexture.image.width!==A.width||A.depthTexture.image.height!==A.height)&&(A.depthTexture.image.width=A.width,A.depthTexture.image.height=A.height,A.depthTexture.needsUpdate=!0),F(A.depthTexture,0);let te=i.get(A.depthTexture).__webglTexture,ae=K(A);if(A.depthTexture.format===Rr)fe(A)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,te,0,ae):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,te,0);else if(A.depthTexture.format===Ns)fe(A)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,te,0,ae):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,te,0);else throw new Error("Unknown depthTexture format")}function oe(D){let A=i.get(D),j=D.isWebGLCubeRenderTarget===!0;if(D.depthTexture&&!A.__autoAllocateDepthBuffer){if(j)throw new Error("target.depthTexture not supported in Cube render targets");ye(A.__webglFramebuffer,D)}else if(j){A.__webglDepthbuffer=[];for(let te=0;te<6;te++)t.bindFramebuffer(n.FRAMEBUFFER,A.__webglFramebuffer[te]),A.__webglDepthbuffer[te]=n.createRenderbuffer(),J(A.__webglDepthbuffer[te],D,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,A.__webglFramebuffer),A.__webglDepthbuffer=n.createRenderbuffer(),J(A.__webglDepthbuffer,D,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function ze(D,A,j){let te=i.get(D);A!==void 0&&Z(te.__webglFramebuffer,D,D.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),j!==void 0&&oe(D)}function xe(D){let A=D.texture,j=i.get(D),te=i.get(A);D.addEventListener("dispose",U);let ae=D.textures,re=D.isWebGLCubeRenderTarget===!0,Ue=ae.length>1;if(Ue||(te.__webglTexture===void 0&&(te.__webglTexture=n.createTexture()),te.__version=A.version,o.memory.textures++),re){j.__webglFramebuffer=[];for(let be=0;be<6;be++)if(A.mipmaps&&A.mipmaps.length>0){j.__webglFramebuffer[be]=[];for(let _e=0;_e<A.mipmaps.length;_e++)j.__webglFramebuffer[be][_e]=n.createFramebuffer()}else j.__webglFramebuffer[be]=n.createFramebuffer()}else{if(A.mipmaps&&A.mipmaps.length>0){j.__webglFramebuffer=[];for(let be=0;be<A.mipmaps.length;be++)j.__webglFramebuffer[be]=n.createFramebuffer()}else j.__webglFramebuffer=n.createFramebuffer();if(Ue)for(let be=0,_e=ae.length;be<_e;be++){let je=i.get(ae[be]);je.__webglTexture===void 0&&(je.__webglTexture=n.createTexture(),o.memory.textures++)}if(D.samples>0&&fe(D)===!1){j.__webglMultisampledFramebuffer=n.createFramebuffer(),j.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,j.__webglMultisampledFramebuffer);for(let be=0;be<ae.length;be++){let _e=ae[be];j.__webglColorRenderbuffer[be]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,j.__webglColorRenderbuffer[be]);let je=s.convert(_e.format,_e.colorSpace),pe=s.convert(_e.type),Oe=x(_e.internalFormat,je,pe,_e.colorSpace,D.isXRRenderTarget===!0),qe=K(D);n.renderbufferStorageMultisample(n.RENDERBUFFER,qe,Oe,D.width,D.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+be,n.RENDERBUFFER,j.__webglColorRenderbuffer[be])}n.bindRenderbuffer(n.RENDERBUFFER,null),D.depthBuffer&&(j.__webglDepthRenderbuffer=n.createRenderbuffer(),J(j.__webglDepthRenderbuffer,D,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(re){t.bindTexture(n.TEXTURE_CUBE_MAP,te.__webglTexture),he(n.TEXTURE_CUBE_MAP,A);for(let be=0;be<6;be++)if(A.mipmaps&&A.mipmaps.length>0)for(let _e=0;_e<A.mipmaps.length;_e++)Z(j.__webglFramebuffer[be][_e],D,A,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+be,_e);else Z(j.__webglFramebuffer[be],D,A,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+be,0);g(A)&&m(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ue){for(let be=0,_e=ae.length;be<_e;be++){let je=ae[be],pe=i.get(je);t.bindTexture(n.TEXTURE_2D,pe.__webglTexture),he(n.TEXTURE_2D,je),Z(j.__webglFramebuffer,D,je,n.COLOR_ATTACHMENT0+be,n.TEXTURE_2D,0),g(je)&&m(n.TEXTURE_2D)}t.unbindTexture()}else{let be=n.TEXTURE_2D;if((D.isWebGL3DRenderTarget||D.isWebGLArrayRenderTarget)&&(be=D.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(be,te.__webglTexture),he(be,A),A.mipmaps&&A.mipmaps.length>0)for(let _e=0;_e<A.mipmaps.length;_e++)Z(j.__webglFramebuffer[_e],D,A,n.COLOR_ATTACHMENT0,be,_e);else Z(j.__webglFramebuffer,D,A,n.COLOR_ATTACHMENT0,be,0);g(A)&&m(be),t.unbindTexture()}D.depthBuffer&&oe(D)}function V(D){let A=D.textures;for(let j=0,te=A.length;j<te;j++){let ae=A[j];if(g(ae)){let re=D.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,Ue=i.get(ae).__webglTexture;t.bindTexture(re,Ue),m(re),t.unbindTexture()}}}let Be=[],Y=[];function de(D){if(D.samples>0){if(fe(D)===!1){let A=D.textures,j=D.width,te=D.height,ae=n.COLOR_BUFFER_BIT,re=D.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ue=i.get(D),be=A.length>1;if(be)for(let _e=0;_e<A.length;_e++)t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+_e,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+_e,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer);for(let _e=0;_e<A.length;_e++){if(D.resolveDepthBuffer&&(D.depthBuffer&&(ae|=n.DEPTH_BUFFER_BIT),D.stencilBuffer&&D.resolveStencilBuffer&&(ae|=n.STENCIL_BUFFER_BIT)),be){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ue.__webglColorRenderbuffer[_e]);let je=i.get(A[_e]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,je,0)}n.blitFramebuffer(0,0,j,te,0,0,j,te,ae,n.NEAREST),c===!0&&(Be.length=0,Y.length=0,Be.push(n.COLOR_ATTACHMENT0+_e),D.depthBuffer&&D.resolveDepthBuffer===!1&&(Be.push(re),Y.push(re),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Y)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Be))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),be)for(let _e=0;_e<A.length;_e++){t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+_e,n.RENDERBUFFER,Ue.__webglColorRenderbuffer[_e]);let je=i.get(A[_e]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+_e,n.TEXTURE_2D,je,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer)}else if(D.depthBuffer&&D.resolveDepthBuffer===!1&&c){let A=D.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[A])}}}function K(D){return Math.min(r.maxSamples,D.samples)}function fe(D){let A=i.get(D);return D.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&A.__useRenderToTexture!==!1}function ie(D){let A=o.render.frame;u.get(D)!==A&&(u.set(D,A),D.update())}function ge(D,A){let j=D.colorSpace,te=D.format,ae=D.type;return D.isCompressedTexture===!0||D.isVideoTexture===!0||j!==Ei&&j!==hi&&(ht.getTransfer(j)===vt?(te!==dn||ae!==wi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",j)),A}function Ie(D){return typeof HTMLImageElement<"u"&&D instanceof HTMLImageElement?(l.width=D.naturalWidth||D.width,l.height=D.naturalHeight||D.height):typeof VideoFrame<"u"&&D instanceof VideoFrame?(l.width=D.displayWidth,l.height=D.displayHeight):(l.width=D.width,l.height=D.height),l}this.allocateTextureUnit=O,this.resetTextureUnits=b,this.setTexture2D=F,this.setTexture2DArray=H,this.setTexture3D=X,this.setTextureCube=ee,this.rebindTextures=ze,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=V,this.updateMultisampleRenderTarget=de,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=fe}function xv(n,e){function t(i,r=hi){let s,o=ht.getTransfer(r);if(i===wi)return n.UNSIGNED_BYTE;if(i===wp)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Sp)return n.UNSIGNED_SHORT_5_5_5_1;if(i===V0)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===B0)return n.BYTE;if(i===z0)return n.SHORT;if(i===bp)return n.UNSIGNED_SHORT;if(i===_p)return n.INT;if(i===Lr)return n.UNSIGNED_INT;if(i===En)return n.FLOAT;if(i===Ua)return n.HALF_FLOAT;if(i===$0)return n.ALPHA;if(i===H0)return n.RGB;if(i===dn)return n.RGBA;if(i===j0)return n.LUMINANCE;if(i===G0)return n.LUMINANCE_ALPHA;if(i===Rr)return n.DEPTH_COMPONENT;if(i===Ns)return n.DEPTH_STENCIL;if(i===Mp)return n.RED;if(i===Ep)return n.RED_INTEGER;if(i===W0)return n.RG;if(i===Ap)return n.RG_INTEGER;if(i===Tp)return n.RGBA_INTEGER;if(i===gl||i===yl||i===vl||i===xl)if(o===vt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===gl)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===yl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===vl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===xl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===gl)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===yl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===vl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===xl)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ah||i===Th||i===Ih||i===Ch)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Ah)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Th)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ih)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ch)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Rh||i===Ph||i===Lh)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Rh||i===Ph)return o===vt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Lh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Dh||i===Oh||i===Uh||i===Nh||i===Fh||i===kh||i===Bh||i===zh||i===Vh||i===$h||i===Hh||i===jh||i===Gh||i===Wh)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Dh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Oh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Uh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Nh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Fh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===kh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Bh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===zh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Vh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===$h)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Hh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===jh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Gh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Wh)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===bl||i===Xh||i===Yh)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===bl)return o===vt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Xh)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Yh)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===X0||i===qh||i===Zh||i===Jh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===bl)return s.COMPRESSED_RED_RGTC1_EXT;if(i===qh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Zh)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Jh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===qs?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}function lI(n,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function i(g,m){m.color.getRGB(g.fogColor.value,dv(n)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,x,v,M){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),d(g,m)):m.isMeshPhongMaterial?(s(g,m),u(g,m)):m.isMeshStandardMaterial?(s(g,m),h(g,m),m.isMeshPhysicalMaterial&&f(g,m,M)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),y(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(o(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?c(g,m,x,v):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===nn&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===nn&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x=e.get(m),v=x.envMap,M=x.envMapRotation;if(v&&(g.envMap.value=v,gr.copy(M),gr.x*=-1,gr.y*=-1,gr.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(gr.y*=-1,gr.z*=-1),g.envMapRotation.value.setFromMatrix4(cI.makeRotationFromEuler(gr)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let U=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*U,t(m.lightMap,g.lightMapTransform)}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function o(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function c(g,m,x,v){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*x,g.scale.value=v*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function u(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function d(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function h(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,x){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===nn&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function y(g,m){let x=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function uI(n,e,t,i){let r={},s={},o=[],a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function c(x,v){let M=v.program;i.uniformBlockBinding(x,M)}function l(x,v){let M=r[x.id];M===void 0&&(p(x),M=u(x),r[x.id]=M,x.addEventListener("dispose",g));let U=v.program;i.updateUBOMapping(x,U);let C=e.render.frame;s[x.id]!==C&&(h(x),s[x.id]=C)}function u(x){let v=d();x.__bindingPointIndex=v;let M=n.createBuffer(),U=x.__size,C=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,M),n.bufferData(n.UNIFORM_BUFFER,U,C),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,v,M),M}function d(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(x){let v=r[x.id],M=x.uniforms,U=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,v);for(let C=0,R=M.length;C<R;C++){let N=Array.isArray(M[C])?M[C]:[M[C]];for(let w=0,b=N.length;w<b;w++){let O=N[w];if(f(O,C,w,U)===!0){let B=O.__offset,F=Array.isArray(O.value)?O.value:[O.value],H=0;for(let X=0;X<F.length;X++){let ee=F[X],ce=y(ee);typeof ee=="number"||typeof ee=="boolean"?(O.__data[0]=ee,n.bufferSubData(n.UNIFORM_BUFFER,B+H,O.__data)):ee.isMatrix3?(O.__data[0]=ee.elements[0],O.__data[1]=ee.elements[1],O.__data[2]=ee.elements[2],O.__data[3]=0,O.__data[4]=ee.elements[3],O.__data[5]=ee.elements[4],O.__data[6]=ee.elements[5],O.__data[7]=0,O.__data[8]=ee.elements[6],O.__data[9]=ee.elements[7],O.__data[10]=ee.elements[8],O.__data[11]=0):(ee.toArray(O.__data,H),H+=ce.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,B,O.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(x,v,M,U){let C=x.value,R=v+"_"+M;if(U[R]===void 0)return typeof C=="number"||typeof C=="boolean"?U[R]=C:U[R]=C.clone(),!0;{let N=U[R];if(typeof C=="number"||typeof C=="boolean"){if(N!==C)return U[R]=C,!0}else if(N.equals(C)===!1)return N.copy(C),!0}return!1}function p(x){let v=x.uniforms,M=0,U=16;for(let R=0,N=v.length;R<N;R++){let w=Array.isArray(v[R])?v[R]:[v[R]];for(let b=0,O=w.length;b<O;b++){let B=w[b],F=Array.isArray(B.value)?B.value:[B.value];for(let H=0,X=F.length;H<X;H++){let ee=F[H],ce=y(ee),k=M%U;k!==0&&U-k<ce.boundary&&(M+=U-k),B.__data=new Float32Array(ce.storage/Float32Array.BYTES_PER_ELEMENT),B.__offset=M,M+=ce.storage}}}let C=M%U;return C>0&&(M+=U-C),x.__size=M,x.__cache={},this}function y(x){let v={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function g(x){let v=x.target;v.removeEventListener("dispose",g);let M=o.indexOf(v.__bindingPointIndex);o.splice(M,1),n.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function m(){for(let x in r)n.deleteBuffer(r[x]);o=[],r={},s={}}return{bind:c,update:l,dispose:m}}function Xc(n,e,t,i,r,s){Ts.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Lo.x=s*Ts.x-r*Ts.y,Lo.y=r*Ts.x+s*Ts.y):Lo.copy(Ts),n.copy(e),n.x+=Lo.x,n.y+=Lo.y,n.applyMatrix4(bv)}function pI(n,e){return n.z-e.z}function mI(n,e){return e.z-n.z}function yI(n,e,t=0){let i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){let r=n.count;for(let s=0;s<r;s++)for(let o=0;o<i;o++)e.setComponent(s+t,o,n.getComponent(s,o))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function el(n,e,t,i,r,s){let o=n.geometry.attributes.position;if(kl.fromBufferAttribute(o,r),Bl.fromBufferAttribute(o,s),t.distanceSqToSegment(kl,Bl,hh,My)>i)return;hh.applyMatrix4(n.matrixWorld);let c=e.ray.origin.distanceTo(hh);if(!(c<e.near||c>e.far))return{distance:c,point:My.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}function Iy(n,e,t,i,r,s,o){let a=xf.distanceSqToPoint(n);if(a<t){let c=new L;xf.closestPointToPoint(n,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}function Lp(){let n=0,e=0,t=0,i=0;function r(s,o,a,c){n=s,e=a,t=-3*s+3*o-2*a-c,i=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,d){let h=(o-s)/l-(a-s)/(l+u)+(a-o)/u,f=(a-o)/u-(c-o)/(u+d)+(c-a)/d;h*=u,f*=u,r(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return n+e*s+t*o+i*a}}}function Cy(n,e,t,i,r){let s=(i-e)*.5,o=(r-t)*.5,a=n*n,c=n*a;return(2*t-2*i+s+o)*c+(-3*t+3*i-2*s-o)*a+s*n+t}function vI(n,e){let t=1-n;return t*t*e}function xI(n,e){return 2*(1-n)*n*e}function bI(n,e){return n*n*e}function jo(n,e,t,i){return vI(n,e)+xI(n,t)+bI(n,i)}function _I(n,e){let t=1-n;return t*t*t*e}function wI(n,e){let t=1-n;return 3*t*t*n*e}function SI(n,e){return 3*(1-n)*n*n*e}function MI(n,e){return n*n*n*e}function Go(n,e,t,i,r){return _I(n,e)+wI(n,t)+SI(n,i)+MI(n,r)}function _v(n,e,t,i,r){let s,o;if(r===VI(n,e,t,i)>0)for(s=e;s<t;s+=i)o=Ry(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=Ry(s,n[s],n[s+1],o);return o&&Bu(o,o.next)&&(Ma(o),o=o.next),o}function kr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Bu(t,t.next)||_t(t.prev,t,t.next)===0)){if(Ma(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function wa(n,e,t,i,r,s,o){if(!n)return;!o&&s&&UI(n,i,r,s);let a=n,c,l;for(;n.prev!==n.next;){if(c=n.prev,l=n.next,s?TI(n,i,r,s):AI(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Ma(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=II(kr(n),e,t),wa(n,e,t,i,r,s,2)):o===2&&CI(n,e,t,i,r,s):wa(kr(n),e,t,i,r,s,1);break}}}function AI(n){let e=n.prev,t=n,i=n.next;if(_t(e,t,i)>=0)return!1;let r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=r<s?r<o?r:o:s<o?s:o,d=a<c?a<l?a:l:c<l?c:l,h=r>s?r>o?r:o:s>o?s:o,f=a>c?a>l?a:l:c>l?c:l,p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Ds(r,a,s,c,o,l,p.x,p.y)&&_t(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function TI(n,e,t,i){let r=n.prev,s=n,o=n.next;if(_t(r,s,o)>=0)return!1;let a=r.x,c=s.x,l=o.x,u=r.y,d=s.y,h=o.y,f=a<c?a<l?a:l:c<l?c:l,p=u<d?u<h?u:h:d<h?d:h,y=a>c?a>l?a:l:c>l?c:l,g=u>d?u>h?u:h:d>h?d:h,m=Ef(f,p,e,t,i),x=Ef(y,g,e,t,i),v=n.prevZ,M=n.nextZ;for(;v&&v.z>=m&&M&&M.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=p&&v.y<=g&&v!==r&&v!==o&&Ds(a,u,c,d,l,h,v.x,v.y)&&_t(v.prev,v,v.next)>=0||(v=v.prevZ,M.x>=f&&M.x<=y&&M.y>=p&&M.y<=g&&M!==r&&M!==o&&Ds(a,u,c,d,l,h,M.x,M.y)&&_t(M.prev,M,M.next)>=0))return!1;M=M.nextZ}for(;v&&v.z>=m;){if(v.x>=f&&v.x<=y&&v.y>=p&&v.y<=g&&v!==r&&v!==o&&Ds(a,u,c,d,l,h,v.x,v.y)&&_t(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;M&&M.z<=x;){if(M.x>=f&&M.x<=y&&M.y>=p&&M.y<=g&&M!==r&&M!==o&&Ds(a,u,c,d,l,h,M.x,M.y)&&_t(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function II(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!Bu(r,s)&&wv(r,i,i.next,s)&&Sa(r,s)&&Sa(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Ma(i),Ma(i.next),i=n=s),i=i.next}while(i!==n);return kr(i)}function CI(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&kI(o,a)){let c=Sv(o,a);o=kr(o,o.next),c=kr(c,c.next),wa(o,e,t,i,r,s,0),wa(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function RI(n,e,t,i){let r=[],s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*i,c=s<o-1?e[s+1]*i:n.length,l=_v(n,a,c,i,!1),l===l.next&&(l.steiner=!0),r.push(FI(l));for(r.sort(PI),s=0;s<r.length;s++)t=LI(r[s],t);return t}function PI(n,e){return n.x-e.x}function LI(n,e){let t=DI(n,e);if(!t)return e;let i=Sv(t,n);return kr(i,i.next),kr(t,t.next)}function DI(n,e){let t=e,i=-1/0,r,s=n.x,o=n.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let h=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=s&&h>i&&(i=h,r=t.x<t.next.x?t:t.next,h===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,c=r.x,l=r.y,u=1/0,d;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&Ds(o<l?s:i,o,c,l,o<l?i:s,o,t.x,t.y)&&(d=Math.abs(o-t.y)/(s-t.x),Sa(t,n)&&(d<u||d===u&&(t.x>r.x||t.x===r.x&&OI(r,t)))&&(r=t,u=d)),t=t.next;while(t!==a);return r}function OI(n,e){return _t(n.prev,n,e.prev)<0&&_t(e.next,n,n.next)<0}function UI(n,e,t,i){let r=n;do r.z===0&&(r.z=Ef(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,NI(r)}function NI(n){let e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<l&&(a++,i=i.nextZ,!!i);e++);for(c=l;a>0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function Ef(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function FI(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Ds(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function kI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!BI(n,e)&&(Sa(n,e)&&Sa(e,n)&&zI(n,e)&&(_t(n.prev,n,e.prev)||_t(n,e.prev,e))||Bu(n,e)&&_t(n.prev,n,n.next)>0&&_t(e.prev,e,e.next)>0)}function _t(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Bu(n,e){return n.x===e.x&&n.y===e.y}function wv(n,e,t,i){let r=cl(_t(n,e,t)),s=cl(_t(n,e,i)),o=cl(_t(t,i,n)),a=cl(_t(t,i,e));return!!(r!==s&&o!==a||r===0&&al(n,t,e)||s===0&&al(n,i,e)||o===0&&al(t,n,i)||a===0&&al(t,e,i))}function al(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function cl(n){return n>0?1:n<0?-1:0}function BI(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&wv(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Sa(n,e){return _t(n.prev,n,n.next)<0?_t(n,e,n.next)>=0&&_t(n,n.prev,e)>=0:_t(n,e,n.prev)<0||_t(n,n.next,e)<0}function zI(n,e){let t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function Sv(n,e){let t=new Af(n.i,n.x,n.y),i=new Af(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function Ry(n,e,t,i){let r=new Af(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Ma(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Af(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function VI(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}function Py(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Ly(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}function HI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){let s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}function jI(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}function Dy(n,e,t){let i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}function Ir(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Mv(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ev(n){function e(r,s){return n[r]-n[s]}let t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Tf(n,e,t){let i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){let a=t[s]*e;for(let c=0;c!==e;++c)r[o++]=n[a+c]}return r}function Dp(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function GI(n,e,t,i,r=30){let s=n.clone();s.name=e;let o=[];for(let c=0;c<s.tracks.length;++c){let l=s.tracks[c],u=l.getValueSize(),d=[],h=[];for(let f=0;f<l.times.length;++f){let p=l.times[f]*r;if(!(p<t||p>=i)){d.push(l.times[f]);for(let y=0;y<u;++y)h.push(l.values[f*u+y])}}d.length!==0&&(l.times=Ir(d,l.times.constructor),l.values=Ir(h,l.values.constructor),o.push(l))}s.tracks=o;let a=1/0;for(let c=0;c<s.tracks.length;++c)a>s.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c<s.tracks.length;++c)s.tracks[c].shift(-1*a);return s.resetDuration(),s}function WI(n,e=0,t=n,i=30){i<=0&&(i=30);let r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){let a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=n.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===c});if(l===void 0)continue;let u=0,d=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=d/3);let h=0,f=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=f/3);let p=a.times.length-1,y;if(s<=a.times[0]){let m=u,x=d-u;y=a.values.slice(m,x)}else if(s>=a.times[p]){let m=p*d+u,x=m+d-u;y=a.values.slice(m,x)}else{let m=a.createInterpolant(),x=u,v=d-u;m.evaluate(s),y=m.resultBuffer.slice(x,v)}c==="quaternion"&&new Zt().fromArray(y).normalize().conjugate().toArray(y);let g=l.times.length;for(let m=0;m<g;++m){let x=m*f+h;if(c==="quaternion")Zt.multiplyQuaternionsFlat(l.values,x,y,0,l.values,x);else{let v=f-h*2;for(let M=0;M<v;++M)l.values[x+M]-=y[M]}}}return n.blendMode=Ip,n}function YI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return zr;case"vector":case"vector2":case"vector3":case"vector4":return Vr;case"color":return Ca;case"quaternion":return Zi;case"bool":case"boolean":return Si;case"string":return Mi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function qI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=YI(n.type);if(n.times===void 0){let t=[],i=[];Dp(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}function $y(){return(typeof performance>"u"?Date:performance).now()}function Wy(n,e){return n.distance-e.distance}function Kf(n,e,t,i){if(n.layers.test(e.layers)&&n.raycast(e,t),i===!0){let r=n.children;for(let s=0,o=r.length;s<o;s++)Kf(r[s],e,t,!0)}}function Tv(n){let e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Tv(n.children[t]));return e}function At(n,e,t,i,r,s,o){fl.set(r,s,o).unproject(i);let a=e[n];if(a!==void 0){let c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],fl.x,fl.y,fl.z)}}var _S,wS,SS,t0,_h,n0,MS,ES,vp,i0,Vn,bi,nn,Hn,yi,Cr,wh,Sh,Mh,r0,ji,s0,o0,a0,c0,l0,u0,d0,h0,wl,Sl,f0,p0,m0,g0,y0,v0,x0,b0,_0,w0,S0,M0,Wo,E0,A0,T0,I0,Oa,C0,R0,vi,P0,L0,D0,O0,U0,N0,F0,Eh,k0,Uu,_i,Wi,Xo,Yo,Ys,qo,Mn,Zo,Nt,xp,AS,Rs,TS,It,Vo,IS,jn,CS,wi,B0,z0,bp,_p,Lr,En,Ua,wp,Sp,qs,V0,$0,H0,dn,j0,G0,Rr,Ns,Mp,Ep,W0,Ap,Tp,gl,yl,vl,xl,Ah,Th,Ih,Ch,Rh,Ph,Lh,Dh,Oh,Uh,Nh,Fh,kh,Bh,zh,Vh,$h,Hh,jh,Gh,Wh,bl,Xh,Yh,X0,qh,Zh,Jh,Y0,q0,Z0,Jo,Ko,_l,Ar,Tr,Qo,Nu,Ip,RS,PS,LS,J0,K0,Ji,Q0,hi,Sn,Ei,Fu,Na,ea,vt,ta,na,DS,Sr,OS,US,NS,FS,kS,BS,zS,VS,$S,HS,jS,GS,WS,Kh,ev,tv,nv,Cp,iv,rv,sv,ov,ia,XS,YS,qS,ZS,JS,KS,QS,eM,tM,Qh,Gn,ra,Nn,Xt,Sg,Pr,Fs,vM,se,Je,Fd,xM,Mg,Eg,Ag,Mc,bM,ht,cs,Ml,_M,pi,wM,Ct,ft,El,fn,ks,ef,oa,tf,Zt,L,zd,Tg,zt,oi,Ln,Ec,ls,us,ds,Ni,Fi,dr,To,Ac,Tc,hr,SM,Io,$d,Ft,ai,Hd,Ic,ki,jd,Cc,Gd,Xi,$e,hs,Dn,MM,EM,Bi,Rc,ln,Ig,Cg,pn,Bs,AM,Rg,fs,ci,Pc,Co,TM,IM,Pg,Lg,Dg,Og,CM,ps,Wd,lt,On,li,Xd,ui,ms,gs,Ug,Yd,qd,Zd,mi,uv,zi,Lc,Ce,Yt,RM,kt,Yn,fi,LM,Tt,Dc,at,nf,rf,sf,of,aa,af,ca,cf,De,DM,wn,Kd,ys,un,Ro,Ut,tt,Ng,fr,Oc,Fg,vs,xs,bs,Qd,Uc,Nc,Fc,kc,kg,Bg,zg,Bc,zc,Mt,Dr,hv,NM,FM,mn,Vs,Vi,Vg,$g,Pt,_s,ws,Al,Or,Tl,eh,kM,BM,$n,pr,$c,Ur,$s,VM,$M,HM,jM,GM,WM,XM,YM,qM,ZM,JM,KM,QM,e1,t1,n1,i1,r1,s1,o1,a1,c1,l1,u1,d1,h1,f1,p1,m1,g1,y1,v1,x1,b1,_1,w1,S1,M1,E1,A1,T1,I1,C1,R1,P1,L1,D1,O1,U1,N1,F1,k1,B1,z1,V1,$1,H1,j1,G1,W1,X1,Y1,q1,Z1,J1,K1,Q1,eE,tE,nE,iE,rE,sE,oE,aE,cE,lE,uE,dE,hE,fE,pE,mE,gE,yE,vE,xE,bE,_E,wE,SE,ME,EE,AE,TE,IE,CE,RE,PE,LE,DE,OE,UE,NE,FE,kE,BE,zE,VE,$E,HE,jE,GE,WE,XE,YE,qE,ZE,JE,KE,QE,eA,tA,nA,iA,rA,sA,oA,aA,cA,lA,uA,dA,hA,fA,pA,mA,gA,yA,vA,xA,Qe,Ee,Un,Hc,mr,bA,Hs,Ls,Hg,Er,th,jg,nh,ih,rh,sh,Mr,Ss,Gg,la,ua,pv,mv,gv,yv,vv,qg,Zg,Jg,Kg,Qg,lf,uf,df,oh,Us,ST,MT,LT,DT,UT,HT,ff,pf,ZT,da,ha,eI,tI,Il,Gi,sI,Ho,oI,aI,mf,gf,gr,cI,yf,Cl,Rl,Pl,js,Qt,Nr,fa,Ms,Po,Es,As,Ts,Lo,bv,Gc,Do,Wc,uy,ah,dy,Ll,Yc,hy,Dl,fy,py,my,dI,gy,qc,ch,yy,lh,Ol,pa,Wn,vy,hI,Ul,Yi,Is,xy,Zc,by,fI,Oo,Uo,Nl,vf,Cs,$i,_y,gI,wy,uh,Jc,yr,No,dh,qt,Kc,Fl,Vt,kl,Bl,Sy,Fo,Qc,hh,My,qn,Ey,Ay,An,zl,ma,Ty,xf,tl,nl,Vl,bf,_f,Gs,wf,Sf,Mf,gn,Ws,$l,il,fh,ph,mh,Hl,ga,jl,ya,Gl,va,xa,ba,Wl,Xl,Fr,_a,Yl,ql,Xs,Zl,qi,Jl,rl,sl,gh,ol,Kl,xi,EI,Xn,Ql,$I,eu,Ea,tu,nu,Aa,iu,ru,su,ou,au,Oy,cu,lu,Ta,uu,du,hu,fu,pu,mu,gu,XI,Br,yu,Ia,vu,yn,Si,Ca,zr,xu,Zi,Mi,Vr,$r,gi,Ra,Av,Jt,di,If,Fn,Cf,Rf,Hr,Pf,Lf,Df,Zn,bu,yh,Uy,Ny,Pa,Of,_u,Fy,ko,vh,Uf,wu,Nf,Su,Mu,Eu,Au,Tu,Iu,La,Cu,Ru,Ff,ZI,ky,By,kf,ll,Da,Bf,zy,Vy,vr,zf,Pu,xr,Hy,JI,br,Vf,Lu,_r,jy,KI,wr,$f,Hf,Du,Op,QI,Up,e2,t2,n2,i2,r2,s2,o2,jf,dt,Gf,Ou,a2,Wf,Xf,c2,Yf,qf,Zf,Gy,Jf,Qf,ep,Xy,tp,Yy,ul,np,qy,ip,Hi,dl,xh,rp,sp,l2,Zy,Jy,op,ap,cp,Ky,hl,Qy,lp,fl,wt,up,pl,dp,hp,fp,e0,ml,bh,pp,mp,gp,yp,Cv=hx(()=>{"use strict";_S="164",wS={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},SS={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},t0=0,_h=1,n0=2,MS=3,ES=0,vp=1,i0=2,Vn=3,bi=0,nn=1,Hn=2,yi=0,Cr=1,wh=2,Sh=3,Mh=4,r0=5,ji=100,s0=101,o0=102,a0=103,c0=104,l0=200,u0=201,d0=202,h0=203,wl=204,Sl=205,f0=206,p0=207,m0=208,g0=209,y0=210,v0=211,x0=212,b0=213,_0=214,w0=0,S0=1,M0=2,Wo=3,E0=4,A0=5,T0=6,I0=7,Oa=0,C0=1,R0=2,vi=0,P0=1,L0=2,D0=3,O0=4,U0=5,N0=6,F0=7,Eh="attached",k0="detached",Uu=300,_i=301,Wi=302,Xo=303,Yo=304,Ys=306,qo=1e3,Mn=1001,Zo=1002,Nt=1003,xp=1004,AS=1004,Rs=1005,TS=1005,It=1006,Vo=1007,IS=1007,jn=1008,CS=1008,wi=1009,B0=1010,z0=1011,bp=1012,_p=1013,Lr=1014,En=1015,Ua=1016,wp=1017,Sp=1018,qs=1020,V0=35902,$0=1021,H0=1022,dn=1023,j0=1024,G0=1025,Rr=1026,Ns=1027,Mp=1028,Ep=1029,W0=1030,Ap=1031,Tp=1033,gl=33776,yl=33777,vl=33778,xl=33779,Ah=35840,Th=35841,Ih=35842,Ch=35843,Rh=36196,Ph=37492,Lh=37496,Dh=37808,Oh=37809,Uh=37810,Nh=37811,Fh=37812,kh=37813,Bh=37814,zh=37815,Vh=37816,$h=37817,Hh=37818,jh=37819,Gh=37820,Wh=37821,bl=36492,Xh=36494,Yh=36495,X0=36283,qh=36284,Zh=36285,Jh=36286,Y0=2200,q0=2201,Z0=2202,Jo=2300,Ko=2301,_l=2302,Ar=2400,Tr=2401,Qo=2402,Nu=2500,Ip=2501,RS=0,PS=1,LS=2,J0=3200,K0=3201,Ji=0,Q0=1,hi="",Sn="srgb",Ei="srgb-linear",Fu="display-p3",Na="display-p3-linear",ea="linear",vt="srgb",ta="rec709",na="p3",DS=0,Sr=7680,OS=7681,US=7682,NS=7683,FS=34055,kS=34056,BS=5386,zS=512,VS=513,$S=514,HS=515,jS=516,GS=517,WS=518,Kh=519,ev=512,tv=513,nv=514,Cp=515,iv=516,rv=517,sv=518,ov=519,ia=35044,XS=35048,YS=35040,qS=35045,ZS=35049,JS=35041,KS=35046,QS=35050,eM=35042,tM="100",Qh="300 es",Gn=2e3,ra=2001,Nn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}},Xt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Sg=1234567,Pr=Math.PI/180,Fs=180/Math.PI;vM={DEG2RAD:Pr,RAD2DEG:Fs,generateUUID:hn,clamp:St,euclideanModulo:Rp,mapLinear:nM,inverseLerp:iM,lerp:$o,damp:rM,pingpong:sM,smoothstep:oM,smootherstep:aM,randInt:cM,randFloat:lM,randFloatSpread:uM,seededRandom:dM,degToRad:hM,radToDeg:fM,isPowerOfTwo:pM,ceilPowerOfTwo:mM,floorPowerOfTwo:gM,setQuaternionFromProperEuler:yM,normalize:Ke,denormalize:tn},se=class n{constructor(e=0,t=0){n.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(St(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Je=class n{constructor(e,t,i,r,s,o,a,c,l){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l)}set(e,t,i,r,s,o,a,c,l){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=i,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],y=r[0],g=r[3],m=r[6],x=r[1],v=r[4],M=r[7],U=r[2],C=r[5],R=r[8];return s[0]=o*y+a*x+c*U,s[3]=o*g+a*v+c*C,s[6]=o*m+a*M+c*R,s[1]=l*y+u*x+d*U,s[4]=l*g+u*v+d*C,s[7]=l*m+u*M+d*R,s[2]=h*y+f*x+p*U,s[5]=h*g+f*v+p*C,s[8]=h*m+f*M+p*R,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-i*s*u+i*a*c+r*s*l-r*o*c}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=u*o-a*l,h=a*c-u*s,f=l*s-o*c,p=t*d+i*h+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/p;return e[0]=d*y,e[1]=(r*l-u*i)*y,e[2]=(a*i-r*o)*y,e[3]=h*y,e[4]=(u*t-r*c)*y,e[5]=(r*s-a*t)*y,e[6]=f*y,e[7]=(i*c-l*t)*y,e[8]=(o*t-i*s)*y,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){let c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*o+l*a)+o+e,-r*l,r*c,-r*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Fd.makeScale(e,t)),this}rotate(e){return this.premultiply(Fd.makeRotation(-e)),this}translate(e,t){return this.premultiply(Fd.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Fd=new Je;xM={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};Mg={};Eg=new Je().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ag=new Je().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Mc={[Ei]:{transfer:ea,primaries:ta,toReference:n=>n,fromReference:n=>n},[Sn]:{transfer:vt,primaries:ta,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[Na]:{transfer:ea,primaries:na,toReference:n=>n.applyMatrix3(Ag),fromReference:n=>n.applyMatrix3(Eg)},[Fu]:{transfer:vt,primaries:na,toReference:n=>n.convertSRGBToLinear().applyMatrix3(Ag),fromReference:n=>n.applyMatrix3(Eg).convertLinearToSRGB()}},bM=new Set([Ei,Na]),ht={enabled:!0,_workingColorSpace:Ei,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!bM.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;let i=Mc[e].toReference,r=Mc[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Mc[n].primaries},getTransfer:function(n){return n===hi?ea:Mc[n].transfer}};Ml=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{cs===void 0&&(cs=sa("canvas")),cs.width=e.width,cs.height=e.height;let i=cs.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=cs}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=sa("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Os(s[o]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Os(t[i]/255)*255):t[i]=Os(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},_M=0,pi=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:_M++}),this.uuid=hn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Bd(r[o].image)):s.push(Bd(r[o]))}else s=Bd(r);i.url=s}return t||(e.images[this.uuid]=i),i}};wM=0,Ct=class n extends Nn{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=Mn,r=Mn,s=It,o=jn,a=dn,c=wi,l=n.DEFAULT_ANISOTROPY,u=hi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:wM++}),this.uuid=hn(),this.name="",this.source=new pi(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new se(0,0),this.repeat=new se(1,1),this.center=new se(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Je,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Uu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case qo:e.x=e.x-Math.floor(e.x);break;case Mn:e.x=e.x<0?0:1;break;case Zo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case qo:e.y=e.y-Math.floor(e.y);break;case Mn:e.y=e.y<0?0:1;break;case Zo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Ct.DEFAULT_IMAGE=null;Ct.DEFAULT_MAPPING=Uu;Ct.DEFAULT_ANISOTROPY=1;ft=class n{constructor(e=0,t=0,i=0,r=1){n.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,c=e.elements,l=c[0],u=c[4],d=c[8],h=c[1],f=c[5],p=c[9],y=c[2],g=c[6],m=c[10];if(Math.abs(u-h)<.01&&Math.abs(d-y)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+y)<.1&&Math.abs(p+g)<.1&&Math.abs(l+f+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let v=(l+1)/2,M=(f+1)/2,U=(m+1)/2,C=(u+h)/4,R=(d+y)/4,N=(p+g)/4;return v>M&&v>U?v<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(v),r=C/i,s=R/i):M>U?M<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(M),i=C/r,s=N/r):U<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(U),i=R/s,r=N/s),this.set(i,r,s,t),this}let x=Math.sqrt((g-p)*(g-p)+(d-y)*(d-y)+(h-u)*(h-u));return Math.abs(x)<.001&&(x=1),this.x=(g-p)/x,this.y=(d-y)/x,this.z=(h-u)/x,this.w=Math.acos((l+f+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},El=class extends Nn{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t);let r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:It,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);let s=new Ct(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];let o=i.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new pi(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},fn=class extends El{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},ks=class extends Ct{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=Mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ef=class extends fn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new ks(null,e,t,i),this.texture.isRenderTargetTexture=!0}},oa=class extends Ct{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=Mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tf=class extends fn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new oa(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Zt=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let c=i[r+0],l=i[r+1],u=i[r+2],d=i[r+3],h=s[o+0],f=s[o+1],p=s[o+2],y=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d;return}if(a===1){e[t+0]=h,e[t+1]=f,e[t+2]=p,e[t+3]=y;return}if(d!==y||c!==h||l!==f||u!==p){let g=1-a,m=c*h+l*f+u*p+d*y,x=m>=0?1:-1,v=1-m*m;if(v>Number.EPSILON){let U=Math.sqrt(v),C=Math.atan2(U,m*x);g=Math.sin(g*C)/U,a=Math.sin(a*C)/U}let M=a*x;if(c=c*g+h*M,l=l*g+f*M,u=u*g+p*M,d=d*g+y*M,g===1-a){let U=1/Math.sqrt(c*c+l*l+u*u+d*d);c*=U,l*=U,u*=U,d*=U}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,o){let a=i[r],c=i[r+1],l=i[r+2],u=i[r+3],d=s[o],h=s[o+1],f=s[o+2],p=s[o+3];return e[t]=a*p+u*d+c*f-l*h,e[t+1]=c*p+u*h+l*d-a*f,e[t+2]=l*p+u*f+a*h-c*d,e[t+3]=u*p-a*d-c*h-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(i/2),u=a(r/2),d=a(s/2),h=c(i/2),f=c(r/2),p=c(s/2);switch(o){case"XYZ":this._x=h*u*d+l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d+h*f*p;break;case"YZX":this._x=h*u*d+l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d-h*f*p;break;case"XZY":this._x=h*u*d-l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d+h*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],d=t[10],h=i+a+d;if(h>0){let f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-c)*f,this._y=(s-l)*f,this._z=(o-r)*f}else if(i>a&&i>d){let f=2*Math.sqrt(1+i-a-d);this._w=(u-c)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+l)/f}else if(a>d){let f=2*Math.sqrt(1+a-i-d);this._w=(s-l)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(c+u)/f}else{let f=2*Math.sqrt(1+d-i-a);this._w=(o-r)/f,this._x=(s+l)/f,this._y=(c+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(St(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=i*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-i*l,this._z=s*u+o*l+i*c-r*a,this._w=o*u-i*a-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*i+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),d=Math.sin((1-t)*u)/l,h=Math.sin(t*u)/l;return this._w=o*d+this._w*h,this._x=i*d+this._x*h,this._y=r*d+this._y*h,this._z=s*d+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},L=class n{constructor(e=0,t=0,i=0){n.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Tg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Tg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*r-a*i),u=2*(a*t-s*r),d=2*(s*i-o*t);return this.x=t+c*l+o*d-a*u,this.y=i+c*u+a*l-s*d,this.z=r+c*d+s*u-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return zd.copy(this).projectOnVector(e),this.sub(zd)}reflect(e){return this.sub(zd.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(St(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},zd=new L,Tg=new Zt,zt=class{constructor(e=new L(1/0,1/0,1/0),t=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Ln.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Ln.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Ln.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Ln):Ln.fromBufferAttribute(s,o),Ln.applyMatrix4(e.matrixWorld),this.expandByPoint(Ln);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ec.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ec.copy(i.boundingBox)),Ec.applyMatrix4(e.matrixWorld),this.union(Ec)}let r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Ln),Ln.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(To),Ac.subVectors(this.max,To),ls.subVectors(e.a,To),us.subVectors(e.b,To),ds.subVectors(e.c,To),Ni.subVectors(us,ls),Fi.subVectors(ds,us),dr.subVectors(ls,ds);let t=[0,-Ni.z,Ni.y,0,-Fi.z,Fi.y,0,-dr.z,dr.y,Ni.z,0,-Ni.x,Fi.z,0,-Fi.x,dr.z,0,-dr.x,-Ni.y,Ni.x,0,-Fi.y,Fi.x,0,-dr.y,dr.x,0];return!Vd(t,ls,us,ds,Ac)||(t=[1,0,0,0,1,0,0,0,1],!Vd(t,ls,us,ds,Ac))?!1:(Tc.crossVectors(Ni,Fi),t=[Tc.x,Tc.y,Tc.z],Vd(t,ls,us,ds,Ac))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ln).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ln).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},oi=[new L,new L,new L,new L,new L,new L,new L,new L],Ln=new L,Ec=new zt,ls=new L,us=new L,ds=new L,Ni=new L,Fi=new L,dr=new L,To=new L,Ac=new L,Tc=new L,hr=new L;SM=new zt,Io=new L,$d=new L,Ft=class{constructor(e=new L,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):SM.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Io.subVectors(e,this.center);let t=Io.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Io,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):($d.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Io.copy(e.center).add($d)),this.expandByPoint(Io.copy(e.center).sub($d))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},ai=new L,Hd=new L,Ic=new L,ki=new L,jd=new L,Cc=new L,Gd=new L,Xi=class{constructor(e=new L,t=new L(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ai)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ai.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ai.copy(this.origin).addScaledVector(this.direction,t),ai.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Hd.copy(e).add(t).multiplyScalar(.5),Ic.copy(t).sub(e).normalize(),ki.copy(this.origin).sub(Hd);let s=e.distanceTo(t)*.5,o=-this.direction.dot(Ic),a=ki.dot(this.direction),c=-ki.dot(Ic),l=ki.lengthSq(),u=Math.abs(1-o*o),d,h,f,p;if(u>0)if(d=o*c-a,h=o*a-c,p=s*u,d>=0)if(h>=-p)if(h<=p){let y=1/u;d*=y,h*=y,f=d*(d+o*h+2*a)+h*(o*d+h+2*c)+l}else h=s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;else h=-s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;else h<=-p?(d=Math.max(0,-(-o*s+a)),h=d>0?-s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l):h<=p?(d=0,h=Math.min(Math.max(-s,-c),s),f=h*(h+2*c)+l):(d=Math.max(0,-(o*s+a)),h=d>0?s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l);else h=o>0?-s:s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Hd).addScaledVector(Ic,h),f}intersectSphere(e,t){ai.subVectors(e.center,this.origin);let i=ai.dot(this.direction),r=ai.dot(ai)-i*i,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,c,l=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),u>=0?(s=(e.min.y-h.y)*u,o=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,o=(e.min.y-h.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),d>=0?(a=(e.min.z-h.z)*d,c=(e.max.z-h.z)*d):(a=(e.max.z-h.z)*d,c=(e.min.z-h.z)*d),i>c||a>r)||((a>i||i!==i)&&(i=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,ai)!==null}intersectTriangle(e,t,i,r,s){jd.subVectors(t,e),Cc.subVectors(i,e),Gd.crossVectors(jd,Cc);let o=this.direction.dot(Gd),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ki.subVectors(this.origin,e);let c=a*this.direction.dot(Cc.crossVectors(ki,Cc));if(c<0)return null;let l=a*this.direction.dot(jd.cross(ki));if(l<0||c+l>o)return null;let u=-a*ki.dot(Gd);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},$e=class n{constructor(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g){n.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g)}set(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=s,m[5]=o,m[9]=a,m[13]=c,m[2]=l,m[6]=u,m[10]=d,m[14]=h,m[3]=f,m[7]=p,m[11]=y,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/hs.setFromMatrixColumn(e,0).length(),s=1/hs.setFromMatrixColumn(e,1).length(),o=1/hs.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=c*u,t[4]=-c*d,t[8]=l,t[1]=f+p*l,t[5]=h-y*l,t[9]=-a*c,t[2]=y-h*l,t[6]=p+f*l,t[10]=o*c}else if(e.order==="YXZ"){let h=c*u,f=c*d,p=l*u,y=l*d;t[0]=h+y*a,t[4]=p*a-f,t[8]=o*l,t[1]=o*d,t[5]=o*u,t[9]=-a,t[2]=f*a-p,t[6]=y+h*a,t[10]=o*c}else if(e.order==="ZXY"){let h=c*u,f=c*d,p=l*u,y=l*d;t[0]=h-y*a,t[4]=-o*d,t[8]=p+f*a,t[1]=f+p*a,t[5]=o*u,t[9]=y-h*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=c*u,t[4]=p*l-f,t[8]=h*l+y,t[1]=c*d,t[5]=y*l+h,t[9]=f*l-p,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let h=o*c,f=o*l,p=a*c,y=a*l;t[0]=c*u,t[4]=y-h*d,t[8]=p*d+f,t[1]=d,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=f*d+p,t[10]=h-y*d}else if(e.order==="XZY"){let h=o*c,f=o*l,p=a*c,y=a*l;t[0]=c*u,t[4]=-d,t[8]=l*u,t[1]=h*d+y,t[5]=o*u,t[9]=f*d-p,t[2]=p*d-f,t[6]=a*u,t[10]=y*d+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(MM,e,EM)}lookAt(e,t,i){let r=this.elements;return ln.subVectors(e,t),ln.lengthSq()===0&&(ln.z=1),ln.normalize(),Bi.crossVectors(i,ln),Bi.lengthSq()===0&&(Math.abs(i.z)===1?ln.x+=1e-4:ln.z+=1e-4,ln.normalize(),Bi.crossVectors(i,ln)),Bi.normalize(),Rc.crossVectors(ln,Bi),r[0]=Bi.x,r[4]=Rc.x,r[8]=ln.x,r[1]=Bi.y,r[5]=Rc.y,r[9]=ln.y,r[2]=Bi.z,r[6]=Rc.z,r[10]=ln.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],u=i[1],d=i[5],h=i[9],f=i[13],p=i[2],y=i[6],g=i[10],m=i[14],x=i[3],v=i[7],M=i[11],U=i[15],C=r[0],R=r[4],N=r[8],w=r[12],b=r[1],O=r[5],B=r[9],F=r[13],H=r[2],X=r[6],ee=r[10],ce=r[14],k=r[3],le=r[7],he=r[11],Te=r[15];return s[0]=o*C+a*b+c*H+l*k,s[4]=o*R+a*O+c*X+l*le,s[8]=o*N+a*B+c*ee+l*he,s[12]=o*w+a*F+c*ce+l*Te,s[1]=u*C+d*b+h*H+f*k,s[5]=u*R+d*O+h*X+f*le,s[9]=u*N+d*B+h*ee+f*he,s[13]=u*w+d*F+h*ce+f*Te,s[2]=p*C+y*b+g*H+m*k,s[6]=p*R+y*O+g*X+m*le,s[10]=p*N+y*B+g*ee+m*he,s[14]=p*w+y*F+g*ce+m*Te,s[3]=x*C+v*b+M*H+U*k,s[7]=x*R+v*O+M*X+U*le,s[11]=x*N+v*B+M*ee+U*he,s[15]=x*w+v*F+M*ce+U*Te,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],d=e[6],h=e[10],f=e[14],p=e[3],y=e[7],g=e[11],m=e[15];return p*(+s*c*d-r*l*d-s*a*h+i*l*h+r*a*f-i*c*f)+y*(+t*c*f-t*l*h+s*o*h-r*o*f+r*l*u-s*c*u)+g*(+t*l*d-t*a*f-s*o*d+i*o*f+s*a*u-i*l*u)+m*(-r*a*u-t*c*d+t*a*h+r*o*d-i*o*h+i*c*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=e[9],h=e[10],f=e[11],p=e[12],y=e[13],g=e[14],m=e[15],x=d*g*l-y*h*l+y*c*f-a*g*f-d*c*m+a*h*m,v=p*h*l-u*g*l-p*c*f+o*g*f+u*c*m-o*h*m,M=u*y*l-p*d*l+p*a*f-o*y*f-u*a*m+o*d*m,U=p*d*c-u*y*c-p*a*h+o*y*h+u*a*g-o*d*g,C=t*x+i*v+r*M+s*U;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/C;return e[0]=x*R,e[1]=(y*h*s-d*g*s-y*r*f+i*g*f+d*r*m-i*h*m)*R,e[2]=(a*g*s-y*c*s+y*r*l-i*g*l-a*r*m+i*c*m)*R,e[3]=(d*c*s-a*h*s-d*r*l+i*h*l+a*r*f-i*c*f)*R,e[4]=v*R,e[5]=(u*g*s-p*h*s+p*r*f-t*g*f-u*r*m+t*h*m)*R,e[6]=(p*c*s-o*g*s-p*r*l+t*g*l+o*r*m-t*c*m)*R,e[7]=(o*h*s-u*c*s+u*r*l-t*h*l-o*r*f+t*c*f)*R,e[8]=M*R,e[9]=(p*d*s-u*y*s-p*i*f+t*y*f+u*i*m-t*d*m)*R,e[10]=(o*y*s-p*a*s+p*i*l-t*y*l-o*i*m+t*a*m)*R,e[11]=(u*a*s-o*d*s-u*i*l+t*d*l+o*i*f-t*a*f)*R,e[12]=U*R,e[13]=(u*y*r-p*d*r+p*i*h-t*y*h-u*i*g+t*d*g)*R,e[14]=(p*a*r-o*y*r-p*i*c+t*y*c+o*i*g-t*a*g)*R,e[15]=(o*d*r-u*a*r+u*i*c-t*d*c-o*i*h+t*a*h)*R,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+i,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,d=a+a,h=s*l,f=s*u,p=s*d,y=o*u,g=o*d,m=a*d,x=c*l,v=c*u,M=c*d,U=i.x,C=i.y,R=i.z;return r[0]=(1-(y+m))*U,r[1]=(f+M)*U,r[2]=(p-v)*U,r[3]=0,r[4]=(f-M)*C,r[5]=(1-(h+m))*C,r[6]=(g+x)*C,r[7]=0,r[8]=(p+v)*R,r[9]=(g-x)*R,r[10]=(1-(h+y))*R,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=hs.set(r[0],r[1],r[2]).length(),o=hs.set(r[4],r[5],r[6]).length(),a=hs.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Dn.copy(this);let l=1/s,u=1/o,d=1/a;return Dn.elements[0]*=l,Dn.elements[1]*=l,Dn.elements[2]*=l,Dn.elements[4]*=u,Dn.elements[5]*=u,Dn.elements[6]*=u,Dn.elements[8]*=d,Dn.elements[9]*=d,Dn.elements[10]*=d,t.setFromRotationMatrix(Dn),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Gn){let c=this.elements,l=2*s/(t-e),u=2*s/(i-r),d=(t+e)/(t-e),h=(i+r)/(i-r),f,p;if(a===Gn)f=-(o+s)/(o-s),p=-2*o*s/(o-s);else if(a===ra)f=-o/(o-s),p=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=Gn){let c=this.elements,l=1/(t-e),u=1/(i-r),d=1/(o-s),h=(t+e)*l,f=(i+r)*u,p,y;if(a===Gn)p=(o+s)*d,y=-2*d;else if(a===ra)p=s*d,y=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-h,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=y,c[14]=-p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},hs=new L,Dn=new $e,MM=new L(0,0,0),EM=new L(1,1,1),Bi=new L,Rc=new L,ln=new L,Ig=new $e,Cg=new Zt,pn=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],d=r[2],h=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(St(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-St(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(St(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-St(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(St(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-St(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Ig.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ig,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Cg.setFromEuler(this),this.setFromQuaternion(Cg,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};pn.DEFAULT_ORDER="XYZ";Bs=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},AM=0,Rg=new L,fs=new Zt,ci=new $e,Pc=new L,Co=new L,TM=new L,IM=new Zt,Pg=new L(1,0,0),Lg=new L(0,1,0),Dg=new L(0,0,1),Og={type:"added"},CM={type:"removed"},ps={type:"childadded",child:null},Wd={type:"childremoved",child:null},lt=class n extends Nn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:AM++}),this.uuid=hn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new L,t=new pn,i=new Zt,r=new L(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new $e},normalMatrix:{value:new Je}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return fs.setFromAxisAngle(e,t),this.quaternion.multiply(fs),this}rotateOnWorldAxis(e,t){return fs.setFromAxisAngle(e,t),this.quaternion.premultiply(fs),this}rotateX(e){return this.rotateOnAxis(Pg,e)}rotateY(e){return this.rotateOnAxis(Lg,e)}rotateZ(e){return this.rotateOnAxis(Dg,e)}translateOnAxis(e,t){return Rg.copy(e).applyQuaternion(this.quaternion),this.position.add(Rg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Pg,e)}translateY(e){return this.translateOnAxis(Lg,e)}translateZ(e){return this.translateOnAxis(Dg,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ci.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Pc.copy(e):Pc.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Co.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ci.lookAt(Co,Pc,this.up):ci.lookAt(Pc,Co,this.up),this.quaternion.setFromRotationMatrix(ci),r&&(ci.extractRotation(r.matrixWorld),fs.setFromRotationMatrix(ci),this.quaternion.premultiply(fs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Og),ps.child=e,this.dispatchEvent(ps),ps.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(CM),Wd.child=e,this.dispatchEvent(Wd),Wd.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ci.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ci.multiply(e.parent.matrixWorld)),e.applyMatrix4(ci),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Og),ps.child=e,this.dispatchEvent(ps),ps.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Co,e,TM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Co,IM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++){let s=t[i];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++){let a=r[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let d=c[l];s(e.shapes,d)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];r.animations.push(s(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),d=o(e.shapes),h=o(e.skeletons),f=o(e.animations),p=o(e.nodes);a.length>0&&(i.geometries=a),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=r,i;function o(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}};lt.DEFAULT_UP=new L(0,1,0);lt.DEFAULT_MATRIX_AUTO_UPDATE=!0;lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;On=new L,li=new L,Xd=new L,ui=new L,ms=new L,gs=new L,Ug=new L,Yd=new L,qd=new L,Zd=new L,mi=class n{constructor(e=new L,t=new L,i=new L){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),On.subVectors(e,t),r.cross(On);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){On.subVectors(r,t),li.subVectors(i,t),Xd.subVectors(e,t);let o=On.dot(On),a=On.dot(li),c=On.dot(Xd),l=li.dot(li),u=li.dot(Xd),d=o*l-a*a;if(d===0)return s.set(0,0,0),null;let h=1/d,f=(l*c-a*u)*h,p=(o*u-a*c)*h;return s.set(1-f-p,p,f)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,ui)===null?!1:ui.x>=0&&ui.y>=0&&ui.x+ui.y<=1}static getInterpolation(e,t,i,r,s,o,a,c){return this.getBarycoord(e,t,i,r,ui)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,ui.x),c.addScaledVector(o,ui.y),c.addScaledVector(a,ui.z),c)}static isFrontFacing(e,t,i,r){return On.subVectors(i,t),li.subVectors(e,t),On.cross(li).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return On.subVectors(this.c,this.b),li.subVectors(this.a,this.b),On.cross(li).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,o,a;ms.subVectors(r,i),gs.subVectors(s,i),Yd.subVectors(e,i);let c=ms.dot(Yd),l=gs.dot(Yd);if(c<=0&&l<=0)return t.copy(i);qd.subVectors(e,r);let u=ms.dot(qd),d=gs.dot(qd);if(u>=0&&d<=u)return t.copy(r);let h=c*d-u*l;if(h<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(i).addScaledVector(ms,o);Zd.subVectors(e,s);let f=ms.dot(Zd),p=gs.dot(Zd);if(p>=0&&f<=p)return t.copy(s);let y=f*l-c*p;if(y<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(i).addScaledVector(gs,a);let g=u*p-f*d;if(g<=0&&d-u>=0&&f-p>=0)return Ug.subVectors(s,r),a=(d-u)/(d-u+(f-p)),t.copy(r).addScaledVector(Ug,a);let m=1/(g+y+h);return o=y*m,a=h*m,t.copy(i).addScaledVector(ms,o).addScaledVector(gs,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},uv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},zi={h:0,s:0,l:0},Lc={h:0,s:0,l:0};Ce=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Sn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ht.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=ht.workingColorSpace){return this.r=e,this.g=t,this.b=i,ht.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=ht.workingColorSpace){if(e=Rp(e,1),t=St(t,0,1),i=St(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=Jd(o,s,e+1/3),this.g=Jd(o,s,e),this.b=Jd(o,s,e-1/3)}return ht.toWorkingColorSpace(this,r),this}setStyle(e,t=Sn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Sn){let i=uv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Os(e.r),this.g=Os(e.g),this.b=Os(e.b),this}copyLinearToSRGB(e){return this.r=kd(e.r),this.g=kd(e.g),this.b=kd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Sn){return ht.fromWorkingColorSpace(Yt.copy(this),e),Math.round(St(Yt.r*255,0,255))*65536+Math.round(St(Yt.g*255,0,255))*256+Math.round(St(Yt.b*255,0,255))}getHexString(e=Sn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ht.workingColorSpace){ht.fromWorkingColorSpace(Yt.copy(this),t);let i=Yt.r,r=Yt.g,s=Yt.b,o=Math.max(i,r,s),a=Math.min(i,r,s),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else{let d=o-a;switch(l=u<=.5?d/(o+a):d/(2-o-a),o){case i:c=(r-s)/d+(r<s?6:0);break;case r:c=(s-i)/d+2;break;case s:c=(i-r)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=ht.workingColorSpace){return ht.fromWorkingColorSpace(Yt.copy(this),t),e.r=Yt.r,e.g=Yt.g,e.b=Yt.b,e}getStyle(e=Sn){ht.fromWorkingColorSpace(Yt.copy(this),e);let t=Yt.r,i=Yt.g,r=Yt.b;return e!==Sn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(zi),this.setHSL(zi.h+e,zi.s+t,zi.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(zi),e.getHSL(Lc);let i=$o(zi.h,Lc.h,t),r=$o(zi.s,Lc.s,t),s=$o(zi.l,Lc.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Yt=new Ce;Ce.NAMES=uv;RM=0,kt=class extends Nn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:RM++}),this.uuid=hn(),this.name="",this.type="Material",this.blending=Cr,this.side=bi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=wl,this.blendDst=Sl,this.blendEquation=ji,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ce(0,0,0),this.blendAlpha=0,this.depthFunc=Wo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Kh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Sr,this.stencilZFail=Sr,this.stencilZPass=Sr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Cr&&(i.blending=this.blending),this.side!==bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==wl&&(i.blendSrc=this.blendSrc),this.blendDst!==Sl&&(i.blendDst=this.blendDst),this.blendEquation!==ji&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Wo&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Kh&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Sr&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Sr&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Sr&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let o=[];for(let a in s){let c=s[a];delete c.metadata,o.push(c)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Yn=class extends kt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ce(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pn,this.combine=Oa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},fi=PM();LM={toHalfFloat:on,fromHalfFloat:Bo},Tt=new L,Dc=new se,at=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=ia,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=En,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return lv("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Dc.fromBufferAttribute(this,t),Dc.applyMatrix3(e),this.setXY(t,Dc.x,Dc.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.applyMatrix3(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.applyMatrix4(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.applyNormalMatrix(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.transformDirection(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=tn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Ke(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Ke(t,this.array),i=Ke(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Ke(t,this.array),i=Ke(i,this.array),r=Ke(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Ke(t,this.array),i=Ke(i,this.array),r=Ke(r,this.array),s=Ke(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ia&&(e.usage=this.usage),e}},nf=class extends at{constructor(e,t,i){super(new Int8Array(e),t,i)}},rf=class extends at{constructor(e,t,i){super(new Uint8Array(e),t,i)}},sf=class extends at{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},of=class extends at{constructor(e,t,i){super(new Int16Array(e),t,i)}},aa=class extends at{constructor(e,t,i){super(new Uint16Array(e),t,i)}},af=class extends at{constructor(e,t,i){super(new Int32Array(e),t,i)}},ca=class extends at{constructor(e,t,i){super(new Uint32Array(e),t,i)}},cf=class extends at{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=Bo(this.array[e*this.itemSize]);return this.normalized&&(t=tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize]=on(t),this}getY(e){let t=Bo(this.array[e*this.itemSize+1]);return this.normalized&&(t=tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize+1]=on(t),this}getZ(e){let t=Bo(this.array[e*this.itemSize+2]);return this.normalized&&(t=tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize+2]=on(t),this}getW(e){let t=Bo(this.array[e*this.itemSize+3]);return this.normalized&&(t=tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize+3]=on(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Ke(t,this.array),i=Ke(i,this.array)),this.array[e+0]=on(t),this.array[e+1]=on(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Ke(t,this.array),i=Ke(i,this.array),r=Ke(r,this.array)),this.array[e+0]=on(t),this.array[e+1]=on(i),this.array[e+2]=on(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Ke(t,this.array),i=Ke(i,this.array),r=Ke(r,this.array),s=Ke(s,this.array)),this.array[e+0]=on(t),this.array[e+1]=on(i),this.array[e+2]=on(r),this.array[e+3]=on(s),this}},De=class extends at{constructor(e,t,i){super(new Float32Array(e),t,i)}},DM=0,wn=new $e,Kd=new lt,ys=new L,un=new zt,Ro=new zt,Ut=new L,tt=class n extends Nn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:DM++}),this.uuid=hn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(av(e)?ca:aa)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let s=new Je().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return wn.makeRotationFromQuaternion(e),this.applyMatrix4(wn),this}rotateX(e){return wn.makeRotationX(e),this.applyMatrix4(wn),this}rotateY(e){return wn.makeRotationY(e),this.applyMatrix4(wn),this}rotateZ(e){return wn.makeRotationZ(e),this.applyMatrix4(wn),this}translate(e,t,i){return wn.makeTranslation(e,t,i),this.applyMatrix4(wn),this}scale(e,t,i){return wn.makeScale(e,t,i),this.applyMatrix4(wn),this}lookAt(e){return Kd.lookAt(e),Kd.updateMatrix(),this.applyMatrix4(Kd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ys).negate(),this.translate(ys.x,ys.y,ys.z),this}setFromPoints(e){let t=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new De(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let s=t[i];un.setFromBufferAttribute(s),this.morphTargetsRelative?(Ut.addVectors(this.boundingBox.min,un.min),this.boundingBox.expandByPoint(Ut),Ut.addVectors(this.boundingBox.max,un.max),this.boundingBox.expandByPoint(Ut)):(this.boundingBox.expandByPoint(un.min),this.boundingBox.expandByPoint(un.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ft);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new L,1/0);return}if(e){let i=this.boundingSphere.center;if(un.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];Ro.setFromBufferAttribute(a),this.morphTargetsRelative?(Ut.addVectors(un.min,Ro.min),un.expandByPoint(Ut),Ut.addVectors(un.max,Ro.max),un.expandByPoint(Ut)):(un.expandByPoint(Ro.min),un.expandByPoint(Ro.max))}un.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Ut.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Ut));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)Ut.fromBufferAttribute(a,l),c&&(ys.fromBufferAttribute(e,l),Ut.add(ys)),r=Math.max(r,i.distanceToSquared(Ut))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new at(new Float32Array(4*i.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let N=0;N<i.count;N++)a[N]=new L,c[N]=new L;let l=new L,u=new L,d=new L,h=new se,f=new se,p=new se,y=new L,g=new L;function m(N,w,b){l.fromBufferAttribute(i,N),u.fromBufferAttribute(i,w),d.fromBufferAttribute(i,b),h.fromBufferAttribute(s,N),f.fromBufferAttribute(s,w),p.fromBufferAttribute(s,b),u.sub(l),d.sub(l),f.sub(h),p.sub(h);let O=1/(f.x*p.y-p.x*f.y);isFinite(O)&&(y.copy(u).multiplyScalar(p.y).addScaledVector(d,-f.y).multiplyScalar(O),g.copy(d).multiplyScalar(f.x).addScaledVector(u,-p.x).multiplyScalar(O),a[N].add(y),a[w].add(y),a[b].add(y),c[N].add(g),c[w].add(g),c[b].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let N=0,w=x.length;N<w;++N){let b=x[N],O=b.start,B=b.count;for(let F=O,H=O+B;F<H;F+=3)m(e.getX(F+0),e.getX(F+1),e.getX(F+2))}let v=new L,M=new L,U=new L,C=new L;function R(N){U.fromBufferAttribute(r,N),C.copy(U);let w=a[N];v.copy(w),v.sub(U.multiplyScalar(U.dot(w))).normalize(),M.crossVectors(C,w);let O=M.dot(c[N])<0?-1:1;o.setXYZW(N,v.x,v.y,v.z,O)}for(let N=0,w=x.length;N<w;++N){let b=x[N],O=b.start,B=b.count;for(let F=O,H=O+B;F<H;F+=3)R(e.getX(F+0)),R(e.getX(F+1)),R(e.getX(F+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new at(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,f=i.count;h<f;h++)i.setXYZ(h,0,0,0);let r=new L,s=new L,o=new L,a=new L,c=new L,l=new L,u=new L,d=new L;if(e)for(let h=0,f=e.count;h<f;h+=3){let p=e.getX(h+0),y=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,g),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),a.fromBufferAttribute(i,p),c.fromBufferAttribute(i,y),l.fromBufferAttribute(i,g),a.add(u),c.add(u),l.add(u),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(y,c.x,c.y,c.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let h=0,f=t.count;h<f;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),o.fromBufferAttribute(t,h+2),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),i.setXYZ(h+0,u.x,u.y,u.z),i.setXYZ(h+1,u.x,u.y,u.z),i.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Ut.fromBufferAttribute(e,t),Ut.normalize(),e.setXYZ(t,Ut.x,Ut.y,Ut.z)}toNonIndexed(){function e(a,c){let l=a.array,u=a.itemSize,d=a.normalized,h=new l.constructor(c.length*u),f=0,p=0;for(let y=0,g=c.length;y<g;y++){a.isInterleavedBufferAttribute?f=c[y]*a.data.stride+a.offset:f=c[y]*u;for(let m=0;m<u;m++)h[p++]=l[f++]}return new at(h,u,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let a in r){let c=r[a],l=e(c,i);t.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let c=[],l=s[a];for(let u=0,d=l.length;u<d;u++){let h=l[u],f=e(h,i);c.push(f)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let c in i){let l=i[c];e.data.attributes[c]=l.toJSON(e.data)}let r={},s=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let d=0,h=l.length;d<h;d++){let f=l[d];u.push(f.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let l in r){let u=r[l];this.setAttribute(l,u.clone(t))}let s=e.morphAttributes;for(let l in s){let u=[],d=s[l];for(let h=0,f=d.length;h<f;h++)u.push(d[h].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,u=o.length;l<u;l++){let d=o[l];this.addGroup(d.start,d.count,d.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ng=new $e,fr=new Xi,Oc=new Ft,Fg=new L,vs=new L,xs=new L,bs=new L,Qd=new L,Uc=new L,Nc=new se,Fc=new se,kc=new se,kg=new L,Bg=new L,zg=new L,Bc=new L,zc=new L,Mt=class extends lt{constructor(e=new tt,t=new Yn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){Uc.set(0,0,0);for(let c=0,l=s.length;c<l;c++){let u=a[c],d=s[c];u!==0&&(Qd.fromBufferAttribute(d,e),o?Uc.addScaledVector(Qd,u):Uc.addScaledVector(Qd.sub(t),u))}t.add(Uc)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Oc.copy(i.boundingSphere),Oc.applyMatrix4(s),fr.copy(e.ray).recast(e.near),!(Oc.containsPoint(fr.origin)===!1&&(fr.intersectSphere(Oc,Fg)===null||fr.origin.distanceToSquared(Fg)>(e.far-e.near)**2))&&(Ng.copy(s).invert(),fr.copy(e.ray).applyMatrix4(Ng),!(i.boundingBox!==null&&fr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,fr)))}_computeIntersections(e,t,i){let r,s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,h=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let M=x,U=v;M<U;M+=3){let C=a.getX(M),R=a.getX(M+1),N=a.getX(M+2);r=Vc(this,m,e,i,l,u,d,C,R,N),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let x=a.getX(g),v=a.getX(g+1),M=a.getX(g+2);r=Vc(this,o,e,i,l,u,d,x,v,M),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(c.count,Math.min(g.start+g.count,f.start+f.count));for(let M=x,U=v;M<U;M+=3){let C=M,R=M+1,N=M+2;r=Vc(this,m,e,i,l,u,d,C,R,N),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(c.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let x=g,v=g+1,M=g+2;r=Vc(this,o,e,i,l,u,d,x,v,M),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};Dr=class n extends tt{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let c=[],l=[],u=[],d=[],h=0,f=0;p("z","y","x",-1,-1,i,t,e,o,s,0),p("z","y","x",1,-1,i,t,-e,o,s,1),p("x","z","y",1,1,e,i,t,r,o,2),p("x","z","y",1,-1,e,i,-t,r,o,3),p("x","y","z",1,-1,e,t,i,r,s,4),p("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(c),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(u,3)),this.setAttribute("uv",new De(d,2));function p(y,g,m,x,v,M,U,C,R,N,w){let b=M/R,O=U/N,B=M/2,F=U/2,H=C/2,X=R+1,ee=N+1,ce=0,k=0,le=new L;for(let he=0;he<ee;he++){let Te=he*O-F;for(let ve=0;ve<X;ve++){let He=ve*b-B;le[y]=He*x,le[g]=Te*v,le[m]=H,l.push(le.x,le.y,le.z),le[y]=0,le[g]=0,le[m]=C>0?1:-1,u.push(le.x,le.y,le.z),d.push(ve/R),d.push(1-he/N),ce+=1}}for(let he=0;he<N;he++)for(let Te=0;Te<R;Te++){let ve=h+Te+X*he,He=h+Te+X*(he+1),Z=h+(Te+1)+X*(he+1),J=h+(Te+1)+X*he;c.push(ve,He,J),c.push(He,Z,J),k+=6}a.addGroup(f,k,w),f+=k,h+=ce}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};hv={clone:zs,merge:en},NM=`void main() {
201
201
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
202
- }`,FS=`void main() {
202
+ }`,FM=`void main() {
203
203
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
204
- }`,xn=class extends $t{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=NS,this.fragmentShader=FS,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ks(e.uniforms),this.uniformsGroups=US(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},Bs=class extends ht{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ze,this.projectionMatrix=new ze,this.projectionMatrixInverse=new ze,this.coordinateSystem=Xn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Hi=new P,Vg=new oe,$g=new oe,Ut=class extends Bs{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Us*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Lr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Us*2*Math.atan(Math.tan(Lr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Hi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Hi.x,Hi.y).multiplyScalar(-e/Hi.z),Hi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Hi.x,Hi.y).multiplyScalar(-e/Hi.z)}getViewSize(e,t){return this.getViewBounds(e,Vg,$g),t.subVectors($g,Vg)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Lr*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*i/l,r*=o.width/c,i*=o.height/l}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},xs=-90,bs=1,Al=class extends ht{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Ut(xs,bs,e,t);r.layers=this.layers,this.add(r);let s=new Ut(xs,bs,e,t);s.layers=this.layers,this.add(s);let o=new Ut(xs,bs,e,t);o.layers=this.layers,this.add(o);let a=new Ut(xs,bs,e,t);a.layers=this.layers,this.add(a);let c=new Ut(xs,bs,e,t);c.layers=this.layers,this.add(c);let l=new Ut(xs,bs,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,c]=t;for(let l of t)this.remove(l);if(e===Xn)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===ra)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,c,l,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,c),e.setRenderTarget(i,4,r),e.render(t,l),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}},Ur=class extends Dt{constructor(e,t,i,r,s,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:Mi,super(e,t,i,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Tl=class extends yn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Ur(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Lt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
204
+ }`,mn=class extends kt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=NM,this.fragmentShader=FM,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=zs(e.uniforms),this.uniformsGroups=UM(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},Vs=class extends lt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e,this.coordinateSystem=Gn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Vi=new L,Vg=new se,$g=new se,Pt=class extends Vs{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Fs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Pr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Fs*2*Math.atan(Math.tan(Pr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Vi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z),Vi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z)}getViewSize(e,t){return this.getViewBounds(e,Vg,$g),t.subVectors($g,Vg)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Pr*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*i/l,r*=o.width/c,i*=o.height/l}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},_s=-90,ws=1,Al=class extends lt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Pt(_s,ws,e,t);r.layers=this.layers,this.add(r);let s=new Pt(_s,ws,e,t);s.layers=this.layers,this.add(s);let o=new Pt(_s,ws,e,t);o.layers=this.layers,this.add(o);let a=new Pt(_s,ws,e,t);a.layers=this.layers,this.add(a);let c=new Pt(_s,ws,e,t);c.layers=this.layers,this.add(c);let l=new Pt(_s,ws,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,c]=t;for(let l of t)this.remove(l);if(e===Gn)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===ra)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,c,l,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,c),e.setRenderTarget(i,4,r),e.render(t,l),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}},Or=class extends Ct{constructor(e,t,i,r,s,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:_i,super(e,t,i,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Tl=class extends fn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Or(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:It}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
205
205
 
206
206
  varying vec3 vWorldDirection;
207
207
 
@@ -236,9 +236,9 @@ Program Info Log: `+z+`
236
236
  gl_FragColor = texture2D( tEquirect, sampleUV );
237
237
 
238
238
  }
239
- `},r=new Or(5,5,5),s=new xn({name:"CubemapFromEquirect",uniforms:ks(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:on,blending:xi});s.uniforms.tEquirect.value=t;let o=new It(r,s),a=t.minFilter;return t.minFilter===Wn&&(t.minFilter=Lt),new Al(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}},eh=new P,kS=new P,BS=new Qe,Gn=class{constructor(e=new P(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=eh.subVectors(i,t).cross(kS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta(eh),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||BS.getNormalMatrix(e),r=this.coplanarPoint(eh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},mr=new Vt,$c=new P,Nr=class{constructor(e=new Gn,t=new Gn,i=new Gn,r=new Gn,s=new Gn,o=new Gn){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Xn){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],d=r[6],h=r[7],f=r[8],p=r[9],y=r[10],g=r[11],m=r[12],v=r[13],x=r[14],w=r[15];if(i[0].setComponents(c-s,h-l,g-f,w-m).normalize(),i[1].setComponents(c+s,h+l,g+f,w+m).normalize(),i[2].setComponents(c+o,h+u,g+p,w+v).normalize(),i[3].setComponents(c-o,h-u,g-p,w-v).normalize(),i[4].setComponents(c-a,h-d,g-y,w-x).normalize(),t===Xn)i[5].setComponents(c+a,h+d,g+y,w+x).normalize();else if(t===ra)i[5].setComponents(a,d,y,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),mr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),mr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(mr)}intersectsSprite(e){return mr.center.set(0,0,0),mr.radius=.7071067811865476,mr.applyMatrix4(e.matrixWorld),this.intersectsSphere(mr)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if($c.x=r.normal.x>0?e.max.x:e.min.x,$c.y=r.normal.y>0?e.max.y:e.min.y,$c.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint($c)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};zs=class n extends it{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,o=t/2,a=Math.floor(i),c=Math.floor(r),l=a+1,u=c+1,d=e/a,h=t/c,f=[],p=[],y=[],g=[];for(let m=0;m<u;m++){let v=m*h-o;for(let x=0;x<l;x++){let w=x*d-s;p.push(w,-v,0),y.push(0,0,1),g.push(x/a),g.push(1-m/c)}}for(let m=0;m<c;m++)for(let v=0;v<a;v++){let x=v+l*m,w=v+l*(m+1),O=v+1+l*(m+1),I=v+1+l*m;f.push(x,w,I),f.push(w,O,I)}this.setIndex(f),this.setAttribute("position",new Le(p,3)),this.setAttribute("normal",new Le(y,3)),this.setAttribute("uv",new Le(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},VS=`#ifdef USE_ALPHAHASH
239
+ `},r=new Dr(5,5,5),s=new mn({name:"CubemapFromEquirect",uniforms:zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:nn,blending:yi});s.uniforms.tEquirect.value=t;let o=new Mt(r,s),a=t.minFilter;return t.minFilter===jn&&(t.minFilter=It),new Al(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}},eh=new L,kM=new L,BM=new Je,$n=class{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=eh.subVectors(i,t).cross(kM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta(eh),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||BM.getNormalMatrix(e),r=this.coplanarPoint(eh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},pr=new Ft,$c=new L,Ur=class{constructor(e=new $n,t=new $n,i=new $n,r=new $n,s=new $n,o=new $n){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Gn){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],d=r[6],h=r[7],f=r[8],p=r[9],y=r[10],g=r[11],m=r[12],x=r[13],v=r[14],M=r[15];if(i[0].setComponents(c-s,h-l,g-f,M-m).normalize(),i[1].setComponents(c+s,h+l,g+f,M+m).normalize(),i[2].setComponents(c+o,h+u,g+p,M+x).normalize(),i[3].setComponents(c-o,h-u,g-p,M-x).normalize(),i[4].setComponents(c-a,h-d,g-y,M-v).normalize(),t===Gn)i[5].setComponents(c+a,h+d,g+y,M+v).normalize();else if(t===ra)i[5].setComponents(a,d,y,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),pr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),pr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(pr)}intersectsSprite(e){return pr.center.set(0,0,0),pr.radius=.7071067811865476,pr.applyMatrix4(e.matrixWorld),this.intersectsSphere(pr)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if($c.x=r.normal.x>0?e.max.x:e.min.x,$c.y=r.normal.y>0?e.max.y:e.min.y,$c.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint($c)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};$s=class n extends tt{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,o=t/2,a=Math.floor(i),c=Math.floor(r),l=a+1,u=c+1,d=e/a,h=t/c,f=[],p=[],y=[],g=[];for(let m=0;m<u;m++){let x=m*h-o;for(let v=0;v<l;v++){let M=v*d-s;p.push(M,-x,0),y.push(0,0,1),g.push(v/a),g.push(1-m/c)}}for(let m=0;m<c;m++)for(let x=0;x<a;x++){let v=x+l*m,M=x+l*(m+1),U=x+1+l*(m+1),C=x+1+l*m;f.push(v,M,C),f.push(M,U,C)}this.setIndex(f),this.setAttribute("position",new De(p,3)),this.setAttribute("normal",new De(y,3)),this.setAttribute("uv",new De(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},VM=`#ifdef USE_ALPHAHASH
240
240
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
241
- #endif`,$S=`#ifdef USE_ALPHAHASH
241
+ #endif`,$M=`#ifdef USE_ALPHAHASH
242
242
  const float ALPHA_HASH_SCALE = 0.05;
243
243
  float hash2D( vec2 value ) {
244
244
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -273,20 +273,20 @@ Program Info Log: `+z+`
273
273
  : cases.z;
274
274
  return clamp( threshold , 1.0e-6, 1.0 );
275
275
  }
276
- #endif`,HS=`#ifdef USE_ALPHAMAP
276
+ #endif`,HM=`#ifdef USE_ALPHAMAP
277
277
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
278
- #endif`,GS=`#ifdef USE_ALPHAMAP
278
+ #endif`,jM=`#ifdef USE_ALPHAMAP
279
279
  uniform sampler2D alphaMap;
280
- #endif`,jS=`#ifdef USE_ALPHATEST
280
+ #endif`,GM=`#ifdef USE_ALPHATEST
281
281
  #ifdef ALPHA_TO_COVERAGE
282
282
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
283
283
  if ( diffuseColor.a == 0.0 ) discard;
284
284
  #else
285
285
  if ( diffuseColor.a < alphaTest ) discard;
286
286
  #endif
287
- #endif`,WS=`#ifdef USE_ALPHATEST
287
+ #endif`,WM=`#ifdef USE_ALPHATEST
288
288
  uniform float alphaTest;
289
- #endif`,XS=`#ifdef USE_AOMAP
289
+ #endif`,XM=`#ifdef USE_AOMAP
290
290
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
291
291
  reflectedLight.indirectDiffuse *= ambientOcclusion;
292
292
  #if defined( USE_CLEARCOAT )
@@ -299,10 +299,10 @@ Program Info Log: `+z+`
299
299
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
300
300
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
301
301
  #endif
302
- #endif`,YS=`#ifdef USE_AOMAP
302
+ #endif`,YM=`#ifdef USE_AOMAP
303
303
  uniform sampler2D aoMap;
304
304
  uniform float aoMapIntensity;
305
- #endif`,qS=`#ifdef USE_BATCHING
305
+ #endif`,qM=`#ifdef USE_BATCHING
306
306
  attribute float batchId;
307
307
  uniform highp sampler2D batchingTexture;
308
308
  mat4 getBatchingMatrix( const in float i ) {
@@ -316,15 +316,15 @@ Program Info Log: `+z+`
316
316
  vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
317
317
  return mat4( v1, v2, v3, v4 );
318
318
  }
319
- #endif`,ZS=`#ifdef USE_BATCHING
319
+ #endif`,ZM=`#ifdef USE_BATCHING
320
320
  mat4 batchingMatrix = getBatchingMatrix( batchId );
321
- #endif`,JS=`vec3 transformed = vec3( position );
321
+ #endif`,JM=`vec3 transformed = vec3( position );
322
322
  #ifdef USE_ALPHAHASH
323
323
  vPosition = vec3( position );
324
- #endif`,KS=`vec3 objectNormal = vec3( normal );
324
+ #endif`,KM=`vec3 objectNormal = vec3( normal );
325
325
  #ifdef USE_TANGENT
326
326
  vec3 objectTangent = vec3( tangent.xyz );
327
- #endif`,QS=`float G_BlinnPhong_Implicit( ) {
327
+ #endif`,QM=`float G_BlinnPhong_Implicit( ) {
328
328
  return 0.25;
329
329
  }
330
330
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -797,7 +797,7 @@ vec4 LinearTosRGB( in vec4 value ) {
797
797
  varying vec3 vReflect;
798
798
  uniform float refractionRatio;
799
799
  #endif
800
- #endif`,M1=`#ifdef USE_ENVMAP
800
+ #endif`,S1=`#ifdef USE_ENVMAP
801
801
  #ifdef ENV_WORLDPOS
802
802
  vWorldPosition = worldPosition.xyz;
803
803
  #else
@@ -814,7 +814,7 @@ vec4 LinearTosRGB( in vec4 value ) {
814
814
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
815
815
  #endif
816
816
  #endif
817
- #endif`,S1=`#ifdef USE_FOG
817
+ #endif`,M1=`#ifdef USE_FOG
818
818
  vFogDepth = - mvPosition.z;
819
819
  #endif`,E1=`#ifdef USE_FOG
820
820
  varying float vFogDepth;
@@ -1583,11 +1583,11 @@ IncidentLight directLight;
1583
1583
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1584
1584
  #endif`,H1=`#if defined( USE_LOGDEPTHBUF )
1585
1585
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1586
- #endif`,G1=`#if defined( USE_LOGDEPTHBUF )
1586
+ #endif`,j1=`#if defined( USE_LOGDEPTHBUF )
1587
1587
  uniform float logDepthBufFC;
1588
1588
  varying float vFragDepth;
1589
1589
  varying float vIsPerspective;
1590
- #endif`,j1=`#ifdef USE_LOGDEPTHBUF
1590
+ #endif`,G1=`#ifdef USE_LOGDEPTHBUF
1591
1591
  varying float vFragDepth;
1592
1592
  varying float vIsPerspective;
1593
1593
  #endif`,W1=`#ifdef USE_LOGDEPTHBUF
@@ -2072,7 +2072,7 @@ gl_Position = projectionMatrix * mvPosition;`,vE=`#ifdef DITHERING
2072
2072
  }
2073
2073
  return shadow;
2074
2074
  }
2075
- #endif`,ME=`#if NUM_SPOT_LIGHT_COORDS > 0
2075
+ #endif`,SE=`#if NUM_SPOT_LIGHT_COORDS > 0
2076
2076
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2077
2077
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2078
2078
  #endif
@@ -2110,7 +2110,7 @@ gl_Position = projectionMatrix * mvPosition;`,vE=`#ifdef DITHERING
2110
2110
  };
2111
2111
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2112
2112
  #endif
2113
- #endif`,SE=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2113
+ #endif`,ME=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2114
2114
  vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
2115
2115
  vec4 shadowWorldPosition;
2116
2116
  #endif
@@ -2763,14 +2763,14 @@ void main() {
2763
2763
  gl_FragColor = texColor;
2764
2764
  #include <tonemapping_fragment>
2765
2765
  #include <colorspace_fragment>
2766
- }`,GE=`varying vec3 vWorldDirection;
2766
+ }`,jE=`varying vec3 vWorldDirection;
2767
2767
  #include <common>
2768
2768
  void main() {
2769
2769
  vWorldDirection = transformDirection( position, modelMatrix );
2770
2770
  #include <begin_vertex>
2771
2771
  #include <project_vertex>
2772
2772
  gl_Position.z = gl_Position.w;
2773
- }`,jE=`uniform samplerCube tCube;
2773
+ }`,GE=`uniform samplerCube tCube;
2774
2774
  uniform float tFlip;
2775
2775
  uniform float opacity;
2776
2776
  varying vec3 vWorldDirection;
@@ -3766,7 +3766,7 @@ void main() {
3766
3766
  #include <tonemapping_fragment>
3767
3767
  #include <colorspace_fragment>
3768
3768
  #include <fog_fragment>
3769
- }`,tt={alphahash_fragment:VS,alphahash_pars_fragment:$S,alphamap_fragment:HS,alphamap_pars_fragment:GS,alphatest_fragment:jS,alphatest_pars_fragment:WS,aomap_fragment:XS,aomap_pars_fragment:YS,batching_pars_vertex:qS,batching_vertex:ZS,begin_vertex:JS,beginnormal_vertex:KS,bsdfs:QS,iridescence_fragment:e1,bumpmap_pars_fragment:t1,clipping_planes_fragment:n1,clipping_planes_pars_fragment:i1,clipping_planes_pars_vertex:r1,clipping_planes_vertex:s1,color_fragment:o1,color_pars_fragment:a1,color_pars_vertex:c1,color_vertex:l1,common:u1,cube_uv_reflection_fragment:d1,defaultnormal_vertex:h1,displacementmap_pars_vertex:f1,displacementmap_vertex:p1,emissivemap_fragment:m1,emissivemap_pars_fragment:g1,colorspace_fragment:y1,colorspace_pars_fragment:v1,envmap_fragment:x1,envmap_common_pars_fragment:b1,envmap_pars_fragment:_1,envmap_pars_vertex:w1,envmap_physical_pars_fragment:D1,envmap_vertex:M1,fog_vertex:S1,fog_pars_vertex:E1,fog_fragment:A1,fog_pars_fragment:T1,gradientmap_pars_fragment:I1,lightmap_pars_fragment:C1,lights_lambert_fragment:R1,lights_lambert_pars_fragment:P1,lights_pars_begin:L1,lights_toon_fragment:O1,lights_toon_pars_fragment:U1,lights_phong_fragment:N1,lights_phong_pars_fragment:F1,lights_physical_fragment:k1,lights_physical_pars_fragment:B1,lights_fragment_begin:z1,lights_fragment_maps:V1,lights_fragment_end:$1,logdepthbuf_fragment:H1,logdepthbuf_pars_fragment:G1,logdepthbuf_pars_vertex:j1,logdepthbuf_vertex:W1,map_fragment:X1,map_pars_fragment:Y1,map_particle_fragment:q1,map_particle_pars_fragment:Z1,metalnessmap_fragment:J1,metalnessmap_pars_fragment:K1,morphinstance_vertex:Q1,morphcolor_vertex:eE,morphnormal_vertex:tE,morphtarget_pars_vertex:nE,morphtarget_vertex:iE,normal_fragment_begin:rE,normal_fragment_maps:sE,normal_pars_fragment:oE,normal_pars_vertex:aE,normal_vertex:cE,normalmap_pars_fragment:lE,clearcoat_normal_fragment_begin:uE,clearcoat_normal_fragment_maps:dE,clearcoat_pars_fragment:hE,iridescence_pars_fragment:fE,opaque_fragment:pE,packing:mE,premultiplied_alpha_fragment:gE,project_vertex:yE,dithering_fragment:vE,dithering_pars_fragment:xE,roughnessmap_fragment:bE,roughnessmap_pars_fragment:_E,shadowmap_pars_fragment:wE,shadowmap_pars_vertex:ME,shadowmap_vertex:SE,shadowmask_pars_fragment:EE,skinbase_vertex:AE,skinning_pars_vertex:TE,skinning_vertex:IE,skinnormal_vertex:CE,specularmap_fragment:RE,specularmap_pars_fragment:PE,tonemapping_fragment:LE,tonemapping_pars_fragment:DE,transmission_fragment:OE,transmission_pars_fragment:UE,uv_pars_fragment:NE,uv_pars_vertex:FE,uv_vertex:kE,worldpos_vertex:BE,background_vert:zE,background_frag:VE,backgroundCube_vert:$E,backgroundCube_frag:HE,cube_vert:GE,cube_frag:jE,depth_vert:WE,depth_frag:XE,distanceRGBA_vert:YE,distanceRGBA_frag:qE,equirect_vert:ZE,equirect_frag:JE,linedashed_vert:KE,linedashed_frag:QE,meshbasic_vert:eA,meshbasic_frag:tA,meshlambert_vert:nA,meshlambert_frag:iA,meshmatcap_vert:rA,meshmatcap_frag:sA,meshnormal_vert:oA,meshnormal_frag:aA,meshphong_vert:cA,meshphong_frag:lA,meshphysical_vert:uA,meshphysical_frag:dA,meshtoon_vert:hA,meshtoon_frag:fA,points_vert:pA,points_frag:mA,shadow_vert:gA,shadow_frag:yA,sprite_vert:vA,sprite_frag:xA},Ee={common:{diffuse:{value:new Ce(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Qe},alphaMap:{value:null},alphaMapTransform:{value:new Qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Qe}},envmap:{envMap:{value:null},envMapRotation:{value:new Qe},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Qe},normalScale:{value:new oe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ce(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ce(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Qe},alphaTest:{value:0},uvTransform:{value:new Qe}},sprite:{diffuse:{value:new Ce(16777215)},opacity:{value:1},center:{value:new oe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Qe},alphaMap:{value:null},alphaMapTransform:{value:new Qe},alphaTest:{value:0}}},kn={basic:{uniforms:rn([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.fog]),vertexShader:tt.meshbasic_vert,fragmentShader:tt.meshbasic_frag},lambert:{uniforms:rn([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ce(0)}}]),vertexShader:tt.meshlambert_vert,fragmentShader:tt.meshlambert_frag},phong:{uniforms:rn([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ce(0)},specular:{value:new Ce(1118481)},shininess:{value:30}}]),vertexShader:tt.meshphong_vert,fragmentShader:tt.meshphong_frag},standard:{uniforms:rn([Ee.common,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.roughnessmap,Ee.metalnessmap,Ee.fog,Ee.lights,{emissive:{value:new Ce(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag},toon:{uniforms:rn([Ee.common,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.gradientmap,Ee.fog,Ee.lights,{emissive:{value:new Ce(0)}}]),vertexShader:tt.meshtoon_vert,fragmentShader:tt.meshtoon_frag},matcap:{uniforms:rn([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,{matcap:{value:null}}]),vertexShader:tt.meshmatcap_vert,fragmentShader:tt.meshmatcap_frag},points:{uniforms:rn([Ee.points,Ee.fog]),vertexShader:tt.points_vert,fragmentShader:tt.points_frag},dashed:{uniforms:rn([Ee.common,Ee.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:tt.linedashed_vert,fragmentShader:tt.linedashed_frag},depth:{uniforms:rn([Ee.common,Ee.displacementmap]),vertexShader:tt.depth_vert,fragmentShader:tt.depth_frag},normal:{uniforms:rn([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,{opacity:{value:1}}]),vertexShader:tt.meshnormal_vert,fragmentShader:tt.meshnormal_frag},sprite:{uniforms:rn([Ee.sprite,Ee.fog]),vertexShader:tt.sprite_vert,fragmentShader:tt.sprite_frag},background:{uniforms:{uvTransform:{value:new Qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:tt.background_vert,fragmentShader:tt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Qe}},vertexShader:tt.backgroundCube_vert,fragmentShader:tt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:tt.cube_vert,fragmentShader:tt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:tt.equirect_vert,fragmentShader:tt.equirect_frag},distanceRGBA:{uniforms:rn([Ee.common,Ee.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:tt.distanceRGBA_vert,fragmentShader:tt.distanceRGBA_frag},shadow:{uniforms:rn([Ee.lights,Ee.fog,{color:{value:new Ce(0)},opacity:{value:1}}]),vertexShader:tt.shadow_vert,fragmentShader:tt.shadow_frag}};kn.physical={uniforms:rn([kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Qe},clearcoatNormalScale:{value:new oe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Qe},sheen:{value:0},sheenColor:{value:new Ce(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Qe},transmissionSamplerSize:{value:new oe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Qe},attenuationDistance:{value:0},attenuationColor:{value:new Ce(0)},specularColor:{value:new Ce(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Qe},anisotropyVector:{value:new oe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Qe}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag};Hc={r:0,b:0,g:0},gr=new vn,bA=new ze;Vs=class extends Bs{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,o=i+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Rs=4,Hg=[.125,.215,.35,.446,.526,.582],Ar=20,th=new Vs,Gg=new Ce,nh=null,ih=0,rh=0,sh=!1,Er=(1+Math.sqrt(5))/2,_s=1/Er,jg=[new P(-Er,_s,0),new P(Er,_s,0),new P(-_s,0,Er),new P(_s,0,Er),new P(0,Er,-_s),new P(0,Er,_s),new P(-1,1,-1),new P(1,1,-1),new P(-1,1,1),new P(1,1,1)],la=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){nh=this._renderer.getRenderTarget(),ih=this._renderer.getActiveCubeFace(),rh=this._renderer.getActiveMipmapLevel(),sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Yg(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Xg(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(nh,ih,rh),this._renderer.xr.enabled=sh,e.scissorTest=!1,Gc(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Mi||e.mapping===Yi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),nh=this._renderer.getRenderTarget(),ih=this._renderer.getActiveCubeFace(),rh=this._renderer.getActiveMipmapLevel(),sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Lt,minFilter:Lt,generateMipmaps:!1,type:Ua,format:mn,colorSpace:Ti,depthBuffer:!1},r=Wg(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Wg(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=TA(s)),this._blurMaterial=IA(s,e,t)}return r}_compileMaterial(e){let t=new It(this._lodPlanes[0],e);this._renderer.compile(t,th)}_sceneToCubeUV(e,t,i,r){let a=new Ut(90,1,t,i),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,h=u.toneMapping;u.getClearColor(Gg),u.toneMapping=bi,u.autoClear=!1;let f=new Zn({name:"PMREM.Background",side:on,depthWrite:!1,depthTest:!1}),p=new It(new Or,f),y=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,y=!0):(f.color.copy(Gg),y=!0);for(let m=0;m<6;m++){let v=m%3;v===0?(a.up.set(0,c[m],0),a.lookAt(l[m],0,0)):v===1?(a.up.set(0,0,c[m]),a.lookAt(0,l[m],0)):(a.up.set(0,c[m],0),a.lookAt(0,0,l[m]));let x=this._cubeSize;Gc(r,v*x,m>2?x:0,x,x),u.setRenderTarget(r),y&&u.render(p,a),u.render(e,a)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===Mi||e.mapping===Yi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Yg()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Xg());let s=r?this._cubemapMaterial:this._equirectMaterial,o=new It(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let c=this._cubeSize;Gc(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(o,th)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let s=1;s<r;s++){let o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=jg[(r-s-1)%jg.length];this._blur(e,s-1,s,o,a)}t.autoClear=i}_blur(e,t,i,r,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,d=new It(this._lodPlanes[r],l),h=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Ar-1),y=s/p,g=isFinite(s)?1+Math.floor(u*y):Ar;g>Ar&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Ar}`);let m=[],v=0;for(let R=0;R<Ar;++R){let U=R/y,_=Math.exp(-U*U/2);m.push(_),R===0?v+=_:R<g&&(v+=2*_)}for(let R=0;R<m.length;R++)m[R]=m[R]/v;h.envMap.value=e.texture,h.samples.value=g,h.weights.value=m,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);let{_lodMax:x}=this;h.dTheta.value=p,h.mipInt.value=x-i;let w=this._sizeLods[r],O=3*w*(r>x-Rs?r-x+Rs:0),I=4*(this._cubeSize-w);Gc(t,O,I,3*w,2*w),c.setRenderTarget(t),c.render(d,th)}};ua=class extends Dt{constructor(e,t,i,r,s,o,a,c,l,u){if(u=u!==void 0?u:Pr,u!==Pr&&u!==Os)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Pr&&(i=Dr),i===void 0&&u===Os&&(i=Xs),super(null,r,s,o,a,c,u,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:zt,this.minFilter=c!==void 0?c:zt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},pv=new Dt,mv=new ua(1,1);mv.compareFunction=Cp;gv=new Ns,yv=new oa,vv=new Ur,qg=[],Zg=[],Jg=new Float32Array(16),Kg=new Float32Array(9),Qg=new Float32Array(4);lf=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=tT(t.type)}},uf=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=_T(t.type)}},df=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let s=0,o=r.length;s!==o;++s){let a=r[s];a.setValue(e,t[a.id],i)}}},oh=/(\w+)(\])?(\[|\.)?/g;Ds=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){let s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);wT(s,o,this)}}setValue(e,t,i,r){let s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],c=i[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&i.push(o)}return i}};MT=37297,ST=0;LT=/^[ \t]*#include +<([\w\d./]+)>/gm;DT=new Map;UT=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;HT=0,ff=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new pf(e),t.set(e,i)),i}},pf=class{constructor(e){this.id=HT++,this.code=e,this.usedTimes=0}};ZT=0;da=class extends $t{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jy,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},ha=class extends $t{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},eI=`void main() {
3769
+ }`,Qe={alphahash_fragment:VM,alphahash_pars_fragment:$M,alphamap_fragment:HM,alphamap_pars_fragment:jM,alphatest_fragment:GM,alphatest_pars_fragment:WM,aomap_fragment:XM,aomap_pars_fragment:YM,batching_pars_vertex:qM,batching_vertex:ZM,begin_vertex:JM,beginnormal_vertex:KM,bsdfs:QM,iridescence_fragment:e1,bumpmap_pars_fragment:t1,clipping_planes_fragment:n1,clipping_planes_pars_fragment:i1,clipping_planes_pars_vertex:r1,clipping_planes_vertex:s1,color_fragment:o1,color_pars_fragment:a1,color_pars_vertex:c1,color_vertex:l1,common:u1,cube_uv_reflection_fragment:d1,defaultnormal_vertex:h1,displacementmap_pars_vertex:f1,displacementmap_vertex:p1,emissivemap_fragment:m1,emissivemap_pars_fragment:g1,colorspace_fragment:y1,colorspace_pars_fragment:v1,envmap_fragment:x1,envmap_common_pars_fragment:b1,envmap_pars_fragment:_1,envmap_pars_vertex:w1,envmap_physical_pars_fragment:D1,envmap_vertex:S1,fog_vertex:M1,fog_pars_vertex:E1,fog_fragment:A1,fog_pars_fragment:T1,gradientmap_pars_fragment:I1,lightmap_pars_fragment:C1,lights_lambert_fragment:R1,lights_lambert_pars_fragment:P1,lights_pars_begin:L1,lights_toon_fragment:O1,lights_toon_pars_fragment:U1,lights_phong_fragment:N1,lights_phong_pars_fragment:F1,lights_physical_fragment:k1,lights_physical_pars_fragment:B1,lights_fragment_begin:z1,lights_fragment_maps:V1,lights_fragment_end:$1,logdepthbuf_fragment:H1,logdepthbuf_pars_fragment:j1,logdepthbuf_pars_vertex:G1,logdepthbuf_vertex:W1,map_fragment:X1,map_pars_fragment:Y1,map_particle_fragment:q1,map_particle_pars_fragment:Z1,metalnessmap_fragment:J1,metalnessmap_pars_fragment:K1,morphinstance_vertex:Q1,morphcolor_vertex:eE,morphnormal_vertex:tE,morphtarget_pars_vertex:nE,morphtarget_vertex:iE,normal_fragment_begin:rE,normal_fragment_maps:sE,normal_pars_fragment:oE,normal_pars_vertex:aE,normal_vertex:cE,normalmap_pars_fragment:lE,clearcoat_normal_fragment_begin:uE,clearcoat_normal_fragment_maps:dE,clearcoat_pars_fragment:hE,iridescence_pars_fragment:fE,opaque_fragment:pE,packing:mE,premultiplied_alpha_fragment:gE,project_vertex:yE,dithering_fragment:vE,dithering_pars_fragment:xE,roughnessmap_fragment:bE,roughnessmap_pars_fragment:_E,shadowmap_pars_fragment:wE,shadowmap_pars_vertex:SE,shadowmap_vertex:ME,shadowmask_pars_fragment:EE,skinbase_vertex:AE,skinning_pars_vertex:TE,skinning_vertex:IE,skinnormal_vertex:CE,specularmap_fragment:RE,specularmap_pars_fragment:PE,tonemapping_fragment:LE,tonemapping_pars_fragment:DE,transmission_fragment:OE,transmission_pars_fragment:UE,uv_pars_fragment:NE,uv_pars_vertex:FE,uv_vertex:kE,worldpos_vertex:BE,background_vert:zE,background_frag:VE,backgroundCube_vert:$E,backgroundCube_frag:HE,cube_vert:jE,cube_frag:GE,depth_vert:WE,depth_frag:XE,distanceRGBA_vert:YE,distanceRGBA_frag:qE,equirect_vert:ZE,equirect_frag:JE,linedashed_vert:KE,linedashed_frag:QE,meshbasic_vert:eA,meshbasic_frag:tA,meshlambert_vert:nA,meshlambert_frag:iA,meshmatcap_vert:rA,meshmatcap_frag:sA,meshnormal_vert:oA,meshnormal_frag:aA,meshphong_vert:cA,meshphong_frag:lA,meshphysical_vert:uA,meshphysical_frag:dA,meshtoon_vert:hA,meshtoon_frag:fA,points_vert:pA,points_frag:mA,shadow_vert:gA,shadow_frag:yA,sprite_vert:vA,sprite_frag:xA},Ee={common:{diffuse:{value:new Ce(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Je},alphaMap:{value:null},alphaMapTransform:{value:new Je},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Je}},envmap:{envMap:{value:null},envMapRotation:{value:new Je},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Je}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Je}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Je},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Je},normalScale:{value:new se(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Je},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Je}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Je}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Je}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ce(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ce(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Je},alphaTest:{value:0},uvTransform:{value:new Je}},sprite:{diffuse:{value:new Ce(16777215)},opacity:{value:1},center:{value:new se(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Je},alphaMap:{value:null},alphaMapTransform:{value:new Je},alphaTest:{value:0}}},Un={basic:{uniforms:en([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.fog]),vertexShader:Qe.meshbasic_vert,fragmentShader:Qe.meshbasic_frag},lambert:{uniforms:en([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ce(0)}}]),vertexShader:Qe.meshlambert_vert,fragmentShader:Qe.meshlambert_frag},phong:{uniforms:en([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ce(0)},specular:{value:new Ce(1118481)},shininess:{value:30}}]),vertexShader:Qe.meshphong_vert,fragmentShader:Qe.meshphong_frag},standard:{uniforms:en([Ee.common,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.roughnessmap,Ee.metalnessmap,Ee.fog,Ee.lights,{emissive:{value:new Ce(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Qe.meshphysical_vert,fragmentShader:Qe.meshphysical_frag},toon:{uniforms:en([Ee.common,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.gradientmap,Ee.fog,Ee.lights,{emissive:{value:new Ce(0)}}]),vertexShader:Qe.meshtoon_vert,fragmentShader:Qe.meshtoon_frag},matcap:{uniforms:en([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,{matcap:{value:null}}]),vertexShader:Qe.meshmatcap_vert,fragmentShader:Qe.meshmatcap_frag},points:{uniforms:en([Ee.points,Ee.fog]),vertexShader:Qe.points_vert,fragmentShader:Qe.points_frag},dashed:{uniforms:en([Ee.common,Ee.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qe.linedashed_vert,fragmentShader:Qe.linedashed_frag},depth:{uniforms:en([Ee.common,Ee.displacementmap]),vertexShader:Qe.depth_vert,fragmentShader:Qe.depth_frag},normal:{uniforms:en([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,{opacity:{value:1}}]),vertexShader:Qe.meshnormal_vert,fragmentShader:Qe.meshnormal_frag},sprite:{uniforms:en([Ee.sprite,Ee.fog]),vertexShader:Qe.sprite_vert,fragmentShader:Qe.sprite_frag},background:{uniforms:{uvTransform:{value:new Je},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Qe.background_vert,fragmentShader:Qe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Je}},vertexShader:Qe.backgroundCube_vert,fragmentShader:Qe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Qe.cube_vert,fragmentShader:Qe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Qe.equirect_vert,fragmentShader:Qe.equirect_frag},distanceRGBA:{uniforms:en([Ee.common,Ee.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qe.distanceRGBA_vert,fragmentShader:Qe.distanceRGBA_frag},shadow:{uniforms:en([Ee.lights,Ee.fog,{color:{value:new Ce(0)},opacity:{value:1}}]),vertexShader:Qe.shadow_vert,fragmentShader:Qe.shadow_frag}};Un.physical={uniforms:en([Un.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Je},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Je},clearcoatNormalScale:{value:new se(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Je},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Je},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Je},sheen:{value:0},sheenColor:{value:new Ce(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Je},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Je},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Je},transmissionSamplerSize:{value:new se},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Je},attenuationDistance:{value:0},attenuationColor:{value:new Ce(0)},specularColor:{value:new Ce(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Je},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Je},anisotropyVector:{value:new se},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Je}}]),vertexShader:Qe.meshphysical_vert,fragmentShader:Qe.meshphysical_frag};Hc={r:0,b:0,g:0},mr=new pn,bA=new $e;Hs=class extends Vs{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,o=i+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Ls=4,Hg=[.125,.215,.35,.446,.526,.582],Er=20,th=new Hs,jg=new Ce,nh=null,ih=0,rh=0,sh=!1,Mr=(1+Math.sqrt(5))/2,Ss=1/Mr,Gg=[new L(-Mr,Ss,0),new L(Mr,Ss,0),new L(-Ss,0,Mr),new L(Ss,0,Mr),new L(0,Mr,-Ss),new L(0,Mr,Ss),new L(-1,1,-1),new L(1,1,-1),new L(-1,1,1),new L(1,1,1)],la=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){nh=this._renderer.getRenderTarget(),ih=this._renderer.getActiveCubeFace(),rh=this._renderer.getActiveMipmapLevel(),sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Yg(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Xg(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(nh,ih,rh),this._renderer.xr.enabled=sh,e.scissorTest=!1,jc(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===_i||e.mapping===Wi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),nh=this._renderer.getRenderTarget(),ih=this._renderer.getActiveCubeFace(),rh=this._renderer.getActiveMipmapLevel(),sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:It,minFilter:It,generateMipmaps:!1,type:Ua,format:dn,colorSpace:Ei,depthBuffer:!1},r=Wg(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Wg(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=TA(s)),this._blurMaterial=IA(s,e,t)}return r}_compileMaterial(e){let t=new Mt(this._lodPlanes[0],e);this._renderer.compile(t,th)}_sceneToCubeUV(e,t,i,r){let a=new Pt(90,1,t,i),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,h=u.toneMapping;u.getClearColor(jg),u.toneMapping=vi,u.autoClear=!1;let f=new Yn({name:"PMREM.Background",side:nn,depthWrite:!1,depthTest:!1}),p=new Mt(new Dr,f),y=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,y=!0):(f.color.copy(jg),y=!0);for(let m=0;m<6;m++){let x=m%3;x===0?(a.up.set(0,c[m],0),a.lookAt(l[m],0,0)):x===1?(a.up.set(0,0,c[m]),a.lookAt(0,l[m],0)):(a.up.set(0,c[m],0),a.lookAt(0,0,l[m]));let v=this._cubeSize;jc(r,x*v,m>2?v:0,v,v),u.setRenderTarget(r),y&&u.render(p,a),u.render(e,a)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===_i||e.mapping===Wi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Yg()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Xg());let s=r?this._cubemapMaterial:this._equirectMaterial,o=new Mt(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let c=this._cubeSize;jc(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(o,th)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let s=1;s<r;s++){let o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=Gg[(r-s-1)%Gg.length];this._blur(e,s-1,s,o,a)}t.autoClear=i}_blur(e,t,i,r,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,d=new Mt(this._lodPlanes[r],l),h=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Er-1),y=s/p,g=isFinite(s)?1+Math.floor(u*y):Er;g>Er&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Er}`);let m=[],x=0;for(let R=0;R<Er;++R){let N=R/y,w=Math.exp(-N*N/2);m.push(w),R===0?x+=w:R<g&&(x+=2*w)}for(let R=0;R<m.length;R++)m[R]=m[R]/x;h.envMap.value=e.texture,h.samples.value=g,h.weights.value=m,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);let{_lodMax:v}=this;h.dTheta.value=p,h.mipInt.value=v-i;let M=this._sizeLods[r],U=3*M*(r>v-Ls?r-v+Ls:0),C=4*(this._cubeSize-M);jc(t,U,C,3*M,2*M),c.setRenderTarget(t),c.render(d,th)}};ua=class extends Ct{constructor(e,t,i,r,s,o,a,c,l,u){if(u=u!==void 0?u:Rr,u!==Rr&&u!==Ns)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Rr&&(i=Lr),i===void 0&&u===Ns&&(i=qs),super(null,r,s,o,a,c,u,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Nt,this.minFilter=c!==void 0?c:Nt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},pv=new Ct,mv=new ua(1,1);mv.compareFunction=Cp;gv=new ks,yv=new oa,vv=new Or,qg=[],Zg=[],Jg=new Float32Array(16),Kg=new Float32Array(9),Qg=new Float32Array(4);lf=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=tT(t.type)}},uf=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=_T(t.type)}},df=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let s=0,o=r.length;s!==o;++s){let a=r[s];a.setValue(e,t[a.id],i)}}},oh=/(\w+)(\])?(\[|\.)?/g;Us=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){let s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);wT(s,o,this)}}setValue(e,t,i,r){let s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],c=i[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&i.push(o)}return i}};ST=37297,MT=0;LT=/^[ \t]*#include +<([\w\d./]+)>/gm;DT=new Map;UT=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;HT=0,ff=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new pf(e),t.set(e,i)),i}},pf=class{constructor(e){this.id=HT++,this.code=e,this.usedTimes=0}};ZT=0;da=class extends kt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=J0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},ha=class extends kt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},eI=`void main() {
3770
3770
  gl_Position = vec4( position, 1.0 );
3771
3771
  }`,tI=`uniform sampler2D shadow_pass;
3772
3772
  uniform vec2 resolution;
@@ -3794,7 +3794,7 @@ void main() {
3794
3794
  squared_mean = squared_mean / samples;
3795
3795
  float std_dev = sqrt( squared_mean - mean * mean );
3796
3796
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3797
- }`;Il=class extends Ut{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Xi=class extends ht{constructor(){super(),this.isGroup=!0,this.type="Group"}},sI={type:"move"},Ho=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Xi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Xi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Xi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,i),m=this._getHandJoint(l,y);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}let u=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],h=u.position.distanceTo(d.position),f=.02,p=.005;l.inputState.pinching&&h>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(sI)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Xi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},oI=`
3797
+ }`;Il=class extends Pt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Gi=class extends lt{constructor(){super(),this.isGroup=!0,this.type="Group"}},sI={type:"move"},Ho=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Gi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,i),m=this._getHandJoint(l,y);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}let u=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],h=u.position.distanceTo(d.position),f=.02,p=.005;l.inputState.pinching&&h>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(sI)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Gi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},oI=`
3798
3798
  void main() {
3799
3799
 
3800
3800
  gl_Position = vec4( position, 1.0 );
@@ -3818,23 +3818,23 @@ void main() {
3818
3818
 
3819
3819
  }
3820
3820
 
3821
- }`,mf=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){let r=new Dt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){let i=t.cameras[0].viewport,r=new xn({vertexShader:oI,fragmentShader:aI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new It(new zs(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},gf=class extends Bn{constructor(e,t){super();let i=this,r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,d=null,h=null,f=null,p=null,y=new mf,g=t.getContextAttributes(),m=null,v=null,x=[],w=[],O=new oe,I=null,R=new Ut;R.layers.enable(1),R.viewport=new gt;let U=new Ut;U.layers.enable(2),U.viewport=new gt;let _=[R,U],b=new Il;b.layers.enable(1),b.layers.enable(2);let D=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let Z=x[q];return Z===void 0&&(Z=new Ho,x[q]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(q){let Z=x[q];return Z===void 0&&(Z=new Ho,x[q]=Z),Z.getGripSpace()},this.getHand=function(q){let Z=x[q];return Z===void 0&&(Z=new Ho,x[q]=Z),Z.getHandSpace()};function F(q){let Z=w.indexOf(q.inputSource);if(Z===-1)return;let ye=x[Z];ye!==void 0&&(ye.update(q.inputSource,q.frame,l||o),ye.dispatchEvent({type:q.type,data:q.inputSource}))}function $(){r.removeEventListener("select",F),r.removeEventListener("selectstart",F),r.removeEventListener("selectend",F),r.removeEventListener("squeeze",F),r.removeEventListener("squeezestart",F),r.removeEventListener("squeezeend",F),r.removeEventListener("end",$),r.removeEventListener("inputsourceschange",W);for(let q=0;q<x.length;q++){let Z=w[q];Z!==null&&(w[q]=null,x[q].disconnect(Z))}D=null,z=null,y.reset(),e.setRenderTarget(m),f=null,h=null,d=null,r=null,v=null,He.stop(),i.isPresenting=!1,e.setPixelRatio(I),e.setSize(O.width,O.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){s=q,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){a=q,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(q){l=q},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(q){if(r=q,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",F),r.addEventListener("selectstart",F),r.addEventListener("selectend",F),r.addEventListener("squeeze",F),r.addEventListener("squeezestart",F),r.addEventListener("squeezeend",F),r.addEventListener("end",$),r.addEventListener("inputsourceschange",W),g.xrCompatible!==!0&&await t.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(O),r.renderState.layers===void 0){let Z={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,t,Z),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),v=new yn(f.framebufferWidth,f.framebufferHeight,{format:mn,type:Si,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let Z=null,ye=null,ae=null;g.depth&&(ae=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Z=g.stencil?Os:Pr,ye=g.stencil?Xs:Dr);let Ie={colorFormat:t.RGBA8,depthFormat:ae,scaleFactor:s};d=new XRWebGLBinding(r,t),h=d.createProjectionLayer(Ie),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),v=new yn(h.textureWidth,h.textureHeight,{format:mn,type:Si,depthTexture:new ua(h.textureWidth,h.textureHeight,ye,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),He.setContext(r),He.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function W(q){for(let Z=0;Z<q.removed.length;Z++){let ye=q.removed[Z],ae=w.indexOf(ye);ae>=0&&(w[ae]=null,x[ae].disconnect(ye))}for(let Z=0;Z<q.added.length;Z++){let ye=q.added[Z],ae=w.indexOf(ye);if(ae===-1){for(let Re=0;Re<x.length;Re++)if(Re>=w.length){w.push(ye),ae=Re;break}else if(w[Re]===null){w[Re]=ye,ae=Re;break}if(ae===-1)break}let Ie=x[ae];Ie&&Ie.connect(ye)}}let ne=new P,J=new P;function V(q,Z,ye){ne.setFromMatrixPosition(Z.matrixWorld),J.setFromMatrixPosition(ye.matrixWorld);let ae=ne.distanceTo(J),Ie=Z.projectionMatrix.elements,Re=ye.projectionMatrix.elements,B=Ie[14]/(Ie[10]-1),Je=Ie[14]/(Ie[10]+1),X=(Ie[9]+1)/Ie[5],he=(Ie[9]-1)/Ie[5],Q=(Ie[8]-1)/Ie[0],me=(Re[8]+1)/Re[0],K=B*Q,we=B*me,De=ae/(-Q+me),L=De*-Q;Z.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(L),q.translateZ(De),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert();let E=B+De,H=Je+De,te=K-L,le=we+(ae-L),re=X*Je/H*E,Ue=he*Je/H*E;q.projectionMatrix.makePerspective(te,le,re,Ue,E,H),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}function ce(q,Z){Z===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(Z.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(r===null)return;y.texture!==null&&(q.near=y.depthNear,q.far=y.depthFar),b.near=U.near=R.near=q.near,b.far=U.far=R.far=q.far,(D!==b.near||z!==b.far)&&(r.updateRenderState({depthNear:b.near,depthFar:b.far}),D=b.near,z=b.far,R.near=D,R.far=z,U.near=D,U.far=z,R.updateProjectionMatrix(),U.updateProjectionMatrix(),q.updateProjectionMatrix());let Z=q.parent,ye=b.cameras;ce(b,Z);for(let ae=0;ae<ye.length;ae++)ce(ye[ae],Z);ye.length===2?V(b,R,U):b.projectionMatrix.copy(R.projectionMatrix),fe(q,b,Z)};function fe(q,Z,ye){ye===null?q.matrix.copy(Z.matrixWorld):(q.matrix.copy(ye.matrixWorld),q.matrix.invert(),q.matrix.multiply(Z.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(Z.projectionMatrix),q.projectionMatrixInverse.copy(Z.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=Us*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return b},this.getFoveation=function(){if(!(h===null&&f===null))return c},this.setFoveation=function(q){c=q,h!==null&&(h.fixedFoveation=q),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=q)},this.hasDepthSensing=function(){return y.texture!==null};let Te=null;function ve(q,Z){if(u=Z.getViewerPose(l||o),p=Z,u!==null){let ye=u.views;f!==null&&(e.setRenderTargetFramebuffer(v,f.framebuffer),e.setRenderTarget(v));let ae=!1;ye.length!==b.cameras.length&&(b.cameras.length=0,ae=!0);for(let Re=0;Re<ye.length;Re++){let B=ye[Re],Je=null;if(f!==null)Je=f.getViewport(B);else{let he=d.getViewSubImage(h,B);Je=he.viewport,Re===0&&(e.setRenderTargetTextures(v,he.colorTexture,h.ignoreDepthValues?void 0:he.depthStencilTexture),e.setRenderTarget(v))}let X=_[Re];X===void 0&&(X=new Ut,X.layers.enable(Re),X.viewport=new gt,_[Re]=X),X.matrix.fromArray(B.transform.matrix),X.matrix.decompose(X.position,X.quaternion,X.scale),X.projectionMatrix.fromArray(B.projectionMatrix),X.projectionMatrixInverse.copy(X.projectionMatrix).invert(),X.viewport.set(Je.x,Je.y,Je.width,Je.height),Re===0&&(b.matrix.copy(X.matrix),b.matrix.decompose(b.position,b.quaternion,b.scale)),ae===!0&&b.cameras.push(X)}let Ie=r.enabledFeatures;if(Ie&&Ie.includes("depth-sensing")){let Re=d.getDepthInformation(ye[0]);Re&&Re.isValid&&Re.texture&&y.init(e,Re,r.renderState)}}for(let ye=0;ye<x.length;ye++){let ae=w[ye],Ie=x[ye];ae!==null&&Ie!==void 0&&Ie.update(ae,Z,l||o)}y.render(e,b),Te&&Te(q,Z),Z.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:Z}),p=null}let He=new fv;He.setAnimationLoop(ve),this.setAnimationLoop=function(q){Te=q},this.dispose=function(){}}},yr=new vn,cI=new ze;yf=class{constructor(e={}){let{canvas:t=cv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let h;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=i.getContextAttributes().alpha}else h=o;let f=new Uint32Array(4),p=new Int32Array(4),y=null,g=null,m=[],v=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Tn,this._useLegacyLights=!1,this.toneMapping=bi,this.toneMappingExposure=1;let x=this,w=!1,O=0,I=0,R=null,U=-1,_=null,b=new gt,D=new gt,z=null,F=new Ce(0),$=0,W=t.width,ne=t.height,J=1,V=null,ce=null,fe=new gt(0,0,W,ne),Te=new gt(0,0,W,ne),ve=!1,He=new Nr,q=!1,Z=!1,ye=new ze,ae=new P,Ie={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Re(){return R===null?J:1}let B=i;function Je(C,M){return t.getContext(C,M)}try{let C={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r164"),t.addEventListener("webglcontextlost",k,!1),t.addEventListener("webglcontextrestored",ue,!1),t.addEventListener("webglcontextcreationerror",ee,!1),B===null){let M="webgl2";if(B=Je(M,C),B===null)throw Je(M)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(C){throw console.error("THREE.WebGLRenderer: "+C.message),C}let X,he,Q,me,K,we,De,L,E,H,te,le,re,Ue,xe,be,Ve,pe,Oe,Ge,Ne,Me,Ye,nt;function yt(){X=new RA(B),X.init(),Me=new xv(B,X),he=new SA(B,X,e,Me),Q=new iI(B),me=new DA(B),K=new jT,we=new rI(B,X,Q,K,he,Me,me),De=new AA(x),L=new CA(x),E=new zS(B),Ye=new wA(B,E),H=new PA(B,E,me,Ye),te=new UA(B,H,E,me),Oe=new OA(B,he,we),be=new EA(K),le=new GT(x,De,L,X,he,Ye,be),re=new lI(x,K),Ue=new XT,xe=new QT(X),pe=new _A(x,De,L,Q,te,h,c),Ve=new nI(x,te,he),nt=new uI(B,me,he,Q),Ge=new MA(B,X,me),Ne=new LA(B,X,me),me.programs=le.programs,x.capabilities=he,x.extensions=X,x.properties=K,x.renderLists=Ue,x.shadowMap=Ve,x.state=Q,x.info=me}yt();let je=new gf(x,B);this.xr=je,this.getContext=function(){return B},this.getContextAttributes=function(){return B.getContextAttributes()},this.forceContextLoss=function(){let C=X.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){let C=X.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(W,ne,!1))},this.getSize=function(C){return C.set(W,ne)},this.setSize=function(C,M,S=!0){if(je.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=C,ne=M,t.width=Math.floor(C*J),t.height=Math.floor(M*J),S===!0&&(t.style.width=C+"px",t.style.height=M+"px"),this.setViewport(0,0,C,M)},this.getDrawingBufferSize=function(C){return C.set(W*J,ne*J).floor()},this.setDrawingBufferSize=function(C,M,S){W=C,ne=M,J=S,t.width=Math.floor(C*S),t.height=Math.floor(M*S),this.setViewport(0,0,C,M)},this.getCurrentViewport=function(C){return C.copy(b)},this.getViewport=function(C){return C.copy(fe)},this.setViewport=function(C,M,S,A){C.isVector4?fe.set(C.x,C.y,C.z,C.w):fe.set(C,M,S,A),Q.viewport(b.copy(fe).multiplyScalar(J).round())},this.getScissor=function(C){return C.copy(Te)},this.setScissor=function(C,M,S,A){C.isVector4?Te.set(C.x,C.y,C.z,C.w):Te.set(C,M,S,A),Q.scissor(D.copy(Te).multiplyScalar(J).round())},this.getScissorTest=function(){return ve},this.setScissorTest=function(C){Q.setScissorTest(ve=C)},this.setOpaqueSort=function(C){V=C},this.setTransparentSort=function(C){ce=C},this.getClearColor=function(C){return C.copy(pe.getClearColor())},this.setClearColor=function(){pe.setClearColor.apply(pe,arguments)},this.getClearAlpha=function(){return pe.getClearAlpha()},this.setClearAlpha=function(){pe.setClearAlpha.apply(pe,arguments)},this.clear=function(C=!0,M=!0,S=!0){let A=0;if(C){let T=!1;if(R!==null){let j=R.texture.format;T=j===Tp||j===Ap||j===Ep}if(T){let j=R.texture.type,ie=j===Si||j===Dr||j===bp||j===Xs||j===wp||j===Mp,ge=pe.getClearColor(),Ae=pe.getClearAlpha(),Pe=ge.r,Xe=ge.g,Be=ge.b;ie?(f[0]=Pe,f[1]=Xe,f[2]=Be,f[3]=Ae,B.clearBufferuiv(B.COLOR,0,f)):(p[0]=Pe,p[1]=Xe,p[2]=Be,p[3]=Ae,B.clearBufferiv(B.COLOR,0,p))}else A|=B.COLOR_BUFFER_BIT}M&&(A|=B.DEPTH_BUFFER_BIT),S&&(A|=B.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B.clear(A)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",k,!1),t.removeEventListener("webglcontextrestored",ue,!1),t.removeEventListener("webglcontextcreationerror",ee,!1),Ue.dispose(),xe.dispose(),K.dispose(),De.dispose(),L.dispose(),te.dispose(),Ye.dispose(),nt.dispose(),le.dispose(),je.dispose(),je.removeEventListener("sessionstart",ot),je.removeEventListener("sessionend",an),N.stop()};function k(C){C.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),w=!0}function ue(){console.log("THREE.WebGLRenderer: Context Restored."),w=!1;let C=me.autoReset,M=Ve.enabled,S=Ve.autoUpdate,A=Ve.needsUpdate,T=Ve.type;yt(),me.autoReset=C,Ve.enabled=M,Ve.autoUpdate=S,Ve.needsUpdate=A,Ve.type=T}function ee(C){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function de(C){let M=C.target;M.removeEventListener("dispose",de),Se(M)}function Se(C){rt(C),K.remove(C)}function rt(C){let M=K.get(C).programs;M!==void 0&&(M.forEach(function(S){le.releaseProgram(S)}),C.isShaderMaterial&&le.releaseShaderCache(C))}this.renderBufferDirect=function(C,M,S,A,T,j){M===null&&(M=Ie);let ie=T.isMesh&&T.matrixWorld.determinant()<0,ge=or(C,M,S,A,T);Q.setMaterial(A,ie);let Ae=S.index,Pe=1;if(A.wireframe===!0){if(Ae=H.getWireframeAttribute(S),Ae===void 0)return;Pe=2}let Xe=S.drawRange,Be=S.attributes.position,bt=Xe.start*Pe,Xt=(Xe.start+Xe.count)*Pe;j!==null&&(bt=Math.max(bt,j.start*Pe),Xt=Math.min(Xt,(j.start+j.count)*Pe)),Ae!==null?(bt=Math.max(bt,0),Xt=Math.min(Xt,Ae.count)):Be!=null&&(bt=Math.max(bt,0),Xt=Math.min(Xt,Be.count));let dn=Xt-bt;if(dn<0||dn===1/0)return;Ye.setup(T,A,ge,S,Ae);let ii,dt=Ge;if(Ae!==null&&(ii=E.get(Ae),dt=Ne,dt.setIndex(ii)),T.isMesh)A.wireframe===!0?(Q.setLineWidth(A.wireframeLinewidth*Re()),dt.setMode(B.LINES)):dt.setMode(B.TRIANGLES);else if(T.isLine){let Ke=A.linewidth;Ke===void 0&&(Ke=1),Q.setLineWidth(Ke*Re()),T.isLineSegments?dt.setMode(B.LINES):T.isLineLoop?dt.setMode(B.LINE_LOOP):dt.setMode(B.LINE_STRIP)}else T.isPoints?dt.setMode(B.POINTS):T.isSprite&&dt.setMode(B.TRIANGLES);if(T.isBatchedMesh)T._multiDrawInstances!==null?dt.renderMultiDrawInstances(T._multiDrawStarts,T._multiDrawCounts,T._multiDrawCount,T._multiDrawInstances):dt.renderMultiDraw(T._multiDrawStarts,T._multiDrawCounts,T._multiDrawCount);else if(T.isInstancedMesh)dt.renderInstances(bt,dn,T.count);else if(S.isInstancedBufferGeometry){let Ke=S._maxInstanceCount!==void 0?S._maxInstanceCount:1/0,to=Math.min(S.instanceCount,Ke);dt.renderInstances(bt,dn,to)}else dt.render(bt,dn)};function at(C,M,S){C.transparent===!0&&C.side===jn&&C.forceSinglePass===!1?(C.side=on,C.needsUpdate=!0,xt(C,M,S),C.side=wi,C.needsUpdate=!0,xt(C,M,S),C.side=jn):xt(C,M,S)}this.compile=function(C,M,S=null){S===null&&(S=C),g=xe.get(S),g.init(M),v.push(g),S.traverseVisible(function(T){T.isLight&&T.layers.test(M.layers)&&(g.pushLight(T),T.castShadow&&g.pushShadow(T))}),C!==S&&C.traverseVisible(function(T){T.isLight&&T.layers.test(M.layers)&&(g.pushLight(T),T.castShadow&&g.pushShadow(T))}),g.setupLights(x._useLegacyLights);let A=new Set;return C.traverse(function(T){let j=T.material;if(j)if(Array.isArray(j))for(let ie=0;ie<j.length;ie++){let ge=j[ie];at(ge,S,T),A.add(ge)}else at(j,S,T),A.add(j)}),v.pop(),g=null,A},this.compileAsync=function(C,M,S=null){let A=this.compile(C,M,S);return new Promise(T=>{function j(){if(A.forEach(function(ie){K.get(ie).currentProgram.isReady()&&A.delete(ie)}),A.size===0){T(C);return}setTimeout(j,10)}X.get("KHR_parallel_shader_compile")!==null?j():setTimeout(j,10)})};let vt=null;function Et(C){vt&&vt(C)}function ot(){N.stop()}function an(){N.start()}let N=new fv;N.setAnimationLoop(Et),typeof self<"u"&&N.setContext(self),this.setAnimationLoop=function(C){vt=C,je.setAnimationLoop(C),C===null?N.stop():N.start()},je.addEventListener("sessionstart",ot),je.addEventListener("sessionend",an),this.render=function(C,M){if(M!==void 0&&M.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(w===!0)return;C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),M.parent===null&&M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),je.enabled===!0&&je.isPresenting===!0&&(je.cameraAutoUpdate===!0&&je.updateCamera(M),M=je.getCamera()),C.isScene===!0&&C.onBeforeRender(x,C,M,R),g=xe.get(C,v.length),g.init(M),v.push(g),ye.multiplyMatrices(M.projectionMatrix,M.matrixWorldInverse),He.setFromProjectionMatrix(ye),Z=this.localClippingEnabled,q=be.init(this.clippingPlanes,Z),y=Ue.get(C,m.length),y.init(),m.push(y),G(C,M,0,x.sortObjects),y.finish(),x.sortObjects===!0&&y.sort(V,ce);let S=je.enabled===!1||je.isPresenting===!1||je.hasDepthSensing()===!1;S&&pe.addToRenderList(y,C),this.info.render.frame++,q===!0&&be.beginShadows();let A=g.state.shadowsArray;Ve.render(A,C,M),q===!0&&be.endShadows(),this.info.autoReset===!0&&this.info.reset();let T=y.opaque,j=y.transmissive;if(g.setupLights(x._useLegacyLights),M.isArrayCamera){let ie=M.cameras;if(j.length>0)for(let ge=0,Ae=ie.length;ge<Ae;ge++){let Pe=ie[ge];$e(T,j,C,Pe)}S&&pe.render(C);for(let ge=0,Ae=ie.length;ge<Ae;ge++){let Pe=ie[ge];se(y,C,Pe,Pe.viewport)}}else j.length>0&&$e(T,j,C,M),S&&pe.render(C),se(y,C,M);R!==null&&(we.updateMultisampleRenderTarget(R),we.updateRenderTargetMipmap(R)),C.isScene===!0&&C.onAfterRender(x,C,M),Ye.resetDefaultState(),U=-1,_=null,v.pop(),v.length>0?(g=v[v.length-1],q===!0&&be.setGlobalState(x.clippingPlanes,g.state.camera)):g=null,m.pop(),m.length>0?y=m[m.length-1]:y=null};function G(C,M,S,A){if(C.visible===!1)return;if(C.layers.test(M.layers)){if(C.isGroup)S=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(M);else if(C.isLight)g.pushLight(C),C.castShadow&&g.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||He.intersectsSprite(C)){A&&ae.setFromMatrixPosition(C.matrixWorld).applyMatrix4(ye);let ie=te.update(C),ge=C.material;ge.visible&&y.push(C,ie,ge,S,ae.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||He.intersectsObject(C))){let ie=te.update(C),ge=C.material;if(A&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),ae.copy(C.boundingSphere.center)):(ie.boundingSphere===null&&ie.computeBoundingSphere(),ae.copy(ie.boundingSphere.center)),ae.applyMatrix4(C.matrixWorld).applyMatrix4(ye)),Array.isArray(ge)){let Ae=ie.groups;for(let Pe=0,Xe=Ae.length;Pe<Xe;Pe++){let Be=Ae[Pe],bt=ge[Be.materialIndex];bt&&bt.visible&&y.push(C,ie,bt,S,ae.z,Be)}}else ge.visible&&y.push(C,ie,ge,S,ae.z,null)}}let j=C.children;for(let ie=0,ge=j.length;ie<ge;ie++)G(j[ie],M,S,A)}function se(C,M,S,A){let T=C.opaque,j=C.transmissive,ie=C.transparent;g.setupLightsView(S),q===!0&&be.setGlobalState(x.clippingPlanes,S),A&&Q.viewport(b.copy(A)),T.length>0&&We(T,M,S),j.length>0&&We(j,M,S),ie.length>0&&We(ie,M,S),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function $e(C,M,S,A){if((S.isScene===!0?S.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[A.id]===void 0&&(g.state.transmissionRenderTarget[A.id]=new yn(1,1,{generateMipmaps:!0,type:X.has("EXT_color_buffer_half_float")||X.has("EXT_color_buffer_float")?Ua:Si,minFilter:Wn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1}));let j=g.state.transmissionRenderTarget[A.id],ie=A.viewport||b;j.setSize(ie.z,ie.w);let ge=x.getRenderTarget();x.setRenderTarget(j),x.getClearColor(F),$=x.getClearAlpha(),$<1&&x.setClearColor(16777215,.5),x.clear();let Ae=x.toneMapping;x.toneMapping=bi;let Pe=A.viewport;if(A.viewport!==void 0&&(A.viewport=void 0),g.setupLightsView(A),q===!0&&be.setGlobalState(x.clippingPlanes,A),We(C,S,A),we.updateMultisampleRenderTarget(j),we.updateRenderTargetMipmap(j),X.has("WEBGL_multisampled_render_to_texture")===!1){let Xe=!1;for(let Be=0,bt=M.length;Be<bt;Be++){let Xt=M[Be],dn=Xt.object,ii=Xt.geometry,dt=Xt.material,Ke=Xt.group;if(dt.side===jn&&dn.layers.test(A.layers)){let to=dt.side;dt.side=on,dt.needsUpdate=!0,ke(dn,S,A,ii,dt,Ke),dt.side=to,dt.needsUpdate=!0,Xe=!0}}Xe===!0&&(we.updateMultisampleRenderTarget(j),we.updateRenderTargetMipmap(j))}x.setRenderTarget(ge),x.setClearColor(F,$),Pe!==void 0&&(A.viewport=Pe),x.toneMapping=Ae}function We(C,M,S){let A=M.isScene===!0?M.overrideMaterial:null;for(let T=0,j=C.length;T<j;T++){let ie=C[T],ge=ie.object,Ae=ie.geometry,Pe=A===null?ie.material:A,Xe=ie.group;ge.layers.test(S.layers)&&ke(ge,M,S,Ae,Pe,Xe)}}function ke(C,M,S,A,T,j){C.onBeforeRender(x,M,S,A,T,j),C.modelViewMatrix.multiplyMatrices(S.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),T.onBeforeRender(x,M,S,A,C,j),T.transparent===!0&&T.side===jn&&T.forceSinglePass===!1?(T.side=on,T.needsUpdate=!0,x.renderBufferDirect(S,M,A,T,C,j),T.side=wi,T.needsUpdate=!0,x.renderBufferDirect(S,M,A,T,C,j),T.side=jn):x.renderBufferDirect(S,M,A,T,C,j),C.onAfterRender(x,M,S,A,T,j)}function xt(C,M,S){M.isScene!==!0&&(M=Ie);let A=K.get(C),T=g.state.lights,j=g.state.shadowsArray,ie=T.state.version,ge=le.getParameters(C,T.state,j,M,S),Ae=le.getProgramCacheKey(ge),Pe=A.programs;A.environment=C.isMeshStandardMaterial?M.environment:null,A.fog=M.fog,A.envMap=(C.isMeshStandardMaterial?L:De).get(C.envMap||A.environment),A.envMapRotation=A.environment!==null&&C.envMap===null?M.environmentRotation:C.envMapRotation,Pe===void 0&&(C.addEventListener("dispose",de),Pe=new Map,A.programs=Pe);let Xe=Pe.get(Ae);if(Xe!==void 0){if(A.currentProgram===Xe&&A.lightsStateVersion===ie)return Pn(C,ge),Xe}else ge.uniforms=le.getUniforms(C),C.onBuild(S,ge,x),C.onBeforeCompile(ge,x),Xe=le.acquireProgram(ge,Ae),Pe.set(Ae,Xe),A.uniforms=ge.uniforms;let Be=A.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(Be.clippingPlanes=be.uniform),Pn(C,ge),A.needsLights=eo(C),A.lightsStateVersion=ie,A.needsLights&&(Be.ambientLightColor.value=T.state.ambient,Be.lightProbe.value=T.state.probe,Be.directionalLights.value=T.state.directional,Be.directionalLightShadows.value=T.state.directionalShadow,Be.spotLights.value=T.state.spot,Be.spotLightShadows.value=T.state.spotShadow,Be.rectAreaLights.value=T.state.rectArea,Be.ltc_1.value=T.state.rectAreaLTC1,Be.ltc_2.value=T.state.rectAreaLTC2,Be.pointLights.value=T.state.point,Be.pointLightShadows.value=T.state.pointShadow,Be.hemisphereLights.value=T.state.hemi,Be.directionalShadowMap.value=T.state.directionalShadowMap,Be.directionalShadowMatrix.value=T.state.directionalShadowMatrix,Be.spotShadowMap.value=T.state.spotShadowMap,Be.spotLightMatrix.value=T.state.spotLightMatrix,Be.spotLightMap.value=T.state.spotLightMap,Be.pointShadowMap.value=T.state.pointShadowMap,Be.pointShadowMatrix.value=T.state.pointShadowMatrix),A.currentProgram=Xe,A.uniformsList=null,Xe}function Ct(C){if(C.uniformsList===null){let M=C.currentProgram.getUniforms();C.uniformsList=Ds.seqWithValue(M.seq,C.uniforms)}return C.uniformsList}function Pn(C,M){let S=K.get(C);S.outputColorSpace=M.outputColorSpace,S.batching=M.batching,S.instancing=M.instancing,S.instancingColor=M.instancingColor,S.instancingMorph=M.instancingMorph,S.skinning=M.skinning,S.morphTargets=M.morphTargets,S.morphNormals=M.morphNormals,S.morphColors=M.morphColors,S.morphTargetsCount=M.morphTargetsCount,S.numClippingPlanes=M.numClippingPlanes,S.numIntersection=M.numClipIntersection,S.vertexAlphas=M.vertexAlphas,S.vertexTangents=M.vertexTangents,S.toneMapping=M.toneMapping}function or(C,M,S,A,T){M.isScene!==!0&&(M=Ie),we.resetTextureUnits();let j=M.fog,ie=A.isMeshStandardMaterial?M.environment:null,ge=R===null?x.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Ti,Ae=(A.isMeshStandardMaterial?L:De).get(A.envMap||ie),Pe=A.vertexColors===!0&&!!S.attributes.color&&S.attributes.color.itemSize===4,Xe=!!S.attributes.tangent&&(!!A.normalMap||A.anisotropy>0),Be=!!S.morphAttributes.position,bt=!!S.morphAttributes.normal,Xt=!!S.morphAttributes.color,dn=bi;A.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(dn=x.toneMapping);let ii=S.morphAttributes.position||S.morphAttributes.normal||S.morphAttributes.color,dt=ii!==void 0?ii.length:0,Ke=K.get(A),to=g.state.lights;if(q===!0&&(Z===!0||C!==_)){let Mn=C===_&&A.id===U;be.setState(A,C,Mn)}let Mt=!1;A.version===Ke.__version?(Ke.needsLights&&Ke.lightsStateVersion!==to.state.version||Ke.outputColorSpace!==ge||T.isBatchedMesh&&Ke.batching===!1||!T.isBatchedMesh&&Ke.batching===!0||T.isInstancedMesh&&Ke.instancing===!1||!T.isInstancedMesh&&Ke.instancing===!0||T.isSkinnedMesh&&Ke.skinning===!1||!T.isSkinnedMesh&&Ke.skinning===!0||T.isInstancedMesh&&Ke.instancingColor===!0&&T.instanceColor===null||T.isInstancedMesh&&Ke.instancingColor===!1&&T.instanceColor!==null||T.isInstancedMesh&&Ke.instancingMorph===!0&&T.morphTexture===null||T.isInstancedMesh&&Ke.instancingMorph===!1&&T.morphTexture!==null||Ke.envMap!==Ae||A.fog===!0&&Ke.fog!==j||Ke.numClippingPlanes!==void 0&&(Ke.numClippingPlanes!==be.numPlanes||Ke.numIntersection!==be.numIntersection)||Ke.vertexAlphas!==Pe||Ke.vertexTangents!==Xe||Ke.morphTargets!==Be||Ke.morphNormals!==bt||Ke.morphColors!==Xt||Ke.toneMapping!==dn||Ke.morphTargetsCount!==dt)&&(Mt=!0):(Mt=!0,Ke.__version=A.version);let ar=Ke.currentProgram;Mt===!0&&(ar=xt(A,M,T));let jp=!1,no=!1,Yu=!1,Yt=ar.getUniforms(),Pi=Ke.uniforms;if(Q.useProgram(ar.program)&&(jp=!0,no=!0,Yu=!0),A.id!==U&&(U=A.id,no=!0),jp||_!==C){Yt.setValue(B,"projectionMatrix",C.projectionMatrix),Yt.setValue(B,"viewMatrix",C.matrixWorldInverse);let Mn=Yt.map.cameraPosition;Mn!==void 0&&Mn.setValue(B,ae.setFromMatrixPosition(C.matrixWorld)),he.logarithmicDepthBuffer&&Yt.setValue(B,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(A.isMeshPhongMaterial||A.isMeshToonMaterial||A.isMeshLambertMaterial||A.isMeshBasicMaterial||A.isMeshStandardMaterial||A.isShaderMaterial)&&Yt.setValue(B,"isOrthographic",C.isOrthographicCamera===!0),_!==C&&(_=C,no=!0,Yu=!0)}if(T.isSkinnedMesh){Yt.setOptional(B,T,"bindMatrix"),Yt.setOptional(B,T,"bindMatrixInverse");let Mn=T.skeleton;Mn&&(Mn.boneTexture===null&&Mn.computeBoneTexture(),Yt.setValue(B,"boneTexture",Mn.boneTexture,we))}T.isBatchedMesh&&(Yt.setOptional(B,T,"batchingTexture"),Yt.setValue(B,"batchingTexture",T._matricesTexture,we));let qu=S.morphAttributes;if((qu.position!==void 0||qu.normal!==void 0||qu.color!==void 0)&&Oe.update(T,S,ar),(no||Ke.receiveShadow!==T.receiveShadow)&&(Ke.receiveShadow=T.receiveShadow,Yt.setValue(B,"receiveShadow",T.receiveShadow)),A.isMeshGouraudMaterial&&A.envMap!==null&&(Pi.envMap.value=Ae,Pi.flipEnvMap.value=Ae.isCubeTexture&&Ae.isRenderTargetTexture===!1?-1:1),A.isMeshStandardMaterial&&A.envMap===null&&M.environment!==null&&(Pi.envMapIntensity.value=M.environmentIntensity),no&&(Yt.setValue(B,"toneMappingExposure",x.toneMappingExposure),Ke.needsLights&&Qs(Pi,Yu),j&&A.fog===!0&&re.refreshFogUniforms(Pi,j),re.refreshMaterialUniforms(Pi,A,J,ne,g.state.transmissionRenderTarget[C.id]),Ds.upload(B,Ct(Ke),Pi,we)),A.isShaderMaterial&&A.uniformsNeedUpdate===!0&&(Ds.upload(B,Ct(Ke),Pi,we),A.uniformsNeedUpdate=!1),A.isSpriteMaterial&&Yt.setValue(B,"center",T.center),Yt.setValue(B,"modelViewMatrix",T.modelViewMatrix),Yt.setValue(B,"normalMatrix",T.normalMatrix),Yt.setValue(B,"modelMatrix",T.matrixWorld),A.isShaderMaterial||A.isRawShaderMaterial){let Mn=A.uniformsGroups;for(let Zu=0,cx=Mn.length;Zu<cx;Zu++){let Wp=Mn[Zu];nt.update(Wp,ar),nt.bind(Wp,ar)}}return ar}function Qs(C,M){C.ambientLightColor.needsUpdate=M,C.lightProbe.needsUpdate=M,C.directionalLights.needsUpdate=M,C.directionalLightShadows.needsUpdate=M,C.pointLights.needsUpdate=M,C.pointLightShadows.needsUpdate=M,C.spotLights.needsUpdate=M,C.spotLightShadows.needsUpdate=M,C.rectAreaLights.needsUpdate=M,C.hemisphereLights.needsUpdate=M}function eo(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return I},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(C,M,S){K.get(C.texture).__webglTexture=M,K.get(C.depthTexture).__webglTexture=S;let A=K.get(C);A.__hasExternalTextures=!0,A.__autoAllocateDepthBuffer=S===void 0,A.__autoAllocateDepthBuffer||X.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),A.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(C,M){let S=K.get(C);S.__webglFramebuffer=M,S.__useDefaultFramebuffer=M===void 0},this.setRenderTarget=function(C,M=0,S=0){R=C,O=M,I=S;let A=!0,T=null,j=!1,ie=!1;if(C){let Ae=K.get(C);Ae.__useDefaultFramebuffer!==void 0?(Q.bindFramebuffer(B.FRAMEBUFFER,null),A=!1):Ae.__webglFramebuffer===void 0?we.setupRenderTarget(C):Ae.__hasExternalTextures&&we.rebindTextures(C,K.get(C.texture).__webglTexture,K.get(C.depthTexture).__webglTexture);let Pe=C.texture;(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)&&(ie=!0);let Xe=K.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(Xe[M])?T=Xe[M][S]:T=Xe[M],j=!0):C.samples>0&&we.useMultisampledRTT(C)===!1?T=K.get(C).__webglMultisampledFramebuffer:Array.isArray(Xe)?T=Xe[S]:T=Xe,b.copy(C.viewport),D.copy(C.scissor),z=C.scissorTest}else b.copy(fe).multiplyScalar(J).floor(),D.copy(Te).multiplyScalar(J).floor(),z=ve;if(Q.bindFramebuffer(B.FRAMEBUFFER,T)&&A&&Q.drawBuffers(C,T),Q.viewport(b),Q.scissor(D),Q.setScissorTest(z),j){let Ae=K.get(C.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+M,Ae.__webglTexture,S)}else if(ie){let Ae=K.get(C.texture),Pe=M||0;B.framebufferTextureLayer(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,Ae.__webglTexture,S||0,Pe)}U=-1},this.readRenderTargetPixels=function(C,M,S,A,T,j,ie){if(!(C&&C.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=K.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&ie!==void 0&&(ge=ge[ie]),ge){Q.bindFramebuffer(B.FRAMEBUFFER,ge);try{let Ae=C.texture,Pe=Ae.format,Xe=Ae.type;if(!he.textureFormatReadable(Pe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!he.textureTypeReadable(Xe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}M>=0&&M<=C.width-A&&S>=0&&S<=C.height-T&&B.readPixels(M,S,A,T,Me.convert(Pe),Me.convert(Xe),j)}finally{let Ae=R!==null?K.get(R).__webglFramebuffer:null;Q.bindFramebuffer(B.FRAMEBUFFER,Ae)}}},this.copyFramebufferToTexture=function(C,M,S=0){let A=Math.pow(2,-S),T=Math.floor(M.image.width*A),j=Math.floor(M.image.height*A);we.setTexture2D(M,0),B.copyTexSubImage2D(B.TEXTURE_2D,S,0,0,C.x,C.y,T,j),Q.unbindTexture()},this.copyTextureToTexture=function(C,M,S,A=0){let T=M.image.width,j=M.image.height,ie=Me.convert(S.format),ge=Me.convert(S.type);we.setTexture2D(S,0),B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,S.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,S.unpackAlignment),M.isDataTexture?B.texSubImage2D(B.TEXTURE_2D,A,C.x,C.y,T,j,ie,ge,M.image.data):M.isCompressedTexture?B.compressedTexSubImage2D(B.TEXTURE_2D,A,C.x,C.y,M.mipmaps[0].width,M.mipmaps[0].height,ie,M.mipmaps[0].data):B.texSubImage2D(B.TEXTURE_2D,A,C.x,C.y,ie,ge,M.image),A===0&&S.generateMipmaps&&B.generateMipmap(B.TEXTURE_2D),Q.unbindTexture()},this.copyTextureToTexture3D=function(C,M,S,A,T=0){let j=C.max.x-C.min.x,ie=C.max.y-C.min.y,ge=C.max.z-C.min.z,Ae=Me.convert(A.format),Pe=Me.convert(A.type),Xe;if(A.isData3DTexture)we.setTexture3D(A,0),Xe=B.TEXTURE_3D;else if(A.isDataArrayTexture||A.isCompressedArrayTexture)we.setTexture2DArray(A,0),Xe=B.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,A.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,A.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,A.unpackAlignment);let Be=B.getParameter(B.UNPACK_ROW_LENGTH),bt=B.getParameter(B.UNPACK_IMAGE_HEIGHT),Xt=B.getParameter(B.UNPACK_SKIP_PIXELS),dn=B.getParameter(B.UNPACK_SKIP_ROWS),ii=B.getParameter(B.UNPACK_SKIP_IMAGES),dt=S.isCompressedTexture?S.mipmaps[T]:S.image;B.pixelStorei(B.UNPACK_ROW_LENGTH,dt.width),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,dt.height),B.pixelStorei(B.UNPACK_SKIP_PIXELS,C.min.x),B.pixelStorei(B.UNPACK_SKIP_ROWS,C.min.y),B.pixelStorei(B.UNPACK_SKIP_IMAGES,C.min.z),S.isDataTexture||S.isData3DTexture?B.texSubImage3D(Xe,T,M.x,M.y,M.z,j,ie,ge,Ae,Pe,dt.data):A.isCompressedArrayTexture?B.compressedTexSubImage3D(Xe,T,M.x,M.y,M.z,j,ie,ge,Ae,dt.data):B.texSubImage3D(Xe,T,M.x,M.y,M.z,j,ie,ge,Ae,Pe,dt),B.pixelStorei(B.UNPACK_ROW_LENGTH,Be),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,bt),B.pixelStorei(B.UNPACK_SKIP_PIXELS,Xt),B.pixelStorei(B.UNPACK_SKIP_ROWS,dn),B.pixelStorei(B.UNPACK_SKIP_IMAGES,ii),T===0&&A.generateMipmaps&&B.generateMipmap(Xe),Q.unbindTexture()},this.initTexture=function(C){C.isCubeTexture?we.setTextureCube(C,0):C.isData3DTexture?we.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?we.setTexture2DArray(C,0):we.setTexture2D(C,0),Q.unbindTexture()},this.resetState=function(){O=0,I=0,R=null,Q.reset(),Ye.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Xn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===Fu?"display-p3":"srgb",t.unpackColorSpace=mt.workingColorSpace===Na?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},Cl=class n{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ce(e),this.density=t}clone(){return new n(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},Rl=class n{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ce(e),this.near=t,this.far=i}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Pl=class extends ht{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new vn,this.environmentIntensity=1,this.environmentRotation=new vn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},$s=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ia,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=gn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return lv("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=gn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=gn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},nn=new P,Fr=class n{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)nn.fromBufferAttribute(this,t),nn.applyMatrix4(e),this.setXYZ(t,nn.x,nn.y,nn.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)nn.fromBufferAttribute(this,t),nn.applyNormalMatrix(e),this.setXYZ(t,nn.x,nn.y,nn.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)nn.fromBufferAttribute(this,t),nn.transformDirection(e),this.setXYZ(t,nn.x,nn.y,nn.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=sn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=et(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=sn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=sn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=sn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=sn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=et(t,this.array),i=et(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=et(t,this.array),i=et(i,this.array),r=et(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=et(t,this.array),i=et(i,this.array),r=et(r,this.array),s=et(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new ut(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new n(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},fa=class extends $t{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ce(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Po=new P,Ms=new P,Ss=new P,Es=new oe,Lo=new oe,bv=new ze,jc=new P,Do=new P,Wc=new P,u0=new oe,ah=new oe,d0=new oe,Ll=class extends ht{constructor(e=new fa){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new it;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new $s(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new Fr(i,3,0,!1)),ws.setAttribute("uv",new Fr(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new oe(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ms.setFromMatrixScale(this.matrixWorld),bv.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ss.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ms.multiplyScalar(-Ss.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;Xc(jc.set(-.5,-.5,0),Ss,o,Ms,r,s),Xc(Do.set(.5,-.5,0),Ss,o,Ms,r,s),Xc(Wc.set(.5,.5,0),Ss,o,Ms,r,s),u0.set(0,0),ah.set(1,0),d0.set(1,1);let a=e.ray.intersectTriangle(jc,Do,Wc,!1,Po);if(a===null&&(Xc(Do.set(-.5,.5,0),Ss,o,Ms,r,s),ah.set(0,1),a=e.ray.intersectTriangle(jc,Wc,Do,!1,Po),a===null))return;let c=e.ray.origin.distanceTo(Po);c<e.near||c>e.far||t.push({distance:c,point:Po.clone(),uv:yi.getInterpolation(Po,jc,Do,Wc,u0,ah,d0,new oe),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};Yc=new P,h0=new P,Dl=class extends ht{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let i=0,r=t.length;i<r;i++){let s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);let r=this.levels,s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Yc.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(Yc);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Yc.setFromMatrixPosition(e.matrixWorld),h0.setFromMatrixPosition(this.matrixWorld);let i=Yc.distanceTo(h0)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),i>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let i=this.levels;for(let r=0,s=i.length;r<s;r++){let o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}},f0=new P,p0=new gt,m0=new gt,dI=new P,g0=new ze,qc=new P,ch=new Vt,y0=new ze,lh=new qi,Ol=class extends It{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Eh,this.bindMatrix=new ze,this.bindMatrixInverse=new ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Gt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,qc),this.boundingBox.expandByPoint(qc)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Vt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,qc),this.boundingSphere.expandByPoint(qc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ch.copy(this.boundingSphere),ch.applyMatrix4(r),e.ray.intersectsSphere(ch)!==!1&&(y0.copy(r).invert(),lh.copy(e.ray).applyMatrix4(y0),!(this.boundingBox!==null&&lh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,lh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new gt,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Eh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===ky?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;p0.fromBufferAttribute(r.attributes.skinIndex,e),m0.fromBufferAttribute(r.attributes.skinWeight,e),f0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=m0.getComponent(s);if(o!==0){let a=p0.getComponent(s);g0.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(dI.copy(f0).applyMatrix4(g0),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},pa=class extends ht{constructor(){super(),this.isBone=!0,this.type="Bone"}},Yn=class extends Dt{constructor(e=null,t=1,i=1,r,s,o,a,c,l=zt,u=zt,d,h){super(null,o,a,c,l,u,r,s,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},v0=new ze,hI=new ze,Ul=class n{constructor(e=[],t=[]){this.uuid=gn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new ze)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new ze;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:hI;v0.multiplyMatrices(a,t[s]),v0.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Yn(t,e,e,mn,Cn);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new pa),this.bones.push(o),this.boneInverses.push(new ze().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let o=t[r];e.bones.push(o.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},Zi=class extends ut{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},As=new ze,x0=new ze,Zc=[],b0=new Gt,fI=new ze,Oo=new It,Uo=new Vt,Nl=class extends It{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Zi(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,fI)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Gt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,As),b0.copy(e.boundingBox).applyMatrix4(As),this.boundingBox.union(b0)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Vt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,As),Uo.copy(e.boundingSphere).applyMatrix4(As),this.boundingSphere.union(Uo)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,o=e*s+1;for(let a=0;a<i.length;a++)i[a]=r[o+a]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(Oo.geometry=this.geometry,Oo.material=this.material,Oo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Uo.copy(this.boundingSphere),Uo.applyMatrix4(i),e.ray.intersectsSphere(Uo)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,As),x0.multiplyMatrices(i,As),Oo.matrixWorld=x0,Oo.raycast(e,Zc);for(let o=0,a=Zc.length;o<a;o++){let c=Zc[o];c.instanceId=s,c.object=this,t.push(c)}Zc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Zi(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Yn(new Float32Array(r*this.count),r,this.count,Sp,Cn));let s=this.morphTexture.source.data.data,o=0;for(let l=0;l<i.length;l++)o+=i[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=r*e;s[c]=a,s.set(i,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};vf=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){let i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});let s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}},Ts="batchId",Gi=new ze,_0=new ze,gI=new ze,w0=new ze,uh=new Nr,Jc=new Gt,vr=new Vt,No=new P,dh=new vf,Kt=new It,Kc=[];Fl=class extends It{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,r){super(new it,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),i=new Yn(t,e,e,mn,Cn);this._matricesTexture=i}_initializeGeometry(e){let t=this.geometry,i=this._maxVertexCount,r=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(let a in e.attributes){let c=e.getAttribute(a),{array:l,itemSize:u,normalized:d}=c,h=new l.constructor(i*u),f=new ut(h,u,d);t.setAttribute(a,f)}if(e.getIndex()!==null){let a=i>65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new ut(a,1))}let o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(Ts,new ut(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Ts))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Ts}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let i in t.attributes){if(i===Ts)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gt);let e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,Gi),this.getBoundingBoxAt(r,Jc).applyMatrix4(Gi),t.union(Jc))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Vt);let e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,Gi),this.getBoundingSphereAt(r,vr).applyMatrix4(Gi),t.union(vr))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},s=null,o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;let l=e.getIndex(),u=l!==null;if(u&&(i===-1?r.indexCount=l.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let d=this._visibility,h=this._active,f=this._matricesTexture,p=this._matricesTexture.image.data;d.push(!0),h.push(!0);let y=this._geometryCount;this._geometryCount++,gI.toArray(p,y*16),f.needsUpdate=!0,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new Gt,sphereInitialized:!1,sphere:new Vt});let g=this.geometry.getAttribute(Ts);for(let m=0;m<r.vertexCount;m++)g.setX(r.vertexStart+m,y);return g.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.vertexCount;for(let f in i.attributes){if(f===Ts)continue;let p=t.getAttribute(f),y=i.getAttribute(f);yI(p,y,c);let g=p.itemSize;for(let m=p.count,v=l;m<v;m++){let x=c+m;for(let w=0;w<g;w++)y.setComponent(x,w,0)}y.needsUpdate=!0,y.addUpdateRange(c*g,l*g)}if(r){let f=a.indexStart;for(let p=0;p<o.count;p++)s.setX(f+p,c+o.getX(p));for(let p=o.count,y=a.indexCount;p<y;p++)s.setX(f+p,c);s.needsUpdate=!0,s.addUpdateRange(f,a.indexCount)}let u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;let d=this._drawRanges[e],h=t.getAttribute("position");return d.count=r?o.count:h.count,this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.box,o=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();let a=o.index,c=o.attributes.position,l=this._drawRanges[e];for(let u=l.start,d=l.start+l.count;u<d;u++){let h=u;a&&(h=a.getX(h)),s.expandByPoint(No.fromBufferAttribute(c,h))}r.boxInitialized=!0}return t.copy(s),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.sphere,o=this.geometry;if(r.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,Jc),Jc.getCenter(s.center);let a=o.index,c=o.attributes.position,l=this._drawRanges[e],u=0;for(let d=l.start,h=l.start+l.count;d<h;d++){let f=d;a&&(f=a.getX(f)),No.fromBufferAttribute(c,f),u=Math.max(u,s.center.distanceToSquared(No))}s.radius=Math.sqrt(u),r.sphereInitialized=!0}return t.copy(s),t}setMatrixAt(e,t){let i=this._active,r=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){let i=this._visibility,r=this._active,s=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,c=this.geometry;Kt.material=this.material,Kt.geometry.index=c.index,Kt.geometry.attributes=c.attributes,Kt.geometry.boundingBox===null&&(Kt.geometry.boundingBox=new Gt),Kt.geometry.boundingSphere===null&&(Kt.geometry.boundingSphere=new Vt);for(let l=0;l<o;l++){if(!i[l]||!r[l])continue;let u=s[l];Kt.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(l,Kt.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,Kt.geometry.boundingBox),this.getBoundingSphereAt(l,Kt.geometry.boundingSphere),Kt.raycast(e,Kc);for(let d=0,h=Kc.length;d<h;d++){let f=Kc[d];f.object=this,f.batchId=l,t.push(f)}Kc.length=0}Kt.material=null,Kt.geometry.index=null,Kt.geometry.attributes={},Kt.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._active,l=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,h=this._drawRanges,f=this.perObjectFrustumCulled;f&&(w0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),uh.setFromProjectionMatrix(w0,e.coordinateSystem));let p=0;if(this.sortObjects){_0.copy(this.matrixWorld).invert(),No.setFromMatrixPosition(i.matrixWorld).applyMatrix4(_0);for(let m=0,v=l.length;m<v;m++)if(l[m]&&c[m]){this.getMatrixAt(m,Gi),this.getBoundingSphereAt(m,vr).applyMatrix4(Gi);let x=!1;if(f&&(x=!uh.intersectsSphere(vr)),!x){let w=No.distanceTo(vr.center);dh.push(h[m],w)}}let y=dh.list,g=this.customSort;g===null?y.sort(s.transparent?mI:pI):g.call(this,y,i);for(let m=0,v=y.length;m<v;m++){let x=y[m];u[p]=x.start*a,d[p]=x.count,p++}dh.reset()}else for(let y=0,g=l.length;y<g;y++)if(l[y]&&c[y]){let m=!1;if(f&&(this.getMatrixAt(y,Gi),this.getBoundingSphereAt(y,vr).applyMatrix4(Gi),m=!uh.intersectsSphere(vr)),!m){let v=h[y];u[p]=v.start*a,d[p]=v.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}},jt=class extends $t{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ce(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},kl=new P,Bl=new P,M0=new ze,Fo=new qi,Qc=new Vt,hh=new P,S0=new P,Jn=class extends ht{constructor(e=new it,t=new jt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)kl.fromBufferAttribute(t,r-1),Bl.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=kl.distanceTo(Bl);e.setAttribute("lineDistance",new Le(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Qc.copy(i.boundingSphere),Qc.applyMatrix4(r),Qc.radius+=s,e.ray.intersectsSphere(Qc)===!1)return;M0.copy(r).invert(),Fo.copy(e.ray).applyMatrix4(M0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){let f=Math.max(0,o.start),p=Math.min(u.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=l){let m=u.getX(y),v=u.getX(y+1),x=el(this,e,Fo,c,m,v);x&&t.push(x)}if(this.isLineLoop){let y=u.getX(p-1),g=u.getX(f),m=el(this,e,Fo,c,y,g);m&&t.push(m)}}else{let f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=l){let m=el(this,e,Fo,c,y,y+1);m&&t.push(m)}if(this.isLineLoop){let y=el(this,e,Fo,c,p-1,f);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};E0=new P,A0=new P,Rn=class extends Jn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)E0.fromBufferAttribute(t,r),A0.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+E0.distanceTo(A0);e.setAttribute("lineDistance",new Le(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},zl=class extends Jn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},ma=class extends $t{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ce(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},T0=new ze,xf=new qi,tl=new Vt,nl=new P,Vl=class extends ht{constructor(e=new it,t=new ma){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),tl.copy(i.boundingSphere),tl.applyMatrix4(r),tl.radius+=s,e.ray.intersectsSphere(tl)===!1)return;T0.copy(r).invert(),xf.copy(e.ray).applyMatrix4(T0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=i.index,d=i.attributes.position;if(l!==null){let h=Math.max(0,o.start),f=Math.min(l.count,o.start+o.count);for(let p=h,y=f;p<y;p++){let g=l.getX(p);nl.fromBufferAttribute(d,g),I0(nl,g,c,r,e,t,this)}}else{let h=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let p=h,y=f;p<y;p++)nl.fromBufferAttribute(d,p),I0(nl,p,c,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};bf=class extends Dt{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Lt,this.magFilter=s!==void 0?s:Lt,this.generateMipmaps=!1;let u=this;function d(){u.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},_f=class extends Dt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=zt,this.minFilter=zt,this.generateMipmaps=!1,this.needsUpdate=!0}},Hs=class extends Dt{constructor(e,t,i,r,s,o,a,c,l,u,d,h){super(null,o,a,c,l,u,r,s,d,h),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},wf=class extends Hs{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=In}},Mf=class extends Hs{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Mi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Sf=class extends Dt{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},bn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,o;t?o=t:o=e*i[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=i[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,i[r]===o)return r/(s-1);let u=i[r],h=i[r+1]-u,f=(o-u)/h;return(r+f)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new oe:new P);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new P,r=[],s=[],o=[],a=new P,c=new ze;for(let f=0;f<=e;f++){let p=f/e;r[f]=this.getTangentAt(p,new P)}s[0]=new P,o[0]=new P;let l=Number.MAX_VALUE,u=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=l&&(l=u,i.set(1,0,0)),d<=l&&(l=d,i.set(0,1,0)),h<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Tt(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(c.makeRotationAxis(a,p))}o[f].crossVectors(r[f],s[f])}if(t===!0){let f=Math.acos(Tt(s[0].dot(s[e]),-1,1));f/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let p=1;p<=e;p++)s[p].applyMatrix4(c.makeRotationAxis(r[p],f*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Gs=class extends bn{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new oe){let i=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=c-this.aX,f=l-this.aY;c=h*u-f*d+this.aX,l=h*d+f*u+this.aY}return i.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},$l=class extends Gs{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};il=new P,fh=new Lp,ph=new Lp,mh=new Lp,Hl=class extends bn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new P){let i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(il.subVectors(r[0],r[1]).add(r[0]),l=il);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(il.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=il),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(d),f),y=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(u),f);y<1e-4&&(y=1),p<1e-4&&(p=y),g<1e-4&&(g=y),fh.initNonuniformCatmullRom(l.x,d.x,h.x,u.x,p,y,g),ph.initNonuniformCatmullRom(l.y,d.y,h.y,u.y,p,y,g),mh.initNonuniformCatmullRom(l.z,d.z,h.z,u.z,p,y,g)}else this.curveType==="catmullrom"&&(fh.initCatmullRom(l.x,d.x,h.x,u.x,this.tension),ph.initCatmullRom(l.y,d.y,h.y,u.y,this.tension),mh.initCatmullRom(l.z,d.z,h.z,u.z,this.tension));return i.set(fh.calc(c),ph.calc(c),mh.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new P().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};ga=class extends bn{constructor(e=new oe,t=new oe,i=new oe,r=new oe){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new oe){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(jo(e,r.x,s.x,o.x,a.x),jo(e,r.y,s.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Gl=class extends bn{constructor(e=new P,t=new P,i=new P,r=new P){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new P){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(jo(e,r.x,s.x,o.x,a.x),jo(e,r.y,s.y,o.y,a.y),jo(e,r.z,s.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ya=class extends bn{constructor(e=new oe,t=new oe){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new oe){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new oe){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},jl=class extends bn{constructor(e=new P,t=new P){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new P){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new P){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},va=class extends bn{constructor(e=new oe,t=new oe,i=new oe){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new oe){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Go(e,r.x,s.x,o.x),Go(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},xa=class extends bn{constructor(e=new P,t=new P,i=new P){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new P){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Go(e,r.x,s.x,o.x),Go(e,r.y,s.y,o.y),Go(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ba=class extends bn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new oe){let i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return i.set(C0(a,c.x,l.x,u.x,d.x),C0(a,c.y,l.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new oe().fromArray(r))}return this}},Wl=Object.freeze({__proto__:null,ArcCurve:$l,CatmullRomCurve3:Hl,CubicBezierCurve:ga,CubicBezierCurve3:Gl,EllipseCurve:Gs,LineCurve:ya,LineCurve3:jl,QuadraticBezierCurve:va,QuadraticBezierCurve3:xa,SplineCurve:ba}),Xl=class extends bn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Wl[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let o=r[s]-i,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new Wl[r.type]().fromJSON(r))}return this}},kr=class extends Xl{constructor(e){super(),this.type="Path",this.currentPoint=new oe,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new ya(this.currentPoint.clone(),new oe(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new va(this.currentPoint.clone(),new oe(e,t),new oe(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){let a=new ga(this.currentPoint.clone(),new oe(e,t),new oe(i,r),new oe(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new ba(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,i,r,s,o,a,c),this}absellipse(e,t,i,r,s,o,a,c){let l=new Gs(e,t,i,r,s,o,a,c);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},_a=class n extends it{constructor(e=[new oe(0,-.5),new oe(.5,0),new oe(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Tt(r,0,Math.PI*2);let s=[],o=[],a=[],c=[],l=[],u=1/t,d=new P,h=new oe,f=new P,p=new P,y=new P,g=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,f.x=m*1,f.y=-g,f.z=m*0,y.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case e.length-1:c.push(y.x,y.y,y.z);break;default:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,f.x=m*1,f.y=-g,f.z=m*0,p.copy(f),f.x+=y.x,f.y+=y.y,f.z+=y.z,f.normalize(),c.push(f.x,f.y,f.z),y.copy(p)}for(let v=0;v<=t;v++){let x=i+v*u*r,w=Math.sin(x),O=Math.cos(x);for(let I=0;I<=e.length-1;I++){d.x=e[I].x*w,d.y=e[I].y,d.z=e[I].x*O,o.push(d.x,d.y,d.z),h.x=v/t,h.y=I/(e.length-1),a.push(h.x,h.y);let R=c[3*I+0]*w,U=c[3*I+1],_=c[3*I+0]*O;l.push(R,U,_)}}for(let v=0;v<t;v++)for(let x=0;x<e.length-1;x++){let w=x+v*e.length,O=w,I=w+e.length,R=w+e.length+1,U=w+1;s.push(O,I,U),s.push(R,U,I)}this.setIndex(s),this.setAttribute("position",new Le(o,3)),this.setAttribute("uv",new Le(a,2)),this.setAttribute("normal",new Le(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.points,e.segments,e.phiStart,e.phiLength)}},Yl=class n extends _a{constructor(e=1,t=1,i=4,r=8){let s=new kr;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new n(e.radius,e.length,e.capSegments,e.radialSegments)}},ql=class n extends it{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let s=[],o=[],a=[],c=[],l=new P,u=new oe;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let d=0,h=3;d<=t;d++,h+=3){let f=i+d/t*r;l.x=e*Math.cos(f),l.y=e*Math.sin(f),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[h]/e+1)/2,u.y=(o[h+1]/e+1)/2,c.push(u.x,u.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new Le(o,3)),this.setAttribute("normal",new Le(a,3)),this.setAttribute("uv",new Le(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},js=class n extends it{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};let l=this;r=Math.floor(r),s=Math.floor(s);let u=[],d=[],h=[],f=[],p=0,y=[],g=i/2,m=0;v(),o===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new Le(d,3)),this.setAttribute("normal",new Le(h,3)),this.setAttribute("uv",new Le(f,2));function v(){let w=new P,O=new P,I=0,R=(t-e)/i;for(let U=0;U<=s;U++){let _=[],b=U/s,D=b*(t-e)+e;for(let z=0;z<=r;z++){let F=z/r,$=F*c+a,W=Math.sin($),ne=Math.cos($);O.x=D*W,O.y=-b*i+g,O.z=D*ne,d.push(O.x,O.y,O.z),w.set(W,R,ne).normalize(),h.push(w.x,w.y,w.z),f.push(F,1-b),_.push(p++)}y.push(_)}for(let U=0;U<r;U++)for(let _=0;_<s;_++){let b=y[_][U],D=y[_+1][U],z=y[_+1][U+1],F=y[_][U+1];u.push(b,D,F),u.push(D,z,F),I+=6}l.addGroup(m,I,0),m+=I}function x(w){let O=p,I=new oe,R=new P,U=0,_=w===!0?e:t,b=w===!0?1:-1;for(let z=1;z<=r;z++)d.push(0,g*b,0),h.push(0,b,0),f.push(.5,.5),p++;let D=p;for(let z=0;z<=r;z++){let $=z/r*c+a,W=Math.cos($),ne=Math.sin($);R.x=_*ne,R.y=g*b,R.z=_*W,d.push(R.x,R.y,R.z),h.push(0,b,0),I.x=W*.5+.5,I.y=ne*.5*b+.5,f.push(I.x,I.y),p++}for(let z=0;z<r;z++){let F=O+z,$=D+z;w===!0?u.push($,$+1,F):u.push($+1,$,F),U+=3}l.addGroup(m,U,w===!0?1:2),m+=U}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Zl=class n extends js{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new n(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ji=class n extends it{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],o=[];a(r),l(i),u(),this.setAttribute("position",new Le(s,3)),this.setAttribute("normal",new Le(s.slice(),3)),this.setAttribute("uv",new Le(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new P,w=new P,O=new P;for(let I=0;I<t.length;I+=3)f(t[I+0],x),f(t[I+1],w),f(t[I+2],O),c(x,w,O,v)}function c(v,x,w,O){let I=O+1,R=[];for(let U=0;U<=I;U++){R[U]=[];let _=v.clone().lerp(w,U/I),b=x.clone().lerp(w,U/I),D=I-U;for(let z=0;z<=D;z++)z===0&&U===I?R[U][z]=_:R[U][z]=_.clone().lerp(b,z/D)}for(let U=0;U<I;U++)for(let _=0;_<2*(I-U)-1;_++){let b=Math.floor(_/2);_%2===0?(h(R[U][b+1]),h(R[U+1][b]),h(R[U][b])):(h(R[U][b+1]),h(R[U+1][b+1]),h(R[U+1][b]))}}function l(v){let x=new P;for(let w=0;w<s.length;w+=3)x.x=s[w+0],x.y=s[w+1],x.z=s[w+2],x.normalize().multiplyScalar(v),s[w+0]=x.x,s[w+1]=x.y,s[w+2]=x.z}function u(){let v=new P;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let w=g(v)/2/Math.PI+.5,O=m(v)/Math.PI+.5;o.push(w,1-O)}p(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],w=o[v+2],O=o[v+4],I=Math.max(x,w,O),R=Math.min(x,w,O);I>.9&&R<.1&&(x<.2&&(o[v+0]+=1),w<.2&&(o[v+2]+=1),O<.2&&(o[v+4]+=1))}}function h(v){s.push(v.x,v.y,v.z)}function f(v,x){let w=v*3;x.x=e[w+0],x.y=e[w+1],x.z=e[w+2]}function p(){let v=new P,x=new P,w=new P,O=new P,I=new oe,R=new oe,U=new oe;for(let _=0,b=0;_<s.length;_+=9,b+=6){v.set(s[_+0],s[_+1],s[_+2]),x.set(s[_+3],s[_+4],s[_+5]),w.set(s[_+6],s[_+7],s[_+8]),I.set(o[b+0],o[b+1]),R.set(o[b+2],o[b+3]),U.set(o[b+4],o[b+5]),O.copy(v).add(x).add(w).divideScalar(3);let D=g(O);y(I,b+0,v,D),y(R,b+2,x,D),y(U,b+4,w,D)}}function y(v,x,w,O){O<0&&v.x===1&&(o[x]=v.x-1),w.x===0&&w.z===0&&(o[x]=O/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.vertices,e.indices,e.radius,e.details)}},Jl=class n extends Ji{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},rl=new P,sl=new P,gh=new P,ol=new yi,Kl=class extends it{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(Lr*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],d=new Array(3),h={},f=[];for(let p=0;p<c;p+=3){o?(l[0]=o.getX(p),l[1]=o.getX(p+1),l[2]=o.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);let{a:y,b:g,c:m}=ol;if(y.fromBufferAttribute(a,l[0]),g.fromBufferAttribute(a,l[1]),m.fromBufferAttribute(a,l[2]),ol.getNormal(gh),d[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,d[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,d[2]=`${Math.round(m.x*r)},${Math.round(m.y*r)},${Math.round(m.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let v=0;v<3;v++){let x=(v+1)%3,w=d[v],O=d[x],I=ol[u[v]],R=ol[u[x]],U=`${w}_${O}`,_=`${O}_${w}`;_ in h&&h[_]?(gh.dot(h[_].normal)<=s&&(f.push(I.x,I.y,I.z),f.push(R.x,R.y,R.z)),h[_]=null):U in h||(h[U]={index0:l[v],index1:l[x],normal:gh.clone()})}}for(let p in h)if(h[p]){let{index0:y,index1:g}=h[p];rl.fromBufferAttribute(a,y),sl.fromBufferAttribute(a,g),f.push(rl.x,rl.y,rl.z),f.push(sl.x,sl.y,sl.z)}this.setAttribute("position",new Le(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},_i=class extends kr{constructor(e){super(e),this.uuid=gn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new kr().fromJSON(r))}return this}},EI={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=_v(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,d,h,f;if(i&&(s=RI(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(let p=t;p<r;p+=t)d=n[p],h=n[p+1],d<a&&(a=d),h<c&&(c=h),d>l&&(l=d),h>u&&(u=h);f=Math.max(l-a,u-c),f=f!==0?32767/f:0}return wa(s,o,t,a,c,f,0),o}};qn=class n{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];P0(e),L0(i,e);let o=e.length;t.forEach(P0);for(let c=0;c<t.length;c++)r.push(o),o+=t[c].length,L0(i,t[c]);let a=EI.triangulate(i,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}};Ql=class n extends it{constructor(e=new _i([new oe(.5,.5),new oe(-.5,.5),new oe(-.5,-.5),new oe(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,r=[],s=[];for(let a=0,c=e.length;a<c;a++){let l=e[a];o(l)}this.setAttribute("position",new Le(r,3)),this.setAttribute("uv",new Le(s,2)),this.computeVertexNormals();function o(a){let c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1,h=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:f-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3,m=t.extrudePath,v=t.UVGenerator!==void 0?t.UVGenerator:$I,x,w=!1,O,I,R,U;m&&(x=m.getSpacedPoints(u),w=!0,h=!1,O=m.computeFrenetFrames(u,!1),I=new P,R=new P,U=new P),h||(g=0,f=0,p=0,y=0);let _=a.extractPoints(l),b=_.shape,D=_.holes;if(!qn.isClockWise(b)){b=b.reverse();for(let X=0,he=D.length;X<he;X++){let Q=D[X];qn.isClockWise(Q)&&(D[X]=Q.reverse())}}let F=qn.triangulateShape(b,D),$=b;for(let X=0,he=D.length;X<he;X++){let Q=D[X];b=b.concat(Q)}function W(X,he,Q){return he||console.error("THREE.ExtrudeGeometry: vec does not exist"),X.clone().addScaledVector(he,Q)}let ne=b.length,J=F.length;function V(X,he,Q){let me,K,we,De=X.x-he.x,L=X.y-he.y,E=Q.x-X.x,H=Q.y-X.y,te=De*De+L*L,le=De*H-L*E;if(Math.abs(le)>Number.EPSILON){let re=Math.sqrt(te),Ue=Math.sqrt(E*E+H*H),xe=he.x-L/re,be=he.y+De/re,Ve=Q.x-H/Ue,pe=Q.y+E/Ue,Oe=((Ve-xe)*H-(pe-be)*E)/(De*H-L*E);me=xe+De*Oe-X.x,K=be+L*Oe-X.y;let Ge=me*me+K*K;if(Ge<=2)return new oe(me,K);we=Math.sqrt(Ge/2)}else{let re=!1;De>Number.EPSILON?E>Number.EPSILON&&(re=!0):De<-Number.EPSILON?E<-Number.EPSILON&&(re=!0):Math.sign(L)===Math.sign(H)&&(re=!0),re?(me=-L,K=De,we=Math.sqrt(te)):(me=De,K=L,we=Math.sqrt(te/2))}return new oe(me/we,K/we)}let ce=[];for(let X=0,he=$.length,Q=he-1,me=X+1;X<he;X++,Q++,me++)Q===he&&(Q=0),me===he&&(me=0),ce[X]=V($[X],$[Q],$[me]);let fe=[],Te,ve=ce.concat();for(let X=0,he=D.length;X<he;X++){let Q=D[X];Te=[];for(let me=0,K=Q.length,we=K-1,De=me+1;me<K;me++,we++,De++)we===K&&(we=0),De===K&&(De=0),Te[me]=V(Q[me],Q[we],Q[De]);fe.push(Te),ve=ve.concat(Te)}for(let X=0;X<g;X++){let he=X/g,Q=f*Math.cos(he*Math.PI/2),me=p*Math.sin(he*Math.PI/2)+y;for(let K=0,we=$.length;K<we;K++){let De=W($[K],ce[K],me);ae(De.x,De.y,-Q)}for(let K=0,we=D.length;K<we;K++){let De=D[K];Te=fe[K];for(let L=0,E=De.length;L<E;L++){let H=W(De[L],Te[L],me);ae(H.x,H.y,-Q)}}}let He=p+y;for(let X=0;X<ne;X++){let he=h?W(b[X],ve[X],He):b[X];w?(R.copy(O.normals[0]).multiplyScalar(he.x),I.copy(O.binormals[0]).multiplyScalar(he.y),U.copy(x[0]).add(R).add(I),ae(U.x,U.y,U.z)):ae(he.x,he.y,0)}for(let X=1;X<=u;X++)for(let he=0;he<ne;he++){let Q=h?W(b[he],ve[he],He):b[he];w?(R.copy(O.normals[X]).multiplyScalar(Q.x),I.copy(O.binormals[X]).multiplyScalar(Q.y),U.copy(x[X]).add(R).add(I),ae(U.x,U.y,U.z)):ae(Q.x,Q.y,d/u*X)}for(let X=g-1;X>=0;X--){let he=X/g,Q=f*Math.cos(he*Math.PI/2),me=p*Math.sin(he*Math.PI/2)+y;for(let K=0,we=$.length;K<we;K++){let De=W($[K],ce[K],me);ae(De.x,De.y,d+Q)}for(let K=0,we=D.length;K<we;K++){let De=D[K];Te=fe[K];for(let L=0,E=De.length;L<E;L++){let H=W(De[L],Te[L],me);w?ae(H.x,H.y+x[u-1].y,x[u-1].x+Q):ae(H.x,H.y,d+Q)}}}q(),Z();function q(){let X=r.length/3;if(h){let he=0,Q=ne*he;for(let me=0;me<J;me++){let K=F[me];Ie(K[2]+Q,K[1]+Q,K[0]+Q)}he=u+g*2,Q=ne*he;for(let me=0;me<J;me++){let K=F[me];Ie(K[0]+Q,K[1]+Q,K[2]+Q)}}else{for(let he=0;he<J;he++){let Q=F[he];Ie(Q[2],Q[1],Q[0])}for(let he=0;he<J;he++){let Q=F[he];Ie(Q[0]+ne*u,Q[1]+ne*u,Q[2]+ne*u)}}i.addGroup(X,r.length/3-X,0)}function Z(){let X=r.length/3,he=0;ye($,he),he+=$.length;for(let Q=0,me=D.length;Q<me;Q++){let K=D[Q];ye(K,he),he+=K.length}i.addGroup(X,r.length/3-X,1)}function ye(X,he){let Q=X.length;for(;--Q>=0;){let me=Q,K=Q-1;K<0&&(K=X.length-1);for(let we=0,De=u+g*2;we<De;we++){let L=ne*we,E=ne*(we+1),H=he+me+L,te=he+K+L,le=he+K+E,re=he+me+E;Re(H,te,le,re)}}}function ae(X,he,Q){c.push(X),c.push(he),c.push(Q)}function Ie(X,he,Q){B(X),B(he),B(Q);let me=r.length/3,K=v.generateTopUV(i,r,me-3,me-2,me-1);Je(K[0]),Je(K[1]),Je(K[2])}function Re(X,he,Q,me){B(X),B(he),B(me),B(he),B(Q),B(me);let K=r.length/3,we=v.generateSideWallUV(i,r,K-6,K-3,K-2,K-1);Je(we[0]),Je(we[1]),Je(we[3]),Je(we[1]),Je(we[2]),Je(we[3])}function B(X){r.push(c[X*3+0]),r.push(c[X*3+1]),r.push(c[X*3+2])}function Je(X){s.push(X.x),s.push(X.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return HI(t,i,e)}static fromJSON(e,t){let i=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];i.push(a)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Wl[r.type]().fromJSON(r)),new n(i,e.options)}},$I={generateTopUV:function(n,e,t,i,r){let s=e[t*3],o=e[t*3+1],a=e[i*3],c=e[i*3+1],l=e[r*3],u=e[r*3+1];return[new oe(s,o),new oe(a,c),new oe(l,u)]},generateSideWallUV:function(n,e,t,i,r,s){let o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[i*3],u=e[i*3+1],d=e[i*3+2],h=e[r*3],f=e[r*3+1],p=e[r*3+2],y=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new oe(o,1-c),new oe(l,1-d),new oe(h,1-p),new oe(y,1-m)]:[new oe(a,1-c),new oe(u,1-d),new oe(f,1-p),new oe(g,1-m)]}};eu=class n extends Ji{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Ea=class n extends Ji{constructor(e=1,t=0){let i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},tu=class n extends it{constructor(e=.5,t=1,i=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);let a=[],c=[],l=[],u=[],d=e,h=(t-e)/r,f=new P,p=new oe;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){let m=s+g/i*o;f.x=d*Math.cos(m),f.y=d*Math.sin(m),c.push(f.x,f.y,f.z),l.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,u.push(p.x,p.y)}d+=h}for(let y=0;y<r;y++){let g=y*(i+1);for(let m=0;m<i;m++){let v=m+g,x=v,w=v+i+1,O=v+i+2,I=v+1;a.push(x,w,I),a.push(w,O,I)}}this.setIndex(a),this.setAttribute("position",new Le(c,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},nu=class n extends it{constructor(e=new _i([new oe(0,.5),new oe(-.5,-.5),new oe(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],s=[],o=[],a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(i),this.setAttribute("position",new Le(r,3)),this.setAttribute("normal",new Le(s,3)),this.setAttribute("uv",new Le(o,2));function l(u){let d=r.length/3,h=u.extractPoints(t),f=h.shape,p=h.holes;qn.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,m=p.length;g<m;g++){let v=p[g];qn.isClockWise(v)===!0&&(p[g]=v.reverse())}let y=qn.triangulateShape(f,p);for(let g=0,m=p.length;g<m;g++){let v=p[g];f=f.concat(v)}for(let g=0,m=f.length;g<m;g++){let v=f[g];r.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let g=0,m=y.length;g<m;g++){let v=y[g],x=v[0]+d,w=v[1]+d,O=v[2]+d;i.push(x,w,O),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return GI(t,e)}static fromJSON(e,t){let i=[];for(let r=0,s=e.shapes.length;r<s;r++){let o=t[e.shapes[r]];i.push(o)}return new n(i,e.curveSegments)}};Aa=class n extends it{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let c=Math.min(o+a,Math.PI),l=0,u=[],d=new P,h=new P,f=[],p=[],y=[],g=[];for(let m=0;m<=i;m++){let v=[],x=m/i,w=0;m===0&&o===0?w=.5/t:m===i&&c===Math.PI&&(w=-.5/t);for(let O=0;O<=t;O++){let I=O/t;d.x=-e*Math.cos(r+I*s)*Math.sin(o+x*a),d.y=e*Math.cos(o+x*a),d.z=e*Math.sin(r+I*s)*Math.sin(o+x*a),p.push(d.x,d.y,d.z),h.copy(d).normalize(),y.push(h.x,h.y,h.z),g.push(I+w,1-x),v.push(l++)}u.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let x=u[m][v+1],w=u[m][v],O=u[m+1][v],I=u[m+1][v+1];(m!==0||o>0)&&f.push(x,w,I),(m!==i-1||c<Math.PI)&&f.push(w,O,I)}this.setIndex(f),this.setAttribute("position",new Le(p,3)),this.setAttribute("normal",new Le(y,3)),this.setAttribute("uv",new Le(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},iu=class n extends Ji{constructor(e=1,t=0){let i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},ru=class n extends it{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let o=[],a=[],c=[],l=[],u=new P,d=new P,h=new P;for(let f=0;f<=i;f++)for(let p=0;p<=r;p++){let y=p/r*s,g=f/i*Math.PI*2;d.x=(e+t*Math.cos(g))*Math.cos(y),d.y=(e+t*Math.cos(g))*Math.sin(y),d.z=t*Math.sin(g),a.push(d.x,d.y,d.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),h.subVectors(d,u).normalize(),c.push(h.x,h.y,h.z),l.push(p/r),l.push(f/i)}for(let f=1;f<=i;f++)for(let p=1;p<=r;p++){let y=(r+1)*f+p-1,g=(r+1)*(f-1)+p-1,m=(r+1)*(f-1)+p,v=(r+1)*f+p;o.push(y,g,v),o.push(g,m,v)}this.setIndex(o),this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(c,3)),this.setAttribute("uv",new Le(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},su=class n extends it{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);let a=[],c=[],l=[],u=[],d=new P,h=new P,f=new P,p=new P,y=new P,g=new P,m=new P;for(let x=0;x<=i;++x){let w=x/i*s*Math.PI*2;v(w,s,o,e,f),v(w+.01,s,o,e,p),g.subVectors(p,f),m.addVectors(p,f),y.crossVectors(g,m),m.crossVectors(y,g),y.normalize(),m.normalize();for(let O=0;O<=r;++O){let I=O/r*Math.PI*2,R=-t*Math.cos(I),U=t*Math.sin(I);d.x=f.x+(R*m.x+U*y.x),d.y=f.y+(R*m.y+U*y.y),d.z=f.z+(R*m.z+U*y.z),c.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),l.push(h.x,h.y,h.z),u.push(x/i),u.push(O/r)}}for(let x=1;x<=i;x++)for(let w=1;w<=r;w++){let O=(r+1)*(x-1)+(w-1),I=(r+1)*x+(w-1),R=(r+1)*x+w,U=(r+1)*(x-1)+w;a.push(O,I,U),a.push(I,R,U)}this.setIndex(a),this.setAttribute("position",new Le(c,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(u,2));function v(x,w,O,I,R){let U=Math.cos(x),_=Math.sin(x),b=O/w*x,D=Math.cos(b);R.x=I*(2+D)*.5*U,R.y=I*(2+D)*_*.5,R.z=I*Math.sin(b)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},ou=class n extends it{constructor(e=new xa(new P(-1,-1,0),new P(-1,1,0),new P(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};let o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new P,c=new P,l=new oe,u=new P,d=[],h=[],f=[],p=[];y(),this.setIndex(p),this.setAttribute("position",new Le(d,3)),this.setAttribute("normal",new Le(h,3)),this.setAttribute("uv",new Le(f,2));function y(){for(let x=0;x<t;x++)g(x);g(s===!1?t:0),v(),m()}function g(x){u=e.getPointAt(x/t,u);let w=o.normals[x],O=o.binormals[x];for(let I=0;I<=r;I++){let R=I/r*Math.PI*2,U=Math.sin(R),_=-Math.cos(R);c.x=_*w.x+U*O.x,c.y=_*w.y+U*O.y,c.z=_*w.z+U*O.z,c.normalize(),h.push(c.x,c.y,c.z),a.x=u.x+i*c.x,a.y=u.y+i*c.y,a.z=u.z+i*c.z,d.push(a.x,a.y,a.z)}}function m(){for(let x=1;x<=t;x++)for(let w=1;w<=r;w++){let O=(r+1)*(x-1)+(w-1),I=(r+1)*x+(w-1),R=(r+1)*x+w,U=(r+1)*(x-1)+w;p.push(O,I,U),p.push(I,R,U)}}function v(){for(let x=0;x<=t;x++)for(let w=0;w<=r;w++)l.x=x/t,l.y=w/r,f.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new n(new Wl[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},au=class extends it{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new P,s=new P;if(e.index!==null){let o=e.attributes.position,a=e.index,c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let d=c[l],h=d.start,f=d.count;for(let p=h,y=h+f;p<y;p+=3)for(let g=0;g<3;g++){let m=a.getX(p+g),v=a.getX(p+(g+1)%3);r.fromBufferAttribute(o,m),s.fromBufferAttribute(o,v),D0(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,d=3*a+(l+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,d),D0(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Le(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};O0=Object.freeze({__proto__:null,BoxGeometry:Or,CapsuleGeometry:Yl,CircleGeometry:ql,ConeGeometry:Zl,CylinderGeometry:js,DodecahedronGeometry:Jl,EdgesGeometry:Kl,ExtrudeGeometry:Ql,IcosahedronGeometry:eu,LatheGeometry:_a,OctahedronGeometry:Ea,PlaneGeometry:zs,PolyhedronGeometry:Ji,RingGeometry:tu,ShapeGeometry:nu,SphereGeometry:Aa,TetrahedronGeometry:iu,TorusGeometry:ru,TorusKnotGeometry:su,TubeGeometry:ou,WireframeGeometry:au}),cu=class extends $t{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ce(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},lu=class extends xn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Ta=class extends $t{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ce(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},uu=class extends Ta{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new oe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Tt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ce(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ce(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ce(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},du=class extends $t{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ce(16777215),this.specular=new Ce(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vn,this.combine=Oa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},hu=class extends $t{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ce(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},fu=class extends $t{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},pu=class extends $t{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ce(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vn,this.combine=Oa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},mu=class extends $t{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ce(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},gu=class extends jt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};XI={convertArray:Cr,isTypedArray:Sv,getKeyframeOrder:Ev,sortedArray:Tf,flattenJSON:Dp,subclip:jI,makeClipAdditive:WI},zr=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){let a=i+o>>>1;e<t[a]?o=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},yu=class extends zr{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Tr,endingEnd:Tr}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,o=e+1,a=r[s],c=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Ir:s=e,a=2*t-i;break;case Qo:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(c===void 0)switch(this.getSettings_().endingEnd){case Ir:o=e,c=2*i-t;break;case Qo:o=1,c=i+r[1]-r[0];break;default:o=e-1,c=t}let l=(i-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,p=(i-t)/(r-t),y=p*p,g=y*p,m=-h*g+2*h*y-h*p,v=(1+h)*g+(-1.5-2*h)*y+(-.5+h)*p+1,x=(-1-f)*g+(1.5+f)*y+.5*p,w=f*g-f*y;for(let O=0;O!==a;++O)s[O]=m*o[u+O]+v*o[l+O]+x*o[c+O]+w*o[d+O];return s}},Ia=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(i-t)/(r-t),d=1-u;for(let h=0;h!==a;++h)s[h]=o[l+h]*d+o[c+h]*u;return s}},vu=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},_n=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Cr(t,this.TimeBufferType),this.values=Cr(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Cr(e.times,Array),values:Cr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new vu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ia(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new yu(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Jo:t=this.InterpolantFactoryMethodDiscrete;break;case Ko:t=this.InterpolantFactoryMethodLinear;break;case _l:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Jo;case this.InterpolantFactoryMethodLinear:return Ko;case this.InterpolantFactoryMethodSmooth:return _l}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&Sv(r))for(let a=0,c=r.length;a!==c;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===_l,s=e.length-1,o=1;for(let a=1;a<s;++a){let c=!1,l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(r)c=!0;else{let d=a*i,h=d-i,f=d+i;for(let p=0;p!==i;++p){let y=t[d+p];if(y!==t[h+p]||y!==t[f+p]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let d=a*i,h=o*i;for(let f=0;f!==i;++f)t[h+f]=t[d+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,c=o*i,l=0;l!==i;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};_n.prototype.TimeBufferType=Float32Array;_n.prototype.ValueBufferType=Float32Array;_n.prototype.DefaultInterpolation=Ko;Ei=class extends _n{};Ei.prototype.ValueTypeName="bool";Ei.prototype.ValueBufferType=Array;Ei.prototype.DefaultInterpolation=Jo;Ei.prototype.InterpolantFactoryMethodLinear=void 0;Ei.prototype.InterpolantFactoryMethodSmooth=void 0;Ca=class extends _n{};Ca.prototype.ValueTypeName="color";Vr=class extends _n{};Vr.prototype.ValueTypeName="number";xu=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-t)/(r-t),l=e*a;for(let u=l+a;l!==u;l+=4)Qt.slerpFlat(s,0,o,l-a,o,l,c);return s}},Ki=class extends _n{InterpolantFactoryMethodLinear(e){return new xu(this.times,this.values,this.getValueSize(),e)}};Ki.prototype.ValueTypeName="quaternion";Ki.prototype.DefaultInterpolation=Ko;Ki.prototype.InterpolantFactoryMethodSmooth=void 0;Ai=class extends _n{};Ai.prototype.ValueTypeName="string";Ai.prototype.ValueBufferType=Array;Ai.prototype.DefaultInterpolation=Jo;Ai.prototype.InterpolantFactoryMethodLinear=void 0;Ai.prototype.InterpolantFactoryMethodSmooth=void 0;$r=class extends _n{};$r.prototype.ValueTypeName="vector";Hr=class{constructor(e="",t=-1,i=[],r=Nu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=gn(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(qI(i[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(_n.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,o=[];for(let a=0;a<s;a++){let c=[],l=[];c.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let u=Ev(c);c=Tf(c,1,u),l=Tf(l,1,u),!r&&c[0]===0&&(c.push(s),l.push(l[0])),o.push(new Vr(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],u=l.name.match(s);if(u&&u.length>1){let d=u[1],h=r[d];h||(r[d]=h=[]),h.push(l)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(d,h,f,p,y){if(f.length!==0){let g=[],m=[];Dp(f,g,m,p),g.length!==0&&y.push(new d(h,g,m))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let d=0;d<l.length;d++){let h=l[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let y=0;y<h[p].morphTargets.length;y++)f[h[p].morphTargets[y]]=-1;for(let y in f){let g=[],m=[];for(let v=0;v!==h[p].morphTargets.length;++v){let x=h[p];g.push(x.time),m.push(x.morphTarget===y?1:0)}r.push(new Vr(".morphTargetInfluence["+y+"]",g,m))}c=f.length*o}else{let f=".bones["+t[d].name+"]";i($r,f+".position",h,"pos",r),i(Ki,f+".quaternion",h,"rot",r),i($r,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,c,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};vi={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},Ra=class{constructor(e,t,i){let r=this,s=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,d){return l.push(u,d),this},this.removeHandler=function(u){let d=l.indexOf(u);return d!==-1&&l.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=l.length;d<h;d+=2){let f=l[d],p=l[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},Av=new Ra,en=class{constructor(e){this.manager=e!==void 0?e:Av,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};en.DEFAULT_MATERIAL_NAME="__DEFAULT";fi={},If=class extends Error{constructor(e,t){super(e),this.response=t}},zn=class extends en{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=vi.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(fi[e]!==void 0){fi[e].push({onLoad:t,onProgress:i,onError:r});return}fi[e]=[],fi[e].push({onLoad:t,onProgress:i,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=fi[e],d=l.body.getReader(),h=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=h?parseInt(h):0,p=f!==0,y=0,g=new ReadableStream({start(m){v();function v(){d.read().then(({done:x,value:w})=>{if(x)m.close();else{y+=w.byteLength;let O=new ProgressEvent("progress",{lengthComputable:p,loaded:y,total:f});for(let I=0,R=u.length;I<R;I++){let U=u[I];U.onProgress&&U.onProgress(O)}m.enqueue(w),v()}})}}});return new Response(g)}else throw new If(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{vi.add(e,l);let u=fi[e];delete fi[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onLoad&&f.onLoad(l)}}).catch(l=>{let u=fi[e];if(u===void 0)throw this.manager.itemError(e),l;delete fi[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Cf=class extends en{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new zn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=[];for(let i=0;i<e.length;i++){let r=Hr.parse(e[i]);t.push(r)}return t}},Rf=class extends en{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new Hs,c=new zn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(s.withCredentials);let l=0;function u(d){c.load(e[d],function(h){let f=s.parse(h,!0);o[d]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},l+=1,l===6&&(f.mipmapCount===1&&(a.minFilter=Lt),a.image=o,a.format=f.format,a.needsUpdate=!0,t&&t(a))},i,r)}if(Array.isArray(e))for(let d=0,h=e.length;d<h;++d)u(d);else c.load(e,function(d){let h=s.parse(d,!0);if(h.isCubemap){let f=h.mipmaps.length/h.mipmapCount;for(let p=0;p<f;p++){o[p]={mipmaps:[]};for(let y=0;y<h.mipmapCount;y++)o[p].mipmaps.push(h.mipmaps[p*h.mipmapCount+y]),o[p].format=h.format,o[p].width=h.width,o[p].height=h.height}a.image=o}else a.image.width=h.width,a.image.height=h.height,a.mipmaps=h.mipmaps;h.mipmapCount===1&&(a.minFilter=Lt),a.format=h.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},Gr=class extends en{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=vi.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=sa("img");function c(){u(),vi.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(d){u(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},Pf=class extends en{constructor(e){super(e)}load(e,t,i,r){let s=new Ur;s.colorSpace=Tn;let o=new Gr(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){s.images[l]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let l=0;l<e.length;++l)c(l);return s}},Lf=class extends en{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Yn,a=new zn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(c){let l;try{l=s.parse(c)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:In,o.wrapT=l.wrapT!==void 0?l.wrapT:In,o.magFilter=l.magFilter!==void 0?l.magFilter:Lt,o.minFilter=l.minFilter!==void 0?l.minFilter:Lt,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=Wn),l.mipmapCount===1&&(o.minFilter=Lt),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},i,r),o}},Df=class extends en{constructor(e){super(e)}load(e,t,i,r){let s=new Dt,o=new Gr(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},Kn=class extends ht{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ce(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},bu=class extends Kn{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ce(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},yh=new ze,U0=new P,N0=new P,Pa=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new oe(512,512),this.map=null,this.mapPass=null,this.matrix=new ze,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Nr,this._frameExtents=new oe(1,1),this._viewportCount=1,this._viewports=[new gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;U0.setFromMatrixPosition(e.matrixWorld),t.position.copy(U0),N0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(N0),t.updateMatrixWorld(),yh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yh),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(yh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Of=class extends Pa{constructor(){super(new Ut(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=Us*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},_u=class extends Kn{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Of}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},F0=new ze,ko=new P,vh=new P,Uf=class extends Pa{constructor(){super(new Ut(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new oe(4,2),this._viewportCount=6,this._viewports=[new gt(2,1,1,1),new gt(0,1,1,1),new gt(3,1,1,1),new gt(1,1,1,1),new gt(3,0,1,1),new gt(1,0,1,1)],this._cubeDirections=[new P(1,0,0),new P(-1,0,0),new P(0,0,1),new P(0,0,-1),new P(0,1,0),new P(0,-1,0)],this._cubeUps=[new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,0,1),new P(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),ko.setFromMatrixPosition(e.matrixWorld),i.position.copy(ko),vh.copy(i.position),vh.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(vh),i.updateMatrixWorld(),r.makeTranslation(-ko.x,-ko.y,-ko.z),F0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(F0)}},wu=class extends Kn{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new Uf}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Nf=class extends Pa{constructor(){super(new Vs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Mu=class extends Kn{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.shadow=new Nf}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Su=class extends Kn{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},Eu=class extends Kn{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},Au=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new P)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}},Tu=class extends Kn{constructor(e=new Au,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},Iu=class n extends en{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new zn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=n.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new Ce().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new Ce().setHex(o.value);break;case"v2":r.uniforms[s].value=new oe().fromArray(o.value);break;case"v3":r.uniforms[s].value=new P().fromArray(o.value);break;case"v4":r.uniforms[s].value=new gt().fromArray(o.value);break;case"m3":r.uniforms[s].value=new Qe().fromArray(o.value);break;case"m4":r.uniforms[s].value=new ze().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new oe().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new oe().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){let t={ShadowMaterial:cu,SpriteMaterial:fa,RawShaderMaterial:lu,ShaderMaterial:xn,PointsMaterial:ma,MeshPhysicalMaterial:uu,MeshStandardMaterial:Ta,MeshPhongMaterial:du,MeshToonMaterial:hu,MeshNormalMaterial:fu,MeshLambertMaterial:pu,MeshDepthMaterial:da,MeshDistanceMaterial:ha,MeshBasicMaterial:Zn,MeshMatcapMaterial:mu,LineDashedMaterial:gu,LineBasicMaterial:jt,Material:$t};return new t[e]}},La=class{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},Cu=class extends it{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Ru=class extends en{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new zn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(f,p){if(t[p]!==void 0)return t[p];let g=f.interleavedBuffers[p],m=s(f,g.buffer),v=Cs(g.type,m),x=new $s(v,g.stride);return x.uuid=g.uuid,t[p]=x,x}function s(f,p){if(i[p]!==void 0)return i[p];let g=f.arrayBuffers[p],m=new Uint32Array(g).buffer;return i[p]=m,m}let o=e.isInstancedBufferGeometry?new Cu:new it,a=e.data.index;if(a!==void 0){let f=Cs(a.type,a.array);o.setIndex(new ut(f,1))}let c=e.data.attributes;for(let f in c){let p=c[f],y;if(p.isInterleavedBufferAttribute){let g=r(e.data,p.data);y=new Fr(g,p.itemSize,p.offset,p.normalized)}else{let g=Cs(p.type,p.array),m=p.isInstancedBufferAttribute?Zi:ut;y=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(y.name=p.name),p.usage!==void 0&&y.setUsage(p.usage),o.setAttribute(f,y)}let l=e.data.morphAttributes;if(l)for(let f in l){let p=l[f],y=[];for(let g=0,m=p.length;g<m;g++){let v=p[g],x;if(v.isInterleavedBufferAttribute){let w=r(e.data,v.data);x=new Fr(w,v.itemSize,v.offset,v.normalized)}else{let w=Cs(v.type,v.array);x=new ut(w,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),y.push(x)}o.morphAttributes[f]=y}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let f=0,p=d.length;f!==p;++f){let y=d[f];o.addGroup(y.start,y.count,y.materialIndex)}let h=e.data.boundingSphere;if(h!==void 0){let f=new P;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Vt(f,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},Ff=class extends en{constructor(e){super(e)}load(e,t,i,r){let s=this,o=this.path===""?La.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new zn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(d){r!==void 0&&r(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}let u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(l,t)},i,r)}async loadAsync(e,t){let i=this,r=this.path===""?La.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new zn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let o=await s.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){let i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,s,c,a,i),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),t!==void 0){let d=!1;for(let h in o)if(o[h].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),c}parseShapes(e){let t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){let s=new _i().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){let i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=new Ul().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new Ru;for(let s=0,o=e.length;s<o;s++){let a,c=e[s];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(c);break;default:c.type in O0?a=O0[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),i[c.uuid]=a}}return i}parseMaterials(e,t){let i={},r={};if(e!==void 0){let s=new Iu;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){let c=e[o];i[c.uuid]===void 0&&(i[c.uuid]=s.parse(c)),r[c.uuid]=i[c.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let i=0;i<e.length;i++){let r=e[i],s=Hr.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let i=this,r={},s;function o(c){return i.manager.itemStart(c),s.load(c,function(){i.manager.itemEnd(c)},void 0,function(){i.manager.itemError(c),i.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:i.resourcePath+l;return o(u)}else return c.data?{data:Cs(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){let c=new Ra(t);s=new Gr(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){let d=e[l],h=d.url;if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p],m=a(g);m!==null&&(m instanceof HTMLImageElement?f.push(m):f.push(new Yn(m.data,m.width,m.height)))}r[d.uuid]=new gi(f)}else{let f=a(d.url);r[d.uuid]=new gi(f)}}}return r}async parseImagesAsync(e){let t=this,i={},r;async function s(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(c)}else return o.data?{data:Cs(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new Gr(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.url;if(Array.isArray(l)){let u=[];for(let d=0,h=l.length;d<h;d++){let f=l[d],p=await s(f);p!==null&&(p instanceof HTMLImageElement?u.push(p):u.push(new Yn(p.data,p.width,p.height)))}i[c.uuid]=new gi(u)}else{let u=await s(c.url);i[c.uuid]=new gi(u)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}let r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=t[a.image],l=c.data,u;Array.isArray(l)?(u=new Ur,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new Yn:u=new Dt,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,ZI)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],k0),u.wrapT=i(a.wrap[1],k0)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,B0)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,B0)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function a(h){return t[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",h),t[h]}function c(h){if(h!==void 0){if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),f.push(i[g])}return f}return i[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",h),i[h]}}function l(h){return r[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",h),r[h]}let u,d;switch(e.type){case"Scene":o=new Pl,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ce(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Rl(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Cl(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new Ut(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new Vs(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new Su(e.color,e.intensity);break;case"DirectionalLight":o=new Mu(e.color,e.intensity);break;case"PointLight":o=new wu(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Eu(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new _u(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new bu(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Tu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=c(e.material),o=new Ol(u,d),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),d=c(e.material),o=new It(u,d);break;case"InstancedMesh":u=a(e.geometry),d=c(e.material);let h=e.count,f=e.instanceMatrix,p=e.instanceColor;o=new Nl(u,d,h),o.instanceMatrix=new Zi(new Float32Array(f.array),16),p!==void 0&&(o.instanceColor=new Zi(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=c(e.material),o=new Fl(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,d),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(y=>{let g=new Gt;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);let m=new Vt;return m.radius=y.sphereRadius,m.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:m}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid);break;case"LOD":o=new Dl;break;case"Line":o=new Jn(a(e.geometry),c(e.material));break;case"LineLoop":o=new zl(a(e.geometry),c(e.material));break;case"LineSegments":o=new Rn(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new Vl(a(e.geometry),c(e.material));break;case"Sprite":o=new Ll(c(e.material));break;case"Group":o=new Xi;break;case"Bone":o=new pa;break;default:o=new ht}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){let h=e.children;for(let f=0;f<h.length;f++)o.add(this.parseObject(h[f],t,i,r,s))}if(e.animations!==void 0){let h=e.animations;for(let f=0;f<h.length;f++){let p=h[f];o.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);let h=e.levels;for(let f=0;f<h.length;f++){let p=h[f],y=o.getObjectByProperty("uuid",p.object);y!==void 0&&o.addLevel(y,p.distance,p.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){let r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}},ZI={UVMapping:Uu,CubeReflectionMapping:Mi,CubeRefractionMapping:Yi,EquirectangularReflectionMapping:Xo,EquirectangularRefractionMapping:Yo,CubeUVReflectionMapping:Ws},k0={RepeatWrapping:qo,ClampToEdgeWrapping:In,MirroredRepeatWrapping:Zo},B0={NearestFilter:zt,NearestMipmapNearestFilter:xp,NearestMipmapLinearFilter:Is,LinearFilter:Lt,LinearMipmapNearestFilter:Vo,LinearMipmapLinearFilter:Wn},kf=class extends en{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=vi.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{r&&r(l)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return vi.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){r&&r(l),vi.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});vi.add(e,c),s.manager.itemStart(e)}},Da=class{static getContext(){return ll===void 0&&(ll=new(window.AudioContext||window.webkitAudioContext)),ll}static setContext(e){ll=e}},Bf=class extends en{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new zn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{let l=c.slice(0);Da.getContext().decodeAudioData(l,function(d){t(d)}).catch(a)}catch(l){a(l)}},i,r);function a(c){r?r(c):console.error(c),s.manager.itemError(e)}}},z0=new ze,V0=new ze,xr=new ze,zf=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ut,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ut,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,xr.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(Lr*t.fov*.5)/t.zoom,a,c;V0.elements[12]=-r,z0.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,xr.elements[0]=2*t.near/(c-a),xr.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(xr),a=-o*t.aspect-s,c=o*t.aspect-s,xr.elements[0]=2*t.near/(c-a),xr.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(xr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(V0),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(z0)}},Pu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=$0(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=$0();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};br=new P,H0=new Qt,JI=new P,_r=new P,Vf=class extends ht{constructor(){super(),this.type="AudioListener",this.context=Da.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Pu}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(br,H0,JI),_r.set(0,0,-1).applyQuaternion(H0),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(br.x,r),t.positionY.linearRampToValueAtTime(br.y,r),t.positionZ.linearRampToValueAtTime(br.z,r),t.forwardX.linearRampToValueAtTime(_r.x,r),t.forwardY.linearRampToValueAtTime(_r.y,r),t.forwardZ.linearRampToValueAtTime(_r.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(br.x,br.y,br.z),t.setOrientation(_r.x,_r.y,_r.z,i.x,i.y,i.z)}},Lu=class extends ht{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},wr=new P,G0=new Qt,KI=new P,Mr=new P,$f=class extends Lu{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(wr,G0,KI),Mr.set(0,0,1).applyQuaternion(G0);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(wr.x,i),t.positionY.linearRampToValueAtTime(wr.y,i),t.positionZ.linearRampToValueAtTime(wr.z,i),t.orientationX.linearRampToValueAtTime(Mr.x,i),t.orientationY.linearRampToValueAtTime(Mr.y,i),t.orientationZ.linearRampToValueAtTime(Mr.z,i)}else t.setPosition(wr.x,wr.y,wr.z),t.setOrientation(Mr.x,Mr.y,Mr.z)}},Hf=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},Du=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)i[s+a]=i[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let c=t*this._origIndex;this._mixBufferRegion(i,r,c,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(i[c]!==i[c+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){Qt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Qt.multiplyQuaternionsFlat(e,o,e,t,e,i),Qt.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){let o=1-r;for(let a=0;a!==s;++a){let c=t+a;e[c]=e[c]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[i+o]*r}}},Op="\\[\\]\\.:\\/",QI=new RegExp("["+Op+"]","g"),Up="[^"+Op+"]",e2="[^"+Op.replace("\\.","")+"]",t2=/((?:WC+[\/:])*)/.source.replace("WC",Up),n2=/(WCOD+)?/.source.replace("WCOD",e2),i2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Up),r2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Up),s2=new RegExp("^"+t2+n2+i2+r2+"$"),o2=["material","materials","bones","map"],Gf=class{constructor(e,t,i){let r=i||pt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},pt=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(QI,"")}static parseTrackName(e){let t=s2.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);o2.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let c=i(a.children);if(c)return c}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[r];if(o===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};pt.Composite=Gf;pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pt.prototype.GetterByBindingType=[pt.prototype._getValue_direct,pt.prototype._getValue_array,pt.prototype._getValue_arrayElement,pt.prototype._getValue_toArray];pt.prototype.SetterByBindingTypeAndVersioning=[[pt.prototype._setValue_direct,pt.prototype._setValue_direct_setNeedsUpdate,pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_array,pt.prototype._setValue_array_setNeedsUpdate,pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_arrayElement,pt.prototype._setValue_arrayElement_setNeedsUpdate,pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_fromArray,pt.prototype._setValue_fromArray_setNeedsUpdate,pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];jf=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=gn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length,a,c=e.length,l=this.nCachedObjects_;for(let u=0,d=arguments.length;u!==d;++u){let h=arguments[u],f=h.uuid,p=t[f];if(p===void 0){p=c++,t[f]=p,e.push(h);for(let y=0,g=o;y!==g;++y)s[y].push(new pt(h,i[y],r[y]))}else if(p<l){a=e[p];let y=--l,g=e[y];t[g.uuid]=p,e[p]=g,t[f]=y,e[y]=h;for(let m=0,v=o;m!==v;++m){let x=s[m],w=x[y],O=x[p];x[p]=w,O===void 0&&(O=new pt(h,i[m],r[m])),x[y]=O}}else e[p]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=s){let d=s++,h=e[d];t[h.uuid]=u,e[u]=h,t[l]=d,e[d]=c;for(let f=0,p=r;f!==p;++f){let y=i[f],g=y[d],m=y[u];y[u]=g,y[d]=m}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,d=t[u];if(d!==void 0)if(delete t[u],d<s){let h=--s,f=e[h],p=--o,y=e[p];t[f.uuid]=d,e[d]=f,t[y.uuid]=h,e[h]=y,e.pop();for(let g=0,m=r;g!==m;++g){let v=i[g],x=v[h],w=v[p];v[d]=x,v[h]=w,v.pop()}}else{let h=--o,f=e[h];h>0&&(t[f.uuid]=d),e[d]=f,e.pop();for(let p=0,y=r;p!==y;++p){let g=i[p];g[d]=g[h],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,r=i[e],s=this._bindings;if(r!==void 0)return s[r];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,d=new Array(l);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(d);for(let h=u,f=c.length;h!==f;++h){let p=c[h];d[h]=new pt(p,e,t)}return d}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=i,o[i]=c,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}},Ou=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,o=s.length,a=new Array(o),c={endingStart:Tr,endingEnd:Tr};for(let l=0;l!==o;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=qy,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+i,l[0]=e/o,l[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let c=(e-s)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Ip:for(let u=0,d=c.length;u!==d;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case Nu:default:for(let u=0,d=c.length;u!==d;++u)c[u].evaluate(o),l[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,o=i===Zy;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===Yy){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Ir,r.endingEnd=Ir):(e?r.endingStart=this.zeroSlopeAtStart?Ir:Tr:r.endingStart=Qo,t?r.endingEnd=this.zeroSlopeAtEnd?Ir:Tr:r.endingEnd=Qo)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=i,this}},a2=new Float32Array(1),Wf=class extends Bn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=i.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let d=0;d!==s;++d){let h=r[d],f=h.name,p=u[f];if(p!==void 0)++p.referenceCount,o[d]=p;else{if(p=o[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}let y=t&&t._propertyBindings[d].binding.parsedPath;p=new Du(pt.create(i,f,y),h.ValueTypeName,h.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),o[d]=p}a[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;let d=a.actionByRoot,h=(e._localRoot||this._root).uuid;delete d[h],c.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[r],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new Ia(new Float32Array(2),new Float32Array(2),1,a2),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,o=typeof e=="string"?Hr.findByName(r,e):e,a=o!==null?o.uuid:e,c=this._actionsByClip[a],l=null;if(i===void 0&&(o!==null?i=o.blendMode:i=Nu),c!==void 0){let d=c.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new Ou(this,o,t,i);return this._bindAction(u,l),this._addInactiveAction(u,a,s),u}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?Hr.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let o=s.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,d=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,d._cacheIndex=u,t[u]=d,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let o in i){let a=i[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Xf=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},c2=0,Yf=class extends Bn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:c2++}),this.name="",this.usage=ia,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){let s=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}},qf=class extends $s{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Zf=class{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},j0=new ze,Jf=class{constructor(e,t,i=0,r=1/0){this.ray=new qi(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Fs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return j0.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(j0),this}intersectObject(e,t=!0,i=[]){return Kf(e,this,i,t),i.sort(W0),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Kf(e[r],this,i,t);return i.sort(W0),i}};Qf=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Tt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},ep=class{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}},X0=new oe,tp=class{constructor(e=new oe(1/0,1/0),t=new oe(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=X0.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,X0).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Y0=new P,ul=new P,np=class{constructor(e=new P,t=new P){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Y0.subVectors(e,this.start),ul.subVectors(this.end,this.start);let i=ul.dot(ul),s=ul.dot(Y0)/i;return t&&(s=Tt(s,0,1)),s}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},q0=new P,ip=class extends ht{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new it,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new Le(r,3));let s=new jt({fog:!1,toneMapped:!1});this.cone=new Rn(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),q0.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(q0),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},ji=new P,dl=new ze,xh=new ze,rp=class extends Rn{constructor(e){let t=Tv(e),i=new it,r=[],s=[],o=new Ce(0,0,1),a=new Ce(0,1,0);for(let l=0;l<t.length;l++){let u=t[l];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new Le(r,3)),i.setAttribute("color",new Le(s,3));let c=new jt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,i=this.geometry,r=i.getAttribute("position");xh.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(dl.multiplyMatrices(xh,a.matrixWorld),ji.setFromMatrixPosition(dl),r.setXYZ(o,ji.x,ji.y,ji.z),dl.multiplyMatrices(xh,a.parent.matrixWorld),ji.setFromMatrixPosition(dl),r.setXYZ(o+1,ji.x,ji.y,ji.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};sp=class extends It{constructor(e,t,i){let r=new Aa(t,4,2),s=new Zn({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},l2=new P,Z0=new Ce,J0=new Ce,op=class extends ht{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";let r=new Ea(t);r.rotateY(Math.PI*.5),this.material=new Zn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new ut(o,3)),this.add(new It(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");Z0.copy(this.light.color),J0.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?Z0:J0;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(l2.setFromMatrixPosition(this.light.matrixWorld).negate())}},ap=class extends Rn{constructor(e=10,t=10,i=4473924,r=8947848){i=new Ce(i),r=new Ce(r);let s=t/2,o=e/t,a=e/2,c=[],l=[];for(let h=0,f=0,p=-a;h<=t;h++,p+=o){c.push(-a,0,p,a,0,p),c.push(p,0,-a,p,0,a);let y=h===s?i:r;y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3}let u=new it;u.setAttribute("position",new Le(c,3)),u.setAttribute("color",new Le(l,3));let d=new jt({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},cp=class extends Rn{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new Ce(s),o=new Ce(o);let a=[],c=[];if(t>1)for(let d=0;d<t;d++){let h=d/t*(Math.PI*2),f=Math.sin(h)*e,p=Math.cos(h)*e;a.push(0,0,0),a.push(f,0,p);let y=d&1?s:o;c.push(y.r,y.g,y.b),c.push(y.r,y.g,y.b)}for(let d=0;d<i;d++){let h=d&1?s:o,f=e-e/i*d;for(let p=0;p<r;p++){let y=p/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f;a.push(g,0,m),c.push(h.r,h.g,h.b),y=(p+1)/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f,a.push(g,0,m),c.push(h.r,h.g,h.b)}}let l=new it;l.setAttribute("position",new Le(a,3)),l.setAttribute("color",new Le(c,3));let u=new jt({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},K0=new P,hl=new P,Q0=new P,lp=class extends ht{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new it;r.setAttribute("position",new Le([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new jt({fog:!1,toneMapped:!1});this.lightPlane=new Jn(r,s),this.add(this.lightPlane),r=new it,r.setAttribute("position",new Le([0,0,0,0,0,1],3)),this.targetLine=new Jn(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),K0.setFromMatrixPosition(this.light.matrixWorld),hl.setFromMatrixPosition(this.light.target.matrixWorld),Q0.subVectors(hl,K0),this.lightPlane.lookAt(hl),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(hl),this.targetLine.scale.z=Q0.length()}},fl=new P,At=new Bs,up=class extends Rn{constructor(e){let t=new it,i=new jt({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,y){c(p),c(y)}function c(p){r.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}t.setAttribute("position",new Le(r,3)),t.setAttribute("color",new Le(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let l=new Ce(16755200),u=new Ce(16711680),d=new Ce(43775),h=new Ce(16777215),f=new Ce(3355443);this.setColors(l,u,d,h,f)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;At.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Rt("c",t,e,At,0,0,-1),Rt("t",t,e,At,0,0,1),Rt("n1",t,e,At,-i,-r,-1),Rt("n2",t,e,At,i,-r,-1),Rt("n3",t,e,At,-i,r,-1),Rt("n4",t,e,At,i,r,-1),Rt("f1",t,e,At,-i,-r,1),Rt("f2",t,e,At,i,-r,1),Rt("f3",t,e,At,-i,r,1),Rt("f4",t,e,At,i,r,1),Rt("u1",t,e,At,i*.7,r*1.1,-1),Rt("u2",t,e,At,-i*.7,r*1.1,-1),Rt("u3",t,e,At,0,r*2,-1),Rt("cf1",t,e,At,-i,0,1),Rt("cf2",t,e,At,i,0,1),Rt("cf3",t,e,At,0,-r,1),Rt("cf4",t,e,At,0,r,1),Rt("cn1",t,e,At,-i,0,-1),Rt("cn2",t,e,At,i,0,-1),Rt("cn3",t,e,At,0,-r,-1),Rt("cn4",t,e,At,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};pl=new Gt,dp=class extends Rn{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new it;s.setIndex(new ut(i,1)),s.setAttribute("position",new ut(r,3)),super(s,new jt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&pl.setFromObject(this.object),pl.isEmpty())return;let t=pl.min,i=pl.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},hp=class extends Rn{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new it;s.setIndex(new ut(i,1)),s.setAttribute("position",new Le(r,3)),super(s,new jt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},fp=class extends Jn{constructor(e,t=1,i=16776960){let r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new it;o.setAttribute("position",new Le(s,3)),o.computeBoundingSphere(),super(o,new jt({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new it;c.setAttribute("position",new Le(a,3)),c.computeBoundingSphere(),this.add(new It(c,new Zn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},ey=new P,pp=class extends ht{constructor(e=new P(0,0,1),t=new P(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",ml===void 0&&(ml=new it,ml.setAttribute("position",new Le([0,0,0,0,1,0],3)),bh=new js(0,.5,1,5,1),bh.translate(0,-.5,0)),this.position.copy(t),this.line=new Jn(ml,new jt({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new It(bh,new Zn({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{ey.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(ey,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},mp=class extends Rn{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new it;r.setAttribute("position",new Le(t,3)),r.setAttribute("color",new Le(i,3));let s=new jt({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ce,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},gp=class{constructor(){this.type="ShapePath",this.color=new Ce,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new kr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){let v=[];for(let x=0,w=m.length;x<w;x++){let O=m[x],I=new _i;I.curves=O.curves,v.push(I)}return v}function i(m,v){let x=v.length,w=!1;for(let O=x-1,I=0;I<x;O=I++){let R=v[O],U=v[I],_=U.x-R.x,b=U.y-R.y;if(Math.abs(b)>Number.EPSILON){if(b<0&&(R=v[I],_=-_,U=v[O],b=-b),m.y<R.y||m.y>U.y)continue;if(m.y===R.y){if(m.x===R.x)return!0}else{let D=b*(m.x-R.x)-_*(m.y-R.y);if(D===0)return!0;if(D<0)continue;w=!w}}else{if(m.y!==R.y)continue;if(U.x<=m.x&&m.x<=R.x||R.x<=m.x&&m.x<=U.x)return!0}}return w}let r=qn.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c,l=[];if(s.length===1)return a=s[0],c=new _i,c.curves=a.curves,l.push(c),l;let u=!r(s[0].getPoints());u=e?!u:u;let d=[],h=[],f=[],p=0,y;h[p]=void 0,f[p]=[];for(let m=0,v=s.length;m<v;m++)a=s[m],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&h[p]&&p++,h[p]={s:new _i,p:y},h[p].s.curves=a.curves,u&&p++,f[p]=[]):f[p].push({h:a,p:y[0]});if(!h[0])return t(s);if(h.length>1){let m=!1,v=0;for(let x=0,w=h.length;x<w;x++)d[x]=[];for(let x=0,w=h.length;x<w;x++){let O=f[x];for(let I=0;I<O.length;I++){let R=O[I],U=!0;for(let _=0;_<h.length;_++)i(R.p,h[_].p)&&(x!==_&&v++,U?(U=!1,d[_].push(R)):m=!0);U&&d[x].push(R)}}v>0&&m===!1&&(f=d)}let g;for(let m=0,v=h.length;m<v;m++){c=h[m].s,l.push(c),g=f[m];for(let x=0,w=g.length;x<w;x++)c.holes.push(g[x].h)}return l}},yp=class extends yn{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"164"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="164")});var $C={};Xp($C,{createWorldOrbitEditor:()=>tx});var Y=class n extends Error{line;column;constructor(e,t,i){let r=t===void 0?"":` (line ${t}${i===void 0?"":`, column ${i}`})`;super(`${e}${r}`),this.name="WorldOrbitError",this.line=t,this.column=i}static fromLocation(e,t){return new n(e,t?.line,t?.column)}};var io=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],Sn=io.filter(n=>n!=="system"),mx=["star","planet","moon","asteroid","comet","structure","phenomenon"],Yp=["structure","phenomenon"],Li=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],gx=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function ct(n,e){return{key:n,...e}}var Ya=new Set(io),qp=new Map([ct("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:Li}),ct("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:Li,unitFamily:"distance"}),ct("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:Li,unitFamily:"distance"}),ct("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:Li}),ct("period",{kind:"unit",placement:!0,arity:"single",objectTypes:Li,unitFamily:"duration"}),ct("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:Li,unitFamily:"angle"}),ct("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:Li,unitFamily:"angle"}),ct("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:Li,unitFamily:"angle"}),ct("at",{kind:"string",placement:!0,arity:"single",objectTypes:Yp}),ct("surface",{kind:"string",placement:!0,arity:"single",objectTypes:Yp}),ct("free",{kind:"string",placement:!0,arity:"single",objectTypes:gx}),ct("kind",{kind:"string",placement:!1,arity:"single",objectTypes:Sn}),ct("class",{kind:"string",placement:!1,arity:"single",objectTypes:Sn}),ct("culture",{kind:"string",placement:!1,arity:"single",objectTypes:Sn}),ct("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:io}),ct("color",{kind:"string",placement:!1,arity:"single",objectTypes:io}),ct("image",{kind:"string",placement:!1,arity:"single",objectTypes:mx}),ct("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:io}),ct("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:Sn,unitFamily:"radius"}),ct("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:Sn,unitFamily:"mass"}),ct("density",{kind:"unit",placement:!1,arity:"single",objectTypes:Sn,unitFamily:"generic"}),ct("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:Sn,unitFamily:"generic"}),ct("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:Sn,unitFamily:"generic"}),ct("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:Sn}),ct("atmosphere",{kind:"string",placement:!1,arity:"single",objectTypes:["planet","moon","asteroid","comet","phenomenon"]}),ct("inner",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),ct("outer",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),ct("view",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),ct("scale",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),ct("units",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),ct("title",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),ct("on",{kind:"string",placement:!1,arity:"single",objectTypes:Sn}),ct("source",{kind:"string",placement:!1,arity:"single",objectTypes:Sn}),ct("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:Sn,unitFamily:"duration"})].map(n=>[n.key,n])),yx=new Set(qp.keys());function hn(n){return qp.get(n)}function Zp(n){return yx.has(n)}function Jp(n,e){return n.objectTypes.includes(e)}function qa(n,e){switch(n){case"distance":return e===null||["au","km","m","ly","pc","kpc","re","sol"].includes(e);case"radius":return e===null||["km","m","re","rj","sol"].includes(e);case"mass":return e===null||["me","mj","sol"].includes(e);case"duration":return e===null||["s","min","h","d","y","ky","my","gy"].includes(e);case"angle":return e===null||e==="deg";case"generic":return!0}}function ro(n,e={}){let t=[],i=e.columnOffset??0,r="",s=null,o=!1,a=!1,c=null,l=()=>{s!==null&&(t.push({value:r,column:s,quoted:o}),r="",s=null,o=!1)};for(let u=0;u<n.length;u++){let d=n[u],h=i+u+1;if(a&&d==="\\"){let f=n[u+1];if(f==='"'||f==="\\"){r+=f,u++;continue}}if(d==='"'){a?a=!1:(s===null&&(s=h),o=!0,c=h,a=!0);continue}if(!a&&/\s/.test(d)){l();continue}s===null&&(s=h),r+=d}if(a)throw new Y("Unclosed quote in line",e.line,c??i+n.length);return l(),t}function Za(n){return n.match(/^\s*/)?.[0].length??0}function so(n){let e=n.split(/\r?\n/),t=[],i=null,r=!1,s=null;for(let o=0;o<e.length;o++){let a=e[o],c=o+1;if(!a.trim())continue;let l=Za(a),u=ro(a.slice(l),{line:c,columnOffset:l});if(u.length!==0){if(l===0){r=!1,s=null;let d=vx(u,c);t.push(d),i=d;continue}if(!i)throw new Y("Indented line without parent object",c,l+1);if(u.length===1&&u[0].value==="info"){r=!0,s=l;continue}r&&l<=(s??0)&&(r=!1),r?i.infoEntries.push(_x(u,c)):i.blockFields.push(bx(u,c))}}return{type:"document",objects:t}}function vx(n,e){if(n.length<2)throw new Y("Invalid object declaration",e,n[0]?.column??1);let[t,i,...r]=n;if(!Ya.has(t.value))throw new Y(`Unknown object type "${t.value}"`,e,t.column);return{type:"object",objectType:t.value,name:i.value,inlineFields:xx(r,e),blockFields:[],infoEntries:[],location:{line:e,column:t.column}}}function xx(n,e){let t=[],i=0;for(;i<n.length;){let r=n[i],s=hn(r.value);if(!s)throw new Y(`Unknown field "${r.value}"`,e,r.column);i++;let o=[];if(s.arity==="multiple")for(;i<n.length&&!Zp(n[i].value);)o.push(n[i]),i++;else{let a=n[i];a&&(o.push(a),i++)}if(o.length===0)throw new Y(`Missing value for field "${r.value}"`,e,r.column);t.push({type:"field",key:r.value,values:o.map(a=>a.value),location:{line:e,column:r.column}})}return t}function bx(n,e){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);if(!hn(n[0].value))throw new Y(`Unknown field "${n[0].value}"`,e,n[0].column);return{type:"field",key:n[0].value,values:n.slice(1).map(t=>t.value),location:{line:e,column:n[0].column}}}function _x(n,e){if(n.length<2)throw new Y("Invalid info entry",e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(t=>t.value).join(" "),location:{line:e,column:n[0].column}}}var Kp=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,wx=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),Mx=/^[A-Za-z][A-Za-z0-9+.-]*:/;function oo(n){let e=null,t=[];for(let i of n.objects){let r=Sx(i);if(i.objectType==="system"){if(e)throw Y.fromLocation("Only one system object is allowed",i.location);e=r}else t.push(r)}return{format:"worldorbit",version:"1.0",schemaVersion:"1.0",system:e,groups:[],relations:[],events:[],objects:t}}function Sx(n){let e=[...n.inlineFields,...n.blockFields];Ex(n.objectType,e);let t=Ax(e),i=Tx(n.objectType,t),r=Ix(t),s=Px(n.infoEntries);return n.objectType==="system"?{type:"system",id:n.name,title:typeof r.title=="string"?r.title:null,description:null,epoch:null,referencePlane:null,properties:r,info:s}:{type:n.objectType,id:n.name,properties:r,placement:i,info:s}}function Ex(n,e){for(let t of e){let i=hn(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(!Jp(i,n))throw Y.fromLocation(`Field "${t.key}" is not valid on "${n}"`,t.location);if(i.arity==="single"&&t.values.length!==1)throw Y.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function Ax(n){let e=new Map;for(let t of n){if(e.has(t.key))throw Y.fromLocation(`Duplicate field "${t.key}"`,t.location);e.set(t.key,t)}return e}function Tx(n,e){let t=e.has("orbit"),i=e.has("at"),r=e.has("surface"),s=e.has("free"),o=[t,i,r,s].filter(Boolean).length;if(o>1){let a=e.get("orbit")??e.get("at")??e.get("surface")??e.get("free");throw Y.fromLocation("Object has multiple placement modes",a?.location)}if(n==="system"&&o>0)throw Y.fromLocation("System objects cannot declare placement",[...e.values()][0]?.location);if(t)return{mode:"orbit",target:Ja(e,"orbit"),distance:Yr(e,"distance"),semiMajor:Yr(e,"semiMajor"),eccentricity:Ox(e,"eccentricity"),period:Yr(e,"period"),angle:Yr(e,"angle"),inclination:Yr(e,"inclination"),phase:Yr(e,"phase")};if(i){let a=Ka(e,"at"),c=Ja(e,"at");return{mode:"at",target:c,reference:Lx(c,a.location)}}if(r)return{mode:"surface",target:Ja(e,"surface")};if(s){let a=Ja(e,"free"),c=Dx(a);return{mode:"free",distance:c??void 0,descriptor:c?void 0:a}}return null}function Ix(n){let e={};for(let[t,i]of n.entries()){let r=hn(t);if(!(!r||r.placement))switch(r.kind){case"list":e[t]=i.values;break;case"boolean":e[t]=Ux(i);break;case"number":e[t]=em(qr(i),t,i.location);break;case"unit":e[t]=Qp(qr(i),i.location,t);break;case"string":e[t]=Cx(t,i);break}}return e}function Cx(n,e){let t=e.values.join(" ").trim();return n==="image"&&Rx(t,e.location),t}function Rx(n,e){if(!n)throw Y.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw Y.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(Mx);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw Y.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function Px(n){let e={};for(let t of n){if(t.key in e)throw Y.fromLocation(`Duplicate info key "${t.key}"`,t.location);e[t.key]=t.value}return e}function Lx(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function Qp(n,e,t){let i=n.match(Kp);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=hn(t);if(s?.unitFamily&&!qa(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function Dx(n){let e=n.match(Kp);return e?{value:Number(e[1]),unit:e[2]??null}:null}function Yr(n,e){if(!n.has(e))return;let t=Ka(n,e);return Qp(qr(t),t.location,e)}function Ox(n,e){if(!n.has(e))return;let t=Ka(n,e);return em(qr(t),e,t.location)}function em(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function Ux(n){let e=qr(n).toLowerCase(),t=wx.get(e);if(t===void 0)throw Y.fromLocation(`Invalid boolean value "${e}" for "${n.key}"`,n.location);return t}function Ka(n,e){let t=n.get(e);if(!t)throw new Y(`Missing value for key "${e}"`);return t}function Ja(n,e){return qr(Ka(n,e))}function qr(n){if(n.values.length!==1)throw Y.fromLocation(`Field "${n.key}" expects exactly one value`,n.location);return n.values[0]}var Nx=new Set(["star","planet","moon","asteroid","comet"]);function ao(n){let e=new Set,t=new Map;for(let i of n.objects){if(e.has(i.id))throw new Y(`Duplicate object id "${i.id}"`);e.add(i.id),t.set(i.id,i)}for(let i of n.objects)if(i.placement){if((i.placement.mode==="orbit"||i.placement.mode==="surface")&&!e.has(i.placement.target))throw new Y(`Unknown placement target "${i.placement.target}" on "${i.id}"`);if(i.placement.mode==="surface"){let r=t.get(i.placement.target);if(!r||!Nx.has(r.type))throw new Y(`Surface target "${i.placement.target}" on "${i.id}" is not surface-capable`)}i.placement.mode==="at"&&(i.placement.reference.kind==="lagrange"&&Fx(i,i.placement.reference,e),i.placement.reference.kind==="anchor"&&kx(i,i.placement.reference,e))}}function Fx(n,e,t){if(!t.has(e.primary))throw new Y(`Unknown Lagrange reference "${e.primary}" on "${n.id}"`);if(e.secondary&&!t.has(e.secondary))throw new Y(`Unknown Lagrange reference "${e.secondary}" on "${n.id}"`)}function kx(n,e,t){if(!t.has(e.objectId))throw new Y(`Unknown anchor target "${e.objectId}" on "${n.id}"`)}function cr(n,e,t=`${e}.failed`){return n instanceof Y?{code:t,severity:"error",source:e,message:n.message,line:n.line,column:n.column}:n instanceof Error?{code:t,severity:"error",source:e,message:n.message}:{code:t,severity:"error",source:e,message:String(n)}}var co=1495978707e-1,Bx=6371,zx=71492,Vx=695700,$x=63241.077,Hx=206264.806,Gx=206264806,am=.68,jx=.2,cm=28;function cn(n,e={}){let t=Yx(e),i=t.width,r=t.height,s=t.padding,o=Xx(n),a=Zx(n,e.projection),c=id(e.camera??null),l=nd(a,c),u=Qx(o,e.scaleModel),d=tb(o),h=n.system?.id??null,f=e.activeEventId??null,p=Wx(n.objects,n.events??[],f),y=new Map(p.map(Z=>[Z.id,Z])),g=kb(p,y),m=new Map,v=[],x=[],w=[],O=[],I=[],R=new Map,U=new Map;for(let Z of p){let ye=Z.placement;if(!ye){w.push(Z);continue}if(ye.mode==="orbit"){rm(U,ye.target,Z);continue}if(ye.mode==="surface"){rm(R,ye.target,Z);continue}if(ye.mode==="at"){I.push(Z);continue}O.push(Z)}let _=O.length>0?i*.42:i/2,b=r/2,D={orbitChildren:U,surfaceChildren:R,objectMap:y,spacingFactor:d,projection:l,scaleModel:u},z=w.find(Z=>Z.type==="star")??w[0]??null;z&&Qu(z,_,b,0,m,v,x,D);let F=w.filter(Z=>Z.id!==z?.id);if(F.length>0){let Z=Math.min(i,r)*.28*d*u.orbitDistanceMultiplier;F.forEach((ye,ae)=>{let Ie=po(ae,F.length,-Math.PI/2),Re=mo(Ie,Z,l,1);Qu(ye,_+Re.x,b+Re.y,0,m,v,x,D)})}O.forEach((Z,ye)=>{let ae=i-s-140-Gb(Z.placement?.mode==="free"?Z.placement.distance:void 0,u),Ie=Math.max(76,(r-s*2-180)/Math.max(1,O.length)*d)*u.freePlacementMultiplier,Re=s+92+ye*Ie;m.set(Z.id,{object:Z,x:ae,y:Re,radius:ic(Z,0,u),sortKey:sc(ae,Re,0)}),x.push({object:Z,groupId:g.groupIds.get(Z.id)??null,x1:ae-60,y1:Re,x2:ae-18,y2:Re,mode:"free"}),tc(Z,m,v,x,D,1)}),I.forEach((Z,ye)=>{if(m.has(Z.id)||!Z.placement||Z.placement.mode!=="at")return;let ae=Nb(Z.placement.reference,m,y,ye,I.length,i,r,s,D);m.set(Z.id,{object:Z,x:ae.x,y:ae.y,radius:ic(Z,2,u),sortKey:sc(ae.x,ae.y,2),anchorX:ae.anchorX,anchorY:ae.anchorY}),ae.anchorX!==void 0&&ae.anchorY!==void 0&&x.push({object:Z,groupId:g.groupIds.get(Z.id)??null,x1:ae.anchorX,y1:ae.anchorY,x2:ae.x,y2:ae.y,mode:"at"}),tc(Z,m,v,x,D,2)});let $=[...m.values()].map(Z=>nb(Z,u,g)),W=v.map(Z=>ib(Z,g.groupIds.get(Z.object.id)??null)),ne=x.map(Z=>rb(Z)),J=sb($,i,r,u.labelMultiplier),V=fb(n,$),ce=pb(n.events??[],$,f),fe=ub(W,V,ce,ne,$,J),Te=db($,W,ne,J,g,u.labelMultiplier),ve=hb(n,$),He=mb(n,a,t.preset,g,y),q=Tb(i,r,$,W,ne,J,u.labelMultiplier);return{width:i,height:r,padding:s,renderPreset:t.preset,projection:a,renderProjection:l,camera:c,scaleModel:u,title:String(n.system?.title??n.system?.properties.title??n.system?.id??"WorldOrbit")||"WorldOrbit",subtitle:Kx(a,l,o,c),systemId:h,viewMode:a,layoutPreset:o,metadata:{format:n.format,version:n.version,view:a,renderProjection:l,scale:String(n.system?.properties.scale??o),units:String(n.system?.properties.units??"mixed"),preset:t.preset??"custom",...c?.azimuth!==null?{"camera.azimuth":String(c?.azimuth)}:{},...c?.elevation!==null?{"camera.elevation":String(c?.elevation)}:{},...c?.roll!==null?{"camera.roll":String(c?.roll)}:{},...c?.distance!==null?{"camera.distance":String(c?.distance)}:{}},contentBounds:q,layers:fe,groups:Te,semanticGroups:ve,viewpoints:He,events:ce,activeEventId:f,objects:$,orbitVisuals:W,relations:V,leaders:ne,labels:J}}function ln(n,e,t){let i=oc(t),r=Math.cos(i),s=Math.sin(i),o=n.x-e.x,a=n.y-e.y;return{x:e.x+o*r-a*s,y:e.y+o*s+a*r}}function Wx(n,e,t){let i=n.map(a=>structuredClone(a));if(!t)return i;let r=e.find(a=>a.id===t);if(!r)return i;let s=new Map(i.map(a=>[a.id,a])),o=new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds,...r.positions.map(a=>a.objectId)]);for(let a of o){let c=s.get(a);c&&(r.epoch&&(c.epoch=r.epoch),r.referencePlane&&(c.referencePlane=r.referencePlane))}for(let a of r.positions){let c=s.get(a.objectId);c&&(a.placement&&(c.placement=structuredClone(a.placement)),a.inner&&(c.properties.inner={...a.inner}),a.outer&&(c.properties.outer={...a.outer}),a.epoch&&(c.epoch=a.epoch),a.referencePlane&&(c.referencePlane=a.referencePlane))}return i}function Xx(n){switch(String(n.system?.properties.scale??"balanced").toLowerCase()){case"compressed":case"compact":return"compact";case"expanded":case"presentation":return"presentation";default:return"balanced"}}function Yx(n){let e=qx(n.preset);return{width:n.width??e.width,height:n.height??e.height,padding:n.padding??e.padding,preset:n.preset??null}}function qx(n){switch(n){case"presentation":return{width:1440,height:900,padding:88};case"atlas-card":return{width:960,height:560,padding:56};case"markdown":return{width:920,height:540,padding:48};default:return{width:1200,height:780,padding:72}}}function Zx(n,e){if(e==="topdown"||e==="isometric"||e==="orthographic"||e==="perspective")return e;let t=String(n.system?.properties.view??"topdown").toLowerCase();return dm(t)??"topdown"}function nd(n,e){switch(n){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return e&&(e.azimuth!==null||e.elevation!==null||e.roll!==null)?"isometric":"topdown";case"perspective":return"isometric"}}function id(n){if(!n)return null;let e={azimuth:Ku(n.azimuth),elevation:Ku(n.elevation),roll:Ku(n.roll),distance:Jx(n.distance)};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function Ku(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Jx(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function Kx(n,e,t,i){let r=[`${sm(n)} view`,`${sm(t)} layout`];if(n!==e&&r.push(`2D ${e} fallback`),i){let s=[i.azimuth!==null?`az ${i.azimuth}`:null,i.elevation!==null?`el ${i.elevation}`:null,i.roll!==null?`roll ${i.roll}`:null,i.distance!==null?`dist ${i.distance}`:null].filter(Boolean);s.length>0&&r.push(`camera ${s.join(" / ")}`)}return r.join(" - ")}function Qx(n,e){return{...eb(n),...e}}function eb(n){switch(n){case"compact":return{orbitDistanceMultiplier:.84,bodyRadiusMultiplier:.92,labelMultiplier:.9,freePlacementMultiplier:.9,ringThicknessMultiplier:.92,minBodyRadius:4,maxBodyRadius:36};case"presentation":return{orbitDistanceMultiplier:1.2,bodyRadiusMultiplier:1.18,labelMultiplier:1.08,freePlacementMultiplier:1.05,ringThicknessMultiplier:1.16,minBodyRadius:5,maxBodyRadius:48};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,labelMultiplier:1,freePlacementMultiplier:1,ringThicknessMultiplier:1,minBodyRadius:4,maxBodyRadius:40}}}function tb(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function nb(n,e,t){let{object:i,x:r,y:s,radius:o,sortKey:a,anchorX:c,anchorY:l}=n,u=i.renderHints?.renderPriority??0;return{renderId:Zr(i.id),objectId:i.id,object:i,parentId:t.parentIds.get(i.id)??null,ancestorIds:t.ancestorIds.get(i.id)??[],childIds:t.childIds.get(i.id)??[],groupId:t.groupIds.get(i.id)??null,semanticGroupIds:[...i.groups??[]],x:r,y:s,radius:o,visualRadius:Hb(i,o,e),sortKey:a+u*.001,anchorX:c,anchorY:l,label:i.id,secondaryLabel:i.type==="structure"?String(i.properties.kind??i.type):i.type,fillColor:Wb(i.properties.color),imageHref:typeof i.properties.image=="string"&&i.properties.image.trim()?i.properties.image:void 0,hidden:i.properties.hidden===!0}}function ib(n,e){return{renderId:`${Zr(n.object.id)}-orbit`,objectId:n.object.id,object:n.object,parentId:n.parentId,groupId:e,semanticGroupIds:[...n.object.groups??[]],kind:n.kind,cx:n.cx,cy:n.cy,radius:n.radius,rx:n.rx,ry:n.ry,rotationDeg:n.rotationDeg,band:n.band,bandThickness:n.bandThickness,frontArcPath:n.frontArcPath,backArcPath:n.backArcPath,hidden:n.object.properties.hidden===!0||n.object.renderHints?.renderOrbit===!1}}function rb(n){return{renderId:`${Zr(n.object.id)}-leader-${n.mode}`,objectId:n.object.id,object:n.object,groupId:n.groupId,semanticGroupIds:[...n.object.groups??[]],x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,mode:n.mode,hidden:n.object.properties.hidden===!0}}function sb(n,e,t,i){let r=[],s=[],o=new Map(n.map(c=>[c.objectId,c])),a=[...n].filter(c=>!c.hidden&&c.object.renderHints?.renderLabel!==!1).sort(ob);for(let c of a){let l=ab(c,o,s,e,t,i)??um(c,lm(c,o.get(c.parentId??"")??null,t),0,i);s.push(gm(c,l,i)),r.push({renderId:`${c.renderId}-label`,objectId:c.objectId,object:c.object,groupId:c.groupId,semanticGroupIds:[...c.semanticGroupIds],label:c.label,secondaryLabel:c.secondaryLabel,x:l.x,y:l.labelY,secondaryY:l.secondaryY,textAnchor:l.textAnchor,direction:l.direction,hidden:c.hidden})}return r}function ob(n,e){let t=tm(n)-tm(e);if(t!==0)return t;let i=(e.object.renderHints?.renderPriority??0)-(n.object.renderHints?.renderPriority??0);return i!==0?i:n.sortKey-e.sortKey}function tm(n){switch(n.object.type){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":case"ring":return 3;case"asteroid":case"comet":return 4;case"structure":case"phenomenon":return 5}}function ab(n,e,t,i,r,s){for(let o of cb(n,e,i,r)){let a=o==="left"||o==="right"?4:6;for(let c=0;c<=a;c+=1){let l=um(n,o,c,s),u=gm(n,l,s);if(!t.some(d=>Vb(d,u)))return l}}return null}function cb(n,e,t,i){let r=n.parentId?e.get(n.parentId)??null:null,s=lm(n,r,i),o=s==="below"?"above":"below",a=lb(n,r,t),c=a==="right"?"left":"right";return n.object.type==="structure"||n.object.type==="phenomenon"||n.object.placement?.mode==="at"||n.object.placement?.mode==="surface"||n.object.placement?.mode==="free"?[a,s,c,o]:[s,a,o,c]}function lm(n,e,t){return e&&Math.abs(n.y-e.y)>6?n.y>=e.y?"below":"above":n.y>t*.62?"above":"below"}function lb(n,e,t){return e&&Math.abs(n.x-e.x)>6?n.x>=e.x?"right":"left":n.x>=t/2?"right":"left"}function um(n,e,t,i){let r=14*i;switch(e){case"above":{let s=n.y-(n.radius+18*i+t*r);return{x:n.x,labelY:s,secondaryY:s-16*i,textAnchor:"middle",direction:e}}case"below":{let s=n.y+n.radius+18*i+t*r;return{x:n.x,labelY:s,secondaryY:s+16*i,textAnchor:"middle",direction:e}}case"left":{let s=n.x-(n.visualRadius+16*i+t*r),o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"end",direction:e}}case"right":{let s=n.x+n.visualRadius+16*i+t*r,o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"start",direction:e}}}}function ub(n,e,t,i,r,s){let o=n.filter(c=>!c.hidden&&!!c.backArcPath).map(c=>c.renderId),a=n.filter(c=>!c.hidden).map(c=>c.renderId);return[{id:"background",renderIds:["wo-bg","wo-bg-glow","wo-grid"]},{id:"guides",renderIds:i.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"orbits-back",renderIds:o},{id:"orbits-front",renderIds:a},{id:"relations",renderIds:e.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"events",renderIds:t.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"objects",renderIds:r.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"labels",renderIds:s.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"metadata",renderIds:["wo-title","wo-subtitle","wo-meta"]}]}function db(n,e,t,i,r,s){let o=new Map,a=c=>{if(!c)return null;let l=o.get(c);if(l)return l;let u=r.groupRoots.get(c)??null,d={renderId:c,rootObjectId:u,label:u??c,objectIds:[],orbitIds:[],labelIds:[],leaderIds:[],contentBounds:fo(0,0,0,0)};return o.set(c,d),d};for(let c of n){let l=a(c.groupId);l&&!c.hidden&&l.objectIds.push(c.objectId)}for(let c of e){let l=a(c.groupId);l&&!c.hidden&&l.orbitIds.push(c.objectId)}for(let c of t){let l=a(c.groupId);l&&!c.hidden&&l.leaderIds.push(c.objectId)}for(let c of i){let l=a(c.groupId);l&&!c.hidden&&l.labelIds.push(c.objectId)}for(let c of o.values())c.contentBounds=Bb(c,n,e,t,i,s);return[...o.values()].sort((c,l)=>c.label.localeCompare(l.label))}function hb(n,e){return[...n.groups].map(t=>({id:t.id,label:t.label,summary:t.summary,color:t.color,tags:[...t.tags],hidden:t.hidden,objectIds:e.filter(i=>!i.hidden&&i.semanticGroupIds.includes(t.id)).map(i=>i.objectId)})).sort((t,i)=>t.label.localeCompare(i.label))}function fb(n,e){let t=new Map(e.map(i=>[i.objectId,i]));return n.relations.map(i=>{let r=t.get(i.from),s=t.get(i.to);return{renderId:`${Zr(i.id)}-relation`,relationId:i.id,relation:i,fromObjectId:i.from,toObjectId:i.to,x1:r?.x??0,y1:r?.y??0,x2:s?.x??0,y2:s?.y??0,hidden:i.hidden||!r||!s||r.hidden||s.hidden}}).sort((i,r)=>i.relation.id.localeCompare(r.relation.id))}function pb(n,e,t){let i=new Map(e.map(r=>[r.objectId,r]));return n.map(r=>{let s=[...new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds])],o=s.map(l=>i.get(l)).filter(Boolean),a=o.length>0?o.reduce((l,u)=>l+u.x,0)/o.length:0,c=o.length>0?o.reduce((l,u)=>l+u.y,0)/o.length:0;return{renderId:`${Zr(r.id)}-event`,eventId:r.id,event:r,objectIds:s,participantIds:[...r.participantObjectIds],targetObjectId:r.targetObjectId,x:a,y:c,hidden:r.hidden||o.length===0||o.every(l=>l.hidden)||t!==null&&r.id!==t}}).sort((r,s)=>r.event.id.localeCompare(s.event.id))}function mb(n,e,t,i,r){let s=gb(n,e,t),o=new Map;for(let[l,u]of Object.entries(n.system?.info??{})){if(!l.startsWith("viewpoint."))continue;let[d,h,...f]=l.split(".");if(d!=="viewpoint"||!h||f.length===0)continue;let p=Sb(h);if(!p)continue;let y=f.join(".").toLowerCase(),g=o.get(p)??{id:p};yb(g,y,u,n,e,t,i,r),o.set(p,g)}let a=[...o.values()].map(l=>vb(l,e,t,r)).filter(Boolean),c=a.findIndex(l=>l.id===s.id);return c>=0?a.splice(c,1,{...s,...a[c],layers:{...s.layers,...a[c].layers},filter:a[c].filter??s.filter,generated:!1}):a.unshift(s),a.sort((l,u)=>l.id==="overview"?-1:u.id==="overview"?1:l.label.localeCompare(u.label))}function gb(n,e,t){let i=n.system?.title??n.system?.properties.title,r=i?`${String(i)} Overview`:"Overview",s=id(null),o=nd(e,s);return{id:"overview",label:r,summary:"Fit the whole system with the current atlas defaults.",objectId:null,selectedObjectId:null,eventIds:[],projection:e,renderProjection:o,camera:s,preset:t,rotationDeg:0,scale:null,layers:{},filter:null,generated:!0}}function yb(n,e,t,i,r,s,o,a){let c=t.trim();switch(e){case"label":case"title":c&&(n.label=c);return;case"summary":case"description":c&&(n.summary=c);return;case"focus":case"object":c&&(n.focus=c);return;case"select":case"selection":c&&(n.select=c);return;case"events":n.eventIds=ho(c);return;case"projection":case"view":n.projection=dm(c)??r;return;case"preset":n.preset=bb(c)??s;return;case"rotation":case"angle":n.rotationDeg=lo(c)??n.rotationDeg??0;return;case"camera.azimuth":n.camera={...n.camera??ec(),azimuth:lo(c)};return;case"camera.elevation":n.camera={...n.camera??ec(),elevation:lo(c)};return;case"camera.roll":n.camera={...n.camera??ec(),roll:lo(c)};return;case"camera.distance":n.camera={...n.camera??ec(),distance:nm(c)};return;case"zoom":case"scale":n.scale=nm(c);return;case"layers":n.layers=_b(c);return;case"query":n.filter={...n.filter??Qa(),query:c||null};return;case"types":case"objecttypes":n.filter={...n.filter??Qa(),objectTypes:wb(c)};return;case"tags":n.filter={...n.filter??Qa(),tags:ho(c)};return;case"groups":n.filter={...n.filter??Qa(),groupIds:Mb(c,i,o,a)};return}}function vb(n,e,t,i){let r=n.focus&&i.has(n.focus)?n.focus:null,s=n.select&&i.has(n.select)?n.select:r,o=xb(n.filter),a=n.label?.trim()||Eb(n.id),c=n.projection??e,l=id(n.camera??null),u=nd(c,l);return{id:n.id,label:a,summary:n.summary?.trim()||Ab(a,r,o),objectId:r,selectedObjectId:s,eventIds:[...new Set(n.eventIds??[])],projection:c,renderProjection:u,camera:l,preset:n.preset??t,rotationDeg:n.rotationDeg??0,scale:n.scale??null,layers:n.layers??{},filter:o,generated:!1}}function Qa(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function ec(){return{azimuth:null,elevation:null,roll:null,distance:null}}function xb(n){if(!n)return null;let e={query:n.query?.trim()||null,objectTypes:[...new Set(n.objectTypes)],tags:[...new Set(n.tags)],groupIds:[...new Set(n.groupIds)]};return e.query||e.objectTypes.length>0||e.tags.length>0||e.groupIds.length>0?e:null}function dm(n){switch(n.toLowerCase()){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return"orthographic";case"perspective":return"perspective";default:return null}}function bb(n){let e=n.toLowerCase();return e==="diagram"||e==="presentation"||e==="atlas-card"||e==="markdown"?e:null}function lo(n){let e=Number(n);return Number.isFinite(e)?e:null}function nm(n){let e=lo(n);return e!==null&&e>0?e:null}function _b(n){let e={};for(let t of ho(n)){let i=!t.startsWith("-")&&!t.startsWith("!"),r=t.replace(/^[-!]+/,"").toLowerCase();if(r==="orbits"){e["orbits-back"]=i,e["orbits-front"]=i;continue}(r==="background"||r==="guides"||r==="orbits-back"||r==="orbits-front"||r==="relations"||r==="events"||r==="objects"||r==="labels"||r==="metadata")&&(e[r]=i)}return e}function wb(n){return ho(n).filter(e=>e==="star"||e==="planet"||e==="moon"||e==="belt"||e==="asteroid"||e==="comet"||e==="ring"||e==="structure"||e==="phenomenon")}function Mb(n,e,t,i){return ho(n).map(r=>e.schemaVersion==="2.1"||e.schemaVersion==="2.5"||e.groups.some(s=>s.id===r)||r.startsWith("wo-")&&r.endsWith("-group")?r:t.groupIds.has(r)?t.groupIds.get(r)??uo(r):(i.has(r),uo(r)))}function ho(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function Sb(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Eb(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Ab(n,e,t){let i=[n];return e&&i.push(`focus ${e}`),t?.objectTypes.length&&i.push(t.objectTypes.join("/")),t?.tags.length&&i.push(`tags ${t.tags.join(", ")}`),t?.query&&i.push(`query "${t.query}"`),i.join(" - ")}function Tb(n,e,t,i,r,s,o){let a=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,d=(h,f)=>{a=Math.min(a,h),c=Math.min(c,f),l=Math.max(l,h),u=Math.max(u,f)};for(let h of i)h.hidden||hm(h,d);for(let h of r)h.hidden||(d(h.x1,h.y1),d(h.x2,h.y2));for(let h of t)h.hidden||fm(h,d);for(let h of s)h.hidden||pm(h,d,o);return!Number.isFinite(a)||!Number.isFinite(c)?fo(0,0,n,e):fo(a,c,l,u)}function hm(n,e){let t=n.bandThickness!==void 0?n.bandThickness/2+4:n.band?10:3;if(n.kind==="circle"&&n.radius!==void 0){e(n.cx-n.radius-t,n.cy-n.radius-t),e(n.cx+n.radius+t,n.cy+n.radius+t);return}let i=n.rx??n.radius??0,r=n.ry??n.radius??0,s=vm(n.cx,n.cy,i,r,n.rotationDeg,0,Math.PI*2,cm*2);for(let o of s)e(o.x-t,o.y-t),e(o.x+t,o.y+t)}function fo(n,e,t,i){return{minX:n,minY:e,maxX:t,maxY:i,width:t-n,height:i-e,centerX:n+(t-n)/2,centerY:e+(i-e)/2}}function fm(n,e){e(n.x-n.visualRadius-24,n.y-n.visualRadius-16),e(n.x+n.visualRadius+24,n.y+n.visualRadius+36)}function pm(n,e,t){let i=ym(n.x,n.y,n.secondaryY,n.textAnchor,n.direction,n.label,n.secondaryLabel,t);e(i.left,i.top),e(i.right,i.bottom)}function Qu(n,e,t,i,r,s,o,a){r.has(n.id)||(r.set(n.id,{object:n,x:e,y:t,radius:ic(n,i,a.scaleModel),sortKey:sc(e,t,i)}),tc(n,r,s,o,a,i+1))}function tc(n,e,t,i,r,s){let o=e.get(n.id);if(!o)return;let a=[...r.orbitChildren.get(n.id)??[]].sort(Ib),c=Cb(a,o.radius,r.spacingFactor,r.scaleModel),l=Lb(a,c);a.forEach((d,h)=>{let f=Rb(d,h,a.length,o,c,l[h]??c.innerPx,r);t.push({object:d,parentId:n.id,kind:f.kind,cx:f.cx,cy:f.cy,radius:f.radius,rx:f.rx,ry:f.ry,rotationDeg:f.rotationDeg,band:f.band,bandThickness:f.bandThickness,frontArcPath:f.frontArcPath,backArcPath:f.backArcPath}),Qu(d,f.objectX,f.objectY,s,e,t,i,r)});let u=[...r.surfaceChildren.get(n.id)??[]];u.forEach((d,h)=>{let f=po(h,u.length,-Math.PI/3),p=28*r.spacingFactor,y=mo(f,o.radius,r.projection,r.projection==="isometric"?.9:1),g=mo(f,o.radius+p,r.projection,r.projection==="isometric"?.9:1),m=o.x+y.x,v=o.y+y.y,x=o.x+g.x,w=o.y+g.y;e.set(d.id,{object:d,x,y:w,radius:ic(d,s+1,r.scaleModel),sortKey:sc(x,w,s+1),anchorX:m,anchorY:v}),i.push({object:d,groupId:r.objectMap.has(d.id)?uo(zb(d,r.objectMap)):null,x1:m,y1:v,x2:x,y2:w,mode:"surface"}),tc(d,e,t,i,r,s+1)})}function Ib(n,e){let t=nc(n),i=nc(e);return t!==null&&i!==null&&t!==i?t-i:t!==null&&i===null?-1:t===null&&i!==null?1:n.id.localeCompare(e.id)}function Cb(n,e,t,i){let r=n.map(d=>nc(d)),s=r.filter(d=>d!==null),o=e+56*t*i.orbitDistanceMultiplier,a=(n.length>2?54:64)*t*i.orbitDistanceMultiplier;if(s.length===0)return{metrics:r,minMetric:0,maxMetric:0,metricSpread:0,innerPx:o,stepPx:a,pixelSpread:Math.max(a*Math.max(n.length-1,1),a),minimumGapPx:a*.42};let c=Math.min(...s),l=Math.max(...s),u=l-c;return{metrics:r,minMetric:c,maxMetric:l,metricSpread:u,innerPx:o,stepPx:a,pixelSpread:Math.max(a*Math.max(n.length-1,1),a),minimumGapPx:a*.42}}function Rb(n,e,t,i,r,s,o){let a=n.placement,c=n.type==="belt"||n.type==="ring";if(!a||a.mode!=="orbit"){let U=r.innerPx+e*r.stepPx;return{kind:"circle",cx:i.x,cy:i.y,radius:U,rotationDeg:0,band:c,bandThickness:c?12*o.scaleModel.ringThicknessMultiplier:void 0,objectX:i.x,objectY:i.y-U}}let l=Ot(typeof a.eccentricity=="number"?a.eccentricity:0,0,.92),u=s,d=Math.max(u*Math.sqrt(1-l*l),u*.18),h=td(a.inclination)??0,f=o.projection==="isometric"?Math.max(jx,Math.cos(oc(h)))*am:1,p=Math.max(d*f,u*.14),y=td(a.angle)??0,g=u*l,m=bm(-g,0,y),v=i.x+m.x,x=i.y+m.y,w=Ob(a.phase,e,t),O=xm(v,x,u,p,y,w),I=o.projection==="topdown"&&l<=1e-4&&Math.abs(y)<=1e-4,R=c?Ub(n,u,r,o.scaleModel):void 0;return{kind:I?"circle":"ellipse",cx:I?i.x:v,cy:I?i.y:x,radius:I?u:void 0,rx:I?void 0:u,ry:I?void 0:p,rotationDeg:y,band:c,bandThickness:R,frontArcPath:o.projection==="isometric"||c?im(v,x,u,p,y,0,Math.PI):void 0,backArcPath:o.projection==="isometric"||c?im(v,x,u,p,y,Math.PI,Math.PI*2):void 0,objectX:O.x,objectY:O.y}}function Pb(n,e){return e.innerPx+e.stepPx*Db(Math.max(n,0)+1)}function Lb(n,e){let t=[];return n.forEach((i,r)=>{let s=nc(i),o=e.innerPx+r*e.stepPx,a=s===null?o:Pb(s,e),c=r===0?e.innerPx:(t[r-1]??e.innerPx)+e.minimumGapPx;t.push(Math.max(a,c))}),t}function nc(n){return!n.placement||n.placement.mode!=="orbit"?null:rc(n.placement.semiMajor??n.placement.distance??null)}function Db(n){return Math.log(n)/Math.log(2)}function Ob(n,e,t){let i=n?td(n):null;return i!==null?oc(i-90):po(e,t,-Math.PI/2)}function Ub(n,e,t,i){let r=rc(ed(n.properties.inner)),s=rc(ed(n.properties.outer));if(r!==null&&s!==null){let a=Math.abs(s-r);if(t.metricSpread>0)return Ot(a/t.metricSpread*t.pixelSpread*i.ringThicknessMultiplier,8,54);let c=Math.max(Math.max(r,s),1e-4);return Ot(a/c*e*.75*i.ringThicknessMultiplier,8,48)}return(n.type==="belt"?18:12)*i.ringThicknessMultiplier}function Nb(n,e,t,i,r,s,o,a,c){if(n.kind==="lagrange")return Fb(n,e,t,s,o);if(n.kind==="anchor"){let l=e.get(n.objectId);if(l){let u=po(i,r,Math.PI/5),d=(l.radius+36)*c.scaleModel.labelMultiplier,h=mo(u,d,c.projection,c.projection==="isometric"?.92:1);return{x:l.x+h.x,y:l.y+h.y,anchorX:l.x,anchorY:l.y}}}if(n.kind==="named"){let l=e.get(n.name);if(l){let u=po(i,r,Math.PI/6),d=(l.radius+36)*c.scaleModel.labelMultiplier,h=mo(u,d,c.projection,c.projection==="isometric"?.92:1);return{x:l.x+h.x,y:l.y+h.y,anchorX:l.x,anchorY:l.y}}}return{x:s-a-170,y:o-a-86-i*58*c.scaleModel.freePlacementMultiplier}}function Fb(n,e,t,i,r){let s=n.secondary?e.get(n.primary):$b(n.primary,e,t),o=e.get(n.secondary??n.primary);if(!s||!o)return{x:i*.7,y:r*.25};let a=o.x-s.x,c=o.y-s.y,l=Math.hypot(a,c)||1,u=a/l,d=c/l,h=-d,f=u,p=Ot(l*.25,24,68);switch(n.point){case"L1":return{x:o.x-u*p,y:o.y-d*p,anchorX:o.x,anchorY:o.y};case"L2":return{x:o.x+u*p,y:o.y+d*p,anchorX:o.x,anchorY:o.y};case"L3":return{x:s.x-u*p,y:s.y-d*p,anchorX:s.x,anchorY:s.y};case"L4":return{x:o.x+(u*.5-h*.8660254)*p,y:o.y+(d*.5-f*.8660254)*p,anchorX:o.x,anchorY:o.y};case"L5":return{x:o.x+(u*.5+h*.8660254)*p,y:o.y+(d*.5+f*.8660254)*p,anchorX:o.x,anchorY:o.y}}}function kb(n,e){let t=new Map,i=new Map;for(let l of n){let u=mm(l,e);if(t.set(l.id,u),u){let d=i.get(u);d?d.push(l.id):i.set(u,[l.id])}i.has(l.id)||i.set(l.id,[])}let r=new Map,s=new Map,o=new Map,a=l=>{let u=r.get(l);if(u)return u;let d=new Set,h=[],f=t.get(l)??null;for(;f&&!d.has(f);)h.push(f),d.add(f),f=t.get(f)??null;return r.set(l,h),h},c=l=>{let u=o.get(s.get(l)??"");if(u)return u;let d=t.get(l)??null,h=e.get(l),f=l;return h?.placement&&h.placement.mode!=="free"&&d&&(f=c(d)),f};for(let l of n){a(l.id);let u=c(l.id),d=uo(u);s.set(l.id,d),o.set(d,u)}return{parentIds:t,childIds:i,ancestorIds:r,groupIds:s,groupRoots:o}}function mm(n,e){let t=n.placement;if(!t)return null;switch(t.mode){case"orbit":case"surface":return e.has(t.target)?t.target:null;case"at":switch(t.reference.kind){case"anchor":return e.has(t.reference.objectId)?t.reference.objectId:null;case"named":return e.has(t.reference.name)?t.reference.name:null;case"lagrange":return t.reference.secondary&&e.has(t.reference.secondary)?t.reference.secondary:e.has(t.reference.primary)?t.reference.primary:null}case"free":return null}}function Bb(n,e,t,i,r,s){let o=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=(d,h)=>{o=Math.min(o,d),a=Math.min(a,h),c=Math.max(c,d),l=Math.max(l,h)};for(let d of e)!d.hidden&&n.objectIds.includes(d.objectId)&&fm(d,u);for(let d of t)!d.hidden&&n.orbitIds.includes(d.objectId)&&hm(d,u);for(let d of i)!d.hidden&&n.leaderIds.includes(d.objectId)&&(u(d.x1,d.y1),u(d.x2,d.y2));for(let d of r)!d.hidden&&n.labelIds.includes(d.objectId)&&pm(d,u,s);return!Number.isFinite(o)||!Number.isFinite(a)?fo(0,0,0,0):fo(o,a,c,l)}function zb(n,e){let t=n,i=new Set;for(;t.placement&&t.placement.mode!=="free"&&!i.has(t.id);){i.add(t.id);let r=mm(t,e);if(!r)break;let s=e.get(r);if(!s)break;t=s}return t.id}function gm(n,e,t){return ym(e.x,e.labelY,e.secondaryY,e.textAnchor,e.direction,n.label,n.secondaryLabel,t)}function ym(n,e,t,i,r,s,o,a){let c=Xb(s,o,a),l=c*2,u=r==="above"?18:12,d=r==="above"?8:12,h=n-c,f=n+c;return i==="start"?(h=n,f=n+l):i==="end"&&(h=n-l,f=n),{left:h,right:f,top:Math.min(e,t)-u,bottom:Math.max(e,t)+d}}function Vb(n,e){return!(n.right<e.left||e.right<n.left||n.bottom<e.top||e.bottom<n.top)}function $b(n,e,t){let i=t.get(n);return!i?.placement||i.placement.mode!=="orbit"?e.get(n):e.get(i.placement.target)}function ic(n,e,t){let i=jb(n.properties.radius,t);if(i!==null)return i;let r=t.bodyRadiusMultiplier;switch(n.type){case"star":return Ot((e===0?28:20)*r,t.minBodyRadius,t.maxBodyRadius);case"planet":return Ot(12*r,t.minBodyRadius,t.maxBodyRadius);case"moon":return Ot(7*r,t.minBodyRadius,t.maxBodyRadius);case"belt":return Ot(5*r,t.minBodyRadius,t.maxBodyRadius);case"asteroid":return Ot(5*r,t.minBodyRadius,t.maxBodyRadius);case"comet":return Ot(6*r,t.minBodyRadius,t.maxBodyRadius);case"ring":return Ot(5*r,t.minBodyRadius,t.maxBodyRadius);case"structure":return Ot(6*r,t.minBodyRadius,t.maxBodyRadius);case"phenomenon":return Ot(8*r,t.minBodyRadius,t.maxBodyRadius)}}function Hb(n,e,t){let i=typeof n.properties.atmosphere=="string"?4:0;switch(n.type){case"star":return e*2.4;case"phenomenon":return e*1.25;case"structure":return e+2;default:return Math.min(e+i,t.maxBodyRadius+10)}}function rc(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/co;case"m":return n.value/1e3/co;case"ly":return n.value*$x;case"pc":return n.value*Hx;case"kpc":return n.value*Gx;case"re":return n.value*Bx/co;case"rj":return n.value*zx/co;case"sol":return n.value*Vx/co;default:return n.value}}function Gb(n,e){let t=rc(n??null);return t===null||t<=0?0:Ot(t*96*e.freePlacementMultiplier,0,420)}function jb(n,e){let t=ed(n);if(!t)return null;let i;switch(t.unit){case"sol":i=Ot(t.value*22,14,40);break;case"re":i=Ot(t.value*10,6,18);break;case"km":i=Ot(Math.log10(Math.max(t.value,1))*2.6,4,16);break;default:i=Ot(t.value*4,4,20);break}return Ot(i*e.bodyRadiusMultiplier,e.minBodyRadius,e.maxBodyRadius)}function ed(n){return!n||typeof n!="object"||!("value"in n)?null:n}function td(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function po(n,e,t){return e<=1?t:t+n*Math.PI*2/e}function im(n,e,t,i,r,s,o){let a=vm(n,e,t,i,r,s,o,cm);return a.length===0?"":a.map((c,l)=>`${l===0?"M":"L"} ${om(c.x)} ${om(c.y)}`).join(" ")}function vm(n,e,t,i,r,s,o,a){let c=[];for(let l=0;l<=a;l+=1){let u=s+(o-s)*l/a;c.push(xm(n,e,t,i,r,u))}return c}function xm(n,e,t,i,r,s){let o=t*Math.cos(s),a=i*Math.sin(s),c=bm(o,a,r);return{x:n+c.x,y:e+c.y}}function bm(n,e,t){let i=oc(t);return{x:n*Math.cos(i)-e*Math.sin(i),y:n*Math.sin(i)+e*Math.cos(i)}}function mo(n,e,t,i){let r=t==="isometric"?am*i:i;return{x:Math.cos(n)*e,y:Math.sin(n)*e*r}}function sc(n,e,t){return e*1e3+n+t*.01}function Ot(n,e,t){return Math.min(Math.max(n,e),t)}function rm(n,e,t){let i=n.get(e);i?i.push(t):n.set(e,[t])}function Zr(n){return`wo-${n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function uo(n){return`${Zr(n)}-group`}function Wb(n){return typeof n=="string"&&n.trim()?n:void 0}function Xb(n,e,t){let i=n.length*4.6*t+18,r=e.length*3.9*t+18;return Math.max(i,r,24)}function sm(n){return n.length>0?n[0].toUpperCase()+n.slice(1):n}function oc(n){return n*Math.PI/180}function om(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var Mm=86400,ac=Mm*365.25,cc=18,_m=180;function Kr(n,e={}){let t={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,camera:e.camera,scaleModel:e.scaleModel,activeEventId:e.activeEventId},i=cn(n,t),r=Jb(i.layoutPreset,e.spatialScaleModel),s={x:i.contentBounds.centerX,y:i.contentBounds.centerY},o=new Map(i.objects.map(y=>[y.objectId,y])),a=new Map(i.orbitVisuals.map(y=>[y.objectId,y])),c=new Map;for(let y of i.objects){let g=y.object.placement;!g||g.mode!=="orbit"||c.set(y.objectId,sd(g))}let l=Math.min(...[...c.values()].filter(y=>Number.isFinite(y)&&y>0))||1,u=new Map,d=i.objects.map(y=>Yb(y,i,s,o,a,r,u,l)),h=new Map(d.map(y=>[y.objectId,y])),f=i.orbitVisuals.map(y=>qb(y,h,l,i.activeEventId!==null)),p=d.map(y=>({objectId:y.objectId,center:{...y.position},radius:y.visualRadius+r.focusPadding}));return{width:i.width,height:i.height,padding:i.padding,renderPreset:i.renderPreset,projection:i.projection,camera:i.camera,scaleModel:r,title:i.title,subtitle:i.subtitle,systemId:i.systemId,viewMode:"3d",layoutPreset:i.layoutPreset,metadata:{...i.metadata,"viewer.mode":"3d"},contentBounds:Qb(d),semanticGroups:i.semanticGroups,viewpoints:i.viewpoints,activeEventId:i.activeEventId,timeFrozen:i.activeEventId!==null,objects:d,orbits:f,focusTargets:p}}function Yb(n,e,t,i,r,s,o,a){let c=lc(n,e,t,i,r,o),l=ad(n.object,r.get(n.objectId),a,e.activeEventId!==null);return{objectId:n.objectId,object:n.object,parentId:n.parentId,ancestorIds:n.ancestorIds.slice(),childIds:n.childIds.slice(),groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),position:c,radius:Jr(n.radius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius),visualRadius:Jr(n.visualRadius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius+24),label:n.label,secondaryLabel:n.secondaryLabel,fillColor:n.fillColor,imageHref:n.imageHref,hidden:n.hidden,motion:l}}function qb(n,e,t,i){let r=e.get(n.objectId),s=e.get(n.parentId);return{objectId:n.objectId,object:n.object,parentId:n.parentId,groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),center:s?.position??{x:0,y:0,z:0},kind:n.kind,radius:n.radius,semiMajor:n.radius??n.rx??0,semiMinor:n.radius??n.ry??0,rotationDeg:n.rotationDeg,inclinationDeg:r?.motion?.inclinationDeg??uc(n.object.placement?.mode==="orbit"?n.object.placement.inclination:void 0)??0,band:n.band,bandThickness:n.bandThickness,hidden:n.hidden,motion:r?.motion??ad(n.object,n,t,i)}}function lc(n,e,t,i,r,s){let o=s.get(n.objectId);if(o)return o;let a=n.object.placement,c;if(a?.mode==="orbit"&&n.parentId){let l=i.get(n.parentId),u=l?lc(l,e,t,i,r,s):{x:0,y:0,z:0},d=r.get(n.objectId),h=ad(n.object,d,1,e.activeEventId!==null),f=h?Sm(h,0):{x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};c=Em(u,f)}else if(a?.mode==="surface"&&n.parentId){let l=i.get(n.parentId),u=l?lc(l,e,t,i,r,s):{x:0,y:0,z:0},d=l?.visualRadius??16,h=e_(n.objectId),f=h*Math.PI*2;c={x:u.x+Math.cos(f)*(d+n.visualRadius*.9),y:u.y+Math.sin(h*Math.PI)*Math.max(n.visualRadius*.2,2),z:u.z+Math.sin(f)*(d+n.visualRadius*.9)}}else if(a?.mode==="at"&&n.parentId){let l=i.get(n.parentId),u=l?lc(l,e,t,i,r,s):{x:0,y:0,z:0},d=n.anchorX??l?.x??t.x,h=n.anchorY??l?.y??t.y;c={x:u.x+(n.x-d),y:u.y,z:u.z+(n.y-h)}}else c={x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};return s.set(n.objectId,c),c}function od(n,e){let t=new Map(n.objects.map(s=>[s.objectId,s])),i=new Map,r=s=>{let o=i.get(s);if(o)return o;let a=t.get(s);if(!a)return{x:0,y:0,z:0};let c={...a.position};if(a.motion&&a.parentId){let l=r(a.parentId),u=Sm(a.motion,n.timeFrozen?0:e);c=Em(l,u)}return i.set(s,c),c};for(let s of n.objects)r(s.objectId);return i}function Sm(n,e){let t=n.phase0Deg+n.angularVelocityDegPerSecond*e,i=rd(t),r=rd(n.rotationDeg),s=rd(n.inclinationDeg),o=Math.cos(i)*n.semiMajor,a=Math.sin(i)*n.semiMinor,c=o*Math.cos(r)-a*Math.sin(r),l=o*Math.sin(r)+a*Math.cos(r);return{x:c,y:l*Math.sin(s),z:l*Math.cos(s)}}function ad(n,e,t,i){let r=n.placement;if(!r||r.mode!=="orbit")return null;let s=e?.radius??e?.rx??Jr(sd(r)*48,24,1200),o=e?.radius??e?.ry??s,a=Zb(r.period),c=sd(r),l=Jr(c/Math.max(t,1e-4),1,20),u=Jr(a?cc*l:cc*Math.pow(l,.75),cc,_m);return{phase0Deg:uc(r.phase)??0,rotationDeg:uc(r.angle)??e?.rotationDeg??0,inclinationDeg:uc(r.inclination)??0,semiMajor:s,semiMinor:o,eccentricity:r.eccentricity??0,periodSeconds:a,angularVelocityDegPerSecond:360/Math.max(u,.001),heuristic:a===null,frozen:i}}function sd(n){let e=wm(n.semiMajor)??wm(n.distance)??1;return Math.max(e,.01)}function wm(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/1495978707e-1;case"m":return n.value/149597870700;case"re":return n.value*6371/1495978707e-1;case"rj":return n.value*71492/1495978707e-1;case"sol":return n.value*695700/1495978707e-1;case"ly":return n.value*63241.077;case"pc":return n.value*206264.806;case"kpc":return n.value*206264806;default:return n.value}}function Zb(n){if(!n)return null;switch(n.unit){case"s":return n.value;case"min":return n.value*60;case"h":return n.value*3600;case"d":return n.value*Mm;case"y":return n.value*ac;case"ky":return n.value*ac*1e3;case"my":return n.value*ac*1e6;case"gy":return n.value*ac*1e9;default:return null}}function uc(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function Jb(n,e){return{...Kb(n),...e}}function Kb(n){switch(n){case"compact":return{orbitDistanceMultiplier:.92,bodyRadiusMultiplier:.92,markerSizeMultiplier:.92,ringThicknessMultiplier:.9,focusPadding:10,minBodyRadius:4,maxBodyRadius:34};case"presentation":return{orbitDistanceMultiplier:1.15,bodyRadiusMultiplier:1.12,markerSizeMultiplier:1.08,ringThicknessMultiplier:1.14,focusPadding:16,minBodyRadius:5,maxBodyRadius:44};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40}}}function Qb(n){if(n.length===0)return{minX:0,minY:0,minZ:0,maxX:0,maxY:0,maxZ:0,width:0,height:0,depth:0,center:{x:0,y:0,z:0}};let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of n)e=Math.min(e,a.position.x-a.visualRadius),t=Math.min(t,a.position.y-a.visualRadius),i=Math.min(i,a.position.z-a.visualRadius),r=Math.max(r,a.position.x+a.visualRadius),s=Math.max(s,a.position.y+a.visualRadius),o=Math.max(o,a.position.z+a.visualRadius);return{minX:e,minY:t,minZ:i,maxX:r,maxY:s,maxZ:o,width:r-e,height:s-t,depth:o-i,center:{x:(e+r)/2,y:(t+s)/2,z:(i+o)/2}}}function Em(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function e_(n){let e=0;for(let t=0;t<n.length;t+=1)e=e*31+n.charCodeAt(t)>>>0;return e%1e4/1e4}function Jr(n,e,t){return Math.min(Math.max(n,e),t)}function rd(n){return n*Math.PI/180}function lr(n,e={}){let t=cn(n,e),i=[],r=i_(n,i),s=r_(n,i),o=n_(n,t.renderPreset??e.preset??null,t.projection),a=n.system?t_(n,o,r,s,i,t.renderPreset??e.preset??null):null;return t.viewpoints.some(c=>!c.generated)&&i.push({code:"upgrade.viewpoints.structured",severity:"info",source:"upgrade",message:`Promoted ${t.viewpoints.filter(c=>!c.generated).length} document-defined viewpoint(s) into the 2.0 atlas section.`}),{format:"worldorbit",version:"2.5",schemaVersion:"2.5",sourceVersion:n.version,system:a,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:structuredClone(n.events??[]),objects:n.objects.map(Tm),diagnostics:i}}function cd(n,e={}){return m_(lr(n,e))}function go(n,e={}){let t=n.system?{type:"system",id:n.system.id,title:n.system.title,description:n.system.description,epoch:n.system.epoch,referencePlane:n.system.referencePlane,properties:h_(n.system),info:f_(n.system)}:null,i=n.objects.map(Tm);return c_(i,n.events??[],e.activeEventId??null),{format:"worldorbit",version:"1.0",schemaVersion:n.version,system:t,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:n.events.map(o_),objects:i}}function t_(n,e,t,i,r,s){let o=cn(n,{preset:s??void 0,projection:e.view});return{type:"system",id:n.system?.id??"WorldOrbit",title:n.system?.title??(typeof n.system?.properties.title=="string"?n.system.properties.title:null),description:n.system?.description??null,epoch:n.system?.epoch??null,referencePlane:n.system?.referencePlane??null,defaults:e,atlasMetadata:t,viewpoints:o.viewpoints.map(s_),annotations:i}}function n_(n,e,t){let i=typeof n.system?.properties.view=="string"?n.system.properties.view.toLowerCase():null;return{view:i==="topdown"||i==="isometric"||i==="orthographic"||i==="perspective"?i:t,scale:typeof n.system?.properties.scale=="string"?n.system.properties.scale:null,units:typeof n.system?.properties.units=="string"?n.system.properties.units:null,preset:e,theme:typeof n.system?.info["atlas.theme"]=="string"?n.system.info["atlas.theme"]:null}}function i_(n,e){let t={};for(let[r,s]of Object.entries(n.system?.info??{}))r.startsWith("viewpoint.")||r.startsWith("annotation.")||(t[r]=s);let i=Object.keys(t);return i.length>0&&e.push({code:"upgrade.atlasMetadata.preserved",severity:"warning",source:"upgrade",message:`Preserved ${i.length} system info entr${i.length===1?"y":"ies"} as atlas metadata in the 2.0 atlas document.`}),t}function r_(n,e){let t=new Map;for(let[i,r]of Object.entries(n.system?.info??{})){if(!i.startsWith("annotation."))continue;let[,s,...o]=i.split(".");if(!s||o.length===0)continue;let a=Am(s);if(!a)continue;let c=t.get(a)??{id:a};switch(o.join(".").toLowerCase()){case"label":c.label=r;break;case"target":case"object":c.targetObjectId=r.trim()||null;break;case"body":case"text":case"description":c.body=r;break;case"tags":c.tags=u_(r);break}t.set(a,c)}for(let i of n.objects){let r=i.info.description;if(!r)continue;let s=Am(`${i.id}-notes`);t.has(s)||(t.set(s,{id:s,label:`${i.id} Notes`,targetObjectId:i.id,body:r,tags:Array.isArray(i.properties.tags)?i.properties.tags.filter(o=>typeof o=="string"):[]}),e.push({code:"upgrade.annotation.objectDescription",severity:"info",source:"upgrade",message:`Lifted ${i.id}.info.description into structured atlas annotation "${s}".`,objectId:i.id,field:"description"}))}return[...t.values()].filter(i=>i.body||i.label).map(i=>({id:i.id,label:i.label??d_(i.id),targetObjectId:i.targetObjectId??null,body:i.body??"",tags:i.tags??[],sourceObjectId:i.targetObjectId??null})).sort((i,r)=>i.label.localeCompare(r.label))}function s_(n){return{id:n.id,label:n.label,summary:n.summary,focusObjectId:n.objectId,selectedObjectId:n.selectedObjectId,events:[...n.eventIds],projection:n.projection,preset:n.preset,zoom:n.scale,rotationDeg:n.rotationDeg,camera:n.camera?{...n.camera}:null,layers:{...n.layers},filter:n.filter?{query:n.filter.query,objectTypes:[...n.filter.objectTypes],tags:[...n.filter.tags],groupIds:[...n.filter.groupIds]}:null}}function Tm(n){return{...n,groups:n.groups?[...n.groups]:void 0,resonance:n.resonance?{...n.resonance}:n.resonance,renderHints:n.renderHints?{...n.renderHints}:n.renderHints,deriveRules:n.deriveRules?n.deriveRules.map(e=>({...e})):void 0,validationRules:n.validationRules?n.validationRules.map(e=>({...e})):void 0,lockedFields:n.lockedFields?[...n.lockedFields]:void 0,tolerances:n.tolerances?n.tolerances.map(e=>({field:e.field,value:e.value&&typeof e.value=="object"&&"value"in e.value?{value:e.value.value,unit:e.value.unit}:Array.isArray(e.value)?[...e.value]:e.value})):void 0,typedBlocks:n.typedBlocks?Object.fromEntries(Object.entries(n.typedBlocks).map(([e,t])=>[e,{...t??{}}])):void 0,properties:l_(n.properties),placement:n.placement?structuredClone(n.placement):null,info:{...n.info}}}function o_(n){return{...n,participantObjectIds:[...n.participantObjectIds],tags:[...n.tags],positions:n.positions.map(a_)}}function a_(n){return{objectId:n.objectId,placement:Im(n.placement),inner:n.inner?{...n.inner}:void 0,outer:n.outer?{...n.outer}:void 0,epoch:n.epoch??null,referencePlane:n.referencePlane??null}}function Im(n){return n?structuredClone(n):null}function c_(n,e,t){if(!t)return;let i=e.find(o=>o.id===t);if(!i)return;let r=new Map(n.map(o=>[o.id,o])),s=new Set([...i.targetObjectId?[i.targetObjectId]:[],...i.participantObjectIds,...i.positions.map(o=>o.objectId)]);for(let o of s){let a=r.get(o);a&&(i.epoch&&(a.epoch=i.epoch),i.referencePlane&&(a.referencePlane=i.referencePlane))}for(let o of i.positions){let a=r.get(o.objectId);a&&(o.placement&&(a.placement=Im(o.placement)),o.inner&&(a.properties.inner={...o.inner}),o.outer&&(a.properties.outer={...o.outer}),o.epoch&&(a.epoch=o.epoch),o.referencePlane&&(a.referencePlane=o.referencePlane))}}function l_(n){let e={};for(let[t,i]of Object.entries(n)){if(Array.isArray(i)){e[t]=[...i];continue}if(i&&typeof i=="object"&&"value"in i){e[t]={value:i.value,unit:i.unit};continue}e[t]=i}return e}function u_(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function Am(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function d_(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function h_(n){let e={};return n.title&&(e.title=n.title),e.view=n.defaults.view,n.defaults.scale&&(e.scale=n.defaults.scale),n.defaults.units&&(e.units=n.defaults.units),n.description&&(e.description=n.description),n.epoch&&(e.epoch=n.epoch),n.referencePlane&&(e.referencePlane=n.referencePlane),e}function f_(n){let e={...n.atlasMetadata};n.defaults.theme&&(e["atlas.theme"]=n.defaults.theme);for(let t of n.viewpoints){let i=`viewpoint.${t.id}`;e[`${i}.label`]=t.label,t.summary&&(e[`${i}.summary`]=t.summary),t.focusObjectId&&(e[`${i}.focus`]=t.focusObjectId),t.selectedObjectId&&(e[`${i}.select`]=t.selectedObjectId),t.projection&&(e[`${i}.projection`]=t.projection),t.preset&&(e[`${i}.preset`]=t.preset),t.zoom!==null&&(e[`${i}.zoom`]=String(t.zoom)),t.rotationDeg!==0&&(e[`${i}.rotation`]=String(t.rotationDeg)),t.camera?.azimuth!==null&&(e[`${i}.camera.azimuth`]=String(t.camera?.azimuth)),t.camera?.elevation!==null&&(e[`${i}.camera.elevation`]=String(t.camera?.elevation)),t.camera?.roll!==null&&(e[`${i}.camera.roll`]=String(t.camera?.roll)),t.camera?.distance!==null&&(e[`${i}.camera.distance`]=String(t.camera?.distance));let r=p_(t.layers);r&&(e[`${i}.layers`]=r),t.filter?.query&&(e[`${i}.query`]=t.filter.query),(t.filter?.objectTypes.length??0)>0&&(e[`${i}.types`]=t.filter?.objectTypes.join(" ")??""),(t.filter?.tags.length??0)>0&&(e[`${i}.tags`]=t.filter?.tags.join(" ")??""),(t.filter?.groupIds.length??0)>0&&(e[`${i}.groups`]=t.filter?.groupIds.join(" ")??""),t.events.length>0&&(e[`${i}.events`]=t.events.join(" "))}for(let t of n.annotations){let i=`annotation.${t.id}`;e[`${i}.label`]=t.label,t.targetObjectId&&(e[`${i}.target`]=t.targetObjectId),e[`${i}.body`]=t.body,t.tags.length>0&&(e[`${i}.tags`]=t.tags.join(" ")),t.sourceObjectId&&(e[`${i}.source`]=t.sourceObjectId)}return e}function p_(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e.join(" ")}function m_(n){return{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}}var Cm=["title","view","scale","units","kind","class","tags","color","image","hidden","orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"];function dc(n,e={}){let t=e.schema??"auto";if(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.0-draft"||n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.0-draft"){if(t==="2.0-draft"){let c=n.version==="2.0-draft"?n:n.version==="2.0"||n.version==="2.1"||n.version==="2.5"?{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}:cd(n);return Pm(c)}let a=n.version==="2.0"||n.version==="2.1"||n.version==="2.5"?n:n.version==="2.0-draft"?{...n,version:"2.0",schemaVersion:"2.0"}:lr(n);return(t==="2.0"||t==="2.1"||t==="2.5")&&a.version!==t?ld({...a,version:t,schemaVersion:t}):ld(a)}let r=[],s=n;s.system&&r.push(...g_(s.system));let o=[...s.objects].sort(hd);for(let a of o)r.length>0&&r.push(""),r.push(...v_(a));return r.join(`
3822
- `)}function ld(n){let e=[`schema ${n.version}`,""];n.system&&e.push(...Lm(n.system));for(let i of[...n.groups].sort(Qr))e.push(""),e.push(...Nm(i));for(let i of[...n.relations].sort(Qr))e.push(""),e.push(...Fm(i));for(let i of[...n.events].sort(Qr))e.push(""),e.push(...km(i));let t=[...n.objects].sort(hd);return t.length>0&&e.at(-1)!==""&&e.push(""),t.forEach((i,r)=>{r>0&&e.push(""),e.push(...Dm(i))}),e.join(`
3823
- `)}function Pm(n){let e=n.version==="2.0-draft"?n:{...n,version:"2.0-draft",schemaVersion:"2.0-draft"},t=["schema 2.0-draft",""];e.system&&t.push(...Lm(e.system));for(let r of[...e.groups].sort(Qr))t.push(""),t.push(...Nm(r));for(let r of[...e.relations].sort(Qr))t.push(""),t.push(...Fm(r));for(let r of[...e.events].sort(Qr))t.push(""),t.push(...km(r));let i=[...e.objects].sort(hd);return i.length>0&&t.at(-1)!==""&&t.push(""),i.forEach((r,s)=>{s>0&&t.push(""),t.push(...Dm(r))}),t.join(`
3824
- `)}function g_(n){return y_("system",n.id,n.properties,null,n.info)}function y_(n,e,t,i,r){let s=[`${n} ${e}`],o=[...ud(i),...Um(t)];for(let c of o)s.push(` ${c}`);let a=Object.entries(r).sort(([c],[l])=>c.localeCompare(l));if(a.length>0){o.length>0&&s.push(""),s.push(" info");for(let[c,l]of a)s.push(` ${c} ${qe(l)}`)}return s}function Lm(n){let e=[`system ${n.id}`];if(n.title&&e.push(` title ${qe(n.title)}`),n.description&&e.push(` description ${qe(n.description)}`),n.epoch&&e.push(` epoch ${qe(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${qe(n.referencePlane)}`),e.push(""),e.push("defaults"),e.push(` view ${n.defaults.view}`),n.defaults.scale&&e.push(` scale ${qe(n.defaults.scale)}`),n.defaults.units&&e.push(` units ${qe(n.defaults.units)}`),n.defaults.preset&&e.push(` preset ${n.defaults.preset}`),n.defaults.theme&&e.push(` theme ${qe(n.defaults.theme)}`),Object.keys(n.atlasMetadata).length>0){e.push(""),e.push("atlas"),e.push(" metadata");for(let[t,i]of Object.entries(n.atlasMetadata).sort(([r],[s])=>r.localeCompare(s)))e.push(` ${t} ${qe(i)}`)}for(let t of n.viewpoints)e.push(""),e.push(...b_(t));for(let t of n.annotations)e.push(""),e.push(...__(t));return e}function v_(n){return Om(n.type,n.id,n)}function Dm(n){return Om(`object ${n.type}`,n.id,n)}function Om(n,e,t){let i=[`${n} ${e}`],r=[...ud(t.placement),...Um(t.properties),...x_(t)];for(let o of r)i.push(` ${o}`);let s=Object.entries(t.info).sort(([o],[a])=>o.localeCompare(a));if(s.length>0){r.length>0&&i.push(""),i.push(" info");for(let[o,a]of s)i.push(` ${o} ${qe(a)}`)}for(let o of["climate","habitability","settlement"]){let a=Object.entries(t.typedBlocks?.[o]??{}).sort(([c],[l])=>c.localeCompare(l));if(a.length>0){i.push(""),i.push(` ${o}`);for(let[c,l]of a)i.push(` ${c} ${qe(l)}`)}}return i}function ud(n){if(!n)return[];switch(n.mode){case"orbit":return[`orbit ${n.target}`,...Di("distance",n.distance),...Di("semiMajor",n.semiMajor),...S_("eccentricity",n.eccentricity),...Di("period",n.period),...Di("angle",n.angle),...Di("inclination",n.inclination),...Di("phase",n.phase)];case"at":return[`at ${E_(n.reference)}`];case"surface":return[`surface ${n.target}`];case"free":return[`free ${n.distance?dd(n.distance):n.descriptor??""}`.trim()]}}function Um(n){return Object.keys(n).sort(T_).map(e=>`${e} ${Bm(n[e])}`)}function x_(n){let e=[];n.groups?.length&&e.push(`groups ${n.groups.join(" ")}`),n.epoch&&e.push(`epoch ${qe(n.epoch)}`),n.referencePlane&&e.push(`referencePlane ${qe(n.referencePlane)}`),n.tidalLock!==void 0&&e.push(`tidalLock ${n.tidalLock?"true":"false"}`),n.renderHints?.renderLabel!==void 0&&e.push(`renderLabel ${n.renderHints.renderLabel?"true":"false"}`),n.renderHints?.renderOrbit!==void 0&&e.push(`renderOrbit ${n.renderHints.renderOrbit?"true":"false"}`),n.renderHints?.renderPriority!==void 0&&e.push(`renderPriority ${n.renderHints.renderPriority}`),n.resonance&&e.push(`resonance ${n.resonance.targetObjectId} ${n.resonance.ratio}`);for(let t of n.deriveRules??[])e.push(`derive ${t.field} ${t.strategy}`);for(let t of n.validationRules??[])e.push(`validate ${t.rule}`);n.lockedFields?.length&&e.push(`locked ${n.lockedFields.join(" ")}`);for(let t of n.tolerances??[])e.push(`tolerance ${t.field} ${Bm(t.value)}`);return e}function b_(n){let e=[`viewpoint ${n.id}`,` label ${qe(n.label)}`];n.focusObjectId&&e.push(` focus ${n.focusObjectId}`),n.selectedObjectId&&n.selectedObjectId!==n.focusObjectId&&e.push(` select ${n.selectedObjectId}`),n.summary&&e.push(` summary ${qe(n.summary)}`),n.projection&&e.push(` projection ${n.projection}`),n.preset&&e.push(` preset ${n.preset}`),n.zoom!==null&&e.push(` zoom ${n.zoom}`),n.rotationDeg!==0&&e.push(` rotation ${n.rotationDeg}`),n.camera&&M_(n.camera)&&(e.push(" camera"),n.camera.azimuth!==null&&e.push(` azimuth ${n.camera.azimuth}`),n.camera.elevation!==null&&e.push(` elevation ${n.camera.elevation}`),n.camera.roll!==null&&e.push(` roll ${n.camera.roll}`),n.camera.distance!==null&&e.push(` distance ${n.camera.distance}`));let t=A_(n.layers);return t.length>0&&e.push(` layers ${t.join(" ")}`),n.events.length>0&&e.push(` events ${n.events.join(" ")}`),n.filter&&(e.push(" filter"),n.filter.query&&e.push(` query ${qe(n.filter.query)}`),n.filter.objectTypes.length>0&&e.push(` objectTypes ${n.filter.objectTypes.join(" ")}`),n.filter.tags.length>0&&e.push(` tags ${n.filter.tags.map(qe).join(" ")}`),n.filter.groupIds.length>0&&e.push(` groups ${n.filter.groupIds.join(" ")}`)),e}function __(n){let e=[`annotation ${n.id}`,` label ${qe(n.label)}`];return n.targetObjectId&&e.push(` target ${n.targetObjectId}`),e.push(` body ${qe(n.body)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(qe).join(" ")}`),e}function Nm(n){let e=[`group ${n.id}`,` label ${qe(n.label)}`];return n.summary&&e.push(` summary ${qe(n.summary)}`),n.color&&e.push(` color ${qe(n.color)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(qe).join(" ")}`),n.hidden&&e.push(" hidden true"),e}function Fm(n){let e=[`relation ${n.id}`];return n.from&&e.push(` from ${qe(n.from)}`),n.to&&e.push(` to ${qe(n.to)}`),n.kind&&e.push(` kind ${qe(n.kind)}`),n.label&&e.push(` label ${qe(n.label)}`),n.summary&&e.push(` summary ${qe(n.summary)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(qe).join(" ")}`),n.color&&e.push(` color ${qe(n.color)}`),n.hidden&&e.push(" hidden true"),e}function km(n){let e=[`event ${n.id}`,` kind ${qe(n.kind)}`];if(n.label&&e.push(` label ${qe(n.label)}`),n.summary&&e.push(` summary ${qe(n.summary)}`),n.targetObjectId&&e.push(` target ${n.targetObjectId}`),n.participantObjectIds.length>0&&e.push(` participants ${n.participantObjectIds.join(" ")}`),n.timing&&e.push(` timing ${qe(n.timing)}`),n.visibility&&e.push(` visibility ${qe(n.visibility)}`),n.epoch&&e.push(` epoch ${qe(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${qe(n.referencePlane)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(qe).join(" ")}`),n.color&&e.push(` color ${qe(n.color)}`),n.hidden&&e.push(" hidden true"),n.positions.length>0){e.push(""),e.push(" positions");for(let t of[...n.positions].sort(I_)){e.push(` pose ${t.objectId}`);for(let i of w_(t))e.push(` ${i}`)}}return e}function w_(n){return[...ud(n.placement),...n.epoch?[`epoch ${qe(n.epoch)}`]:[],...n.referencePlane?[`referencePlane ${qe(n.referencePlane)}`]:[],...Di("inner",n.inner),...Di("outer",n.outer)]}function M_(n){return n.azimuth!==null||n.elevation!==null||n.roll!==null||n.distance!==null}function Bm(n){return Array.isArray(n)?n.map(e=>qe(e)).join(" "):typeof n=="boolean"?n?"true":"false":typeof n=="number"?String(n):typeof n=="string"?qe(n):dd(n)}function dd(n){return`${n.value}${n.unit??""}`}function Di(n,e){return e?[`${n} ${dd(e)}`]:[]}function S_(n,e){return e===void 0?[]:[`${n} ${e}`]}function E_(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function A_(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e}function T_(n,e){let t=Cm.indexOf(n),i=Cm.indexOf(e);return t===-1&&i===-1?n.localeCompare(e):t===-1?1:i===-1?-1:t-i}function hd(n,e){let t=Rm(n.type),i=Rm(e.type);return t!==i?t-i:n.id.localeCompare(e.id)}function Qr(n,e){return n.id.localeCompare(e.id)}function I_(n,e){return n.objectId.localeCompare(e.objectId)}function Rm(n){switch(n){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":return 3;case"asteroid":return 4;case"comet":return 5;case"ring":return 6;case"structure":return 7;case"phenomenon":return 8}}function qe(n){return!/\s/.test(n)&&!n.includes('"')?n:`"${n.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}var zm=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,C_=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),R_=/^[A-Za-z][A-Za-z0-9+.-]*:/;function es(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function vo(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function fd(n,e,t){let i=n.match(zm);if(!i)throw Y.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=hn(t);if(s?.unitFamily&&!qa(s.unitFamily,r.unit))throw Y.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function pd(n){let e=n.match(zm);return e?{value:Number(e[1]),unit:e[2]??null}:null}function hc(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw Y.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function Oi(n,e,t){let i=C_.get(n.toLowerCase());if(i===void 0)throw Y.fromLocation(`Invalid boolean value "${n}" for "${e}"`,t);return i}function Vm(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw Y.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function P_(n,e){if(!n)throw Y.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw Y.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(R_);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw Y.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function $m(n,e,t){let i=hn(n);if(!i)throw Y.fromLocation(`Unknown field "${n}"`,t);if(i.arity==="single"&&e.length!==1)throw Y.fromLocation(`Field "${n}" expects exactly one value`,t);switch(i.kind){case"list":return e;case"boolean":return Oi(yo(e,n,t),n,t);case"number":return hc(yo(e,n,t),n,t);case"unit":return fd(yo(e,n,t),t,n);case"string":{let r=e.join(" ").trim();return n==="image"&&P_(r,t),r}}}function md(n,e,t){let i=hn(n);if(!i)throw Y.fromLocation(`Unknown field "${n}"`,t);if(!i.objectTypes.includes(e))throw Y.fromLocation(`Field "${n}" is not valid on "${e}"`,t)}function yo(n,e,t){if(n.length!==1)throw Y.fromLocation(`Field "${e}" expects exactly one value`,t);return n[0]}var Gm=new Set(["star","planet","moon","asteroid","comet"]),L_=332946.0487,D_=1047.3486,fc=1495978707e-1,O_=6371,U_=695700,N_=63241.077,F_=206264.806,k_=206264806;function xo(n,e){let t=[],i=new Map(n.objects.map(a=>[a.id,a])),r=new Set(n.groups.map(a=>a.id)),s=new Set(n.events.map(a=>a.id));n.system||t.push(st("validate.system.required","Atlas documents must declare exactly one system."));let o=new Map;for(let[a,c]of[["group",n.groups.map(l=>l.id)],["viewpoint",n.system?.viewpoints.map(l=>l.id)??[]],["annotation",n.system?.annotations.map(l=>l.id)??[]],["relation",n.relations.map(l=>l.id)],["event",n.events.map(l=>l.id)],["object",n.objects.map(l=>l.id)]])for(let l of c){let u=o.get(l);u?t.push(st("validate.id.duplicate",`Duplicate ${a} id "${l}" already used by ${u}.`)):o.set(l,a)}for(let a of n.relations)B_(a,i,t);for(let a of n.system?.viewpoints??[])z_(a,r,s,e,t,i);for(let a of n.objects)V_(a,n.system,i,r,t);for(let a of n.events)$_(a,n.system,i,t);return t}function B_(n,e,t){n.from?e.has(n.from)||t.push(st("validate.relation.from.unknown",`Unknown relation source "${n.from}" on "${n.id}".`)):t.push(st("validate.relation.from.required",`Relation "${n.id}" is missing a "from" target.`)),n.to?e.has(n.to)||t.push(st("validate.relation.to.unknown",`Unknown relation target "${n.to}" on "${n.id}".`)):t.push(st("validate.relation.to.required",`Relation "${n.id}" is missing a "to" target.`)),n.kind||t.push(st("validate.relation.kind.required",`Relation "${n.id}" is missing a "kind" value.`))}function z_(n,e,t,i,r,s){let o=n.filter;if(i==="2.1"||i==="2.5"){if(o)for(let a of o.groupIds)e.has(a)||r.push(_t("validate.viewpoint.group.unknown",`Unknown group "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.groups`));for(let a of n.events??[])t.has(a)||r.push(_t("validate.viewpoint.event.unknown",`Unknown event "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.events`))}W_(n.projection,r,`viewpoint.${n.id}.projection`,n.id),X_(n.camera,n.projection,n.rotationDeg,r,n.id,n.focusObjectId,n.selectedObjectId,o,s)}function V_(n,e,t,i,r){let s=n.placement,o=s?.mode==="orbit"?s:null,a=s?.mode==="orbit"?t.get(s.target)??null:null;if(n.groups)for(let c of n.groups)i.has(c)||r.push(_t("validate.group.unknown",`Unknown group "${c}" on "${n.id}".`,n.id,"groups"));if(typeof n.epoch=="string"&&!n.epoch.trim()&&r.push(_t("validate.epoch.empty",`Object "${n.id}" defines an empty epoch string.`,n.id,"epoch")),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&r.push(_t("validate.referencePlane.empty",`Object "${n.id}" defines an empty reference plane string.`,n.id,"referencePlane")),o&&(t.has(o.target)||r.push(st("validate.orbit.target.unknown",`Unknown placement target "${o.target}" on "${n.id}".`,n.id,"orbit")),o.distance&&o.semiMajor&&r.push(st("validate.orbit.distanceConflict",`Object "${n.id}" cannot declare both "distance" and "semiMajor".`,n.id,"distance")),o.phase&&!n.epoch&&!e?.epoch&&r.push(_t("validate.phase.epochMissing",`Object "${n.id}" sets "phase" without an object or system epoch.`,n.id,"phase")),o.inclination&&!n.referencePlane&&!e?.referencePlane&&r.push(_t("validate.inclination.referencePlaneMissing",`Object "${n.id}" sets "inclination" without an object or system reference plane.`,n.id,"inclination")),o.period&&!yd(a?.properties.mass)&&r.push(_t("validate.period.massMissing",`Object "${n.id}" sets "period" but its central mass cannot be derived.`,n.id,"period"))),s?.mode==="surface"){let c=t.get(s.target);c?Gm.has(c.type)||r.push(st("validate.surface.target.invalid",`Surface target "${s.target}" on "${n.id}" is not surface-capable.`,n.id,"surface")):r.push(st("validate.surface.target.unknown",`Unknown placement target "${s.target}" on "${n.id}".`,n.id,"surface"))}if(s?.mode==="at"&&(n.type!=="structure"&&n.type!=="phenomenon"&&r.push(st("validate.at.objectType",`Only structures and phenomena may use "at" placement; found "${n.type}" on "${n.id}".`,n.id,"at")),G_(n,t,r)||r.push(st("validate.at.target.unknown",`Unknown at-reference target "${s.target}" on "${n.id}".`,n.id,"at"))),n.resonance){let c=t.get(n.resonance.targetObjectId);c?(n.placement?.mode!=="orbit"||c.placement?.mode!=="orbit"||n.placement.target!==c.placement.target)&&r.push(_t("validate.resonance.orbitMismatch",`Resonance target "${n.resonance.targetObjectId}" on "${n.id}" does not share a compatible orbital parent.`,n.id,"resonance")):r.push(st("validate.resonance.target.unknown",`Unknown resonance target "${n.resonance.targetObjectId}" on "${n.id}".`,n.id,"resonance"))}for(let c of n.deriveRules??[]){if(c.field!=="period"||c.strategy!=="kepler"){r.push(_t("validate.derive.unsupported",`Unsupported derive rule "${c.field} ${c.strategy}" on "${n.id}".`,n.id,"derive"));continue}let l=Hm(n,a);if(l===null){r.push(_t("validate.derive.inputsMissing",`Object "${n.id}" requests "derive period kepler" but lacks enough input data.`,n.id,"derive"));continue}o?.period||r.push(gd("validate.derive.period.available",`Object "${n.id}" can derive a Kepler period of ${J_(l)}.`,n.id,"derive"))}for(let c of n.validationRules??[]){if(c.rule!=="kepler"){r.push(_t("validate.rule.unsupported",`Unsupported validation rule "${c.rule}" on "${n.id}".`,n.id,"validate"));continue}let l=jm(o?.period),u=Hm(n,a);if(l===null||u===null)continue;let d=Z_(n,"period");Math.abs(l-u)>d&&r.push(st("validate.kepler.mismatch",`Object "${n.id}" fails Kepler validation for "period".`,n.id,"validate"))}}function $_(n,e,t,i){let r=`event.${n.id}`,s=new Set;n.kind.trim()||i.push(st("validate.event.kind.required",`Event "${n.id}" is missing a "kind" value.`,void 0,`${r}.kind`)),typeof n.epoch=="string"&&!n.epoch.trim()&&i.push(_t("validate.event.epoch.empty",`Event "${n.id}" defines an empty epoch string.`,void 0,`${r}.epoch`)),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&i.push(_t("validate.event.referencePlane.empty",`Event "${n.id}" defines an empty reference plane string.`,void 0,`${r}.referencePlane`)),!n.targetObjectId&&n.participantObjectIds.length===0&&i.push(st("validate.event.references.required",`Event "${n.id}" must define a "target" or at least one participant.`,void 0,`${r}.participants`)),n.targetObjectId&&(s.add(n.targetObjectId),t.has(n.targetObjectId)||i.push(st("validate.event.target.unknown",`Unknown event target "${n.targetObjectId}" on "${n.id}".`,void 0,`${r}.target`)));let o=new Set;for(let l of n.participantObjectIds){if(s.add(l),o.has(l)){i.push(_t("validate.event.participants.duplicate",`Event "${n.id}" repeats participant "${l}".`,void 0,`${r}.participants`));continue}o.add(l),t.has(l)||i.push(st("validate.event.participants.unknown",`Unknown event participant "${l}" on "${n.id}".`,void 0,`${r}.participants`))}n.targetObjectId&&n.participantObjectIds.length>0&&!n.participantObjectIds.includes(n.targetObjectId)&&i.push(_t("validate.event.target.notParticipant",`Event "${n.id}" defines a target outside its participants list.`,void 0,`${r}.target`)),n.positions.length===0&&i.push(_t("validate.event.positions.missing",`Event "${n.id}" has no positions block and cannot drive a scene snapshot.`,void 0,`${r}.positions`)),/(?:^|[-_])(solar-eclipse|lunar-eclipse|transit|occultation)(?:$|[-_])/.test(n.kind)&&s.size<3&&i.push(_t("validate.event.kind.participants",`Event "${n.id}" looks like an eclipse or transit but references fewer than three bodies.`,void 0,`${r}.participants`));let a=new Set;for(let l of n.positions){let u=`${r}.pose.${l.objectId}`;if(a.has(l.objectId)){i.push(st("validate.event.pose.duplicate",`Event "${n.id}" defines "${l.objectId}" more than once in positions.`,void 0,u));continue}a.add(l.objectId);let d=t.get(l.objectId);if(!d){i.push(st("validate.event.pose.object.unknown",`Unknown event pose object "${l.objectId}" on "${n.id}".`,void 0,u));continue}s.has(l.objectId)||i.push(_t("validate.event.pose.unreferenced",`Event pose "${l.objectId}" on "${n.id}" is not listed in target/participants.`,void 0,u)),H_(l,d,n,e,t,i,u,n.id)}let c=[...s].filter(l=>!a.has(l));n.positions.length>0&&c.length>0&&i.push(_t("validate.event.positions.partial",`Event "${n.id}" leaves ${c.length} referenced object(s) on their base placement.`,void 0,`${r}.positions`))}function H_(n,e,t,i,r,s,o,a){let c=n.placement;if(!c){s.push(st("validate.event.pose.placement.required",`Event "${a}" pose "${n.objectId}" is missing a placement mode.`,void 0,o));return}if(c.mode==="orbit"){r.has(c.target)||s.push(st("validate.event.pose.orbit.target.unknown",`Unknown event orbit target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.orbit`)),c.distance&&c.semiMajor&&s.push(st("validate.event.pose.orbit.distanceConflict",`Event "${a}" pose "${n.objectId}" cannot declare both "distance" and "semiMajor".`,void 0,`${o}.distance`)),c.phase&&!Y_(i,e,t,n)&&s.push(_t("validate.event.pose.phase.epochMissing",`Event "${a}" pose "${n.objectId}" sets "phase" without an effective epoch.`,void 0,`${o}.phase`)),c.inclination&&!q_(i,e,t,n)&&s.push(_t("validate.event.pose.inclination.referencePlaneMissing",`Event "${a}" pose "${n.objectId}" sets "inclination" without an effective reference plane.`,void 0,`${o}.inclination`)),c.period&&!yd(r.get(c.target)?.properties.mass)&&s.push(_t("validate.event.pose.period.massMissing",`Event "${a}" pose "${n.objectId}" sets "period" but its central mass cannot be derived.`,void 0,`${o}.period`));return}if(c.mode==="surface"){let l=r.get(c.target);l?Gm.has(l.type)||s.push(st("validate.event.pose.surface.target.invalid",`Event surface target "${c.target}" on "${a}:${n.objectId}" is not surface-capable.`,void 0,`${o}.surface`)):s.push(st("validate.event.pose.surface.target.unknown",`Unknown event surface target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.surface`));return}if(c.mode==="at"){e.type!=="structure"&&e.type!=="phenomenon"&&s.push(st("validate.event.pose.at.objectType",`Only structures and phenomena may use "at" placement in events; found "${e.type}" on "${a}:${n.objectId}".`,void 0,`${o}.at`));let l=c.reference;l.kind==="named"&&!r.has(l.name)?s.push(st("validate.event.pose.at.target.unknown",`Unknown event at-reference target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):l.kind==="anchor"&&!r.has(l.objectId)?s.push(st("validate.event.pose.anchor.target.unknown",`Unknown event anchor target "${l.objectId}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):l.kind==="lagrange"&&(r.has(l.primary)?l.secondary&&!r.has(l.secondary)&&s.push(st("validate.event.pose.lagrange.secondary.unknown",`Unknown event Lagrange target "${l.secondary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):s.push(st("validate.event.pose.lagrange.primary.unknown",`Unknown event Lagrange target "${l.primary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)))}}function G_(n,e,t){let i=n.placement?.mode==="at"?n.placement.reference:null;return i?i.kind==="named"?e.has(i.name):i.kind==="anchor"?e.has(i.objectId)?!0:(t.push(st("validate.anchor.target.unknown",`Unknown anchor target "${i.objectId}" on "${n.id}".`,n.id,"at")),!1):e.has(i.primary)?i.secondary&&!e.has(i.secondary)?(t.push(st("validate.lagrange.secondary.unknown",`Unknown Lagrange reference "${i.secondary}" on "${n.id}".`,n.id,"at")),!1):!0:(t.push(st("validate.lagrange.primary.unknown",`Unknown Lagrange reference "${i.primary}" on "${n.id}".`,n.id,"at")),!1):!0}function Hm(n,e){let t=n.placement;if(!t||t.mode!=="orbit")return null;let i=j_(t.semiMajor??t.distance),r=yd(e?.properties.mass);return i===null||r===null||r<=0?null:Math.sqrt(i**3/r)*365.25}function j_(n){if(!n)return null;switch(n.unit){case null:case"au":return n.value;case"km":return n.value/fc;case"m":return n.value/(fc*1e3);case"ly":return n.value*N_;case"pc":return n.value*F_;case"kpc":return n.value*k_;case"re":return n.value*O_/fc;case"sol":return n.value*U_/fc;default:return null}}function yd(n){if(!n||typeof n!="object"||!("value"in n))return null;let e=n;switch(e.unit){case null:case"sol":return e.value;case"me":return e.value/L_;case"mj":return e.value/D_;default:return null}}function jm(n){if(!n)return null;switch(n.unit){case null:case"d":return n.value;case"s":return n.value/86400;case"min":return n.value/1440;case"h":return n.value/24;case"y":return n.value*365.25;case"ky":return n.value*365250;case"my":return n.value*36525e4;case"gy":return n.value*36525e7;default:return null}}function W_(n,e,t,i){n!=="topdown"&&n!=="isometric"&&n!=="orthographic"&&n!=="perspective"&&e.push(st("validate.viewpoint.projection.invalid",`Unknown projection "${String(n)}" in viewpoint "${i}".`,void 0,t))}function X_(n,e,t,i,r,s,o,a,c){if(!n)return;let l=`viewpoint.${r}.camera`;for(let[d,h]of[["azimuth",n.azimuth],["elevation",n.elevation],["roll",n.roll],["distance",n.distance]])h!==null&&(!Number.isFinite(h)||d==="distance"&&h<=0)&&i.push(st("validate.viewpoint.camera.invalid",`Invalid camera ${d} "${String(h)}" in viewpoint "${r}".`,void 0,`${l}.${d}`));n.distance!==null&&e!=="perspective"&&i.push(_t("validate.viewpoint.camera.distance.partialEffect",`Camera "distance" only has a semantic effect in perspective viewpoints; "${r}" uses "${e}".`,void 0,`${l}.distance`)),e==="topdown"&&(n.elevation!==null||n.roll!==null)&&i.push(_t("validate.viewpoint.camera.topdownPartial",`Camera elevation/roll on topdown viewpoint "${r}" are currently stored for future 3D use and only partially affect 2D rendering.`,void 0,l)),e==="isometric"&&n.elevation!==null&&i.push(gd("validate.viewpoint.camera.isometricStored",`Camera elevation on isometric viewpoint "${r}" is preserved semantically for future 3D rendering.`,void 0,`${l}.elevation`)),n.azimuth!==null&&n.azimuth!==0&&t!==0&&i.push(_t("validate.viewpoint.rotation.cameraOverlap",`Viewpoint "${r}" uses camera.azimuth; keep "rotation" only for 2D screen rotation to avoid ambiguity.`,void 0,`${l}.azimuth`)),s!==null&&c.has(s)||o!==null&&c.has(o)||a||i.push(gd("validate.viewpoint.camera.anchorMissing",`Viewpoint "${r}" stores camera settings without a focus object, selection, or filter anchor.`,void 0,l))}function Y_(n,e,t,i){return Ui(i?.epoch)??Ui(t?.epoch)??Ui(e.epoch)??Ui(n?.epoch)??null}function q_(n,e,t,i){return Ui(i?.referencePlane)??Ui(t?.referencePlane)??Ui(e.referencePlane)??Ui(n?.referencePlane)??null}function Ui(n){return typeof n=="string"&&n.trim()?n.trim():null}function Z_(n,e){let t=n.tolerances?.find(i=>i.field===e)?.value;return typeof t=="number"?t:t&&typeof t=="object"&&"value"in t?jm(t)??0:0}function J_(n){return`${Math.round(n*100)/100}d`}function st(n,e,t,i){return{code:n,severity:"error",source:"validate",message:e,objectId:t,field:i}}function _t(n,e,t,i){return{code:n,severity:"warning",source:"validate",message:e,objectId:t,field:i}}function gd(n,e,t,i){return{code:n,severity:"info",source:"validate",message:e,objectId:t,field:i}}var K_=new Set(["climate","habitability","settlement"]),mc=new Map;for(let n of["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","kind","class","culture","tags","color","image","hidden","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"]){let e=hn(n);e&&mc.set(n,{key:n,version:"2.0",inlineMode:e.arity==="multiple"?"multiple":"single",allowRepeat:!1,legacySchema:e})}for(let n of[{key:"groups",inlineMode:"multiple",allowRepeat:!1},{key:"epoch",inlineMode:"single",allowRepeat:!1},{key:"referencePlane",inlineMode:"single",allowRepeat:!1},{key:"tidalLock",inlineMode:"single",allowRepeat:!1},{key:"renderLabel",inlineMode:"single",allowRepeat:!1},{key:"renderOrbit",inlineMode:"single",allowRepeat:!1},{key:"renderPriority",inlineMode:"single",allowRepeat:!1},{key:"resonance",inlineMode:"pair",allowRepeat:!1},{key:"derive",inlineMode:"pair",allowRepeat:!0},{key:"validate",inlineMode:"single",allowRepeat:!0},{key:"locked",inlineMode:"multiple",allowRepeat:!1},{key:"tolerance",inlineMode:"pair",allowRepeat:!0}])mc.set(n.key,{key:n.key,version:"2.1",inlineMode:n.inlineMode,allowRepeat:n.allowRepeat});var Q_=new Set(mc.keys()),Xm=new Set(["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","inner","outer","epoch","referencePlane"]);function vd(n){return ew(n)}function ew(n,e){let t=zw(n),i=t.source.split(/\r?\n/),r=[],s=!1,o="2.0",a=null,c=null,l=[],u=[],d=[],h=[],f=new Map,p=!1,y=!1,g=new Set,m=new Set,v=new Set,x=new Set,w=new Set;for(let b=0;b<i.length;b++){let D=i[b],z=b+1;if(!D.trim())continue;let F=Za(D),$=ro(D.slice(F),{line:z,columnOffset:F});if($.length!==0){if(!s){o=tw($,z),s=!0,t.comments.length>0&&gc(o,"2.1")&&r.push({code:"parse.schema21.commentCompatibility",severity:"warning",source:"parse",message:`Comments require schema 2.1; parsed in compatibility mode because the document header is "schema ${o}".`,line:t.comments[0].line,column:t.comments[0].column});continue}if(F===0){c=nw($,z,o,r,a,l,u,d,h,f,g,m,v,x,w,{sawDefaults:p,sawAtlas:y}),c.kind==="system"?a=c.system:c.kind==="defaults"?p=!0:c.kind==="atlas"&&(y=!0);continue}if(!c)throw new Y("Indented line without parent atlas section",z,F+1);uw(c,F,$,z)}}if(!s)throw new Y('Missing required atlas schema header "schema 2.0"');let O=l.map(b=>Cw(b,o,r)),I=h.map(b=>Rw(b,f.get(b.id)??[])),R=e??(o==="2.0-draft"?"2.0":o),U={format:"worldorbit",sourceVersion:"1.0",system:a,groups:u,relations:d,events:I,objects:O,diagnostics:r};if(R==="2.0-draft"){let b={...U,version:"2.0-draft",schemaVersion:"2.0-draft"};return b.diagnostics.push(...xo(b,o)),b}let _={...U,version:R,schemaVersion:R};return o==="2.0-draft"&&_.diagnostics.push({code:"load.schema.deprecatedDraft",severity:"warning",source:"upgrade",message:'Source header "schema 2.0-draft" is deprecated; canonical v2 documents now use "schema 2.0".'}),_.diagnostics.push(...xo(_,o)),_}function tw(n,e){if(n.length!==2||n[0].value.toLowerCase()!=="schema"||!["2.0-draft","2.0","2.1","2.5"].includes(n[1].value.toLowerCase()))throw new Y('Expected atlas header "schema 2.0", "schema 2.1", "schema 2.5", or legacy "schema 2.0-draft"',e,n[0]?.column??1);let t=n[1].value.toLowerCase();return t==="2.5"?"2.5":t==="2.1"?"2.1":t==="2.0-draft"?"2.0-draft":"2.0"}function nw(n,e,t,i,r,s,o,a,c,l,u,d,h,f,p,y){switch(n[0]?.value.toLowerCase()){case"system":if(r)throw new Y('Atlas section "system" may only appear once',e,n[0].column);return iw(n,e,t,i);case"defaults":if(!r)throw new Y('Atlas section "defaults" requires a preceding system declaration',e,n[0].column);if(y.sawDefaults)throw new Y('Atlas section "defaults" may only appear once',e,n[0].column);return{kind:"defaults",system:r,sourceSchemaVersion:t,diagnostics:i,seenFields:new Set};case"atlas":if(!r)throw new Y('Atlas section "atlas" requires a preceding system declaration',e,n[0].column);if(y.sawAtlas)throw new Y('Atlas section "atlas" may only appear once',e,n[0].column);return{kind:"atlas",system:r,inMetadata:!1,metadataIndent:null};case"viewpoint":if(!r)throw new Y('Atlas section "viewpoint" requires a preceding system declaration',e,n[0].column);return rw(n,e,r,u,t,i);case"annotation":if(!r)throw new Y('Atlas section "annotation" requires a preceding system declaration',e,n[0].column);return sw(n,e,r,d);case"group":return En(t,i,"group",{line:e,column:n[0].column}),ow(n,e,o,h);case"relation":return En(t,i,"relation",{line:e,column:n[0].column}),aw(n,e,a,f);case"event":return En(t,i,"event",{line:e,column:n[0].column}),cw(n,e,c,l,p,t,i);case"object":return lw(n,e,t,i,s);default:throw new Y(`Unknown atlas section "${n[0]?.value??""}"`,e,n[0]?.column??1)}}function iw(n,e,t,i){if(n.length!==2)throw new Y("Invalid atlas system declaration",e,n[0]?.column??1);return{kind:"system",system:{type:"system",id:n[1].value,title:null,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},sourceSchemaVersion:t,diagnostics:i,seenFields:new Set}}function rw(n,e,t,i,r,s){if(n.length!==2)throw new Y("Invalid viewpoint declaration",e,n[0]?.column??1);let o=es(n[1].value);if(!o)throw new Y("Viewpoint id must not be empty",e,n[1].column);if(i.has(o))throw new Y(`Duplicate viewpoint id "${o}"`,e,n[1].column);let a={id:o,label:vo(o),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:t.defaults.view,preset:t.defaults.preset,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null};return t.viewpoints.push(a),i.add(o),{kind:"viewpoint",viewpoint:a,sourceSchemaVersion:r,diagnostics:s,seenFields:new Set,inFilter:!1,filterIndent:null,seenFilterFields:new Set,inCamera:!1,cameraIndent:null,seenCameraFields:new Set}}function sw(n,e,t,i){if(n.length!==2)throw new Y("Invalid annotation declaration",e,n[0]?.column??1);let r=es(n[1].value);if(!r)throw new Y("Annotation id must not be empty",e,n[1].column);if(i.has(r))throw new Y(`Duplicate annotation id "${r}"`,e,n[1].column);let s={id:r,label:vo(r),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return t.annotations.push(s),i.add(r),{kind:"annotation",annotation:s,seenFields:new Set}}function ow(n,e,t,i){if(n.length!==2)throw new Y("Invalid group declaration",e,n[0]?.column??1);let r=es(n[1].value);if(!r)throw new Y("Group id must not be empty",e,n[1].column);if(i.has(r))throw new Y(`Duplicate group id "${r}"`,e,n[1].column);let s={id:r,label:vo(r),summary:"",color:null,tags:[],hidden:!1};return t.push(s),i.add(r),{kind:"group",group:s,seenFields:new Set}}function aw(n,e,t,i){if(n.length!==2)throw new Y("Invalid relation declaration",e,n[0]?.column??1);let r=es(n[1].value);if(!r)throw new Y("Relation id must not be empty",e,n[1].column);if(i.has(r))throw new Y(`Duplicate relation id "${r}"`,e,n[1].column);let s={id:r,from:"",to:"",kind:"",label:null,summary:null,tags:[],color:null,hidden:!1};return t.push(s),i.add(r),{kind:"relation",relation:s,seenFields:new Set}}function cw(n,e,t,i,r,s,o){if(n.length!==2)throw new Y("Invalid event declaration",e,n[0]?.column??1);let a=es(n[1].value);if(!a)throw new Y("Event id must not be empty",e,n[1].column);if(r.has(a))throw new Y(`Duplicate event id "${a}"`,e,n[1].column);let c={id:a,kind:"",label:vo(a),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},l=[];return t.push(c),i.set(a,l),r.add(a),{kind:"event",event:c,sourceSchemaVersion:s,diagnostics:o,seenFields:new Set,rawPoses:l,inPositions:!1,positionsIndent:null,activePose:null,poseIndent:null,activePoseSeenFields:new Set}}function lw(n,e,t,i,r){if(n.length<3)throw new Y("Invalid atlas object declaration",e,n[0]?.column??1);let s=n[1],o=n[2],a=s.value;if(!Ya.has(a)||a==="system")throw new Y(`Unknown object type "${s.value}"`,e,s.column);let c={objectType:a,id:o.value,fields:Tw(n.slice(3),e,a,t,i),infoEntries:[],typedBlockEntries:{},location:{line:e,column:s.column}};return r.push(c),{kind:"object",objectNode:c,sourceSchemaVersion:t,diagnostics:i,activeBlock:null,blockIndent:null,seenInfoKeys:new Set,seenTypedBlockKeys:{}}}function uw(n,e,t,i){switch(n.kind){case"system":dw(n,t,i);return;case"defaults":hw(n,t,i);return;case"atlas":fw(n,e,t,i);return;case"viewpoint":pw(n,e,t,i);return;case"annotation":yw(n,t,i);return;case"group":vw(n,t,i);return;case"relation":xw(n,t,i);return;case"event":bw(n,e,t,i);return;case"object":ww(n,e,t,i);return}}function dw(n,e,t){let i=ri(e,n.seenFields,t),r=ft(e,t);switch(i){case"title":n.system.title=r;return;case"description":En(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.description=r;return;case"epoch":En(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.epoch=r;return;case"referenceplane":En(n.sourceSchemaVersion,n.diagnostics,"referencePlane",{line:t,column:e[0].column}),n.system.referencePlane=r;return;default:throw new Y(`Unknown system atlas field "${e[0].value}"`,t,e[0].column)}}function hw(n,e,t){let i=ri(e,n.seenFields,t),r=ft(e,t);switch(i){case"view":qm(r)&&ur(n.sourceSchemaVersion,n.diagnostics,"defaults.view",{line:t,column:e[0].column}),n.system.defaults.view=Ym(r,t,e[0].column);return;case"scale":n.system.defaults.scale=r;return;case"units":n.system.defaults.units=r;return;case"preset":n.system.defaults.preset=Zm(r,t,e[0].column);return;case"theme":n.system.defaults.theme=r;return;default:throw new Y(`Unknown defaults field "${e[0].value}"`,t,e[0].column)}}function fw(n,e,t,i){if(n.inMetadata&&e<=(n.metadataIndent??0)&&(n.inMetadata=!1,n.metadataIndent=null),n.inMetadata){let r=Jm(t,i,"Invalid atlas metadata entry");if(r.key in n.system.atlasMetadata)throw new Y(`Duplicate atlas metadata key "${r.key}"`,i,t[0].column);n.system.atlasMetadata[r.key]=r.value;return}if(t.length===1&&t[0].value.toLowerCase()==="metadata"){n.inMetadata=!0,n.metadataIndent=e;return}throw new Y(`Unknown atlas field "${t[0].value}"`,i,t[0].column)}function pw(n,e,t,i){if(n.inCamera&&e<=(n.cameraIndent??0)&&(n.inCamera=!1,n.cameraIndent=null),n.inFilter&&e<=(n.filterIndent??0)&&(n.inFilter=!1,n.filterIndent=null),n.inCamera){mw(n,t,i);return}if(n.inFilter){gw(n,t,i);return}if(t.length===1&&t[0].value.toLowerCase()==="camera"){if(ur(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.seenFields.has("camera"))throw new Y('Duplicate viewpoint field "camera"',i,t[0].column);n.seenFields.add("camera"),n.inCamera=!0,n.cameraIndent=e,n.viewpoint.camera=n.viewpoint.camera??bd();return}if(t.length===1&&t[0].value.toLowerCase()==="filter"){if(n.seenFields.has("filter"))throw new Y('Duplicate viewpoint field "filter"',i,t[0].column);n.seenFields.add("filter"),n.inFilter=!0,n.filterIndent=e;return}let r=ri(t,n.seenFields,i),s=ft(t,i);switch(r){case"label":n.viewpoint.label=s;return;case"summary":n.viewpoint.summary=s;return;case"focus":n.viewpoint.focusObjectId=s;return;case"select":n.viewpoint.selectedObjectId=s;return;case"projection":qm(s)&&ur(n.sourceSchemaVersion,n.diagnostics,"projection",{line:i,column:t[0].column}),n.viewpoint.projection=Ym(s,i,t[0].column);return;case"preset":n.viewpoint.preset=Zm(s,i,t[0].column);return;case"zoom":n.viewpoint.zoom=xd(s,i,t[0].column,"zoom");return;case"rotation":n.viewpoint.rotationDeg=Fi(s,i,t[0].column,"rotation");return;case"camera":ur(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.viewpoint.camera=Aw(t.slice(1),i,n.viewpoint.camera);return;case"layers":n.viewpoint.layers=Sw(t.slice(1),i,n.sourceSchemaVersion,n.diagnostics);return;case"events":En(n.sourceSchemaVersion,n.diagnostics,"viewpoint.events",{line:i,column:t[0].column}),n.viewpoint.events=Vn(t.slice(1),i,"events");return;default:throw new Y(`Unknown viewpoint field "${t[0].value}"`,i,t[0].column)}}function mw(n,e,t){let i=ri(e,n.seenCameraFields,t),r=ft(e,t),s=n.viewpoint.camera??bd();switch(i){case"azimuth":s.azimuth=Fi(r,t,e[0].column,"camera.azimuth");break;case"elevation":s.elevation=Fi(r,t,e[0].column,"camera.elevation");break;case"roll":s.roll=Fi(r,t,e[0].column,"camera.roll");break;case"distance":s.distance=xd(r,t,e[0].column,"camera.distance");break;default:throw new Y(`Unknown viewpoint camera field "${e[0].value}"`,t,e[0].column)}n.viewpoint.camera=s}function gw(n,e,t){let i=ri(e,n.seenFilterFields,t),r=n.viewpoint.filter??Ew();switch(i){case"query":r.query=ft(e,t);break;case"objecttypes":r.objectTypes=Mw(e.slice(1),t);break;case"tags":r.tags=Vn(e.slice(1),t,"tags");break;case"groups":r.groupIds=Vn(e.slice(1),t,"groups");break;default:throw new Y(`Unknown viewpoint filter field "${e[0].value}"`,t,e[0].column)}n.viewpoint.filter=r}function yw(n,e,t){switch(ri(e,n.seenFields,t)){case"label":n.annotation.label=ft(e,t);return;case"target":n.annotation.targetObjectId=ft(e,t);return;case"body":n.annotation.body=ft(e,t);return;case"tags":n.annotation.tags=Vn(e.slice(1),t,"tags");return;default:throw new Y(`Unknown annotation field "${e[0].value}"`,t,e[0].column)}}function vw(n,e,t){switch(ri(e,n.seenFields,t)){case"label":n.group.label=ft(e,t);return;case"summary":n.group.summary=ft(e,t);return;case"color":n.group.color=ft(e,t);return;case"tags":n.group.tags=Vn(e.slice(1),t,"tags");return;case"hidden":n.group.hidden=Oi(ft(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new Y(`Unknown group field "${e[0].value}"`,t,e[0].column)}}function xw(n,e,t){switch(ri(e,n.seenFields,t)){case"from":n.relation.from=ft(e,t);return;case"to":n.relation.to=ft(e,t);return;case"kind":n.relation.kind=ft(e,t);return;case"label":n.relation.label=ft(e,t);return;case"summary":n.relation.summary=ft(e,t);return;case"tags":n.relation.tags=Vn(e.slice(1),t,"tags");return;case"color":n.relation.color=ft(e,t);return;case"hidden":n.relation.hidden=Oi(ft(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new Y(`Unknown relation field "${e[0].value}"`,t,e[0].column)}}function bw(n,e,t,i){if(n.activePose&&e<=(n.poseIndent??0)&&(n.activePose=null,n.poseIndent=null,n.activePoseSeenFields.clear()),!n.activePose&&n.inPositions&&e<=(n.positionsIndent??0)&&(n.inPositions=!1,n.positionsIndent=null),n.activePose){(t[0]?.value==="epoch"||t[0]?.value==="referencePlane")&&ur(n.sourceSchemaVersion,n.diagnostics,`pose.${t[0].value}`,{line:i,column:t[0]?.column??1}),n.activePose.fields.push(_w(t,i,n.activePoseSeenFields));return}if(n.inPositions){if(t.length!==2||t[0].value.toLowerCase()!=="pose")throw new Y(`Unknown event positions field "${t[0].value}"`,i,t[0]?.column??1);let s=t[1].value;if(!s.trim())throw new Y("Event pose object id must not be empty",i,t[1].column);let o={objectId:s,fields:[],location:{line:i,column:t[0].column}};n.rawPoses.push(o),n.activePose=o,n.poseIndent=e,n.activePoseSeenFields=new Set;return}if(t.length===1&&t[0].value.toLowerCase()==="positions"){if(n.seenFields.has("positions"))throw new Y('Duplicate event field "positions"',i,t[0].column);n.seenFields.add("positions"),n.inPositions=!0,n.positionsIndent=e;return}switch(ri(t,n.seenFields,i)){case"kind":n.event.kind=ft(t,i);return;case"label":n.event.label=ft(t,i);return;case"summary":n.event.summary=ft(t,i);return;case"target":n.event.targetObjectId=ft(t,i);return;case"participants":n.event.participantObjectIds=Vn(t.slice(1),i,"participants");return;case"timing":n.event.timing=ft(t,i);return;case"visibility":n.event.visibility=ft(t,i);return;case"epoch":ur(n.sourceSchemaVersion,n.diagnostics,"event.epoch",{line:i,column:t[0].column}),n.event.epoch=ft(t,i);return;case"referenceplane":ur(n.sourceSchemaVersion,n.diagnostics,"event.referencePlane",{line:i,column:t[0].column}),n.event.referencePlane=ft(t,i);return;case"tags":n.event.tags=Vn(t.slice(1),i,"tags");return;case"color":n.event.color=ft(t,i);return;case"hidden":n.event.hidden=Oi(ft(t,i),"hidden",{line:i,column:t[0].column});return;default:throw new Y(`Unknown event field "${t[0].value}"`,i,t[0].column)}}function _w(n,e,t){if(n.length<2)throw new Y("Invalid event pose field line",e,n[0]?.column??1);let i=n[0].value;if(!Xm.has(i))throw new Y(`Unknown event pose field "${i}"`,e,n[0].column);if(t.has(i))throw new Y(`Duplicate event pose field "${i}"`,e,n[0].column);return t.add(i),{type:"field",key:i,values:n.slice(1).map(r=>r.value),location:{line:e,column:n[0].column}}}function ww(n,e,t,i){if(n.activeBlock&&e<=(n.blockIndent??0)&&(n.activeBlock=null,n.blockIndent=null),t.length===1){let r=t[0].value.toLowerCase();if(r==="info"||K_.has(r)){r!=="info"&&En(n.sourceSchemaVersion,n.diagnostics,r,{line:i,column:t[0].column}),n.activeBlock=r,n.blockIndent=e;return}}if(n.activeBlock){let r=Jm(t,i,`Invalid ${n.activeBlock} entry`);if(n.activeBlock==="info"){if(n.seenInfoKeys.has(r.key))throw new Y(`Duplicate info key "${r.key}"`,i,t[0].column);n.seenInfoKeys.add(r.key),n.objectNode.infoEntries.push(r);return}let s=n.activeBlock,o=n.seenTypedBlockKeys[s]??(n.seenTypedBlockKeys[s]=new Set);if(o.has(r.key))throw new Y(`Duplicate ${s} key "${r.key}"`,i,t[0].column);o.add(r.key),(n.objectNode.typedBlockEntries[s]??(n.objectNode.typedBlockEntries[s]=[])).push(r);return}n.objectNode.fields.push(Iw(t,i,n.objectNode.objectType,n.sourceSchemaVersion,n.diagnostics))}function ri(n,e,t){if(n.length<2)throw new Y("Invalid atlas field line",t,n[0]?.column??1);let i=n[0].value.toLowerCase();if(e.has(i))throw new Y(`Duplicate atlas field "${n[0].value}"`,t,n[0].column);return e.add(i),i}function ft(n,e){if(n.length<2)throw new Y("Missing value for atlas field",e,n[0]?.column??1);return n.slice(1).map(t=>t.value).join(" ").trim()}function Mw(n,e){return Vn(n,e,"objectTypes").filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function Sw(n,e,t,i){let r={};for(let s of Vn(n,e,"layers")){let o=!s.startsWith("-")&&!s.startsWith("!"),a=s.replace(/^[-!]+/,"").toLowerCase();if(a==="orbits"){r["orbits-back"]=o,r["orbits-front"]=o;continue}(a==="background"||a==="guides"||a==="orbits-back"||a==="orbits-front"||a==="relations"||a==="events"||a==="objects"||a==="labels"||a==="metadata")&&(a==="events"&&t&&i&&En(t,i,"layers.events",{line:e,column:n[0]?.column??1}),r[a]=o)}return r}function Vn(n,e,t){if(n.length===0)throw new Y(`Missing value for atlas field "${t}"`,e,1);let i=n.map(r=>r.value).filter(Boolean);if(i.length===0)throw new Y(`Missing value for atlas field "${t}"`,e,n[0]?.column??1);return i}function Ym(n,e,t){let i=n.toLowerCase();if(i!=="topdown"&&i!=="isometric"&&i!=="orthographic"&&i!=="perspective")throw new Y(`Unknown projection "${n}"`,e,t);return i}function qm(n){let e=n.toLowerCase();return e==="orthographic"||e==="perspective"}function Zm(n,e,t){let i=n.toLowerCase();if(i==="diagram"||i==="presentation"||i==="atlas-card"||i==="markdown")return i;throw new Y(`Unknown render preset "${n}"`,e,t)}function xd(n,e,t,i){let r=Fi(n,e,t,i);if(r<=0)throw new Y(`Field "${i}" must be greater than zero`,e,t);return r}function Fi(n,e,t,i){let r=Number(n);if(!Number.isFinite(r))throw new Y(`Invalid numeric value "${n}" for "${i}"`,e,t);return r}function Ew(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function bd(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Aw(n,e,t){if(n.length===0||n.length%2!==0)throw new Y('Field "camera" expects "<field> <value>" pairs',e,n[0]?.column??1);let i=t?{...t}:bd(),r=new Set;for(let s=0;s<n.length;s+=2){let o=n[s],a=n[s+1],c=o.value.toLowerCase();if(r.has(c))throw new Y(`Duplicate viewpoint camera field "${o.value}"`,e,o.column);r.add(c);let l=a.value;switch(c){case"azimuth":i.azimuth=Fi(l,e,o.column,"camera.azimuth");break;case"elevation":i.elevation=Fi(l,e,o.column,"camera.elevation");break;case"roll":i.roll=Fi(l,e,o.column,"camera.roll");break;case"distance":i.distance=xd(l,e,o.column,"camera.distance");break;default:throw new Y(`Unknown viewpoint camera field "${o.value}"`,e,o.column)}}return i}function Tw(n,e,t,i,r){let s=[],o=0;for(;o<n.length;){let a=n[o],c=bo(a.value);if(!c)throw new Y(`Unknown field "${a.value}"`,e,a.column);c.version==="2.1"&&En(i,r,a.value,{line:e,column:a.column}),o++;let l=[];if(c.inlineMode==="single"){let u=n[o];u&&(l.push(u),o++)}else if(c.inlineMode==="pair")for(let u=0;u<2;u++){let d=n[o];if(!d)break;l.push(d),o++}else for(;o<n.length&&!Q_.has(n[o].value);)l.push(n[o]),o++;if(l.length===0)throw new Y(`Missing value for field "${a.value}"`,e,a.column);s.push({type:"field",key:a.value,values:l.map(u=>u.value),location:{line:e,column:a.column}})}return tg(s,t),s}function Iw(n,e,t,i,r){if(n.length<2)throw new Y("Invalid field line",e,n[0]?.column??1);let s=bo(n[0].value);if(!s)throw new Y(`Unknown field "${n[0].value}"`,e,n[0].column);s.version==="2.1"&&En(i,r,n[0].value,{line:e,column:n[0].column});let o={type:"field",key:n[0].value,values:n.slice(1).map(a=>a.value),location:{line:e,column:n[0].column}};return tg([o],t),o}function Jm(n,e,t){if(n.length<2)throw new Y(t,e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(i=>i.value).join(" "),location:{line:e,column:n[0].column}}}function Cw(n,e,t){let i=Km(n.fields),r=Qm(i),s=Lw(n.objectType,i),o=kw(i.get("groups")?.[0]),a=pc(i.get("epoch")?.[0]),c=pc(i.get("referencePlane")?.[0]),l=i.has("tidalLock")?Oi(Ln(i.get("tidalLock")[0]),"tidalLock",i.get("tidalLock")[0].location):void 0,u=i.has("resonance")?Uw(i.get("resonance")[0]):void 0,d=Ow(i),h=i.get("derive")?.map(x=>Nw(x)),f=i.get("validate")?.map(x=>({rule:Ln(x)})),p=i.has("locked")?[...new Set(i.get("locked").flatMap(x=>x.values))]:void 0,y=i.get("tolerance")?.map(x=>Fw(x)),g=Dw(n.typedBlockEntries),m=eg(n.infoEntries,"info"),v={type:n.objectType,id:n.id,properties:s,placement:r,info:m};return o.length>0&&(v.groups=o),a&&(v.epoch=a),c&&(v.referencePlane=c),l!==void 0&&(v.tidalLock=l),u&&(v.resonance=u),d&&(v.renderHints=d),h?.length&&(v.deriveRules=h),f?.length&&(v.validationRules=f),p?.length&&(v.lockedFields=p),y?.length&&(v.tolerances=y),g&&Object.keys(g).length>0&&(v.typedBlocks=g),gc(e,"2.1")&&(v.groups||v.epoch||v.referencePlane||v.tidalLock!==void 0||v.resonance||v.renderHints||v.deriveRules?.length||v.validationRules?.length||v.lockedFields?.length||v.tolerances?.length||v.typedBlocks)&&En(e,t,n.id,n.location),v}function Rw(n,e){return{...n,participantObjectIds:[...new Set(n.participantObjectIds)],tags:[...new Set(n.tags)],positions:e.map(t=>Pw(t))}}function Pw(n){let e=Km(n.fields,"event-pose"),t=Qm(e);return{objectId:n.objectId,placement:t,inner:Ni(e.get("inner")?.[0],"inner"),outer:Ni(e.get("outer")?.[0],"outer"),epoch:pc(e.get("epoch")?.[0]),referencePlane:pc(e.get("referencePlane")?.[0])}}function Km(n,e="object"){let t=new Map;for(let i of n){let r=bo(i.key);if(!r&&!Xm.has(i.key))throw Y.fromLocation(`Unknown field "${i.key}"`,i.location);if(!r?.allowRepeat&&t.has(i.key))throw Y.fromLocation(`Duplicate field "${i.key}"`,i.location);let s=t.get(i.key)??[];s.push(i),t.set(i.key,s)}return t}function Qm(n){let e=n.get("orbit")?.[0],t=n.get("at")?.[0],i=n.get("surface")?.[0],r=n.get("free")?.[0];if([e,t,i,r].filter(Boolean).length>1){let o=e??t??i??r;throw Y.fromLocation("Object has multiple placement modes",o?.location)}if(e)return{mode:"orbit",target:Ln(e),distance:Ni(n.get("distance")?.[0],"distance"),semiMajor:Ni(n.get("semiMajor")?.[0],"semiMajor"),eccentricity:Bw(n.get("eccentricity")?.[0],"eccentricity"),period:Ni(n.get("period")?.[0],"period"),angle:Ni(n.get("angle")?.[0],"angle"),inclination:Ni(n.get("inclination")?.[0],"inclination"),phase:Ni(n.get("phase")?.[0],"phase")};if(t){let o=Ln(t);return{mode:"at",target:o,reference:Vm(o,t.location)}}if(i)return{mode:"surface",target:Ln(i)};if(r){let o=Ln(r),a=pd(o);return{mode:"free",distance:a??void 0,descriptor:a?void 0:o}}return null}function Lw(n,e){let t={};for(let[i,r]of e.entries()){let s=r[0],o=bo(i);!s||!o?.legacySchema||o.legacySchema.placement||(md(i,n,s.location),t[i]=$m(i,s.values,s.location))}return t}function eg(n,e){let t={};for(let i of n){if(i.key in t)throw Y.fromLocation(`Duplicate ${e} key "${i.key}"`,i.location);t[i.key]=i.value}return t}function Dw(n){let e={};for(let t of Object.keys(n)){let i=n[t];i?.length&&(e[t]=eg(i,t))}return e}function Ow(n){let e={},t=n.get("renderLabel")?.[0],i=n.get("renderOrbit")?.[0],r=n.get("renderPriority")?.[0];return t&&(e.renderLabel=Oi(Ln(t),"renderLabel",t.location)),i&&(e.renderOrbit=Oi(Ln(i),"renderOrbit",i.location)),r&&(e.renderPriority=hc(Ln(r),"renderPriority",r.location)),Object.keys(e).length>0?e:void 0}function Uw(n){if(n.values.length!==2)throw Y.fromLocation('Field "resonance" expects "<targetObjectId> <ratio>"',n.location);let e=n.values[1];if(!/^\d+:\d+$/.test(e))throw Y.fromLocation(`Invalid resonance ratio "${e}"`,n.location);return{targetObjectId:n.values[0],ratio:e}}function Nw(n){if(n.values.length!==2)throw Y.fromLocation('Field "derive" expects "<field> <strategy>"',n.location);return{field:n.values[0],strategy:n.values[1]}}function Fw(n){if(n.values.length!==2)throw Y.fromLocation('Field "tolerance" expects "<field> <value>"',n.location);let e=n.values[1],t=pd(e),i=Number(e);return{field:n.values[0],value:t??(Number.isFinite(i)?i:e)}}function kw(n){return n?[...new Set(n.values)]:[]}function pc(n){return n&&n.values.join(" ").trim()||null}function Ni(n,e){return n?fd(Ln(n),n.location,e):void 0}function Bw(n,e){return n?hc(Ln(n),e,n.location):void 0}function Ln(n){return yo(n.values,n.key,n.location)}function bo(n){return mc.get(n)}function tg(n,e){for(let t of n){let i=bo(t.key);if(!i)throw Y.fromLocation(`Unknown field "${t.key}"`,t.location);if(i.legacySchema){md(t.key,e,t.location);continue}if((t.key==="renderLabel"||t.key==="renderOrbit"||t.key==="tidalLock")&&t.values.length!==1)throw Y.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function En(n,e,t,i){gc(n,"2.1")&&e.push({code:"parse.schema21.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.1; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function ur(n,e,t,i){gc(n,"2.5")&&e.push({code:"parse.schema25.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.5; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function gc(n,e){return Wm(n)<Wm(e)}function Wm(n){switch(n){case"2.0-draft":return 0;case"2.0":return 1;case"2.1":return 2;case"2.5":return 3}}function zw(n){let e=[...n],t=[],i=!1,r=!1,s=null,o=1,a=1;for(let c=0;c<e.length;c++){let l=e[c],u=e[c+1];if(r){if(l==="*"&&u==="/"){e[c]=" ",e[c+1]=" ",r=!1,s=null,c++,a+=2;continue}l!==`
3821
+ }`,mf=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){let r=new Ct,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){let i=t.cameras[0].viewport,r=new mn({vertexShader:oI,fragmentShader:aI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new Mt(new $s(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},gf=class extends Nn{constructor(e,t){super();let i=this,r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,d=null,h=null,f=null,p=null,y=new mf,g=t.getContextAttributes(),m=null,x=null,v=[],M=[],U=new se,C=null,R=new Pt;R.layers.enable(1),R.viewport=new ft;let N=new Pt;N.layers.enable(2),N.viewport=new ft;let w=[R,N],b=new Il;b.layers.enable(1),b.layers.enable(2);let O=null,B=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let J=v[Z];return J===void 0&&(J=new Ho,v[Z]=J),J.getTargetRaySpace()},this.getControllerGrip=function(Z){let J=v[Z];return J===void 0&&(J=new Ho,v[Z]=J),J.getGripSpace()},this.getHand=function(Z){let J=v[Z];return J===void 0&&(J=new Ho,v[Z]=J),J.getHandSpace()};function F(Z){let J=M.indexOf(Z.inputSource);if(J===-1)return;let ye=v[J];ye!==void 0&&(ye.update(Z.inputSource,Z.frame,l||o),ye.dispatchEvent({type:Z.type,data:Z.inputSource}))}function H(){r.removeEventListener("select",F),r.removeEventListener("selectstart",F),r.removeEventListener("selectend",F),r.removeEventListener("squeeze",F),r.removeEventListener("squeezestart",F),r.removeEventListener("squeezeend",F),r.removeEventListener("end",H),r.removeEventListener("inputsourceschange",X);for(let Z=0;Z<v.length;Z++){let J=M[Z];J!==null&&(M[Z]=null,v[Z].disconnect(J))}O=null,B=null,y.reset(),e.setRenderTarget(m),f=null,h=null,d=null,r=null,x=null,He.stop(),i.isPresenting=!1,e.setPixelRatio(C),e.setSize(U.width,U.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){s=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){a=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(Z){l=Z},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(Z){if(r=Z,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",F),r.addEventListener("selectstart",F),r.addEventListener("selectend",F),r.addEventListener("squeeze",F),r.addEventListener("squeezestart",F),r.addEventListener("squeezeend",F),r.addEventListener("end",H),r.addEventListener("inputsourceschange",X),g.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(U),r.renderState.layers===void 0){let J={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,t,J),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new fn(f.framebufferWidth,f.framebufferHeight,{format:dn,type:wi,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let J=null,ye=null,oe=null;g.depth&&(oe=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,J=g.stencil?Ns:Rr,ye=g.stencil?qs:Lr);let ze={colorFormat:t.RGBA8,depthFormat:oe,scaleFactor:s};d=new XRWebGLBinding(r,t),h=d.createProjectionLayer(ze),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),x=new fn(h.textureWidth,h.textureHeight,{format:dn,type:wi,depthTexture:new ua(h.textureWidth,h.textureHeight,ye,void 0,void 0,void 0,void 0,void 0,void 0,J),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),He.setContext(r),He.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function X(Z){for(let J=0;J<Z.removed.length;J++){let ye=Z.removed[J],oe=M.indexOf(ye);oe>=0&&(M[oe]=null,v[oe].disconnect(ye))}for(let J=0;J<Z.added.length;J++){let ye=Z.added[J],oe=M.indexOf(ye);if(oe===-1){for(let xe=0;xe<v.length;xe++)if(xe>=M.length){M.push(ye),oe=xe;break}else if(M[xe]===null){M[xe]=ye,oe=xe;break}if(oe===-1)break}let ze=v[oe];ze&&ze.connect(ye)}}let ee=new L,ce=new L;function k(Z,J,ye){ee.setFromMatrixPosition(J.matrixWorld),ce.setFromMatrixPosition(ye.matrixWorld);let oe=ee.distanceTo(ce),ze=J.projectionMatrix.elements,xe=ye.projectionMatrix.elements,V=ze[14]/(ze[10]-1),Be=ze[14]/(ze[10]+1),Y=(ze[9]+1)/ze[5],de=(ze[9]-1)/ze[5],K=(ze[8]-1)/ze[0],fe=(xe[8]+1)/xe[0],ie=V*K,ge=V*fe,Ie=oe/(-K+fe),D=Ie*-K;J.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(D),Z.translateZ(Ie),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();let A=V+Ie,j=Be+Ie,te=ie-D,ae=ge+(oe-D),re=Y*Be/j*A,Ue=de*Be/j*A;Z.projectionMatrix.makePerspective(te,ae,re,Ue,A,j),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function le(Z,J){J===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(J.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(r===null)return;y.texture!==null&&(Z.near=y.depthNear,Z.far=y.depthFar),b.near=N.near=R.near=Z.near,b.far=N.far=R.far=Z.far,(O!==b.near||B!==b.far)&&(r.updateRenderState({depthNear:b.near,depthFar:b.far}),O=b.near,B=b.far,R.near=O,R.far=B,N.near=O,N.far=B,R.updateProjectionMatrix(),N.updateProjectionMatrix(),Z.updateProjectionMatrix());let J=Z.parent,ye=b.cameras;le(b,J);for(let oe=0;oe<ye.length;oe++)le(ye[oe],J);ye.length===2?k(b,R,N):b.projectionMatrix.copy(R.projectionMatrix),he(Z,b,J)};function he(Z,J,ye){ye===null?Z.matrix.copy(J.matrixWorld):(Z.matrix.copy(ye.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(J.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(J.projectionMatrix),Z.projectionMatrixInverse.copy(J.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=Fs*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return b},this.getFoveation=function(){if(!(h===null&&f===null))return c},this.setFoveation=function(Z){c=Z,h!==null&&(h.fixedFoveation=Z),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Z)},this.hasDepthSensing=function(){return y.texture!==null};let Te=null;function ve(Z,J){if(u=J.getViewerPose(l||o),p=J,u!==null){let ye=u.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let oe=!1;ye.length!==b.cameras.length&&(b.cameras.length=0,oe=!0);for(let xe=0;xe<ye.length;xe++){let V=ye[xe],Be=null;if(f!==null)Be=f.getViewport(V);else{let de=d.getViewSubImage(h,V);Be=de.viewport,xe===0&&(e.setRenderTargetTextures(x,de.colorTexture,h.ignoreDepthValues?void 0:de.depthStencilTexture),e.setRenderTarget(x))}let Y=w[xe];Y===void 0&&(Y=new Pt,Y.layers.enable(xe),Y.viewport=new ft,w[xe]=Y),Y.matrix.fromArray(V.transform.matrix),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.projectionMatrix.fromArray(V.projectionMatrix),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert(),Y.viewport.set(Be.x,Be.y,Be.width,Be.height),xe===0&&(b.matrix.copy(Y.matrix),b.matrix.decompose(b.position,b.quaternion,b.scale)),oe===!0&&b.cameras.push(Y)}let ze=r.enabledFeatures;if(ze&&ze.includes("depth-sensing")){let xe=d.getDepthInformation(ye[0]);xe&&xe.isValid&&xe.texture&&y.init(e,xe,r.renderState)}}for(let ye=0;ye<v.length;ye++){let oe=M[ye],ze=v[ye];oe!==null&&ze!==void 0&&ze.update(oe,J,l||o)}y.render(e,b),Te&&Te(Z,J),J.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:J}),p=null}let He=new fv;He.setAnimationLoop(ve),this.setAnimationLoop=function(Z){Te=Z},this.dispose=function(){}}},gr=new pn,cI=new $e;yf=class{constructor(e={}){let{canvas:t=cv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let h;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=i.getContextAttributes().alpha}else h=o;let f=new Uint32Array(4),p=new Int32Array(4),y=null,g=null,m=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Sn,this._useLegacyLights=!1,this.toneMapping=vi,this.toneMappingExposure=1;let v=this,M=!1,U=0,C=0,R=null,N=-1,w=null,b=new ft,O=new ft,B=null,F=new Ce(0),H=0,X=t.width,ee=t.height,ce=1,k=null,le=null,he=new ft(0,0,X,ee),Te=new ft(0,0,X,ee),ve=!1,He=new Ur,Z=!1,J=!1,ye=new $e,oe=new L,ze={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function xe(){return R===null?ce:1}let V=i;function Be(E,_){return t.getContext(E,_)}try{let E={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r164"),t.addEventListener("webglcontextlost",z,!1),t.addEventListener("webglcontextrestored",ue,!1),t.addEventListener("webglcontextcreationerror",Q,!1),V===null){let _="webgl2";if(V=Be(_,E),V===null)throw Be(_)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let Y,de,K,fe,ie,ge,Ie,D,A,j,te,ae,re,Ue,be,_e,je,pe,Oe,qe,Ne,Re,Fe,et;function mt(){Y=new RA(V),Y.init(),Re=new xv(V,Y),de=new MA(V,Y,e,Re),K=new iI(V),fe=new DA(V),ie=new GT,ge=new rI(V,Y,K,ie,de,Re,fe),Ie=new AA(v),D=new CA(v),A=new zM(V),Fe=new wA(V,A),j=new PA(V,A,fe,Fe),te=new UA(V,j,A,fe),Oe=new OA(V,de,ge),_e=new EA(ie),ae=new jT(v,Ie,D,Y,de,Fe,_e),re=new lI(v,ie),Ue=new XT,be=new QT(Y),pe=new _A(v,Ie,D,K,te,h,c),je=new nI(v,te,de),et=new uI(V,fe,de,K),qe=new SA(V,Y,fe),Ne=new LA(V,Y,fe),fe.programs=ae.programs,v.capabilities=de,v.extensions=Y,v.properties=ie,v.renderLists=Ue,v.shadowMap=je,v.state=K,v.info=fe}mt();let Ge=new gf(v,V);this.xr=Ge,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){let E=Y.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=Y.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return ce},this.setPixelRatio=function(E){E!==void 0&&(ce=E,this.setSize(X,ee,!1))},this.getSize=function(E){return E.set(X,ee)},this.setSize=function(E,_,S=!0){if(Ge.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}X=E,ee=_,t.width=Math.floor(E*ce),t.height=Math.floor(_*ce),S===!0&&(t.style.width=E+"px",t.style.height=_+"px"),this.setViewport(0,0,E,_)},this.getDrawingBufferSize=function(E){return E.set(X*ce,ee*ce).floor()},this.setDrawingBufferSize=function(E,_,S){X=E,ee=_,ce=S,t.width=Math.floor(E*S),t.height=Math.floor(_*S),this.setViewport(0,0,E,_)},this.getCurrentViewport=function(E){return E.copy(b)},this.getViewport=function(E){return E.copy(he)},this.setViewport=function(E,_,S,T){E.isVector4?he.set(E.x,E.y,E.z,E.w):he.set(E,_,S,T),K.viewport(b.copy(he).multiplyScalar(ce).round())},this.getScissor=function(E){return E.copy(Te)},this.setScissor=function(E,_,S,T){E.isVector4?Te.set(E.x,E.y,E.z,E.w):Te.set(E,_,S,T),K.scissor(O.copy(Te).multiplyScalar(ce).round())},this.getScissorTest=function(){return ve},this.setScissorTest=function(E){K.setScissorTest(ve=E)},this.setOpaqueSort=function(E){k=E},this.setTransparentSort=function(E){le=E},this.getClearColor=function(E){return E.copy(pe.getClearColor())},this.setClearColor=function(){pe.setClearColor.apply(pe,arguments)},this.getClearAlpha=function(){return pe.getClearAlpha()},this.setClearAlpha=function(){pe.setClearAlpha.apply(pe,arguments)},this.clear=function(E=!0,_=!0,S=!0){let T=0;if(E){let I=!1;if(R!==null){let W=R.texture.format;I=W===Tp||W===Ap||W===Ep}if(I){let W=R.texture.type,ne=W===wi||W===Lr||W===bp||W===qs||W===wp||W===Sp,me=pe.getClearColor(),Me=pe.getClearAlpha(),Le=me.r,We=me.g,Ve=me.b;ne?(f[0]=Le,f[1]=We,f[2]=Ve,f[3]=Me,V.clearBufferuiv(V.COLOR,0,f)):(p[0]=Le,p[1]=We,p[2]=Ve,p[3]=Me,V.clearBufferiv(V.COLOR,0,p))}else T|=V.COLOR_BUFFER_BIT}_&&(T|=V.DEPTH_BUFFER_BIT),S&&(T|=V.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V.clear(T)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",z,!1),t.removeEventListener("webglcontextrestored",ue,!1),t.removeEventListener("webglcontextcreationerror",Q,!1),Ue.dispose(),be.dispose(),ie.dispose(),Ie.dispose(),D.dispose(),te.dispose(),Fe.dispose(),et.dispose(),ae.dispose(),Ge.dispose(),Ge.removeEventListener("sessionstart",st),Ge.removeEventListener("sessionend",Ht),Et.stop()};function z(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),M=!0}function ue(){console.log("THREE.WebGLRenderer: Context Restored."),M=!1;let E=fe.autoReset,_=je.enabled,S=je.autoUpdate,T=je.needsUpdate,I=je.type;mt(),fe.autoReset=E,je.enabled=_,je.autoUpdate=S,je.needsUpdate=T,je.type=I}function Q(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Se(E){let _=E.target;_.removeEventListener("dispose",Se),Ae(_)}function Ae(E){Pe(E),ie.remove(E)}function Pe(E){let _=ie.get(E).programs;_!==void 0&&(_.forEach(function(S){ae.releaseProgram(S)}),E.isShaderMaterial&&ae.releaseShaderCache(E))}this.renderBufferDirect=function(E,_,S,T,I,W){_===null&&(_=ze);let ne=I.isMesh&&I.matrixWorld.determinant()<0,me=P(E,_,S,T,I);K.setMaterial(T,ne);let Me=S.index,Le=1;if(T.wireframe===!0){if(Me=j.getWireframeAttribute(S),Me===void 0)return;Le=2}let We=S.drawRange,Ve=S.attributes.position,gt=We.start*Le,jt=(We.start+We.count)*Le;W!==null&&(gt=Math.max(gt,W.start*Le),jt=Math.min(jt,(W.start+W.count)*Le)),Me!==null?(gt=Math.max(gt,0),jt=Math.min(jt,Me.count)):Ve!=null&&(gt=Math.max(gt,0),jt=Math.min(jt,Ve.count));let an=jt-gt;if(an<0||an===1/0)return;Fe.setup(I,T,me,S,Me);let ti,ct=qe;if(Me!==null&&(ti=A.get(Me),ct=Ne,ct.setIndex(ti)),I.isMesh)T.wireframe===!0?(K.setLineWidth(T.wireframeLinewidth*xe()),ct.setMode(V.LINES)):ct.setMode(V.TRIANGLES);else if(I.isLine){let Ze=T.linewidth;Ze===void 0&&(Ze=1),K.setLineWidth(Ze*xe()),I.isLineSegments?ct.setMode(V.LINES):I.isLineLoop?ct.setMode(V.LINE_LOOP):ct.setMode(V.LINE_STRIP)}else I.isPoints?ct.setMode(V.POINTS):I.isSprite&&ct.setMode(V.TRIANGLES);if(I.isBatchedMesh)I._multiDrawInstances!==null?ct.renderMultiDrawInstances(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount,I._multiDrawInstances):ct.renderMultiDraw(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount);else if(I.isInstancedMesh)ct.renderInstances(gt,an,I.count);else if(S.isInstancedBufferGeometry){let Ze=S._maxInstanceCount!==void 0?S._maxInstanceCount:1/0,to=Math.min(S.instanceCount,Ze);ct.renderInstances(gt,an,to)}else ct.render(gt,an)};function nt(E,_,S){E.transparent===!0&&E.side===Hn&&E.forceSinglePass===!1?(E.side=nn,E.needsUpdate=!0,In(E,_,S),E.side=bi,E.needsUpdate=!0,In(E,_,S),E.side=Hn):In(E,_,S)}this.compile=function(E,_,S=null){S===null&&(S=E),g=be.get(S),g.init(_),x.push(g),S.traverseVisible(function(I){I.isLight&&I.layers.test(_.layers)&&(g.pushLight(I),I.castShadow&&g.pushShadow(I))}),E!==S&&E.traverseVisible(function(I){I.isLight&&I.layers.test(_.layers)&&(g.pushLight(I),I.castShadow&&g.pushShadow(I))}),g.setupLights(v._useLegacyLights);let T=new Set;return E.traverse(function(I){let W=I.material;if(W)if(Array.isArray(W))for(let ne=0;ne<W.length;ne++){let me=W[ne];nt(me,S,I),T.add(me)}else nt(W,S,I),T.add(W)}),x.pop(),g=null,T},this.compileAsync=function(E,_,S=null){let T=this.compile(E,_,S);return new Promise(I=>{function W(){if(T.forEach(function(ne){ie.get(ne).currentProgram.isReady()&&T.delete(ne)}),T.size===0){I(E);return}setTimeout(W,10)}Y.get("KHR_parallel_shader_compile")!==null?W():setTimeout(W,10)})};let pt=null;function xt(E){pt&&pt(E)}function st(){Et.stop()}function Ht(){Et.start()}let Et=new fv;Et.setAnimationLoop(xt),typeof self<"u"&&Et.setContext(self),this.setAnimationLoop=function(E){pt=E,Ge.setAnimationLoop(E),E===null?Et.stop():Et.start()},Ge.addEventListener("sessionstart",st),Ge.addEventListener("sessionend",Ht),this.render=function(E,_){if(_!==void 0&&_.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M===!0)return;E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),_.parent===null&&_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),Ge.enabled===!0&&Ge.isPresenting===!0&&(Ge.cameraAutoUpdate===!0&&Ge.updateCamera(_),_=Ge.getCamera()),E.isScene===!0&&E.onBeforeRender(v,E,_,R),g=be.get(E,x.length),g.init(_),x.push(g),ye.multiplyMatrices(_.projectionMatrix,_.matrixWorldInverse),He.setFromProjectionMatrix(ye),J=this.localClippingEnabled,Z=_e.init(this.clippingPlanes,J),y=Ue.get(E,m.length),y.init(),m.push(y),Xr(E,_,0,v.sortObjects),y.finish(),v.sortObjects===!0&&y.sort(k,le);let S=Ge.enabled===!1||Ge.isPresenting===!1||Ge.hasDepthSensing()===!1;S&&pe.addToRenderList(y,E),this.info.render.frame++,Z===!0&&_e.beginShadows();let T=g.state.shadowsArray;je.render(T,E,_),Z===!0&&_e.endShadows(),this.info.autoReset===!0&&this.info.reset();let I=y.opaque,W=y.transmissive;if(g.setupLights(v._useLegacyLights),_.isArrayCamera){let ne=_.cameras;if(W.length>0)for(let me=0,Me=ne.length;me<Me;me++){let Le=ne[me];kn(I,W,E,Le)}S&&pe.render(E);for(let me=0,Me=ne.length;me<Me;me++){let Le=ne[me];rr(y,E,Le,Le.viewport)}}else W.length>0&&kn(I,W,E,_),S&&pe.render(E),rr(y,E,_);R!==null&&(ge.updateMultisampleRenderTarget(R),ge.updateRenderTargetMipmap(R)),E.isScene===!0&&E.onAfterRender(v,E,_),Fe.resetDefaultState(),N=-1,w=null,x.pop(),x.length>0?(g=x[x.length-1],Z===!0&&_e.setGlobalState(v.clippingPlanes,g.state.camera)):g=null,m.pop(),m.length>0?y=m[m.length-1]:y=null};function Xr(E,_,S,T){if(E.visible===!1)return;if(E.layers.test(_.layers)){if(E.isGroup)S=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(_);else if(E.isLight)g.pushLight(E),E.castShadow&&g.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||He.intersectsSprite(E)){T&&oe.setFromMatrixPosition(E.matrixWorld).applyMatrix4(ye);let ne=te.update(E),me=E.material;me.visible&&y.push(E,ne,me,S,oe.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||He.intersectsObject(E))){let ne=te.update(E),me=E.material;if(T&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),oe.copy(E.boundingSphere.center)):(ne.boundingSphere===null&&ne.computeBoundingSphere(),oe.copy(ne.boundingSphere.center)),oe.applyMatrix4(E.matrixWorld).applyMatrix4(ye)),Array.isArray(me)){let Me=ne.groups;for(let Le=0,We=Me.length;Le<We;Le++){let Ve=Me[Le],gt=me[Ve.materialIndex];gt&&gt.visible&&y.push(E,ne,gt,S,oe.z,Ve)}}else me.visible&&y.push(E,ne,me,S,oe.z,null)}}let W=E.children;for(let ne=0,me=W.length;ne<me;ne++)Xr(W[ne],_,S,T)}function rr(E,_,S,T){let I=E.opaque,W=E.transmissive,ne=E.transparent;g.setupLightsView(S),Z===!0&&_e.setGlobalState(v.clippingPlanes,S),T&&K.viewport(b.copy(T)),I.length>0&&Tn(I,_,S),W.length>0&&Tn(W,_,S),ne.length>0&&Tn(ne,_,S),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}function kn(E,_,S,T){if((S.isScene===!0?S.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[T.id]===void 0&&(g.state.transmissionRenderTarget[T.id]=new fn(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")||Y.has("EXT_color_buffer_float")?Ua:wi,minFilter:jn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1}));let W=g.state.transmissionRenderTarget[T.id],ne=T.viewport||b;W.setSize(ne.z,ne.w);let me=v.getRenderTarget();v.setRenderTarget(W),v.getClearColor(F),H=v.getClearAlpha(),H<1&&v.setClearColor(16777215,.5),v.clear();let Me=v.toneMapping;v.toneMapping=vi;let Le=T.viewport;if(T.viewport!==void 0&&(T.viewport=void 0),g.setupLightsView(T),Z===!0&&_e.setGlobalState(v.clippingPlanes,T),Tn(E,S,T),ge.updateMultisampleRenderTarget(W),ge.updateRenderTargetMipmap(W),Y.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let Ve=0,gt=_.length;Ve<gt;Ve++){let jt=_[Ve],an=jt.object,ti=jt.geometry,ct=jt.material,Ze=jt.group;if(ct.side===Hn&&an.layers.test(T.layers)){let to=ct.side;ct.side=nn,ct.needsUpdate=!0,sr(an,S,T,ti,ct,Ze),ct.side=to,ct.needsUpdate=!0,We=!0}}We===!0&&(ge.updateMultisampleRenderTarget(W),ge.updateRenderTargetMipmap(W))}v.setRenderTarget(me),v.setClearColor(F,H),Le!==void 0&&(T.viewport=Le),v.toneMapping=Me}function Tn(E,_,S){let T=_.isScene===!0?_.overrideMaterial:null;for(let I=0,W=E.length;I<W;I++){let ne=E[I],me=ne.object,Me=ne.geometry,Le=T===null?ne.material:T,We=ne.group;me.layers.test(S.layers)&&sr(me,_,S,Me,Le,We)}}function sr(E,_,S,T,I,W){E.onBeforeRender(v,_,S,T,I,W),E.modelViewMatrix.multiplyMatrices(S.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),I.onBeforeRender(v,_,S,T,E,W),I.transparent===!0&&I.side===Hn&&I.forceSinglePass===!1?(I.side=nn,I.needsUpdate=!0,v.renderBufferDirect(S,_,T,I,E,W),I.side=bi,I.needsUpdate=!0,v.renderBufferDirect(S,_,T,I,E,W),I.side=Hn):v.renderBufferDirect(S,_,T,I,E,W),E.onAfterRender(v,_,S,T,I,W)}function In(E,_,S){_.isScene!==!0&&(_=ze);let T=ie.get(E),I=g.state.lights,W=g.state.shadowsArray,ne=I.state.version,me=ae.getParameters(E,I.state,W,_,S),Me=ae.getProgramCacheKey(me),Le=T.programs;T.environment=E.isMeshStandardMaterial?_.environment:null,T.fog=_.fog,T.envMap=(E.isMeshStandardMaterial?D:Ie).get(E.envMap||T.environment),T.envMapRotation=T.environment!==null&&E.envMap===null?_.environmentRotation:E.envMapRotation,Le===void 0&&(E.addEventListener("dispose",Se),Le=new Map,T.programs=Le);let We=Le.get(Me);if(We!==void 0){if(T.currentProgram===We&&T.lightsStateVersion===ne)return qr(E,me),We}else me.uniforms=ae.getUniforms(E),E.onBuild(S,me,v),E.onBeforeCompile(me,v),We=ae.acquireProgram(me,Me),Le.set(Me,We),T.uniforms=me.uniforms;let Ve=T.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Ve.clippingPlanes=_e.uniform),qr(E,me),T.needsLights=G(E),T.lightsStateVersion=ne,T.needsLights&&(Ve.ambientLightColor.value=I.state.ambient,Ve.lightProbe.value=I.state.probe,Ve.directionalLights.value=I.state.directional,Ve.directionalLightShadows.value=I.state.directionalShadow,Ve.spotLights.value=I.state.spot,Ve.spotLightShadows.value=I.state.spotShadow,Ve.rectAreaLights.value=I.state.rectArea,Ve.ltc_1.value=I.state.rectAreaLTC1,Ve.ltc_2.value=I.state.rectAreaLTC2,Ve.pointLights.value=I.state.point,Ve.pointLightShadows.value=I.state.pointShadow,Ve.hemisphereLights.value=I.state.hemi,Ve.directionalShadowMap.value=I.state.directionalShadowMap,Ve.directionalShadowMatrix.value=I.state.directionalShadowMatrix,Ve.spotShadowMap.value=I.state.spotShadowMap,Ve.spotLightMatrix.value=I.state.spotLightMatrix,Ve.spotLightMap.value=I.state.spotLightMap,Ve.pointShadowMap.value=I.state.pointShadowMap,Ve.pointShadowMatrix.value=I.state.pointShadowMatrix),T.currentProgram=We,T.uniformsList=null,We}function Yr(E){if(E.uniformsList===null){let _=E.currentProgram.getUniforms();E.uniformsList=Us.seqWithValue(_.seq,E.uniforms)}return E.uniformsList}function qr(E,_){let S=ie.get(E);S.outputColorSpace=_.outputColorSpace,S.batching=_.batching,S.instancing=_.instancing,S.instancingColor=_.instancingColor,S.instancingMorph=_.instancingMorph,S.skinning=_.skinning,S.morphTargets=_.morphTargets,S.morphNormals=_.morphNormals,S.morphColors=_.morphColors,S.morphTargetsCount=_.morphTargetsCount,S.numClippingPlanes=_.numClippingPlanes,S.numIntersection=_.numClipIntersection,S.vertexAlphas=_.vertexAlphas,S.vertexTangents=_.vertexTangents,S.toneMapping=_.toneMapping}function P(E,_,S,T,I){_.isScene!==!0&&(_=ze),ge.resetTextureUnits();let W=_.fog,ne=T.isMeshStandardMaterial?_.environment:null,me=R===null?v.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Ei,Me=(T.isMeshStandardMaterial?D:Ie).get(T.envMap||ne),Le=T.vertexColors===!0&&!!S.attributes.color&&S.attributes.color.itemSize===4,We=!!S.attributes.tangent&&(!!T.normalMap||T.anisotropy>0),Ve=!!S.morphAttributes.position,gt=!!S.morphAttributes.normal,jt=!!S.morphAttributes.color,an=vi;T.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(an=v.toneMapping);let ti=S.morphAttributes.position||S.morphAttributes.normal||S.morphAttributes.color,ct=ti!==void 0?ti.length:0,Ze=ie.get(T),to=g.state.lights;if(Z===!0&&(J===!0||E!==w)){let xn=E===w&&T.id===N;_e.setState(T,E,xn)}let bt=!1;T.version===Ze.__version?(Ze.needsLights&&Ze.lightsStateVersion!==to.state.version||Ze.outputColorSpace!==me||I.isBatchedMesh&&Ze.batching===!1||!I.isBatchedMesh&&Ze.batching===!0||I.isInstancedMesh&&Ze.instancing===!1||!I.isInstancedMesh&&Ze.instancing===!0||I.isSkinnedMesh&&Ze.skinning===!1||!I.isSkinnedMesh&&Ze.skinning===!0||I.isInstancedMesh&&Ze.instancingColor===!0&&I.instanceColor===null||I.isInstancedMesh&&Ze.instancingColor===!1&&I.instanceColor!==null||I.isInstancedMesh&&Ze.instancingMorph===!0&&I.morphTexture===null||I.isInstancedMesh&&Ze.instancingMorph===!1&&I.morphTexture!==null||Ze.envMap!==Me||T.fog===!0&&Ze.fog!==W||Ze.numClippingPlanes!==void 0&&(Ze.numClippingPlanes!==_e.numPlanes||Ze.numIntersection!==_e.numIntersection)||Ze.vertexAlphas!==Le||Ze.vertexTangents!==We||Ze.morphTargets!==Ve||Ze.morphNormals!==gt||Ze.morphColors!==jt||Ze.toneMapping!==an||Ze.morphTargetsCount!==ct)&&(bt=!0):(bt=!0,Ze.__version=T.version);let or=Ze.currentProgram;bt===!0&&(or=In(T,_,I));let Gp=!1,no=!1,Yu=!1,Gt=or.getUniforms(),Ci=Ze.uniforms;if(K.useProgram(or.program)&&(Gp=!0,no=!0,Yu=!0),T.id!==N&&(N=T.id,no=!0),Gp||w!==E){Gt.setValue(V,"projectionMatrix",E.projectionMatrix),Gt.setValue(V,"viewMatrix",E.matrixWorldInverse);let xn=Gt.map.cameraPosition;xn!==void 0&&xn.setValue(V,oe.setFromMatrixPosition(E.matrixWorld)),de.logarithmicDepthBuffer&&Gt.setValue(V,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(T.isMeshPhongMaterial||T.isMeshToonMaterial||T.isMeshLambertMaterial||T.isMeshBasicMaterial||T.isMeshStandardMaterial||T.isShaderMaterial)&&Gt.setValue(V,"isOrthographic",E.isOrthographicCamera===!0),w!==E&&(w=E,no=!0,Yu=!0)}if(I.isSkinnedMesh){Gt.setOptional(V,I,"bindMatrix"),Gt.setOptional(V,I,"bindMatrixInverse");let xn=I.skeleton;xn&&(xn.boneTexture===null&&xn.computeBoneTexture(),Gt.setValue(V,"boneTexture",xn.boneTexture,ge))}I.isBatchedMesh&&(Gt.setOptional(V,I,"batchingTexture"),Gt.setValue(V,"batchingTexture",I._matricesTexture,ge));let qu=S.morphAttributes;if((qu.position!==void 0||qu.normal!==void 0||qu.color!==void 0)&&Oe.update(I,S,or),(no||Ze.receiveShadow!==I.receiveShadow)&&(Ze.receiveShadow=I.receiveShadow,Gt.setValue(V,"receiveShadow",I.receiveShadow)),T.isMeshGouraudMaterial&&T.envMap!==null&&(Ci.envMap.value=Me,Ci.flipEnvMap.value=Me.isCubeTexture&&Me.isRenderTargetTexture===!1?-1:1),T.isMeshStandardMaterial&&T.envMap===null&&_.environment!==null&&(Ci.envMapIntensity.value=_.environmentIntensity),no&&(Gt.setValue(V,"toneMappingExposure",v.toneMappingExposure),Ze.needsLights&&$(Ci,Yu),W&&T.fog===!0&&re.refreshFogUniforms(Ci,W),re.refreshMaterialUniforms(Ci,T,ce,ee,g.state.transmissionRenderTarget[E.id]),Us.upload(V,Yr(Ze),Ci,ge)),T.isShaderMaterial&&T.uniformsNeedUpdate===!0&&(Us.upload(V,Yr(Ze),Ci,ge),T.uniformsNeedUpdate=!1),T.isSpriteMaterial&&Gt.setValue(V,"center",I.center),Gt.setValue(V,"modelViewMatrix",I.modelViewMatrix),Gt.setValue(V,"normalMatrix",I.normalMatrix),Gt.setValue(V,"modelMatrix",I.matrixWorld),T.isShaderMaterial||T.isRawShaderMaterial){let xn=T.uniformsGroups;for(let Zu=0,cx=xn.length;Zu<cx;Zu++){let Wp=xn[Zu];et.update(Wp,or),et.bind(Wp,or)}}return or}function $(E,_){E.ambientLightColor.needsUpdate=_,E.lightProbe.needsUpdate=_,E.directionalLights.needsUpdate=_,E.directionalLightShadows.needsUpdate=_,E.pointLights.needsUpdate=_,E.pointLightShadows.needsUpdate=_,E.spotLights.needsUpdate=_,E.spotLightShadows.needsUpdate=_,E.rectAreaLights.needsUpdate=_,E.hemisphereLights.needsUpdate=_}function G(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(E,_,S){ie.get(E.texture).__webglTexture=_,ie.get(E.depthTexture).__webglTexture=S;let T=ie.get(E);T.__hasExternalTextures=!0,T.__autoAllocateDepthBuffer=S===void 0,T.__autoAllocateDepthBuffer||Y.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),T.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(E,_){let S=ie.get(E);S.__webglFramebuffer=_,S.__useDefaultFramebuffer=_===void 0},this.setRenderTarget=function(E,_=0,S=0){R=E,U=_,C=S;let T=!0,I=null,W=!1,ne=!1;if(E){let Me=ie.get(E);Me.__useDefaultFramebuffer!==void 0?(K.bindFramebuffer(V.FRAMEBUFFER,null),T=!1):Me.__webglFramebuffer===void 0?ge.setupRenderTarget(E):Me.__hasExternalTextures&&ge.rebindTextures(E,ie.get(E.texture).__webglTexture,ie.get(E.depthTexture).__webglTexture);let Le=E.texture;(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)&&(ne=!0);let We=ie.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(We[_])?I=We[_][S]:I=We[_],W=!0):E.samples>0&&ge.useMultisampledRTT(E)===!1?I=ie.get(E).__webglMultisampledFramebuffer:Array.isArray(We)?I=We[S]:I=We,b.copy(E.viewport),O.copy(E.scissor),B=E.scissorTest}else b.copy(he).multiplyScalar(ce).floor(),O.copy(Te).multiplyScalar(ce).floor(),B=ve;if(K.bindFramebuffer(V.FRAMEBUFFER,I)&&T&&K.drawBuffers(E,I),K.viewport(b),K.scissor(O),K.setScissorTest(B),W){let Me=ie.get(E.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+_,Me.__webglTexture,S)}else if(ne){let Me=ie.get(E.texture),Le=_||0;V.framebufferTextureLayer(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,Me.__webglTexture,S||0,Le)}N=-1},this.readRenderTargetPixels=function(E,_,S,T,I,W,ne){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let me=ie.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&ne!==void 0&&(me=me[ne]),me){K.bindFramebuffer(V.FRAMEBUFFER,me);try{let Me=E.texture,Le=Me.format,We=Me.type;if(!de.textureFormatReadable(Le)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!de.textureTypeReadable(We)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}_>=0&&_<=E.width-T&&S>=0&&S<=E.height-I&&V.readPixels(_,S,T,I,Re.convert(Le),Re.convert(We),W)}finally{let Me=R!==null?ie.get(R).__webglFramebuffer:null;K.bindFramebuffer(V.FRAMEBUFFER,Me)}}},this.copyFramebufferToTexture=function(E,_,S=0){let T=Math.pow(2,-S),I=Math.floor(_.image.width*T),W=Math.floor(_.image.height*T);ge.setTexture2D(_,0),V.copyTexSubImage2D(V.TEXTURE_2D,S,0,0,E.x,E.y,I,W),K.unbindTexture()},this.copyTextureToTexture=function(E,_,S,T=0){let I=_.image.width,W=_.image.height,ne=Re.convert(S.format),me=Re.convert(S.type);ge.setTexture2D(S,0),V.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,S.flipY),V.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),V.pixelStorei(V.UNPACK_ALIGNMENT,S.unpackAlignment),_.isDataTexture?V.texSubImage2D(V.TEXTURE_2D,T,E.x,E.y,I,W,ne,me,_.image.data):_.isCompressedTexture?V.compressedTexSubImage2D(V.TEXTURE_2D,T,E.x,E.y,_.mipmaps[0].width,_.mipmaps[0].height,ne,_.mipmaps[0].data):V.texSubImage2D(V.TEXTURE_2D,T,E.x,E.y,ne,me,_.image),T===0&&S.generateMipmaps&&V.generateMipmap(V.TEXTURE_2D),K.unbindTexture()},this.copyTextureToTexture3D=function(E,_,S,T,I=0){let W=E.max.x-E.min.x,ne=E.max.y-E.min.y,me=E.max.z-E.min.z,Me=Re.convert(T.format),Le=Re.convert(T.type),We;if(T.isData3DTexture)ge.setTexture3D(T,0),We=V.TEXTURE_3D;else if(T.isDataArrayTexture||T.isCompressedArrayTexture)ge.setTexture2DArray(T,0),We=V.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}V.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,T.flipY),V.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,T.premultiplyAlpha),V.pixelStorei(V.UNPACK_ALIGNMENT,T.unpackAlignment);let Ve=V.getParameter(V.UNPACK_ROW_LENGTH),gt=V.getParameter(V.UNPACK_IMAGE_HEIGHT),jt=V.getParameter(V.UNPACK_SKIP_PIXELS),an=V.getParameter(V.UNPACK_SKIP_ROWS),ti=V.getParameter(V.UNPACK_SKIP_IMAGES),ct=S.isCompressedTexture?S.mipmaps[I]:S.image;V.pixelStorei(V.UNPACK_ROW_LENGTH,ct.width),V.pixelStorei(V.UNPACK_IMAGE_HEIGHT,ct.height),V.pixelStorei(V.UNPACK_SKIP_PIXELS,E.min.x),V.pixelStorei(V.UNPACK_SKIP_ROWS,E.min.y),V.pixelStorei(V.UNPACK_SKIP_IMAGES,E.min.z),S.isDataTexture||S.isData3DTexture?V.texSubImage3D(We,I,_.x,_.y,_.z,W,ne,me,Me,Le,ct.data):T.isCompressedArrayTexture?V.compressedTexSubImage3D(We,I,_.x,_.y,_.z,W,ne,me,Me,ct.data):V.texSubImage3D(We,I,_.x,_.y,_.z,W,ne,me,Me,Le,ct),V.pixelStorei(V.UNPACK_ROW_LENGTH,Ve),V.pixelStorei(V.UNPACK_IMAGE_HEIGHT,gt),V.pixelStorei(V.UNPACK_SKIP_PIXELS,jt),V.pixelStorei(V.UNPACK_SKIP_ROWS,an),V.pixelStorei(V.UNPACK_SKIP_IMAGES,ti),I===0&&T.generateMipmaps&&V.generateMipmap(We),K.unbindTexture()},this.initTexture=function(E){E.isCubeTexture?ge.setTextureCube(E,0):E.isData3DTexture?ge.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?ge.setTexture2DArray(E,0):ge.setTexture2D(E,0),K.unbindTexture()},this.resetState=function(){U=0,C=0,R=null,K.reset(),Fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Gn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===Fu?"display-p3":"srgb",t.unpackColorSpace=ht.workingColorSpace===Na?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},Cl=class n{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ce(e),this.density=t}clone(){return new n(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},Rl=class n{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ce(e),this.near=t,this.far=i}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Pl=class extends lt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new pn,this.environmentIntensity=1,this.environmentRotation=new pn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},js=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ia,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=hn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return lv("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=hn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=hn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Qt=new L,Nr=class n{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.applyMatrix4(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.applyNormalMatrix(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.transformDirection(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=tn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Ke(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Ke(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Ke(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Ke(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Ke(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=tn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=tn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=tn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=tn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ke(t,this.array),i=Ke(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ke(t,this.array),i=Ke(i,this.array),r=Ke(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ke(t,this.array),i=Ke(i,this.array),r=Ke(r,this.array),s=Ke(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new at(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new n(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},fa=class extends kt{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ce(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Po=new L,Es=new L,As=new L,Ts=new se,Lo=new se,bv=new $e,Gc=new L,Do=new L,Wc=new L,uy=new se,ah=new se,dy=new se,Ll=class extends lt{constructor(e=new fa){if(super(),this.isSprite=!0,this.type="Sprite",Ms===void 0){Ms=new tt;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new js(t,5);Ms.setIndex([0,1,2,0,2,3]),Ms.setAttribute("position",new Nr(i,3,0,!1)),Ms.setAttribute("uv",new Nr(i,2,3,!1))}this.geometry=Ms,this.material=e,this.center=new se(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Es.setFromMatrixScale(this.matrixWorld),bv.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),As.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Es.multiplyScalar(-As.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;Xc(Gc.set(-.5,-.5,0),As,o,Es,r,s),Xc(Do.set(.5,-.5,0),As,o,Es,r,s),Xc(Wc.set(.5,.5,0),As,o,Es,r,s),uy.set(0,0),ah.set(1,0),dy.set(1,1);let a=e.ray.intersectTriangle(Gc,Do,Wc,!1,Po);if(a===null&&(Xc(Do.set(-.5,.5,0),As,o,Es,r,s),ah.set(0,1),a=e.ray.intersectTriangle(Gc,Wc,Do,!1,Po),a===null))return;let c=e.ray.origin.distanceTo(Po);c<e.near||c>e.far||t.push({distance:c,point:Po.clone(),uv:mi.getInterpolation(Po,Gc,Do,Wc,uy,ah,dy,new se),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};Yc=new L,hy=new L,Dl=class extends lt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let i=0,r=t.length;i<r;i++){let s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);let r=this.levels,s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Yc.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(Yc);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Yc.setFromMatrixPosition(e.matrixWorld),hy.setFromMatrixPosition(this.matrixWorld);let i=Yc.distanceTo(hy)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),i>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let i=this.levels;for(let r=0,s=i.length;r<s;r++){let o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}},fy=new L,py=new ft,my=new ft,dI=new L,gy=new $e,qc=new L,ch=new Ft,yy=new $e,lh=new Xi,Ol=class extends Mt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Eh,this.bindMatrix=new $e,this.bindMatrixInverse=new $e,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new zt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,qc),this.boundingBox.expandByPoint(qc)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ft),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,qc),this.boundingSphere.expandByPoint(qc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ch.copy(this.boundingSphere),ch.applyMatrix4(r),e.ray.intersectsSphere(ch)!==!1&&(yy.copy(r).invert(),lh.copy(e.ray).applyMatrix4(yy),!(this.boundingBox!==null&&lh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,lh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new ft,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Eh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===k0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;py.fromBufferAttribute(r.attributes.skinIndex,e),my.fromBufferAttribute(r.attributes.skinWeight,e),fy.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=my.getComponent(s);if(o!==0){let a=py.getComponent(s);gy.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(dI.copy(fy).applyMatrix4(gy),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},pa=class extends lt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Wn=class extends Ct{constructor(e=null,t=1,i=1,r,s,o,a,c,l=Nt,u=Nt,d,h){super(null,o,a,c,l,u,r,s,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},vy=new $e,hI=new $e,Ul=class n{constructor(e=[],t=[]){this.uuid=hn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new $e)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new $e;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:hI;vy.multiplyMatrices(a,t[s]),vy.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Wn(t,e,e,dn,En);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new pa),this.bones.push(o),this.boneInverses.push(new $e().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let o=t[r];e.bones.push(o.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},Yi=class extends at{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Is=new $e,xy=new $e,Zc=[],by=new zt,fI=new $e,Oo=new Mt,Uo=new Ft,Nl=class extends Mt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Yi(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,fI)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new zt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Is),by.copy(e.boundingBox).applyMatrix4(Is),this.boundingBox.union(by)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ft),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Is),Uo.copy(e.boundingSphere).applyMatrix4(Is),this.boundingSphere.union(Uo)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,o=e*s+1;for(let a=0;a<i.length;a++)i[a]=r[o+a]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(Oo.geometry=this.geometry,Oo.material=this.material,Oo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Uo.copy(this.boundingSphere),Uo.applyMatrix4(i),e.ray.intersectsSphere(Uo)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Is),xy.multiplyMatrices(i,Is),Oo.matrixWorld=xy,Oo.raycast(e,Zc);for(let o=0,a=Zc.length;o<a;o++){let c=Zc[o];c.instanceId=s,c.object=this,t.push(c)}Zc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Yi(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Wn(new Float32Array(r*this.count),r,this.count,Mp,En));let s=this.morphTexture.source.data.data,o=0;for(let l=0;l<i.length;l++)o+=i[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=r*e;s[c]=a,s.set(i,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};vf=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){let i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});let s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}},Cs="batchId",$i=new $e,_y=new $e,gI=new $e,wy=new $e,uh=new Ur,Jc=new zt,yr=new Ft,No=new L,dh=new vf,qt=new Mt,Kc=[];Fl=class extends Mt{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,r){super(new tt,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),i=new Wn(t,e,e,dn,En);this._matricesTexture=i}_initializeGeometry(e){let t=this.geometry,i=this._maxVertexCount,r=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(let a in e.attributes){let c=e.getAttribute(a),{array:l,itemSize:u,normalized:d}=c,h=new l.constructor(i*u),f=new at(h,u,d);t.setAttribute(a,f)}if(e.getIndex()!==null){let a=i>65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new at(a,1))}let o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(Cs,new at(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Cs))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Cs}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let i in t.attributes){if(i===Cs)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zt);let e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,$i),this.getBoundingBoxAt(r,Jc).applyMatrix4($i),t.union(Jc))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ft);let e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,$i),this.getBoundingSphereAt(r,yr).applyMatrix4($i),t.union(yr))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},s=null,o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;let l=e.getIndex(),u=l!==null;if(u&&(i===-1?r.indexCount=l.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let d=this._visibility,h=this._active,f=this._matricesTexture,p=this._matricesTexture.image.data;d.push(!0),h.push(!0);let y=this._geometryCount;this._geometryCount++,gI.toArray(p,y*16),f.needsUpdate=!0,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new zt,sphereInitialized:!1,sphere:new Ft});let g=this.geometry.getAttribute(Cs);for(let m=0;m<r.vertexCount;m++)g.setX(r.vertexStart+m,y);return g.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.vertexCount;for(let f in i.attributes){if(f===Cs)continue;let p=t.getAttribute(f),y=i.getAttribute(f);yI(p,y,c);let g=p.itemSize;for(let m=p.count,x=l;m<x;m++){let v=c+m;for(let M=0;M<g;M++)y.setComponent(v,M,0)}y.needsUpdate=!0,y.addUpdateRange(c*g,l*g)}if(r){let f=a.indexStart;for(let p=0;p<o.count;p++)s.setX(f+p,c+o.getX(p));for(let p=o.count,y=a.indexCount;p<y;p++)s.setX(f+p,c);s.needsUpdate=!0,s.addUpdateRange(f,a.indexCount)}let u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;let d=this._drawRanges[e],h=t.getAttribute("position");return d.count=r?o.count:h.count,this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.box,o=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();let a=o.index,c=o.attributes.position,l=this._drawRanges[e];for(let u=l.start,d=l.start+l.count;u<d;u++){let h=u;a&&(h=a.getX(h)),s.expandByPoint(No.fromBufferAttribute(c,h))}r.boxInitialized=!0}return t.copy(s),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.sphere,o=this.geometry;if(r.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,Jc),Jc.getCenter(s.center);let a=o.index,c=o.attributes.position,l=this._drawRanges[e],u=0;for(let d=l.start,h=l.start+l.count;d<h;d++){let f=d;a&&(f=a.getX(f)),No.fromBufferAttribute(c,f),u=Math.max(u,s.center.distanceToSquared(No))}s.radius=Math.sqrt(u),r.sphereInitialized=!0}return t.copy(s),t}setMatrixAt(e,t){let i=this._active,r=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){let i=this._visibility,r=this._active,s=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,c=this.geometry;qt.material=this.material,qt.geometry.index=c.index,qt.geometry.attributes=c.attributes,qt.geometry.boundingBox===null&&(qt.geometry.boundingBox=new zt),qt.geometry.boundingSphere===null&&(qt.geometry.boundingSphere=new Ft);for(let l=0;l<o;l++){if(!i[l]||!r[l])continue;let u=s[l];qt.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(l,qt.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,qt.geometry.boundingBox),this.getBoundingSphereAt(l,qt.geometry.boundingSphere),qt.raycast(e,Kc);for(let d=0,h=Kc.length;d<h;d++){let f=Kc[d];f.object=this,f.batchId=l,t.push(f)}Kc.length=0}qt.material=null,qt.geometry.index=null,qt.geometry.attributes={},qt.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._active,l=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,h=this._drawRanges,f=this.perObjectFrustumCulled;f&&(wy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),uh.setFromProjectionMatrix(wy,e.coordinateSystem));let p=0;if(this.sortObjects){_y.copy(this.matrixWorld).invert(),No.setFromMatrixPosition(i.matrixWorld).applyMatrix4(_y);for(let m=0,x=l.length;m<x;m++)if(l[m]&&c[m]){this.getMatrixAt(m,$i),this.getBoundingSphereAt(m,yr).applyMatrix4($i);let v=!1;if(f&&(v=!uh.intersectsSphere(yr)),!v){let M=No.distanceTo(yr.center);dh.push(h[m],M)}}let y=dh.list,g=this.customSort;g===null?y.sort(s.transparent?mI:pI):g.call(this,y,i);for(let m=0,x=y.length;m<x;m++){let v=y[m];u[p]=v.start*a,d[p]=v.count,p++}dh.reset()}else for(let y=0,g=l.length;y<g;y++)if(l[y]&&c[y]){let m=!1;if(f&&(this.getMatrixAt(y,$i),this.getBoundingSphereAt(y,yr).applyMatrix4($i),m=!uh.intersectsSphere(yr)),!m){let x=h[y];u[p]=x.start*a,d[p]=x.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}},Vt=class extends kt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ce(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},kl=new L,Bl=new L,Sy=new $e,Fo=new Xi,Qc=new Ft,hh=new L,My=new L,qn=class extends lt{constructor(e=new tt,t=new Vt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)kl.fromBufferAttribute(t,r-1),Bl.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=kl.distanceTo(Bl);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Qc.copy(i.boundingSphere),Qc.applyMatrix4(r),Qc.radius+=s,e.ray.intersectsSphere(Qc)===!1)return;Sy.copy(r).invert(),Fo.copy(e.ray).applyMatrix4(Sy);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){let f=Math.max(0,o.start),p=Math.min(u.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=l){let m=u.getX(y),x=u.getX(y+1),v=el(this,e,Fo,c,m,x);v&&t.push(v)}if(this.isLineLoop){let y=u.getX(p-1),g=u.getX(f),m=el(this,e,Fo,c,y,g);m&&t.push(m)}}else{let f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=l){let m=el(this,e,Fo,c,y,y+1);m&&t.push(m)}if(this.isLineLoop){let y=el(this,e,Fo,c,p-1,f);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};Ey=new L,Ay=new L,An=class extends qn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Ey.fromBufferAttribute(t,r),Ay.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Ey.distanceTo(Ay);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},zl=class extends qn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},ma=class extends kt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ce(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ty=new $e,xf=new Xi,tl=new Ft,nl=new L,Vl=class extends lt{constructor(e=new tt,t=new ma){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),tl.copy(i.boundingSphere),tl.applyMatrix4(r),tl.radius+=s,e.ray.intersectsSphere(tl)===!1)return;Ty.copy(r).invert(),xf.copy(e.ray).applyMatrix4(Ty);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=i.index,d=i.attributes.position;if(l!==null){let h=Math.max(0,o.start),f=Math.min(l.count,o.start+o.count);for(let p=h,y=f;p<y;p++){let g=l.getX(p);nl.fromBufferAttribute(d,g),Iy(nl,g,c,r,e,t,this)}}else{let h=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let p=h,y=f;p<y;p++)nl.fromBufferAttribute(d,p),Iy(nl,p,c,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};bf=class extends Ct{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:It,this.magFilter=s!==void 0?s:It,this.generateMipmaps=!1;let u=this;function d(){u.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},_f=class extends Ct{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Nt,this.minFilter=Nt,this.generateMipmaps=!1,this.needsUpdate=!0}},Gs=class extends Ct{constructor(e,t,i,r,s,o,a,c,l,u,d,h){super(null,o,a,c,l,u,r,s,d,h),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},wf=class extends Gs{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Mn}},Sf=class extends Gs{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,_i),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Mf=class extends Ct{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},gn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,o;t?o=t:o=e*i[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=i[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,i[r]===o)return r/(s-1);let u=i[r],h=i[r+1]-u,f=(o-u)/h;return(r+f)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new se:new L);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new L,r=[],s=[],o=[],a=new L,c=new $e;for(let f=0;f<=e;f++){let p=f/e;r[f]=this.getTangentAt(p,new L)}s[0]=new L,o[0]=new L;let l=Number.MAX_VALUE,u=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=l&&(l=u,i.set(1,0,0)),d<=l&&(l=d,i.set(0,1,0)),h<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(St(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(c.makeRotationAxis(a,p))}o[f].crossVectors(r[f],s[f])}if(t===!0){let f=Math.acos(St(s[0].dot(s[e]),-1,1));f/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let p=1;p<=e;p++)s[p].applyMatrix4(c.makeRotationAxis(r[p],f*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Ws=class extends gn{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new se){let i=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=c-this.aX,f=l-this.aY;c=h*u-f*d+this.aX,l=h*d+f*u+this.aY}return i.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},$l=class extends Ws{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};il=new L,fh=new Lp,ph=new Lp,mh=new Lp,Hl=class extends gn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new L){let i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(il.subVectors(r[0],r[1]).add(r[0]),l=il);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(il.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=il),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(d),f),y=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(u),f);y<1e-4&&(y=1),p<1e-4&&(p=y),g<1e-4&&(g=y),fh.initNonuniformCatmullRom(l.x,d.x,h.x,u.x,p,y,g),ph.initNonuniformCatmullRom(l.y,d.y,h.y,u.y,p,y,g),mh.initNonuniformCatmullRom(l.z,d.z,h.z,u.z,p,y,g)}else this.curveType==="catmullrom"&&(fh.initCatmullRom(l.x,d.x,h.x,u.x,this.tension),ph.initCatmullRom(l.y,d.y,h.y,u.y,this.tension),mh.initCatmullRom(l.z,d.z,h.z,u.z,this.tension));return i.set(fh.calc(c),ph.calc(c),mh.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new L().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};ga=class extends gn{constructor(e=new se,t=new se,i=new se,r=new se){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new se){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Go(e,r.x,s.x,o.x,a.x),Go(e,r.y,s.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},jl=class extends gn{constructor(e=new L,t=new L,i=new L,r=new L){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new L){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Go(e,r.x,s.x,o.x,a.x),Go(e,r.y,s.y,o.y,a.y),Go(e,r.z,s.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ya=class extends gn{constructor(e=new se,t=new se){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new se){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new se){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Gl=class extends gn{constructor(e=new L,t=new L){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new L){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new L){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},va=class extends gn{constructor(e=new se,t=new se,i=new se){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new se){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(jo(e,r.x,s.x,o.x),jo(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},xa=class extends gn{constructor(e=new L,t=new L,i=new L){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new L){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(jo(e,r.x,s.x,o.x),jo(e,r.y,s.y,o.y),jo(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ba=class extends gn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new se){let i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return i.set(Cy(a,c.x,l.x,u.x,d.x),Cy(a,c.y,l.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new se().fromArray(r))}return this}},Wl=Object.freeze({__proto__:null,ArcCurve:$l,CatmullRomCurve3:Hl,CubicBezierCurve:ga,CubicBezierCurve3:jl,EllipseCurve:Ws,LineCurve:ya,LineCurve3:Gl,QuadraticBezierCurve:va,QuadraticBezierCurve3:xa,SplineCurve:ba}),Xl=class extends gn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Wl[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let o=r[s]-i,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new Wl[r.type]().fromJSON(r))}return this}},Fr=class extends Xl{constructor(e){super(),this.type="Path",this.currentPoint=new se,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new ya(this.currentPoint.clone(),new se(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new va(this.currentPoint.clone(),new se(e,t),new se(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){let a=new ga(this.currentPoint.clone(),new se(e,t),new se(i,r),new se(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new ba(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,i,r,s,o,a,c),this}absellipse(e,t,i,r,s,o,a,c){let l=new Ws(e,t,i,r,s,o,a,c);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},_a=class n extends tt{constructor(e=[new se(0,-.5),new se(.5,0),new se(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=St(r,0,Math.PI*2);let s=[],o=[],a=[],c=[],l=[],u=1/t,d=new L,h=new se,f=new L,p=new L,y=new L,g=0,m=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:g=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,f.x=m*1,f.y=-g,f.z=m*0,y.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case e.length-1:c.push(y.x,y.y,y.z);break;default:g=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,f.x=m*1,f.y=-g,f.z=m*0,p.copy(f),f.x+=y.x,f.y+=y.y,f.z+=y.z,f.normalize(),c.push(f.x,f.y,f.z),y.copy(p)}for(let x=0;x<=t;x++){let v=i+x*u*r,M=Math.sin(v),U=Math.cos(v);for(let C=0;C<=e.length-1;C++){d.x=e[C].x*M,d.y=e[C].y,d.z=e[C].x*U,o.push(d.x,d.y,d.z),h.x=x/t,h.y=C/(e.length-1),a.push(h.x,h.y);let R=c[3*C+0]*M,N=c[3*C+1],w=c[3*C+0]*U;l.push(R,N,w)}}for(let x=0;x<t;x++)for(let v=0;v<e.length-1;v++){let M=v+x*e.length,U=M,C=M+e.length,R=M+e.length+1,N=M+1;s.push(U,C,N),s.push(R,N,C)}this.setIndex(s),this.setAttribute("position",new De(o,3)),this.setAttribute("uv",new De(a,2)),this.setAttribute("normal",new De(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.points,e.segments,e.phiStart,e.phiLength)}},Yl=class n extends _a{constructor(e=1,t=1,i=4,r=8){let s=new Fr;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new n(e.radius,e.length,e.capSegments,e.radialSegments)}},ql=class n extends tt{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let s=[],o=[],a=[],c=[],l=new L,u=new se;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let d=0,h=3;d<=t;d++,h+=3){let f=i+d/t*r;l.x=e*Math.cos(f),l.y=e*Math.sin(f),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[h]/e+1)/2,u.y=(o[h+1]/e+1)/2,c.push(u.x,u.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(a,3)),this.setAttribute("uv",new De(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},Xs=class n extends tt{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};let l=this;r=Math.floor(r),s=Math.floor(s);let u=[],d=[],h=[],f=[],p=0,y=[],g=i/2,m=0;x(),o===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(f,2));function x(){let M=new L,U=new L,C=0,R=(t-e)/i;for(let N=0;N<=s;N++){let w=[],b=N/s,O=b*(t-e)+e;for(let B=0;B<=r;B++){let F=B/r,H=F*c+a,X=Math.sin(H),ee=Math.cos(H);U.x=O*X,U.y=-b*i+g,U.z=O*ee,d.push(U.x,U.y,U.z),M.set(X,R,ee).normalize(),h.push(M.x,M.y,M.z),f.push(F,1-b),w.push(p++)}y.push(w)}for(let N=0;N<r;N++)for(let w=0;w<s;w++){let b=y[w][N],O=y[w+1][N],B=y[w+1][N+1],F=y[w][N+1];u.push(b,O,F),u.push(O,B,F),C+=6}l.addGroup(m,C,0),m+=C}function v(M){let U=p,C=new se,R=new L,N=0,w=M===!0?e:t,b=M===!0?1:-1;for(let B=1;B<=r;B++)d.push(0,g*b,0),h.push(0,b,0),f.push(.5,.5),p++;let O=p;for(let B=0;B<=r;B++){let H=B/r*c+a,X=Math.cos(H),ee=Math.sin(H);R.x=w*ee,R.y=g*b,R.z=w*X,d.push(R.x,R.y,R.z),h.push(0,b,0),C.x=X*.5+.5,C.y=ee*.5*b+.5,f.push(C.x,C.y),p++}for(let B=0;B<r;B++){let F=U+B,H=O+B;M===!0?u.push(H,H+1,F):u.push(H+1,H,F),N+=3}l.addGroup(m,N,M===!0?1:2),m+=N}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Zl=class n extends Xs{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new n(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},qi=class n extends tt{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],o=[];a(r),l(i),u(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(x){let v=new L,M=new L,U=new L;for(let C=0;C<t.length;C+=3)f(t[C+0],v),f(t[C+1],M),f(t[C+2],U),c(v,M,U,x)}function c(x,v,M,U){let C=U+1,R=[];for(let N=0;N<=C;N++){R[N]=[];let w=x.clone().lerp(M,N/C),b=v.clone().lerp(M,N/C),O=C-N;for(let B=0;B<=O;B++)B===0&&N===C?R[N][B]=w:R[N][B]=w.clone().lerp(b,B/O)}for(let N=0;N<C;N++)for(let w=0;w<2*(C-N)-1;w++){let b=Math.floor(w/2);w%2===0?(h(R[N][b+1]),h(R[N+1][b]),h(R[N][b])):(h(R[N][b+1]),h(R[N+1][b+1]),h(R[N+1][b]))}}function l(x){let v=new L;for(let M=0;M<s.length;M+=3)v.x=s[M+0],v.y=s[M+1],v.z=s[M+2],v.normalize().multiplyScalar(x),s[M+0]=v.x,s[M+1]=v.y,s[M+2]=v.z}function u(){let x=new L;for(let v=0;v<s.length;v+=3){x.x=s[v+0],x.y=s[v+1],x.z=s[v+2];let M=g(x)/2/Math.PI+.5,U=m(x)/Math.PI+.5;o.push(M,1-U)}p(),d()}function d(){for(let x=0;x<o.length;x+=6){let v=o[x+0],M=o[x+2],U=o[x+4],C=Math.max(v,M,U),R=Math.min(v,M,U);C>.9&&R<.1&&(v<.2&&(o[x+0]+=1),M<.2&&(o[x+2]+=1),U<.2&&(o[x+4]+=1))}}function h(x){s.push(x.x,x.y,x.z)}function f(x,v){let M=x*3;v.x=e[M+0],v.y=e[M+1],v.z=e[M+2]}function p(){let x=new L,v=new L,M=new L,U=new L,C=new se,R=new se,N=new se;for(let w=0,b=0;w<s.length;w+=9,b+=6){x.set(s[w+0],s[w+1],s[w+2]),v.set(s[w+3],s[w+4],s[w+5]),M.set(s[w+6],s[w+7],s[w+8]),C.set(o[b+0],o[b+1]),R.set(o[b+2],o[b+3]),N.set(o[b+4],o[b+5]),U.copy(x).add(v).add(M).divideScalar(3);let O=g(U);y(C,b+0,x,O),y(R,b+2,v,O),y(N,b+4,M,O)}}function y(x,v,M,U){U<0&&x.x===1&&(o[v]=x.x-1),M.x===0&&M.z===0&&(o[v]=U/2/Math.PI+.5)}function g(x){return Math.atan2(x.z,-x.x)}function m(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.vertices,e.indices,e.radius,e.details)}},Jl=class n extends qi{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},rl=new L,sl=new L,gh=new L,ol=new mi,Kl=class extends tt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(Pr*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],d=new Array(3),h={},f=[];for(let p=0;p<c;p+=3){o?(l[0]=o.getX(p),l[1]=o.getX(p+1),l[2]=o.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);let{a:y,b:g,c:m}=ol;if(y.fromBufferAttribute(a,l[0]),g.fromBufferAttribute(a,l[1]),m.fromBufferAttribute(a,l[2]),ol.getNormal(gh),d[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,d[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,d[2]=`${Math.round(m.x*r)},${Math.round(m.y*r)},${Math.round(m.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let x=0;x<3;x++){let v=(x+1)%3,M=d[x],U=d[v],C=ol[u[x]],R=ol[u[v]],N=`${M}_${U}`,w=`${U}_${M}`;w in h&&h[w]?(gh.dot(h[w].normal)<=s&&(f.push(C.x,C.y,C.z),f.push(R.x,R.y,R.z)),h[w]=null):N in h||(h[N]={index0:l[x],index1:l[v],normal:gh.clone()})}}for(let p in h)if(h[p]){let{index0:y,index1:g}=h[p];rl.fromBufferAttribute(a,y),sl.fromBufferAttribute(a,g),f.push(rl.x,rl.y,rl.z),f.push(sl.x,sl.y,sl.z)}this.setAttribute("position",new De(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},xi=class extends Fr{constructor(e){super(e),this.uuid=hn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Fr().fromJSON(r))}return this}},EI={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=_v(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,d,h,f;if(i&&(s=RI(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(let p=t;p<r;p+=t)d=n[p],h=n[p+1],d<a&&(a=d),h<c&&(c=h),d>l&&(l=d),h>u&&(u=h);f=Math.max(l-a,u-c),f=f!==0?32767/f:0}return wa(s,o,t,a,c,f,0),o}};Xn=class n{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Py(e),Ly(i,e);let o=e.length;t.forEach(Py);for(let c=0;c<t.length;c++)r.push(o),o+=t[c].length,Ly(i,t[c]);let a=EI.triangulate(i,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}};Ql=class n extends tt{constructor(e=new xi([new se(.5,.5),new se(-.5,.5),new se(-.5,-.5),new se(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,r=[],s=[];for(let a=0,c=e.length;a<c;a++){let l=e[a];o(l)}this.setAttribute("position",new De(r,3)),this.setAttribute("uv",new De(s,2)),this.computeVertexNormals();function o(a){let c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1,h=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:f-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3,m=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:$I,v,M=!1,U,C,R,N;m&&(v=m.getSpacedPoints(u),M=!0,h=!1,U=m.computeFrenetFrames(u,!1),C=new L,R=new L,N=new L),h||(g=0,f=0,p=0,y=0);let w=a.extractPoints(l),b=w.shape,O=w.holes;if(!Xn.isClockWise(b)){b=b.reverse();for(let Y=0,de=O.length;Y<de;Y++){let K=O[Y];Xn.isClockWise(K)&&(O[Y]=K.reverse())}}let F=Xn.triangulateShape(b,O),H=b;for(let Y=0,de=O.length;Y<de;Y++){let K=O[Y];b=b.concat(K)}function X(Y,de,K){return de||console.error("THREE.ExtrudeGeometry: vec does not exist"),Y.clone().addScaledVector(de,K)}let ee=b.length,ce=F.length;function k(Y,de,K){let fe,ie,ge,Ie=Y.x-de.x,D=Y.y-de.y,A=K.x-Y.x,j=K.y-Y.y,te=Ie*Ie+D*D,ae=Ie*j-D*A;if(Math.abs(ae)>Number.EPSILON){let re=Math.sqrt(te),Ue=Math.sqrt(A*A+j*j),be=de.x-D/re,_e=de.y+Ie/re,je=K.x-j/Ue,pe=K.y+A/Ue,Oe=((je-be)*j-(pe-_e)*A)/(Ie*j-D*A);fe=be+Ie*Oe-Y.x,ie=_e+D*Oe-Y.y;let qe=fe*fe+ie*ie;if(qe<=2)return new se(fe,ie);ge=Math.sqrt(qe/2)}else{let re=!1;Ie>Number.EPSILON?A>Number.EPSILON&&(re=!0):Ie<-Number.EPSILON?A<-Number.EPSILON&&(re=!0):Math.sign(D)===Math.sign(j)&&(re=!0),re?(fe=-D,ie=Ie,ge=Math.sqrt(te)):(fe=Ie,ie=D,ge=Math.sqrt(te/2))}return new se(fe/ge,ie/ge)}let le=[];for(let Y=0,de=H.length,K=de-1,fe=Y+1;Y<de;Y++,K++,fe++)K===de&&(K=0),fe===de&&(fe=0),le[Y]=k(H[Y],H[K],H[fe]);let he=[],Te,ve=le.concat();for(let Y=0,de=O.length;Y<de;Y++){let K=O[Y];Te=[];for(let fe=0,ie=K.length,ge=ie-1,Ie=fe+1;fe<ie;fe++,ge++,Ie++)ge===ie&&(ge=0),Ie===ie&&(Ie=0),Te[fe]=k(K[fe],K[ge],K[Ie]);he.push(Te),ve=ve.concat(Te)}for(let Y=0;Y<g;Y++){let de=Y/g,K=f*Math.cos(de*Math.PI/2),fe=p*Math.sin(de*Math.PI/2)+y;for(let ie=0,ge=H.length;ie<ge;ie++){let Ie=X(H[ie],le[ie],fe);oe(Ie.x,Ie.y,-K)}for(let ie=0,ge=O.length;ie<ge;ie++){let Ie=O[ie];Te=he[ie];for(let D=0,A=Ie.length;D<A;D++){let j=X(Ie[D],Te[D],fe);oe(j.x,j.y,-K)}}}let He=p+y;for(let Y=0;Y<ee;Y++){let de=h?X(b[Y],ve[Y],He):b[Y];M?(R.copy(U.normals[0]).multiplyScalar(de.x),C.copy(U.binormals[0]).multiplyScalar(de.y),N.copy(v[0]).add(R).add(C),oe(N.x,N.y,N.z)):oe(de.x,de.y,0)}for(let Y=1;Y<=u;Y++)for(let de=0;de<ee;de++){let K=h?X(b[de],ve[de],He):b[de];M?(R.copy(U.normals[Y]).multiplyScalar(K.x),C.copy(U.binormals[Y]).multiplyScalar(K.y),N.copy(v[Y]).add(R).add(C),oe(N.x,N.y,N.z)):oe(K.x,K.y,d/u*Y)}for(let Y=g-1;Y>=0;Y--){let de=Y/g,K=f*Math.cos(de*Math.PI/2),fe=p*Math.sin(de*Math.PI/2)+y;for(let ie=0,ge=H.length;ie<ge;ie++){let Ie=X(H[ie],le[ie],fe);oe(Ie.x,Ie.y,d+K)}for(let ie=0,ge=O.length;ie<ge;ie++){let Ie=O[ie];Te=he[ie];for(let D=0,A=Ie.length;D<A;D++){let j=X(Ie[D],Te[D],fe);M?oe(j.x,j.y+v[u-1].y,v[u-1].x+K):oe(j.x,j.y,d+K)}}}Z(),J();function Z(){let Y=r.length/3;if(h){let de=0,K=ee*de;for(let fe=0;fe<ce;fe++){let ie=F[fe];ze(ie[2]+K,ie[1]+K,ie[0]+K)}de=u+g*2,K=ee*de;for(let fe=0;fe<ce;fe++){let ie=F[fe];ze(ie[0]+K,ie[1]+K,ie[2]+K)}}else{for(let de=0;de<ce;de++){let K=F[de];ze(K[2],K[1],K[0])}for(let de=0;de<ce;de++){let K=F[de];ze(K[0]+ee*u,K[1]+ee*u,K[2]+ee*u)}}i.addGroup(Y,r.length/3-Y,0)}function J(){let Y=r.length/3,de=0;ye(H,de),de+=H.length;for(let K=0,fe=O.length;K<fe;K++){let ie=O[K];ye(ie,de),de+=ie.length}i.addGroup(Y,r.length/3-Y,1)}function ye(Y,de){let K=Y.length;for(;--K>=0;){let fe=K,ie=K-1;ie<0&&(ie=Y.length-1);for(let ge=0,Ie=u+g*2;ge<Ie;ge++){let D=ee*ge,A=ee*(ge+1),j=de+fe+D,te=de+ie+D,ae=de+ie+A,re=de+fe+A;xe(j,te,ae,re)}}}function oe(Y,de,K){c.push(Y),c.push(de),c.push(K)}function ze(Y,de,K){V(Y),V(de),V(K);let fe=r.length/3,ie=x.generateTopUV(i,r,fe-3,fe-2,fe-1);Be(ie[0]),Be(ie[1]),Be(ie[2])}function xe(Y,de,K,fe){V(Y),V(de),V(fe),V(de),V(K),V(fe);let ie=r.length/3,ge=x.generateSideWallUV(i,r,ie-6,ie-3,ie-2,ie-1);Be(ge[0]),Be(ge[1]),Be(ge[3]),Be(ge[1]),Be(ge[2]),Be(ge[3])}function V(Y){r.push(c[Y*3+0]),r.push(c[Y*3+1]),r.push(c[Y*3+2])}function Be(Y){s.push(Y.x),s.push(Y.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return HI(t,i,e)}static fromJSON(e,t){let i=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];i.push(a)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Wl[r.type]().fromJSON(r)),new n(i,e.options)}},$I={generateTopUV:function(n,e,t,i,r){let s=e[t*3],o=e[t*3+1],a=e[i*3],c=e[i*3+1],l=e[r*3],u=e[r*3+1];return[new se(s,o),new se(a,c),new se(l,u)]},generateSideWallUV:function(n,e,t,i,r,s){let o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[i*3],u=e[i*3+1],d=e[i*3+2],h=e[r*3],f=e[r*3+1],p=e[r*3+2],y=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new se(o,1-c),new se(l,1-d),new se(h,1-p),new se(y,1-m)]:[new se(a,1-c),new se(u,1-d),new se(f,1-p),new se(g,1-m)]}};eu=class n extends qi{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Ea=class n extends qi{constructor(e=1,t=0){let i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},tu=class n extends tt{constructor(e=.5,t=1,i=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);let a=[],c=[],l=[],u=[],d=e,h=(t-e)/r,f=new L,p=new se;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){let m=s+g/i*o;f.x=d*Math.cos(m),f.y=d*Math.sin(m),c.push(f.x,f.y,f.z),l.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,u.push(p.x,p.y)}d+=h}for(let y=0;y<r;y++){let g=y*(i+1);for(let m=0;m<i;m++){let x=m+g,v=x,M=x+i+1,U=x+i+2,C=x+1;a.push(v,M,C),a.push(M,U,C)}}this.setIndex(a),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},nu=class n extends tt{constructor(e=new xi([new se(0,.5),new se(-.5,-.5),new se(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],s=[],o=[],a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(i),this.setAttribute("position",new De(r,3)),this.setAttribute("normal",new De(s,3)),this.setAttribute("uv",new De(o,2));function l(u){let d=r.length/3,h=u.extractPoints(t),f=h.shape,p=h.holes;Xn.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,m=p.length;g<m;g++){let x=p[g];Xn.isClockWise(x)===!0&&(p[g]=x.reverse())}let y=Xn.triangulateShape(f,p);for(let g=0,m=p.length;g<m;g++){let x=p[g];f=f.concat(x)}for(let g=0,m=f.length;g<m;g++){let x=f[g];r.push(x.x,x.y,0),s.push(0,0,1),o.push(x.x,x.y)}for(let g=0,m=y.length;g<m;g++){let x=y[g],v=x[0]+d,M=x[1]+d,U=x[2]+d;i.push(v,M,U),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return jI(t,e)}static fromJSON(e,t){let i=[];for(let r=0,s=e.shapes.length;r<s;r++){let o=t[e.shapes[r]];i.push(o)}return new n(i,e.curveSegments)}};Aa=class n extends tt{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let c=Math.min(o+a,Math.PI),l=0,u=[],d=new L,h=new L,f=[],p=[],y=[],g=[];for(let m=0;m<=i;m++){let x=[],v=m/i,M=0;m===0&&o===0?M=.5/t:m===i&&c===Math.PI&&(M=-.5/t);for(let U=0;U<=t;U++){let C=U/t;d.x=-e*Math.cos(r+C*s)*Math.sin(o+v*a),d.y=e*Math.cos(o+v*a),d.z=e*Math.sin(r+C*s)*Math.sin(o+v*a),p.push(d.x,d.y,d.z),h.copy(d).normalize(),y.push(h.x,h.y,h.z),g.push(C+M,1-v),x.push(l++)}u.push(x)}for(let m=0;m<i;m++)for(let x=0;x<t;x++){let v=u[m][x+1],M=u[m][x],U=u[m+1][x],C=u[m+1][x+1];(m!==0||o>0)&&f.push(v,M,C),(m!==i-1||c<Math.PI)&&f.push(M,U,C)}this.setIndex(f),this.setAttribute("position",new De(p,3)),this.setAttribute("normal",new De(y,3)),this.setAttribute("uv",new De(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},iu=class n extends qi{constructor(e=1,t=0){let i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},ru=class n extends tt{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let o=[],a=[],c=[],l=[],u=new L,d=new L,h=new L;for(let f=0;f<=i;f++)for(let p=0;p<=r;p++){let y=p/r*s,g=f/i*Math.PI*2;d.x=(e+t*Math.cos(g))*Math.cos(y),d.y=(e+t*Math.cos(g))*Math.sin(y),d.z=t*Math.sin(g),a.push(d.x,d.y,d.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),h.subVectors(d,u).normalize(),c.push(h.x,h.y,h.z),l.push(p/r),l.push(f/i)}for(let f=1;f<=i;f++)for(let p=1;p<=r;p++){let y=(r+1)*f+p-1,g=(r+1)*(f-1)+p-1,m=(r+1)*(f-1)+p,x=(r+1)*f+p;o.push(y,g,x),o.push(g,m,x)}this.setIndex(o),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},su=class n extends tt{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);let a=[],c=[],l=[],u=[],d=new L,h=new L,f=new L,p=new L,y=new L,g=new L,m=new L;for(let v=0;v<=i;++v){let M=v/i*s*Math.PI*2;x(M,s,o,e,f),x(M+.01,s,o,e,p),g.subVectors(p,f),m.addVectors(p,f),y.crossVectors(g,m),m.crossVectors(y,g),y.normalize(),m.normalize();for(let U=0;U<=r;++U){let C=U/r*Math.PI*2,R=-t*Math.cos(C),N=t*Math.sin(C);d.x=f.x+(R*m.x+N*y.x),d.y=f.y+(R*m.y+N*y.y),d.z=f.z+(R*m.z+N*y.z),c.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),l.push(h.x,h.y,h.z),u.push(v/i),u.push(U/r)}}for(let v=1;v<=i;v++)for(let M=1;M<=r;M++){let U=(r+1)*(v-1)+(M-1),C=(r+1)*v+(M-1),R=(r+1)*v+M,N=(r+1)*(v-1)+M;a.push(U,C,N),a.push(C,R,N)}this.setIndex(a),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(u,2));function x(v,M,U,C,R){let N=Math.cos(v),w=Math.sin(v),b=U/M*v,O=Math.cos(b);R.x=C*(2+O)*.5*N,R.y=C*(2+O)*w*.5,R.z=C*Math.sin(b)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},ou=class n extends tt{constructor(e=new xa(new L(-1,-1,0),new L(-1,1,0),new L(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};let o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new L,c=new L,l=new se,u=new L,d=[],h=[],f=[],p=[];y(),this.setIndex(p),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(f,2));function y(){for(let v=0;v<t;v++)g(v);g(s===!1?t:0),x(),m()}function g(v){u=e.getPointAt(v/t,u);let M=o.normals[v],U=o.binormals[v];for(let C=0;C<=r;C++){let R=C/r*Math.PI*2,N=Math.sin(R),w=-Math.cos(R);c.x=w*M.x+N*U.x,c.y=w*M.y+N*U.y,c.z=w*M.z+N*U.z,c.normalize(),h.push(c.x,c.y,c.z),a.x=u.x+i*c.x,a.y=u.y+i*c.y,a.z=u.z+i*c.z,d.push(a.x,a.y,a.z)}}function m(){for(let v=1;v<=t;v++)for(let M=1;M<=r;M++){let U=(r+1)*(v-1)+(M-1),C=(r+1)*v+(M-1),R=(r+1)*v+M,N=(r+1)*(v-1)+M;p.push(U,C,N),p.push(C,R,N)}}function x(){for(let v=0;v<=t;v++)for(let M=0;M<=r;M++)l.x=v/t,l.y=M/r,f.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new n(new Wl[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},au=class extends tt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new L,s=new L;if(e.index!==null){let o=e.attributes.position,a=e.index,c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let d=c[l],h=d.start,f=d.count;for(let p=h,y=h+f;p<y;p+=3)for(let g=0;g<3;g++){let m=a.getX(p+g),x=a.getX(p+(g+1)%3);r.fromBufferAttribute(o,m),s.fromBufferAttribute(o,x),Dy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,d=3*a+(l+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,d),Dy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new De(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};Oy=Object.freeze({__proto__:null,BoxGeometry:Dr,CapsuleGeometry:Yl,CircleGeometry:ql,ConeGeometry:Zl,CylinderGeometry:Xs,DodecahedronGeometry:Jl,EdgesGeometry:Kl,ExtrudeGeometry:Ql,IcosahedronGeometry:eu,LatheGeometry:_a,OctahedronGeometry:Ea,PlaneGeometry:$s,PolyhedronGeometry:qi,RingGeometry:tu,ShapeGeometry:nu,SphereGeometry:Aa,TetrahedronGeometry:iu,TorusGeometry:ru,TorusKnotGeometry:su,TubeGeometry:ou,WireframeGeometry:au}),cu=class extends kt{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ce(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},lu=class extends mn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Ta=class extends kt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ce(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},uu=class extends Ta{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new se(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return St(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ce(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ce(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ce(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},du=class extends kt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ce(16777215),this.specular=new Ce(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pn,this.combine=Oa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},hu=class extends kt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ce(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},fu=class extends kt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},pu=class extends kt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ce(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pn,this.combine=Oa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},mu=class extends kt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ce(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},gu=class extends Vt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};XI={convertArray:Ir,isTypedArray:Mv,getKeyframeOrder:Ev,sortedArray:Tf,flattenJSON:Dp,subclip:GI,makeClipAdditive:WI},Br=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){let a=i+o>>>1;e<t[a]?o=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},yu=class extends Br{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ar,endingEnd:Ar}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,o=e+1,a=r[s],c=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Tr:s=e,a=2*t-i;break;case Qo:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(c===void 0)switch(this.getSettings_().endingEnd){case Tr:o=e,c=2*i-t;break;case Qo:o=1,c=i+r[1]-r[0];break;default:o=e-1,c=t}let l=(i-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,p=(i-t)/(r-t),y=p*p,g=y*p,m=-h*g+2*h*y-h*p,x=(1+h)*g+(-1.5-2*h)*y+(-.5+h)*p+1,v=(-1-f)*g+(1.5+f)*y+.5*p,M=f*g-f*y;for(let U=0;U!==a;++U)s[U]=m*o[u+U]+x*o[l+U]+v*o[c+U]+M*o[d+U];return s}},Ia=class extends Br{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(i-t)/(r-t),d=1-u;for(let h=0;h!==a;++h)s[h]=o[l+h]*d+o[c+h]*u;return s}},vu=class extends Br{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},yn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ir(t,this.TimeBufferType),this.values=Ir(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Ir(e.times,Array),values:Ir(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new vu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ia(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new yu(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Jo:t=this.InterpolantFactoryMethodDiscrete;break;case Ko:t=this.InterpolantFactoryMethodLinear;break;case _l:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Jo;case this.InterpolantFactoryMethodLinear:return Ko;case this.InterpolantFactoryMethodSmooth:return _l}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&Mv(r))for(let a=0,c=r.length;a!==c;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===_l,s=e.length-1,o=1;for(let a=1;a<s;++a){let c=!1,l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(r)c=!0;else{let d=a*i,h=d-i,f=d+i;for(let p=0;p!==i;++p){let y=t[d+p];if(y!==t[h+p]||y!==t[f+p]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let d=a*i,h=o*i;for(let f=0;f!==i;++f)t[h+f]=t[d+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,c=o*i,l=0;l!==i;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};yn.prototype.TimeBufferType=Float32Array;yn.prototype.ValueBufferType=Float32Array;yn.prototype.DefaultInterpolation=Ko;Si=class extends yn{};Si.prototype.ValueTypeName="bool";Si.prototype.ValueBufferType=Array;Si.prototype.DefaultInterpolation=Jo;Si.prototype.InterpolantFactoryMethodLinear=void 0;Si.prototype.InterpolantFactoryMethodSmooth=void 0;Ca=class extends yn{};Ca.prototype.ValueTypeName="color";zr=class extends yn{};zr.prototype.ValueTypeName="number";xu=class extends Br{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-t)/(r-t),l=e*a;for(let u=l+a;l!==u;l+=4)Zt.slerpFlat(s,0,o,l-a,o,l,c);return s}},Zi=class extends yn{InterpolantFactoryMethodLinear(e){return new xu(this.times,this.values,this.getValueSize(),e)}};Zi.prototype.ValueTypeName="quaternion";Zi.prototype.DefaultInterpolation=Ko;Zi.prototype.InterpolantFactoryMethodSmooth=void 0;Mi=class extends yn{};Mi.prototype.ValueTypeName="string";Mi.prototype.ValueBufferType=Array;Mi.prototype.DefaultInterpolation=Jo;Mi.prototype.InterpolantFactoryMethodLinear=void 0;Mi.prototype.InterpolantFactoryMethodSmooth=void 0;Vr=class extends yn{};Vr.prototype.ValueTypeName="vector";$r=class{constructor(e="",t=-1,i=[],r=Nu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=hn(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(qI(i[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(yn.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,o=[];for(let a=0;a<s;a++){let c=[],l=[];c.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let u=Ev(c);c=Tf(c,1,u),l=Tf(l,1,u),!r&&c[0]===0&&(c.push(s),l.push(l[0])),o.push(new zr(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],u=l.name.match(s);if(u&&u.length>1){let d=u[1],h=r[d];h||(r[d]=h=[]),h.push(l)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(d,h,f,p,y){if(f.length!==0){let g=[],m=[];Dp(f,g,m,p),g.length!==0&&y.push(new d(h,g,m))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let d=0;d<l.length;d++){let h=l[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let y=0;y<h[p].morphTargets.length;y++)f[h[p].morphTargets[y]]=-1;for(let y in f){let g=[],m=[];for(let x=0;x!==h[p].morphTargets.length;++x){let v=h[p];g.push(v.time),m.push(v.morphTarget===y?1:0)}r.push(new zr(".morphTargetInfluence["+y+"]",g,m))}c=f.length*o}else{let f=".bones["+t[d].name+"]";i(Vr,f+".position",h,"pos",r),i(Zi,f+".quaternion",h,"rot",r),i(Vr,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,c,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};gi={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},Ra=class{constructor(e,t,i){let r=this,s=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,d){return l.push(u,d),this},this.removeHandler=function(u){let d=l.indexOf(u);return d!==-1&&l.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=l.length;d<h;d+=2){let f=l[d],p=l[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},Av=new Ra,Jt=class{constructor(e){this.manager=e!==void 0?e:Av,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Jt.DEFAULT_MATERIAL_NAME="__DEFAULT";di={},If=class extends Error{constructor(e,t){super(e),this.response=t}},Fn=class extends Jt{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=gi.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(di[e]!==void 0){di[e].push({onLoad:t,onProgress:i,onError:r});return}di[e]=[],di[e].push({onLoad:t,onProgress:i,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=di[e],d=l.body.getReader(),h=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=h?parseInt(h):0,p=f!==0,y=0,g=new ReadableStream({start(m){x();function x(){d.read().then(({done:v,value:M})=>{if(v)m.close();else{y+=M.byteLength;let U=new ProgressEvent("progress",{lengthComputable:p,loaded:y,total:f});for(let C=0,R=u.length;C<R;C++){let N=u[C];N.onProgress&&N.onProgress(U)}m.enqueue(M),x()}})}}});return new Response(g)}else throw new If(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{gi.add(e,l);let u=di[e];delete di[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onLoad&&f.onLoad(l)}}).catch(l=>{let u=di[e];if(u===void 0)throw this.manager.itemError(e),l;delete di[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Cf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Fn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=[];for(let i=0;i<e.length;i++){let r=$r.parse(e[i]);t.push(r)}return t}},Rf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new Gs,c=new Fn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(s.withCredentials);let l=0;function u(d){c.load(e[d],function(h){let f=s.parse(h,!0);o[d]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},l+=1,l===6&&(f.mipmapCount===1&&(a.minFilter=It),a.image=o,a.format=f.format,a.needsUpdate=!0,t&&t(a))},i,r)}if(Array.isArray(e))for(let d=0,h=e.length;d<h;++d)u(d);else c.load(e,function(d){let h=s.parse(d,!0);if(h.isCubemap){let f=h.mipmaps.length/h.mipmapCount;for(let p=0;p<f;p++){o[p]={mipmaps:[]};for(let y=0;y<h.mipmapCount;y++)o[p].mipmaps.push(h.mipmaps[p*h.mipmapCount+y]),o[p].format=h.format,o[p].width=h.width,o[p].height=h.height}a.image=o}else a.image.width=h.width,a.image.height=h.height,a.mipmaps=h.mipmaps;h.mipmapCount===1&&(a.minFilter=It),a.format=h.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},Hr=class extends Jt{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=gi.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=sa("img");function c(){u(),gi.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(d){u(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},Pf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=new Or;s.colorSpace=Sn;let o=new Hr(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){s.images[l]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let l=0;l<e.length;++l)c(l);return s}},Lf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Wn,a=new Fn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(c){let l;try{l=s.parse(c)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:Mn,o.wrapT=l.wrapT!==void 0?l.wrapT:Mn,o.magFilter=l.magFilter!==void 0?l.magFilter:It,o.minFilter=l.minFilter!==void 0?l.minFilter:It,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=jn),l.mipmapCount===1&&(o.minFilter=It),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},i,r),o}},Df=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=new Ct,o=new Hr(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},Zn=class extends lt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ce(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},bu=class extends Zn{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(lt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ce(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},yh=new $e,Uy=new L,Ny=new L,Pa=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new se(512,512),this.map=null,this.mapPass=null,this.matrix=new $e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ur,this._frameExtents=new se(1,1),this._viewportCount=1,this._viewports=[new ft(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;Uy.setFromMatrixPosition(e.matrixWorld),t.position.copy(Uy),Ny.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ny),t.updateMatrixWorld(),yh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yh),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(yh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Of=class extends Pa{constructor(){super(new Pt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=Fs*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},_u=class extends Zn{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(lt.DEFAULT_UP),this.updateMatrix(),this.target=new lt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Of}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Fy=new $e,ko=new L,vh=new L,Uf=class extends Pa{constructor(){super(new Pt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new se(4,2),this._viewportCount=6,this._viewports=[new ft(2,1,1,1),new ft(0,1,1,1),new ft(3,1,1,1),new ft(1,1,1,1),new ft(3,0,1,1),new ft(1,0,1,1)],this._cubeDirections=[new L(1,0,0),new L(-1,0,0),new L(0,0,1),new L(0,0,-1),new L(0,1,0),new L(0,-1,0)],this._cubeUps=[new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,0,1),new L(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),ko.setFromMatrixPosition(e.matrixWorld),i.position.copy(ko),vh.copy(i.position),vh.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(vh),i.updateMatrixWorld(),r.makeTranslation(-ko.x,-ko.y,-ko.z),Fy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Fy)}},wu=class extends Zn{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new Uf}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Nf=class extends Pa{constructor(){super(new Hs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Su=class extends Zn{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(lt.DEFAULT_UP),this.updateMatrix(),this.target=new lt,this.shadow=new Nf}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Mu=class extends Zn{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},Eu=class extends Zn{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},Au=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new L)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}},Tu=class extends Zn{constructor(e=new Au,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},Iu=class n extends Jt{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new Fn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=n.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new Ce().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new Ce().setHex(o.value);break;case"v2":r.uniforms[s].value=new se().fromArray(o.value);break;case"v3":r.uniforms[s].value=new L().fromArray(o.value);break;case"v4":r.uniforms[s].value=new ft().fromArray(o.value);break;case"m3":r.uniforms[s].value=new Je().fromArray(o.value);break;case"m4":r.uniforms[s].value=new $e().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new se().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new se().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){let t={ShadowMaterial:cu,SpriteMaterial:fa,RawShaderMaterial:lu,ShaderMaterial:mn,PointsMaterial:ma,MeshPhysicalMaterial:uu,MeshStandardMaterial:Ta,MeshPhongMaterial:du,MeshToonMaterial:hu,MeshNormalMaterial:fu,MeshLambertMaterial:pu,MeshDepthMaterial:da,MeshDistanceMaterial:ha,MeshBasicMaterial:Yn,MeshMatcapMaterial:mu,LineDashedMaterial:gu,LineBasicMaterial:Vt,Material:kt};return new t[e]}},La=class{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},Cu=class extends tt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Ru=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Fn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(f,p){if(t[p]!==void 0)return t[p];let g=f.interleavedBuffers[p],m=s(f,g.buffer),x=Ps(g.type,m),v=new js(x,g.stride);return v.uuid=g.uuid,t[p]=v,v}function s(f,p){if(i[p]!==void 0)return i[p];let g=f.arrayBuffers[p],m=new Uint32Array(g).buffer;return i[p]=m,m}let o=e.isInstancedBufferGeometry?new Cu:new tt,a=e.data.index;if(a!==void 0){let f=Ps(a.type,a.array);o.setIndex(new at(f,1))}let c=e.data.attributes;for(let f in c){let p=c[f],y;if(p.isInterleavedBufferAttribute){let g=r(e.data,p.data);y=new Nr(g,p.itemSize,p.offset,p.normalized)}else{let g=Ps(p.type,p.array),m=p.isInstancedBufferAttribute?Yi:at;y=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(y.name=p.name),p.usage!==void 0&&y.setUsage(p.usage),o.setAttribute(f,y)}let l=e.data.morphAttributes;if(l)for(let f in l){let p=l[f],y=[];for(let g=0,m=p.length;g<m;g++){let x=p[g],v;if(x.isInterleavedBufferAttribute){let M=r(e.data,x.data);v=new Nr(M,x.itemSize,x.offset,x.normalized)}else{let M=Ps(x.type,x.array);v=new at(M,x.itemSize,x.normalized)}x.name!==void 0&&(v.name=x.name),y.push(v)}o.morphAttributes[f]=y}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let f=0,p=d.length;f!==p;++f){let y=d[f];o.addGroup(y.start,y.count,y.materialIndex)}let h=e.data.boundingSphere;if(h!==void 0){let f=new L;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Ft(f,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},Ff=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=this.path===""?La.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Fn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(d){r!==void 0&&r(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}let u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(l,t)},i,r)}async loadAsync(e,t){let i=this,r=this.path===""?La.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Fn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let o=await s.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){let i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,s,c,a,i),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),t!==void 0){let d=!1;for(let h in o)if(o[h].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),c}parseShapes(e){let t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){let s=new xi().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){let i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=new Ul().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new Ru;for(let s=0,o=e.length;s<o;s++){let a,c=e[s];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(c);break;default:c.type in Oy?a=Oy[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),i[c.uuid]=a}}return i}parseMaterials(e,t){let i={},r={};if(e!==void 0){let s=new Iu;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){let c=e[o];i[c.uuid]===void 0&&(i[c.uuid]=s.parse(c)),r[c.uuid]=i[c.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let i=0;i<e.length;i++){let r=e[i],s=$r.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let i=this,r={},s;function o(c){return i.manager.itemStart(c),s.load(c,function(){i.manager.itemEnd(c)},void 0,function(){i.manager.itemError(c),i.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:i.resourcePath+l;return o(u)}else return c.data?{data:Ps(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){let c=new Ra(t);s=new Hr(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){let d=e[l],h=d.url;if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p],m=a(g);m!==null&&(m instanceof HTMLImageElement?f.push(m):f.push(new Wn(m.data,m.width,m.height)))}r[d.uuid]=new pi(f)}else{let f=a(d.url);r[d.uuid]=new pi(f)}}}return r}async parseImagesAsync(e){let t=this,i={},r;async function s(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(c)}else return o.data?{data:Ps(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new Hr(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.url;if(Array.isArray(l)){let u=[];for(let d=0,h=l.length;d<h;d++){let f=l[d],p=await s(f);p!==null&&(p instanceof HTMLImageElement?u.push(p):u.push(new Wn(p.data,p.width,p.height)))}i[c.uuid]=new pi(u)}else{let u=await s(c.url);i[c.uuid]=new pi(u)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}let r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=t[a.image],l=c.data,u;Array.isArray(l)?(u=new Or,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new Wn:u=new Ct,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,ZI)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],ky),u.wrapT=i(a.wrap[1],ky)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,By)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,By)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function a(h){return t[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",h),t[h]}function c(h){if(h!==void 0){if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),f.push(i[g])}return f}return i[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",h),i[h]}}function l(h){return r[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",h),r[h]}let u,d;switch(e.type){case"Scene":o=new Pl,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ce(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Rl(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Cl(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new Pt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new Hs(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new Mu(e.color,e.intensity);break;case"DirectionalLight":o=new Su(e.color,e.intensity);break;case"PointLight":o=new wu(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Eu(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new _u(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new bu(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Tu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=c(e.material),o=new Ol(u,d),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),d=c(e.material),o=new Mt(u,d);break;case"InstancedMesh":u=a(e.geometry),d=c(e.material);let h=e.count,f=e.instanceMatrix,p=e.instanceColor;o=new Nl(u,d,h),o.instanceMatrix=new Yi(new Float32Array(f.array),16),p!==void 0&&(o.instanceColor=new Yi(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=c(e.material),o=new Fl(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,d),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(y=>{let g=new zt;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);let m=new Ft;return m.radius=y.sphereRadius,m.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:m}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid);break;case"LOD":o=new Dl;break;case"Line":o=new qn(a(e.geometry),c(e.material));break;case"LineLoop":o=new zl(a(e.geometry),c(e.material));break;case"LineSegments":o=new An(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new Vl(a(e.geometry),c(e.material));break;case"Sprite":o=new Ll(c(e.material));break;case"Group":o=new Gi;break;case"Bone":o=new pa;break;default:o=new lt}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){let h=e.children;for(let f=0;f<h.length;f++)o.add(this.parseObject(h[f],t,i,r,s))}if(e.animations!==void 0){let h=e.animations;for(let f=0;f<h.length;f++){let p=h[f];o.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);let h=e.levels;for(let f=0;f<h.length;f++){let p=h[f],y=o.getObjectByProperty("uuid",p.object);y!==void 0&&o.addLevel(y,p.distance,p.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){let r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}},ZI={UVMapping:Uu,CubeReflectionMapping:_i,CubeRefractionMapping:Wi,EquirectangularReflectionMapping:Xo,EquirectangularRefractionMapping:Yo,CubeUVReflectionMapping:Ys},ky={RepeatWrapping:qo,ClampToEdgeWrapping:Mn,MirroredRepeatWrapping:Zo},By={NearestFilter:Nt,NearestMipmapNearestFilter:xp,NearestMipmapLinearFilter:Rs,LinearFilter:It,LinearMipmapNearestFilter:Vo,LinearMipmapLinearFilter:jn},kf=class extends Jt{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=gi.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{r&&r(l)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return gi.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){r&&r(l),gi.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});gi.add(e,c),s.manager.itemStart(e)}},Da=class{static getContext(){return ll===void 0&&(ll=new(window.AudioContext||window.webkitAudioContext)),ll}static setContext(e){ll=e}},Bf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Fn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{let l=c.slice(0);Da.getContext().decodeAudioData(l,function(d){t(d)}).catch(a)}catch(l){a(l)}},i,r);function a(c){r?r(c):console.error(c),s.manager.itemError(e)}}},zy=new $e,Vy=new $e,vr=new $e,zf=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Pt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Pt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,vr.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(Pr*t.fov*.5)/t.zoom,a,c;Vy.elements[12]=-r,zy.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,vr.elements[0]=2*t.near/(c-a),vr.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(vr),a=-o*t.aspect-s,c=o*t.aspect-s,vr.elements[0]=2*t.near/(c-a),vr.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(vr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Vy),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(zy)}},Pu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=$y(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=$y();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};xr=new L,Hy=new Zt,JI=new L,br=new L,Vf=class extends lt{constructor(){super(),this.type="AudioListener",this.context=Da.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Pu}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(xr,Hy,JI),br.set(0,0,-1).applyQuaternion(Hy),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(xr.x,r),t.positionY.linearRampToValueAtTime(xr.y,r),t.positionZ.linearRampToValueAtTime(xr.z,r),t.forwardX.linearRampToValueAtTime(br.x,r),t.forwardY.linearRampToValueAtTime(br.y,r),t.forwardZ.linearRampToValueAtTime(br.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(xr.x,xr.y,xr.z),t.setOrientation(br.x,br.y,br.z,i.x,i.y,i.z)}},Lu=class extends lt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},_r=new L,jy=new Zt,KI=new L,wr=new L,$f=class extends Lu{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(_r,jy,KI),wr.set(0,0,1).applyQuaternion(jy);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(_r.x,i),t.positionY.linearRampToValueAtTime(_r.y,i),t.positionZ.linearRampToValueAtTime(_r.z,i),t.orientationX.linearRampToValueAtTime(wr.x,i),t.orientationY.linearRampToValueAtTime(wr.y,i),t.orientationZ.linearRampToValueAtTime(wr.z,i)}else t.setPosition(_r.x,_r.y,_r.z),t.setOrientation(wr.x,wr.y,wr.z)}},Hf=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},Du=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)i[s+a]=i[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let c=t*this._origIndex;this._mixBufferRegion(i,r,c,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(i[c]!==i[c+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){Zt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Zt.multiplyQuaternionsFlat(e,o,e,t,e,i),Zt.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){let o=1-r;for(let a=0;a!==s;++a){let c=t+a;e[c]=e[c]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[i+o]*r}}},Op="\\[\\]\\.:\\/",QI=new RegExp("["+Op+"]","g"),Up="[^"+Op+"]",e2="[^"+Op.replace("\\.","")+"]",t2=/((?:WC+[\/:])*)/.source.replace("WC",Up),n2=/(WCOD+)?/.source.replace("WCOD",e2),i2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Up),r2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Up),s2=new RegExp("^"+t2+n2+i2+r2+"$"),o2=["material","materials","bones","map"],jf=class{constructor(e,t,i){let r=i||dt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},dt=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(QI,"")}static parseTrackName(e){let t=s2.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);o2.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let c=i(a.children);if(c)return c}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[r];if(o===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};dt.Composite=jf;dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};dt.prototype.GetterByBindingType=[dt.prototype._getValue_direct,dt.prototype._getValue_array,dt.prototype._getValue_arrayElement,dt.prototype._getValue_toArray];dt.prototype.SetterByBindingTypeAndVersioning=[[dt.prototype._setValue_direct,dt.prototype._setValue_direct_setNeedsUpdate,dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_array,dt.prototype._setValue_array_setNeedsUpdate,dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_arrayElement,dt.prototype._setValue_arrayElement_setNeedsUpdate,dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_fromArray,dt.prototype._setValue_fromArray_setNeedsUpdate,dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Gf=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=hn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length,a,c=e.length,l=this.nCachedObjects_;for(let u=0,d=arguments.length;u!==d;++u){let h=arguments[u],f=h.uuid,p=t[f];if(p===void 0){p=c++,t[f]=p,e.push(h);for(let y=0,g=o;y!==g;++y)s[y].push(new dt(h,i[y],r[y]))}else if(p<l){a=e[p];let y=--l,g=e[y];t[g.uuid]=p,e[p]=g,t[f]=y,e[y]=h;for(let m=0,x=o;m!==x;++m){let v=s[m],M=v[y],U=v[p];v[p]=M,U===void 0&&(U=new dt(h,i[m],r[m])),v[y]=U}}else e[p]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=s){let d=s++,h=e[d];t[h.uuid]=u,e[u]=h,t[l]=d,e[d]=c;for(let f=0,p=r;f!==p;++f){let y=i[f],g=y[d],m=y[u];y[u]=g,y[d]=m}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,d=t[u];if(d!==void 0)if(delete t[u],d<s){let h=--s,f=e[h],p=--o,y=e[p];t[f.uuid]=d,e[d]=f,t[y.uuid]=h,e[h]=y,e.pop();for(let g=0,m=r;g!==m;++g){let x=i[g],v=x[h],M=x[p];x[d]=v,x[h]=M,x.pop()}}else{let h=--o,f=e[h];h>0&&(t[f.uuid]=d),e[d]=f,e.pop();for(let p=0,y=r;p!==y;++p){let g=i[p];g[d]=g[h],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,r=i[e],s=this._bindings;if(r!==void 0)return s[r];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,d=new Array(l);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(d);for(let h=u,f=c.length;h!==f;++h){let p=c[h];d[h]=new dt(p,e,t)}return d}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=i,o[i]=c,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}},Ou=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,o=s.length,a=new Array(o),c={endingStart:Ar,endingEnd:Ar};for(let l=0;l!==o;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=q0,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+i,l[0]=e/o,l[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let c=(e-s)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Ip:for(let u=0,d=c.length;u!==d;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case Nu:default:for(let u=0,d=c.length;u!==d;++u)c[u].evaluate(o),l[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,o=i===Z0;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===Y0){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Tr,r.endingEnd=Tr):(e?r.endingStart=this.zeroSlopeAtStart?Tr:Ar:r.endingStart=Qo,t?r.endingEnd=this.zeroSlopeAtEnd?Tr:Ar:r.endingEnd=Qo)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=i,this}},a2=new Float32Array(1),Wf=class extends Nn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=i.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let d=0;d!==s;++d){let h=r[d],f=h.name,p=u[f];if(p!==void 0)++p.referenceCount,o[d]=p;else{if(p=o[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}let y=t&&t._propertyBindings[d].binding.parsedPath;p=new Du(dt.create(i,f,y),h.ValueTypeName,h.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),o[d]=p}a[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;let d=a.actionByRoot,h=(e._localRoot||this._root).uuid;delete d[h],c.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[r],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new Ia(new Float32Array(2),new Float32Array(2),1,a2),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,o=typeof e=="string"?$r.findByName(r,e):e,a=o!==null?o.uuid:e,c=this._actionsByClip[a],l=null;if(i===void 0&&(o!==null?i=o.blendMode:i=Nu),c!==void 0){let d=c.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new Ou(this,o,t,i);return this._bindAction(u,l),this._addInactiveAction(u,a,s),u}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?$r.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let o=s.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,d=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,d._cacheIndex=u,t[u]=d,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let o in i){let a=i[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Xf=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},c2=0,Yf=class extends Nn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:c2++}),this.name="",this.usage=ia,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){let s=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}},qf=class extends js{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Zf=class{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},Gy=new $e,Jf=class{constructor(e,t,i=0,r=1/0){this.ray=new Xi(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Bs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Gy.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Gy),this}intersectObject(e,t=!0,i=[]){return Kf(e,this,i,t),i.sort(Wy),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Kf(e[r],this,i,t);return i.sort(Wy),i}};Qf=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(St(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},ep=class{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}},Xy=new se,tp=class{constructor(e=new se(1/0,1/0),t=new se(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Xy.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xy).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Yy=new L,ul=new L,np=class{constructor(e=new L,t=new L){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Yy.subVectors(e,this.start),ul.subVectors(this.end,this.start);let i=ul.dot(ul),s=ul.dot(Yy)/i;return t&&(s=St(s,0,1)),s}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},qy=new L,ip=class extends lt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new tt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new De(r,3));let s=new Vt({fog:!1,toneMapped:!1});this.cone=new An(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),qy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(qy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Hi=new L,dl=new $e,xh=new $e,rp=class extends An{constructor(e){let t=Tv(e),i=new tt,r=[],s=[],o=new Ce(0,0,1),a=new Ce(0,1,0);for(let l=0;l<t.length;l++){let u=t[l];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new De(r,3)),i.setAttribute("color",new De(s,3));let c=new Vt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,i=this.geometry,r=i.getAttribute("position");xh.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(dl.multiplyMatrices(xh,a.matrixWorld),Hi.setFromMatrixPosition(dl),r.setXYZ(o,Hi.x,Hi.y,Hi.z),dl.multiplyMatrices(xh,a.parent.matrixWorld),Hi.setFromMatrixPosition(dl),r.setXYZ(o+1,Hi.x,Hi.y,Hi.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};sp=class extends Mt{constructor(e,t,i){let r=new Aa(t,4,2),s=new Yn({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},l2=new L,Zy=new Ce,Jy=new Ce,op=class extends lt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";let r=new Ea(t);r.rotateY(Math.PI*.5),this.material=new Yn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new at(o,3)),this.add(new Mt(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");Zy.copy(this.light.color),Jy.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?Zy:Jy;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(l2.setFromMatrixPosition(this.light.matrixWorld).negate())}},ap=class extends An{constructor(e=10,t=10,i=4473924,r=8947848){i=new Ce(i),r=new Ce(r);let s=t/2,o=e/t,a=e/2,c=[],l=[];for(let h=0,f=0,p=-a;h<=t;h++,p+=o){c.push(-a,0,p,a,0,p),c.push(p,0,-a,p,0,a);let y=h===s?i:r;y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3}let u=new tt;u.setAttribute("position",new De(c,3)),u.setAttribute("color",new De(l,3));let d=new Vt({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},cp=class extends An{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new Ce(s),o=new Ce(o);let a=[],c=[];if(t>1)for(let d=0;d<t;d++){let h=d/t*(Math.PI*2),f=Math.sin(h)*e,p=Math.cos(h)*e;a.push(0,0,0),a.push(f,0,p);let y=d&1?s:o;c.push(y.r,y.g,y.b),c.push(y.r,y.g,y.b)}for(let d=0;d<i;d++){let h=d&1?s:o,f=e-e/i*d;for(let p=0;p<r;p++){let y=p/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f;a.push(g,0,m),c.push(h.r,h.g,h.b),y=(p+1)/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f,a.push(g,0,m),c.push(h.r,h.g,h.b)}}let l=new tt;l.setAttribute("position",new De(a,3)),l.setAttribute("color",new De(c,3));let u=new Vt({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Ky=new L,hl=new L,Qy=new L,lp=class extends lt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new tt;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Vt({fog:!1,toneMapped:!1});this.lightPlane=new qn(r,s),this.add(this.lightPlane),r=new tt,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new qn(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Ky.setFromMatrixPosition(this.light.matrixWorld),hl.setFromMatrixPosition(this.light.target.matrixWorld),Qy.subVectors(hl,Ky),this.lightPlane.lookAt(hl),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(hl),this.targetLine.scale.z=Qy.length()}},fl=new L,wt=new Vs,up=class extends An{constructor(e){let t=new tt,i=new Vt({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,y){c(p),c(y)}function c(p){r.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let l=new Ce(16755200),u=new Ce(16711680),d=new Ce(43775),h=new Ce(16777215),f=new Ce(3355443);this.setColors(l,u,d,h,f)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;wt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),At("c",t,e,wt,0,0,-1),At("t",t,e,wt,0,0,1),At("n1",t,e,wt,-i,-r,-1),At("n2",t,e,wt,i,-r,-1),At("n3",t,e,wt,-i,r,-1),At("n4",t,e,wt,i,r,-1),At("f1",t,e,wt,-i,-r,1),At("f2",t,e,wt,i,-r,1),At("f3",t,e,wt,-i,r,1),At("f4",t,e,wt,i,r,1),At("u1",t,e,wt,i*.7,r*1.1,-1),At("u2",t,e,wt,-i*.7,r*1.1,-1),At("u3",t,e,wt,0,r*2,-1),At("cf1",t,e,wt,-i,0,1),At("cf2",t,e,wt,i,0,1),At("cf3",t,e,wt,0,-r,1),At("cf4",t,e,wt,0,r,1),At("cn1",t,e,wt,-i,0,-1),At("cn2",t,e,wt,i,0,-1),At("cn3",t,e,wt,0,-r,-1),At("cn4",t,e,wt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};pl=new zt,dp=class extends An{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new tt;s.setIndex(new at(i,1)),s.setAttribute("position",new at(r,3)),super(s,new Vt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&pl.setFromObject(this.object),pl.isEmpty())return;let t=pl.min,i=pl.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},hp=class extends An{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new tt;s.setIndex(new at(i,1)),s.setAttribute("position",new De(r,3)),super(s,new Vt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},fp=class extends qn{constructor(e,t=1,i=16776960){let r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new tt;o.setAttribute("position",new De(s,3)),o.computeBoundingSphere(),super(o,new Vt({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new tt;c.setAttribute("position",new De(a,3)),c.computeBoundingSphere(),this.add(new Mt(c,new Yn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},e0=new L,pp=class extends lt{constructor(e=new L(0,0,1),t=new L(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",ml===void 0&&(ml=new tt,ml.setAttribute("position",new De([0,0,0,0,1,0],3)),bh=new Xs(0,.5,1,5,1),bh.translate(0,-.5,0)),this.position.copy(t),this.line=new qn(ml,new Vt({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Mt(bh,new Yn({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{e0.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(e0,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},mp=class extends An{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new tt;r.setAttribute("position",new De(t,3)),r.setAttribute("color",new De(i,3));let s=new Vt({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ce,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},gp=class{constructor(){this.type="ShapePath",this.color=new Ce,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Fr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){let x=[];for(let v=0,M=m.length;v<M;v++){let U=m[v],C=new xi;C.curves=U.curves,x.push(C)}return x}function i(m,x){let v=x.length,M=!1;for(let U=v-1,C=0;C<v;U=C++){let R=x[U],N=x[C],w=N.x-R.x,b=N.y-R.y;if(Math.abs(b)>Number.EPSILON){if(b<0&&(R=x[C],w=-w,N=x[U],b=-b),m.y<R.y||m.y>N.y)continue;if(m.y===R.y){if(m.x===R.x)return!0}else{let O=b*(m.x-R.x)-w*(m.y-R.y);if(O===0)return!0;if(O<0)continue;M=!M}}else{if(m.y!==R.y)continue;if(N.x<=m.x&&m.x<=R.x||R.x<=m.x&&m.x<=N.x)return!0}}return M}let r=Xn.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c,l=[];if(s.length===1)return a=s[0],c=new xi,c.curves=a.curves,l.push(c),l;let u=!r(s[0].getPoints());u=e?!u:u;let d=[],h=[],f=[],p=0,y;h[p]=void 0,f[p]=[];for(let m=0,x=s.length;m<x;m++)a=s[m],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&h[p]&&p++,h[p]={s:new xi,p:y},h[p].s.curves=a.curves,u&&p++,f[p]=[]):f[p].push({h:a,p:y[0]});if(!h[0])return t(s);if(h.length>1){let m=!1,x=0;for(let v=0,M=h.length;v<M;v++)d[v]=[];for(let v=0,M=h.length;v<M;v++){let U=f[v];for(let C=0;C<U.length;C++){let R=U[C],N=!0;for(let w=0;w<h.length;w++)i(R.p,h[w].p)&&(v!==w&&x++,N?(N=!1,d[w].push(R)):m=!0);N&&d[v].push(R)}}x>0&&m===!1&&(f=d)}let g;for(let m=0,x=h.length;m<x;m++){c=h[m].s,l.push(c),g=f[m];for(let v=0,M=g.length;v<M;v++)c.holes.push(g[v].h)}return l}},yp=class extends fn{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"164"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="164")});var $C={};Xp($C,{createWorldOrbitEditor:()=>tx});var q=class n extends Error{line;column;constructor(e,t,i){let r=t===void 0?"":` (line ${t}${i===void 0?"":`, column ${i}`})`;super(`${e}${r}`),this.name="WorldOrbitError",this.line=t,this.column=i}static fromLocation(e,t){return new n(e,t?.line,t?.column)}};var io=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],bn=io.filter(n=>n!=="system"),mx=["star","planet","moon","asteroid","comet","structure","phenomenon"],Yp=["structure","phenomenon"],Ri=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],gx=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function rt(n,e){return{key:n,...e}}var Ya=new Set(io),qp=new Map([rt("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:Ri}),rt("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:Ri,unitFamily:"distance"}),rt("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:Ri,unitFamily:"distance"}),rt("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:Ri}),rt("period",{kind:"unit",placement:!0,arity:"single",objectTypes:Ri,unitFamily:"duration"}),rt("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:Ri,unitFamily:"angle"}),rt("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:Ri,unitFamily:"angle"}),rt("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:Ri,unitFamily:"angle"}),rt("at",{kind:"string",placement:!0,arity:"single",objectTypes:Yp}),rt("surface",{kind:"string",placement:!0,arity:"single",objectTypes:Yp}),rt("free",{kind:"string",placement:!0,arity:"single",objectTypes:gx}),rt("kind",{kind:"string",placement:!1,arity:"single",objectTypes:bn}),rt("class",{kind:"string",placement:!1,arity:"single",objectTypes:bn}),rt("culture",{kind:"string",placement:!1,arity:"single",objectTypes:bn}),rt("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:io}),rt("color",{kind:"string",placement:!1,arity:"single",objectTypes:io}),rt("image",{kind:"string",placement:!1,arity:"single",objectTypes:mx}),rt("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:io}),rt("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:bn,unitFamily:"radius"}),rt("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:bn,unitFamily:"mass"}),rt("density",{kind:"unit",placement:!1,arity:"single",objectTypes:bn,unitFamily:"generic"}),rt("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:bn,unitFamily:"generic"}),rt("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:bn,unitFamily:"generic"}),rt("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:bn}),rt("atmosphere",{kind:"string",placement:!1,arity:"single",objectTypes:["planet","moon","asteroid","comet","phenomenon"]}),rt("inner",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),rt("outer",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),rt("view",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),rt("scale",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),rt("units",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),rt("title",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),rt("on",{kind:"string",placement:!1,arity:"single",objectTypes:bn}),rt("source",{kind:"string",placement:!1,arity:"single",objectTypes:bn}),rt("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:bn,unitFamily:"duration"})].map(n=>[n.key,n])),yx=new Set(qp.keys());function cn(n){return qp.get(n)}function Zp(n){return yx.has(n)}function Jp(n,e){return n.objectTypes.includes(e)}function qa(n,e){switch(n){case"distance":return e===null||["au","km","m","ly","pc","kpc","re","sol"].includes(e);case"radius":return e===null||["km","m","re","rj","sol"].includes(e);case"mass":return e===null||["me","mj","sol"].includes(e);case"duration":return e===null||["s","min","h","d","y","ky","my","gy"].includes(e);case"angle":return e===null||e==="deg";case"generic":return!0}}function ro(n,e={}){let t=[],i=e.columnOffset??0,r="",s=null,o=!1,a=!1,c=null,l=()=>{s!==null&&(t.push({value:r,column:s,quoted:o}),r="",s=null,o=!1)};for(let u=0;u<n.length;u++){let d=n[u],h=i+u+1;if(a&&d==="\\"){let f=n[u+1];if(f==='"'||f==="\\"){r+=f,u++;continue}}if(d==='"'){a?a=!1:(s===null&&(s=h),o=!0,c=h,a=!0);continue}if(!a&&/\s/.test(d)){l();continue}s===null&&(s=h),r+=d}if(a)throw new q("Unclosed quote in line",e.line,c??i+n.length);return l(),t}function Za(n){return n.match(/^\s*/)?.[0].length??0}function so(n){let e=n.split(/\r?\n/),t=[],i=null,r=!1,s=null;for(let o=0;o<e.length;o++){let a=e[o],c=o+1;if(!a.trim())continue;let l=Za(a),u=ro(a.slice(l),{line:c,columnOffset:l});if(u.length!==0){if(l===0){r=!1,s=null;let d=vx(u,c);t.push(d),i=d;continue}if(!i)throw new q("Indented line without parent object",c,l+1);if(u.length===1&&u[0].value==="info"){r=!0,s=l;continue}r&&l<=(s??0)&&(r=!1),r?i.infoEntries.push(_x(u,c)):i.blockFields.push(bx(u,c))}}return{type:"document",objects:t}}function vx(n,e){if(n.length<2)throw new q("Invalid object declaration",e,n[0]?.column??1);let[t,i,...r]=n;if(!Ya.has(t.value))throw new q(`Unknown object type "${t.value}"`,e,t.column);return{type:"object",objectType:t.value,name:i.value,inlineFields:xx(r,e),blockFields:[],infoEntries:[],location:{line:e,column:t.column}}}function xx(n,e){let t=[],i=0;for(;i<n.length;){let r=n[i],s=cn(r.value);if(!s)throw new q(`Unknown field "${r.value}"`,e,r.column);i++;let o=[];if(s.arity==="multiple")for(;i<n.length&&!Zp(n[i].value);)o.push(n[i]),i++;else{let a=n[i];a&&(o.push(a),i++)}if(o.length===0)throw new q(`Missing value for field "${r.value}"`,e,r.column);t.push({type:"field",key:r.value,values:o.map(a=>a.value),location:{line:e,column:r.column}})}return t}function bx(n,e){if(n.length<2)throw new q("Invalid field line",e,n[0]?.column??1);if(!cn(n[0].value))throw new q(`Unknown field "${n[0].value}"`,e,n[0].column);return{type:"field",key:n[0].value,values:n.slice(1).map(t=>t.value),location:{line:e,column:n[0].column}}}function _x(n,e){if(n.length<2)throw new q("Invalid info entry",e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(t=>t.value).join(" "),location:{line:e,column:n[0].column}}}var Kp=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,wx=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),Sx=/^[A-Za-z][A-Za-z0-9+.-]*:/;function oo(n){let e=null,t=[];for(let i of n.objects){let r=Mx(i);if(i.objectType==="system"){if(e)throw q.fromLocation("Only one system object is allowed",i.location);e=r}else t.push(r)}return{format:"worldorbit",version:"1.0",schemaVersion:"1.0",system:e,groups:[],relations:[],events:[],objects:t}}function Mx(n){let e=[...n.inlineFields,...n.blockFields];Ex(n.objectType,e);let t=Ax(e),i=Tx(n.objectType,t),r=Ix(t),s=Px(n.infoEntries);return n.objectType==="system"?{type:"system",id:n.name,title:typeof r.title=="string"?r.title:null,description:null,epoch:null,referencePlane:null,properties:r,info:s}:{type:n.objectType,id:n.name,properties:r,placement:i,info:s}}function Ex(n,e){for(let t of e){let i=cn(t.key);if(!i)throw q.fromLocation(`Unknown field "${t.key}"`,t.location);if(!Jp(i,n))throw q.fromLocation(`Field "${t.key}" is not valid on "${n}"`,t.location);if(i.arity==="single"&&t.values.length!==1)throw q.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function Ax(n){let e=new Map;for(let t of n){if(e.has(t.key))throw q.fromLocation(`Duplicate field "${t.key}"`,t.location);e.set(t.key,t)}return e}function Tx(n,e){let t=e.has("orbit"),i=e.has("at"),r=e.has("surface"),s=e.has("free"),o=[t,i,r,s].filter(Boolean).length;if(o>1){let a=e.get("orbit")??e.get("at")??e.get("surface")??e.get("free");throw q.fromLocation("Object has multiple placement modes",a?.location)}if(n==="system"&&o>0)throw q.fromLocation("System objects cannot declare placement",[...e.values()][0]?.location);if(t)return{mode:"orbit",target:Ja(e,"orbit"),distance:Zr(e,"distance"),semiMajor:Zr(e,"semiMajor"),eccentricity:Ox(e,"eccentricity"),period:Zr(e,"period"),angle:Zr(e,"angle"),inclination:Zr(e,"inclination"),phase:Zr(e,"phase")};if(i){let a=Ka(e,"at"),c=Ja(e,"at");return{mode:"at",target:c,reference:Lx(c,a.location)}}if(r)return{mode:"surface",target:Ja(e,"surface")};if(s){let a=Ja(e,"free"),c=Dx(a);return{mode:"free",distance:c??void 0,descriptor:c?void 0:a}}return null}function Ix(n){let e={};for(let[t,i]of n.entries()){let r=cn(t);if(!(!r||r.placement))switch(r.kind){case"list":e[t]=i.values;break;case"boolean":e[t]=Ux(i);break;case"number":e[t]=em(Jr(i),t,i.location);break;case"unit":e[t]=Qp(Jr(i),i.location,t);break;case"string":e[t]=Cx(t,i);break}}return e}function Cx(n,e){let t=e.values.join(" ").trim();return n==="image"&&Rx(t,e.location),t}function Rx(n,e){if(!n)throw q.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw q.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(Sx);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw q.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function Px(n){let e={};for(let t of n){if(t.key in e)throw q.fromLocation(`Duplicate info key "${t.key}"`,t.location);e[t.key]=t.value}return e}function Lx(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function Qp(n,e,t){let i=n.match(Kp);if(!i)throw q.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=cn(t);if(s?.unitFamily&&!qa(s.unitFamily,r.unit))throw q.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function Dx(n){let e=n.match(Kp);return e?{value:Number(e[1]),unit:e[2]??null}:null}function Zr(n,e){if(!n.has(e))return;let t=Ka(n,e);return Qp(Jr(t),t.location,e)}function Ox(n,e){if(!n.has(e))return;let t=Ka(n,e);return em(Jr(t),e,t.location)}function em(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw q.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function Ux(n){let e=Jr(n).toLowerCase(),t=wx.get(e);if(t===void 0)throw q.fromLocation(`Invalid boolean value "${e}" for "${n.key}"`,n.location);return t}function Ka(n,e){let t=n.get(e);if(!t)throw new q(`Missing value for key "${e}"`);return t}function Ja(n,e){return Jr(Ka(n,e))}function Jr(n){if(n.values.length!==1)throw q.fromLocation(`Field "${n.key}" expects exactly one value`,n.location);return n.values[0]}var Nx=new Set(["star","planet","moon","asteroid","comet"]);function ao(n){let e=new Set,t=new Map;for(let i of n.objects){if(e.has(i.id))throw new q(`Duplicate object id "${i.id}"`);e.add(i.id),t.set(i.id,i)}for(let i of n.objects)if(i.placement){if((i.placement.mode==="orbit"||i.placement.mode==="surface")&&!e.has(i.placement.target))throw new q(`Unknown placement target "${i.placement.target}" on "${i.id}"`);if(i.placement.mode==="surface"){let r=t.get(i.placement.target);if(!r||!Nx.has(r.type))throw new q(`Surface target "${i.placement.target}" on "${i.id}" is not surface-capable`)}i.placement.mode==="at"&&(i.placement.reference.kind==="lagrange"&&Fx(i,i.placement.reference,e),i.placement.reference.kind==="anchor"&&kx(i,i.placement.reference,e))}}function Fx(n,e,t){if(!t.has(e.primary))throw new q(`Unknown Lagrange reference "${e.primary}" on "${n.id}"`);if(e.secondary&&!t.has(e.secondary))throw new q(`Unknown Lagrange reference "${e.secondary}" on "${n.id}"`)}function kx(n,e,t){if(!t.has(e.objectId))throw new q(`Unknown anchor target "${e.objectId}" on "${n.id}"`)}function ar(n,e,t=`${e}.failed`){return n instanceof q?{code:t,severity:"error",source:e,message:n.message,line:n.line,column:n.column}:n instanceof Error?{code:t,severity:"error",source:e,message:n.message}:{code:t,severity:"error",source:e,message:String(n)}}var co=1495978707e-1,Bx=6371,zx=71492,Vx=695700,$x=63241.077,Hx=206264.806,jx=206264806,am=.68,Gx=.2,cm=28;function rn(n,e={}){let t=Yx(e),i=t.width,r=t.height,s=t.padding,o=Xx(n),a=Zx(n,e.projection),c=id(e.camera??null),l=nd(a,c),u=Qx(o,e.scaleModel),d=tb(o),h=n.system?.id??null,f=e.activeEventId??null,p=Wx(n.objects,n.events??[],f),y=new Map(p.map(J=>[J.id,J])),g=kb(p,y),m=new Map,x=[],v=[],M=[],U=[],C=[],R=new Map,N=new Map;for(let J of p){let ye=J.placement;if(!ye){M.push(J);continue}if(ye.mode==="orbit"){rm(N,ye.target,J);continue}if(ye.mode==="surface"){rm(R,ye.target,J);continue}if(ye.mode==="at"){C.push(J);continue}U.push(J)}let w=U.length>0?i*.42:i/2,b=r/2,O={orbitChildren:N,surfaceChildren:R,objectMap:y,spacingFactor:d,projection:l,scaleModel:u},B=M.find(J=>J.type==="star")??M[0]??null;B&&Qu(B,w,b,0,m,x,v,O);let F=M.filter(J=>J.id!==B?.id);if(F.length>0){let J=Math.min(i,r)*.28*d*u.orbitDistanceMultiplier;F.forEach((ye,oe)=>{let ze=po(oe,F.length,-Math.PI/2),xe=mo(ze,J,l,1);Qu(ye,w+xe.x,b+xe.y,0,m,x,v,O)})}U.forEach((J,ye)=>{let oe=i-s-140-jb(J.placement?.mode==="free"?J.placement.distance:void 0,u),ze=Math.max(76,(r-s*2-180)/Math.max(1,U.length)*d)*u.freePlacementMultiplier,xe=s+92+ye*ze;m.set(J.id,{object:J,x:oe,y:xe,radius:ic(J,0,u),sortKey:sc(oe,xe,0)}),v.push({object:J,groupId:g.groupIds.get(J.id)??null,x1:oe-60,y1:xe,x2:oe-18,y2:xe,mode:"free"}),tc(J,m,x,v,O,1)}),C.forEach((J,ye)=>{if(m.has(J.id)||!J.placement||J.placement.mode!=="at")return;let oe=Nb(J.placement.reference,m,y,ye,C.length,i,r,s,O);m.set(J.id,{object:J,x:oe.x,y:oe.y,radius:ic(J,2,u),sortKey:sc(oe.x,oe.y,2),anchorX:oe.anchorX,anchorY:oe.anchorY}),oe.anchorX!==void 0&&oe.anchorY!==void 0&&v.push({object:J,groupId:g.groupIds.get(J.id)??null,x1:oe.anchorX,y1:oe.anchorY,x2:oe.x,y2:oe.y,mode:"at"}),tc(J,m,x,v,O,2)});let H=[...m.values()].map(J=>nb(J,u,g)),X=x.map(J=>ib(J,g.groupIds.get(J.object.id)??null)),ee=v.map(J=>rb(J)),ce=sb(H,i,r,u.labelMultiplier),k=fb(n,H),le=pb(n.events??[],H,f),he=ub(X,k,le,ee,H,ce),Te=db(H,X,ee,ce,g,u.labelMultiplier),ve=hb(n,H),He=mb(n,a,t.preset,g,y),Z=Tb(i,r,H,X,ee,ce,u.labelMultiplier);return{width:i,height:r,padding:s,renderPreset:t.preset,projection:a,renderProjection:l,camera:c,scaleModel:u,title:String(n.system?.title??n.system?.properties.title??n.system?.id??"WorldOrbit")||"WorldOrbit",subtitle:Kx(a,l,o,c),systemId:h,viewMode:a,layoutPreset:o,metadata:{format:n.format,version:n.version,view:a,renderProjection:l,scale:String(n.system?.properties.scale??o),units:String(n.system?.properties.units??"mixed"),preset:t.preset??"custom",...c?.azimuth!==null?{"camera.azimuth":String(c?.azimuth)}:{},...c?.elevation!==null?{"camera.elevation":String(c?.elevation)}:{},...c?.roll!==null?{"camera.roll":String(c?.roll)}:{},...c?.distance!==null?{"camera.distance":String(c?.distance)}:{}},contentBounds:Z,layers:he,groups:Te,semanticGroups:ve,viewpoints:He,events:le,activeEventId:f,objects:H,orbitVisuals:X,relations:k,leaders:ee,labels:ce}}function sn(n,e,t){let i=oc(t),r=Math.cos(i),s=Math.sin(i),o=n.x-e.x,a=n.y-e.y;return{x:e.x+o*r-a*s,y:e.y+o*s+a*r}}function Wx(n,e,t){let i=n.map(a=>structuredClone(a));if(!t)return i;let r=e.find(a=>a.id===t);if(!r)return i;let s=new Map(i.map(a=>[a.id,a])),o=new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds,...r.positions.map(a=>a.objectId)]);for(let a of o){let c=s.get(a);c&&(r.epoch&&(c.epoch=r.epoch),r.referencePlane&&(c.referencePlane=r.referencePlane))}for(let a of r.positions){let c=s.get(a.objectId);c&&(a.placement&&(c.placement=structuredClone(a.placement)),a.inner&&(c.properties.inner={...a.inner}),a.outer&&(c.properties.outer={...a.outer}),a.epoch&&(c.epoch=a.epoch),a.referencePlane&&(c.referencePlane=a.referencePlane))}return i}function Xx(n){switch(String(n.system?.properties.scale??"balanced").toLowerCase()){case"compressed":case"compact":return"compact";case"expanded":case"presentation":return"presentation";default:return"balanced"}}function Yx(n){let e=qx(n.preset);return{width:n.width??e.width,height:n.height??e.height,padding:n.padding??e.padding,preset:n.preset??null}}function qx(n){switch(n){case"presentation":return{width:1440,height:900,padding:88};case"atlas-card":return{width:960,height:560,padding:56};case"markdown":return{width:920,height:540,padding:48};default:return{width:1200,height:780,padding:72}}}function Zx(n,e){if(e==="topdown"||e==="isometric"||e==="orthographic"||e==="perspective")return e;let t=String(n.system?.properties.view??"topdown").toLowerCase();return dm(t)??"topdown"}function nd(n,e){switch(n){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return e&&(e.azimuth!==null||e.elevation!==null||e.roll!==null)?"isometric":"topdown";case"perspective":return"isometric"}}function id(n){if(!n)return null;let e={azimuth:Ku(n.azimuth),elevation:Ku(n.elevation),roll:Ku(n.roll),distance:Jx(n.distance)};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function Ku(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Jx(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function Kx(n,e,t,i){let r=[`${sm(n)} view`,`${sm(t)} layout`];if(n!==e&&r.push(`2D ${e} fallback`),i){let s=[i.azimuth!==null?`az ${i.azimuth}`:null,i.elevation!==null?`el ${i.elevation}`:null,i.roll!==null?`roll ${i.roll}`:null,i.distance!==null?`dist ${i.distance}`:null].filter(Boolean);s.length>0&&r.push(`camera ${s.join(" / ")}`)}return r.join(" - ")}function Qx(n,e){return{...eb(n),...e}}function eb(n){switch(n){case"compact":return{orbitDistanceMultiplier:.84,bodyRadiusMultiplier:.92,labelMultiplier:.9,freePlacementMultiplier:.9,ringThicknessMultiplier:.92,minBodyRadius:4,maxBodyRadius:36};case"presentation":return{orbitDistanceMultiplier:1.2,bodyRadiusMultiplier:1.18,labelMultiplier:1.08,freePlacementMultiplier:1.05,ringThicknessMultiplier:1.16,minBodyRadius:5,maxBodyRadius:48};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,labelMultiplier:1,freePlacementMultiplier:1,ringThicknessMultiplier:1,minBodyRadius:4,maxBodyRadius:40}}}function tb(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function nb(n,e,t){let{object:i,x:r,y:s,radius:o,sortKey:a,anchorX:c,anchorY:l}=n,u=i.renderHints?.renderPriority??0;return{renderId:Kr(i.id),objectId:i.id,object:i,parentId:t.parentIds.get(i.id)??null,ancestorIds:t.ancestorIds.get(i.id)??[],childIds:t.childIds.get(i.id)??[],groupId:t.groupIds.get(i.id)??null,semanticGroupIds:[...i.groups??[]],x:r,y:s,radius:o,visualRadius:Hb(i,o,e),sortKey:a+u*.001,anchorX:c,anchorY:l,label:i.id,secondaryLabel:i.type==="structure"?String(i.properties.kind??i.type):i.type,fillColor:Wb(i.properties.color),imageHref:typeof i.properties.image=="string"&&i.properties.image.trim()?i.properties.image:void 0,hidden:i.properties.hidden===!0}}function ib(n,e){return{renderId:`${Kr(n.object.id)}-orbit`,objectId:n.object.id,object:n.object,parentId:n.parentId,groupId:e,semanticGroupIds:[...n.object.groups??[]],kind:n.kind,cx:n.cx,cy:n.cy,radius:n.radius,rx:n.rx,ry:n.ry,rotationDeg:n.rotationDeg,band:n.band,bandThickness:n.bandThickness,frontArcPath:n.frontArcPath,backArcPath:n.backArcPath,hidden:n.object.properties.hidden===!0||n.object.renderHints?.renderOrbit===!1}}function rb(n){return{renderId:`${Kr(n.object.id)}-leader-${n.mode}`,objectId:n.object.id,object:n.object,groupId:n.groupId,semanticGroupIds:[...n.object.groups??[]],x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,mode:n.mode,hidden:n.object.properties.hidden===!0}}function sb(n,e,t,i){let r=[],s=[],o=new Map(n.map(c=>[c.objectId,c])),a=[...n].filter(c=>!c.hidden&&c.object.renderHints?.renderLabel!==!1).sort(ob);for(let c of a){let l=ab(c,o,s,e,t,i)??um(c,lm(c,o.get(c.parentId??"")??null,t),0,i);s.push(gm(c,l,i)),r.push({renderId:`${c.renderId}-label`,objectId:c.objectId,object:c.object,groupId:c.groupId,semanticGroupIds:[...c.semanticGroupIds],label:c.label,secondaryLabel:c.secondaryLabel,x:l.x,y:l.labelY,secondaryY:l.secondaryY,textAnchor:l.textAnchor,direction:l.direction,hidden:c.hidden})}return r}function ob(n,e){let t=tm(n)-tm(e);if(t!==0)return t;let i=(e.object.renderHints?.renderPriority??0)-(n.object.renderHints?.renderPriority??0);return i!==0?i:n.sortKey-e.sortKey}function tm(n){switch(n.object.type){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":case"ring":return 3;case"asteroid":case"comet":return 4;case"structure":case"phenomenon":return 5}}function ab(n,e,t,i,r,s){for(let o of cb(n,e,i,r)){let a=o==="left"||o==="right"?4:6;for(let c=0;c<=a;c+=1){let l=um(n,o,c,s),u=gm(n,l,s);if(!t.some(d=>Vb(d,u)))return l}}return null}function cb(n,e,t,i){let r=n.parentId?e.get(n.parentId)??null:null,s=lm(n,r,i),o=s==="below"?"above":"below",a=lb(n,r,t),c=a==="right"?"left":"right";return n.object.type==="structure"||n.object.type==="phenomenon"||n.object.placement?.mode==="at"||n.object.placement?.mode==="surface"||n.object.placement?.mode==="free"?[a,s,c,o]:[s,a,o,c]}function lm(n,e,t){return e&&Math.abs(n.y-e.y)>6?n.y>=e.y?"below":"above":n.y>t*.62?"above":"below"}function lb(n,e,t){return e&&Math.abs(n.x-e.x)>6?n.x>=e.x?"right":"left":n.x>=t/2?"right":"left"}function um(n,e,t,i){let r=14*i;switch(e){case"above":{let s=n.y-(n.radius+18*i+t*r);return{x:n.x,labelY:s,secondaryY:s-16*i,textAnchor:"middle",direction:e}}case"below":{let s=n.y+n.radius+18*i+t*r;return{x:n.x,labelY:s,secondaryY:s+16*i,textAnchor:"middle",direction:e}}case"left":{let s=n.x-(n.visualRadius+16*i+t*r),o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"end",direction:e}}case"right":{let s=n.x+n.visualRadius+16*i+t*r,o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"start",direction:e}}}}function ub(n,e,t,i,r,s){let o=n.filter(c=>!c.hidden&&!!c.backArcPath).map(c=>c.renderId),a=n.filter(c=>!c.hidden).map(c=>c.renderId);return[{id:"background",renderIds:["wo-bg","wo-bg-glow","wo-grid"]},{id:"guides",renderIds:i.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"orbits-back",renderIds:o},{id:"orbits-front",renderIds:a},{id:"relations",renderIds:e.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"events",renderIds:t.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"objects",renderIds:r.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"labels",renderIds:s.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"metadata",renderIds:["wo-title","wo-subtitle","wo-meta"]}]}function db(n,e,t,i,r,s){let o=new Map,a=c=>{if(!c)return null;let l=o.get(c);if(l)return l;let u=r.groupRoots.get(c)??null,d={renderId:c,rootObjectId:u,label:u??c,objectIds:[],orbitIds:[],labelIds:[],leaderIds:[],contentBounds:fo(0,0,0,0)};return o.set(c,d),d};for(let c of n){let l=a(c.groupId);l&&!c.hidden&&l.objectIds.push(c.objectId)}for(let c of e){let l=a(c.groupId);l&&!c.hidden&&l.orbitIds.push(c.objectId)}for(let c of t){let l=a(c.groupId);l&&!c.hidden&&l.leaderIds.push(c.objectId)}for(let c of i){let l=a(c.groupId);l&&!c.hidden&&l.labelIds.push(c.objectId)}for(let c of o.values())c.contentBounds=Bb(c,n,e,t,i,s);return[...o.values()].sort((c,l)=>c.label.localeCompare(l.label))}function hb(n,e){return[...n.groups].map(t=>({id:t.id,label:t.label,summary:t.summary,color:t.color,tags:[...t.tags],hidden:t.hidden,objectIds:e.filter(i=>!i.hidden&&i.semanticGroupIds.includes(t.id)).map(i=>i.objectId)})).sort((t,i)=>t.label.localeCompare(i.label))}function fb(n,e){let t=new Map(e.map(i=>[i.objectId,i]));return n.relations.map(i=>{let r=t.get(i.from),s=t.get(i.to);return{renderId:`${Kr(i.id)}-relation`,relationId:i.id,relation:i,fromObjectId:i.from,toObjectId:i.to,x1:r?.x??0,y1:r?.y??0,x2:s?.x??0,y2:s?.y??0,hidden:i.hidden||!r||!s||r.hidden||s.hidden}}).sort((i,r)=>i.relation.id.localeCompare(r.relation.id))}function pb(n,e,t){let i=new Map(e.map(r=>[r.objectId,r]));return n.map(r=>{let s=[...new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds])],o=s.map(l=>i.get(l)).filter(Boolean),a=o.length>0?o.reduce((l,u)=>l+u.x,0)/o.length:0,c=o.length>0?o.reduce((l,u)=>l+u.y,0)/o.length:0;return{renderId:`${Kr(r.id)}-event`,eventId:r.id,event:r,objectIds:s,participantIds:[...r.participantObjectIds],targetObjectId:r.targetObjectId,x:a,y:c,hidden:r.hidden||o.length===0||o.every(l=>l.hidden)||t!==null&&r.id!==t}}).sort((r,s)=>r.event.id.localeCompare(s.event.id))}function mb(n,e,t,i,r){let s=gb(n,e,t),o=new Map;for(let[l,u]of Object.entries(n.system?.info??{})){if(!l.startsWith("viewpoint."))continue;let[d,h,...f]=l.split(".");if(d!=="viewpoint"||!h||f.length===0)continue;let p=Mb(h);if(!p)continue;let y=f.join(".").toLowerCase(),g=o.get(p)??{id:p};yb(g,y,u,n,e,t,i,r),o.set(p,g)}let a=[...o.values()].map(l=>vb(l,e,t,r)).filter(Boolean),c=a.findIndex(l=>l.id===s.id);return c>=0?a.splice(c,1,{...s,...a[c],layers:{...s.layers,...a[c].layers},filter:a[c].filter??s.filter,generated:!1}):a.unshift(s),a.sort((l,u)=>l.id==="overview"?-1:u.id==="overview"?1:l.label.localeCompare(u.label))}function gb(n,e,t){let i=n.system?.title??n.system?.properties.title,r=i?`${String(i)} Overview`:"Overview",s=id(null),o=nd(e,s);return{id:"overview",label:r,summary:"Fit the whole system with the current atlas defaults.",objectId:null,selectedObjectId:null,eventIds:[],projection:e,renderProjection:o,camera:s,preset:t,rotationDeg:0,scale:null,layers:{},filter:null,generated:!0}}function yb(n,e,t,i,r,s,o,a){let c=t.trim();switch(e){case"label":case"title":c&&(n.label=c);return;case"summary":case"description":c&&(n.summary=c);return;case"focus":case"object":c&&(n.focus=c);return;case"select":case"selection":c&&(n.select=c);return;case"events":n.eventIds=ho(c);return;case"projection":case"view":n.projection=dm(c)??r;return;case"preset":n.preset=bb(c)??s;return;case"rotation":case"angle":n.rotationDeg=lo(c)??n.rotationDeg??0;return;case"camera.azimuth":n.camera={...n.camera??ec(),azimuth:lo(c)};return;case"camera.elevation":n.camera={...n.camera??ec(),elevation:lo(c)};return;case"camera.roll":n.camera={...n.camera??ec(),roll:lo(c)};return;case"camera.distance":n.camera={...n.camera??ec(),distance:nm(c)};return;case"zoom":case"scale":n.scale=nm(c);return;case"layers":n.layers=_b(c);return;case"query":n.filter={...n.filter??Qa(),query:c||null};return;case"types":case"objecttypes":n.filter={...n.filter??Qa(),objectTypes:wb(c)};return;case"tags":n.filter={...n.filter??Qa(),tags:ho(c)};return;case"groups":n.filter={...n.filter??Qa(),groupIds:Sb(c,i,o,a)};return}}function vb(n,e,t,i){let r=n.focus&&i.has(n.focus)?n.focus:null,s=n.select&&i.has(n.select)?n.select:r,o=xb(n.filter),a=n.label?.trim()||Eb(n.id),c=n.projection??e,l=id(n.camera??null),u=nd(c,l);return{id:n.id,label:a,summary:n.summary?.trim()||Ab(a,r,o),objectId:r,selectedObjectId:s,eventIds:[...new Set(n.eventIds??[])],projection:c,renderProjection:u,camera:l,preset:n.preset??t,rotationDeg:n.rotationDeg??0,scale:n.scale??null,layers:n.layers??{},filter:o,generated:!1}}function Qa(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function ec(){return{azimuth:null,elevation:null,roll:null,distance:null}}function xb(n){if(!n)return null;let e={query:n.query?.trim()||null,objectTypes:[...new Set(n.objectTypes)],tags:[...new Set(n.tags)],groupIds:[...new Set(n.groupIds)]};return e.query||e.objectTypes.length>0||e.tags.length>0||e.groupIds.length>0?e:null}function dm(n){switch(n.toLowerCase()){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return"orthographic";case"perspective":return"perspective";default:return null}}function bb(n){let e=n.toLowerCase();return e==="diagram"||e==="presentation"||e==="atlas-card"||e==="markdown"?e:null}function lo(n){let e=Number(n);return Number.isFinite(e)?e:null}function nm(n){let e=lo(n);return e!==null&&e>0?e:null}function _b(n){let e={};for(let t of ho(n)){let i=!t.startsWith("-")&&!t.startsWith("!"),r=t.replace(/^[-!]+/,"").toLowerCase();if(r==="orbits"){e["orbits-back"]=i,e["orbits-front"]=i;continue}(r==="background"||r==="guides"||r==="orbits-back"||r==="orbits-front"||r==="relations"||r==="events"||r==="objects"||r==="labels"||r==="metadata")&&(e[r]=i)}return e}function wb(n){return ho(n).filter(e=>e==="star"||e==="planet"||e==="moon"||e==="belt"||e==="asteroid"||e==="comet"||e==="ring"||e==="structure"||e==="phenomenon")}function Sb(n,e,t,i){return ho(n).map(r=>e.schemaVersion==="2.1"||e.schemaVersion==="2.5"||e.groups.some(s=>s.id===r)||r.startsWith("wo-")&&r.endsWith("-group")?r:t.groupIds.has(r)?t.groupIds.get(r)??uo(r):(i.has(r),uo(r)))}function ho(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function Mb(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Eb(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Ab(n,e,t){let i=[n];return e&&i.push(`focus ${e}`),t?.objectTypes.length&&i.push(t.objectTypes.join("/")),t?.tags.length&&i.push(`tags ${t.tags.join(", ")}`),t?.query&&i.push(`query "${t.query}"`),i.join(" - ")}function Tb(n,e,t,i,r,s,o){let a=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,d=(h,f)=>{a=Math.min(a,h),c=Math.min(c,f),l=Math.max(l,h),u=Math.max(u,f)};for(let h of i)h.hidden||hm(h,d);for(let h of r)h.hidden||(d(h.x1,h.y1),d(h.x2,h.y2));for(let h of t)h.hidden||fm(h,d);for(let h of s)h.hidden||pm(h,d,o);return!Number.isFinite(a)||!Number.isFinite(c)?fo(0,0,n,e):fo(a,c,l,u)}function hm(n,e){let t=n.bandThickness!==void 0?n.bandThickness/2+4:n.band?10:3;if(n.kind==="circle"&&n.radius!==void 0){e(n.cx-n.radius-t,n.cy-n.radius-t),e(n.cx+n.radius+t,n.cy+n.radius+t);return}let i=n.rx??n.radius??0,r=n.ry??n.radius??0,s=vm(n.cx,n.cy,i,r,n.rotationDeg,0,Math.PI*2,cm*2);for(let o of s)e(o.x-t,o.y-t),e(o.x+t,o.y+t)}function fo(n,e,t,i){return{minX:n,minY:e,maxX:t,maxY:i,width:t-n,height:i-e,centerX:n+(t-n)/2,centerY:e+(i-e)/2}}function fm(n,e){e(n.x-n.visualRadius-24,n.y-n.visualRadius-16),e(n.x+n.visualRadius+24,n.y+n.visualRadius+36)}function pm(n,e,t){let i=ym(n.x,n.y,n.secondaryY,n.textAnchor,n.direction,n.label,n.secondaryLabel,t);e(i.left,i.top),e(i.right,i.bottom)}function Qu(n,e,t,i,r,s,o,a){r.has(n.id)||(r.set(n.id,{object:n,x:e,y:t,radius:ic(n,i,a.scaleModel),sortKey:sc(e,t,i)}),tc(n,r,s,o,a,i+1))}function tc(n,e,t,i,r,s){let o=e.get(n.id);if(!o)return;let a=[...r.orbitChildren.get(n.id)??[]].sort(Ib),c=Cb(a,o.radius,r.spacingFactor,r.scaleModel),l=Lb(a,c);a.forEach((d,h)=>{let f=Rb(d,h,a.length,o,c,l[h]??c.innerPx,r);t.push({object:d,parentId:n.id,kind:f.kind,cx:f.cx,cy:f.cy,radius:f.radius,rx:f.rx,ry:f.ry,rotationDeg:f.rotationDeg,band:f.band,bandThickness:f.bandThickness,frontArcPath:f.frontArcPath,backArcPath:f.backArcPath}),Qu(d,f.objectX,f.objectY,s,e,t,i,r)});let u=[...r.surfaceChildren.get(n.id)??[]];u.forEach((d,h)=>{let f=po(h,u.length,-Math.PI/3),p=28*r.spacingFactor,y=mo(f,o.radius,r.projection,r.projection==="isometric"?.9:1),g=mo(f,o.radius+p,r.projection,r.projection==="isometric"?.9:1),m=o.x+y.x,x=o.y+y.y,v=o.x+g.x,M=o.y+g.y;e.set(d.id,{object:d,x:v,y:M,radius:ic(d,s+1,r.scaleModel),sortKey:sc(v,M,s+1),anchorX:m,anchorY:x}),i.push({object:d,groupId:r.objectMap.has(d.id)?uo(zb(d,r.objectMap)):null,x1:m,y1:x,x2:v,y2:M,mode:"surface"}),tc(d,e,t,i,r,s+1)})}function Ib(n,e){let t=nc(n),i=nc(e);return t!==null&&i!==null&&t!==i?t-i:t!==null&&i===null?-1:t===null&&i!==null?1:n.id.localeCompare(e.id)}function Cb(n,e,t,i){let r=n.map(d=>nc(d)),s=r.filter(d=>d!==null),o=e+56*t*i.orbitDistanceMultiplier,a=(n.length>2?54:64)*t*i.orbitDistanceMultiplier;if(s.length===0)return{metrics:r,minMetric:0,maxMetric:0,metricSpread:0,innerPx:o,stepPx:a,pixelSpread:Math.max(a*Math.max(n.length-1,1),a),minimumGapPx:a*.42};let c=Math.min(...s),l=Math.max(...s),u=l-c;return{metrics:r,minMetric:c,maxMetric:l,metricSpread:u,innerPx:o,stepPx:a,pixelSpread:Math.max(a*Math.max(n.length-1,1),a),minimumGapPx:a*.42}}function Rb(n,e,t,i,r,s,o){let a=n.placement,c=n.type==="belt"||n.type==="ring";if(!a||a.mode!=="orbit"){let N=r.innerPx+e*r.stepPx;return{kind:"circle",cx:i.x,cy:i.y,radius:N,rotationDeg:0,band:c,bandThickness:c?12*o.scaleModel.ringThicknessMultiplier:void 0,objectX:i.x,objectY:i.y-N}}let l=Rt(typeof a.eccentricity=="number"?a.eccentricity:0,0,.92),u=s,d=Math.max(u*Math.sqrt(1-l*l),u*.18),h=td(a.inclination)??0,f=o.projection==="isometric"?Math.max(Gx,Math.cos(oc(h)))*am:1,p=Math.max(d*f,u*.14),y=td(a.angle)??0,g=u*l,m=bm(-g,0,y),x=i.x+m.x,v=i.y+m.y,M=Ob(a.phase,e,t),U=xm(x,v,u,p,y,M),C=o.projection==="topdown"&&l<=1e-4&&Math.abs(y)<=1e-4,R=c?Ub(n,u,r,o.scaleModel):void 0;return{kind:C?"circle":"ellipse",cx:C?i.x:x,cy:C?i.y:v,radius:C?u:void 0,rx:C?void 0:u,ry:C?void 0:p,rotationDeg:y,band:c,bandThickness:R,frontArcPath:o.projection==="isometric"||c?im(x,v,u,p,y,0,Math.PI):void 0,backArcPath:o.projection==="isometric"||c?im(x,v,u,p,y,Math.PI,Math.PI*2):void 0,objectX:U.x,objectY:U.y}}function Pb(n,e){return e.innerPx+e.stepPx*Db(Math.max(n,0)+1)}function Lb(n,e){let t=[];return n.forEach((i,r)=>{let s=nc(i),o=e.innerPx+r*e.stepPx,a=s===null?o:Pb(s,e),c=r===0?e.innerPx:(t[r-1]??e.innerPx)+e.minimumGapPx;t.push(Math.max(a,c))}),t}function nc(n){return!n.placement||n.placement.mode!=="orbit"?null:rc(n.placement.semiMajor??n.placement.distance??null)}function Db(n){return Math.log(n)/Math.log(2)}function Ob(n,e,t){let i=n?td(n):null;return i!==null?oc(i-90):po(e,t,-Math.PI/2)}function Ub(n,e,t,i){let r=rc(ed(n.properties.inner)),s=rc(ed(n.properties.outer));if(r!==null&&s!==null){let a=Math.abs(s-r);if(t.metricSpread>0)return Rt(a/t.metricSpread*t.pixelSpread*i.ringThicknessMultiplier,8,54);let c=Math.max(Math.max(r,s),1e-4);return Rt(a/c*e*.75*i.ringThicknessMultiplier,8,48)}return(n.type==="belt"?18:12)*i.ringThicknessMultiplier}function Nb(n,e,t,i,r,s,o,a,c){if(n.kind==="lagrange")return Fb(n,e,t,s,o);if(n.kind==="anchor"){let l=e.get(n.objectId);if(l){let u=po(i,r,Math.PI/5),d=(l.radius+36)*c.scaleModel.labelMultiplier,h=mo(u,d,c.projection,c.projection==="isometric"?.92:1);return{x:l.x+h.x,y:l.y+h.y,anchorX:l.x,anchorY:l.y}}}if(n.kind==="named"){let l=e.get(n.name);if(l){let u=po(i,r,Math.PI/6),d=(l.radius+36)*c.scaleModel.labelMultiplier,h=mo(u,d,c.projection,c.projection==="isometric"?.92:1);return{x:l.x+h.x,y:l.y+h.y,anchorX:l.x,anchorY:l.y}}}return{x:s-a-170,y:o-a-86-i*58*c.scaleModel.freePlacementMultiplier}}function Fb(n,e,t,i,r){let s=n.secondary?e.get(n.primary):$b(n.primary,e,t),o=e.get(n.secondary??n.primary);if(!s||!o)return{x:i*.7,y:r*.25};let a=o.x-s.x,c=o.y-s.y,l=Math.hypot(a,c)||1,u=a/l,d=c/l,h=-d,f=u,p=Rt(l*.25,24,68);switch(n.point){case"L1":return{x:o.x-u*p,y:o.y-d*p,anchorX:o.x,anchorY:o.y};case"L2":return{x:o.x+u*p,y:o.y+d*p,anchorX:o.x,anchorY:o.y};case"L3":return{x:s.x-u*p,y:s.y-d*p,anchorX:s.x,anchorY:s.y};case"L4":return{x:o.x+(u*.5-h*.8660254)*p,y:o.y+(d*.5-f*.8660254)*p,anchorX:o.x,anchorY:o.y};case"L5":return{x:o.x+(u*.5+h*.8660254)*p,y:o.y+(d*.5+f*.8660254)*p,anchorX:o.x,anchorY:o.y}}}function kb(n,e){let t=new Map,i=new Map;for(let l of n){let u=mm(l,e);if(t.set(l.id,u),u){let d=i.get(u);d?d.push(l.id):i.set(u,[l.id])}i.has(l.id)||i.set(l.id,[])}let r=new Map,s=new Map,o=new Map,a=l=>{let u=r.get(l);if(u)return u;let d=new Set,h=[],f=t.get(l)??null;for(;f&&!d.has(f);)h.push(f),d.add(f),f=t.get(f)??null;return r.set(l,h),h},c=l=>{let u=o.get(s.get(l)??"");if(u)return u;let d=t.get(l)??null,h=e.get(l),f=l;return h?.placement&&h.placement.mode!=="free"&&d&&(f=c(d)),f};for(let l of n){a(l.id);let u=c(l.id),d=uo(u);s.set(l.id,d),o.set(d,u)}return{parentIds:t,childIds:i,ancestorIds:r,groupIds:s,groupRoots:o}}function mm(n,e){let t=n.placement;if(!t)return null;switch(t.mode){case"orbit":case"surface":return e.has(t.target)?t.target:null;case"at":switch(t.reference.kind){case"anchor":return e.has(t.reference.objectId)?t.reference.objectId:null;case"named":return e.has(t.reference.name)?t.reference.name:null;case"lagrange":return t.reference.secondary&&e.has(t.reference.secondary)?t.reference.secondary:e.has(t.reference.primary)?t.reference.primary:null}case"free":return null}}function Bb(n,e,t,i,r,s){let o=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=(d,h)=>{o=Math.min(o,d),a=Math.min(a,h),c=Math.max(c,d),l=Math.max(l,h)};for(let d of e)!d.hidden&&n.objectIds.includes(d.objectId)&&fm(d,u);for(let d of t)!d.hidden&&n.orbitIds.includes(d.objectId)&&hm(d,u);for(let d of i)!d.hidden&&n.leaderIds.includes(d.objectId)&&(u(d.x1,d.y1),u(d.x2,d.y2));for(let d of r)!d.hidden&&n.labelIds.includes(d.objectId)&&pm(d,u,s);return!Number.isFinite(o)||!Number.isFinite(a)?fo(0,0,0,0):fo(o,a,c,l)}function zb(n,e){let t=n,i=new Set;for(;t.placement&&t.placement.mode!=="free"&&!i.has(t.id);){i.add(t.id);let r=mm(t,e);if(!r)break;let s=e.get(r);if(!s)break;t=s}return t.id}function gm(n,e,t){return ym(e.x,e.labelY,e.secondaryY,e.textAnchor,e.direction,n.label,n.secondaryLabel,t)}function ym(n,e,t,i,r,s,o,a){let c=Xb(s,o,a),l=c*2,u=r==="above"?18:12,d=r==="above"?8:12,h=n-c,f=n+c;return i==="start"?(h=n,f=n+l):i==="end"&&(h=n-l,f=n),{left:h,right:f,top:Math.min(e,t)-u,bottom:Math.max(e,t)+d}}function Vb(n,e){return!(n.right<e.left||e.right<n.left||n.bottom<e.top||e.bottom<n.top)}function $b(n,e,t){let i=t.get(n);return!i?.placement||i.placement.mode!=="orbit"?e.get(n):e.get(i.placement.target)}function ic(n,e,t){let i=Gb(n.properties.radius,t);if(i!==null)return i;let r=t.bodyRadiusMultiplier;switch(n.type){case"star":return Rt((e===0?28:20)*r,t.minBodyRadius,t.maxBodyRadius);case"planet":return Rt(12*r,t.minBodyRadius,t.maxBodyRadius);case"moon":return Rt(7*r,t.minBodyRadius,t.maxBodyRadius);case"belt":return Rt(5*r,t.minBodyRadius,t.maxBodyRadius);case"asteroid":return Rt(5*r,t.minBodyRadius,t.maxBodyRadius);case"comet":return Rt(6*r,t.minBodyRadius,t.maxBodyRadius);case"ring":return Rt(5*r,t.minBodyRadius,t.maxBodyRadius);case"structure":return Rt(6*r,t.minBodyRadius,t.maxBodyRadius);case"phenomenon":return Rt(8*r,t.minBodyRadius,t.maxBodyRadius)}}function Hb(n,e,t){let i=typeof n.properties.atmosphere=="string"?4:0;switch(n.type){case"star":return e*2.4;case"phenomenon":return e*1.25;case"structure":return e+2;default:return Math.min(e+i,t.maxBodyRadius+10)}}function rc(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/co;case"m":return n.value/1e3/co;case"ly":return n.value*$x;case"pc":return n.value*Hx;case"kpc":return n.value*jx;case"re":return n.value*Bx/co;case"rj":return n.value*zx/co;case"sol":return n.value*Vx/co;default:return n.value}}function jb(n,e){let t=rc(n??null);return t===null||t<=0?0:Rt(t*96*e.freePlacementMultiplier,0,420)}function Gb(n,e){let t=ed(n);if(!t)return null;let i;switch(t.unit){case"sol":i=Rt(t.value*22,14,40);break;case"re":i=Rt(t.value*10,6,18);break;case"km":i=Rt(Math.log10(Math.max(t.value,1))*2.6,4,16);break;default:i=Rt(t.value*4,4,20);break}return Rt(i*e.bodyRadiusMultiplier,e.minBodyRadius,e.maxBodyRadius)}function ed(n){return!n||typeof n!="object"||!("value"in n)?null:n}function td(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function po(n,e,t){return e<=1?t:t+n*Math.PI*2/e}function im(n,e,t,i,r,s,o){let a=vm(n,e,t,i,r,s,o,cm);return a.length===0?"":a.map((c,l)=>`${l===0?"M":"L"} ${om(c.x)} ${om(c.y)}`).join(" ")}function vm(n,e,t,i,r,s,o,a){let c=[];for(let l=0;l<=a;l+=1){let u=s+(o-s)*l/a;c.push(xm(n,e,t,i,r,u))}return c}function xm(n,e,t,i,r,s){let o=t*Math.cos(s),a=i*Math.sin(s),c=bm(o,a,r);return{x:n+c.x,y:e+c.y}}function bm(n,e,t){let i=oc(t);return{x:n*Math.cos(i)-e*Math.sin(i),y:n*Math.sin(i)+e*Math.cos(i)}}function mo(n,e,t,i){let r=t==="isometric"?am*i:i;return{x:Math.cos(n)*e,y:Math.sin(n)*e*r}}function sc(n,e,t){return e*1e3+n+t*.01}function Rt(n,e,t){return Math.min(Math.max(n,e),t)}function rm(n,e,t){let i=n.get(e);i?i.push(t):n.set(e,[t])}function Kr(n){return`wo-${n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function uo(n){return`${Kr(n)}-group`}function Wb(n){return typeof n=="string"&&n.trim()?n:void 0}function Xb(n,e,t){let i=n.length*4.6*t+18,r=e.length*3.9*t+18;return Math.max(i,r,24)}function sm(n){return n.length>0?n[0].toUpperCase()+n.slice(1):n}function oc(n){return n*Math.PI/180}function om(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var Sm=86400,ac=Sm*365.25,cc=18,_m=180;function es(n,e={}){let t={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,camera:e.camera,scaleModel:e.scaleModel,activeEventId:e.activeEventId},i=rn(n,t),r=Jb(i.layoutPreset,e.spatialScaleModel),s={x:i.contentBounds.centerX,y:i.contentBounds.centerY},o=new Map(i.objects.map(y=>[y.objectId,y])),a=new Map(i.orbitVisuals.map(y=>[y.objectId,y])),c=new Map;for(let y of i.objects){let g=y.object.placement;!g||g.mode!=="orbit"||c.set(y.objectId,sd(g))}let l=Math.min(...[...c.values()].filter(y=>Number.isFinite(y)&&y>0))||1,u=new Map,d=i.objects.map(y=>Yb(y,i,s,o,a,r,u,l)),h=new Map(d.map(y=>[y.objectId,y])),f=i.orbitVisuals.map(y=>qb(y,h,l,i.activeEventId!==null)),p=d.map(y=>({objectId:y.objectId,center:{...y.position},radius:y.visualRadius+r.focusPadding}));return{width:i.width,height:i.height,padding:i.padding,renderPreset:i.renderPreset,projection:i.projection,camera:i.camera,scaleModel:r,title:i.title,subtitle:i.subtitle,systemId:i.systemId,viewMode:"3d",layoutPreset:i.layoutPreset,metadata:{...i.metadata,"viewer.mode":"3d"},contentBounds:Qb(d),semanticGroups:i.semanticGroups,viewpoints:i.viewpoints,activeEventId:i.activeEventId,timeFrozen:i.activeEventId!==null,objects:d,orbits:f,focusTargets:p}}function Yb(n,e,t,i,r,s,o,a){let c=lc(n,e,t,i,r,o),l=ad(n.object,r.get(n.objectId),a,e.activeEventId!==null);return{objectId:n.objectId,object:n.object,parentId:n.parentId,ancestorIds:n.ancestorIds.slice(),childIds:n.childIds.slice(),groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),position:c,radius:Qr(n.radius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius),visualRadius:Qr(n.visualRadius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius+24),label:n.label,secondaryLabel:n.secondaryLabel,fillColor:n.fillColor,imageHref:n.imageHref,hidden:n.hidden,motion:l}}function qb(n,e,t,i){let r=e.get(n.objectId),s=e.get(n.parentId);return{objectId:n.objectId,object:n.object,parentId:n.parentId,groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),center:s?.position??{x:0,y:0,z:0},kind:n.kind,radius:n.radius,semiMajor:n.radius??n.rx??0,semiMinor:n.radius??n.ry??0,rotationDeg:n.rotationDeg,inclinationDeg:r?.motion?.inclinationDeg??uc(n.object.placement?.mode==="orbit"?n.object.placement.inclination:void 0)??0,band:n.band,bandThickness:n.bandThickness,hidden:n.hidden,motion:r?.motion??ad(n.object,n,t,i)}}function lc(n,e,t,i,r,s){let o=s.get(n.objectId);if(o)return o;let a=n.object.placement,c;if(a?.mode==="orbit"&&n.parentId){let l=i.get(n.parentId),u=l?lc(l,e,t,i,r,s):{x:0,y:0,z:0},d=r.get(n.objectId),h=ad(n.object,d,1,e.activeEventId!==null),f=h?Mm(h,0):{x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};c=Em(u,f)}else if(a?.mode==="surface"&&n.parentId){let l=i.get(n.parentId),u=l?lc(l,e,t,i,r,s):{x:0,y:0,z:0},d=l?.visualRadius??16,h=e_(n.objectId),f=h*Math.PI*2;c={x:u.x+Math.cos(f)*(d+n.visualRadius*.9),y:u.y+Math.sin(h*Math.PI)*Math.max(n.visualRadius*.2,2),z:u.z+Math.sin(f)*(d+n.visualRadius*.9)}}else if(a?.mode==="at"&&n.parentId){let l=i.get(n.parentId),u=l?lc(l,e,t,i,r,s):{x:0,y:0,z:0},d=n.anchorX??l?.x??t.x,h=n.anchorY??l?.y??t.y;c={x:u.x+(n.x-d),y:u.y,z:u.z+(n.y-h)}}else c={x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};return s.set(n.objectId,c),c}function od(n,e){let t=new Map(n.objects.map(s=>[s.objectId,s])),i=new Map,r=s=>{let o=i.get(s);if(o)return o;let a=t.get(s);if(!a)return{x:0,y:0,z:0};let c={...a.position};if(a.motion&&a.parentId){let l=r(a.parentId),u=Mm(a.motion,n.timeFrozen?0:e);c=Em(l,u)}return i.set(s,c),c};for(let s of n.objects)r(s.objectId);return i}function Mm(n,e){let t=n.phase0Deg+n.angularVelocityDegPerSecond*e,i=rd(t),r=rd(n.rotationDeg),s=rd(n.inclinationDeg),o=Math.cos(i)*n.semiMajor,a=Math.sin(i)*n.semiMinor,c=o*Math.cos(r)-a*Math.sin(r),l=o*Math.sin(r)+a*Math.cos(r);return{x:c,y:l*Math.sin(s),z:l*Math.cos(s)}}function ad(n,e,t,i){let r=n.placement;if(!r||r.mode!=="orbit")return null;let s=e?.radius??e?.rx??Qr(sd(r)*48,24,1200),o=e?.radius??e?.ry??s,a=Zb(r.period),c=sd(r),l=Qr(c/Math.max(t,1e-4),1,20),u=Qr(a?cc*l:cc*Math.pow(l,.75),cc,_m);return{phase0Deg:uc(r.phase)??0,rotationDeg:uc(r.angle)??e?.rotationDeg??0,inclinationDeg:uc(r.inclination)??0,semiMajor:s,semiMinor:o,eccentricity:r.eccentricity??0,periodSeconds:a,angularVelocityDegPerSecond:360/Math.max(u,.001),heuristic:a===null,frozen:i}}function sd(n){let e=wm(n.semiMajor)??wm(n.distance)??1;return Math.max(e,.01)}function wm(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/1495978707e-1;case"m":return n.value/149597870700;case"re":return n.value*6371/1495978707e-1;case"rj":return n.value*71492/1495978707e-1;case"sol":return n.value*695700/1495978707e-1;case"ly":return n.value*63241.077;case"pc":return n.value*206264.806;case"kpc":return n.value*206264806;default:return n.value}}function Zb(n){if(!n)return null;switch(n.unit){case"s":return n.value;case"min":return n.value*60;case"h":return n.value*3600;case"d":return n.value*Sm;case"y":return n.value*ac;case"ky":return n.value*ac*1e3;case"my":return n.value*ac*1e6;case"gy":return n.value*ac*1e9;default:return null}}function uc(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function Jb(n,e){return{...Kb(n),...e}}function Kb(n){switch(n){case"compact":return{orbitDistanceMultiplier:.92,bodyRadiusMultiplier:.92,markerSizeMultiplier:.92,ringThicknessMultiplier:.9,focusPadding:10,minBodyRadius:4,maxBodyRadius:34};case"presentation":return{orbitDistanceMultiplier:1.15,bodyRadiusMultiplier:1.12,markerSizeMultiplier:1.08,ringThicknessMultiplier:1.14,focusPadding:16,minBodyRadius:5,maxBodyRadius:44};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40}}}function Qb(n){if(n.length===0)return{minX:0,minY:0,minZ:0,maxX:0,maxY:0,maxZ:0,width:0,height:0,depth:0,center:{x:0,y:0,z:0}};let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of n)e=Math.min(e,a.position.x-a.visualRadius),t=Math.min(t,a.position.y-a.visualRadius),i=Math.min(i,a.position.z-a.visualRadius),r=Math.max(r,a.position.x+a.visualRadius),s=Math.max(s,a.position.y+a.visualRadius),o=Math.max(o,a.position.z+a.visualRadius);return{minX:e,minY:t,minZ:i,maxX:r,maxY:s,maxZ:o,width:r-e,height:s-t,depth:o-i,center:{x:(e+r)/2,y:(t+s)/2,z:(i+o)/2}}}function Em(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function e_(n){let e=0;for(let t=0;t<n.length;t+=1)e=e*31+n.charCodeAt(t)>>>0;return e%1e4/1e4}function Qr(n,e,t){return Math.min(Math.max(n,e),t)}function rd(n){return n*Math.PI/180}function cr(n,e={}){let t=rn(n,e),i=[],r=i_(n,i),s=r_(n,i),o=n_(n,t.renderPreset??e.preset??null,t.projection),a=n.system?t_(n,o,r,s,i,t.renderPreset??e.preset??null):null;return t.viewpoints.some(c=>!c.generated)&&i.push({code:"upgrade.viewpoints.structured",severity:"info",source:"upgrade",message:`Promoted ${t.viewpoints.filter(c=>!c.generated).length} document-defined viewpoint(s) into the 2.0 atlas section.`}),{format:"worldorbit",version:"2.5",schemaVersion:"2.5",sourceVersion:n.version,system:a,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:structuredClone(n.events??[]),objects:n.objects.map(Tm),diagnostics:i}}function cd(n,e={}){return m_(cr(n,e))}function go(n,e={}){let t=n.system?{type:"system",id:n.system.id,title:n.system.title,description:n.system.description,epoch:n.system.epoch,referencePlane:n.system.referencePlane,properties:h_(n.system),info:f_(n.system)}:null,i=n.objects.map(Tm);return c_(i,n.events??[],e.activeEventId??null),{format:"worldorbit",version:"1.0",schemaVersion:n.version,system:t,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:n.events.map(o_),objects:i}}function t_(n,e,t,i,r,s){let o=rn(n,{preset:s??void 0,projection:e.view});return{type:"system",id:n.system?.id??"WorldOrbit",title:n.system?.title??(typeof n.system?.properties.title=="string"?n.system.properties.title:null),description:n.system?.description??null,epoch:n.system?.epoch??null,referencePlane:n.system?.referencePlane??null,defaults:e,atlasMetadata:t,viewpoints:o.viewpoints.map(s_),annotations:i}}function n_(n,e,t){let i=typeof n.system?.properties.view=="string"?n.system.properties.view.toLowerCase():null;return{view:i==="topdown"||i==="isometric"||i==="orthographic"||i==="perspective"?i:t,scale:typeof n.system?.properties.scale=="string"?n.system.properties.scale:null,units:typeof n.system?.properties.units=="string"?n.system.properties.units:null,preset:e,theme:typeof n.system?.info["atlas.theme"]=="string"?n.system.info["atlas.theme"]:null}}function i_(n,e){let t={};for(let[r,s]of Object.entries(n.system?.info??{}))r.startsWith("viewpoint.")||r.startsWith("annotation.")||(t[r]=s);let i=Object.keys(t);return i.length>0&&e.push({code:"upgrade.atlasMetadata.preserved",severity:"warning",source:"upgrade",message:`Preserved ${i.length} system info entr${i.length===1?"y":"ies"} as atlas metadata in the 2.0 atlas document.`}),t}function r_(n,e){let t=new Map;for(let[i,r]of Object.entries(n.system?.info??{})){if(!i.startsWith("annotation."))continue;let[,s,...o]=i.split(".");if(!s||o.length===0)continue;let a=Am(s);if(!a)continue;let c=t.get(a)??{id:a};switch(o.join(".").toLowerCase()){case"label":c.label=r;break;case"target":case"object":c.targetObjectId=r.trim()||null;break;case"body":case"text":case"description":c.body=r;break;case"tags":c.tags=u_(r);break}t.set(a,c)}for(let i of n.objects){let r=i.info.description;if(!r)continue;let s=Am(`${i.id}-notes`);t.has(s)||(t.set(s,{id:s,label:`${i.id} Notes`,targetObjectId:i.id,body:r,tags:Array.isArray(i.properties.tags)?i.properties.tags.filter(o=>typeof o=="string"):[]}),e.push({code:"upgrade.annotation.objectDescription",severity:"info",source:"upgrade",message:`Lifted ${i.id}.info.description into structured atlas annotation "${s}".`,objectId:i.id,field:"description"}))}return[...t.values()].filter(i=>i.body||i.label).map(i=>({id:i.id,label:i.label??d_(i.id),targetObjectId:i.targetObjectId??null,body:i.body??"",tags:i.tags??[],sourceObjectId:i.targetObjectId??null})).sort((i,r)=>i.label.localeCompare(r.label))}function s_(n){return{id:n.id,label:n.label,summary:n.summary,focusObjectId:n.objectId,selectedObjectId:n.selectedObjectId,events:[...n.eventIds],projection:n.projection,preset:n.preset,zoom:n.scale,rotationDeg:n.rotationDeg,camera:n.camera?{...n.camera}:null,layers:{...n.layers},filter:n.filter?{query:n.filter.query,objectTypes:[...n.filter.objectTypes],tags:[...n.filter.tags],groupIds:[...n.filter.groupIds]}:null}}function Tm(n){return{...n,groups:n.groups?[...n.groups]:void 0,resonance:n.resonance?{...n.resonance}:n.resonance,renderHints:n.renderHints?{...n.renderHints}:n.renderHints,deriveRules:n.deriveRules?n.deriveRules.map(e=>({...e})):void 0,validationRules:n.validationRules?n.validationRules.map(e=>({...e})):void 0,lockedFields:n.lockedFields?[...n.lockedFields]:void 0,tolerances:n.tolerances?n.tolerances.map(e=>({field:e.field,value:e.value&&typeof e.value=="object"&&"value"in e.value?{value:e.value.value,unit:e.value.unit}:Array.isArray(e.value)?[...e.value]:e.value})):void 0,typedBlocks:n.typedBlocks?Object.fromEntries(Object.entries(n.typedBlocks).map(([e,t])=>[e,{...t??{}}])):void 0,properties:l_(n.properties),placement:n.placement?structuredClone(n.placement):null,info:{...n.info}}}function o_(n){return{...n,participantObjectIds:[...n.participantObjectIds],tags:[...n.tags],positions:n.positions.map(a_)}}function a_(n){return{objectId:n.objectId,placement:Im(n.placement),inner:n.inner?{...n.inner}:void 0,outer:n.outer?{...n.outer}:void 0,epoch:n.epoch??null,referencePlane:n.referencePlane??null}}function Im(n){return n?structuredClone(n):null}function c_(n,e,t){if(!t)return;let i=e.find(o=>o.id===t);if(!i)return;let r=new Map(n.map(o=>[o.id,o])),s=new Set([...i.targetObjectId?[i.targetObjectId]:[],...i.participantObjectIds,...i.positions.map(o=>o.objectId)]);for(let o of s){let a=r.get(o);a&&(i.epoch&&(a.epoch=i.epoch),i.referencePlane&&(a.referencePlane=i.referencePlane))}for(let o of i.positions){let a=r.get(o.objectId);a&&(o.placement&&(a.placement=Im(o.placement)),o.inner&&(a.properties.inner={...o.inner}),o.outer&&(a.properties.outer={...o.outer}),o.epoch&&(a.epoch=o.epoch),o.referencePlane&&(a.referencePlane=o.referencePlane))}}function l_(n){let e={};for(let[t,i]of Object.entries(n)){if(Array.isArray(i)){e[t]=[...i];continue}if(i&&typeof i=="object"&&"value"in i){e[t]={value:i.value,unit:i.unit};continue}e[t]=i}return e}function u_(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function Am(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function d_(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function h_(n){let e={};return n.title&&(e.title=n.title),e.view=n.defaults.view,n.defaults.scale&&(e.scale=n.defaults.scale),n.defaults.units&&(e.units=n.defaults.units),n.description&&(e.description=n.description),n.epoch&&(e.epoch=n.epoch),n.referencePlane&&(e.referencePlane=n.referencePlane),e}function f_(n){let e={...n.atlasMetadata};n.defaults.theme&&(e["atlas.theme"]=n.defaults.theme);for(let t of n.viewpoints){let i=`viewpoint.${t.id}`;e[`${i}.label`]=t.label,t.summary&&(e[`${i}.summary`]=t.summary),t.focusObjectId&&(e[`${i}.focus`]=t.focusObjectId),t.selectedObjectId&&(e[`${i}.select`]=t.selectedObjectId),t.projection&&(e[`${i}.projection`]=t.projection),t.preset&&(e[`${i}.preset`]=t.preset),t.zoom!==null&&(e[`${i}.zoom`]=String(t.zoom)),t.rotationDeg!==0&&(e[`${i}.rotation`]=String(t.rotationDeg)),t.camera?.azimuth!==null&&(e[`${i}.camera.azimuth`]=String(t.camera?.azimuth)),t.camera?.elevation!==null&&(e[`${i}.camera.elevation`]=String(t.camera?.elevation)),t.camera?.roll!==null&&(e[`${i}.camera.roll`]=String(t.camera?.roll)),t.camera?.distance!==null&&(e[`${i}.camera.distance`]=String(t.camera?.distance));let r=p_(t.layers);r&&(e[`${i}.layers`]=r),t.filter?.query&&(e[`${i}.query`]=t.filter.query),(t.filter?.objectTypes.length??0)>0&&(e[`${i}.types`]=t.filter?.objectTypes.join(" ")??""),(t.filter?.tags.length??0)>0&&(e[`${i}.tags`]=t.filter?.tags.join(" ")??""),(t.filter?.groupIds.length??0)>0&&(e[`${i}.groups`]=t.filter?.groupIds.join(" ")??""),t.events.length>0&&(e[`${i}.events`]=t.events.join(" "))}for(let t of n.annotations){let i=`annotation.${t.id}`;e[`${i}.label`]=t.label,t.targetObjectId&&(e[`${i}.target`]=t.targetObjectId),e[`${i}.body`]=t.body,t.tags.length>0&&(e[`${i}.tags`]=t.tags.join(" ")),t.sourceObjectId&&(e[`${i}.source`]=t.sourceObjectId)}return e}function p_(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e.join(" ")}function m_(n){return{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}}var Cm=["title","view","scale","units","kind","class","tags","color","image","hidden","orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"];function dc(n,e={}){let t=e.schema??"auto";if(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.0-draft"||n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.0-draft"){if(t==="2.0-draft"){let c=n.version==="2.0-draft"?n:n.version==="2.0"||n.version==="2.1"||n.version==="2.5"?{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}:cd(n);return Pm(c)}let a=n.version==="2.0"||n.version==="2.1"||n.version==="2.5"?n:n.version==="2.0-draft"?{...n,version:"2.0",schemaVersion:"2.0"}:cr(n);return(t==="2.0"||t==="2.1"||t==="2.5")&&a.version!==t?ld({...a,version:t,schemaVersion:t}):ld(a)}let r=[],s=n;s.system&&r.push(...g_(s.system));let o=[...s.objects].sort(hd);for(let a of o)r.length>0&&r.push(""),r.push(...v_(a));return r.join(`
3822
+ `)}function ld(n){let e=[`schema ${n.version}`,""];n.system&&e.push(...Lm(n.system));for(let i of[...n.groups].sort(ts))e.push(""),e.push(...Nm(i));for(let i of[...n.relations].sort(ts))e.push(""),e.push(...Fm(i));for(let i of[...n.events].sort(ts))e.push(""),e.push(...km(i));let t=[...n.objects].sort(hd);return t.length>0&&e.at(-1)!==""&&e.push(""),t.forEach((i,r)=>{r>0&&e.push(""),e.push(...Dm(i))}),e.join(`
3823
+ `)}function Pm(n){let e=n.version==="2.0-draft"?n:{...n,version:"2.0-draft",schemaVersion:"2.0-draft"},t=["schema 2.0-draft",""];e.system&&t.push(...Lm(e.system));for(let r of[...e.groups].sort(ts))t.push(""),t.push(...Nm(r));for(let r of[...e.relations].sort(ts))t.push(""),t.push(...Fm(r));for(let r of[...e.events].sort(ts))t.push(""),t.push(...km(r));let i=[...e.objects].sort(hd);return i.length>0&&t.at(-1)!==""&&t.push(""),i.forEach((r,s)=>{s>0&&t.push(""),t.push(...Dm(r))}),t.join(`
3824
+ `)}function g_(n){return y_("system",n.id,n.properties,null,n.info)}function y_(n,e,t,i,r){let s=[`${n} ${e}`],o=[...ud(i),...Um(t)];for(let c of o)s.push(` ${c}`);let a=Object.entries(r).sort(([c],[l])=>c.localeCompare(l));if(a.length>0){o.length>0&&s.push(""),s.push(" info");for(let[c,l]of a)s.push(` ${c} ${Xe(l)}`)}return s}function Lm(n){let e=[`system ${n.id}`];if(n.title&&e.push(` title ${Xe(n.title)}`),n.description&&e.push(` description ${Xe(n.description)}`),n.epoch&&e.push(` epoch ${Xe(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${Xe(n.referencePlane)}`),e.push(""),e.push("defaults"),e.push(` view ${n.defaults.view}`),n.defaults.scale&&e.push(` scale ${Xe(n.defaults.scale)}`),n.defaults.units&&e.push(` units ${Xe(n.defaults.units)}`),n.defaults.preset&&e.push(` preset ${n.defaults.preset}`),n.defaults.theme&&e.push(` theme ${Xe(n.defaults.theme)}`),Object.keys(n.atlasMetadata).length>0){e.push(""),e.push("atlas"),e.push(" metadata");for(let[t,i]of Object.entries(n.atlasMetadata).sort(([r],[s])=>r.localeCompare(s)))e.push(` ${t} ${Xe(i)}`)}for(let t of n.viewpoints)e.push(""),e.push(...b_(t));for(let t of n.annotations)e.push(""),e.push(...__(t));return e}function v_(n){return Om(n.type,n.id,n)}function Dm(n){return Om(`object ${n.type}`,n.id,n)}function Om(n,e,t){let i=[`${n} ${e}`],r=[...ud(t.placement),...Um(t.properties),...x_(t)];for(let o of r)i.push(` ${o}`);let s=Object.entries(t.info).sort(([o],[a])=>o.localeCompare(a));if(s.length>0){r.length>0&&i.push(""),i.push(" info");for(let[o,a]of s)i.push(` ${o} ${Xe(a)}`)}for(let o of["climate","habitability","settlement"]){let a=Object.entries(t.typedBlocks?.[o]??{}).sort(([c],[l])=>c.localeCompare(l));if(a.length>0){i.push(""),i.push(` ${o}`);for(let[c,l]of a)i.push(` ${c} ${Xe(l)}`)}}return i}function ud(n){if(!n)return[];switch(n.mode){case"orbit":return[`orbit ${n.target}`,...Pi("distance",n.distance),...Pi("semiMajor",n.semiMajor),...M_("eccentricity",n.eccentricity),...Pi("period",n.period),...Pi("angle",n.angle),...Pi("inclination",n.inclination),...Pi("phase",n.phase)];case"at":return[`at ${E_(n.reference)}`];case"surface":return[`surface ${n.target}`];case"free":return[`free ${n.distance?dd(n.distance):n.descriptor??""}`.trim()]}}function Um(n){return Object.keys(n).sort(T_).map(e=>`${e} ${Bm(n[e])}`)}function x_(n){let e=[];n.groups?.length&&e.push(`groups ${n.groups.join(" ")}`),n.epoch&&e.push(`epoch ${Xe(n.epoch)}`),n.referencePlane&&e.push(`referencePlane ${Xe(n.referencePlane)}`),n.tidalLock!==void 0&&e.push(`tidalLock ${n.tidalLock?"true":"false"}`),n.renderHints?.renderLabel!==void 0&&e.push(`renderLabel ${n.renderHints.renderLabel?"true":"false"}`),n.renderHints?.renderOrbit!==void 0&&e.push(`renderOrbit ${n.renderHints.renderOrbit?"true":"false"}`),n.renderHints?.renderPriority!==void 0&&e.push(`renderPriority ${n.renderHints.renderPriority}`),n.resonance&&e.push(`resonance ${n.resonance.targetObjectId} ${n.resonance.ratio}`);for(let t of n.deriveRules??[])e.push(`derive ${t.field} ${t.strategy}`);for(let t of n.validationRules??[])e.push(`validate ${t.rule}`);n.lockedFields?.length&&e.push(`locked ${n.lockedFields.join(" ")}`);for(let t of n.tolerances??[])e.push(`tolerance ${t.field} ${Bm(t.value)}`);return e}function b_(n){let e=[`viewpoint ${n.id}`,` label ${Xe(n.label)}`];n.focusObjectId&&e.push(` focus ${n.focusObjectId}`),n.selectedObjectId&&n.selectedObjectId!==n.focusObjectId&&e.push(` select ${n.selectedObjectId}`),n.summary&&e.push(` summary ${Xe(n.summary)}`),n.projection&&e.push(` projection ${n.projection}`),n.preset&&e.push(` preset ${n.preset}`),n.zoom!==null&&e.push(` zoom ${n.zoom}`),n.rotationDeg!==0&&e.push(` rotation ${n.rotationDeg}`),n.camera&&S_(n.camera)&&(e.push(" camera"),n.camera.azimuth!==null&&e.push(` azimuth ${n.camera.azimuth}`),n.camera.elevation!==null&&e.push(` elevation ${n.camera.elevation}`),n.camera.roll!==null&&e.push(` roll ${n.camera.roll}`),n.camera.distance!==null&&e.push(` distance ${n.camera.distance}`));let t=A_(n.layers);return t.length>0&&e.push(` layers ${t.join(" ")}`),n.events.length>0&&e.push(` events ${n.events.join(" ")}`),n.filter&&(e.push(" filter"),n.filter.query&&e.push(` query ${Xe(n.filter.query)}`),n.filter.objectTypes.length>0&&e.push(` objectTypes ${n.filter.objectTypes.join(" ")}`),n.filter.tags.length>0&&e.push(` tags ${n.filter.tags.map(Xe).join(" ")}`),n.filter.groupIds.length>0&&e.push(` groups ${n.filter.groupIds.join(" ")}`)),e}function __(n){let e=[`annotation ${n.id}`,` label ${Xe(n.label)}`];return n.targetObjectId&&e.push(` target ${n.targetObjectId}`),e.push(` body ${Xe(n.body)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(Xe).join(" ")}`),e}function Nm(n){let e=[`group ${n.id}`,` label ${Xe(n.label)}`];return n.summary&&e.push(` summary ${Xe(n.summary)}`),n.color&&e.push(` color ${Xe(n.color)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(Xe).join(" ")}`),n.hidden&&e.push(" hidden true"),e}function Fm(n){let e=[`relation ${n.id}`];return n.from&&e.push(` from ${Xe(n.from)}`),n.to&&e.push(` to ${Xe(n.to)}`),n.kind&&e.push(` kind ${Xe(n.kind)}`),n.label&&e.push(` label ${Xe(n.label)}`),n.summary&&e.push(` summary ${Xe(n.summary)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(Xe).join(" ")}`),n.color&&e.push(` color ${Xe(n.color)}`),n.hidden&&e.push(" hidden true"),e}function km(n){let e=[`event ${n.id}`,` kind ${Xe(n.kind)}`];if(n.label&&e.push(` label ${Xe(n.label)}`),n.summary&&e.push(` summary ${Xe(n.summary)}`),n.targetObjectId&&e.push(` target ${n.targetObjectId}`),n.participantObjectIds.length>0&&e.push(` participants ${n.participantObjectIds.join(" ")}`),n.timing&&e.push(` timing ${Xe(n.timing)}`),n.visibility&&e.push(` visibility ${Xe(n.visibility)}`),n.epoch&&e.push(` epoch ${Xe(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${Xe(n.referencePlane)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(Xe).join(" ")}`),n.color&&e.push(` color ${Xe(n.color)}`),n.hidden&&e.push(" hidden true"),n.positions.length>0){e.push(""),e.push(" positions");for(let t of[...n.positions].sort(I_)){e.push(` pose ${t.objectId}`);for(let i of w_(t))e.push(` ${i}`)}}return e}function w_(n){return[...ud(n.placement),...n.epoch?[`epoch ${Xe(n.epoch)}`]:[],...n.referencePlane?[`referencePlane ${Xe(n.referencePlane)}`]:[],...Pi("inner",n.inner),...Pi("outer",n.outer)]}function S_(n){return n.azimuth!==null||n.elevation!==null||n.roll!==null||n.distance!==null}function Bm(n){return Array.isArray(n)?n.map(e=>Xe(e)).join(" "):typeof n=="boolean"?n?"true":"false":typeof n=="number"?String(n):typeof n=="string"?Xe(n):dd(n)}function dd(n){return`${n.value}${n.unit??""}`}function Pi(n,e){return e?[`${n} ${dd(e)}`]:[]}function M_(n,e){return e===void 0?[]:[`${n} ${e}`]}function E_(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function A_(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e}function T_(n,e){let t=Cm.indexOf(n),i=Cm.indexOf(e);return t===-1&&i===-1?n.localeCompare(e):t===-1?1:i===-1?-1:t-i}function hd(n,e){let t=Rm(n.type),i=Rm(e.type);return t!==i?t-i:n.id.localeCompare(e.id)}function ts(n,e){return n.id.localeCompare(e.id)}function I_(n,e){return n.objectId.localeCompare(e.objectId)}function Rm(n){switch(n){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":return 3;case"asteroid":return 4;case"comet":return 5;case"ring":return 6;case"structure":return 7;case"phenomenon":return 8}}function Xe(n){return!/\s/.test(n)&&!n.includes('"')?n:`"${n.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}var zm=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,C_=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),R_=/^[A-Za-z][A-Za-z0-9+.-]*:/;function ns(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function vo(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function fd(n,e,t){let i=n.match(zm);if(!i)throw q.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=cn(t);if(s?.unitFamily&&!qa(s.unitFamily,r.unit))throw q.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function pd(n){let e=n.match(zm);return e?{value:Number(e[1]),unit:e[2]??null}:null}function hc(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw q.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function Li(n,e,t){let i=C_.get(n.toLowerCase());if(i===void 0)throw q.fromLocation(`Invalid boolean value "${n}" for "${e}"`,t);return i}function Vm(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function P_(n,e){if(!n)throw q.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw q.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(R_);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw q.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function $m(n,e,t){let i=cn(n);if(!i)throw q.fromLocation(`Unknown field "${n}"`,t);if(i.arity==="single"&&e.length!==1)throw q.fromLocation(`Field "${n}" expects exactly one value`,t);switch(i.kind){case"list":return e;case"boolean":return Li(yo(e,n,t),n,t);case"number":return hc(yo(e,n,t),n,t);case"unit":return fd(yo(e,n,t),t,n);case"string":{let r=e.join(" ").trim();return n==="image"&&P_(r,t),r}}}function md(n,e,t){let i=cn(n);if(!i)throw q.fromLocation(`Unknown field "${n}"`,t);if(!i.objectTypes.includes(e))throw q.fromLocation(`Field "${n}" is not valid on "${e}"`,t)}function yo(n,e,t){if(n.length!==1)throw q.fromLocation(`Field "${e}" expects exactly one value`,t);return n[0]}var jm=new Set(["star","planet","moon","asteroid","comet"]),L_=332946.0487,D_=1047.3486,fc=1495978707e-1,O_=6371,U_=695700,N_=63241.077,F_=206264.806,k_=206264806;function xo(n,e){let t=[],i=new Map(n.objects.map(a=>[a.id,a])),r=new Set(n.groups.map(a=>a.id)),s=new Set(n.events.map(a=>a.id));n.system||t.push(it("validate.system.required","Atlas documents must declare exactly one system."));let o=new Map;for(let[a,c]of[["group",n.groups.map(l=>l.id)],["viewpoint",n.system?.viewpoints.map(l=>l.id)??[]],["annotation",n.system?.annotations.map(l=>l.id)??[]],["relation",n.relations.map(l=>l.id)],["event",n.events.map(l=>l.id)],["object",n.objects.map(l=>l.id)]])for(let l of c){let u=o.get(l);u?t.push(it("validate.id.duplicate",`Duplicate ${a} id "${l}" already used by ${u}.`)):o.set(l,a)}for(let a of n.relations)B_(a,i,t);for(let a of n.system?.viewpoints??[])z_(a,r,s,e,t,i);for(let a of n.objects)V_(a,n.system,i,r,t);for(let a of n.events)$_(a,n.system,i,t);return t}function B_(n,e,t){n.from?e.has(n.from)||t.push(it("validate.relation.from.unknown",`Unknown relation source "${n.from}" on "${n.id}".`)):t.push(it("validate.relation.from.required",`Relation "${n.id}" is missing a "from" target.`)),n.to?e.has(n.to)||t.push(it("validate.relation.to.unknown",`Unknown relation target "${n.to}" on "${n.id}".`)):t.push(it("validate.relation.to.required",`Relation "${n.id}" is missing a "to" target.`)),n.kind||t.push(it("validate.relation.kind.required",`Relation "${n.id}" is missing a "kind" value.`))}function z_(n,e,t,i,r,s){let o=n.filter;if(i==="2.1"||i==="2.5"){if(o)for(let a of o.groupIds)e.has(a)||r.push(yt("validate.viewpoint.group.unknown",`Unknown group "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.groups`));for(let a of n.events??[])t.has(a)||r.push(yt("validate.viewpoint.event.unknown",`Unknown event "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.events`))}W_(n.projection,r,`viewpoint.${n.id}.projection`,n.id),X_(n.camera,n.projection,n.rotationDeg,r,n.id,n.focusObjectId,n.selectedObjectId,o,s)}function V_(n,e,t,i,r){let s=n.placement,o=s?.mode==="orbit"?s:null,a=s?.mode==="orbit"?t.get(s.target)??null:null;if(n.groups)for(let c of n.groups)i.has(c)||r.push(yt("validate.group.unknown",`Unknown group "${c}" on "${n.id}".`,n.id,"groups"));if(typeof n.epoch=="string"&&!n.epoch.trim()&&r.push(yt("validate.epoch.empty",`Object "${n.id}" defines an empty epoch string.`,n.id,"epoch")),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&r.push(yt("validate.referencePlane.empty",`Object "${n.id}" defines an empty reference plane string.`,n.id,"referencePlane")),o&&(t.has(o.target)||r.push(it("validate.orbit.target.unknown",`Unknown placement target "${o.target}" on "${n.id}".`,n.id,"orbit")),o.distance&&o.semiMajor&&r.push(it("validate.orbit.distanceConflict",`Object "${n.id}" cannot declare both "distance" and "semiMajor".`,n.id,"distance")),o.phase&&!n.epoch&&!e?.epoch&&r.push(yt("validate.phase.epochMissing",`Object "${n.id}" sets "phase" without an object or system epoch.`,n.id,"phase")),o.inclination&&!n.referencePlane&&!e?.referencePlane&&r.push(yt("validate.inclination.referencePlaneMissing",`Object "${n.id}" sets "inclination" without an object or system reference plane.`,n.id,"inclination")),o.period&&!yd(a?.properties.mass)&&r.push(yt("validate.period.massMissing",`Object "${n.id}" sets "period" but its central mass cannot be derived.`,n.id,"period"))),s?.mode==="surface"){let c=t.get(s.target);c?jm.has(c.type)||r.push(it("validate.surface.target.invalid",`Surface target "${s.target}" on "${n.id}" is not surface-capable.`,n.id,"surface")):r.push(it("validate.surface.target.unknown",`Unknown placement target "${s.target}" on "${n.id}".`,n.id,"surface"))}if(s?.mode==="at"&&(n.type!=="structure"&&n.type!=="phenomenon"&&r.push(it("validate.at.objectType",`Only structures and phenomena may use "at" placement; found "${n.type}" on "${n.id}".`,n.id,"at")),j_(n,t,r)||r.push(it("validate.at.target.unknown",`Unknown at-reference target "${s.target}" on "${n.id}".`,n.id,"at"))),n.resonance){let c=t.get(n.resonance.targetObjectId);c?(n.placement?.mode!=="orbit"||c.placement?.mode!=="orbit"||n.placement.target!==c.placement.target)&&r.push(yt("validate.resonance.orbitMismatch",`Resonance target "${n.resonance.targetObjectId}" on "${n.id}" does not share a compatible orbital parent.`,n.id,"resonance")):r.push(it("validate.resonance.target.unknown",`Unknown resonance target "${n.resonance.targetObjectId}" on "${n.id}".`,n.id,"resonance"))}for(let c of n.deriveRules??[]){if(c.field!=="period"||c.strategy!=="kepler"){r.push(yt("validate.derive.unsupported",`Unsupported derive rule "${c.field} ${c.strategy}" on "${n.id}".`,n.id,"derive"));continue}let l=Hm(n,a);if(l===null){r.push(yt("validate.derive.inputsMissing",`Object "${n.id}" requests "derive period kepler" but lacks enough input data.`,n.id,"derive"));continue}o?.period||r.push(gd("validate.derive.period.available",`Object "${n.id}" can derive a Kepler period of ${J_(l)}.`,n.id,"derive"))}for(let c of n.validationRules??[]){if(c.rule!=="kepler"){r.push(yt("validate.rule.unsupported",`Unsupported validation rule "${c.rule}" on "${n.id}".`,n.id,"validate"));continue}let l=Gm(o?.period),u=Hm(n,a);if(l===null||u===null)continue;let d=Z_(n,"period");Math.abs(l-u)>d&&r.push(it("validate.kepler.mismatch",`Object "${n.id}" fails Kepler validation for "period".`,n.id,"validate"))}}function $_(n,e,t,i){let r=`event.${n.id}`,s=new Set;n.kind.trim()||i.push(it("validate.event.kind.required",`Event "${n.id}" is missing a "kind" value.`,void 0,`${r}.kind`)),typeof n.epoch=="string"&&!n.epoch.trim()&&i.push(yt("validate.event.epoch.empty",`Event "${n.id}" defines an empty epoch string.`,void 0,`${r}.epoch`)),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&i.push(yt("validate.event.referencePlane.empty",`Event "${n.id}" defines an empty reference plane string.`,void 0,`${r}.referencePlane`)),!n.targetObjectId&&n.participantObjectIds.length===0&&i.push(it("validate.event.references.required",`Event "${n.id}" must define a "target" or at least one participant.`,void 0,`${r}.participants`)),n.targetObjectId&&(s.add(n.targetObjectId),t.has(n.targetObjectId)||i.push(it("validate.event.target.unknown",`Unknown event target "${n.targetObjectId}" on "${n.id}".`,void 0,`${r}.target`)));let o=new Set;for(let l of n.participantObjectIds){if(s.add(l),o.has(l)){i.push(yt("validate.event.participants.duplicate",`Event "${n.id}" repeats participant "${l}".`,void 0,`${r}.participants`));continue}o.add(l),t.has(l)||i.push(it("validate.event.participants.unknown",`Unknown event participant "${l}" on "${n.id}".`,void 0,`${r}.participants`))}n.targetObjectId&&n.participantObjectIds.length>0&&!n.participantObjectIds.includes(n.targetObjectId)&&i.push(yt("validate.event.target.notParticipant",`Event "${n.id}" defines a target outside its participants list.`,void 0,`${r}.target`)),n.positions.length===0&&i.push(yt("validate.event.positions.missing",`Event "${n.id}" has no positions block and cannot drive a scene snapshot.`,void 0,`${r}.positions`)),/(?:^|[-_])(solar-eclipse|lunar-eclipse|transit|occultation)(?:$|[-_])/.test(n.kind)&&s.size<3&&i.push(yt("validate.event.kind.participants",`Event "${n.id}" looks like an eclipse or transit but references fewer than three bodies.`,void 0,`${r}.participants`));let a=new Set;for(let l of n.positions){let u=`${r}.pose.${l.objectId}`;if(a.has(l.objectId)){i.push(it("validate.event.pose.duplicate",`Event "${n.id}" defines "${l.objectId}" more than once in positions.`,void 0,u));continue}a.add(l.objectId);let d=t.get(l.objectId);if(!d){i.push(it("validate.event.pose.object.unknown",`Unknown event pose object "${l.objectId}" on "${n.id}".`,void 0,u));continue}s.has(l.objectId)||i.push(yt("validate.event.pose.unreferenced",`Event pose "${l.objectId}" on "${n.id}" is not listed in target/participants.`,void 0,u)),H_(l,d,n,e,t,i,u,n.id)}let c=[...s].filter(l=>!a.has(l));n.positions.length>0&&c.length>0&&i.push(yt("validate.event.positions.partial",`Event "${n.id}" leaves ${c.length} referenced object(s) on their base placement.`,void 0,`${r}.positions`))}function H_(n,e,t,i,r,s,o,a){let c=n.placement;if(!c){s.push(it("validate.event.pose.placement.required",`Event "${a}" pose "${n.objectId}" is missing a placement mode.`,void 0,o));return}if(c.mode==="orbit"){r.has(c.target)||s.push(it("validate.event.pose.orbit.target.unknown",`Unknown event orbit target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.orbit`)),c.distance&&c.semiMajor&&s.push(it("validate.event.pose.orbit.distanceConflict",`Event "${a}" pose "${n.objectId}" cannot declare both "distance" and "semiMajor".`,void 0,`${o}.distance`)),c.phase&&!Y_(i,e,t,n)&&s.push(yt("validate.event.pose.phase.epochMissing",`Event "${a}" pose "${n.objectId}" sets "phase" without an effective epoch.`,void 0,`${o}.phase`)),c.inclination&&!q_(i,e,t,n)&&s.push(yt("validate.event.pose.inclination.referencePlaneMissing",`Event "${a}" pose "${n.objectId}" sets "inclination" without an effective reference plane.`,void 0,`${o}.inclination`)),c.period&&!yd(r.get(c.target)?.properties.mass)&&s.push(yt("validate.event.pose.period.massMissing",`Event "${a}" pose "${n.objectId}" sets "period" but its central mass cannot be derived.`,void 0,`${o}.period`));return}if(c.mode==="surface"){let l=r.get(c.target);l?jm.has(l.type)||s.push(it("validate.event.pose.surface.target.invalid",`Event surface target "${c.target}" on "${a}:${n.objectId}" is not surface-capable.`,void 0,`${o}.surface`)):s.push(it("validate.event.pose.surface.target.unknown",`Unknown event surface target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.surface`));return}if(c.mode==="at"){e.type!=="structure"&&e.type!=="phenomenon"&&s.push(it("validate.event.pose.at.objectType",`Only structures and phenomena may use "at" placement in events; found "${e.type}" on "${a}:${n.objectId}".`,void 0,`${o}.at`));let l=c.reference;l.kind==="named"&&!r.has(l.name)?s.push(it("validate.event.pose.at.target.unknown",`Unknown event at-reference target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):l.kind==="anchor"&&!r.has(l.objectId)?s.push(it("validate.event.pose.anchor.target.unknown",`Unknown event anchor target "${l.objectId}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):l.kind==="lagrange"&&(r.has(l.primary)?l.secondary&&!r.has(l.secondary)&&s.push(it("validate.event.pose.lagrange.secondary.unknown",`Unknown event Lagrange target "${l.secondary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):s.push(it("validate.event.pose.lagrange.primary.unknown",`Unknown event Lagrange target "${l.primary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)))}}function j_(n,e,t){let i=n.placement?.mode==="at"?n.placement.reference:null;return i?i.kind==="named"?e.has(i.name):i.kind==="anchor"?e.has(i.objectId)?!0:(t.push(it("validate.anchor.target.unknown",`Unknown anchor target "${i.objectId}" on "${n.id}".`,n.id,"at")),!1):e.has(i.primary)?i.secondary&&!e.has(i.secondary)?(t.push(it("validate.lagrange.secondary.unknown",`Unknown Lagrange reference "${i.secondary}" on "${n.id}".`,n.id,"at")),!1):!0:(t.push(it("validate.lagrange.primary.unknown",`Unknown Lagrange reference "${i.primary}" on "${n.id}".`,n.id,"at")),!1):!0}function Hm(n,e){let t=n.placement;if(!t||t.mode!=="orbit")return null;let i=G_(t.semiMajor??t.distance),r=yd(e?.properties.mass);return i===null||r===null||r<=0?null:Math.sqrt(i**3/r)*365.25}function G_(n){if(!n)return null;switch(n.unit){case null:case"au":return n.value;case"km":return n.value/fc;case"m":return n.value/(fc*1e3);case"ly":return n.value*N_;case"pc":return n.value*F_;case"kpc":return n.value*k_;case"re":return n.value*O_/fc;case"sol":return n.value*U_/fc;default:return null}}function yd(n){if(!n||typeof n!="object"||!("value"in n))return null;let e=n;switch(e.unit){case null:case"sol":return e.value;case"me":return e.value/L_;case"mj":return e.value/D_;default:return null}}function Gm(n){if(!n)return null;switch(n.unit){case null:case"d":return n.value;case"s":return n.value/86400;case"min":return n.value/1440;case"h":return n.value/24;case"y":return n.value*365.25;case"ky":return n.value*365250;case"my":return n.value*36525e4;case"gy":return n.value*36525e7;default:return null}}function W_(n,e,t,i){n!=="topdown"&&n!=="isometric"&&n!=="orthographic"&&n!=="perspective"&&e.push(it("validate.viewpoint.projection.invalid",`Unknown projection "${String(n)}" in viewpoint "${i}".`,void 0,t))}function X_(n,e,t,i,r,s,o,a,c){if(!n)return;let l=`viewpoint.${r}.camera`;for(let[d,h]of[["azimuth",n.azimuth],["elevation",n.elevation],["roll",n.roll],["distance",n.distance]])h!==null&&(!Number.isFinite(h)||d==="distance"&&h<=0)&&i.push(it("validate.viewpoint.camera.invalid",`Invalid camera ${d} "${String(h)}" in viewpoint "${r}".`,void 0,`${l}.${d}`));n.distance!==null&&e!=="perspective"&&i.push(yt("validate.viewpoint.camera.distance.partialEffect",`Camera "distance" only has a semantic effect in perspective viewpoints; "${r}" uses "${e}".`,void 0,`${l}.distance`)),e==="topdown"&&(n.elevation!==null||n.roll!==null)&&i.push(yt("validate.viewpoint.camera.topdownPartial",`Camera elevation/roll on topdown viewpoint "${r}" are currently stored for future 3D use and only partially affect 2D rendering.`,void 0,l)),e==="isometric"&&n.elevation!==null&&i.push(gd("validate.viewpoint.camera.isometricStored",`Camera elevation on isometric viewpoint "${r}" is preserved semantically for future 3D rendering.`,void 0,`${l}.elevation`)),n.azimuth!==null&&n.azimuth!==0&&t!==0&&i.push(yt("validate.viewpoint.rotation.cameraOverlap",`Viewpoint "${r}" uses camera.azimuth; keep "rotation" only for 2D screen rotation to avoid ambiguity.`,void 0,`${l}.azimuth`)),s!==null&&c.has(s)||o!==null&&c.has(o)||a||i.push(gd("validate.viewpoint.camera.anchorMissing",`Viewpoint "${r}" stores camera settings without a focus object, selection, or filter anchor.`,void 0,l))}function Y_(n,e,t,i){return Di(i?.epoch)??Di(t?.epoch)??Di(e.epoch)??Di(n?.epoch)??null}function q_(n,e,t,i){return Di(i?.referencePlane)??Di(t?.referencePlane)??Di(e.referencePlane)??Di(n?.referencePlane)??null}function Di(n){return typeof n=="string"&&n.trim()?n.trim():null}function Z_(n,e){let t=n.tolerances?.find(i=>i.field===e)?.value;return typeof t=="number"?t:t&&typeof t=="object"&&"value"in t?Gm(t)??0:0}function J_(n){return`${Math.round(n*100)/100}d`}function it(n,e,t,i){return{code:n,severity:"error",source:"validate",message:e,objectId:t,field:i}}function yt(n,e,t,i){return{code:n,severity:"warning",source:"validate",message:e,objectId:t,field:i}}function gd(n,e,t,i){return{code:n,severity:"info",source:"validate",message:e,objectId:t,field:i}}var K_=new Set(["climate","habitability","settlement"]),mc=new Map;for(let n of["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","kind","class","culture","tags","color","image","hidden","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"]){let e=cn(n);e&&mc.set(n,{key:n,version:"2.0",inlineMode:e.arity==="multiple"?"multiple":"single",allowRepeat:!1,legacySchema:e})}for(let n of[{key:"groups",inlineMode:"multiple",allowRepeat:!1},{key:"epoch",inlineMode:"single",allowRepeat:!1},{key:"referencePlane",inlineMode:"single",allowRepeat:!1},{key:"tidalLock",inlineMode:"single",allowRepeat:!1},{key:"renderLabel",inlineMode:"single",allowRepeat:!1},{key:"renderOrbit",inlineMode:"single",allowRepeat:!1},{key:"renderPriority",inlineMode:"single",allowRepeat:!1},{key:"resonance",inlineMode:"pair",allowRepeat:!1},{key:"derive",inlineMode:"pair",allowRepeat:!0},{key:"validate",inlineMode:"single",allowRepeat:!0},{key:"locked",inlineMode:"multiple",allowRepeat:!1},{key:"tolerance",inlineMode:"pair",allowRepeat:!0}])mc.set(n.key,{key:n.key,version:"2.1",inlineMode:n.inlineMode,allowRepeat:n.allowRepeat});var Q_=new Set(mc.keys()),Xm=new Set(["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","inner","outer","epoch","referencePlane"]);function vd(n){return ew(n)}function ew(n,e){let t=zw(n),i=t.source.split(/\r?\n/),r=[],s=!1,o="2.0",a=null,c=null,l=[],u=[],d=[],h=[],f=new Map,p=!1,y=!1,g=new Set,m=new Set,x=new Set,v=new Set,M=new Set;for(let b=0;b<i.length;b++){let O=i[b],B=b+1;if(!O.trim())continue;let F=Za(O),H=ro(O.slice(F),{line:B,columnOffset:F});if(H.length!==0){if(!s){o=tw(H,B),s=!0,t.comments.length>0&&gc(o,"2.1")&&r.push({code:"parse.schema21.commentCompatibility",severity:"warning",source:"parse",message:`Comments require schema 2.1; parsed in compatibility mode because the document header is "schema ${o}".`,line:t.comments[0].line,column:t.comments[0].column});continue}if(F===0){c=nw(H,B,o,r,a,l,u,d,h,f,g,m,x,v,M,{sawDefaults:p,sawAtlas:y}),c.kind==="system"?a=c.system:c.kind==="defaults"?p=!0:c.kind==="atlas"&&(y=!0);continue}if(!c)throw new q("Indented line without parent atlas section",B,F+1);uw(c,F,H,B)}}if(!s)throw new q('Missing required atlas schema header "schema 2.0"');let U=l.map(b=>Cw(b,o,r)),C=h.map(b=>Rw(b,f.get(b.id)??[])),R=e??(o==="2.0-draft"?"2.0":o),N={format:"worldorbit",sourceVersion:"1.0",system:a,groups:u,relations:d,events:C,objects:U,diagnostics:r};if(R==="2.0-draft"){let b={...N,version:"2.0-draft",schemaVersion:"2.0-draft"};return b.diagnostics.push(...xo(b,o)),b}let w={...N,version:R,schemaVersion:R};return o==="2.0-draft"&&w.diagnostics.push({code:"load.schema.deprecatedDraft",severity:"warning",source:"upgrade",message:'Source header "schema 2.0-draft" is deprecated; canonical v2 documents now use "schema 2.0".'}),w.diagnostics.push(...xo(w,o)),w}function tw(n,e){if(n.length!==2||n[0].value.toLowerCase()!=="schema"||!["2.0-draft","2.0","2.1","2.5"].includes(n[1].value.toLowerCase()))throw new q('Expected atlas header "schema 2.0", "schema 2.1", "schema 2.5", or legacy "schema 2.0-draft"',e,n[0]?.column??1);let t=n[1].value.toLowerCase();return t==="2.5"?"2.5":t==="2.1"?"2.1":t==="2.0-draft"?"2.0-draft":"2.0"}function nw(n,e,t,i,r,s,o,a,c,l,u,d,h,f,p,y){switch(n[0]?.value.toLowerCase()){case"system":if(r)throw new q('Atlas section "system" may only appear once',e,n[0].column);return iw(n,e,t,i);case"defaults":if(!r)throw new q('Atlas section "defaults" requires a preceding system declaration',e,n[0].column);if(y.sawDefaults)throw new q('Atlas section "defaults" may only appear once',e,n[0].column);return{kind:"defaults",system:r,sourceSchemaVersion:t,diagnostics:i,seenFields:new Set};case"atlas":if(!r)throw new q('Atlas section "atlas" requires a preceding system declaration',e,n[0].column);if(y.sawAtlas)throw new q('Atlas section "atlas" may only appear once',e,n[0].column);return{kind:"atlas",system:r,inMetadata:!1,metadataIndent:null};case"viewpoint":if(!r)throw new q('Atlas section "viewpoint" requires a preceding system declaration',e,n[0].column);return rw(n,e,r,u,t,i);case"annotation":if(!r)throw new q('Atlas section "annotation" requires a preceding system declaration',e,n[0].column);return sw(n,e,r,d);case"group":return _n(t,i,"group",{line:e,column:n[0].column}),ow(n,e,o,h);case"relation":return _n(t,i,"relation",{line:e,column:n[0].column}),aw(n,e,a,f);case"event":return _n(t,i,"event",{line:e,column:n[0].column}),cw(n,e,c,l,p,t,i);case"object":return lw(n,e,t,i,s);default:throw new q(`Unknown atlas section "${n[0]?.value??""}"`,e,n[0]?.column??1)}}function iw(n,e,t,i){if(n.length!==2)throw new q("Invalid atlas system declaration",e,n[0]?.column??1);return{kind:"system",system:{type:"system",id:n[1].value,title:null,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},sourceSchemaVersion:t,diagnostics:i,seenFields:new Set}}function rw(n,e,t,i,r,s){if(n.length!==2)throw new q("Invalid viewpoint declaration",e,n[0]?.column??1);let o=ns(n[1].value);if(!o)throw new q("Viewpoint id must not be empty",e,n[1].column);if(i.has(o))throw new q(`Duplicate viewpoint id "${o}"`,e,n[1].column);let a={id:o,label:vo(o),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:t.defaults.view,preset:t.defaults.preset,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null};return t.viewpoints.push(a),i.add(o),{kind:"viewpoint",viewpoint:a,sourceSchemaVersion:r,diagnostics:s,seenFields:new Set,inFilter:!1,filterIndent:null,seenFilterFields:new Set,inCamera:!1,cameraIndent:null,seenCameraFields:new Set}}function sw(n,e,t,i){if(n.length!==2)throw new q("Invalid annotation declaration",e,n[0]?.column??1);let r=ns(n[1].value);if(!r)throw new q("Annotation id must not be empty",e,n[1].column);if(i.has(r))throw new q(`Duplicate annotation id "${r}"`,e,n[1].column);let s={id:r,label:vo(r),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return t.annotations.push(s),i.add(r),{kind:"annotation",annotation:s,seenFields:new Set}}function ow(n,e,t,i){if(n.length!==2)throw new q("Invalid group declaration",e,n[0]?.column??1);let r=ns(n[1].value);if(!r)throw new q("Group id must not be empty",e,n[1].column);if(i.has(r))throw new q(`Duplicate group id "${r}"`,e,n[1].column);let s={id:r,label:vo(r),summary:"",color:null,tags:[],hidden:!1};return t.push(s),i.add(r),{kind:"group",group:s,seenFields:new Set}}function aw(n,e,t,i){if(n.length!==2)throw new q("Invalid relation declaration",e,n[0]?.column??1);let r=ns(n[1].value);if(!r)throw new q("Relation id must not be empty",e,n[1].column);if(i.has(r))throw new q(`Duplicate relation id "${r}"`,e,n[1].column);let s={id:r,from:"",to:"",kind:"",label:null,summary:null,tags:[],color:null,hidden:!1};return t.push(s),i.add(r),{kind:"relation",relation:s,seenFields:new Set}}function cw(n,e,t,i,r,s,o){if(n.length!==2)throw new q("Invalid event declaration",e,n[0]?.column??1);let a=ns(n[1].value);if(!a)throw new q("Event id must not be empty",e,n[1].column);if(r.has(a))throw new q(`Duplicate event id "${a}"`,e,n[1].column);let c={id:a,kind:"",label:vo(a),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},l=[];return t.push(c),i.set(a,l),r.add(a),{kind:"event",event:c,sourceSchemaVersion:s,diagnostics:o,seenFields:new Set,rawPoses:l,inPositions:!1,positionsIndent:null,activePose:null,poseIndent:null,activePoseSeenFields:new Set}}function lw(n,e,t,i,r){if(n.length<3)throw new q("Invalid atlas object declaration",e,n[0]?.column??1);let s=n[1],o=n[2],a=s.value;if(!Ya.has(a)||a==="system")throw new q(`Unknown object type "${s.value}"`,e,s.column);let c={objectType:a,id:o.value,fields:Tw(n.slice(3),e,a,t,i),infoEntries:[],typedBlockEntries:{},location:{line:e,column:s.column}};return r.push(c),{kind:"object",objectNode:c,sourceSchemaVersion:t,diagnostics:i,activeBlock:null,blockIndent:null,seenInfoKeys:new Set,seenTypedBlockKeys:{}}}function uw(n,e,t,i){switch(n.kind){case"system":dw(n,t,i);return;case"defaults":hw(n,t,i);return;case"atlas":fw(n,e,t,i);return;case"viewpoint":pw(n,e,t,i);return;case"annotation":yw(n,t,i);return;case"group":vw(n,t,i);return;case"relation":xw(n,t,i);return;case"event":bw(n,e,t,i);return;case"object":ww(n,e,t,i);return}}function dw(n,e,t){let i=ni(e,n.seenFields,t),r=ut(e,t);switch(i){case"title":n.system.title=r;return;case"description":_n(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.description=r;return;case"epoch":_n(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.epoch=r;return;case"referenceplane":_n(n.sourceSchemaVersion,n.diagnostics,"referencePlane",{line:t,column:e[0].column}),n.system.referencePlane=r;return;default:throw new q(`Unknown system atlas field "${e[0].value}"`,t,e[0].column)}}function hw(n,e,t){let i=ni(e,n.seenFields,t),r=ut(e,t);switch(i){case"view":qm(r)&&lr(n.sourceSchemaVersion,n.diagnostics,"defaults.view",{line:t,column:e[0].column}),n.system.defaults.view=Ym(r,t,e[0].column);return;case"scale":n.system.defaults.scale=r;return;case"units":n.system.defaults.units=r;return;case"preset":n.system.defaults.preset=Zm(r,t,e[0].column);return;case"theme":n.system.defaults.theme=r;return;default:throw new q(`Unknown defaults field "${e[0].value}"`,t,e[0].column)}}function fw(n,e,t,i){if(n.inMetadata&&e<=(n.metadataIndent??0)&&(n.inMetadata=!1,n.metadataIndent=null),n.inMetadata){let r=Jm(t,i,"Invalid atlas metadata entry");if(r.key in n.system.atlasMetadata)throw new q(`Duplicate atlas metadata key "${r.key}"`,i,t[0].column);n.system.atlasMetadata[r.key]=r.value;return}if(t.length===1&&t[0].value.toLowerCase()==="metadata"){n.inMetadata=!0,n.metadataIndent=e;return}throw new q(`Unknown atlas field "${t[0].value}"`,i,t[0].column)}function pw(n,e,t,i){if(n.inCamera&&e<=(n.cameraIndent??0)&&(n.inCamera=!1,n.cameraIndent=null),n.inFilter&&e<=(n.filterIndent??0)&&(n.inFilter=!1,n.filterIndent=null),n.inCamera){mw(n,t,i);return}if(n.inFilter){gw(n,t,i);return}if(t.length===1&&t[0].value.toLowerCase()==="camera"){if(lr(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.seenFields.has("camera"))throw new q('Duplicate viewpoint field "camera"',i,t[0].column);n.seenFields.add("camera"),n.inCamera=!0,n.cameraIndent=e,n.viewpoint.camera=n.viewpoint.camera??bd();return}if(t.length===1&&t[0].value.toLowerCase()==="filter"){if(n.seenFields.has("filter"))throw new q('Duplicate viewpoint field "filter"',i,t[0].column);n.seenFields.add("filter"),n.inFilter=!0,n.filterIndent=e;return}let r=ni(t,n.seenFields,i),s=ut(t,i);switch(r){case"label":n.viewpoint.label=s;return;case"summary":n.viewpoint.summary=s;return;case"focus":n.viewpoint.focusObjectId=s;return;case"select":n.viewpoint.selectedObjectId=s;return;case"projection":qm(s)&&lr(n.sourceSchemaVersion,n.diagnostics,"projection",{line:i,column:t[0].column}),n.viewpoint.projection=Ym(s,i,t[0].column);return;case"preset":n.viewpoint.preset=Zm(s,i,t[0].column);return;case"zoom":n.viewpoint.zoom=xd(s,i,t[0].column,"zoom");return;case"rotation":n.viewpoint.rotationDeg=Ui(s,i,t[0].column,"rotation");return;case"camera":lr(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.viewpoint.camera=Aw(t.slice(1),i,n.viewpoint.camera);return;case"layers":n.viewpoint.layers=Mw(t.slice(1),i,n.sourceSchemaVersion,n.diagnostics);return;case"events":_n(n.sourceSchemaVersion,n.diagnostics,"viewpoint.events",{line:i,column:t[0].column}),n.viewpoint.events=Bn(t.slice(1),i,"events");return;default:throw new q(`Unknown viewpoint field "${t[0].value}"`,i,t[0].column)}}function mw(n,e,t){let i=ni(e,n.seenCameraFields,t),r=ut(e,t),s=n.viewpoint.camera??bd();switch(i){case"azimuth":s.azimuth=Ui(r,t,e[0].column,"camera.azimuth");break;case"elevation":s.elevation=Ui(r,t,e[0].column,"camera.elevation");break;case"roll":s.roll=Ui(r,t,e[0].column,"camera.roll");break;case"distance":s.distance=xd(r,t,e[0].column,"camera.distance");break;default:throw new q(`Unknown viewpoint camera field "${e[0].value}"`,t,e[0].column)}n.viewpoint.camera=s}function gw(n,e,t){let i=ni(e,n.seenFilterFields,t),r=n.viewpoint.filter??Ew();switch(i){case"query":r.query=ut(e,t);break;case"objecttypes":r.objectTypes=Sw(e.slice(1),t);break;case"tags":r.tags=Bn(e.slice(1),t,"tags");break;case"groups":r.groupIds=Bn(e.slice(1),t,"groups");break;default:throw new q(`Unknown viewpoint filter field "${e[0].value}"`,t,e[0].column)}n.viewpoint.filter=r}function yw(n,e,t){switch(ni(e,n.seenFields,t)){case"label":n.annotation.label=ut(e,t);return;case"target":n.annotation.targetObjectId=ut(e,t);return;case"body":n.annotation.body=ut(e,t);return;case"tags":n.annotation.tags=Bn(e.slice(1),t,"tags");return;default:throw new q(`Unknown annotation field "${e[0].value}"`,t,e[0].column)}}function vw(n,e,t){switch(ni(e,n.seenFields,t)){case"label":n.group.label=ut(e,t);return;case"summary":n.group.summary=ut(e,t);return;case"color":n.group.color=ut(e,t);return;case"tags":n.group.tags=Bn(e.slice(1),t,"tags");return;case"hidden":n.group.hidden=Li(ut(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new q(`Unknown group field "${e[0].value}"`,t,e[0].column)}}function xw(n,e,t){switch(ni(e,n.seenFields,t)){case"from":n.relation.from=ut(e,t);return;case"to":n.relation.to=ut(e,t);return;case"kind":n.relation.kind=ut(e,t);return;case"label":n.relation.label=ut(e,t);return;case"summary":n.relation.summary=ut(e,t);return;case"tags":n.relation.tags=Bn(e.slice(1),t,"tags");return;case"color":n.relation.color=ut(e,t);return;case"hidden":n.relation.hidden=Li(ut(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new q(`Unknown relation field "${e[0].value}"`,t,e[0].column)}}function bw(n,e,t,i){if(n.activePose&&e<=(n.poseIndent??0)&&(n.activePose=null,n.poseIndent=null,n.activePoseSeenFields.clear()),!n.activePose&&n.inPositions&&e<=(n.positionsIndent??0)&&(n.inPositions=!1,n.positionsIndent=null),n.activePose){(t[0]?.value==="epoch"||t[0]?.value==="referencePlane")&&lr(n.sourceSchemaVersion,n.diagnostics,`pose.${t[0].value}`,{line:i,column:t[0]?.column??1}),n.activePose.fields.push(_w(t,i,n.activePoseSeenFields));return}if(n.inPositions){if(t.length!==2||t[0].value.toLowerCase()!=="pose")throw new q(`Unknown event positions field "${t[0].value}"`,i,t[0]?.column??1);let s=t[1].value;if(!s.trim())throw new q("Event pose object id must not be empty",i,t[1].column);let o={objectId:s,fields:[],location:{line:i,column:t[0].column}};n.rawPoses.push(o),n.activePose=o,n.poseIndent=e,n.activePoseSeenFields=new Set;return}if(t.length===1&&t[0].value.toLowerCase()==="positions"){if(n.seenFields.has("positions"))throw new q('Duplicate event field "positions"',i,t[0].column);n.seenFields.add("positions"),n.inPositions=!0,n.positionsIndent=e;return}switch(ni(t,n.seenFields,i)){case"kind":n.event.kind=ut(t,i);return;case"label":n.event.label=ut(t,i);return;case"summary":n.event.summary=ut(t,i);return;case"target":n.event.targetObjectId=ut(t,i);return;case"participants":n.event.participantObjectIds=Bn(t.slice(1),i,"participants");return;case"timing":n.event.timing=ut(t,i);return;case"visibility":n.event.visibility=ut(t,i);return;case"epoch":lr(n.sourceSchemaVersion,n.diagnostics,"event.epoch",{line:i,column:t[0].column}),n.event.epoch=ut(t,i);return;case"referenceplane":lr(n.sourceSchemaVersion,n.diagnostics,"event.referencePlane",{line:i,column:t[0].column}),n.event.referencePlane=ut(t,i);return;case"tags":n.event.tags=Bn(t.slice(1),i,"tags");return;case"color":n.event.color=ut(t,i);return;case"hidden":n.event.hidden=Li(ut(t,i),"hidden",{line:i,column:t[0].column});return;default:throw new q(`Unknown event field "${t[0].value}"`,i,t[0].column)}}function _w(n,e,t){if(n.length<2)throw new q("Invalid event pose field line",e,n[0]?.column??1);let i=n[0].value;if(!Xm.has(i))throw new q(`Unknown event pose field "${i}"`,e,n[0].column);if(t.has(i))throw new q(`Duplicate event pose field "${i}"`,e,n[0].column);return t.add(i),{type:"field",key:i,values:n.slice(1).map(r=>r.value),location:{line:e,column:n[0].column}}}function ww(n,e,t,i){if(n.activeBlock&&e<=(n.blockIndent??0)&&(n.activeBlock=null,n.blockIndent=null),t.length===1){let r=t[0].value.toLowerCase();if(r==="info"||K_.has(r)){r!=="info"&&_n(n.sourceSchemaVersion,n.diagnostics,r,{line:i,column:t[0].column}),n.activeBlock=r,n.blockIndent=e;return}}if(n.activeBlock){let r=Jm(t,i,`Invalid ${n.activeBlock} entry`);if(n.activeBlock==="info"){if(n.seenInfoKeys.has(r.key))throw new q(`Duplicate info key "${r.key}"`,i,t[0].column);n.seenInfoKeys.add(r.key),n.objectNode.infoEntries.push(r);return}let s=n.activeBlock,o=n.seenTypedBlockKeys[s]??(n.seenTypedBlockKeys[s]=new Set);if(o.has(r.key))throw new q(`Duplicate ${s} key "${r.key}"`,i,t[0].column);o.add(r.key),(n.objectNode.typedBlockEntries[s]??(n.objectNode.typedBlockEntries[s]=[])).push(r);return}n.objectNode.fields.push(Iw(t,i,n.objectNode.objectType,n.sourceSchemaVersion,n.diagnostics))}function ni(n,e,t){if(n.length<2)throw new q("Invalid atlas field line",t,n[0]?.column??1);let i=n[0].value.toLowerCase();if(e.has(i))throw new q(`Duplicate atlas field "${n[0].value}"`,t,n[0].column);return e.add(i),i}function ut(n,e){if(n.length<2)throw new q("Missing value for atlas field",e,n[0]?.column??1);return n.slice(1).map(t=>t.value).join(" ").trim()}function Sw(n,e){return Bn(n,e,"objectTypes").filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function Mw(n,e,t,i){let r={};for(let s of Bn(n,e,"layers")){let o=!s.startsWith("-")&&!s.startsWith("!"),a=s.replace(/^[-!]+/,"").toLowerCase();if(a==="orbits"){r["orbits-back"]=o,r["orbits-front"]=o;continue}(a==="background"||a==="guides"||a==="orbits-back"||a==="orbits-front"||a==="relations"||a==="events"||a==="objects"||a==="labels"||a==="metadata")&&(a==="events"&&t&&i&&_n(t,i,"layers.events",{line:e,column:n[0]?.column??1}),r[a]=o)}return r}function Bn(n,e,t){if(n.length===0)throw new q(`Missing value for atlas field "${t}"`,e,1);let i=n.map(r=>r.value).filter(Boolean);if(i.length===0)throw new q(`Missing value for atlas field "${t}"`,e,n[0]?.column??1);return i}function Ym(n,e,t){let i=n.toLowerCase();if(i!=="topdown"&&i!=="isometric"&&i!=="orthographic"&&i!=="perspective")throw new q(`Unknown projection "${n}"`,e,t);return i}function qm(n){let e=n.toLowerCase();return e==="orthographic"||e==="perspective"}function Zm(n,e,t){let i=n.toLowerCase();if(i==="diagram"||i==="presentation"||i==="atlas-card"||i==="markdown")return i;throw new q(`Unknown render preset "${n}"`,e,t)}function xd(n,e,t,i){let r=Ui(n,e,t,i);if(r<=0)throw new q(`Field "${i}" must be greater than zero`,e,t);return r}function Ui(n,e,t,i){let r=Number(n);if(!Number.isFinite(r))throw new q(`Invalid numeric value "${n}" for "${i}"`,e,t);return r}function Ew(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function bd(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Aw(n,e,t){if(n.length===0||n.length%2!==0)throw new q('Field "camera" expects "<field> <value>" pairs',e,n[0]?.column??1);let i=t?{...t}:bd(),r=new Set;for(let s=0;s<n.length;s+=2){let o=n[s],a=n[s+1],c=o.value.toLowerCase();if(r.has(c))throw new q(`Duplicate viewpoint camera field "${o.value}"`,e,o.column);r.add(c);let l=a.value;switch(c){case"azimuth":i.azimuth=Ui(l,e,o.column,"camera.azimuth");break;case"elevation":i.elevation=Ui(l,e,o.column,"camera.elevation");break;case"roll":i.roll=Ui(l,e,o.column,"camera.roll");break;case"distance":i.distance=xd(l,e,o.column,"camera.distance");break;default:throw new q(`Unknown viewpoint camera field "${o.value}"`,e,o.column)}}return i}function Tw(n,e,t,i,r){let s=[],o=0;for(;o<n.length;){let a=n[o],c=bo(a.value);if(!c)throw new q(`Unknown field "${a.value}"`,e,a.column);c.version==="2.1"&&_n(i,r,a.value,{line:e,column:a.column}),o++;let l=[];if(c.inlineMode==="single"){let u=n[o];u&&(l.push(u),o++)}else if(c.inlineMode==="pair")for(let u=0;u<2;u++){let d=n[o];if(!d)break;l.push(d),o++}else for(;o<n.length&&!Q_.has(n[o].value);)l.push(n[o]),o++;if(l.length===0)throw new q(`Missing value for field "${a.value}"`,e,a.column);s.push({type:"field",key:a.value,values:l.map(u=>u.value),location:{line:e,column:a.column}})}return tg(s,t),s}function Iw(n,e,t,i,r){if(n.length<2)throw new q("Invalid field line",e,n[0]?.column??1);let s=bo(n[0].value);if(!s)throw new q(`Unknown field "${n[0].value}"`,e,n[0].column);s.version==="2.1"&&_n(i,r,n[0].value,{line:e,column:n[0].column});let o={type:"field",key:n[0].value,values:n.slice(1).map(a=>a.value),location:{line:e,column:n[0].column}};return tg([o],t),o}function Jm(n,e,t){if(n.length<2)throw new q(t,e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(i=>i.value).join(" "),location:{line:e,column:n[0].column}}}function Cw(n,e,t){let i=Km(n.fields),r=Qm(i),s=Lw(n.objectType,i),o=kw(i.get("groups")?.[0]),a=pc(i.get("epoch")?.[0]),c=pc(i.get("referencePlane")?.[0]),l=i.has("tidalLock")?Li(Cn(i.get("tidalLock")[0]),"tidalLock",i.get("tidalLock")[0].location):void 0,u=i.has("resonance")?Uw(i.get("resonance")[0]):void 0,d=Ow(i),h=i.get("derive")?.map(v=>Nw(v)),f=i.get("validate")?.map(v=>({rule:Cn(v)})),p=i.has("locked")?[...new Set(i.get("locked").flatMap(v=>v.values))]:void 0,y=i.get("tolerance")?.map(v=>Fw(v)),g=Dw(n.typedBlockEntries),m=eg(n.infoEntries,"info"),x={type:n.objectType,id:n.id,properties:s,placement:r,info:m};return o.length>0&&(x.groups=o),a&&(x.epoch=a),c&&(x.referencePlane=c),l!==void 0&&(x.tidalLock=l),u&&(x.resonance=u),d&&(x.renderHints=d),h?.length&&(x.deriveRules=h),f?.length&&(x.validationRules=f),p?.length&&(x.lockedFields=p),y?.length&&(x.tolerances=y),g&&Object.keys(g).length>0&&(x.typedBlocks=g),gc(e,"2.1")&&(x.groups||x.epoch||x.referencePlane||x.tidalLock!==void 0||x.resonance||x.renderHints||x.deriveRules?.length||x.validationRules?.length||x.lockedFields?.length||x.tolerances?.length||x.typedBlocks)&&_n(e,t,n.id,n.location),x}function Rw(n,e){return{...n,participantObjectIds:[...new Set(n.participantObjectIds)],tags:[...new Set(n.tags)],positions:e.map(t=>Pw(t))}}function Pw(n){let e=Km(n.fields,"event-pose"),t=Qm(e);return{objectId:n.objectId,placement:t,inner:Oi(e.get("inner")?.[0],"inner"),outer:Oi(e.get("outer")?.[0],"outer"),epoch:pc(e.get("epoch")?.[0]),referencePlane:pc(e.get("referencePlane")?.[0])}}function Km(n,e="object"){let t=new Map;for(let i of n){let r=bo(i.key);if(!r&&!Xm.has(i.key))throw q.fromLocation(`Unknown field "${i.key}"`,i.location);if(!r?.allowRepeat&&t.has(i.key))throw q.fromLocation(`Duplicate field "${i.key}"`,i.location);let s=t.get(i.key)??[];s.push(i),t.set(i.key,s)}return t}function Qm(n){let e=n.get("orbit")?.[0],t=n.get("at")?.[0],i=n.get("surface")?.[0],r=n.get("free")?.[0];if([e,t,i,r].filter(Boolean).length>1){let o=e??t??i??r;throw q.fromLocation("Object has multiple placement modes",o?.location)}if(e)return{mode:"orbit",target:Cn(e),distance:Oi(n.get("distance")?.[0],"distance"),semiMajor:Oi(n.get("semiMajor")?.[0],"semiMajor"),eccentricity:Bw(n.get("eccentricity")?.[0],"eccentricity"),period:Oi(n.get("period")?.[0],"period"),angle:Oi(n.get("angle")?.[0],"angle"),inclination:Oi(n.get("inclination")?.[0],"inclination"),phase:Oi(n.get("phase")?.[0],"phase")};if(t){let o=Cn(t);return{mode:"at",target:o,reference:Vm(o,t.location)}}if(i)return{mode:"surface",target:Cn(i)};if(r){let o=Cn(r),a=pd(o);return{mode:"free",distance:a??void 0,descriptor:a?void 0:o}}return null}function Lw(n,e){let t={};for(let[i,r]of e.entries()){let s=r[0],o=bo(i);!s||!o?.legacySchema||o.legacySchema.placement||(md(i,n,s.location),t[i]=$m(i,s.values,s.location))}return t}function eg(n,e){let t={};for(let i of n){if(i.key in t)throw q.fromLocation(`Duplicate ${e} key "${i.key}"`,i.location);t[i.key]=i.value}return t}function Dw(n){let e={};for(let t of Object.keys(n)){let i=n[t];i?.length&&(e[t]=eg(i,t))}return e}function Ow(n){let e={},t=n.get("renderLabel")?.[0],i=n.get("renderOrbit")?.[0],r=n.get("renderPriority")?.[0];return t&&(e.renderLabel=Li(Cn(t),"renderLabel",t.location)),i&&(e.renderOrbit=Li(Cn(i),"renderOrbit",i.location)),r&&(e.renderPriority=hc(Cn(r),"renderPriority",r.location)),Object.keys(e).length>0?e:void 0}function Uw(n){if(n.values.length!==2)throw q.fromLocation('Field "resonance" expects "<targetObjectId> <ratio>"',n.location);let e=n.values[1];if(!/^\d+:\d+$/.test(e))throw q.fromLocation(`Invalid resonance ratio "${e}"`,n.location);return{targetObjectId:n.values[0],ratio:e}}function Nw(n){if(n.values.length!==2)throw q.fromLocation('Field "derive" expects "<field> <strategy>"',n.location);return{field:n.values[0],strategy:n.values[1]}}function Fw(n){if(n.values.length!==2)throw q.fromLocation('Field "tolerance" expects "<field> <value>"',n.location);let e=n.values[1],t=pd(e),i=Number(e);return{field:n.values[0],value:t??(Number.isFinite(i)?i:e)}}function kw(n){return n?[...new Set(n.values)]:[]}function pc(n){return n&&n.values.join(" ").trim()||null}function Oi(n,e){return n?fd(Cn(n),n.location,e):void 0}function Bw(n,e){return n?hc(Cn(n),e,n.location):void 0}function Cn(n){return yo(n.values,n.key,n.location)}function bo(n){return mc.get(n)}function tg(n,e){for(let t of n){let i=bo(t.key);if(!i)throw q.fromLocation(`Unknown field "${t.key}"`,t.location);if(i.legacySchema){md(t.key,e,t.location);continue}if((t.key==="renderLabel"||t.key==="renderOrbit"||t.key==="tidalLock")&&t.values.length!==1)throw q.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function _n(n,e,t,i){gc(n,"2.1")&&e.push({code:"parse.schema21.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.1; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function lr(n,e,t,i){gc(n,"2.5")&&e.push({code:"parse.schema25.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.5; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function gc(n,e){return Wm(n)<Wm(e)}function Wm(n){switch(n){case"2.0-draft":return 0;case"2.0":return 1;case"2.1":return 2;case"2.5":return 3}}function zw(n){let e=[...n],t=[],i=!1,r=!1,s=null,o=1,a=1;for(let c=0;c<e.length;c++){let l=e[c],u=e[c+1];if(r){if(l==="*"&&u==="/"){e[c]=" ",e[c+1]=" ",r=!1,s=null,c++,a+=2;continue}l!==`
3825
3825
  `&&l!=="\r"&&(e[c]=" "),l===`
3826
3826
  `?(o++,a=1):a++;continue}if(!i&&l==="/"&&u==="*"){t.push({kind:"block",line:o,column:a}),e[c]=" ",e[c+1]=" ",r=!0,s={line:o,column:a},c++,a+=2;continue}if(!i&&l==="#"&&!Vw(e,c)){t.push({kind:"line",line:o,column:a}),e[c]=" ";let d=c+1;for(;d<e.length&&e[d]!==`
3827
3827
  `&&e[d]!=="\r";)e[d]=" ",d++;a+=d-c,c=d-1;continue}l==='"'&&e[c-1]!=="\\"&&(i=!i),l===`
3828
- `?(o++,a=1):a++}if(r)throw Y.fromLocation("Unclosed block comment",s??void 0);return{source:e.join(""),comments:t}}function Vw(n,e){let t=e+1,i=0;for(;t<n.length&&/[0-9a-f]/i.test(n[t]??"");)t++,i++;if(![3,4,6,8].includes(i))return!1;let r=n[t];return r===void 0||r===" "||r===" "||r==="\r"||r===`
3829
- `}function yc(n="WorldOrbit",e="2.5"){return{format:"worldorbit",version:e,schemaVersion:e,sourceVersion:"1.0",system:{type:"system",id:n,title:n,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},groups:[],relations:[],events:[],objects:[],diagnostics:[]}}function lt(n){return structuredClone(n)}function _d(n,e){switch(e.kind){case"system":return n.system;case"defaults":return n.system?.defaults??null;case"metadata":return e.key?n.system?.atlasMetadata[e.key]??null:null;case"group":return e.id?sg(n,e.id):null;case"event":return e.id?vc(n,e.id):null;case"event-pose":return e.id&&e.key?ag(n,e.id,e.key):null;case"object":return e.id?rg(n,e.id):null;case"viewpoint":return e.id?cg(n.system,e.id):null;case"annotation":return e.id?lg(n.system,e.id):null;case"relation":return e.id?og(n,e.id):null}}function wd(n,e){let t=lt(n),i=ig(t);switch(e.kind){case"metadata":return e.key&&delete i.atlasMetadata[e.key],t;case"object":return e.id&&(t.objects=t.objects.filter(r=>r.id!==e.id)),t;case"group":return e.id&&(t.groups=t.groups.filter(r=>r.id!==e.id)),t;case"event":return e.id&&(t.events=t.events.filter(r=>r.id!==e.id)),t;case"event-pose":if(e.id&&e.key){let r=vc(t,e.id);r&&(r.positions=r.positions.filter(s=>s.objectId!==e.key))}return t;case"viewpoint":return e.id&&(i.viewpoints=i.viewpoints.filter(r=>r.id!==e.id)),t;case"annotation":return e.id&&(i.annotations=i.annotations.filter(r=>r.id!==e.id)),t;case"relation":return e.id&&(t.relations=t.relations.filter(r=>r.id!==e.id)),t;default:return t}}function _o(n,e){return e.map(t=>({diagnostic:t,path:ng(n,t)}))}function ng(n,e){if(e.objectId&&rg(n,e.objectId))return{kind:"object",id:e.objectId};if(e.field?.startsWith("group.")){let t=e.field.split(".");if(t[1]&&sg(n,t[1]))return{kind:"group",id:t[1]}}if(e.field?.startsWith("viewpoint.")){let t=e.field.split(".");if(t[1]&&cg(n.system,t[1]))return{kind:"viewpoint",id:t[1]}}if(e.field?.startsWith("annotation.")){let t=e.field.split(".");if(t[1]&&lg(n.system,t[1]))return{kind:"annotation",id:t[1]}}if(e.field?.startsWith("relation.")){let t=e.field.split(".");if(t[1]&&og(n,t[1]))return{kind:"relation",id:t[1]}}if(e.field?.startsWith("event.")){let t=e.field.split(".");if(t[1]&&vc(n,t[1]))return t[2]==="pose"&&t[3]&&ag(n,t[1],t[3])?{kind:"event-pose",id:t[1],key:t[3]}:{kind:"event",id:t[1]}}return e.field&&e.field in ig(n).atlasMetadata?{kind:"metadata",key:e.field}:null}function Md(n){let e=[...n.diagnostics,...xo(n,n.version)];return _o(n,e)}function ig(n){return n.system||(n.system=yc().system),n.system}function rg(n,e){return n.objects.find(t=>t.id===e)??null}function sg(n,e){return n.groups.find(t=>t.id===e)??null}function og(n,e){return n.relations.find(t=>t.id===e)??null}function vc(n,e){return n.events.find(t=>t.id===e)??null}function ag(n,e,t){return vc(n,e)?.positions.find(i=>i.objectId===t)??null}function cg(n,e){return n?.viewpoints.find(t=>t.id===e)??null}function lg(n,e){return n?.annotations.find(t=>t.id===e)??null}var $w=/^schema\s+2(?:\.0|\.1|\.5)?$/i,Hw=/^schema\s+2\.1$/i,Gw=/^schema\s+2\.5$/i,jw=/^schema\s+2\.0-draft$/i;function ug(n){for(let e of Ww(n).split(/\r?\n/)){let t=e.trim();if(t)return jw.test(t)?"2.0-draft":Hw.test(t)?"2.1":Gw.test(t)?"2.5":$w.test(t)?"2.0":"1.0"}return"1.0"}function Ww(n){let e=[...n],t=!1,i=!1;for(let r=0;r<e.length;r++){let s=e[r],o=e[r+1];if(i){if(s==="*"&&o==="/"){e[r]=" ",e[r+1]=" ",i=!1,r++;continue}s!==`
3828
+ `?(o++,a=1):a++}if(r)throw q.fromLocation("Unclosed block comment",s??void 0);return{source:e.join(""),comments:t}}function Vw(n,e){let t=e+1,i=0;for(;t<n.length&&/[0-9a-f]/i.test(n[t]??"");)t++,i++;if(![3,4,6,8].includes(i))return!1;let r=n[t];return r===void 0||r===" "||r===" "||r==="\r"||r===`
3829
+ `}function yc(n="WorldOrbit",e="2.5"){return{format:"worldorbit",version:e,schemaVersion:e,sourceVersion:"1.0",system:{type:"system",id:n,title:n,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},groups:[],relations:[],events:[],objects:[],diagnostics:[]}}function ot(n){return structuredClone(n)}function _d(n,e){switch(e.kind){case"system":return n.system;case"defaults":return n.system?.defaults??null;case"metadata":return e.key?n.system?.atlasMetadata[e.key]??null:null;case"group":return e.id?sg(n,e.id):null;case"event":return e.id?vc(n,e.id):null;case"event-pose":return e.id&&e.key?ag(n,e.id,e.key):null;case"object":return e.id?rg(n,e.id):null;case"viewpoint":return e.id?cg(n.system,e.id):null;case"annotation":return e.id?lg(n.system,e.id):null;case"relation":return e.id?og(n,e.id):null}}function wd(n,e){let t=ot(n),i=ig(t);switch(e.kind){case"metadata":return e.key&&delete i.atlasMetadata[e.key],t;case"object":return e.id&&(t.objects=t.objects.filter(r=>r.id!==e.id)),t;case"group":return e.id&&(t.groups=t.groups.filter(r=>r.id!==e.id)),t;case"event":return e.id&&(t.events=t.events.filter(r=>r.id!==e.id)),t;case"event-pose":if(e.id&&e.key){let r=vc(t,e.id);r&&(r.positions=r.positions.filter(s=>s.objectId!==e.key))}return t;case"viewpoint":return e.id&&(i.viewpoints=i.viewpoints.filter(r=>r.id!==e.id)),t;case"annotation":return e.id&&(i.annotations=i.annotations.filter(r=>r.id!==e.id)),t;case"relation":return e.id&&(t.relations=t.relations.filter(r=>r.id!==e.id)),t;default:return t}}function _o(n,e){return e.map(t=>({diagnostic:t,path:ng(n,t)}))}function ng(n,e){if(e.objectId&&rg(n,e.objectId))return{kind:"object",id:e.objectId};if(e.field?.startsWith("group.")){let t=e.field.split(".");if(t[1]&&sg(n,t[1]))return{kind:"group",id:t[1]}}if(e.field?.startsWith("viewpoint.")){let t=e.field.split(".");if(t[1]&&cg(n.system,t[1]))return{kind:"viewpoint",id:t[1]}}if(e.field?.startsWith("annotation.")){let t=e.field.split(".");if(t[1]&&lg(n.system,t[1]))return{kind:"annotation",id:t[1]}}if(e.field?.startsWith("relation.")){let t=e.field.split(".");if(t[1]&&og(n,t[1]))return{kind:"relation",id:t[1]}}if(e.field?.startsWith("event.")){let t=e.field.split(".");if(t[1]&&vc(n,t[1]))return t[2]==="pose"&&t[3]&&ag(n,t[1],t[3])?{kind:"event-pose",id:t[1],key:t[3]}:{kind:"event",id:t[1]}}return e.field&&e.field in ig(n).atlasMetadata?{kind:"metadata",key:e.field}:null}function Sd(n){let e=[...n.diagnostics,...xo(n,n.version)];return _o(n,e)}function ig(n){return n.system||(n.system=yc().system),n.system}function rg(n,e){return n.objects.find(t=>t.id===e)??null}function sg(n,e){return n.groups.find(t=>t.id===e)??null}function og(n,e){return n.relations.find(t=>t.id===e)??null}function vc(n,e){return n.events.find(t=>t.id===e)??null}function ag(n,e,t){return vc(n,e)?.positions.find(i=>i.objectId===t)??null}function cg(n,e){return n?.viewpoints.find(t=>t.id===e)??null}function lg(n,e){return n?.annotations.find(t=>t.id===e)??null}var $w=/^schema\s+2(?:\.0|\.1|\.5)?$/i,Hw=/^schema\s+2\.1$/i,jw=/^schema\s+2\.5$/i,Gw=/^schema\s+2\.0-draft$/i;function ug(n){for(let e of Ww(n).split(/\r?\n/)){let t=e.trim();if(t)return Gw.test(t)?"2.0-draft":Hw.test(t)?"2.1":jw.test(t)?"2.5":$w.test(t)?"2.0":"1.0"}return"1.0"}function Ww(n){let e=[...n],t=!1,i=!1;for(let r=0;r<e.length;r++){let s=e[r],o=e[r+1];if(i){if(s==="*"&&o==="/"){e[r]=" ",e[r+1]=" ",i=!1,r++;continue}s!==`
3830
3830
  `&&s!=="\r"&&(e[r]=" ");continue}if(!t&&s==="/"&&o==="*"){e[r]=" ",e[r+1]=" ",i=!0,r++;continue}if(!t&&s==="#"){e[r]=" ";let a=r+1;for(;a<e.length&&e[a]!==`
3831
- `&&e[a]!=="\r";)e[a]=" ",a++;r=a-1;continue}s==='"'&&e[r-1]!=="\\"&&(t=!t)}return e.join("")}function si(n){let e=wo(n);if(!e.ok||!e.value){let t=e.diagnostics[0];throw new Y(t?.message??"Failed to load WorldOrbit source",t?.line,t?.column)}return e.value}function wo(n){let e=ug(n);if(e==="2.0"||e==="2.0-draft"||e==="2.1"||e==="2.5")return Xw(n,e);let t;try{t=so(n)}catch(r){return{ok:!1,value:null,diagnostics:[cr(r,"parse")]}}let i;try{i=oo(t)}catch(r){return{ok:!1,value:null,diagnostics:[cr(r,"normalize")]}}try{ao(i)}catch(r){return{ok:!1,value:null,diagnostics:[cr(r,"validate")]}}return{ok:!0,value:{schemaVersion:e,ast:t,document:i,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function Xw(n,e){let t;try{t=vd(n)}catch(o){return{ok:!1,value:null,diagnostics:[cr(o,"parse","load.atlas.failed")]}}let i=[...t.diagnostics];if(i.some(o=>o.severity==="error"))return{ok:!1,value:null,diagnostics:i};let r;try{r=go(t)}catch(o){return{ok:!1,value:null,diagnostics:[cr(o,"normalize","load.atlas.materialize.failed")]}}return{ok:!0,value:{schemaVersion:e,ast:null,document:r,atlasDocument:t,draftDocument:t,diagnostics:i},diagnostics:i}}var xc=class extends Error{constructor(e){super(e),this.name="WorldOrbitViewerError"}},oi=class extends xc{constructor(e="WorldOrbit 3D is unavailable in this environment."){super(e),this.name="WorldOrbit3DUnavailableError"}};var qw={background:!0,guides:!0,relations:!0,events:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},bc={atlas:{name:"atlas",backgroundStart:"#041018",backgroundEnd:"#0a2331",backgroundGlow:"rgba(240, 180, 100, 0.18)",panel:"rgba(7, 17, 27, 0.9)",panelLine:"rgba(168, 207, 242, 0.18)",relation:"rgba(240, 180, 100, 0.42)",orbit:"rgba(163, 209, 255, 0.24)",orbitBand:"rgba(255, 190, 120, 0.28)",guide:"rgba(255, 255, 255, 0.04)",leader:"rgba(225, 238, 255, 0.4)",ink:"#e8f0ff",muted:"rgba(232, 240, 255, 0.7)",accent:"#f0b464",accentStrong:"#ff7f5f",selected:"rgba(255, 214, 139, 0.92)",starCore:"#ffcc67",starStroke:"rgba(255, 245, 203, 0.85)",starGlow:"#ffe8a3",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},nightglass:{name:"nightglass",backgroundStart:"#07131f",backgroundEnd:"#13283a",backgroundGlow:"rgba(120, 255, 215, 0.16)",panel:"rgba(7, 20, 30, 0.9)",panelLine:"rgba(120, 255, 215, 0.16)",relation:"rgba(156, 231, 255, 0.42)",orbit:"rgba(120, 255, 215, 0.2)",orbitBand:"rgba(137, 185, 255, 0.24)",guide:"rgba(255, 255, 255, 0.035)",leader:"rgba(192, 255, 233, 0.42)",ink:"#edfff8",muted:"rgba(237, 255, 248, 0.68)",accent:"#78ffd7",accentStrong:"#9ce7ff",selected:"rgba(120, 255, 215, 0.9)",starCore:"#e5f98c",starStroke:"rgba(246, 255, 217, 0.9)",starGlow:"#fffab4",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},ember:{name:"ember",backgroundStart:"#17090b",backgroundEnd:"#31111a",backgroundGlow:"rgba(255, 127, 95, 0.18)",panel:"rgba(24, 9, 13, 0.9)",panelLine:"rgba(255, 166, 149, 0.16)",relation:"rgba(255, 178, 125, 0.42)",orbit:"rgba(255, 188, 164, 0.22)",orbitBand:"rgba(255, 214, 139, 0.24)",guide:"rgba(255, 255, 255, 0.03)",leader:"rgba(255, 223, 209, 0.42)",ink:"#fff3ee",muted:"rgba(255, 243, 238, 0.68)",accent:"#ffb27d",accentStrong:"#ff7f5f",selected:"rgba(255, 178, 125, 0.9)",starCore:"#ffb766",starStroke:"rgba(255, 236, 205, 0.88)",starGlow:"#ffe2ad",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'}};function Mo(n){return n?typeof n=="string"?bc[n]??bc.atlas:{...bc.atlas,...n}:bc.atlas}function Sd(n){return{...qw,...n}}function $n(n){if(!n)return null;let e={query:n.query?.trim()||void 0,objectTypes:Ed(n.objectTypes??[]),tags:Ed((n.tags??[]).map(t=>t.trim()).filter(Boolean)),groupIds:Ed((n.groupIds??[]).map(t=>t.trim()).filter(Boolean)),includeAncestors:n.includeAncestors??!0};return Zw(e)?e:null}function Zw(n){return!!(n&&(n.query?.trim()||n.objectTypes?.length||n.tags?.length||n.groupIds?.length))}function _c(n,e){let t=$n(e),i=new Set;for(let r of n.objects)if(!r.hidden&&Jw(r,t)&&(i.add(r.objectId),t?.includeAncestors!==!1))for(let s of r.ancestorIds)i.add(s);return t?i:new Set(n.objects.filter(r=>!r.hidden).map(r=>r.objectId))}function Ad(n,e,t=12){let i=e.trim().toLowerCase();return i?n.objects.filter(r=>!r.hidden).map(r=>({object:r,score:Kw(r,i)})).filter(r=>r.score>0).sort((r,s)=>s.score-r.score||r.object.label.localeCompare(s.object.label)).slice(0,t).map(r=>dg(r.object,r.score)):n.objects.filter(r=>!r.hidden).slice().sort((r,s)=>r.label.localeCompare(s.label)).slice(0,t).map(r=>dg(r,1))}function hg(n,e,t,i){return{version:"2.5",viewpointId:i,activeEventId:e.activeEventId??null,viewerState:{...n},renderOptions:{preset:e.preset,projection:e.projection,camera:e.camera?{...e.camera}:null,layers:e.layers?{...e.layers}:void 0,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,activeEventId:e.activeEventId??null,viewMode:e.viewMode??"2d"},filter:$n(t)}}function Td(n){return encodeURIComponent(JSON.stringify(n))}function Id(n){let e=JSON.parse(decodeURIComponent(n));return{version:e.version==="2.0"?"2.0":"2.5",viewpointId:e.viewpointId??null,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewerState:{scale:e.viewerState?.scale??1,rotationDeg:e.viewerState?.rotationDeg??0,translateX:e.viewerState?.translateX??0,translateY:e.viewerState?.translateY??0,selectedObjectId:e.viewerState?.selectedObjectId??null},renderOptions:{preset:e.renderOptions?.preset,projection:e.renderOptions?.projection,camera:e.renderOptions?.camera?{...e.renderOptions.camera}:null,layers:e.renderOptions?.layers?{...e.renderOptions.layers}:void 0,scaleModel:e.renderOptions?.scaleModel?{...e.renderOptions.scaleModel}:void 0,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewMode:e.renderOptions?.viewMode??"2d"},filter:$n(e.filter??null)}}function fg(n,e,t){let i=n.trim()||"bookmark";return{id:i.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"bookmark",label:e?.trim()||i,atlasState:{...t,viewerState:{...t.viewerState},renderOptions:{...t.renderOptions,camera:t.renderOptions.camera?{...t.renderOptions.camera}:null,layers:t.renderOptions.layers?{...t.renderOptions.layers}:void 0,scaleModel:t.renderOptions.scaleModel?{...t.renderOptions.scaleModel}:void 0,activeEventId:t.renderOptions.activeEventId??null,viewMode:t.renderOptions.viewMode??"2d"},filter:t.filter?{...t.filter}:null}}}function Cd(n){if(!(!n||!(Object.keys(n.layers).length>0)))return{background:n.layers.background,guides:n.layers.guides,relations:n.layers.relations,events:n.layers.events,orbits:n.layers["orbits-front"]===void 0&&n.layers["orbits-back"]===void 0?void 0:n.layers["orbits-front"]!==!1||n.layers["orbits-back"]!==!1,objects:n.layers.objects,labels:n.layers.labels,metadata:n.layers.metadata}}function Rd(n){return n?.filter?$n({query:n.filter.query??void 0,objectTypes:n.filter.objectTypes,tags:n.filter.tags,groupIds:n.filter.groupIds,includeAncestors:!0}):null}function dg(n,e){return{objectId:n.objectId,label:n.label,type:n.object.type,score:e,groupId:n.groupId,parentId:n.parentId,tags:Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(t=>typeof t=="string"):[]}}function Jw(n,e){if(!e)return!0;if(e.objectTypes?.length&&!e.objectTypes.includes(n.object.type))return!1;if(e.groupIds?.length&&(!n.groupId||!e.groupIds.includes(n.groupId))){let t=n.semanticGroupIds.length>0&&e.groupIds.some(r=>n.semanticGroupIds.includes(r)),i=!!(n.groupId&&e.groupIds.includes(n.groupId));if(!t&&!i)return!1}if(e.tags?.length){let t=Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(i=>typeof i=="string"):[];if(!e.tags.every(i=>t.includes(i)))return!1}if(e.query?.trim()){let t=pg(n.object,n.label).toLowerCase();if(!e.query.toLowerCase().split(/\s+/).filter(Boolean).every(r=>t.includes(r)))return!1}return!0}function Kw(n,e){let t=n.objectId.toLowerCase(),i=n.label.toLowerCase(),r=pg(n.object,n.label).toLowerCase(),s=0;return t===e||i===e?s+=120:t.startsWith(e)||i.startsWith(e)?s+=96:(t.includes(e)||i.includes(e))&&(s+=72),e.split(/\s+/).filter(Boolean).every(c=>r.includes(c))&&(s+=32),n.object.type===e&&(s+=24),(Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(c=>typeof c=="string"):[]).some(c=>c.toLowerCase()===e)&&(s+=18),s}function pg(n,e){let t=Object.values(n.info),i=Object.values(n.properties).flatMap(r=>Array.isArray(r)?r:typeof r=="object"&&r&&"value"in r?[String(r.value),String(r.unit??"")]:[String(r)]).filter(Boolean);return[n.id,e,n.type,...i,...t].join(" ")}function Ed(n){return[...new Set(n)]}var Dn={scale:1,rotationDeg:0,translateX:0,translateY:0,selectedObjectId:null};function mg(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function wc(n,e){return Math.min(Math.max(n,e.minScale),e.maxScale)}function ts(n,e,t){return{...n,translateX:n.translateX+e,translateY:n.translateY+t}}function Pd(n,e){return{...n,rotationDeg:mg(n.rotationDeg+e)}}function So(n,e,t,i,r){if(!Number.isFinite(t)||t<=0)return e;let s=is(n),o=wc(e.scale*t,r);if(o===e.scale)return e;let a=o/e.scale,c=i.x-s.x,l=i.y-s.y;return{...e,scale:o,translateX:(1-a)*c+a*e.translateX,translateY:(1-a)*l+a*e.translateY}}function ns(n,e,t){let i=is(n),r=Qw(n.contentBounds,i,e.rotationDeg),s=Math.max(n.width-t.fitPadding*2,1),o=Math.max(n.height-t.fitPadding*2,1),a=Math.max(r.width,1),c=Math.max(r.height,1),l=wc(Math.min(s/a,o/c),t),u=ln({x:n.contentBounds.centerX,y:n.contentBounds.centerY},i,e.rotationDeg);return{...e,scale:l,translateX:i.x-(i.x+(u.x-i.x)*l),translateY:i.y-(i.y+(u.y-i.y)*l)}}function Ld(n,e,t,i){let r=n.objects.find(c=>c.objectId===t&&!c.hidden);if(!r)return e;let s=is(n),o=wc(Math.max(e.scale,1.8),i),a=ln({x:r.x,y:r.y},s,e.rotationDeg);return{...e,scale:o,translateX:s.x-(s.x+(a.x-s.x)*o),translateY:s.y-(s.y+(a.y-s.y)*o),selectedObjectId:t}}function Dd(n,e){let t=is(n);return`translate(${e.translateX} ${e.translateY}) translate(${t.x} ${t.y}) rotate(${e.rotationDeg}) scale(${e.scale}) translate(${-t.x} ${-t.y})`}function dr(n,e,t){let i=is(n),r={x:t.x-e.translateX,y:t.y-e.translateY},s={x:r.x-i.x,y:r.y-i.y},o={x:s.x/Math.max(e.scale,1e-4),y:s.y/Math.max(e.scale,1e-4)},a=ln({x:o.x,y:o.y},{x:0,y:0},-e.rotationDeg);return{x:i.x+a.x,y:i.y+a.y}}function Eo(n,e){let t=[{x:0,y:0},{x:n.width,y:0},{x:n.width,y:n.height},{x:0,y:n.height}].map(a=>dr(n,e,a)),i=Math.min(...t.map(a=>a.x)),r=Math.min(...t.map(a=>a.y)),s=Math.max(...t.map(a=>a.x)),o=Math.max(...t.map(a=>a.y));return{minX:i,minY:r,maxX:s,maxY:o,width:s-i,height:o-r,centerX:i+(s-i)/2,centerY:r+(o-r)/2}}function is(n){return{x:n.width/2,y:n.height/2}}function Qw(n,e,t){let i=[{x:n.minX,y:n.minY},{x:n.maxX,y:n.minY},{x:n.maxX,y:n.maxY},{x:n.minX,y:n.maxY}].map(c=>ln(c,e,t)),r=Math.min(...i.map(c=>c.x)),s=Math.min(...i.map(c=>c.y)),o=Math.max(...i.map(c=>c.x)),a=Math.max(...i.map(c=>c.y));return{minX:r,minY:s,maxX:o,maxY:a,width:o-r,height:a-s,centerX:r+(o-r)/2,centerY:s+(a-s)/2}}var Od="worldorbit-camera-root";function ai(n,e={}){let t=Mo(e.theme),i=mM(e.preset??n.renderPreset??void 0),r=Sd({...i.layers,...e.layers}),s=e.subtitle??n.subtitle,o=_c(n,e.filter??null),a=n.objects.filter(v=>!v.hidden).filter(v=>o.has(v.objectId)).filter(v=>r.structures||!Mc(v.object)).sort((v,x)=>v.sortKey-x.sortKey),c=n.labels.filter(v=>!v.hidden).filter(v=>o.has(v.objectId)).filter(v=>r.structures||!Mc(v.object)),l=nM(a),u=r.orbits?tM(n,o,r.structures):{back:"",front:""},d=r.guides?n.leaders.filter(v=>!v.hidden).filter(v=>o.has(v.objectId)).filter(v=>r.structures||!Mc(v.object)).map(v=>`<line class="wo-leader wo-leader-${v.mode}" x1="${v.x1}" y1="${v.y1}" x2="${v.x2}" y2="${v.y2}" data-render-id="${kt(v.renderId)}" data-group-id="${qt(v.groupId??"")}" />`).join(""):"",h=r.relations?n.relations.filter(v=>!v.hidden).filter(v=>o.has(v.fromObjectId)&&o.has(v.toObjectId)).map(v=>`<line class="wo-relation" x1="${v.x1}" y1="${v.y1}" x2="${v.x2}" y2="${v.y2}" data-render-id="${kt(v.renderId)}" data-relation-id="${qt(v.relationId)}" />`).join(""):"",f=r.events?n.events.filter(v=>!v.hidden).map(v=>eM(n,v,o,t)).join(""):"",p=r.objects?a.map(v=>iM(v,e.selectedObjectId??null,t)).join(""):"",y=r.labels?c.map(v=>rM(n,v,e.selectedObjectId??null)).join(""):"",g=r.metadata?`<text class="wo-title" x="56" y="64">${kt(n.title)}</text>
3832
- <text class="wo-subtitle" x="56" y="88">${kt(s)}</text>
3833
- <text class="wo-meta" x="56" y="${n.height-42}">${kt(yM(n))}</text>`:"",m=r.background?`<rect class="wo-bg" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
3831
+ `&&e[a]!=="\r";)e[a]=" ",a++;r=a-1;continue}s==='"'&&e[r-1]!=="\\"&&(t=!t)}return e.join("")}function ii(n){let e=wo(n);if(!e.ok||!e.value){let t=e.diagnostics[0];throw new q(t?.message??"Failed to load WorldOrbit source",t?.line,t?.column)}return e.value}function wo(n){let e=ug(n);if(e==="2.0"||e==="2.0-draft"||e==="2.1"||e==="2.5")return Xw(n,e);let t;try{t=so(n)}catch(r){return{ok:!1,value:null,diagnostics:[ar(r,"parse")]}}let i;try{i=oo(t)}catch(r){return{ok:!1,value:null,diagnostics:[ar(r,"normalize")]}}try{ao(i)}catch(r){return{ok:!1,value:null,diagnostics:[ar(r,"validate")]}}return{ok:!0,value:{schemaVersion:e,ast:t,document:i,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function Xw(n,e){let t;try{t=vd(n)}catch(o){return{ok:!1,value:null,diagnostics:[ar(o,"parse","load.atlas.failed")]}}let i=[...t.diagnostics];if(i.some(o=>o.severity==="error"))return{ok:!1,value:null,diagnostics:i};let r;try{r=go(t)}catch(o){return{ok:!1,value:null,diagnostics:[ar(o,"normalize","load.atlas.materialize.failed")]}}return{ok:!0,value:{schemaVersion:e,ast:null,document:r,atlasDocument:t,draftDocument:t,diagnostics:i},diagnostics:i}}var xc=class extends Error{constructor(e){super(e),this.name="WorldOrbitViewerError"}},ri=class extends xc{constructor(e="WorldOrbit 3D is unavailable in this environment."){super(e),this.name="WorldOrbit3DUnavailableError"}};var qw={background:!0,guides:!0,relations:!0,events:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},bc={atlas:{name:"atlas",backgroundStart:"#041018",backgroundEnd:"#0a2331",backgroundGlow:"rgba(240, 180, 100, 0.18)",panel:"rgba(7, 17, 27, 0.9)",panelLine:"rgba(168, 207, 242, 0.18)",relation:"rgba(240, 180, 100, 0.42)",orbit:"rgba(163, 209, 255, 0.24)",orbitBand:"rgba(255, 190, 120, 0.28)",guide:"rgba(255, 255, 255, 0.04)",leader:"rgba(225, 238, 255, 0.4)",ink:"#e8f0ff",muted:"rgba(232, 240, 255, 0.7)",accent:"#f0b464",accentStrong:"#ff7f5f",selected:"rgba(255, 214, 139, 0.92)",starCore:"#ffcc67",starStroke:"rgba(255, 245, 203, 0.85)",starGlow:"#ffe8a3",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},nightglass:{name:"nightglass",backgroundStart:"#07131f",backgroundEnd:"#13283a",backgroundGlow:"rgba(120, 255, 215, 0.16)",panel:"rgba(7, 20, 30, 0.9)",panelLine:"rgba(120, 255, 215, 0.16)",relation:"rgba(156, 231, 255, 0.42)",orbit:"rgba(120, 255, 215, 0.2)",orbitBand:"rgba(137, 185, 255, 0.24)",guide:"rgba(255, 255, 255, 0.035)",leader:"rgba(192, 255, 233, 0.42)",ink:"#edfff8",muted:"rgba(237, 255, 248, 0.68)",accent:"#78ffd7",accentStrong:"#9ce7ff",selected:"rgba(120, 255, 215, 0.9)",starCore:"#e5f98c",starStroke:"rgba(246, 255, 217, 0.9)",starGlow:"#fffab4",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},ember:{name:"ember",backgroundStart:"#17090b",backgroundEnd:"#31111a",backgroundGlow:"rgba(255, 127, 95, 0.18)",panel:"rgba(24, 9, 13, 0.9)",panelLine:"rgba(255, 166, 149, 0.16)",relation:"rgba(255, 178, 125, 0.42)",orbit:"rgba(255, 188, 164, 0.22)",orbitBand:"rgba(255, 214, 139, 0.24)",guide:"rgba(255, 255, 255, 0.03)",leader:"rgba(255, 223, 209, 0.42)",ink:"#fff3ee",muted:"rgba(255, 243, 238, 0.68)",accent:"#ffb27d",accentStrong:"#ff7f5f",selected:"rgba(255, 178, 125, 0.9)",starCore:"#ffb766",starStroke:"rgba(255, 236, 205, 0.88)",starGlow:"#ffe2ad",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'}};function So(n){return n?typeof n=="string"?bc[n]??bc.atlas:{...bc.atlas,...n}:bc.atlas}function Md(n){return{...qw,...n}}function zn(n){if(!n)return null;let e={query:n.query?.trim()||void 0,objectTypes:Ed(n.objectTypes??[]),tags:Ed((n.tags??[]).map(t=>t.trim()).filter(Boolean)),groupIds:Ed((n.groupIds??[]).map(t=>t.trim()).filter(Boolean)),includeAncestors:n.includeAncestors??!0};return Zw(e)?e:null}function Zw(n){return!!(n&&(n.query?.trim()||n.objectTypes?.length||n.tags?.length||n.groupIds?.length))}function _c(n,e){let t=zn(e),i=new Set;for(let r of n.objects)if(!r.hidden&&Jw(r,t)&&(i.add(r.objectId),t?.includeAncestors!==!1))for(let s of r.ancestorIds)i.add(s);return t?i:new Set(n.objects.filter(r=>!r.hidden).map(r=>r.objectId))}function Ad(n,e,t=12){let i=e.trim().toLowerCase();return i?n.objects.filter(r=>!r.hidden).map(r=>({object:r,score:Kw(r,i)})).filter(r=>r.score>0).sort((r,s)=>s.score-r.score||r.object.label.localeCompare(s.object.label)).slice(0,t).map(r=>dg(r.object,r.score)):n.objects.filter(r=>!r.hidden).slice().sort((r,s)=>r.label.localeCompare(s.label)).slice(0,t).map(r=>dg(r,1))}function hg(n,e,t,i){return{version:"2.5",viewpointId:i,activeEventId:e.activeEventId??null,viewerState:{...n},renderOptions:{preset:e.preset,projection:e.projection,camera:e.camera?{...e.camera}:null,layers:e.layers?{...e.layers}:void 0,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,activeEventId:e.activeEventId??null,viewMode:e.viewMode??"2d"},filter:zn(t)}}function Td(n){return encodeURIComponent(JSON.stringify(n))}function Id(n){let e=JSON.parse(decodeURIComponent(n));return{version:e.version==="2.0"?"2.0":"2.5",viewpointId:e.viewpointId??null,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewerState:{scale:e.viewerState?.scale??1,rotationDeg:e.viewerState?.rotationDeg??0,translateX:e.viewerState?.translateX??0,translateY:e.viewerState?.translateY??0,selectedObjectId:e.viewerState?.selectedObjectId??null},renderOptions:{preset:e.renderOptions?.preset,projection:e.renderOptions?.projection,camera:e.renderOptions?.camera?{...e.renderOptions.camera}:null,layers:e.renderOptions?.layers?{...e.renderOptions.layers}:void 0,scaleModel:e.renderOptions?.scaleModel?{...e.renderOptions.scaleModel}:void 0,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewMode:e.renderOptions?.viewMode??"2d"},filter:zn(e.filter??null)}}function fg(n,e,t){let i=n.trim()||"bookmark";return{id:i.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"bookmark",label:e?.trim()||i,atlasState:{...t,viewerState:{...t.viewerState},renderOptions:{...t.renderOptions,camera:t.renderOptions.camera?{...t.renderOptions.camera}:null,layers:t.renderOptions.layers?{...t.renderOptions.layers}:void 0,scaleModel:t.renderOptions.scaleModel?{...t.renderOptions.scaleModel}:void 0,activeEventId:t.renderOptions.activeEventId??null,viewMode:t.renderOptions.viewMode??"2d"},filter:t.filter?{...t.filter}:null}}}function Cd(n){if(!(!n||!(Object.keys(n.layers).length>0)))return{background:n.layers.background,guides:n.layers.guides,relations:n.layers.relations,events:n.layers.events,orbits:n.layers["orbits-front"]===void 0&&n.layers["orbits-back"]===void 0?void 0:n.layers["orbits-front"]!==!1||n.layers["orbits-back"]!==!1,objects:n.layers.objects,labels:n.layers.labels,metadata:n.layers.metadata}}function Rd(n){return n?.filter?zn({query:n.filter.query??void 0,objectTypes:n.filter.objectTypes,tags:n.filter.tags,groupIds:n.filter.groupIds,includeAncestors:!0}):null}function dg(n,e){return{objectId:n.objectId,label:n.label,type:n.object.type,score:e,groupId:n.groupId,parentId:n.parentId,tags:Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(t=>typeof t=="string"):[]}}function Jw(n,e){if(!e)return!0;if(e.objectTypes?.length&&!e.objectTypes.includes(n.object.type))return!1;if(e.groupIds?.length&&(!n.groupId||!e.groupIds.includes(n.groupId))){let t=n.semanticGroupIds.length>0&&e.groupIds.some(r=>n.semanticGroupIds.includes(r)),i=!!(n.groupId&&e.groupIds.includes(n.groupId));if(!t&&!i)return!1}if(e.tags?.length){let t=Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(i=>typeof i=="string"):[];if(!e.tags.every(i=>t.includes(i)))return!1}if(e.query?.trim()){let t=pg(n.object,n.label).toLowerCase();if(!e.query.toLowerCase().split(/\s+/).filter(Boolean).every(r=>t.includes(r)))return!1}return!0}function Kw(n,e){let t=n.objectId.toLowerCase(),i=n.label.toLowerCase(),r=pg(n.object,n.label).toLowerCase(),s=0;return t===e||i===e?s+=120:t.startsWith(e)||i.startsWith(e)?s+=96:(t.includes(e)||i.includes(e))&&(s+=72),e.split(/\s+/).filter(Boolean).every(c=>r.includes(c))&&(s+=32),n.object.type===e&&(s+=24),(Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(c=>typeof c=="string"):[]).some(c=>c.toLowerCase()===e)&&(s+=18),s}function pg(n,e){let t=Object.values(n.info),i=Object.values(n.properties).flatMap(r=>Array.isArray(r)?r:typeof r=="object"&&r&&"value"in r?[String(r.value),String(r.unit??"")]:[String(r)]).filter(Boolean);return[n.id,e,n.type,...i,...t].join(" ")}function Ed(n){return[...new Set(n)]}var Rn={scale:1,rotationDeg:0,translateX:0,translateY:0,selectedObjectId:null};function mg(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function wc(n,e){return Math.min(Math.max(n,e.minScale),e.maxScale)}function is(n,e,t){return{...n,translateX:n.translateX+e,translateY:n.translateY+t}}function Pd(n,e){return{...n,rotationDeg:mg(n.rotationDeg+e)}}function Mo(n,e,t,i,r){if(!Number.isFinite(t)||t<=0)return e;let s=ss(n),o=wc(e.scale*t,r);if(o===e.scale)return e;let a=o/e.scale,c=i.x-s.x,l=i.y-s.y;return{...e,scale:o,translateX:(1-a)*c+a*e.translateX,translateY:(1-a)*l+a*e.translateY}}function rs(n,e,t){let i=ss(n),r=Qw(n.contentBounds,i,e.rotationDeg),s=Math.max(n.width-t.fitPadding*2,1),o=Math.max(n.height-t.fitPadding*2,1),a=Math.max(r.width,1),c=Math.max(r.height,1),l=wc(Math.min(s/a,o/c),t),u=sn({x:n.contentBounds.centerX,y:n.contentBounds.centerY},i,e.rotationDeg);return{...e,scale:l,translateX:i.x-(i.x+(u.x-i.x)*l),translateY:i.y-(i.y+(u.y-i.y)*l)}}function Ld(n,e,t,i){let r=n.objects.find(c=>c.objectId===t&&!c.hidden);if(!r)return e;let s=ss(n),o=wc(Math.max(e.scale,1.8),i),a=sn({x:r.x,y:r.y},s,e.rotationDeg);return{...e,scale:o,translateX:s.x-(s.x+(a.x-s.x)*o),translateY:s.y-(s.y+(a.y-s.y)*o),selectedObjectId:t}}function Dd(n,e){let t=ss(n);return`translate(${e.translateX} ${e.translateY}) translate(${t.x} ${t.y}) rotate(${e.rotationDeg}) scale(${e.scale}) translate(${-t.x} ${-t.y})`}function ur(n,e,t){let i=ss(n),r={x:t.x-e.translateX,y:t.y-e.translateY},s={x:r.x-i.x,y:r.y-i.y},o={x:s.x/Math.max(e.scale,1e-4),y:s.y/Math.max(e.scale,1e-4)},a=sn({x:o.x,y:o.y},{x:0,y:0},-e.rotationDeg);return{x:i.x+a.x,y:i.y+a.y}}function Eo(n,e){let t=[{x:0,y:0},{x:n.width,y:0},{x:n.width,y:n.height},{x:0,y:n.height}].map(a=>ur(n,e,a)),i=Math.min(...t.map(a=>a.x)),r=Math.min(...t.map(a=>a.y)),s=Math.max(...t.map(a=>a.x)),o=Math.max(...t.map(a=>a.y));return{minX:i,minY:r,maxX:s,maxY:o,width:s-i,height:o-r,centerX:i+(s-i)/2,centerY:r+(o-r)/2}}function ss(n){return{x:n.width/2,y:n.height/2}}function Qw(n,e,t){let i=[{x:n.minX,y:n.minY},{x:n.maxX,y:n.minY},{x:n.maxX,y:n.maxY},{x:n.minX,y:n.maxY}].map(c=>sn(c,e,t)),r=Math.min(...i.map(c=>c.x)),s=Math.min(...i.map(c=>c.y)),o=Math.max(...i.map(c=>c.x)),a=Math.max(...i.map(c=>c.y));return{minX:r,minY:s,maxX:o,maxY:a,width:o-r,height:a-s,centerX:r+(o-r)/2,centerY:s+(a-s)/2}}var Od="worldorbit-camera-root";function si(n,e={}){let t=So(e.theme),i=mS(e.preset??n.renderPreset??void 0),r=Md({...i.layers,...e.layers}),s=e.subtitle??n.subtitle,o=_c(n,e.filter??null),a=n.objects.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Sc(x.object)).sort((x,v)=>x.sortKey-v.sortKey),c=n.labels.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Sc(x.object)),l=nS(a),u=r.orbits?tS(n,o,r.structures):{back:"",front:""},d=r.guides?n.leaders.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Sc(x.object)).map(x=>`<line class="wo-leader wo-leader-${x.mode}" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${Ot(x.renderId)}" data-group-id="${Wt(x.groupId??"")}" />`).join(""):"",h=r.relations?n.relations.filter(x=>!x.hidden).filter(x=>o.has(x.fromObjectId)&&o.has(x.toObjectId)).map(x=>`<line class="wo-relation" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${Ot(x.renderId)}" data-relation-id="${Wt(x.relationId)}" />`).join(""):"",f=r.events?n.events.filter(x=>!x.hidden).map(x=>eS(n,x,o,t)).join(""):"",p=r.objects?a.map(x=>iS(x,e.selectedObjectId??null,t)).join(""):"",y=r.labels?c.map(x=>rS(n,x,e.selectedObjectId??null)).join(""):"",g=r.metadata?`<text class="wo-title" x="56" y="64">${Ot(n.title)}</text>
3832
+ <text class="wo-subtitle" x="56" y="88">${Ot(s)}</text>
3833
+ <text class="wo-meta" x="56" y="${n.height-42}">${Ot(yS(n))}</text>`:"",m=r.background?`<rect class="wo-bg" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
3834
3834
  <rect class="wo-bg-glow" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
3835
- ${r.guides?gM(n.width,n.height):""}`:"";return`<svg xmlns="http://www.w3.org/2000/svg" data-worldorbit-svg="true" width="${n.width}" height="${n.height}" viewBox="0 0 ${n.width} ${n.height}" preserveAspectRatio="xMidYMid meet" role="img" aria-labelledby="worldorbit-title worldorbit-desc">
3836
- <title id="worldorbit-title">${kt(n.title)}</title>
3837
- <desc id="worldorbit-desc">A ${kt(n.viewMode)} WorldOrbit render with ${a.length} visible objects.</desc>
3835
+ ${r.guides?gS(n.width,n.height):""}`:"";return`<svg xmlns="http://www.w3.org/2000/svg" data-worldorbit-svg="true" width="${n.width}" height="${n.height}" viewBox="0 0 ${n.width} ${n.height}" preserveAspectRatio="xMidYMid meet" role="img" aria-labelledby="worldorbit-title worldorbit-desc">
3836
+ <title id="worldorbit-title">${Ot(n.title)}</title>
3837
+ <desc id="worldorbit-desc">A ${Ot(n.viewMode)} WorldOrbit render with ${a.length} visible objects.</desc>
3838
3838
  <defs>
3839
3839
  <linearGradient id="wo-bg" x1="0%" y1="0%" x2="100%" y2="100%">
3840
3840
  <stop offset="0%" stop-color="${t.backgroundStart}" />
@@ -3903,19 +3903,19 @@ void main() {
3903
3903
  </g>
3904
3904
  </g>
3905
3905
  </g>
3906
- </svg>`}function eM(n,e,t,i){let r=e.objectIds.filter(c=>t.has(c)).map(c=>n.objects.find(l=>l.objectId===c&&!l.hidden)).filter(Boolean);if(r.length===0)return"";let s=e.event.color||i.accent,o=e.event.label||e.event.id,a=r.map(c=>`<line class="wo-event-line" x1="${e.x}" y1="${e.y}" x2="${c.x}" y2="${c.y}" stroke="${qt(s)}" data-event-id="${qt(e.eventId)}" data-object-id="${qt(c.objectId)}" />`).join("");return`<g class="wo-event" data-render-id="${kt(e.renderId)}" data-event-id="${qt(e.eventId)}">
3906
+ </svg>`}function eS(n,e,t,i){let r=e.objectIds.filter(c=>t.has(c)).map(c=>n.objects.find(l=>l.objectId===c&&!l.hidden)).filter(Boolean);if(r.length===0)return"";let s=e.event.color||i.accent,o=e.event.label||e.event.id,a=r.map(c=>`<line class="wo-event-line" x1="${e.x}" y1="${e.y}" x2="${c.x}" y2="${c.y}" stroke="${Wt(s)}" data-event-id="${Wt(e.eventId)}" data-object-id="${Wt(c.objectId)}" />`).join("");return`<g class="wo-event" data-render-id="${Ot(e.renderId)}" data-event-id="${Wt(e.eventId)}">
3907
3907
  ${a}
3908
- <circle class="wo-event-node" cx="${e.x}" cy="${e.y}" r="5" fill="${qt(s)}" />
3909
- <text class="wo-event-label" x="${e.x}" y="${e.y-10}" text-anchor="middle" font-size="10">${kt(o)}</text>
3910
- </g>`}function tM(n,e,t){let i=[],r=[];for(let s of n.orbitVisuals.filter(o=>!o.hidden&&e.has(o.objectId)&&(t||!Mc(o.object)))){let o=s.bandThickness??(s.band?10:1.5),a=s.band?"wo-orbit wo-orbit-band wo-orbit-node":"wo-orbit wo-orbit-node",c=`data-render-id="${kt(s.renderId)}" data-orbit-object-id="${qt(s.objectId)}" data-parent-id="${qt(s.parentId)}" data-group-id="${qt(s.groupId??"")}"`;if(s.backArcPath||s.frontArcPath){s.backArcPath&&i.push(`<path class="${a} wo-orbit-back" d="${s.backArcPath}" stroke-width="${o}" ${c} />`),s.frontArcPath&&r.push(`<path class="${a} wo-orbit-front" d="${s.frontArcPath}" stroke-width="${o}" ${c} />`);continue}if(s.kind==="ellipse"){let l=s.rx??s.radius??0,u=s.ry??s.radius??0;r.push(`<ellipse class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" rx="${l}" ry="${u}" transform="rotate(${s.rotationDeg} ${s.cx} ${s.cy})" stroke-width="${o}" ${c} />`);continue}r.push(`<circle class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" r="${s.radius??0}" stroke-width="${o}" ${c} />`)}return{back:i.join(""),front:r.join("")}}function nM(n){return n.filter(e=>!!e.imageHref).map(e=>aM(e)).join("")}function iM(n,e,t){let{object:i,x:r,y:s,radius:o,visualRadius:a}=n,c=e===n.objectId?" wo-object-selected":"",l=i.properties.kind?` wo-kind-${String(i.properties.kind).toLowerCase().replace(/[^a-z0-9-]/g,"-")}`:"",u=lM(n,t),d=oM(n),h=d?gg(i,r,s,o,u,{outlineOnly:!0}):"";return`<g class="wo-object wo-object-${i.type}${l}${c}" data-object-id="${kt(n.objectId)}" data-parent-id="${qt(n.parentId??"")}" data-group-id="${qt(n.groupId??"")}" data-render-id="${kt(n.renderId)}" tabindex="0" role="button" aria-label="${kt(`${i.type} ${n.objectId}`)}">
3908
+ <circle class="wo-event-node" cx="${e.x}" cy="${e.y}" r="5" fill="${Wt(s)}" />
3909
+ <text class="wo-event-label" x="${e.x}" y="${e.y-10}" text-anchor="middle" font-size="10">${Ot(o)}</text>
3910
+ </g>`}function tS(n,e,t){let i=[],r=[];for(let s of n.orbitVisuals.filter(o=>!o.hidden&&e.has(o.objectId)&&(t||!Sc(o.object)))){let o=s.bandThickness??(s.band?10:1.5),a=s.band?"wo-orbit wo-orbit-band wo-orbit-node":"wo-orbit wo-orbit-node",c=`data-render-id="${Ot(s.renderId)}" data-orbit-object-id="${Wt(s.objectId)}" data-parent-id="${Wt(s.parentId)}" data-group-id="${Wt(s.groupId??"")}"`;if(s.backArcPath||s.frontArcPath){s.backArcPath&&i.push(`<path class="${a} wo-orbit-back" d="${s.backArcPath}" stroke-width="${o}" ${c} />`),s.frontArcPath&&r.push(`<path class="${a} wo-orbit-front" d="${s.frontArcPath}" stroke-width="${o}" ${c} />`);continue}if(s.kind==="ellipse"){let l=s.rx??s.radius??0,u=s.ry??s.radius??0;r.push(`<ellipse class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" rx="${l}" ry="${u}" transform="rotate(${s.rotationDeg} ${s.cx} ${s.cy})" stroke-width="${o}" ${c} />`);continue}r.push(`<circle class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" r="${s.radius??0}" stroke-width="${o}" ${c} />`)}return{back:i.join(""),front:r.join("")}}function nS(n){return n.filter(e=>!!e.imageHref).map(e=>aS(e)).join("")}function iS(n,e,t){let{object:i,x:r,y:s,radius:o,visualRadius:a}=n,c=e===n.objectId?" wo-object-selected":"",l=i.properties.kind?` wo-kind-${String(i.properties.kind).toLowerCase().replace(/[^a-z0-9-]/g,"-")}`:"",u=lS(n,t),d=oS(n),h=d?gg(i,r,s,o,u,{outlineOnly:!0}):"";return`<g class="wo-object wo-object-${i.type}${l}${c}" data-object-id="${Ot(n.objectId)}" data-parent-id="${Wt(n.parentId??"")}" data-group-id="${Wt(n.groupId??"")}" data-render-id="${Ot(n.renderId)}" tabindex="0" role="button" aria-label="${Ot(`${i.type} ${n.objectId}`)}">
3911
3911
  <circle class="wo-selection-ring" cx="${r}" cy="${s}" r="${a+8}" />
3912
- ${sM(n,u)}
3912
+ ${sS(n,u)}
3913
3913
  ${gg(i,r,s,o,u)}
3914
3914
  ${d}
3915
3915
  ${h}
3916
- </g>`}function rM(n,e,t){let i=t===e.objectId?" wo-object-label-selected":"",r=n.scaleModel.labelMultiplier;return`<g class="wo-object-label${i}" data-object-id="${kt(e.objectId)}" data-group-id="${qt(e.groupId??"")}" data-render-id="${kt(e.renderId)}">
3917
- <text class="wo-label" x="${e.x}" y="${e.y}" text-anchor="${e.textAnchor}" font-size="${14*r}">${kt(e.label)}</text>
3918
- <text class="wo-label-secondary" x="${e.x}" y="${e.secondaryY}" text-anchor="${e.textAnchor}" font-size="${11*r}">${kt(e.secondaryLabel)}</text>
3916
+ </g>`}function rS(n,e,t){let i=t===e.objectId?" wo-object-label-selected":"",r=n.scaleModel.labelMultiplier;return`<g class="wo-object-label${i}" data-object-id="${Ot(e.objectId)}" data-group-id="${Wt(e.groupId??"")}" data-render-id="${Ot(e.renderId)}">
3917
+ <text class="wo-label" x="${e.x}" y="${e.y}" text-anchor="${e.textAnchor}" font-size="${14*r}">${Ot(e.label)}</text>
3918
+ <text class="wo-label-secondary" x="${e.x}" y="${e.secondaryY}" text-anchor="${e.textAnchor}" font-size="${11*r}">${Ot(e.secondaryLabel)}</text>
3919
3919
  </g>`}function gg(n,e,t,i,r,s={}){let o=s.outlineOnly?"transparent":r.fill,a=r.tail??r.fill;switch(n.type){case"star":return s.outlineOnly?`<circle cx="${e}" cy="${t}" r="${i}" fill="transparent" stroke="${r.stroke}" stroke-width="2" />`:`<circle cx="${e}" cy="${t}" r="${i*2.4}" fill="${r.glow??"url(#wo-star-glow)"}" opacity="0.84" />
3920
3920
  <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="2" />`;case"planet":case"moon":case"belt":case"asteroid":case"ring":return`<circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="${s.outlineOnly?1.5:1.4}" />`;case"comet":return s.outlineOnly?`<circle cx="${e}" cy="${t}" r="${i}" fill="transparent" stroke="${r.stroke}" stroke-width="1.4" />`:`<path d="M ${e-i*2} ${t+i*1.3} Q ${e-i*.7} ${t+i*.3} ${e-i*.45} ${t}" fill="none" stroke="${a}" stroke-width="${Math.max(2,i*.8)}" stroke-linecap="round" opacity="0.85" />
3921
3921
  <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`;case"structure":return`<polygon points="${bg(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`;case"phenomenon":{let c=String(n.properties.kind??"").toLowerCase().replace(/_/g,"-");return s.outlineOnly?c==="black-hole"||c==="nebula"||c==="galaxy"||c==="dwarf-galaxy"?`<circle cx="${e}" cy="${t}" r="${i}" fill="transparent" stroke="${r.stroke}" stroke-width="1.4" />`:`<polygon points="${Ud(e,t,i)}" fill="transparent" stroke="${r.stroke}" stroke-width="1.4" />`:c==="black-hole"?`<ellipse cx="${e}" cy="${t}" rx="${i*2.4}" ry="${i*.55}" fill="none" stroke="${r.accentRing??r.stroke}" stroke-width="3.5" />
@@ -3923,26 +3923,26 @@ void main() {
3923
3923
  <ellipse cx="${e}" cy="${t}" rx="${i*1.5}" ry="${i*.42}" fill="${o}" stroke="${r.stroke}" stroke-width="1.2" />
3924
3924
  <circle cx="${e}" cy="${t}" r="${i*.28}" fill="${r.core??"#fff"}" stroke="none" />`:c==="dwarf-galaxy"?`<ellipse cx="${e}" cy="${t}" rx="${i*1.6}" ry="${i*.55}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />
3925
3925
  <circle cx="${e}" cy="${t}" r="${i*.25}" fill="${r.core??"#fff"}" stroke="none" />`:c==="nebula"?`<circle cx="${e}" cy="${t}" r="${i*2.2}" fill="${r.halo??"none"}" stroke="none" />
3926
- <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />`:`<polygon points="${Ud(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`}}}function sM(n,e){if(!e.atmosphere)return"";let{object:t,x:i,y:r,radius:s}=n;return t.type!=="planet"&&t.type!=="moon"&&t.type!=="asteroid"?"":`<circle cx="${i}" cy="${r}" r="${s+4}" fill="none" stroke="${e.atmosphere}" stroke-width="4" opacity="0.45" />`}function oM(n){if(!n.imageHref)return"";let e=cM(n);return`<image class="wo-object-image" x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" href="${qt(n.imageHref)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#${qt(xg(n))})" />`}function aM(n){let{x:e,y:t,radius:i}=n,r="";switch(n.object.type){case"star":case"planet":case"moon":case"asteroid":case"comet":r=`<circle cx="${e}" cy="${t}" r="${i}" />`;break;case"structure":r=`<polygon points="${bg(e,t,i)}" />`;break;case"phenomenon":r=`<polygon points="${Ud(e,t,i)}" />`;break;default:return""}return`<clipPath id="${qt(xg(n))}" clipPathUnits="userSpaceOnUse">${r}</clipPath>`}function cM(n){let{object:e,x:t,y:i,radius:r}=n;switch(e.type){case"structure":return{x:t-r,y:i-r,width:r*2,height:r*2};case"phenomenon":return{x:t-r*1.2,y:i-r*1.2,width:r*2.4,height:r*2.4};default:return{x:t-r,y:i-r,width:r*2,height:r*2}}}function lM(n,e){let t=String(n.object.properties.kind??"").toLowerCase().replace(/_/g,"-"),i=uM(n.object.type,t,e),r=n.fillColor&&xM(n.fillColor)?n.fillColor:i.fill,s=yg(n.object.properties.albedo),o=yg(n.object.properties.temperature),a=hM(r,o,s,n.object.type),c=Ao(a,"#ffffff",.4)??i.stroke,l=pM(n.object.properties.atmosphere),u=n.object.type==="star"?vg(Ao(a,"#fff2cb",.4)??a,.82):void 0;return{fill:a,stroke:c,glow:u,atmosphere:l,tail:n.object.type==="comet"?vg(Ao(a,"#ffffff",.5)??a,.72):void 0}}function uM(n,e,t){switch(n){case"star":return{fill:t.starCore,stroke:t.starStroke};case"planet":return{fill:"#72b7ff",stroke:"#d8efff"};case"moon":return{fill:"#c7d7ea",stroke:"#f2f8ff"};case"belt":return{fill:"#d9aa74",stroke:"#f7d5aa"};case"asteroid":return{fill:"#a7a5b8",stroke:"#ebe5ff"};case"comet":return{fill:"#9ce7ff",stroke:"#e7fbff"};case"ring":return{fill:"#e59f7d",stroke:"#fff0d3"};case"structure":return{fill:t.accentStrong,stroke:"#fff2ea"};case"phenomenon":return dM(e)}}function dM(n){return n==="galaxy"?{fill:"rgba(165,125,255,0.55)",stroke:"rgba(210,185,255,0.75)",halo:"rgba(160,120,255,0.10)",core:"#ede0ff"}:n==="dwarf-galaxy"?{fill:"rgba(190,165,255,0.45)",stroke:"rgba(220,205,255,0.75)",core:"#ddd0ff"}:n==="black-hole"?{fill:"#040408",stroke:"#ff6a00",accentRing:"rgba(255,140,20,0.72)"}:n==="nebula"?{fill:"rgba(105,205,255,0.45)",stroke:"rgba(180,235,255,0.72)",halo:"rgba(100,200,255,0.08)"}:n==="void"?{fill:"#05080f",stroke:"rgba(130,160,255,0.4)"}:{fill:"#78ffd7",stroke:"#e9fff7"}}function hM(n,e,t,i){let r=n;if(e!==null){let s=fM(e,i);r=Ao(r,s,i==="star"?.42:.2)??r}if(t!==null){let s=Math.min(Math.max(t,0),1);r=Ao(r,s>=.5?"#ffffff":"#0f1520",Math.abs(s-.5)*.7)??r}return r}function fM(n,e){return e==="star"?n>=8e3?"#d7ebff":n>=6e3?"#fff3d8":n>=4e3?"#ffd39a":"#ff9d76":n<=180?"#8fd8ff":n>=600?"#ffb56e":"#fff1c4"}function pM(n){if(typeof n!="string"||!n.trim())return;let e=n.trim().toLowerCase();return e.includes("methane")?"rgba(134, 236, 255, 0.75)":e.includes("nitrogen")||e.includes("oxygen")||e.includes("air")?"rgba(122, 194, 255, 0.75)":e.includes("carbon")||e.includes("co2")?"rgba(255, 198, 138, 0.75)":e.includes("sulfur")?"rgba(255, 233, 138, 0.75)":"rgba(180, 222, 255, 0.68)"}function mM(n){switch(n){case"presentation":return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"atlas-card":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"markdown":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!1}};default:return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}}}}function yg(n){return typeof n=="number"?n:n&&typeof n=="object"&&"value"in n?n.value:null}function xg(n){return`${n.renderId}-clip`}function bg(n,e,t){return`${n},${e-t} ${n+t},${e} ${n},${e+t} ${n-t},${e}`}function Ud(n,e,t){return`${n},${e-t*1.2} ${n+t*.9},${e-t*.3} ${n+t*1.2},${e+t*.8} ${n},${e+t*1.2} ${n-t*1.1},${e+t*.3} ${n-t*.8},${e-t*.8}`}function gM(n,e){let t=Array.from({length:10},(r,s)=>{let o=90+s*((n-180)/9);return`<line class="wo-grid" x1="${o}" y1="120" x2="${o}" y2="${e-70}" />`}).join(""),i=Array.from({length:6},(r,s)=>{let o=150+s*((e-240)/5);return`<line class="wo-grid" x1="56" y1="${o}" x2="${n-56}" y2="${o}" />`}).join("");return`${t}${i}`}function yM(n){return[`${n.layoutPreset} layout`,`${n.viewMode} view`,`${n.renderPreset??"custom"} preset`,`schema ${n.metadata.version??"1.0"}`].join(" - ")}function Mc(n){return n.type==="structure"||n.type==="phenomenon"}function Ao(n,e,t){let i=Nd(n),r=Nd(e);if(!i||!r)return;let s=Math.min(Math.max(t,0),1);return vM({r:Math.round(i.r+(r.r-i.r)*s),g:Math.round(i.g+(r.g-i.g)*s),b:Math.round(i.b+(r.b-i.b)*s)})}function vg(n,e){let t=Nd(n);return t?`rgba(${t.r}, ${t.g}, ${t.b}, ${e})`:n}function Nd(n){let e=n.trim();return/^#[0-9a-f]{6}$/i.test(e)?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:/^#[0-9a-f]{3}$/i.test(e)?{r:Number.parseInt(e[1]+e[1],16),g:Number.parseInt(e[2]+e[2],16),b:Number.parseInt(e[3]+e[3],16)}:null}function vM(n){let e=t=>t.toString(16).padStart(2,"0");return`#${e(n.r)}${e(n.g)}${e(n.b)}`}function xM(n){return!!n.trim()}function kt(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function qt(n){return kt(n)}var rs=180,ss=120,_g=10;function wg(n,e,t){let i=n.contentBounds.width>0&&n.contentBounds.height>0?n.contentBounds:{minX:0,minY:0,maxX:n.width,maxY:n.height,width:n.width,height:n.height,centerX:n.width/2,centerY:n.height/2},r=Math.min((rs-_g*2)/Math.max(i.width,1),(ss-_g*2)/Math.max(i.height,1)),s=(rs-i.width*r)/2-i.minX*r,o=(ss-i.height*r)/2-i.minY*r,a=Eo(n,e),c=t.map(l=>{let u=l.x*r+s,d=l.y*r+o,h=Math.max(1.4,Math.min(l.visualRadius*r,5.2)),f=l.fillColor??bM(l.object.type);return`<circle cx="${On(u)}" cy="${On(d)}" r="${On(h)}" fill="${f}" fill-opacity="0.92" />`}).join("");return`<div data-worldorbit-minimap="true" style="position:absolute;right:16px;bottom:16px;width:${rs}px;height:${ss}px;padding:8px;border-radius:16px;background:rgba(5, 14, 22, 0.78);border:1px solid rgba(179, 216, 255, 0.16);box-shadow:0 14px 28px rgba(0, 0, 0, 0.24);backdrop-filter:blur(8px);pointer-events:none;">
3927
- <svg width="${rs}" height="${ss}" viewBox="0 0 ${rs} ${ss}" role="presentation" aria-hidden="true">
3928
- <rect x="0.5" y="0.5" width="${rs-1}" height="${ss-1}" rx="12" ry="12" fill="rgba(7, 17, 27, 0.85)" stroke="rgba(179, 216, 255, 0.18)" />
3929
- <rect x="${On(i.minX*r+s)}" y="${On(i.minY*r+o)}" width="${On(i.width*r)}" height="${On(i.height*r)}" rx="10" ry="10" fill="rgba(163, 209, 255, 0.04)" stroke="rgba(163, 209, 255, 0.16)" />
3926
+ <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />`:`<polygon points="${Ud(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`}}}function sS(n,e){if(!e.atmosphere)return"";let{object:t,x:i,y:r,radius:s}=n;return t.type!=="planet"&&t.type!=="moon"&&t.type!=="asteroid"?"":`<circle cx="${i}" cy="${r}" r="${s+4}" fill="none" stroke="${e.atmosphere}" stroke-width="4" opacity="0.45" />`}function oS(n){if(!n.imageHref)return"";let e=cS(n);return`<image class="wo-object-image" x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" href="${Wt(n.imageHref)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#${Wt(xg(n))})" />`}function aS(n){let{x:e,y:t,radius:i}=n,r="";switch(n.object.type){case"star":case"planet":case"moon":case"asteroid":case"comet":r=`<circle cx="${e}" cy="${t}" r="${i}" />`;break;case"structure":r=`<polygon points="${bg(e,t,i)}" />`;break;case"phenomenon":r=`<polygon points="${Ud(e,t,i)}" />`;break;default:return""}return`<clipPath id="${Wt(xg(n))}" clipPathUnits="userSpaceOnUse">${r}</clipPath>`}function cS(n){let{object:e,x:t,y:i,radius:r}=n;switch(e.type){case"structure":return{x:t-r,y:i-r,width:r*2,height:r*2};case"phenomenon":return{x:t-r*1.2,y:i-r*1.2,width:r*2.4,height:r*2.4};default:return{x:t-r,y:i-r,width:r*2,height:r*2}}}function lS(n,e){let t=String(n.object.properties.kind??"").toLowerCase().replace(/_/g,"-"),i=uS(n.object.type,t,e),r=n.fillColor&&xS(n.fillColor)?n.fillColor:i.fill,s=yg(n.object.properties.albedo),o=yg(n.object.properties.temperature),a=hS(r,o,s,n.object.type),c=Ao(a,"#ffffff",.4)??i.stroke,l=pS(n.object.properties.atmosphere),u=n.object.type==="star"?vg(Ao(a,"#fff2cb",.4)??a,.82):void 0;return{fill:a,stroke:c,glow:u,atmosphere:l,tail:n.object.type==="comet"?vg(Ao(a,"#ffffff",.5)??a,.72):void 0}}function uS(n,e,t){switch(n){case"star":return{fill:t.starCore,stroke:t.starStroke};case"planet":return{fill:"#72b7ff",stroke:"#d8efff"};case"moon":return{fill:"#c7d7ea",stroke:"#f2f8ff"};case"belt":return{fill:"#d9aa74",stroke:"#f7d5aa"};case"asteroid":return{fill:"#a7a5b8",stroke:"#ebe5ff"};case"comet":return{fill:"#9ce7ff",stroke:"#e7fbff"};case"ring":return{fill:"#e59f7d",stroke:"#fff0d3"};case"structure":return{fill:t.accentStrong,stroke:"#fff2ea"};case"phenomenon":return dS(e)}}function dS(n){return n==="galaxy"?{fill:"rgba(165,125,255,0.55)",stroke:"rgba(210,185,255,0.75)",halo:"rgba(160,120,255,0.10)",core:"#ede0ff"}:n==="dwarf-galaxy"?{fill:"rgba(190,165,255,0.45)",stroke:"rgba(220,205,255,0.75)",core:"#ddd0ff"}:n==="black-hole"?{fill:"#040408",stroke:"#ff6a00",accentRing:"rgba(255,140,20,0.72)"}:n==="nebula"?{fill:"rgba(105,205,255,0.45)",stroke:"rgba(180,235,255,0.72)",halo:"rgba(100,200,255,0.08)"}:n==="void"?{fill:"#05080f",stroke:"rgba(130,160,255,0.4)"}:{fill:"#78ffd7",stroke:"#e9fff7"}}function hS(n,e,t,i){let r=n;if(e!==null){let s=fS(e,i);r=Ao(r,s,i==="star"?.42:.2)??r}if(t!==null){let s=Math.min(Math.max(t,0),1);r=Ao(r,s>=.5?"#ffffff":"#0f1520",Math.abs(s-.5)*.7)??r}return r}function fS(n,e){return e==="star"?n>=8e3?"#d7ebff":n>=6e3?"#fff3d8":n>=4e3?"#ffd39a":"#ff9d76":n<=180?"#8fd8ff":n>=600?"#ffb56e":"#fff1c4"}function pS(n){if(typeof n!="string"||!n.trim())return;let e=n.trim().toLowerCase();return e.includes("methane")?"rgba(134, 236, 255, 0.75)":e.includes("nitrogen")||e.includes("oxygen")||e.includes("air")?"rgba(122, 194, 255, 0.75)":e.includes("carbon")||e.includes("co2")?"rgba(255, 198, 138, 0.75)":e.includes("sulfur")?"rgba(255, 233, 138, 0.75)":"rgba(180, 222, 255, 0.68)"}function mS(n){switch(n){case"presentation":return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"atlas-card":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"markdown":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!1}};default:return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}}}}function yg(n){return typeof n=="number"?n:n&&typeof n=="object"&&"value"in n?n.value:null}function xg(n){return`${n.renderId}-clip`}function bg(n,e,t){return`${n},${e-t} ${n+t},${e} ${n},${e+t} ${n-t},${e}`}function Ud(n,e,t){return`${n},${e-t*1.2} ${n+t*.9},${e-t*.3} ${n+t*1.2},${e+t*.8} ${n},${e+t*1.2} ${n-t*1.1},${e+t*.3} ${n-t*.8},${e-t*.8}`}function gS(n,e){let t=Array.from({length:10},(r,s)=>{let o=90+s*((n-180)/9);return`<line class="wo-grid" x1="${o}" y1="120" x2="${o}" y2="${e-70}" />`}).join(""),i=Array.from({length:6},(r,s)=>{let o=150+s*((e-240)/5);return`<line class="wo-grid" x1="56" y1="${o}" x2="${n-56}" y2="${o}" />`}).join("");return`${t}${i}`}function yS(n){return[`${n.layoutPreset} layout`,`${n.viewMode} view`,`${n.renderPreset??"custom"} preset`,`schema ${n.metadata.version??"1.0"}`].join(" - ")}function Sc(n){return n.type==="structure"||n.type==="phenomenon"}function Ao(n,e,t){let i=Nd(n),r=Nd(e);if(!i||!r)return;let s=Math.min(Math.max(t,0),1);return vS({r:Math.round(i.r+(r.r-i.r)*s),g:Math.round(i.g+(r.g-i.g)*s),b:Math.round(i.b+(r.b-i.b)*s)})}function vg(n,e){let t=Nd(n);return t?`rgba(${t.r}, ${t.g}, ${t.b}, ${e})`:n}function Nd(n){let e=n.trim();return/^#[0-9a-f]{6}$/i.test(e)?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:/^#[0-9a-f]{3}$/i.test(e)?{r:Number.parseInt(e[1]+e[1],16),g:Number.parseInt(e[2]+e[2],16),b:Number.parseInt(e[3]+e[3],16)}:null}function vS(n){let e=t=>t.toString(16).padStart(2,"0");return`#${e(n.r)}${e(n.g)}${e(n.b)}`}function xS(n){return!!n.trim()}function Ot(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Wt(n){return Ot(n)}var os=180,as=120,_g=10;function wg(n,e,t){let i=n.contentBounds.width>0&&n.contentBounds.height>0?n.contentBounds:{minX:0,minY:0,maxX:n.width,maxY:n.height,width:n.width,height:n.height,centerX:n.width/2,centerY:n.height/2},r=Math.min((os-_g*2)/Math.max(i.width,1),(as-_g*2)/Math.max(i.height,1)),s=(os-i.width*r)/2-i.minX*r,o=(as-i.height*r)/2-i.minY*r,a=Eo(n,e),c=t.map(l=>{let u=l.x*r+s,d=l.y*r+o,h=Math.max(1.4,Math.min(l.visualRadius*r,5.2)),f=l.fillColor??bS(l.object.type);return`<circle cx="${Pn(u)}" cy="${Pn(d)}" r="${Pn(h)}" fill="${f}" fill-opacity="0.92" />`}).join("");return`<div data-worldorbit-minimap="true" style="position:absolute;right:16px;bottom:16px;width:${os}px;height:${as}px;padding:8px;border-radius:16px;background:rgba(5, 14, 22, 0.78);border:1px solid rgba(179, 216, 255, 0.16);box-shadow:0 14px 28px rgba(0, 0, 0, 0.24);backdrop-filter:blur(8px);pointer-events:none;">
3927
+ <svg width="${os}" height="${as}" viewBox="0 0 ${os} ${as}" role="presentation" aria-hidden="true">
3928
+ <rect x="0.5" y="0.5" width="${os-1}" height="${as-1}" rx="12" ry="12" fill="rgba(7, 17, 27, 0.85)" stroke="rgba(179, 216, 255, 0.18)" />
3929
+ <rect x="${Pn(i.minX*r+s)}" y="${Pn(i.minY*r+o)}" width="${Pn(i.width*r)}" height="${Pn(i.height*r)}" rx="10" ry="10" fill="rgba(163, 209, 255, 0.04)" stroke="rgba(163, 209, 255, 0.16)" />
3930
3930
  ${c}
3931
- <rect x="${On(a.minX*r+s)}" y="${On(a.minY*r+o)}" width="${On(a.width*r)}" height="${On(a.height*r)}" rx="8" ry="8" fill="rgba(255, 180, 100, 0.09)" stroke="rgba(255, 180, 100, 0.88)" stroke-width="1.4" />
3931
+ <rect x="${Pn(a.minX*r+s)}" y="${Pn(a.minY*r+o)}" width="${Pn(a.width*r)}" height="${Pn(a.height*r)}" rx="8" ry="8" fill="rgba(255, 180, 100, 0.09)" stroke="rgba(255, 180, 100, 0.88)" stroke-width="1.4" />
3932
3932
  </svg>
3933
- </div>`}function bM(n){switch(n){case"star":return"#ffcc67";case"planet":return"#72b7ff";case"moon":return"#c7d7ea";case"belt":case"ring":return"#d9aa74";case"asteroid":return"#a7a5b8";case"comet":return"#9ce7ff";case"structure":return"#ff7f5f";case"phenomenon":return"#78ffd7"}}function On(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var u2="wo-viewer-3d-root",Np=null;function Lv(n){g2();let e=document.createElement("div");e.className=u2,e.dataset.worldorbit3d="true",e.innerHTML='<div class="wo-viewer-3d-loading">Loading 3D view...</div>',n.innerHTML="",n.append(e);let t=null,i=null,r=null,s=null,o=new Set,a=null,c=null,l=0,u=new Map,d=null,h=!1,f=new Map,p=new Map,y=[];return x2().then(_=>{if(h)return;let b=new _.Scene,D=new _.PerspectiveCamera(52,1,.1,2e4),z=new _.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});z.domElement.classList.add("wo-viewer-3d-canvas"),z.domElement.dataset.worldorbit3dCanvas="true",e.innerHTML="",e.append(z.domElement);let F=new _.AmbientLight(16777215,1.2),$=new _.PointLight(16777215,1.35,0,2);b.add(F),b.add($);let W=new _.Group,ne=new _.Group;b.add(W),b.add(ne);let J=new _.Raycaster;J.params.Line={threshold:10},t={THREE:_,scene3d:b,camera:D,renderer:z,keyLight:$,orbitLayer:W,objectLayer:ne,raycaster:J,pointer:new _.Vector2},d&&g(d)}).catch(_=>{h||(e.innerHTML=`<div class="wo-viewer-3d-loading is-error">${v2(_ instanceof Error?_.message:"WorldOrbit 3D could not be initialized.")}</div>`)}),{update(_){d=_,g(_)},hitTest(_,b){if(!t||!i)return null;let D=t.renderer.domElement.getBoundingClientRect();if(!D.width||!D.height)return null;t.pointer.x=(_-D.left)/D.width*2-1,t.pointer.y=-((b-D.top)/D.height)*2+1,t.raycaster.setFromCamera(t.pointer,t.camera);let z=t.raycaster.intersectObjects(y,!0);for(let F of z){let $=y2(F.object);if($)return $}return null},projectObjectToContainer(_){if(!t)return null;let b=u.get(_);if(!b)return null;let D=new t.THREE.Vector3(b.x,b.y,b.z);if(D.project(t.camera),D.z>1)return null;let z=t.renderer.domElement.getBoundingClientRect(),F=n.getBoundingClientRect();return{x:z.left-F.left+(D.x+1)/2*z.width,y:z.top-F.top+(1-D.y)/2*z.height}},destroy(){h=!0,d=null,t?.renderer.dispose(),e.remove(),f.clear(),p.clear(),y.length=0,t=null}};function g(_){if(!t)return;let b=i!==_.spatialScene;i=_.spatialScene,r=_.renderOptions,s=_.state,o=_.visibleObjectIds,a=_.selectedObjectId,c=_.hoveredObjectId,l=_.timeSeconds,b&&m(_.spatialScene),R(_.spatialScene),u=od(_.spatialScene,_.timeSeconds),v(),x(),w(),O(),I(),U()}function m(_){if(!t)return;Pv(t.orbitLayer),Pv(t.objectLayer),f.clear(),p.clear(),y.length=0;let b=Mo(r?.theme);t.scene3d.background=new t.THREE.Color(b.backgroundStart);for(let D of _.orbits){let z=h2(t.THREE,D,b);t.orbitLayer.add(z.root),p.set(D.objectId,z),y.push(z.root)}for(let D of _.objects){let z=d2(t.THREE,D,b);t.objectLayer.add(z.root),f.set(D.objectId,z),y.push(z.root)}}function v(){for(let _ of i?.objects??[]){let b=f.get(_.objectId),D=u.get(_.objectId);!b||!D||b.root.position.set(D.x,D.y,D.z)}}function x(){for(let _ of i?.orbits??[]){let b=p.get(_.objectId);if(!b)continue;let D=u.get(_.parentId);b.root.position.set(D?.x??_.center.x,D?.y??_.center.y,D?.z??_.center.z)}}function w(){let _=r?.layers??{};for(let b of i?.objects??[]){let D=f.get(b.objectId);if(!D)continue;let z=_.structures===!1&&(b.object.type==="structure"||b.object.type==="phenomenon"),F=_.objects===!1;D.root.visible=!b.hidden&&o.has(b.objectId)&&!z&&!F}for(let b of i?.orbits??[]){let D=p.get(b.objectId);if(!D)continue;let z=_.structures===!1&&(b.object.type==="structure"||b.object.type==="phenomenon");D.root.visible=!b.hidden&&o.has(b.objectId)&&_.orbits!==!1&&!z}}function O(){if(t){for(let _ of f.values()){Rv(t.THREE,_.materials,_.baseColor,a===_.objectId,c===_.objectId);let b=a===_.objectId?1.2:c===_.objectId?1.1:1;_.root.scale.set(b,b,b)}for(let _ of p.values())Rv(t.THREE,_.materials,_.baseColor,a===_.objectId,c===_.objectId)}}function I(){if(!t||!i||!s)return;let _=r?.camera??i.camera,b=i.contentBounds,D=Math.max(b.width,b.depth,b.height,160),z=Fa((_?.azimuth??34)+s.rotationDeg),F=Fa(zu(_?.elevation??24,-75,75)),$=zu(2.4/Math.max(s.scale,.1),.35,8),W=zu(_?.distance??6,2,24),ne=zu(D*$*(W/6),28,8e3),J=Math.max(D/900,.12),V=new t.THREE.Vector3(b.center.x-s.translateX*J,b.center.y,b.center.z-s.translateY*J);t.camera.position.set(V.x+ne*Math.cos(F)*Math.sin(z),V.y+ne*Math.sin(F),V.z+ne*Math.cos(F)*Math.cos(z)),t.camera.lookAt(V),_?.roll&&(t.camera.rotation.z=Fa(_.roll)),t.keyLight.position.copy(t.camera.position)}function R(_){if(!t)return;let b=Math.max(1,Math.round(n.clientWidth||_.width||960)),D=Math.max(1,Math.round(n.clientHeight||_.height||560));t.renderer.setSize(b,D,!1),t.camera.aspect=b/D,t.camera.updateProjectionMatrix()}function U(){t&&t.renderer.render(t.scene3d,t.camera)}}function d2(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId;let r=e.fillColor??m2(e),s=new n.MeshPhongMaterial({color:r,emissive:e.object.type==="star"?new n.Color(t.starGlow):new n.Color(0),emissiveIntensity:e.object.type==="star"?.6:.08,transparent:!0,opacity:e.object.type==="phenomenon"?.7:1}),o=f2(n,e),a=new n.Mesh(o,s);return a.userData.objectId=e.objectId,i.add(a),{objectId:e.objectId,root:i,body:a,materials:[s],baseColor:r}}function h2(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId,i.rotation.y=Fa(e.rotationDeg),i.rotation.x=Fa(e.inclinationDeg);let r=e.object.properties.color??t.orbit,s=[];if(e.band){let o=new n.MeshBasicMaterial({color:r,transparent:!0,opacity:.42,side:2}),a=p2(n,e),c=new n.Mesh(a,o);c.userData.objectId=e.objectId,i.add(c),s.push(o)}else{let o=new n.LineBasicMaterial({color:r,transparent:!0,opacity:.55}),a=Dv(n,e),c=new n.BufferGeometry().setFromPoints(a),l=new n.LineLoop(c,o);l.userData.objectId=e.objectId,i.add(l),s.push(o)}return{objectId:e.objectId,root:i,materials:s,baseColor:r}}function f2(n,e){let t=Math.max(e.visualRadius,2);switch(e.object.type){case"star":return new n.SphereGeometry(t*1.12,28,20);case"structure":return new n.BoxGeometry(t*1.5,t*1.5,t*1.5);case"phenomenon":return new n.OctahedronGeometry(t*1.25,0);case"belt":case"ring":return new n.OctahedronGeometry(Math.max(t*.85,3),0);default:return new n.SphereGeometry(t,20,14)}}function p2(n,e){let t=Math.max(e.bandThickness??8,3),i=Dv(n,e,72),r=new n.CatmullRomCurve3(i,!0);return new n.TubeGeometry(r,128,t*.28,10,!0)}function Dv(n,e,t=96){let i=[],r=Math.max(e.semiMajor,e.radius??1,1),s=Math.max(e.semiMinor,e.radius??1,1);for(let o=0;o<t;o+=1){let a=o/t*Math.PI*2;i.push(new n.Vector3(Math.cos(a)*r,0,Math.sin(a)*s))}return i}function m2(n){switch(n.object.type){case"star":return"#ffd36a";case"planet":return"#73b6ff";case"moon":return"#d8dde8";case"belt":return"#b8926a";case"ring":return"#cdbf9a";case"structure":return"#ffce8a";case"phenomenon":return"#7ce6ff";case"asteroid":return"#cdb5a1";case"comet":return"#b8f2ff"}}function Rv(n,e,t,i,r){let s=new n.Color(t);i?s.offsetHSL(0,0,.16):r&&s.offsetHSL(0,0,.08);for(let o of e)o&&(o.color?.set?.(s),typeof o.opacity=="number"&&(o.opacity=i?.85:r?.72:o.transparent?.55:1),o.emissive?.set?.(i?new n.Color("#ffdda9"):r?new n.Color("#cfe9ff"):new n.Color(0)),o.emissiveIntensity=i?.28:r?.14:o.emissiveIntensity??.08)}function Pv(n){for(;n.children.length>0;){let e=n.children[0];n.remove(e),e.geometry?.dispose?.(),Array.isArray(e.material)?e.material.forEach(t=>t?.dispose?.()):e.material?.dispose?.()}}function g2(){if(typeof document>"u")throw new oi;let n=document.defaultView?.navigator??globalThis.window?.navigator??(typeof navigator<"u"?navigator:void 0);if(/jsdom/i.test(n?.userAgent??""))throw new oi("WorldOrbit 3D needs WebGL support, but this environment did not provide it.");let e=document.createElement("canvas"),t=r=>{try{return e.getContext?.(r)??null}catch{return null}};if(!(t("webgl2")??t("webgl")??t("experimental-webgl")))throw new oi("WorldOrbit 3D needs WebGL support, but this environment did not provide it.")}function y2(n){let e=n;for(;e;){if(typeof e.userData?.objectId=="string")return e.userData.objectId;e=e.parent}return null}function zu(n,e,t){return Math.min(Math.max(n,e),t)}function Fa(n){return n*Math.PI/180}function v2(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function x2(){return Np||(Np=Promise.resolve().then(()=>(Cv(),Iv))),Np}var b2=["radius","temperature","atmosphere","period","semiMajor","distance","eccentricity","angle","inclination","phase","albedo","mass","density","gravity"];function Uv(n){return{objectId:n.objectId,title:n.objectId,typeLabel:E2(n.object.type),imageHref:n.renderObject.imageHref??null,description:M2(n),tags:w2(n.object.properties.tags),fields:_2(n),parentLabel:n.parent?.objectId??null,orbitLabel:n.orbit?.parentId??null,details:n}}function Nv(n,e){let t=n.tags.length?`<div class="wo-tooltip-tags">${n.tags.map(s=>`<span class="wo-tooltip-tag">${Qn(s)}</span>`).join("")}</div>`:"",i=n.fields.length?`<dl class="wo-tooltip-fields">${n.fields.map(s=>`<div class="wo-tooltip-field"><dt>${Qn(s.label)}</dt><dd>${Qn(s.value)}</dd></div>`).join("")}</dl>`:"",r=[n.parentLabel?`Parent: ${n.parentLabel}`:null,n.orbitLabel?`Orbit: ${n.orbitLabel}`:null,e==="pinned"?"Pinned tooltip":"Hover tooltip"].filter(Boolean);return`<article class="wo-tooltip-card" data-tooltip-object-id="${Qn(n.objectId)}">
3933
+ </div>`}function bS(n){switch(n){case"star":return"#ffcc67";case"planet":return"#72b7ff";case"moon":return"#c7d7ea";case"belt":case"ring":return"#d9aa74";case"asteroid":return"#a7a5b8";case"comet":return"#9ce7ff";case"structure":return"#ff7f5f";case"phenomenon":return"#78ffd7"}}function Pn(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var u2="wo-viewer-3d-root",Np=null;function Lv(n){g2();let e=document.createElement("div");e.className=u2,e.dataset.worldorbit3d="true",e.innerHTML='<div class="wo-viewer-3d-loading">Loading 3D view...</div>',n.innerHTML="",n.append(e);let t=null,i=null,r=null,s=null,o=new Set,a=null,c=null,l=0,u=new Map,d=null,h=!1,f=new Map,p=new Map,y=[];return x2().then(w=>{if(h)return;let b=new w.Scene,O=new w.PerspectiveCamera(52,1,.1,2e4),B=new w.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});B.domElement.classList.add("wo-viewer-3d-canvas"),B.domElement.dataset.worldorbit3dCanvas="true",e.innerHTML="",e.append(B.domElement);let F=new w.AmbientLight(16777215,1.2),H=new w.PointLight(16777215,1.35,0,2);b.add(F),b.add(H);let X=new w.Group,ee=new w.Group;b.add(X),b.add(ee);let ce=new w.Raycaster;ce.params.Line={threshold:10},t={THREE:w,scene3d:b,camera:O,renderer:B,keyLight:H,orbitLayer:X,objectLayer:ee,raycaster:ce,pointer:new w.Vector2},d&&g(d)}).catch(w=>{h||(e.innerHTML=`<div class="wo-viewer-3d-loading is-error">${v2(w instanceof Error?w.message:"WorldOrbit 3D could not be initialized.")}</div>`)}),{update(w){d=w,g(w)},hitTest(w,b){if(!t||!i)return null;let O=t.renderer.domElement.getBoundingClientRect();if(!O.width||!O.height)return null;t.pointer.x=(w-O.left)/O.width*2-1,t.pointer.y=-((b-O.top)/O.height)*2+1,t.raycaster.setFromCamera(t.pointer,t.camera);let B=t.raycaster.intersectObjects(y,!0);for(let F of B){let H=y2(F.object);if(H)return H}return null},projectObjectToContainer(w){if(!t)return null;let b=u.get(w);if(!b)return null;let O=new t.THREE.Vector3(b.x,b.y,b.z);if(O.project(t.camera),O.z>1)return null;let B=t.renderer.domElement.getBoundingClientRect(),F=n.getBoundingClientRect();return{x:B.left-F.left+(O.x+1)/2*B.width,y:B.top-F.top+(1-O.y)/2*B.height}},destroy(){h=!0,d=null,t?.renderer.dispose(),e.remove(),f.clear(),p.clear(),y.length=0,t=null}};function g(w){if(!t)return;let b=i!==w.spatialScene;i=w.spatialScene,r=w.renderOptions,s=w.state,o=w.visibleObjectIds,a=w.selectedObjectId,c=w.hoveredObjectId,l=w.timeSeconds,b&&m(w.spatialScene),R(w.spatialScene),u=od(w.spatialScene,w.timeSeconds),x(),v(),M(),U(),C(),N()}function m(w){if(!t)return;Pv(t.orbitLayer),Pv(t.objectLayer),f.clear(),p.clear(),y.length=0;let b=So(r?.theme);t.scene3d.background=new t.THREE.Color(b.backgroundStart);for(let O of w.orbits){let B=h2(t.THREE,O,b);t.orbitLayer.add(B.root),p.set(O.objectId,B),y.push(B.root)}for(let O of w.objects){let B=d2(t.THREE,O,b);t.objectLayer.add(B.root),f.set(O.objectId,B),y.push(B.root)}}function x(){for(let w of i?.objects??[]){let b=f.get(w.objectId),O=u.get(w.objectId);!b||!O||b.root.position.set(O.x,O.y,O.z)}}function v(){for(let w of i?.orbits??[]){let b=p.get(w.objectId);if(!b)continue;let O=u.get(w.parentId);b.root.position.set(O?.x??w.center.x,O?.y??w.center.y,O?.z??w.center.z)}}function M(){let w=r?.layers??{};for(let b of i?.objects??[]){let O=f.get(b.objectId);if(!O)continue;let B=w.structures===!1&&(b.object.type==="structure"||b.object.type==="phenomenon"),F=w.objects===!1;O.root.visible=!b.hidden&&o.has(b.objectId)&&!B&&!F}for(let b of i?.orbits??[]){let O=p.get(b.objectId);if(!O)continue;let B=w.structures===!1&&(b.object.type==="structure"||b.object.type==="phenomenon");O.root.visible=!b.hidden&&o.has(b.objectId)&&w.orbits!==!1&&!B}}function U(){if(t){for(let w of f.values()){Rv(t.THREE,w.materials,w.baseColor,a===w.objectId,c===w.objectId);let b=a===w.objectId?1.2:c===w.objectId?1.1:1;w.root.scale.set(b,b,b)}for(let w of p.values())Rv(t.THREE,w.materials,w.baseColor,a===w.objectId,c===w.objectId)}}function C(){if(!t||!i||!s)return;let w=r?.camera??i.camera,b=i.contentBounds,O=Math.max(b.width,b.depth,b.height,160),B=Fa((w?.azimuth??34)+s.rotationDeg),F=Fa(zu(w?.elevation??24,-75,75)),H=zu(2.4/Math.max(s.scale,.1),.35,8),X=zu(w?.distance??6,2,24),ee=zu(O*H*(X/6),28,8e3),ce=Math.max(O/900,.12),k=new t.THREE.Vector3(b.center.x-s.translateX*ce,b.center.y,b.center.z-s.translateY*ce);t.camera.position.set(k.x+ee*Math.cos(F)*Math.sin(B),k.y+ee*Math.sin(F),k.z+ee*Math.cos(F)*Math.cos(B)),t.camera.lookAt(k),w?.roll&&(t.camera.rotation.z=Fa(w.roll)),t.keyLight.position.copy(t.camera.position)}function R(w){if(!t)return;let b=Math.max(1,Math.round(n.clientWidth||w.width||960)),O=Math.max(1,Math.round(n.clientHeight||w.height||560));t.renderer.setSize(b,O,!1),t.camera.aspect=b/O,t.camera.updateProjectionMatrix()}function N(){t&&t.renderer.render(t.scene3d,t.camera)}}function d2(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId;let r=e.fillColor??m2(e),s=new n.MeshPhongMaterial({color:r,emissive:e.object.type==="star"?new n.Color(t.starGlow):new n.Color(0),emissiveIntensity:e.object.type==="star"?.6:.08,transparent:!0,opacity:e.object.type==="phenomenon"?.7:1}),o=f2(n,e),a=new n.Mesh(o,s);return a.userData.objectId=e.objectId,i.add(a),{objectId:e.objectId,root:i,body:a,materials:[s],baseColor:r}}function h2(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId,i.rotation.y=Fa(e.rotationDeg),i.rotation.x=Fa(e.inclinationDeg);let r=e.object.properties.color??t.orbit,s=[];if(e.band){let o=new n.MeshBasicMaterial({color:r,transparent:!0,opacity:.42,side:2}),a=p2(n,e),c=new n.Mesh(a,o);c.userData.objectId=e.objectId,i.add(c),s.push(o)}else{let o=new n.LineBasicMaterial({color:r,transparent:!0,opacity:.55}),a=Dv(n,e),c=new n.BufferGeometry().setFromPoints(a),l=new n.LineLoop(c,o);l.userData.objectId=e.objectId,i.add(l),s.push(o)}return{objectId:e.objectId,root:i,materials:s,baseColor:r}}function f2(n,e){let t=Math.max(e.visualRadius,2);switch(e.object.type){case"star":return new n.SphereGeometry(t*1.12,28,20);case"structure":return new n.BoxGeometry(t*1.5,t*1.5,t*1.5);case"phenomenon":return new n.OctahedronGeometry(t*1.25,0);case"belt":case"ring":return new n.OctahedronGeometry(Math.max(t*.85,3),0);default:return new n.SphereGeometry(t,20,14)}}function p2(n,e){let t=Math.max(e.bandThickness??8,3),i=Dv(n,e,72),r=new n.CatmullRomCurve3(i,!0);return new n.TubeGeometry(r,128,t*.28,10,!0)}function Dv(n,e,t=96){let i=[],r=Math.max(e.semiMajor,e.radius??1,1),s=Math.max(e.semiMinor,e.radius??1,1);for(let o=0;o<t;o+=1){let a=o/t*Math.PI*2;i.push(new n.Vector3(Math.cos(a)*r,0,Math.sin(a)*s))}return i}function m2(n){switch(n.object.type){case"star":return"#ffd36a";case"planet":return"#73b6ff";case"moon":return"#d8dde8";case"belt":return"#b8926a";case"ring":return"#cdbf9a";case"structure":return"#ffce8a";case"phenomenon":return"#7ce6ff";case"asteroid":return"#cdb5a1";case"comet":return"#b8f2ff"}}function Rv(n,e,t,i,r){let s=new n.Color(t);i?s.offsetHSL(0,0,.16):r&&s.offsetHSL(0,0,.08);for(let o of e)o&&(o.color?.set?.(s),typeof o.opacity=="number"&&(o.opacity=i?.85:r?.72:o.transparent?.55:1),o.emissive?.set?.(i?new n.Color("#ffdda9"):r?new n.Color("#cfe9ff"):new n.Color(0)),o.emissiveIntensity=i?.28:r?.14:o.emissiveIntensity??.08)}function Pv(n){for(;n.children.length>0;){let e=n.children[0];n.remove(e),e.geometry?.dispose?.(),Array.isArray(e.material)?e.material.forEach(t=>t?.dispose?.()):e.material?.dispose?.()}}function g2(){if(typeof document>"u")throw new ri;let n=document.defaultView?.navigator??globalThis.window?.navigator??(typeof navigator<"u"?navigator:void 0);if(/jsdom/i.test(n?.userAgent??""))throw new ri("WorldOrbit 3D needs WebGL support, but this environment did not provide it.");let e=document.createElement("canvas"),t=r=>{try{return e.getContext?.(r)??null}catch{return null}};if(!(t("webgl2")??t("webgl")??t("experimental-webgl")))throw new ri("WorldOrbit 3D needs WebGL support, but this environment did not provide it.")}function y2(n){let e=n;for(;e;){if(typeof e.userData?.objectId=="string")return e.userData.objectId;e=e.parent}return null}function zu(n,e,t){return Math.min(Math.max(n,e),t)}function Fa(n){return n*Math.PI/180}function v2(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function x2(){return Np||(Np=Promise.resolve().then(()=>(Cv(),Iv))),Np}var b2=["radius","temperature","atmosphere","period","semiMajor","distance","eccentricity","angle","inclination","phase","albedo","mass","density","gravity"];function Uv(n){return{objectId:n.objectId,title:n.objectId,typeLabel:E2(n.object.type),imageHref:n.renderObject.imageHref??null,description:S2(n),tags:w2(n.object.properties.tags),fields:_2(n),parentLabel:n.parent?.objectId??null,orbitLabel:n.orbit?.parentId??null,details:n}}function Nv(n,e){let t=n.tags.length?`<div class="wo-tooltip-tags">${n.tags.map(s=>`<span class="wo-tooltip-tag">${Jn(s)}</span>`).join("")}</div>`:"",i=n.fields.length?`<dl class="wo-tooltip-fields">${n.fields.map(s=>`<div class="wo-tooltip-field"><dt>${Jn(s.label)}</dt><dd>${Jn(s.value)}</dd></div>`).join("")}</dl>`:"",r=[n.parentLabel?`Parent: ${n.parentLabel}`:null,n.orbitLabel?`Orbit: ${n.orbitLabel}`:null,e==="pinned"?"Pinned tooltip":"Hover tooltip"].filter(Boolean);return`<article class="wo-tooltip-card" data-tooltip-object-id="${Jn(n.objectId)}">
3934
3934
  <div class="wo-tooltip-head">
3935
- ${n.imageHref?`<img class="wo-tooltip-image" src="${T2(n.imageHref)}" alt="" />`:`<div class="wo-tooltip-image wo-tooltip-image-placeholder">${Qn(n.typeLabel.slice(0,1))}</div>`}
3935
+ ${n.imageHref?`<img class="wo-tooltip-image" src="${T2(n.imageHref)}" alt="" />`:`<div class="wo-tooltip-image wo-tooltip-image-placeholder">${Jn(n.typeLabel.slice(0,1))}</div>`}
3936
3936
  <div class="wo-tooltip-heading">
3937
- <strong>${Qn(n.title)}</strong>
3938
- <span>${Qn(n.typeLabel)}</span>
3937
+ <strong>${Jn(n.title)}</strong>
3938
+ <span>${Jn(n.typeLabel)}</span>
3939
3939
  </div>
3940
3940
  </div>
3941
- ${n.description?`<p class="wo-tooltip-description">${Qn(n.description)}</p>`:""}
3941
+ ${n.description?`<p class="wo-tooltip-description">${Jn(n.description)}</p>`:""}
3942
3942
  ${t}
3943
3943
  ${i}
3944
- ${r.length?`<p class="wo-tooltip-relations">${Qn(r.join(" - "))}</p>`:""}
3945
- </article>`}function _2(n){let e=new Map;for(let i of b2){let r=n.object.properties[i];r!==void 0&&e.set(i,{key:i,label:A2(i),value:Ov(r)})}let t=n.object.placement;return n.object.groups?.length&&e.set("groups",{key:"groups",label:"Groups",value:n.object.groups.join(", ")}),n.object.epoch&&e.set("epoch",{key:"epoch",label:"Epoch",value:n.object.epoch}),n.object.referencePlane&&e.set("referencePlane",{key:"referencePlane",label:"Reference Plane",value:n.object.referencePlane}),n.object.tidalLock!==void 0&&e.set("tidalLock",{key:"tidalLock",label:"Tidal Lock",value:n.object.tidalLock?"true":"false"}),n.object.resonance&&e.set("resonance",{key:"resonance",label:"Resonance",value:`${n.object.resonance.targetObjectId} ${n.object.resonance.ratio}`}),n.relatedEvents.length>0&&e.set("events",{key:"events",label:"Events",value:n.relatedEvents.map(i=>i.event.label||i.event.id).join(", ")}),t?.mode==="at"?e.set("placement",{key:"placement",label:"Placement",value:`At ${t.target}`}):t?.mode==="surface"?e.set("placement",{key:"placement",label:"Placement",value:`Surface ${t.target}`}):t?.mode==="free"&&e.set("placement",{key:"placement",label:"Placement",value:t.distance?`Free ${Ov(t.distance)}`:`Free ${t.descriptor??"custom"}`}),[...e.values()]}function w2(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function M2(n){let e=n.object.info.description?.trim();if(e)return e;let t=n.group?.label?.trim();return t&&t!==n.objectId?t:null}function Ov(n){return typeof n=="string"?n:typeof n=="number"?String(n):typeof n=="boolean"?n?"true":"false":Array.isArray(n)?n.join(", "):S2(n)}function S2(n){return`${n.value}${n.unit??""}`}function E2(n){return n.charAt(0).toUpperCase()+n.slice(1)}function A2(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase())}function Qn(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function T2(n){return Qn(n)}var qs={minScale:.2,maxScale:8,fitPadding:48,panStep:40,zoomStep:1.2,rotationStep:15},Fv="worldorbit-viewer-tooltip-style";function Zs(n,e){if(P2(n),+!!e.source+ +!!e.document+ +!!e.scene!==1)throw new Error('Interactive viewer requires exactly one of "source", "document", or "scene".');let i={minScale:e.minScale??qs.minScale,maxScale:e.maxScale??qs.maxScale,fitPadding:e.fitPadding??qs.fitPadding},r={keyboard:e.keyboard??!0,pointer:e.pointer??!0,touch:e.touch??!0,selection:e.selection??!0,tooltipMode:e.tooltipMode??"hover",minimap:e.minimap??!1,panStep:e.panStep??qs.panStep,zoomStep:e.zoomStep??qs.zoomStep,rotationStep:e.rotationStep??qs.rotationStep},s={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,viewMode:e.viewMode??"2d",camera:e.camera?{...e.camera}:null,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,theme:e.theme,layers:e.layers,filter:$n(e.initialFilter),subtitle:e.subtitle},o=n.getAttribute("tabindex"),a=n.style.touchAction,c=n.style.position,l=I2(e),u=ka(l,s),d=e.spatialScene??null,h=s.viewMode==="3d"?jr(l,s,d):null,f={...Dn},p=null,y=null,g=null,m=null,v=null,x=!1,w=null,O=null,I=0,R=!1,U=new Map,_=null,b=null,D=null,z=null,F=null,$=null,W=null,ne=null,J={playing:!1,speed:1,timeSeconds:0,frozenByEvent:h?.timeFrozen??!1};o===null&&(n.tabIndex=0),L2(),n.classList.add("wo-viewer-container"),n.style.touchAction=r.touch?"none":a,n.style.position||(n.style.position="relative"),Se();let V=N=>{if(!r.pointer||R)return;if(N.preventDefault(),n.focus(),de()){let $e=Wr(Math.exp(-N.deltaY*.002),.6,1.6);Ie.zoomBy($e);return}let G=H(N.clientX,N.clientY),se=Wr(Math.exp(-N.deltaY*.002),.6,1.6);B(So(u,f,se,G,i))},ce=N=>{if(R)return;let G=N.pointerType==="touch";if(G&&!r.touch||!G&&!r.pointer||!G&&N.button!==0&&!de())return;n.focus(),n.setPointerCapture?.(N.pointerId);let se=E(N.clientX,N.clientY);if(G){U.set(N.pointerId,se),U.size===2?_=Bv(u,f,U):U.size===1&&(I=0,x=!1);return}w=N.pointerId,O=se,I=0,x=!1},fe=N=>{if(R)return;if(N.pointerType==="touch"){if(de()||!r.touch||!U.has(N.pointerId))return;let ke=U.get(N.pointerId),xt=E(N.clientX,N.clientY);if(U.set(N.pointerId,xt),U.size===2){_||(_=Bv(u,f,U));let Ct=$v(U),Pn=Ct.distance/Math.max(_.startDistance,1),or=So(u,_.startState,Pn,_.startCenter,i),Qs=Ct.center.x-_.startViewportCenter.x,eo=Ct.center.y-_.startViewportCenter.y;B(ts(or,Qs,eo))}else if(U.size===1){let Ct=xt.x-ke.x,Pn=xt.y-ke.y;I+=Math.abs(Ct)+Math.abs(Pn),I>2&&(x=!0),B(ts(f,Ct,Pn))}return}if(de()&&r.pointer&&w===null){Q(g?.hitTest(N.clientX,N.clientY)??null);return}if(de()&&r.pointer&&w===N.pointerId&&O){let ke=E(N.clientX,N.clientY),xt=ke.x-O.x,Ct=ke.y-O.y;I+=Math.abs(xt)+Math.abs(Ct),O=ke,I>2&&(x=!0),N.shiftKey||N.buttons===2?Ie.panBy(xt,Ct):(Ie.rotateBy(xt*.35),Ie.panBy(0,Ct*.35)),Q(g?.hitTest(N.clientX,N.clientY)??null);return}if(!r.pointer||w!==N.pointerId||!O)return;let se=E(N.clientX,N.clientY),$e=se.x-O.x,We=se.y-O.y;I+=Math.abs($e)+Math.abs(We),O=se,I>2&&(x=!0),B(ts(f,$e,We))},Te=N=>{if(N.pointerType==="touch"){U.delete(N.pointerId),U.size<2&&(_=null);return}w===N.pointerId&&(w=null,O=null)},ve=N=>{if(!r.selection||R)return;if(x){x=!1;return}let G=de()?g?.hitTest(N.clientX,N.clientY)??null:Vu(N.target);he(G),r.tooltipMode==="pinned"&&(D=G,Me())},He=N=>{if(de())return;let G=Vu(N.target);Q(G)},q=()=>{Q(null)},Z=N=>{if(de())return;let G=Vu(N.target);G&&Q(G)},ye=()=>{Q(null)},ae=N=>{if(!r.keyboard||R)return;let G=de()?f.selectedObjectId:Vu(N.target);if((N.key==="Enter"||N.key===" ")&&G){N.preventDefault(),he(G),r.tooltipMode==="pinned"&&(D=G,Me());return}switch(N.key){case"Escape":r.tooltipMode==="pinned"&&D&&(N.preventDefault(),D=null,Me());return;case"+":case"=":N.preventDefault(),Ie.zoomBy(r.zoomStep);return;case"-":N.preventDefault(),Ie.zoomBy(1/r.zoomStep);return;case"ArrowLeft":N.preventDefault(),Ie.panBy(-r.panStep,0);return;case"ArrowRight":N.preventDefault(),Ie.panBy(r.panStep,0);return;case"ArrowUp":N.preventDefault(),Ie.panBy(0,-r.panStep);return;case"ArrowDown":N.preventDefault(),Ie.panBy(0,r.panStep);return;case"[":N.preventDefault(),Ie.rotateBy(-r.rotationStep);return;case"]":N.preventDefault(),Ie.rotateBy(r.rotationStep);return;case"f":case"F":N.preventDefault(),Ie.fitToSystem();return;case"0":N.preventDefault(),Ie.resetView();return}};n.addEventListener("wheel",V,{passive:!1}),n.addEventListener("pointerdown",ce),n.addEventListener("pointermove",fe),n.addEventListener("pointerup",Te),n.addEventListener("pointercancel",Te),n.addEventListener("click",ve),n.addEventListener("mouseover",He),n.addEventListener("mouseleave",q),n.addEventListener("focusin",Z),n.addEventListener("focusout",ye),n.addEventListener("keydown",ae);let Ie={setSource(N){l={kind:"source",value:N},u=ka(l,s),d=null,h=s.viewMode==="3d"?jr(l,s,null):null,Se(),$=null,Re(!0)},setDocument(N){l={kind:"document",value:N},u=ka(l,s),d=null,h=s.viewMode==="3d"?jr(l,s,null):null,Se(),$=null,Re(!0)},setScene(N){l={kind:"scene",value:N},u=N,d=null,h=s.viewMode==="3d"?jr(l,s,null):null,Se(),$=null,Re(!0)},getScene(){return u},getRenderOptions(){return C2(s)},getViewMode(){return s.viewMode??"2d"},setViewMode(N){let G=s,se=h,$e=Fp(s,{viewMode:N}),We=N==="3d"?jr(l,$e,d):null;s=$e,h=We,Se();try{Re(!1)}catch(ke){throw s=G,h=se,Se(),Re(!1),ke}},listViewpoints(){return u.viewpoints.slice()},getActiveViewpoint(){return Ue($)},goToViewpoint(N){let G=Ue(N);if(!G)return!1;let se={},$e=Cd(G);if(G.preset!==null&&(se.preset=G.preset),l.kind!=="scene"&&G.projection!==u.projection&&(se.projection=G.projection),G.camera?se.camera={...G.camera}:s.camera&&(se.camera=null),$e&&(se.layers=$e),$=G.id,Object.keys(se).length>0){let ke=kv(se);s=Fp(s,se),l.kind!=="scene"&&ke&&(u=ka(l,s)),Re(ke)}Ve(Rd(G),!1,!1);let We=xe(G);return B(We),he(G.selectedObjectId??G.objectId??null,!1),e.onSelectionChange?.(me()),e.onSelectionDetailsChange?.(we(f.selectedObjectId)),Oe(),Ge(),!0},getActiveEventId(){return s.activeEventId??null},setActiveEvent(N){Ie.setRenderOptions({activeEventId:N})},playAnimation(){if(!de()){J={...J,playing:!1},at();return}if(J.frozenByEvent){J={...J,playing:!1};return}J={...J,playing:!0},rt()},pauseAnimation(){J={...J,playing:!1},at()},resetAnimation(){J={...J,playing:!1,timeSeconds:0},at(),Et()},setAnimationSpeed(N){J={...J,speed:Wr(N,.1,64)}},getAnimationState(){return{...J}},search(N,G=12){return Ad(u,N,G)},getFilter(){return s.filter?{...s.filter}:null},setFilter(N){Ve(N,!0,!0)},getVisibleObjects(){return le()},getFocusPath(N){return re(N)},getObjectDetails(N){return we(N)},getSelectionDetails(){return we(f.selectedObjectId)},getTooltipDetails(){return F},getAtlasState(){return hg(f,s,s.filter??null,$)},setAtlasState(N){let G=typeof N=="string"?Id(N):N;G.viewpointId&&Ie.goToViewpoint(G.viewpointId),Ie.setRenderOptions(G.renderOptions),Ve(G.filter??null,!1,!1),B(Je({...f,...G.viewerState})),he(G.viewerState.selectedObjectId??null,!1),Oe(),e.onSelectionChange?.(me()),e.onSelectionDetailsChange?.(we(f.selectedObjectId)),Ge()},serializeAtlasState(){return Td(Ie.getAtlasState())},captureBookmark(N,G){return fg(N,G,Ie.getAtlasState())},applyBookmark(N){return typeof N=="string"?(Ie.setAtlasState(N),!0):(Ie.setAtlasState(N.atlasState),!0)},setRenderOptions(N){let G=kv(N),se=s,$e=u,We=h,ke=Fp(s,N),xt=u;l.kind!=="scene"&&G&&(xt=ka(l,ke));let Ct=ke.viewMode==="3d"?jr(l,ke,d):null;s=ke,u=xt,h=Ct,Se();try{Re(G)}catch(Pn){throw s=se,u=$e,h=We,Se(),Re(G),Pn}},getState(){return{...f}},setState(N){B(Je({...f,...N}))},zoomBy(N,G){B(So(u,f,N,G??{x:u.width/2,y:u.height/2},i))},panBy(N,G){B(ts(f,N,G))},rotateBy(N){B(Pd(f,N))},fitToSystem(){B(de()?{...Dn,selectedObjectId:f.selectedObjectId}:ns(u,f,i))},focusObject(N){$=null,B(de()?an(N):Ld(u,f,N,i)),he(N),r.tooltipMode==="pinned"&&(D=K(N)?.objectId??null,Me())},pinTooltip(N){D=K(N)?.objectId??null,Me()},resetView(){let N=de()?{...Dn}:ns(u,{...Dn},i);$=null,B(N),he(null),D=null,Me()},exportSvg(){return ai(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId})},destroy(){R||(R=!0,n.removeEventListener("wheel",V),n.removeEventListener("pointerdown",ce),n.removeEventListener("pointermove",fe),n.removeEventListener("pointerup",Te),n.removeEventListener("pointercancel",Te),n.removeEventListener("click",ve),n.removeEventListener("mouseover",He),n.removeEventListener("mouseleave",q),n.removeEventListener("focusin",Z),n.removeEventListener("focusout",ye),n.removeEventListener("keydown",ae),at(),g?.destroy(),g=null,v?.remove(),v=null,m?.remove(),m=null,n.classList.remove("wo-viewer-container"),n.style.touchAction=a,n.style.position=c,o===null?n.removeAttribute("tabindex"):n.setAttribute("tabindex",o))}};return Re(!0),e.initialViewpointId?Ie.goToViewpoint(e.initialViewpointId):e.initialSelectionObjectId?Ie.focusObject(e.initialSelectionObjectId):Ge(),Ie;function Re(N){if(g?.destroy(),g=null,n.innerHTML="",p=null,y=null,m=null,v=null,de()?(h=h??jr(l,s,d),g=Lv(n)):(n.innerHTML=ai(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId}),p=n.querySelector('[data-worldorbit-svg="true"]'),y=n.querySelector("#worldorbit-camera-root")),r.minimap&&(m=document.createElement("div"),m.dataset.worldorbitMinimapRoot="true",n.append(m)),r.tooltipMode!=="disabled"&&(v=document.createElement("div"),v.className="wo-viewer-tooltip-root",v.dataset.worldorbitTooltip="true",v.hidden=!0,v.addEventListener("click",ue),n.append(v)),!de()&&(!p||!y))throw new Error("Interactive viewer could not locate the rendered SVG camera root.");f=N?de()?{...Dn}:ns(u,{...Dn},i):Je(f),he(f.selectedObjectId&&K(f.selectedObjectId)?f.selectedObjectId:null,!1),Q(b&&K(b)?b:null,!1),D=D&&K(D)?D:null,Et(),pe(),Oe(),e.onViewChange?.({...f}),Ge()}function B(N){f=Je(N),Et(),e.onViewChange?.({...f}),Ge()}function Je(N){return{scale:Wr(N.scale,i.minScale,i.maxScale),rotationDeg:zv(N.rotationDeg),translateX:Number.isFinite(N.translateX)?N.translateX:f.translateX,translateY:Number.isFinite(N.translateY)?N.translateY:f.translateY,selectedObjectId:N.selectedObjectId&&K(N.selectedObjectId)?N.selectedObjectId:null}}function X(){if(de()){ot();return}y&&(y.setAttribute("transform",Dd(u,f)),Ne(),Me())}function he(N,G=!0){!de()&&f.selectedObjectId&&n.querySelector(`[data-object-id="${Ba(f.selectedObjectId)}"]`)?.classList.remove("wo-object-selected"),f={...f,selectedObjectId:N&&K(N)?N:null},!de()&&f.selectedObjectId&&n.querySelector(`[data-object-id="${Ba(f.selectedObjectId)}"]`)?.classList.add("wo-object-selected"),De(),Me(),G&&(e.onSelectionChange?.(me()),e.onSelectionDetailsChange?.(we(f.selectedObjectId)),e.onViewChange?.({...f}),Ge())}function Q(N,G=!0){b===N&&G||(b=N&&K(N)?N:null,De(),Me(),G&&(e.onHoverChange?.(K(b)),e.onHoverDetailsChange?.(we(b))))}function me(){return K(f.selectedObjectId)}function K(N){if(!N)return null;let G=te();return u.objects.find(se=>se.objectId===N&&!se.hidden&&G.has(se.objectId))??null}function we(N){let G=K(N);return G?{objectId:G.objectId,object:G.object,renderObject:G,label:u.labels.find(se=>se.objectId===G.objectId&&!se.hidden)??null,group:u.groups.find(se=>se.renderId===G.groupId)??null,semanticGroups:u.semanticGroups.filter(se=>G.semanticGroupIds.includes(se.id)),orbit:u.orbitVisuals.find(se=>se.objectId===G.objectId&&!se.hidden)??null,relatedOrbits:u.orbitVisuals.filter(se=>!se.hidden&&(se.objectId===G.objectId||G.ancestorIds.includes(se.objectId)||G.childIds.includes(se.objectId))),relations:u.relations.filter(se=>!se.hidden&&(se.fromObjectId===G.objectId||se.toObjectId===G.objectId)),relatedEvents:u.events.filter(se=>!se.hidden&&(se.targetObjectId===G.objectId||se.objectIds.includes(G.objectId))),parent:K(G.parentId),children:G.childIds.map(se=>K(se)).filter(Boolean),ancestors:G.ancestorIds.map(se=>K(se)).filter(Boolean),focusPath:re(G.objectId)}:null}function De(){if(de()){ot();return}for(let N of n.querySelectorAll(".wo-chain-selected, .wo-chain-hover, .wo-ancestor-selected, .wo-ancestor-hover, .wo-orbit-related-selected, .wo-orbit-related-hover"))N.classList.remove("wo-chain-selected","wo-chain-hover","wo-ancestor-selected","wo-ancestor-hover","wo-orbit-related-selected","wo-orbit-related-hover");L(f.selectedObjectId,{objectClass:"wo-chain-selected",ancestorClass:"wo-ancestor-selected",orbitClass:"wo-orbit-related-selected"}),L(b,{objectClass:"wo-chain-hover",ancestorClass:"wo-ancestor-hover",orbitClass:"wo-orbit-related-hover"})}function L(N,G){let se=we(N);if(!se)return;let $e=new Set([se.objectId,...se.renderObject.childIds,...se.renderObject.ancestorIds]);for(let We of $e)for(let ke of n.querySelectorAll(`[data-object-id="${Ba(We)}"]`))ke.classList.add(G.objectClass);for(let We of se.ancestors)for(let ke of n.querySelectorAll(`[data-object-id="${Ba(We.objectId)}"]`))ke.classList.add(G.ancestorClass);for(let We of se.relatedOrbits)for(let ke of n.querySelectorAll(`[data-orbit-object-id="${Ba(We.objectId)}"]`))ke.classList.add(G.orbitClass)}function E(N,G){if(de()){let $e=n.getBoundingClientRect();return!$e.width||!$e.height?{x:u.width/2,y:u.height/2}:{x:N-$e.left,y:G-$e.top}}if(!p)return{x:u.width/2,y:u.height/2};let se=p.getBoundingClientRect();return!se.width||!se.height?{x:u.width/2,y:u.height/2}:{x:(N-se.left)/se.width*u.width,y:(G-se.top)/se.height*u.height}}function H(N,G){return dr(u,f,E(N,G))}function te(){return _c(u,s.filter??null)}function le(){let N=te();return u.objects.filter(G=>!G.hidden&&N.has(G.objectId))}function re(N){let G=u.objects.find(se=>se.objectId===N&&!se.hidden);return G?[...G.ancestorIds,G.objectId].map(se=>K(se)).filter(Boolean):[]}function Ue(N){return u.viewpoints.find(G=>G.id===N)??null}function xe(N){let G=zv(N.rotationDeg),se=N.scale!==null&&N.scale!==void 0?Wr(N.scale,i.minScale,i.maxScale):null;if(de()){let ke=N.objectId??N.selectedObjectId??null,xt=ke?h?.focusTargets.find(Ct=>Ct.objectId===ke):null;return{scale:se??1.6,rotationDeg:G,translateX:xt?-xt.center.x:0,translateY:xt?-xt.center.z:0,selectedObjectId:N.selectedObjectId??N.objectId??null}}let $e=N.objectId&&u.objects.find(ke=>ke.objectId===N.objectId&&!ke.hidden);if($e)return be({x:$e.x,y:$e.y},se??Math.max(1.8,Dn.scale),G,N.selectedObjectId??$e.objectId);let We=ns(u,{...Dn,rotationDeg:G},i);return se===null?{...We,rotationDeg:G,selectedObjectId:N.selectedObjectId??null}:be({x:u.contentBounds.centerX,y:u.contentBounds.centerY},se,G,N.selectedObjectId??null)}function be(N,G,se,$e){let We={x:u.width/2,y:u.height/2},ke=ln(N,We,se);return{scale:G,rotationDeg:se,translateX:We.x-(We.x+(ke.x-We.x)*G),translateY:We.y-(We.y+(ke.y-We.y)*G),selectedObjectId:$e}}function Ve(N,G,se){s={...s,filter:$n(N)},se&&($=null),Re(!1)}function pe(){e.onFilterChange?.(s.filter??null,le())}function Oe(){e.onViewpointChange?.(Ue($))}function Ge(){e.onAtlasStateChange?.(Ie.getAtlasState())}function Ne(){!r.minimap||!m||(m.innerHTML=wg(u,f,le()))}function Me(){if(r.tooltipMode==="disabled"||!v){ee(null);return}let N=Ye();if(!N){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),ee(null);return}let G=we(N.objectId);if(!G){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),ee(null);return}let se=Uv(G);z=N.objectId,v.hidden=!1,v.dataset.mode=N.mode,v.classList.toggle("is-pinned",N.mode==="pinned"),v.style.pointerEvents="auto",v.style.visibility="hidden",nt(v,se,N.mode),yt(v,G.renderObject),v.style.visibility="visible",ee(se)}function Ye(){return D&&K(D)?{objectId:D,mode:"pinned"}:b&&K(b)?{objectId:b,mode:"hover"}:null}function nt(N,G,se){let $e=e.tooltipRenderer?.(G,se);N.innerHTML="",typeof $e=="string"?N.innerHTML=$e:$e instanceof HTMLElement?N.append($e):N.innerHTML=Nv(G,se);let We=document.createElement("div");if(We.className="wo-tooltip-actions",se==="pinned"){let ke=document.createElement("button");ke.type="button",ke.className="wo-tooltip-action",ke.dataset.tooltipAction="unpin",ke.textContent="Unpin",We.append(ke)}else{let ke=document.createElement("button");ke.type="button",ke.className="wo-tooltip-action",ke.dataset.tooltipAction="pin",ke.dataset.objectId=G.objectId,ke.textContent="Pin",We.append(ke)}We.childElementCount>0&&N.append(We)}function yt(N,G){let se=de()?g?.projectObjectToContainer(G.objectId)??null:k(G);if(!se)return;let $e=Math.max(n.clientWidth-N.offsetWidth-12,12),We=Math.max(n.clientHeight-N.offsetHeight-12,12),ke=se.y>n.clientHeight*.48,xt=Wr(se.x+18,12,$e),Ct=Wr(ke?se.y-N.offsetHeight-18:se.y+18,12,We);N.style.left=`${xt}px`,N.style.top=`${Ct}px`}function je(N){if(de())return N;let G={x:u.width/2,y:u.height/2},se=ln(N,G,f.rotationDeg);return{x:G.x+(se.x-G.x)*f.scale+f.translateX,y:G.y+(se.y-G.y)*f.scale+f.translateY}}function k(N){if(!p)return null;let G={x:N.anchorX??N.x,y:N.anchorY??N.y-Math.max(N.visualRadius,N.radius)},se=je(G),$e=p.getBoundingClientRect(),We=n.getBoundingClientRect();return{x:$e.left-We.left+se.x/Math.max(u.width,1)*$e.width,y:$e.top-We.top+se.y/Math.max(u.height,1)*$e.height}}function ue(N){let G=N.target?.closest("[data-tooltip-action]");if(G){switch(N.preventDefault(),N.stopPropagation(),G.dataset.tooltipAction){case"pin":D=G.dataset.objectId??z;break;case"unpin":D=null;break}Me()}}function ee(N){let G=F?.objectId!==N?.objectId||F?.description!==N?.description||F?.imageHref!==N?.imageHref;F=N,z=N?.objectId??null,G&&e.onTooltipChange?.(N)}function de(){return s.viewMode==="3d"}function Se(){J={...J,frozenByEvent:h?.timeFrozen??!1},J.frozenByEvent&&(J={...J,playing:!1},at())}function rt(){W!==null||!J.playing||R||(W=window.requestAnimationFrame(vt))}function at(){W!==null&&(window.cancelAnimationFrame(W),W=null),ne=null}function vt(N){if(W=null,!J.playing||R){ne=null;return}let se=Math.max((N-(ne??N))/1e3,0);ne=N,J={...J,timeSeconds:J.timeSeconds+se*J.speed},ot(),rt()}function Et(){X(),de()&&J.playing?rt():(!J.playing||!de())&&at()}function ot(){!de()||!g||!h||(g.update({spatialScene:h,renderOptions:s,visibleObjectIds:te(),selectedObjectId:f.selectedObjectId,hoveredObjectId:b,state:f,timeSeconds:J.timeSeconds}),Ne(),Me())}function an(N){let G=h?.focusTargets.find(se=>se.objectId===N);return G?{scale:1.8,rotationDeg:f.rotationDeg,translateX:-G.center.x,translateY:-G.center.z,selectedObjectId:N}:{...Dn,selectedObjectId:N}}}function I2(n){if(n.scene)return{kind:"scene",value:n.scene};if(n.document)return{kind:"document",value:n.document};if(n.source)return{kind:"source",value:n.source};throw new Error("Interactive viewer requires an initial render input.")}function ka(n,e){switch(n.kind){case"scene":return n.value;case"document":return cn(n.value,e);case"source":{let t=si(n.value);return cn(t.document,Vv(t,e))}}}function jr(n,e,t){if(t)return t;switch(n.kind){case"scene":return R2(n.value);case"document":return Kr(n.value,e);case"source":{let i=si(n.value);return Kr(i.document,Vv(i,e))}}}function C2(n){return{...n,camera:n.camera?{...n.camera}:null,filter:n.filter?{...n.filter}:void 0,scaleModel:n.scaleModel?{...n.scaleModel}:void 0,layers:n.layers?{...n.layers}:void 0,theme:n.theme&&typeof n.theme=="object"?{...n.theme}:n.theme,activeEventId:n.activeEventId??null,viewMode:n.viewMode??"2d"}}function Fp(n,e){return{...n,...e,camera:e.camera!==void 0?e.camera?{...e.camera}:null:n.camera?{...n.camera}:null,filter:e.filter!==void 0?$n(e.filter):n.filter?{...n.filter}:void 0,scaleModel:e.scaleModel?{...n.scaleModel??{},...e.scaleModel}:n.scaleModel?{...n.scaleModel}:void 0,layers:e.layers?{...n.layers??{},...e.layers}:n.layers?{...n.layers}:void 0,theme:e.theme&&typeof e.theme=="object"?{...e.theme}:e.theme??n.theme,viewMode:e.viewMode??n.viewMode??"2d"}}function kv(n){return n.width!==void 0||n.height!==void 0||n.padding!==void 0||n.preset!==void 0||n.projection!==void 0||n.camera!==void 0||n.scaleModel!==void 0||n.activeEventId!==void 0}function Vv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function R2(n){return{width:n.width,height:n.height,padding:n.padding,renderPreset:n.renderPreset,projection:n.projection,camera:n.camera,scaleModel:{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40},title:n.title,subtitle:n.subtitle,systemId:n.systemId,viewMode:"3d",layoutPreset:n.layoutPreset,metadata:{...n.metadata,"viewer.mode":"3d-fallback"},contentBounds:{minX:n.contentBounds.minX-n.contentBounds.centerX,minY:-40,minZ:n.contentBounds.minY-n.contentBounds.centerY,maxX:n.contentBounds.maxX-n.contentBounds.centerX,maxY:40,maxZ:n.contentBounds.maxY-n.contentBounds.centerY,width:n.contentBounds.width,height:80,depth:n.contentBounds.height,center:{x:0,y:0,z:0}},semanticGroups:n.semanticGroups,viewpoints:n.viewpoints,activeEventId:n.activeEventId,timeFrozen:n.activeEventId!==null,objects:n.objects.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,ancestorIds:e.ancestorIds.slice(),childIds:e.childIds.slice(),groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),position:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.radius,visualRadius:e.visualRadius,label:e.label,secondaryLabel:e.secondaryLabel,fillColor:e.fillColor,imageHref:e.imageHref,hidden:e.hidden,motion:null})),orbits:n.orbitVisuals.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),center:{x:0,y:0,z:0},kind:e.kind,radius:e.radius,semiMajor:e.radius??e.rx??0,semiMinor:e.radius??e.ry??0,rotationDeg:e.rotationDeg,inclinationDeg:0,band:e.band,bandThickness:e.bandThickness,hidden:e.hidden,motion:null})),focusTargets:n.objects.map(e=>({objectId:e.objectId,center:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.visualRadius+12}))}}function Bv(n,e,t){let{center:i,distance:r}=$v(t);return{startState:{...e},startCenter:dr(n,e,i),startViewportCenter:i,startDistance:r}}function $v(n){let e=[...n.values()];if(e.length<2)return{center:e[0]??{x:0,y:0},distance:1};let[t,i]=e;return{center:{x:(t.x+i.x)/2,y:(t.y+i.y)/2},distance:Math.hypot(i.x-t.x,i.y-t.y)}}function Vu(n){return n instanceof Element?n.closest("[data-object-id]")?.dataset.objectId??null:null}function P2(n){if(typeof window>"u"||typeof document>"u")throw new Error("createInteractiveViewer can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("Interactive viewer requires an HTMLElement container.")}function Wr(n,e,t){return Math.min(Math.max(n,e),t)}function zv(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function Ba(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/["\\]/g,"\\$&")}function L2(){if(typeof document>"u"||document.getElementById(Fv))return;let n=document.createElement("style");n.id=Fv,n.textContent=`
3944
+ ${r.length?`<p class="wo-tooltip-relations">${Jn(r.join(" - "))}</p>`:""}
3945
+ </article>`}function _2(n){let e=new Map;for(let i of b2){let r=n.object.properties[i];r!==void 0&&e.set(i,{key:i,label:A2(i),value:Ov(r)})}let t=n.object.placement;return n.object.groups?.length&&e.set("groups",{key:"groups",label:"Groups",value:n.object.groups.join(", ")}),n.object.epoch&&e.set("epoch",{key:"epoch",label:"Epoch",value:n.object.epoch}),n.object.referencePlane&&e.set("referencePlane",{key:"referencePlane",label:"Reference Plane",value:n.object.referencePlane}),n.object.tidalLock!==void 0&&e.set("tidalLock",{key:"tidalLock",label:"Tidal Lock",value:n.object.tidalLock?"true":"false"}),n.object.resonance&&e.set("resonance",{key:"resonance",label:"Resonance",value:`${n.object.resonance.targetObjectId} ${n.object.resonance.ratio}`}),n.relatedEvents.length>0&&e.set("events",{key:"events",label:"Events",value:n.relatedEvents.map(i=>i.event.label||i.event.id).join(", ")}),t?.mode==="at"?e.set("placement",{key:"placement",label:"Placement",value:`At ${t.target}`}):t?.mode==="surface"?e.set("placement",{key:"placement",label:"Placement",value:`Surface ${t.target}`}):t?.mode==="free"&&e.set("placement",{key:"placement",label:"Placement",value:t.distance?`Free ${Ov(t.distance)}`:`Free ${t.descriptor??"custom"}`}),[...e.values()]}function w2(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function S2(n){let e=n.object.info.description?.trim();if(e)return e;let t=n.group?.label?.trim();return t&&t!==n.objectId?t:null}function Ov(n){return typeof n=="string"?n:typeof n=="number"?String(n):typeof n=="boolean"?n?"true":"false":Array.isArray(n)?n.join(", "):M2(n)}function M2(n){return`${n.value}${n.unit??""}`}function E2(n){return n.charAt(0).toUpperCase()+n.slice(1)}function A2(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase())}function Jn(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function T2(n){return Jn(n)}var Js={minScale:.2,maxScale:8,fitPadding:48,panStep:40,zoomStep:1.2,rotationStep:15},Fv="worldorbit-viewer-tooltip-style";function Ks(n,e){if(P2(n),+!!e.source+ +!!e.document+ +!!e.scene!==1)throw new Error('Interactive viewer requires exactly one of "source", "document", or "scene".');let i={minScale:e.minScale??Js.minScale,maxScale:e.maxScale??Js.maxScale,fitPadding:e.fitPadding??Js.fitPadding},r={keyboard:e.keyboard??!0,pointer:e.pointer??!0,touch:e.touch??!0,selection:e.selection??!0,tooltipMode:e.tooltipMode??"hover",minimap:e.minimap??!1,panStep:e.panStep??Js.panStep,zoomStep:e.zoomStep??Js.zoomStep,rotationStep:e.rotationStep??Js.rotationStep},s={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,viewMode:e.viewMode??"2d",camera:e.camera?{...e.camera}:null,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,theme:e.theme,layers:e.layers,filter:zn(e.initialFilter),subtitle:e.subtitle},o=n.getAttribute("tabindex"),a=n.style.touchAction,c=n.style.position,l=I2(e),u=ka(l,s),d=e.spatialScene??null,h=s.viewMode==="3d"?jr(l,s,d):null,f={...Rn},p=null,y=null,g=null,m=null,x=null,v=null,M=!1,U=null,C=null,R=0,N=!1,w=new Map,b=null,O=null,B=null,F=null,H=null,X=null,ee=null,ce=null,k={playing:!1,speed:1,timeSeconds:0,frozenByEvent:h?.timeFrozen??!1};o===null&&(n.tabIndex=0),L2(),n.classList.add("wo-viewer-container"),n.style.touchAction=r.touch?"none":a,n.style.position||(n.style.position="relative"),nt();let le=P=>{if(!r.pointer||N)return;if(P.preventDefault(),n.focus(),Pe()){let E=Gr(Math.exp(-P.deltaY*.002),.6,1.6);xe.zoomBy(E);return}let $=te(P.clientX,P.clientY),G=Gr(Math.exp(-P.deltaY*.002),.6,1.6);Be(Mo(u,f,G,$,i))},he=P=>{if(N)return;let $=P.pointerType==="touch";if($&&!r.touch||!$&&!r.pointer||!$&&P.button!==0&&!Pe())return;n.focus(),n.setPointerCapture?.(P.pointerId);let G=j(P.clientX,P.clientY);if($){w.set(P.pointerId,G),w.size===2?b=Bv(u,f,w):w.size===1&&(R=0,M=!1);return}U=P.pointerId,C=G,R=0,M=!1},Te=P=>{if(N)return;if(P.pointerType==="touch"){if(Pe()||!r.touch||!w.has(P.pointerId))return;let S=w.get(P.pointerId),T=j(P.clientX,P.clientY);if(w.set(P.pointerId,T),w.size===2){b||(b=Bv(u,f,w));let I=$v(w),W=I.distance/Math.max(b.startDistance,1),ne=Mo(u,b.startState,W,b.startCenter,i),me=I.center.x-b.startViewportCenter.x,Me=I.center.y-b.startViewportCenter.y;Be(is(ne,me,Me))}else if(w.size===1){let I=T.x-S.x,W=T.y-S.y;R+=Math.abs(I)+Math.abs(W),R>2&&(M=!0),Be(is(f,I,W))}return}if(Pe()&&r.pointer&&U===null){fe(g?.hitTest(P.clientX,P.clientY)??null);return}if(Pe()&&r.pointer&&U===P.pointerId&&C){let S=j(P.clientX,P.clientY),T=S.x-C.x,I=S.y-C.y;R+=Math.abs(T)+Math.abs(I),C=S,R>2&&(M=!0),P.shiftKey||P.buttons===2?xe.panBy(T,I):(xe.rotateBy(T*.35),xe.panBy(0,I*.35)),fe(g?.hitTest(P.clientX,P.clientY)??null);return}if(!r.pointer||U!==P.pointerId||!C)return;let G=j(P.clientX,P.clientY),E=G.x-C.x,_=G.y-C.y;R+=Math.abs(E)+Math.abs(_),C=G,R>2&&(M=!0),Be(is(f,E,_))},ve=P=>{if(P.pointerType==="touch"){w.delete(P.pointerId),w.size<2&&(b=null);return}U===P.pointerId&&(U=null,C=null)},He=P=>{if(!r.selection||N)return;if(M){M=!1;return}let $=Pe()?g?.hitTest(P.clientX,P.clientY)??null:Vu(P.target);K($),r.tooltipMode==="pinned"&&(B=$,Fe())},Z=P=>{if(Pe())return;let $=Vu(P.target);fe($)},J=()=>{fe(null)},ye=P=>{if(Pe())return;let $=Vu(P.target);$&&fe($)},oe=()=>{fe(null)},ze=P=>{if(!r.keyboard||N)return;let $=Pe()?f.selectedObjectId:Vu(P.target);if((P.key==="Enter"||P.key===" ")&&$){P.preventDefault(),K($),r.tooltipMode==="pinned"&&(B=$,Fe());return}switch(P.key){case"Escape":r.tooltipMode==="pinned"&&B&&(P.preventDefault(),B=null,Fe());return;case"+":case"=":P.preventDefault(),xe.zoomBy(r.zoomStep);return;case"-":P.preventDefault(),xe.zoomBy(1/r.zoomStep);return;case"ArrowLeft":P.preventDefault(),xe.panBy(-r.panStep,0);return;case"ArrowRight":P.preventDefault(),xe.panBy(r.panStep,0);return;case"ArrowUp":P.preventDefault(),xe.panBy(0,-r.panStep);return;case"ArrowDown":P.preventDefault(),xe.panBy(0,r.panStep);return;case"[":P.preventDefault(),xe.rotateBy(-r.rotationStep);return;case"]":P.preventDefault(),xe.rotateBy(r.rotationStep);return;case"f":case"F":P.preventDefault(),xe.fitToSystem();return;case"0":P.preventDefault(),xe.resetView();return}};n.addEventListener("wheel",le,{passive:!1}),n.addEventListener("pointerdown",he),n.addEventListener("pointermove",Te),n.addEventListener("pointerup",ve),n.addEventListener("pointercancel",ve),n.addEventListener("click",He),n.addEventListener("mouseover",Z),n.addEventListener("mouseleave",J),n.addEventListener("focusin",ye),n.addEventListener("focusout",oe),n.addEventListener("keydown",ze);let xe={setSource(P){l={kind:"source",value:P},u=ka(l,s),d=null,h=s.viewMode==="3d"?jr(l,s,null):null,nt(),X=null,V(!0)},setDocument(P){l={kind:"document",value:P},u=ka(l,s),d=null,h=s.viewMode==="3d"?jr(l,s,null):null,nt(),X=null,V(!0)},setScene(P){l={kind:"scene",value:P},u=P,d=null,h=s.viewMode==="3d"?jr(l,s,null):null,nt(),X=null,V(!0)},getScene(){return u},getRenderOptions(){return C2(s)},getViewMode(){return s.viewMode??"2d"},setViewMode(P){let $=s,G=h,E=Fp(s,{viewMode:P}),_=P==="3d"?jr(l,E,d):null;s=E,h=_,nt();try{V(!1)}catch(S){throw s=$,h=G,nt(),V(!1),S}},listViewpoints(){return u.viewpoints.slice()},getActiveViewpoint(){return be(X)},goToViewpoint(P){let $=be(P);if(!$)return!1;let G={},E=Cd($);if($.preset!==null&&(G.preset=$.preset),l.kind!=="scene"&&$.projection!==u.projection&&(G.projection=$.projection),$.camera?G.camera={...$.camera}:s.camera&&(G.camera=null),E&&(G.layers=E),X=$.id,Object.keys(G).length>0){let S=kv(G);s=Fp(s,G),l.kind!=="scene"&&S&&(u=ka(l,s)),V(S)}pe(Rd($),!1,!1);let _=_e($);return Be(_),K($.selectedObjectId??$.objectId??null,!1),e.onSelectionChange?.(ie()),e.onSelectionDetailsChange?.(Ie(f.selectedObjectId)),qe(),Ne(),!0},getActiveEventId(){return s.activeEventId??null},setActiveEvent(P){xe.setRenderOptions({activeEventId:P})},playAnimation(){if(!Pe()){k={...k,playing:!1},xt();return}if(k.frozenByEvent){k={...k,playing:!1};return}k={...k,playing:!0},pt()},pauseAnimation(){k={...k,playing:!1},xt()},resetAnimation(){k={...k,playing:!1,timeSeconds:0},xt(),Ht()},setAnimationSpeed(P){k={...k,speed:Gr(P,.1,64)}},getAnimationState(){return{...k}},search(P,$=12){return Ad(u,P,$)},getFilter(){return s.filter?{...s.filter}:null},setFilter(P){pe(P,!0,!0)},getVisibleObjects(){return re()},getFocusPath(P){return Ue(P)},getObjectDetails(P){return Ie(P)},getSelectionDetails(){return Ie(f.selectedObjectId)},getTooltipDetails(){return H},getAtlasState(){return hg(f,s,s.filter??null,X)},setAtlasState(P){let $=typeof P=="string"?Id(P):P;$.viewpointId&&xe.goToViewpoint($.viewpointId),xe.setRenderOptions($.renderOptions),pe($.filter??null,!1,!1),Be(Y({...f,...$.viewerState})),K($.viewerState.selectedObjectId??null,!1),qe(),e.onSelectionChange?.(ie()),e.onSelectionDetailsChange?.(Ie(f.selectedObjectId)),Ne()},serializeAtlasState(){return Td(xe.getAtlasState())},captureBookmark(P,$){return fg(P,$,xe.getAtlasState())},applyBookmark(P){return typeof P=="string"?(xe.setAtlasState(P),!0):(xe.setAtlasState(P.atlasState),!0)},setRenderOptions(P){let $=kv(P),G=s,E=u,_=h,S=Fp(s,P),T=u;l.kind!=="scene"&&$&&(T=ka(l,S));let I=S.viewMode==="3d"?jr(l,S,d):null;s=S,u=T,h=I,nt();try{V($)}catch(W){throw s=G,u=E,h=_,nt(),V($),W}},getState(){return{...f}},setState(P){Be(Y({...f,...P}))},zoomBy(P,$){Be(Mo(u,f,P,$??{x:u.width/2,y:u.height/2},i))},panBy(P,$){Be(is(f,P,$))},rotateBy(P){Be(Pd(f,P))},fitToSystem(){Be(Pe()?{...Rn,selectedObjectId:f.selectedObjectId}:rs(u,f,i))},focusObject(P){X=null,Be(Pe()?qr(P):Ld(u,f,P,i)),K(P),r.tooltipMode==="pinned"&&(B=ge(P)?.objectId??null,Fe())},pinTooltip(P){B=ge(P)?.objectId??null,Fe()},resetView(){let P=Pe()?{...Rn}:rs(u,{...Rn},i);X=null,Be(P),K(null),B=null,Fe()},exportSvg(){return si(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId})},destroy(){N||(N=!0,n.removeEventListener("wheel",le),n.removeEventListener("pointerdown",he),n.removeEventListener("pointermove",Te),n.removeEventListener("pointerup",ve),n.removeEventListener("pointercancel",ve),n.removeEventListener("click",He),n.removeEventListener("mouseover",Z),n.removeEventListener("mouseleave",J),n.removeEventListener("focusin",ye),n.removeEventListener("focusout",oe),n.removeEventListener("keydown",ze),xt(),g?.destroy(),g=null,x?.remove(),x=null,v?.remove(),v=null,m?.remove(),m=null,n.classList.remove("wo-viewer-container"),n.style.touchAction=a,n.style.position=c,o===null?n.removeAttribute("tabindex"):n.setAttribute("tabindex",o))}};return V(!0),e.initialViewpointId?xe.goToViewpoint(e.initialViewpointId):e.initialSelectionObjectId?xe.focusObject(e.initialSelectionObjectId):Ne(),xe;function V(P){if(g?.destroy(),g=null,n.innerHTML="",p=null,y=null,m=null,x=null,v=null,Pe()?(h=h??jr(l,s,d),g=Lv(n)):(n.innerHTML=si(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId}),p=n.querySelector('[data-worldorbit-svg="true"]'),y=n.querySelector("#worldorbit-camera-root")),r.minimap&&(m=document.createElement("div"),m.dataset.worldorbitMinimapRoot="true",n.append(m)),x=document.createElement("div"),x.className="wo-viewer-label-root",x.dataset.worldorbitLabelRoot="true",n.append(x),r.tooltipMode!=="disabled"&&(v=document.createElement("div"),v.className="wo-viewer-tooltip-root",v.dataset.worldorbitTooltip="true",v.hidden=!0,v.addEventListener("click",Se),n.append(v)),!Pe()&&(!p||!y))throw new Error("Interactive viewer could not locate the rendered SVG camera root.");Xr(),f=P?Pe()?{...Rn}:rs(u,{...Rn},i):Y(f),K(f.selectedObjectId&&ge(f.selectedObjectId)?f.selectedObjectId:null,!1),fe(O&&ge(O)?O:null,!1),B=B&&ge(B)?B:null,Ht(),Oe(),qe(),e.onViewChange?.({...f}),Ne()}function Be(P){f=Y(P),Ht(),e.onViewChange?.({...f}),Ne()}function Y(P){return{scale:Gr(P.scale,i.minScale,i.maxScale),rotationDeg:zv(P.rotationDeg),translateX:Number.isFinite(P.translateX)?P.translateX:f.translateX,translateY:Number.isFinite(P.translateY)?P.translateY:f.translateY,selectedObjectId:P.selectedObjectId&&ge(P.selectedObjectId)?P.selectedObjectId:null}}function de(){if(Pe()){Et();return}y&&(y.setAttribute("transform",Dd(u,f)),rr(),Re(),Fe())}function K(P,$=!0){if(!Pe()&&f.selectedObjectId)for(let G of n.querySelectorAll(`[data-object-id="${Ba(f.selectedObjectId)}"]`))G.classList.remove("wo-object-selected");if(f={...f,selectedObjectId:P&&ge(P)?P:null},!Pe()&&f.selectedObjectId)for(let G of n.querySelectorAll(`[data-object-id="${Ba(f.selectedObjectId)}"]`))G.classList.add("wo-object-selected");D(),Fe(),$&&(e.onSelectionChange?.(ie()),e.onSelectionDetailsChange?.(Ie(f.selectedObjectId)),e.onViewChange?.({...f}),Ne())}function fe(P,$=!0){O===P&&$||(O=P&&ge(P)?P:null,D(),Fe(),$&&(e.onHoverChange?.(ge(O)),e.onHoverDetailsChange?.(Ie(O))))}function ie(){return ge(f.selectedObjectId)}function ge(P){if(!P)return null;let $=ae();return u.objects.find(G=>G.objectId===P&&!G.hidden&&$.has(G.objectId))??null}function Ie(P){let $=ge(P);return $?{objectId:$.objectId,object:$.object,renderObject:$,label:u.labels.find(G=>G.objectId===$.objectId&&!G.hidden)??null,group:u.groups.find(G=>G.renderId===$.groupId)??null,semanticGroups:u.semanticGroups.filter(G=>$.semanticGroupIds.includes(G.id)),orbit:u.orbitVisuals.find(G=>G.objectId===$.objectId&&!G.hidden)??null,relatedOrbits:u.orbitVisuals.filter(G=>!G.hidden&&(G.objectId===$.objectId||$.ancestorIds.includes(G.objectId)||$.childIds.includes(G.objectId))),relations:u.relations.filter(G=>!G.hidden&&(G.fromObjectId===$.objectId||G.toObjectId===$.objectId)),relatedEvents:u.events.filter(G=>!G.hidden&&(G.targetObjectId===$.objectId||G.objectIds.includes($.objectId))),parent:ge($.parentId),children:$.childIds.map(G=>ge(G)).filter(Boolean),ancestors:$.ancestorIds.map(G=>ge(G)).filter(Boolean),focusPath:Ue($.objectId)}:null}function D(){if(Pe()){Et();return}for(let P of n.querySelectorAll(".wo-chain-selected, .wo-chain-hover, .wo-ancestor-selected, .wo-ancestor-hover, .wo-orbit-related-selected, .wo-orbit-related-hover"))P.classList.remove("wo-chain-selected","wo-chain-hover","wo-ancestor-selected","wo-ancestor-hover","wo-orbit-related-selected","wo-orbit-related-hover");A(f.selectedObjectId,{objectClass:"wo-chain-selected",ancestorClass:"wo-ancestor-selected",orbitClass:"wo-orbit-related-selected"}),A(O,{objectClass:"wo-chain-hover",ancestorClass:"wo-ancestor-hover",orbitClass:"wo-orbit-related-hover"})}function A(P,$){let G=Ie(P);if(!G)return;let E=new Set([G.objectId,...G.renderObject.childIds,...G.renderObject.ancestorIds]);for(let _ of E)for(let S of n.querySelectorAll(`[data-object-id="${Ba(_)}"]`))S.classList.add($.objectClass);for(let _ of G.ancestors)for(let S of n.querySelectorAll(`[data-object-id="${Ba(_.objectId)}"]`))S.classList.add($.ancestorClass);for(let _ of G.relatedOrbits)for(let S of n.querySelectorAll(`[data-orbit-object-id="${Ba(_.objectId)}"]`))S.classList.add($.orbitClass)}function j(P,$){if(Pe()){let E=n.getBoundingClientRect();return!E.width||!E.height?{x:u.width/2,y:u.height/2}:{x:P-E.left,y:$-E.top}}if(!p)return{x:u.width/2,y:u.height/2};let G=p.getBoundingClientRect();return!G.width||!G.height?{x:u.width/2,y:u.height/2}:{x:(P-G.left)/G.width*u.width,y:($-G.top)/G.height*u.height}}function te(P,$){return ur(u,f,j(P,$))}function ae(){return _c(u,s.filter??null)}function re(){let P=ae();return u.objects.filter($=>!$.hidden&&P.has($.objectId))}function Ue(P){let $=u.objects.find(G=>G.objectId===P&&!G.hidden);return $?[...$.ancestorIds,$.objectId].map(G=>ge(G)).filter(Boolean):[]}function be(P){return u.viewpoints.find($=>$.id===P)??null}function _e(P){let $=zv(P.rotationDeg),G=P.scale!==null&&P.scale!==void 0?Gr(P.scale,i.minScale,i.maxScale):null;if(Pe()){let S=P.objectId??P.selectedObjectId??null,T=S?h?.focusTargets.find(I=>I.objectId===S):null;return{scale:G??1.6,rotationDeg:$,translateX:T?-T.center.x:0,translateY:T?-T.center.z:0,selectedObjectId:P.selectedObjectId??P.objectId??null}}let E=P.objectId&&u.objects.find(S=>S.objectId===P.objectId&&!S.hidden);if(E)return je({x:E.x,y:E.y},G??Math.max(1.8,Rn.scale),$,P.selectedObjectId??E.objectId);let _=rs(u,{...Rn,rotationDeg:$},i);return G===null?{..._,rotationDeg:$,selectedObjectId:P.selectedObjectId??null}:je({x:u.contentBounds.centerX,y:u.contentBounds.centerY},G,$,P.selectedObjectId??null)}function je(P,$,G,E){let _={x:u.width/2,y:u.height/2},S=sn(P,_,G);return{scale:$,rotationDeg:G,translateX:_.x-(_.x+(S.x-_.x)*$),translateY:_.y-(_.y+(S.y-_.y)*$),selectedObjectId:E}}function pe(P,$,G){s={...s,filter:zn(P)},G&&(X=null),V(!1)}function Oe(){e.onFilterChange?.(s.filter??null,re())}function qe(){e.onViewpointChange?.(be(X))}function Ne(){e.onAtlasStateChange?.(xe.getAtlasState())}function Re(){!r.minimap||!m||(m.innerHTML=wg(u,f,re()))}function Fe(){if(r.tooltipMode==="disabled"||!v){Ae(null);return}let P=et();if(!P){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),Ae(null);return}let $=Ie(P.objectId);if(!$){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),Ae(null);return}let G=Uv($);F=P.objectId,v.hidden=!1,v.dataset.mode=P.mode,v.classList.toggle("is-pinned",P.mode==="pinned"),v.style.pointerEvents="auto",v.style.visibility="hidden",mt(v,G,P.mode),Ge(v,$.renderObject),v.style.visibility="visible",Ae(G)}function et(){return B&&ge(B)?{objectId:B,mode:"pinned"}:O&&ge(O)?{objectId:O,mode:"hover"}:null}function mt(P,$,G){let E=e.tooltipRenderer?.($,G);P.innerHTML="",typeof E=="string"?P.innerHTML=E:E instanceof HTMLElement?P.append(E):P.innerHTML=Nv($,G);let _=document.createElement("div");if(_.className="wo-tooltip-actions",G==="pinned"){let S=document.createElement("button");S.type="button",S.className="wo-tooltip-action",S.dataset.tooltipAction="unpin",S.textContent="Unpin",_.append(S)}else{let S=document.createElement("button");S.type="button",S.className="wo-tooltip-action",S.dataset.tooltipAction="pin",S.dataset.objectId=$.objectId,S.textContent="Pin",_.append(S)}_.childElementCount>0&&P.append(_)}function Ge(P,$){let G=Pe()?g?.projectObjectToContainer($.objectId)??null:ue($);if(!G)return;let E=Math.max(n.clientWidth-P.offsetWidth-12,12),_=Math.max(n.clientHeight-P.offsetHeight-12,12),S=G.y>n.clientHeight*.48,T=Gr(G.x+18,12,E),I=Gr(S?G.y-P.offsetHeight-18:G.y+18,12,_);P.style.left=`${T}px`,P.style.top=`${I}px`}function z(P){if(Pe())return P;let $={x:u.width/2,y:u.height/2},G=sn(P,$,f.rotationDeg);return{x:$.x+(G.x-$.x)*f.scale+f.translateX,y:$.y+(G.y-$.y)*f.scale+f.translateY}}function ue(P){let $={x:P.anchorX??P.x,y:P.anchorY??P.y-Math.max(P.visualRadius,P.radius)};return Q($)}function Q(P){if(!p)return null;let $=z(P),G=p.getBoundingClientRect(),E=n.getBoundingClientRect();return{x:G.left-E.left+$.x/Math.max(u.width,1)*G.width,y:G.top-E.top+$.y/Math.max(u.height,1)*G.height}}function Se(P){let $=P.target?.closest("[data-tooltip-action]");if($){switch(P.preventDefault(),P.stopPropagation(),$.dataset.tooltipAction){case"pin":B=$.dataset.objectId??F;break;case"unpin":B=null;break}Fe()}}function Ae(P){let $=H?.objectId!==P?.objectId||H?.description!==P?.description||H?.imageHref!==P?.imageHref;H=P,F=P?.objectId??null,$&&e.onTooltipChange?.(P)}function Pe(){return s.viewMode==="3d"}function nt(){k={...k,frozenByEvent:h?.timeFrozen??!1},k.frozenByEvent&&(k={...k,playing:!1},xt())}function pt(){ee!==null||!k.playing||N||(ee=window.requestAnimationFrame(st))}function xt(){ee!==null&&(window.cancelAnimationFrame(ee),ee=null),ce=null}function st(P){if(ee=null,!k.playing||N){ce=null;return}let G=Math.max((P-(ce??P))/1e3,0);ce=P,k={...k,timeSeconds:k.timeSeconds+G*k.speed},Et(),pt()}function Ht(){de(),Pe()&&k.playing?pt():(!k.playing||!Pe())&&xt()}function Et(){!Pe()||!g||!h||(g.update({spatialScene:h,renderOptions:s,visibleObjectIds:ae(),selectedObjectId:f.selectedObjectId,hoveredObjectId:O,state:f,timeSeconds:k.timeSeconds}),rr(),Re(),Fe())}function Xr(){if(!Pe()){n.querySelector('[data-layer-id="labels"]')?.setAttribute("display","none");for(let P of n.querySelectorAll(".wo-event-label"))P.setAttribute("display","none")}}function rr(){if(!x)return;let P=kn();x.replaceChildren(...P.map($=>sr($))),x.hidden=P.length===0}function kn(){let P=[],$=ae();if(In("labels"))for(let G of u.labels){if(G.hidden||!$.has(G.objectId))continue;let E=Pe()?g?.projectObjectToContainer(G.objectId)??null:Q({x:G.x,y:G.y});E&&P.push({key:`object:${G.renderId}`,kind:"object",point:Pe()?{x:E.x,y:E.y-18}:E,textAnchor:G.textAnchor,objectId:G.objectId,primaryText:G.label,secondaryText:G.secondaryLabel,secondaryOffset:Math.max(G.secondaryY-G.y,12)})}if(!Pe()&&In("events"))for(let G of u.events){if(G.hidden||!Tn(G,$))continue;let E=Q({x:G.x,y:G.y-10});E&&P.push({key:`event:${G.renderId}`,kind:"event",point:E,textAnchor:"middle",primaryText:G.event.label||G.event.id})}return P}function Tn(P,$){return P.objectIds.some(G=>$.has(G))}function sr(P){let $=document.createElement("div");if($.className=`wo-viewer-label wo-viewer-label-${P.kind}`,$.dataset.worldorbitScreenLabel="true",$.dataset.labelKey=P.key,$.dataset.anchor=P.textAnchor,$.style.left=`${P.point.x}px`,$.style.top=`${P.point.y}px`,P.objectId){$.dataset.objectId=P.objectId;for(let E of Yr(P.objectId))$.classList.add(E)}let G=document.createElement("span");if(G.className="wo-viewer-label-primary",P.kind==="object"&&(G.style.fontSize=`${14*u.scaleModel.labelMultiplier}px`),G.textContent=P.primaryText,$.append(G),P.secondaryText){let E=document.createElement("span");E.className="wo-viewer-label-secondary",E.style.fontSize=`${11*u.scaleModel.labelMultiplier}px`,E.style.marginTop=`${Math.max(P.secondaryOffset??12,10)-10}px`,E.textContent=P.secondaryText,$.append(E)}return $}function In(P){return s.layers?.[P]!==!1}function Yr(P){let $=[],G=Ie(f.selectedObjectId),E=Ie(O);if(f.selectedObjectId===P&&$.push("wo-object-selected"),G){let _=new Set([G.objectId,...G.renderObject.childIds,...G.renderObject.ancestorIds]),S=new Set(G.ancestors.map(T=>T.objectId));_.has(P)&&$.push("wo-chain-selected"),S.has(P)&&$.push("wo-ancestor-selected")}if(E){let _=new Set([E.objectId,...E.renderObject.childIds,...E.renderObject.ancestorIds]),S=new Set(E.ancestors.map(T=>T.objectId));_.has(P)&&$.push("wo-chain-hover"),S.has(P)&&$.push("wo-ancestor-hover")}return $}function qr(P){let $=h?.focusTargets.find(G=>G.objectId===P);return $?{scale:1.8,rotationDeg:f.rotationDeg,translateX:-$.center.x,translateY:-$.center.z,selectedObjectId:P}:{...Rn,selectedObjectId:P}}}function I2(n){if(n.scene)return{kind:"scene",value:n.scene};if(n.document)return{kind:"document",value:n.document};if(n.source)return{kind:"source",value:n.source};throw new Error("Interactive viewer requires an initial render input.")}function ka(n,e){switch(n.kind){case"scene":return n.value;case"document":return rn(n.value,e);case"source":{let t=ii(n.value);return rn(t.document,Vv(t,e))}}}function jr(n,e,t){if(t)return t;switch(n.kind){case"scene":return R2(n.value);case"document":return es(n.value,e);case"source":{let i=ii(n.value);return es(i.document,Vv(i,e))}}}function C2(n){return{...n,camera:n.camera?{...n.camera}:null,filter:n.filter?{...n.filter}:void 0,scaleModel:n.scaleModel?{...n.scaleModel}:void 0,layers:n.layers?{...n.layers}:void 0,theme:n.theme&&typeof n.theme=="object"?{...n.theme}:n.theme,activeEventId:n.activeEventId??null,viewMode:n.viewMode??"2d"}}function Fp(n,e){return{...n,...e,camera:e.camera!==void 0?e.camera?{...e.camera}:null:n.camera?{...n.camera}:null,filter:e.filter!==void 0?zn(e.filter):n.filter?{...n.filter}:void 0,scaleModel:e.scaleModel?{...n.scaleModel??{},...e.scaleModel}:n.scaleModel?{...n.scaleModel}:void 0,layers:e.layers?{...n.layers??{},...e.layers}:n.layers?{...n.layers}:void 0,theme:e.theme&&typeof e.theme=="object"?{...e.theme}:e.theme??n.theme,viewMode:e.viewMode??n.viewMode??"2d"}}function kv(n){return n.width!==void 0||n.height!==void 0||n.padding!==void 0||n.preset!==void 0||n.projection!==void 0||n.camera!==void 0||n.scaleModel!==void 0||n.activeEventId!==void 0}function Vv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function R2(n){return{width:n.width,height:n.height,padding:n.padding,renderPreset:n.renderPreset,projection:n.projection,camera:n.camera,scaleModel:{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40},title:n.title,subtitle:n.subtitle,systemId:n.systemId,viewMode:"3d",layoutPreset:n.layoutPreset,metadata:{...n.metadata,"viewer.mode":"3d-fallback"},contentBounds:{minX:n.contentBounds.minX-n.contentBounds.centerX,minY:-40,minZ:n.contentBounds.minY-n.contentBounds.centerY,maxX:n.contentBounds.maxX-n.contentBounds.centerX,maxY:40,maxZ:n.contentBounds.maxY-n.contentBounds.centerY,width:n.contentBounds.width,height:80,depth:n.contentBounds.height,center:{x:0,y:0,z:0}},semanticGroups:n.semanticGroups,viewpoints:n.viewpoints,activeEventId:n.activeEventId,timeFrozen:n.activeEventId!==null,objects:n.objects.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,ancestorIds:e.ancestorIds.slice(),childIds:e.childIds.slice(),groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),position:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.radius,visualRadius:e.visualRadius,label:e.label,secondaryLabel:e.secondaryLabel,fillColor:e.fillColor,imageHref:e.imageHref,hidden:e.hidden,motion:null})),orbits:n.orbitVisuals.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),center:{x:0,y:0,z:0},kind:e.kind,radius:e.radius,semiMajor:e.radius??e.rx??0,semiMinor:e.radius??e.ry??0,rotationDeg:e.rotationDeg,inclinationDeg:0,band:e.band,bandThickness:e.bandThickness,hidden:e.hidden,motion:null})),focusTargets:n.objects.map(e=>({objectId:e.objectId,center:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.visualRadius+12}))}}function Bv(n,e,t){let{center:i,distance:r}=$v(t);return{startState:{...e},startCenter:ur(n,e,i),startViewportCenter:i,startDistance:r}}function $v(n){let e=[...n.values()];if(e.length<2)return{center:e[0]??{x:0,y:0},distance:1};let[t,i]=e;return{center:{x:(t.x+i.x)/2,y:(t.y+i.y)/2},distance:Math.hypot(i.x-t.x,i.y-t.y)}}function Vu(n){return n instanceof Element?n.closest("[data-object-id]")?.dataset.objectId??null:null}function P2(n){if(typeof window>"u"||typeof document>"u")throw new Error("createInteractiveViewer can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("Interactive viewer requires an HTMLElement container.")}function Gr(n,e,t){return Math.min(Math.max(n,e),t)}function zv(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function Ba(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/["\\]/g,"\\$&")}function L2(){if(typeof document>"u"||document.getElementById(Fv))return;let n=document.createElement("style");n.id=Fv,n.textContent=`
3946
3946
  .wo-viewer-3d-root {
3947
3947
  position: relative;
3948
3948
  min-height: 320px;
@@ -3971,6 +3971,56 @@ void main() {
3971
3971
  height: 100%;
3972
3972
  min-height: 320px;
3973
3973
  }
3974
+ .wo-viewer-label-root {
3975
+ position: absolute;
3976
+ inset: 0;
3977
+ z-index: 8;
3978
+ pointer-events: none;
3979
+ overflow: hidden;
3980
+ }
3981
+ .wo-viewer-label {
3982
+ position: absolute;
3983
+ display: grid;
3984
+ gap: 2px;
3985
+ color: #edf6ff;
3986
+ font-family: "Segoe UI Variable", "Segoe UI", sans-serif;
3987
+ line-height: 1.15;
3988
+ text-shadow: 0 1px 2px rgba(7, 16, 25, 0.65), 0 0 18px rgba(7, 16, 25, 0.18);
3989
+ white-space: nowrap;
3990
+ }
3991
+ .wo-viewer-label[data-anchor="middle"] { transform: translate(-50%, 0); }
3992
+ .wo-viewer-label[data-anchor="end"] { transform: translate(-100%, 0); }
3993
+ .wo-viewer-label-primary {
3994
+ font-size: 14px;
3995
+ font-weight: 600;
3996
+ letter-spacing: 0.02em;
3997
+ }
3998
+ .wo-viewer-label-secondary {
3999
+ font-size: 11px;
4000
+ font-weight: 500;
4001
+ color: rgba(237, 246, 255, 0.72);
4002
+ }
4003
+ .wo-viewer-label-event {
4004
+ color: #ffce8a;
4005
+ text-transform: uppercase;
4006
+ letter-spacing: 0.04em;
4007
+ }
4008
+ .wo-viewer-label-event .wo-viewer-label-primary {
4009
+ font-size: 10px;
4010
+ font-weight: 700;
4011
+ }
4012
+ .wo-viewer-label.wo-object-selected .wo-viewer-label-primary,
4013
+ .wo-viewer-label.wo-chain-selected .wo-viewer-label-primary,
4014
+ .wo-viewer-label.wo-chain-hover .wo-viewer-label-primary {
4015
+ color: #ffce8a;
4016
+ }
4017
+ .wo-viewer-label.wo-object-selected .wo-viewer-label-secondary {
4018
+ color: #8fcaff;
4019
+ }
4020
+ .wo-viewer-label.wo-ancestor-selected .wo-viewer-label-primary,
4021
+ .wo-viewer-label.wo-ancestor-hover .wo-viewer-label-primary {
4022
+ opacity: 0.82;
4023
+ }
3974
4024
  .wo-viewer-tooltip-root {
3975
4025
  position: absolute;
3976
4026
  z-index: 12;
@@ -4036,10 +4086,10 @@ void main() {
4036
4086
  padding: 6px 12px;
4037
4087
  font: 600 12px/1.3 "Segoe UI Variable", "Segoe UI", sans-serif;
4038
4088
  }
4039
- `,document.head.append(n)}function Hv(n){return encodeURIComponent(JSON.stringify(n))}function Bp(n,e,t={}){return{version:"2.0",mode:kp(e),scene:n,spatialScene:t.spatialScene,options:{viewMode:t.viewMode??Gv(kp(e)),initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}}}function zp(n,e={}){let t={...n,options:{...n.options,theme:e.theme??n.options?.theme,layers:e.layers??n.options?.layers,subtitle:e.subtitle??n.options?.subtitle,preset:e.preset??n.options?.preset,viewMode:e.viewMode??n.options?.viewMode??Gv(kp(n.mode)),initialViewpointId:e.initialViewpointId??n.options?.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId??n.options?.initialSelectionObjectId,initialFilter:e.initialFilter??n.options?.initialFilter??null,atlasState:e.atlasState??n.options?.atlasState??null,minimap:e.minimap??n.options?.minimap}},i=ai(n.scene,{theme:t.options?.theme,layers:t.options?.layers,filter:t.options?.initialFilter??null,selectedObjectId:t.options?.initialSelectionObjectId??null,subtitle:t.options?.subtitle,preset:t.options?.preset});return`<div class="${$u(e.className??"worldorbit-embed")}" data-worldorbit-embed="true" data-worldorbit-mode="${t.mode}" data-worldorbit-preset="${$u(t.options?.preset??n.scene.renderPreset??"custom")}" data-worldorbit-viewpoint="${$u(t.options?.initialViewpointId??"")}" data-worldorbit-payload="${$u(Hv(t))}">${i}</div>`}function $u(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function kp(n){return!n||n==="interactive"?"interactive-2d":n}function Gv(n){return n==="interactive-3d"?"3d":"2d"}function za(n,e={}){try{let t=si(n),i=cn(t.document,jv(t,e)),r=e.mode??"static";if(r==="interactive"||r==="interactive-2d"||r==="interactive-3d"){let s=r==="interactive"?"interactive-2d":r;return zp(Bp(i,s,{spatialScene:s==="interactive-3d"?Kr(t.document,jv(t,e)):void 0,viewMode:s==="interactive-3d"?"3d":"2d",initialViewpointId:e.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId,initialFilter:e.initialFilter??null,atlasState:e.atlasState??null,minimap:e.minimap}),{className:e.className??"worldorbit-block worldorbit-interactive",theme:e.theme,layers:e.layers,subtitle:e.subtitle,preset:e.preset,viewMode:s==="interactive-3d"?"3d":"2d",initialViewpointId:e.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId,initialFilter:e.initialFilter??null,atlasState:e.atlasState??null,minimap:e.minimap})}return`<figure class="${O2(e.className??"worldorbit-block worldorbit-static")}">${ai(i,e)}</figure>`}catch(t){if(e.strict)throw t;return Wv(t instanceof Error?t.message:String(t))}}function Wv(n){return`<pre class="worldorbit-error">WorldOrbit error: ${Xv(n)}</pre>`}function Xv(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function O2(n){return Xv(n).replaceAll('"',"&quot;")}function jv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}var Yv="worldorbit-editor-style",U2=120,N2=16,F2=96,Ks=1495978707e-1,Qv=6371,ex=695700,$p=new Set(["placement","target","reference","distance","semiMajor","eccentricity","period","angle","inclination","phase","descriptor"]),k2=new Set(["star","planet","moon","asteroid","comet"]),Gp=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],B2=["kind","class","culture","color","image","atmosphere","on","source"],z2=["radius","mass","density","gravity","temperature","inner","outer","cycle"],V2=["albedo"],$2={"defaults-view":{description:"Sets the default camera projection for the atlas.",references:["Topdown = map-like","Isometric = angled overview","Orthographic/Perspective = 3D-ready semantic views"]},"defaults-scale":{description:"Chooses the overall spacing/style preset used by the renderer.",references:["diagram = tighter","presentation = roomier"]},"defaults-units":{description:"Stores a document-wide note about the unit style you want to use.",references:["Example: metric","Example: lore-standard"]},"viewpoint-projection":{description:"Overrides the projection for this saved viewpoint.",references:["Topdown = flat orbital map","Isometric = angled scene","Orthographic/Perspective = stored with current 2D fallback"]},"viewpoint-zoom":{description:"Controls how closely this viewpoint frames the system.",references:["1 = scene fit","2+ = close-up"]},"viewpoint-rotation":{description:"Legacy 2D screen rotation. This is separate from the Schema 2.5 camera block.",references:["90deg = quarter turn","Use camera.azimuth for semantic view direction"]},"viewpoint-camera-azimuth":{description:"Horizontal camera direction in degrees for Schema 2.5 viewpoints.",references:["0 = forward/default","90 = quarter orbit around the scene"]},"viewpoint-camera-elevation":{description:"Vertical camera tilt in degrees for 3D-ready viewpoints.",references:["0 = level","30 = gentle look down"]},"viewpoint-camera-roll":{description:"Rolls the camera around its forward axis.",references:["0 = upright","15 = slight bank"]},"viewpoint-camera-distance":{description:"Semantic camera distance for perspective viewpoints.",references:["4 = close","12 = wide framing"]},"viewpoint-events":{description:"Lists event IDs that this viewpoint should feature in its detail panel.",references:["solar-eclipse-naar","transit-window conjunction"]},"event-kind":{description:"Short semantic event type for tooling and viewer overlays.",references:["solar-eclipse","lunar-eclipse","transit"]},"event-target":{description:"Primary object this event is centered on.",references:["Naar","Seyra"]},"event-participants":{description:"Objects that participate in the event snapshot or description.",references:["Iyath Naar Seyra","Naar Seyra Orun"]},"event-timing":{description:"Free-text timing note for the event.",references:['"Every late bloom season"','"At local midyear"']},"event-visibility":{description:"Notes where or how the event is visible.",references:['"Visible from Naar"','"Southern hemisphere only"']},"event-epoch":{description:"Optional event-wide epoch that event poses inherit unless they override it.",references:['"JY-0001.0"','"Naar bloom cycle year 18"']},"event-referencePlane":{description:"Optional event-wide reference plane for all poses in this snapshot.",references:["ecliptic","naar-equatorial"]},"event-viewpoints":{description:"Viewpoint IDs that should list this event prominently.",references:["naar-system","overview inner-system"]},"placement-target":{description:"Names the body or reference this object is attached to.",references:["orbit Primary","surface Homeworld","at Naar:L4"]},"placement-free":{description:"Stores a free-placement offset or a descriptive label for loose placement.",references:["8au = far from the star",'"outer system" = descriptive note']},"placement-distance":{description:"Mean orbit distance from the target body.",references:["1 au = Earth-Sun distance","384400km = Earth-Moon distance"]},"placement-semiMajor":{description:"Semi-major axis of an orbit, used for elliptical orbits.",references:["1 au = Earth-Sun distance","Use this instead of distance when orbit shape matters"]},"placement-eccentricity":{description:"Controls how stretched the orbit is. Lower is rounder.",references:["0 = circular orbit","0.1 = mildly elliptical"]},"placement-period":{description:"How long one orbit takes.",references:["1 y = one Earth year","27.3d = Moon around Earth"]},"placement-angle":{description:"Rotates the orbit ellipse within the scene.",references:["0deg = default orientation","90deg = quarter turn"]},"placement-inclination":{description:"Tilts the orbit relative to the main orbital plane.",references:["0deg = same plane","5deg = slight tilt"]},"placement-phase":{description:"Starting position of the object along its orbit.",references:["0deg = start position","180deg = opposite side"]},"pose-epoch":{description:"Overrides the effective epoch for this pose only.",references:['"JY-0001.0"',"Falls back to event, object, then system"]},"pose-referencePlane":{description:"Overrides the effective reference plane for this pose only.",references:["naar-equatorial","Falls back to event, object, then system"]},"prop-radius":{description:"Visual body size or real-world-inspired radius value.",references:["1re = Earth radius","1sol = Sun radius"]},"prop-mass":{description:"Optional mass value for the body.",references:["1me = Earth mass","1sol = Sun mass"]},"prop-gravity":{description:"Surface gravity or a custom gravity marker.",references:["1g = Earth-like gravity","0.16g = Moon-like gravity"]},"prop-temperature":{description:"Typical temperature or narrative temperature marker.",references:["288K = Earth-like average","1200K = very hot world"]},"prop-atmosphere":{description:"Short atmosphere descriptor for the object.",references:['"nitrogen-oxygen"','"methane haze"']},"prop-inner":{description:"Inner edge for a belt, ring, or broad phenomenon.",references:["120000km = ring inner edge","2au = belt starts here"]},"prop-outer":{description:"Outer edge for a belt, ring, or broad phenomenon.",references:["190000km = ring outer edge","3au = belt ends here"]}};function tx(n,e={}){zC(n),VC();let t=H2(e),i=t.atlasDocument,r=t.source,s=r,o=r,a=t.diagnostics,c=i.objects[0]?{kind:"object",id:i.objects[0].id}:{kind:"system"},l=[],u=[],d=null,h=!1,f=!1,p=!1,y=null,g=null,m="",v="",x=new Map,w=e.showTextPane??!0,O=e.showInspector??!0,I=e.showPreview??!0,R=e.shortcuts??!0,U=e.viewMode??"2d";n.classList.add("wo-editor"),n.dataset.woShowInspector=String(O),n.dataset.woShowTextPane=String(w),n.dataset.woShowPreview=String(I),n.innerHTML=G2();let _=wn(n,"[data-editor-toolbar]"),b=wn(n,"[data-editor-outline]"),D=wn(n,"[data-editor-stage-shell]"),z=wn(n,"[data-editor-stage]"),F=wn(n,"[data-editor-overlay]"),$=wn(n,"[data-editor-diagnostics]"),W=wn(n,"[data-editor-source-diagnostics]"),ne=wn(n,"[data-editor-status]"),J=wn(n,"[data-editor-live]"),V=wn(n,"[data-editor-inspector]"),ce=wn(n,"[data-editor-source]"),fe=wn(n,"[data-editor-preview-visual]"),Te=wn(n,"[data-editor-preview-markup]"),ve=null;ve=Zs(z,{source:r,width:e.viewerWidth??1120,height:e.viewerHeight??680,preset:i.system?.defaults.preset??"atlas-card",projection:"document",viewMode:U,minimap:!0,tooltipMode:"hover",onSelectionChange(M){let S=c?Vp(c):null;if(h||!M){h||(c?.kind==="event-pose"&&c.id?K({kind:"event",id:c.id},!1,!0):c?.kind==="object"?K(S?{kind:"event",id:S}:null,!1,!0):c?.kind==="event"&&c.id&&K({kind:"event",id:c.id},!1,!0));return}if(S&&sx(i,S,M.objectId)){K({kind:"event-pose",id:S,key:M.objectId},!1,!0);return}K({kind:"object",id:M.objectId},!1,!0)},onViewChange(){xe()}}),_.addEventListener("click",Oe),b.addEventListener("click",Ge),F.addEventListener("pointerdown",ue),V?.addEventListener("click",Ne),V?.addEventListener("input",Me),V?.addEventListener("change",Ye),ce?.addEventListener("input",yt),ce?.addEventListener("change",je),ce?.addEventListener("blur",je),n.addEventListener("keydown",k),window.addEventListener("pointermove",ee),window.addEventListener("pointerup",de),window.addEventListener("pointercancel",de);let He={setSource(M){he(M,!1)&&(Z(),L())},setAtlasDocument(M){X(M,!1,c,!1),Z(),L()},getSource(){return r},getAtlasDocument(){return lt(i)},getDiagnostics(){return a.map(ju)},getSelection(){return c?{path:{...c}}:null},getViewMode(){return U},setViewMode(M){let S=U;try{ve.setViewMode(M),U=M,xe(),xt()}catch(A){throw U=S,A}},isDirty(){return p},markSaved(){B(!0)},selectPath(M){K(M,!0,!0)},canUndo(){return l.length>0},canRedo(){return u.length>0},undo(){let M=l.pop();return M?(u.unshift(q()),Je(M),!0):!1},redo(){let M=u.shift();return M?(l.push(q()),Je(M),!0):!1},addObject(M="planet"){let S=Ha(M,i.objects.map(j=>j.id)),A=lC(M,S,i),T=uC(i,A);return X(T,!0,{kind:"object",id:S}),S},addEvent(){let M=Ha("event",i.events.map(T=>T.id)),S={id:M,kind:"",label:Ga(M),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},A=lt(i);return A.events.push(S),A.events.sort(Jv),X(A,!0,{kind:"event",id:M}),M},addViewpoint(){let M=Ha("viewpoint",i.system?.viewpoints.map(T=>T.id)??[]),S={id:M,label:Ga(M),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:i.system?.defaults.view??"topdown",preset:i.system?.defaults.preset??null,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null},A=lt(i);return A.system?.viewpoints.push(S),A.system?.viewpoints.sort((T,j)=>T.id.localeCompare(j.id)),X(A,!0,{kind:"viewpoint",id:M}),M},addAnnotation(){let M=Ha("annotation",i.system?.annotations.map(T=>T.id)??[]),S={id:M,label:Ga(M),targetObjectId:null,body:"",tags:[],sourceObjectId:null},A=lt(i);return A.system?.annotations.push(S),A.system?.annotations.sort((T,j)=>T.id.localeCompare(j.id)),X(A,!0,{kind:"annotation",id:M}),M},addMetadata(M,S){let A=M?.trim()||Ha("metadata",Object.keys(i.system?.atlasMetadata??{})),T=lt(i);return T.system&&(T.system.atlasMetadata[A]=S??""),X(T,!0,{kind:"metadata",key:A}),A},removeSelection(){if(!c||c.kind==="system"||c.kind==="defaults")return!1;let M=fC(i,c);return X(M,!0,{kind:"system"}),!0},exportSvg(){return ve.exportSvg()},exportEmbedMarkup(){return Zv(Ie(),i,U)},destroy(){f||(f=!0,_.removeEventListener("click",Oe),b.removeEventListener("click",Ge),F.removeEventListener("pointerdown",ue),V?.removeEventListener("click",Ne),V?.removeEventListener("input",Me),V?.removeEventListener("change",Ye),ce?.removeEventListener("input",yt),ce?.removeEventListener("change",je),ce?.removeEventListener("blur",je),n.removeEventListener("keydown",k),window.removeEventListener("pointermove",ee),window.removeEventListener("pointerup",de),window.removeEventListener("pointercancel",de),ye(),ae(),ve.destroy(),n.innerHTML="",n.classList.remove("wo-editor"))}};return De(!0),Re(!0),He;function q(){return{atlasDocument:lt(i),selection:c?{...c}:null,source:r}}function Z(){l.length=0,u.length=0,L()}function ye(){y!==null&&(window.clearTimeout(y),y=null)}function ae(){g!==null&&(window.clearTimeout(g),g=null)}function Ie(){return d?.changed?ir(i):r}function Re(M=!1){let S=s!==o||r!==o||d?.changed===!0;!M&&S===p||(p=S,$e(),e.onDirtyChange?.(p))}function B(M=!1){s=r,re(),o=r,Re(M)}function Je(M){ye(),i=lt(M.atlasDocument),r=M.source,s=r,a=rr(i),c=we(M.selection),Q({preserveCamera:!0,applyViewpointSelection:c?.kind==="viewpoint"}),K(c,!1,!1),De(),Re(),me()}function X(M,S,A,T=!1){S&&(l.push(q()),u.length=0),ye(),i=lt(M),r=ir(i),T||(s=r),a=rr(i),c=we(A),Q({preserveCamera:c?.kind!=="viewpoint",applyViewpointSelection:c?.kind==="viewpoint"}),K(c,!1,!1),De(),Re(),me()}function he(M,S){s=M,ce&&ce.value!==M&&(ce.value=M);let A=wo(M);if(!A.ok||!A.value)return a=A.diagnostics.map(ie=>({diagnostic:ie,path:null})),H(),te(),E(),le(),$e(),We(),Re(),e.onDiagnosticsChange?.(a.map(ju)),!1;let T=A.value.atlasDocument??lr(A.value.document),j=_o(T,A.diagnostics);return S&&(l.push(q()),u.length=0,s=ir(T)),i=lt(T),r=ir(i),a=ix(j,rr(i)),c=we(c),Q({preserveCamera:c?.kind!=="viewpoint",applyViewpointSelection:c?.kind==="viewpoint"}),De(),Re(),me(),!0}function Q(M={}){if(!ve)return;let S=ve.getState(),A=ve.getRenderOptions(),T=i.system?.defaults.preset??"atlas-card",j=c?Vp(c):null;h=!0,(A.preset!==T||A.projection!=="document"||(A.activeEventId??null)!==j)&&ve.setRenderOptions({preset:T,projection:"document",activeEventId:j}),ve.setDocument(go(i)),M.applyViewpointSelection&&c?.kind==="viewpoint"&&c.id?ve.goToViewpoint(c.id):M.preserveCamera!==!1?ve.setState({...S,selectedObjectId:c?.kind==="object"?c.id??null:c?.kind==="event-pose"?c.key??null:null}):c?.kind==="object"&&c.id?ve.focusObject(c.id):c?.kind==="event-pose"&&c.key&&ve.focusObject(c.key),h=!1}function me(){let M={source:r,atlasDocument:lt(i),diagnostics:a.map(ju),selection:c?{path:{...c}}:null};e.onDiagnosticsChange?.(M.diagnostics),e.onSelectionChange?.(M.selection),e.onChange?.(M)}function K(M,S,A=!0){c=we(M),S&&(h=!0,ve.setRenderOptions({activeEventId:c?Vp(c):null}),c?.kind==="object"&&c.id?ve.focusObject(c.id):c?.kind==="event-pose"&&c.key?ve.focusObject(c.key):c?.kind==="viewpoint"&&c.id&&ve.goToViewpoint(c.id),h=!1),L(),E(),V?.contains(document.activeElement)||le(),xe(),$e(),We(),A&&e.onSelectionChange?.(c?{path:{...c}}:null)}function we(M){if(!M)return null;let S=_d(i,M);return S==null?M.kind==="system"||M.kind==="defaults"?M:null:M}function De(M=!1){L(),E(),H(),te(),V?.contains(document.activeElement)||le(),re(),Ue(M),xe(),$e(),We()}function L(){let M=_.querySelector("[data-editor-add-object-type]")?.value??"planet";_.innerHTML=`
4089
+ `,document.head.append(n)}function Hv(n){return encodeURIComponent(JSON.stringify(n))}function Bp(n,e,t={}){return{version:"2.0",mode:kp(e),scene:n,spatialScene:t.spatialScene,options:{viewMode:t.viewMode??jv(kp(e)),initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}}}function zp(n,e={}){let t={...n,options:{...n.options,theme:e.theme??n.options?.theme,layers:e.layers??n.options?.layers,subtitle:e.subtitle??n.options?.subtitle,preset:e.preset??n.options?.preset,viewMode:e.viewMode??n.options?.viewMode??jv(kp(n.mode)),initialViewpointId:e.initialViewpointId??n.options?.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId??n.options?.initialSelectionObjectId,initialFilter:e.initialFilter??n.options?.initialFilter??null,atlasState:e.atlasState??n.options?.atlasState??null,minimap:e.minimap??n.options?.minimap}},i=si(n.scene,{theme:t.options?.theme,layers:t.options?.layers,filter:t.options?.initialFilter??null,selectedObjectId:t.options?.initialSelectionObjectId??null,subtitle:t.options?.subtitle,preset:t.options?.preset});return`<div class="${$u(e.className??"worldorbit-embed")}" data-worldorbit-embed="true" data-worldorbit-mode="${t.mode}" data-worldorbit-preset="${$u(t.options?.preset??n.scene.renderPreset??"custom")}" data-worldorbit-viewpoint="${$u(t.options?.initialViewpointId??"")}" data-worldorbit-payload="${$u(Hv(t))}">${i}</div>`}function $u(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function kp(n){return!n||n==="interactive"?"interactive-2d":n}function jv(n){return n==="interactive-3d"?"3d":"2d"}function za(n,e={}){try{let t=ii(n),i=rn(t.document,Gv(t,e)),r=e.mode??"static";if(r==="interactive"||r==="interactive-2d"||r==="interactive-3d"){let s=r==="interactive"?"interactive-2d":r;return zp(Bp(i,s,{spatialScene:s==="interactive-3d"?es(t.document,Gv(t,e)):void 0,viewMode:s==="interactive-3d"?"3d":"2d",initialViewpointId:e.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId,initialFilter:e.initialFilter??null,atlasState:e.atlasState??null,minimap:e.minimap}),{className:e.className??"worldorbit-block worldorbit-interactive",theme:e.theme,layers:e.layers,subtitle:e.subtitle,preset:e.preset,viewMode:s==="interactive-3d"?"3d":"2d",initialViewpointId:e.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId,initialFilter:e.initialFilter??null,atlasState:e.atlasState??null,minimap:e.minimap})}return`<figure class="${O2(e.className??"worldorbit-block worldorbit-static")}">${si(i,e)}</figure>`}catch(t){if(e.strict)throw t;return Wv(t instanceof Error?t.message:String(t))}}function Wv(n){return`<pre class="worldorbit-error">WorldOrbit error: ${Xv(n)}</pre>`}function Xv(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function O2(n){return Xv(n).replaceAll('"',"&quot;")}function Gv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}var Yv="worldorbit-editor-style",U2=120,N2=16,F2=96,eo=1495978707e-1,Qv=6371,ex=695700,$p=new Set(["placement","target","reference","distance","semiMajor","eccentricity","period","angle","inclination","phase","descriptor"]),k2=new Set(["star","planet","moon","asteroid","comet"]),jp=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],B2=["kind","class","culture","color","image","atmosphere","on","source"],z2=["radius","mass","density","gravity","temperature","inner","outer","cycle"],V2=["albedo"],$2={"defaults-view":{description:"Sets the default camera projection for the atlas.",references:["Topdown = map-like","Isometric = angled overview","Orthographic/Perspective = 3D-ready semantic views"]},"defaults-scale":{description:"Chooses the overall spacing/style preset used by the renderer.",references:["diagram = tighter","presentation = roomier"]},"defaults-units":{description:"Stores a document-wide note about the unit style you want to use.",references:["Example: metric","Example: lore-standard"]},"viewpoint-projection":{description:"Overrides the projection for this saved viewpoint.",references:["Topdown = flat orbital map","Isometric = angled scene","Orthographic/Perspective = stored with current 2D fallback"]},"viewpoint-zoom":{description:"Controls how closely this viewpoint frames the system.",references:["1 = scene fit","2+ = close-up"]},"viewpoint-rotation":{description:"Legacy 2D screen rotation. This is separate from the Schema 2.5 camera block.",references:["90deg = quarter turn","Use camera.azimuth for semantic view direction"]},"viewpoint-camera-azimuth":{description:"Horizontal camera direction in degrees for Schema 2.5 viewpoints.",references:["0 = forward/default","90 = quarter orbit around the scene"]},"viewpoint-camera-elevation":{description:"Vertical camera tilt in degrees for 3D-ready viewpoints.",references:["0 = level","30 = gentle look down"]},"viewpoint-camera-roll":{description:"Rolls the camera around its forward axis.",references:["0 = upright","15 = slight bank"]},"viewpoint-camera-distance":{description:"Semantic camera distance for perspective viewpoints.",references:["4 = close","12 = wide framing"]},"viewpoint-events":{description:"Lists event IDs that this viewpoint should feature in its detail panel.",references:["solar-eclipse-naar","transit-window conjunction"]},"event-kind":{description:"Short semantic event type for tooling and viewer overlays.",references:["solar-eclipse","lunar-eclipse","transit"]},"event-target":{description:"Primary object this event is centered on.",references:["Naar","Seyra"]},"event-participants":{description:"Objects that participate in the event snapshot or description.",references:["Iyath Naar Seyra","Naar Seyra Orun"]},"event-timing":{description:"Free-text timing note for the event.",references:['"Every late bloom season"','"At local midyear"']},"event-visibility":{description:"Notes where or how the event is visible.",references:['"Visible from Naar"','"Southern hemisphere only"']},"event-epoch":{description:"Optional event-wide epoch that event poses inherit unless they override it.",references:['"JY-0001.0"','"Naar bloom cycle year 18"']},"event-referencePlane":{description:"Optional event-wide reference plane for all poses in this snapshot.",references:["ecliptic","naar-equatorial"]},"event-viewpoints":{description:"Viewpoint IDs that should list this event prominently.",references:["naar-system","overview inner-system"]},"placement-target":{description:"Names the body or reference this object is attached to.",references:["orbit Primary","surface Homeworld","at Naar:L4"]},"placement-free":{description:"Stores a free-placement offset or a descriptive label for loose placement.",references:["8au = far from the star",'"outer system" = descriptive note']},"placement-distance":{description:"Mean orbit distance from the target body.",references:["1 au = Earth-Sun distance","384400km = Earth-Moon distance"]},"placement-semiMajor":{description:"Semi-major axis of an orbit, used for elliptical orbits.",references:["1 au = Earth-Sun distance","Use this instead of distance when orbit shape matters"]},"placement-eccentricity":{description:"Controls how stretched the orbit is. Lower is rounder.",references:["0 = circular orbit","0.1 = mildly elliptical"]},"placement-period":{description:"How long one orbit takes.",references:["1 y = one Earth year","27.3d = Moon around Earth"]},"placement-angle":{description:"Rotates the orbit ellipse within the scene.",references:["0deg = default orientation","90deg = quarter turn"]},"placement-inclination":{description:"Tilts the orbit relative to the main orbital plane.",references:["0deg = same plane","5deg = slight tilt"]},"placement-phase":{description:"Starting position of the object along its orbit.",references:["0deg = start position","180deg = opposite side"]},"pose-epoch":{description:"Overrides the effective epoch for this pose only.",references:['"JY-0001.0"',"Falls back to event, object, then system"]},"pose-referencePlane":{description:"Overrides the effective reference plane for this pose only.",references:["naar-equatorial","Falls back to event, object, then system"]},"prop-radius":{description:"Visual body size or real-world-inspired radius value.",references:["1re = Earth radius","1sol = Sun radius"]},"prop-mass":{description:"Optional mass value for the body.",references:["1me = Earth mass","1sol = Sun mass"]},"prop-gravity":{description:"Surface gravity or a custom gravity marker.",references:["1g = Earth-like gravity","0.16g = Moon-like gravity"]},"prop-temperature":{description:"Typical temperature or narrative temperature marker.",references:["288K = Earth-like average","1200K = very hot world"]},"prop-atmosphere":{description:"Short atmosphere descriptor for the object.",references:['"nitrogen-oxygen"','"methane haze"']},"prop-inner":{description:"Inner edge for a belt, ring, or broad phenomenon.",references:["120000km = ring inner edge","2au = belt starts here"]},"prop-outer":{description:"Outer edge for a belt, ring, or broad phenomenon.",references:["190000km = ring outer edge","3au = belt ends here"]}};function tx(n,e={}){zC(n),VC();let t=H2(e),i=t.atlasDocument,r=t.source,s=r,o=r,a=t.diagnostics,c=i.objects[0]?{kind:"object",id:i.objects[0].id}:{kind:"system"},l=[],u=[],d=null,h=!1,f=!1,p=!1,y=null,g=null,m="",x="",v=new Map,M=e.showTextPane??!0,U=e.showInspector??!0,C=e.showPreview??!0,R=e.shortcuts??!0,N=e.viewMode??"2d";n.classList.add("wo-editor"),n.dataset.woShowInspector=String(U),n.dataset.woShowTextPane=String(M),n.dataset.woShowPreview=String(C),n.innerHTML=j2();let w=vn(n,"[data-editor-toolbar]"),b=vn(n,"[data-editor-outline]"),O=vn(n,"[data-editor-stage-shell]"),B=vn(n,"[data-editor-stage]"),F=vn(n,"[data-editor-overlay]"),H=vn(n,"[data-editor-diagnostics]"),X=vn(n,"[data-editor-source-diagnostics]"),ee=vn(n,"[data-editor-status]"),ce=vn(n,"[data-editor-live]"),k=vn(n,"[data-editor-inspector]"),le=vn(n,"[data-editor-source]"),he=vn(n,"[data-editor-preview-visual]"),Te=vn(n,"[data-editor-preview-markup]"),ve=null;ve=Ks(B,{source:r,width:e.viewerWidth??1120,height:e.viewerHeight??680,preset:i.system?.defaults.preset??"atlas-card",projection:"document",viewMode:N,minimap:!0,tooltipMode:"hover",onSelectionChange(_){let S=c?Vp(c):null;if(h||!_){h||(c?.kind==="event-pose"&&c.id?ie({kind:"event",id:c.id},!1,!0):c?.kind==="object"?ie(S?{kind:"event",id:S}:null,!1,!0):c?.kind==="event"&&c.id&&ie({kind:"event",id:c.id},!1,!0));return}if(S&&sx(i,S,_.objectId)){ie({kind:"event-pose",id:S,key:_.objectId},!1,!0);return}ie({kind:"object",id:_.objectId},!1,!0)},onViewChange(){be()}}),w.addEventListener("click",Oe),b.addEventListener("click",qe),F.addEventListener("pointerdown",ue),k?.addEventListener("click",Ne),k?.addEventListener("input",Re),k?.addEventListener("change",Fe),le?.addEventListener("input",mt),le?.addEventListener("change",Ge),le?.addEventListener("blur",Ge),n.addEventListener("keydown",z),window.addEventListener("pointermove",Q),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se);let He={setSource(_){de(_,!1)&&(J(),D())},setAtlasDocument(_){Y(_,!1,c,!1),J(),D()},getSource(){return r},getAtlasDocument(){return ot(i)},getDiagnostics(){return a.map(Gu)},getSelection(){return c?{path:{...c}}:null},getViewMode(){return N},setViewMode(_){let S=N;try{ve.setViewMode(_),N=_,be(),In()}catch(T){throw N=S,T}},isDirty(){return p},markSaved(){V(!0)},selectPath(_){ie(_,!0,!0)},canUndo(){return l.length>0},canRedo(){return u.length>0},undo(){let _=l.pop();return _?(u.unshift(Z()),Be(_),!0):!1},redo(){let _=u.shift();return _?(l.push(Z()),Be(_),!0):!1},addObject(_="planet"){let S=Ha(_,i.objects.map(W=>W.id)),T=lC(_,S,i),I=uC(i,T);return Y(I,!0,{kind:"object",id:S}),S},addEvent(){let _=Ha("event",i.events.map(I=>I.id)),S={id:_,kind:"",label:ja(_),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},T=ot(i);return T.events.push(S),T.events.sort(Jv),Y(T,!0,{kind:"event",id:_}),_},addViewpoint(){let _=Ha("viewpoint",i.system?.viewpoints.map(I=>I.id)??[]),S={id:_,label:ja(_),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:i.system?.defaults.view??"topdown",preset:i.system?.defaults.preset??null,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null},T=ot(i);return T.system?.viewpoints.push(S),T.system?.viewpoints.sort((I,W)=>I.id.localeCompare(W.id)),Y(T,!0,{kind:"viewpoint",id:_}),_},addAnnotation(){let _=Ha("annotation",i.system?.annotations.map(I=>I.id)??[]),S={id:_,label:ja(_),targetObjectId:null,body:"",tags:[],sourceObjectId:null},T=ot(i);return T.system?.annotations.push(S),T.system?.annotations.sort((I,W)=>I.id.localeCompare(W.id)),Y(T,!0,{kind:"annotation",id:_}),_},addMetadata(_,S){let T=_?.trim()||Ha("metadata",Object.keys(i.system?.atlasMetadata??{})),I=ot(i);return I.system&&(I.system.atlasMetadata[T]=S??""),Y(I,!0,{kind:"metadata",key:T}),T},removeSelection(){if(!c||c.kind==="system"||c.kind==="defaults")return!1;let _=fC(i,c);return Y(_,!0,{kind:"system"}),!0},exportSvg(){return ve.exportSvg()},exportEmbedMarkup(){return Zv(ze(),i,N)},destroy(){f||(f=!0,w.removeEventListener("click",Oe),b.removeEventListener("click",qe),F.removeEventListener("pointerdown",ue),k?.removeEventListener("click",Ne),k?.removeEventListener("input",Re),k?.removeEventListener("change",Fe),le?.removeEventListener("input",mt),le?.removeEventListener("change",Ge),le?.removeEventListener("blur",Ge),n.removeEventListener("keydown",z),window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),ye(),oe(),ve.destroy(),n.innerHTML="",n.classList.remove("wo-editor"))}};return Ie(!0),xe(!0),He;function Z(){return{atlasDocument:ot(i),selection:c?{...c}:null,source:r}}function J(){l.length=0,u.length=0,D()}function ye(){y!==null&&(window.clearTimeout(y),y=null)}function oe(){g!==null&&(window.clearTimeout(g),g=null)}function ze(){return d?.changed?tr(i):r}function xe(_=!1){let S=s!==o||r!==o||d?.changed===!0;!_&&S===p||(p=S,kn(),e.onDirtyChange?.(p))}function V(_=!1){s=r,re(),o=r,xe(_)}function Be(_){ye(),i=ot(_.atlasDocument),r=_.source,s=r,a=nr(i),c=ge(_.selection),K({preserveCamera:!0,applyViewpointSelection:c?.kind==="viewpoint"}),ie(c,!1,!1),Ie(),xe(),fe()}function Y(_,S,T,I=!1){S&&(l.push(Z()),u.length=0),ye(),i=ot(_),r=tr(i),I||(s=r),a=nr(i),c=ge(T),K({preserveCamera:c?.kind!=="viewpoint",applyViewpointSelection:c?.kind==="viewpoint"}),ie(c,!1,!1),Ie(),xe(),fe()}function de(_,S){s=_,le&&le.value!==_&&(le.value=_);let T=wo(_);if(!T.ok||!T.value)return a=T.diagnostics.map(ne=>({diagnostic:ne,path:null})),j(),te(),A(),ae(),kn(),Tn(),xe(),e.onDiagnosticsChange?.(a.map(Gu)),!1;let I=T.value.atlasDocument??cr(T.value.document),W=_o(I,T.diagnostics);return S&&(l.push(Z()),u.length=0,s=tr(I)),i=ot(I),r=tr(i),a=ix(W,nr(i)),c=ge(c),K({preserveCamera:c?.kind!=="viewpoint",applyViewpointSelection:c?.kind==="viewpoint"}),Ie(),xe(),fe(),!0}function K(_={}){if(!ve)return;let S=ve.getState(),T=ve.getRenderOptions(),I=i.system?.defaults.preset??"atlas-card",W=c?Vp(c):null;h=!0,(T.preset!==I||T.projection!=="document"||(T.activeEventId??null)!==W)&&ve.setRenderOptions({preset:I,projection:"document",activeEventId:W}),ve.setDocument(go(i)),_.applyViewpointSelection&&c?.kind==="viewpoint"&&c.id?ve.goToViewpoint(c.id):_.preserveCamera!==!1?ve.setState({...S,selectedObjectId:c?.kind==="object"?c.id??null:c?.kind==="event-pose"?c.key??null:null}):c?.kind==="object"&&c.id?ve.focusObject(c.id):c?.kind==="event-pose"&&c.key&&ve.focusObject(c.key),h=!1}function fe(){let _={source:r,atlasDocument:ot(i),diagnostics:a.map(Gu),selection:c?{path:{...c}}:null};e.onDiagnosticsChange?.(_.diagnostics),e.onSelectionChange?.(_.selection),e.onChange?.(_)}function ie(_,S,T=!0){c=ge(_),S&&(h=!0,ve.setRenderOptions({activeEventId:c?Vp(c):null}),c?.kind==="object"&&c.id?ve.focusObject(c.id):c?.kind==="event-pose"&&c.key?ve.focusObject(c.key):c?.kind==="viewpoint"&&c.id&&ve.goToViewpoint(c.id),h=!1),D(),A(),k?.contains(document.activeElement)||ae(),be(),kn(),Tn(),T&&e.onSelectionChange?.(c?{path:{...c}}:null)}function ge(_){if(!_)return null;let S=_d(i,_);return S==null?_.kind==="system"||_.kind==="defaults"?_:null:_}function Ie(_=!1){D(),A(),j(),te(),k?.contains(document.activeElement)||ae(),re(),Ue(_),be(),kn(),Tn()}function D(){let _=w.querySelector("[data-editor-add-object-type]")?.value??"planet";w.innerHTML=`
4040
4090
  <div class="wo-editor-toolbar-group">
4041
4091
  <select data-editor-add-object-type>
4042
- ${Gp.map(S=>`<option value="${Ze(S)}"${S===M?" selected":""}>${Ze(Ga(S))}</option>`).join("")}
4092
+ ${jp.map(S=>`<option value="${Ye(S)}"${S===_?" selected":""}>${Ye(ja(S))}</option>`).join("")}
4043
4093
  </select>
4044
4094
  <button type="button" data-editor-action="add-object">Add object</button>
4045
4095
  <button type="button" data-editor-action="add-event">Add event</button>
@@ -4053,55 +4103,55 @@ void main() {
4053
4103
  <button type="button" data-editor-action="redo"${u.length===0?" disabled":""}>Redo</button>
4054
4104
  <button type="button" data-editor-action="format">Format source</button>
4055
4105
  </div>
4056
- `}function E(){let M=Ri(c),S=MC(a),A=Object.entries(i.system?.atlasMetadata??{}).sort(([T],[j])=>T.localeCompare(j));b.innerHTML=`
4106
+ `}function A(){let _=Ii(c),S=SC(a),T=Object.entries(i.system?.atlasMetadata??{}).sort(([I],[W])=>I.localeCompare(W));b.innerHTML=`
4057
4107
  <div class="wo-editor-outline-section">
4058
4108
  <h3>Atlas</h3>
4059
- ${Ci({kind:"system"},"System",M,S)}
4060
- ${Ci({kind:"defaults"},"Defaults",M,S)}
4109
+ ${Ti({kind:"system"},"System",_,S)}
4110
+ ${Ti({kind:"defaults"},"Defaults",_,S)}
4061
4111
  </div>
4062
4112
  <div class="wo-editor-outline-section">
4063
4113
  <h3>Metadata</h3>
4064
- ${A.length>0?A.map(([T])=>Ci({kind:"metadata",key:T},T,M,S)).join(""):'<p class="wo-editor-empty">No atlas metadata yet.</p>'}
4114
+ ${T.length>0?T.map(([I])=>Ti({kind:"metadata",key:I},I,_,S)).join(""):'<p class="wo-editor-empty">No atlas metadata yet.</p>'}
4065
4115
  </div>
4066
4116
  <div class="wo-editor-outline-section">
4067
4117
  <h3>Viewpoints</h3>
4068
- ${(i.system?.viewpoints.length??0)>0?i.system?.viewpoints.map(T=>Ci({kind:"viewpoint",id:T.id},T.label,M,S)).join(""):'<p class="wo-editor-empty">No viewpoints yet.</p>'}
4118
+ ${(i.system?.viewpoints.length??0)>0?i.system?.viewpoints.map(I=>Ti({kind:"viewpoint",id:I.id},I.label,_,S)).join(""):'<p class="wo-editor-empty">No viewpoints yet.</p>'}
4069
4119
  </div>
4070
4120
  <div class="wo-editor-outline-section">
4071
4121
  <h3>Annotations</h3>
4072
- ${(i.system?.annotations.length??0)>0?i.system?.annotations.map(T=>Ci({kind:"annotation",id:T.id},T.label,M,S)).join(""):'<p class="wo-editor-empty">No annotations yet.</p>'}
4122
+ ${(i.system?.annotations.length??0)>0?i.system?.annotations.map(I=>Ti({kind:"annotation",id:I.id},I.label,_,S)).join(""):'<p class="wo-editor-empty">No annotations yet.</p>'}
4073
4123
  </div>
4074
4124
  <div class="wo-editor-outline-section">
4075
4125
  <h3>Events</h3>
4076
- ${i.events.length>0?i.events.map(T=>q2(T,M,S)).join(""):'<p class="wo-editor-empty">No events yet.</p>'}
4126
+ ${i.events.length>0?i.events.map(I=>q2(I,_,S)).join(""):'<p class="wo-editor-empty">No events yet.</p>'}
4077
4127
  </div>
4078
4128
  <div class="wo-editor-outline-section">
4079
4129
  <h3>Objects</h3>
4080
- ${i.objects.length>0?i.objects.map(T=>Ci({kind:"object",id:T.id},`${T.id} - ${T.type}`,M,S)).join(""):'<p class="wo-editor-empty">No objects yet.</p>'}
4130
+ ${i.objects.length>0?i.objects.map(I=>Ti({kind:"object",id:I.id},`${I.id} - ${I.type}`,_,S)).join(""):'<p class="wo-editor-empty">No objects yet.</p>'}
4081
4131
  </div>
4082
- `}function H(){$.innerHTML=a.length===0?'<p class="wo-editor-empty">No diagnostics.</p>':a.map(M=>{let S=M.path?Gu(M.path):"Source",A=qv(M);return`<article class="wo-editor-diagnostic wo-editor-diagnostic-${Ze(M.diagnostic.severity)}">
4083
- <strong>${Ze(M.diagnostic.severity.toUpperCase())}</strong>
4084
- <span>${Ze(S)}${A?` \xB7 ${Ze(A)}`:""}</span>
4085
- <p>${Ze(M.diagnostic.message)}</p>
4086
- </article>`}).join("")}function te(){let M=a.filter(S=>!S.path||S.diagnostic.line!==void 0);W.innerHTML=M.length===0?'<p class="wo-editor-empty">No source diagnostics.</p>':M.map(S=>{let A=qv(S)??"Source";return`<article class="wo-editor-diagnostic wo-editor-diagnostic-${Ze(S.diagnostic.severity)}">
4087
- <strong>${Ze(S.diagnostic.severity.toUpperCase())}</strong>
4088
- <span>${Ze(A)}</span>
4089
- <p>${Ze(S.diagnostic.message)}</p>
4090
- </article>`}).join("")}function le(){if(!V)return;W2(V,x);let M={selection:c?{path:{...c}}:null,system:i.system,viewpoints:i.system?.viewpoints??[],events:i.events,objects:i.objects};if(!c){V.innerHTML='<p class="wo-editor-empty">Select an atlas node or object to edit it.</p>';return}let S=eo(c,a);switch(c.kind){case"system":V.innerHTML=S+Z2(M),er(V,x),C(c,a);return;case"defaults":V.innerHTML=S+J2(M),er(V,x),C(c,a);return;case"metadata":V.innerHTML=S+K2(M,c.key??""),er(V,x),C(c,a);return;case"viewpoint":V.innerHTML=S+Q2(M,c.id??""),er(V,x),C(c,a);return;case"event":V.innerHTML=S+eC(M,c.id??""),er(V,x),C(c,a);return;case"event-pose":V.innerHTML=S+tC(M,c.id??"",c.key??""),er(V,x),C(c,a);return;case"annotation":V.innerHTML=S+nC(M,c.id??""),er(V,x),C(c,a);return;case"object":V.innerHTML=S+iC(M,c.id??""),er(V,x),C(c,a);return}}function re(){ce&&ce.value!==s&&(ce.value=s)}function Ue(M=!1){if(M){xt();return}ke()}function xe(){if(!ve||(F.innerHTML="",U==="3d"))return;let M=c?.kind==="object"?c.id??null:c?.kind==="event-pose"?c.key??null:null;if(!M)return;let S=ve.getObjectDetails(M);if(!S)return;if(be(S.renderObject.x,S.renderObject.y,S.renderObject.objectId),S.parent&&be(S.parent.x,S.parent.y,`Parent: ${S.parent.objectId}`,!0),S.renderObject.anchorX!==void 0&&S.renderObject.anchorY!==void 0&&be(S.renderObject.anchorX,S.renderObject.anchorY,"Anchor",!0),S.object.placement?.mode==="orbit"&&S.orbit){let T=pe({x:S.renderObject.x,y:S.renderObject.y});F.append($a("orbit-phase",S.objectId,T,"Phase"));let j=Ve(S);F.append($a("orbit-radius",S.objectId,j,"Size"))}if(S.object.placement?.mode==="at"){F.append($a("at-reference",S.objectId,pe({x:S.renderObject.x,y:S.renderObject.y}),"Reference"));let T=document.createElement("div");T.className="wo-editor-hint wo-editor-hint-note",T.textContent="Drag to an object center or nearby Lagrange point.",F.append(T)}if(S.object.placement?.mode==="surface"){F.append($a("surface-target",S.objectId,pe({x:S.renderObject.x,y:S.renderObject.y}),"Surface"));let T=document.createElement("div");T.className="wo-editor-hint wo-editor-hint-note",T.textContent="Drag onto another surface-capable body.",F.append(T)}if(S.object.placement?.mode==="free"){F.append($a("free-distance",S.objectId,pe({x:S.renderObject.x,y:S.renderObject.y}),"Offset"));let T=document.createElement("div");T.className="wo-editor-hint wo-editor-hint-note",T.textContent="Drag horizontally to change free offset.",F.append(T)}let A=Qs(c,a).slice(0,3);if(A.length>0){let T=document.createElement("div");T.className="wo-editor-overlay-diagnostics",T.setAttribute("role","status"),T.setAttribute("aria-live","polite"),T.innerHTML=A.map(j=>`<article class="wo-editor-overlay-diagnostic wo-editor-overlay-diagnostic-${Ze(j.diagnostic.severity)}">
4091
- <strong>${Ze(j.diagnostic.severity.toUpperCase())}</strong>
4092
- <p>${Ze(j.diagnostic.message)}</p>
4093
- </article>`).join(""),F.append(T)}}function be(M,S,A,T=!1){let j=pe({x:M,y:S}),ie=document.createElement("div");ie.className=`wo-editor-hint${T?" is-subtle":""}`,ie.style.left=`${j.x}px`,ie.style.top=`${j.y}px`,ie.textContent=A,F.append(ie)}function Ve(M){let S=M.orbit;if(!S)return pe({x:M.renderObject.x,y:M.renderObject.y});let A={x:S.cx+(S.kind==="circle"?S.radius??0:S.rx??0),y:S.cy},T=ln(A,{x:S.cx,y:S.cy},S.rotationDeg);return pe(T)}function pe(M){let S=ve.getScene(),A=ve.getState(),T={x:S.width/2,y:S.height/2},j=ln(M,T,A.rotationDeg),ie={x:T.x+(j.x-T.x)*A.scale+A.translateX,y:T.y+(j.y-T.y)*A.scale+A.translateY},ge=z.querySelector("svg");if(!ge)return ie;let Ae=ge.getBoundingClientRect(),Pe=D.getBoundingClientRect();return{x:Ae.left-Pe.left+ie.x/Math.max(S.width,1)*Ae.width,y:Ae.top-Pe.top+ie.y/Math.max(S.height,1)*Ae.height}}function Oe(M){let S=M.target?.closest("[data-editor-action]");if(S)switch(S.dataset.editorAction){case"add-object":{let A=_.querySelector("[data-editor-add-object-type]")?.value;He.addObject(A??"planet");return}case"add-viewpoint":He.addViewpoint();return;case"add-event":He.addEvent();return;case"add-annotation":He.addAnnotation();return;case"add-metadata":He.addMetadata();return;case"remove":He.removeSelection();return;case"undo":He.undo();return;case"redo":He.redo();return;case"format":ye(),s=r,re(),Re();return}}function Ge(M){let S=M.target?.closest("[data-path-kind]");S&&K({kind:S.dataset.pathKind,id:S.dataset.pathId||void 0,key:S.dataset.pathKey||void 0},!0,!0)}function Ne(M){let S=M.target?.closest("[data-path-kind]");if(S){K({kind:S.dataset.pathKind,id:S.dataset.pathId||void 0,key:S.dataset.pathKey||void 0},!0,!0);return}let A=M.target?.closest("[data-editor-action]");if(A&&A.dataset.editorAction==="add-event-pose"){let T=A.dataset.editorEventId||(c?.kind==="event"||c?.kind==="event-pose"?c.id??"":"");if(!T)return;let j=TC(i,T),ie=j.events.find(Ae=>Ae.id===T),ge=ie?.positions.at(-1)??ie?.positions[0];X(j,!0,ge?{kind:"event-pose",id:T,key:ge.objectId}:{kind:"event",id:T});return}}function Me(){nt(!1)}function Ye(){nt(!0)}function nt(M){if(!(!c||!V))switch(c.kind){case"system":X(at(),M,c,!1);return;case"defaults":X(vt(),M,c,!1);return;case"metadata":X(Et(c.key??""),M,c,!1);return;case"viewpoint":X(ot(c.id??""),M,c,!1);return;case"event":X(an(c.id??""),M,c,!1);return;case"event-pose":X(N(c.id??"",c.key??""),M,c,!1);return;case"annotation":X(G(c.id??""),M,c,!1);return;case"object":X(se(c.id??""),M,c,!1);return}}function yt(){s=ce?.value??"",Re(),ye(),y=window.setTimeout(()=>{y=null,he(s,!1)},U2)}function je(){ye(),he(ce?.value??"",!0)&&re()}function k(M){if(M.key==="Escape"&&d){M.preventDefault(),Se();return}if(!R||M.defaultPrevented||Pn(M))return;let S=(M.ctrlKey||M.metaKey)&&!M.shiftKey&&M.key.toLowerCase()==="z",A=(M.ctrlKey||M.metaKey)&&(M.shiftKey&&M.key.toLowerCase()==="z"||M.key.toLowerCase()==="y");if(S){M.preventDefault(),He.undo();return}A&&(M.preventDefault(),He.redo())}function ue(M){let S=M.target?.closest("[data-handle-kind]");if(!S)return;let A=S.dataset.objectId,T=S.dataset.handleKind;if(!A||!["orbit-phase","orbit-radius","at-reference","surface-target","free-distance"].includes(T))return;if(ye(),s!==r&&!he(s,!0)){M.preventDefault();return}let j=ve?.getObjectDetails(A)??null;d={kind:T,objectId:A,pointerId:M.pointerId,path:c?{...c}:{kind:"object",id:A},startedFrom:q(),changed:!1,orbitRadiusContext:T==="orbit-radius"&&j?vC(i,ve.getScene(),j):null},S.setPointerCapture?.(M.pointerId),M.preventDefault()}function ee(M){if(!d||d.pointerId!==M.pointerId||!c||Ri(c)!==Ri(d.path))return;let S=ve.getObjectDetails(d.objectId);if(!S)return;let A=rt(M.clientX,M.clientY),T=i;switch(d.kind){case"orbit-phase":S.object.placement?.mode==="orbit"&&S.orbit&&(T=pC(i,d.path,d.objectId,S,A));break;case"orbit-radius":S.object.placement?.mode==="orbit"&&S.orbit&&(T=mC(i,d.path,d.objectId,S,A,d.orbitRadiusContext??null));break;case"at-reference":S.object.placement?.mode==="at"&&(T=gC(i,d.path,d.objectId,ve.getScene(),A));break;case"surface-target":S.object.placement?.mode==="surface"&&(T=yC(i,d.path,d.objectId,ve.getScene(),A));break;case"free-distance":S.object.placement?.mode==="free"&&(T=xC(i,d.path,d.objectId,ve.getScene(),S,A));break}T!==i&&(d.changed=!0,i=lt(T),a=rr(i),Q({preserveCamera:!0,applyViewpointSelection:!1}),H(),te(),E(),le(),xe(),$e(),We(),ke(),Re())}function de(M){if(!d||d.pointerId!==M.pointerId)return;let S=d;if(!d.changed){d=null;return}l.push(d.startedFrom),u.length=0,r=ir(i),s=r,d=null,De(),S.kind==="orbit-radius"&&Ct(S.objectId),Re(),me()}function Se(){if(!d)return;let M=d.startedFrom;d=null,i=lt(M.atlasDocument),r=M.source,s=r,a=rr(i),K(M.selection,!1,!1),Q({preserveCamera:!0,applyViewpointSelection:c?.kind==="viewpoint"}),De(),Re(),me()}function rt(M,S){let A=z.querySelector("svg"),T=ve.getScene();if(!A)return{x:T.width/2,y:T.height/2};let j=A.getBoundingClientRect(),ie={x:(M-j.left)/Math.max(j.width,1)*T.width,y:(S-j.top)/Math.max(j.height,1)*T.height};return dr(T,ve.getState(),ie)}function at(){let M=lt(i),S=V?.querySelector("form[data-editor-form='system']");return!S||!M.system||(M.system.id=tn(S,"system-id")||M.system.id,M.system.title=Fe(S,"system-title")),M}function vt(){let M=lt(i),S=V?.querySelector("form[data-editor-form='defaults']");return!S||!M.system||(M.system.defaults.view=tn(S,"defaults-view")||"topdown",M.system.defaults.scale=Fe(S,"defaults-scale"),M.system.defaults.units=Fe(S,"defaults-units"),M.system.defaults.preset=Fe(S,"defaults-preset")??null,M.system.defaults.theme=Fe(S,"defaults-theme")),M}function Et(M){let S=lt(i),A=V?.querySelector("form[data-editor-form='metadata']");if(!A||!S.system)return S;let T=tn(A,"metadata-key")||M,j=Fe(A,"metadata-value")??"";return T!==M?(delete S.system.atlasMetadata[M],S.system.atlasMetadata[T]=j,c={kind:"metadata",key:T},S):(S.system.atlasMetadata[M]=j,S)}function ot(M){let S=lt(i),A=V?.querySelector("form[data-editor-form='viewpoint']"),T=S.system?.viewpoints.find(ge=>ge.id===M);if(!A||!T||!S.system)return S;let j=tn(A,"viewpoint-id")||T.id,ie={...T,id:j,label:tn(A,"viewpoint-label")||T.label,summary:Fe(A,"viewpoint-summary")??"",focusObjectId:Fe(A,"viewpoint-focus"),selectedObjectId:Fe(A,"viewpoint-select"),projection:tn(A,"viewpoint-projection")||T.projection,preset:Fe(A,"viewpoint-preset")??null,zoom:sr(Fe(A,"viewpoint-zoom")),rotationDeg:sr(Fe(A,"viewpoint-rotation"))??0,camera:aC(A),layers:{background:ei(A,"layer-background"),guides:ei(A,"layer-guides"),"orbits-back":ei(A,"layer-orbits-back"),"orbits-front":ei(A,"layer-orbits-front"),events:ei(A,"layer-events"),objects:ei(A,"layer-objects"),labels:ei(A,"layer-labels"),metadata:ei(A,"layer-metadata")},events:Ii(Fe(A,"viewpoint-events")),filter:{query:Fe(A,"filter-query"),objectTypes:cC(Fe(A,"filter-object-types")),tags:Ii(Fe(A,"filter-tags")),groupIds:Ii(Fe(A,"filter-groups"))}};return S.system.viewpoints=S.system.viewpoints.filter(ge=>ge.id!==T.id).concat(ie).sort((ge,Ae)=>ge.id.localeCompare(Ae.id)),T.id!==ie.id&&(c={kind:"viewpoint",id:ie.id}),S}function an(M){let S=lt(i),A=V?.querySelector("form[data-editor-form='event']"),T=S.events.find(ge=>ge.id===M);if(!A||!T)return S;let j=tn(A,"event-id")||T.id,ie={...T,id:j,kind:tn(A,"event-kind"),label:tn(A,"event-label")||T.label,summary:Fe(A,"event-summary"),targetObjectId:Fe(A,"event-target"),participantObjectIds:Ii(Fe(A,"event-participants")),timing:Fe(A,"event-timing"),visibility:Fe(A,"event-visibility"),epoch:Fe(A,"event-epoch"),referencePlane:Fe(A,"event-referencePlane"),tags:Ii(Fe(A,"event-tags")),color:Fe(A,"event-color"),hidden:ei(A,"event-hidden")};return S.events=S.events.filter(ge=>ge.id!==T.id).concat(ie).sort(Jv),CC(S,T.id,ie.id,Ii(Fe(A,"event-viewpoints"))),T.id!==ie.id&&(c={kind:"event",id:ie.id}),S}function N(M,S){let A=lt(i),T=V?.querySelector("form[data-editor-form='event-pose']"),j=A.events.find(Be=>Be.id===M),ie=j?.positions.find(Be=>Be.objectId===S);if(!T||!j||!ie)return A;let Ae={objectId:tn(T,"pose-object-id")||ie.objectId,placement:sC(T,ie),epoch:Fe(T,"pose-epoch"),referencePlane:Fe(T,"pose-referencePlane")},Pe=ni(Fe(T,"prop-inner")),Xe=ni(Fe(T,"prop-outer"));return Pe&&(Ae.inner=Pe),Xe&&(Ae.outer=Xe),j.positions=j.positions.filter(Be=>Be.objectId!==ie.objectId).concat(Ae).sort(Xu),j.targetObjectId!==Ae.objectId&&!j.participantObjectIds.includes(Ae.objectId)&&(j.participantObjectIds.push(Ae.objectId),j.participantObjectIds.sort((Be,bt)=>Be.localeCompare(bt))),ie.objectId!==Ae.objectId&&(c={kind:"event-pose",id:M,key:Ae.objectId}),A}function G(M){let S=lt(i),A=V?.querySelector("form[data-editor-form='annotation']"),T=S.system?.annotations.find(ge=>ge.id===M);if(!A||!T||!S.system)return S;let j=tn(A,"annotation-id")||T.id,ie={...T,id:j,label:tn(A,"annotation-label")||T.label,targetObjectId:Fe(A,"annotation-target"),body:Fe(A,"annotation-body")??"",tags:Ii(Fe(A,"annotation-tags")),sourceObjectId:Fe(A,"annotation-source")};return S.system.annotations=S.system.annotations.filter(ge=>ge.id!==T.id).concat(ie).sort((ge,Ae)=>ge.id.localeCompare(Ae.id)),T.id!==ie.id&&(c={kind:"annotation",id:ie.id}),S}function se(M){let S=lt(i),A=V?.querySelector("form[data-editor-form='object']"),T=S.objects.find(Pe=>Pe.id===M);if(!A||!T)return S;let j=tn(A,"object-id")||T.id,ie={...T,id:j,type:tn(A,"object-type")||T.type,properties:{...T.properties},info:{...T.info},placement:rC(A,T)};for(let Pe of B2)Hu(ie.properties,Pe,Fe(A,`prop-${Pe}`));for(let Pe of z2)Hu(ie.properties,Pe,oC(Fe(A,`prop-${Pe}`)));for(let Pe of V2)Hu(ie.properties,Pe,sr(Fe(A,`prop-${Pe}`)));Hu(ie.properties,"tags",Ii(Fe(A,"prop-tags"))),ie.properties.hidden=ei(A,"prop-hidden");let ge=Fe(A,"info-description");ge?ie.info.description=ge:delete ie.info.description;let Ae=dC(S,T.id,ie);return T.id!==ie.id&&(c={kind:"object",id:ie.id}),Ae}function $e(){let M=a.filter(T=>T.diagnostic.severity==="error").length,S=a.filter(T=>T.diagnostic.severity==="warning").length,A=c?Gu(c):"Nothing selected";ne.innerHTML=`
4132
+ `}function j(){H.innerHTML=a.length===0?'<p class="wo-editor-empty">No diagnostics.</p>':a.map(_=>{let S=_.path?ju(_.path):"Source",T=qv(_);return`<article class="wo-editor-diagnostic wo-editor-diagnostic-${Ye(_.diagnostic.severity)}">
4133
+ <strong>${Ye(_.diagnostic.severity.toUpperCase())}</strong>
4134
+ <span>${Ye(S)}${T?` \xB7 ${Ye(T)}`:""}</span>
4135
+ <p>${Ye(_.diagnostic.message)}</p>
4136
+ </article>`}).join("")}function te(){let _=a.filter(S=>!S.path||S.diagnostic.line!==void 0);X.innerHTML=_.length===0?'<p class="wo-editor-empty">No source diagnostics.</p>':_.map(S=>{let T=qv(S)??"Source";return`<article class="wo-editor-diagnostic wo-editor-diagnostic-${Ye(S.diagnostic.severity)}">
4137
+ <strong>${Ye(S.diagnostic.severity.toUpperCase())}</strong>
4138
+ <span>${Ye(T)}</span>
4139
+ <p>${Ye(S.diagnostic.message)}</p>
4140
+ </article>`}).join("")}function ae(){if(!k)return;W2(k,v);let _={selection:c?{path:{...c}}:null,system:i.system,viewpoints:i.system?.viewpoints??[],events:i.events,objects:i.objects};if(!c){k.innerHTML='<p class="wo-editor-empty">Select an atlas node or object to edit it.</p>';return}let S=G(c,a);switch(c.kind){case"system":k.innerHTML=S+Z2(_),Ki(k,v),E(c,a);return;case"defaults":k.innerHTML=S+J2(_),Ki(k,v),E(c,a);return;case"metadata":k.innerHTML=S+K2(_,c.key??""),Ki(k,v),E(c,a);return;case"viewpoint":k.innerHTML=S+Q2(_,c.id??""),Ki(k,v),E(c,a);return;case"event":k.innerHTML=S+eC(_,c.id??""),Ki(k,v),E(c,a);return;case"event-pose":k.innerHTML=S+tC(_,c.id??"",c.key??""),Ki(k,v),E(c,a);return;case"annotation":k.innerHTML=S+nC(_,c.id??""),Ki(k,v),E(c,a);return;case"object":k.innerHTML=S+iC(_,c.id??""),Ki(k,v),E(c,a);return}}function re(){le&&le.value!==s&&(le.value=s)}function Ue(_=!1){if(_){In();return}sr()}function be(){if(!ve||(F.innerHTML="",N==="3d"))return;let _=c?.kind==="object"?c.id??null:c?.kind==="event-pose"?c.key??null:null;if(!_)return;let S=ve.getObjectDetails(_);if(!S)return;if(_e(S.renderObject.x,S.renderObject.y,S.renderObject.objectId),S.parent&&_e(S.parent.x,S.parent.y,`Parent: ${S.parent.objectId}`,!0),S.renderObject.anchorX!==void 0&&S.renderObject.anchorY!==void 0&&_e(S.renderObject.anchorX,S.renderObject.anchorY,"Anchor",!0),S.object.placement?.mode==="orbit"&&S.orbit){let I=pe({x:S.renderObject.x,y:S.renderObject.y});F.append($a("orbit-phase",S.objectId,I,"Phase"));let W=je(S);F.append($a("orbit-radius",S.objectId,W,"Size"))}if(S.object.placement?.mode==="at"){F.append($a("at-reference",S.objectId,pe({x:S.renderObject.x,y:S.renderObject.y}),"Reference"));let I=document.createElement("div");I.className="wo-editor-hint wo-editor-hint-note",I.textContent="Drag to an object center or nearby Lagrange point.",F.append(I)}if(S.object.placement?.mode==="surface"){F.append($a("surface-target",S.objectId,pe({x:S.renderObject.x,y:S.renderObject.y}),"Surface"));let I=document.createElement("div");I.className="wo-editor-hint wo-editor-hint-note",I.textContent="Drag onto another surface-capable body.",F.append(I)}if(S.object.placement?.mode==="free"){F.append($a("free-distance",S.objectId,pe({x:S.renderObject.x,y:S.renderObject.y}),"Offset"));let I=document.createElement("div");I.className="wo-editor-hint wo-editor-hint-note",I.textContent="Drag horizontally to change free offset.",F.append(I)}let T=$(c,a).slice(0,3);if(T.length>0){let I=document.createElement("div");I.className="wo-editor-overlay-diagnostics",I.setAttribute("role","status"),I.setAttribute("aria-live","polite"),I.innerHTML=T.map(W=>`<article class="wo-editor-overlay-diagnostic wo-editor-overlay-diagnostic-${Ye(W.diagnostic.severity)}">
4141
+ <strong>${Ye(W.diagnostic.severity.toUpperCase())}</strong>
4142
+ <p>${Ye(W.diagnostic.message)}</p>
4143
+ </article>`).join(""),F.append(I)}}function _e(_,S,T,I=!1){let W=pe({x:_,y:S}),ne=document.createElement("div");ne.className=`wo-editor-hint${I?" is-subtle":""}`,ne.style.left=`${W.x}px`,ne.style.top=`${W.y}px`,ne.textContent=T,F.append(ne)}function je(_){let S=_.orbit;if(!S)return pe({x:_.renderObject.x,y:_.renderObject.y});let T={x:S.cx+(S.kind==="circle"?S.radius??0:S.rx??0),y:S.cy},I=sn(T,{x:S.cx,y:S.cy},S.rotationDeg);return pe(I)}function pe(_){let S=ve.getScene(),T=ve.getState(),I={x:S.width/2,y:S.height/2},W=sn(_,I,T.rotationDeg),ne={x:I.x+(W.x-I.x)*T.scale+T.translateX,y:I.y+(W.y-I.y)*T.scale+T.translateY},me=B.querySelector("svg");if(!me)return ne;let Me=me.getBoundingClientRect(),Le=O.getBoundingClientRect();return{x:Me.left-Le.left+ne.x/Math.max(S.width,1)*Me.width,y:Me.top-Le.top+ne.y/Math.max(S.height,1)*Me.height}}function Oe(_){let S=_.target?.closest("[data-editor-action]");if(S)switch(S.dataset.editorAction){case"add-object":{let T=w.querySelector("[data-editor-add-object-type]")?.value;He.addObject(T??"planet");return}case"add-viewpoint":He.addViewpoint();return;case"add-event":He.addEvent();return;case"add-annotation":He.addAnnotation();return;case"add-metadata":He.addMetadata();return;case"remove":He.removeSelection();return;case"undo":He.undo();return;case"redo":He.redo();return;case"format":ye(),s=r,re(),xe();return}}function qe(_){let S=_.target?.closest("[data-path-kind]");S&&ie({kind:S.dataset.pathKind,id:S.dataset.pathId||void 0,key:S.dataset.pathKey||void 0},!0,!0)}function Ne(_){let S=_.target?.closest("[data-path-kind]");if(S){ie({kind:S.dataset.pathKind,id:S.dataset.pathId||void 0,key:S.dataset.pathKey||void 0},!0,!0);return}let T=_.target?.closest("[data-editor-action]");if(T&&T.dataset.editorAction==="add-event-pose"){let I=T.dataset.editorEventId||(c?.kind==="event"||c?.kind==="event-pose"?c.id??"":"");if(!I)return;let W=TC(i,I),ne=W.events.find(Me=>Me.id===I),me=ne?.positions.at(-1)??ne?.positions[0];Y(W,!0,me?{kind:"event-pose",id:I,key:me.objectId}:{kind:"event",id:I});return}}function Re(){et(!1)}function Fe(){et(!0)}function et(_){if(!(!c||!k))switch(c.kind){case"system":Y(nt(),_,c,!1);return;case"defaults":Y(pt(),_,c,!1);return;case"metadata":Y(xt(c.key??""),_,c,!1);return;case"viewpoint":Y(st(c.id??""),_,c,!1);return;case"event":Y(Ht(c.id??""),_,c,!1);return;case"event-pose":Y(Et(c.id??"",c.key??""),_,c,!1);return;case"annotation":Y(Xr(c.id??""),_,c,!1);return;case"object":Y(rr(c.id??""),_,c,!1);return}}function mt(){s=le?.value??"",xe(),ye(),y=window.setTimeout(()=>{y=null,de(s,!1)},U2)}function Ge(){ye(),de(le?.value??"",!0)&&re()}function z(_){if(_.key==="Escape"&&d){_.preventDefault(),Ae();return}if(!R||_.defaultPrevented||qr(_))return;let S=(_.ctrlKey||_.metaKey)&&!_.shiftKey&&_.key.toLowerCase()==="z",T=(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"||_.key.toLowerCase()==="y");if(S){_.preventDefault(),He.undo();return}T&&(_.preventDefault(),He.redo())}function ue(_){let S=_.target?.closest("[data-handle-kind]");if(!S)return;let T=S.dataset.objectId,I=S.dataset.handleKind;if(!T||!["orbit-phase","orbit-radius","at-reference","surface-target","free-distance"].includes(I))return;if(ye(),s!==r&&!de(s,!0)){_.preventDefault();return}let W=ve?.getObjectDetails(T)??null;d={kind:I,objectId:T,pointerId:_.pointerId,path:c?{...c}:{kind:"object",id:T},startedFrom:Z(),changed:!1,orbitRadiusContext:I==="orbit-radius"&&W?vC(i,ve.getScene(),W):null},S.setPointerCapture?.(_.pointerId),_.preventDefault()}function Q(_){if(!d||d.pointerId!==_.pointerId||!c||Ii(c)!==Ii(d.path))return;let S=ve.getObjectDetails(d.objectId);if(!S)return;let T=Pe(_.clientX,_.clientY),I=i;switch(d.kind){case"orbit-phase":S.object.placement?.mode==="orbit"&&S.orbit&&(I=pC(i,d.path,d.objectId,S,T));break;case"orbit-radius":S.object.placement?.mode==="orbit"&&S.orbit&&(I=mC(i,d.path,d.objectId,S,T,d.orbitRadiusContext??null));break;case"at-reference":S.object.placement?.mode==="at"&&(I=gC(i,d.path,d.objectId,ve.getScene(),T));break;case"surface-target":S.object.placement?.mode==="surface"&&(I=yC(i,d.path,d.objectId,ve.getScene(),T));break;case"free-distance":S.object.placement?.mode==="free"&&(I=xC(i,d.path,d.objectId,ve.getScene(),S,T));break}I!==i&&(d.changed=!0,i=ot(I),a=nr(i),K({preserveCamera:!0,applyViewpointSelection:!1}),j(),te(),A(),ae(),be(),kn(),Tn(),sr(),xe())}function Se(_){if(!d||d.pointerId!==_.pointerId)return;let S=d;if(!d.changed){d=null;return}l.push(d.startedFrom),u.length=0,r=tr(i),s=r,d=null,Ie(),S.kind==="orbit-radius"&&Yr(S.objectId),xe(),fe()}function Ae(){if(!d)return;let _=d.startedFrom;d=null,i=ot(_.atlasDocument),r=_.source,s=r,a=nr(i),ie(_.selection,!1,!1),K({preserveCamera:!0,applyViewpointSelection:c?.kind==="viewpoint"}),Ie(),xe(),fe()}function Pe(_,S){let T=B.querySelector("svg"),I=ve.getScene();if(!T)return{x:I.width/2,y:I.height/2};let W=T.getBoundingClientRect(),ne={x:(_-W.left)/Math.max(W.width,1)*I.width,y:(S-W.top)/Math.max(W.height,1)*I.height};return ur(I,ve.getState(),ne)}function nt(){let _=ot(i),S=k?.querySelector("form[data-editor-form='system']");return!S||!_.system||(_.system.id=Kt(S,"system-id")||_.system.id,_.system.title=ke(S,"system-title")),_}function pt(){let _=ot(i),S=k?.querySelector("form[data-editor-form='defaults']");return!S||!_.system||(_.system.defaults.view=Kt(S,"defaults-view")||"topdown",_.system.defaults.scale=ke(S,"defaults-scale"),_.system.defaults.units=ke(S,"defaults-units"),_.system.defaults.preset=ke(S,"defaults-preset")??null,_.system.defaults.theme=ke(S,"defaults-theme")),_}function xt(_){let S=ot(i),T=k?.querySelector("form[data-editor-form='metadata']");if(!T||!S.system)return S;let I=Kt(T,"metadata-key")||_,W=ke(T,"metadata-value")??"";return I!==_?(delete S.system.atlasMetadata[_],S.system.atlasMetadata[I]=W,c={kind:"metadata",key:I},S):(S.system.atlasMetadata[_]=W,S)}function st(_){let S=ot(i),T=k?.querySelector("form[data-editor-form='viewpoint']"),I=S.system?.viewpoints.find(me=>me.id===_);if(!T||!I||!S.system)return S;let W=Kt(T,"viewpoint-id")||I.id,ne={...I,id:W,label:Kt(T,"viewpoint-label")||I.label,summary:ke(T,"viewpoint-summary")??"",focusObjectId:ke(T,"viewpoint-focus"),selectedObjectId:ke(T,"viewpoint-select"),projection:Kt(T,"viewpoint-projection")||I.projection,preset:ke(T,"viewpoint-preset")??null,zoom:ir(ke(T,"viewpoint-zoom")),rotationDeg:ir(ke(T,"viewpoint-rotation"))??0,camera:aC(T),layers:{background:Kn(T,"layer-background"),guides:Kn(T,"layer-guides"),"orbits-back":Kn(T,"layer-orbits-back"),"orbits-front":Kn(T,"layer-orbits-front"),events:Kn(T,"layer-events"),objects:Kn(T,"layer-objects"),labels:Kn(T,"layer-labels"),metadata:Kn(T,"layer-metadata")},events:Ai(ke(T,"viewpoint-events")),filter:{query:ke(T,"filter-query"),objectTypes:cC(ke(T,"filter-object-types")),tags:Ai(ke(T,"filter-tags")),groupIds:Ai(ke(T,"filter-groups"))}};return S.system.viewpoints=S.system.viewpoints.filter(me=>me.id!==I.id).concat(ne).sort((me,Me)=>me.id.localeCompare(Me.id)),I.id!==ne.id&&(c={kind:"viewpoint",id:ne.id}),S}function Ht(_){let S=ot(i),T=k?.querySelector("form[data-editor-form='event']"),I=S.events.find(me=>me.id===_);if(!T||!I)return S;let W=Kt(T,"event-id")||I.id,ne={...I,id:W,kind:Kt(T,"event-kind"),label:Kt(T,"event-label")||I.label,summary:ke(T,"event-summary"),targetObjectId:ke(T,"event-target"),participantObjectIds:Ai(ke(T,"event-participants")),timing:ke(T,"event-timing"),visibility:ke(T,"event-visibility"),epoch:ke(T,"event-epoch"),referencePlane:ke(T,"event-referencePlane"),tags:Ai(ke(T,"event-tags")),color:ke(T,"event-color"),hidden:Kn(T,"event-hidden")};return S.events=S.events.filter(me=>me.id!==I.id).concat(ne).sort(Jv),CC(S,I.id,ne.id,Ai(ke(T,"event-viewpoints"))),I.id!==ne.id&&(c={kind:"event",id:ne.id}),S}function Et(_,S){let T=ot(i),I=k?.querySelector("form[data-editor-form='event-pose']"),W=T.events.find(Ve=>Ve.id===_),ne=W?.positions.find(Ve=>Ve.objectId===S);if(!I||!W||!ne)return T;let Me={objectId:Kt(I,"pose-object-id")||ne.objectId,placement:sC(I,ne),epoch:ke(I,"pose-epoch"),referencePlane:ke(I,"pose-referencePlane")},Le=ei(ke(I,"prop-inner")),We=ei(ke(I,"prop-outer"));return Le&&(Me.inner=Le),We&&(Me.outer=We),W.positions=W.positions.filter(Ve=>Ve.objectId!==ne.objectId).concat(Me).sort(Xu),W.targetObjectId!==Me.objectId&&!W.participantObjectIds.includes(Me.objectId)&&(W.participantObjectIds.push(Me.objectId),W.participantObjectIds.sort((Ve,gt)=>Ve.localeCompare(gt))),ne.objectId!==Me.objectId&&(c={kind:"event-pose",id:_,key:Me.objectId}),T}function Xr(_){let S=ot(i),T=k?.querySelector("form[data-editor-form='annotation']"),I=S.system?.annotations.find(me=>me.id===_);if(!T||!I||!S.system)return S;let W=Kt(T,"annotation-id")||I.id,ne={...I,id:W,label:Kt(T,"annotation-label")||I.label,targetObjectId:ke(T,"annotation-target"),body:ke(T,"annotation-body")??"",tags:Ai(ke(T,"annotation-tags")),sourceObjectId:ke(T,"annotation-source")};return S.system.annotations=S.system.annotations.filter(me=>me.id!==I.id).concat(ne).sort((me,Me)=>me.id.localeCompare(Me.id)),I.id!==ne.id&&(c={kind:"annotation",id:ne.id}),S}function rr(_){let S=ot(i),T=k?.querySelector("form[data-editor-form='object']"),I=S.objects.find(Le=>Le.id===_);if(!T||!I)return S;let W=Kt(T,"object-id")||I.id,ne={...I,id:W,type:Kt(T,"object-type")||I.type,properties:{...I.properties},info:{...I.info},placement:rC(T,I)};for(let Le of B2)Hu(ne.properties,Le,ke(T,`prop-${Le}`));for(let Le of z2)Hu(ne.properties,Le,oC(ke(T,`prop-${Le}`)));for(let Le of V2)Hu(ne.properties,Le,ir(ke(T,`prop-${Le}`)));Hu(ne.properties,"tags",Ai(ke(T,"prop-tags"))),ne.properties.hidden=Kn(T,"prop-hidden");let me=ke(T,"info-description");me?ne.info.description=me:delete ne.info.description;let Me=dC(S,I.id,ne);return I.id!==ne.id&&(c={kind:"object",id:ne.id}),Me}function kn(){let _=a.filter(I=>I.diagnostic.severity==="error").length,S=a.filter(I=>I.diagnostic.severity==="warning").length,T=c?ju(c):"Nothing selected";ee.innerHTML=`
4094
4144
  <span class="wo-editor-status-pill${p?" is-dirty":" is-clean"}">${p?"Unsaved changes":"Saved"}</span>
4095
- <span class="wo-editor-status-pill">Schema ${Ze(i.version)}</span>
4096
- <span class="wo-editor-status-pill${M>0?" is-error":S>0?" is-warning":""}">${M} errors \xB7 ${S} warnings</span>
4097
- <span class="wo-editor-status-pill">${Ze(A)}</span>
4098
- `}function We(){let M=a.filter(A=>A.diagnostic.severity==="error").length,S=a.filter(A=>A.diagnostic.severity==="warning").length;J.textContent=`${p?"Unsaved changes.":"Saved."} ${M} errors, ${S} warnings. ${c?Gu(c):"Nothing selected"}.`}function ke(){g===null&&(g=window.setTimeout(()=>{g=null,xt()},N2))}function xt(){if(!ve)return;let M=ve.exportSvg();fe&&M!==m&&(fe.innerHTML=M,m=M);let S=Zv(Ie(),i,U);Te&&S!==v&&(Te.textContent=S,v=S)}function Ct(M){if(!ve)return;let S=ve.getObjectDetails(M);if(!S)return;let A=Eo(ve.getScene(),ve.getState()),T=36/Math.max(ve.getState().scale,.001),j=S.renderObject;(j.x<A.minX+T||j.x>A.maxX-T||j.y<A.minY+T||j.y>A.maxY-T)&&ve.fitToSystem()}function Pn(M){let S=M.target;if(!S)return!1;let A=S.tagName.toLowerCase();return S.isContentEditable||A==="input"||A==="textarea"||A==="select"}function or(M,S){if(!M)return[];let A=Ri(M);return S.filter(T=>{let j=Ri(T.path);return j&&j===A?!0:M.kind==="object"&&T.diagnostic.objectId===M.id})}function Qs(M,S){return or(M,S).filter(A=>{let T=A.diagnostic.field??"";return $p.has(T)||A.diagnostic.message.toLowerCase().includes("placement")||A.diagnostic.message.toLowerCase().includes("orbit")||A.diagnostic.message.toLowerCase().includes("surface")||A.diagnostic.message.toLowerCase().includes("lagrange")||A.diagnostic.message.toLowerCase().includes("anchor")})}function eo(M,S){let A=or(M,S);return A.length===0?"":`<div class="wo-editor-inspector-summary">
4099
- ${A.slice(0,4).map(T=>`<article class="wo-editor-diagnostic wo-editor-diagnostic-${Ze(T.diagnostic.severity)}">
4100
- <strong>${Ze(T.diagnostic.severity.toUpperCase())}</strong>
4101
- <span>${Ze(T.diagnostic.field??Gu(M))}</span>
4102
- <p>${Ze(T.diagnostic.message)}</p>
4145
+ <span class="wo-editor-status-pill">Schema ${Ye(i.version)}</span>
4146
+ <span class="wo-editor-status-pill${_>0?" is-error":S>0?" is-warning":""}">${_} errors \xB7 ${S} warnings</span>
4147
+ <span class="wo-editor-status-pill">${Ye(T)}</span>
4148
+ `}function Tn(){let _=a.filter(T=>T.diagnostic.severity==="error").length,S=a.filter(T=>T.diagnostic.severity==="warning").length;ce.textContent=`${p?"Unsaved changes.":"Saved."} ${_} errors, ${S} warnings. ${c?ju(c):"Nothing selected"}.`}function sr(){g===null&&(g=window.setTimeout(()=>{g=null,In()},N2))}function In(){if(!ve)return;let _=ve.exportSvg();he&&_!==m&&(he.innerHTML=_,m=_);let S=Zv(ze(),i,N);Te&&S!==x&&(Te.textContent=S,x=S)}function Yr(_){if(!ve)return;let S=ve.getObjectDetails(_);if(!S)return;let T=Eo(ve.getScene(),ve.getState()),I=36/Math.max(ve.getState().scale,.001),W=S.renderObject;(W.x<T.minX+I||W.x>T.maxX-I||W.y<T.minY+I||W.y>T.maxY-I)&&ve.fitToSystem()}function qr(_){let S=_.target;if(!S)return!1;let T=S.tagName.toLowerCase();return S.isContentEditable||T==="input"||T==="textarea"||T==="select"}function P(_,S){if(!_)return[];let T=Ii(_);return S.filter(I=>{let W=Ii(I.path);return W&&W===T?!0:_.kind==="object"&&I.diagnostic.objectId===_.id})}function $(_,S){return P(_,S).filter(T=>{let I=T.diagnostic.field??"";return $p.has(I)||T.diagnostic.message.toLowerCase().includes("placement")||T.diagnostic.message.toLowerCase().includes("orbit")||T.diagnostic.message.toLowerCase().includes("surface")||T.diagnostic.message.toLowerCase().includes("lagrange")||T.diagnostic.message.toLowerCase().includes("anchor")})}function G(_,S){let T=P(_,S);return T.length===0?"":`<div class="wo-editor-inspector-summary">
4149
+ ${T.slice(0,4).map(I=>`<article class="wo-editor-diagnostic wo-editor-diagnostic-${Ye(I.diagnostic.severity)}">
4150
+ <strong>${Ye(I.diagnostic.severity.toUpperCase())}</strong>
4151
+ <span>${Ye(I.diagnostic.field??ju(_))}</span>
4152
+ <p>${Ye(I.diagnostic.message)}</p>
4103
4153
  </article>`).join("")}
4104
- </div>`}function C(M,S){if(!V||!M)return;let A=or(M,S),T=new Map;for(let j of A)for(let ie of SC(M,j.diagnostic.field)){let ge=T.get(ie)??[];ge.push(j),T.set(ie,ge)}for(let[j,ie]of T){let ge=V.querySelector(`[name="${CSS.escape(j)}"]`),Ae=ge?.closest(".wo-editor-field, .wo-editor-checkbox");if(!ge||!Ae)continue;let Pe=ie.some(bt=>bt.diagnostic.severity==="error"),Xe=ie.some(bt=>bt.diagnostic.severity==="warning");Ae.classList.add(Pe?"has-error":"has-warning"),ge.setAttribute("aria-invalid",Pe?"true":"false");let Be=document.createElement("div");Be.className=`wo-editor-field-note${Pe?" is-error":Xe?" is-warning":""}`,Be.textContent=ie[0]?.diagnostic.message??"",Ae.append(Be)}}}function H2(n){if(n.atlasDocument){let t=lt(n.atlasDocument);return{atlasDocument:t,source:ir(t),diagnostics:rr(t)}}if(n.source){let t=wo(n.source);if(t.ok&&t.value){let i=t.value.atlasDocument??lr(t.value.document);return{atlasDocument:i,source:ir(i),diagnostics:ix(_o(i,t.diagnostics),rr(i))}}}let e=yc("WorldOrbit");return{atlasDocument:e,source:ir(e),diagnostics:rr(e)}}function ir(n){return dc(n,{schema:n.version})}function G2(){let n=Y2();return`<section class="wo-editor-shell">
4154
+ </div>`}function E(_,S){if(!k||!_)return;let T=P(_,S),I=new Map;for(let W of T)for(let ne of MC(_,W.diagnostic.field)){let me=I.get(ne)??[];me.push(W),I.set(ne,me)}for(let[W,ne]of I){let me=k.querySelector(`[name="${CSS.escape(W)}"]`),Me=me?.closest(".wo-editor-field, .wo-editor-checkbox");if(!me||!Me)continue;let Le=ne.some(gt=>gt.diagnostic.severity==="error"),We=ne.some(gt=>gt.diagnostic.severity==="warning");Me.classList.add(Le?"has-error":"has-warning"),me.setAttribute("aria-invalid",Le?"true":"false");let Ve=document.createElement("div");Ve.className=`wo-editor-field-note${Le?" is-error":We?" is-warning":""}`,Ve.textContent=ne[0]?.diagnostic.message??"",Me.append(Ve)}}}function H2(n){if(n.atlasDocument){let t=ot(n.atlasDocument);return{atlasDocument:t,source:tr(t),diagnostics:nr(t)}}if(n.source){let t=wo(n.source);if(t.ok&&t.value){let i=t.value.atlasDocument??cr(t.value.document);return{atlasDocument:i,source:tr(i),diagnostics:ix(_o(i,t.diagnostics),nr(i))}}}let e=yc("WorldOrbit");return{atlasDocument:e,source:tr(e),diagnostics:nr(e)}}function tr(n){return dc(n,{schema:n.version})}function j2(){let n=Y2();return`<section class="wo-editor-shell">
4105
4155
  <div class="wo-editor-toolbar" data-editor-toolbar></div>
4106
4156
  <div class="wo-editor-status" data-editor-status role="status" aria-live="polite"></div>
4107
4157
  <div class="wo-editor-main">
@@ -4146,156 +4196,156 @@ void main() {
4146
4196
  ></div>`)}
4147
4197
  </div>
4148
4198
  <div class="wo-editor-live-region" data-editor-live aria-live="polite" aria-atomic="true"></div>
4149
- </section>`}function Va(n,e,t,i=!0){return`<details class="wo-editor-panel-section" data-editor-panel-section="${Ze(e)}"${i?" open":""}>
4150
- <summary><span>${Ze(n)}</span></summary>
4199
+ </section>`}function Va(n,e,t,i=!0){return`<details class="wo-editor-panel-section" data-editor-panel-section="${Ye(e)}"${i?" open":""}>
4200
+ <summary><span>${Ye(n)}</span></summary>
4151
4201
  <div class="wo-editor-panel-section-body">${t}</div>
4152
- </details>`}function Ht(n,e,t,i,r=!1){let s=X2(n,e);return`<details class="wo-editor-inspector-section" data-editor-form-section="${Ze(e)}" data-editor-form-id="${Ze(n)}" data-editor-section-state="${Ze(s)}"${r?" open":""}>
4153
- <summary><span>${Ze(t)}</span></summary>
4202
+ </details>`}function Bt(n,e,t,i,r=!1){let s=X2(n,e);return`<details class="wo-editor-inspector-section" data-editor-form-section="${Ye(e)}" data-editor-form-id="${Ye(n)}" data-editor-section-state="${Ye(s)}"${r?" open":""}>
4203
+ <summary><span>${Ye(t)}</span></summary>
4154
4204
  <div class="wo-editor-inspector-section-body">${i}</div>
4155
- </details>`}function Wu(n,e){return`<span class="wo-editor-field-label">${Ze(n)}${j2(e)}</span>`}function j2(n){let e=$2[n];return e?`<details class="wo-editor-field-help">
4205
+ </details>`}function Wu(n,e){return`<span class="wo-editor-field-label">${Ye(n)}${G2(e)}</span>`}function G2(n){let e=$2[n];return e?`<details class="wo-editor-field-help">
4156
4206
  <summary aria-label="Explain ${ax(n)}">?</summary>
4157
4207
  <div class="wo-editor-field-help-card">
4158
- <p>${Ze(e.description)}</p>
4159
- ${(e.references?.length??0)>0?`<div class="wo-editor-field-help-chips">${(e.references??[]).map(t=>`<span>${Ze(t)}</span>`).join("")}</div>`:""}
4208
+ <p>${Ye(e.description)}</p>
4209
+ ${(e.references?.length??0)>0?`<div class="wo-editor-field-help-chips">${(e.references??[]).map(t=>`<span>${Ye(t)}</span>`).join("")}</div>`:""}
4160
4210
  </div>
4161
- </details>`:""}function W2(n,e){for(let t of n.querySelectorAll("[data-editor-section-state]")){let i=t.dataset.editorSectionState;i&&e.set(i,t.open)}}function er(n,e){for(let t of n.querySelectorAll("[data-editor-section-state]")){let i=t.dataset.editorSectionState;!i||!e.has(i)||(t.open=e.get(i)===!0)}}function X2(n,e){return`${n}:${e}`}function Y2(){return typeof window>"u"?!0:typeof window.matchMedia=="function"?!window.matchMedia("(max-width: 1280px)").matches:window.innerWidth>1280}function Ci(n,e,t,i){let r=Ri(n),s=r?i.get(r):null,o=s&&(s.errors>0||s.warnings>0)?`<span class="wo-editor-outline-badge${s.errors>0?" is-error":" is-warning"}">${s.errors>0?s.errors:s.warnings}</span>`:"";return`<button type="button" class="wo-editor-outline-item${r===t?" is-active":""}" data-path-kind="${Ze(n.kind)}"${n.id?` data-path-id="${Ze(n.id)}"`:""}${n.key?` data-path-key="${Ze(n.key)}"`:""}><span>${Ze(e)}</span>${o}</button>`}function q2(n,e,t){return`<div class="wo-editor-outline-group">
4162
- ${Ci({kind:"event",id:n.id},n.label||n.id,e,t)}
4163
- ${n.positions.length>0?`<div class="wo-editor-outline-children">${[...n.positions].sort(Xu).map(i=>Ci({kind:"event-pose",id:n.id,key:i.objectId},i.objectId,e,t)).join("")}</div>`:""}
4211
+ </details>`:""}function W2(n,e){for(let t of n.querySelectorAll("[data-editor-section-state]")){let i=t.dataset.editorSectionState;i&&e.set(i,t.open)}}function Ki(n,e){for(let t of n.querySelectorAll("[data-editor-section-state]")){let i=t.dataset.editorSectionState;!i||!e.has(i)||(t.open=e.get(i)===!0)}}function X2(n,e){return`${n}:${e}`}function Y2(){return typeof window>"u"?!0:typeof window.matchMedia=="function"?!window.matchMedia("(max-width: 1280px)").matches:window.innerWidth>1280}function Ti(n,e,t,i){let r=Ii(n),s=r?i.get(r):null,o=s&&(s.errors>0||s.warnings>0)?`<span class="wo-editor-outline-badge${s.errors>0?" is-error":" is-warning"}">${s.errors>0?s.errors:s.warnings}</span>`:"";return`<button type="button" class="wo-editor-outline-item${r===t?" is-active":""}" data-path-kind="${Ye(n.kind)}"${n.id?` data-path-id="${Ye(n.id)}"`:""}${n.key?` data-path-key="${Ye(n.key)}"`:""}><span>${Ye(e)}</span>${o}</button>`}function q2(n,e,t){return`<div class="wo-editor-outline-group">
4212
+ ${Ti({kind:"event",id:n.id},n.label||n.id,e,t)}
4213
+ ${n.positions.length>0?`<div class="wo-editor-outline-children">${[...n.positions].sort(Xu).map(i=>Ti({kind:"event-pose",id:n.id,key:i.objectId},i.objectId,e,t)).join("")}</div>`:""}
4164
4214
  </div>`}function Z2(n){return`<form class="wo-editor-form" data-editor-form="system">
4165
4215
  <h2>System</h2>
4166
- ${Ht("system","basics","Basics",`${_e("System ID","system-id",n.system?.id??"")}
4167
- ${_e("Title","system-title",n.system?.title??"")}`,!0)}
4216
+ ${Bt("system","basics","Basics",`${we("System ID","system-id",n.system?.id??"")}
4217
+ ${we("Title","system-title",n.system?.title??"")}`,!0)}
4168
4218
  </form>`}function J2(n){let e=n.system?.defaults;return`<form class="wo-editor-form" data-editor-form="defaults">
4169
4219
  <h2>Defaults</h2>
4170
- ${Ht("defaults","basics","Basics",`${Xr("Projection","defaults-view",[["topdown","Topdown"],["isometric","Isometric"],["orthographic","Orthographic"],["perspective","Perspective"]],e?.view??"topdown")}
4171
- ${_e("Scale preset","defaults-scale",e?.scale??"")}
4172
- ${_e("Units","defaults-units",e?.units??"")}
4173
- ${Xr("Render preset","defaults-preset",[["","Document default"],["diagram","Diagram"],["presentation","Presentation"],["atlas-card","Atlas Card"],["markdown","Markdown"]],e?.preset??"")}
4174
- ${_e("Theme","defaults-theme",e?.theme??"")}`,!0)}
4220
+ ${Bt("defaults","basics","Basics",`${Wr("Projection","defaults-view",[["topdown","Topdown"],["isometric","Isometric"],["orthographic","Orthographic"],["perspective","Perspective"]],e?.view??"topdown")}
4221
+ ${we("Scale preset","defaults-scale",e?.scale??"")}
4222
+ ${we("Units","defaults-units",e?.units??"")}
4223
+ ${Wr("Render preset","defaults-preset",[["","Document default"],["diagram","Diagram"],["presentation","Presentation"],["atlas-card","Atlas Card"],["markdown","Markdown"]],e?.preset??"")}
4224
+ ${we("Theme","defaults-theme",e?.theme??"")}`,!0)}
4175
4225
  </form>`}function K2(n,e){let t=n.system?.atlasMetadata[e]??"";return`<form class="wo-editor-form" data-editor-form="metadata">
4176
4226
  <h2>Metadata</h2>
4177
- ${Ht("metadata","entry","Entry",`${_e("Key","metadata-key",e)}
4227
+ ${Bt("metadata","entry","Entry",`${we("Key","metadata-key",e)}
4178
4228
  ${Wa("Value","metadata-value",t)}`,!0)}
4179
4229
  </form>`}function Q2(n,e){let t=n.viewpoints.find(i=>i.id===e);return t?`<form class="wo-editor-form" data-editor-form="viewpoint">
4180
4230
  <h2>Viewpoint</h2>
4181
- ${Ht("viewpoint","basics","Basics",`${_e("ID","viewpoint-id",t.id)}
4182
- ${_e("Label","viewpoint-label",t.label)}
4231
+ ${Bt("viewpoint","basics","Basics",`${we("ID","viewpoint-id",t.id)}
4232
+ ${we("Label","viewpoint-label",t.label)}
4183
4233
  ${Wa("Summary","viewpoint-summary",t.summary)}
4184
- ${_e("Focus object","viewpoint-focus",t.focusObjectId??"")}
4185
- ${_e("Selected object","viewpoint-select",t.selectedObjectId??"")}
4186
- ${Xr("Projection","viewpoint-projection",[["topdown","Topdown"],["isometric","Isometric"],["orthographic","Orthographic"],["perspective","Perspective"]],t.projection)}
4187
- ${Xr("Preset","viewpoint-preset",[["","Document default"],["diagram","Diagram"],["presentation","Presentation"],["atlas-card","Atlas Card"],["markdown","Markdown"]],t.preset??"")}
4188
- ${_e("Zoom","viewpoint-zoom",t.zoom===null?"":String(t.zoom))}
4189
- ${_e("Rotation","viewpoint-rotation",String(t.rotationDeg))}`,!0)}
4190
- ${Ht("viewpoint","camera","Camera",`${_e("Azimuth","viewpoint-camera-azimuth",t.camera?.azimuth===null||t.camera?.azimuth===void 0?"":String(t.camera.azimuth))}
4191
- ${_e("Elevation","viewpoint-camera-elevation",t.camera?.elevation===null||t.camera?.elevation===void 0?"":String(t.camera.elevation))}
4192
- ${_e("Roll","viewpoint-camera-roll",t.camera?.roll===null||t.camera?.roll===void 0?"":String(t.camera.roll))}
4193
- ${_e("Distance","viewpoint-camera-distance",t.camera?.distance===null||t.camera?.distance===void 0?"":String(t.camera.distance))}
4234
+ ${we("Focus object","viewpoint-focus",t.focusObjectId??"")}
4235
+ ${we("Selected object","viewpoint-select",t.selectedObjectId??"")}
4236
+ ${Wr("Projection","viewpoint-projection",[["topdown","Topdown"],["isometric","Isometric"],["orthographic","Orthographic"],["perspective","Perspective"]],t.projection)}
4237
+ ${Wr("Preset","viewpoint-preset",[["","Document default"],["diagram","Diagram"],["presentation","Presentation"],["atlas-card","Atlas Card"],["markdown","Markdown"]],t.preset??"")}
4238
+ ${we("Zoom","viewpoint-zoom",t.zoom===null?"":String(t.zoom))}
4239
+ ${we("Rotation","viewpoint-rotation",String(t.rotationDeg))}`,!0)}
4240
+ ${Bt("viewpoint","camera","Camera",`${we("Azimuth","viewpoint-camera-azimuth",t.camera?.azimuth===null||t.camera?.azimuth===void 0?"":String(t.camera.azimuth))}
4241
+ ${we("Elevation","viewpoint-camera-elevation",t.camera?.elevation===null||t.camera?.elevation===void 0?"":String(t.camera.elevation))}
4242
+ ${we("Roll","viewpoint-camera-roll",t.camera?.roll===null||t.camera?.roll===void 0?"":String(t.camera.roll))}
4243
+ ${we("Distance","viewpoint-camera-distance",t.camera?.distance===null||t.camera?.distance===void 0?"":String(t.camera.distance))}
4194
4244
  <p class="wo-editor-inline-note">Rotation stays a 2D screen-rotation hint. The camera block stores Schema 2.5 view direction and framing.</p>`)}
4195
- ${Ht("viewpoint","layers","Layers",`<fieldset class="wo-editor-fieldset">
4245
+ ${Bt("viewpoint","layers","Layers",`<fieldset class="wo-editor-fieldset">
4196
4246
  <legend>Layers</legend>
4197
- ${ti("Background","layer-background",t.layers.background!==!1)}
4198
- ${ti("Guides","layer-guides",t.layers.guides!==!1)}
4199
- ${ti("Orbits back","layer-orbits-back",t.layers["orbits-back"]!==!1)}
4200
- ${ti("Orbits front","layer-orbits-front",t.layers["orbits-front"]!==!1)}
4201
- ${ti("Events","layer-events",t.layers.events!==!1)}
4202
- ${ti("Objects","layer-objects",t.layers.objects!==!1)}
4203
- ${ti("Labels","layer-labels",t.layers.labels!==!1)}
4204
- ${ti("Metadata","layer-metadata",t.layers.metadata!==!1)}
4247
+ ${Qn("Background","layer-background",t.layers.background!==!1)}
4248
+ ${Qn("Guides","layer-guides",t.layers.guides!==!1)}
4249
+ ${Qn("Orbits back","layer-orbits-back",t.layers["orbits-back"]!==!1)}
4250
+ ${Qn("Orbits front","layer-orbits-front",t.layers["orbits-front"]!==!1)}
4251
+ ${Qn("Events","layer-events",t.layers.events!==!1)}
4252
+ ${Qn("Objects","layer-objects",t.layers.objects!==!1)}
4253
+ ${Qn("Labels","layer-labels",t.layers.labels!==!1)}
4254
+ ${Qn("Metadata","layer-metadata",t.layers.metadata!==!1)}
4205
4255
  </fieldset>`)}
4206
- ${Ht("viewpoint","filter","Filter",`${_e("Filter query","filter-query",t.filter?.query??"")}
4207
- ${_e("Filter object types","filter-object-types",t.filter?.objectTypes.join(" ")??"")}
4208
- ${_e("Filter tags","filter-tags",t.filter?.tags.join(" ")??"")}
4209
- ${_e("Filter groups","filter-groups",t.filter?.groupIds.join(" ")??"")}
4210
- ${_e("Events","viewpoint-events",t.events.join(" "))}`)}
4256
+ ${Bt("viewpoint","filter","Filter",`${we("Filter query","filter-query",t.filter?.query??"")}
4257
+ ${we("Filter object types","filter-object-types",t.filter?.objectTypes.join(" ")??"")}
4258
+ ${we("Filter tags","filter-tags",t.filter?.tags.join(" ")??"")}
4259
+ ${we("Filter groups","filter-groups",t.filter?.groupIds.join(" ")??"")}
4260
+ ${we("Events","viewpoint-events",t.events.join(" "))}`)}
4211
4261
  </form>`:'<p class="wo-editor-empty">Viewpoint not found.</p>'}function eC(n,e){let t=n.events.find(r=>r.id===e);if(!t)return'<p class="wo-editor-empty">Event not found.</p>';let i=n.viewpoints.filter(r=>r.events.includes(t.id)).map(r=>r.id).join(" ");return`<form class="wo-editor-form" data-editor-form="event">
4212
4262
  <h2>Event</h2>
4213
- ${Ht("event","basics","Basics",`${_e("ID","event-id",t.id)}
4214
- ${_e("Kind","event-kind",t.kind)}
4215
- ${_e("Label","event-label",t.label)}
4263
+ ${Bt("event","basics","Basics",`${we("ID","event-id",t.id)}
4264
+ ${we("Kind","event-kind",t.kind)}
4265
+ ${we("Label","event-label",t.label)}
4216
4266
  ${Wa("Summary","event-summary",t.summary??"")}
4217
- ${_e("Target object","event-target",t.targetObjectId??"")}
4218
- ${_e("Participants","event-participants",t.participantObjectIds.join(" "))}
4219
- ${_e("Timing","event-timing",t.timing??"")}
4220
- ${_e("Visibility","event-visibility",t.visibility??"")}
4221
- ${_e("Epoch","event-epoch",t.epoch??"")}
4222
- ${_e("Reference plane","event-referencePlane",t.referencePlane??"")}
4223
- ${_e("Tags","event-tags",t.tags.join(" "))}
4224
- ${_e("Color","event-color",t.color??"")}
4225
- ${ti("Hidden","event-hidden",t.hidden===!0)}`,!0)}
4226
- ${Ht("event","viewpoints","Viewpoints",`${_e("Viewpoints","event-viewpoints",i)}`)}
4227
- ${Ht("event","positions","Positions",`${t.positions.length>0?`<div class="wo-editor-inline-list">${t.positions.map(r=>Ci({kind:"event-pose",id:t.id,key:r.objectId},r.objectId,null,new Map)).join("")}</div>`:'<p class="wo-editor-empty">No event poses yet.</p>'}
4267
+ ${we("Target object","event-target",t.targetObjectId??"")}
4268
+ ${we("Participants","event-participants",t.participantObjectIds.join(" "))}
4269
+ ${we("Timing","event-timing",t.timing??"")}
4270
+ ${we("Visibility","event-visibility",t.visibility??"")}
4271
+ ${we("Epoch","event-epoch",t.epoch??"")}
4272
+ ${we("Reference plane","event-referencePlane",t.referencePlane??"")}
4273
+ ${we("Tags","event-tags",t.tags.join(" "))}
4274
+ ${we("Color","event-color",t.color??"")}
4275
+ ${Qn("Hidden","event-hidden",t.hidden===!0)}`,!0)}
4276
+ ${Bt("event","viewpoints","Viewpoints",`${we("Viewpoints","event-viewpoints",i)}`)}
4277
+ ${Bt("event","positions","Positions",`${t.positions.length>0?`<div class="wo-editor-inline-list">${t.positions.map(r=>Ti({kind:"event-pose",id:t.id,key:r.objectId},r.objectId,null,new Map)).join("")}</div>`:'<p class="wo-editor-empty">No event poses yet.</p>'}
4228
4278
  <div class="wo-editor-inline-actions">
4229
- <button type="button" data-editor-action="add-event-pose" data-editor-event-id="${Ze(t.id)}">Add pose</button>
4279
+ <button type="button" data-editor-action="add-event-pose" data-editor-event-id="${Ye(t.id)}">Add pose</button>
4230
4280
  </div>`)}
4231
- </form>`}function tC(n,e,t){let i=n.events.find(c=>c.id===e),r=i?.positions.find(c=>c.objectId===t);if(!i||!r)return'<p class="wo-editor-empty">Event pose not found.</p>';let s=r.placement?.mode??"",o=r.placement?.mode==="orbit"||r.placement?.mode==="surface"||r.placement?.mode==="at"?r.placement.target:"",a=r.placement?.mode==="free"?r.placement.distance?Wt(r.placement.distance):r.placement.descriptor??"":"";return`<form class="wo-editor-form" data-editor-form="event-pose">
4281
+ </form>`}function tC(n,e,t){let i=n.events.find(c=>c.id===e),r=i?.positions.find(c=>c.objectId===t);if(!i||!r)return'<p class="wo-editor-empty">Event pose not found.</p>';let s=r.placement?.mode??"",o=r.placement?.mode==="orbit"||r.placement?.mode==="surface"||r.placement?.mode==="at"?r.placement.target:"",a=r.placement?.mode==="free"?r.placement.distance?$t(r.placement.distance):r.placement.descriptor??"":"";return`<form class="wo-editor-form" data-editor-form="event-pose">
4232
4282
  <h2>Event Pose</h2>
4233
- <p class="wo-editor-inline-note">Event <strong>${Ze(i.label||i.id)}</strong></p>
4234
- ${Ht("event-pose","identity","Identity",`${_e("Object","pose-object-id",r.objectId)}
4283
+ <p class="wo-editor-inline-note">Event <strong>${Ye(i.label||i.id)}</strong></p>
4284
+ ${Bt("event-pose","identity","Identity",`${we("Object","pose-object-id",r.objectId)}
4235
4285
  <div class="wo-editor-inline-actions">
4236
- <button type="button" data-path-kind="event" data-path-id="${Ze(i.id)}">Select event</button>
4286
+ <button type="button" data-path-kind="event" data-path-id="${Ye(i.id)}">Select event</button>
4237
4287
  </div>`,!0)}
4238
- ${Ht("event-pose","placement","Placement",`${Xr("Placement mode","placement-mode",[["","None"],["orbit","Orbit"],["at","At"],["surface","Surface"],["free","Free"]],s)}
4239
- ${_e("Placement target","placement-target",o)}
4240
- ${_e("Free value","placement-free",a)}
4241
- ${_e("Distance","placement-distance",r.placement?.mode==="orbit"&&r.placement.distance?Wt(r.placement.distance):"")}
4242
- ${_e("Semi-major","placement-semiMajor",r.placement?.mode==="orbit"&&r.placement.semiMajor?Wt(r.placement.semiMajor):"")}
4243
- ${_e("Eccentricity","placement-eccentricity",r.placement?.mode==="orbit"&&r.placement.eccentricity!==void 0?String(r.placement.eccentricity):"")}
4244
- ${_e("Period","placement-period",r.placement?.mode==="orbit"&&r.placement.period?Wt(r.placement.period):"")}
4245
- ${_e("Angle","placement-angle",r.placement?.mode==="orbit"&&r.placement.angle?Wt(r.placement.angle):"")}
4246
- ${_e("Inclination","placement-inclination",r.placement?.mode==="orbit"&&r.placement.inclination?Wt(r.placement.inclination):"")}
4247
- ${_e("Phase","placement-phase",r.placement?.mode==="orbit"&&r.placement.phase?Wt(r.placement.phase):"")}
4248
- ${_e("Inner","prop-inner",r.inner?Wt(r.inner):"")}
4249
- ${_e("Outer","prop-outer",r.outer?Wt(r.outer):"")}`,!0)}
4250
- ${Ht("event-pose","context","Context",`${_e("Epoch","pose-epoch",r.epoch??"")}
4251
- ${_e("Reference plane","pose-referencePlane",r.referencePlane??"")}
4288
+ ${Bt("event-pose","placement","Placement",`${Wr("Placement mode","placement-mode",[["","None"],["orbit","Orbit"],["at","At"],["surface","Surface"],["free","Free"]],s)}
4289
+ ${we("Placement target","placement-target",o)}
4290
+ ${we("Free value","placement-free",a)}
4291
+ ${we("Distance","placement-distance",r.placement?.mode==="orbit"&&r.placement.distance?$t(r.placement.distance):"")}
4292
+ ${we("Semi-major","placement-semiMajor",r.placement?.mode==="orbit"&&r.placement.semiMajor?$t(r.placement.semiMajor):"")}
4293
+ ${we("Eccentricity","placement-eccentricity",r.placement?.mode==="orbit"&&r.placement.eccentricity!==void 0?String(r.placement.eccentricity):"")}
4294
+ ${we("Period","placement-period",r.placement?.mode==="orbit"&&r.placement.period?$t(r.placement.period):"")}
4295
+ ${we("Angle","placement-angle",r.placement?.mode==="orbit"&&r.placement.angle?$t(r.placement.angle):"")}
4296
+ ${we("Inclination","placement-inclination",r.placement?.mode==="orbit"&&r.placement.inclination?$t(r.placement.inclination):"")}
4297
+ ${we("Phase","placement-phase",r.placement?.mode==="orbit"&&r.placement.phase?$t(r.placement.phase):"")}
4298
+ ${we("Inner","prop-inner",r.inner?$t(r.inner):"")}
4299
+ ${we("Outer","prop-outer",r.outer?$t(r.outer):"")}`,!0)}
4300
+ ${Bt("event-pose","context","Context",`${we("Epoch","pose-epoch",r.epoch??"")}
4301
+ ${we("Reference plane","pose-referencePlane",r.referencePlane??"")}
4252
4302
  <p class="wo-editor-inline-note">Falls back to event, then object, then system context when left empty.</p>`)}
4253
4303
  </form>`}function nC(n,e){let t=n.system?.annotations.find(i=>i.id===e);return t?`<form class="wo-editor-form" data-editor-form="annotation">
4254
4304
  <h2>Annotation</h2>
4255
- ${Ht("annotation","entry","Entry",`${_e("ID","annotation-id",t.id)}
4256
- ${_e("Label","annotation-label",t.label)}
4257
- ${_e("Target object","annotation-target",t.targetObjectId??"")}
4258
- ${_e("Source object","annotation-source",t.sourceObjectId??"")}
4305
+ ${Bt("annotation","entry","Entry",`${we("ID","annotation-id",t.id)}
4306
+ ${we("Label","annotation-label",t.label)}
4307
+ ${we("Target object","annotation-target",t.targetObjectId??"")}
4308
+ ${we("Source object","annotation-source",t.sourceObjectId??"")}
4259
4309
  ${Wa("Body","annotation-body",t.body)}
4260
- ${_e("Tags","annotation-tags",t.tags.join(" "))}`,!0)}
4261
- </form>`:'<p class="wo-editor-empty">Annotation not found.</p>'}function iC(n,e){let t=n.objects.find(o=>o.id===e);if(!t)return'<p class="wo-editor-empty">Object not found.</p>';let i=t.placement?.mode??"",r=t.placement?.mode==="orbit"||t.placement?.mode==="surface"||t.placement?.mode==="at"?t.placement.target:"",s=t.placement?.mode==="free"?t.placement.distance?Wt(t.placement.distance):t.placement.descriptor??"":"";return`<form class="wo-editor-form" data-editor-form="object">
4310
+ ${we("Tags","annotation-tags",t.tags.join(" "))}`,!0)}
4311
+ </form>`:'<p class="wo-editor-empty">Annotation not found.</p>'}function iC(n,e){let t=n.objects.find(o=>o.id===e);if(!t)return'<p class="wo-editor-empty">Object not found.</p>';let i=t.placement?.mode??"",r=t.placement?.mode==="orbit"||t.placement?.mode==="surface"||t.placement?.mode==="at"?t.placement.target:"",s=t.placement?.mode==="free"?t.placement.distance?$t(t.placement.distance):t.placement.descriptor??"":"";return`<form class="wo-editor-form" data-editor-form="object">
4262
4312
  <h2>Object</h2>
4263
- ${Ht("object","identity","Identity",`${_e("ID","object-id",t.id)}
4264
- ${Xr("Type","object-type",Gp.map(o=>[o,Ga(o)]),t.type)}`,!0)}
4265
- ${Ht("object","placement","Placement",`${Xr("Placement mode","placement-mode",[["","None"],["orbit","Orbit"],["at","At"],["surface","Surface"],["free","Free"]],i)}
4266
- ${_e("Placement target","placement-target",r)}
4267
- ${_e("Free value","placement-free",s)}
4268
- ${_e("Distance","placement-distance",t.placement?.mode==="orbit"&&t.placement.distance?Wt(t.placement.distance):"")}
4269
- ${_e("Semi-major","placement-semiMajor",t.placement?.mode==="orbit"&&t.placement.semiMajor?Wt(t.placement.semiMajor):"")}
4270
- ${_e("Eccentricity","placement-eccentricity",t.placement?.mode==="orbit"&&t.placement.eccentricity!==void 0?String(t.placement.eccentricity):"")}
4271
- ${_e("Period","placement-period",t.placement?.mode==="orbit"&&t.placement.period?Wt(t.placement.period):"")}
4272
- ${_e("Angle","placement-angle",t.placement?.mode==="orbit"&&t.placement.angle?Wt(t.placement.angle):"")}
4273
- ${_e("Inclination","placement-inclination",t.placement?.mode==="orbit"&&t.placement.inclination?Wt(t.placement.inclination):"")}
4274
- ${_e("Phase","placement-phase",t.placement?.mode==="orbit"&&t.placement.phase?Wt(t.placement.phase):"")}`,!0)}
4275
- ${Ht("object","properties","Properties",`<fieldset class="wo-editor-fieldset">
4313
+ ${Bt("object","identity","Identity",`${we("ID","object-id",t.id)}
4314
+ ${Wr("Type","object-type",jp.map(o=>[o,ja(o)]),t.type)}`,!0)}
4315
+ ${Bt("object","placement","Placement",`${Wr("Placement mode","placement-mode",[["","None"],["orbit","Orbit"],["at","At"],["surface","Surface"],["free","Free"]],i)}
4316
+ ${we("Placement target","placement-target",r)}
4317
+ ${we("Free value","placement-free",s)}
4318
+ ${we("Distance","placement-distance",t.placement?.mode==="orbit"&&t.placement.distance?$t(t.placement.distance):"")}
4319
+ ${we("Semi-major","placement-semiMajor",t.placement?.mode==="orbit"&&t.placement.semiMajor?$t(t.placement.semiMajor):"")}
4320
+ ${we("Eccentricity","placement-eccentricity",t.placement?.mode==="orbit"&&t.placement.eccentricity!==void 0?String(t.placement.eccentricity):"")}
4321
+ ${we("Period","placement-period",t.placement?.mode==="orbit"&&t.placement.period?$t(t.placement.period):"")}
4322
+ ${we("Angle","placement-angle",t.placement?.mode==="orbit"&&t.placement.angle?$t(t.placement.angle):"")}
4323
+ ${we("Inclination","placement-inclination",t.placement?.mode==="orbit"&&t.placement.inclination?$t(t.placement.inclination):"")}
4324
+ ${we("Phase","placement-phase",t.placement?.mode==="orbit"&&t.placement.phase?$t(t.placement.phase):"")}`,!0)}
4325
+ ${Bt("object","properties","Properties",`<fieldset class="wo-editor-fieldset">
4276
4326
  <legend>Properties</legend>
4277
- ${_e("Kind","prop-kind",tr(t.properties.kind))}
4278
- ${_e("Class","prop-class",tr(t.properties.class))}
4279
- ${_e("Culture","prop-culture",tr(t.properties.culture))}
4280
- ${_e("Tags","prop-tags",RC(t.properties.tags))}
4281
- ${_e("Color","prop-color",tr(t.properties.color))}
4282
- ${_e("Image","prop-image",tr(t.properties.image))}
4283
- ${ti("Hidden","prop-hidden",t.properties.hidden===!0)}
4284
- ${_e("Radius","prop-radius",nr(t.properties.radius))}
4285
- ${_e("Mass","prop-mass",nr(t.properties.mass))}
4286
- ${_e("Density","prop-density",nr(t.properties.density))}
4287
- ${_e("Gravity","prop-gravity",nr(t.properties.gravity))}
4288
- ${_e("Temperature","prop-temperature",nr(t.properties.temperature))}
4289
- ${_e("Albedo","prop-albedo",PC(t.properties.albedo))}
4290
- ${_e("Atmosphere","prop-atmosphere",tr(t.properties.atmosphere))}
4291
- ${_e("Inner","prop-inner",nr(t.properties.inner))}
4292
- ${_e("Outer","prop-outer",nr(t.properties.outer))}
4293
- ${_e("On","prop-on",tr(t.properties.on))}
4294
- ${_e("Source","prop-source",tr(t.properties.source))}
4295
- ${_e("Cycle","prop-cycle",nr(t.properties.cycle))}
4327
+ ${we("Kind","prop-kind",Qi(t.properties.kind))}
4328
+ ${we("Class","prop-class",Qi(t.properties.class))}
4329
+ ${we("Culture","prop-culture",Qi(t.properties.culture))}
4330
+ ${we("Tags","prop-tags",RC(t.properties.tags))}
4331
+ ${we("Color","prop-color",Qi(t.properties.color))}
4332
+ ${we("Image","prop-image",Qi(t.properties.image))}
4333
+ ${Qn("Hidden","prop-hidden",t.properties.hidden===!0)}
4334
+ ${we("Radius","prop-radius",er(t.properties.radius))}
4335
+ ${we("Mass","prop-mass",er(t.properties.mass))}
4336
+ ${we("Density","prop-density",er(t.properties.density))}
4337
+ ${we("Gravity","prop-gravity",er(t.properties.gravity))}
4338
+ ${we("Temperature","prop-temperature",er(t.properties.temperature))}
4339
+ ${we("Albedo","prop-albedo",PC(t.properties.albedo))}
4340
+ ${we("Atmosphere","prop-atmosphere",Qi(t.properties.atmosphere))}
4341
+ ${we("Inner","prop-inner",er(t.properties.inner))}
4342
+ ${we("Outer","prop-outer",er(t.properties.outer))}
4343
+ ${we("On","prop-on",Qi(t.properties.on))}
4344
+ ${we("Source","prop-source",Qi(t.properties.source))}
4345
+ ${we("Cycle","prop-cycle",er(t.properties.cycle))}
4296
4346
  </fieldset>`)}
4297
- ${Ht("object","info","Info",`${Wa("Description","info-description",t.info.description??"")}`)}
4298
- </form>`}function _e(n,e,t){return`<label class="wo-editor-field">${Wu(n,e)}<input name="${Ze(e)}" value="${ax(t)}" /></label>`}function Wa(n,e,t){return`<label class="wo-editor-field">${Wu(n,e)}<textarea name="${Ze(e)}">${Ze(t)}</textarea></label>`}function Xr(n,e,t,i){return`<label class="wo-editor-field">${Wu(n,e)}<select name="${Ze(e)}">${t.map(([r,s])=>`<option value="${Ze(r)}"${r===i?" selected":""}>${Ze(s)}</option>`).join("")}</select></label>`}function ti(n,e,t){return`<label class="wo-editor-checkbox"><input type="checkbox" name="${Ze(e)}"${t?" checked":""} />${Wu(n,e)}</label>`}function $a(n,e,t,i){let r=document.createElement("button");return r.type="button",r.className="wo-editor-handle",r.dataset.handleKind=n,r.dataset.objectId=e,r.style.left=`${t.x}px`,r.style.top=`${t.y}px`,r.textContent=i,r}function tn(n,e){return n.elements.namedItem(e)?.value.trim()??""}function Fe(n,e){let t=tn(n,e);return t||null}function ei(n,e){return n.elements.namedItem(e)?.checked??!1}function rC(n,e){return nx(n,e.placement,e.id)}function sC(n,e){return nx(n,e.placement,e.objectId)}function nx(n,e,t){let i=tn(n,"placement-mode"),r=Fe(n,"placement-target");switch(i){case"orbit":return{mode:i,target:r??(e?.mode==="orbit"?e.target:t),distance:ni(Fe(n,"placement-distance")),semiMajor:ni(Fe(n,"placement-semiMajor")),eccentricity:sr(Fe(n,"placement-eccentricity"))??void 0,period:ni(Fe(n,"placement-period")),angle:ni(Fe(n,"placement-angle")),inclination:ni(Fe(n,"placement-inclination")),phase:ni(Fe(n,"placement-phase"))};case"at":return{mode:i,target:r??t,reference:ja(r??t)};case"surface":return{mode:i,target:r??t};case"free":{let s=Fe(n,"placement-free"),o=ni(s);return{mode:i,distance:o??void 0,descriptor:o?void 0:s??void 0}}default:return null}}function Hu(n,e,t){let i=Array.isArray(t)&&t.length===0;if(t==null||i||t===""){delete n[e];return}n[e]=t}function oC(n){return n?ni(n)??n:null}function ni(n){if(!n)return;let e=n.match(/^(-?\d+(?:\.\d+)?)(au|km|re|sol|me|d|y|h|deg)?$/);if(e)return{value:Number(e[1]),unit:e[2]??null}}function sr(n){if(!n)return null;let e=Number(n);return Number.isFinite(e)?e:null}function aC(n){let e={azimuth:sr(Fe(n,"viewpoint-camera-azimuth")),elevation:sr(Fe(n,"viewpoint-camera-elevation")),roll:sr(Fe(n,"viewpoint-camera-roll")),distance:sr(Fe(n,"viewpoint-camera-distance"))};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function cC(n){return Ii(n).filter(t=>Gp.includes(t))}function Ii(n){return n?.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)??[]}function lC(n,e,t){let i=t.objects.find(r=>r.type==="star")?.id??t.objects[0]?.id??e;return{type:n,id:e,properties:{},placement:n==="structure"||n==="phenomenon"?{mode:"at",target:`${i}:L4`,reference:ja(`${i}:L4`)}:{mode:"orbit",target:i,distance:{value:1,unit:"au"}},info:{}}}function uC(n,e){let t=lt(n);return t.objects=t.objects.filter(i=>i.id!==e.id).concat(e).sort(rx),t}function dC(n,e,t){let i=lt(n);return i.objects=i.objects.filter(r=>r.id!==e).concat(t).sort(rx),e!==t.id&&hC(i,e,t.id),i}function hC(n,e,t){for(let i of n.objects)if(i.id!==t&&(i.placement?.mode==="orbit"&&i.placement.target===e&&(i.placement.target=t),i.placement?.mode==="surface"&&i.placement.target===e&&(i.placement.target=t),i.placement?.mode==="at")){let r=i.placement.reference;r.kind==="anchor"&&r.objectId===e&&(r.objectId=t),r.kind==="lagrange"&&(r.primary===e&&(r.primary=t),r.secondary===e&&(r.secondary=t)),i.placement.target=Hp(r)}for(let i of n.system?.viewpoints??[])i.focusObjectId===e&&(i.focusObjectId=t),i.selectedObjectId===e&&(i.selectedObjectId=t);for(let i of n.system?.annotations??[])i.targetObjectId===e&&(i.targetObjectId=t),i.sourceObjectId===e&&(i.sourceObjectId=t);for(let i of n.events){i.targetObjectId===e&&(i.targetObjectId=t),i.participantObjectIds=i.participantObjectIds.map(r=>r===e?t:r);for(let r of i.positions)if(r.objectId===e&&(r.objectId=t),r.placement?.mode==="orbit"&&r.placement.target===e&&(r.placement.target=t),r.placement?.mode==="surface"&&r.placement.target===e&&(r.placement.target=t),r.placement?.mode==="at"){let s=r.placement.reference;s.kind==="anchor"&&s.objectId===e&&(s.objectId=t),s.kind==="lagrange"&&(s.primary===e&&(s.primary=t),s.secondary===e&&(s.secondary=t)),r.placement.target=Hp(s)}i.positions.sort(Xu)}}function fC(n,e){let t=wd(n,e);if(e.kind==="event"&&e.id){for(let i of t.system?.viewpoints??[])i.events=i.events.filter(r=>r!==e.id);return t}if(e.kind!=="object"||!e.id)return t;for(let i of t.objects)if(i.placement?.mode==="orbit"&&i.placement.target===e.id&&(i.placement=null),i.placement?.mode==="surface"&&i.placement.target===e.id&&(i.placement=null),i.placement?.mode==="at"){let r=i.placement.reference;(r.kind==="anchor"&&r.objectId===e.id||r.kind==="lagrange"&&(r.primary===e.id||r.secondary===e.id))&&(i.placement=null)}for(let i of t.system?.viewpoints??[])i.focusObjectId===e.id&&(i.focusObjectId=null),i.selectedObjectId===e.id&&(i.selectedObjectId=null);for(let i of t.system?.annotations??[])i.targetObjectId===e.id&&(i.targetObjectId=null),i.sourceObjectId===e.id&&(i.sourceObjectId=null);for(let i of t.events){i.targetObjectId===e.id&&(i.targetObjectId=null),i.participantObjectIds=i.participantObjectIds.filter(r=>r!==e.id),i.positions=i.positions.filter(r=>r.objectId!==e.id);for(let r of i.positions)if(r.placement?.mode==="orbit"&&r.placement.target===e.id&&(r.placement=null),r.placement?.mode==="surface"&&r.placement.target===e.id&&(r.placement=null),r.placement?.mode==="at"){let s=r.placement.reference;(s.kind==="anchor"&&s.objectId===e.id||s.kind==="lagrange"&&(s.primary===e.id||s.secondary===e.id))&&(r.placement=null)}}return t}function Xa(n,e,t){if(e.kind==="event-pose"&&e.id&&e.key){let r=sx(n,e.id,e.key);return r?.placement?{placement:r.placement}:null}let i=AC(n,t);return i?.placement?{placement:i.placement}:null}function pC(n,e,t,i,r){let s=i.orbit;if(!s||i.object.placement?.mode!=="orbit")return n;let o=ln(r,{x:s.cx,y:s.cy},-s.rotationDeg),a=s.kind==="circle"?s.radius??1:s.rx??1,c=s.kind==="circle"?s.radius??1:s.ry??1,l=Math.atan2((o.y-s.cy)/Math.max(c,1),(o.x-s.cx)/Math.max(a,1)),u=DC(l*180/Math.PI),d=lt(n),h=Xa(d,e,t);return!h||h.placement.mode!=="orbit"?n:(h.placement.phase={value:Js(u,2),unit:"deg"},d)}function mC(n,e,t,i,r,s){let o=i.orbit;if(!o||i.object.placement?.mode!=="orbit"||!s)return n;let a=ln(r,{x:o.cx,y:o.cy},-o.rotationDeg),c=Math.max(Math.abs(a.x-o.cx),24),l=Math.max(c-s.radiusOffsetPx,s.innerPx),u=FC(l,s.innerPx,s.stepPx),d=lt(n),h=Xa(d,e,t);if(!h||h.placement.mode!=="orbit")return n;let f=h.placement.semiMajor??h.placement.distance??{value:1,unit:"au"},p=ox(Math.max(u,0),s.preferredUnit??f.unit);return h.placement.semiMajor?h.placement.semiMajor=p:h.placement.distance=p,d}function gC(n,e,t,i,r){let s=_C(i,t,r);if(!s)return n;let o=lt(n),a=Xa(o,e,t);return!a||a.placement.mode!=="at"?n:(a.placement.reference=s.reference,a.placement.target=Hp(s.reference),o)}function yC(n,e,t,i,r){let s=bC(i,t,r,c=>k2.has(c.object.type));if(!s)return n;let o=lt(n),a=Xa(o,e,t);return!a||a.placement.mode!=="surface"?n:(a.placement.target=s.objectId,o)}function vC(n,e,t){if(t.object.placement?.mode!=="orbit"||!t.orbit||!t.parent)return null;let i=t.object.placement.target,r=e.objects.filter(h=>h.object.placement?.mode==="orbit"&&h.object.placement.target===i&&!h.hidden).length,s=kC(e.layoutPreset),o=(r>2?54:64)*s*e.scaleModel.orbitDistanceMultiplier,a=t.parent.radius+56*s*e.scaleModel.orbitDistanceMultiplier,c=t.object.placement.semiMajor??t.object.placement.distance??null,l=UC(c),u=t.orbit.kind==="circle"?t.orbit.radius??1:t.orbit.rx??1,d=NC(l??0,a,o);return{innerPx:a,stepPx:o,radiusOffsetPx:u-d,preferredUnit:c?.unit??null}}function xC(n,e,t,i,r,s){if(r.object.placement?.mode!=="free")return n;let o=i.width-i.padding-140,a=Math.max(0,o-s.x),c=lt(n),l=Xa(c,e,t);if(!l||l.placement.mode!=="free")return n;let u=OC(l.placement.distance?.unit??null),d=a/Math.max(F2*i.scaleModel.freePlacementMultiplier,1);return d<.01?(l.placement.distance=void 0,l.placement.descriptor||delete l.placement.descriptor,c):(l.placement.distance=ox(d,u),delete l.placement.descriptor,c)}function bC(n,e,t,i=()=>!0){let r=null,s=Number.POSITIVE_INFINITY;for(let o of n.objects){if(o.hidden||o.objectId===e||!i(o))continue;let a=Math.hypot(t.x-o.x,t.y-o.y);a<s&&(r=o,s=a)}return s<=140?r:null}function _C(n,e,t){let i=null;for(let a of n.objects){if(a.hidden||a.objectId===e)continue;let c=Math.hypot(t.x-a.x,t.y-a.y),l=Math.max(a.visualRadius+16,28);c<=l&&(!i||c<i.distance)&&(i={reference:ja(a.objectId),x:a.x,y:a.y,distance:c})}if(i)return{reference:i.reference,x:i.x,y:i.y};let r=[];for(let a of n.objects)a.hidden||a.objectId===e||r.push({reference:ja(a.objectId),x:a.x,y:a.y});for(let a of n.orbitVisuals){if(a.hidden||a.objectId===e)continue;let c=n.objects.find(u=>u.objectId===a.parentId&&!u.hidden),l=n.objects.find(u=>u.objectId===a.objectId&&!u.hidden);if(!(!c||!l))for(let u of["L1","L2","L3","L4","L5"]){let d=wC(c,l,u);r.push({reference:ja(`${a.objectId}:${u}`),x:d.x,y:d.y})}}let s=null,o=Number.POSITIVE_INFINITY;for(let a of r){let c=Math.hypot(t.x-a.x,t.y-a.y);c<o&&(s=a,o=c)}return o<=140?s:null}function wC(n,e,t){let i=e.x-n.x,r=e.y-n.y,s=Math.hypot(i,r)||1,o=i/s,a=r/s,c=-a,l=o,u=LC(s*.25,24,68);switch(t){case"L1":return{x:e.x-o*u,y:e.y-a*u};case"L2":return{x:e.x+o*u,y:e.y+a*u};case"L3":return{x:n.x-o*u,y:n.y-a*u};case"L4":return{x:e.x+(o*.5-c*.8660254)*u,y:e.y+(a*.5-l*.8660254)*u};case"L5":return{x:e.x+(o*.5+c*.8660254)*u,y:e.y+(a*.5+l*.8660254)*u}}}function ja(n){let e=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(e)return{kind:"lagrange",primary:e[1],secondary:e[2],point:e[3]};let t=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:null,point:t[2]};let i=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return i?{kind:"anchor",objectId:i[1],anchor:i[2]}:{kind:"named",name:n}}function Hp(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function rr(n){return Md(n)}function ix(n,e){let t=new Set,i=[];for(let r of[...n,...e]){let s=`${r.diagnostic.code}:${r.diagnostic.message}:${Ri(r.path)}`;t.has(s)||(t.add(s),i.push(ju(r)))}return i}function MC(n){let e=new Map;for(let t of n){let i=Ri(t.path)??(t.diagnostic.objectId?Ri({kind:"object",id:t.diagnostic.objectId}):null);if(!i)continue;let r=e.get(i)??{errors:0,warnings:0};t.diagnostic.severity==="error"?r.errors+=1:t.diagnostic.severity==="warning"&&(r.warnings+=1),e.set(i,r)}return e}function qv(n){return n.diagnostic.line!==void 0&&n.diagnostic.column!==void 0?`Line ${n.diagnostic.line}:${n.diagnostic.column}`:n.diagnostic.line!==void 0?`Line ${n.diagnostic.line}`:null}function SC(n,e){if(!e)return[];switch(n.kind){case"system":return e==="id"?["system-id"]:e==="title"?["system-title"]:[];case"defaults":switch(e){case"view":return["defaults-view"];case"scale":return["defaults-scale"];case"units":return["defaults-units"];case"preset":return["defaults-preset"];case"theme":return["defaults-theme"];default:return[]}case"metadata":return e==="key"?["metadata-key"]:["metadata-value"];case"group":switch(e){case"id":return["group-id"];case"label":return["group-label"];case"summary":return["group-summary"];case"color":return["group-color"];case"tags":return["group-tags"];case"hidden":return["group-hidden"];default:return[]}case"viewpoint":switch(e){case"id":return["viewpoint-id"];case"label":return["viewpoint-label"];case"summary":return["viewpoint-summary"];case"focusObjectId":return["viewpoint-focus"];case"selectedObjectId":return["viewpoint-select"];case"projection":return["viewpoint-projection"];case"preset":return["viewpoint-preset"];case"zoom":return["viewpoint-zoom"];case"rotationDeg":return["viewpoint-rotation"];case"camera":return["viewpoint-camera-azimuth","viewpoint-camera-elevation","viewpoint-camera-roll","viewpoint-camera-distance"];case"camera.azimuth":return["viewpoint-camera-azimuth"];case"camera.elevation":return["viewpoint-camera-elevation"];case"camera.roll":return["viewpoint-camera-roll"];case"camera.distance":return["viewpoint-camera-distance"];case"events":return["viewpoint-events"];default:return[]}case"event":switch(e){case"id":return["event-id"];case"kind":return["event-kind"];case"label":return["event-label"];case"summary":return["event-summary"];case"targetObjectId":case"target":return["event-target"];case"participantObjectIds":case"participants":return["event-participants"];case"timing":return["event-timing"];case"visibility":return["event-visibility"];case"epoch":return["event-epoch"];case"referencePlane":return["event-referencePlane"];case"tags":return["event-tags"];case"color":return["event-color"];case"hidden":return["event-hidden"];default:return[]}case"event-pose":return e==="objectId"?["pose-object-id"]:e==="placement"?["placement-mode"]:e==="reference"||e==="target"?["placement-target"]:e==="descriptor"?["placement-free"]:$p.has(e)?[`placement-${e}`]:e==="inner"||e==="outer"?[`prop-${e}`]:e==="epoch"?["pose-epoch"]:e==="referencePlane"?["pose-referencePlane"]:[];case"annotation":switch(e){case"id":return["annotation-id"];case"label":return["annotation-label"];case"targetObjectId":return["annotation-target"];case"sourceObjectId":return["annotation-source"];case"body":return["annotation-body"];case"tags":return["annotation-tags"];default:return[]}case"relation":switch(e){case"id":return["relation-id"];case"from":return["relation-from"];case"to":return["relation-to"];case"kind":return["relation-kind"];case"label":return["relation-label"];case"summary":return["relation-summary"];case"tags":return["relation-tags"];case"color":return["relation-color"];case"hidden":return["relation-hidden"];default:return[]}case"object":return e==="id"?["object-id"]:e==="type"?["object-type"]:e==="placement"?["placement-mode"]:e==="description"?["info-description"]:e==="reference"?["placement-target"]:e==="descriptor"?["placement-free"]:e==="target"?["placement-target"]:$p.has(e)?[`placement-${e}`]:[`prop-${e}`]}}function Zv(n,e,t){return za(n,{mode:t==="3d"?"interactive-3d":"interactive-2d",preset:e.system?.defaults.preset??"atlas-card",projection:e.system?.defaults.view??"topdown"})}function Gu(n){switch(n.kind){case"system":return"System";case"defaults":return"Defaults";case"metadata":return`Metadata: ${n.key??""}`;case"group":return`Group: ${n.id??""}`;case"event":return`Event: ${n.id??""}`;case"event-pose":return`Event Pose: ${n.id??""} / ${n.key??""}`;case"object":return`Object: ${n.id??""}`;case"viewpoint":return`Viewpoint: ${n.id??""}`;case"annotation":return`Annotation: ${n.id??""}`;case"relation":return`Relation: ${n.id??""}`}}function Ri(n){return n?`${n.kind}:${n.id??""}:${n.key??""}`:null}function Vp(n){return n&&(n.kind==="event"||n.kind==="event-pose")?n.id??null:null}function rx(n,e){return n.id.localeCompare(e.id)}function Jv(n,e){return n.id.localeCompare(e.id)}function Xu(n,e){return n.objectId.localeCompare(e.objectId)}function EC(n,e){return n.events.find(t=>t.id===e)??null}function sx(n,e,t){return EC(n,e)?.positions.find(i=>i.objectId===t)??null}function AC(n,e){return n.objects.find(t=>t.id===e)??null}function TC(n,e){let t=lt(n),i=t.events.find(s=>s.id===e);if(!i)return n;let r=t.objects.find(s=>!i.positions.some(o=>o.objectId===s.id))??t.objects[0];return r?(i.targetObjectId!==r.id&&!i.participantObjectIds.includes(r.id)&&(i.participantObjectIds.push(r.id),i.participantObjectIds.sort((s,o)=>s.localeCompare(o))),i.positions.push(IC(r)),i.positions.sort(Xu),t):n}function IC(n){return{objectId:n.id,placement:n.placement?structuredClone(n.placement):null,inner:Kv(n.properties.inner),outer:Kv(n.properties.outer)}}function CC(n,e,t,i){let r=new Set(i);for(let s of n.system?.viewpoints??[]){let o=new Set(s.events);o.delete(e),o.delete(t),r.has(s.id)&&o.add(t),s.events=[...o].sort((a,c)=>a.localeCompare(c))}}function Ha(n,e){let t=n.trim()||"item",i=1,r=t;for(;e.includes(r);)i+=1,r=`${t}-${i}`;return r}function Ga(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function ju(n){return{diagnostic:{...n.diagnostic},path:n.path?{...n.path}:null}}function tr(n){return typeof n=="string"?n:""}function RC(n){return Array.isArray(n)?n.join(" "):""}function nr(n){return n&&typeof n=="object"&&"value"in n?Wt(n):""}function Kv(n){return n&&typeof n=="object"&&"value"in n?n:void 0}function PC(n){return typeof n=="number"?String(n):""}function Wt(n){return`${n.value}${n.unit??""}`}function Js(n,e){let t=10**e;return Math.round(n*t)/t}function LC(n,e,t){return Math.min(Math.max(n,e),t)}function DC(n){let e=n%360;return e<0&&(e+=360),e}function OC(n){switch(n){case"au":case"km":case"re":case"sol":case null:return n;default:return null}}function UC(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/Ks;case"re":return n.value*Qv/Ks;case"sol":return n.value*ex/Ks;default:return n.value}}function ox(n,e){switch(e){case"km":return{value:Js(n*Ks,0),unit:e};case"re":return{value:Js(n*Ks/Qv,3),unit:e};case"sol":return{value:Js(n*Ks/ex,4),unit:e};case"au":return{value:Js(n,3),unit:e};default:return{value:Js(n,2),unit:null}}}function NC(n,e,t){return e+t*BC(Math.max(n,0)+1)}function FC(n,e,t){return n<=e?0:Math.pow(2,(n-e)/Math.max(t,1e-4))-1}function kC(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function BC(n){return Math.log(n)/Math.log(2)}function Ze(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function ax(n){return Ze(n)}function zC(n){if(typeof window>"u"||typeof document>"u")throw new Error("createWorldOrbitEditor can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("WorldOrbit editor requires an HTMLElement container.")}function wn(n,e){let t=n.querySelector(e);if(!t)throw new Error(`WorldOrbit editor failed to initialize selector "${e}".`);return t}function VC(){if(document.getElementById(Yv))return;let n=document.createElement("style");n.id=Yv,n.textContent=`
4347
+ ${Bt("object","info","Info",`${Wa("Description","info-description",t.info.description??"")}`)}
4348
+ </form>`}function we(n,e,t){return`<label class="wo-editor-field">${Wu(n,e)}<input name="${Ye(e)}" value="${ax(t)}" /></label>`}function Wa(n,e,t){return`<label class="wo-editor-field">${Wu(n,e)}<textarea name="${Ye(e)}">${Ye(t)}</textarea></label>`}function Wr(n,e,t,i){return`<label class="wo-editor-field">${Wu(n,e)}<select name="${Ye(e)}">${t.map(([r,s])=>`<option value="${Ye(r)}"${r===i?" selected":""}>${Ye(s)}</option>`).join("")}</select></label>`}function Qn(n,e,t){return`<label class="wo-editor-checkbox"><input type="checkbox" name="${Ye(e)}"${t?" checked":""} />${Wu(n,e)}</label>`}function $a(n,e,t,i){let r=document.createElement("button");return r.type="button",r.className="wo-editor-handle",r.dataset.handleKind=n,r.dataset.objectId=e,r.style.left=`${t.x}px`,r.style.top=`${t.y}px`,r.textContent=i,r}function Kt(n,e){return n.elements.namedItem(e)?.value.trim()??""}function ke(n,e){let t=Kt(n,e);return t||null}function Kn(n,e){return n.elements.namedItem(e)?.checked??!1}function rC(n,e){return nx(n,e.placement,e.id)}function sC(n,e){return nx(n,e.placement,e.objectId)}function nx(n,e,t){let i=Kt(n,"placement-mode"),r=ke(n,"placement-target");switch(i){case"orbit":return{mode:i,target:r??(e?.mode==="orbit"?e.target:t),distance:ei(ke(n,"placement-distance")),semiMajor:ei(ke(n,"placement-semiMajor")),eccentricity:ir(ke(n,"placement-eccentricity"))??void 0,period:ei(ke(n,"placement-period")),angle:ei(ke(n,"placement-angle")),inclination:ei(ke(n,"placement-inclination")),phase:ei(ke(n,"placement-phase"))};case"at":return{mode:i,target:r??t,reference:Ga(r??t)};case"surface":return{mode:i,target:r??t};case"free":{let s=ke(n,"placement-free"),o=ei(s);return{mode:i,distance:o??void 0,descriptor:o?void 0:s??void 0}}default:return null}}function Hu(n,e,t){let i=Array.isArray(t)&&t.length===0;if(t==null||i||t===""){delete n[e];return}n[e]=t}function oC(n){return n?ei(n)??n:null}function ei(n){if(!n)return;let e=n.match(/^(-?\d+(?:\.\d+)?)(au|km|re|sol|me|d|y|h|deg)?$/);if(e)return{value:Number(e[1]),unit:e[2]??null}}function ir(n){if(!n)return null;let e=Number(n);return Number.isFinite(e)?e:null}function aC(n){let e={azimuth:ir(ke(n,"viewpoint-camera-azimuth")),elevation:ir(ke(n,"viewpoint-camera-elevation")),roll:ir(ke(n,"viewpoint-camera-roll")),distance:ir(ke(n,"viewpoint-camera-distance"))};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function cC(n){return Ai(n).filter(t=>jp.includes(t))}function Ai(n){return n?.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)??[]}function lC(n,e,t){let i=t.objects.find(r=>r.type==="star")?.id??t.objects[0]?.id??e;return{type:n,id:e,properties:{},placement:n==="structure"||n==="phenomenon"?{mode:"at",target:`${i}:L4`,reference:Ga(`${i}:L4`)}:{mode:"orbit",target:i,distance:{value:1,unit:"au"}},info:{}}}function uC(n,e){let t=ot(n);return t.objects=t.objects.filter(i=>i.id!==e.id).concat(e).sort(rx),t}function dC(n,e,t){let i=ot(n);return i.objects=i.objects.filter(r=>r.id!==e).concat(t).sort(rx),e!==t.id&&hC(i,e,t.id),i}function hC(n,e,t){for(let i of n.objects)if(i.id!==t&&(i.placement?.mode==="orbit"&&i.placement.target===e&&(i.placement.target=t),i.placement?.mode==="surface"&&i.placement.target===e&&(i.placement.target=t),i.placement?.mode==="at")){let r=i.placement.reference;r.kind==="anchor"&&r.objectId===e&&(r.objectId=t),r.kind==="lagrange"&&(r.primary===e&&(r.primary=t),r.secondary===e&&(r.secondary=t)),i.placement.target=Hp(r)}for(let i of n.system?.viewpoints??[])i.focusObjectId===e&&(i.focusObjectId=t),i.selectedObjectId===e&&(i.selectedObjectId=t);for(let i of n.system?.annotations??[])i.targetObjectId===e&&(i.targetObjectId=t),i.sourceObjectId===e&&(i.sourceObjectId=t);for(let i of n.events){i.targetObjectId===e&&(i.targetObjectId=t),i.participantObjectIds=i.participantObjectIds.map(r=>r===e?t:r);for(let r of i.positions)if(r.objectId===e&&(r.objectId=t),r.placement?.mode==="orbit"&&r.placement.target===e&&(r.placement.target=t),r.placement?.mode==="surface"&&r.placement.target===e&&(r.placement.target=t),r.placement?.mode==="at"){let s=r.placement.reference;s.kind==="anchor"&&s.objectId===e&&(s.objectId=t),s.kind==="lagrange"&&(s.primary===e&&(s.primary=t),s.secondary===e&&(s.secondary=t)),r.placement.target=Hp(s)}i.positions.sort(Xu)}}function fC(n,e){let t=wd(n,e);if(e.kind==="event"&&e.id){for(let i of t.system?.viewpoints??[])i.events=i.events.filter(r=>r!==e.id);return t}if(e.kind!=="object"||!e.id)return t;for(let i of t.objects)if(i.placement?.mode==="orbit"&&i.placement.target===e.id&&(i.placement=null),i.placement?.mode==="surface"&&i.placement.target===e.id&&(i.placement=null),i.placement?.mode==="at"){let r=i.placement.reference;(r.kind==="anchor"&&r.objectId===e.id||r.kind==="lagrange"&&(r.primary===e.id||r.secondary===e.id))&&(i.placement=null)}for(let i of t.system?.viewpoints??[])i.focusObjectId===e.id&&(i.focusObjectId=null),i.selectedObjectId===e.id&&(i.selectedObjectId=null);for(let i of t.system?.annotations??[])i.targetObjectId===e.id&&(i.targetObjectId=null),i.sourceObjectId===e.id&&(i.sourceObjectId=null);for(let i of t.events){i.targetObjectId===e.id&&(i.targetObjectId=null),i.participantObjectIds=i.participantObjectIds.filter(r=>r!==e.id),i.positions=i.positions.filter(r=>r.objectId!==e.id);for(let r of i.positions)if(r.placement?.mode==="orbit"&&r.placement.target===e.id&&(r.placement=null),r.placement?.mode==="surface"&&r.placement.target===e.id&&(r.placement=null),r.placement?.mode==="at"){let s=r.placement.reference;(s.kind==="anchor"&&s.objectId===e.id||s.kind==="lagrange"&&(s.primary===e.id||s.secondary===e.id))&&(r.placement=null)}}return t}function Xa(n,e,t){if(e.kind==="event-pose"&&e.id&&e.key){let r=sx(n,e.id,e.key);return r?.placement?{placement:r.placement}:null}let i=AC(n,t);return i?.placement?{placement:i.placement}:null}function pC(n,e,t,i,r){let s=i.orbit;if(!s||i.object.placement?.mode!=="orbit")return n;let o=sn(r,{x:s.cx,y:s.cy},-s.rotationDeg),a=s.kind==="circle"?s.radius??1:s.rx??1,c=s.kind==="circle"?s.radius??1:s.ry??1,l=Math.atan2((o.y-s.cy)/Math.max(c,1),(o.x-s.cx)/Math.max(a,1)),u=DC(l*180/Math.PI),d=ot(n),h=Xa(d,e,t);return!h||h.placement.mode!=="orbit"?n:(h.placement.phase={value:Qs(u,2),unit:"deg"},d)}function mC(n,e,t,i,r,s){let o=i.orbit;if(!o||i.object.placement?.mode!=="orbit"||!s)return n;let a=sn(r,{x:o.cx,y:o.cy},-o.rotationDeg),c=Math.max(Math.abs(a.x-o.cx),24),l=Math.max(c-s.radiusOffsetPx,s.innerPx),u=FC(l,s.innerPx,s.stepPx),d=ot(n),h=Xa(d,e,t);if(!h||h.placement.mode!=="orbit")return n;let f=h.placement.semiMajor??h.placement.distance??{value:1,unit:"au"},p=ox(Math.max(u,0),s.preferredUnit??f.unit);return h.placement.semiMajor?h.placement.semiMajor=p:h.placement.distance=p,d}function gC(n,e,t,i,r){let s=_C(i,t,r);if(!s)return n;let o=ot(n),a=Xa(o,e,t);return!a||a.placement.mode!=="at"?n:(a.placement.reference=s.reference,a.placement.target=Hp(s.reference),o)}function yC(n,e,t,i,r){let s=bC(i,t,r,c=>k2.has(c.object.type));if(!s)return n;let o=ot(n),a=Xa(o,e,t);return!a||a.placement.mode!=="surface"?n:(a.placement.target=s.objectId,o)}function vC(n,e,t){if(t.object.placement?.mode!=="orbit"||!t.orbit||!t.parent)return null;let i=t.object.placement.target,r=e.objects.filter(h=>h.object.placement?.mode==="orbit"&&h.object.placement.target===i&&!h.hidden).length,s=kC(e.layoutPreset),o=(r>2?54:64)*s*e.scaleModel.orbitDistanceMultiplier,a=t.parent.radius+56*s*e.scaleModel.orbitDistanceMultiplier,c=t.object.placement.semiMajor??t.object.placement.distance??null,l=UC(c),u=t.orbit.kind==="circle"?t.orbit.radius??1:t.orbit.rx??1,d=NC(l??0,a,o);return{innerPx:a,stepPx:o,radiusOffsetPx:u-d,preferredUnit:c?.unit??null}}function xC(n,e,t,i,r,s){if(r.object.placement?.mode!=="free")return n;let o=i.width-i.padding-140,a=Math.max(0,o-s.x),c=ot(n),l=Xa(c,e,t);if(!l||l.placement.mode!=="free")return n;let u=OC(l.placement.distance?.unit??null),d=a/Math.max(F2*i.scaleModel.freePlacementMultiplier,1);return d<.01?(l.placement.distance=void 0,l.placement.descriptor||delete l.placement.descriptor,c):(l.placement.distance=ox(d,u),delete l.placement.descriptor,c)}function bC(n,e,t,i=()=>!0){let r=null,s=Number.POSITIVE_INFINITY;for(let o of n.objects){if(o.hidden||o.objectId===e||!i(o))continue;let a=Math.hypot(t.x-o.x,t.y-o.y);a<s&&(r=o,s=a)}return s<=140?r:null}function _C(n,e,t){let i=null;for(let a of n.objects){if(a.hidden||a.objectId===e)continue;let c=Math.hypot(t.x-a.x,t.y-a.y),l=Math.max(a.visualRadius+16,28);c<=l&&(!i||c<i.distance)&&(i={reference:Ga(a.objectId),x:a.x,y:a.y,distance:c})}if(i)return{reference:i.reference,x:i.x,y:i.y};let r=[];for(let a of n.objects)a.hidden||a.objectId===e||r.push({reference:Ga(a.objectId),x:a.x,y:a.y});for(let a of n.orbitVisuals){if(a.hidden||a.objectId===e)continue;let c=n.objects.find(u=>u.objectId===a.parentId&&!u.hidden),l=n.objects.find(u=>u.objectId===a.objectId&&!u.hidden);if(!(!c||!l))for(let u of["L1","L2","L3","L4","L5"]){let d=wC(c,l,u);r.push({reference:Ga(`${a.objectId}:${u}`),x:d.x,y:d.y})}}let s=null,o=Number.POSITIVE_INFINITY;for(let a of r){let c=Math.hypot(t.x-a.x,t.y-a.y);c<o&&(s=a,o=c)}return o<=140?s:null}function wC(n,e,t){let i=e.x-n.x,r=e.y-n.y,s=Math.hypot(i,r)||1,o=i/s,a=r/s,c=-a,l=o,u=LC(s*.25,24,68);switch(t){case"L1":return{x:e.x-o*u,y:e.y-a*u};case"L2":return{x:e.x+o*u,y:e.y+a*u};case"L3":return{x:n.x-o*u,y:n.y-a*u};case"L4":return{x:e.x+(o*.5-c*.8660254)*u,y:e.y+(a*.5-l*.8660254)*u};case"L5":return{x:e.x+(o*.5+c*.8660254)*u,y:e.y+(a*.5+l*.8660254)*u}}}function Ga(n){let e=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(e)return{kind:"lagrange",primary:e[1],secondary:e[2],point:e[3]};let t=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:null,point:t[2]};let i=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return i?{kind:"anchor",objectId:i[1],anchor:i[2]}:{kind:"named",name:n}}function Hp(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function nr(n){return Sd(n)}function ix(n,e){let t=new Set,i=[];for(let r of[...n,...e]){let s=`${r.diagnostic.code}:${r.diagnostic.message}:${Ii(r.path)}`;t.has(s)||(t.add(s),i.push(Gu(r)))}return i}function SC(n){let e=new Map;for(let t of n){let i=Ii(t.path)??(t.diagnostic.objectId?Ii({kind:"object",id:t.diagnostic.objectId}):null);if(!i)continue;let r=e.get(i)??{errors:0,warnings:0};t.diagnostic.severity==="error"?r.errors+=1:t.diagnostic.severity==="warning"&&(r.warnings+=1),e.set(i,r)}return e}function qv(n){return n.diagnostic.line!==void 0&&n.diagnostic.column!==void 0?`Line ${n.diagnostic.line}:${n.diagnostic.column}`:n.diagnostic.line!==void 0?`Line ${n.diagnostic.line}`:null}function MC(n,e){if(!e)return[];switch(n.kind){case"system":return e==="id"?["system-id"]:e==="title"?["system-title"]:[];case"defaults":switch(e){case"view":return["defaults-view"];case"scale":return["defaults-scale"];case"units":return["defaults-units"];case"preset":return["defaults-preset"];case"theme":return["defaults-theme"];default:return[]}case"metadata":return e==="key"?["metadata-key"]:["metadata-value"];case"group":switch(e){case"id":return["group-id"];case"label":return["group-label"];case"summary":return["group-summary"];case"color":return["group-color"];case"tags":return["group-tags"];case"hidden":return["group-hidden"];default:return[]}case"viewpoint":switch(e){case"id":return["viewpoint-id"];case"label":return["viewpoint-label"];case"summary":return["viewpoint-summary"];case"focusObjectId":return["viewpoint-focus"];case"selectedObjectId":return["viewpoint-select"];case"projection":return["viewpoint-projection"];case"preset":return["viewpoint-preset"];case"zoom":return["viewpoint-zoom"];case"rotationDeg":return["viewpoint-rotation"];case"camera":return["viewpoint-camera-azimuth","viewpoint-camera-elevation","viewpoint-camera-roll","viewpoint-camera-distance"];case"camera.azimuth":return["viewpoint-camera-azimuth"];case"camera.elevation":return["viewpoint-camera-elevation"];case"camera.roll":return["viewpoint-camera-roll"];case"camera.distance":return["viewpoint-camera-distance"];case"events":return["viewpoint-events"];default:return[]}case"event":switch(e){case"id":return["event-id"];case"kind":return["event-kind"];case"label":return["event-label"];case"summary":return["event-summary"];case"targetObjectId":case"target":return["event-target"];case"participantObjectIds":case"participants":return["event-participants"];case"timing":return["event-timing"];case"visibility":return["event-visibility"];case"epoch":return["event-epoch"];case"referencePlane":return["event-referencePlane"];case"tags":return["event-tags"];case"color":return["event-color"];case"hidden":return["event-hidden"];default:return[]}case"event-pose":return e==="objectId"?["pose-object-id"]:e==="placement"?["placement-mode"]:e==="reference"||e==="target"?["placement-target"]:e==="descriptor"?["placement-free"]:$p.has(e)?[`placement-${e}`]:e==="inner"||e==="outer"?[`prop-${e}`]:e==="epoch"?["pose-epoch"]:e==="referencePlane"?["pose-referencePlane"]:[];case"annotation":switch(e){case"id":return["annotation-id"];case"label":return["annotation-label"];case"targetObjectId":return["annotation-target"];case"sourceObjectId":return["annotation-source"];case"body":return["annotation-body"];case"tags":return["annotation-tags"];default:return[]}case"relation":switch(e){case"id":return["relation-id"];case"from":return["relation-from"];case"to":return["relation-to"];case"kind":return["relation-kind"];case"label":return["relation-label"];case"summary":return["relation-summary"];case"tags":return["relation-tags"];case"color":return["relation-color"];case"hidden":return["relation-hidden"];default:return[]}case"object":return e==="id"?["object-id"]:e==="type"?["object-type"]:e==="placement"?["placement-mode"]:e==="description"?["info-description"]:e==="reference"?["placement-target"]:e==="descriptor"?["placement-free"]:e==="target"?["placement-target"]:$p.has(e)?[`placement-${e}`]:[`prop-${e}`]}}function Zv(n,e,t){return za(n,{mode:t==="3d"?"interactive-3d":"interactive-2d",preset:e.system?.defaults.preset??"atlas-card",projection:e.system?.defaults.view??"topdown"})}function ju(n){switch(n.kind){case"system":return"System";case"defaults":return"Defaults";case"metadata":return`Metadata: ${n.key??""}`;case"group":return`Group: ${n.id??""}`;case"event":return`Event: ${n.id??""}`;case"event-pose":return`Event Pose: ${n.id??""} / ${n.key??""}`;case"object":return`Object: ${n.id??""}`;case"viewpoint":return`Viewpoint: ${n.id??""}`;case"annotation":return`Annotation: ${n.id??""}`;case"relation":return`Relation: ${n.id??""}`}}function Ii(n){return n?`${n.kind}:${n.id??""}:${n.key??""}`:null}function Vp(n){return n&&(n.kind==="event"||n.kind==="event-pose")?n.id??null:null}function rx(n,e){return n.id.localeCompare(e.id)}function Jv(n,e){return n.id.localeCompare(e.id)}function Xu(n,e){return n.objectId.localeCompare(e.objectId)}function EC(n,e){return n.events.find(t=>t.id===e)??null}function sx(n,e,t){return EC(n,e)?.positions.find(i=>i.objectId===t)??null}function AC(n,e){return n.objects.find(t=>t.id===e)??null}function TC(n,e){let t=ot(n),i=t.events.find(s=>s.id===e);if(!i)return n;let r=t.objects.find(s=>!i.positions.some(o=>o.objectId===s.id))??t.objects[0];return r?(i.targetObjectId!==r.id&&!i.participantObjectIds.includes(r.id)&&(i.participantObjectIds.push(r.id),i.participantObjectIds.sort((s,o)=>s.localeCompare(o))),i.positions.push(IC(r)),i.positions.sort(Xu),t):n}function IC(n){return{objectId:n.id,placement:n.placement?structuredClone(n.placement):null,inner:Kv(n.properties.inner),outer:Kv(n.properties.outer)}}function CC(n,e,t,i){let r=new Set(i);for(let s of n.system?.viewpoints??[]){let o=new Set(s.events);o.delete(e),o.delete(t),r.has(s.id)&&o.add(t),s.events=[...o].sort((a,c)=>a.localeCompare(c))}}function Ha(n,e){let t=n.trim()||"item",i=1,r=t;for(;e.includes(r);)i+=1,r=`${t}-${i}`;return r}function ja(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Gu(n){return{diagnostic:{...n.diagnostic},path:n.path?{...n.path}:null}}function Qi(n){return typeof n=="string"?n:""}function RC(n){return Array.isArray(n)?n.join(" "):""}function er(n){return n&&typeof n=="object"&&"value"in n?$t(n):""}function Kv(n){return n&&typeof n=="object"&&"value"in n?n:void 0}function PC(n){return typeof n=="number"?String(n):""}function $t(n){return`${n.value}${n.unit??""}`}function Qs(n,e){let t=10**e;return Math.round(n*t)/t}function LC(n,e,t){return Math.min(Math.max(n,e),t)}function DC(n){let e=n%360;return e<0&&(e+=360),e}function OC(n){switch(n){case"au":case"km":case"re":case"sol":case null:return n;default:return null}}function UC(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/eo;case"re":return n.value*Qv/eo;case"sol":return n.value*ex/eo;default:return n.value}}function ox(n,e){switch(e){case"km":return{value:Qs(n*eo,0),unit:e};case"re":return{value:Qs(n*eo/Qv,3),unit:e};case"sol":return{value:Qs(n*eo/ex,4),unit:e};case"au":return{value:Qs(n,3),unit:e};default:return{value:Qs(n,2),unit:null}}}function NC(n,e,t){return e+t*BC(Math.max(n,0)+1)}function FC(n,e,t){return n<=e?0:Math.pow(2,(n-e)/Math.max(t,1e-4))-1}function kC(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function BC(n){return Math.log(n)/Math.log(2)}function Ye(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function ax(n){return Ye(n)}function zC(n){if(typeof window>"u"||typeof document>"u")throw new Error("createWorldOrbitEditor can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("WorldOrbit editor requires an HTMLElement container.")}function vn(n,e){let t=n.querySelector(e);if(!t)throw new Error(`WorldOrbit editor failed to initialize selector "${e}".`);return t}function VC(){if(document.getElementById(Yv))return;let n=document.createElement("style");n.id=Yv,n.textContent=`
4299
4349
  .wo-editor {
4300
4350
  --wo-editor-sidebar-width: 280px;
4301
4351
  --wo-editor-inspector-width: 360px;