-var OV=(()=>{var Kh=Object.defineProperty;var wv=Object.getOwnPropertyDescriptor;var Cv=Object.getOwnPropertyNames;var Rv=Object.prototype.hasOwnProperty;var Iv=(r,e)=>{for(var t in e)Kh(r,t,{get:e[t],enumerable:!0})},Pv=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Cv(e))!Rv.call(r,i)&&i!==t&&Kh(r,i,{get:()=>e[i],enumerable:!(n=wv(e,i))||n.enumerable});return r};var Nv=r=>Pv(Kh({},"__esModule",{value:!0}),r);var JS={};Iv(JS,{AddCoord2D:()=>Hp,AddCoord3D:()=>Bc,AddDiv:()=>fv,AddDomElement:()=>Cp,ArrayBufferToAsciiString:()=>$p,ArrayBufferToUtf8String:()=>xn,ArrayToCoord3D:()=>Ei,ArrayToQuaternion:()=>bo,ArrayToRGBColor:()=>qp,AsciiStringToArrayBuffer:()=>Qp,Base64DataURIToArrayBuffer:()=>Ls,BezierTweenFunction:()=>rm,BigEps:()=>Gp,BinaryReader:()=>Qn,BinaryWriter:()=>Gi,BoundingBoxCalculator3D:()=>Po,Box3D:()=>Fs,CalculateSurfaceArea:()=>cv,CalculateTriangleNormal:()=>Ds,CalculateVolume:()=>bp,Camera:()=>Sr,CameraIsEqual3D:()=>Fh,CameraValidator:()=>yc,CheckModel:()=>S0,ClearDomElement:()=>dv,ClickDetector:()=>vc,ColorComponentFromFloat:()=>Rn,ColorComponentToFloat:()=>Ps,ColorToMaterialConverter:()=>ri,ConvertColorToThreeColor:()=>wn,ConvertMeshToMeshBuffer:()=>_o,ConvertModelToThreeObject:()=>Uh,ConvertThreeColorToColor:()=>Jl,ConvertThreeGeometryToMesh:()=>Zi,Coord2D:()=>At,Coord3D:()=>Xe,Coord4D:()=>Vi,CoordDistance2D:()=>Is,CoordDistance3D:()=>Yn,CoordIsEqual2D:()=>Fi,CoordIsEqual3D:()=>pi,CopyObjectAttributes:()=>co,CreateDiv:()=>Mv,CreateDomElement:()=>Vh,CreateHighlightMaterial:()=>Od,CreateHighlightMaterials:()=>ph,CreateModelUrlParameters:()=>hv,CreateObjectUrl:()=>Os,CreateObjectUrlWithMimeType:()=>Vc,CreateOcctWorker:()=>yo,CreateUrlBuilder:()=>wp,CreateUrlParser:()=>uv,CrossVector3D:()=>Bi,DegRad:()=>ar,Direction:()=>pt,DisposeThreeObjects:()=>mh,DotVector2D:()=>dl,DotVector3D:()=>ml,EdgeSettings:()=>ro,EmbeddedViewer:()=>al,EnvironmentSettings:()=>so,Eps:()=>Bp,EscapeHtmlChars:()=>wc,EventNotifier:()=>Cc,ExportedFile:()=>$t,Exporter:()=>qc,Exporter3dm:()=>Mo,ExporterBase:()=>Pn,ExporterBim:()=>Eo,ExporterGltf:()=>So,ExporterModel:()=>Ao,ExporterObj:()=>wo,ExporterOff:()=>Co,ExporterPly:()=>Ro,ExporterSettings:()=>_l,ExporterStl:()=>Io,FLoc:()=>uo,FaceMaterial:()=>go,FileFormat:()=>an,FileSource:()=>ki,FinalizeModel:()=>vh,FlipMeshTrianglesOrientation:()=>jc,FormatString:()=>Ac,GenerateCone:()=>Tp,GenerateCuboid:()=>sv,GenerateCylinder:()=>ov,GeneratePlatonicSolid:()=>lv,GenerateSphere:()=>av,Generator:()=>Ss,GeneratorHelper:()=>$a,GeneratorParams:()=>cc,GetBoundingBox:()=>Qh,GetDefaultCamera:()=>zh,GetDefaultMaterials:()=>om,GetDomElementClientCoordinates:()=>Kr,GetDomElementExternalHeight:()=>Bh,GetDomElementExternalWidth:()=>kh,GetDomElementInnerDimensions:()=>Gh,GetDomElementOuterHeight:()=>xv,GetDomElementOuterWidth:()=>yv,GetFileExtension:()=>ur,GetFileExtensionFromMimeType:()=>es,GetFileName:()=>En,GetIntegerFromStyle:()=>Fn,GetLineSegmentsProjectedDistance:()=>gh,GetShadingType:()=>dh,GetShadingTypeOfObject:()=>Pp,GetTetrahedronSignedVolume:()=>Ep,GetTopology:()=>ef,GetTriangleArea:()=>Mp,HasHighpDriverIssue:()=>fh,HexStringToRGBAColor:()=>jp,HexStringToRGBColor:()=>Xp,ImportError:()=>bs,ImportErrorCode:()=>br,ImportResult:()=>oc,ImportSettings:()=>Za,Importer:()=>Ja,Importer3dm:()=>Ia,Importer3ds:()=>Pa,ImporterBase:()=>Ht,ImporterBim:()=>Ba,ImporterFcstd:()=>Ka,ImporterFile:()=>Us,ImporterFileAccessor:()=>ac,ImporterFileList:()=>ks,ImporterGltf:()=>Na,ImporterIfc:()=>La,ImporterObj:()=>Oa,ImporterOcct:()=>Ua,ImporterOff:()=>Da,ImporterPly:()=>Fa,ImporterStl:()=>ka,ImporterThree3mf:()=>ja,ImporterThreeAmf:()=>qa,ImporterThreeBase:()=>tr,ImporterThreeDae:()=>Wa,ImporterThreeFbx:()=>Ha,ImporterThreeSvg:()=>Dh,ImporterThreeWrl:()=>Xa,Init3DViewerElements:()=>bv,Init3DViewerFromFileList:()=>Ev,Init3DViewerFromUrlList:()=>Np,InputFile:()=>Do,InputFilesFromFileObjects:()=>Jc,InputFilesFromUrls:()=>Zc,InsertDomElementAfter:()=>mv,InsertDomElementBefore:()=>pv,IntegerToHexString:()=>Mn,IntersectionMode:()=>Sp,IsDefined:()=>lo,IsDomElementVisible:()=>vv,IsEmptyMesh:()=>ts,IsEqual:()=>It,IsEqualEps:()=>zp,IsGreater:()=>Lc,IsGreaterOrEqual:()=>mo,IsLower:()=>fo,IsLowerOrEqual:()=>po,IsModelEmpty:()=>Uo,IsNegative:()=>Cr,IsObjectEmpty:()=>Sc,IsPositive:()=>Ti,IsPowerOfTwo:()=>Zh,IsTwoManifold:()=>tf,IsUrl:()=>Jp,IsZero:()=>wr,Line:()=>jr,LinearToSRGB:()=>Ns,LinearTweenFunction:()=>sm,LoadExternalLibrary:()=>cr,LoadExternalLibraryFromUrl:()=>vo,Loc:()=>Ze,MaterialBase:()=>pl,MaterialGeometryType:()=>Cs,MaterialSource:()=>yn,MaterialType:()=>Un,Matrix:()=>fn,MatrixIsEqual:()=>Xc,Mesh:()=>Kt,MeshBuffer:()=>vl,MeshInstance:()=>Nr,MeshInstanceId:()=>bi,MeshPrimitiveBuffer:()=>gl,Model:()=>dr,ModelObject3D:()=>fr,ModelToThreeConversionOutput:()=>tl,ModelToThreeConversionParams:()=>el,MouseInteraction:()=>mc,NameFromLine:()=>Pr,Navigation:()=>rl,NavigationMode:()=>As,NavigationType:()=>ti,NextPowerOfTwo:()=>Zp,Node:()=>Nn,Object3D:()=>yl,Octree:()=>Lo,OctreeNode:()=>Tl,ParabolicTweenFunction:()=>Kc,ParameterConverter:()=>Jt,ParameterListBuilder:()=>uc,ParameterListParser:()=>hc,ParametersFromLine:()=>Ui,PhongMaterial:()=>vn,PhysicalMaterial:()=>Qr,ProjectPointToSegment2D:()=>Jh,ProjectionMode:()=>Xn,Property:()=>nn,PropertyGroup:()=>Vn,PropertyToString:()=>Hc,PropertyType:()=>Vt,Quaternion:()=>Kn,QuaternionFromAxisAngle:()=>Wc,QuaternionFromXYZ:()=>tm,QuaternionIsEqual:()=>em,RGBAColor:()=>Rr,RGBAColorToHexString:()=>Wp,RGBColor:()=>Mt,RGBColorFromFloatComponents:()=>di,RGBColorIsEqual:()=>Ir,RGBColorToHexString:()=>Oc,RadDeg:()=>Vp,ReadFile:()=>Uc,ReadLines:()=>Mi,ReplaceDefaultMaterialsColor:()=>am,RequestUrl:()=>Fc,RevokeObjectUrl:()=>zc,RunTaskAsync:()=>fl,RunTasks:()=>Ic,RunTasksBatch:()=>Pc,SRGBToLinear:()=>lr,Segment2D:()=>No,SegmentPointDistance2D:()=>Yc,SetDomElementHeight:()=>Ip,SetDomElementOuterHeight:()=>Tv,SetDomElementOuterWidth:()=>_v,SetDomElementWidth:()=>Rp,SetLanguageCode:()=>kp,SetLocalizedStrings:()=>Up,SetThreeMeshPolygonOffset:()=>Ap,ShadingModel:()=>sl,ShadingType:()=>ci,ShowDomElement:()=>gv,SubCoord2D:()=>Jr,SubCoord3D:()=>In,TaskRunner:()=>ho,TextWriter:()=>oi,TextureIsEqual:()=>Yp,TextureMap:()=>ii,TextureMapIsEqual:()=>$r,ThreeColorConverter:()=>Ca,ThreeConversionStateHandler:()=>fc,ThreeLinearToSRGBColorConverter:()=>to,ThreeMaterialHandler:()=>pc,ThreeMeshMaterialHandler:()=>nl,ThreeModelLoader:()=>il,ThreeNodeTree:()=>dc,ThreeSRGBToLinearColorConverter:()=>Ra,Topology:()=>Fo,TopologyEdge:()=>El,TopologyTriangle:()=>Sl,TopologyTriangleEdge:()=>bl,TopologyVertex:()=>Ml,TouchInteraction:()=>gc,TransformFileHostUrls:()=>kc,TransformMesh:()=>hr,Transformation:()=>ln,TransformationIsEqual:()=>nm,TraverseThreeObject:()=>Hh,Triangle:()=>Xt,TweenCoord3D:()=>Oo,Unit:()=>ns,UpVector:()=>xc,UpdateMaterialTransparency:()=>si,Utf8StringToArrayBuffer:()=>To,ValueOrDefault:()=>Fp,VectorAngle3D:()=>Gc,VectorLength3D:()=>xo,Viewer:()=>ol,ViewerMainModel:()=>Qa,ViewerModel:()=>ws,WaitWhile:()=>Nc});function lo(r){return r!=null}function Fp(r,e){return r??e}function co(r,e){if(lo(r))for(let t of Object.keys(r))lo(r[t])&&(e[t]=r[t])}function Sc(r){return Object.keys(r).length===0}function Ac(r,...e){return r.replace(/{([0-9]+)}/g,(t,n)=>e[n]===void 0?t:e[n])}function wc(r){return r.replace(/</g,"<").replace(/>/g,">")}var Cc=class{constructor(){this.eventListeners=new Map}AddEventListener(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,[]),this.eventListeners.get(e).push(t)}HasEventListener(e){return this.eventListeners.has(e)}GetEventNotifier(e){return()=>{this.NotifyEventListeners(e)}}NotifyEventListeners(e,...t){if(!this.eventListeners.has(e))return;let n=this.eventListeners.get(e);for(let i of n)i(...t)}};var hl=null,Rc=null;function Up(r){hl=r}function kp(r){Rc=r}function Ze(r){return hl===null||Rc===null||!hl[r]||!hl[r][Rc]?r:hl[r][Rc]}function uo(r,...e){return Ac(Ze(r),...e)}var ho=class{constructor(){this.count=null,this.current=null,this.callbacks=null}Run(e,t){this.count=e,this.current=0,this.callbacks=t,e===0?this.TaskReady():this.RunOnce()}RunBatch(e,t,n){let i=0;e>0&&(i=parseInt((e-1)/t,10)+1),this.Run(i,{runTask:(s,o)=>{let a=s*t,l=Math.min((s+1)*t,e)-1;n.runTask(a,l,o)},onReady:n.onReady})}RunOnce(){setTimeout(()=>{this.callbacks.runTask(this.current,this.TaskReady.bind(this))},0)}TaskReady(){this.current+=1,this.current<this.count?this.RunOnce():this.callbacks.onReady&&this.callbacks.onReady()}};function fl(r){setTimeout(()=>{r()},10)}function Ic(r,e){new ho().Run(r,e)}function Pc(r,e,t){new ho().RunBatch(r,e,t)}function Nc(r){function e(t){t()&&setTimeout(()=>{e(t)},10)}e(r)}var Bp=1e-8,Gp=1e-4,Vp=57.29577951308232,ar=.017453292519943;function wr(r){return Math.abs(r)<1e-8}function fo(r,e){return e-r>1e-8}function Lc(r,e){return r-e>1e-8}function po(r,e){return e-r>-1e-8}function mo(r,e){return r-e>-1e-8}function It(r,e){return Math.abs(e-r)<1e-8}function zp(r,e,t){return Math.abs(e-r)<t}function Ti(r){return r>1e-8}function Cr(r){return r<-1e-8}var pt={X:1,Y:2,Z:3};var At=class r{constructor(e,t){this.x=e,this.y=t}Clone(){return new r(this.x,this.y)}};function Fi(r,e){return It(r.x,e.x)&&It(r.y,e.y)}function Hp(r,e){return new At(r.x+e.x,r.y+e.y)}function Jr(r,e){return new At(r.x-e.x,r.y-e.y)}function Is(r,e){return Math.sqrt((r.x-e.x)*(r.x-e.x)+(r.y-e.y)*(r.y-e.y))}function dl(r,e){return r.x*e.x+r.y*e.y}var Mt=class r{constructor(e,t,n){this.r=e,this.g=t,this.b=n}Set(e,t,n){this.r=e,this.g=t,this.b=n}Clone(){return new r(this.r,this.g,this.b)}},Rr=class r{constructor(e,t,n,i){this.r=e,this.g=t,this.b=n,this.a=i}Set(e,t,n,i){this.r=e,this.g=t,this.b=n,this.a=i}Clone(){return new r(this.r,this.g,this.b,this.a)}};function Rn(r){return parseInt(Math.round(r*255),10)}function Ps(r){return r/255}function di(r,e,t){return new Mt(Rn(r),Rn(e),Rn(t))}function lr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Ns(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}function Mn(r){let e=parseInt(r,10).toString(16);for(;e.length<2;)e="0"+e;return e}function Oc(r){let e=Mn(r.r),t=Mn(r.g),n=Mn(r.b);return e+t+n}function Wp(r){let e=Mn(r.r),t=Mn(r.g),n=Mn(r.b),i=Mn(r.a);return e+t+n+i}function Xp(r){if(r.length!==6)return null;let e=parseInt(r.substring(0,2),16),t=parseInt(r.substring(2,4),16),n=parseInt(r.substring(4,6),16);return new Mt(e,t,n)}function jp(r){if(r.length!==6&&r.length!==8)return null;let e=parseInt(r.substring(0,2),16),t=parseInt(r.substring(2,4),16),n=parseInt(r.substring(4,6),16),i=255;return r.length===8&&(i=parseInt(r.substring(6,8),16)),new Rr(e,t,n,i)}function qp(r){return new Mt(r[0],r[1],r[2])}function Ir(r,e){return r.r===e.r&&r.g===e.g&&r.b===e.b}var ii=class{constructor(){this.name=null,this.mimeType=null,this.buffer=null,this.offset=new At(0,0),this.scale=new At(1,1),this.rotation=0}IsValid(){return this.name!==null&&this.buffer!==null}HasTransformation(){return!Fi(this.offset,new At(0,0))||!Fi(this.scale,new At(1,1))||!It(this.rotation,0)}IsEqual(e){return!(this.name!==e.name||this.mimeType!==e.mimeType||!Fi(this.offset,e.offset)||!Fi(this.scale,e.scale)||!It(this.rotation,e.rotation))}};function $r(r,e){return r===null&&e===null?!0:r===null||e===null?!1:r.IsEqual(e)}var Un={Phong:1,Physical:2},yn={Model:1,DefaultFace:2,DefaultLine:3},pl=class{constructor(e){this.type=e,this.source=yn.Model,this.name="",this.color=new Mt(0,0,0),this.vertexColors=!1}IsEqual(e){return!(this.type!==e.type||this.source!==e.source||this.name!==e.name||!Ir(this.color,e.color)||this.vertexColors!==e.vertexColors)}},go=class extends pl{constructor(e){super(e),this.emissive=new Mt(0,0,0),this.opacity=1,this.transparent=!1,this.diffuseMap=null,this.bumpMap=null,this.normalMap=null,this.emissiveMap=null,this.alphaTest=0,this.multiplyDiffuseMap=!1}IsEqual(e){return!(!super.IsEqual(e)||!Ir(this.emissive,e.emissive)||!It(this.opacity,e.opacity)||this.transparent!==e.transparent||!$r(this.diffuseMap,e.diffuseMap)||!$r(this.bumpMap,e.bumpMap)||!$r(this.normalMap,e.normalMap)||!$r(this.emissiveMap,e.emissiveMap)||!It(this.alphaTest,e.alphaTest)||this.multiplyDiffuseMap!==e.multiplyDiffuseMap)}},vn=class extends go{constructor(){super(Un.Phong),this.ambient=new Mt(0,0,0),this.specular=new Mt(0,0,0),this.shininess=0,this.specularMap=null}IsEqual(e){return!(!super.IsEqual(e)||!Ir(this.ambient,e.ambient)||!Ir(this.specular,e.specular)||!It(this.shininess,e.shininess)||!$r(this.specularMap,e.specularMap))}},Qr=class extends go{constructor(){super(Un.Physical),this.metalness=0,this.roughness=1,this.metalnessMap=null}IsEqual(e){return!(!super.IsEqual(e)||!It(this.metalness,e.metalness)||!It(this.roughness,e.roughness)||!$r(this.metalnessMap,e.metalnessMap))}};function Yp(r,e){return!(r.name!==e.name||r.mimeType!==e.mimeType||!Fi(r.offset,e.offset)||!Fi(r.scale,e.scale)||!It(r.rotation,e.rotation))}var Kp=new Set;function vo(r){return new Promise((e,t)=>{if(Kp.has(r)){e();return}let n=document.createElement("script");n.type="text/javascript",n.src=r,n.onload=()=>{Kp.add(r),e()},n.onerror=()=>{t()},document.head.appendChild(n)})}function Pr(r,e,t){let n=r.substring(e),i=n.indexOf(t);return i!==-1&&(n=n.substring(0,i)),n.trim()}function Ui(r,e){if(e!==null){let t=r.indexOf(e);t!==-1&&(r=r.substring(0,t).trim())}return r.split(/\s+/u)}function Mi(r,e){function t(s,o){let a=s.trim();a.length>0&&o(a)}let n=0,i=r.indexOf(`
+var OV=(()=>{var dd=Object.defineProperty;var kx=Object.getOwnPropertyDescriptor;var Bx=Object.getOwnPropertyNames;var Gx=Object.prototype.hasOwnProperty;var Vx=(r,e)=>{for(var t in e)dd(r,t,{get:e[t],enumerable:!0})},zx=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Bx(e))!Gx.call(r,i)&&i!==t&&dd(r,i,{get:()=>e[i],enumerable:!(n=kx(e,i))||n.enumerable});return r};var Hx=r=>zx(dd({},"__esModule",{value:!0}),r);var nA={};Vx(nA,{AddCoord2D:()=>ig,AddCoord3D:()=>Eu,AddDiv:()=>bx,AddDomElement:()=>Wm,ArrayBufferToAsciiString:()=>fg,ArrayBufferToUtf8String:()=>Sn,ArrayToCoord3D:()=>Ui,ArrayToQuaternion:()=>Zo,ArrayToRGBColor:()=>ag,AsciiStringToArrayBuffer:()=>dg,Base64DataURIToArrayBuffer:()=>qs,BezierTweenFunction:()=>xg,BigEps:()=>eg,BinaryReader:()=>oi,BinaryWriter:()=>Ji,BoundingBoxCalculator3D:()=>ia,Box3D:()=>Ks,CalculateSurfaceArea:()=>Tx,CalculateTriangleNormal:()=>Ys,CalculateVolume:()=>Gm,Camera:()=>Or,CameraIsEqual3D:()=>Qf,CameraValidator:()=>ru,CheckModel:()=>ky,ClearDomElement:()=>Sx,ClickDetector:()=>iu,ColorComponentFromFloat:()=>Fn,ColorComponentToFloat:()=>Ws,ColorToMaterialConverter:()=>di,ConvertColorToThreeColor:()=>Dn,ConvertMeshToMeshBuffer:()=>qo,ConvertModelToThreeObject:()=>ed,ConvertThreeColorToColor:()=>Fc,ConvertThreeGeometryToMesh:()=>ur,Coord2D:()=>Nt,Coord3D:()=>Ye,Coord4D:()=>$i,CoordDistance2D:()=>Hs,CoordDistance3D:()=>ni,CoordIsEqual2D:()=>ji,CoordIsEqual3D:()=>bi,CopyObjectAttributes:()=>Fo,CreateDiv:()=>Ox,CreateDomElement:()=>rd,CreateHighlightMaterial:()=>Zp,CreateHighlightMaterials:()=>Pf,CreateModelUrlParameters:()=>Ex,CreateObjectUrl:()=>js,CreateObjectUrlWithMimeType:()=>Su,CreateOcctWorker:()=>Wo,CreateUrlBuilder:()=>Hm,CreateUrlParser:()=>Mx,CrossVector3D:()=>Zi,DegRad:()=>xr,Direction:()=>_t,DisposeThreeObjects:()=>Nf,DotVector2D:()=>Rl,DotVector3D:()=>Nl,EdgeSettings:()=>Io,EmbeddedViewer:()=>Al,EnvironmentSettings:()=>Ro,Eps:()=>Qm,EscapeHtmlChars:()=>hu,EventNotifier:()=>fu,ExportedFile:()=>sn,Exporter:()=>Pu,Exporter3dm:()=>Yo,ExporterBase:()=>kn,ExporterBim:()=>Ko,ExporterGltf:()=>Jo,ExporterModel:()=>$o,ExporterObj:()=>Qo,ExporterOff:()=>ea,ExporterPly:()=>ta,ExporterSettings:()=>Ul,ExporterStl:()=>na,FLoc:()=>Uo,FaceMaterial:()=>zo,FileFormat:()=>dn,FileSource:()=>Ki,FinalizeModel:()=>Of,FlipMeshTrianglesOrientation:()=>Ru,FormatString:()=>uu,GenerateCone:()=>Um,GenerateCuboid:()=>yx,GenerateCylinder:()=>xx,GeneratePlatonicSolid:()=>_x,GenerateSphere:()=>vx,Generator:()=>ks,GeneratorHelper:()=>yl,GeneratorParams:()=>Kc,GetBoundingBox:()=>yd,GetDefaultCamera:()=>sd,GetDefaultMaterials:()=>_g,GetDomElementClientCoordinates:()=>ps,GetDomElementExternalHeight:()=>nd,GetDomElementExternalWidth:()=>td,GetDomElementInnerDimensions:()=>id,GetDomElementOuterHeight:()=>Px,GetDomElementOuterWidth:()=>Rx,GetFileExtension:()=>Tr,GetFileExtensionFromMimeType:()=>xs,GetFileName:()=>Rn,GetIntegerFromStyle:()=>zn,GetLineSegmentsProjectedDistance:()=>Lf,GetShadingType:()=>Rf,GetShadingTypeOfObject:()=>jm,GetTetrahedronSignedVolume:()=>Bm,GetTopology:()=>xd,GetTriangleArea:()=>km,HasHighpDriverIssue:()=>If,HexStringToRGBAColor:()=>og,HexStringToRGBColor:()=>sg,ImportError:()=>Us,ImportErrorCode:()=>Lr,ImportResult:()=>qc,ImportSettings:()=>ml,Importer:()=>gl,Importer3dm:()=>Ka,Importer3ds:()=>Za,ImporterBase:()=>Jt,ImporterBim:()=>rl,ImporterFcstd:()=>pl,ImporterFile:()=>Zs,ImporterFileAccessor:()=>jc,ImporterFileList:()=>Js,ImporterGltf:()=>Ja,ImporterIfc:()=>$a,ImporterObj:()=>Qa,ImporterOcct:()=>nl,ImporterOff:()=>el,ImporterPly:()=>tl,ImporterStl:()=>il,ImporterThree3mf:()=>hl,ImporterThreeAmf:()=>fl,ImporterThreeBase:()=>mr,ImporterThreeDae:()=>cl,ImporterThreeFbx:()=>ll,ImporterThreeSvg:()=>$f,ImporterThreeWrl:()=>ul,Init3DViewerElements:()=>Fx,Init3DViewerFromFileList:()=>Dx,Init3DViewerFromUrlList:()=>Ym,InputFile:()=>aa,InputFilesFromFileObjects:()=>Du,InputFilesFromUrls:()=>Ou,InsertDomElementAfter:()=>wx,InsertDomElementBefore:()=>Ax,IntegerToHexString:()=>In,IntersectionMode:()=>Vm,IsDefined:()=>Do,IsDomElementVisible:()=>Ix,IsEmptyMesh:()=>vs,IsEqual:()=>Ut,IsEqualEps:()=>ng,IsGreater:()=>yu,IsGreaterOrEqual:()=>Vo,IsLower:()=>Bo,IsLowerOrEqual:()=>Go,IsModelEmpty:()=>ca,IsNegative:()=>Br,IsObjectEmpty:()=>cu,IsPositive:()=>Di,IsPowerOfTwo:()=>pd,IsTwoManifold:()=>vd,IsUrl:()=>hg,IsZero:()=>kr,Line:()=>hs,LinearToSRGB:()=>Xs,LinearTweenFunction:()=>vg,LoadExternalLibrary:()=>_r,LoadExternalLibraryFromUrl:()=>Ho,Loc:()=>nt,MaterialBase:()=>Pl,MaterialGeometryType:()=>Vs,MaterialSource:()=>bn,MaterialType:()=>Wn,Matrix:()=>xn,MatrixIsEqual:()=>Iu,Mesh:()=>tn,MeshBuffer:()=>Ol,MeshInstance:()=>Hr,MeshInstanceId:()=>ki,MeshPrimitiveBuffer:()=>Ll,Model:()=>br,ModelObject3D:()=>Er,ModelToThreeConversionOutput:()=>_l,ModelToThreeConversionParams:()=>vl,MouseInteraction:()=>tu,NameFromLine:()=>zr,Navigation:()=>El,NavigationMode:()=>Bs,NavigationType:()=>li,NextPowerOfTwo:()=>ug,Node:()=>Bn,Object3D:()=>Dl,Octree:()=>sa,OctreeNode:()=>kl,ParabolicTweenFunction:()=>Lu,ParameterConverter:()=>rn,ParameterListBuilder:()=>Zc,ParameterListParser:()=>Jc,ParametersFromLine:()=>Yi,PhongMaterial:()=>En,PhysicalMaterial:()=>ys,ProjectPointToSegment2D:()=>md,ProjectionMode:()=>ei,Property:()=>cn,PropertyGroup:()=>Kn,PropertyToString:()=>wu,PropertyType:()=>Yt,Quaternion:()=>ii,QuaternionFromAxisAngle:()=>Cu,QuaternionFromXYZ:()=>mg,QuaternionIsEqual:()=>pg,RGBAColor:()=>Gr,RGBAColorToHexString:()=>rg,RGBColor:()=>St,RGBColorFromFloatComponents:()=>Ei,RGBColorIsEqual:()=>Vr,RGBColorToHexString:()=>xu,RadDeg:()=>tg,ReadFile:()=>Tu,ReadLines:()=>Fi,ReplaceDefaultMaterialsColor:()=>Tg,RequestUrl:()=>_u,RevokeObjectUrl:()=>Au,RunTaskAsync:()=>Il,RunTasks:()=>pu,RunTasksBatch:()=>mu,SRGBToLinear:()=>vr,Segment2D:()=>ra,SegmentPointDistance2D:()=>Nu,SetDomElementHeight:()=>qm,SetDomElementOuterHeight:()=>Lx,SetDomElementOuterWidth:()=>Nx,SetDomElementWidth:()=>Xm,SetLanguageCode:()=>$m,SetLocalizedStrings:()=>Jm,SetThreeMeshPolygonOffset:()=>zm,ShadingModel:()=>bl,ShadingType:()=>vi,ShowDomElement:()=>Cx,SubCoord2D:()=>ms,SubCoord3D:()=>Un,TaskRunner:()=>ko,TextWriter:()=>mi,TextureIsEqual:()=>lg,TextureMap:()=>fi,TextureMapIsEqual:()=>gs,ThreeColorConverter:()=>ja,ThreeConversionStateHandler:()=>$c,ThreeLinearToSRGBColorConverter:()=>Cf,ThreeMaterialHandler:()=>eu,ThreeMeshMaterialHandler:()=>Tl,ThreeModelLoader:()=>Ml,ThreeNodeTree:()=>Qc,ThreeSRGBToLinearColorConverter:()=>Ya,Topology:()=>la,TopologyEdge:()=>Gl,TopologyTriangle:()=>zl,TopologyTriangleEdge:()=>Vl,TopologyVertex:()=>Bl,TouchInteraction:()=>nu,TransformFileHostUrls:()=>Mu,TransformMesh:()=>Mr,Transformation:()=>pn,TransformationIsEqual:()=>gg,TraverseThreeObject:()=>od,Triangle:()=>Qt,TweenCoord3D:()=>oa,Unit:()=>_s,UpVector:()=>su,UpdateMaterialTransparency:()=>pi,Utf8StringToArrayBuffer:()=>jo,ValueOrDefault:()=>Zm,VectorAngle3D:()=>bu,VectorLength3D:()=>Xo,Viewer:()=>Sl,ViewerMainModel:()=>xl,ViewerModel:()=>Gs,WaitWhile:()=>gu});function Do(r){return r!=null}function Zm(r,e){return r??e}function Fo(r,e){if(Do(r))for(let t of Object.keys(r))Do(r[t])&&(e[t]=r[t])}function cu(r){return Object.keys(r).length===0}function uu(r,...e){return r.replace(/{([0-9]+)}/g,(t,n)=>e[n]===void 0?t:e[n])}function hu(r){return r.replace(/</g,"<").replace(/>/g,">")}var fu=class{constructor(){this.eventListeners=new Map}AddEventListener(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,[]),this.eventListeners.get(e).push(t)}HasEventListener(e){return this.eventListeners.has(e)}GetEventNotifier(e){return()=>{this.NotifyEventListeners(e)}}NotifyEventListeners(e,...t){if(!this.eventListeners.has(e))return;let n=this.eventListeners.get(e);for(let i of n)i(...t)}};var Cl=null,du=null;function Jm(r){Cl=r}function $m(r){du=r}function nt(r){return Cl===null||du===null||!Cl[r]||!Cl[r][du]?r:Cl[r][du]}function Uo(r,...e){return uu(nt(r),...e)}var ko=class{constructor(){this.count=null,this.current=null,this.callbacks=null}Run(e,t){this.count=e,this.current=0,this.callbacks=t,e===0?this.TaskReady():this.RunOnce()}RunBatch(e,t,n){let i=0;e>0&&(i=parseInt((e-1)/t,10)+1),this.Run(i,{runTask:(s,o)=>{let a=s*t,l=Math.min((s+1)*t,e)-1;n.runTask(a,l,o)},onReady:n.onReady})}RunOnce(){setTimeout(()=>{this.callbacks.runTask(this.current,this.TaskReady.bind(this))},0)}TaskReady(){this.current+=1,this.current<this.count?this.RunOnce():this.callbacks.onReady&&this.callbacks.onReady()}};function Il(r){setTimeout(()=>{r()},10)}function pu(r,e){new ko().Run(r,e)}function mu(r,e,t){new ko().RunBatch(r,e,t)}function gu(r){function e(t){t()&&setTimeout(()=>{e(t)},10)}e(r)}var Qm=1e-8,eg=1e-4,tg=57.29577951308232,xr=.017453292519943;function kr(r){return Math.abs(r)<1e-8}function Bo(r,e){return e-r>1e-8}function yu(r,e){return r-e>1e-8}function Go(r,e){return e-r>-1e-8}function Vo(r,e){return r-e>-1e-8}function Ut(r,e){return Math.abs(e-r)<1e-8}function ng(r,e,t){return Math.abs(e-r)<t}function Di(r){return r>1e-8}function Br(r){return r<-1e-8}var _t={X:1,Y:2,Z:3};var Nt=class r{constructor(e,t){this.x=e,this.y=t}Clone(){return new r(this.x,this.y)}};function ji(r,e){return Ut(r.x,e.x)&&Ut(r.y,e.y)}function ig(r,e){return new Nt(r.x+e.x,r.y+e.y)}function ms(r,e){return new Nt(r.x-e.x,r.y-e.y)}function Hs(r,e){return Math.sqrt((r.x-e.x)*(r.x-e.x)+(r.y-e.y)*(r.y-e.y))}function Rl(r,e){return r.x*e.x+r.y*e.y}var St=class r{constructor(e,t,n){this.r=e,this.g=t,this.b=n}Set(e,t,n){this.r=e,this.g=t,this.b=n}Clone(){return new r(this.r,this.g,this.b)}},Gr=class r{constructor(e,t,n,i){this.r=e,this.g=t,this.b=n,this.a=i}Set(e,t,n,i){this.r=e,this.g=t,this.b=n,this.a=i}Clone(){return new r(this.r,this.g,this.b,this.a)}};function Fn(r){return parseInt(Math.round(r*255),10)}function Ws(r){return r/255}function Ei(r,e,t){return new St(Fn(r),Fn(e),Fn(t))}function vr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Xs(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}function In(r){let e=parseInt(r,10).toString(16);for(;e.length<2;)e="0"+e;return e}function xu(r){let e=In(r.r),t=In(r.g),n=In(r.b);return e+t+n}function rg(r){let e=In(r.r),t=In(r.g),n=In(r.b),i=In(r.a);return e+t+n+i}function sg(r){if(r.length!==6)return null;let e=parseInt(r.substring(0,2),16),t=parseInt(r.substring(2,4),16),n=parseInt(r.substring(4,6),16);return new St(e,t,n)}function og(r){if(r.length!==6&&r.length!==8)return null;let e=parseInt(r.substring(0,2),16),t=parseInt(r.substring(2,4),16),n=parseInt(r.substring(4,6),16),i=255;return r.length===8&&(i=parseInt(r.substring(6,8),16)),new Gr(e,t,n,i)}function ag(r){return new St(r[0],r[1],r[2])}function Vr(r,e){return r.r===e.r&&r.g===e.g&&r.b===e.b}var fi=class{constructor(){this.name=null,this.mimeType=null,this.buffer=null,this.offset=new Nt(0,0),this.scale=new Nt(1,1),this.rotation=0}IsValid(){return this.name!==null&&this.buffer!==null}HasTransformation(){return!ji(this.offset,new Nt(0,0))||!ji(this.scale,new Nt(1,1))||!Ut(this.rotation,0)}IsEqual(e){return!(this.name!==e.name||this.mimeType!==e.mimeType||!ji(this.offset,e.offset)||!ji(this.scale,e.scale)||!Ut(this.rotation,e.rotation))}};function gs(r,e){return r===null&&e===null?!0:r===null||e===null?!1:r.IsEqual(e)}var Wn={Phong:1,Physical:2},bn={Model:1,DefaultFace:2,DefaultLine:3},Pl=class{constructor(e){this.type=e,this.source=bn.Model,this.name="",this.color=new St(0,0,0),this.vertexColors=!1}IsEqual(e){return!(this.type!==e.type||this.source!==e.source||this.name!==e.name||!Vr(this.color,e.color)||this.vertexColors!==e.vertexColors)}},zo=class extends Pl{constructor(e){super(e),this.emissive=new St(0,0,0),this.opacity=1,this.transparent=!1,this.diffuseMap=null,this.bumpMap=null,this.normalMap=null,this.emissiveMap=null,this.alphaTest=0,this.multiplyDiffuseMap=!1}IsEqual(e){return!(!super.IsEqual(e)||!Vr(this.emissive,e.emissive)||!Ut(this.opacity,e.opacity)||this.transparent!==e.transparent||!gs(this.diffuseMap,e.diffuseMap)||!gs(this.bumpMap,e.bumpMap)||!gs(this.normalMap,e.normalMap)||!gs(this.emissiveMap,e.emissiveMap)||!Ut(this.alphaTest,e.alphaTest)||this.multiplyDiffuseMap!==e.multiplyDiffuseMap)}},En=class extends zo{constructor(){super(Wn.Phong),this.ambient=new St(0,0,0),this.specular=new St(0,0,0),this.shininess=0,this.specularMap=null}IsEqual(e){return!(!super.IsEqual(e)||!Vr(this.ambient,e.ambient)||!Vr(this.specular,e.specular)||!Ut(this.shininess,e.shininess)||!gs(this.specularMap,e.specularMap))}},ys=class extends zo{constructor(){super(Wn.Physical),this.metalness=0,this.roughness=1,this.metalnessMap=null}IsEqual(e){return!(!super.IsEqual(e)||!Ut(this.metalness,e.metalness)||!Ut(this.roughness,e.roughness)||!gs(this.metalnessMap,e.metalnessMap))}};function lg(r,e){return!(r.name!==e.name||r.mimeType!==e.mimeType||!ji(r.offset,e.offset)||!ji(r.scale,e.scale)||!Ut(r.rotation,e.rotation))}var cg=new Set;function Ho(r){return new Promise((e,t)=>{if(cg.has(r)){e();return}let n=document.createElement("script");n.type="text/javascript",n.src=r,n.onload=()=>{cg.add(r),e()},n.onerror=()=>{t()},document.head.appendChild(n)})}function zr(r,e,t){let n=r.substring(e),i=n.indexOf(t);return i!==-1&&(n=n.substring(0,i)),n.trim()}function Yi(r,e){if(e!==null){let t=r.indexOf(e);t!==-1&&(r=r.substring(0,t).trim())}return r.split(/\s+/u)}function Fi(r,e){function t(s,o){let a=s.trim();a.length>0&&o(a)}let n=0,i=r.indexOf(`
`,n);for(;i!==-1;)t(r.substring(n,i),e),n=i+1,i=r.indexOf(`
-`,n);t(r.substring(n),e)}function Zh(r){return(r&r-1)===0}function Zp(r){if(Zh(r))return r;let e=Math.pow(2,Math.ceil(Math.log(r)/Math.log(2)));return parseInt(e,10)}function si(r){r.transparent=!1,fo(r.opacity,1)&&(r.transparent=!0)}var ri=class{constructor(e){this.model=e,this.colorToMaterialIndex=new Map}GetMaterialIndex(e,t,n,i){let s=Mn(e)+Mn(t)+Mn(n),o=i!=null;if(o&&(s+=Mn(i)),this.colorToMaterialIndex.has(s))return this.colorToMaterialIndex.get(s);{let a=new vn;a.name=s.toUpperCase(),a.color=new Mt(e,t,n),o&&i<255&&(a.opacity=i/255,si(a));let l=this.model.AddMaterial(a);return this.colorToMaterialIndex.set(s,l),l}}},Dc=null;function yo(r){return new Promise((e,t)=>{if(Dc!==null){e(new Worker(Dc));return}let n="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.22/dist/";fetch(n+"occt-import-js-worker.js").then(i=>i.ok?i.text():t()).then(i=>{i=i.replace("occt-import-js.js",n+"occt-import-js.js"),i=i.replace("return path","return '"+n+"occt-import-js.wasm'");let s=new Blob([i],{type:"text/javascript"});return Dc=URL.createObjectURL(s),e(new Worker(Dc))}).catch(t)})}function cr(r){return r==="rhino3dm"?vo("https://cdn.jsdelivr.net/npm/rhino3dm@8.4.0/rhino3dm.min.js"):r==="webifc"?vo("https://cdn.jsdelivr.net/npm/web-ifc@0.0.55/web-ifc-api-iife.js"):r==="draco3d"?vo("https://cdn.jsdelivr.net/npm/draco3d@1.5.7/draco_decoder_nodejs.min.js"):null}var ki={Url:1,File:2,Decompressed:3},an={Text:1,Binary:2};function En(r){let e=r,t=e.indexOf("?");t!==-1&&(e=e.substring(0,t));let n=e.lastIndexOf("/");return n===-1&&(n=e.lastIndexOf("\\")),n!==-1&&(e=e.substring(n+1)),decodeURI(e)}function ur(r){let e=En(r),t=e.lastIndexOf(".");return t===-1?"":e.substring(t+1).toLowerCase()}function Fc(r,e){return new Promise((t,n)=>{let i=new XMLHttpRequest;i.open("GET",r,!0),i.onprogress=s=>{e(s.loaded,s.total)},i.onload=()=>{i.status===200?t(i.response):n()},i.onerror=()=>{n()},i.responseType="arraybuffer",i.send(null)})}function Uc(r,e){return new Promise((t,n)=>{let i=new FileReader;i.onprogress=s=>{e(s.loaded,s.total)},i.onloadend=s=>{s.target.readyState===FileReader.DONE&&t(s.target.result)},i.onerror=()=>{n()},i.readAsArrayBuffer(r)})}function kc(r){for(let e=0;e<r.length;e++){let t=r[e];t.indexOf("www.dropbox.com")!==-1?(t=t.replace("www.dropbox.com","dl.dropbox.com"),r[e]=t):t.indexOf("github.com")!==-1&&(t=t.replace("github.com","raw.githubusercontent.com"),t=t.replace("/blob",""),r[e]=t)}}function Jp(r){let e=/^https?:\/\/\S+$/g;return r.match(e)!==null}var Xe=class r{constructor(e,t,n){this.x=e,this.y=t,this.z=n}Length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}MultiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}Normalize(){let e=this.Length();return e>0&&this.MultiplyScalar(1/e),this}Offset(e,t){let n=e.Clone().Normalize();return this.x+=n.x*t,this.y+=n.y*t,this.z+=n.z*t,this}Rotate(e,t,n){let i=e.Clone().Normalize(),s=i.x,o=i.y,a=i.z,l=this.x-n.x,c=this.y-n.y,u=this.z-n.z,h=Math.sin(t),f=Math.cos(t);return this.x=-s*(-s*l-o*c-a*u)*(1-f)+l*f+(-a*c+o*u)*h,this.y=-o*(-s*l-o*c-a*u)*(1-f)+c*f+(a*l-s*u)*h,this.z=-a*(-s*l-o*c-a*u)*(1-f)+u*f+(-o*l+s*c)*h,this.x+=n.x,this.y+=n.y,this.z+=n.z,this}Clone(){return new r(this.x,this.y,this.z)}};function pi(r,e){return It(r.x,e.x)&&It(r.y,e.y)&&It(r.z,e.z)}function Bc(r,e){return new Xe(r.x+e.x,r.y+e.y,r.z+e.z)}function In(r,e){return new Xe(r.x-e.x,r.y-e.y,r.z-e.z)}function Yn(r,e){return Math.sqrt((r.x-e.x)*(r.x-e.x)+(r.y-e.y)*(r.y-e.y)+(r.z-e.z)*(r.z-e.z))}function ml(r,e){return r.x*e.x+r.y*e.y+r.z*e.z}function Gc(r,e){let t=r.Clone().Normalize(),n=e.Clone().Normalize();if(pi(t,n))return 0;let i=ml(t,n);return Math.acos(i)}function Bi(r,e){let t=new Xe(0,0,0);return t.x=r.y*e.z-r.z*e.y,t.y=r.z*e.x-r.x*e.z,t.z=r.x*e.y-r.y*e.x,t}function xo(r,e,t){return Math.sqrt(r*r+e*e+t*t)}function Ei(r){return new Xe(r[0],r[1],r[2])}var gl=class{constructor(){this.indices=[],this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.material=null}GetBounds(){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let n=0;n<this.vertices.length/3;n++)for(let i=0;i<3;i++)e[i]=Math.min(e[i],this.vertices[n*3+i]),t[i]=Math.max(t[i],this.vertices[n*3+i]);return{min:e,max:t}}GetByteLength(e,t){let n=this.indices.length,i=this.vertices.length+this.colors.length+this.normals.length+this.uvs.length;return n*e+i*t}},vl=class{constructor(){this.primitives=[]}PrimitiveCount(){return this.primitives.length}GetPrimitive(e){return this.primitives[e]}GetByteLength(e,t){let n=0;for(let i=0;i<this.primitives.length;i++){let s=this.primitives[i];n+=s.GetByteLength(e,t)}return n}};function _o(r){function e(a,l,c,u){function h(v,d,m){return d!==null?v.GetVertexColor(d):m?new Mt(0,0,0):null}function f(v,d,m){return d!==null?v.GetTextureUV(d):m?new At(0,0):null}function p(v,d,m){let _=v.VertexColorCount()>0,y=v.TextureUVCount()>0,x=v.GetVertex(d.vertex),w=v.GetNormal(d.normal),I=m.vertices.length/3;m.indices.push(I),m.vertices.push(x.x,x.y,x.z);let C=h(v,d.color,_);C!==null&&m.colors.push(C.r/255,C.g/255,C.b/255),m.normals.push(w.x,w.y,w.z);let P=f(v,d.uv,y);return P!==null&&m.uvs.push(P.x,P.y),{index:I,color:C,normal:w,uv:P}}function g(v,d,m){function _(w,I,C){if(C===null&&I===null)return!0;let P=h(w,I,!0);return Ir(C,P)}function y(w,I,C){let P=w.GetNormal(I);return pi(C,P)}function x(w,I,C){if(C===null&&I===null)return!0;let P=f(w,I,!0);return Fi(C,P)}for(let w=0;w<d.length;w++){let I=d[w],C=_(v,m.color,I.color),P=y(v,m.normal,I.normal),E=x(v,m.uv,I.uv);if(C&&P&&E)return I}return null}if(u.has(l.vertex)){let v=u.get(l.vertex),d=g(a,v,l);if(d!==null)c.indices.push(d.index);else{let m=p(a,l,c);v.push(m)}}else{let v=p(a,l,c);u.set(l.vertex,[v])}}let t=new vl,n=r.TriangleCount();if(n===0)return null;let i=[];for(let a=0;a<n;a++)i.push(a);i.sort((a,l)=>{let c=r.GetTriangle(a),u=r.GetTriangle(l);return c.mat-u.mat});let s=null,o=null;for(let a=0;a<i.length;a++){let l=i[a],c=r.GetTriangle(l);(s===null||s.material!==c.mat)&&(s=new gl,s.material=c.mat,o=new Map,t.primitives.push(s));let u={vertex:c.v0,color:c.c0,normal:c.n0,uv:c.u0},h={vertex:c.v1,color:c.c1,normal:c.n1,uv:c.u1},f={vertex:c.v2,color:c.c2,normal:c.n2,uv:c.u2};e(r,u,s,o),e(r,h,s,o),e(r,f,s,o)}return t}function xn(r){return new TextDecoder("utf-8").decode(r)}function $p(r){let e="",t=new Uint8Array(r);for(let n=0;n<t.byteLength;n++)e+=String.fromCharCode(t[n]);return e}function Qp(r){let e=new ArrayBuffer(r.length),t=new Uint8Array(e);for(let n=0;n<r.length;n++)t[n]=r.charCodeAt(n);return e}function To(r){return new TextEncoder().encode(r).buffer}function Ls(r){let e="data:";if(!r.startsWith(e))return null;let t=r.indexOf(";");if(t===-1)return null;let n=r.indexOf(",");if(n===-1)return null;let i=r.substring(e.length,e.length+t-5),s=atob(r.substring(n+1)),o=new ArrayBuffer(s.length),a=new Uint8Array(o);for(let l=0;l<s.length;l++)a[l]=s.charCodeAt(l);return{mimeType:i,buffer:o}}function es(r){if(r==null)return"";let e=r.split("/");return e.length===0?"":e[e.length-1]}function Os(r){let e=new Blob([r]);return URL.createObjectURL(e)}function Vc(r,e){let t=new Blob([r],{type:e});return URL.createObjectURL(t)}function zc(r){URL.revokeObjectURL(r)}var $t=class{constructor(e){this.name=e,this.content=null}GetName(){return this.name}SetName(e){this.name=e}GetTextContent(){return xn(this.content)}GetBufferContent(){return this.content}SetTextContent(e){let t=To(e);this.content=t}SetBufferContent(e){this.content=e}},Pn=class{constructor(){}CanExport(e,t){return!1}Export(e,t,n){let i=[];this.ExportContent(e,t,i,()=>{n(i)})}ExportContent(e,t,n,i){}GetExportedMaterialName(e){return this.GetExportedName(e,Ze("Material"))}GetExportedMeshName(e){return this.GetExportedName(e,Ze("Mesh"))}GetExportedName(e,t){return e.length===0?t:e}};var Mo=class extends Pn{constructor(){super(),this.rhino=null}CanExport(e,t){return e===an.Binary&&t==="3dm"}ExportContent(e,t,n,i){this.rhino===null?cr("rhino3dm").then(()=>{rhino3dm().then(s=>{this.rhino=s,this.ExportRhinoContent(e,n,i)})}).catch(()=>{i()}):this.ExportRhinoContent(e,n,i)}ExportRhinoContent(e,t,n){function i(c){return{r:c.r,g:c.g,b:c.b,a:255}}let s=new $t("model.3dm");t.push(s);let o=new this.rhino.File3dm;e.EnumerateTransformedMeshInstances(c=>{let u=_o(c);for(let h=0;h<u.PrimitiveCount();h++){let f=u.GetPrimitive(h),p={data:{attributes:{position:{itemSize:3,type:"Float32Array",array:f.vertices},normal:{itemSize:3,type:"Float32Array",array:f.normals}},index:{type:"Uint16Array",array:f.indices}}},g=e.GetMaterial(f.material),v=new this.rhino.Material;v.name=this.GetExportedMaterialName(g.name),g.type===Un.Phong&&(v.ambientColor=i(g.ambient),v.specularColor=i(g.specular)),v.diffuseColor=i(g.color),v.transparency=1-g.opacity;let d=o.materials().count;o.materials().add(v);let m=new this.rhino.Mesh.createFromThreejsJSON(p),_=new this.rhino.ObjectAttributes;_.name=this.GetExportedMeshName(c.GetName()),_.materialSource=this.rhino.ObjectMaterialSource.MaterialFromObject,_.materialIndex=d,o.objects().add(m,_)}});let a=new this.rhino.File3dmWriteOptions;a.version=6;let l=o.toByteArrayOptions(a);s.SetBufferContent(l),n()}};var Vt={Text:1,Integer:2,Number:3,Boolean:4,Percent:5,Color:6},nn=class r{constructor(e,t,n){this.type=e,this.name=t,this.value=n}Clone(){return this.type===Vt.Color?new r(this.type,this.name,this.value.Clone()):new r(this.type,this.name,this.value)}},Vn=class r{constructor(e){this.name=e,this.properties=[]}PropertyCount(){return this.properties.length}AddProperty(e){this.properties.push(e)}GetProperty(e){return this.properties[e]}Clone(){let e=new r(this.name);for(let t of this.properties)e.AddProperty(t.Clone());return e}};function Hc(r){return r.type===Vt.Text?wc(r.value):r.type===Vt.Integer?r.value.toLocaleString():r.type===Vt.Number?r.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):r.type===Vt.Boolean?r.value?Ze("True"):Ze("False"):r.type===Vt.Percent?parseInt(r.value*100,10).toString()+"%":r.type===Vt.Color?"#"+Oc(r.value):null}function Lv(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Eo=class extends Pn{constructor(){super()}CanExport(e,t){return e===an.Text&&t==="bim"}ExportContent(e,t,n,i){let s={schema_version:"1.1.0",meshes:[],elements:[],info:{}};this.ExportProperties(e.GetModel(),s.info);let o=0;e.EnumerateTransformedMeshInstances(l=>{let c={mesh_id:o,coordinates:[],indices:[]};l.EnumerateVertices(g=>{c.coordinates.push(g.x,g.y,g.z)}),l.EnumerateTriangleVertexIndices((g,v,d)=>{c.indices.push(g,v,d)});let u={mesh_id:o,type:"Other",color:{r:200,g:200,b:200,a:255},vector:{x:0,y:0,z:0},rotation:{qx:0,qy:0,qz:0,qw:1},guid:Lv(),info:{}},h=null,f=!0,p=[];for(let g=0;g<l.TriangleCount();g++){let v=l.GetTriangle(g),d=e.GetMaterial(v.mat),m={r:Math.round(d.color.r),g:Math.round(d.color.g),b:Math.round(d.color.b),a:Rn(d.opacity)};p.push(m.r,m.g,m.b,m.a),f&&(h===null?h=m:(h.r!==m.r||h.g!==m.g||h.b!==m.b||h.a!==m.a)&&(f=!1,h=null))}f?u.color=h:u.face_colors=p,u.info.Name=l.GetName(),this.ExportProperties(l,u.info),s.meshes.push(c),s.elements.push(u),o+=1});let a=new $t("model.bim");a.SetTextContent(JSON.stringify(s,null,4)),n.push(a),i()}ExportProperties(e,t){for(let n=0;n<e.PropertyGroupCount();n++){let i=e.GetPropertyGroup(n);for(let s=0;s<i.PropertyCount();s++){let o=i.GetProperty(s);t[o.name]=Hc(o)}}}};var Gi=class{constructor(e,t){this.arrayBuffer=new ArrayBuffer(e),this.dataView=new DataView(this.arrayBuffer),this.isLittleEndian=t,this.position=0}GetPosition(){return this.position}SetPosition(e){this.position=e}End(){return this.position>=this.arrayBuffer.byteLength}GetBuffer(){return this.arrayBuffer}WriteArrayBuffer(e){let t=new Uint8Array(e);new Uint8Array(this.arrayBuffer).set(t,this.position),this.position+=e.byteLength}WriteBoolean8(e){this.dataView.setInt8(this.position,e?1:0),this.position=this.position+1}WriteCharacter8(e){this.dataView.setInt8(this.position,e),this.position=this.position+1}WriteUnsignedCharacter8(e){this.dataView.setUint8(this.position,e),this.position=this.position+1}WriteInteger16(e){this.dataView.setInt16(this.position,e,this.isLittleEndian),this.position=this.position+2}WriteUnsignedInteger16(e){this.dataView.setUint16(this.position,e,this.isLittleEndian),this.position=this.position+2}WriteInteger32(e){this.dataView.setInt32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteUnsignedInteger32(e){this.dataView.setUint32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteFloat32(e){this.dataView.setFloat32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteDouble64(e){this.dataView.setFloat64(this.position,e,this.isLittleEndian),this.position=this.position+8}};var Vi=class r{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.w=i}Clone(){return new r(this.x,this.y,this.z,this.w)}};var Kn=class{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.w=i}};function em(r,e){return It(r.x,e.x)&&It(r.y,e.y)&&It(r.z,e.z)&&It(r.w,e.w)}function bo(r){return new Kn(r[0],r[1],r[2],r[3])}function Wc(r,e){let t=e/2,n=Math.sin(t);return new Kn(r.x*n,r.y*n,r.z*n,Math.cos(t))}function tm(r,e,t,n){let i=Math.cos(r/2),s=Math.cos(e/2),o=Math.cos(t/2),a=Math.sin(r/2),l=Math.sin(e/2),c=Math.sin(t/2),u=new Kn(0,0,0,1);if(n==="XYZ")u.x=a*s*o+i*l*c,u.y=i*l*o-a*s*c,u.z=i*s*c+a*l*o,u.w=i*s*o-a*l*c;else if(n==="YXZ")u.x=a*s*o+i*l*c,u.y=i*l*o-a*s*c,u.z=i*s*c-a*l*o,u.w=i*s*o+a*l*c;else if(n==="ZXY")u.x=a*s*o-i*l*c,u.y=i*l*o+a*s*c,u.z=i*s*c+a*l*o,u.w=i*s*o-a*l*c;else if(n==="ZYX")u.x=a*s*o-i*l*c,u.y=i*l*o+a*s*c,u.z=i*s*c-a*l*o,u.w=i*s*o+a*l*c;else if(n==="YZX")u.x=a*s*o+i*l*c,u.y=i*l*o+a*s*c,u.z=i*s*c-a*l*o,u.w=i*s*o-a*l*c;else if(n==="XZY")u.x=a*s*o-i*l*c,u.y=i*l*o-a*s*c,u.z=i*s*c+a*l*o,u.w=i*s*o+a*l*c;else return null;return u}var fn=class r{constructor(e){this.matrix=null,e!=null&&(this.matrix=e)}IsValid(){return this.matrix!==null}Set(e){return this.matrix=e,this}Get(){return this.matrix}Clone(){let e=[this.matrix[0],this.matrix[1],this.matrix[2],this.matrix[3],this.matrix[4],this.matrix[5],this.matrix[6],this.matrix[7],this.matrix[8],this.matrix[9],this.matrix[10],this.matrix[11],this.matrix[12],this.matrix[13],this.matrix[14],this.matrix[15]];return new r(e)}CreateIdentity(){return this.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this}IsIdentity(){let e=new r().CreateIdentity().Get();for(let t=0;t<16;t++)if(!It(this.matrix[t],e[t]))return!1;return!0}CreateTranslation(e,t,n){return this.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,e,t,n,1],this}CreateRotation(e,t,n,i){let s=e+e,o=t+t,a=n+n,l=e*s,c=e*o,u=e*a,h=t*o,f=t*a,p=n*a,g=i*s,v=i*o,d=i*a;return this.matrix=[1-(h+p),c+d,u-v,0,c-d,1-(l+p),f+g,0,u+v,f-g,1-(l+h),0,0,0,0,1],this}CreateRotationAxisAngle(e,t){let n=Wc(e,t);return this.CreateRotation(n.x,n.y,n.z,n.w)}CreateScale(e,t,n){return this.matrix=[e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1],this}ComposeTRS(e,t,n){let i=e.x,s=e.y,o=e.z,a=t.x,l=t.y,c=t.z,u=t.w,h=n.x,f=n.y,p=n.z,g=a+a,v=l+l,d=c+c,m=a*g,_=a*v,y=a*d,x=l*v,w=l*d,I=c*d,C=u*g,P=u*v,E=u*d;return this.matrix=[(1-(x+I))*h,(_+E)*h,(y-P)*h,0,(_-E)*f,(1-(m+I))*f,(w+C)*f,0,(y+P)*p,(w-C)*p,(1-(m+x))*p,0,i,s,o,1],this}DecomposeTRS(){let e=new Xe(this.matrix[12],this.matrix[13],this.matrix[14]),t=xo(this.matrix[0],this.matrix[1],this.matrix[2]),n=xo(this.matrix[4],this.matrix[5],this.matrix[6]),i=xo(this.matrix[8],this.matrix[9],this.matrix[10]),s=this.Determinant();Cr(s)&&(t*=-1);let o=new Xe(t,n,i),a=this.matrix[0]/t,l=this.matrix[4]/n,c=this.matrix[8]/i,u=this.matrix[1]/t,h=this.matrix[5]/n,f=this.matrix[9]/i,p=this.matrix[2]/t,g=this.matrix[6]/n,v=this.matrix[10]/i,d=null,m=a+h+v;if(m>0){let _=Math.sqrt(m+1)*2;d=new Kn((g-f)/_,(c-p)/_,(u-l)/_,.25*_)}else if(a>h&&a>v){let _=Math.sqrt(1+a-h-v)*2;d=new Kn(.25*_,(l+u)/_,(c+p)/_,(g-f)/_)}else if(h>v){let _=Math.sqrt(1+h-a-v)*2;d=new Kn((l+u)/_,.25*_,(f+g)/_,(c-p)/_)}else{let _=Math.sqrt(1+v-a-h)*2;d=new Kn((c+p)/_,(f+g)/_,.25*_,(u-l)/_)}return{translation:e,rotation:d,scale:o}}Determinant(){let e=this.matrix[0],t=this.matrix[1],n=this.matrix[2],i=this.matrix[3],s=this.matrix[4],o=this.matrix[5],a=this.matrix[6],l=this.matrix[7],c=this.matrix[8],u=this.matrix[9],h=this.matrix[10],f=this.matrix[11],p=this.matrix[12],g=this.matrix[13],v=this.matrix[14],d=this.matrix[15],m=e*o-t*s,_=e*a-n*s,y=e*l-i*s,x=t*a-n*o,w=t*l-i*o,I=n*l-i*a,C=c*g-u*p,P=c*v-h*p,E=c*d-f*p,M=u*v-h*g,L=u*d-f*g,N=h*d-f*v;return m*N-_*L+y*M+x*E-w*P+I*C}Invert(){let e=this.matrix[0],t=this.matrix[1],n=this.matrix[2],i=this.matrix[3],s=this.matrix[4],o=this.matrix[5],a=this.matrix[6],l=this.matrix[7],c=this.matrix[8],u=this.matrix[9],h=this.matrix[10],f=this.matrix[11],p=this.matrix[12],g=this.matrix[13],v=this.matrix[14],d=this.matrix[15],m=e*o-t*s,_=e*a-n*s,y=e*l-i*s,x=t*a-n*o,w=t*l-i*o,I=n*l-i*a,C=c*g-u*p,P=c*v-h*p,E=c*d-f*p,M=u*v-h*g,L=u*d-f*g,N=h*d-f*v,O=m*N-_*L+y*M+x*E-w*P+I*C;if(It(O,0))return null;let B=[(o*N-a*L+l*M)/O,(n*L-t*N-i*M)/O,(g*I-v*w+d*x)/O,(h*w-u*I-f*x)/O,(a*E-s*N-l*P)/O,(e*N-n*E+i*P)/O,(v*y-p*I-d*_)/O,(c*I-h*y+f*_)/O,(s*L-o*E+l*C)/O,(t*E-e*L-i*C)/O,(p*w-g*y+d*m)/O,(u*y-c*w-f*m)/O,(o*P-s*M-a*C)/O,(e*M-t*P+n*C)/O,(g*_-p*x-v*m)/O,(c*x-u*_+h*m)/O];return new r(B)}Transpose(){let e=[this.matrix[0],this.matrix[4],this.matrix[8],this.matrix[12],this.matrix[1],this.matrix[5],this.matrix[9],this.matrix[13],this.matrix[2],this.matrix[6],this.matrix[10],this.matrix[14],this.matrix[3],this.matrix[7],this.matrix[11],this.matrix[15]];return new r(e)}InvertTranspose(){let e=this.Invert();return e===null?null:e.Transpose()}MultiplyVector(e){let t=e.x,n=e.y,i=e.z,s=e.w,o=this.matrix[0],a=this.matrix[1],l=this.matrix[2],c=this.matrix[3],u=this.matrix[4],h=this.matrix[5],f=this.matrix[6],p=this.matrix[7],g=this.matrix[8],v=this.matrix[9],d=this.matrix[10],m=this.matrix[11],_=this.matrix[12],y=this.matrix[13],x=this.matrix[14],w=this.matrix[15];return new Vi(t*o+n*u+i*g+s*_,t*a+n*h+i*v+s*y,t*l+n*f+i*d+s*x,t*c+n*p+i*m+s*w)}MultiplyMatrix(e){let t=this.matrix[0],n=this.matrix[1],i=this.matrix[2],s=this.matrix[3],o=this.matrix[4],a=this.matrix[5],l=this.matrix[6],c=this.matrix[7],u=this.matrix[8],h=this.matrix[9],f=this.matrix[10],p=this.matrix[11],g=this.matrix[12],v=this.matrix[13],d=this.matrix[14],m=this.matrix[15],_=e.matrix[0],y=e.matrix[1],x=e.matrix[2],w=e.matrix[3],I=e.matrix[4],C=e.matrix[5],P=e.matrix[6],E=e.matrix[7],M=e.matrix[8],L=e.matrix[9],N=e.matrix[10],O=e.matrix[11],B=e.matrix[12],ie=e.matrix[13],$=e.matrix[14],te=e.matrix[15],W=[t*_+n*I+i*M+s*B,t*y+n*C+i*L+s*ie,t*x+n*P+i*N+s*$,t*w+n*E+i*O+s*te,o*_+a*I+l*M+c*B,o*y+a*C+l*L+c*ie,o*x+a*P+l*N+c*$,o*w+a*E+l*O+c*te,u*_+h*I+f*M+p*B,u*y+h*C+f*L+p*ie,u*x+h*P+f*N+p*$,u*w+h*E+f*O+p*te,g*_+v*I+d*M+m*B,g*y+v*C+d*L+m*ie,g*x+v*P+d*N+m*$,g*w+v*E+d*O+m*te];return new r(W)}};function Xc(r,e){let t=r.Get(),n=e.Get();for(let i=0;i<16;i++)if(!It(t[i],n[i]))return!1;return!0}var ln=class r{constructor(e){e!=null?this.matrix=e:(this.matrix=new fn,this.matrix.CreateIdentity())}SetMatrix(e){return this.matrix=e,this}GetMatrix(){return this.matrix}IsIdentity(){return this.matrix.IsIdentity()}AppendMatrix(e){return this.matrix=this.matrix.MultiplyMatrix(e),this}Append(e){return this.AppendMatrix(e.GetMatrix()),this}TransformCoord3D(e){let t=new Vi(e.x,e.y,e.z,1),n=this.matrix.MultiplyVector(t);return new Xe(n.x,n.y,n.z)}Clone(){let e=this.matrix.Clone();return new r(e)}};function nm(r,e){return Xc(r.GetMatrix(),e.GetMatrix())}function ts(r){return r.LineCount()===0&&r.TriangleCount()===0}function Ds(r,e,t){let n=In(e,r),i=In(t,r),s=Bi(n,i);return s.Normalize(),s}function hr(r,e){if(!e.IsIdentity()){for(let t=0;t<r.VertexCount();t++){let n=r.GetVertex(t),i=e.TransformCoord3D(n);n.x=i.x,n.y=i.y,n.z=i.z}if(r.NormalCount()>0){let t=e.GetMatrix().InvertTranspose();if(t!==null){let n=new ln(t);for(let i=0;i<r.NormalCount();i++){let s=r.GetNormal(i),o=n.TransformCoord3D(s);s.x=o.x,s.y=o.y,s.z=o.z}}}}}function jc(r){for(let e=0;e<r.TriangleCount();e++){let t=r.GetTriangle(e),n=t.v1;t.v1=t.v2,t.v2=n}}var yl=class{constructor(){}VertexCount(){return 0}VertexColorCount(){return 0}NormalCount(){return 0}TextureUVCount(){return 0}LineCount(){return 0}LineSegmentCount(){return 0}TriangleCount(){return 0}EnumerateVertices(e){}EnumerateTriangleVertexIndices(e){}EnumerateTriangleVertices(e){}},fr=class extends yl{constructor(){super(),this.name="",this.propertyGroups=[]}GetName(){return this.name}SetName(e){this.name=e}PropertyGroupCount(){return this.propertyGroups.length}AddPropertyGroup(e){return this.propertyGroups.push(e),this.propertyGroups.length-1}GetPropertyGroup(e){return this.propertyGroups[e]}CloneProperties(e){for(let t of this.propertyGroups)e.AddPropertyGroup(t.Clone())}};var bi=class{constructor(e,t){this.nodeId=e,this.meshIndex=t}IsEqual(e){return this.nodeId===e.nodeId&&this.meshIndex===e.meshIndex}GetKey(){return this.nodeId.toString()+":"+this.meshIndex.toString()}},Nr=class extends fr{constructor(e,t,n){super(),this.id=e,this.node=t,this.mesh=n}GetId(){return this.id}GetTransformation(){return this.node.GetWorldTransformation()}GetMesh(){return this.mesh}VertexCount(){return this.mesh.VertexCount()}VertexColorCount(){return this.mesh.VertexColorCount()}NormalCount(){return this.mesh.NormalCount()}TextureUVCount(){return this.mesh.TextureUVCount()}LineCount(){return this.mesh.LineCount()}LineSegmentCount(){return this.mesh.LineSegmentCount()}TriangleCount(){return this.mesh.TriangleCount()}EnumerateVertices(e){let t=this.node.GetWorldTransformation();t.IsIdentity()?this.mesh.EnumerateVertices(e):this.mesh.EnumerateVertices(n=>{let i=t.TransformCoord3D(n);e(i)})}EnumerateTriangleVertexIndices(e){this.mesh.EnumerateTriangleVertexIndices(e)}EnumerateTriangleVertices(e){let t=this.node.GetWorldTransformation();t.IsIdentity()?this.mesh.EnumerateTriangleVertices(e):this.mesh.EnumerateTriangleVertices((n,i,s)=>{let o=t.TransformCoord3D(n),a=t.TransformCoord3D(i),l=t.TransformCoord3D(s);e(o,a,l)})}PropertyGroupCount(){return this.mesh.PropertyGroupCount()}AddPropertyGroup(e){return this.mesh.AddPropertyGroup(e)}GetPropertyGroup(e){return this.mesh.GetPropertyGroup(e)}GetTransformedMesh(){let e=this.node.GetWorldTransformation(),t=this.mesh.Clone();return hr(t,e),t}};var im={UNSIGNED_INT:5125,FLOAT:5126},xl={ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963},So=class extends Pn{constructor(){super(),this.components={index:{type:im.UNSIGNED_INT,size:4},number:{type:im.FLOAT,size:4}}}CanExport(e,t){return e===an.Text&&t==="gltf"||e===an.Binary&&t==="glb"}ExportContent(e,t,n,i){t===an.Text?this.ExportAsciiContent(e,n):t===an.Binary&&this.ExportBinaryContent(e,n),i()}ExportAsciiContent(e,t){let n=new $t("model.gltf"),i=new $t("model.bin");t.push(n),t.push(i);let s=this.GetMeshData(e),o=this.GetMainBuffer(s),a=this.GetMainJson(e,s);a.buffers.push({uri:i.GetName(),byteLength:o.byteLength});let l=new Map;this.ExportMaterials(e,a,c=>{let u=En(c.name);if(l.has(u))return l.get(u);{let h=new $t(u);h.SetBufferContent(c.buffer),t.push(h);let f=a.textures.length;return l.set(u,f),a.images.push({uri:u}),a.textures.push({source:f}),f}}),n.SetTextContent(JSON.stringify(a,null,4)),i.SetBufferContent(o)}ExportBinaryContent(e,t){function n(x){let w=x%4;return w===0?x:x+(4-w)}function i(x,w,I){for(let C=0;C<I;C++)x.WriteUnsignedCharacter8(w)}let s=new $t("model.glb");t.push(s);let o=this.GetMeshData(e),a=this.GetMainBuffer(o),l=this.GetMainJson(e,o),c=[],u=a.byteLength,h=new Map;this.ExportMaterials(e,l,x=>{let w=En(x.name),I=ur(x.name);if(h.has(w))return h.get(w);{let C=l.bufferViews.length,P=l.textures.length;h.set(w,P);let E=x.buffer;return c.push(E),l.bufferViews.push({buffer:0,byteOffset:u,byteLength:E.byteLength}),u+=E.byteLength,l.images.push({bufferView:C,mimeType:"image/"+I}),l.textures.push({source:P}),P}});let f=a.byteLength;for(let x=0;x<c.length;x++){let w=c[x];f+=w.byteLength}let p=n(f);l.buffers.push({byteLength:p});let g=JSON.stringify(l),v=To(g),d=v.byteLength,m=n(d),_=20+m+8+p,y=new Gi(_,!0);y.WriteUnsignedInteger32(1179937895),y.WriteUnsignedInteger32(2),y.WriteUnsignedInteger32(_),y.WriteUnsignedInteger32(m),y.WriteUnsignedInteger32(1313821514),y.WriteArrayBuffer(v),i(y,32,m-d),y.WriteUnsignedInteger32(p),y.WriteUnsignedInteger32(5130562),y.WriteArrayBuffer(a);for(let x=0;x<c.length;x++){let w=c[x];y.WriteArrayBuffer(w)}i(y,0,p-f),s.SetBufferContent(y.GetBuffer())}GetMeshData(e){let t=[];return e.EnumerateMeshes(n=>{let i=_o(n);t.push({name:n.GetName(),buffer:i,offsets:[],sizes:[]})}),t}GetMainBuffer(e){let t=0;for(let i of e)t+=i.buffer.GetByteLength(this.components.index.size,this.components.number.size);let n=new Gi(t,!0);for(let i of e)for(let s=0;s<i.buffer.PrimitiveCount();s++){let o=i.buffer.GetPrimitive(s),a=n.GetPosition();for(let l=0;l<o.indices.length;l++)n.WriteUnsignedInteger32(o.indices[l]);for(let l=0;l<o.vertices.length;l++)n.WriteFloat32(o.vertices[l]);for(let l=0;l<o.colors.length;l++)n.WriteFloat32(lr(o.colors[l]));for(let l=0;l<o.normals.length;l++)n.WriteFloat32(o.normals[l]);for(let l=0;l<o.uvs.length;l++){let c=o.uvs[l];l%2===1&&(c*=-1),n.WriteFloat32(c)}i.offsets.push(a),i.sizes.push(n.GetPosition()-a)}return n.GetBuffer()}GetMainJson(e,t){class n{constructor(h,f){this.mainJson=h,this.byteOffset=f}AddBufferView(h,f){let p={buffer:0,byteOffset:this.byteOffset,byteLength:h,target:f};return this.mainJson.bufferViews.push(p),this.byteOffset+=h,this.mainJson.bufferViews.length-1}}function i(u,h){for(let f of h.GetMeshIndices()){let p=new bi(h.GetId(),f);if(u.IsMeshInstanceVisible(p))return!0}for(let f of h.GetChildNodes())if(i(u,f))return!0;return!1}function s(u,h,f,p){if(p.IsMeshNode())for(let g of p.GetMeshIndices())o(u,h,f,p,g,!0);else if(i(u,p)){let g={},v=p.GetName();v.length>0&&(g.name=v),p.GetTransformation().IsIdentity()||(g.matrix=p.GetTransformation().GetMatrix().Get()),f.push(g),h.push(f.length-1),g.children=[],a(u,g.children,f,p)}}function o(u,h,f,p,g,v){let d=new bi(p.GetId(),g);if(!u.IsMeshInstanceVisible(d))return;let m={mesh:u.MapMeshIndex(g)};v&&(p.GetTransformation().IsIdentity()||(m.matrix=p.GetTransformation().GetMatrix().Get())),f.push(m),h.push(f.length-1)}function a(u,h,f,p){for(let g of p.GetChildNodes())s(u,h,f,g);for(let g of p.GetMeshIndices())o(u,h,f,p,g,!1)}let l={asset:{generator:"https://3dviewer.net",version:"2.0"},scene:0,scenes:[{nodes:[]}],nodes:[],materials:[],meshes:[],buffers:[],bufferViews:[],accessors:[]},c=e.GetModel().GetRootNode();a(e,l.scenes[0].nodes,l.nodes,c);for(let u of t){let h={name:this.GetExportedMeshName(u.name),primitives:[]},f=u.buffer.primitives;for(let p=0;p<f.length;p++){let g=f[p],v=new n(l,u.offsets[p]),d=v.AddBufferView(g.indices.length*this.components.index.size,xl.ELEMENT_ARRAY_BUFFER),m=v.AddBufferView(g.vertices.length*this.components.number.size,xl.ARRAY_BUFFER),_=null;g.colors.length>0&&(_=v.AddBufferView(g.colors.length*this.components.number.size,xl.ARRAY_BUFFER));let y=v.AddBufferView(g.normals.length*this.components.number.size,xl.ARRAY_BUFFER),x=null;g.uvs.length>0&&(x=v.AddBufferView(g.uvs.length*this.components.number.size,xl.ARRAY_BUFFER));let w={attributes:{},mode:4,material:g.material},I=g.GetBounds();l.accessors.push({bufferView:d,byteOffset:0,componentType:this.components.index.type,count:g.indices.length,type:"SCALAR"}),w.indices=l.accessors.length-1,l.accessors.push({bufferView:m,byteOffset:0,componentType:this.components.number.type,count:g.vertices.length/3,min:I.min,max:I.max,type:"VEC3"}),w.attributes.POSITION=l.accessors.length-1,_!==null&&(l.accessors.push({bufferView:_,byteOffset:0,componentType:this.components.number.type,count:g.colors.length/3,type:"VEC3"}),w.attributes.COLOR_0=l.accessors.length-1),l.accessors.push({bufferView:y,byteOffset:0,componentType:this.components.number.type,count:g.normals.length/3,type:"VEC3"}),w.attributes.NORMAL=l.accessors.length-1,x!==null&&(l.accessors.push({bufferView:x,byteOffset:0,componentType:this.components.number.type,count:g.uvs.length/2,type:"VEC2"}),w.attributes.TEXCOORD_0=l.accessors.length-1),h.primitives.push(w)}l.meshes.push(h)}return l}ExportMaterials(e,t,n){function i(s,o,a,l){function c(d,m){return[lr(d.r/255),lr(d.g/255),lr(d.b/255),m]}function u(d){return[lr(d.r/255),lr(d.g/255),lr(d.b/255)]}function h(d,m,_){if(m===null||!m.IsValid())return null;d.images===void 0&&(d.images=[]),d.textures===void 0&&(d.textures=[]);let x={index:_(m)};if(m.HasTransformation()){let w="KHR_texture_transform";d.extensionsUsed===void 0&&(d.extensionsUsed=[]),d.extensionsUsed.indexOf(w)===-1&&d.extensionsUsed.push(w),x.extensions={KHR_texture_transform:{offset:[m.offset.x,-m.offset.y],scale:[m.scale.x,m.scale.y],rotation:-m.rotation}}}return x}let f={name:s.GetExportedMaterialName(a.name),pbrMetallicRoughness:{baseColorFactor:c(a.color,a.opacity)},emissiveFactor:u(a.emissive),doubleSided:!0,alphaMode:"OPAQUE"};a.transparent&&(f.alphaMode="BLEND");let p=h(o,a.diffuseMap,l);if(p!==null&&(a.multiplyDiffuseMap||(f.pbrMetallicRoughness.baseColorFactor=c(new Mt(255,255,255),a.opacity)),f.pbrMetallicRoughness.baseColorTexture=p),a.type===Un.Physical){let d=h(o,a.metalnessMap,l);d!==null?f.pbrMetallicRoughness.metallicRoughnessTexture=d:(f.pbrMetallicRoughness.metallicFactor=a.metalness,f.pbrMetallicRoughness.roughnessFactor=a.roughness)}let g=h(o,a.normalMap,l);g!==null&&(f.normalTexture=g);let v=h(o,a.emissiveMap,l);v!==null&&(f.emissiveTexture=v),o.materials.push(f)}for(let s=0;s<e.MaterialCount();s++){let o=e.GetMaterial(s);i(this,t,o,n)}}};var _l=class{constructor(e){this.transformation=new ln,this.isMeshVisible=t=>!0,co(e,this)}},Ao=class{constructor(e,t){this.model=e,this.settings=t||new _l,this.visibleMeshes=null,this.meshToVisibleMeshIndex=null}GetModel(){return this.model}MaterialCount(){return this.model.MaterialCount()}GetMaterial(e){return this.model.GetMaterial(e)}VertexCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.VertexCount()}),e}TriangleCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.TriangleCount()}),e}MeshCount(){let e=0;return this.EnumerateMeshes(t=>{e+=1}),e}EnumerateMeshes(e){this.FillVisibleMeshCache();for(let t=0;t<this.model.MeshCount();t++)if(this.visibleMeshes.has(t)){let n=this.model.GetMesh(t);e(n)}}MapMeshIndex(e){return this.FillVisibleMeshCache(),this.meshToVisibleMeshIndex.get(e)}IsMeshInstanceVisible(e){return this.settings.isMeshVisible(e)}MeshInstanceCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=1}),e}EnumerateMeshInstances(e){this.model.EnumerateMeshInstances(t=>{this.settings.isMeshVisible(t.GetId())&&e(t)})}EnumerateTransformedMeshInstances(e){this.EnumerateMeshInstances(t=>{let n=t.GetTransformation();this.settings.transformation.IsIdentity()||n.Append(this.settings.transformation);let s=t.GetMesh().Clone();n.IsIdentity()||hr(s,n),e(s)})}EnumerateVerticesAndTriangles(e){let t=[];this.EnumerateTransformedMeshInstances(i=>{t.push(i)});for(let i of t)i.EnumerateVertices(s=>{e.onVertex(s.x,s.y,s.z)});let n=0;for(let i of t)i.EnumerateTriangleVertexIndices((s,o,a)=>{e.onTriangle(s+n,o+n,a+n)}),n+=i.VertexCount()}EnumerateTrianglesWithNormals(e){this.EnumerateTransformedMeshInstances(t=>{t.EnumerateTriangleVertices((n,i,s)=>{let o=Ds(n,i,s);e(n,i,s,o)})})}FillVisibleMeshCache(){if(this.visibleMeshes!==null&&this.meshToVisibleMeshIndex!==null)return;this.visibleMeshes=new Set,this.model.EnumerateMeshInstances(t=>{let n=t.GetId();this.settings.isMeshVisible(n)&&this.visibleMeshes.add(n.meshIndex)}),this.meshToVisibleMeshIndex=new Map;let e=0;for(let t=0;t<this.model.MeshCount();t++)this.visibleMeshes.has(t)&&(this.meshToVisibleMeshIndex.set(t,e),e+=1)}};var oi=class{constructor(){this.text="",this.indentation=0}GetText(){return this.text}Indent(e){this.indentation+=e}WriteArrayLine(e){this.WriteLine(e.join(" "))}WriteLine(e){this.WriteIndentation(),this.Write(e+`
-`)}WriteIndentation(){for(let e=0;e<this.indentation;e++)this.Write(" ")}Write(e){this.text+=e}};var wo=class extends Pn{constructor(){super()}CanExport(e,t){return e===an.Text&&t==="obj"}ExportContent(e,t,n,i){function s(g,v,d,m){if(d===null||!d.IsValid())return;let _=En(d.name);if(g.WriteArrayLine([v,_]),m.findIndex(x=>x.GetName()===_)===-1){let x=new $t(_);x.SetBufferContent(d.buffer),m.push(x)}}let o=new $t("model.mtl"),a=new $t("model.obj");n.push(o),n.push(a);let l=new oi;l.WriteLine(this.GetHeaderText());for(let g=0;g<e.MaterialCount();g++){let v=e.GetMaterial(g);l.WriteArrayLine(["newmtl",this.GetExportedMaterialName(v.name)]),l.WriteArrayLine(["Kd",v.color.r/255,v.color.g/255,v.color.b/255]),l.WriteArrayLine(["d",v.opacity]),v.type===Un.Phong&&(l.WriteArrayLine(["Ka",v.ambient.r/255,v.ambient.g/255,v.ambient.b/255]),l.WriteArrayLine(["Ks",v.specular.r/255,v.specular.g/255,v.specular.b/255]),l.WriteArrayLine(["Ns",v.shininess*1e3])),s(l,"map_Kd",v.diffuseMap,n),v.type===Un.Phong&&s(l,"map_Ks",v.specularMap,n),s(l,"bump",v.bumpMap,n)}o.SetTextContent(l.GetText());let c=new oi;c.WriteLine(this.GetHeaderText()),c.WriteArrayLine(["mtllib",o.GetName()]);let u=0,h=0,f=0,p=null;e.EnumerateTransformedMeshInstances(g=>{c.WriteArrayLine(["g",this.GetExportedMeshName(g.GetName())]);for(let v=0;v<g.VertexCount();v++){let d=g.GetVertex(v);c.WriteArrayLine(["v",d.x,d.y,d.z])}for(let v=0;v<g.NormalCount();v++){let d=g.GetNormal(v);c.WriteArrayLine(["vn",d.x,d.y,d.z])}for(let v=0;v<g.TextureUVCount();v++){let d=g.GetTextureUV(v);c.WriteArrayLine(["vt",d.x,d.y])}for(let v=0;v<g.TriangleCount();v++){let d=g.GetTriangle(v),m=d.v0+u+1,_=d.v1+u+1,y=d.v2+u+1,x=d.n0+h+1,w=d.n1+h+1,I=d.n2+h+1,C="",P="",E="";if(d.HasTextureUVs()&&(C=d.u0+f+1,P=d.u1+f+1,E=d.u2+f+1),d.mat!==null){let M=e.GetMaterial(d.mat),L=this.GetExportedMaterialName(M.name);L!==p&&(c.WriteArrayLine(["usemtl",L]),p=L)}c.WriteArrayLine(["f",[m,C,x].join("/"),[_,P,w].join("/"),[y,E,I].join("/")])}for(let v=0;v<g.LineCount();v++){let d=g.GetLine(v),m=[];for(let _=0;_<d.vertices.length;_++)m.push(d.vertices[_]+u+1);if(d.mat!==null){let _=e.GetMaterial(d.mat),y=this.GetExportedMaterialName(_.name);y!==p&&(c.WriteArrayLine(["usemtl",y]),p=y)}c.WriteArrayLine(["l",m.join(" ")])}u+=g.VertexCount(),h+=g.NormalCount(),f+=g.TextureUVCount()}),a.SetTextContent(c.GetText()),i()}GetHeaderText(){return"# exported by https://3dviewer.net"}};var Co=class extends Pn{constructor(){super()}CanExport(e,t){return e===an.Text&&t==="off"}ExportContent(e,t,n,i){let s=new $t("model.off");n.push(s);let o=new oi;o.WriteLine("OFF"),o.WriteArrayLine([e.VertexCount(),e.TriangleCount(),0]),e.EnumerateVerticesAndTriangles({onVertex:function(a,l,c){o.WriteArrayLine([a,l,c])},onTriangle:function(a,l,c){o.WriteArrayLine([3,a,l,c])}}),s.SetTextContent(o.GetText()),i()}};var Ro=class extends Pn{constructor(){super()}CanExport(e,t){return(e===an.Text||e===an.Binary)&&t==="ply"}ExportContent(e,t,n,i){t===an.Text?this.ExportText(e,n):this.ExportBinary(e,n),i()}ExportText(e,t){let n=new $t("model.ply");t.push(n);let i=new oi,s=e.VertexCount(),o=e.TriangleCount(),a=this.GetHeaderText("ascii",s,o);i.Write(a),e.EnumerateVerticesAndTriangles({onVertex:function(l,c,u){i.WriteArrayLine([l,c,u])},onTriangle:function(l,c,u){i.WriteArrayLine([3,l,c,u])}}),n.SetTextContent(i.GetText())}ExportBinary(e,t){let n=new $t("model.ply");t.push(n);let i=e.VertexCount(),s=e.TriangleCount(),o=this.GetHeaderText("binary_little_endian",i,s),a=o.length+i*3*4+s*(1+3*4),l=new Gi(a,!0);for(let c=0;c<o.length;c++)l.WriteUnsignedCharacter8(o.charCodeAt(c));e.EnumerateVerticesAndTriangles({onVertex:function(c,u,h){l.WriteFloat32(c),l.WriteFloat32(u),l.WriteFloat32(h)},onTriangle:function(c,u,h){l.WriteUnsignedCharacter8(3),l.WriteInteger32(c),l.WriteInteger32(u),l.WriteInteger32(h)}}),n.SetBufferContent(l.GetBuffer())}GetHeaderText(e,t,n){let i=new oi;return i.WriteLine("ply"),i.WriteLine("format "+e+" 1.0"),i.WriteLine("element vertex "+t),i.WriteLine("property float x"),i.WriteLine("property float y"),i.WriteLine("property float z"),i.WriteLine("element face "+n),i.WriteLine("property list uchar int vertex_index"),i.WriteLine("end_header"),i.GetText()}};var Io=class extends Pn{constructor(){super()}CanExport(e,t){return(e===an.Text||e===an.Binary)&&t==="stl"}ExportContent(e,t,n,i){t===an.Text?this.ExportText(e,n):this.ExportBinary(e,n),i()}ExportText(e,t){let n=new $t("model.stl");t.push(n);let i=new oi;i.WriteLine("solid Model"),e.EnumerateTrianglesWithNormals((s,o,a,l)=>{i.WriteArrayLine(["facet","normal",l.x,l.y,l.z]),i.Indent(1),i.WriteLine("outer loop"),i.Indent(1),i.WriteArrayLine(["vertex",s.x,s.y,s.z]),i.WriteArrayLine(["vertex",o.x,o.y,o.z]),i.WriteArrayLine(["vertex",a.x,a.y,a.z]),i.Indent(-1),i.WriteLine("endloop"),i.Indent(-1),i.WriteLine("endfacet")}),i.WriteLine("endsolid Model"),n.SetTextContent(i.GetText())}ExportBinary(e,t){let n=new $t("model.stl");t.push(n);let i=e.TriangleCount(),s=80,o=s+4+i*50,a=new Gi(o,!0);for(let l=0;l<s;l++)a.WriteUnsignedCharacter8(0);a.WriteUnsignedInteger32(i),e.EnumerateTrianglesWithNormals((l,c,u,h)=>{a.WriteFloat32(h.x),a.WriteFloat32(h.y),a.WriteFloat32(h.z),a.WriteFloat32(l.x),a.WriteFloat32(l.y),a.WriteFloat32(l.z),a.WriteFloat32(c.x),a.WriteFloat32(c.y),a.WriteFloat32(c.z),a.WriteFloat32(u.x),a.WriteFloat32(u.y),a.WriteFloat32(u.z),a.WriteUnsignedInteger16(0)}),n.SetBufferContent(a.GetBuffer())}};var qc=class{constructor(){this.exporters=[new wo,new Io,new Ro,new Co,new So,new Mo,new Eo]}AddExporter(e){this.exporters.push(e)}Export(e,t,n,i,s){let o=null;for(let l=0;l<this.exporters.length;l++){let c=this.exporters[l];if(c.CanExport(n,i)){o=c;break}}if(o===null){s.onError();return}let a=new Ao(e,t);o.Export(a,n,l=>{l.length===0?s.onError():s.onSuccess(l)})}};var Fs=class{constructor(e,t){this.min=e,this.max=t}GetMin(){return this.min}GetMax(){return this.max}GetCenter(){return new Xe((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,(this.min.z+this.max.z)/2)}},Po=class{constructor(){this.box=new Fs(new Xe(1/0,1/0,1/0),new Xe(-1/0,-1/0,-1/0)),this.isValid=!1}GetBox(){return this.isValid?this.box:null}AddPoint(e){this.box.min.x=Math.min(this.box.min.x,e.x),this.box.min.y=Math.min(this.box.min.y,e.y),this.box.min.z=Math.min(this.box.min.z,e.z),this.box.max.x=Math.max(this.box.max.x,e.x),this.box.max.y=Math.max(this.box.max.y,e.y),this.box.max.z=Math.max(this.box.max.z,e.z),this.isValid=!0}};var No=class r{constructor(e,t){this.beg=e,this.end=t}Clone(){return new r(this.beg,this.end)}};function Jh(r,e){let t=Jr(r.end,r.beg),n=Jr(e,r.beg),i=dl(t,n),s=dl(t,t);if(wr(s))return r.beg.Clone();let o=i/s;return o=Math.max(0,Math.min(1,o)),new At(r.beg.x+o*t.x,r.beg.y+o*t.y)}function Yc(r,e){let t=Jh(r,e);return Is(t,e)}var Tl=class r{constructor(e,t){this.boundingBox=e,this.level=t,this.pointItems=[],this.childNodes=[]}AddPoint(e,t,n){let i=this.FindNodeForPoint(e);if(i===null||i.FindPointDirectly(e)!==null)return!1;if(i.pointItems.length<n.maxPointsPerNode||i.level>=n.maxTreeDepth)return i.AddPointDirectly(e,t),!0;{i.CreateChildNodes();let s=i.pointItems;i.pointItems=[];for(let o=0;o<s.length;o++){let a=s[o];if(!i.AddPoint(a.point,a.data,n))return!1}return i.AddPoint(e,t,n)}}FindPoint(e){let t=this.FindNodeForPoint(e);return t===null?null:t.FindPointDirectly(e)}AddPointDirectly(e,t){this.pointItems.push({point:e,data:t})}FindPointDirectly(e){for(let t=0;t<this.pointItems.length;t++){let n=this.pointItems[t];if(pi(e,n.point))return n.data}return null}FindNodeForPoint(e){if(!this.IsPointInBounds(e))return null;if(this.childNodes.length===0)return this;for(let t=0;t<this.childNodes.length;t++){let i=this.childNodes[t].FindNodeForPoint(e);if(i!==null)return i}return null}CreateChildNodes(){function e(a,l,c,u,h,f,p){let g=new Fs(new Xe(l,c,u),new Xe(l+h,c+f,u+p));a.childNodes.push(new r(g,a.level+1))}let t=this.boundingBox.min,n=this.boundingBox.GetCenter(),i=(this.boundingBox.max.x-this.boundingBox.min.x)/2,s=(this.boundingBox.max.y-this.boundingBox.min.y)/2,o=(this.boundingBox.max.z-this.boundingBox.min.z)/2;e(this,t.x,t.y,t.z,i,s,o),e(this,n.x,t.y,t.z,i,s,o),e(this,t.x,n.y,t.z,i,s,o),e(this,n.x,n.y,t.z,i,s,o),e(this,t.x,t.y,n.z,i,s,o),e(this,n.x,t.y,n.z,i,s,o),e(this,t.x,n.y,n.z,i,s,o),e(this,n.x,n.y,n.z,i,s,o)}IsPointInBounds(e){return mo(e.x,this.boundingBox.min.x)&&mo(e.y,this.boundingBox.min.y)&&mo(e.z,this.boundingBox.min.z)&&po(e.x,this.boundingBox.max.x)&&po(e.y,this.boundingBox.max.y)&&po(e.z,this.boundingBox.max.z)}},Lo=class{constructor(e,t){this.options={maxPointsPerNode:10,maxTreeDepth:10},t!==void 0&&(t.maxPointsPerNode!==void 0&&(this.options.maxPointsPerNode=t.maxPointsPerNode),t.maxTreeDepth!==void 0&&(this.options.maxTreeDepth=t.maxTreeDepth)),this.rootNode=new Tl(e,0)}AddPoint(e,t){return this.rootNode.AddPoint(e,t,this.options)}FindPoint(e){return this.rootNode.FindPoint(e)}};function rm(r,e,t){let n=e/t;return r*(n*n*(3-2*n))}function sm(r,e,t){return e*r/t}function Kc(r,e,t){let n=e/t,i=n*n;return r*(i/(2*(i-n)+1))}function Oo(r,e,t,n){let i=In(e,r).Normalize(),s=Yn(r,e),o=[];for(let a=0;a<t;a++){let l=n(s,a,t-1);o.push(r.Clone().Offset(i,l))}return o}var Do=class{constructor(e,t,n){this.name=e,this.source=t,this.data=n}};function Zc(r){let e=[];for(let t of r){let n=En(t);e.push(new Do(n,ki.Url,t))}return e}function Jc(r){let e=[];for(let t of r){let n=En(t.name);e.push(new Do(n,ki.File,t))}return e}var Us=class{constructor(e,t,n){this.name=En(e),this.extension=ur(e),this.source=t,this.data=n,this.content=null}SetContent(e){this.content=e}},ks=class{constructor(){this.files=[]}FillFromInputFiles(e){this.files=[];for(let t of e){let n=new Us(t.name,t.source,t.data);this.files.push(n)}}ExtendFromFileList(e){let t=e.GetFiles();for(let n=0;n<t.length;n++){let i=t[n];this.ContainsFileByPath(i.name)||this.files.push(i)}}GetFiles(){return this.files}GetContent(e){Ic(this.files.length,{runTask:(t,n)=>{e.onFileListProgress(t,this.files.length),this.GetFileContent(this.files[t],{onReady:n,onProgress:e.onFileLoadProgress})},onReady:e.onReady})}ContainsFileByPath(e){return this.FindFileByPath(e)!==null}FindFileByPath(e){let t=En(e).toLowerCase();for(let n=0;n<this.files.length;n++){let i=this.files[n];if(i.name.toLowerCase()===t)return i}return null}IsOnlyUrlSource(){if(this.files.length===0)return!1;for(let e=0;e<this.files.length;e++){let t=this.files[e];if(t.source!==ki.Url&&t.source!==ki.Decompressed)return!1}return!0}AddFile(e){this.files.push(e)}GetFileContent(e,t){if(e.content!==null){t.onReady();return}let n=null;if(e.source===ki.Url)n=Fc(e.data,t.onProgress);else if(e.source===ki.File)n=Uc(e.data,t.onProgress);else{t.onReady();return}n.then(i=>{e.SetContent(i)}).catch(()=>{}).finally(()=>{t.onReady()})}};var $h=class{constructor(){this.nextId=0}GenerateId(){let e=this.nextId;return this.nextId+=1,e}},Nn=class{constructor(){this.name="",this.parent=null,this.transformation=new ln,this.childNodes=[],this.meshIndices=[],this.idGenerator=new $h,this.id=this.idGenerator.GenerateId()}IsEmpty(){return this.childNodes.length===0&&this.meshIndices.length===0}IsMeshNode(){return this.childNodes.length===0&&this.meshIndices.length===1}GetId(){return this.id}GetName(){return this.name}SetName(e){this.name=e}HasParent(){return this.parent!==null}GetParent(){return this.parent}GetTransformation(){return this.transformation}GetWorldTransformation(){let e=this.transformation.Clone(),t=this.parent;for(;t!==null;)e.Append(t.transformation),t=t.parent;return e}SetTransformation(e){this.transformation=e}AddChildNode(e){return e.parent=this,e.idGenerator=this.idGenerator,e.id=e.idGenerator.GenerateId(),this.childNodes.push(e),this.childNodes.length-1}RemoveChildNode(e){e.parent=null;let t=this.childNodes.indexOf(e);this.childNodes.splice(t,1)}GetChildNodes(){return this.childNodes}ChildNodeCount(){return this.childNodes.length}GetChildNode(e){return this.childNodes[e]}AddMeshIndex(e){return this.meshIndices.push(e),this.meshIndices.length-1}MeshIndexCount(){return this.meshIndices.length}GetMeshIndex(e){return this.meshIndices[e]}GetMeshIndices(){return this.meshIndices}Enumerate(e){e(this);for(let t of this.childNodes)t.Enumerate(e)}EnumerateChildren(e){for(let t of this.childNodes)e(t),t.EnumerateChildren(e)}EnumerateMeshIndices(e){for(let t of this.meshIndices)e(t);for(let t of this.childNodes)t.EnumerateMeshIndices(e)}};var ns={Unknown:0,Millimeter:1,Centimeter:2,Meter:3,Inch:4,Foot:5};var dr=class extends fr{constructor(){super(),this.unit=ns.Unknown,this.root=new Nn,this.materials=[],this.meshes=[]}GetUnit(){return this.unit}SetUnit(e){this.unit=e}GetRootNode(){return this.root}NodeCount(){let e=0;return this.root.Enumerate(t=>{e+=1}),e-1}MaterialCount(){return this.materials.length}MeshCount(){return this.meshes.length}MeshInstanceCount(){let e=0;return this.root.Enumerate(t=>{e+=t.MeshIndexCount()}),e}VertexCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.VertexCount()}),e}VertexColorCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.VertexColorCount()}),e}NormalCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.NormalCount()}),e}TextureUVCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.TextureUVCount()}),e}LineCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.LineCount()}),e}LineSegmentCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.LineSegmentCount()}),e}TriangleCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.TriangleCount()}),e}AddMaterial(e){return this.materials.push(e),this.materials.length-1}GetMaterial(e){return this.materials[e]}AddMesh(e){return this.meshes.push(e),this.meshes.length-1}AddMeshToRootNode(e){let t=this.AddMesh(e);return this.root.AddMeshIndex(t),t}RemoveMesh(e){this.meshes.splice(e,1),this.root.Enumerate(t=>{for(let n=0;n<t.meshIndices.length;n++)t.meshIndices[n]===e?(t.meshIndices.splice(n,1),n-=1):t.meshIndices[n]>e&&(t.meshIndices[n]-=1)})}GetMesh(e){return this.meshes[e]}GetMeshInstance(e){let t=null;if(this.root.Enumerate(o=>{o.GetId()===e.nodeId&&(t=o)}),t===null||t.GetMeshIndices().indexOf(e.meshIndex)===-1)return null;let i=this.GetMesh(e.meshIndex),s=new bi(t.GetId(),e.meshIndex);return new Nr(s,t,i)}EnumerateMeshes(e){for(let t of this.meshes)e(t)}EnumerateMeshInstances(e){this.root.Enumerate(t=>{for(let n of t.GetMeshIndices()){let i=new bi(t.GetId(),n),s=this.GetMesh(n),o=new Nr(i,t,s);e(o)}})}EnumerateTransformedMeshInstances(e){this.EnumerateMeshInstances(t=>{let n=t.GetTransformedMesh();e(n)})}EnumerateVertices(e){this.EnumerateMeshInstances(t=>{t.EnumerateVertices(e)})}EnumerateTriangleVertexIndices(e){this.EnumerateMeshInstances(t=>{t.EnumerateTriangleVertexIndices(e)})}EnumerateTriangleVertices(e){this.EnumerateMeshInstances(t=>{t.EnumerateTriangleVertices(e)})}};var Ml=class{constructor(){this.edges=[],this.triangles=[]}},El=class{constructor(e,t){this.vertex1=e,this.vertex2=t,this.triangles=[]}},bl=class{constructor(e,t){this.edge=e,this.reversed=t}},Sl=class{constructor(){this.triEdge1=null,this.triEdge2=null,this.triEdge3=null}},Fo=class{constructor(){this.vertices=[],this.edges=[],this.triangleEdges=[],this.triangles=[],this.edgeStartToEndVertexMap=new Map}AddVertex(){return this.vertices.push(new Ml),this.vertices.length-1}AddTriangle(e,t,n){function i(c,u,h){c[u].triangles.push(h)}function s(c,u,h,f){let p=c[h],g=u[f];p.edges.push(g.edge)}function o(c,u,h,f){let p=u[h];c[p.edge].triangles.push(f)}let a=this.triangles.length,l=new Sl;l.triEdge1=this.AddTriangleEdge(e,t),l.triEdge2=this.AddTriangleEdge(t,n),l.triEdge3=this.AddTriangleEdge(n,e),i(this.vertices,e,a),i(this.vertices,t,a),i(this.vertices,n,a),s(this.vertices,this.triangleEdges,e,l.triEdge1),s(this.vertices,this.triangleEdges,t,l.triEdge2),s(this.vertices,this.triangleEdges,n,l.triEdge3),o(this.edges,this.triangleEdges,l.triEdge1,a),o(this.edges,this.triangleEdges,l.triEdge2,a),o(this.edges,this.triangleEdges,l.triEdge3,a),this.triangles.push(l)}AddTriangleEdge(e,t){let n=e,i=t,s=!1;t<e&&(n=t,i=e,s=!0);let o=this.AddEdge(n,i);return this.triangleEdges.push(new bl(o,s)),this.triangleEdges.length-1}AddEdge(e,t){this.edgeStartToEndVertexMap.has(e)||this.edgeStartToEndVertexMap.set(e,[]);let n=this.edgeStartToEndVertexMap.get(e);for(let s=0;s<n.length;s++){let o=n[s];if(o.endVertex===t)return o.edgeIndex}let i=this.edges.length;return n.push({endVertex:t,edgeIndex:i}),this.edges.push(new El(e,t)),i}};function Uo(r){let e=!0;return r.EnumerateMeshInstances(t=>{ts(t)||(e=!1)}),e}function Qh(r){let e=new Po;return r.EnumerateVertices(t=>{e.AddPoint(t)}),e.GetBox()}function ef(r){function e(s,o,a){let l=o.FindPoint(s);return l===null&&(l=a.AddVertex(),o.AddPoint(s,l)),l}let t=Qh(r),n=new Lo(t),i=new Fo;return r.EnumerateTriangleVertices((s,o,a)=>{let l=e(s,n,i),c=e(o,n,i),u=e(a,n,i);i.AddTriangle(l,c,u)}),i}function tf(r){function e(t,n,i){let s=t.triangles[n],o=t.triangleEdges[s.triEdge1],a=t.triangleEdges[s.triEdge2],l=t.triangleEdges[s.triEdge3];return o.edge===i?o.reversed:a.edge===i?a.reversed:l.edge===i?l.reversed:null}if(r instanceof dr){let t=!0;return r.EnumerateMeshInstances(n=>{t&&(t=tf(n))}),t}else{let t=ef(r);for(let n=0;n<t.edges.length;n++){let i=t.edges[n];if(i.triangles.length!==2)return!1;let s=e(t,i.triangles[0],n),o=e(t,i.triangles[1],n);if(s===null||o===null||s===o)return!1}return!0}}function om(r){let e=[];for(let t=0;t<r.MaterialCount();t++){let n=r.GetMaterial(t);n.source!==yn.Model&&!n.vertexColors&&e.push(n)}return e}function am(r,e,t){for(let n=0;n<r.MaterialCount();n++){let i=r.GetMaterial(n);i.source===yn.DefaultFace?i.color=e:i.source===yn.DefaultLine&&(i.color=t)}}var Kt=class r extends fr{constructor(){super(),this.vertices=[],this.vertexColors=[],this.normals=[],this.uvs=[],this.lines=[],this.triangles=[]}VertexCount(){return this.vertices.length}VertexColorCount(){return this.vertexColors.length}NormalCount(){return this.normals.length}TextureUVCount(){return this.uvs.length}LineCount(){return this.lines.length}LineSegmentCount(){let e=0;for(let t of this.lines)e+=t.SegmentCount();return e}TriangleCount(){return this.triangles.length}AddVertex(e){return this.vertices.push(e),this.vertices.length-1}SetVertex(e,t){this.vertices[e]=t}GetVertex(e){return this.vertices[e]}AddVertexColor(e){return this.vertexColors.push(e),this.vertexColors.length-1}SetVertexColor(e,t){this.vertexColors[e]=t}GetVertexColor(e){return this.vertexColors[e]}AddNormal(e){return this.normals.push(e),this.normals.length-1}SetNormal(e,t){this.normals[e]=t}GetNormal(e){return this.normals[e]}AddTextureUV(e){return this.uvs.push(e),this.uvs.length-1}SetTextureUV(e,t){this.uvs[e]=t}GetTextureUV(e){return this.uvs[e]}AddLine(e){return this.lines.push(e),this.lines.length-1}GetLine(e){return this.lines[e]}AddTriangle(e){return this.triangles.push(e),this.triangles.length-1}GetTriangle(e){return this.triangles[e]}EnumerateVertices(e){for(let t of this.vertices)e(t)}EnumerateTriangleVertexIndices(e){for(let t of this.triangles)e(t.v0,t.v1,t.v2)}EnumerateTriangleVertices(e){for(let t of this.triangles){let n=this.vertices[t.v0],i=this.vertices[t.v1],s=this.vertices[t.v2];e(n,i,s)}}Clone(){let e=new r;e.SetName(this.GetName()),this.CloneProperties(e);for(let t=0;t<this.VertexCount();t++){let n=this.GetVertex(t);e.AddVertex(n.Clone())}for(let t=0;t<this.VertexColorCount();t++){let n=this.GetVertexColor(t);e.AddVertexColor(n.Clone())}for(let t=0;t<this.NormalCount();t++){let n=this.GetNormal(t);e.AddNormal(n.Clone())}for(let t=0;t<this.TextureUVCount();t++){let n=this.GetTextureUV(t);e.AddTextureUV(n.Clone())}for(let t=0;t<this.LineCount();t++){let n=this.GetLine(t);e.AddLine(n.Clone())}for(let t=0;t<this.TriangleCount();t++){let n=this.GetTriangle(t);e.AddTriangle(n.Clone())}return e}};var Xt=class r{constructor(e,t,n){this.v0=e,this.v1=t,this.v2=n,this.c0=null,this.c1=null,this.c2=null,this.n0=null,this.n1=null,this.n2=null,this.u0=null,this.u1=null,this.u2=null,this.mat=null,this.curve=null}HasVertices(){return this.v0!==null&&this.v1!==null&&this.v2!==null}HasVertexColors(){return this.c0!==null&&this.c1!==null&&this.c2!==null}HasNormals(){return this.n0!==null&&this.n1!==null&&this.n2!==null}HasTextureUVs(){return this.u0!==null&&this.u1!==null&&this.u2!==null}SetVertices(e,t,n){return this.v0=e,this.v1=t,this.v2=n,this}SetVertexColors(e,t,n){return this.c0=e,this.c1=t,this.c2=n,this}SetNormals(e,t,n){return this.n0=e,this.n1=t,this.n2=n,this}SetTextureUVs(e,t,n){return this.u0=e,this.u1=t,this.u2=n,this}SetMaterial(e){return this.mat=e,this}SetCurve(e){return this.curve=e,this}Clone(){let e=new r(this.v0,this.v1,this.v2);return e.SetVertexColors(this.c0,this.c1,this.c2),e.SetNormals(this.n0,this.n1,this.n2),e.SetTextureUVs(this.u0,this.u1,this.u2),e.SetMaterial(this.mat),e.SetCurve(this.curve),e}};var wd="163";var Ov=0,lm=1,Dv=2;var t0=1,Fv=2,Br=3,wi=0,Tn=1,On=2,us=0,ra=1,cm=2,um=3,hm=4,Uv=5,js=100,kv=101,Bv=102,Gv=103,Vv=104,zv=200,Hv=201,Wv=202,Xv=203,Hf=204,Wf=205,jv=206,qv=207,Yv=208,Kv=209,Zv=210,Jv=211,$v=212,Qv=213,ey=214,ty=0,ny=1,iy=2,Pu=3,ry=4,sy=5,oy=6,ay=7,oh=0,ly=1,cy=2,hs=0,uy=1,hy=2,fy=3,dy=4,py=5,my=6,gy=7,fm="attached",vy="detached",n0=300,ca=301,ua=302,Fl=303,Xf=304,ah=306,rn=1e3,un=1001,ha=1002,Bn=1003,yy=1004;var $c=1005;var bn=1006,nf=1007;var vi=1008;var fs=1009,xy=1010,_y=1011,i0=1012,r0=1013,fa=1014,Vr=1015,Nu=1016,s0=1017,o0=1018,Zl=1020,Ty=35902,My=1021,Ey=1022,Xi=1023,by=1024,Sy=1025,sa=1026,Ul=1027,Ay=1028,a0=1029,wy=1030,l0=1031,c0=1033,rf=33776,sf=33777,of=33778,af=33779,dm=35840,pm=35841,mm=35842,gm=35843,u0=36196,vm=37492,ym=37496,xm=37808,_m=37809,Tm=37810,Mm=37811,Em=37812,bm=37813,Sm=37814,Am=37815,wm=37816,Cm=37817,Rm=37818,Im=37819,Pm=37820,Nm=37821,lf=36492,Lm=36494,Om=36495,Cy=36283,Dm=36284,Fm=36285,Um=36286;var Lu=2300,Ou=2301,cf=2302,km=2400,Bm=2401,Gm=2402,Ry=2500;var Iy=3200,Py=3201,lh=0,Ny=1,cs="",jt="srgb",li="srgb-linear",Cd="display-p3",ch="display-p3-linear",Du="linear",Qt="srgb",Fu="rec709",Uu="p3";var ko=7680;var Vm=519,Ly=512,Oy=513,Dy=514,h0=515,Fy=516,Uy=517,ky=518,By=519,zm=35044;var Hm="300 es",zr=2e3,ku=2001,ps=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let i=this._listeners[e];if(i!==void 0){let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}},zn=["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"],Wm=1234567,oa=Math.PI/180,da=180/Math.PI;function Xr(){let r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(zn[r&255]+zn[r>>8&255]+zn[r>>16&255]+zn[r>>24&255]+"-"+zn[e&255]+zn[e>>8&255]+"-"+zn[e>>16&15|64]+zn[e>>24&255]+"-"+zn[t&63|128]+zn[t>>8&255]+"-"+zn[t>>16&255]+zn[t>>24&255]+zn[n&255]+zn[n>>8&255]+zn[n>>16&255]+zn[n>>24&255]).toLowerCase()}function kn(r,e,t){return Math.max(e,Math.min(t,r))}function Rd(r,e){return(r%e+e)%e}function Gy(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function Vy(r,e,t){return r!==e?(t-r)/(e-r):0}function Nl(r,e,t){return(1-t)*r+t*e}function zy(r,e,t,n){return Nl(r,e,1-Math.exp(-t*n))}function Hy(r,e=1){return e-Math.abs(Rd(r,e*2)-e)}function Wy(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Xy(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function jy(r,e){return r+Math.floor(Math.random()*(e-r+1))}function qy(r,e){return r+Math.random()*(e-r)}function Yy(r){return r*(.5-Math.random())}function Ky(r){r!==void 0&&(Wm=r);let e=Wm+=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 Zy(r){return r*oa}function Jy(r){return r*da}function $y(r){return(r&r-1)===0&&r!==0}function Qy(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function ex(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function tx(r,e,t,n,i){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),f=o((e-n)/2),p=s((n-e)/2),g=o((n-e)/2);switch(i){case"XYX":r.set(a*u,l*h,l*f,a*c);break;case"YZY":r.set(l*f,a*u,l*h,a*c);break;case"ZXZ":r.set(l*h,l*f,a*u,a*c);break;case"XZX":r.set(a*u,l*g,l*p,a*c);break;case"YXY":r.set(l*p,a*u,l*g,a*c);break;case"ZYZ":r.set(l*g,l*p,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ta(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Zn(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}var pn={DEG2RAD:oa,RAD2DEG:da,generateUUID:Xr,clamp:kn,euclideanModulo:Rd,mapLinear:Gy,inverseLerp:Vy,lerp:Nl,damp:zy,pingpong:Hy,smoothstep:Wy,smootherstep:Xy,randInt:jy,randFloat:qy,randFloatSpread:Yy,seededRandom:Ky,degToRad:Zy,radToDeg:Jy,isPowerOfTwo:$y,ceilPowerOfTwo:Qy,floorPowerOfTwo:ex,setQuaternionFromProperEuler:tx,normalize:Zn,denormalize:ta},Ce=class r{constructor(e=0,t=0){r.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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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 n=this.dot(e)/t;return Math.acos(kn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},ft=class r{constructor(e,t,n,i,s,o,a,l,c){r.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,l,c)}set(e,t,n,i,s,o,a,l,c){let u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],h=n[7],f=n[2],p=n[5],g=n[8],v=i[0],d=i[3],m=i[6],_=i[1],y=i[4],x=i[7],w=i[2],I=i[5],C=i[8];return s[0]=o*v+a*_+l*w,s[3]=o*d+a*y+l*I,s[6]=o*m+a*x+l*C,s[1]=c*v+u*_+h*w,s[4]=c*d+u*y+h*I,s[7]=c*m+u*x+h*C,s[2]=f*v+p*_+g*w,s[5]=f*d+p*y+g*I,s[8]=f*m+p*x+g*C,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],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*s*u+n*a*l+i*s*c-i*o*l}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,f=a*l-u*s,p=c*s-o*l,g=t*h+n*f+i*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/g;return e[0]=h*v,e[1]=(i*c-u*n)*v,e[2]=(a*n-i*o)*v,e[3]=f*v,e[4]=(u*t-i*l)*v,e[5]=(i*s-a*t)*v,e[6]=p*v,e[7]=(n*l-c*t)*v,e[8]=(o*t-n*s)*v,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,n,i,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(uf.makeScale(e,t)),this}rotate(e){return this.premultiply(uf.makeRotation(-e)),this}translate(e,t){return this.premultiply(uf.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},uf=new ft;function f0(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function kl(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function nx(){let r=kl("canvas");return r.style.display="block",r}var Xm={};function ix(r){r in Xm||(Xm[r]=!0,console.warn(r))}var jm=new ft().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),qm=new ft().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Qc={[li]:{transfer:Du,primaries:Fu,toReference:r=>r,fromReference:r=>r},[jt]:{transfer:Qt,primaries:Fu,toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[ch]:{transfer:Du,primaries:Uu,toReference:r=>r.applyMatrix3(qm),fromReference:r=>r.applyMatrix3(jm)},[Cd]:{transfer:Qt,primaries:Uu,toReference:r=>r.convertSRGBToLinear().applyMatrix3(qm),fromReference:r=>r.applyMatrix3(jm).convertLinearToSRGB()}},rx=new Set([li,ch]),Bt={enabled:!0,_workingColorSpace:li,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!rx.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;let n=Qc[e].toReference,i=Qc[t].fromReference;return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this._workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this._workingColorSpace)},getPrimaries:function(r){return Qc[r].primaries},getTransfer:function(r){return r===cs?Du:Qc[r].transfer}};function aa(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function hf(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}var Bo,pa=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{Bo===void 0&&(Bo=kl("canvas")),Bo.width=e.width,Bo.height=e.height;let n=Bo.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Bo}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=kl("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=aa(s[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(aa(t[n]/255)*255):t[n]=aa(t[n]);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}},sx=0,Bu=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:sx++}),this.uuid=Xr(),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 n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(ff(i[o].image)):s.push(ff(i[o]))}else s=ff(i);n.url=s}return t||(e.images[this.uuid]=n),n}};function ff(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?pa.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var ox=0,Dn=class r extends ps{constructor(e=r.DEFAULT_IMAGE,t=r.DEFAULT_MAPPING,n=un,i=un,s=bn,o=vi,a=Xi,l=fs,c=r.DEFAULT_ANISOTROPY,u=cs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ox++}),this.uuid=Xr(),this.name="",this.source=new Bu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ce(0,0),this.repeat=new Ce(1,1),this.center=new Ce(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ft,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 n={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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==n0)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case rn:e.x=e.x-Math.floor(e.x);break;case un:e.x=e.x<0?0:1;break;case ha: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 rn:e.y=e.y-Math.floor(e.y);break;case un:e.y=e.y<0?0:1;break;case ha: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++}};Dn.DEFAULT_IMAGE=null;Dn.DEFAULT_MAPPING=n0;Dn.DEFAULT_ANISOTROPY=1;var Ct=class r{constructor(e=0,t=0,n=0,i=1){r.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}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,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+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,n,i,s,l=e.elements,c=l[0],u=l[4],h=l[8],f=l[1],p=l[5],g=l[9],v=l[2],d=l[6],m=l[10];if(Math.abs(u-f)<.01&&Math.abs(h-v)<.01&&Math.abs(g-d)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+v)<.1&&Math.abs(g+d)<.1&&Math.abs(c+p+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let y=(c+1)/2,x=(p+1)/2,w=(m+1)/2,I=(u+f)/4,C=(h+v)/4,P=(g+d)/4;return y>x&&y>w?y<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(y),i=I/n,s=C/n):x>w?x<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(x),n=I/i,s=P/i):w<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),n=C/s,i=P/s),this.set(n,i,s,t),this}let _=Math.sqrt((d-g)*(d-g)+(h-v)*(h-v)+(f-u)*(f-u));return Math.abs(_)<.001&&(_=1),this.x=(d-g)/_,this.y=(h-v)/_,this.z=(f-u)/_,this.w=Math.acos((c+p+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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}},jf=class extends ps{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Ct(0,0,e,t),this.scissorTest=!1,this.viewport=new Ct(0,0,e,t);let i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:bn,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0,count:1},n);let s=new Dn(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;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 n=0,i=e.textures.length;n<i;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new Bu(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Hr=class extends jf{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Gu=class extends Dn{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Bn,this.minFilter=Bn,this.wrapR=un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var qf=class extends Dn{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Bn,this.minFilter=Bn,this.wrapR=un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var sn=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3],f=s[o+0],p=s[o+1],g=s[o+2],v=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=f,e[t+1]=p,e[t+2]=g,e[t+3]=v;return}if(h!==v||l!==f||c!==p||u!==g){let d=1-a,m=l*f+c*p+u*g+h*v,_=m>=0?1:-1,y=1-m*m;if(y>Number.EPSILON){let w=Math.sqrt(y),I=Math.atan2(w,m*_);d=Math.sin(d*I)/w,a=Math.sin(a*I)/w}let x=a*_;if(l=l*d+f*x,c=c*d+p*x,u=u*d+g*x,h=h*d+v*x,d===1-a){let w=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=w,c*=w,u*=w,h*=w}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,o){let a=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=s[o],f=s[o+1],p=s[o+2],g=s[o+3];return e[t]=a*g+u*h+l*p-c*f,e[t+1]=l*g+u*f+c*h-a*p,e[t+2]=c*g+u*p+a*f-l*h,e[t+3]=u*g-a*h-l*f-c*p,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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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 n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(i/2),h=a(s/2),f=l(n/2),p=l(i/2),g=l(s/2);switch(o){case"XYZ":this._x=f*u*h+c*p*g,this._y=c*p*h-f*u*g,this._z=c*u*g+f*p*h,this._w=c*u*h-f*p*g;break;case"YXZ":this._x=f*u*h+c*p*g,this._y=c*p*h-f*u*g,this._z=c*u*g-f*p*h,this._w=c*u*h+f*p*g;break;case"ZXY":this._x=f*u*h-c*p*g,this._y=c*p*h+f*u*g,this._z=c*u*g+f*p*h,this._w=c*u*h-f*p*g;break;case"ZYX":this._x=f*u*h-c*p*g,this._y=c*p*h+f*u*g,this._z=c*u*g-f*p*h,this._w=c*u*h+f*p*g;break;case"YZX":this._x=f*u*h+c*p*g,this._y=c*p*h+f*u*g,this._z=c*u*g-f*p*h,this._w=c*u*h-f*p*g;break;case"XZY":this._x=f*u*h-c*p*g,this._y=c*p*h-f*u*g,this._z=c*u*g+f*p*h,this._w=c*u*h+f*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],f=n+a+h;if(f>0){let p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(o-i)*p}else if(n>a&&n>h){let p=2*Math.sqrt(1+n-a-h);this._w=(u-l)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+c)/p}else if(a>h){let p=2*Math.sqrt(1+a-n-h);this._w=(s-c)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(l+u)/p}else{let p=2*Math.sqrt(1+h-n-a);this._w=(o-i)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(kn(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),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 n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+i*c-s*l,this._y=i*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-i*a,this._w=o*u-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,i=this._y,s=this._z,o=this._w,a=o*e._w+n*e._x+i*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=n,this._y=i,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let p=1-t;return this._w=p*o+t*this._w,this._x=p*n+t*this._x,this._y=p*i+t*this._y,this._z=p*s+t*this._z,this.normalize(),this}let c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,f=Math.sin(t*u)/c;return this._w=o*h+this._w*f,this._x=n*h+this._x*f,this._y=i*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*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}},oe=class r{constructor(e=0,t=0,n=0){r.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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(Ym.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ym.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*i-a*n),u=2*(a*t-s*i),h=2*(s*n-o*t);return this.x=t+l*c+o*h-a*u,this.y=n+l*u+a*c-s*h,this.z=i+l*h+s*u-o*c,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,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return df.copy(this).projectOnVector(e),this.sub(df)}reflect(e){return this.sub(df.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 n=this.dot(e)/t;return Math.acos(kn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},df=new oe,Ym=new sn,ji=class{constructor(e=new oe(1/0,1/0,1/0),t=new oe(-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,n=e.length;t<n;t+=3)this.expandByPoint(zi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(zi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=zi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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 n=e.geometry;if(n!==void 0){let s=n.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,zi):zi.fromBufferAttribute(s,o),zi.applyMatrix4(e.matrixWorld),this.expandByPoint(zi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),eu.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),eu.copy(n.boundingBox)),eu.applyMatrix4(e.matrixWorld),this.union(eu)}let i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[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,zi),zi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Al),tu.subVectors(this.max,Al),Go.subVectors(e.a,Al),Vo.subVectors(e.b,Al),zo.subVectors(e.c,Al),is.subVectors(Vo,Go),rs.subVectors(zo,Vo),Bs.subVectors(Go,zo);let t=[0,-is.z,is.y,0,-rs.z,rs.y,0,-Bs.z,Bs.y,is.z,0,-is.x,rs.z,0,-rs.x,Bs.z,0,-Bs.x,-is.y,is.x,0,-rs.y,rs.x,0,-Bs.y,Bs.x,0];return!pf(t,Go,Vo,zo,tu)||(t=[1,0,0,0,1,0,0,0,1],!pf(t,Go,Vo,zo,tu))?!1:(nu.crossVectors(is,rs),t=[nu.x,nu.y,nu.z],pf(t,Go,Vo,zo,tu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,zi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(zi).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:(Lr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Lr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Lr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Lr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Lr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Lr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Lr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Lr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Lr),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)}},Lr=[new oe,new oe,new oe,new oe,new oe,new oe,new oe,new oe],zi=new oe,eu=new ji,Go=new oe,Vo=new oe,zo=new oe,is=new oe,rs=new oe,Bs=new oe,Al=new oe,tu=new oe,nu=new oe,Gs=new oe;function pf(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Gs.fromArray(r,s);let a=i.x*Math.abs(Gs.x)+i.y*Math.abs(Gs.y)+i.z*Math.abs(Gs.z),l=e.dot(Gs),c=t.dot(Gs),u=n.dot(Gs);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var ax=new ji,wl=new oe,mf=new oe,qi=class{constructor(e=new oe,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 n=this.center;t!==void 0?n.copy(t):ax.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),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 n=this.center.distanceToSquared(e);return t.copy(e),n>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;wl.subVectors(e,this.center);let t=wl.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(wl,i/n),this.radius+=i}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):(mf.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(wl.copy(e.center).add(mf)),this.expandByPoint(wl.copy(e.center).sub(mf))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Or=new oe,gf=new oe,iu=new oe,ss=new oe,vf=new oe,ru=new oe,yf=new oe,Ks=class{constructor(e=new oe,t=new oe(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,Or)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Or.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Or.copy(this.origin).addScaledVector(this.direction,t),Or.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){gf.copy(e).add(t).multiplyScalar(.5),iu.copy(t).sub(e).normalize(),ss.copy(this.origin).sub(gf);let s=e.distanceTo(t)*.5,o=-this.direction.dot(iu),a=ss.dot(this.direction),l=-ss.dot(iu),c=ss.lengthSq(),u=Math.abs(1-o*o),h,f,p,g;if(u>0)if(h=o*l-a,f=o*a-l,g=s*u,h>=0)if(f>=-g)if(f<=g){let v=1/u;h*=v,f*=v,p=h*(h+o*f+2*a)+f*(o*h+f+2*l)+c}else f=s,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*l)+c;else f=-s,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*l)+c;else f<=-g?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+f*(f+2*l)+c):f<=g?(h=0,f=Math.min(Math.max(-s,-l),s),p=f*(f+2*l)+c):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+f*(f+2*l)+c);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(gf).addScaledVector(iu,f),p}intersectSphere(e,t){Or.subVectors(e.center,this.origin);let n=Or.dot(this.direction),i=Or.dot(Or)-n*n,s=e.radius*e.radius;if(i>s)return null;let o=Math.sqrt(s-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o<i||isNaN(i))&&(i=o),h>=0?(a=(e.min.z-f.z)*h,l=(e.max.z-f.z)*h):(a=(e.max.z-f.z)*h,l=(e.min.z-f.z)*h),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Or)!==null}intersectTriangle(e,t,n,i,s){vf.subVectors(t,e),ru.subVectors(n,e),yf.crossVectors(vf,ru);let o=this.direction.dot(yf),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ss.subVectors(this.origin,e);let l=a*this.direction.dot(ru.crossVectors(ss,ru));if(l<0)return null;let c=a*this.direction.dot(vf.cross(ss));if(c<0||l+c>o)return null;let u=-a*ss.dot(yf);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)}},Ye=class r{constructor(e,t,n,i,s,o,a,l,c,u,h,f,p,g,v,d){r.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,n,i,s,o,a,l,c,u,h,f,p,g,v,d)}set(e,t,n,i,s,o,a,l,c,u,h,f,p,g,v,d){let m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=u,m[10]=h,m[14]=f,m[3]=p,m[7]=g,m[11]=v,m[15]=d,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 r().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,i=1/Ho.setFromMatrixColumn(e,0).length(),s=1/Ho.setFromMatrixColumn(e,1).length(),o=1/Ho.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let f=o*u,p=o*h,g=a*u,v=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=p+g*c,t[5]=f-v*c,t[9]=-a*l,t[2]=v-f*c,t[6]=g+p*c,t[10]=o*l}else if(e.order==="YXZ"){let f=l*u,p=l*h,g=c*u,v=c*h;t[0]=f+v*a,t[4]=g*a-p,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=p*a-g,t[6]=v+f*a,t[10]=o*l}else if(e.order==="ZXY"){let f=l*u,p=l*h,g=c*u,v=c*h;t[0]=f-v*a,t[4]=-o*h,t[8]=g+p*a,t[1]=p+g*a,t[5]=o*u,t[9]=v-f*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let f=o*u,p=o*h,g=a*u,v=a*h;t[0]=l*u,t[4]=g*c-p,t[8]=f*c+v,t[1]=l*h,t[5]=v*c+f,t[9]=p*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let f=o*l,p=o*c,g=a*l,v=a*c;t[0]=l*u,t[4]=v-f*h,t[8]=g*h+p,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=p*h+g,t[10]=f-v*h}else if(e.order==="XZY"){let f=o*l,p=o*c,g=a*l,v=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=f*h+v,t[5]=o*u,t[9]=p*h-g,t[2]=g*h-p,t[6]=a*u,t[10]=v*h+f}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(lx,e,cx)}lookAt(e,t,n){let i=this.elements;return mi.subVectors(e,t),mi.lengthSq()===0&&(mi.z=1),mi.normalize(),os.crossVectors(n,mi),os.lengthSq()===0&&(Math.abs(n.z)===1?mi.x+=1e-4:mi.z+=1e-4,mi.normalize(),os.crossVectors(n,mi)),os.normalize(),su.crossVectors(mi,os),i[0]=os.x,i[4]=su.x,i[8]=mi.x,i[1]=os.y,i[5]=su.y,i[9]=mi.y,i[2]=os.z,i[6]=su.z,i[10]=mi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],h=n[5],f=n[9],p=n[13],g=n[2],v=n[6],d=n[10],m=n[14],_=n[3],y=n[7],x=n[11],w=n[15],I=i[0],C=i[4],P=i[8],E=i[12],M=i[1],L=i[5],N=i[9],O=i[13],B=i[2],ie=i[6],$=i[10],te=i[14],W=i[3],ae=i[7],de=i[11],ye=i[15];return s[0]=o*I+a*M+l*B+c*W,s[4]=o*C+a*L+l*ie+c*ae,s[8]=o*P+a*N+l*$+c*de,s[12]=o*E+a*O+l*te+c*ye,s[1]=u*I+h*M+f*B+p*W,s[5]=u*C+h*L+f*ie+p*ae,s[9]=u*P+h*N+f*$+p*de,s[13]=u*E+h*O+f*te+p*ye,s[2]=g*I+v*M+d*B+m*W,s[6]=g*C+v*L+d*ie+m*ae,s[10]=g*P+v*N+d*$+m*de,s[14]=g*E+v*O+d*te+m*ye,s[3]=_*I+y*M+x*B+w*W,s[7]=_*C+y*L+x*ie+w*ae,s[11]=_*P+y*N+x*$+w*de,s[15]=_*E+y*O+x*te+w*ye,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],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],f=e[10],p=e[14],g=e[3],v=e[7],d=e[11],m=e[15];return g*(+s*l*h-i*c*h-s*a*f+n*c*f+i*a*p-n*l*p)+v*(+t*l*p-t*c*f+s*o*f-i*o*p+i*c*u-s*l*u)+d*(+t*c*h-t*a*p-s*o*h+n*o*p+s*a*u-n*c*u)+m*(-i*a*u-t*l*h+t*a*f+i*o*h-n*o*f+n*l*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,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],f=e[10],p=e[11],g=e[12],v=e[13],d=e[14],m=e[15],_=h*d*c-v*f*c+v*l*p-a*d*p-h*l*m+a*f*m,y=g*f*c-u*d*c-g*l*p+o*d*p+u*l*m-o*f*m,x=u*v*c-g*h*c+g*a*p-o*v*p-u*a*m+o*h*m,w=g*h*l-u*v*l-g*a*f+o*v*f+u*a*d-o*h*d,I=t*_+n*y+i*x+s*w;if(I===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let C=1/I;return e[0]=_*C,e[1]=(v*f*s-h*d*s-v*i*p+n*d*p+h*i*m-n*f*m)*C,e[2]=(a*d*s-v*l*s+v*i*c-n*d*c-a*i*m+n*l*m)*C,e[3]=(h*l*s-a*f*s-h*i*c+n*f*c+a*i*p-n*l*p)*C,e[4]=y*C,e[5]=(u*d*s-g*f*s+g*i*p-t*d*p-u*i*m+t*f*m)*C,e[6]=(g*l*s-o*d*s-g*i*c+t*d*c+o*i*m-t*l*m)*C,e[7]=(o*f*s-u*l*s+u*i*c-t*f*c-o*i*p+t*l*p)*C,e[8]=x*C,e[9]=(g*h*s-u*v*s-g*n*p+t*v*p+u*n*m-t*h*m)*C,e[10]=(o*v*s-g*a*s+g*n*c-t*v*c-o*n*m+t*a*m)*C,e[11]=(u*a*s-o*h*s-u*n*c+t*h*c+o*n*p-t*a*p)*C,e[12]=w*C,e[13]=(u*v*i-g*h*i+g*n*f-t*v*f-u*n*d+t*h*d)*C,e[14]=(g*a*i-o*v*i-g*n*l+t*v*l+o*n*d-t*a*d)*C,e[15]=(o*h*i-u*a*i+u*n*l-t*h*l-o*n*f+t*a*f)*C,this}scale(e){let t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+n,u*l-i*o,0,c*l-i*a,u*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,h=a+a,f=s*c,p=s*u,g=s*h,v=o*u,d=o*h,m=a*h,_=l*c,y=l*u,x=l*h,w=n.x,I=n.y,C=n.z;return i[0]=(1-(v+m))*w,i[1]=(p+x)*w,i[2]=(g-y)*w,i[3]=0,i[4]=(p-x)*I,i[5]=(1-(f+m))*I,i[6]=(d+_)*I,i[7]=0,i[8]=(g+y)*C,i[9]=(d-_)*C,i[10]=(1-(f+v))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,s=Ho.set(i[0],i[1],i[2]).length(),o=Ho.set(i[4],i[5],i[6]).length(),a=Ho.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Hi.copy(this);let c=1/s,u=1/o,h=1/a;return Hi.elements[0]*=c,Hi.elements[1]*=c,Hi.elements[2]*=c,Hi.elements[4]*=u,Hi.elements[5]*=u,Hi.elements[6]*=u,Hi.elements[8]*=h,Hi.elements[9]*=h,Hi.elements[10]*=h,t.setFromRotationMatrix(Hi),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o,a=zr){let l=this.elements,c=2*s/(t-e),u=2*s/(n-i),h=(t+e)/(t-e),f=(n+i)/(n-i),p,g;if(a===zr)p=-(o+s)/(o-s),g=-2*o*s/(o-s);else if(a===ku)p=-o/(o-s),g=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,o,a=zr){let l=this.elements,c=1/(t-e),u=1/(n-i),h=1/(o-s),f=(t+e)*c,p=(n+i)*u,g,v;if(a===zr)g=(o+s)*h,v=-2*h;else if(a===ku)g=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=v,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Ho=new oe,Hi=new Ye,lx=new oe(0,0,0),cx=new oe(1,1,1),os=new oe,su=new oe,mi=new oe,Km=new Ye,Zm=new sn,hn=class r{constructor(e=0,t=0,n=0,i=r.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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,n=!0){let i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],h=i[2],f=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(kn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-kn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(kn(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-kn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(kn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-kn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Km.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Km,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Zm.setFromEuler(this),this.setFromQuaternion(Zm,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}};hn.DEFAULT_ORDER="XYZ";var Bl=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}},ux=0,Jm=new oe,Wo=new sn,Dr=new Ye,ou=new oe,Cl=new oe,hx=new oe,fx=new sn,$m=new oe(1,0,0),Qm=new oe(0,1,0),eg=new oe(0,0,1),tg={type:"added"},dx={type:"removed"},Xo={type:"childadded",child:null},xf={type:"childremoved",child:null},Rt=class r extends ps{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ux++}),this.uuid=Xr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=r.DEFAULT_UP.clone();let e=new oe,t=new hn,n=new sn,i=new oe(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._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:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ye},normalMatrix:{value:new ft}}),this.matrix=new Ye,this.matrixWorld=new Ye,this.matrixAutoUpdate=r.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=r.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bl,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 Wo.setFromAxisAngle(e,t),this.quaternion.multiply(Wo),this}rotateOnWorldAxis(e,t){return Wo.setFromAxisAngle(e,t),this.quaternion.premultiply(Wo),this}rotateX(e){return this.rotateOnAxis($m,e)}rotateY(e){return this.rotateOnAxis(Qm,e)}rotateZ(e){return this.rotateOnAxis(eg,e)}translateOnAxis(e,t){return Jm.copy(e).applyQuaternion(this.quaternion),this.position.add(Jm.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($m,e)}translateY(e){return this.translateOnAxis(Qm,e)}translateZ(e){return this.translateOnAxis(eg,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Dr.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ou.copy(e):ou.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),Cl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Dr.lookAt(Cl,ou,this.up):Dr.lookAt(ou,Cl,this.up),this.quaternion.setFromRotationMatrix(Dr),i&&(Dr.extractRotation(i.matrixWorld),Wo.setFromRotationMatrix(Dr),this.quaternion.premultiply(Wo.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(tg),Xo.child=e,this.dispatchEvent(Xo),Xo.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(dx),xf.child=e,this.dispatchEvent(xf),xf.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),Dr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Dr.multiply(e.parent.matrixWorld)),e.applyMatrix4(Dr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(tg),Xo.child=e,this.dispatchEvent(Xo),Xo.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 n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Cl,e,hx),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Cl,fx,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 n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].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 n=0,i=t.length;n<i;n++){let s=t[n];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.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 i=this.children;for(let s=0,o=i.length;s<o;s++){let a=i[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.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()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){let h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),u=o(e.images),h=o(e.shapes),f=o(e.skeletons),p=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=i,n;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}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 n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}};Rt.DEFAULT_UP=new oe(0,1,0);Rt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Wi=new oe,Fr=new oe,_f=new oe,Ur=new oe,jo=new oe,qo=new oe,ng=new oe,Tf=new oe,Mf=new oe,Ef=new oe,Ys=class r{constructor(e=new oe,t=new oe,n=new oe){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Wi.subVectors(e,t),i.cross(Wi);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Wi.subVectors(i,t),Fr.subVectors(n,t),_f.subVectors(e,t);let o=Wi.dot(Wi),a=Wi.dot(Fr),l=Wi.dot(_f),c=Fr.dot(Fr),u=Fr.dot(_f),h=o*c-a*a;if(h===0)return s.set(0,0,0),null;let f=1/h,p=(c*l-a*u)*f,g=(o*u-a*l)*f;return s.set(1-p-g,g,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ur)===null?!1:Ur.x>=0&&Ur.y>=0&&Ur.x+Ur.y<=1}static getInterpolation(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,Ur)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Ur.x),l.addScaledVector(o,Ur.y),l.addScaledVector(a,Ur.z),l)}static isFrontFacing(e,t,n,i){return Wi.subVectors(n,t),Fr.subVectors(e,t),Wi.cross(Fr).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 Wi.subVectors(this.c,this.b),Fr.subVectors(this.a,this.b),Wi.cross(Fr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return r.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return r.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return r.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return r.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return r.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,o,a;jo.subVectors(i,n),qo.subVectors(s,n),Tf.subVectors(e,n);let l=jo.dot(Tf),c=qo.dot(Tf);if(l<=0&&c<=0)return t.copy(n);Mf.subVectors(e,i);let u=jo.dot(Mf),h=qo.dot(Mf);if(u>=0&&h<=u)return t.copy(i);let f=l*h-u*c;if(f<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(jo,o);Ef.subVectors(e,s);let p=jo.dot(Ef),g=qo.dot(Ef);if(g>=0&&p<=g)return t.copy(s);let v=p*c-l*g;if(v<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(n).addScaledVector(qo,a);let d=u*g-p*h;if(d<=0&&h-u>=0&&p-g>=0)return ng.subVectors(s,i),a=(h-u)/(h-u+(p-g)),t.copy(i).addScaledVector(ng,a);let m=1/(d+v+f);return o=v*m,a=f*m,t.copy(n).addScaledVector(jo,o).addScaledVector(qo,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},d0={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},as={h:0,s:0,l:0},au={h:0,s:0,l:0};function bf(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}var Ve=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=jt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Bt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Bt.workingColorSpace){return this.r=e,this.g=t,this.b=n,Bt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Bt.workingColorSpace){if(e=Rd(e,1),t=kn(t,0,1),n=kn(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=bf(o,s,e+1/3),this.g=bf(o,s,e),this.b=bf(o,s,e-1/3)}return Bt.toWorkingColorSpace(this,i),this}setStyle(e,t=jt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=i[1],a=i[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 n(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 n(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 n(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(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=i[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=jt){let n=d0[e.toLowerCase()];return n!==void 0?this.setHex(n,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=aa(e.r),this.g=aa(e.g),this.b=aa(e.b),this}copyLinearToSRGB(e){return this.r=hf(e.r),this.g=hf(e.g),this.b=hf(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=jt){return Bt.fromWorkingColorSpace(Hn.copy(this),e),Math.round(kn(Hn.r*255,0,255))*65536+Math.round(kn(Hn.g*255,0,255))*256+Math.round(kn(Hn.b*255,0,255))}getHexString(e=jt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Bt.workingColorSpace){Bt.fromWorkingColorSpace(Hn.copy(this),t);let n=Hn.r,i=Hn.g,s=Hn.b,o=Math.max(n,i,s),a=Math.min(n,i,s),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case n:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-n)/h+2;break;case s:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=Bt.workingColorSpace){return Bt.fromWorkingColorSpace(Hn.copy(this),t),e.r=Hn.r,e.g=Hn.g,e.b=Hn.b,e}getStyle(e=jt){Bt.fromWorkingColorSpace(Hn.copy(this),e);let t=Hn.r,n=Hn.g,i=Hn.b;return e!==jt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(as),this.setHSL(as.h+e,as.s+t,as.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(as),e.getHSL(au);let n=Nl(as.h,au.h,t),i=Nl(as.s,au.s,t),s=Nl(as.l,au.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,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}},Hn=new Ve;Ve.NAMES=d0;var px=0,Yi=class extends ps{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:px++}),this.uuid=Xr(),this.name="",this.type="Material",this.blending=ra,this.side=wi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Hf,this.blendDst=Wf,this.blendEquation=js,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ve(0,0,0),this.blendAlpha=0,this.depthFunc=Pu,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Vm,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ko,this.stencilZFail=ko,this.stencilZPass=ko,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 n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ra&&(n.blending=this.blending),this.side!==wi&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Hf&&(n.blendSrc=this.blendSrc),this.blendDst!==Wf&&(n.blendDst=this.blendDst),this.blendEquation!==js&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Pu&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Vm&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ko&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ko&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ko&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}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,n=null;if(t!==null){let i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,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++}},Ci=class extends Yi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ve(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 hn,this.combine=oh,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}};var _n=new oe,lu=new Ce,Gn=class{constructor(e,t,n=!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=n,this.usage=zm,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Vr,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return ix("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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)lu.fromBufferAttribute(this,t),lu.applyMatrix3(e),this.setXY(t,lu.x,lu.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.applyMatrix3(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.applyMatrix4(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.applyNormalMatrix(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.transformDirection(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ta(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Zn(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ta(t,this.array)),t}setX(e,t){return this.normalized&&(t=Zn(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ta(t,this.array)),t}setY(e,t){return this.normalized&&(t=Zn(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=ta(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Zn(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=ta(t,this.array)),t}setW(e,t){return this.normalized&&(t=Zn(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Zn(t,this.array),n=Zn(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Zn(t,this.array),n=Zn(n,this.array),i=Zn(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=Zn(t,this.array),n=Zn(n,this.array),i=Zn(i,this.array),s=Zn(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,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!==zm&&(e.usage=this.usage),e}};var ma=class extends Gn{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var Vu=class extends Gn{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var ze=class extends Gn{constructor(e,t,n){super(new Float32Array(e),t,n)}},mx=0,Si=new Ye,Sf=new Rt,Yo=new oe,gi=new ji,Rl=new ji,Ln=new oe,St=class r extends ps{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:mx++}),this.uuid=Xr(),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(f0(e)?Vu:ma)(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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}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 n=this.attributes.normal;if(n!==void 0){let s=new ft().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Si.makeRotationFromQuaternion(e),this.applyMatrix4(Si),this}rotateX(e){return Si.makeRotationX(e),this.applyMatrix4(Si),this}rotateY(e){return Si.makeRotationY(e),this.applyMatrix4(Si),this}rotateZ(e){return Si.makeRotationZ(e),this.applyMatrix4(Si),this}translate(e,t,n){return Si.makeTranslation(e,t,n),this.applyMatrix4(Si),this}scale(e,t,n){return Si.makeScale(e,t,n),this.applyMatrix4(Si),this}lookAt(e){return Sf.lookAt(e),Sf.updateMatrix(),this.applyMatrix4(Sf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Yo).negate(),this.translate(Yo.x,Yo.y,Yo.z),this}setFromPoints(e){let t=[];for(let n=0,i=e.length;n<i;n++){let s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new ze(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ji);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 oe(-1/0,-1/0,-1/0),new oe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let s=t[n];gi.setFromBufferAttribute(s),this.morphTargetsRelative?(Ln.addVectors(this.boundingBox.min,gi.min),this.boundingBox.expandByPoint(Ln),Ln.addVectors(this.boundingBox.max,gi.max),this.boundingBox.expandByPoint(Ln)):(this.boundingBox.expandByPoint(gi.min),this.boundingBox.expandByPoint(gi.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 qi);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 oe,1/0);return}if(e){let n=this.boundingSphere.center;if(gi.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];Rl.setFromBufferAttribute(a),this.morphTargetsRelative?(Ln.addVectors(gi.min,Rl.min),gi.expandByPoint(Ln),Ln.addVectors(gi.max,Rl.max),gi.expandByPoint(Ln)):(gi.expandByPoint(Rl.min),gi.expandByPoint(Rl.max))}gi.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)Ln.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Ln));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Ln.fromBufferAttribute(a,c),l&&(Yo.fromBufferAttribute(e,c),Ln.add(Yo)),i=Math.max(i,n.distanceToSquared(Ln))}this.boundingSphere.radius=Math.sqrt(i),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 n=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Gn(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],l=[];for(let P=0;P<n.count;P++)a[P]=new oe,l[P]=new oe;let c=new oe,u=new oe,h=new oe,f=new Ce,p=new Ce,g=new Ce,v=new oe,d=new oe;function m(P,E,M){c.fromBufferAttribute(n,P),u.fromBufferAttribute(n,E),h.fromBufferAttribute(n,M),f.fromBufferAttribute(s,P),p.fromBufferAttribute(s,E),g.fromBufferAttribute(s,M),u.sub(c),h.sub(c),p.sub(f),g.sub(f);let L=1/(p.x*g.y-g.x*p.y);isFinite(L)&&(v.copy(u).multiplyScalar(g.y).addScaledVector(h,-p.y).multiplyScalar(L),d.copy(h).multiplyScalar(p.x).addScaledVector(u,-g.x).multiplyScalar(L),a[P].add(v),a[E].add(v),a[M].add(v),l[P].add(d),l[E].add(d),l[M].add(d))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let P=0,E=_.length;P<E;++P){let M=_[P],L=M.start,N=M.count;for(let O=L,B=L+N;O<B;O+=3)m(e.getX(O+0),e.getX(O+1),e.getX(O+2))}let y=new oe,x=new oe,w=new oe,I=new oe;function C(P){w.fromBufferAttribute(i,P),I.copy(w);let E=a[P];y.copy(E),y.sub(w.multiplyScalar(w.dot(E))).normalize(),x.crossVectors(I,E);let L=x.dot(l[P])<0?-1:1;o.setXYZW(P,y.x,y.y,y.z,L)}for(let P=0,E=_.length;P<E;++P){let M=_[P],L=M.start,N=M.count;for(let O=L,B=L+N;O<B;O+=3)C(e.getX(O+0)),C(e.getX(O+1)),C(e.getX(O+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Gn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,p=n.count;f<p;f++)n.setXYZ(f,0,0,0);let i=new oe,s=new oe,o=new oe,a=new oe,l=new oe,c=new oe,u=new oe,h=new oe;if(e)for(let f=0,p=e.count;f<p;f+=3){let g=e.getX(f+0),v=e.getX(f+1),d=e.getX(f+2);i.fromBufferAttribute(t,g),s.fromBufferAttribute(t,v),o.fromBufferAttribute(t,d),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),a.fromBufferAttribute(n,g),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,d),a.add(u),l.add(u),c.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(d,c.x,c.y,c.z)}else for(let f=0,p=t.count;f<p;f+=3)i.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ln.fromBufferAttribute(e,t),Ln.normalize(),e.setXYZ(t,Ln.x,Ln.y,Ln.z)}toNonIndexed(){function e(a,l){let c=a.array,u=a.itemSize,h=a.normalized,f=new c.constructor(l.length*u),p=0,g=0;for(let v=0,d=l.length;v<d;v++){a.isInterleavedBufferAttribute?p=l[v]*a.data.stride+a.offset:p=l[v]*u;for(let m=0;m<u;m++)f[g++]=c[p++]}return new Gn(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new r,n=this.index.array,i=this.attributes;for(let a in i){let l=i[a],c=e(l,n);t.setAttribute(a,c)}let s=this.morphAttributes;for(let a in s){let l=[],c=s[a];for(let u=0,h=c.length;u<h;u++){let f=c[u],p=e(f,n);l.push(p)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.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 l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);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 n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let i={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let h=0,f=c.length;h<f;h++){let p=c[h];u.push(p.toJSON(e.data))}u.length>0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,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 n=e.index;n!==null&&this.setIndex(n.clone(t));let i=e.attributes;for(let c in i){let u=i[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],h=s[c];for(let f=0,p=h.length;f<p;f++)u.push(h[f].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,u=o.length;c<u;c++){let h=o[c];this.addGroup(h.start,h.count,h.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},ig=new Ye,Vs=new Ks,cu=new qi,rg=new oe,Ko=new oe,Zo=new oe,Jo=new oe,Af=new oe,uu=new oe,hu=new Ce,fu=new Ce,du=new Ce,sg=new oe,og=new oe,ag=new oe,pu=new oe,mu=new oe,Pt=class extends Rt{constructor(e=new St,t=new Ci){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,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let a=this.morphTargetInfluences;if(s&&a){uu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){let u=a[l],h=s[l];u!==0&&(Af.fromBufferAttribute(h,e),o?uu.addScaledVector(Af,u):uu.addScaledVector(Af.sub(t),u))}t.add(uu)}return t}raycast(e,t){let n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),cu.copy(n.boundingSphere),cu.applyMatrix4(s),Vs.copy(e.ray).recast(e.near),!(cu.containsPoint(Vs.origin)===!1&&(Vs.intersectSphere(cu,rg)===null||Vs.origin.distanceToSquared(rg)>(e.far-e.near)**2))&&(ig.copy(s).invert(),Vs.copy(e.ray).applyMatrix4(ig),!(n.boundingBox!==null&&Vs.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Vs)))}_computeIntersections(e,t,n){let i,s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,v=f.length;g<v;g++){let d=f[g],m=o[d.materialIndex],_=Math.max(d.start,p.start),y=Math.min(a.count,Math.min(d.start+d.count,p.start+p.count));for(let x=_,w=y;x<w;x+=3){let I=a.getX(x),C=a.getX(x+1),P=a.getX(x+2);i=gu(this,m,e,n,c,u,h,I,C,P),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=d.materialIndex,t.push(i))}}else{let g=Math.max(0,p.start),v=Math.min(a.count,p.start+p.count);for(let d=g,m=v;d<m;d+=3){let _=a.getX(d),y=a.getX(d+1),x=a.getX(d+2);i=gu(this,o,e,n,c,u,h,_,y,x),i&&(i.faceIndex=Math.floor(d/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,v=f.length;g<v;g++){let d=f[g],m=o[d.materialIndex],_=Math.max(d.start,p.start),y=Math.min(l.count,Math.min(d.start+d.count,p.start+p.count));for(let x=_,w=y;x<w;x+=3){let I=x,C=x+1,P=x+2;i=gu(this,m,e,n,c,u,h,I,C,P),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=d.materialIndex,t.push(i))}}else{let g=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let d=g,m=v;d<m;d+=3){let _=d,y=d+1,x=d+2;i=gu(this,o,e,n,c,u,h,_,y,x),i&&(i.faceIndex=Math.floor(d/3),t.push(i))}}}};function gx(r,e,t,n,i,s,o,a){let l;if(e.side===Tn?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,e.side===wi,a),l===null)return null;mu.copy(a),mu.applyMatrix4(r.matrixWorld);let c=t.ray.origin.distanceTo(mu);return c<t.near||c>t.far?null:{distance:c,point:mu.clone(),object:r}}function gu(r,e,t,n,i,s,o,a,l,c){r.getVertexPosition(a,Ko),r.getVertexPosition(l,Zo),r.getVertexPosition(c,Jo);let u=gx(r,e,t,n,Ko,Zo,Jo,pu);if(u){i&&(hu.fromBufferAttribute(i,a),fu.fromBufferAttribute(i,l),du.fromBufferAttribute(i,c),u.uv=Ys.getInterpolation(pu,Ko,Zo,Jo,hu,fu,du,new Ce)),s&&(hu.fromBufferAttribute(s,a),fu.fromBufferAttribute(s,l),du.fromBufferAttribute(s,c),u.uv1=Ys.getInterpolation(pu,Ko,Zo,Jo,hu,fu,du,new Ce)),o&&(sg.fromBufferAttribute(o,a),og.fromBufferAttribute(o,l),ag.fromBufferAttribute(o,c),u.normal=Ys.getInterpolation(pu,Ko,Zo,Jo,sg,og,ag,new oe),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let h={a,b:l,c,normal:new oe,materialIndex:0};Ys.getNormal(Ko,Zo,Jo,h.normal),u.face=h}return u}var Zs=class r extends St{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};let a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],u=[],h=[],f=0,p=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new ze(c,3)),this.setAttribute("normal",new ze(u,3)),this.setAttribute("uv",new ze(h,2));function g(v,d,m,_,y,x,w,I,C,P,E){let M=x/C,L=w/P,N=x/2,O=w/2,B=I/2,ie=C+1,$=P+1,te=0,W=0,ae=new oe;for(let de=0;de<$;de++){let ye=de*L-O;for(let Me=0;Me<ie;Me++){let ve=Me*M-N;ae[v]=ve*_,ae[d]=ye*y,ae[m]=B,c.push(ae.x,ae.y,ae.z),ae[v]=0,ae[d]=0,ae[m]=I>0?1:-1,u.push(ae.x,ae.y,ae.z),h.push(Me/C),h.push(1-de/P),te+=1}}for(let de=0;de<P;de++)for(let ye=0;ye<C;ye++){let Me=f+ye+ie*de,ve=f+ye+ie*(de+1),R=f+(ye+1)+ie*(de+1),T=f+(ye+1)+ie*de;l.push(Me,ve,T),l.push(ve,R,T),W+=6}a.addGroup(p,W,E),p+=W,f+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function ga(r){let e={};for(let t in r){e[t]={};for(let n in r[t]){let i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Jn(r){let e={};for(let t=0;t<r.length;t++){let n=ga(r[t]);for(let i in n)e[i]=n[i]}return e}function vx(r){let e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function p0(r){let e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Bt.workingColorSpace}var yx={clone:ga,merge:Jn},xx=`void main() {
+`,n);t(r.substring(n),e)}function pd(r){return(r&r-1)===0}function ug(r){if(pd(r))return r;let e=Math.pow(2,Math.ceil(Math.log(r)/Math.log(2)));return parseInt(e,10)}function pi(r){r.transparent=!1,Bo(r.opacity,1)&&(r.transparent=!0)}var di=class{constructor(e){this.model=e,this.colorToMaterialIndex=new Map}GetMaterialIndex(e,t,n,i){let s=In(e)+In(t)+In(n),o=i!=null;if(o&&(s+=In(i)),this.colorToMaterialIndex.has(s))return this.colorToMaterialIndex.get(s);{let a=new En;a.name=s.toUpperCase(),a.color=new St(e,t,n),o&&i<255&&(a.opacity=i/255,pi(a));let l=this.model.AddMaterial(a);return this.colorToMaterialIndex.set(s,l),l}}},vu=null;function Wo(r){return new Promise((e,t)=>{if(vu!==null){e(new Worker(vu));return}let n="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.22/dist/";fetch(n+"occt-import-js-worker.js").then(i=>i.ok?i.text():t()).then(i=>{i=i.replace("occt-import-js.js",n+"occt-import-js.js"),i=i.replace("return path","return '"+n+"occt-import-js.wasm'");let s=new Blob([i],{type:"text/javascript"});return vu=URL.createObjectURL(s),e(new Worker(vu))}).catch(t)})}function _r(r){return r==="rhino3dm"?Ho("https://cdn.jsdelivr.net/npm/rhino3dm@8.17.0/rhino3dm.min.js"):r==="webifc"?Ho("https://cdn.jsdelivr.net/npm/web-ifc@0.0.68/web-ifc-api-iife.js"):r==="draco3d"?Ho("https://cdn.jsdelivr.net/npm/draco3d@1.5.7/draco_decoder_nodejs.min.js"):null}var Ki={Url:1,File:2,Decompressed:3},dn={Text:1,Binary:2};function Rn(r){let e=r,t=e.indexOf("?");t!==-1&&(e=e.substring(0,t));let n=e.lastIndexOf("/");return n===-1&&(n=e.lastIndexOf("\\")),n!==-1&&(e=e.substring(n+1)),decodeURI(e)}function Tr(r){let e=Rn(r),t=e.lastIndexOf(".");return t===-1?"":e.substring(t+1).toLowerCase()}function _u(r,e){return new Promise((t,n)=>{let i=new XMLHttpRequest;i.open("GET",r,!0),i.onprogress=s=>{e(s.loaded,s.total)},i.onload=()=>{i.status===200?t(i.response):n()},i.onerror=()=>{n()},i.responseType="arraybuffer",i.send(null)})}function Tu(r,e){return new Promise((t,n)=>{let i=new FileReader;i.onprogress=s=>{e(s.loaded,s.total)},i.onloadend=s=>{s.target.readyState===FileReader.DONE&&t(s.target.result)},i.onerror=()=>{n()},i.readAsArrayBuffer(r)})}function Mu(r){for(let e=0;e<r.length;e++){let t=r[e];t.indexOf("www.dropbox.com")!==-1?(t=t.replace("www.dropbox.com","dl.dropbox.com"),r[e]=t):t.indexOf("github.com")!==-1&&(t=t.replace("github.com","raw.githubusercontent.com"),t=t.replace("/blob",""),r[e]=t)}}function hg(r){let e=/^https?:\/\/\S+$/g;return r.match(e)!==null}var Ye=class r{constructor(e,t,n){this.x=e,this.y=t,this.z=n}Length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}MultiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}Normalize(){let e=this.Length();return e>0&&this.MultiplyScalar(1/e),this}Offset(e,t){let n=e.Clone().Normalize();return this.x+=n.x*t,this.y+=n.y*t,this.z+=n.z*t,this}Rotate(e,t,n){let i=e.Clone().Normalize(),s=i.x,o=i.y,a=i.z,l=this.x-n.x,c=this.y-n.y,u=this.z-n.z,h=Math.sin(t),f=Math.cos(t);return this.x=-s*(-s*l-o*c-a*u)*(1-f)+l*f+(-a*c+o*u)*h,this.y=-o*(-s*l-o*c-a*u)*(1-f)+c*f+(a*l-s*u)*h,this.z=-a*(-s*l-o*c-a*u)*(1-f)+u*f+(-o*l+s*c)*h,this.x+=n.x,this.y+=n.y,this.z+=n.z,this}Clone(){return new r(this.x,this.y,this.z)}};function bi(r,e){return Ut(r.x,e.x)&&Ut(r.y,e.y)&&Ut(r.z,e.z)}function Eu(r,e){return new Ye(r.x+e.x,r.y+e.y,r.z+e.z)}function Un(r,e){return new Ye(r.x-e.x,r.y-e.y,r.z-e.z)}function ni(r,e){return Math.sqrt((r.x-e.x)*(r.x-e.x)+(r.y-e.y)*(r.y-e.y)+(r.z-e.z)*(r.z-e.z))}function Nl(r,e){return r.x*e.x+r.y*e.y+r.z*e.z}function bu(r,e){let t=r.Clone().Normalize(),n=e.Clone().Normalize();if(bi(t,n))return 0;let i=Nl(t,n);return Math.acos(i)}function Zi(r,e){let t=new Ye(0,0,0);return t.x=r.y*e.z-r.z*e.y,t.y=r.z*e.x-r.x*e.z,t.z=r.x*e.y-r.y*e.x,t}function Xo(r,e,t){return Math.sqrt(r*r+e*e+t*t)}function Ui(r){return new Ye(r[0],r[1],r[2])}var Ll=class{constructor(){this.indices=[],this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.material=null}GetBounds(){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let n=0;n<this.vertices.length/3;n++)for(let i=0;i<3;i++)e[i]=Math.min(e[i],this.vertices[n*3+i]),t[i]=Math.max(t[i],this.vertices[n*3+i]);return{min:e,max:t}}GetByteLength(e,t){let n=this.indices.length,i=this.vertices.length+this.colors.length+this.normals.length+this.uvs.length;return n*e+i*t}},Ol=class{constructor(){this.primitives=[]}PrimitiveCount(){return this.primitives.length}GetPrimitive(e){return this.primitives[e]}GetByteLength(e,t){let n=0;for(let i=0;i<this.primitives.length;i++){let s=this.primitives[i];n+=s.GetByteLength(e,t)}return n}};function qo(r){function e(a,l,c,u){function h(y,d,m){return d!==null?y.GetVertexColor(d):m?new St(0,0,0):null}function f(y,d,m){return d!==null?y.GetTextureUV(d):m?new Nt(0,0):null}function p(y,d,m){let _=y.VertexColorCount()>0,v=y.TextureUVCount()>0,x=y.GetVertex(d.vertex),S=y.GetNormal(d.normal),I=m.vertices.length/3;m.indices.push(I),m.vertices.push(x.x,x.y,x.z);let A=h(y,d.color,_);A!==null&&m.colors.push(A.r/255,A.g/255,A.b/255),m.normals.push(S.x,S.y,S.z);let C=f(y,d.uv,v);return C!==null&&m.uvs.push(C.x,C.y),{index:I,color:A,normal:S,uv:C}}function g(y,d,m){function _(S,I,A){if(A===null&&I===null)return!0;let C=h(S,I,!0);return Vr(A,C)}function v(S,I,A){let C=S.GetNormal(I);return bi(A,C)}function x(S,I,A){if(A===null&&I===null)return!0;let C=f(S,I,!0);return ji(A,C)}for(let S=0;S<d.length;S++){let I=d[S],A=_(y,m.color,I.color),C=v(y,m.normal,I.normal),E=x(y,m.uv,I.uv);if(A&&C&&E)return I}return null}if(u.has(l.vertex)){let y=u.get(l.vertex),d=g(a,y,l);if(d!==null)c.indices.push(d.index);else{let m=p(a,l,c);y.push(m)}}else{let y=p(a,l,c);u.set(l.vertex,[y])}}let t=new Ol,n=r.TriangleCount();if(n===0)return null;let i=[];for(let a=0;a<n;a++)i.push(a);i.sort((a,l)=>{let c=r.GetTriangle(a),u=r.GetTriangle(l);return c.mat-u.mat});let s=null,o=null;for(let a=0;a<i.length;a++){let l=i[a],c=r.GetTriangle(l);(s===null||s.material!==c.mat)&&(s=new Ll,s.material=c.mat,o=new Map,t.primitives.push(s));let u={vertex:c.v0,color:c.c0,normal:c.n0,uv:c.u0},h={vertex:c.v1,color:c.c1,normal:c.n1,uv:c.u1},f={vertex:c.v2,color:c.c2,normal:c.n2,uv:c.u2};e(r,u,s,o),e(r,h,s,o),e(r,f,s,o)}return t}function Sn(r){return new TextDecoder("utf-8").decode(r)}function fg(r){let e="",t=new Uint8Array(r);for(let n=0;n<t.byteLength;n++)e+=String.fromCharCode(t[n]);return e}function dg(r){let e=new ArrayBuffer(r.length),t=new Uint8Array(e);for(let n=0;n<r.length;n++)t[n]=r.charCodeAt(n);return e}function jo(r){return new TextEncoder().encode(r).buffer}function qs(r){let e="data:";if(!r.startsWith(e))return null;let t=r.indexOf(";");if(t===-1)return null;let n=r.indexOf(",");if(n===-1)return null;let i=r.substring(e.length,e.length+t-5),s=atob(r.substring(n+1)),o=new ArrayBuffer(s.length),a=new Uint8Array(o);for(let l=0;l<s.length;l++)a[l]=s.charCodeAt(l);return{mimeType:i,buffer:o}}function xs(r){if(r==null)return"";let e=r.split("/");return e.length===0?"":e[e.length-1]}function js(r){let e=new Blob([r]);return URL.createObjectURL(e)}function Su(r,e){let t=new Blob([r],{type:e});return URL.createObjectURL(t)}function Au(r){URL.revokeObjectURL(r)}var sn=class{constructor(e){this.name=e,this.content=null}GetName(){return this.name}SetName(e){this.name=e}GetTextContent(){return Sn(this.content)}GetBufferContent(){return this.content}SetTextContent(e){let t=jo(e);this.content=t}SetBufferContent(e){this.content=e}},kn=class{constructor(){}CanExport(e,t){return!1}Export(e,t,n){let i=[];this.ExportContent(e,t,i,()=>{n(i)})}ExportContent(e,t,n,i){}GetExportedMaterialName(e){return this.GetExportedName(e,nt("Material"))}GetExportedMeshName(e){return this.GetExportedName(e,nt("Mesh"))}GetExportedName(e,t){return e.length===0?t:e}};var Yo=class extends kn{constructor(){super(),this.rhino=null}CanExport(e,t){return e===dn.Binary&&t==="3dm"}ExportContent(e,t,n,i){this.rhino===null?_r("rhino3dm").then(()=>{rhino3dm().then(s=>{this.rhino=s,this.ExportRhinoContent(e,n,i)})}).catch(()=>{i()}):this.ExportRhinoContent(e,n,i)}ExportRhinoContent(e,t,n){function i(c){return{r:c.r,g:c.g,b:c.b,a:255}}let s=new sn("model.3dm");t.push(s);let o=new this.rhino.File3dm;e.EnumerateTransformedMeshInstances(c=>{let u=qo(c);for(let h=0;h<u.PrimitiveCount();h++){let f=u.GetPrimitive(h),p={data:{attributes:{position:{itemSize:3,type:"Float32Array",array:f.vertices},normal:{itemSize:3,type:"Float32Array",array:f.normals}},index:{type:"Uint16Array",array:f.indices}}},g=e.GetMaterial(f.material),y=new this.rhino.Material;y.name=this.GetExportedMaterialName(g.name),g.type===Wn.Phong&&(y.ambientColor=i(g.ambient),y.specularColor=i(g.specular)),y.diffuseColor=i(g.color),y.transparency=1-g.opacity;let d=o.materials().count;o.materials().add(y);let m=new this.rhino.Mesh.createFromThreejsJSON(p),_=new this.rhino.ObjectAttributes;_.name=this.GetExportedMeshName(c.GetName()),_.materialSource=this.rhino.ObjectMaterialSource.MaterialFromObject,_.materialIndex=d,o.objects().add(m,_)}});let a=new this.rhino.File3dmWriteOptions;a.version=6;let l=o.toByteArrayOptions(a);s.SetBufferContent(l),n()}};var Yt={Text:1,Integer:2,Number:3,Boolean:4,Percent:5,Color:6},cn=class r{constructor(e,t,n){this.type=e,this.name=t,this.value=n}Clone(){return this.type===Yt.Color?new r(this.type,this.name,this.value.Clone()):new r(this.type,this.name,this.value)}},Kn=class r{constructor(e){this.name=e,this.properties=[]}PropertyCount(){return this.properties.length}AddProperty(e){this.properties.push(e)}GetProperty(e){return this.properties[e]}Clone(){let e=new r(this.name);for(let t of this.properties)e.AddProperty(t.Clone());return e}};function wu(r){return r.type===Yt.Text?hu(r.value):r.type===Yt.Integer?r.value.toLocaleString():r.type===Yt.Number?r.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):r.type===Yt.Boolean?r.value?nt("True"):nt("False"):r.type===Yt.Percent?parseInt(r.value*100,10).toString()+"%":r.type===Yt.Color?"#"+xu(r.value):null}function Wx(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Ko=class extends kn{constructor(){super()}CanExport(e,t){return e===dn.Text&&t==="bim"}ExportContent(e,t,n,i){let s={schema_version:"1.1.0",meshes:[],elements:[],info:{}};this.ExportProperties(e.GetModel(),s.info);let o=0;e.EnumerateTransformedMeshInstances(l=>{let c={mesh_id:o,coordinates:[],indices:[]};l.EnumerateVertices(g=>{c.coordinates.push(g.x,g.y,g.z)}),l.EnumerateTriangleVertexIndices((g,y,d)=>{c.indices.push(g,y,d)});let u={mesh_id:o,type:"Other",color:{r:200,g:200,b:200,a:255},vector:{x:0,y:0,z:0},rotation:{qx:0,qy:0,qz:0,qw:1},guid:Wx(),info:{}},h=null,f=!0,p=[];for(let g=0;g<l.TriangleCount();g++){let y=l.GetTriangle(g),d=e.GetMaterial(y.mat),m={r:Math.round(d.color.r),g:Math.round(d.color.g),b:Math.round(d.color.b),a:Fn(d.opacity)};p.push(m.r,m.g,m.b,m.a),f&&(h===null?h=m:(h.r!==m.r||h.g!==m.g||h.b!==m.b||h.a!==m.a)&&(f=!1,h=null))}f?u.color=h:u.face_colors=p,u.info.Name=l.GetName(),this.ExportProperties(l,u.info),s.meshes.push(c),s.elements.push(u),o+=1});let a=new sn("model.bim");a.SetTextContent(JSON.stringify(s,null,4)),n.push(a),i()}ExportProperties(e,t){for(let n=0;n<e.PropertyGroupCount();n++){let i=e.GetPropertyGroup(n);for(let s=0;s<i.PropertyCount();s++){let o=i.GetProperty(s);t[o.name]=wu(o)}}}};var Ji=class{constructor(e,t){this.arrayBuffer=new ArrayBuffer(e),this.dataView=new DataView(this.arrayBuffer),this.isLittleEndian=t,this.position=0}GetPosition(){return this.position}SetPosition(e){this.position=e}End(){return this.position>=this.arrayBuffer.byteLength}GetBuffer(){return this.arrayBuffer}WriteArrayBuffer(e){let t=new Uint8Array(e);new Uint8Array(this.arrayBuffer).set(t,this.position),this.position+=e.byteLength}WriteBoolean8(e){this.dataView.setInt8(this.position,e?1:0),this.position=this.position+1}WriteCharacter8(e){this.dataView.setInt8(this.position,e),this.position=this.position+1}WriteUnsignedCharacter8(e){this.dataView.setUint8(this.position,e),this.position=this.position+1}WriteInteger16(e){this.dataView.setInt16(this.position,e,this.isLittleEndian),this.position=this.position+2}WriteUnsignedInteger16(e){this.dataView.setUint16(this.position,e,this.isLittleEndian),this.position=this.position+2}WriteInteger32(e){this.dataView.setInt32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteUnsignedInteger32(e){this.dataView.setUint32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteFloat32(e){this.dataView.setFloat32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteDouble64(e){this.dataView.setFloat64(this.position,e,this.isLittleEndian),this.position=this.position+8}};var $i=class r{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.w=i}Clone(){return new r(this.x,this.y,this.z,this.w)}};var ii=class{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.w=i}};function pg(r,e){return Ut(r.x,e.x)&&Ut(r.y,e.y)&&Ut(r.z,e.z)&&Ut(r.w,e.w)}function Zo(r){return new ii(r[0],r[1],r[2],r[3])}function Cu(r,e){let t=e/2,n=Math.sin(t);return new ii(r.x*n,r.y*n,r.z*n,Math.cos(t))}function mg(r,e,t,n){let i=Math.cos(r/2),s=Math.cos(e/2),o=Math.cos(t/2),a=Math.sin(r/2),l=Math.sin(e/2),c=Math.sin(t/2),u=new ii(0,0,0,1);if(n==="XYZ")u.x=a*s*o+i*l*c,u.y=i*l*o-a*s*c,u.z=i*s*c+a*l*o,u.w=i*s*o-a*l*c;else if(n==="YXZ")u.x=a*s*o+i*l*c,u.y=i*l*o-a*s*c,u.z=i*s*c-a*l*o,u.w=i*s*o+a*l*c;else if(n==="ZXY")u.x=a*s*o-i*l*c,u.y=i*l*o+a*s*c,u.z=i*s*c+a*l*o,u.w=i*s*o-a*l*c;else if(n==="ZYX")u.x=a*s*o-i*l*c,u.y=i*l*o+a*s*c,u.z=i*s*c-a*l*o,u.w=i*s*o+a*l*c;else if(n==="YZX")u.x=a*s*o+i*l*c,u.y=i*l*o+a*s*c,u.z=i*s*c-a*l*o,u.w=i*s*o-a*l*c;else if(n==="XZY")u.x=a*s*o-i*l*c,u.y=i*l*o-a*s*c,u.z=i*s*c+a*l*o,u.w=i*s*o+a*l*c;else return null;return u}var xn=class r{constructor(e){this.matrix=null,e!=null&&(this.matrix=e)}IsValid(){return this.matrix!==null}Set(e){return this.matrix=e,this}Get(){return this.matrix}Clone(){let e=[this.matrix[0],this.matrix[1],this.matrix[2],this.matrix[3],this.matrix[4],this.matrix[5],this.matrix[6],this.matrix[7],this.matrix[8],this.matrix[9],this.matrix[10],this.matrix[11],this.matrix[12],this.matrix[13],this.matrix[14],this.matrix[15]];return new r(e)}CreateIdentity(){return this.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this}IsIdentity(){let e=new r().CreateIdentity().Get();for(let t=0;t<16;t++)if(!Ut(this.matrix[t],e[t]))return!1;return!0}CreateTranslation(e,t,n){return this.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,e,t,n,1],this}CreateRotation(e,t,n,i){let s=e+e,o=t+t,a=n+n,l=e*s,c=e*o,u=e*a,h=t*o,f=t*a,p=n*a,g=i*s,y=i*o,d=i*a;return this.matrix=[1-(h+p),c+d,u-y,0,c-d,1-(l+p),f+g,0,u+y,f-g,1-(l+h),0,0,0,0,1],this}CreateRotationAxisAngle(e,t){let n=Cu(e,t);return this.CreateRotation(n.x,n.y,n.z,n.w)}CreateScale(e,t,n){return this.matrix=[e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1],this}ComposeTRS(e,t,n){let i=e.x,s=e.y,o=e.z,a=t.x,l=t.y,c=t.z,u=t.w,h=n.x,f=n.y,p=n.z,g=a+a,y=l+l,d=c+c,m=a*g,_=a*y,v=a*d,x=l*y,S=l*d,I=c*d,A=u*g,C=u*y,E=u*d;return this.matrix=[(1-(x+I))*h,(_+E)*h,(v-C)*h,0,(_-E)*f,(1-(m+I))*f,(S+A)*f,0,(v+C)*p,(S-A)*p,(1-(m+x))*p,0,i,s,o,1],this}DecomposeTRS(){let e=new Ye(this.matrix[12],this.matrix[13],this.matrix[14]),t=Xo(this.matrix[0],this.matrix[1],this.matrix[2]),n=Xo(this.matrix[4],this.matrix[5],this.matrix[6]),i=Xo(this.matrix[8],this.matrix[9],this.matrix[10]),s=this.Determinant();Br(s)&&(t*=-1);let o=new Ye(t,n,i),a=this.matrix[0]/t,l=this.matrix[4]/n,c=this.matrix[8]/i,u=this.matrix[1]/t,h=this.matrix[5]/n,f=this.matrix[9]/i,p=this.matrix[2]/t,g=this.matrix[6]/n,y=this.matrix[10]/i,d=null,m=a+h+y;if(m>0){let _=Math.sqrt(m+1)*2;d=new ii((g-f)/_,(c-p)/_,(u-l)/_,.25*_)}else if(a>h&&a>y){let _=Math.sqrt(1+a-h-y)*2;d=new ii(.25*_,(l+u)/_,(c+p)/_,(g-f)/_)}else if(h>y){let _=Math.sqrt(1+h-a-y)*2;d=new ii((l+u)/_,.25*_,(f+g)/_,(c-p)/_)}else{let _=Math.sqrt(1+y-a-h)*2;d=new ii((c+p)/_,(f+g)/_,.25*_,(u-l)/_)}return{translation:e,rotation:d,scale:o}}Determinant(){let e=this.matrix[0],t=this.matrix[1],n=this.matrix[2],i=this.matrix[3],s=this.matrix[4],o=this.matrix[5],a=this.matrix[6],l=this.matrix[7],c=this.matrix[8],u=this.matrix[9],h=this.matrix[10],f=this.matrix[11],p=this.matrix[12],g=this.matrix[13],y=this.matrix[14],d=this.matrix[15],m=e*o-t*s,_=e*a-n*s,v=e*l-i*s,x=t*a-n*o,S=t*l-i*o,I=n*l-i*a,A=c*g-u*p,C=c*y-h*p,E=c*d-f*p,b=u*y-h*g,R=u*d-f*g,N=h*d-f*y;return m*N-_*R+v*b+x*E-S*C+I*A}Invert(){let e=this.matrix[0],t=this.matrix[1],n=this.matrix[2],i=this.matrix[3],s=this.matrix[4],o=this.matrix[5],a=this.matrix[6],l=this.matrix[7],c=this.matrix[8],u=this.matrix[9],h=this.matrix[10],f=this.matrix[11],p=this.matrix[12],g=this.matrix[13],y=this.matrix[14],d=this.matrix[15],m=e*o-t*s,_=e*a-n*s,v=e*l-i*s,x=t*a-n*o,S=t*l-i*o,I=n*l-i*a,A=c*g-u*p,C=c*y-h*p,E=c*d-f*p,b=u*y-h*g,R=u*d-f*g,N=h*d-f*y,B=m*N-_*R+v*b+x*E-S*C+I*A;if(Ut(B,0))return null;let V=[(o*N-a*R+l*b)/B,(n*R-t*N-i*b)/B,(g*I-y*S+d*x)/B,(h*S-u*I-f*x)/B,(a*E-s*N-l*C)/B,(e*N-n*E+i*C)/B,(y*v-p*I-d*_)/B,(c*I-h*v+f*_)/B,(s*R-o*E+l*A)/B,(t*E-e*R-i*A)/B,(p*S-g*v+d*m)/B,(u*v-c*S-f*m)/B,(o*C-s*b-a*A)/B,(e*b-t*C+n*A)/B,(g*_-p*x-y*m)/B,(c*x-u*_+h*m)/B];return new r(V)}Transpose(){let e=[this.matrix[0],this.matrix[4],this.matrix[8],this.matrix[12],this.matrix[1],this.matrix[5],this.matrix[9],this.matrix[13],this.matrix[2],this.matrix[6],this.matrix[10],this.matrix[14],this.matrix[3],this.matrix[7],this.matrix[11],this.matrix[15]];return new r(e)}InvertTranspose(){let e=this.Invert();return e===null?null:e.Transpose()}MultiplyVector(e){let t=e.x,n=e.y,i=e.z,s=e.w,o=this.matrix[0],a=this.matrix[1],l=this.matrix[2],c=this.matrix[3],u=this.matrix[4],h=this.matrix[5],f=this.matrix[6],p=this.matrix[7],g=this.matrix[8],y=this.matrix[9],d=this.matrix[10],m=this.matrix[11],_=this.matrix[12],v=this.matrix[13],x=this.matrix[14],S=this.matrix[15];return new $i(t*o+n*u+i*g+s*_,t*a+n*h+i*y+s*v,t*l+n*f+i*d+s*x,t*c+n*p+i*m+s*S)}MultiplyMatrix(e){let t=this.matrix[0],n=this.matrix[1],i=this.matrix[2],s=this.matrix[3],o=this.matrix[4],a=this.matrix[5],l=this.matrix[6],c=this.matrix[7],u=this.matrix[8],h=this.matrix[9],f=this.matrix[10],p=this.matrix[11],g=this.matrix[12],y=this.matrix[13],d=this.matrix[14],m=this.matrix[15],_=e.matrix[0],v=e.matrix[1],x=e.matrix[2],S=e.matrix[3],I=e.matrix[4],A=e.matrix[5],C=e.matrix[6],E=e.matrix[7],b=e.matrix[8],R=e.matrix[9],N=e.matrix[10],B=e.matrix[11],V=e.matrix[12],ie=e.matrix[13],Y=e.matrix[14],te=e.matrix[15],q=[t*_+n*I+i*b+s*V,t*v+n*A+i*R+s*ie,t*x+n*C+i*N+s*Y,t*S+n*E+i*B+s*te,o*_+a*I+l*b+c*V,o*v+a*A+l*R+c*ie,o*x+a*C+l*N+c*Y,o*S+a*E+l*B+c*te,u*_+h*I+f*b+p*V,u*v+h*A+f*R+p*ie,u*x+h*C+f*N+p*Y,u*S+h*E+f*B+p*te,g*_+y*I+d*b+m*V,g*v+y*A+d*R+m*ie,g*x+y*C+d*N+m*Y,g*S+y*E+d*B+m*te];return new r(q)}};function Iu(r,e){let t=r.Get(),n=e.Get();for(let i=0;i<16;i++)if(!Ut(t[i],n[i]))return!1;return!0}var pn=class r{constructor(e){e!=null?this.matrix=e:(this.matrix=new xn,this.matrix.CreateIdentity())}SetMatrix(e){return this.matrix=e,this}GetMatrix(){return this.matrix}IsIdentity(){return this.matrix.IsIdentity()}AppendMatrix(e){return this.matrix=this.matrix.MultiplyMatrix(e),this}Append(e){return this.AppendMatrix(e.GetMatrix()),this}TransformCoord3D(e){let t=new $i(e.x,e.y,e.z,1),n=this.matrix.MultiplyVector(t);return new Ye(n.x,n.y,n.z)}Clone(){let e=this.matrix.Clone();return new r(e)}};function gg(r,e){return Iu(r.GetMatrix(),e.GetMatrix())}function vs(r){return r.LineCount()===0&&r.TriangleCount()===0}function Ys(r,e,t){let n=Un(e,r),i=Un(t,r),s=Zi(n,i);return s.Normalize(),s}function Mr(r,e){if(!e.IsIdentity()){for(let t=0;t<r.VertexCount();t++){let n=r.GetVertex(t),i=e.TransformCoord3D(n);n.x=i.x,n.y=i.y,n.z=i.z}if(r.NormalCount()>0){let t=e.GetMatrix().InvertTranspose();if(t!==null){let n=new pn(t);for(let i=0;i<r.NormalCount();i++){let s=r.GetNormal(i),o=n.TransformCoord3D(s);s.x=o.x,s.y=o.y,s.z=o.z}}}}}function Ru(r){for(let e=0;e<r.TriangleCount();e++){let t=r.GetTriangle(e),n=t.v1;t.v1=t.v2,t.v2=n}}var Dl=class{constructor(){}VertexCount(){return 0}VertexColorCount(){return 0}NormalCount(){return 0}TextureUVCount(){return 0}LineCount(){return 0}LineSegmentCount(){return 0}TriangleCount(){return 0}EnumerateVertices(e){}EnumerateTriangleVertexIndices(e){}EnumerateTriangleVertices(e){}},Er=class extends Dl{constructor(){super(),this.name="",this.propertyGroups=[]}GetName(){return this.name}SetName(e){this.name=e}PropertyGroupCount(){return this.propertyGroups.length}AddPropertyGroup(e){return this.propertyGroups.push(e),this.propertyGroups.length-1}GetPropertyGroup(e){return this.propertyGroups[e]}CloneProperties(e){for(let t of this.propertyGroups)e.AddPropertyGroup(t.Clone())}};var ki=class{constructor(e,t){this.nodeId=e,this.meshIndex=t}IsEqual(e){return this.nodeId===e.nodeId&&this.meshIndex===e.meshIndex}GetKey(){return this.nodeId.toString()+":"+this.meshIndex.toString()}},Hr=class extends Er{constructor(e,t,n){super(),this.id=e,this.node=t,this.mesh=n}GetId(){return this.id}GetTransformation(){return this.node.GetWorldTransformation()}GetMesh(){return this.mesh}VertexCount(){return this.mesh.VertexCount()}VertexColorCount(){return this.mesh.VertexColorCount()}NormalCount(){return this.mesh.NormalCount()}TextureUVCount(){return this.mesh.TextureUVCount()}LineCount(){return this.mesh.LineCount()}LineSegmentCount(){return this.mesh.LineSegmentCount()}TriangleCount(){return this.mesh.TriangleCount()}EnumerateVertices(e){let t=this.node.GetWorldTransformation();t.IsIdentity()?this.mesh.EnumerateVertices(e):this.mesh.EnumerateVertices(n=>{let i=t.TransformCoord3D(n);e(i)})}EnumerateTriangleVertexIndices(e){this.mesh.EnumerateTriangleVertexIndices(e)}EnumerateTriangleVertices(e){let t=this.node.GetWorldTransformation();t.IsIdentity()?this.mesh.EnumerateTriangleVertices(e):this.mesh.EnumerateTriangleVertices((n,i,s)=>{let o=t.TransformCoord3D(n),a=t.TransformCoord3D(i),l=t.TransformCoord3D(s);e(o,a,l)})}PropertyGroupCount(){return this.mesh.PropertyGroupCount()}AddPropertyGroup(e){return this.mesh.AddPropertyGroup(e)}GetPropertyGroup(e){return this.mesh.GetPropertyGroup(e)}GetTransformedMesh(){let e=this.node.GetWorldTransformation(),t=this.mesh.Clone();return Mr(t,e),t}};var yg={UNSIGNED_INT:5125,FLOAT:5126},Fl={ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963},Jo=class extends kn{constructor(){super(),this.components={index:{type:yg.UNSIGNED_INT,size:4},number:{type:yg.FLOAT,size:4}}}CanExport(e,t){return e===dn.Text&&t==="gltf"||e===dn.Binary&&t==="glb"}ExportContent(e,t,n,i){t===dn.Text?this.ExportAsciiContent(e,n):t===dn.Binary&&this.ExportBinaryContent(e,n),i()}ExportAsciiContent(e,t){let n=new sn("model.gltf"),i=new sn("model.bin");t.push(n),t.push(i);let s=this.GetMeshData(e),o=this.GetMainBuffer(s),a=this.GetMainJson(e,s);a.buffers.push({uri:i.GetName(),byteLength:o.byteLength});let l=new Map;this.ExportMaterials(e,a,c=>{let u=Rn(c.name);if(l.has(u))return l.get(u);{let h=new sn(u);h.SetBufferContent(c.buffer),t.push(h);let f=a.textures.length;return l.set(u,f),a.images.push({uri:u}),a.textures.push({source:f}),f}}),n.SetTextContent(JSON.stringify(a,null,4)),i.SetBufferContent(o)}ExportBinaryContent(e,t){function n(x){let S=x%4;return S===0?x:x+(4-S)}function i(x,S,I){for(let A=0;A<I;A++)x.WriteUnsignedCharacter8(S)}let s=new sn("model.glb");t.push(s);let o=this.GetMeshData(e),a=this.GetMainBuffer(o),l=this.GetMainJson(e,o),c=[],u=a.byteLength,h=new Map;this.ExportMaterials(e,l,x=>{let S=Rn(x.name),I=Tr(x.name);if(h.has(S))return h.get(S);{let A=l.bufferViews.length,C=l.textures.length;h.set(S,C);let E=x.buffer;return c.push(E),l.bufferViews.push({buffer:0,byteOffset:u,byteLength:E.byteLength}),u+=E.byteLength,l.images.push({bufferView:A,mimeType:"image/"+I}),l.textures.push({source:C}),C}});let f=a.byteLength;for(let x=0;x<c.length;x++){let S=c[x];f+=S.byteLength}let p=n(f);l.buffers.push({byteLength:p});let g=JSON.stringify(l),y=jo(g),d=y.byteLength,m=n(d),_=20+m+8+p,v=new Ji(_,!0);v.WriteUnsignedInteger32(1179937895),v.WriteUnsignedInteger32(2),v.WriteUnsignedInteger32(_),v.WriteUnsignedInteger32(m),v.WriteUnsignedInteger32(1313821514),v.WriteArrayBuffer(y),i(v,32,m-d),v.WriteUnsignedInteger32(p),v.WriteUnsignedInteger32(5130562),v.WriteArrayBuffer(a);for(let x=0;x<c.length;x++){let S=c[x];v.WriteArrayBuffer(S)}i(v,0,p-f),s.SetBufferContent(v.GetBuffer())}GetMeshData(e){let t=[];return e.EnumerateMeshes(n=>{let i=qo(n);t.push({name:n.GetName(),buffer:i,offsets:[],sizes:[]})}),t}GetMainBuffer(e){let t=0;for(let i of e)t+=i.buffer.GetByteLength(this.components.index.size,this.components.number.size);let n=new Ji(t,!0);for(let i of e)for(let s=0;s<i.buffer.PrimitiveCount();s++){let o=i.buffer.GetPrimitive(s),a=n.GetPosition();for(let l=0;l<o.indices.length;l++)n.WriteUnsignedInteger32(o.indices[l]);for(let l=0;l<o.vertices.length;l++)n.WriteFloat32(o.vertices[l]);for(let l=0;l<o.colors.length;l++)n.WriteFloat32(vr(o.colors[l]));for(let l=0;l<o.normals.length;l++)n.WriteFloat32(o.normals[l]);for(let l=0;l<o.uvs.length;l++){let c=o.uvs[l];l%2===1&&(c*=-1),n.WriteFloat32(c)}i.offsets.push(a),i.sizes.push(n.GetPosition()-a)}return n.GetBuffer()}GetMainJson(e,t){class n{constructor(h,f){this.mainJson=h,this.byteOffset=f}AddBufferView(h,f){let p={buffer:0,byteOffset:this.byteOffset,byteLength:h,target:f};return this.mainJson.bufferViews.push(p),this.byteOffset+=h,this.mainJson.bufferViews.length-1}}function i(u,h){for(let f of h.GetMeshIndices()){let p=new ki(h.GetId(),f);if(u.IsMeshInstanceVisible(p))return!0}for(let f of h.GetChildNodes())if(i(u,f))return!0;return!1}function s(u,h,f,p){if(p.IsMeshNode())for(let g of p.GetMeshIndices())o(u,h,f,p,g,!0);else if(i(u,p)){let g={},y=p.GetName();y.length>0&&(g.name=y),p.GetTransformation().IsIdentity()||(g.matrix=p.GetTransformation().GetMatrix().Get()),f.push(g),h.push(f.length-1),g.children=[],a(u,g.children,f,p)}}function o(u,h,f,p,g,y){let d=new ki(p.GetId(),g);if(!u.IsMeshInstanceVisible(d))return;let m={mesh:u.MapMeshIndex(g)};y&&(p.GetTransformation().IsIdentity()||(m.matrix=p.GetTransformation().GetMatrix().Get())),f.push(m),h.push(f.length-1)}function a(u,h,f,p){for(let g of p.GetChildNodes())s(u,h,f,g);for(let g of p.GetMeshIndices())o(u,h,f,p,g,!1)}let l={asset:{generator:"https://3dviewer.net",version:"2.0"},scene:0,scenes:[{nodes:[]}],nodes:[],materials:[],meshes:[],buffers:[],bufferViews:[],accessors:[]},c=e.GetModel().GetRootNode();a(e,l.scenes[0].nodes,l.nodes,c);for(let u of t){let h={name:this.GetExportedMeshName(u.name),primitives:[]},f=u.buffer.primitives;for(let p=0;p<f.length;p++){let g=f[p],y=new n(l,u.offsets[p]),d=y.AddBufferView(g.indices.length*this.components.index.size,Fl.ELEMENT_ARRAY_BUFFER),m=y.AddBufferView(g.vertices.length*this.components.number.size,Fl.ARRAY_BUFFER),_=null;g.colors.length>0&&(_=y.AddBufferView(g.colors.length*this.components.number.size,Fl.ARRAY_BUFFER));let v=y.AddBufferView(g.normals.length*this.components.number.size,Fl.ARRAY_BUFFER),x=null;g.uvs.length>0&&(x=y.AddBufferView(g.uvs.length*this.components.number.size,Fl.ARRAY_BUFFER));let S={attributes:{},mode:4,material:g.material},I=g.GetBounds();l.accessors.push({bufferView:d,byteOffset:0,componentType:this.components.index.type,count:g.indices.length,type:"SCALAR"}),S.indices=l.accessors.length-1,l.accessors.push({bufferView:m,byteOffset:0,componentType:this.components.number.type,count:g.vertices.length/3,min:I.min,max:I.max,type:"VEC3"}),S.attributes.POSITION=l.accessors.length-1,_!==null&&(l.accessors.push({bufferView:_,byteOffset:0,componentType:this.components.number.type,count:g.colors.length/3,type:"VEC3"}),S.attributes.COLOR_0=l.accessors.length-1),l.accessors.push({bufferView:v,byteOffset:0,componentType:this.components.number.type,count:g.normals.length/3,type:"VEC3"}),S.attributes.NORMAL=l.accessors.length-1,x!==null&&(l.accessors.push({bufferView:x,byteOffset:0,componentType:this.components.number.type,count:g.uvs.length/2,type:"VEC2"}),S.attributes.TEXCOORD_0=l.accessors.length-1),h.primitives.push(S)}l.meshes.push(h)}return l}ExportMaterials(e,t,n){function i(s,o,a,l){function c(d,m){return[vr(d.r/255),vr(d.g/255),vr(d.b/255),m]}function u(d){return[vr(d.r/255),vr(d.g/255),vr(d.b/255)]}function h(d,m,_){if(m===null||!m.IsValid())return null;d.images===void 0&&(d.images=[]),d.textures===void 0&&(d.textures=[]);let x={index:_(m)};if(m.HasTransformation()){let S="KHR_texture_transform";d.extensionsUsed===void 0&&(d.extensionsUsed=[]),d.extensionsUsed.indexOf(S)===-1&&d.extensionsUsed.push(S),x.extensions={KHR_texture_transform:{offset:[m.offset.x,-m.offset.y],scale:[m.scale.x,m.scale.y],rotation:-m.rotation}}}return x}let f={name:s.GetExportedMaterialName(a.name),pbrMetallicRoughness:{baseColorFactor:c(a.color,a.opacity)},emissiveFactor:u(a.emissive),doubleSided:!0,alphaMode:"OPAQUE"};a.transparent&&(f.alphaMode="BLEND");let p=h(o,a.diffuseMap,l);if(p!==null&&(a.multiplyDiffuseMap||(f.pbrMetallicRoughness.baseColorFactor=c(new St(255,255,255),a.opacity)),f.pbrMetallicRoughness.baseColorTexture=p),a.type===Wn.Physical){let d=h(o,a.metalnessMap,l);d!==null?f.pbrMetallicRoughness.metallicRoughnessTexture=d:(f.pbrMetallicRoughness.metallicFactor=a.metalness,f.pbrMetallicRoughness.roughnessFactor=a.roughness)}let g=h(o,a.normalMap,l);g!==null&&(f.normalTexture=g);let y=h(o,a.emissiveMap,l);y!==null&&(f.emissiveTexture=y),o.materials.push(f)}for(let s=0;s<e.MaterialCount();s++){let o=e.GetMaterial(s);i(this,t,o,n)}}};var Ul=class{constructor(e){this.transformation=new pn,this.isMeshVisible=t=>!0,Fo(e,this)}},$o=class{constructor(e,t){this.model=e,this.settings=t||new Ul,this.visibleMeshes=null,this.meshToVisibleMeshIndex=null}GetModel(){return this.model}MaterialCount(){return this.model.MaterialCount()}GetMaterial(e){return this.model.GetMaterial(e)}VertexCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.VertexCount()}),e}TriangleCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.TriangleCount()}),e}MeshCount(){let e=0;return this.EnumerateMeshes(t=>{e+=1}),e}EnumerateMeshes(e){this.FillVisibleMeshCache();for(let t=0;t<this.model.MeshCount();t++)if(this.visibleMeshes.has(t)){let n=this.model.GetMesh(t);e(n)}}MapMeshIndex(e){return this.FillVisibleMeshCache(),this.meshToVisibleMeshIndex.get(e)}IsMeshInstanceVisible(e){return this.settings.isMeshVisible(e)}MeshInstanceCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=1}),e}EnumerateMeshInstances(e){this.model.EnumerateMeshInstances(t=>{this.settings.isMeshVisible(t.GetId())&&e(t)})}EnumerateTransformedMeshInstances(e){this.EnumerateMeshInstances(t=>{let n=t.GetTransformation();this.settings.transformation.IsIdentity()||n.Append(this.settings.transformation);let s=t.GetMesh().Clone();n.IsIdentity()||Mr(s,n),e(s)})}EnumerateVerticesAndTriangles(e){let t=[];this.EnumerateTransformedMeshInstances(i=>{t.push(i)});for(let i of t)i.EnumerateVertices(s=>{e.onVertex(s.x,s.y,s.z)});let n=0;for(let i of t)i.EnumerateTriangleVertexIndices((s,o,a)=>{e.onTriangle(s+n,o+n,a+n)}),n+=i.VertexCount()}EnumerateTrianglesWithNormals(e){this.EnumerateTransformedMeshInstances(t=>{t.EnumerateTriangleVertices((n,i,s)=>{let o=Ys(n,i,s);e(n,i,s,o)})})}FillVisibleMeshCache(){if(this.visibleMeshes!==null&&this.meshToVisibleMeshIndex!==null)return;this.visibleMeshes=new Set,this.model.EnumerateMeshInstances(t=>{let n=t.GetId();this.settings.isMeshVisible(n)&&this.visibleMeshes.add(n.meshIndex)}),this.meshToVisibleMeshIndex=new Map;let e=0;for(let t=0;t<this.model.MeshCount();t++)this.visibleMeshes.has(t)&&(this.meshToVisibleMeshIndex.set(t,e),e+=1)}};var mi=class{constructor(){this.text="",this.indentation=0}GetText(){return this.text}Indent(e){this.indentation+=e}WriteArrayLine(e){this.WriteLine(e.join(" "))}WriteLine(e){this.WriteIndentation(),this.Write(e+`
+`)}WriteIndentation(){for(let e=0;e<this.indentation;e++)this.Write(" ")}Write(e){this.text+=e}};var Qo=class extends kn{constructor(){super()}CanExport(e,t){return e===dn.Text&&t==="obj"}ExportContent(e,t,n,i){function s(g,y,d,m){if(d===null||!d.IsValid())return;let _=Rn(d.name);if(g.WriteArrayLine([y,_]),m.findIndex(x=>x.GetName()===_)===-1){let x=new sn(_);x.SetBufferContent(d.buffer),m.push(x)}}let o=new sn("model.mtl"),a=new sn("model.obj");n.push(o),n.push(a);let l=new mi;l.WriteLine(this.GetHeaderText());for(let g=0;g<e.MaterialCount();g++){let y=e.GetMaterial(g);l.WriteArrayLine(["newmtl",this.GetExportedMaterialName(y.name)]),l.WriteArrayLine(["Kd",y.color.r/255,y.color.g/255,y.color.b/255]),l.WriteArrayLine(["d",y.opacity]),y.type===Wn.Phong&&(l.WriteArrayLine(["Ka",y.ambient.r/255,y.ambient.g/255,y.ambient.b/255]),l.WriteArrayLine(["Ks",y.specular.r/255,y.specular.g/255,y.specular.b/255]),l.WriteArrayLine(["Ns",y.shininess*1e3])),s(l,"map_Kd",y.diffuseMap,n),y.type===Wn.Phong&&s(l,"map_Ks",y.specularMap,n),s(l,"bump",y.bumpMap,n)}o.SetTextContent(l.GetText());let c=new mi;c.WriteLine(this.GetHeaderText()),c.WriteArrayLine(["mtllib",o.GetName()]);let u=0,h=0,f=0,p=null;e.EnumerateTransformedMeshInstances(g=>{c.WriteArrayLine(["g",this.GetExportedMeshName(g.GetName())]);for(let y=0;y<g.VertexCount();y++){let d=g.GetVertex(y);c.WriteArrayLine(["v",d.x,d.y,d.z])}for(let y=0;y<g.NormalCount();y++){let d=g.GetNormal(y);c.WriteArrayLine(["vn",d.x,d.y,d.z])}for(let y=0;y<g.TextureUVCount();y++){let d=g.GetTextureUV(y);c.WriteArrayLine(["vt",d.x,d.y])}for(let y=0;y<g.TriangleCount();y++){let d=g.GetTriangle(y),m=d.v0+u+1,_=d.v1+u+1,v=d.v2+u+1,x=d.n0+h+1,S=d.n1+h+1,I=d.n2+h+1,A="",C="",E="";if(d.HasTextureUVs()&&(A=d.u0+f+1,C=d.u1+f+1,E=d.u2+f+1),d.mat!==null){let b=e.GetMaterial(d.mat),R=this.GetExportedMaterialName(b.name);R!==p&&(c.WriteArrayLine(["usemtl",R]),p=R)}c.WriteArrayLine(["f",[m,A,x].join("/"),[_,C,S].join("/"),[v,E,I].join("/")])}for(let y=0;y<g.LineCount();y++){let d=g.GetLine(y),m=[];for(let _=0;_<d.vertices.length;_++)m.push(d.vertices[_]+u+1);if(d.mat!==null){let _=e.GetMaterial(d.mat),v=this.GetExportedMaterialName(_.name);v!==p&&(c.WriteArrayLine(["usemtl",v]),p=v)}c.WriteArrayLine(["l",m.join(" ")])}u+=g.VertexCount(),h+=g.NormalCount(),f+=g.TextureUVCount()}),a.SetTextContent(c.GetText()),i()}GetHeaderText(){return"# exported by https://3dviewer.net"}};var ea=class extends kn{constructor(){super()}CanExport(e,t){return e===dn.Text&&t==="off"}ExportContent(e,t,n,i){let s=new sn("model.off");n.push(s);let o=new mi;o.WriteLine("OFF"),o.WriteArrayLine([e.VertexCount(),e.TriangleCount(),0]),e.EnumerateVerticesAndTriangles({onVertex:function(a,l,c){o.WriteArrayLine([a,l,c])},onTriangle:function(a,l,c){o.WriteArrayLine([3,a,l,c])}}),s.SetTextContent(o.GetText()),i()}};var ta=class extends kn{constructor(){super()}CanExport(e,t){return(e===dn.Text||e===dn.Binary)&&t==="ply"}ExportContent(e,t,n,i){t===dn.Text?this.ExportText(e,n):this.ExportBinary(e,n),i()}ExportText(e,t){let n=new sn("model.ply");t.push(n);let i=new mi,s=e.VertexCount(),o=e.TriangleCount(),a=this.GetHeaderText("ascii",s,o);i.Write(a),e.EnumerateVerticesAndTriangles({onVertex:function(l,c,u){i.WriteArrayLine([l,c,u])},onTriangle:function(l,c,u){i.WriteArrayLine([3,l,c,u])}}),n.SetTextContent(i.GetText())}ExportBinary(e,t){let n=new sn("model.ply");t.push(n);let i=e.VertexCount(),s=e.TriangleCount(),o=this.GetHeaderText("binary_little_endian",i,s),a=o.length+i*3*4+s*(1+3*4),l=new Ji(a,!0);for(let c=0;c<o.length;c++)l.WriteUnsignedCharacter8(o.charCodeAt(c));e.EnumerateVerticesAndTriangles({onVertex:function(c,u,h){l.WriteFloat32(c),l.WriteFloat32(u),l.WriteFloat32(h)},onTriangle:function(c,u,h){l.WriteUnsignedCharacter8(3),l.WriteInteger32(c),l.WriteInteger32(u),l.WriteInteger32(h)}}),n.SetBufferContent(l.GetBuffer())}GetHeaderText(e,t,n){let i=new mi;return i.WriteLine("ply"),i.WriteLine("format "+e+" 1.0"),i.WriteLine("element vertex "+t),i.WriteLine("property float x"),i.WriteLine("property float y"),i.WriteLine("property float z"),i.WriteLine("element face "+n),i.WriteLine("property list uchar int vertex_index"),i.WriteLine("end_header"),i.GetText()}};var na=class extends kn{constructor(){super()}CanExport(e,t){return(e===dn.Text||e===dn.Binary)&&t==="stl"}ExportContent(e,t,n,i){t===dn.Text?this.ExportText(e,n):this.ExportBinary(e,n),i()}ExportText(e,t){let n=new sn("model.stl");t.push(n);let i=new mi;i.WriteLine("solid Model"),e.EnumerateTrianglesWithNormals((s,o,a,l)=>{i.WriteArrayLine(["facet","normal",l.x,l.y,l.z]),i.Indent(1),i.WriteLine("outer loop"),i.Indent(1),i.WriteArrayLine(["vertex",s.x,s.y,s.z]),i.WriteArrayLine(["vertex",o.x,o.y,o.z]),i.WriteArrayLine(["vertex",a.x,a.y,a.z]),i.Indent(-1),i.WriteLine("endloop"),i.Indent(-1),i.WriteLine("endfacet")}),i.WriteLine("endsolid Model"),n.SetTextContent(i.GetText())}ExportBinary(e,t){let n=new sn("model.stl");t.push(n);let i=e.TriangleCount(),s=80,o=s+4+i*50,a=new Ji(o,!0);for(let l=0;l<s;l++)a.WriteUnsignedCharacter8(0);a.WriteUnsignedInteger32(i),e.EnumerateTrianglesWithNormals((l,c,u,h)=>{a.WriteFloat32(h.x),a.WriteFloat32(h.y),a.WriteFloat32(h.z),a.WriteFloat32(l.x),a.WriteFloat32(l.y),a.WriteFloat32(l.z),a.WriteFloat32(c.x),a.WriteFloat32(c.y),a.WriteFloat32(c.z),a.WriteFloat32(u.x),a.WriteFloat32(u.y),a.WriteFloat32(u.z),a.WriteUnsignedInteger16(0)}),n.SetBufferContent(a.GetBuffer())}};var Pu=class{constructor(){this.exporters=[new Qo,new na,new ta,new ea,new Jo,new Yo,new Ko]}AddExporter(e){this.exporters.push(e)}Export(e,t,n,i,s){let o=null;for(let l=0;l<this.exporters.length;l++){let c=this.exporters[l];if(c.CanExport(n,i)){o=c;break}}if(o===null){s.onError();return}let a=new $o(e,t);o.Export(a,n,l=>{l.length===0?s.onError():s.onSuccess(l)})}};var Ks=class{constructor(e,t){this.min=e,this.max=t}GetMin(){return this.min}GetMax(){return this.max}GetCenter(){return new Ye((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,(this.min.z+this.max.z)/2)}},ia=class{constructor(){this.box=new Ks(new Ye(1/0,1/0,1/0),new Ye(-1/0,-1/0,-1/0)),this.isValid=!1}GetBox(){return this.isValid?this.box:null}AddPoint(e){this.box.min.x=Math.min(this.box.min.x,e.x),this.box.min.y=Math.min(this.box.min.y,e.y),this.box.min.z=Math.min(this.box.min.z,e.z),this.box.max.x=Math.max(this.box.max.x,e.x),this.box.max.y=Math.max(this.box.max.y,e.y),this.box.max.z=Math.max(this.box.max.z,e.z),this.isValid=!0}};var ra=class r{constructor(e,t){this.beg=e,this.end=t}Clone(){return new r(this.beg,this.end)}};function md(r,e){let t=ms(r.end,r.beg),n=ms(e,r.beg),i=Rl(t,n),s=Rl(t,t);if(kr(s))return r.beg.Clone();let o=i/s;return o=Math.max(0,Math.min(1,o)),new Nt(r.beg.x+o*t.x,r.beg.y+o*t.y)}function Nu(r,e){let t=md(r,e);return Hs(t,e)}var kl=class r{constructor(e,t){this.boundingBox=e,this.level=t,this.pointItems=[],this.childNodes=[]}AddPoint(e,t,n){let i=this.FindNodeForPoint(e);if(i===null||i.FindPointDirectly(e)!==null)return!1;if(i.pointItems.length<n.maxPointsPerNode||i.level>=n.maxTreeDepth)return i.AddPointDirectly(e,t),!0;{i.CreateChildNodes();let s=i.pointItems;i.pointItems=[];for(let o=0;o<s.length;o++){let a=s[o];if(!i.AddPoint(a.point,a.data,n))return!1}return i.AddPoint(e,t,n)}}FindPoint(e){let t=this.FindNodeForPoint(e);return t===null?null:t.FindPointDirectly(e)}AddPointDirectly(e,t){this.pointItems.push({point:e,data:t})}FindPointDirectly(e){for(let t=0;t<this.pointItems.length;t++){let n=this.pointItems[t];if(bi(e,n.point))return n.data}return null}FindNodeForPoint(e){if(!this.IsPointInBounds(e))return null;if(this.childNodes.length===0)return this;for(let t=0;t<this.childNodes.length;t++){let i=this.childNodes[t].FindNodeForPoint(e);if(i!==null)return i}return null}CreateChildNodes(){function e(a,l,c,u,h,f,p){let g=new Ks(new Ye(l,c,u),new Ye(l+h,c+f,u+p));a.childNodes.push(new r(g,a.level+1))}let t=this.boundingBox.min,n=this.boundingBox.GetCenter(),i=(this.boundingBox.max.x-this.boundingBox.min.x)/2,s=(this.boundingBox.max.y-this.boundingBox.min.y)/2,o=(this.boundingBox.max.z-this.boundingBox.min.z)/2;e(this,t.x,t.y,t.z,i,s,o),e(this,n.x,t.y,t.z,i,s,o),e(this,t.x,n.y,t.z,i,s,o),e(this,n.x,n.y,t.z,i,s,o),e(this,t.x,t.y,n.z,i,s,o),e(this,n.x,t.y,n.z,i,s,o),e(this,t.x,n.y,n.z,i,s,o),e(this,n.x,n.y,n.z,i,s,o)}IsPointInBounds(e){return Vo(e.x,this.boundingBox.min.x)&&Vo(e.y,this.boundingBox.min.y)&&Vo(e.z,this.boundingBox.min.z)&&Go(e.x,this.boundingBox.max.x)&&Go(e.y,this.boundingBox.max.y)&&Go(e.z,this.boundingBox.max.z)}},sa=class{constructor(e,t){this.options={maxPointsPerNode:10,maxTreeDepth:10},t!==void 0&&(t.maxPointsPerNode!==void 0&&(this.options.maxPointsPerNode=t.maxPointsPerNode),t.maxTreeDepth!==void 0&&(this.options.maxTreeDepth=t.maxTreeDepth)),this.rootNode=new kl(e,0)}AddPoint(e,t){return this.rootNode.AddPoint(e,t,this.options)}FindPoint(e){return this.rootNode.FindPoint(e)}};function xg(r,e,t){let n=e/t;return r*(n*n*(3-2*n))}function vg(r,e,t){return e*r/t}function Lu(r,e,t){let n=e/t,i=n*n;return r*(i/(2*(i-n)+1))}function oa(r,e,t,n){let i=Un(e,r).Normalize(),s=ni(r,e),o=[];for(let a=0;a<t;a++){let l=n(s,a,t-1);o.push(r.Clone().Offset(i,l))}return o}var aa=class{constructor(e,t,n){this.name=e,this.source=t,this.data=n}};function Ou(r){let e=[];for(let t of r){let n=Rn(t);e.push(new aa(n,Ki.Url,t))}return e}function Du(r){let e=[];for(let t of r){let n=Rn(t.name);e.push(new aa(n,Ki.File,t))}return e}var Zs=class{constructor(e,t,n){this.name=Rn(e),this.extension=Tr(e),this.source=t,this.data=n,this.content=null}SetContent(e){this.content=e}},Js=class{constructor(){this.files=[]}FillFromInputFiles(e){this.files=[];for(let t of e){let n=new Zs(t.name,t.source,t.data);this.files.push(n)}}ExtendFromFileList(e){let t=e.GetFiles();for(let n=0;n<t.length;n++){let i=t[n];this.ContainsFileByPath(i.name)||this.files.push(i)}}GetFiles(){return this.files}GetContent(e){pu(this.files.length,{runTask:(t,n)=>{e.onFileListProgress(t,this.files.length),this.GetFileContent(this.files[t],{onReady:n,onProgress:e.onFileLoadProgress})},onReady:e.onReady})}ContainsFileByPath(e){return this.FindFileByPath(e)!==null}FindFileByPath(e){let t=Rn(e).toLowerCase();for(let n=0;n<this.files.length;n++){let i=this.files[n];if(i.name.toLowerCase()===t)return i}return null}IsOnlyUrlSource(){if(this.files.length===0)return!1;for(let e=0;e<this.files.length;e++){let t=this.files[e];if(t.source!==Ki.Url&&t.source!==Ki.Decompressed)return!1}return!0}AddFile(e){this.files.push(e)}GetFileContent(e,t){if(e.content!==null){t.onReady();return}let n=null;if(e.source===Ki.Url)n=_u(e.data,t.onProgress);else if(e.source===Ki.File)n=Tu(e.data,t.onProgress);else{t.onReady();return}n.then(i=>{e.SetContent(i)}).catch(()=>{}).finally(()=>{t.onReady()})}};var gd=class{constructor(){this.nextId=0}GenerateId(){let e=this.nextId;return this.nextId+=1,e}},Bn=class{constructor(){this.name="",this.parent=null,this.transformation=new pn,this.childNodes=[],this.meshIndices=[],this.idGenerator=new gd,this.id=this.idGenerator.GenerateId()}IsEmpty(){return this.childNodes.length===0&&this.meshIndices.length===0}IsMeshNode(){return this.childNodes.length===0&&this.meshIndices.length===1}GetId(){return this.id}GetName(){return this.name}SetName(e){this.name=e}HasParent(){return this.parent!==null}GetParent(){return this.parent}GetTransformation(){return this.transformation}GetWorldTransformation(){let e=this.transformation.Clone(),t=this.parent;for(;t!==null;)e.Append(t.transformation),t=t.parent;return e}SetTransformation(e){this.transformation=e}AddChildNode(e){return e.parent=this,e.idGenerator=this.idGenerator,e.id=e.idGenerator.GenerateId(),this.childNodes.push(e),this.childNodes.length-1}RemoveChildNode(e){e.parent=null;let t=this.childNodes.indexOf(e);this.childNodes.splice(t,1)}GetChildNodes(){return this.childNodes}ChildNodeCount(){return this.childNodes.length}GetChildNode(e){return this.childNodes[e]}AddMeshIndex(e){return this.meshIndices.push(e),this.meshIndices.length-1}MeshIndexCount(){return this.meshIndices.length}GetMeshIndex(e){return this.meshIndices[e]}GetMeshIndices(){return this.meshIndices}Enumerate(e){e(this);for(let t of this.childNodes)t.Enumerate(e)}EnumerateChildren(e){for(let t of this.childNodes)e(t),t.EnumerateChildren(e)}EnumerateMeshIndices(e){for(let t of this.meshIndices)e(t);for(let t of this.childNodes)t.EnumerateMeshIndices(e)}};var _s={Unknown:0,Millimeter:1,Centimeter:2,Meter:3,Inch:4,Foot:5};var br=class extends Er{constructor(){super(),this.unit=_s.Unknown,this.root=new Bn,this.materials=[],this.meshes=[]}GetUnit(){return this.unit}SetUnit(e){this.unit=e}GetRootNode(){return this.root}NodeCount(){let e=0;return this.root.Enumerate(t=>{e+=1}),e-1}MaterialCount(){return this.materials.length}MeshCount(){return this.meshes.length}MeshInstanceCount(){let e=0;return this.root.Enumerate(t=>{e+=t.MeshIndexCount()}),e}VertexCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.VertexCount()}),e}VertexColorCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.VertexColorCount()}),e}NormalCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.NormalCount()}),e}TextureUVCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.TextureUVCount()}),e}LineCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.LineCount()}),e}LineSegmentCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.LineSegmentCount()}),e}TriangleCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.TriangleCount()}),e}AddMaterial(e){return this.materials.push(e),this.materials.length-1}GetMaterial(e){return this.materials[e]}AddMesh(e){return this.meshes.push(e),this.meshes.length-1}AddMeshToRootNode(e){let t=this.AddMesh(e);return this.root.AddMeshIndex(t),t}RemoveMesh(e){this.meshes.splice(e,1),this.root.Enumerate(t=>{for(let n=0;n<t.meshIndices.length;n++)t.meshIndices[n]===e?(t.meshIndices.splice(n,1),n-=1):t.meshIndices[n]>e&&(t.meshIndices[n]-=1)})}GetMesh(e){return this.meshes[e]}GetMeshInstance(e){let t=null;if(this.root.Enumerate(o=>{o.GetId()===e.nodeId&&(t=o)}),t===null||t.GetMeshIndices().indexOf(e.meshIndex)===-1)return null;let i=this.GetMesh(e.meshIndex),s=new ki(t.GetId(),e.meshIndex);return new Hr(s,t,i)}EnumerateMeshes(e){for(let t of this.meshes)e(t)}EnumerateMeshInstances(e){this.root.Enumerate(t=>{for(let n of t.GetMeshIndices()){let i=new ki(t.GetId(),n),s=this.GetMesh(n),o=new Hr(i,t,s);e(o)}})}EnumerateTransformedMeshInstances(e){this.EnumerateMeshInstances(t=>{let n=t.GetTransformedMesh();e(n)})}EnumerateVertices(e){this.EnumerateMeshInstances(t=>{t.EnumerateVertices(e)})}EnumerateTriangleVertexIndices(e){this.EnumerateMeshInstances(t=>{t.EnumerateTriangleVertexIndices(e)})}EnumerateTriangleVertices(e){this.EnumerateMeshInstances(t=>{t.EnumerateTriangleVertices(e)})}};var Bl=class{constructor(){this.edges=[],this.triangles=[]}},Gl=class{constructor(e,t){this.vertex1=e,this.vertex2=t,this.triangles=[]}},Vl=class{constructor(e,t){this.edge=e,this.reversed=t}},zl=class{constructor(){this.triEdge1=null,this.triEdge2=null,this.triEdge3=null}},la=class{constructor(){this.vertices=[],this.edges=[],this.triangleEdges=[],this.triangles=[],this.edgeStartToEndVertexMap=new Map}AddVertex(){return this.vertices.push(new Bl),this.vertices.length-1}AddTriangle(e,t,n){function i(c,u,h){c[u].triangles.push(h)}function s(c,u,h,f){let p=c[h],g=u[f];p.edges.push(g.edge)}function o(c,u,h,f){let p=u[h];c[p.edge].triangles.push(f)}let a=this.triangles.length,l=new zl;l.triEdge1=this.AddTriangleEdge(e,t),l.triEdge2=this.AddTriangleEdge(t,n),l.triEdge3=this.AddTriangleEdge(n,e),i(this.vertices,e,a),i(this.vertices,t,a),i(this.vertices,n,a),s(this.vertices,this.triangleEdges,e,l.triEdge1),s(this.vertices,this.triangleEdges,t,l.triEdge2),s(this.vertices,this.triangleEdges,n,l.triEdge3),o(this.edges,this.triangleEdges,l.triEdge1,a),o(this.edges,this.triangleEdges,l.triEdge2,a),o(this.edges,this.triangleEdges,l.triEdge3,a),this.triangles.push(l)}AddTriangleEdge(e,t){let n=e,i=t,s=!1;t<e&&(n=t,i=e,s=!0);let o=this.AddEdge(n,i);return this.triangleEdges.push(new Vl(o,s)),this.triangleEdges.length-1}AddEdge(e,t){this.edgeStartToEndVertexMap.has(e)||this.edgeStartToEndVertexMap.set(e,[]);let n=this.edgeStartToEndVertexMap.get(e);for(let s=0;s<n.length;s++){let o=n[s];if(o.endVertex===t)return o.edgeIndex}let i=this.edges.length;return n.push({endVertex:t,edgeIndex:i}),this.edges.push(new Gl(e,t)),i}};function ca(r){let e=!0;return r.EnumerateMeshInstances(t=>{vs(t)||(e=!1)}),e}function yd(r){let e=new ia;return r.EnumerateVertices(t=>{e.AddPoint(t)}),e.GetBox()}function xd(r){function e(s,o,a){let l=o.FindPoint(s);return l===null&&(l=a.AddVertex(),o.AddPoint(s,l)),l}let t=yd(r),n=new sa(t),i=new la;return r.EnumerateTriangleVertices((s,o,a)=>{let l=e(s,n,i),c=e(o,n,i),u=e(a,n,i);i.AddTriangle(l,c,u)}),i}function vd(r){function e(t,n,i){let s=t.triangles[n],o=t.triangleEdges[s.triEdge1],a=t.triangleEdges[s.triEdge2],l=t.triangleEdges[s.triEdge3];return o.edge===i?o.reversed:a.edge===i?a.reversed:l.edge===i?l.reversed:null}if(r instanceof br){let t=!0;return r.EnumerateMeshInstances(n=>{t&&(t=vd(n))}),t}else{let t=xd(r);for(let n=0;n<t.edges.length;n++){let i=t.edges[n];if(i.triangles.length!==2)return!1;let s=e(t,i.triangles[0],n),o=e(t,i.triangles[1],n);if(s===null||o===null||s===o)return!1}return!0}}function _g(r){let e=[];for(let t=0;t<r.MaterialCount();t++){let n=r.GetMaterial(t);n.source!==bn.Model&&!n.vertexColors&&e.push(n)}return e}function Tg(r,e,t){for(let n=0;n<r.MaterialCount();n++){let i=r.GetMaterial(n);i.source===bn.DefaultFace?i.color=e:i.source===bn.DefaultLine&&(i.color=t)}}var tn=class r extends Er{constructor(){super(),this.vertices=[],this.vertexColors=[],this.normals=[],this.uvs=[],this.lines=[],this.triangles=[]}VertexCount(){return this.vertices.length}VertexColorCount(){return this.vertexColors.length}NormalCount(){return this.normals.length}TextureUVCount(){return this.uvs.length}LineCount(){return this.lines.length}LineSegmentCount(){let e=0;for(let t of this.lines)e+=t.SegmentCount();return e}TriangleCount(){return this.triangles.length}AddVertex(e){return this.vertices.push(e),this.vertices.length-1}SetVertex(e,t){this.vertices[e]=t}GetVertex(e){return this.vertices[e]}AddVertexColor(e){return this.vertexColors.push(e),this.vertexColors.length-1}SetVertexColor(e,t){this.vertexColors[e]=t}GetVertexColor(e){return this.vertexColors[e]}AddNormal(e){return this.normals.push(e),this.normals.length-1}SetNormal(e,t){this.normals[e]=t}GetNormal(e){return this.normals[e]}AddTextureUV(e){return this.uvs.push(e),this.uvs.length-1}SetTextureUV(e,t){this.uvs[e]=t}GetTextureUV(e){return this.uvs[e]}AddLine(e){return this.lines.push(e),this.lines.length-1}GetLine(e){return this.lines[e]}AddTriangle(e){return this.triangles.push(e),this.triangles.length-1}GetTriangle(e){return this.triangles[e]}EnumerateVertices(e){for(let t of this.vertices)e(t)}EnumerateTriangleVertexIndices(e){for(let t of this.triangles)e(t.v0,t.v1,t.v2)}EnumerateTriangleVertices(e){for(let t of this.triangles){let n=this.vertices[t.v0],i=this.vertices[t.v1],s=this.vertices[t.v2];e(n,i,s)}}Clone(){let e=new r;e.SetName(this.GetName()),this.CloneProperties(e);for(let t=0;t<this.VertexCount();t++){let n=this.GetVertex(t);e.AddVertex(n.Clone())}for(let t=0;t<this.VertexColorCount();t++){let n=this.GetVertexColor(t);e.AddVertexColor(n.Clone())}for(let t=0;t<this.NormalCount();t++){let n=this.GetNormal(t);e.AddNormal(n.Clone())}for(let t=0;t<this.TextureUVCount();t++){let n=this.GetTextureUV(t);e.AddTextureUV(n.Clone())}for(let t=0;t<this.LineCount();t++){let n=this.GetLine(t);e.AddLine(n.Clone())}for(let t=0;t<this.TriangleCount();t++){let n=this.GetTriangle(t);e.AddTriangle(n.Clone())}return e}};var Qt=class r{constructor(e,t,n){this.v0=e,this.v1=t,this.v2=n,this.c0=null,this.c1=null,this.c2=null,this.n0=null,this.n1=null,this.n2=null,this.u0=null,this.u1=null,this.u2=null,this.mat=null,this.curve=null}HasVertices(){return this.v0!==null&&this.v1!==null&&this.v2!==null}HasVertexColors(){return this.c0!==null&&this.c1!==null&&this.c2!==null}HasNormals(){return this.n0!==null&&this.n1!==null&&this.n2!==null}HasTextureUVs(){return this.u0!==null&&this.u1!==null&&this.u2!==null}SetVertices(e,t,n){return this.v0=e,this.v1=t,this.v2=n,this}SetVertexColors(e,t,n){return this.c0=e,this.c1=t,this.c2=n,this}SetNormals(e,t,n){return this.n0=e,this.n1=t,this.n2=n,this}SetTextureUVs(e,t,n){return this.u0=e,this.u1=t,this.u2=n,this}SetMaterial(e){return this.mat=e,this}SetCurve(e){return this.curve=e,this}Clone(){let e=new r(this.v0,this.v1,this.v2);return e.SetVertexColors(this.c0,this.c1,this.c2),e.SetNormals(this.n0,this.n1,this.n2),e.SetTextureUVs(this.u0,this.u1,this.u2),e.SetMaterial(this.mat),e.SetCurve(this.curve),e}};var Oh="176";var c0=0,fp=1,u0=2;var dp=1,h0=2,Ir=3,wi=0,_n=1,Nn=2,as=0,io=1,pp=2,mp=3,gp=4,f0=5,ws=100,d0=101,p0=102,m0=103,g0=104,y0=200,x0=201,v0=202,_0=203,fh=204,dh=205,T0=206,M0=207,E0=208,b0=209,S0=210,A0=211,w0=212,C0=213,I0=214,Dh=0,Fh=1,Uh=2,ro=3,kh=4,Bh=5,Gh=6,Vh=7,Sc=0,R0=1,P0=2,ls=0,N0=1,L0=2,O0=3,D0=4,F0=5,U0=6,k0=7,Kd="attached",B0="detached",yp=300,_o=301,To=302,Ua=303,zh=304,Ac=306,on=1e3,un=1001,so=1002,Xn=1003,G0=1004;var wc=1005;var Pn=1006,Hh=1007;var xi=1008;var lr=1009,xp=1010,vp=1011,ka=1012,Wh=1013,Ls=1014,cr=1015,Ba=1016,Xh=1017,qh=1018,Ga=1020,_p=35902,Tp=1021,Mp=1022,Pi=1023,Sa=1026,Va=1027,Ep=1028,jh=1029,bp=1030,Yh=1031;var Kh=1033,Cc=33776,Ic=33777,Rc=33778,Pc=33779,Zh=35840,Jh=35841,$h=35842,Qh=35843,ef=36196,tf=37492,nf=37496,rf=37808,sf=37809,of=37810,af=37811,lf=37812,cf=37813,uf=37814,hf=37815,ff=37816,df=37817,pf=37818,mf=37819,gf=37820,yf=37821,Nc=36492,xf=36494,vf=36495,Sp=36283,_f=36284,Tf=36285,Mf=36286;var Ql=2300,ph=2301,hh=2302,Zd=2400,Jd=2401,$d=2402,V0=2500;var z0=3200,H0=3201;var Lc=0,W0=1,cs="",yt="srgb",Ci="srgb-linear",ec="linear",Kt="srgb";var no=7680;var Qd=519,X0=512,q0=513,j0=514,Ap=515,Y0=516,K0=517,Z0=518,J0=519,ep=35044;var wp="300 es",Ar=2e3,tc=2001;var Qr=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}},Zn=["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,Ea=Math.PI/180,oo=180/Math.PI;function us(){let r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Zn[r&255]+Zn[r>>8&255]+Zn[r>>16&255]+Zn[r>>24&255]+"-"+Zn[e&255]+Zn[e>>8&255]+"-"+Zn[e>>16&15|64]+Zn[e>>24&255]+"-"+Zn[t&63|128]+Zn[t>>8&255]+"-"+Zn[t>>16&255]+Zn[t>>24&255]+Zn[n&255]+Zn[n>>8&255]+Zn[n>>16&255]+Zn[n>>24&255]).toLowerCase()}function Pt(r,e,t){return Math.max(e,Math.min(t,r))}function Cp(r,e){return(r%e+e)%e}function Xx(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function qx(r,e,t){return r!==e?(t-r)/(e-r):0}function Zl(r,e,t){return(1-t)*r+t*e}function jx(r,e,t,n){return Zl(r,e,1-Math.exp(-t*n))}function Yx(r,e=1){return e-Math.abs(Cp(r,e*2)-e)}function Kx(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Zx(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function Jx(r,e){return r+Math.floor(Math.random()*(e-r+1))}function $x(r,e){return r+Math.random()*(e-r)}function Qx(r){return r*(.5-Math.random())}function ev(r){r!==void 0&&(Mg=r);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 tv(r){return r*Ea}function nv(r){return r*oo}function iv(r){return(r&r-1)===0&&r!==0}function rv(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function sv(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function ov(r,e,t,n,i){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),f=o((e-n)/2),p=s((n-e)/2),g=o((n-e)/2);switch(i){case"XYX":r.set(a*u,l*h,l*f,a*c);break;case"YZY":r.set(l*f,a*u,l*h,a*c);break;case"ZXZ":r.set(l*h,l*f,a*u,a*c);break;case"XZX":r.set(a*u,l*g,l*p,a*c);break;case"YXY":r.set(l*p,a*u,l*g,a*c);break;case"ZYZ":r.set(l*g,l*p,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ma(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function ri(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}var yn={DEG2RAD:Ea,RAD2DEG:oo,generateUUID:us,clamp:Pt,euclideanModulo:Cp,mapLinear:Xx,inverseLerp:qx,lerp:Zl,damp:jx,pingpong:Yx,smoothstep:Kx,smootherstep:Zx,randInt:Jx,randFloat:$x,randFloatSpread:Qx,seededRandom:ev,degToRad:tv,radToDeg:nv,isPowerOfTwo:iv,ceilPowerOfTwo:rv,floorPowerOfTwo:sv,setQuaternionFromProperEuler:ov,normalize:ri,denormalize:Ma},Pe=class r{constructor(e=0,t=0){r.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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=Pt(this.x,e.x,t.x),this.y=Pt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Pt(this.x,e,t),this.y=Pt(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Pt(n,e,t))}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 n=this.dot(e)/t;return Math.acos(Pt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},gt=class r{constructor(e,t,n,i,s,o,a,l,c){r.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,l,c)}set(e,t,n,i,s,o,a,l,c){let u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],h=n[7],f=n[2],p=n[5],g=n[8],y=i[0],d=i[3],m=i[6],_=i[1],v=i[4],x=i[7],S=i[2],I=i[5],A=i[8];return s[0]=o*y+a*_+l*S,s[3]=o*d+a*v+l*I,s[6]=o*m+a*x+l*A,s[1]=c*y+u*_+h*S,s[4]=c*d+u*v+h*I,s[7]=c*m+u*x+h*A,s[2]=f*y+p*_+g*S,s[5]=f*d+p*v+g*I,s[8]=f*m+p*x+g*A,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],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*s*u+n*a*l+i*s*c-i*o*l}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,f=a*l-u*s,p=c*s-o*l,g=t*h+n*f+i*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/g;return e[0]=h*y,e[1]=(i*c-u*n)*y,e[2]=(a*n-i*o)*y,e[3]=f*y,e[4]=(u*t-i*l)*y,e[5]=(i*s-a*t)*y,e[6]=p*y,e[7]=(n*l-c*t)*y,e[8]=(o*t-n*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,n,i,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(_d.makeScale(e,t)),this}rotate(e){return this.premultiply(_d.makeRotation(-e)),this}translate(e,t){return this.premultiply(_d.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},_d=new gt;function Ip(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function Aa(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function $0(){let r=Aa("canvas");return r.style.display="block",r}var Eg={};function Oc(r){r in Eg||(Eg[r]=!0,console.warn(r))}function Q0(r,e,t){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function ey(r){let e=r.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function ty(r){let e=r.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}var bg=new gt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Sg=new gt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function av(){let r={enabled:!0,workingColorSpace:Ci,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Kt&&(i.r=Jr(i.r),i.g=Jr(i.g),i.b=Jr(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Kt&&(i.r=ba(i.r),i.g=ba(i.g),i.b=ba(i.b))),i},fromWorkingColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},toWorkingColorSpace:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===cs?ec:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[Ci]:{primaries:e,whitePoint:n,transfer:ec,toXYZ:bg,fromXYZ:Sg,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:yt},outputColorSpaceConfig:{drawingBufferColorSpace:yt}},[yt]:{primaries:e,whitePoint:n,transfer:Kt,toXYZ:bg,fromXYZ:Sg,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:yt}}}),r}var mt=av();function Jr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ba(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}var ua,ao=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ua===void 0&&(ua=Aa("canvas")),ua.width=e.width,ua.height=e.height;let i=ua.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=ua}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Aa("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Jr(s[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Jr(t[n]/255)*255):t[n]=Jr(t[n]);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}},lv=0,wa=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:lv++}),this.uuid=us(),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 n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Td(i[o].image)):s.push(Td(i[o]))}else s=Td(i);n.url=s}return t||(e.images[this.uuid]=n),n}};function Td(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?ao.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var cv=0,qn=class r extends Qr{constructor(e=r.DEFAULT_IMAGE,t=r.DEFAULT_MAPPING,n=un,i=un,s=Pn,o=xi,a=Pi,l=lr,c=r.DEFAULT_ANISOTROPY,u=cs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:cv++}),this.uuid=us(),this.name="",this.source=new wa(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Pe(0,0),this.repeat=new Pe(1,1),this.center=new Pe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new gt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isTextureArray=!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.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isTextureArray=e.isTextureArray,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 n={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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==yp)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case on:e.x=e.x-Math.floor(e.x);break;case un:e.x=e.x<0?0:1;break;case so: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 on:e.y=e.y-Math.floor(e.y);break;case un:e.y=e.y<0?0:1;break;case so: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++}};qn.DEFAULT_IMAGE=null;qn.DEFAULT_MAPPING=yp;qn.DEFAULT_ANISOTROPY=1;var wt=class r{constructor(e=0,t=0,n=0,i=1){r.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}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,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,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,n,i,s,l=e.elements,c=l[0],u=l[4],h=l[8],f=l[1],p=l[5],g=l[9],y=l[2],d=l[6],m=l[10];if(Math.abs(u-f)<.01&&Math.abs(h-y)<.01&&Math.abs(g-d)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+y)<.1&&Math.abs(g+d)<.1&&Math.abs(c+p+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let v=(c+1)/2,x=(p+1)/2,S=(m+1)/2,I=(u+f)/4,A=(h+y)/4,C=(g+d)/4;return v>x&&v>S?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=I/n,s=A/n):x>S?x<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(x),n=I/i,s=C/i):S<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(S),n=A/s,i=C/s),this.set(n,i,s,t),this}let _=Math.sqrt((d-g)*(d-g)+(h-y)*(h-y)+(f-u)*(f-u));return Math.abs(_)<.001&&(_=1),this.x=(d-g)/_,this.y=(h-y)/_,this.z=(f-u)/_,this.w=Math.acos((c+p+m-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],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=Pt(this.x,e.x,t.x),this.y=Pt(this.y,e.y,t.y),this.z=Pt(this.z,e.z,t.z),this.w=Pt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Pt(this.x,e,t),this.y=Pt(this.y,e,t),this.z=Pt(this.z,e,t),this.w=Pt(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Pt(n,e,t))}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}},mh=class extends Qr{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth?n.depth:1,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t);let i={width:e,height:t,depth:this.depth};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Pn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,multiview:!1},n);let s=new qn(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;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 t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new wa(i)}return 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"})}},wr=class extends mh{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},nc=class extends qn{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Xn,this.minFilter=Xn,this.wrapR=un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var gh=class extends qn{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Xn,this.minFilter=Xn,this.wrapR=un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var an=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3],f=s[o+0],p=s[o+1],g=s[o+2],y=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=f,e[t+1]=p,e[t+2]=g,e[t+3]=y;return}if(h!==y||l!==f||c!==p||u!==g){let d=1-a,m=l*f+c*p+u*g+h*y,_=m>=0?1:-1,v=1-m*m;if(v>Number.EPSILON){let S=Math.sqrt(v),I=Math.atan2(S,m*_);d=Math.sin(d*I)/S,a=Math.sin(a*I)/S}let x=a*_;if(l=l*d+f*x,c=c*d+p*x,u=u*d+g*x,h=h*d+y*x,d===1-a){let S=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=S,c*=S,u*=S,h*=S}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,o){let a=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=s[o],f=s[o+1],p=s[o+2],g=s[o+3];return e[t]=a*g+u*h+l*p-c*f,e[t+1]=l*g+u*f+c*h-a*p,e[t+2]=c*g+u*p+a*f-l*h,e[t+3]=u*g-a*h-l*f-c*p,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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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 n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(i/2),h=a(s/2),f=l(n/2),p=l(i/2),g=l(s/2);switch(o){case"XYZ":this._x=f*u*h+c*p*g,this._y=c*p*h-f*u*g,this._z=c*u*g+f*p*h,this._w=c*u*h-f*p*g;break;case"YXZ":this._x=f*u*h+c*p*g,this._y=c*p*h-f*u*g,this._z=c*u*g-f*p*h,this._w=c*u*h+f*p*g;break;case"ZXY":this._x=f*u*h-c*p*g,this._y=c*p*h+f*u*g,this._z=c*u*g+f*p*h,this._w=c*u*h-f*p*g;break;case"ZYX":this._x=f*u*h-c*p*g,this._y=c*p*h+f*u*g,this._z=c*u*g-f*p*h,this._w=c*u*h+f*p*g;break;case"YZX":this._x=f*u*h+c*p*g,this._y=c*p*h+f*u*g,this._z=c*u*g-f*p*h,this._w=c*u*h-f*p*g;break;case"XZY":this._x=f*u*h-c*p*g,this._y=c*p*h-f*u*g,this._z=c*u*g+f*p*h,this._w=c*u*h+f*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],f=n+a+h;if(f>0){let p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(o-i)*p}else if(n>a&&n>h){let p=2*Math.sqrt(1+n-a-h);this._w=(u-l)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+c)/p}else if(a>h){let p=2*Math.sqrt(1+a-n-h);this._w=(s-c)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(l+u)/p}else{let p=2*Math.sqrt(1+h-n-a);this._w=(o-i)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Pt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),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 n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+i*c-s*l,this._y=i*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-i*a,this._w=o*u-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,i=this._y,s=this._z,o=this._w,a=o*e._w+n*e._x+i*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=n,this._y=i,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let p=1-t;return this._w=p*o+t*this._w,this._x=p*n+t*this._x,this._y=p*i+t*this._y,this._z=p*s+t*this._z,this.normalize(),this}let c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,f=Math.sin(t*u)/c;return this._w=o*h+this._w*f,this._x=n*h+this._x*f,this._y=i*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*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}},se=class r{constructor(e=0,t=0,n=0){r.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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(Ag.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ag.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*i-a*n),u=2*(a*t-s*i),h=2*(s*n-o*t);return this.x=t+l*c+o*h-a*u,this.y=n+l*u+a*c-s*h,this.z=i+l*h+s*u-o*c,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,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,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=Pt(this.x,e.x,t.x),this.y=Pt(this.y,e.y,t.y),this.z=Pt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Pt(this.x,e,t),this.y=Pt(this.y,e,t),this.z=Pt(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Pt(n,e,t))}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Md.copy(this).projectOnVector(e),this.sub(Md)}reflect(e){return this.sub(Md.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 n=this.dot(e)/t;return Math.acos(Pt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Md=new se,Ag=new an,Gi=class{constructor(e=new se(1/0,1/0,1/0),t=new se(-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,n=e.length;t<n;t+=3)this.expandByPoint(Qi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Qi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Qi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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 n=e.geometry;if(n!==void 0){let s=n.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,Qi):Qi.fromBufferAttribute(s,o),Qi.applyMatrix4(e.matrixWorld),this.expandByPoint(Qi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Fu.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Fu.copy(n.boundingBox)),Fu.applyMatrix4(e.matrixWorld),this.union(Fu)}let i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[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,Qi),Qi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Hl),Uu.subVectors(this.max,Hl),ha.subVectors(e.a,Hl),fa.subVectors(e.b,Hl),da.subVectors(e.c,Hl),Ts.subVectors(fa,ha),Ms.subVectors(da,fa),$s.subVectors(ha,da);let t=[0,-Ts.z,Ts.y,0,-Ms.z,Ms.y,0,-$s.z,$s.y,Ts.z,0,-Ts.x,Ms.z,0,-Ms.x,$s.z,0,-$s.x,-Ts.y,Ts.x,0,-Ms.y,Ms.x,0,-$s.y,$s.x,0];return!Ed(t,ha,fa,da,Uu)||(t=[1,0,0,0,1,0,0,0,1],!Ed(t,ha,fa,da,Uu))?!1:(ku.crossVectors(Ts,Ms),t=[ku.x,ku.y,ku.z],Ed(t,ha,fa,da,Uu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Qi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Qi).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:(Wr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Wr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Wr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Wr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Wr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Wr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Wr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Wr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Wr),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)}},Wr=[new se,new se,new se,new se,new se,new se,new se,new se],Qi=new se,Fu=new Gi,ha=new se,fa=new se,da=new se,Ts=new se,Ms=new se,$s=new se,Hl=new se,Uu=new se,ku=new se,Qs=new se;function Ed(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Qs.fromArray(r,s);let a=i.x*Math.abs(Qs.x)+i.y*Math.abs(Qs.y)+i.z*Math.abs(Qs.z),l=e.dot(Qs),c=t.dot(Qs),u=n.dot(Qs);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var uv=new Gi,Wl=new se,bd=new se,Vi=class{constructor(e=new se,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 n=this.center;t!==void 0?n.copy(t):uv.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),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 n=this.center.distanceToSquared(e);return t.copy(e),n>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;Wl.subVectors(e,this.center);let t=Wl.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Wl,i/n),this.radius+=i}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):(bd.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Wl.copy(e.center).add(bd)),this.expandByPoint(Wl.copy(e.center).sub(bd))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Xr=new se,Sd=new se,Bu=new se,Es=new se,Ad=new se,Gu=new se,wd=new se,Cs=class{constructor(e=new se,t=new se(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,Xr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Xr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Xr.copy(this.origin).addScaledVector(this.direction,t),Xr.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Sd.copy(e).add(t).multiplyScalar(.5),Bu.copy(t).sub(e).normalize(),Es.copy(this.origin).sub(Sd);let s=e.distanceTo(t)*.5,o=-this.direction.dot(Bu),a=Es.dot(this.direction),l=-Es.dot(Bu),c=Es.lengthSq(),u=Math.abs(1-o*o),h,f,p,g;if(u>0)if(h=o*l-a,f=o*a-l,g=s*u,h>=0)if(f>=-g)if(f<=g){let y=1/u;h*=y,f*=y,p=h*(h+o*f+2*a)+f*(o*h+f+2*l)+c}else f=s,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*l)+c;else f=-s,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*l)+c;else f<=-g?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+f*(f+2*l)+c):f<=g?(h=0,f=Math.min(Math.max(-s,-l),s),p=f*(f+2*l)+c):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+f*(f+2*l)+c);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Sd).addScaledVector(Bu,f),p}intersectSphere(e,t){Xr.subVectors(e.center,this.origin);let n=Xr.dot(this.direction),i=Xr.dot(Xr)-n*n,s=e.radius*e.radius;if(i>s)return null;let o=Math.sqrt(s-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o<i||isNaN(i))&&(i=o),h>=0?(a=(e.min.z-f.z)*h,l=(e.max.z-f.z)*h):(a=(e.max.z-f.z)*h,l=(e.min.z-f.z)*h),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Xr)!==null}intersectTriangle(e,t,n,i,s){Ad.subVectors(t,e),Gu.subVectors(n,e),wd.crossVectors(Ad,Gu);let o=this.direction.dot(wd),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Es.subVectors(this.origin,e);let l=a*this.direction.dot(Gu.crossVectors(Es,Gu));if(l<0)return null;let c=a*this.direction.dot(Ad.cross(Es));if(c<0||l+c>o)return null;let u=-a*Es.dot(wd);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)}},Je=class r{constructor(e,t,n,i,s,o,a,l,c,u,h,f,p,g,y,d){r.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,n,i,s,o,a,l,c,u,h,f,p,g,y,d)}set(e,t,n,i,s,o,a,l,c,u,h,f,p,g,y,d){let m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=u,m[10]=h,m[14]=f,m[3]=p,m[7]=g,m[11]=y,m[15]=d,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 r().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,i=1/pa.setFromMatrixColumn(e,0).length(),s=1/pa.setFromMatrixColumn(e,1).length(),o=1/pa.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let f=o*u,p=o*h,g=a*u,y=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=p+g*c,t[5]=f-y*c,t[9]=-a*l,t[2]=y-f*c,t[6]=g+p*c,t[10]=o*l}else if(e.order==="YXZ"){let f=l*u,p=l*h,g=c*u,y=c*h;t[0]=f+y*a,t[4]=g*a-p,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=p*a-g,t[6]=y+f*a,t[10]=o*l}else if(e.order==="ZXY"){let f=l*u,p=l*h,g=c*u,y=c*h;t[0]=f-y*a,t[4]=-o*h,t[8]=g+p*a,t[1]=p+g*a,t[5]=o*u,t[9]=y-f*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let f=o*u,p=o*h,g=a*u,y=a*h;t[0]=l*u,t[4]=g*c-p,t[8]=f*c+y,t[1]=l*h,t[5]=y*c+f,t[9]=p*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let f=o*l,p=o*c,g=a*l,y=a*c;t[0]=l*u,t[4]=y-f*h,t[8]=g*h+p,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=p*h+g,t[10]=f-y*h}else if(e.order==="XZY"){let f=o*l,p=o*c,g=a*l,y=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=f*h+y,t[5]=o*u,t[9]=p*h-g,t[2]=g*h-p,t[6]=a*u,t[10]=y*h+f}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(hv,e,fv)}lookAt(e,t,n){let i=this.elements;return Si.subVectors(e,t),Si.lengthSq()===0&&(Si.z=1),Si.normalize(),bs.crossVectors(n,Si),bs.lengthSq()===0&&(Math.abs(n.z)===1?Si.x+=1e-4:Si.z+=1e-4,Si.normalize(),bs.crossVectors(n,Si)),bs.normalize(),Vu.crossVectors(Si,bs),i[0]=bs.x,i[4]=Vu.x,i[8]=Si.x,i[1]=bs.y,i[5]=Vu.y,i[9]=Si.y,i[2]=bs.z,i[6]=Vu.z,i[10]=Si.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],h=n[5],f=n[9],p=n[13],g=n[2],y=n[6],d=n[10],m=n[14],_=n[3],v=n[7],x=n[11],S=n[15],I=i[0],A=i[4],C=i[8],E=i[12],b=i[1],R=i[5],N=i[9],B=i[13],V=i[2],ie=i[6],Y=i[10],te=i[14],q=i[3],le=i[7],ye=i[11],Te=i[15];return s[0]=o*I+a*b+l*V+c*q,s[4]=o*A+a*R+l*ie+c*le,s[8]=o*C+a*N+l*Y+c*ye,s[12]=o*E+a*B+l*te+c*Te,s[1]=u*I+h*b+f*V+p*q,s[5]=u*A+h*R+f*ie+p*le,s[9]=u*C+h*N+f*Y+p*ye,s[13]=u*E+h*B+f*te+p*Te,s[2]=g*I+y*b+d*V+m*q,s[6]=g*A+y*R+d*ie+m*le,s[10]=g*C+y*N+d*Y+m*ye,s[14]=g*E+y*B+d*te+m*Te,s[3]=_*I+v*b+x*V+S*q,s[7]=_*A+v*R+x*ie+S*le,s[11]=_*C+v*N+x*Y+S*ye,s[15]=_*E+v*B+x*te+S*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],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],f=e[10],p=e[14],g=e[3],y=e[7],d=e[11],m=e[15];return g*(+s*l*h-i*c*h-s*a*f+n*c*f+i*a*p-n*l*p)+y*(+t*l*p-t*c*f+s*o*f-i*o*p+i*c*u-s*l*u)+d*(+t*c*h-t*a*p-s*o*h+n*o*p+s*a*u-n*c*u)+m*(-i*a*u-t*l*h+t*a*f+i*o*h-n*o*f+n*l*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,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],f=e[10],p=e[11],g=e[12],y=e[13],d=e[14],m=e[15],_=h*d*c-y*f*c+y*l*p-a*d*p-h*l*m+a*f*m,v=g*f*c-u*d*c-g*l*p+o*d*p+u*l*m-o*f*m,x=u*y*c-g*h*c+g*a*p-o*y*p-u*a*m+o*h*m,S=g*h*l-u*y*l-g*a*f+o*y*f+u*a*d-o*h*d,I=t*_+n*v+i*x+s*S;if(I===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/I;return e[0]=_*A,e[1]=(y*f*s-h*d*s-y*i*p+n*d*p+h*i*m-n*f*m)*A,e[2]=(a*d*s-y*l*s+y*i*c-n*d*c-a*i*m+n*l*m)*A,e[3]=(h*l*s-a*f*s-h*i*c+n*f*c+a*i*p-n*l*p)*A,e[4]=v*A,e[5]=(u*d*s-g*f*s+g*i*p-t*d*p-u*i*m+t*f*m)*A,e[6]=(g*l*s-o*d*s-g*i*c+t*d*c+o*i*m-t*l*m)*A,e[7]=(o*f*s-u*l*s+u*i*c-t*f*c-o*i*p+t*l*p)*A,e[8]=x*A,e[9]=(g*h*s-u*y*s-g*n*p+t*y*p+u*n*m-t*h*m)*A,e[10]=(o*y*s-g*a*s+g*n*c-t*y*c-o*n*m+t*a*m)*A,e[11]=(u*a*s-o*h*s-u*n*c+t*h*c+o*n*p-t*a*p)*A,e[12]=S*A,e[13]=(u*y*i-g*h*i+g*n*f-t*y*f-u*n*d+t*h*d)*A,e[14]=(g*a*i-o*y*i-g*n*l+t*y*l+o*n*d-t*a*d)*A,e[15]=(o*h*i-u*a*i+u*n*l-t*h*l-o*n*f+t*a*f)*A,this}scale(e){let t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+n,u*l-i*o,0,c*l-i*a,u*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,h=a+a,f=s*c,p=s*u,g=s*h,y=o*u,d=o*h,m=a*h,_=l*c,v=l*u,x=l*h,S=n.x,I=n.y,A=n.z;return i[0]=(1-(y+m))*S,i[1]=(p+x)*S,i[2]=(g-v)*S,i[3]=0,i[4]=(p-x)*I,i[5]=(1-(f+m))*I,i[6]=(d+_)*I,i[7]=0,i[8]=(g+v)*A,i[9]=(d-_)*A,i[10]=(1-(f+y))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,s=pa.set(i[0],i[1],i[2]).length(),o=pa.set(i[4],i[5],i[6]).length(),a=pa.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],er.copy(this);let c=1/s,u=1/o,h=1/a;return er.elements[0]*=c,er.elements[1]*=c,er.elements[2]*=c,er.elements[4]*=u,er.elements[5]*=u,er.elements[6]*=u,er.elements[8]*=h,er.elements[9]*=h,er.elements[10]*=h,t.setFromRotationMatrix(er),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o,a=Ar){let l=this.elements,c=2*s/(t-e),u=2*s/(n-i),h=(t+e)/(t-e),f=(n+i)/(n-i),p,g;if(a===Ar)p=-(o+s)/(o-s),g=-2*o*s/(o-s);else if(a===tc)p=-o/(o-s),g=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,o,a=Ar){let l=this.elements,c=1/(t-e),u=1/(n-i),h=1/(o-s),f=(t+e)*c,p=(n+i)*u,g,y;if(a===Ar)g=(o+s)*h,y=-2*h;else if(a===tc)g=s*h,y=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=y,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},pa=new se,er=new Je,hv=new se(0,0,0),fv=new se(1,1,1),bs=new se,Vu=new se,Si=new se,wg=new Je,Cg=new an,vn=class r{constructor(e=0,t=0,n=0,i=r.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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,n=!0){let i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],h=i[2],f=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(Pt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Pt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Pt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Pt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Pt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Pt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return wg.makeRotationFromQuaternion(e),this.setFromRotationMatrix(wg,t,n)}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";var Ca=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}},dv=0,Ig=new se,ma=new an,qr=new Je,zu=new se,Xl=new se,pv=new se,mv=new an,Rg=new se(1,0,0),Pg=new se(0,1,0),Ng=new se(0,0,1),Lg={type:"added"},gv={type:"removed"},ga={type:"childadded",child:null},Cd={type:"childremoved",child:null},Lt=class r extends Qr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:dv++}),this.uuid=us(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=r.DEFAULT_UP.clone();let e=new se,t=new vn,n=new an,i=new se(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._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:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Je},normalMatrix:{value:new gt}}),this.matrix=new Je,this.matrixWorld=new Je,this.matrixAutoUpdate=r.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=r.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ca,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,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 ma.setFromAxisAngle(e,t),this.quaternion.multiply(ma),this}rotateOnWorldAxis(e,t){return ma.setFromAxisAngle(e,t),this.quaternion.premultiply(ma),this}rotateX(e){return this.rotateOnAxis(Rg,e)}rotateY(e){return this.rotateOnAxis(Pg,e)}rotateZ(e){return this.rotateOnAxis(Ng,e)}translateOnAxis(e,t){return Ig.copy(e).applyQuaternion(this.quaternion),this.position.add(Ig.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Rg,e)}translateY(e){return this.translateOnAxis(Pg,e)}translateZ(e){return this.translateOnAxis(Ng,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(qr.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?zu.copy(e):zu.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),Xl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?qr.lookAt(Xl,zu,this.up):qr.lookAt(zu,Xl,this.up),this.quaternion.setFromRotationMatrix(qr),i&&(qr.extractRotation(i.matrixWorld),ma.setFromRotationMatrix(qr),this.quaternion.premultiply(ma.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(Lg),ga.child=e,this.dispatchEvent(ga),ga.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(gv),Cd.child=e,this.dispatchEvent(Cd),Cd.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),qr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),qr.multiply(e.parent.matrixWorld)),e.applyMatrix4(qr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Lg),ga.child=e,this.dispatchEvent(ga),ga.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 n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xl,e,pv),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xl,mv,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 n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].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.matrixWorldAutoUpdate===!0&&(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 n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?{min:a.boundingBox.min.toArray(),max:a.boundingBox.max.toArray()}:void 0,boundingSphere:a.boundingSphere?{radius:a.boundingSphere.radius,center:a.boundingSphere.center.toArray()}:void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:this.boundingSphere.center.toArray(),radius:this.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:this.boundingBox.min.toArray(),max:this.boundingBox.max.toArray()}));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){let h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),u=o(e.images),h=o(e.shapes),f=o(e.skeletons),p=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=i,n;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}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 n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}};Lt.DEFAULT_UP=new se(0,1,0);Lt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var tr=new se,jr=new se,Id=new se,Yr=new se,ya=new se,xa=new se,Og=new se,Rd=new se,Pd=new se,Nd=new se,Ld=new wt,Od=new wt,Dd=new wt,Zr=class r{constructor(e=new se,t=new se,n=new se){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),tr.subVectors(e,t),i.cross(tr);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){tr.subVectors(i,t),jr.subVectors(n,t),Id.subVectors(e,t);let o=tr.dot(tr),a=tr.dot(jr),l=tr.dot(Id),c=jr.dot(jr),u=jr.dot(Id),h=o*c-a*a;if(h===0)return s.set(0,0,0),null;let f=1/h,p=(c*l-a*u)*f,g=(o*u-a*l)*f;return s.set(1-p-g,g,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Yr)===null?!1:Yr.x>=0&&Yr.y>=0&&Yr.x+Yr.y<=1}static getInterpolation(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,Yr)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Yr.x),l.addScaledVector(o,Yr.y),l.addScaledVector(a,Yr.z),l)}static getInterpolatedAttribute(e,t,n,i,s,o){return Ld.setScalar(0),Od.setScalar(0),Dd.setScalar(0),Ld.fromBufferAttribute(e,t),Od.fromBufferAttribute(e,n),Dd.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(Ld,s.x),o.addScaledVector(Od,s.y),o.addScaledVector(Dd,s.z),o}static isFrontFacing(e,t,n,i){return tr.subVectors(n,t),jr.subVectors(e,t),tr.cross(jr).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 tr.subVectors(this.c,this.b),jr.subVectors(this.a,this.b),tr.cross(jr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return r.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return r.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return r.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return r.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return r.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,o,a;ya.subVectors(i,n),xa.subVectors(s,n),Rd.subVectors(e,n);let l=ya.dot(Rd),c=xa.dot(Rd);if(l<=0&&c<=0)return t.copy(n);Pd.subVectors(e,i);let u=ya.dot(Pd),h=xa.dot(Pd);if(u>=0&&h<=u)return t.copy(i);let f=l*h-u*c;if(f<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(ya,o);Nd.subVectors(e,s);let p=ya.dot(Nd),g=xa.dot(Nd);if(g>=0&&p<=g)return t.copy(s);let y=p*c-l*g;if(y<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(n).addScaledVector(xa,a);let d=u*g-p*h;if(d<=0&&h-u>=0&&p-g>=0)return Og.subVectors(s,i),a=(h-u)/(h-u+(p-g)),t.copy(i).addScaledVector(Og,a);let m=1/(d+y+f);return o=y*m,a=f*m,t.copy(n).addScaledVector(ya,o).addScaledVector(xa,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ny={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},Ss={h:0,s:0,l:0},Hu={h:0,s:0,l:0};function Fd(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}var He=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=yt){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,n,i=mt.workingColorSpace){return this.r=e,this.g=t,this.b=n,mt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=mt.workingColorSpace){if(e=Cp(e,1),t=Pt(t,0,1),n=Pt(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=Fd(o,s,e+1/3),this.g=Fd(o,s,e),this.b=Fd(o,s,e-1/3)}return mt.toWorkingColorSpace(this,i),this}setStyle(e,t=yt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=i[1],a=i[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 n(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 n(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 n(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(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=i[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=yt){let n=ny[e.toLowerCase()];return n!==void 0?this.setHex(n,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=Jr(e.r),this.g=Jr(e.g),this.b=Jr(e.b),this}copyLinearToSRGB(e){return this.r=ba(e.r),this.g=ba(e.g),this.b=ba(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=yt){return mt.fromWorkingColorSpace(Jn.copy(this),e),Math.round(Pt(Jn.r*255,0,255))*65536+Math.round(Pt(Jn.g*255,0,255))*256+Math.round(Pt(Jn.b*255,0,255))}getHexString(e=yt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mt.workingColorSpace){mt.fromWorkingColorSpace(Jn.copy(this),t);let n=Jn.r,i=Jn.g,s=Jn.b,o=Math.max(n,i,s),a=Math.min(n,i,s),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case n:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-n)/h+2;break;case s:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=mt.workingColorSpace){return mt.fromWorkingColorSpace(Jn.copy(this),t),e.r=Jn.r,e.g=Jn.g,e.b=Jn.b,e}getStyle(e=yt){mt.fromWorkingColorSpace(Jn.copy(this),e);let t=Jn.r,n=Jn.g,i=Jn.b;return e!==yt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Ss),this.setHSL(Ss.h+e,Ss.s+t,Ss.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Ss),e.getHSL(Hu);let n=Zl(Ss.h,Hu.h,t),i=Zl(Ss.s,Hu.s,t),s=Zl(Ss.l,Hu.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,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}},Jn=new He;He.NAMES=ny;var yv=0,zi=class extends Qr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:yv++}),this.uuid=us(),this.name="",this.type="Material",this.blending=io,this.side=wi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=fh,this.blendDst=dh,this.blendEquation=ws,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new He(0,0,0),this.blendAlpha=0,this.depthFunc=ro,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Qd,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=no,this.stencilZFail=no,this.stencilZPass=no,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.allowOverride=!0,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}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==io&&(n.blending=this.blending),this.side!==wi&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==fh&&(n.blendSrc=this.blendSrc),this.blendDst!==dh&&(n.blendDst=this.blendDst),this.blendEquation!==ws&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==ro&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Qd&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==no&&(n.stencilFail=this.stencilFail),this.stencilZFail!==no&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==no&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}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,n=null;if(t!==null){let i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,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++}},Ii=class extends zi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new He(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=Sc,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}};var An=new se,Wu=new Pe,xv=0,Vn=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:xv++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ep,this.updateRanges=[],this.gpuType=cr,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Wu.fromBufferAttribute(this,t),Wu.applyMatrix3(e),this.setXY(t,Wu.x,Wu.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)An.fromBufferAttribute(this,t),An.applyMatrix3(e),this.setXYZ(t,An.x,An.y,An.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)An.fromBufferAttribute(this,t),An.applyMatrix4(e),this.setXYZ(t,An.x,An.y,An.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)An.fromBufferAttribute(this,t),An.applyNormalMatrix(e),this.setXYZ(t,An.x,An.y,An.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)An.fromBufferAttribute(this,t),An.transformDirection(e),this.setXYZ(t,An.x,An.y,An.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Ma(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ri(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ma(t,this.array)),t}setX(e,t){return this.normalized&&(t=ri(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ma(t,this.array)),t}setY(e,t){return this.normalized&&(t=ri(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=Ma(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ri(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=Ma(t,this.array)),t}setW(e,t){return this.normalized&&(t=ri(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ri(t,this.array),n=ri(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ri(t,this.array),n=ri(n,this.array),i=ri(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=ri(t,this.array),n=ri(n,this.array),i=ri(i,this.array),s=ri(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,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!==ep&&(e.usage=this.usage),e}};var lo=class extends Vn{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var ic=class extends Vn{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var We=class extends Vn{constructor(e,t,n){super(new Float32Array(e),t,n)}},vv=0,Bi=new Je,Ud=new Lt,va=new se,Ai=new Gi,ql=new Gi,Gn=new se,It=class r extends Qr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:vv++}),this.uuid=us(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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(Ip(e)?ic:lo)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}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 n=this.attributes.normal;if(n!==void 0){let s=new gt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Bi.makeRotationFromQuaternion(e),this.applyMatrix4(Bi),this}rotateX(e){return Bi.makeRotationX(e),this.applyMatrix4(Bi),this}rotateY(e){return Bi.makeRotationY(e),this.applyMatrix4(Bi),this}rotateZ(e){return Bi.makeRotationZ(e),this.applyMatrix4(Bi),this}translate(e,t,n){return Bi.makeTranslation(e,t,n),this.applyMatrix4(Bi),this}scale(e,t,n){return Bi.makeScale(e,t,n),this.applyMatrix4(Bi),this}lookAt(e){return Ud.lookAt(e),Ud.updateMatrix(),this.applyMatrix4(Ud.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(va).negate(),this.translate(va.x,va.y,va.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,s=e.length;i<s;i++){let o=e[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new We(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gi);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 se(-1/0,-1/0,-1/0),new se(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let s=t[n];Ai.setFromBufferAttribute(s),this.morphTargetsRelative?(Gn.addVectors(this.boundingBox.min,Ai.min),this.boundingBox.expandByPoint(Gn),Gn.addVectors(this.boundingBox.max,Ai.max),this.boundingBox.expandByPoint(Gn)):(this.boundingBox.expandByPoint(Ai.min),this.boundingBox.expandByPoint(Ai.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 Vi);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 se,1/0);return}if(e){let n=this.boundingSphere.center;if(Ai.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];ql.setFromBufferAttribute(a),this.morphTargetsRelative?(Gn.addVectors(Ai.min,ql.min),Ai.expandByPoint(Gn),Gn.addVectors(Ai.max,ql.max),Ai.expandByPoint(Gn)):(Ai.expandByPoint(ql.min),Ai.expandByPoint(ql.max))}Ai.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)Gn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Gn));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Gn.fromBufferAttribute(a,c),l&&(va.fromBufferAttribute(e,c),Gn.add(va)),i=Math.max(i,n.distanceToSquared(Gn))}this.boundingSphere.radius=Math.sqrt(i),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 n=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Vn(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],l=[];for(let C=0;C<n.count;C++)a[C]=new se,l[C]=new se;let c=new se,u=new se,h=new se,f=new Pe,p=new Pe,g=new Pe,y=new se,d=new se;function m(C,E,b){c.fromBufferAttribute(n,C),u.fromBufferAttribute(n,E),h.fromBufferAttribute(n,b),f.fromBufferAttribute(s,C),p.fromBufferAttribute(s,E),g.fromBufferAttribute(s,b),u.sub(c),h.sub(c),p.sub(f),g.sub(f);let R=1/(p.x*g.y-g.x*p.y);isFinite(R)&&(y.copy(u).multiplyScalar(g.y).addScaledVector(h,-p.y).multiplyScalar(R),d.copy(h).multiplyScalar(p.x).addScaledVector(u,-g.x).multiplyScalar(R),a[C].add(y),a[E].add(y),a[b].add(y),l[C].add(d),l[E].add(d),l[b].add(d))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let C=0,E=_.length;C<E;++C){let b=_[C],R=b.start,N=b.count;for(let B=R,V=R+N;B<V;B+=3)m(e.getX(B+0),e.getX(B+1),e.getX(B+2))}let v=new se,x=new se,S=new se,I=new se;function A(C){S.fromBufferAttribute(i,C),I.copy(S);let E=a[C];v.copy(E),v.sub(S.multiplyScalar(S.dot(E))).normalize(),x.crossVectors(I,E);let R=x.dot(l[C])<0?-1:1;o.setXYZW(C,v.x,v.y,v.z,R)}for(let C=0,E=_.length;C<E;++C){let b=_[C],R=b.start,N=b.count;for(let B=R,V=R+N;B<V;B+=3)A(e.getX(B+0)),A(e.getX(B+1)),A(e.getX(B+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Vn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,p=n.count;f<p;f++)n.setXYZ(f,0,0,0);let i=new se,s=new se,o=new se,a=new se,l=new se,c=new se,u=new se,h=new se;if(e)for(let f=0,p=e.count;f<p;f+=3){let g=e.getX(f+0),y=e.getX(f+1),d=e.getX(f+2);i.fromBufferAttribute(t,g),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,d),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),a.fromBufferAttribute(n,g),l.fromBufferAttribute(n,y),c.fromBufferAttribute(n,d),a.add(u),l.add(u),c.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(y,l.x,l.y,l.z),n.setXYZ(d,c.x,c.y,c.z)}else for(let f=0,p=t.count;f<p;f+=3)i.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gn.fromBufferAttribute(e,t),Gn.normalize(),e.setXYZ(t,Gn.x,Gn.y,Gn.z)}toNonIndexed(){function e(a,l){let c=a.array,u=a.itemSize,h=a.normalized,f=new c.constructor(l.length*u),p=0,g=0;for(let y=0,d=l.length;y<d;y++){a.isInterleavedBufferAttribute?p=l[y]*a.data.stride+a.offset:p=l[y]*u;for(let m=0;m<u;m++)f[g++]=c[p++]}return new Vn(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new r,n=this.index.array,i=this.attributes;for(let a in i){let l=i[a],c=e(l,n);t.setAttribute(a,c)}let s=this.morphAttributes;for(let a in s){let l=[],c=s[a];for(let u=0,h=c.length;u<h;u++){let f=c[u],p=e(f,n);l.push(p)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.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 l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);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 n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let i={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let h=0,f=c.length;h<f;h++){let p=c[h];u.push(p.toJSON(e.data))}u.length>0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,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 n=e.index;n!==null&&this.setIndex(n.clone());let i=e.attributes;for(let c in i){let u=i[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],h=s[c];for(let f=0,p=h.length;f<p;f++)u.push(h[f].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,u=o.length;c<u;c++){let h=o[c];this.addGroup(h.start,h.count,h.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Dg=new Je,eo=new Cs,Xu=new Vi,Fg=new se,qu=new se,ju=new se,Yu=new se,kd=new se,Ku=new se,Ug=new se,Zu=new se,Dt=class extends Lt{constructor(e=new It,t=new Ii){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,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,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let a=this.morphTargetInfluences;if(s&&a){Ku.set(0,0,0);for(let l=0,c=s.length;l<c;l++){let u=a[l],h=s[l];u!==0&&(kd.fromBufferAttribute(h,e),o?Ku.addScaledVector(kd,u):Ku.addScaledVector(kd.sub(t),u))}t.add(Ku)}return t}raycast(e,t){let n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Xu.copy(n.boundingSphere),Xu.applyMatrix4(s),eo.copy(e.ray).recast(e.near),!(Xu.containsPoint(eo.origin)===!1&&(eo.intersectSphere(Xu,Fg)===null||eo.origin.distanceToSquared(Fg)>(e.far-e.near)**2))&&(Dg.copy(s).invert(),eo.copy(e.ray).applyMatrix4(Dg),!(n.boundingBox!==null&&eo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,eo)))}_computeIntersections(e,t,n){let i,s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,y=f.length;g<y;g++){let d=f[g],m=o[d.materialIndex],_=Math.max(d.start,p.start),v=Math.min(a.count,Math.min(d.start+d.count,p.start+p.count));for(let x=_,S=v;x<S;x+=3){let I=a.getX(x),A=a.getX(x+1),C=a.getX(x+2);i=Ju(this,m,e,n,c,u,h,I,A,C),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=d.materialIndex,t.push(i))}}else{let g=Math.max(0,p.start),y=Math.min(a.count,p.start+p.count);for(let d=g,m=y;d<m;d+=3){let _=a.getX(d),v=a.getX(d+1),x=a.getX(d+2);i=Ju(this,o,e,n,c,u,h,_,v,x),i&&(i.faceIndex=Math.floor(d/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,y=f.length;g<y;g++){let d=f[g],m=o[d.materialIndex],_=Math.max(d.start,p.start),v=Math.min(l.count,Math.min(d.start+d.count,p.start+p.count));for(let x=_,S=v;x<S;x+=3){let I=x,A=x+1,C=x+2;i=Ju(this,m,e,n,c,u,h,I,A,C),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=d.materialIndex,t.push(i))}}else{let g=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let d=g,m=y;d<m;d+=3){let _=d,v=d+1,x=d+2;i=Ju(this,o,e,n,c,u,h,_,v,x),i&&(i.faceIndex=Math.floor(d/3),t.push(i))}}}};function _v(r,e,t,n,i,s,o,a){let l;if(e.side===_n?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,e.side===wi,a),l===null)return null;Zu.copy(a),Zu.applyMatrix4(r.matrixWorld);let c=t.ray.origin.distanceTo(Zu);return c<t.near||c>t.far?null:{distance:c,point:Zu.clone(),object:r}}function Ju(r,e,t,n,i,s,o,a,l,c){r.getVertexPosition(a,qu),r.getVertexPosition(l,ju),r.getVertexPosition(c,Yu);let u=_v(r,e,t,n,qu,ju,Yu,Ug);if(u){let h=new se;Zr.getBarycoord(Ug,qu,ju,Yu,h),i&&(u.uv=Zr.getInterpolatedAttribute(i,a,l,c,h,new Pe)),s&&(u.uv1=Zr.getInterpolatedAttribute(s,a,l,c,h,new Pe)),o&&(u.normal=Zr.getInterpolatedAttribute(o,a,l,c,h,new se),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let f={a,b:l,c,normal:new se,materialIndex:0};Zr.getNormal(qu,ju,Yu,f.normal),u.face=f,u.barycoord=h}return u}var Is=class r extends It{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};let a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],u=[],h=[],f=0,p=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new We(c,3)),this.setAttribute("normal",new We(u,3)),this.setAttribute("uv",new We(h,2));function g(y,d,m,_,v,x,S,I,A,C,E){let b=x/A,R=S/C,N=x/2,B=S/2,V=I/2,ie=A+1,Y=C+1,te=0,q=0,le=new se;for(let ye=0;ye<Y;ye++){let Te=ye*R-B;for(let Ae=0;Ae<ie;Ae++){let _e=Ae*b-N;le[y]=_e*_,le[d]=Te*v,le[m]=V,c.push(le.x,le.y,le.z),le[y]=0,le[d]=0,le[m]=I>0?1:-1,u.push(le.x,le.y,le.z),h.push(Ae/A),h.push(1-ye/C),te+=1}}for(let ye=0;ye<C;ye++)for(let Te=0;Te<A;Te++){let Ae=f+Te+ie*ye,_e=f+Te+ie*(ye+1),G=f+(Te+1)+ie*(ye+1),P=f+(Te+1)+ie*ye;l.push(Ae,_e,P),l.push(_e,G,P),q+=6}a.addGroup(p,q,E),p+=q,f+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Mo(r){let e={};for(let t in r){e[t]={};for(let n in r[t]){let i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Qn(r){let e={};for(let t=0;t<r.length;t++){let n=Mo(r[t]);for(let i in n)e[i]=n[i]}return e}function Tv(r){let e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Rp(r){let e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:mt.workingColorSpace}var iy={clone:Mo,merge:Qn},Mv=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,_x=`void main() {
+}`,Ev=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`,mr=class extends Yi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=xx,this.fragmentShader=_x,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=ga(e.uniforms),this.uniformsGroups=vx(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 i in this.uniforms){let o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={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 n={};for(let i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},zu=class extends Rt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ye,this.projectionMatrix=new Ye,this.projectionMatrixInverse=new Ye,this.coordinateSystem=zr}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)}},ls=new oe,lg=new Ce,cg=new Ce,en=class extends zu{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=da*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(oa*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return da*2*Math.atan(Math.tan(oa*.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,n){ls.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ls.x,ls.y).multiplyScalar(-e/ls.z),ls.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ls.x,ls.y).multiplyScalar(-e/ls.z)}getViewSize(e,t){return this.getViewBounds(e,lg,cg),t.subVectors(cg,lg)}setViewOffset(e,t,n,i,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=n,this.view.offsetY=i,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(oa*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,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}},$o=-90,Qo=1,Yf=class extends Rt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new en($o,Qo,e,t);i.layers=this.layers,this.add(i);let s=new en($o,Qo,e,t);s.layers=this.layers,this.add(s);let o=new en($o,Qo,e,t);o.layers=this.layers,this.add(o);let a=new en($o,Qo,e,t);a.layers=this.layers,this.add(a);let l=new en($o,Qo,e,t);l.layers=this.layers,this.add(l);let c=new en($o,Qo,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,s,o,a,l]=t;for(let c of t)this.remove(c);if(e===zr)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.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),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===ku)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.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),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,l,c,u]=this.children,h=e.getRenderTarget(),f=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,s),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(h,f,p),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},Gl=class extends Dn{constructor(e,t,n,i,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:ca,super(e,t,n,i,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Kf=class extends Hr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Gl(i,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:bn}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 n={uniforms:{tEquirect:{value:null}},vertexShader:`
+}`,nr=class extends zi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Mv,this.fragmentShader=Ev,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=Mo(e.uniforms),this.uniformsGroups=Tv(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 i in this.uniforms){let o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={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 n={};for(let i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},rc=class extends Lt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Je,this.projectionMatrix=new Je,this.projectionMatrixInverse=new Je,this.coordinateSystem=Ar}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)}},As=new se,kg=new Pe,Bg=new Pe,nn=class extends rc{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=oo*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ea*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return oo*2*Math.atan(Math.tan(Ea*.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,n){As.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(As.x,As.y).multiplyScalar(-e/As.z),As.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(As.x,As.y).multiplyScalar(-e/As.z)}getViewSize(e,t){return this.getViewBounds(e,kg,Bg),t.subVectors(Bg,kg)}setViewOffset(e,t,n,i,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=n,this.view.offsetY=i,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(Ea*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,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}},_a=-90,Ta=1,yh=class extends Lt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new nn(_a,Ta,e,t);i.layers=this.layers,this.add(i);let s=new nn(_a,Ta,e,t);s.layers=this.layers,this.add(s);let o=new nn(_a,Ta,e,t);o.layers=this.layers,this.add(o);let a=new nn(_a,Ta,e,t);a.layers=this.layers,this.add(a);let l=new nn(_a,Ta,e,t);l.layers=this.layers,this.add(l);let c=new nn(_a,Ta,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,s,o,a,l]=t;for(let c of t)this.remove(c);if(e===Ar)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.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),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===tc)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.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),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,l,c,u]=this.children,h=e.getRenderTarget(),f=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,s),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(h,f,p),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},Ia=class extends qn{constructor(e=[],t=_o,n,i,s,o,a,l,c,u){super(e,t,n,i,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},xh=class extends wr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Ia(i,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:Pn}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 n={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},i=new Zs(5,5,5),s=new mr({name:"CubemapFromEquirect",uniforms:ga(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Tn,blending:us});s.uniforms.tEquirect.value=t;let o=new Pt(i,s),a=t.minFilter;return t.minFilter===vi&&(t.minFilter=bn),new Yf(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}},wf=new oe,Tx=new oe,Mx=new ft,Gr=class{constructor(e=new oe(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,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=wf.subVectors(n,t).cross(Tx.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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 n=e.delta(wf),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||Mx.getNormalMatrix(e),i=this.coplanarPoint(wf).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.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)}},zs=new qi,vu=new oe,Vl=class{constructor(e=new Gr,t=new Gr,n=new Gr,i=new Gr,s=new Gr,o=new Gr){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=zr){let n=this.planes,i=e.elements,s=i[0],o=i[1],a=i[2],l=i[3],c=i[4],u=i[5],h=i[6],f=i[7],p=i[8],g=i[9],v=i[10],d=i[11],m=i[12],_=i[13],y=i[14],x=i[15];if(n[0].setComponents(l-s,f-c,d-p,x-m).normalize(),n[1].setComponents(l+s,f+c,d+p,x+m).normalize(),n[2].setComponents(l+o,f+u,d+g,x+_).normalize(),n[3].setComponents(l-o,f-u,d-g,x-_).normalize(),n[4].setComponents(l-a,f-h,d-v,x-y).normalize(),t===zr)n[5].setComponents(l+a,f+h,d+v,x+y).normalize();else if(t===ku)n[5].setComponents(a,h,v,y).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(),zs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),zs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(zs)}intersectsSprite(e){return zs.center.set(0,0,0),zs.radius=.7071067811865476,zs.applyMatrix4(e.matrixWorld),this.intersectsSphere(zs)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(vu.x=i.normal.x>0?e.max.x:e.min.x,vu.y=i.normal.y>0?e.max.y:e.min.y,vu.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(vu)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function m0(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function Ex(r){let e=new WeakMap;function t(a,l){let c=a.array,u=a.usage,h=c.byteLength,f=r.createBuffer();r.bindBuffer(l,f),r.bufferData(l,c,u),a.onUploadCallback();let p;if(c instanceof Float32Array)p=r.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?p=r.HALF_FLOAT:p=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=r.SHORT;else if(c instanceof Uint32Array)p=r.UNSIGNED_INT;else if(c instanceof Int32Array)p=r.INT;else if(c instanceof Int8Array)p=r.BYTE;else if(c instanceof Uint8Array)p=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:f,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,l,c){let u=l.array,h=l._updateRange,f=l.updateRanges;if(r.bindBuffer(c,a),h.count===-1&&f.length===0&&r.bufferSubData(c,0,u),f.length!==0){for(let p=0,g=f.length;p<g;p++){let v=f[p];r.bufferSubData(c,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}l.clearUpdateRanges()}h.count!==-1&&(r.bufferSubData(c,h.offset*u.BYTES_PER_ELEMENT,u,h.offset,h.count),h.count=-1),l.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);l&&(r.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){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 c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.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.");n(c.buffer,a,l),c.version=a.version}}return{get:i,remove:s,update:o}}var va=class r extends St{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let s=e/2,o=t/2,a=Math.floor(n),l=Math.floor(i),c=a+1,u=l+1,h=e/a,f=t/l,p=[],g=[],v=[],d=[];for(let m=0;m<u;m++){let _=m*f-o;for(let y=0;y<c;y++){let x=y*h-s;g.push(x,-_,0),v.push(0,0,1),d.push(y/a),d.push(1-m/l)}}for(let m=0;m<l;m++)for(let _=0;_<a;_++){let y=_+c*m,x=_+c*(m+1),w=_+1+c*(m+1),I=_+1+c*m;p.push(y,x,I),p.push(x,w,I)}this.setIndex(p),this.setAttribute("position",new ze(g,3)),this.setAttribute("normal",new ze(v,3)),this.setAttribute("uv",new ze(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.width,e.height,e.widthSegments,e.heightSegments)}},bx=`#ifdef USE_ALPHAHASH
+ `},i=new Is(5,5,5),s=new nr({name:"CubemapFromEquirect",uniforms:Mo(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:_n,blending:as});s.uniforms.tEquirect.value=t;let o=new Dt(i,s),a=t.minFilter;return t.minFilter===xi&&(t.minFilter=Pn),new yh(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}},gn=class extends Lt{constructor(){super(),this.isGroup=!0,this.type="Group"}},bv={type:"move"},Ra=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new gn,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 gn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new se,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new se),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new gn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new se,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new se),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 n of e.hand.values())this._getHandJoint(t,n)}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,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(let y of e.hand.values()){let d=t.getJointPose(y,n),m=this._getHandJoint(c,y);d!==null&&(m.matrix.fromArray(d.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=d.radius),m.visible=d!==null}let u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],f=u.position.distanceTo(h.position),p=.02,g=.005;c.inputState.pinching&&f>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(bv)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new gn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}};var ir=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 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}};var Gg=new se,Vg=new wt,zg=new wt,Sv=new se,Hg=new Je,$u=new se,Bd=new Vi,Wg=new Je,Gd=new Cs,co=class extends Dt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Kd,this.bindMatrix=new Je,this.bindMatrixInverse=new Je,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Gi),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,$u),this.boundingBox.expandByPoint($u)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Vi),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,$u),this.boundingSphere.expandByPoint($u)}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 n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Bd.copy(this.boundingSphere),Bd.applyMatrix4(i),e.ray.intersectsSphere(Bd)!==!1&&(Wg.copy(i).invert(),Gd.copy(e.ray).applyMatrix4(Wg),!(this.boundingBox!==null&&Gd.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Gd)))}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 wt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Kd?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===B0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;Vg.fromBufferAttribute(i.attributes.skinIndex,e),zg.fromBufferAttribute(i.attributes.skinWeight,e),Gg.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=zg.getComponent(s);if(o!==0){let a=Vg.getComponent(s);Hg.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(Sv.copy(Gg).applyMatrix4(Hg),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},es=class extends Lt{constructor(){super(),this.isBone=!0,this.type="Bone"}},uo=class extends qn{constructor(e=null,t=1,n=1,i,s,o,a,l,c=Xn,u=Xn,h,f){super(null,o,a,l,c,u,i,s,h,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Xg=new Je,Av=new Je,ho=class r{constructor(e=[],t=[]){this.uuid=us(),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 n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Je)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Je;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:Av;Xg.multiplyMatrices(a,t[s]),Xg.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new r(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 n=new uo(t,e,e,Pi,cr);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let s=e.bones[n],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new es),this.bones.push(o),this.boneInverses.push(new Je().fromArray(e.boneInverses[n]))}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,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){let o=t[i];e.bones.push(o.uuid);let a=n[i];e.boneInverses.push(a.toArray())}return e}};var Vd=new se,wv=new se,Cv=new gt,Sr=class{constructor(e=new se(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,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Vd.subVectors(n,t).cross(wv.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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 n=e.delta(Vd),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||Cv.getNormalMatrix(e),i=this.coplanarPoint(Vd).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.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)}},to=new Vi,Qu=new se,Pa=class{constructor(e=new Sr,t=new Sr,n=new Sr,i=new Sr,s=new Sr,o=new Sr){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ar){let n=this.planes,i=e.elements,s=i[0],o=i[1],a=i[2],l=i[3],c=i[4],u=i[5],h=i[6],f=i[7],p=i[8],g=i[9],y=i[10],d=i[11],m=i[12],_=i[13],v=i[14],x=i[15];if(n[0].setComponents(l-s,f-c,d-p,x-m).normalize(),n[1].setComponents(l+s,f+c,d+p,x+m).normalize(),n[2].setComponents(l+o,f+u,d+g,x+_).normalize(),n[3].setComponents(l-o,f-u,d-g,x-_).normalize(),n[4].setComponents(l-a,f-h,d-y,x-v).normalize(),t===Ar)n[5].setComponents(l+a,f+h,d+y,x+v).normalize();else if(t===tc)n[5].setComponents(a,h,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(),to.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),to.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(to)}intersectsSprite(e){return to.center.set(0,0,0),to.radius=.7071067811865476,to.applyMatrix4(e.matrixWorld),this.intersectsSphere(to)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Qu.x=i.normal.x>0?e.max.x:e.min.x,Qu.y=i.normal.y>0?e.max.y:e.min.y,Qu.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Qu)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var jn=class extends zi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new He(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}},vh=new se,_h=new se,qg=new Je,jl=new Cs,eh=new Vi,zd=new se,jg=new se,Rs=class extends Lt{constructor(e=new It,t=new jn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,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,n=[0];for(let i=1,s=t.count;i<s;i++)vh.fromBufferAttribute(t,i-1),_h.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=vh.distanceTo(_h);e.setAttribute("lineDistance",new We(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),eh.copy(n.boundingSphere),eh.applyMatrix4(i),eh.radius+=s,e.ray.intersectsSphere(eh)===!1)return;qg.copy(i).invert(),jl.copy(e.ray).applyMatrix4(qg);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,u=n.index,f=n.attributes.position;if(u!==null){let p=Math.max(0,o.start),g=Math.min(u.count,o.start+o.count);for(let y=p,d=g-1;y<d;y+=c){let m=u.getX(y),_=u.getX(y+1),v=th(this,e,jl,l,m,_,y);v&&t.push(v)}if(this.isLineLoop){let y=u.getX(g-1),d=u.getX(p),m=th(this,e,jl,l,y,d,g-1);m&&t.push(m)}}else{let p=Math.max(0,o.start),g=Math.min(f.count,o.start+o.count);for(let y=p,d=g-1;y<d;y+=c){let m=th(this,e,jl,l,y,y+1,y);m&&t.push(m)}if(this.isLineLoop){let y=th(this,e,jl,l,g-1,p,g-1);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};function th(r,e,t,n,i,s,o){let a=r.geometry.attributes.position;if(vh.fromBufferAttribute(a,i),_h.fromBufferAttribute(a,s),t.distanceSqToSegment(vh,_h,zd,jg)>n)return;zd.applyMatrix4(r.matrixWorld);let c=e.ray.origin.distanceTo(zd);if(!(c<e.near||c>e.far))return{distance:c,point:jg.clone().applyMatrix4(r.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:r}}var Yg=new se,Kg=new se,rr=class extends Rs{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,n=[];for(let i=0,s=t.count;i<s;i+=2)Yg.fromBufferAttribute(t,i),Kg.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Yg.distanceTo(Kg);e.setAttribute("lineDistance",new We(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Na=class extends zi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new He(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}},Zg=new Je,tp=new Cs,nh=new Vi,ih=new se,sc=class extends Lt{constructor(e=new It,t=new Na){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,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 n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),nh.copy(n.boundingSphere),nh.applyMatrix4(i),nh.radius+=s,e.ray.intersectsSphere(nh)===!1)return;Zg.copy(i).invert(),tp.copy(e.ray).applyMatrix4(Zg);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,h=n.attributes.position;if(c!==null){let f=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let g=f,y=p;g<y;g++){let d=c.getX(g);ih.fromBufferAttribute(h,d),Jg(ih,d,l,i,e,t,this)}}else{let f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let g=f,y=p;g<y;g++)ih.fromBufferAttribute(h,g),Jg(ih,g,l,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};function Jg(r,e,t,n,i,s,o){let a=tp.distanceSqToPoint(r);if(a<t){let l=new se;tp.closestPointToPoint(r,l),l.applyMatrix4(n);let c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var oc=class extends qn{constructor(e,t,n=Ls,i,s,o,a=Xn,l=Xn,c,u=Sa){if(u!==Sa&&u!==Va)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super(null,i,s,o,a,l,u,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new wa(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};var La=class r extends It{constructor(e=1,t=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let u=[],h=[],f=[],p=[],g=0,y=[],d=n/2,m=0;_(),o===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new We(h,3)),this.setAttribute("normal",new We(f,3)),this.setAttribute("uv",new We(p,2));function _(){let x=new se,S=new se,I=0,A=(t-e)/n;for(let C=0;C<=s;C++){let E=[],b=C/s,R=b*(t-e)+e;for(let N=0;N<=i;N++){let B=N/i,V=B*l+a,ie=Math.sin(V),Y=Math.cos(V);S.x=R*ie,S.y=-b*n+d,S.z=R*Y,h.push(S.x,S.y,S.z),x.set(ie,A,Y).normalize(),f.push(x.x,x.y,x.z),p.push(B,1-b),E.push(g++)}y.push(E)}for(let C=0;C<i;C++)for(let E=0;E<s;E++){let b=y[E][C],R=y[E+1][C],N=y[E+1][C+1],B=y[E][C+1];(e>0||E!==0)&&(u.push(b,R,B),I+=3),(t>0||E!==s-1)&&(u.push(R,N,B),I+=3)}c.addGroup(m,I,0),m+=I}function v(x){let S=g,I=new Pe,A=new se,C=0,E=x===!0?e:t,b=x===!0?1:-1;for(let N=1;N<=i;N++)h.push(0,d*b,0),f.push(0,b,0),p.push(.5,.5),g++;let R=g;for(let N=0;N<=i;N++){let V=N/i*l+a,ie=Math.cos(V),Y=Math.sin(V);A.x=E*Y,A.y=d*b,A.z=E*ie,h.push(A.x,A.y,A.z),f.push(0,b,0),I.x=ie*.5+.5,I.y=Y*.5*b+.5,p.push(I.x,I.y),g++}for(let N=0;N<i;N++){let B=S+N,V=R+N;x===!0?u.push(V,V+1,B):u.push(V+1,V,B),C+=3}c.addGroup(m,C,x===!0?1:2),m+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ac=class r extends La{constructor(e=1,t=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new r(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}};var rh=new se,sh=new se,Hd=new se,oh=new Zr,lc=class extends It{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let i=Math.pow(10,4),s=Math.cos(Ea*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],h=new Array(3),f={},p=[];for(let g=0;g<l;g+=3){o?(c[0]=o.getX(g),c[1]=o.getX(g+1),c[2]=o.getX(g+2)):(c[0]=g,c[1]=g+1,c[2]=g+2);let{a:y,b:d,c:m}=oh;if(y.fromBufferAttribute(a,c[0]),d.fromBufferAttribute(a,c[1]),m.fromBufferAttribute(a,c[2]),oh.getNormal(Hd),h[0]=`${Math.round(y.x*i)},${Math.round(y.y*i)},${Math.round(y.z*i)}`,h[1]=`${Math.round(d.x*i)},${Math.round(d.y*i)},${Math.round(d.z*i)}`,h[2]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let _=0;_<3;_++){let v=(_+1)%3,x=h[_],S=h[v],I=oh[u[_]],A=oh[u[v]],C=`${x}_${S}`,E=`${S}_${x}`;E in f&&f[E]?(Hd.dot(f[E].normal)<=s&&(p.push(I.x,I.y,I.z),p.push(A.x,A.y,A.z)),f[E]=null):C in f||(f[C]={index0:c[_],index1:c[v],normal:Hd.clone()})}}for(let g in f)if(f[g]){let{index0:y,index1:d}=f[g];rh.fromBufferAttribute(a,y),sh.fromBufferAttribute(a,d),p.push(rh.x,rh.y,rh.z),p.push(sh.x,sh.y,sh.z)}this.setAttribute("position",new We(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},si=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/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=[],n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),i=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let u=n[i],f=n[i+1]-u,p=(o-u)/f;return(i+p)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new Pe:new se);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new se,i=[],s=[],o=[],a=new se,l=new Je;for(let p=0;p<=e;p++){let g=p/e;i[p]=this.getTangentAt(g,new se)}s[0]=new se,o[0]=new se;let c=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=c&&(c=u,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),f<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();let g=Math.acos(Pt(i[p-1].dot(i[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,g))}o[p].crossVectors(i[p],s[p])}if(t===!0){let p=Math.acos(Pt(s[0].dot(s[e]),-1,1));p/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(p=-p);for(let g=1;g<=e;g++)s[g].applyMatrix4(l.makeRotationAxis(i[g],p*g)),o[g].crossVectors(i[g],s[g])}return{tangents:i,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}},Oa=class extends si{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new Pe){let n=t,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=l-this.aX,p=c-this.aY;l=f*u-p*h+this.aX,c=f*h+p*u+this.aY}return n.set(l,c)}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}},Th=class extends Oa{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Pp(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let f=(o-s)/c-(a-s)/(c+u)+(a-o)/u,p=(a-o)/u-(l-o)/(u+h)+(l-a)/h;f*=u,p*=u,i(o,a,f,p)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+n*a}}}var ah=new se,Wd=new Pp,Xd=new Pp,qd=new Pp,Mh=class extends si{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new se){let n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%s]:(ah.subVectors(i[0],i[1]).add(i[0]),c=ah);let h=i[a%s],f=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(ah.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=ah),this.curveType==="centripetal"||this.curveType==="chordal"){let p=this.curveType==="chordal"?.5:.25,g=Math.pow(c.distanceToSquared(h),p),y=Math.pow(h.distanceToSquared(f),p),d=Math.pow(f.distanceToSquared(u),p);y<1e-4&&(y=1),g<1e-4&&(g=y),d<1e-4&&(d=y),Wd.initNonuniformCatmullRom(c.x,h.x,f.x,u.x,g,y,d),Xd.initNonuniformCatmullRom(c.y,h.y,f.y,u.y,g,y,d),qd.initNonuniformCatmullRom(c.z,h.z,f.z,u.z,g,y,d)}else this.curveType==="catmullrom"&&(Wd.initCatmullRom(c.x,h.x,f.x,u.x,this.tension),Xd.initCatmullRom(c.y,h.y,f.y,u.y,this.tension),qd.initCatmullRom(c.z,h.z,f.z,u.z,this.tension));return n.set(Wd.calc(l),Xd.calc(l),qd.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.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,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.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,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new se().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function $g(r,e,t,n,i){let s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function Iv(r,e){let t=1-r;return t*t*e}function Rv(r,e){return 2*(1-r)*r*e}function Pv(r,e){return r*r*e}function Jl(r,e,t,n){return Iv(r,e)+Rv(r,t)+Pv(r,n)}function Nv(r,e){let t=1-r;return t*t*t*e}function Lv(r,e){let t=1-r;return 3*t*t*r*e}function Ov(r,e){return 3*(1-r)*r*r*e}function Dv(r,e){return r*r*r*e}function $l(r,e,t,n,i){return Nv(r,e)+Lv(r,t)+Ov(r,n)+Dv(r,i)}var cc=class extends si{constructor(e=new Pe,t=new Pe,n=new Pe,i=new Pe){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Pe){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set($l(e,i.x,s.x,o.x,a.x),$l(e,i.y,s.y,o.y,a.y)),n}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}},Eh=class extends si{constructor(e=new se,t=new se,n=new se,i=new se){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new se){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set($l(e,i.x,s.x,o.x,a.x),$l(e,i.y,s.y,o.y,a.y),$l(e,i.z,s.z,o.z,a.z)),n}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}},uc=class extends si{constructor(e=new Pe,t=new Pe){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Pe){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Pe){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}},bh=class extends si{constructor(e=new se,t=new se){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new se){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}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}},hc=class extends si{constructor(e=new Pe,t=new Pe,n=new Pe){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Pe){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Jl(e,i.x,s.x,o.x),Jl(e,i.y,s.y,o.y)),n}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}},Sh=class extends si{constructor(e=new se,t=new se,n=new se){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new se){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Jl(e,i.x,s.x,o.x),Jl(e,i.y,s.y,o.y),Jl(e,i.z,s.z,o.z)),n}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}},fc=class extends si{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Pe){let n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set($g(a,l.x,c.x,u.x,h.x),$g(a,l.y,c.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new Pe().fromArray(i))}return this}},np=Object.freeze({__proto__:null,ArcCurve:Th,CatmullRomCurve3:Mh,CubicBezierCurve:cc,CubicBezierCurve3:Eh,EllipseCurve:Oa,LineCurve:uc,LineCurve3:bh,QuadraticBezierCurve:hc,QuadraticBezierCurve3:Sh,SplineCurve:fc}),Ah=class extends si{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 n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new np[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,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 n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){let u=l[c];n&&n.equals(u)||(t.push(u),n=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,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(new np[i.type]().fromJSON(i))}return this}},Cr=class extends Ah{constructor(e){super(),this.type="Path",this.currentPoint=new Pe,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;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 n=new uc(this.currentPoint.clone(),new Pe(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let s=new hc(this.currentPoint.clone(),new Pe(e,t),new Pe(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){let a=new cc(this.currentPoint.clone(),new Pe(e,t),new Pe(n,i),new Pe(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new fc(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){let c=new Oa(e,t,n,i,s,o,a,l);if(this.curves.length>0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.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}},$r=class extends Cr{constructor(e){super(e),this.uuid=us(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].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,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(new Cr().fromJSON(i))}return this}};function Fv(r,e,t=2){let n=e&&e.length,i=n?e[0]*t:r.length,s=ry(r,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(n&&(s=Vv(r,e,s,t)),r.length>80*t){a=1/0,l=1/0;let u=-1/0,h=-1/0;for(let f=t;f<i;f+=t){let p=r[f],g=r[f+1];p<a&&(a=p),g<l&&(l=g),p>u&&(u=p),g>h&&(h=g)}c=Math.max(u-a,h-l),c=c!==0?32767/c:0}return dc(s,o,t,a,l,c,0),o}function ry(r,e,t,n,i){let s;if(i===$v(r,e,t,n)>0)for(let o=e;o<t;o+=n)s=Qg(o/n|0,r[o],r[o+1],s);else for(let o=t-n;o>=e;o-=n)s=Qg(o/n|0,r[o],r[o+1],s);return s&&Da(s,s.next)&&(mc(s),s=s.next),s}function fo(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(Da(t,t.next)||mn(t.prev,t,t.next)===0)){if(mc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function dc(r,e,t,n,i,s,o){if(!r)return;!o&&s&&qv(r,n,i,s);let a=r;for(;r.prev!==r.next;){let l=r.prev,c=r.next;if(s?kv(r,n,i,s):Uv(r)){e.push(l.i,r.i,c.i),mc(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=Bv(fo(r),e),dc(r,e,t,n,i,s,2)):o===2&&Gv(r,e,t,n,i,s):dc(fo(r),e,t,n,i,s,1);break}}}function Uv(r){let e=r.prev,t=r,n=r.next;if(mn(e,t,n)>=0)return!1;let i=e.x,s=t.x,o=n.x,a=e.y,l=t.y,c=n.y,u=Math.min(i,s,o),h=Math.min(a,l,c),f=Math.max(i,s,o),p=Math.max(a,l,c),g=n.next;for(;g!==e;){if(g.x>=u&&g.x<=f&&g.y>=h&&g.y<=p&&Kl(i,a,s,l,o,c,g.x,g.y)&&mn(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function kv(r,e,t,n){let i=r.prev,s=r,o=r.next;if(mn(i,s,o)>=0)return!1;let a=i.x,l=s.x,c=o.x,u=i.y,h=s.y,f=o.y,p=Math.min(a,l,c),g=Math.min(u,h,f),y=Math.max(a,l,c),d=Math.max(u,h,f),m=ip(p,g,e,t,n),_=ip(y,d,e,t,n),v=r.prevZ,x=r.nextZ;for(;v&&v.z>=m&&x&&x.z<=_;){if(v.x>=p&&v.x<=y&&v.y>=g&&v.y<=d&&v!==i&&v!==o&&Kl(a,u,l,h,c,f,v.x,v.y)&&mn(v.prev,v,v.next)>=0||(v=v.prevZ,x.x>=p&&x.x<=y&&x.y>=g&&x.y<=d&&x!==i&&x!==o&&Kl(a,u,l,h,c,f,x.x,x.y)&&mn(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;v&&v.z>=m;){if(v.x>=p&&v.x<=y&&v.y>=g&&v.y<=d&&v!==i&&v!==o&&Kl(a,u,l,h,c,f,v.x,v.y)&&mn(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=_;){if(x.x>=p&&x.x<=y&&x.y>=g&&x.y<=d&&x!==i&&x!==o&&Kl(a,u,l,h,c,f,x.x,x.y)&&mn(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Bv(r,e){let t=r;do{let n=t.prev,i=t.next.next;!Da(n,i)&&oy(n,t,t.next,i)&&pc(n,i)&&pc(i,n)&&(e.push(n.i,t.i,i.i),mc(t),mc(t.next),t=r=i),t=t.next}while(t!==r);return fo(t)}function Gv(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Kv(o,a)){let l=ay(o,a);o=fo(o,o.next),l=fo(l,l.next),dc(o,e,t,n,i,s,0),dc(l,e,t,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function Vv(r,e,t,n){let i=[];for(let s=0,o=e.length;s<o;s++){let a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,c=ry(r,a,l,n,!1);c===c.next&&(c.steiner=!0),i.push(Yv(c))}i.sort(zv);for(let s=0;s<i.length;s++)t=Hv(i[s],t);return t}function zv(r,e){let t=r.x-e.x;if(t===0&&(t=r.y-e.y,t===0)){let n=(r.next.y-r.y)/(r.next.x-r.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=n-i}return t}function Hv(r,e){let t=Wv(r,e);if(!t)return e;let n=ay(t,r);return fo(n,n.next),fo(t,t.next)}function Wv(r,e){let t=e,n=r.x,i=r.y,s=-1/0,o;if(Da(r,t))return t;do{if(Da(r,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){let h=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=n&&h>s&&(s=h,o=t.x<t.next.x?t:t.next,h===n))return o}t=t.next}while(t!==e);if(!o)return null;let a=o,l=o.x,c=o.y,u=1/0;t=o;do{if(n>=t.x&&t.x>=l&&n!==t.x&&sy(i<c?n:s,i,l,c,i<c?s:n,i,t.x,t.y)){let h=Math.abs(i-t.y)/(n-t.x);pc(t,r)&&(h<u||h===u&&(t.x>o.x||t.x===o.x&&Xv(o,t)))&&(o=t,u=h)}t=t.next}while(t!==a);return o}function Xv(r,e){return mn(r.prev,r,e.prev)<0&&mn(e.next,r,r.next)<0}function qv(r,e,t,n){let i=r;do i.z===0&&(i.z=ip(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,jv(i)}function jv(r){let e,t=1;do{let n=r,i;r=null;let s=null;for(e=0;n;){e++;let o=n,a=0;for(let c=0;c<t&&(a++,o=o.nextZ,!!o);c++);let l=t;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||n.z<=o.z)?(i=n,n=n.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;n=o}s.nextZ=null,t*=2}while(e>1);return r}function ip(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function Yv(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function sy(r,e,t,n,i,s,o,a){return(i-o)*(e-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(n-a)}function Kl(r,e,t,n,i,s,o,a){return!(r===o&&e===a)&&sy(r,e,t,n,i,s,o,a)}function Kv(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!Zv(r,e)&&(pc(r,e)&&pc(e,r)&&Jv(r,e)&&(mn(r.prev,r,e.prev)||mn(r,e.prev,e))||Da(r,e)&&mn(r.prev,r,r.next)>0&&mn(e.prev,e,e.next)>0)}function mn(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Da(r,e){return r.x===e.x&&r.y===e.y}function oy(r,e,t,n){let i=ch(mn(r,e,t)),s=ch(mn(r,e,n)),o=ch(mn(t,n,r)),a=ch(mn(t,n,e));return!!(i!==s&&o!==a||i===0&&lh(r,t,e)||s===0&&lh(r,n,e)||o===0&&lh(t,r,n)||a===0&&lh(t,e,n))}function lh(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function ch(r){return r>0?1:r<0?-1:0}function Zv(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&oy(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function pc(r,e){return mn(r.prev,r,r.next)<0?mn(r,e,r.next)>=0&&mn(r,r.prev,e)>=0:mn(r,e,r.prev)<0||mn(r,r.next,e)<0}function Jv(r,e){let t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function ay(r,e){let t=rp(r.i,r.x,r.y),n=rp(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Qg(r,e,t,n){let i=rp(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function mc(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function rp(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function $v(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var sp=class{static triangulate(e,t,n=2){return Fv(e,t,n)}},gi=class r{static area(e){let t=e.length,n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return r.area(e)<0}static triangulateShape(e,t){let n=[],i=[],s=[];e0(e),t0(n,e);let o=e.length;t.forEach(e0);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,t0(n,t[l]);let a=sp.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function e0(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function t0(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var gc=class r extends It{constructor(e=new $r([new Pe(.5,.5),new Pe(-.5,.5),new Pe(-.5,-.5),new Pe(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,i=[],s=[];for(let a=0,l=e.length;a<l;a++){let c=e[a];o(c)}this.setAttribute("position",new We(i,3)),this.setAttribute("uv",new We(s,2)),this.computeVertexNormals();function o(a){let l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1,f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:p-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,d=t.bevelSegments!==void 0?t.bevelSegments:3,m=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:Qv,v,x=!1,S,I,A,C;m&&(v=m.getSpacedPoints(u),x=!0,f=!1,S=m.computeFrenetFrames(u,!1),I=new se,A=new se,C=new se),f||(d=0,p=0,g=0,y=0);let E=a.extractPoints(c),b=E.shape,R=E.holes;if(!gi.isClockWise(b)){b=b.reverse();for(let w=0,ae=R.length;w<ae;w++){let pe=R[w];gi.isClockWise(pe)&&(R[w]=pe.reverse())}}function B(w){let pe=10000000000000001e-36,ue=w[0];for(let ee=1;ee<=w.length;ee++){let $=ee%w.length,ve=w[$],H=ve.x-ue.x,L=ve.y-ue.y,O=H*H+L*L,D=Math.max(Math.abs(ve.x),Math.abs(ve.y),Math.abs(ue.x),Math.abs(ue.y)),z=pe*D*D;if(O<=z){w.splice($,1),ee--;continue}ue=ve}}B(b),R.forEach(B);let V=R.length,ie=b;for(let w=0;w<V;w++){let ae=R[w];b=b.concat(ae)}function Y(w,ae,pe){return ae||console.error("THREE.ExtrudeGeometry: vec does not exist"),w.clone().addScaledVector(ae,pe)}let te=b.length;function q(w,ae,pe){let ue,ee,$,ve=w.x-ae.x,H=w.y-ae.y,L=pe.x-w.x,O=pe.y-w.y,D=ve*ve+H*H,z=ve*O-H*L;if(Math.abs(z)>Number.EPSILON){let Q=Math.sqrt(D),ne=Math.sqrt(L*L+O*O),oe=ae.x-H/Q,he=ae.y+ve/Q,ge=pe.x-O/ne,de=pe.y+L/ne,Ee=((ge-oe)*O-(de-he)*L)/(ve*O-H*L);ue=oe+ve*Ee-w.x,ee=he+H*Ee-w.y;let Re=ue*ue+ee*ee;if(Re<=2)return new Pe(ue,ee);$=Math.sqrt(Re/2)}else{let Q=!1;ve>Number.EPSILON?L>Number.EPSILON&&(Q=!0):ve<-Number.EPSILON?L<-Number.EPSILON&&(Q=!0):Math.sign(H)===Math.sign(O)&&(Q=!0),Q?(ue=-H,ee=ve,$=Math.sqrt(D)):(ue=ve,ee=H,$=Math.sqrt(D/2))}return new Pe(ue/$,ee/$)}let le=[];for(let w=0,ae=ie.length,pe=ae-1,ue=w+1;w<ae;w++,pe++,ue++)pe===ae&&(pe=0),ue===ae&&(ue=0),le[w]=q(ie[w],ie[pe],ie[ue]);let ye=[],Te,Ae=le.concat();for(let w=0,ae=V;w<ae;w++){let pe=R[w];Te=[];for(let ue=0,ee=pe.length,$=ee-1,ve=ue+1;ue<ee;ue++,$++,ve++)$===ee&&($=0),ve===ee&&(ve=0),Te[ue]=q(pe[ue],pe[$],pe[ve]);ye.push(Te),Ae=Ae.concat(Te)}let _e;if(d===0)_e=gi.triangulateShape(ie,R);else{let w=[],ae=[];for(let pe=0;pe<d;pe++){let ue=pe/d,ee=p*Math.cos(ue*Math.PI/2),$=g*Math.sin(ue*Math.PI/2)+y;for(let ve=0,H=ie.length;ve<H;ve++){let L=Y(ie[ve],le[ve],$);j(L.x,L.y,-ee),ue===0&&w.push(L)}for(let ve=0,H=V;ve<H;ve++){let L=R[ve];Te=ye[ve];let O=[];for(let D=0,z=L.length;D<z;D++){let Q=Y(L[D],Te[D],$);j(Q.x,Q.y,-ee),ue===0&&O.push(Q)}ue===0&&ae.push(O)}}_e=gi.triangulateShape(w,ae)}let G=_e.length,P=g+y;for(let w=0;w<te;w++){let ae=f?Y(b[w],Ae[w],P):b[w];x?(A.copy(S.normals[0]).multiplyScalar(ae.x),I.copy(S.binormals[0]).multiplyScalar(ae.y),C.copy(v[0]).add(A).add(I),j(C.x,C.y,C.z)):j(ae.x,ae.y,0)}for(let w=1;w<=u;w++)for(let ae=0;ae<te;ae++){let pe=f?Y(b[ae],Ae[ae],P):b[ae];x?(A.copy(S.normals[w]).multiplyScalar(pe.x),I.copy(S.binormals[w]).multiplyScalar(pe.y),C.copy(v[w]).add(A).add(I),j(C.x,C.y,C.z)):j(pe.x,pe.y,h/u*w)}for(let w=d-1;w>=0;w--){let ae=w/d,pe=p*Math.cos(ae*Math.PI/2),ue=g*Math.sin(ae*Math.PI/2)+y;for(let ee=0,$=ie.length;ee<$;ee++){let ve=Y(ie[ee],le[ee],ue);j(ve.x,ve.y,h+pe)}for(let ee=0,$=R.length;ee<$;ee++){let ve=R[ee];Te=ye[ee];for(let H=0,L=ve.length;H<L;H++){let O=Y(ve[H],Te[H],ue);x?j(O.x,O.y+v[u-1].y,v[u-1].x+pe):j(O.x,O.y,h+pe)}}}M(),T();function M(){let w=i.length/3;if(f){let ae=0,pe=te*ae;for(let ue=0;ue<G;ue++){let ee=_e[ue];W(ee[2]+pe,ee[1]+pe,ee[0]+pe)}ae=u+d*2,pe=te*ae;for(let ue=0;ue<G;ue++){let ee=_e[ue];W(ee[0]+pe,ee[1]+pe,ee[2]+pe)}}else{for(let ae=0;ae<G;ae++){let pe=_e[ae];W(pe[2],pe[1],pe[0])}for(let ae=0;ae<G;ae++){let pe=_e[ae];W(pe[0]+te*u,pe[1]+te*u,pe[2]+te*u)}}n.addGroup(w,i.length/3-w,0)}function T(){let w=i.length/3,ae=0;k(ie,ae),ae+=ie.length;for(let pe=0,ue=R.length;pe<ue;pe++){let ee=R[pe];k(ee,ae),ae+=ee.length}n.addGroup(w,i.length/3-w,1)}function k(w,ae){let pe=w.length;for(;--pe>=0;){let ue=pe,ee=pe-1;ee<0&&(ee=w.length-1);for(let $=0,ve=u+d*2;$<ve;$++){let H=te*$,L=te*($+1),O=ae+ue+H,D=ae+ee+H,z=ae+ee+L,Q=ae+ue+L;re(O,D,z,Q)}}}function j(w,ae,pe){l.push(w),l.push(ae),l.push(pe)}function W(w,ae,pe){ce(w),ce(ae),ce(pe);let ue=i.length/3,ee=_.generateTopUV(n,i,ue-3,ue-2,ue-1);me(ee[0]),me(ee[1]),me(ee[2])}function re(w,ae,pe,ue){ce(w),ce(ae),ce(ue),ce(ae),ce(pe),ce(ue);let ee=i.length/3,$=_.generateSideWallUV(n,i,ee-6,ee-3,ee-2,ee-1);me($[0]),me($[1]),me($[3]),me($[1]),me($[2]),me($[3])}function ce(w){i.push(l[w*3+0]),i.push(l[w*3+1]),i.push(l[w*3+2])}function me(w){s.push(w.x),s.push(w.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return e_(t,n,e)}static fromJSON(e,t){let n=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];n.push(a)}let i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new np[i.type]().fromJSON(i)),new r(n,e.options)}},Qv={generateTopUV:function(r,e,t,n,i){let s=e[t*3],o=e[t*3+1],a=e[n*3],l=e[n*3+1],c=e[i*3],u=e[i*3+1];return[new Pe(s,o),new Pe(a,l),new Pe(c,u)]},generateSideWallUV:function(r,e,t,n,i,s){let o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[n*3],u=e[n*3+1],h=e[n*3+2],f=e[i*3],p=e[i*3+1],g=e[i*3+2],y=e[s*3],d=e[s*3+1],m=e[s*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new Pe(o,1-l),new Pe(c,1-h),new Pe(f,1-g),new Pe(y,1-m)]:[new Pe(a,1-l),new Pe(u,1-h),new Pe(p,1-g),new Pe(d,1-m)]}};function e_(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){let s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var po=class r extends It{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let s=e/2,o=t/2,a=Math.floor(n),l=Math.floor(i),c=a+1,u=l+1,h=e/a,f=t/l,p=[],g=[],y=[],d=[];for(let m=0;m<u;m++){let _=m*f-o;for(let v=0;v<c;v++){let x=v*h-s;g.push(x,-_,0),y.push(0,0,1),d.push(v/a),d.push(1-m/l)}}for(let m=0;m<l;m++)for(let _=0;_<a;_++){let v=_+c*m,x=_+c*(m+1),S=_+1+c*(m+1),I=_+1+c*m;p.push(v,x,I),p.push(x,S,I)}this.setIndex(p),this.setAttribute("position",new We(g,3)),this.setAttribute("normal",new We(y,3)),this.setAttribute("uv",new We(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.width,e.height,e.widthSegments,e.heightSegments)}};var mo=class r extends It{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),c=0,u=[],h=new se,f=new se,p=[],g=[],y=[],d=[];for(let m=0;m<=n;m++){let _=[],v=m/n,x=0;m===0&&o===0?x=.5/t:m===n&&l===Math.PI&&(x=-.5/t);for(let S=0;S<=t;S++){let I=S/t;h.x=-e*Math.cos(i+I*s)*Math.sin(o+v*a),h.y=e*Math.cos(o+v*a),h.z=e*Math.sin(i+I*s)*Math.sin(o+v*a),g.push(h.x,h.y,h.z),f.copy(h).normalize(),y.push(f.x,f.y,f.z),d.push(I+x,1-v),_.push(c++)}u.push(_)}for(let m=0;m<n;m++)for(let _=0;_<t;_++){let v=u[m][_+1],x=u[m][_],S=u[m+1][_],I=u[m+1][_+1];(m!==0||o>0)&&p.push(v,x,I),(m!==n-1||l<Math.PI)&&p.push(x,S,I)}this.setIndex(p),this.setAttribute("position",new We(g,3)),this.setAttribute("normal",new We(y,3)),this.setAttribute("uv",new We(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var ts=class extends zi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new He(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 He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lc,this.normalScale=new Pe(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}};var Zt=class extends zi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new He(16777215),this.specular=new He(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lc,this.normalScale=new Pe(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=Sc,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}};var go=class extends zi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new He(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lc,this.normalScale=new Pe(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=Sc,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}},wh=class extends zi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=z0,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}},Ch=class extends zi{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}};function uh(r,e){return!r||r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function t_(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function n_(r){function e(i,s){return r[i]-r[s]}let t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function n0(r,e,t){let n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i}function ly(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push(...o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)}var yo=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Ih=class extends yo{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Zd,endingEnd:Zd}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Jd:s=e,a=2*t-n;break;case $d:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Jd:o=e,l=2*n-t;break;case $d:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}let c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,f=this._weightPrev,p=this._weightNext,g=(n-t)/(i-t),y=g*g,d=y*g,m=-f*d+2*f*y-f*g,_=(1+f)*d+(-1.5-2*f)*y+(-.5+f)*g+1,v=(-1-p)*d+(1.5+p)*y+.5*g,x=p*d-p*y;for(let S=0;S!==a;++S)s[S]=m*o[u+S]+_*o[c+S]+v*o[l+S]+x*o[h+S];return s}},Rh=class extends yo{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(n-t)/(i-t),h=1-u;for(let f=0;f!==a;++f)s[f]=o[c+f]*h+o[l+f]*u;return s}},Ph=class extends yo{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},yi=class{constructor(e,t,n,i){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=uh(t,this.TimeBufferType),this.values=uh(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:uh(e.times,Array),values:uh(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Ph(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Rh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ih(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ql:t=this.InterpolantFactoryMethodDiscrete;break;case ph:t=this.InterpolantFactoryMethodLinear;break;case hh:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="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(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ql;case this.InterpolantFactoryMethodLinear:return ph;case this.InterpolantFactoryMethodSmooth:return hh}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=n.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 n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&t_(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===hh,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(i)l=!0;else{let h=a*n,f=h-n,p=h+n;for(let g=0;g!==n;++g){let y=t[h+g];if(y!==t[f+g]||y!==t[p+g]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let h=a*n,f=o*n;for(let p=0;p!==n;++p)t[f+p]=t[h+p]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};yi.prototype.ValueTypeName="";yi.prototype.TimeBufferType=Float32Array;yi.prototype.ValueBufferType=Float32Array;yi.prototype.DefaultInterpolation=ph;var ns=class extends yi{constructor(e,t,n){super(e,t,n)}};ns.prototype.ValueTypeName="bool";ns.prototype.ValueBufferType=Array;ns.prototype.DefaultInterpolation=Ql;ns.prototype.InterpolantFactoryMethodLinear=void 0;ns.prototype.InterpolantFactoryMethodSmooth=void 0;var yc=class extends yi{constructor(e,t,n,i){super(e,t,n,i)}};yc.prototype.ValueTypeName="color";var is=class extends yi{constructor(e,t,n,i){super(e,t,n,i)}};is.prototype.ValueTypeName="number";var Nh=class extends yo{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),c=e*a;for(let u=c+a;c!==u;c+=4)an.slerpFlat(s,0,o,c-a,o,c,l);return s}},Hi=class extends yi{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Nh(this.times,this.values,this.getValueSize(),e)}};Hi.prototype.ValueTypeName="quaternion";Hi.prototype.InterpolantFactoryMethodSmooth=void 0;var rs=class extends yi{constructor(e,t,n){super(e,t,n)}};rs.prototype.ValueTypeName="string";rs.prototype.ValueBufferType=Array;rs.prototype.DefaultInterpolation=Ql;rs.prototype.InterpolantFactoryMethodLinear=void 0;rs.prototype.InterpolantFactoryMethodSmooth=void 0;var Wi=class extends yi{constructor(e,t,n,i){super(e,t,n,i)}};Wi.prototype.ValueTypeName="vector";var Ps=class{constructor(e="",t=-1,n=[],i=V0){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=us(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(r_(n[o]).scale(i));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(yi.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let s=t.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);let u=n_(l);l=n0(l,1,u),c=n0(c,1,u),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new is(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){let c=e[a],u=c.name.match(s);if(u&&u.length>1){let h=u[1],f=i[h];f||(i[h]=f=[]),f.push(c)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,f,p,g,y){if(p.length!==0){let d=[],m=[];ly(p,d,m,g),d.length!==0&&y.push(new h(f,d,m))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let h=0;h<c.length;h++){let f=c[h].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let p={},g;for(g=0;g<f.length;g++)if(f[g].morphTargets)for(let y=0;y<f[g].morphTargets.length;y++)p[f[g].morphTargets[y]]=-1;for(let y in p){let d=[],m=[];for(let _=0;_!==f[g].morphTargets.length;++_){let v=f[g];d.push(v.time),m.push(v.morphTarget===y?1:0)}i.push(new is(".morphTargetInfluence["+y+"]",d,m))}l=p.length*o}else{let p=".bones["+t[h].name+"]";n(Wi,p+".position",f,"pos",i),n(Hi,p+".quaternion",f,"rot",i),n(Wi,p+".scale",f,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let s=this.tracks[n];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)}};function i_(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return is;case"vector":case"vector2":case"vector3":case"vector4":return Wi;case"color":return yc;case"quaternion":return Hi;case"bool":case"boolean":return ns;case"string":return rs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function r_(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=i_(r.type);if(r.times===void 0){let t=[],n=[];ly(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}var xc={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},Fa=class{constructor(e,t,n){let i=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){a++,s===!1&&i.onStart!==void 0&&i.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){let h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=c.length;h<f;h+=2){let p=c[h],g=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return g}return null}}},cy=new Fa,zt=class{constructor(e){this.manager=e!==void 0?e:cy,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,s){n.load(e,i,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}};zt.DEFAULT_MATERIAL_NAME="__DEFAULT";var Kr={},op=class extends Error{constructor(e,t){super(e),this.response=t}},$n=class extends zt{constructor(e){super(e),this.mimeType="",this.responseType=""}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=xc.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Kr[e]!==void 0){Kr[e].push({onLoad:t,onProgress:n,onError:i});return}Kr[e]=[],Kr[e].push({onLoad:t,onProgress:n,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=Kr[e],h=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=f?parseInt(f):0,g=p!==0,y=0,d=new ReadableStream({start(m){_();function _(){h.read().then(({done:v,value:x})=>{if(v)m.close();else{y+=x.byteLength;let S=new ProgressEvent("progress",{lengthComputable:g,loaded:y,total:p});for(let I=0,A=u.length;I<A;I++){let C=u[I];C.onProgress&&C.onProgress(S)}m.enqueue(x),_()}},v=>{m.error(v)})}}});return new Response(d)}else throw new op(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a==="")return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(f);return c.arrayBuffer().then(g=>p.decode(g))}}}).then(c=>{xc.add(e,c);let u=Kr[e];delete Kr[e];for(let h=0,f=u.length;h<f;h++){let p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{let u=Kr[e];if(u===void 0)throw this.manager.itemError(e),c;delete Kr[e];for(let h=0,f=u.length;h<f;h++){let p=u[h];p.onError&&p.onError(c)}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}};var vc=class extends zt{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=xc.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=Aa("img");function l(){u(),xc.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),i&&i(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},_c=class extends zt{constructor(e){super(e)}load(e,t,n,i){let s=new Ia;s.colorSpace=yt;let o=new vc(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){s.images[c]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,i)}for(let c=0;c<e.length;++c)l(c);return s}},Tc=class extends zt{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new uo,a=new $n(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:un,o.wrapT=c.wrapT!==void 0?c.wrapT:un,o.magFilter=c.magFilter!==void 0?c.magFilter:Pn,o.minFilter=c.minFilter!==void 0?c.minFilter:Pn,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=xi),c.mipmapCount===1&&(o.minFilter=Pn),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},n,i),o}},Ri=class extends zt{constructor(e){super(e)}load(e,t,n,i){let s=new qn,o=new vc(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)},n,i),s}},xo=class extends Lt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new He(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()),this.target!==void 0&&(t.object.target=this.target.uuid),t}};var jd=new Je,i0=new se,r0=new se,Mc=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Pe(512,512),this.mapType=lr,this.map=null,this.mapPass=null,this.matrix=new Je,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Pa,this._frameExtents=new Pe(1,1),this._viewportCount=1,this._viewports=[new wt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;i0.setFromMatrixPosition(e.matrixWorld),t.position.copy(i0),r0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(r0),t.updateMatrixWorld(),jd.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(jd),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(jd)}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.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),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}},ap=class extends Mc{constructor(){super(new nn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=oo*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},vo=class extends xo{constructor(e,t,n=0,i=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=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new ap}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}},s0=new Je,Yl=new se,Yd=new se,lp=class extends Mc{constructor(){super(new nn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Pe(4,2),this._viewportCount=6,this._viewports=[new wt(2,1,1,1),new wt(0,1,1,1),new wt(3,1,1,1),new wt(1,1,1,1),new wt(3,0,1,1),new wt(1,0,1,1)],this._cubeDirections=[new se(1,0,0),new se(-1,0,0),new se(0,0,1),new se(0,0,-1),new se(0,1,0),new se(0,-1,0)],this._cubeUps=[new se(0,1,0),new se(0,1,0),new se(0,1,0),new se(0,1,0),new se(0,0,1),new se(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Yl.setFromMatrixPosition(e.matrixWorld),n.position.copy(Yl),Yd.copy(n.position),Yd.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Yd),n.updateMatrixWorld(),i.makeTranslation(-Yl.x,-Yl.y,-Yl.z),s0.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(s0)}},Ns=class extends xo{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new lp}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}},ss=class extends rc{constructor(e=-1,t=1,n=1,i=-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=n,this.bottom=i,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,n,i,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=n,this.view.offsetY=i,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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,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}},cp=class extends Mc{constructor(){super(new ss(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},sr=class extends xo{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 cp}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},or=class extends xo{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}};var os=class{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)}};var Lh=class extends nn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var Np="\\[\\]\\.:\\/",s_=new RegExp("["+Np+"]","g"),Lp="[^"+Np+"]",o_="[^"+Np.replace("\\.","")+"]",a_=/((?:WC+[\/:])*)/.source.replace("WC",Lp),l_=/(WCOD+)?/.source.replace("WCOD",o_),c_=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Lp),u_=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Lp),h_=new RegExp("^"+a_+l_+c_+u_+"$"),f_=["material","materials","bones","map"],up=class{constructor(e,t,n){let i=n||qt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},qt=class r{constructor(e,t,n){this.path=t,this.parsedPath=n||r.parseTrackName(t),this.node=r.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new r.Composite(e,t,n):new r(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(s_,"")}static parseTrackName(e){let t=h_.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);f_.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_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 n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=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,n=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=r.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(n){let c=t.objectIndex;switch(n){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===c){c=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[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[i];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?a=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="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])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};qt.Composite=up;qt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};qt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};qt.prototype.GetterByBindingType=[qt.prototype._getValue_direct,qt.prototype._getValue_array,qt.prototype._getValue_arrayElement,qt.prototype._getValue_toArray];qt.prototype.SetterByBindingTypeAndVersioning=[[qt.prototype._setValue_direct,qt.prototype._setValue_direct_setNeedsUpdate,qt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[qt.prototype._setValue_array,qt.prototype._setValue_array_setNeedsUpdate,qt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[qt.prototype._setValue_arrayElement,qt.prototype._setValue_arrayElement_setNeedsUpdate,qt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[qt.prototype._setValue_fromArray,qt.prototype._setValue_fromArray_setNeedsUpdate,qt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var U1=new Float32Array(1);var o0=new Je,Ec=class{constructor(e,t,n=0,i=1/0){this.ray=new Cs(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Ca,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 o0.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(o0),this}intersectObject(e,t=!0,n=[]){return hp(e,this,n,t),n.sort(a0),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)hp(e[i],this,n,t);return n.sort(a0),n}};function a0(r,e){return r.distance-e.distance}function hp(r,e,t,n){let i=!0;if(r.layers.test(e.layers)&&r.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){let s=r.children;for(let o=0,a=s.length;o<a;o++)hp(s[o],e,t,!0)}}var l0=new Pe,bc=class{constructor(e=new Pe(1/0,1/0),t=new Pe(-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,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=l0.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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,l0).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)}};var ar=class{constructor(){this.type="ShapePath",this.color=new He,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Cr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,o){return this.currentPath.bezierCurveTo(e,t,n,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){let _=[];for(let v=0,x=m.length;v<x;v++){let S=m[v],I=new $r;I.curves=S.curves,_.push(I)}return _}function n(m,_){let v=_.length,x=!1;for(let S=v-1,I=0;I<v;S=I++){let A=_[S],C=_[I],E=C.x-A.x,b=C.y-A.y;if(Math.abs(b)>Number.EPSILON){if(b<0&&(A=_[I],E=-E,C=_[S],b=-b),m.y<A.y||m.y>C.y)continue;if(m.y===A.y){if(m.x===A.x)return!0}else{let R=b*(m.x-A.x)-E*(m.y-A.y);if(R===0)return!0;if(R<0)continue;x=!x}}else{if(m.y!==A.y)continue;if(C.x<=m.x&&m.x<=A.x||A.x<=m.x&&m.x<=C.x)return!0}}return x}let i=gi.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l,c=[];if(s.length===1)return a=s[0],l=new $r,l.curves=a.curves,c.push(l),c;let u=!i(s[0].getPoints());u=e?!u:u;let h=[],f=[],p=[],g=0,y;f[g]=void 0,p[g]=[];for(let m=0,_=s.length;m<_;m++)a=s[m],y=a.getPoints(),o=i(y),o=e?!o:o,o?(!u&&f[g]&&g++,f[g]={s:new $r,p:y},f[g].s.curves=a.curves,u&&g++,p[g]=[]):p[g].push({h:a,p:y[0]});if(!f[0])return t(s);if(f.length>1){let m=!1,_=0;for(let v=0,x=f.length;v<x;v++)h[v]=[];for(let v=0,x=f.length;v<x;v++){let S=p[v];for(let I=0;I<S.length;I++){let A=S[I],C=!0;for(let E=0;E<f.length;E++)n(A.p,f[E].p)&&(v!==E&&_++,C?(C=!1,h[E].push(A)):m=!0);C&&h[v].push(A)}}_>0&&m===!1&&(p=h)}let d;for(let m=0,_=f.length;m<_;m++){l=f[m].s,c.push(l),d=p[m];for(let v=0,x=d.length;v<x;v++)l.holes.push(d[v].h)}return c}};function Op(r,e,t,n){let i=d_(n);switch(t){case Tp:return r*e;case Ep:return r*e/i.components*i.byteLength;case jh:return r*e/i.components*i.byteLength;case bp:return r*e*2/i.components*i.byteLength;case Yh:return r*e*2/i.components*i.byteLength;case Mp:return r*e*3/i.components*i.byteLength;case Pi:return r*e*4/i.components*i.byteLength;case Kh:return r*e*4/i.components*i.byteLength;case Cc:case Ic:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Rc:case Pc:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Jh:case Qh:return Math.max(r,16)*Math.max(e,8)/4;case Zh:case $h:return Math.max(r,8)*Math.max(e,8)/2;case ef:case tf:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case nf:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case rf:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case sf:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case of:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case af:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case lf:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case cf:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case uf:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case hf:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case ff:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case df:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case pf:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case mf:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case gf:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case yf:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case Nc:case xf:case vf:return Math.ceil(r/4)*Math.ceil(e/4)*16;case Sp:case _f:return Math.ceil(r/4)*Math.ceil(e/4)*8;case Tf:case Mf:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function d_(r){switch(r){case lr:case xp:return{byteLength:1,components:1};case ka:case vp:case Ba:return{byteLength:2,components:1};case Xh:case qh:return{byteLength:2,components:4};case Ls:case Wh:case cr:return{byteLength:4,components:1};case _p:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Oh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Oh);function Ly(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function p_(r){let e=new WeakMap;function t(a,l){let c=a.array,u=a.usage,h=c.byteLength,f=r.createBuffer();r.bindBuffer(l,f),r.bufferData(l,c,u),a.onUploadCallback();let p;if(c instanceof Float32Array)p=r.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?p=r.HALF_FLOAT:p=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=r.SHORT;else if(c instanceof Uint32Array)p=r.UNSIGNED_INT;else if(c instanceof Int32Array)p=r.INT;else if(c instanceof Int8Array)p=r.BYTE;else if(c instanceof Uint8Array)p=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:f,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,l,c){let u=l.array,h=l.updateRanges;if(r.bindBuffer(c,a),h.length===0)r.bufferSubData(c,0,u);else{h.sort((p,g)=>p.start-g.start);let f=0;for(let p=1;p<h.length;p++){let g=h[f],y=h[p];y.start<=g.start+g.count+1?g.count=Math.max(g.count,y.start+y.count-g.start):(++f,h[f]=y)}h.length=f+1;for(let p=0,g=h.length;p<g;p++){let y=h[p];r.bufferSubData(c,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);l&&(r.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),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}let c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.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.");n(c.buffer,a,l),c.version=a.version}}return{get:i,remove:s,update:o}}var m_=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,Sx=`#ifdef USE_ALPHAHASH
+#endif`,g_=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
-#endif`,Ax=`#ifdef USE_ALPHAMAP
+#endif`,y_=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,wx=`#ifdef USE_ALPHAMAP
+#endif`,x_=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,Cx=`#ifdef USE_ALPHATEST
+#endif`,v_=`#ifdef USE_ALPHATEST
#ifdef ALPHA_TO_COVERAGE
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
if ( diffuseColor.a == 0.0 ) discard;
#else
if ( diffuseColor.a < alphaTest ) discard;
#endif
-#endif`,Rx=`#ifdef USE_ALPHATEST
+#endif`,__=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,Ix=`#ifdef USE_AOMAP
+#endif`,T_=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
-#endif`,Px=`#ifdef USE_AOMAP
+#endif`,M_=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,Nx=`#ifdef USE_BATCHING
- attribute float batchId;
+#endif`,E_=`#ifdef USE_BATCHING
+ #if ! defined( GL_ANGLE_multi_draw )
+ #define gl_DrawID _gl_DrawID
+ uniform int _gl_DrawID;
+ #endif
uniform highp sampler2D batchingTexture;
+ uniform highp usampler2D batchingIdTexture;
mat4 getBatchingMatrix( const in float i ) {
int size = textureSize( batchingTexture, 0 ).x;
int j = int( i ) * 4;
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,Lx=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
-#endif`,Ox=`vec3 transformed = vec3( position );
+ float getIndirectIndex( const in int i ) {
+ int size = textureSize( batchingIdTexture, 0 ).x;
+ int x = i % size;
+ int y = i / size;
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
+ }
+#endif
+#ifdef USE_BATCHING_COLOR
+ uniform sampler2D batchingColorTexture;
+ vec3 getBatchingColor( const in float i ) {
+ int size = textureSize( batchingColorTexture, 0 ).x;
+ int j = int( i );
+ int x = j % size;
+ int y = j / size;
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
+ }
+#endif`,b_=`#ifdef USE_BATCHING
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
+#endif`,S_=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,Dx=`vec3 objectNormal = vec3( normal );
+#endif`,A_=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,Fx=`float G_BlinnPhong_Implicit( ) {
+#endif`,w_=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
-} // validated`,Ux=`#ifdef USE_IRIDESCENCE
+} // validated`,C_=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
}
return max( I, vec3( 0.0 ) );
}
-#endif`,kx=`#ifdef USE_BUMPMAP
+#endif`,I_=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
-#endif`,Bx=`#if NUM_CLIPPING_PLANES > 0
+#endif`,R_=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
if ( clipped ) discard;
#endif
#endif
-#endif`,Gx=`#if NUM_CLIPPING_PLANES > 0
+#endif`,P_=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,Vx=`#if NUM_CLIPPING_PLANES > 0
+#endif`,N_=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,zx=`#if NUM_CLIPPING_PLANES > 0
+#endif`,L_=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,Hx=`#if defined( USE_COLOR_ALPHA )
+#endif`,O_=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
-#endif`,Wx=`#if defined( USE_COLOR_ALPHA )
+#endif`,D_=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
-#endif`,Xx=`#if defined( USE_COLOR_ALPHA )
+#endif`,F_=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
+#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
-#endif`,jx=`#if defined( USE_COLOR_ALPHA )
+#endif`,U_=`#if defined( USE_COLOR_ALPHA )
vColor = vec4( 1.0 );
-#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
+#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
#endif
#ifdef USE_INSTANCING_COLOR
vColor.xyz *= instanceColor.xyz;
-#endif`,qx=`#define PI 3.141592653589793
+#endif
+#ifdef USE_BATCHING_COLOR
+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
+ vColor.xyz *= batchingColor.xyz;
+#endif`,k_=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
return tmp;
}
-float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
-}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
-} // validated`,Yx=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,B_=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
-#endif`,Kx=`vec3 transformedNormal = objectNormal;
+#endif`,G_=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
#ifdef FLIP_SIDED
transformedTangent = - transformedTangent;
#endif
-#endif`,Zx=`#ifdef USE_DISPLACEMENTMAP
+#endif`,V_=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,Jx=`#ifdef USE_DISPLACEMENTMAP
+#endif`,z_=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,$x=`#ifdef USE_EMISSIVEMAP
+#endif`,H_=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
+ emissiveColor = sRGBTransferEOTF( emissiveColor );
+ #endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,Qx=`#ifdef USE_EMISSIVEMAP
+#endif`,W_=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,e_="gl_FragColor = linearToOutputTexel( gl_FragColor );",t_=`
-const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
-);
-const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
-);
-vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
-}
-vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
-}
-vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,X_="gl_FragColor = linearToOutputTexel( gl_FragColor );",q_=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
+vec4 sRGBTransferEOTF( in vec4 value ) {
+ return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
+}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
-}
-vec4 LinearToLinear( in vec4 value ) {
- return value;
-}
-vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
-}`,n_=`#ifdef USE_ENVMAP
+}`,j_=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
-#endif`,i_=`#ifdef USE_ENVMAP
+#endif`,Y_=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
uniform mat3 envMapRotation;
uniform sampler2D envMap;
#endif
-#endif`,r_=`#ifdef USE_ENVMAP
+#endif`,K_=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#else
varying vec3 vReflect;
#endif
-#endif`,s_=`#ifdef USE_ENVMAP
+#endif`,Z_=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
varying vec3 vReflect;
uniform float refractionRatio;
#endif
-#endif`,o_=`#ifdef USE_ENVMAP
+#endif`,J_=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
-#endif`,a_=`#ifdef USE_FOG
+#endif`,$_=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,l_=`#ifdef USE_FOG
+#endif`,Q_=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,c_=`#ifdef USE_FOG
+#endif`,eT=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
-#endif`,u_=`#ifdef USE_FOG
+#endif`,tT=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogNear;
uniform float fogFar;
#endif
-#endif`,h_=`#ifdef USE_GRADIENTMAP
+#endif`,nT=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
-}`,f_=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
-#endif`,d_=`#ifdef USE_LIGHTMAP
+}`,iT=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,p_=`LambertMaterial material;
+#endif`,rT=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,m_=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,sT=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,g_=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,oT=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
+ if ( cutoffDistance > 0.0 ) {
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
+ }
+ return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
-#endif`,v_=`#ifdef USE_ENVMAP
+#endif`,aT=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
#endif
}
#endif
-#endif`,y_=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,x_=`varying vec3 vViewPosition;
+#endif`,lT=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,cT=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,__=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,uT=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,T_=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,hT=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
-#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,M_=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,fT=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
+#ifdef USE_DISPERSION
+ material.dispersion = dispersion;
+#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
-#endif`,E_=`struct PhysicalMaterial {
+#endif`,dT=`struct PhysicalMaterial {
vec3 diffuseColor;
float roughness;
vec3 specularColor;
float specularF90;
+ float dispersion;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
-}`,b_=`
+}`,pT=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
getPointLightInfo( pointLight, geometryPosition, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#undef SPOT_LIGHT_MAP_INDEX
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
getDirectionalLightInfo( directionalLight, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
-#endif`,S_=`#if defined( RE_IndirectDiffuse )
+#endif`,mT=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
-#endif`,A_=`#if defined( RE_IndirectDiffuse )
+#endif`,gT=`#if defined( RE_IndirectDiffuse )
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
-#endif`,w_=`#if defined( USE_LOGDEPTHBUF )
+#endif`,yT=`#if defined( USE_LOGDEPTHBUF )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,C_=`#if defined( USE_LOGDEPTHBUF )
+#endif`,xT=`#if defined( USE_LOGDEPTHBUF )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,R_=`#ifdef USE_LOGDEPTHBUF
+#endif`,vT=`#ifdef USE_LOGDEPTHBUF
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,I_=`#ifdef USE_LOGDEPTHBUF
+#endif`,_T=`#ifdef USE_LOGDEPTHBUF
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,P_=`#ifdef USE_MAP
+#endif`,TT=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,N_=`#ifdef USE_MAP
+#endif`,MT=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,L_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,ET=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
-#endif`,O_=`#if defined( USE_POINTS_UV )
+#endif`,bT=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,D_=`float metalnessFactor = metalness;
+#endif`,ST=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,F_=`#ifdef USE_METALNESSMAP
+#endif`,AT=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,U_=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[MORPHTARGETS_COUNT];
+#endif`,wT=`#ifdef USE_INSTANCING_MORPH
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
}
-#endif`,k_=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
+#endif`,CT=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
-#endif`,B_=`#ifdef USE_MORPHNORMALS
+#endif`,IT=`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
-#endif`,G_=`#ifdef USE_MORPHTARGETS
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
+ }
+#endif`,RT=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
- #endif
- #ifdef MORPHTARGETS_TEXTURE
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
-#endif`,V_=`#ifdef USE_MORPHTARGETS
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
+ #endif
+ uniform sampler2DArray morphTargetsTexture;
+ uniform ivec2 morphTargetsTextureSize;
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
+ int y = texelIndex / morphTargetsTextureSize.x;
+ int x = texelIndex - y * morphTargetsTextureSize.x;
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
+ }
+#endif`,PT=`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
-#endif`,z_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
+ }
+#endif`,NT=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
tbn2[1] *= faceDirection;
#endif
#endif
-vec3 nonPerturbedNormal = normal;`,H_=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,LT=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,W_=`#ifndef FLAT_SHADED
+#endif`,OT=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,X_=`#ifndef FLAT_SHADED
+#endif`,DT=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,j_=`#ifndef FLAT_SHADED
+#endif`,FT=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
-#endif`,q_=`#ifdef USE_NORMALMAP
+#endif`,UT=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
-#endif`,Y_=`#ifdef USE_CLEARCOAT
+#endif`,kT=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,K_=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,BT=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,Z_=`#ifdef USE_CLEARCOATMAP
+#endif`,GT=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,J_=`#ifdef USE_IRIDESCENCEMAP
+#endif`,VT=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,$_=`#ifdef OPAQUE
+#endif`,zT=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Q_=`vec3 packNormalToRGB( const in vec3 normal ) {
+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,HT=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
-const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
-const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
-const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
-const float ShiftRight8 = 1. / 256.;
+const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
+const float Inv255 = 1. / 255.;
+const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
+const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
+const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
+const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
+ if( v <= 0.0 )
+ return vec4( 0., 0., 0., 0. );
+ if( v >= 1.0 )
+ return vec4( 1., 1., 1., 1. );
+ float vuf;
+ float af = modf( v * PackFactors.a, vuf );
+ float bf = modf( vuf * ShiftRight8, vuf );
+ float gf = modf( vuf * ShiftRight8, vuf );
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
+}
+vec3 packDepthToRGB( const in float v ) {
+ if( v <= 0.0 )
+ return vec3( 0., 0., 0. );
+ if( v >= 1.0 )
+ return vec3( 1., 1., 1. );
+ float vuf;
+ float bf = modf( v * PackFactors.b, vuf );
+ float gf = modf( vuf * ShiftRight8, vuf );
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
+}
+vec2 packDepthToRG( const in float v ) {
+ if( v <= 0.0 )
+ return vec2( 0., 0. );
+ if( v >= 1.0 )
+ return vec2( 1., 1. );
+ float vuf;
+ float gf = modf( v * 256., vuf );
+ return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
+ return dot( v, UnpackFactors4 );
}
-vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
+float unpackRGBToDepth( const in vec3 v ) {
+ return dot( v, UnpackFactors3 );
}
-float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
+float unpackRGToDepth( const in vec2 v ) {
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
-vec4 pack2HalfToRGBA( vec2 v ) {
+vec4 pack2HalfToRGBA( const in vec2 v ) {
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
-vec2 unpackRGBATo2Half( vec4 v ) {
+vec2 unpackRGBATo2Half( const in vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
return ( near * far ) / ( ( far - near ) * depth - far );
-}`,eT=`#ifdef PREMULTIPLIED_ALPHA
+}`,WT=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,tT=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,XT=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
-gl_Position = projectionMatrix * mvPosition;`,nT=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,qT=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,iT=`#ifdef DITHERING
+#endif`,jT=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
-#endif`,rT=`float roughnessFactor = roughness;
+#endif`,YT=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,sT=`#ifdef USE_ROUGHNESSMAP
+#endif`,KT=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,oT=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,ZT=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
#if NUM_SPOT_LIGHT_SHADOWS > 0
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
struct SpotLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
}
return occlusion;
}
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
#endif
}
- return shadow;
+ return mix( 1.0, shadow, shadowIntensity );
}
vec2 cubeToUV( vec3 v, float texelSizeY ) {
vec3 absV = abs( v );
}
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
}
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
- return shadow;
+ return mix( 1.0, shadow, shadowIntensity );
}
-#endif`,aT=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,JT=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
struct SpotLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#endif`,lT=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
+#endif`,$T=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
vec4 shadowWorldPosition;
#endif
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,cT=`float getShadowMask() {
+#endif`,QT=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
#endif
return shadow;
-}`,uT=`#ifdef USE_SKINNING
+}`,eM=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,hT=`#ifdef USE_SKINNING
+#endif`,tM=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,fT=`#ifdef USE_SKINNING
+#endif`,nM=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,dT=`#ifdef USE_SKINNING
+#endif`,iM=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,pT=`float specularStrength;
+#endif`,rM=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,mT=`#ifdef USE_SPECULARMAP
+#endif`,sM=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,gT=`#if defined( TONE_MAPPING )
+#endif`,oM=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,vT=`#ifndef saturate
+#endif`,aM=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
color *= toneMappingExposure;
return saturate( color / ( vec3( 1.0 ) + color ) );
}
-vec3 OptimizedCineonToneMapping( vec3 color ) {
+vec3 CineonToneMapping( vec3 color ) {
color *= toneMappingExposure;
color = max( vec3( 0.0 ), color - 0.004 );
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
return color;
}
vec3 NeutralToneMapping( vec3 color ) {
- float startCompression = 0.8 - 0.04;
- float desaturation = 0.15;
+ const float StartCompression = 0.8 - 0.04;
+ const float Desaturation = 0.15;
color *= toneMappingExposure;
- float x = min(color.r, min(color.g, color.b));
+ float x = min( color.r, min( color.g, color.b ) );
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
color -= offset;
- float peak = max(color.r, max(color.g, color.b));
- if (peak < startCompression) return color;
- float d = 1. - startCompression;
- float newPeak = 1. - d * d / (peak + d - startCompression);
+ float peak = max( color.r, max( color.g, color.b ) );
+ if ( peak < StartCompression ) return color;
+ float d = 1. - StartCompression;
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
color *= newPeak / peak;
- float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
- return mix(color, newPeak * vec3(1, 1, 1), g);
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
+ return mix( color, vec3( newPeak ), g );
}
-vec3 CustomToneMapping( vec3 color ) { return color; }`,yT=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,lM=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
vec3 n = inverseTransformDirection( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,xT=`#ifdef USE_TRANSMISSION
+#endif`,cM=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
}
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
+ vec4 transmittedLight;
+ vec3 transmittance;
+ #ifdef USE_DISPERSION
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
+ for ( int i = 0; i < 3; i ++ ) {
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
+ vec3 refractedRayExit = position + transmissionRay;
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
+ refractionCoords += 1.0;
+ refractionCoords /= 2.0;
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
+ transmittedLight[ i ] = transmissionSample[ i ];
+ transmittedLight.a += transmissionSample.a;
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
+ }
+ transmittedLight.a /= 3.0;
+ #else
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
+ vec3 refractedRayExit = position + transmissionRay;
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
+ refractionCoords += 1.0;
+ refractionCoords /= 2.0;
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
+ #endif
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
}
-#endif`,_T=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,uM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,TT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,hM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,MT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,fM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`,ET=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`,dM=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,bT=`varying vec2 vUv;
+#endif`,pM=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,ST=`uniform sampler2D t2D;
+}`,mM=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,AT=`varying vec3 vWorldDirection;
+}`,gM=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,wT=`#ifdef ENVMAP_TYPE_CUBE
+}`,yM=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,CT=`varying vec3 vWorldDirection;
+}`,xM=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,RT=`uniform samplerCube tCube;
+}`,vM=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,IT=`#include <common>
+}`,_M=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
-}`,PT=`#if DEPTH_PACKING == 3200
+}`,TM=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
#elif DEPTH_PACKING == 3201
gl_FragColor = packDepthToRGBA( fragCoordZ );
+ #elif DEPTH_PACKING == 3202
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
+ #elif DEPTH_PACKING == 3203
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
-}`,NT=`#define DISTANCE
+}`,MM=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
-}`,LT=`#define DISTANCE
+}`,EM=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = packDepthToRGBA( dist );
-}`,OT=`varying vec3 vWorldDirection;
+}`,bM=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,DT=`uniform sampler2D tEquirect;
+}`,SM=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,FT=`uniform float scale;
+}`,AM=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,UT=`uniform vec3 diffuse;
+}`,wM=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,kT=`#include <common>
+}`,CM=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
-}`,BT=`uniform vec3 diffuse;
+}`,IM=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,GT=`#define LAMBERT
+}`,RM=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,VT=`#define LAMBERT
+}`,PM=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,zT=`#define MATCAP
+}`,NM=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
-}`,HT=`#define MATCAP
+}`,LM=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,WT=`#define NORMAL
+}`,OM=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
-}`,XT=`#define NORMAL
+}`,DM=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
-}`,jT=`#define PHONG
+}`,FM=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,qT=`#define PHONG
+}`,UM=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,YT=`#define STANDARD
+}`,kM=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,KT=`#define STANDARD
+}`,BM=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
+#ifdef USE_DISPERSION
+ uniform float dispersion;
+#endif
#ifdef USE_IRIDESCENCE
uniform float iridescence;
uniform float iridescenceIOR;
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,ZT=`#define TOON
+}`,GM=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,JT=`#define TOON
+}`,VM=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,$T=`uniform float size;
+}`,zM=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
-}`,QT=`uniform vec3 diffuse;
+}`,HM=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,eM=`#include <common>
+}`,WM=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,tM=`uniform vec3 color;
+}`,XM=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
-}`,nM=`uniform float rotation;
+}`,qM=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
+ vec4 mvPosition = modelViewMatrix[ 3 ];
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
#ifndef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,iM=`uniform vec3 diffuse;
+}`,jM=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
-}`,Et={alphahash_fragment:bx,alphahash_pars_fragment:Sx,alphamap_fragment:Ax,alphamap_pars_fragment:wx,alphatest_fragment:Cx,alphatest_pars_fragment:Rx,aomap_fragment:Ix,aomap_pars_fragment:Px,batching_pars_vertex:Nx,batching_vertex:Lx,begin_vertex:Ox,beginnormal_vertex:Dx,bsdfs:Fx,iridescence_fragment:Ux,bumpmap_pars_fragment:kx,clipping_planes_fragment:Bx,clipping_planes_pars_fragment:Gx,clipping_planes_pars_vertex:Vx,clipping_planes_vertex:zx,color_fragment:Hx,color_pars_fragment:Wx,color_pars_vertex:Xx,color_vertex:jx,common:qx,cube_uv_reflection_fragment:Yx,defaultnormal_vertex:Kx,displacementmap_pars_vertex:Zx,displacementmap_vertex:Jx,emissivemap_fragment:$x,emissivemap_pars_fragment:Qx,colorspace_fragment:e_,colorspace_pars_fragment:t_,envmap_fragment:n_,envmap_common_pars_fragment:i_,envmap_pars_fragment:r_,envmap_pars_vertex:s_,envmap_physical_pars_fragment:v_,envmap_vertex:o_,fog_vertex:a_,fog_pars_vertex:l_,fog_fragment:c_,fog_pars_fragment:u_,gradientmap_pars_fragment:h_,lightmap_fragment:f_,lightmap_pars_fragment:d_,lights_lambert_fragment:p_,lights_lambert_pars_fragment:m_,lights_pars_begin:g_,lights_toon_fragment:y_,lights_toon_pars_fragment:x_,lights_phong_fragment:__,lights_phong_pars_fragment:T_,lights_physical_fragment:M_,lights_physical_pars_fragment:E_,lights_fragment_begin:b_,lights_fragment_maps:S_,lights_fragment_end:A_,logdepthbuf_fragment:w_,logdepthbuf_pars_fragment:C_,logdepthbuf_pars_vertex:R_,logdepthbuf_vertex:I_,map_fragment:P_,map_pars_fragment:N_,map_particle_fragment:L_,map_particle_pars_fragment:O_,metalnessmap_fragment:D_,metalnessmap_pars_fragment:F_,morphinstance_vertex:U_,morphcolor_vertex:k_,morphnormal_vertex:B_,morphtarget_pars_vertex:G_,morphtarget_vertex:V_,normal_fragment_begin:z_,normal_fragment_maps:H_,normal_pars_fragment:W_,normal_pars_vertex:X_,normal_vertex:j_,normalmap_pars_fragment:q_,clearcoat_normal_fragment_begin:Y_,clearcoat_normal_fragment_maps:K_,clearcoat_pars_fragment:Z_,iridescence_pars_fragment:J_,opaque_fragment:$_,packing:Q_,premultiplied_alpha_fragment:eT,project_vertex:tT,dithering_fragment:nT,dithering_pars_fragment:iT,roughnessmap_fragment:rT,roughnessmap_pars_fragment:sT,shadowmap_pars_fragment:oT,shadowmap_pars_vertex:aT,shadowmap_vertex:lT,shadowmask_pars_fragment:cT,skinbase_vertex:uT,skinning_pars_vertex:hT,skinning_vertex:fT,skinnormal_vertex:dT,specularmap_fragment:pT,specularmap_pars_fragment:mT,tonemapping_fragment:gT,tonemapping_pars_fragment:vT,transmission_fragment:yT,transmission_pars_fragment:xT,uv_pars_fragment:_T,uv_pars_vertex:TT,uv_vertex:MT,worldpos_vertex:ET,background_vert:bT,background_frag:ST,backgroundCube_vert:AT,backgroundCube_frag:wT,cube_vert:CT,cube_frag:RT,depth_vert:IT,depth_frag:PT,distanceRGBA_vert:NT,distanceRGBA_frag:LT,equirect_vert:OT,equirect_frag:DT,linedashed_vert:FT,linedashed_frag:UT,meshbasic_vert:kT,meshbasic_frag:BT,meshlambert_vert:GT,meshlambert_frag:VT,meshmatcap_vert:zT,meshmatcap_frag:HT,meshnormal_vert:WT,meshnormal_frag:XT,meshphong_vert:jT,meshphong_frag:qT,meshphysical_vert:YT,meshphysical_frag:KT,meshtoon_vert:ZT,meshtoon_frag:JT,points_vert:$T,points_frag:QT,shadow_vert:eM,shadow_frag:tM,sprite_vert:nM,sprite_frag:iM},Ge={common:{diffuse:{value:new Ve(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ft},alphaMap:{value:null},alphaMapTransform:{value:new ft},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ft}},envmap:{envMap:{value:null},envMapRotation:{value:new ft},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ft}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ft}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ft},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ft},normalScale:{value:new Ce(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ft},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ft}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ft}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ft}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ve(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 Ve(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ft},alphaTest:{value:0},uvTransform:{value:new ft}},sprite:{diffuse:{value:new Ve(16777215)},opacity:{value:1},center:{value:new Ce(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ft},alphaMap:{value:null},alphaMapTransform:{value:new ft},alphaTest:{value:0}}},pr={basic:{uniforms:Jn([Ge.common,Ge.specularmap,Ge.envmap,Ge.aomap,Ge.lightmap,Ge.fog]),vertexShader:Et.meshbasic_vert,fragmentShader:Et.meshbasic_frag},lambert:{uniforms:Jn([Ge.common,Ge.specularmap,Ge.envmap,Ge.aomap,Ge.lightmap,Ge.emissivemap,Ge.bumpmap,Ge.normalmap,Ge.displacementmap,Ge.fog,Ge.lights,{emissive:{value:new Ve(0)}}]),vertexShader:Et.meshlambert_vert,fragmentShader:Et.meshlambert_frag},phong:{uniforms:Jn([Ge.common,Ge.specularmap,Ge.envmap,Ge.aomap,Ge.lightmap,Ge.emissivemap,Ge.bumpmap,Ge.normalmap,Ge.displacementmap,Ge.fog,Ge.lights,{emissive:{value:new Ve(0)},specular:{value:new Ve(1118481)},shininess:{value:30}}]),vertexShader:Et.meshphong_vert,fragmentShader:Et.meshphong_frag},standard:{uniforms:Jn([Ge.common,Ge.envmap,Ge.aomap,Ge.lightmap,Ge.emissivemap,Ge.bumpmap,Ge.normalmap,Ge.displacementmap,Ge.roughnessmap,Ge.metalnessmap,Ge.fog,Ge.lights,{emissive:{value:new Ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Et.meshphysical_vert,fragmentShader:Et.meshphysical_frag},toon:{uniforms:Jn([Ge.common,Ge.aomap,Ge.lightmap,Ge.emissivemap,Ge.bumpmap,Ge.normalmap,Ge.displacementmap,Ge.gradientmap,Ge.fog,Ge.lights,{emissive:{value:new Ve(0)}}]),vertexShader:Et.meshtoon_vert,fragmentShader:Et.meshtoon_frag},matcap:{uniforms:Jn([Ge.common,Ge.bumpmap,Ge.normalmap,Ge.displacementmap,Ge.fog,{matcap:{value:null}}]),vertexShader:Et.meshmatcap_vert,fragmentShader:Et.meshmatcap_frag},points:{uniforms:Jn([Ge.points,Ge.fog]),vertexShader:Et.points_vert,fragmentShader:Et.points_frag},dashed:{uniforms:Jn([Ge.common,Ge.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Et.linedashed_vert,fragmentShader:Et.linedashed_frag},depth:{uniforms:Jn([Ge.common,Ge.displacementmap]),vertexShader:Et.depth_vert,fragmentShader:Et.depth_frag},normal:{uniforms:Jn([Ge.common,Ge.bumpmap,Ge.normalmap,Ge.displacementmap,{opacity:{value:1}}]),vertexShader:Et.meshnormal_vert,fragmentShader:Et.meshnormal_frag},sprite:{uniforms:Jn([Ge.sprite,Ge.fog]),vertexShader:Et.sprite_vert,fragmentShader:Et.sprite_frag},background:{uniforms:{uvTransform:{value:new ft},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Et.background_vert,fragmentShader:Et.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ft}},vertexShader:Et.backgroundCube_vert,fragmentShader:Et.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Et.cube_vert,fragmentShader:Et.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Et.equirect_vert,fragmentShader:Et.equirect_frag},distanceRGBA:{uniforms:Jn([Ge.common,Ge.displacementmap,{referencePosition:{value:new oe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Et.distanceRGBA_vert,fragmentShader:Et.distanceRGBA_frag},shadow:{uniforms:Jn([Ge.lights,Ge.fog,{color:{value:new Ve(0)},opacity:{value:1}}]),vertexShader:Et.shadow_vert,fragmentShader:Et.shadow_frag}};pr.physical={uniforms:Jn([pr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ft},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ft},clearcoatNormalScale:{value:new Ce(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ft},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ft},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ft},sheen:{value:0},sheenColor:{value:new Ve(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ft},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ft},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ft},transmissionSamplerSize:{value:new Ce},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ft},attenuationDistance:{value:0},attenuationColor:{value:new Ve(0)},specularColor:{value:new Ve(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ft},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ft},anisotropyVector:{value:new Ce},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ft}}]),vertexShader:Et.meshphysical_vert,fragmentShader:Et.meshphysical_frag};var yu={r:0,b:0,g:0},Hs=new hn,rM=new Ye;function sM(r,e,t,n,i,s,o){let a=new Ve(0),l=s===!0?0:1,c,u,h=null,f=0,p=null;function g(d,m){let _=!1,y=m.isScene===!0?m.background:null;y&&y.isTexture&&(y=(m.backgroundBlurriness>0?t:e).get(y)),y===null?v(a,l):y&&y.isColor&&(v(y,1),_=!0);let x=r.xr.getEnvironmentBlendMode();x==="additive"?n.buffers.color.setClear(0,0,0,1,o):x==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(r.autoClear||_)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),y&&(y.isCubeTexture||y.mapping===ah)?(u===void 0&&(u=new Pt(new Zs(1,1,1),new mr({name:"BackgroundCubeMaterial",uniforms:ga(pr.backgroundCube.uniforms),vertexShader:pr.backgroundCube.vertexShader,fragmentShader:pr.backgroundCube.fragmentShader,side:Tn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(w,I,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Hs.copy(m.backgroundRotation),Hs.x*=-1,Hs.y*=-1,Hs.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Hs.y*=-1,Hs.z*=-1),u.material.uniforms.envMap.value=y,u.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(rM.makeRotationFromEuler(Hs)),u.material.toneMapped=Bt.getTransfer(y.colorSpace)!==Qt,(h!==y||f!==y.version||p!==r.toneMapping)&&(u.material.needsUpdate=!0,h=y,f=y.version,p=r.toneMapping),u.layers.enableAll(),d.unshift(u,u.geometry,u.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new Pt(new va(2,2),new mr({name:"BackgroundMaterial",uniforms:ga(pr.background.uniforms),vertexShader:pr.background.vertexShader,fragmentShader:pr.background.fragmentShader,side:wi,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,c.material.toneMapped=Bt.getTransfer(y.colorSpace)!==Qt,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(h!==y||f!==y.version||p!==r.toneMapping)&&(c.material.needsUpdate=!0,h=y,f=y.version,p=r.toneMapping),c.layers.enableAll(),d.unshift(c,c.geometry,c.material,0,0,null))}function v(d,m){d.getRGB(yu,p0(r)),n.buffers.color.setClear(yu.r,yu.g,yu.b,m,o)}return{getClearColor:function(){return a},setClearColor:function(d,m=1){a.set(d),l=m,v(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(d){l=d,v(a,l)},render:g}}function oM(r,e){let t=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=f(null),s=i,o=!1;function a(M,L,N,O,B){let ie=!1,$=h(O,N,L);s!==$&&(s=$,c(s.object)),ie=p(M,O,N,B),ie&&g(M,O,N,B),B!==null&&e.update(B,r.ELEMENT_ARRAY_BUFFER),(ie||o)&&(o=!1,x(M,L,N,O),B!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(B).buffer))}function l(){return r.createVertexArray()}function c(M){return r.bindVertexArray(M)}function u(M){return r.deleteVertexArray(M)}function h(M,L,N){let O=N.wireframe===!0,B=n[M.id];B===void 0&&(B={},n[M.id]=B);let ie=B[L.id];ie===void 0&&(ie={},B[L.id]=ie);let $=ie[O];return $===void 0&&($=f(l()),ie[O]=$),$}function f(M){let L=[],N=[],O=[];for(let B=0;B<t;B++)L[B]=0,N[B]=0,O[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:N,attributeDivisors:O,object:M,attributes:{},index:null}}function p(M,L,N,O){let B=s.attributes,ie=L.attributes,$=0,te=N.getAttributes();for(let W in te)if(te[W].location>=0){let de=B[W],ye=ie[W];if(ye===void 0&&(W==="instanceMatrix"&&M.instanceMatrix&&(ye=M.instanceMatrix),W==="instanceColor"&&M.instanceColor&&(ye=M.instanceColor)),de===void 0||de.attribute!==ye||ye&&de.data!==ye.data)return!0;$++}return s.attributesNum!==$||s.index!==O}function g(M,L,N,O){let B={},ie=L.attributes,$=0,te=N.getAttributes();for(let W in te)if(te[W].location>=0){let de=ie[W];de===void 0&&(W==="instanceMatrix"&&M.instanceMatrix&&(de=M.instanceMatrix),W==="instanceColor"&&M.instanceColor&&(de=M.instanceColor));let ye={};ye.attribute=de,de&&de.data&&(ye.data=de.data),B[W]=ye,$++}s.attributes=B,s.attributesNum=$,s.index=O}function v(){let M=s.newAttributes;for(let L=0,N=M.length;L<N;L++)M[L]=0}function d(M){m(M,0)}function m(M,L){let N=s.newAttributes,O=s.enabledAttributes,B=s.attributeDivisors;N[M]=1,O[M]===0&&(r.enableVertexAttribArray(M),O[M]=1),B[M]!==L&&(r.vertexAttribDivisor(M,L),B[M]=L)}function _(){let M=s.newAttributes,L=s.enabledAttributes;for(let N=0,O=L.length;N<O;N++)L[N]!==M[N]&&(r.disableVertexAttribArray(N),L[N]=0)}function y(M,L,N,O,B,ie,$){$===!0?r.vertexAttribIPointer(M,L,N,B,ie):r.vertexAttribPointer(M,L,N,O,B,ie)}function x(M,L,N,O){v();let B=O.attributes,ie=N.getAttributes(),$=L.defaultAttributeValues;for(let te in ie){let W=ie[te];if(W.location>=0){let ae=B[te];if(ae===void 0&&(te==="instanceMatrix"&&M.instanceMatrix&&(ae=M.instanceMatrix),te==="instanceColor"&&M.instanceColor&&(ae=M.instanceColor)),ae!==void 0){let de=ae.normalized,ye=ae.itemSize,Me=e.get(ae);if(Me===void 0)continue;let ve=Me.buffer,R=Me.type,T=Me.bytesPerElement,S=R===r.INT||R===r.UNSIGNED_INT||ae.gpuType===r0;if(ae.isInterleavedBufferAttribute){let b=ae.data,V=b.stride,q=ae.offset;if(b.isInstancedInterleavedBuffer){for(let Y=0;Y<W.locationSize;Y++)m(W.location+Y,b.meshPerAttribute);M.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=b.meshPerAttribute*b.count)}else for(let Y=0;Y<W.locationSize;Y++)d(W.location+Y);r.bindBuffer(r.ARRAY_BUFFER,ve);for(let Y=0;Y<W.locationSize;Y++)y(W.location+Y,ye/W.locationSize,R,de,V*T,(q+ye/W.locationSize*Y)*T,S)}else{if(ae.isInstancedBufferAttribute){for(let b=0;b<W.locationSize;b++)m(W.location+b,ae.meshPerAttribute);M.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let b=0;b<W.locationSize;b++)d(W.location+b);r.bindBuffer(r.ARRAY_BUFFER,ve);for(let b=0;b<W.locationSize;b++)y(W.location+b,ye/W.locationSize,R,de,ye*T,ye/W.locationSize*b*T,S)}}else if($!==void 0){let de=$[te];if(de!==void 0)switch(de.length){case 2:r.vertexAttrib2fv(W.location,de);break;case 3:r.vertexAttrib3fv(W.location,de);break;case 4:r.vertexAttrib4fv(W.location,de);break;default:r.vertexAttrib1fv(W.location,de)}}}}_()}function w(){P();for(let M in n){let L=n[M];for(let N in L){let O=L[N];for(let B in O)u(O[B].object),delete O[B];delete L[N]}delete n[M]}}function I(M){if(n[M.id]===void 0)return;let L=n[M.id];for(let N in L){let O=L[N];for(let B in O)u(O[B].object),delete O[B];delete L[N]}delete n[M.id]}function C(M){for(let L in n){let N=n[L];if(N[M.id]===void 0)continue;let O=N[M.id];for(let B in O)u(O[B].object),delete O[B];delete N[M.id]}}function P(){E(),o=!0,s!==i&&(s=i,c(s.object))}function E(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:P,resetDefaultState:E,dispose:w,releaseStatesOfGeometry:I,releaseStatesOfProgram:C,initAttributes:v,enableAttribute:d,disableUnusedAttributes:_}}function aM(r,e,t){let n;function i(l){n=l}function s(l,c){r.drawArrays(n,l,c),t.update(c,n,1)}function o(l,c,u){u!==0&&(r.drawArraysInstanced(n,l,c,u),t.update(c,n,u))}function a(l,c,u){if(u===0)return;let h=e.get("WEBGL_multi_draw");if(h===null)for(let f=0;f<u;f++)this.render(l[f],c[f]);else{h.multiDrawArraysWEBGL(n,l,0,c,0,u);let f=0;for(let p=0;p<u;p++)f+=c[p];t.update(f,n,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function lM(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){let y=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(y.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(y){if(y==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";y="mediump"}return y==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=t.precision!==void 0?t.precision:"highp",a=s(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);let l=t.logarithmicDepthBuffer===!0,c=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),u=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=r.getParameter(r.MAX_TEXTURE_SIZE),f=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),p=r.getParameter(r.MAX_VERTEX_ATTRIBS),g=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),v=r.getParameter(r.MAX_VARYING_VECTORS),d=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),m=u>0,_=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:l,maxTextures:c,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:g,maxVaryings:v,maxFragmentUniforms:d,vertexTextures:m,maxSamples:_}}function cM(r){let e=this,t=null,n=0,i=!1,s=!1,o=new Gr,a=new ft,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){let p=h.length!==0||f||n!==0||i;return i=f,n=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){t=u(h,f,0)},this.setState=function(h,f,p){let g=h.clippingPlanes,v=h.clipIntersection,d=h.clipShadows,m=r.get(h);if(!i||g===null||g.length===0||s&&!d)s?u(null):c();else{let _=s?0:n,y=_*4,x=m.clippingState||null;l.value=x,x=u(g,f,y,p);for(let w=0;w!==y;++w)x[w]=t[w];m.clippingState=x,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,f,p,g){let v=h!==null?h.length:0,d=null;if(v!==0){if(d=l.value,g!==!0||d===null){let m=p+v*4,_=f.matrixWorldInverse;a.getNormalMatrix(_),(d===null||d.length<m)&&(d=new Float32Array(m));for(let y=0,x=p;y!==v;++y,x+=4)o.copy(h[y]).applyMatrix4(_,a),o.normal.toArray(d,x),d[x+3]=o.constant}l.value=d,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,d}}function uM(r){let e=new WeakMap;function t(o,a){return a===Fl?o.mapping=ca:a===Xf&&(o.mapping=ua),o}function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===Fl||a===Xf)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new Kf(l.height);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}var gr=class extends zu{constructor(e=-1,t=1,n=1,i=-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=n,this.bottom=i,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,n,i,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=n,this.view.offsetY=i,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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,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}},na=4,ug=[.125,.215,.35,.446,.526,.582],qs=20,Cf=new gr,hg=new Ve,Rf=null,If=0,Pf=0,Nf=!1,Xs=(1+Math.sqrt(5))/2,ea=1/Xs,fg=[new oe(1,1,1),new oe(-1,1,1),new oe(1,1,-1),new oe(-1,1,-1),new oe(0,Xs,ea),new oe(0,Xs,-ea),new oe(ea,0,Xs),new oe(-ea,0,Xs),new oe(Xs,ea,0),new oe(-Xs,ea,0)],Hu=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,n=.1,i=100){Rf=this._renderer.getRenderTarget(),If=this._renderer.getActiveCubeFace(),Pf=this._renderer.getActiveMipmapLevel(),Nf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,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=mg(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=pg(),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(Rf,If,Pf),this._renderer.xr.enabled=Nf,e.scissorTest=!1,xu(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ca||e.mapping===ua?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Rf=this._renderer.getRenderTarget(),If=this._renderer.getActiveCubeFace(),Pf=this._renderer.getActiveMipmapLevel(),Nf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:bn,minFilter:bn,generateMipmaps:!1,type:Nu,format:Xi,colorSpace:li,depthBuffer:!1},i=dg(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=dg(e,t,n);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=hM(s)),this._blurMaterial=fM(s,e,t)}return i}_compileMaterial(e){let t=new Pt(this._lodPlanes[0],e);this._renderer.compile(t,Cf)}_sceneToCubeUV(e,t,n,i){let a=new en(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,f=u.toneMapping;u.getClearColor(hg),u.toneMapping=hs,u.autoClear=!1;let p=new Ci({name:"PMREM.Background",side:Tn,depthWrite:!1,depthTest:!1}),g=new Pt(new Zs,p),v=!1,d=e.background;d?d.isColor&&(p.color.copy(d),e.background=null,v=!0):(p.color.copy(hg),v=!0);for(let m=0;m<6;m++){let _=m%3;_===0?(a.up.set(0,l[m],0),a.lookAt(c[m],0,0)):_===1?(a.up.set(0,0,l[m]),a.lookAt(0,c[m],0)):(a.up.set(0,l[m],0),a.lookAt(0,0,c[m]));let y=this._cubeSize;xu(i,_*y,m>2?y:0,y,y),u.setRenderTarget(i),v&&u.render(g,a),u.render(e,a)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=f,u.autoClear=h,e.background=d}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===ca||e.mapping===ua;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=mg()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=pg());let s=i?this._cubemapMaterial:this._equirectMaterial,o=new Pt(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let l=this._cubeSize;xu(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Cf)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){let s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=fg[(i-1)%fg.length];this._blur(e,i-1,i,s,o)}t.autoClear=n}_blur(e,t,n,i,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",s),this._halfBlur(o,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new Pt(this._lodPlanes[i],c),f=c.uniforms,p=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*qs-1),v=s/g,d=isFinite(s)?1+Math.floor(u*v):qs;d>qs&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${d} samples when the maximum is set to ${qs}`);let m=[],_=0;for(let C=0;C<qs;++C){let P=C/v,E=Math.exp(-P*P/2);m.push(E),C===0?_+=E:C<d&&(_+=2*E)}for(let C=0;C<m.length;C++)m[C]=m[C]/_;f.envMap.value=e.texture,f.samples.value=d,f.weights.value=m,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);let{_lodMax:y}=this;f.dTheta.value=g,f.mipInt.value=y-n;let x=this._sizeLods[i],w=3*x*(i>y-na?i-y+na:0),I=4*(this._cubeSize-x);xu(t,w,I,3*x,2*x),l.setRenderTarget(t),l.render(h,Cf)}};function hM(r){let e=[],t=[],n=[],i=r,s=r-na+1+ug.length;for(let o=0;o<s;o++){let a=Math.pow(2,i);t.push(a);let l=1/a;o>r-na?l=ug[o-r+na-1]:o===0&&(l=0),n.push(l);let c=1/(a-2),u=-c,h=1+c,f=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,g=6,v=3,d=2,m=1,_=new Float32Array(v*g*p),y=new Float32Array(d*g*p),x=new Float32Array(m*g*p);for(let I=0;I<p;I++){let C=I%3*2/3-1,P=I>2?0:-1,E=[C,P,0,C+2/3,P,0,C+2/3,P+1,0,C,P,0,C+2/3,P+1,0,C,P+1,0];_.set(E,v*g*I),y.set(f,d*g*I);let M=[I,I,I,I,I,I];x.set(M,m*g*I)}let w=new St;w.setAttribute("position",new Gn(_,v)),w.setAttribute("uv",new Gn(y,d)),w.setAttribute("faceIndex",new Gn(x,m)),e.push(w),i>na&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function dg(r,e,t){let n=new Hr(r,e,t);return n.texture.mapping=ah,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function xu(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function fM(r,e,t){let n=new Float32Array(qs),i=new oe(0,1,0);return new mr({name:"SphericalGaussianBlur",defines:{n:qs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Id(),fragmentShader:`
+}`,Ct={alphahash_fragment:m_,alphahash_pars_fragment:g_,alphamap_fragment:y_,alphamap_pars_fragment:x_,alphatest_fragment:v_,alphatest_pars_fragment:__,aomap_fragment:T_,aomap_pars_fragment:M_,batching_pars_vertex:E_,batching_vertex:b_,begin_vertex:S_,beginnormal_vertex:A_,bsdfs:w_,iridescence_fragment:C_,bumpmap_pars_fragment:I_,clipping_planes_fragment:R_,clipping_planes_pars_fragment:P_,clipping_planes_pars_vertex:N_,clipping_planes_vertex:L_,color_fragment:O_,color_pars_fragment:D_,color_pars_vertex:F_,color_vertex:U_,common:k_,cube_uv_reflection_fragment:B_,defaultnormal_vertex:G_,displacementmap_pars_vertex:V_,displacementmap_vertex:z_,emissivemap_fragment:H_,emissivemap_pars_fragment:W_,colorspace_fragment:X_,colorspace_pars_fragment:q_,envmap_fragment:j_,envmap_common_pars_fragment:Y_,envmap_pars_fragment:K_,envmap_pars_vertex:Z_,envmap_physical_pars_fragment:aT,envmap_vertex:J_,fog_vertex:$_,fog_pars_vertex:Q_,fog_fragment:eT,fog_pars_fragment:tT,gradientmap_pars_fragment:nT,lightmap_pars_fragment:iT,lights_lambert_fragment:rT,lights_lambert_pars_fragment:sT,lights_pars_begin:oT,lights_toon_fragment:lT,lights_toon_pars_fragment:cT,lights_phong_fragment:uT,lights_phong_pars_fragment:hT,lights_physical_fragment:fT,lights_physical_pars_fragment:dT,lights_fragment_begin:pT,lights_fragment_maps:mT,lights_fragment_end:gT,logdepthbuf_fragment:yT,logdepthbuf_pars_fragment:xT,logdepthbuf_pars_vertex:vT,logdepthbuf_vertex:_T,map_fragment:TT,map_pars_fragment:MT,map_particle_fragment:ET,map_particle_pars_fragment:bT,metalnessmap_fragment:ST,metalnessmap_pars_fragment:AT,morphinstance_vertex:wT,morphcolor_vertex:CT,morphnormal_vertex:IT,morphtarget_pars_vertex:RT,morphtarget_vertex:PT,normal_fragment_begin:NT,normal_fragment_maps:LT,normal_pars_fragment:OT,normal_pars_vertex:DT,normal_vertex:FT,normalmap_pars_fragment:UT,clearcoat_normal_fragment_begin:kT,clearcoat_normal_fragment_maps:BT,clearcoat_pars_fragment:GT,iridescence_pars_fragment:VT,opaque_fragment:zT,packing:HT,premultiplied_alpha_fragment:WT,project_vertex:XT,dithering_fragment:qT,dithering_pars_fragment:jT,roughnessmap_fragment:YT,roughnessmap_pars_fragment:KT,shadowmap_pars_fragment:ZT,shadowmap_pars_vertex:JT,shadowmap_vertex:$T,shadowmask_pars_fragment:QT,skinbase_vertex:eM,skinning_pars_vertex:tM,skinning_vertex:nM,skinnormal_vertex:iM,specularmap_fragment:rM,specularmap_pars_fragment:sM,tonemapping_fragment:oM,tonemapping_pars_fragment:aM,transmission_fragment:lM,transmission_pars_fragment:cM,uv_pars_fragment:uM,uv_pars_vertex:hM,uv_vertex:fM,worldpos_vertex:dM,background_vert:pM,background_frag:mM,backgroundCube_vert:gM,backgroundCube_frag:yM,cube_vert:xM,cube_frag:vM,depth_vert:_M,depth_frag:TM,distanceRGBA_vert:MM,distanceRGBA_frag:EM,equirect_vert:bM,equirect_frag:SM,linedashed_vert:AM,linedashed_frag:wM,meshbasic_vert:CM,meshbasic_frag:IM,meshlambert_vert:RM,meshlambert_frag:PM,meshmatcap_vert:NM,meshmatcap_frag:LM,meshnormal_vert:OM,meshnormal_frag:DM,meshphong_vert:FM,meshphong_frag:UM,meshphysical_vert:kM,meshphysical_frag:BM,meshtoon_vert:GM,meshtoon_frag:VM,points_vert:zM,points_frag:HM,shadow_vert:WM,shadow_frag:XM,sprite_vert:qM,sprite_frag:jM},qe={common:{diffuse:{value:new He(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new gt},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new gt}},envmap:{envMap:{value:null},envMapRotation:{value:new gt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new gt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new gt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new gt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new gt},normalScale:{value:new Pe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new gt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new gt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new gt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new gt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new He(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 He(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0},uvTransform:{value:new gt}},sprite:{diffuse:{value:new He(16777215)},opacity:{value:1},center:{value:new Pe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new gt},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0}}},Rr={basic:{uniforms:Qn([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.fog]),vertexShader:Ct.meshbasic_vert,fragmentShader:Ct.meshbasic_frag},lambert:{uniforms:Qn([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,qe.lights,{emissive:{value:new He(0)}}]),vertexShader:Ct.meshlambert_vert,fragmentShader:Ct.meshlambert_frag},phong:{uniforms:Qn([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,qe.lights,{emissive:{value:new He(0)},specular:{value:new He(1118481)},shininess:{value:30}}]),vertexShader:Ct.meshphong_vert,fragmentShader:Ct.meshphong_frag},standard:{uniforms:Qn([qe.common,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.roughnessmap,qe.metalnessmap,qe.fog,qe.lights,{emissive:{value:new He(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ct.meshphysical_vert,fragmentShader:Ct.meshphysical_frag},toon:{uniforms:Qn([qe.common,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.gradientmap,qe.fog,qe.lights,{emissive:{value:new He(0)}}]),vertexShader:Ct.meshtoon_vert,fragmentShader:Ct.meshtoon_frag},matcap:{uniforms:Qn([qe.common,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,{matcap:{value:null}}]),vertexShader:Ct.meshmatcap_vert,fragmentShader:Ct.meshmatcap_frag},points:{uniforms:Qn([qe.points,qe.fog]),vertexShader:Ct.points_vert,fragmentShader:Ct.points_frag},dashed:{uniforms:Qn([qe.common,qe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ct.linedashed_vert,fragmentShader:Ct.linedashed_frag},depth:{uniforms:Qn([qe.common,qe.displacementmap]),vertexShader:Ct.depth_vert,fragmentShader:Ct.depth_frag},normal:{uniforms:Qn([qe.common,qe.bumpmap,qe.normalmap,qe.displacementmap,{opacity:{value:1}}]),vertexShader:Ct.meshnormal_vert,fragmentShader:Ct.meshnormal_frag},sprite:{uniforms:Qn([qe.sprite,qe.fog]),vertexShader:Ct.sprite_vert,fragmentShader:Ct.sprite_frag},background:{uniforms:{uvTransform:{value:new gt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ct.background_vert,fragmentShader:Ct.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new gt}},vertexShader:Ct.backgroundCube_vert,fragmentShader:Ct.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ct.cube_vert,fragmentShader:Ct.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ct.equirect_vert,fragmentShader:Ct.equirect_frag},distanceRGBA:{uniforms:Qn([qe.common,qe.displacementmap,{referencePosition:{value:new se},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ct.distanceRGBA_vert,fragmentShader:Ct.distanceRGBA_frag},shadow:{uniforms:Qn([qe.lights,qe.fog,{color:{value:new He(0)},opacity:{value:1}}]),vertexShader:Ct.shadow_vert,fragmentShader:Ct.shadow_frag}};Rr.physical={uniforms:Qn([Rr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new gt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new gt},clearcoatNormalScale:{value:new Pe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new gt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new gt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new gt},sheen:{value:0},sheenColor:{value:new He(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new gt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new gt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new gt},transmissionSamplerSize:{value:new Pe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new gt},attenuationDistance:{value:0},attenuationColor:{value:new He(0)},specularColor:{value:new He(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new gt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new gt},anisotropyVector:{value:new Pe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new gt}}]),vertexShader:Ct.meshphysical_vert,fragmentShader:Ct.meshphysical_frag};var Ef={r:0,b:0,g:0},Eo=new vn,YM=new Je;function KM(r,e,t,n,i,s,o){let a=new He(0),l=s===!0?0:1,c,u,h=null,f=0,p=null;function g(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,S=g(v);S===null?m(a,l):S&&S.isColor&&(m(S,1),x=!0);let I=r.xr.getEnvironmentBlendMode();I==="additive"?n.buffers.color.setClear(0,0,0,1,o):I==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(r.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function d(v,x){let S=g(x);S&&(S.isCubeTexture||S.mapping===Ac)?(u===void 0&&(u=new Dt(new Is(1,1,1),new nr({name:"BackgroundCubeMaterial",uniforms:Mo(Rr.backgroundCube.uniforms),vertexShader:Rr.backgroundCube.vertexShader,fragmentShader:Rr.backgroundCube.fragmentShader,side:_n,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(I,A,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Eo.copy(x.backgroundRotation),Eo.x*=-1,Eo.y*=-1,Eo.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Eo.y*=-1,Eo.z*=-1),u.material.uniforms.envMap.value=S,u.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(YM.makeRotationFromEuler(Eo)),u.material.toneMapped=mt.getTransfer(S.colorSpace)!==Kt,(h!==S||f!==S.version||p!==r.toneMapping)&&(u.material.needsUpdate=!0,h=S,f=S.version,p=r.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new Dt(new po(2,2),new nr({name:"BackgroundMaterial",uniforms:Mo(Rr.background.uniforms),vertexShader:Rr.background.vertexShader,fragmentShader:Rr.background.fragmentShader,side:wi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=mt.getTransfer(S.colorSpace)!==Kt,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||f!==S.version||p!==r.toneMapping)&&(c.material.needsUpdate=!0,h=S,f=S.version,p=r.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function m(v,x){v.getRGB(Ef,Rp(r)),n.buffers.color.setClear(Ef.r,Ef.g,Ef.b,x,o)}function _(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(v,x=1){a.set(v),l=x,m(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,m(a,l)},render:y,addToRenderList:d,dispose:_}}function ZM(r,e){let t=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=f(null),s=i,o=!1;function a(b,R,N,B,V){let ie=!1,Y=h(B,N,R);s!==Y&&(s=Y,c(s.object)),ie=p(b,B,N,V),ie&&g(b,B,N,V),V!==null&&e.update(V,r.ELEMENT_ARRAY_BUFFER),(ie||o)&&(o=!1,x(b,R,N,B),V!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(V).buffer))}function l(){return r.createVertexArray()}function c(b){return r.bindVertexArray(b)}function u(b){return r.deleteVertexArray(b)}function h(b,R,N){let B=N.wireframe===!0,V=n[b.id];V===void 0&&(V={},n[b.id]=V);let ie=V[R.id];ie===void 0&&(ie={},V[R.id]=ie);let Y=ie[B];return Y===void 0&&(Y=f(l()),ie[B]=Y),Y}function f(b){let R=[],N=[],B=[];for(let V=0;V<t;V++)R[V]=0,N[V]=0,B[V]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:N,attributeDivisors:B,object:b,attributes:{},index:null}}function p(b,R,N,B){let V=s.attributes,ie=R.attributes,Y=0,te=N.getAttributes();for(let q in te)if(te[q].location>=0){let ye=V[q],Te=ie[q];if(Te===void 0&&(q==="instanceMatrix"&&b.instanceMatrix&&(Te=b.instanceMatrix),q==="instanceColor"&&b.instanceColor&&(Te=b.instanceColor)),ye===void 0||ye.attribute!==Te||Te&&ye.data!==Te.data)return!0;Y++}return s.attributesNum!==Y||s.index!==B}function g(b,R,N,B){let V={},ie=R.attributes,Y=0,te=N.getAttributes();for(let q in te)if(te[q].location>=0){let ye=ie[q];ye===void 0&&(q==="instanceMatrix"&&b.instanceMatrix&&(ye=b.instanceMatrix),q==="instanceColor"&&b.instanceColor&&(ye=b.instanceColor));let Te={};Te.attribute=ye,ye&&ye.data&&(Te.data=ye.data),V[q]=Te,Y++}s.attributes=V,s.attributesNum=Y,s.index=B}function y(){let b=s.newAttributes;for(let R=0,N=b.length;R<N;R++)b[R]=0}function d(b){m(b,0)}function m(b,R){let N=s.newAttributes,B=s.enabledAttributes,V=s.attributeDivisors;N[b]=1,B[b]===0&&(r.enableVertexAttribArray(b),B[b]=1),V[b]!==R&&(r.vertexAttribDivisor(b,R),V[b]=R)}function _(){let b=s.newAttributes,R=s.enabledAttributes;for(let N=0,B=R.length;N<B;N++)R[N]!==b[N]&&(r.disableVertexAttribArray(N),R[N]=0)}function v(b,R,N,B,V,ie,Y){Y===!0?r.vertexAttribIPointer(b,R,N,V,ie):r.vertexAttribPointer(b,R,N,B,V,ie)}function x(b,R,N,B){y();let V=B.attributes,ie=N.getAttributes(),Y=R.defaultAttributeValues;for(let te in ie){let q=ie[te];if(q.location>=0){let le=V[te];if(le===void 0&&(te==="instanceMatrix"&&b.instanceMatrix&&(le=b.instanceMatrix),te==="instanceColor"&&b.instanceColor&&(le=b.instanceColor)),le!==void 0){let ye=le.normalized,Te=le.itemSize,Ae=e.get(le);if(Ae===void 0)continue;let _e=Ae.buffer,G=Ae.type,P=Ae.bytesPerElement,M=G===r.INT||G===r.UNSIGNED_INT||le.gpuType===Wh;if(le.isInterleavedBufferAttribute){let T=le.data,k=T.stride,j=le.offset;if(T.isInstancedInterleavedBuffer){for(let W=0;W<q.locationSize;W++)m(q.location+W,T.meshPerAttribute);b.isInstancedMesh!==!0&&B._maxInstanceCount===void 0&&(B._maxInstanceCount=T.meshPerAttribute*T.count)}else for(let W=0;W<q.locationSize;W++)d(q.location+W);r.bindBuffer(r.ARRAY_BUFFER,_e);for(let W=0;W<q.locationSize;W++)v(q.location+W,Te/q.locationSize,G,ye,k*P,(j+Te/q.locationSize*W)*P,M)}else{if(le.isInstancedBufferAttribute){for(let T=0;T<q.locationSize;T++)m(q.location+T,le.meshPerAttribute);b.isInstancedMesh!==!0&&B._maxInstanceCount===void 0&&(B._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let T=0;T<q.locationSize;T++)d(q.location+T);r.bindBuffer(r.ARRAY_BUFFER,_e);for(let T=0;T<q.locationSize;T++)v(q.location+T,Te/q.locationSize,G,ye,Te*P,Te/q.locationSize*T*P,M)}}else if(Y!==void 0){let ye=Y[te];if(ye!==void 0)switch(ye.length){case 2:r.vertexAttrib2fv(q.location,ye);break;case 3:r.vertexAttrib3fv(q.location,ye);break;case 4:r.vertexAttrib4fv(q.location,ye);break;default:r.vertexAttrib1fv(q.location,ye)}}}}_()}function S(){C();for(let b in n){let R=n[b];for(let N in R){let B=R[N];for(let V in B)u(B[V].object),delete B[V];delete R[N]}delete n[b]}}function I(b){if(n[b.id]===void 0)return;let R=n[b.id];for(let N in R){let B=R[N];for(let V in B)u(B[V].object),delete B[V];delete R[N]}delete n[b.id]}function A(b){for(let R in n){let N=n[R];if(N[b.id]===void 0)continue;let B=N[b.id];for(let V in B)u(B[V].object),delete B[V];delete N[b.id]}}function C(){E(),o=!0,s!==i&&(s=i,c(s.object))}function E(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:C,resetDefaultState:E,dispose:S,releaseStatesOfGeometry:I,releaseStatesOfProgram:A,initAttributes:y,enableAttribute:d,disableUnusedAttributes:_}}function JM(r,e,t){let n;function i(c){n=c}function s(c,u){r.drawArrays(n,c,u),t.update(u,n,1)}function o(c,u,h){h!==0&&(r.drawArraysInstanced(n,c,u,h),t.update(u,n,h))}function a(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,u,0,h);let p=0;for(let g=0;g<h;g++)p+=u[g];t.update(p,n,1)}function l(c,u,h,f){if(h===0)return;let p=e.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<c.length;g++)o(c[g],u[g],f[g]);else{p.multiDrawArraysInstancedWEBGL(n,c,0,u,0,f,0,h);let g=0;for(let y=0;y<h;y++)g+=u[y]*f[y];t.update(g,n,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function $M(r,e,t,n){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){let A=e.get("EXT_texture_filter_anisotropic");i=r.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(A){return!(A!==Pi&&n.convert(A)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){let C=A===Ba&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==lr&&n.convert(A)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==cr&&!C)}function l(A){if(A==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);let h=t.logarithmicDepthBuffer===!0,f=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),p=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),g=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=r.getParameter(r.MAX_TEXTURE_SIZE),d=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),m=r.getParameter(r.MAX_VERTEX_ATTRIBS),_=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),v=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),S=g>0,I=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:f,maxTextures:p,maxVertexTextures:g,maxTextureSize:y,maxCubemapSize:d,maxAttributes:m,maxVertexUniforms:_,maxVaryings:v,maxFragmentUniforms:x,vertexTextures:S,maxSamples:I}}function QM(r){let e=this,t=null,n=0,i=!1,s=!1,o=new Sr,a=new gt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){let p=h.length!==0||f||n!==0||i;return i=f,n=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){t=u(h,f,0)},this.setState=function(h,f,p){let g=h.clippingPlanes,y=h.clipIntersection,d=h.clipShadows,m=r.get(h);if(!i||g===null||g.length===0||s&&!d)s?u(null):c();else{let _=s?0:n,v=_*4,x=m.clippingState||null;l.value=x,x=u(g,f,v,p);for(let S=0;S!==v;++S)x[S]=t[S];m.clippingState=x,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=_}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,f,p,g){let y=h!==null?h.length:0,d=null;if(y!==0){if(d=l.value,g!==!0||d===null){let m=p+y*4,_=f.matrixWorldInverse;a.getNormalMatrix(_),(d===null||d.length<m)&&(d=new Float32Array(m));for(let v=0,x=p;v!==y;++v,x+=4)o.copy(h[v]).applyMatrix4(_,a),o.normal.toArray(d,x),d[x+3]=o.constant}l.value=d,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,d}}function eE(r){let e=new WeakMap;function t(o,a){return a===Ua?o.mapping=_o:a===zh&&(o.mapping=To),o}function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===Ua||a===zh)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new xh(l.height);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}var Ha=4,uy=[.125,.215,.35,.446,.526,.582],Ao=20,Dp=new ss,hy=new He,Fp=null,Up=0,kp=0,Bp=!1,So=(1+Math.sqrt(5))/2,za=1/So,fy=[new se(-So,za,0),new se(So,za,0),new se(-za,0,So),new se(za,0,So),new se(0,So,-za),new se(0,So,za),new se(-1,1,-1),new se(1,1,-1),new se(-1,1,1),new se(1,1,1)],tE=new se,Af=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,n=.1,i=100,s={}){let{size:o=256,position:a=tE}=s;Fp=this._renderer.getRenderTarget(),Up=this._renderer.getActiveCubeFace(),kp=this._renderer.getActiveMipmapLevel(),Bp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,i,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=my(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=py(),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(Fp,Up,kp),this._renderer.xr.enabled=Bp,e.scissorTest=!1,bf(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===_o||e.mapping===To?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Fp=this._renderer.getRenderTarget(),Up=this._renderer.getActiveCubeFace(),kp=this._renderer.getActiveMipmapLevel(),Bp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Pn,minFilter:Pn,generateMipmaps:!1,type:Ba,format:Pi,colorSpace:Ci,depthBuffer:!1},i=dy(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=dy(e,t,n);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=nE(s)),this._blurMaterial=iE(s,e,t)}return i}_compileMaterial(e){let t=new Dt(this._lodPlanes[0],e);this._renderer.compile(t,Dp)}_sceneToCubeUV(e,t,n,i,s){let l=new nn(90,1,t,n),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,f=h.autoClear,p=h.toneMapping;h.getClearColor(hy),h.toneMapping=ls,h.autoClear=!1;let g=new Ii({name:"PMREM.Background",side:_n,depthWrite:!1,depthTest:!1}),y=new Dt(new Is,g),d=!1,m=e.background;m?m.isColor&&(g.color.copy(m),e.background=null,d=!0):(g.color.copy(hy),d=!0);for(let _=0;_<6;_++){let v=_%3;v===0?(l.up.set(0,c[_],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+u[_],s.y,s.z)):v===1?(l.up.set(0,0,c[_]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+u[_],s.z)):(l.up.set(0,c[_],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+u[_]));let x=this._cubeSize;bf(i,v*x,_>2?x:0,x,x),h.setRenderTarget(i),d&&h.render(y,l),h.render(e,l)}y.geometry.dispose(),y.material.dispose(),h.toneMapping=p,h.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===_o||e.mapping===To;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=my()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=py());let s=i?this._cubemapMaterial:this._equirectMaterial,o=new Dt(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let l=this._cubeSize;bf(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Dp)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodPlanes.length;for(let s=1;s<i;s++){let o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=fy[(i-s-1)%fy.length];this._blur(e,s-1,s,o,a)}t.autoClear=n}_blur(e,t,n,i,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",s),this._halfBlur(o,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new Dt(this._lodPlanes[i],c),f=c.uniforms,p=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Ao-1),y=s/g,d=isFinite(s)?1+Math.floor(u*y):Ao;d>Ao&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${d} samples when the maximum is set to ${Ao}`);let m=[],_=0;for(let A=0;A<Ao;++A){let C=A/y,E=Math.exp(-C*C/2);m.push(E),A===0?_+=E:A<d&&(_+=2*E)}for(let A=0;A<m.length;A++)m[A]=m[A]/_;f.envMap.value=e.texture,f.samples.value=d,f.weights.value=m,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);let{_lodMax:v}=this;f.dTheta.value=g,f.mipInt.value=v-n;let x=this._sizeLods[i],S=3*x*(i>v-Ha?i-v+Ha:0),I=4*(this._cubeSize-x);bf(t,S,I,3*x,2*x),l.setRenderTarget(t),l.render(h,Dp)}};function nE(r){let e=[],t=[],n=[],i=r,s=r-Ha+1+uy.length;for(let o=0;o<s;o++){let a=Math.pow(2,i);t.push(a);let l=1/a;o>r-Ha?l=uy[o-r+Ha-1]:o===0&&(l=0),n.push(l);let c=1/(a-2),u=-c,h=1+c,f=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,g=6,y=3,d=2,m=1,_=new Float32Array(y*g*p),v=new Float32Array(d*g*p),x=new Float32Array(m*g*p);for(let I=0;I<p;I++){let A=I%3*2/3-1,C=I>2?0:-1,E=[A,C,0,A+2/3,C,0,A+2/3,C+1,0,A,C,0,A+2/3,C+1,0,A,C+1,0];_.set(E,y*g*I),v.set(f,d*g*I);let b=[I,I,I,I,I,I];x.set(b,m*g*I)}let S=new It;S.setAttribute("position",new Vn(_,y)),S.setAttribute("uv",new Vn(v,d)),S.setAttribute("faceIndex",new Vn(x,m)),e.push(S),i>Ha&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function dy(r,e,t){let n=new wr(r,e,t);return n.texture.mapping=Ac,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function bf(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function iE(r,e,t){let n=new Float32Array(Ao),i=new se(0,1,0);return new nr({name:"SphericalGaussianBlur",defines:{n:Ao,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Kp(),fragmentShader:`
precision mediump float;
precision mediump int;
}
}
- `,blending:us,depthTest:!1,depthWrite:!1})}function pg(){return new mr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Id(),fragmentShader:`
+ `,blending:as,depthTest:!1,depthWrite:!1})}function py(){return new nr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Kp(),fragmentShader:`
precision mediump float;
precision mediump int;
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
- `,blending:us,depthTest:!1,depthWrite:!1})}function mg(){return new mr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Id(),fragmentShader:`
+ `,blending:as,depthTest:!1,depthWrite:!1})}function my(){return new nr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Kp(),fragmentShader:`
precision mediump float;
precision mediump int;
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
- `,blending:us,depthTest:!1,depthWrite:!1})}function Id(){return`
+ `,blending:as,depthTest:!1,depthWrite:!1})}function Kp(){return`
precision mediump float;
precision mediump int;
gl_Position = vec4( position, 1.0 );
}
- `}function dM(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let l=a.mapping,c=l===Fl||l===Xf,u=l===ca||l===ua;if(c||u){let h=e.get(a),f=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==f)return t===null&&(t=new Hu(r)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{let p=a.image;return c&&p&&p.height>0||u&&p&&i(p)?(t===null&&(t=new Hu(r)),h=c?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function i(a){let l=0,c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){let l=a.target;l.removeEventListener("dispose",s);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function pM(r){let e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==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(n){let i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function mM(r,e,t,n){let i={},s=new WeakMap;function o(h){let f=h.target;f.index!==null&&e.remove(f.index);for(let g in f.attributes)e.remove(f.attributes[g]);for(let g in f.morphAttributes){let v=f.morphAttributes[g];for(let d=0,m=v.length;d<m;d++)e.remove(v[d])}f.removeEventListener("dispose",o),delete i[f.id];let p=s.get(f);p&&(e.remove(p),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function a(h,f){return i[f.id]===!0||(f.addEventListener("dispose",o),i[f.id]=!0,t.memory.geometries++),f}function l(h){let f=h.attributes;for(let g in f)e.update(f[g],r.ARRAY_BUFFER);let p=h.morphAttributes;for(let g in p){let v=p[g];for(let d=0,m=v.length;d<m;d++)e.update(v[d],r.ARRAY_BUFFER)}}function c(h){let f=[],p=h.index,g=h.attributes.position,v=0;if(p!==null){let _=p.array;v=p.version;for(let y=0,x=_.length;y<x;y+=3){let w=_[y+0],I=_[y+1],C=_[y+2];f.push(w,I,I,C,C,w)}}else if(g!==void 0){let _=g.array;v=g.version;for(let y=0,x=_.length/3-1;y<x;y+=3){let w=y+0,I=y+1,C=y+2;f.push(w,I,I,C,C,w)}}else return;let d=new(f0(f)?Vu:ma)(f,1);d.version=v;let m=s.get(h);m&&e.remove(m),s.set(h,d)}function u(h){let f=s.get(h);if(f){let p=h.index;p!==null&&f.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:u}}function gM(r,e,t){let n;function i(h){n=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function l(h,f){r.drawElements(n,f,s,h*o),t.update(f,n,1)}function c(h,f,p){p!==0&&(r.drawElementsInstanced(n,f,s,h*o,p),t.update(f,n,p))}function u(h,f,p){if(p===0)return;let g=e.get("WEBGL_multi_draw");if(g===null)for(let v=0;v<p;v++)this.render(h[v]/o,f[v]);else{g.multiDrawElementsWEBGL(n,f,0,s,h,0,p);let v=0;for(let d=0;d<p;d++)v+=f[d];t.update(v,n,1)}}this.setMode=i,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function vM(r){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case r.TRIANGLES:t.triangles+=a*(s/3);break;case r.LINES:t.lines+=a*(s/2);break;case r.LINE_STRIP:t.lines+=a*(s-1);break;case r.LINE_LOOP:t.lines+=a*s;break;case r.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function yM(r,e,t){let n=new WeakMap,i=new Ct;function s(o,a,l){let c=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,f=n.get(a);if(f===void 0||f.count!==h){let E=function(){C.dispose(),n.delete(a),a.removeEventListener("dispose",E)};f!==void 0&&f.texture.dispose();let p=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,v=a.morphAttributes.color!==void 0,d=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],_=a.morphAttributes.color||[],y=0;p===!0&&(y=1),g===!0&&(y=2),v===!0&&(y=3);let x=a.attributes.position.count*y,w=1;x>e.maxTextureSize&&(w=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);let I=new Float32Array(x*w*4*h),C=new Gu(I,x,w,h);C.type=Vr,C.needsUpdate=!0;let P=y*4;for(let M=0;M<h;M++){let L=d[M],N=m[M],O=_[M],B=x*w*4*M;for(let ie=0;ie<L.count;ie++){let $=ie*P;p===!0&&(i.fromBufferAttribute(L,ie),I[B+$+0]=i.x,I[B+$+1]=i.y,I[B+$+2]=i.z,I[B+$+3]=0),g===!0&&(i.fromBufferAttribute(N,ie),I[B+$+4]=i.x,I[B+$+5]=i.y,I[B+$+6]=i.z,I[B+$+7]=0),v===!0&&(i.fromBufferAttribute(O,ie),I[B+$+8]=i.x,I[B+$+9]=i.y,I[B+$+10]=i.z,I[B+$+11]=O.itemSize===4?i.w:1)}}f={count:h,texture:C,size:new Ce(x,w)},n.set(a,f),a.addEventListener("dispose",E)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(r,"morphTexture",o.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];let g=a.morphTargetsRelative?1:1-p;l.getUniforms().setValue(r,"morphTargetBaseInfluence",g),l.getUniforms().setValue(r,"morphTargetInfluences",c)}l.getUniforms().setValue(r,"morphTargetsTexture",f.texture,t),l.getUniforms().setValue(r,"morphTargetsTextureSize",f.size)}return{update:s}}function xM(r,e,t,n){let i=new WeakMap;function s(l){let c=n.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),i.get(l)!==c&&(t.update(l.instanceMatrix,r.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,r.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){let f=l.skeleton;i.get(f)!==c&&(f.update(),i.set(f,c))}return h}function o(){i=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}var Wu=class extends Dn{constructor(e,t,n,i,s,o,a,l,c,u){if(u=u!==void 0?u:sa,u!==sa&&u!==Ul)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===sa&&(n=fa),n===void 0&&u===Ul&&(n=Zl),super(null,i,s,o,a,l,u,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Bn,this.minFilter=l!==void 0?l:Bn,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}},g0=new Dn,v0=new Wu(1,1);v0.compareFunction=h0;var y0=new Gu,x0=new qf,_0=new Gl,gg=[],vg=[],yg=new Float32Array(16),xg=new Float32Array(9),_g=new Float32Array(4);function wa(r,e,t){let n=r[0];if(n<=0||n>0)return r;let i=e*t,s=gg[i];if(s===void 0&&(s=new Float32Array(i),gg[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function Sn(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function An(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function uh(r,e){let t=vg[e];t===void 0&&(t=new Int32Array(e),vg[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function _M(r,e){let t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function TM(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Sn(t,e))return;r.uniform2fv(this.addr,e),An(t,e)}}function MM(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.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)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Sn(t,e))return;r.uniform3fv(this.addr,e),An(t,e)}}function EM(r,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)&&(r.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(Sn(t,e))return;r.uniform4fv(this.addr,e),An(t,e)}}function bM(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Sn(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),An(t,e)}else{if(Sn(t,n))return;_g.set(n),r.uniformMatrix2fv(this.addr,!1,_g),An(t,n)}}function SM(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Sn(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),An(t,e)}else{if(Sn(t,n))return;xg.set(n),r.uniformMatrix3fv(this.addr,!1,xg),An(t,n)}}function AM(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Sn(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),An(t,e)}else{if(Sn(t,n))return;yg.set(n),r.uniformMatrix4fv(this.addr,!1,yg),An(t,n)}}function wM(r,e){let t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function CM(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Sn(t,e))return;r.uniform2iv(this.addr,e),An(t,e)}}function RM(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Sn(t,e))return;r.uniform3iv(this.addr,e),An(t,e)}}function IM(r,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)&&(r.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(Sn(t,e))return;r.uniform4iv(this.addr,e),An(t,e)}}function PM(r,e){let t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function NM(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Sn(t,e))return;r.uniform2uiv(this.addr,e),An(t,e)}}function LM(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Sn(t,e))return;r.uniform3uiv(this.addr,e),An(t,e)}}function OM(r,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)&&(r.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(Sn(t,e))return;r.uniform4uiv(this.addr,e),An(t,e)}}function DM(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i);let s=this.type===r.SAMPLER_2D_SHADOW?v0:g0;t.setTexture2D(e||s,i)}function FM(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||x0,i)}function UM(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||_0,i)}function kM(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||y0,i)}function BM(r){switch(r){case 5126:return _M;case 35664:return TM;case 35665:return MM;case 35666:return EM;case 35674:return bM;case 35675:return SM;case 35676:return AM;case 5124:case 35670:return wM;case 35667:case 35671:return CM;case 35668:case 35672:return RM;case 35669:case 35673:return IM;case 5125:return PM;case 36294:return NM;case 36295:return LM;case 36296:return OM;case 35678:case 36198:case 36298:case 36306:case 35682:return DM;case 35679:case 36299:case 36307:return FM;case 35680:case 36300:case 36308:case 36293:return UM;case 36289:case 36303:case 36311:case 36292:return kM}}function GM(r,e){r.uniform1fv(this.addr,e)}function VM(r,e){let t=wa(e,this.size,2);r.uniform2fv(this.addr,t)}function zM(r,e){let t=wa(e,this.size,3);r.uniform3fv(this.addr,t)}function HM(r,e){let t=wa(e,this.size,4);r.uniform4fv(this.addr,t)}function WM(r,e){let t=wa(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function XM(r,e){let t=wa(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function jM(r,e){let t=wa(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function qM(r,e){r.uniform1iv(this.addr,e)}function YM(r,e){r.uniform2iv(this.addr,e)}function KM(r,e){r.uniform3iv(this.addr,e)}function ZM(r,e){r.uniform4iv(this.addr,e)}function JM(r,e){r.uniform1uiv(this.addr,e)}function $M(r,e){r.uniform2uiv(this.addr,e)}function QM(r,e){r.uniform3uiv(this.addr,e)}function eE(r,e){r.uniform4uiv(this.addr,e)}function tE(r,e,t){let n=this.cache,i=e.length,s=uh(t,i);Sn(n,s)||(r.uniform1iv(this.addr,s),An(n,s));for(let o=0;o!==i;++o)t.setTexture2D(e[o]||g0,s[o])}function nE(r,e,t){let n=this.cache,i=e.length,s=uh(t,i);Sn(n,s)||(r.uniform1iv(this.addr,s),An(n,s));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||x0,s[o])}function iE(r,e,t){let n=this.cache,i=e.length,s=uh(t,i);Sn(n,s)||(r.uniform1iv(this.addr,s),An(n,s));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||_0,s[o])}function rE(r,e,t){let n=this.cache,i=e.length,s=uh(t,i);Sn(n,s)||(r.uniform1iv(this.addr,s),An(n,s));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||y0,s[o])}function sE(r){switch(r){case 5126:return GM;case 35664:return VM;case 35665:return zM;case 35666:return HM;case 35674:return WM;case 35675:return XM;case 35676:return jM;case 5124:case 35670:return qM;case 35667:case 35671:return YM;case 35668:case 35672:return KM;case 35669:case 35673:return ZM;case 5125:return JM;case 36294:return $M;case 36295:return QM;case 36296:return eE;case 35678:case 36198:case 36298:case 36306:case 35682:return tE;case 35679:case 36299:case 36307:return nE;case 35680:case 36300:case 36308:case 36293:return iE;case 36289:case 36303:case 36311:case 36292:return rE}}var Zf=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=BM(t.type)}},Jf=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=sE(t.type)}},$f=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let s=0,o=i.length;s!==o;++s){let a=i[s];a.setValue(e,t[a.id],n)}}},Lf=/(\w+)(\])?(\[|\.)?/g;function Tg(r,e){r.seq.push(e),r.map[e.id]=e}function oE(r,e,t){let n=r.name,i=n.length;for(Lf.lastIndex=0;;){let s=Lf.exec(n),o=Lf.lastIndex,a=s[1],l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){Tg(t,c===void 0?new Zf(a,r,e):new Jf(a,r,e));break}else{let h=t.map[a];h===void 0&&(h=new $f(a),Tg(t,h)),t=h}}}var la=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let s=e.getActiveUniform(t,i),o=e.getUniformLocation(t,s.name);oE(s,o,this)}}setValue(e,t,n,i){let s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,o=t.length;s!==o;++s){let a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,s=e.length;i!==s;++i){let o=e[i];o.id in t&&n.push(o)}return n}};function Mg(r,e,t){let n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}var aE=37297,lE=0;function cE(r,e){let t=r.split(`
+ `}function rE(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let l=a.mapping,c=l===Ua||l===zh,u=l===_o||l===To;if(c||u){let h=e.get(a),f=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==f)return t===null&&(t=new Af(r)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{let p=a.image;return c&&p&&p.height>0||u&&p&&i(p)?(t===null&&(t=new Af(r)),h=c?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function i(a){let l=0,c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){let l=a.target;l.removeEventListener("dispose",s);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function sE(r){let e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==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(n){let i=t(n);return i===null&&Oc("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function oE(r,e,t,n){let i={},s=new WeakMap;function o(h){let f=h.target;f.index!==null&&e.remove(f.index);for(let g in f.attributes)e.remove(f.attributes[g]);f.removeEventListener("dispose",o),delete i[f.id];let p=s.get(f);p&&(e.remove(p),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function a(h,f){return i[f.id]===!0||(f.addEventListener("dispose",o),i[f.id]=!0,t.memory.geometries++),f}function l(h){let f=h.attributes;for(let p in f)e.update(f[p],r.ARRAY_BUFFER)}function c(h){let f=[],p=h.index,g=h.attributes.position,y=0;if(p!==null){let _=p.array;y=p.version;for(let v=0,x=_.length;v<x;v+=3){let S=_[v+0],I=_[v+1],A=_[v+2];f.push(S,I,I,A,A,S)}}else if(g!==void 0){let _=g.array;y=g.version;for(let v=0,x=_.length/3-1;v<x;v+=3){let S=v+0,I=v+1,A=v+2;f.push(S,I,I,A,A,S)}}else return;let d=new(Ip(f)?ic:lo)(f,1);d.version=y;let m=s.get(h);m&&e.remove(m),s.set(h,d)}function u(h){let f=s.get(h);if(f){let p=h.index;p!==null&&f.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:u}}function aE(r,e,t){let n;function i(f){n=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function l(f,p){r.drawElements(n,p,s,f*o),t.update(p,n,1)}function c(f,p,g){g!==0&&(r.drawElementsInstanced(n,p,s,f*o,g),t.update(p,n,g))}function u(f,p,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,s,f,0,g);let d=0;for(let m=0;m<g;m++)d+=p[m];t.update(d,n,1)}function h(f,p,g,y){if(g===0)return;let d=e.get("WEBGL_multi_draw");if(d===null)for(let m=0;m<f.length;m++)c(f[m]/o,p[m],y[m]);else{d.multiDrawElementsInstancedWEBGL(n,p,0,s,f,0,y,0,g);let m=0;for(let _=0;_<g;_++)m+=p[_]*y[_];t.update(m,n,1)}}this.setMode=i,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function lE(r){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case r.TRIANGLES:t.triangles+=a*(s/3);break;case r.LINES:t.lines+=a*(s/2);break;case r.LINE_STRIP:t.lines+=a*(s-1);break;case r.LINE_LOOP:t.lines+=a*s;break;case r.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function cE(r,e,t){let n=new WeakMap,i=new wt;function s(o,a,l){let c=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,f=n.get(a);if(f===void 0||f.count!==h){let E=function(){A.dispose(),n.delete(a),a.removeEventListener("dispose",E)};f!==void 0&&f.texture.dispose();let p=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,y=a.morphAttributes.color!==void 0,d=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],_=a.morphAttributes.color||[],v=0;p===!0&&(v=1),g===!0&&(v=2),y===!0&&(v=3);let x=a.attributes.position.count*v,S=1;x>e.maxTextureSize&&(S=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);let I=new Float32Array(x*S*4*h),A=new nc(I,x,S,h);A.type=cr,A.needsUpdate=!0;let C=v*4;for(let b=0;b<h;b++){let R=d[b],N=m[b],B=_[b],V=x*S*4*b;for(let ie=0;ie<R.count;ie++){let Y=ie*C;p===!0&&(i.fromBufferAttribute(R,ie),I[V+Y+0]=i.x,I[V+Y+1]=i.y,I[V+Y+2]=i.z,I[V+Y+3]=0),g===!0&&(i.fromBufferAttribute(N,ie),I[V+Y+4]=i.x,I[V+Y+5]=i.y,I[V+Y+6]=i.z,I[V+Y+7]=0),y===!0&&(i.fromBufferAttribute(B,ie),I[V+Y+8]=i.x,I[V+Y+9]=i.y,I[V+Y+10]=i.z,I[V+Y+11]=B.itemSize===4?i.w:1)}}f={count:h,texture:A,size:new Pe(x,S)},n.set(a,f),a.addEventListener("dispose",E)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(r,"morphTexture",o.morphTexture,t);else{let p=0;for(let y=0;y<c.length;y++)p+=c[y];let g=a.morphTargetsRelative?1:1-p;l.getUniforms().setValue(r,"morphTargetBaseInfluence",g),l.getUniforms().setValue(r,"morphTargetInfluences",c)}l.getUniforms().setValue(r,"morphTargetsTexture",f.texture,t),l.getUniforms().setValue(r,"morphTargetsTextureSize",f.size)}return{update:s}}function uE(r,e,t,n){let i=new WeakMap;function s(l){let c=n.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),i.get(l)!==c&&(t.update(l.instanceMatrix,r.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,r.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){let f=l.skeleton;i.get(f)!==c&&(f.update(),i.set(f,c))}return h}function o(){i=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}var Oy=new qn,gy=new oc(1,1),Dy=new nc,Fy=new gh,Uy=new Ia,yy=[],xy=[],vy=new Float32Array(16),_y=new Float32Array(9),Ty=new Float32Array(4);function qa(r,e,t){let n=r[0];if(n<=0||n>0)return r;let i=e*t,s=yy[i];if(s===void 0&&(s=new Float32Array(i),yy[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function Ln(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function On(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function wf(r,e){let t=xy[e];t===void 0&&(t=new Int32Array(e),xy[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function hE(r,e){let t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function fE(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ln(t,e))return;r.uniform2fv(this.addr,e),On(t,e)}}function dE(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.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)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ln(t,e))return;r.uniform3fv(this.addr,e),On(t,e)}}function pE(r,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)&&(r.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(Ln(t,e))return;r.uniform4fv(this.addr,e),On(t,e)}}function mE(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Ln(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),On(t,e)}else{if(Ln(t,n))return;Ty.set(n),r.uniformMatrix2fv(this.addr,!1,Ty),On(t,n)}}function gE(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Ln(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),On(t,e)}else{if(Ln(t,n))return;_y.set(n),r.uniformMatrix3fv(this.addr,!1,_y),On(t,n)}}function yE(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Ln(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),On(t,e)}else{if(Ln(t,n))return;vy.set(n),r.uniformMatrix4fv(this.addr,!1,vy),On(t,n)}}function xE(r,e){let t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function vE(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ln(t,e))return;r.uniform2iv(this.addr,e),On(t,e)}}function _E(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ln(t,e))return;r.uniform3iv(this.addr,e),On(t,e)}}function TE(r,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)&&(r.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(Ln(t,e))return;r.uniform4iv(this.addr,e),On(t,e)}}function ME(r,e){let t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function EE(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ln(t,e))return;r.uniform2uiv(this.addr,e),On(t,e)}}function bE(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ln(t,e))return;r.uniform3uiv(this.addr,e),On(t,e)}}function SE(r,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)&&(r.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(Ln(t,e))return;r.uniform4uiv(this.addr,e),On(t,e)}}function AE(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i);let s;this.type===r.SAMPLER_2D_SHADOW?(gy.compareFunction=Ap,s=gy):s=Oy,t.setTexture2D(e||s,i)}function wE(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Fy,i)}function CE(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Uy,i)}function IE(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Dy,i)}function RE(r){switch(r){case 5126:return hE;case 35664:return fE;case 35665:return dE;case 35666:return pE;case 35674:return mE;case 35675:return gE;case 35676:return yE;case 5124:case 35670:return xE;case 35667:case 35671:return vE;case 35668:case 35672:return _E;case 35669:case 35673:return TE;case 5125:return ME;case 36294:return EE;case 36295:return bE;case 36296:return SE;case 35678:case 36198:case 36298:case 36306:case 35682:return AE;case 35679:case 36299:case 36307:return wE;case 35680:case 36300:case 36308:case 36293:return CE;case 36289:case 36303:case 36311:case 36292:return IE}}function PE(r,e){r.uniform1fv(this.addr,e)}function NE(r,e){let t=qa(e,this.size,2);r.uniform2fv(this.addr,t)}function LE(r,e){let t=qa(e,this.size,3);r.uniform3fv(this.addr,t)}function OE(r,e){let t=qa(e,this.size,4);r.uniform4fv(this.addr,t)}function DE(r,e){let t=qa(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function FE(r,e){let t=qa(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function UE(r,e){let t=qa(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function kE(r,e){r.uniform1iv(this.addr,e)}function BE(r,e){r.uniform2iv(this.addr,e)}function GE(r,e){r.uniform3iv(this.addr,e)}function VE(r,e){r.uniform4iv(this.addr,e)}function zE(r,e){r.uniform1uiv(this.addr,e)}function HE(r,e){r.uniform2uiv(this.addr,e)}function WE(r,e){r.uniform3uiv(this.addr,e)}function XE(r,e){r.uniform4uiv(this.addr,e)}function qE(r,e,t){let n=this.cache,i=e.length,s=wf(t,i);Ln(n,s)||(r.uniform1iv(this.addr,s),On(n,s));for(let o=0;o!==i;++o)t.setTexture2D(e[o]||Oy,s[o])}function jE(r,e,t){let n=this.cache,i=e.length,s=wf(t,i);Ln(n,s)||(r.uniform1iv(this.addr,s),On(n,s));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||Fy,s[o])}function YE(r,e,t){let n=this.cache,i=e.length,s=wf(t,i);Ln(n,s)||(r.uniform1iv(this.addr,s),On(n,s));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||Uy,s[o])}function KE(r,e,t){let n=this.cache,i=e.length,s=wf(t,i);Ln(n,s)||(r.uniform1iv(this.addr,s),On(n,s));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||Dy,s[o])}function ZE(r){switch(r){case 5126:return PE;case 35664:return NE;case 35665:return LE;case 35666:return OE;case 35674:return DE;case 35675:return FE;case 35676:return UE;case 5124:case 35670:return kE;case 35667:case 35671:return BE;case 35668:case 35672:return GE;case 35669:case 35673:return VE;case 5125:return zE;case 36294:return HE;case 36295:return WE;case 36296:return XE;case 35678:case 36198:case 36298:case 36306:case 35682:return qE;case 35679:case 36299:case 36307:return jE;case 35680:case 36300:case 36308:case 36293:return YE;case 36289:case 36303:case 36311:case 36292:return KE}}var Vp=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=RE(t.type)}},zp=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=ZE(t.type)}},Hp=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let s=0,o=i.length;s!==o;++s){let a=i[s];a.setValue(e,t[a.id],n)}}},Gp=/(\w+)(\])?(\[|\.)?/g;function My(r,e){r.seq.push(e),r.map[e.id]=e}function JE(r,e,t){let n=r.name,i=n.length;for(Gp.lastIndex=0;;){let s=Gp.exec(n),o=Gp.lastIndex,a=s[1],l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){My(t,c===void 0?new Vp(a,r,e):new zp(a,r,e));break}else{let h=t.map[a];h===void 0&&(h=new Hp(a),My(t,h)),t=h}}}var Wa=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let s=e.getActiveUniform(t,i),o=e.getUniformLocation(t,s.name);JE(s,o,this)}}setValue(e,t,n,i){let s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,o=t.length;s!==o;++s){let a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,s=e.length;i!==s;++i){let o=e[i];o.id in t&&n.push(o)}return n}};function Ey(r,e,t){let n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}var $E=37297,QE=0;function eb(r,e){let t=r.split(`
`),n=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=i;o<s;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
-`)}function uE(r){let e=Bt.getPrimaries(Bt.workingColorSpace),t=Bt.getPrimaries(r),n;switch(e===t?n="":e===Uu&&t===Fu?n="LinearDisplayP3ToLinearSRGB":e===Fu&&t===Uu&&(n="LinearSRGBToLinearDisplayP3"),r){case li:case ch:return[n,"LinearTransferOETF"];case jt:case Cd:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),[n,"LinearTransferOETF"]}}function Eg(r,e,t){let n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";let s=/ERROR: 0:(\d+)/.exec(i);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
+`)}var by=new gt;function tb(r){mt._getMatrix(by,mt.workingColorSpace,r);let e=`mat3( ${by.elements.map(t=>t.toFixed(4))} )`;switch(mt.getTransfer(r)){case ec:return[e,"LinearTransferOETF"];case Kt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",r),[e,"LinearTransferOETF"]}}function Sy(r,e,t){let n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";let s=/ERROR: 0:(\d+)/.exec(i);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
`+i+`
-`+cE(r.getShaderSource(e),o)}else return i}function hE(r,e){let t=uE(e);return`vec4 ${r}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function fE(r,e){let t;switch(e){case uy:t="Linear";break;case hy:t="Reinhard";break;case fy:t="OptimizedCineon";break;case dy:t="ACESFilmic";break;case my:t="AgX";break;case gy:t="Neutral";break;case py:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function dE(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Pl).join(`
-`)}function pE(r){let e=[];for(let t in r){let n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
-`)}function mE(r,e){let t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let s=r.getActiveAttrib(e,i),o=s.name,a=1;s.type===r.FLOAT_MAT2&&(a=2),s.type===r.FLOAT_MAT3&&(a=3),s.type===r.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:r.getAttribLocation(e,o),locationSize:a}}return t}function Pl(r){return r!==""}function bg(r,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.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 Sg(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var gE=/^[ \t]*#include +<([\w\d./]+)>/gm;function Qf(r){return r.replace(gE,yE)}var vE=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function yE(r,e){let t=Et[e];if(t===void 0){let n=vE.get(e);if(n!==void 0)t=Et[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Qf(t)}var xE=/#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;function Ag(r){return r.replace(xE,_E)}function _E(r,e,t,n){let i="";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function wg(r){let e=`precision ${r.precision} float;
+`+eb(r.getShaderSource(e),o)}else return i}function nb(r,e){let t=tb(e);return[`vec4 ${r}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
+`)}function ib(r,e){let t;switch(e){case N0:t="Linear";break;case L0:t="Reinhard";break;case O0:t="Cineon";break;case D0:t="ACESFilmic";break;case U0:t="AgX";break;case k0:t="Neutral";break;case F0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var Sf=new se;function rb(){mt.getLuminanceCoefficients(Sf);let r=Sf.x.toFixed(4),e=Sf.y.toFixed(4),t=Sf.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${r}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
+`)}function sb(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Dc).join(`
+`)}function ob(r){let e=[];for(let t in r){let n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
+`)}function ab(r,e){let t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let s=r.getActiveAttrib(e,i),o=s.name,a=1;s.type===r.FLOAT_MAT2&&(a=2),s.type===r.FLOAT_MAT3&&(a=3),s.type===r.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:r.getAttribLocation(e,o),locationSize:a}}return t}function Dc(r){return r!==""}function Ay(r,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.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 wy(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var lb=/^[ \t]*#include +<([\w\d./]+)>/gm;function Wp(r){return r.replace(lb,ub)}var cb=new Map;function ub(r,e){let t=Ct[e];if(t===void 0){let n=cb.get(e);if(n!==void 0)t=Ct[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Wp(t)}var hb=/#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;function Cy(r){return r.replace(hb,fb)}function fb(r,e,t,n){let i="";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function Iy(r){let e=`precision ${r.precision} float;
precision ${r.precision} int;
precision ${r.precision} sampler2D;
precision ${r.precision} samplerCube;
`;return r.precision==="highp"?e+=`
#define HIGH_PRECISION`:r.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
-#define LOW_PRECISION`),e}function TE(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===t0?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===Fv?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Br&&(e="SHADOWMAP_TYPE_VSM"),e}function ME(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case ca:case ua:e="ENVMAP_TYPE_CUBE";break;case ah:e="ENVMAP_TYPE_CUBE_UV";break}return e}function EE(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case ua:e="ENVMAP_MODE_REFRACTION";break}return e}function bE(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case oh:e="ENVMAP_BLENDING_MULTIPLY";break;case ly:e="ENVMAP_BLENDING_MIX";break;case cy:e="ENVMAP_BLENDING_ADD";break}return e}function SE(r){let e=r.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function AE(r,e,t,n){let i=r.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,l=TE(t),c=ME(t),u=EE(t),h=bE(t),f=SE(t),p=dE(t),g=pE(s),v=i.createProgram(),d,m,_=t.glslVersion?"#version "+t.glslVersion+`
-`:"";t.isRawShaderMaterial?(d=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Pl).join(`
+#define LOW_PRECISION`),e}function db(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===dp?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===h0?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Ir&&(e="SHADOWMAP_TYPE_VSM"),e}function pb(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case _o:case To:e="ENVMAP_TYPE_CUBE";break;case Ac:e="ENVMAP_TYPE_CUBE_UV";break}return e}function mb(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case To:e="ENVMAP_MODE_REFRACTION";break}return e}function gb(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case Sc:e="ENVMAP_BLENDING_MULTIPLY";break;case R0:e="ENVMAP_BLENDING_MIX";break;case P0:e="ENVMAP_BLENDING_ADD";break}return e}function yb(r){let e=r.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function xb(r,e,t,n){let i=r.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,l=db(t),c=pb(t),u=mb(t),h=gb(t),f=yb(t),p=sb(t),g=ob(s),y=i.createProgram(),d,m,_=t.glslVersion?"#version "+t.glslVersion+`
+`:"";t.isRawShaderMaterial?(d=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Dc).join(`
`),d.length>0&&(d+=`
-`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Pl).join(`
+`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Dc).join(`
`),m.length>0&&(m+=`
-`)):(d=[wg(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,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 "+l:"",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",`
-`].filter(Pl).join(`
-`),m=[wg(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,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 "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.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.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 "+l:"",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!==hs?"#define TONE_MAPPING":"",t.toneMapping!==hs?Et.tonemapping_pars_fragment:"",t.toneMapping!==hs?fE("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Et.colorspace_pars_fragment,hE("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
-`].filter(Pl).join(`
-`)),o=Qf(o),o=bg(o,t),o=Sg(o,t),a=Qf(a),a=bg(a,t),a=Sg(a,t),o=Ag(o),a=Ag(a),t.isRawShaderMaterial!==!0&&(_=`#version 300 es
+`)):(d=[Iy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",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_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 "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
+`].filter(Dc).join(`
+`),m=[Iy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,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 "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.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||t.batchingColor?"#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 "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ls?"#define TONE_MAPPING":"",t.toneMapping!==ls?Ct.tonemapping_pars_fragment:"",t.toneMapping!==ls?ib("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ct.colorspace_pars_fragment,nb("linearToOutputTexel",t.outputColorSpace),rb(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
+`].filter(Dc).join(`
+`)),o=Wp(o),o=Ay(o,t),o=wy(o,t),a=Wp(a),a=Ay(a,t),a=wy(a,t),o=Cy(o),a=Cy(a),t.isRawShaderMaterial!==!0&&(_=`#version 300 es
`,d=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
-`+d,m=["#define varying in",t.glslVersion===Hm?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Hm?"":"#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(`
+`+d,m=["#define varying in",t.glslVersion===wp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===wp?"":"#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(`
`)+`
-`+m);let y=_+d+o,x=_+m+a,w=Mg(i,i.VERTEX_SHADER,y),I=Mg(i,i.FRAGMENT_SHADER,x);i.attachShader(v,w),i.attachShader(v,I),t.index0AttributeName!==void 0?i.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function C(L){if(r.debug.checkShaderErrors){let N=i.getProgramInfoLog(v).trim(),O=i.getShaderInfoLog(w).trim(),B=i.getShaderInfoLog(I).trim(),ie=!0,$=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(ie=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,v,w,I);else{let te=Eg(i,w,"vertex"),W=Eg(i,I,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
+`+m);let v=_+d+o,x=_+m+a,S=Ey(i,i.VERTEX_SHADER,v),I=Ey(i,i.FRAGMENT_SHADER,x);i.attachShader(y,S),i.attachShader(y,I),t.index0AttributeName!==void 0?i.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function A(R){if(r.debug.checkShaderErrors){let N=i.getProgramInfoLog(y).trim(),B=i.getShaderInfoLog(S).trim(),V=i.getShaderInfoLog(I).trim(),ie=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(ie=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,y,S,I);else{let te=Sy(i,S,"vertex"),q=Sy(i,I,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
-Material Name: `+L.name+`
-Material Type: `+L.type+`
+Material Name: `+R.name+`
+Material Type: `+R.type+`
Program Info Log: `+N+`
`+te+`
-`+W)}else N!==""?console.warn("THREE.WebGLProgram: Program Info Log:",N):(O===""||B==="")&&($=!1);$&&(L.diagnostics={runnable:ie,programLog:N,vertexShader:{log:O,prefix:d},fragmentShader:{log:B,prefix:m}})}i.deleteShader(w),i.deleteShader(I),P=new la(i,v),E=mE(i,v)}let P;this.getUniforms=function(){return P===void 0&&C(this),P};let E;this.getAttributes=function(){return E===void 0&&C(this),E};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=i.getProgramParameter(v,aE)),M},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=lE++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=w,this.fragmentShader=I,this}var wE=0,ed=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new td(e),t.set(e,n)),n}},td=class{constructor(e){this.id=wE++,this.code=e,this.usedTimes=0}};function CE(r,e,t,n,i,s,o){let a=new Bl,l=new ed,c=new Set,u=[],h=i.logarithmicDepthBuffer,f=i.vertexTextures,p=i.precision,g={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 v(E){return c.add(E),E===0?"uv":`uv${E}`}function d(E,M,L,N,O){let B=N.fog,ie=O.geometry,$=E.isMeshStandardMaterial?N.environment:null,te=(E.isMeshStandardMaterial?t:e).get(E.envMap||$),W=te&&te.mapping===ah?te.image.height:null,ae=g[E.type];E.precision!==null&&(p=i.getMaxPrecision(E.precision),p!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",p,"instead."));let de=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,ye=de!==void 0?de.length:0,Me=0;ie.morphAttributes.position!==void 0&&(Me=1),ie.morphAttributes.normal!==void 0&&(Me=2),ie.morphAttributes.color!==void 0&&(Me=3);let ve,R,T,S;if(ae){let wt=pr[ae];ve=wt.vertexShader,R=wt.fragmentShader}else ve=E.vertexShader,R=E.fragmentShader,l.update(E),T=l.getVertexShaderID(E),S=l.getFragmentShaderID(E);let b=r.getRenderTarget(),V=O.isInstancedMesh===!0,q=O.isBatchedMesh===!0,Y=!!E.map,z=!!E.matcap,X=!!te,se=!!E.aoMap,re=!!E.lightMap,le=!!E.bumpMap,xe=!!E.normalMap,G=!!E.displacementMap,A=!!E.emissiveMap,U=!!E.metalnessMap,he=!!E.roughnessMap,me=E.anisotropy>0,Te=E.clearcoat>0,ee=E.iridescence>0,k=E.sheen>0,J=E.transmission>0,ue=me&&!!E.anisotropyMap,Z=Te&&!!E.clearcoatMap,ce=Te&&!!E.clearcoatNormalMap,pe=Te&&!!E.clearcoatRoughnessMap,fe=ee&&!!E.iridescenceMap,ge=ee&&!!E.iridescenceThicknessMap,Ae=k&&!!E.sheenColorMap,Ie=k&&!!E.sheenRoughnessMap,Fe=!!E.specularMap,Je=!!E.specularColorMap,dt=!!E.specularIntensityMap,Oe=J&&!!E.transmissionMap,ne=J&&!!E.thicknessMap,Pe=!!E.gradientMap,Ne=!!E.alphaMap,Ue=E.alphaTest>0,De=!!E.alphaHash,ut=!!E.extensions,at=hs;E.toneMapped&&(b===null||b.isXRRenderTarget===!0)&&(at=r.toneMapping);let yt={shaderID:ae,shaderType:E.type,shaderName:E.name,vertexShader:ve,fragmentShader:R,defines:E.defines,customVertexShaderID:T,customFragmentShaderID:S,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:p,batching:q,instancing:V,instancingColor:V&&O.instanceColor!==null,instancingMorph:V&&O.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:b===null?r.outputColorSpace:b.isXRRenderTarget===!0?b.texture.colorSpace:li,alphaToCoverage:!!E.alphaToCoverage,map:Y,matcap:z,envMap:X,envMapMode:X&&te.mapping,envMapCubeUVHeight:W,aoMap:se,lightMap:re,bumpMap:le,normalMap:xe,displacementMap:f&&G,emissiveMap:A,normalMapObjectSpace:xe&&E.normalMapType===Ny,normalMapTangentSpace:xe&&E.normalMapType===lh,metalnessMap:U,roughnessMap:he,anisotropy:me,anisotropyMap:ue,clearcoat:Te,clearcoatMap:Z,clearcoatNormalMap:ce,clearcoatRoughnessMap:pe,iridescence:ee,iridescenceMap:fe,iridescenceThicknessMap:ge,sheen:k,sheenColorMap:Ae,sheenRoughnessMap:Ie,specularMap:Fe,specularColorMap:Je,specularIntensityMap:dt,transmission:J,transmissionMap:Oe,thicknessMap:ne,gradientMap:Pe,opaque:E.transparent===!1&&E.blending===ra&&E.alphaToCoverage===!1,alphaMap:Ne,alphaTest:Ue,alphaHash:De,combine:E.combine,mapUv:Y&&v(E.map.channel),aoMapUv:se&&v(E.aoMap.channel),lightMapUv:re&&v(E.lightMap.channel),bumpMapUv:le&&v(E.bumpMap.channel),normalMapUv:xe&&v(E.normalMap.channel),displacementMapUv:G&&v(E.displacementMap.channel),emissiveMapUv:A&&v(E.emissiveMap.channel),metalnessMapUv:U&&v(E.metalnessMap.channel),roughnessMapUv:he&&v(E.roughnessMap.channel),anisotropyMapUv:ue&&v(E.anisotropyMap.channel),clearcoatMapUv:Z&&v(E.clearcoatMap.channel),clearcoatNormalMapUv:ce&&v(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:pe&&v(E.clearcoatRoughnessMap.channel),iridescenceMapUv:fe&&v(E.iridescenceMap.channel),iridescenceThicknessMapUv:ge&&v(E.iridescenceThicknessMap.channel),sheenColorMapUv:Ae&&v(E.sheenColorMap.channel),sheenRoughnessMapUv:Ie&&v(E.sheenRoughnessMap.channel),specularMapUv:Fe&&v(E.specularMap.channel),specularColorMapUv:Je&&v(E.specularColorMap.channel),specularIntensityMapUv:dt&&v(E.specularIntensityMap.channel),transmissionMapUv:Oe&&v(E.transmissionMap.channel),thicknessMapUv:ne&&v(E.thicknessMap.channel),alphaMapUv:Ne&&v(E.alphaMap.channel),vertexTangents:!!ie.attributes.tangent&&(xe||me),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!ie.attributes.uv&&(Y||Ne),fog:!!B,useFog:E.fog===!0,fogExp2:!!B&&B.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:O.isSkinnedMesh===!0,morphTargets:ie.morphAttributes.position!==void 0,morphNormals:ie.morphAttributes.normal!==void 0,morphColors:ie.morphAttributes.color!==void 0,morphTargetsCount:ye,morphTextureStride:Me,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:E.dithering,shadowMapEnabled:r.shadowMap.enabled&&L.length>0,shadowMapType:r.shadowMap.type,toneMapping:at,useLegacyLights:r._useLegacyLights,decodeVideoTexture:Y&&E.map.isVideoTexture===!0&&Bt.getTransfer(E.map.colorSpace)===Qt,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===On,flipSided:E.side===Tn,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:ut&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:ut&&E.extensions.multiDraw===!0&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return yt.vertexUv1s=c.has(1),yt.vertexUv2s=c.has(2),yt.vertexUv3s=c.has(3),c.clear(),yt}function m(E){let M=[];if(E.shaderID?M.push(E.shaderID):(M.push(E.customVertexShaderID),M.push(E.customFragmentShaderID)),E.defines!==void 0)for(let L in E.defines)M.push(L),M.push(E.defines[L]);return E.isRawShaderMaterial===!1&&(_(M,E),y(M,E),M.push(r.outputColorSpace)),M.push(E.customProgramCacheKey),M.join()}function _(E,M){E.push(M.precision),E.push(M.outputColorSpace),E.push(M.envMapMode),E.push(M.envMapCubeUVHeight),E.push(M.mapUv),E.push(M.alphaMapUv),E.push(M.lightMapUv),E.push(M.aoMapUv),E.push(M.bumpMapUv),E.push(M.normalMapUv),E.push(M.displacementMapUv),E.push(M.emissiveMapUv),E.push(M.metalnessMapUv),E.push(M.roughnessMapUv),E.push(M.anisotropyMapUv),E.push(M.clearcoatMapUv),E.push(M.clearcoatNormalMapUv),E.push(M.clearcoatRoughnessMapUv),E.push(M.iridescenceMapUv),E.push(M.iridescenceThicknessMapUv),E.push(M.sheenColorMapUv),E.push(M.sheenRoughnessMapUv),E.push(M.specularMapUv),E.push(M.specularColorMapUv),E.push(M.specularIntensityMapUv),E.push(M.transmissionMapUv),E.push(M.thicknessMapUv),E.push(M.combine),E.push(M.fogExp2),E.push(M.sizeAttenuation),E.push(M.morphTargetsCount),E.push(M.morphAttributeCount),E.push(M.numDirLights),E.push(M.numPointLights),E.push(M.numSpotLights),E.push(M.numSpotLightMaps),E.push(M.numHemiLights),E.push(M.numRectAreaLights),E.push(M.numDirLightShadows),E.push(M.numPointLightShadows),E.push(M.numSpotLightShadows),E.push(M.numSpotLightShadowsWithMaps),E.push(M.numLightProbes),E.push(M.shadowMapType),E.push(M.toneMapping),E.push(M.numClippingPlanes),E.push(M.numClipIntersection),E.push(M.depthPacking)}function y(E,M){a.disableAll(),M.supportsVertexTextures&&a.enable(0),M.instancing&&a.enable(1),M.instancingColor&&a.enable(2),M.instancingMorph&&a.enable(3),M.matcap&&a.enable(4),M.envMap&&a.enable(5),M.normalMapObjectSpace&&a.enable(6),M.normalMapTangentSpace&&a.enable(7),M.clearcoat&&a.enable(8),M.iridescence&&a.enable(9),M.alphaTest&&a.enable(10),M.vertexColors&&a.enable(11),M.vertexAlphas&&a.enable(12),M.vertexUv1s&&a.enable(13),M.vertexUv2s&&a.enable(14),M.vertexUv3s&&a.enable(15),M.vertexTangents&&a.enable(16),M.anisotropy&&a.enable(17),M.alphaHash&&a.enable(18),M.batching&&a.enable(19),E.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.skinning&&a.enable(4),M.morphTargets&&a.enable(5),M.morphNormals&&a.enable(6),M.morphColors&&a.enable(7),M.premultipliedAlpha&&a.enable(8),M.shadowMapEnabled&&a.enable(9),M.useLegacyLights&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.transmission&&a.enable(15),M.sheen&&a.enable(16),M.opaque&&a.enable(17),M.pointsUvs&&a.enable(18),M.decodeVideoTexture&&a.enable(19),M.alphaToCoverage&&a.enable(20),E.push(a.mask)}function x(E){let M=g[E.type],L;if(M){let N=pr[M];L=yx.clone(N.uniforms)}else L=E.uniforms;return L}function w(E,M){let L;for(let N=0,O=u.length;N<O;N++){let B=u[N];if(B.cacheKey===M){L=B,++L.usedTimes;break}}return L===void 0&&(L=new AE(r,M,E,s),u.push(L)),L}function I(E){if(--E.usedTimes===0){let M=u.indexOf(E);u[M]=u[u.length-1],u.pop(),E.destroy()}}function C(E){l.remove(E)}function P(){l.dispose()}return{getParameters:d,getProgramCacheKey:m,getUniforms:x,acquireProgram:w,releaseProgram:I,releaseShaderCache:C,programs:u,dispose:P}}function RE(){let r=new WeakMap;function e(s){let o=r.get(s);return o===void 0&&(o={},r.set(s,o)),o}function t(s){r.delete(s)}function n(s,o,a){r.get(s)[o]=a}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function IE(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function Cg(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function Rg(){let r=[],e=0,t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function o(h,f,p,g,v,d){let m=r[e];return m===void 0?(m={id:h.id,object:h,geometry:f,material:p,groupOrder:g,renderOrder:h.renderOrder,z:v,group:d},r[e]=m):(m.id=h.id,m.object=h,m.geometry=f,m.material=p,m.groupOrder=g,m.renderOrder=h.renderOrder,m.z=v,m.group=d),e++,m}function a(h,f,p,g,v,d){let m=o(h,f,p,g,v,d);p.transmission>0?n.push(m):p.transparent===!0?i.push(m):t.push(m)}function l(h,f,p,g,v,d){let m=o(h,f,p,g,v,d);p.transmission>0?n.unshift(m):p.transparent===!0?i.unshift(m):t.unshift(m)}function c(h,f){t.length>1&&t.sort(h||IE),n.length>1&&n.sort(f||Cg),i.length>1&&i.sort(f||Cg)}function u(){for(let h=e,f=r.length;h<f;h++){let p=r[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:a,unshift:l,finish:u,sort:c}}function PE(){let r=new WeakMap;function e(n,i){let s=r.get(n),o;return s===void 0?(o=new Rg,r.set(n,[o])):i>=s.length?(o=new Rg,s.push(o)):o=s[i],o}function t(){r=new WeakMap}return{get:e,dispose:t}}function NE(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new oe,color:new Ve};break;case"SpotLight":t={position:new oe,direction:new oe,color:new Ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new oe,color:new Ve,distance:0,decay:0};break;case"HemisphereLight":t={direction:new oe,skyColor:new Ve,groundColor:new Ve};break;case"RectAreaLight":t={color:new Ve,position:new oe,halfWidth:new oe,halfHeight:new oe};break}return r[e.id]=t,t}}}function LE(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}var OE=0;function DE(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function FE(r){let e=new NE,t=LE(),n={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 c=0;c<9;c++)n.probe.push(new oe);let i=new oe,s=new Ye,o=new Ye;function a(c,u){let h=0,f=0,p=0;for(let L=0;L<9;L++)n.probe[L].set(0,0,0);let g=0,v=0,d=0,m=0,_=0,y=0,x=0,w=0,I=0,C=0,P=0;c.sort(DE);let E=u===!0?Math.PI:1;for(let L=0,N=c.length;L<N;L++){let O=c[L],B=O.color,ie=O.intensity,$=O.distance,te=O.shadow&&O.shadow.map?O.shadow.map.texture:null;if(O.isAmbientLight)h+=B.r*ie*E,f+=B.g*ie*E,p+=B.b*ie*E;else if(O.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(O.sh.coefficients[W],ie);P++}else if(O.isDirectionalLight){let W=e.get(O);if(W.color.copy(O.color).multiplyScalar(O.intensity*E),O.castShadow){let ae=O.shadow,de=t.get(O);de.shadowBias=ae.bias,de.shadowNormalBias=ae.normalBias,de.shadowRadius=ae.radius,de.shadowMapSize=ae.mapSize,n.directionalShadow[g]=de,n.directionalShadowMap[g]=te,n.directionalShadowMatrix[g]=O.shadow.matrix,y++}n.directional[g]=W,g++}else if(O.isSpotLight){let W=e.get(O);W.position.setFromMatrixPosition(O.matrixWorld),W.color.copy(B).multiplyScalar(ie*E),W.distance=$,W.coneCos=Math.cos(O.angle),W.penumbraCos=Math.cos(O.angle*(1-O.penumbra)),W.decay=O.decay,n.spot[d]=W;let ae=O.shadow;if(O.map&&(n.spotLightMap[I]=O.map,I++,ae.updateMatrices(O),O.castShadow&&C++),n.spotLightMatrix[d]=ae.matrix,O.castShadow){let de=t.get(O);de.shadowBias=ae.bias,de.shadowNormalBias=ae.normalBias,de.shadowRadius=ae.radius,de.shadowMapSize=ae.mapSize,n.spotShadow[d]=de,n.spotShadowMap[d]=te,w++}d++}else if(O.isRectAreaLight){let W=e.get(O);W.color.copy(B).multiplyScalar(ie),W.halfWidth.set(O.width*.5,0,0),W.halfHeight.set(0,O.height*.5,0),n.rectArea[m]=W,m++}else if(O.isPointLight){let W=e.get(O);if(W.color.copy(O.color).multiplyScalar(O.intensity*E),W.distance=O.distance,W.decay=O.decay,O.castShadow){let ae=O.shadow,de=t.get(O);de.shadowBias=ae.bias,de.shadowNormalBias=ae.normalBias,de.shadowRadius=ae.radius,de.shadowMapSize=ae.mapSize,de.shadowCameraNear=ae.camera.near,de.shadowCameraFar=ae.camera.far,n.pointShadow[v]=de,n.pointShadowMap[v]=te,n.pointShadowMatrix[v]=O.shadow.matrix,x++}n.point[v]=W,v++}else if(O.isHemisphereLight){let W=e.get(O);W.skyColor.copy(O.color).multiplyScalar(ie*E),W.groundColor.copy(O.groundColor).multiplyScalar(ie*E),n.hemi[_]=W,_++}}m>0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Ge.LTC_FLOAT_1,n.rectAreaLTC2=Ge.LTC_FLOAT_2):(n.rectAreaLTC1=Ge.LTC_HALF_1,n.rectAreaLTC2=Ge.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=f,n.ambient[2]=p;let M=n.hash;(M.directionalLength!==g||M.pointLength!==v||M.spotLength!==d||M.rectAreaLength!==m||M.hemiLength!==_||M.numDirectionalShadows!==y||M.numPointShadows!==x||M.numSpotShadows!==w||M.numSpotMaps!==I||M.numLightProbes!==P)&&(n.directional.length=g,n.spot.length=d,n.rectArea.length=m,n.point.length=v,n.hemi.length=_,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=w,n.spotShadowMap.length=w,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=w+I-C,n.spotLightMap.length=I,n.numSpotLightShadowsWithMaps=C,n.numLightProbes=P,M.directionalLength=g,M.pointLength=v,M.spotLength=d,M.rectAreaLength=m,M.hemiLength=_,M.numDirectionalShadows=y,M.numPointShadows=x,M.numSpotShadows=w,M.numSpotMaps=I,M.numLightProbes=P,n.version=OE++)}function l(c,u){let h=0,f=0,p=0,g=0,v=0,d=u.matrixWorldInverse;for(let m=0,_=c.length;m<_;m++){let y=c[m];if(y.isDirectionalLight){let x=n.directional[h];x.direction.setFromMatrixPosition(y.matrixWorld),i.setFromMatrixPosition(y.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(d),h++}else if(y.isSpotLight){let x=n.spot[p];x.position.setFromMatrixPosition(y.matrixWorld),x.position.applyMatrix4(d),x.direction.setFromMatrixPosition(y.matrixWorld),i.setFromMatrixPosition(y.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(d),p++}else if(y.isRectAreaLight){let x=n.rectArea[g];x.position.setFromMatrixPosition(y.matrixWorld),x.position.applyMatrix4(d),o.identity(),s.copy(y.matrixWorld),s.premultiply(d),o.extractRotation(s),x.halfWidth.set(y.width*.5,0,0),x.halfHeight.set(0,y.height*.5,0),x.halfWidth.applyMatrix4(o),x.halfHeight.applyMatrix4(o),g++}else if(y.isPointLight){let x=n.point[f];x.position.setFromMatrixPosition(y.matrixWorld),x.position.applyMatrix4(d),f++}else if(y.isHemisphereLight){let x=n.hemi[v];x.direction.setFromMatrixPosition(y.matrixWorld),x.direction.transformDirection(d),v++}}}return{setup:a,setupView:l,state:n}}function Ig(r){let e=new FE(r),t=[],n=[];function i(){t.length=0,n.length=0}function s(u){t.push(u)}function o(u){n.push(u)}function a(u){e.setup(t,u)}function l(u){e.setupView(t,u)}return{init:i,state:{lightsArray:t,shadowsArray:n,lights:e,transmissionRenderTarget:null},setupLights:a,setupLightsView:l,pushLight:s,pushShadow:o}}function UE(r){let e=new WeakMap;function t(i,s=0){let o=e.get(i),a;return o===void 0?(a=new Ig(r),e.set(i,[a])):s>=o.length?(a=new Ig(r),o.push(a)):a=o[s],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var nd=class extends Yi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Iy,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}},id=class extends Yi{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}},kE=`void main() {
+`+q)}else N!==""?console.warn("THREE.WebGLProgram: Program Info Log:",N):(B===""||V==="")&&(Y=!1);Y&&(R.diagnostics={runnable:ie,programLog:N,vertexShader:{log:B,prefix:d},fragmentShader:{log:V,prefix:m}})}i.deleteShader(S),i.deleteShader(I),C=new Wa(i,y),E=ab(i,y)}let C;this.getUniforms=function(){return C===void 0&&A(this),C};let E;this.getAttributes=function(){return E===void 0&&A(this),E};let b=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=i.getProgramParameter(y,$E)),b},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=QE++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=S,this.fragmentShader=I,this}var vb=0,Xp=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new qp(e),t.set(e,n)),n}},qp=class{constructor(e){this.id=vb++,this.code=e,this.usedTimes=0}};function _b(r,e,t,n,i,s,o){let a=new Ca,l=new Xp,c=new Set,u=[],h=i.logarithmicDepthBuffer,f=i.vertexTextures,p=i.precision,g={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(E){return c.add(E),E===0?"uv":`uv${E}`}function d(E,b,R,N,B){let V=N.fog,ie=B.geometry,Y=E.isMeshStandardMaterial?N.environment:null,te=(E.isMeshStandardMaterial?t:e).get(E.envMap||Y),q=te&&te.mapping===Ac?te.image.height:null,le=g[E.type];E.precision!==null&&(p=i.getMaxPrecision(E.precision),p!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",p,"instead."));let ye=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,Te=ye!==void 0?ye.length:0,Ae=0;ie.morphAttributes.position!==void 0&&(Ae=1),ie.morphAttributes.normal!==void 0&&(Ae=2),ie.morphAttributes.color!==void 0&&(Ae=3);let _e,G,P,M;if(le){let Fe=Rr[le];_e=Fe.vertexShader,G=Fe.fragmentShader}else _e=E.vertexShader,G=E.fragmentShader,l.update(E),P=l.getVertexShaderID(E),M=l.getFragmentShaderID(E);let T=r.getRenderTarget(),k=r.state.buffers.depth.getReversed(),j=B.isInstancedMesh===!0,W=B.isBatchedMesh===!0,re=!!E.map,ce=!!E.matcap,me=!!te,w=!!E.aoMap,ae=!!E.lightMap,pe=!!E.bumpMap,ue=!!E.normalMap,ee=!!E.displacementMap,$=!!E.emissiveMap,ve=!!E.metalnessMap,H=!!E.roughnessMap,L=E.anisotropy>0,O=E.clearcoat>0,D=E.dispersion>0,z=E.iridescence>0,Q=E.sheen>0,ne=E.transmission>0,oe=L&&!!E.anisotropyMap,he=O&&!!E.clearcoatMap,ge=O&&!!E.clearcoatNormalMap,de=O&&!!E.clearcoatRoughnessMap,Ee=z&&!!E.iridescenceMap,Re=z&&!!E.iridescenceThicknessMap,De=Q&&!!E.sheenColorMap,ke=Q&&!!E.sheenRoughnessMap,at=!!E.specularMap,je=!!E.specularColorMap,Ke=!!E.specularIntensityMap,fe=ne&&!!E.transmissionMap,Le=ne&&!!E.thicknessMap,be=!!E.gradientMap,Ce=!!E.alphaMap,Be=E.alphaTest>0,Oe=!!E.alphaHash,rt=!!E.extensions,Et=ls;E.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(Et=r.toneMapping);let ft={shaderID:le,shaderType:E.type,shaderName:E.name,vertexShader:_e,fragmentShader:G,defines:E.defines,customVertexShaderID:P,customFragmentShaderID:M,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:p,batching:W,batchingColor:W&&B._colorsTexture!==null,instancing:j,instancingColor:j&&B.instanceColor!==null,instancingMorph:j&&B.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:T===null?r.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:Ci,alphaToCoverage:!!E.alphaToCoverage,map:re,matcap:ce,envMap:me,envMapMode:me&&te.mapping,envMapCubeUVHeight:q,aoMap:w,lightMap:ae,bumpMap:pe,normalMap:ue,displacementMap:f&&ee,emissiveMap:$,normalMapObjectSpace:ue&&E.normalMapType===W0,normalMapTangentSpace:ue&&E.normalMapType===Lc,metalnessMap:ve,roughnessMap:H,anisotropy:L,anisotropyMap:oe,clearcoat:O,clearcoatMap:he,clearcoatNormalMap:ge,clearcoatRoughnessMap:de,dispersion:D,iridescence:z,iridescenceMap:Ee,iridescenceThicknessMap:Re,sheen:Q,sheenColorMap:De,sheenRoughnessMap:ke,specularMap:at,specularColorMap:je,specularIntensityMap:Ke,transmission:ne,transmissionMap:fe,thicknessMap:Le,gradientMap:be,opaque:E.transparent===!1&&E.blending===io&&E.alphaToCoverage===!1,alphaMap:Ce,alphaTest:Be,alphaHash:Oe,combine:E.combine,mapUv:re&&y(E.map.channel),aoMapUv:w&&y(E.aoMap.channel),lightMapUv:ae&&y(E.lightMap.channel),bumpMapUv:pe&&y(E.bumpMap.channel),normalMapUv:ue&&y(E.normalMap.channel),displacementMapUv:ee&&y(E.displacementMap.channel),emissiveMapUv:$&&y(E.emissiveMap.channel),metalnessMapUv:ve&&y(E.metalnessMap.channel),roughnessMapUv:H&&y(E.roughnessMap.channel),anisotropyMapUv:oe&&y(E.anisotropyMap.channel),clearcoatMapUv:he&&y(E.clearcoatMap.channel),clearcoatNormalMapUv:ge&&y(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:de&&y(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Ee&&y(E.iridescenceMap.channel),iridescenceThicknessMapUv:Re&&y(E.iridescenceThicknessMap.channel),sheenColorMapUv:De&&y(E.sheenColorMap.channel),sheenRoughnessMapUv:ke&&y(E.sheenRoughnessMap.channel),specularMapUv:at&&y(E.specularMap.channel),specularColorMapUv:je&&y(E.specularColorMap.channel),specularIntensityMapUv:Ke&&y(E.specularIntensityMap.channel),transmissionMapUv:fe&&y(E.transmissionMap.channel),thicknessMapUv:Le&&y(E.thicknessMap.channel),alphaMapUv:Ce&&y(E.alphaMap.channel),vertexTangents:!!ie.attributes.tangent&&(ue||L),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,pointsUvs:B.isPoints===!0&&!!ie.attributes.uv&&(re||Ce),fog:!!V,useFog:E.fog===!0,fogExp2:!!V&&V.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:k,skinning:B.isSkinnedMesh===!0,morphTargets:ie.morphAttributes.position!==void 0,morphNormals:ie.morphAttributes.normal!==void 0,morphColors:ie.morphAttributes.color!==void 0,morphTargetsCount:Te,morphTextureStride:Ae,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:E.dithering,shadowMapEnabled:r.shadowMap.enabled&&R.length>0,shadowMapType:r.shadowMap.type,toneMapping:Et,decodeVideoTexture:re&&E.map.isVideoTexture===!0&&mt.getTransfer(E.map.colorSpace)===Kt,decodeVideoTextureEmissive:$&&E.emissiveMap.isVideoTexture===!0&&mt.getTransfer(E.emissiveMap.colorSpace)===Kt,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Nn,flipSided:E.side===_n,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:rt&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(rt&&E.extensions.multiDraw===!0||W)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return ft.vertexUv1s=c.has(1),ft.vertexUv2s=c.has(2),ft.vertexUv3s=c.has(3),c.clear(),ft}function m(E){let b=[];if(E.shaderID?b.push(E.shaderID):(b.push(E.customVertexShaderID),b.push(E.customFragmentShaderID)),E.defines!==void 0)for(let R in E.defines)b.push(R),b.push(E.defines[R]);return E.isRawShaderMaterial===!1&&(_(b,E),v(b,E),b.push(r.outputColorSpace)),b.push(E.customProgramCacheKey),b.join()}function _(E,b){E.push(b.precision),E.push(b.outputColorSpace),E.push(b.envMapMode),E.push(b.envMapCubeUVHeight),E.push(b.mapUv),E.push(b.alphaMapUv),E.push(b.lightMapUv),E.push(b.aoMapUv),E.push(b.bumpMapUv),E.push(b.normalMapUv),E.push(b.displacementMapUv),E.push(b.emissiveMapUv),E.push(b.metalnessMapUv),E.push(b.roughnessMapUv),E.push(b.anisotropyMapUv),E.push(b.clearcoatMapUv),E.push(b.clearcoatNormalMapUv),E.push(b.clearcoatRoughnessMapUv),E.push(b.iridescenceMapUv),E.push(b.iridescenceThicknessMapUv),E.push(b.sheenColorMapUv),E.push(b.sheenRoughnessMapUv),E.push(b.specularMapUv),E.push(b.specularColorMapUv),E.push(b.specularIntensityMapUv),E.push(b.transmissionMapUv),E.push(b.thicknessMapUv),E.push(b.combine),E.push(b.fogExp2),E.push(b.sizeAttenuation),E.push(b.morphTargetsCount),E.push(b.morphAttributeCount),E.push(b.numDirLights),E.push(b.numPointLights),E.push(b.numSpotLights),E.push(b.numSpotLightMaps),E.push(b.numHemiLights),E.push(b.numRectAreaLights),E.push(b.numDirLightShadows),E.push(b.numPointLightShadows),E.push(b.numSpotLightShadows),E.push(b.numSpotLightShadowsWithMaps),E.push(b.numLightProbes),E.push(b.shadowMapType),E.push(b.toneMapping),E.push(b.numClippingPlanes),E.push(b.numClipIntersection),E.push(b.depthPacking)}function v(E,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),b.batchingColor&&a.enable(21),E.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.reverseDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&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.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),E.push(a.mask)}function x(E){let b=g[E.type],R;if(b){let N=Rr[b];R=iy.clone(N.uniforms)}else R=E.uniforms;return R}function S(E,b){let R;for(let N=0,B=u.length;N<B;N++){let V=u[N];if(V.cacheKey===b){R=V,++R.usedTimes;break}}return R===void 0&&(R=new xb(r,b,E,s),u.push(R)),R}function I(E){if(--E.usedTimes===0){let b=u.indexOf(E);u[b]=u[u.length-1],u.pop(),E.destroy()}}function A(E){l.remove(E)}function C(){l.dispose()}return{getParameters:d,getProgramCacheKey:m,getUniforms:x,acquireProgram:S,releaseProgram:I,releaseShaderCache:A,programs:u,dispose:C}}function Tb(){let r=new WeakMap;function e(o){return r.has(o)}function t(o){let a=r.get(o);return a===void 0&&(a={},r.set(o,a)),a}function n(o){r.delete(o)}function i(o,a,l){r.get(o)[a]=l}function s(){r=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:s}}function Mb(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function Ry(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function Py(){let r=[],e=0,t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function o(h,f,p,g,y,d){let m=r[e];return m===void 0?(m={id:h.id,object:h,geometry:f,material:p,groupOrder:g,renderOrder:h.renderOrder,z:y,group:d},r[e]=m):(m.id=h.id,m.object=h,m.geometry=f,m.material=p,m.groupOrder=g,m.renderOrder=h.renderOrder,m.z=y,m.group=d),e++,m}function a(h,f,p,g,y,d){let m=o(h,f,p,g,y,d);p.transmission>0?n.push(m):p.transparent===!0?i.push(m):t.push(m)}function l(h,f,p,g,y,d){let m=o(h,f,p,g,y,d);p.transmission>0?n.unshift(m):p.transparent===!0?i.unshift(m):t.unshift(m)}function c(h,f){t.length>1&&t.sort(h||Mb),n.length>1&&n.sort(f||Ry),i.length>1&&i.sort(f||Ry)}function u(){for(let h=e,f=r.length;h<f;h++){let p=r[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:a,unshift:l,finish:u,sort:c}}function Eb(){let r=new WeakMap;function e(n,i){let s=r.get(n),o;return s===void 0?(o=new Py,r.set(n,[o])):i>=s.length?(o=new Py,s.push(o)):o=s[i],o}function t(){r=new WeakMap}return{get:e,dispose:t}}function bb(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new se,color:new He};break;case"SpotLight":t={position:new se,direction:new se,color:new He,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new se,color:new He,distance:0,decay:0};break;case"HemisphereLight":t={direction:new se,skyColor:new He,groundColor:new He};break;case"RectAreaLight":t={color:new He,position:new se,halfWidth:new se,halfHeight:new se};break}return r[e.id]=t,t}}}function Sb(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}var Ab=0;function wb(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function Cb(r){let e=new bb,t=Sb(),n={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 c=0;c<9;c++)n.probe.push(new se);let i=new se,s=new Je,o=new Je;function a(c){let u=0,h=0,f=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let p=0,g=0,y=0,d=0,m=0,_=0,v=0,x=0,S=0,I=0,A=0;c.sort(wb);for(let E=0,b=c.length;E<b;E++){let R=c[E],N=R.color,B=R.intensity,V=R.distance,ie=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)u+=N.r*B,h+=N.g*B,f+=N.b*B;else if(R.isLightProbe){for(let Y=0;Y<9;Y++)n.probe[Y].addScaledVector(R.sh.coefficients[Y],B);A++}else if(R.isDirectionalLight){let Y=e.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let te=R.shadow,q=t.get(R);q.shadowIntensity=te.intensity,q.shadowBias=te.bias,q.shadowNormalBias=te.normalBias,q.shadowRadius=te.radius,q.shadowMapSize=te.mapSize,n.directionalShadow[p]=q,n.directionalShadowMap[p]=ie,n.directionalShadowMatrix[p]=R.shadow.matrix,_++}n.directional[p]=Y,p++}else if(R.isSpotLight){let Y=e.get(R);Y.position.setFromMatrixPosition(R.matrixWorld),Y.color.copy(N).multiplyScalar(B),Y.distance=V,Y.coneCos=Math.cos(R.angle),Y.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),Y.decay=R.decay,n.spot[y]=Y;let te=R.shadow;if(R.map&&(n.spotLightMap[S]=R.map,S++,te.updateMatrices(R),R.castShadow&&I++),n.spotLightMatrix[y]=te.matrix,R.castShadow){let q=t.get(R);q.shadowIntensity=te.intensity,q.shadowBias=te.bias,q.shadowNormalBias=te.normalBias,q.shadowRadius=te.radius,q.shadowMapSize=te.mapSize,n.spotShadow[y]=q,n.spotShadowMap[y]=ie,x++}y++}else if(R.isRectAreaLight){let Y=e.get(R);Y.color.copy(N).multiplyScalar(B),Y.halfWidth.set(R.width*.5,0,0),Y.halfHeight.set(0,R.height*.5,0),n.rectArea[d]=Y,d++}else if(R.isPointLight){let Y=e.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity),Y.distance=R.distance,Y.decay=R.decay,R.castShadow){let te=R.shadow,q=t.get(R);q.shadowIntensity=te.intensity,q.shadowBias=te.bias,q.shadowNormalBias=te.normalBias,q.shadowRadius=te.radius,q.shadowMapSize=te.mapSize,q.shadowCameraNear=te.camera.near,q.shadowCameraFar=te.camera.far,n.pointShadow[g]=q,n.pointShadowMap[g]=ie,n.pointShadowMatrix[g]=R.shadow.matrix,v++}n.point[g]=Y,g++}else if(R.isHemisphereLight){let Y=e.get(R);Y.skyColor.copy(R.color).multiplyScalar(B),Y.groundColor.copy(R.groundColor).multiplyScalar(B),n.hemi[m]=Y,m++}}d>0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=qe.LTC_FLOAT_1,n.rectAreaLTC2=qe.LTC_FLOAT_2):(n.rectAreaLTC1=qe.LTC_HALF_1,n.rectAreaLTC2=qe.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=f;let C=n.hash;(C.directionalLength!==p||C.pointLength!==g||C.spotLength!==y||C.rectAreaLength!==d||C.hemiLength!==m||C.numDirectionalShadows!==_||C.numPointShadows!==v||C.numSpotShadows!==x||C.numSpotMaps!==S||C.numLightProbes!==A)&&(n.directional.length=p,n.spot.length=y,n.rectArea.length=d,n.point.length=g,n.hemi.length=m,n.directionalShadow.length=_,n.directionalShadowMap.length=_,n.pointShadow.length=v,n.pointShadowMap.length=v,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=_,n.pointShadowMatrix.length=v,n.spotLightMatrix.length=x+S-I,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=I,n.numLightProbes=A,C.directionalLength=p,C.pointLength=g,C.spotLength=y,C.rectAreaLength=d,C.hemiLength=m,C.numDirectionalShadows=_,C.numPointShadows=v,C.numSpotShadows=x,C.numSpotMaps=S,C.numLightProbes=A,n.version=Ab++)}function l(c,u){let h=0,f=0,p=0,g=0,y=0,d=u.matrixWorldInverse;for(let m=0,_=c.length;m<_;m++){let v=c[m];if(v.isDirectionalLight){let x=n.directional[h];x.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(d),h++}else if(v.isSpotLight){let x=n.spot[p];x.position.setFromMatrixPosition(v.matrixWorld),x.position.applyMatrix4(d),x.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(d),p++}else if(v.isRectAreaLight){let x=n.rectArea[g];x.position.setFromMatrixPosition(v.matrixWorld),x.position.applyMatrix4(d),o.identity(),s.copy(v.matrixWorld),s.premultiply(d),o.extractRotation(s),x.halfWidth.set(v.width*.5,0,0),x.halfHeight.set(0,v.height*.5,0),x.halfWidth.applyMatrix4(o),x.halfHeight.applyMatrix4(o),g++}else if(v.isPointLight){let x=n.point[f];x.position.setFromMatrixPosition(v.matrixWorld),x.position.applyMatrix4(d),f++}else if(v.isHemisphereLight){let x=n.hemi[y];x.direction.setFromMatrixPosition(v.matrixWorld),x.direction.transformDirection(d),y++}}}return{setup:a,setupView:l,state:n}}function Ny(r){let e=new Cb(r),t=[],n=[];function i(u){c.camera=u,t.length=0,n.length=0}function s(u){t.push(u)}function o(u){n.push(u)}function a(){e.setup(t)}function l(u){e.setupView(t,u)}let c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:a,setupLightsView:l,pushLight:s,pushShadow:o}}function Ib(r){let e=new WeakMap;function t(i,s=0){let o=e.get(i),a;return o===void 0?(a=new Ny(r),e.set(i,[a])):s>=o.length?(a=new Ny(r),o.push(a)):a=o[s],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var Rb=`void main() {
gl_Position = vec4( position, 1.0 );
-}`,BE=`uniform sampler2D shadow_pass;
+}`,Pb=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
squared_mean = squared_mean / samples;
float std_dev = sqrt( squared_mean - mean * mean );
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
-}`;function GE(r,e,t){let n=new Vl,i=new Ce,s=new Ce,o=new Ct,a=new nd({depthPacking:Py}),l=new id,c={},u=t.maxTextureSize,h={[wi]:Tn,[Tn]:wi,[On]:On},f=new mr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ce},radius:{value:4}},vertexShader:kE,fragmentShader:BE}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let g=new St;g.setAttribute("position",new Gn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new Pt(g,f),d=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=t0;let m=this.type;this.render=function(I,C,P){if(d.enabled===!1||d.autoUpdate===!1&&d.needsUpdate===!1||I.length===0)return;let E=r.getRenderTarget(),M=r.getActiveCubeFace(),L=r.getActiveMipmapLevel(),N=r.state;N.setBlending(us),N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);let O=m!==Br&&this.type===Br,B=m===Br&&this.type!==Br;for(let ie=0,$=I.length;ie<$;ie++){let te=I[ie],W=te.shadow;if(W===void 0){console.warn("THREE.WebGLShadowMap:",te,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;i.copy(W.mapSize);let ae=W.getFrameExtents();if(i.multiply(ae),s.copy(W.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/ae.x),i.x=s.x*ae.x,W.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/ae.y),i.y=s.y*ae.y,W.mapSize.y=s.y)),W.map===null||O===!0||B===!0){let ye=this.type!==Br?{minFilter:Bn,magFilter:Bn}:{};W.map!==null&&W.map.dispose(),W.map=new Hr(i.x,i.y,ye),W.map.texture.name=te.name+".shadowMap",W.camera.updateProjectionMatrix()}r.setRenderTarget(W.map),r.clear();let de=W.getViewportCount();for(let ye=0;ye<de;ye++){let Me=W.getViewport(ye);o.set(s.x*Me.x,s.y*Me.y,s.x*Me.z,s.y*Me.w),N.viewport(o),W.updateMatrices(te,ye),n=W.getFrustum(),x(C,P,W.camera,te,this.type)}W.isPointLightShadow!==!0&&this.type===Br&&_(W,P),W.needsUpdate=!1}m=this.type,d.needsUpdate=!1,r.setRenderTarget(E,M,L)};function _(I,C){let P=e.update(v);f.defines.VSM_SAMPLES!==I.blurSamples&&(f.defines.VSM_SAMPLES=I.blurSamples,p.defines.VSM_SAMPLES=I.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),I.mapPass===null&&(I.mapPass=new Hr(i.x,i.y)),f.uniforms.shadow_pass.value=I.map.texture,f.uniforms.resolution.value=I.mapSize,f.uniforms.radius.value=I.radius,r.setRenderTarget(I.mapPass),r.clear(),r.renderBufferDirect(C,null,P,f,v,null),p.uniforms.shadow_pass.value=I.mapPass.texture,p.uniforms.resolution.value=I.mapSize,p.uniforms.radius.value=I.radius,r.setRenderTarget(I.map),r.clear(),r.renderBufferDirect(C,null,P,p,v,null)}function y(I,C,P,E){let M=null,L=P.isPointLight===!0?I.customDistanceMaterial:I.customDepthMaterial;if(L!==void 0)M=L;else if(M=P.isPointLight===!0?l:a,r.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){let N=M.uuid,O=C.uuid,B=c[N];B===void 0&&(B={},c[N]=B);let ie=B[O];ie===void 0&&(ie=M.clone(),B[O]=ie,C.addEventListener("dispose",w)),M=ie}if(M.visible=C.visible,M.wireframe=C.wireframe,E===Br?M.side=C.shadowSide!==null?C.shadowSide:C.side:M.side=C.shadowSide!==null?C.shadowSide:h[C.side],M.alphaMap=C.alphaMap,M.alphaTest=C.alphaTest,M.map=C.map,M.clipShadows=C.clipShadows,M.clippingPlanes=C.clippingPlanes,M.clipIntersection=C.clipIntersection,M.displacementMap=C.displacementMap,M.displacementScale=C.displacementScale,M.displacementBias=C.displacementBias,M.wireframeLinewidth=C.wireframeLinewidth,M.linewidth=C.linewidth,P.isPointLight===!0&&M.isMeshDistanceMaterial===!0){let N=r.properties.get(M);N.light=P}return M}function x(I,C,P,E,M){if(I.visible===!1)return;if(I.layers.test(C.layers)&&(I.isMesh||I.isLine||I.isPoints)&&(I.castShadow||I.receiveShadow&&M===Br)&&(!I.frustumCulled||n.intersectsObject(I))){I.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,I.matrixWorld);let O=e.update(I),B=I.material;if(Array.isArray(B)){let ie=O.groups;for(let $=0,te=ie.length;$<te;$++){let W=ie[$],ae=B[W.materialIndex];if(ae&&ae.visible){let de=y(I,ae,E,M);I.onBeforeShadow(r,I,C,P,O,de,W),r.renderBufferDirect(P,null,O,de,I,W),I.onAfterShadow(r,I,C,P,O,de,W)}}}else if(B.visible){let ie=y(I,B,E,M);I.onBeforeShadow(r,I,C,P,O,ie,null),r.renderBufferDirect(P,null,O,ie,I,null),I.onAfterShadow(r,I,C,P,O,ie,null)}}let N=I.children;for(let O=0,B=N.length;O<B;O++)x(N[O],C,P,E,M)}function w(I){I.target.removeEventListener("dispose",w);for(let P in c){let E=c[P],M=I.target.uuid;M in E&&(E[M].dispose(),delete E[M])}}}function VE(r){function e(){let ne=!1,Pe=new Ct,Ne=null,Ue=new Ct(0,0,0,0);return{setMask:function(De){Ne!==De&&!ne&&(r.colorMask(De,De,De,De),Ne=De)},setLocked:function(De){ne=De},setClear:function(De,ut,at,yt,wt){wt===!0&&(De*=yt,ut*=yt,at*=yt),Pe.set(De,ut,at,yt),Ue.equals(Pe)===!1&&(r.clearColor(De,ut,at,yt),Ue.copy(Pe))},reset:function(){ne=!1,Ne=null,Ue.set(-1,0,0,0)}}}function t(){let ne=!1,Pe=null,Ne=null,Ue=null;return{setTest:function(De){De?S(r.DEPTH_TEST):b(r.DEPTH_TEST)},setMask:function(De){Pe!==De&&!ne&&(r.depthMask(De),Pe=De)},setFunc:function(De){if(Ne!==De){switch(De){case ty:r.depthFunc(r.NEVER);break;case ny:r.depthFunc(r.ALWAYS);break;case iy:r.depthFunc(r.LESS);break;case Pu:r.depthFunc(r.LEQUAL);break;case ry:r.depthFunc(r.EQUAL);break;case sy:r.depthFunc(r.GEQUAL);break;case oy:r.depthFunc(r.GREATER);break;case ay:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Ne=De}},setLocked:function(De){ne=De},setClear:function(De){Ue!==De&&(r.clearDepth(De),Ue=De)},reset:function(){ne=!1,Pe=null,Ne=null,Ue=null}}}function n(){let ne=!1,Pe=null,Ne=null,Ue=null,De=null,ut=null,at=null,yt=null,wt=null;return{setTest:function(Qe){ne||(Qe?S(r.STENCIL_TEST):b(r.STENCIL_TEST))},setMask:function(Qe){Pe!==Qe&&!ne&&(r.stencilMask(Qe),Pe=Qe)},setFunc:function(Qe,ke,qe){(Ne!==Qe||Ue!==ke||De!==qe)&&(r.stencilFunc(Qe,ke,qe),Ne=Qe,Ue=ke,De=qe)},setOp:function(Qe,ke,qe){(ut!==Qe||at!==ke||yt!==qe)&&(r.stencilOp(Qe,ke,qe),ut=Qe,at=ke,yt=qe)},setLocked:function(Qe){ne=Qe},setClear:function(Qe){wt!==Qe&&(r.clearStencil(Qe),wt=Qe)},reset:function(){ne=!1,Pe=null,Ne=null,Ue=null,De=null,ut=null,at=null,yt=null,wt=null}}}let i=new e,s=new t,o=new n,a=new WeakMap,l=new WeakMap,c={},u={},h=new WeakMap,f=[],p=null,g=!1,v=null,d=null,m=null,_=null,y=null,x=null,w=null,I=new Ve(0,0,0),C=0,P=!1,E=null,M=null,L=null,N=null,O=null,B=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS),ie=!1,$=0,te=r.getParameter(r.VERSION);te.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(te)[1]),ie=$>=1):te.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),ie=$>=2);let W=null,ae={},de=r.getParameter(r.SCISSOR_BOX),ye=r.getParameter(r.VIEWPORT),Me=new Ct().fromArray(de),ve=new Ct().fromArray(ye);function R(ne,Pe,Ne,Ue){let De=new Uint8Array(4),ut=r.createTexture();r.bindTexture(ne,ut),r.texParameteri(ne,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(ne,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let at=0;at<Ne;at++)ne===r.TEXTURE_3D||ne===r.TEXTURE_2D_ARRAY?r.texImage3D(Pe,0,r.RGBA,1,1,Ue,0,r.RGBA,r.UNSIGNED_BYTE,De):r.texImage2D(Pe+at,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,De);return ut}let T={};T[r.TEXTURE_2D]=R(r.TEXTURE_2D,r.TEXTURE_2D,1),T[r.TEXTURE_CUBE_MAP]=R(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),T[r.TEXTURE_2D_ARRAY]=R(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),T[r.TEXTURE_3D]=R(r.TEXTURE_3D,r.TEXTURE_3D,1,1),i.setClear(0,0,0,1),s.setClear(1),o.setClear(0),S(r.DEPTH_TEST),s.setFunc(Pu),le(!1),xe(lm),S(r.CULL_FACE),se(us);function S(ne){c[ne]!==!0&&(r.enable(ne),c[ne]=!0)}function b(ne){c[ne]!==!1&&(r.disable(ne),c[ne]=!1)}function V(ne,Pe){return u[ne]!==Pe?(r.bindFramebuffer(ne,Pe),u[ne]=Pe,ne===r.DRAW_FRAMEBUFFER&&(u[r.FRAMEBUFFER]=Pe),ne===r.FRAMEBUFFER&&(u[r.DRAW_FRAMEBUFFER]=Pe),!0):!1}function q(ne,Pe){let Ne=f,Ue=!1;if(ne){Ne=h.get(Pe),Ne===void 0&&(Ne=[],h.set(Pe,Ne));let De=ne.textures;if(Ne.length!==De.length||Ne[0]!==r.COLOR_ATTACHMENT0){for(let ut=0,at=De.length;ut<at;ut++)Ne[ut]=r.COLOR_ATTACHMENT0+ut;Ne.length=De.length,Ue=!0}}else Ne[0]!==r.BACK&&(Ne[0]=r.BACK,Ue=!0);Ue&&r.drawBuffers(Ne)}function Y(ne){return p!==ne?(r.useProgram(ne),p=ne,!0):!1}let z={[js]:r.FUNC_ADD,[kv]:r.FUNC_SUBTRACT,[Bv]:r.FUNC_REVERSE_SUBTRACT};z[Gv]=r.MIN,z[Vv]=r.MAX;let X={[zv]:r.ZERO,[Hv]:r.ONE,[Wv]:r.SRC_COLOR,[Hf]:r.SRC_ALPHA,[Zv]:r.SRC_ALPHA_SATURATE,[Yv]:r.DST_COLOR,[jv]:r.DST_ALPHA,[Xv]:r.ONE_MINUS_SRC_COLOR,[Wf]:r.ONE_MINUS_SRC_ALPHA,[Kv]:r.ONE_MINUS_DST_COLOR,[qv]:r.ONE_MINUS_DST_ALPHA,[Jv]:r.CONSTANT_COLOR,[$v]:r.ONE_MINUS_CONSTANT_COLOR,[Qv]:r.CONSTANT_ALPHA,[ey]:r.ONE_MINUS_CONSTANT_ALPHA};function se(ne,Pe,Ne,Ue,De,ut,at,yt,wt,Qe){if(ne===us){g===!0&&(b(r.BLEND),g=!1);return}if(g===!1&&(S(r.BLEND),g=!0),ne!==Uv){if(ne!==v||Qe!==P){if((d!==js||y!==js)&&(r.blendEquation(r.FUNC_ADD),d=js,y=js),Qe)switch(ne){case ra:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case cm:r.blendFunc(r.ONE,r.ONE);break;case um:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case hm:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ne);break}else switch(ne){case ra:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case cm:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case um:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case hm:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ne);break}m=null,_=null,x=null,w=null,I.set(0,0,0),C=0,v=ne,P=Qe}return}De=De||Pe,ut=ut||Ne,at=at||Ue,(Pe!==d||De!==y)&&(r.blendEquationSeparate(z[Pe],z[De]),d=Pe,y=De),(Ne!==m||Ue!==_||ut!==x||at!==w)&&(r.blendFuncSeparate(X[Ne],X[Ue],X[ut],X[at]),m=Ne,_=Ue,x=ut,w=at),(yt.equals(I)===!1||wt!==C)&&(r.blendColor(yt.r,yt.g,yt.b,wt),I.copy(yt),C=wt),v=ne,P=!1}function re(ne,Pe){ne.side===On?b(r.CULL_FACE):S(r.CULL_FACE);let Ne=ne.side===Tn;Pe&&(Ne=!Ne),le(Ne),ne.blending===ra&&ne.transparent===!1?se(us):se(ne.blending,ne.blendEquation,ne.blendSrc,ne.blendDst,ne.blendEquationAlpha,ne.blendSrcAlpha,ne.blendDstAlpha,ne.blendColor,ne.blendAlpha,ne.premultipliedAlpha),s.setFunc(ne.depthFunc),s.setTest(ne.depthTest),s.setMask(ne.depthWrite),i.setMask(ne.colorWrite);let Ue=ne.stencilWrite;o.setTest(Ue),Ue&&(o.setMask(ne.stencilWriteMask),o.setFunc(ne.stencilFunc,ne.stencilRef,ne.stencilFuncMask),o.setOp(ne.stencilFail,ne.stencilZFail,ne.stencilZPass)),A(ne.polygonOffset,ne.polygonOffsetFactor,ne.polygonOffsetUnits),ne.alphaToCoverage===!0?S(r.SAMPLE_ALPHA_TO_COVERAGE):b(r.SAMPLE_ALPHA_TO_COVERAGE)}function le(ne){E!==ne&&(ne?r.frontFace(r.CW):r.frontFace(r.CCW),E=ne)}function xe(ne){ne!==Ov?(S(r.CULL_FACE),ne!==M&&(ne===lm?r.cullFace(r.BACK):ne===Dv?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):b(r.CULL_FACE),M=ne}function G(ne){ne!==L&&(ie&&r.lineWidth(ne),L=ne)}function A(ne,Pe,Ne){ne?(S(r.POLYGON_OFFSET_FILL),(N!==Pe||O!==Ne)&&(r.polygonOffset(Pe,Ne),N=Pe,O=Ne)):b(r.POLYGON_OFFSET_FILL)}function U(ne){ne?S(r.SCISSOR_TEST):b(r.SCISSOR_TEST)}function he(ne){ne===void 0&&(ne=r.TEXTURE0+B-1),W!==ne&&(r.activeTexture(ne),W=ne)}function me(ne,Pe,Ne){Ne===void 0&&(W===null?Ne=r.TEXTURE0+B-1:Ne=W);let Ue=ae[Ne];Ue===void 0&&(Ue={type:void 0,texture:void 0},ae[Ne]=Ue),(Ue.type!==ne||Ue.texture!==Pe)&&(W!==Ne&&(r.activeTexture(Ne),W=Ne),r.bindTexture(ne,Pe||T[ne]),Ue.type=ne,Ue.texture=Pe)}function Te(){let ne=ae[W];ne!==void 0&&ne.type!==void 0&&(r.bindTexture(ne.type,null),ne.type=void 0,ne.texture=void 0)}function ee(){try{r.compressedTexImage2D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function k(){try{r.compressedTexImage3D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function J(){try{r.texSubImage2D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function ue(){try{r.texSubImage3D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function Z(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function ce(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function pe(){try{r.texStorage2D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function fe(){try{r.texStorage3D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function ge(){try{r.texImage2D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function Ae(){try{r.texImage3D.apply(r,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function Ie(ne){Me.equals(ne)===!1&&(r.scissor(ne.x,ne.y,ne.z,ne.w),Me.copy(ne))}function Fe(ne){ve.equals(ne)===!1&&(r.viewport(ne.x,ne.y,ne.z,ne.w),ve.copy(ne))}function Je(ne,Pe){let Ne=l.get(Pe);Ne===void 0&&(Ne=new WeakMap,l.set(Pe,Ne));let Ue=Ne.get(ne);Ue===void 0&&(Ue=r.getUniformBlockIndex(Pe,ne.name),Ne.set(ne,Ue))}function dt(ne,Pe){let Ue=l.get(Pe).get(ne);a.get(Pe)!==Ue&&(r.uniformBlockBinding(Pe,Ue,ne.__bindingPointIndex),a.set(Pe,Ue))}function Oe(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),c={},W=null,ae={},u={},h=new WeakMap,f=[],p=null,g=!1,v=null,d=null,m=null,_=null,y=null,x=null,w=null,I=new Ve(0,0,0),C=0,P=!1,E=null,M=null,L=null,N=null,O=null,Me.set(0,0,r.canvas.width,r.canvas.height),ve.set(0,0,r.canvas.width,r.canvas.height),i.reset(),s.reset(),o.reset()}return{buffers:{color:i,depth:s,stencil:o},enable:S,disable:b,bindFramebuffer:V,drawBuffers:q,useProgram:Y,setBlending:se,setMaterial:re,setFlipSided:le,setCullFace:xe,setLineWidth:G,setPolygonOffset:A,setScissorTest:U,activeTexture:he,bindTexture:me,unbindTexture:Te,compressedTexImage2D:ee,compressedTexImage3D:k,texImage2D:ge,texImage3D:Ae,updateUBOMapping:Je,uniformBlockBinding:dt,texStorage2D:pe,texStorage3D:fe,texSubImage2D:J,texSubImage3D:ue,compressedTexSubImage2D:Z,compressedTexSubImage3D:ce,scissor:Ie,viewport:Fe,reset:Oe}}function zE(r,e,t,n,i,s,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ce,u=new WeakMap,h,f=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(G,A){return p?new OffscreenCanvas(G,A):kl("canvas")}function v(G,A,U){let he=1,me=xe(G);if((me.width>U||me.height>U)&&(he=U/Math.max(me.width,me.height)),he<1)if(typeof HTMLImageElement<"u"&&G instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&G instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&G instanceof ImageBitmap||typeof VideoFrame<"u"&&G instanceof VideoFrame){let Te=Math.floor(he*me.width),ee=Math.floor(he*me.height);h===void 0&&(h=g(Te,ee));let k=A?g(Te,ee):h;return k.width=Te,k.height=ee,k.getContext("2d").drawImage(G,0,0,Te,ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+me.width+"x"+me.height+") to ("+Te+"x"+ee+")."),k}else return"data"in G&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+me.width+"x"+me.height+")."),G;return G}function d(G){return G.generateMipmaps&&G.minFilter!==Bn&&G.minFilter!==bn}function m(G){r.generateMipmap(G)}function _(G,A,U,he,me=!1){if(G!==null){if(r[G]!==void 0)return r[G];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+G+"'")}let Te=A;if(A===r.RED&&(U===r.FLOAT&&(Te=r.R32F),U===r.HALF_FLOAT&&(Te=r.R16F),U===r.UNSIGNED_BYTE&&(Te=r.R8)),A===r.RED_INTEGER&&(U===r.UNSIGNED_BYTE&&(Te=r.R8UI),U===r.UNSIGNED_SHORT&&(Te=r.R16UI),U===r.UNSIGNED_INT&&(Te=r.R32UI),U===r.BYTE&&(Te=r.R8I),U===r.SHORT&&(Te=r.R16I),U===r.INT&&(Te=r.R32I)),A===r.RG&&(U===r.FLOAT&&(Te=r.RG32F),U===r.HALF_FLOAT&&(Te=r.RG16F),U===r.UNSIGNED_BYTE&&(Te=r.RG8)),A===r.RG_INTEGER&&(U===r.UNSIGNED_BYTE&&(Te=r.RG8UI),U===r.UNSIGNED_SHORT&&(Te=r.RG16UI),U===r.UNSIGNED_INT&&(Te=r.RG32UI),U===r.BYTE&&(Te=r.RG8I),U===r.SHORT&&(Te=r.RG16I),U===r.INT&&(Te=r.RG32I)),A===r.RGB&&U===r.UNSIGNED_INT_5_9_9_9_REV&&(Te=r.RGB9_E5),A===r.RGBA){let ee=me?Du:Bt.getTransfer(he);U===r.FLOAT&&(Te=r.RGBA32F),U===r.HALF_FLOAT&&(Te=r.RGBA16F),U===r.UNSIGNED_BYTE&&(Te=ee===Qt?r.SRGB8_ALPHA8:r.RGBA8),U===r.UNSIGNED_SHORT_4_4_4_4&&(Te=r.RGBA4),U===r.UNSIGNED_SHORT_5_5_5_1&&(Te=r.RGB5_A1)}return(Te===r.R16F||Te===r.R32F||Te===r.RG16F||Te===r.RG32F||Te===r.RGBA16F||Te===r.RGBA32F)&&e.get("EXT_color_buffer_float"),Te}function y(G,A){return d(G)===!0||G.isFramebufferTexture&&G.minFilter!==Bn&&G.minFilter!==bn?Math.log2(Math.max(A.width,A.height))+1:G.mipmaps!==void 0&&G.mipmaps.length>0?G.mipmaps.length:G.isCompressedTexture&&Array.isArray(G.image)?A.mipmaps.length:1}function x(G){let A=G.target;A.removeEventListener("dispose",x),I(A),A.isVideoTexture&&u.delete(A)}function w(G){let A=G.target;A.removeEventListener("dispose",w),P(A)}function I(G){let A=n.get(G);if(A.__webglInit===void 0)return;let U=G.source,he=f.get(U);if(he){let me=he[A.__cacheKey];me.usedTimes--,me.usedTimes===0&&C(G),Object.keys(he).length===0&&f.delete(U)}n.remove(G)}function C(G){let A=n.get(G);r.deleteTexture(A.__webglTexture);let U=G.source,he=f.get(U);delete he[A.__cacheKey],o.memory.textures--}function P(G){let A=n.get(G);if(G.depthTexture&&G.depthTexture.dispose(),G.isWebGLCubeRenderTarget)for(let he=0;he<6;he++){if(Array.isArray(A.__webglFramebuffer[he]))for(let me=0;me<A.__webglFramebuffer[he].length;me++)r.deleteFramebuffer(A.__webglFramebuffer[he][me]);else r.deleteFramebuffer(A.__webglFramebuffer[he]);A.__webglDepthbuffer&&r.deleteRenderbuffer(A.__webglDepthbuffer[he])}else{if(Array.isArray(A.__webglFramebuffer))for(let he=0;he<A.__webglFramebuffer.length;he++)r.deleteFramebuffer(A.__webglFramebuffer[he]);else r.deleteFramebuffer(A.__webglFramebuffer);if(A.__webglDepthbuffer&&r.deleteRenderbuffer(A.__webglDepthbuffer),A.__webglMultisampledFramebuffer&&r.deleteFramebuffer(A.__webglMultisampledFramebuffer),A.__webglColorRenderbuffer)for(let he=0;he<A.__webglColorRenderbuffer.length;he++)A.__webglColorRenderbuffer[he]&&r.deleteRenderbuffer(A.__webglColorRenderbuffer[he]);A.__webglDepthRenderbuffer&&r.deleteRenderbuffer(A.__webglDepthRenderbuffer)}let U=G.textures;for(let he=0,me=U.length;he<me;he++){let Te=n.get(U[he]);Te.__webglTexture&&(r.deleteTexture(Te.__webglTexture),o.memory.textures--),n.remove(U[he])}n.remove(G)}let E=0;function M(){E=0}function L(){let G=E;return G>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+G+" texture units while this GPU supports only "+i.maxTextures),E+=1,G}function N(G){let A=[];return A.push(G.wrapS),A.push(G.wrapT),A.push(G.wrapR||0),A.push(G.magFilter),A.push(G.minFilter),A.push(G.anisotropy),A.push(G.internalFormat),A.push(G.format),A.push(G.type),A.push(G.generateMipmaps),A.push(G.premultiplyAlpha),A.push(G.flipY),A.push(G.unpackAlignment),A.push(G.colorSpace),A.join()}function O(G,A){let U=n.get(G);if(G.isVideoTexture&&re(G),G.isRenderTargetTexture===!1&&G.version>0&&U.__version!==G.version){let he=G.image;if(he===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(he.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Me(U,G,A);return}}t.bindTexture(r.TEXTURE_2D,U.__webglTexture,r.TEXTURE0+A)}function B(G,A){let U=n.get(G);if(G.version>0&&U.__version!==G.version){Me(U,G,A);return}t.bindTexture(r.TEXTURE_2D_ARRAY,U.__webglTexture,r.TEXTURE0+A)}function ie(G,A){let U=n.get(G);if(G.version>0&&U.__version!==G.version){Me(U,G,A);return}t.bindTexture(r.TEXTURE_3D,U.__webglTexture,r.TEXTURE0+A)}function $(G,A){let U=n.get(G);if(G.version>0&&U.__version!==G.version){ve(U,G,A);return}t.bindTexture(r.TEXTURE_CUBE_MAP,U.__webglTexture,r.TEXTURE0+A)}let te={[rn]:r.REPEAT,[un]:r.CLAMP_TO_EDGE,[ha]:r.MIRRORED_REPEAT},W={[Bn]:r.NEAREST,[yy]:r.NEAREST_MIPMAP_NEAREST,[$c]:r.NEAREST_MIPMAP_LINEAR,[bn]:r.LINEAR,[nf]:r.LINEAR_MIPMAP_NEAREST,[vi]:r.LINEAR_MIPMAP_LINEAR},ae={[Ly]:r.NEVER,[By]:r.ALWAYS,[Oy]:r.LESS,[h0]:r.LEQUAL,[Dy]:r.EQUAL,[ky]:r.GEQUAL,[Fy]:r.GREATER,[Uy]:r.NOTEQUAL};function de(G,A){if(A.type===Vr&&e.has("OES_texture_float_linear")===!1&&(A.magFilter===bn||A.magFilter===nf||A.magFilter===$c||A.magFilter===vi||A.minFilter===bn||A.minFilter===nf||A.minFilter===$c||A.minFilter===vi)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(G,r.TEXTURE_WRAP_S,te[A.wrapS]),r.texParameteri(G,r.TEXTURE_WRAP_T,te[A.wrapT]),(G===r.TEXTURE_3D||G===r.TEXTURE_2D_ARRAY)&&r.texParameteri(G,r.TEXTURE_WRAP_R,te[A.wrapR]),r.texParameteri(G,r.TEXTURE_MAG_FILTER,W[A.magFilter]),r.texParameteri(G,r.TEXTURE_MIN_FILTER,W[A.minFilter]),A.compareFunction&&(r.texParameteri(G,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(G,r.TEXTURE_COMPARE_FUNC,ae[A.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(A.magFilter===Bn||A.minFilter!==$c&&A.minFilter!==vi||A.type===Vr&&e.has("OES_texture_float_linear")===!1)return;if(A.anisotropy>1||n.get(A).__currentAnisotropy){let U=e.get("EXT_texture_filter_anisotropic");r.texParameterf(G,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(A.anisotropy,i.getMaxAnisotropy())),n.get(A).__currentAnisotropy=A.anisotropy}}}function ye(G,A){let U=!1;G.__webglInit===void 0&&(G.__webglInit=!0,A.addEventListener("dispose",x));let he=A.source,me=f.get(he);me===void 0&&(me={},f.set(he,me));let Te=N(A);if(Te!==G.__cacheKey){me[Te]===void 0&&(me[Te]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,U=!0),me[Te].usedTimes++;let ee=me[G.__cacheKey];ee!==void 0&&(me[G.__cacheKey].usedTimes--,ee.usedTimes===0&&C(A)),G.__cacheKey=Te,G.__webglTexture=me[Te].texture}return U}function Me(G,A,U){let he=r.TEXTURE_2D;(A.isDataArrayTexture||A.isCompressedArrayTexture)&&(he=r.TEXTURE_2D_ARRAY),A.isData3DTexture&&(he=r.TEXTURE_3D);let me=ye(G,A),Te=A.source;t.bindTexture(he,G.__webglTexture,r.TEXTURE0+U);let ee=n.get(Te);if(Te.version!==ee.__version||me===!0){t.activeTexture(r.TEXTURE0+U);let k=Bt.getPrimaries(Bt.workingColorSpace),J=A.colorSpace===cs?null:Bt.getPrimaries(A.colorSpace),ue=A.colorSpace===cs||k===J?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,A.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,A.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,A.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ue);let Z=v(A.image,!1,i.maxTextureSize);Z=le(A,Z);let ce=s.convert(A.format,A.colorSpace),pe=s.convert(A.type),fe=_(A.internalFormat,ce,pe,A.colorSpace,A.isVideoTexture);de(he,A);let ge,Ae=A.mipmaps,Ie=A.isVideoTexture!==!0&&fe!==u0,Fe=ee.__version===void 0||me===!0,Je=Te.dataReady,dt=y(A,Z);if(A.isDepthTexture)fe=r.DEPTH_COMPONENT16,A.type===Vr?fe=r.DEPTH_COMPONENT32F:A.type===fa?fe=r.DEPTH_COMPONENT24:A.type===Zl&&(fe=r.DEPTH24_STENCIL8),Fe&&(Ie?t.texStorage2D(r.TEXTURE_2D,1,fe,Z.width,Z.height):t.texImage2D(r.TEXTURE_2D,0,fe,Z.width,Z.height,0,ce,pe,null));else if(A.isDataTexture)if(Ae.length>0){Ie&&Fe&&t.texStorage2D(r.TEXTURE_2D,dt,fe,Ae[0].width,Ae[0].height);for(let Oe=0,ne=Ae.length;Oe<ne;Oe++)ge=Ae[Oe],Ie?Je&&t.texSubImage2D(r.TEXTURE_2D,Oe,0,0,ge.width,ge.height,ce,pe,ge.data):t.texImage2D(r.TEXTURE_2D,Oe,fe,ge.width,ge.height,0,ce,pe,ge.data);A.generateMipmaps=!1}else Ie?(Fe&&t.texStorage2D(r.TEXTURE_2D,dt,fe,Z.width,Z.height),Je&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,Z.width,Z.height,ce,pe,Z.data)):t.texImage2D(r.TEXTURE_2D,0,fe,Z.width,Z.height,0,ce,pe,Z.data);else if(A.isCompressedTexture)if(A.isCompressedArrayTexture){Ie&&Fe&&t.texStorage3D(r.TEXTURE_2D_ARRAY,dt,fe,Ae[0].width,Ae[0].height,Z.depth);for(let Oe=0,ne=Ae.length;Oe<ne;Oe++)ge=Ae[Oe],A.format!==Xi?ce!==null?Ie?Je&&t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Oe,0,0,0,ge.width,ge.height,Z.depth,ce,ge.data,0,0):t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,Oe,fe,ge.width,ge.height,Z.depth,0,ge.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ie?Je&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,Oe,0,0,0,ge.width,ge.height,Z.depth,ce,pe,ge.data):t.texImage3D(r.TEXTURE_2D_ARRAY,Oe,fe,ge.width,ge.height,Z.depth,0,ce,pe,ge.data)}else{Ie&&Fe&&t.texStorage2D(r.TEXTURE_2D,dt,fe,Ae[0].width,Ae[0].height);for(let Oe=0,ne=Ae.length;Oe<ne;Oe++)ge=Ae[Oe],A.format!==Xi?ce!==null?Ie?Je&&t.compressedTexSubImage2D(r.TEXTURE_2D,Oe,0,0,ge.width,ge.height,ce,ge.data):t.compressedTexImage2D(r.TEXTURE_2D,Oe,fe,ge.width,ge.height,0,ge.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ie?Je&&t.texSubImage2D(r.TEXTURE_2D,Oe,0,0,ge.width,ge.height,ce,pe,ge.data):t.texImage2D(r.TEXTURE_2D,Oe,fe,ge.width,ge.height,0,ce,pe,ge.data)}else if(A.isDataArrayTexture)Ie?(Fe&&t.texStorage3D(r.TEXTURE_2D_ARRAY,dt,fe,Z.width,Z.height,Z.depth),Je&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,Z.width,Z.height,Z.depth,ce,pe,Z.data)):t.texImage3D(r.TEXTURE_2D_ARRAY,0,fe,Z.width,Z.height,Z.depth,0,ce,pe,Z.data);else if(A.isData3DTexture)Ie?(Fe&&t.texStorage3D(r.TEXTURE_3D,dt,fe,Z.width,Z.height,Z.depth),Je&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,Z.width,Z.height,Z.depth,ce,pe,Z.data)):t.texImage3D(r.TEXTURE_3D,0,fe,Z.width,Z.height,Z.depth,0,ce,pe,Z.data);else if(A.isFramebufferTexture){if(Fe)if(Ie)t.texStorage2D(r.TEXTURE_2D,dt,fe,Z.width,Z.height);else{let Oe=Z.width,ne=Z.height;for(let Pe=0;Pe<dt;Pe++)t.texImage2D(r.TEXTURE_2D,Pe,fe,Oe,ne,0,ce,pe,null),Oe>>=1,ne>>=1}}else if(Ae.length>0){if(Ie&&Fe){let Oe=xe(Ae[0]);t.texStorage2D(r.TEXTURE_2D,dt,fe,Oe.width,Oe.height)}for(let Oe=0,ne=Ae.length;Oe<ne;Oe++)ge=Ae[Oe],Ie?Je&&t.texSubImage2D(r.TEXTURE_2D,Oe,0,0,ce,pe,ge):t.texImage2D(r.TEXTURE_2D,Oe,fe,ce,pe,ge);A.generateMipmaps=!1}else if(Ie){if(Fe){let Oe=xe(Z);t.texStorage2D(r.TEXTURE_2D,dt,fe,Oe.width,Oe.height)}Je&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,ce,pe,Z)}else t.texImage2D(r.TEXTURE_2D,0,fe,ce,pe,Z);d(A)&&m(he),ee.__version=Te.version,A.onUpdate&&A.onUpdate(A)}G.__version=A.version}function ve(G,A,U){if(A.image.length!==6)return;let he=ye(G,A),me=A.source;t.bindTexture(r.TEXTURE_CUBE_MAP,G.__webglTexture,r.TEXTURE0+U);let Te=n.get(me);if(me.version!==Te.__version||he===!0){t.activeTexture(r.TEXTURE0+U);let ee=Bt.getPrimaries(Bt.workingColorSpace),k=A.colorSpace===cs?null:Bt.getPrimaries(A.colorSpace),J=A.colorSpace===cs||ee===k?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,A.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,A.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,A.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);let ue=A.isCompressedTexture||A.image[0].isCompressedTexture,Z=A.image[0]&&A.image[0].isDataTexture,ce=[];for(let ne=0;ne<6;ne++)!ue&&!Z?ce[ne]=v(A.image[ne],!0,i.maxCubemapSize):ce[ne]=Z?A.image[ne].image:A.image[ne],ce[ne]=le(A,ce[ne]);let pe=ce[0],fe=s.convert(A.format,A.colorSpace),ge=s.convert(A.type),Ae=_(A.internalFormat,fe,ge,A.colorSpace),Ie=A.isVideoTexture!==!0,Fe=Te.__version===void 0||he===!0,Je=me.dataReady,dt=y(A,pe);de(r.TEXTURE_CUBE_MAP,A);let Oe;if(ue){Ie&&Fe&&t.texStorage2D(r.TEXTURE_CUBE_MAP,dt,Ae,pe.width,pe.height);for(let ne=0;ne<6;ne++){Oe=ce[ne].mipmaps;for(let Pe=0;Pe<Oe.length;Pe++){let Ne=Oe[Pe];A.format!==Xi?fe!==null?Ie?Je&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Pe,0,0,Ne.width,Ne.height,fe,Ne.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Pe,Ae,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ie?Je&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Pe,0,0,Ne.width,Ne.height,fe,ge,Ne.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Pe,Ae,Ne.width,Ne.height,0,fe,ge,Ne.data)}}}else{if(Oe=A.mipmaps,Ie&&Fe){Oe.length>0&&dt++;let ne=xe(ce[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,dt,Ae,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Z){Ie?Je&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,ce[ne].width,ce[ne].height,fe,ge,ce[ne].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Ae,ce[ne].width,ce[ne].height,0,fe,ge,ce[ne].data);for(let Pe=0;Pe<Oe.length;Pe++){let Ue=Oe[Pe].image[ne].image;Ie?Je&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Pe+1,0,0,Ue.width,Ue.height,fe,ge,Ue.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Pe+1,Ae,Ue.width,Ue.height,0,fe,ge,Ue.data)}}else{Ie?Je&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,fe,ge,ce[ne]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Ae,fe,ge,ce[ne]);for(let Pe=0;Pe<Oe.length;Pe++){let Ne=Oe[Pe];Ie?Je&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Pe+1,0,0,fe,ge,Ne.image[ne]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Pe+1,Ae,fe,ge,Ne.image[ne])}}}d(A)&&m(r.TEXTURE_CUBE_MAP),Te.__version=me.version,A.onUpdate&&A.onUpdate(A)}G.__version=A.version}function R(G,A,U,he,me,Te){let ee=s.convert(U.format,U.colorSpace),k=s.convert(U.type),J=_(U.internalFormat,ee,k,U.colorSpace);if(!n.get(A).__hasExternalTextures){let Z=Math.max(1,A.width>>Te),ce=Math.max(1,A.height>>Te);me===r.TEXTURE_3D||me===r.TEXTURE_2D_ARRAY?t.texImage3D(me,Te,J,Z,ce,A.depth,0,ee,k,null):t.texImage2D(me,Te,J,Z,ce,0,ee,k,null)}t.bindFramebuffer(r.FRAMEBUFFER,G),se(A)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,he,me,n.get(U).__webglTexture,0,X(A)):(me===r.TEXTURE_2D||me>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&me<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,he,me,n.get(U).__webglTexture,Te),t.bindFramebuffer(r.FRAMEBUFFER,null)}function T(G,A,U){if(r.bindRenderbuffer(r.RENDERBUFFER,G),A.depthBuffer&&!A.stencilBuffer){let he=r.DEPTH_COMPONENT24;if(U||se(A)){let me=A.depthTexture;me&&me.isDepthTexture&&(me.type===Vr?he=r.DEPTH_COMPONENT32F:me.type===fa&&(he=r.DEPTH_COMPONENT24));let Te=X(A);se(A)?a.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Te,he,A.width,A.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,Te,he,A.width,A.height)}else r.renderbufferStorage(r.RENDERBUFFER,he,A.width,A.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,G)}else if(A.depthBuffer&&A.stencilBuffer){let he=X(A);U&&se(A)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,he,r.DEPTH24_STENCIL8,A.width,A.height):se(A)?a.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,he,r.DEPTH24_STENCIL8,A.width,A.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,A.width,A.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,G)}else{let he=A.textures;for(let me=0;me<he.length;me++){let Te=he[me],ee=s.convert(Te.format,Te.colorSpace),k=s.convert(Te.type),J=_(Te.internalFormat,ee,k,Te.colorSpace),ue=X(A);U&&se(A)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,ue,J,A.width,A.height):se(A)?a.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,ue,J,A.width,A.height):r.renderbufferStorage(r.RENDERBUFFER,J,A.width,A.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function S(G,A){if(A&&A.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,G),!(A.depthTexture&&A.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.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),O(A.depthTexture,0);let he=n.get(A.depthTexture).__webglTexture,me=X(A);if(A.depthTexture.format===sa)se(A)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,he,0,me):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,he,0);else if(A.depthTexture.format===Ul)se(A)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,he,0,me):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,he,0);else throw new Error("Unknown depthTexture format")}function b(G){let A=n.get(G),U=G.isWebGLCubeRenderTarget===!0;if(G.depthTexture&&!A.__autoAllocateDepthBuffer){if(U)throw new Error("target.depthTexture not supported in Cube render targets");S(A.__webglFramebuffer,G)}else if(U){A.__webglDepthbuffer=[];for(let he=0;he<6;he++)t.bindFramebuffer(r.FRAMEBUFFER,A.__webglFramebuffer[he]),A.__webglDepthbuffer[he]=r.createRenderbuffer(),T(A.__webglDepthbuffer[he],G,!1)}else t.bindFramebuffer(r.FRAMEBUFFER,A.__webglFramebuffer),A.__webglDepthbuffer=r.createRenderbuffer(),T(A.__webglDepthbuffer,G,!1);t.bindFramebuffer(r.FRAMEBUFFER,null)}function V(G,A,U){let he=n.get(G);A!==void 0&&R(he.__webglFramebuffer,G,G.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),U!==void 0&&b(G)}function q(G){let A=G.texture,U=n.get(G),he=n.get(A);G.addEventListener("dispose",w);let me=G.textures,Te=G.isWebGLCubeRenderTarget===!0,ee=me.length>1;if(ee||(he.__webglTexture===void 0&&(he.__webglTexture=r.createTexture()),he.__version=A.version,o.memory.textures++),Te){U.__webglFramebuffer=[];for(let k=0;k<6;k++)if(A.mipmaps&&A.mipmaps.length>0){U.__webglFramebuffer[k]=[];for(let J=0;J<A.mipmaps.length;J++)U.__webglFramebuffer[k][J]=r.createFramebuffer()}else U.__webglFramebuffer[k]=r.createFramebuffer()}else{if(A.mipmaps&&A.mipmaps.length>0){U.__webglFramebuffer=[];for(let k=0;k<A.mipmaps.length;k++)U.__webglFramebuffer[k]=r.createFramebuffer()}else U.__webglFramebuffer=r.createFramebuffer();if(ee)for(let k=0,J=me.length;k<J;k++){let ue=n.get(me[k]);ue.__webglTexture===void 0&&(ue.__webglTexture=r.createTexture(),o.memory.textures++)}if(G.samples>0&&se(G)===!1){U.__webglMultisampledFramebuffer=r.createFramebuffer(),U.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let k=0;k<me.length;k++){let J=me[k];U.__webglColorRenderbuffer[k]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,U.__webglColorRenderbuffer[k]);let ue=s.convert(J.format,J.colorSpace),Z=s.convert(J.type),ce=_(J.internalFormat,ue,Z,J.colorSpace,G.isXRRenderTarget===!0),pe=X(G);r.renderbufferStorageMultisample(r.RENDERBUFFER,pe,ce,G.width,G.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+k,r.RENDERBUFFER,U.__webglColorRenderbuffer[k])}r.bindRenderbuffer(r.RENDERBUFFER,null),G.depthBuffer&&(U.__webglDepthRenderbuffer=r.createRenderbuffer(),T(U.__webglDepthRenderbuffer,G,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(Te){t.bindTexture(r.TEXTURE_CUBE_MAP,he.__webglTexture),de(r.TEXTURE_CUBE_MAP,A);for(let k=0;k<6;k++)if(A.mipmaps&&A.mipmaps.length>0)for(let J=0;J<A.mipmaps.length;J++)R(U.__webglFramebuffer[k][J],G,A,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+k,J);else R(U.__webglFramebuffer[k],G,A,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+k,0);d(A)&&m(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ee){for(let k=0,J=me.length;k<J;k++){let ue=me[k],Z=n.get(ue);t.bindTexture(r.TEXTURE_2D,Z.__webglTexture),de(r.TEXTURE_2D,ue),R(U.__webglFramebuffer,G,ue,r.COLOR_ATTACHMENT0+k,r.TEXTURE_2D,0),d(ue)&&m(r.TEXTURE_2D)}t.unbindTexture()}else{let k=r.TEXTURE_2D;if((G.isWebGL3DRenderTarget||G.isWebGLArrayRenderTarget)&&(k=G.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(k,he.__webglTexture),de(k,A),A.mipmaps&&A.mipmaps.length>0)for(let J=0;J<A.mipmaps.length;J++)R(U.__webglFramebuffer[J],G,A,r.COLOR_ATTACHMENT0,k,J);else R(U.__webglFramebuffer,G,A,r.COLOR_ATTACHMENT0,k,0);d(A)&&m(k),t.unbindTexture()}G.depthBuffer&&b(G)}function Y(G){let A=G.textures;for(let U=0,he=A.length;U<he;U++){let me=A[U];if(d(me)){let Te=G.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,ee=n.get(me).__webglTexture;t.bindTexture(Te,ee),m(Te),t.unbindTexture()}}}function z(G){if(G.samples>0&&se(G)===!1){let A=G.textures,U=G.width,he=G.height,me=r.COLOR_BUFFER_BIT,Te=[],ee=G.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,k=n.get(G),J=A.length>1;if(J)for(let ue=0;ue<A.length;ue++)t.bindFramebuffer(r.FRAMEBUFFER,k.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ue,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,k.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ue,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,k.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,k.__webglFramebuffer);for(let ue=0;ue<A.length;ue++){Te.push(r.COLOR_ATTACHMENT0+ue),G.depthBuffer&&Te.push(ee);let Z=k.__ignoreDepthValues!==void 0?k.__ignoreDepthValues:!1;if(Z===!1&&(G.depthBuffer&&(me|=r.DEPTH_BUFFER_BIT),G.stencilBuffer&&k.__isTransmissionRenderTarget!==!0&&(me|=r.STENCIL_BUFFER_BIT)),J&&r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,k.__webglColorRenderbuffer[ue]),Z===!0&&(r.invalidateFramebuffer(r.READ_FRAMEBUFFER,[ee]),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[ee])),J){let ce=n.get(A[ue]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,ce,0)}r.blitFramebuffer(0,0,U,he,0,0,U,he,me,r.NEAREST),l&&r.invalidateFramebuffer(r.READ_FRAMEBUFFER,Te)}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),J)for(let ue=0;ue<A.length;ue++){t.bindFramebuffer(r.FRAMEBUFFER,k.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ue,r.RENDERBUFFER,k.__webglColorRenderbuffer[ue]);let Z=n.get(A[ue]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,k.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ue,r.TEXTURE_2D,Z,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,k.__webglMultisampledFramebuffer)}}function X(G){return Math.min(i.maxSamples,G.samples)}function se(G){let A=n.get(G);return G.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&A.__useRenderToTexture!==!1}function re(G){let A=o.render.frame;u.get(G)!==A&&(u.set(G,A),G.update())}function le(G,A){let U=G.colorSpace,he=G.format,me=G.type;return G.isCompressedTexture===!0||G.isVideoTexture===!0||U!==li&&U!==cs&&(Bt.getTransfer(U)===Qt?(he!==Xi||me!==fs)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",U)),A}function xe(G){return typeof HTMLImageElement<"u"&&G instanceof HTMLImageElement?(c.width=G.naturalWidth||G.width,c.height=G.naturalHeight||G.height):typeof VideoFrame<"u"&&G instanceof VideoFrame?(c.width=G.displayWidth,c.height=G.displayHeight):(c.width=G.width,c.height=G.height),c}this.allocateTextureUnit=L,this.resetTextureUnits=M,this.setTexture2D=O,this.setTexture2DArray=B,this.setTexture3D=ie,this.setTextureCube=$,this.rebindTextures=V,this.setupRenderTarget=q,this.updateRenderTargetMipmap=Y,this.updateMultisampleRenderTarget=z,this.setupDepthRenderbuffer=b,this.setupFrameBufferTexture=R,this.useMultisampledRTT=se}function HE(r,e){function t(n,i=cs){let s,o=Bt.getTransfer(i);if(n===fs)return r.UNSIGNED_BYTE;if(n===s0)return r.UNSIGNED_SHORT_4_4_4_4;if(n===o0)return r.UNSIGNED_SHORT_5_5_5_1;if(n===Ty)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===xy)return r.BYTE;if(n===_y)return r.SHORT;if(n===i0)return r.UNSIGNED_SHORT;if(n===r0)return r.INT;if(n===fa)return r.UNSIGNED_INT;if(n===Vr)return r.FLOAT;if(n===Nu)return r.HALF_FLOAT;if(n===My)return r.ALPHA;if(n===Ey)return r.RGB;if(n===Xi)return r.RGBA;if(n===by)return r.LUMINANCE;if(n===Sy)return r.LUMINANCE_ALPHA;if(n===sa)return r.DEPTH_COMPONENT;if(n===Ul)return r.DEPTH_STENCIL;if(n===Ay)return r.RED;if(n===a0)return r.RED_INTEGER;if(n===wy)return r.RG;if(n===l0)return r.RG_INTEGER;if(n===c0)return r.RGBA_INTEGER;if(n===rf||n===sf||n===of||n===af)if(o===Qt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===rf)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===sf)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===of)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===af)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===rf)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===sf)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===of)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===af)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===dm||n===pm||n===mm||n===gm)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===dm)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===pm)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===mm)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===gm)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===u0)return s=e.get("WEBGL_compressed_texture_etc1"),s!==null?s.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===vm||n===ym)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===vm)return o===Qt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===ym)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===xm||n===_m||n===Tm||n===Mm||n===Em||n===bm||n===Sm||n===Am||n===wm||n===Cm||n===Rm||n===Im||n===Pm||n===Nm)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===xm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===_m)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Tm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Mm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Em)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===bm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Sm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Am)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===wm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Cm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Rm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Im)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Pm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Nm)return o===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===lf||n===Lm||n===Om)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===lf)return o===Qt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Lm)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Om)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Cy||n===Dm||n===Fm||n===Um)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===lf)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Dm)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fm)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Um)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Zl?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:t}}var rd=class extends en{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},dn=class extends Rt{constructor(){super(),this.isGroup=!0,this.type="Group"}},WE={type:"move"},Ll=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dn,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 dn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new oe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new oe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new oe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new oe),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 n of e.hand.values())this._getHandJoint(t,n)}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,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(let v of e.hand.values()){let d=t.getJointPose(v,n),m=this._getHandJoint(c,v);d!==null&&(m.matrix.fromArray(d.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=d.radius),m.visible=d!==null}let u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],f=u.position.distanceTo(h.position),p=.02,g=.005;c.inputState.pinching&&f>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(WE)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new dn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},XE=`
+}`;function Nb(r,e,t){let n=new Pa,i=new Pe,s=new Pe,o=new wt,a=new wh({depthPacking:H0}),l=new Ch,c={},u=t.maxTextureSize,h={[wi]:_n,[_n]:wi,[Nn]:Nn},f=new nr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Pe},radius:{value:4}},vertexShader:Rb,fragmentShader:Pb}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let g=new It;g.setAttribute("position",new Vn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new Dt(g,f),d=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=dp;let m=this.type;this.render=function(I,A,C){if(d.enabled===!1||d.autoUpdate===!1&&d.needsUpdate===!1||I.length===0)return;let E=r.getRenderTarget(),b=r.getActiveCubeFace(),R=r.getActiveMipmapLevel(),N=r.state;N.setBlending(as),N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);let B=m!==Ir&&this.type===Ir,V=m===Ir&&this.type!==Ir;for(let ie=0,Y=I.length;ie<Y;ie++){let te=I[ie],q=te.shadow;if(q===void 0){console.warn("THREE.WebGLShadowMap:",te,"has no shadow.");continue}if(q.autoUpdate===!1&&q.needsUpdate===!1)continue;i.copy(q.mapSize);let le=q.getFrameExtents();if(i.multiply(le),s.copy(q.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/le.x),i.x=s.x*le.x,q.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/le.y),i.y=s.y*le.y,q.mapSize.y=s.y)),q.map===null||B===!0||V===!0){let Te=this.type!==Ir?{minFilter:Xn,magFilter:Xn}:{};q.map!==null&&q.map.dispose(),q.map=new wr(i.x,i.y,Te),q.map.texture.name=te.name+".shadowMap",q.camera.updateProjectionMatrix()}r.setRenderTarget(q.map),r.clear();let ye=q.getViewportCount();for(let Te=0;Te<ye;Te++){let Ae=q.getViewport(Te);o.set(s.x*Ae.x,s.y*Ae.y,s.x*Ae.z,s.y*Ae.w),N.viewport(o),q.updateMatrices(te,Te),n=q.getFrustum(),x(A,C,q.camera,te,this.type)}q.isPointLightShadow!==!0&&this.type===Ir&&_(q,C),q.needsUpdate=!1}m=this.type,d.needsUpdate=!1,r.setRenderTarget(E,b,R)};function _(I,A){let C=e.update(y);f.defines.VSM_SAMPLES!==I.blurSamples&&(f.defines.VSM_SAMPLES=I.blurSamples,p.defines.VSM_SAMPLES=I.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),I.mapPass===null&&(I.mapPass=new wr(i.x,i.y)),f.uniforms.shadow_pass.value=I.map.texture,f.uniforms.resolution.value=I.mapSize,f.uniforms.radius.value=I.radius,r.setRenderTarget(I.mapPass),r.clear(),r.renderBufferDirect(A,null,C,f,y,null),p.uniforms.shadow_pass.value=I.mapPass.texture,p.uniforms.resolution.value=I.mapSize,p.uniforms.radius.value=I.radius,r.setRenderTarget(I.map),r.clear(),r.renderBufferDirect(A,null,C,p,y,null)}function v(I,A,C,E){let b=null,R=C.isPointLight===!0?I.customDistanceMaterial:I.customDepthMaterial;if(R!==void 0)b=R;else if(b=C.isPointLight===!0?l:a,r.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let N=b.uuid,B=A.uuid,V=c[N];V===void 0&&(V={},c[N]=V);let ie=V[B];ie===void 0&&(ie=b.clone(),V[B]=ie,A.addEventListener("dispose",S)),b=ie}if(b.visible=A.visible,b.wireframe=A.wireframe,E===Ir?b.side=A.shadowSide!==null?A.shadowSide:A.side:b.side=A.shadowSide!==null?A.shadowSide:h[A.side],b.alphaMap=A.alphaMap,b.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,b.map=A.map,b.clipShadows=A.clipShadows,b.clippingPlanes=A.clippingPlanes,b.clipIntersection=A.clipIntersection,b.displacementMap=A.displacementMap,b.displacementScale=A.displacementScale,b.displacementBias=A.displacementBias,b.wireframeLinewidth=A.wireframeLinewidth,b.linewidth=A.linewidth,C.isPointLight===!0&&b.isMeshDistanceMaterial===!0){let N=r.properties.get(b);N.light=C}return b}function x(I,A,C,E,b){if(I.visible===!1)return;if(I.layers.test(A.layers)&&(I.isMesh||I.isLine||I.isPoints)&&(I.castShadow||I.receiveShadow&&b===Ir)&&(!I.frustumCulled||n.intersectsObject(I))){I.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,I.matrixWorld);let B=e.update(I),V=I.material;if(Array.isArray(V)){let ie=B.groups;for(let Y=0,te=ie.length;Y<te;Y++){let q=ie[Y],le=V[q.materialIndex];if(le&&le.visible){let ye=v(I,le,E,b);I.onBeforeShadow(r,I,A,C,B,ye,q),r.renderBufferDirect(C,null,B,ye,I,q),I.onAfterShadow(r,I,A,C,B,ye,q)}}}else if(V.visible){let ie=v(I,V,E,b);I.onBeforeShadow(r,I,A,C,B,ie,null),r.renderBufferDirect(C,null,B,ie,I,null),I.onAfterShadow(r,I,A,C,B,ie,null)}}let N=I.children;for(let B=0,V=N.length;B<V;B++)x(N[B],A,C,E,b)}function S(I){I.target.removeEventListener("dispose",S);for(let C in c){let E=c[C],b=I.target.uuid;b in E&&(E[b].dispose(),delete E[b])}}}var Lb={[Dh]:Fh,[Uh]:Gh,[kh]:Vh,[ro]:Bh,[Fh]:Dh,[Gh]:Uh,[Vh]:kh,[Bh]:ro};function Ob(r,e){function t(){let fe=!1,Le=new wt,be=null,Ce=new wt(0,0,0,0);return{setMask:function(Be){be!==Be&&!fe&&(r.colorMask(Be,Be,Be,Be),be=Be)},setLocked:function(Be){fe=Be},setClear:function(Be,Oe,rt,Et,ft){ft===!0&&(Be*=Et,Oe*=Et,rt*=Et),Le.set(Be,Oe,rt,Et),Ce.equals(Le)===!1&&(r.clearColor(Be,Oe,rt,Et),Ce.copy(Le))},reset:function(){fe=!1,be=null,Ce.set(-1,0,0,0)}}}function n(){let fe=!1,Le=!1,be=null,Ce=null,Be=null;return{setReversed:function(Oe){if(Le!==Oe){let rt=e.get("EXT_clip_control");Oe?rt.clipControlEXT(rt.LOWER_LEFT_EXT,rt.ZERO_TO_ONE_EXT):rt.clipControlEXT(rt.LOWER_LEFT_EXT,rt.NEGATIVE_ONE_TO_ONE_EXT),Le=Oe;let Et=Be;Be=null,this.setClear(Et)}},getReversed:function(){return Le},setTest:function(Oe){Oe?T(r.DEPTH_TEST):k(r.DEPTH_TEST)},setMask:function(Oe){be!==Oe&&!fe&&(r.depthMask(Oe),be=Oe)},setFunc:function(Oe){if(Le&&(Oe=Lb[Oe]),Ce!==Oe){switch(Oe){case Dh:r.depthFunc(r.NEVER);break;case Fh:r.depthFunc(r.ALWAYS);break;case Uh:r.depthFunc(r.LESS);break;case ro:r.depthFunc(r.LEQUAL);break;case kh:r.depthFunc(r.EQUAL);break;case Bh:r.depthFunc(r.GEQUAL);break;case Gh:r.depthFunc(r.GREATER);break;case Vh:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Ce=Oe}},setLocked:function(Oe){fe=Oe},setClear:function(Oe){Be!==Oe&&(Le&&(Oe=1-Oe),r.clearDepth(Oe),Be=Oe)},reset:function(){fe=!1,be=null,Ce=null,Be=null,Le=!1}}}function i(){let fe=!1,Le=null,be=null,Ce=null,Be=null,Oe=null,rt=null,Et=null,ft=null;return{setTest:function(Fe){fe||(Fe?T(r.STENCIL_TEST):k(r.STENCIL_TEST))},setMask:function(Fe){Le!==Fe&&!fe&&(r.stencilMask(Fe),Le=Fe)},setFunc:function(Fe,$e,ze){(be!==Fe||Ce!==$e||Be!==ze)&&(r.stencilFunc(Fe,$e,ze),be=Fe,Ce=$e,Be=ze)},setOp:function(Fe,$e,ze){(Oe!==Fe||rt!==$e||Et!==ze)&&(r.stencilOp(Fe,$e,ze),Oe=Fe,rt=$e,Et=ze)},setLocked:function(Fe){fe=Fe},setClear:function(Fe){ft!==Fe&&(r.clearStencil(Fe),ft=Fe)},reset:function(){fe=!1,Le=null,be=null,Ce=null,Be=null,Oe=null,rt=null,Et=null,ft=null}}}let s=new t,o=new n,a=new i,l=new WeakMap,c=new WeakMap,u={},h={},f=new WeakMap,p=[],g=null,y=!1,d=null,m=null,_=null,v=null,x=null,S=null,I=null,A=new He(0,0,0),C=0,E=!1,b=null,R=null,N=null,B=null,V=null,ie=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS),Y=!1,te=0,q=r.getParameter(r.VERSION);q.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(q)[1]),Y=te>=1):q.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),Y=te>=2);let le=null,ye={},Te=r.getParameter(r.SCISSOR_BOX),Ae=r.getParameter(r.VIEWPORT),_e=new wt().fromArray(Te),G=new wt().fromArray(Ae);function P(fe,Le,be,Ce){let Be=new Uint8Array(4),Oe=r.createTexture();r.bindTexture(fe,Oe),r.texParameteri(fe,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(fe,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let rt=0;rt<be;rt++)fe===r.TEXTURE_3D||fe===r.TEXTURE_2D_ARRAY?r.texImage3D(Le,0,r.RGBA,1,1,Ce,0,r.RGBA,r.UNSIGNED_BYTE,Be):r.texImage2D(Le+rt,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,Be);return Oe}let M={};M[r.TEXTURE_2D]=P(r.TEXTURE_2D,r.TEXTURE_2D,1),M[r.TEXTURE_CUBE_MAP]=P(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),M[r.TEXTURE_2D_ARRAY]=P(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),M[r.TEXTURE_3D]=P(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),T(r.DEPTH_TEST),o.setFunc(ro),pe(!1),ue(fp),T(r.CULL_FACE),w(as);function T(fe){u[fe]!==!0&&(r.enable(fe),u[fe]=!0)}function k(fe){u[fe]!==!1&&(r.disable(fe),u[fe]=!1)}function j(fe,Le){return h[fe]!==Le?(r.bindFramebuffer(fe,Le),h[fe]=Le,fe===r.DRAW_FRAMEBUFFER&&(h[r.FRAMEBUFFER]=Le),fe===r.FRAMEBUFFER&&(h[r.DRAW_FRAMEBUFFER]=Le),!0):!1}function W(fe,Le){let be=p,Ce=!1;if(fe){be=f.get(Le),be===void 0&&(be=[],f.set(Le,be));let Be=fe.textures;if(be.length!==Be.length||be[0]!==r.COLOR_ATTACHMENT0){for(let Oe=0,rt=Be.length;Oe<rt;Oe++)be[Oe]=r.COLOR_ATTACHMENT0+Oe;be.length=Be.length,Ce=!0}}else be[0]!==r.BACK&&(be[0]=r.BACK,Ce=!0);Ce&&r.drawBuffers(be)}function re(fe){return g!==fe?(r.useProgram(fe),g=fe,!0):!1}let ce={[ws]:r.FUNC_ADD,[d0]:r.FUNC_SUBTRACT,[p0]:r.FUNC_REVERSE_SUBTRACT};ce[m0]=r.MIN,ce[g0]=r.MAX;let me={[y0]:r.ZERO,[x0]:r.ONE,[v0]:r.SRC_COLOR,[fh]:r.SRC_ALPHA,[S0]:r.SRC_ALPHA_SATURATE,[E0]:r.DST_COLOR,[T0]:r.DST_ALPHA,[_0]:r.ONE_MINUS_SRC_COLOR,[dh]:r.ONE_MINUS_SRC_ALPHA,[b0]:r.ONE_MINUS_DST_COLOR,[M0]:r.ONE_MINUS_DST_ALPHA,[A0]:r.CONSTANT_COLOR,[w0]:r.ONE_MINUS_CONSTANT_COLOR,[C0]:r.CONSTANT_ALPHA,[I0]:r.ONE_MINUS_CONSTANT_ALPHA};function w(fe,Le,be,Ce,Be,Oe,rt,Et,ft,Fe){if(fe===as){y===!0&&(k(r.BLEND),y=!1);return}if(y===!1&&(T(r.BLEND),y=!0),fe!==f0){if(fe!==d||Fe!==E){if((m!==ws||x!==ws)&&(r.blendEquation(r.FUNC_ADD),m=ws,x=ws),Fe)switch(fe){case io:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case pp:r.blendFunc(r.ONE,r.ONE);break;case mp:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case gp:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",fe);break}else switch(fe){case io:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case pp:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case mp:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case gp:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",fe);break}_=null,v=null,S=null,I=null,A.set(0,0,0),C=0,d=fe,E=Fe}return}Be=Be||Le,Oe=Oe||be,rt=rt||Ce,(Le!==m||Be!==x)&&(r.blendEquationSeparate(ce[Le],ce[Be]),m=Le,x=Be),(be!==_||Ce!==v||Oe!==S||rt!==I)&&(r.blendFuncSeparate(me[be],me[Ce],me[Oe],me[rt]),_=be,v=Ce,S=Oe,I=rt),(Et.equals(A)===!1||ft!==C)&&(r.blendColor(Et.r,Et.g,Et.b,ft),A.copy(Et),C=ft),d=fe,E=!1}function ae(fe,Le){fe.side===Nn?k(r.CULL_FACE):T(r.CULL_FACE);let be=fe.side===_n;Le&&(be=!be),pe(be),fe.blending===io&&fe.transparent===!1?w(as):w(fe.blending,fe.blendEquation,fe.blendSrc,fe.blendDst,fe.blendEquationAlpha,fe.blendSrcAlpha,fe.blendDstAlpha,fe.blendColor,fe.blendAlpha,fe.premultipliedAlpha),o.setFunc(fe.depthFunc),o.setTest(fe.depthTest),o.setMask(fe.depthWrite),s.setMask(fe.colorWrite);let Ce=fe.stencilWrite;a.setTest(Ce),Ce&&(a.setMask(fe.stencilWriteMask),a.setFunc(fe.stencilFunc,fe.stencilRef,fe.stencilFuncMask),a.setOp(fe.stencilFail,fe.stencilZFail,fe.stencilZPass)),$(fe.polygonOffset,fe.polygonOffsetFactor,fe.polygonOffsetUnits),fe.alphaToCoverage===!0?T(r.SAMPLE_ALPHA_TO_COVERAGE):k(r.SAMPLE_ALPHA_TO_COVERAGE)}function pe(fe){b!==fe&&(fe?r.frontFace(r.CW):r.frontFace(r.CCW),b=fe)}function ue(fe){fe!==c0?(T(r.CULL_FACE),fe!==R&&(fe===fp?r.cullFace(r.BACK):fe===u0?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):k(r.CULL_FACE),R=fe}function ee(fe){fe!==N&&(Y&&r.lineWidth(fe),N=fe)}function $(fe,Le,be){fe?(T(r.POLYGON_OFFSET_FILL),(B!==Le||V!==be)&&(r.polygonOffset(Le,be),B=Le,V=be)):k(r.POLYGON_OFFSET_FILL)}function ve(fe){fe?T(r.SCISSOR_TEST):k(r.SCISSOR_TEST)}function H(fe){fe===void 0&&(fe=r.TEXTURE0+ie-1),le!==fe&&(r.activeTexture(fe),le=fe)}function L(fe,Le,be){be===void 0&&(le===null?be=r.TEXTURE0+ie-1:be=le);let Ce=ye[be];Ce===void 0&&(Ce={type:void 0,texture:void 0},ye[be]=Ce),(Ce.type!==fe||Ce.texture!==Le)&&(le!==be&&(r.activeTexture(be),le=be),r.bindTexture(fe,Le||M[fe]),Ce.type=fe,Ce.texture=Le)}function O(){let fe=ye[le];fe!==void 0&&fe.type!==void 0&&(r.bindTexture(fe.type,null),fe.type=void 0,fe.texture=void 0)}function D(){try{r.compressedTexImage2D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function z(){try{r.compressedTexImage3D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Q(){try{r.texSubImage2D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function ne(){try{r.texSubImage3D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function oe(){try{r.compressedTexSubImage2D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function he(){try{r.compressedTexSubImage3D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function ge(){try{r.texStorage2D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function de(){try{r.texStorage3D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Ee(){try{r.texImage2D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Re(){try{r.texImage3D(...arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function De(fe){_e.equals(fe)===!1&&(r.scissor(fe.x,fe.y,fe.z,fe.w),_e.copy(fe))}function ke(fe){G.equals(fe)===!1&&(r.viewport(fe.x,fe.y,fe.z,fe.w),G.copy(fe))}function at(fe,Le){let be=c.get(Le);be===void 0&&(be=new WeakMap,c.set(Le,be));let Ce=be.get(fe);Ce===void 0&&(Ce=r.getUniformBlockIndex(Le,fe.name),be.set(fe,Ce))}function je(fe,Le){let Ce=c.get(Le).get(fe);l.get(Le)!==Ce&&(r.uniformBlockBinding(Le,Ce,fe.__bindingPointIndex),l.set(Le,Ce))}function Ke(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),o.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),u={},le=null,ye={},h={},f=new WeakMap,p=[],g=null,y=!1,d=null,m=null,_=null,v=null,x=null,S=null,I=null,A=new He(0,0,0),C=0,E=!1,b=null,R=null,N=null,B=null,V=null,_e.set(0,0,r.canvas.width,r.canvas.height),G.set(0,0,r.canvas.width,r.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:T,disable:k,bindFramebuffer:j,drawBuffers:W,useProgram:re,setBlending:w,setMaterial:ae,setFlipSided:pe,setCullFace:ue,setLineWidth:ee,setPolygonOffset:$,setScissorTest:ve,activeTexture:H,bindTexture:L,unbindTexture:O,compressedTexImage2D:D,compressedTexImage3D:z,texImage2D:Ee,texImage3D:Re,updateUBOMapping:at,uniformBlockBinding:je,texStorage2D:ge,texStorage3D:de,texSubImage2D:Q,texSubImage3D:ne,compressedTexSubImage2D:oe,compressedTexSubImage3D:he,scissor:De,viewport:ke,reset:Ke}}function Db(r,e,t,n,i,s,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Pe,u=new WeakMap,h,f=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(H,L){return p?new OffscreenCanvas(H,L):Aa("canvas")}function y(H,L,O){let D=1,z=ve(H);if((z.width>O||z.height>O)&&(D=O/Math.max(z.width,z.height)),D<1)if(typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&H instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&H instanceof ImageBitmap||typeof VideoFrame<"u"&&H instanceof VideoFrame){let Q=Math.floor(D*z.width),ne=Math.floor(D*z.height);h===void 0&&(h=g(Q,ne));let oe=L?g(Q,ne):h;return oe.width=Q,oe.height=ne,oe.getContext("2d").drawImage(H,0,0,Q,ne),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+Q+"x"+ne+")."),oe}else return"data"in H&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+")."),H;return H}function d(H){return H.generateMipmaps}function m(H){r.generateMipmap(H)}function _(H){return H.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:H.isWebGL3DRenderTarget?r.TEXTURE_3D:H.isWebGLArrayRenderTarget||H.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function v(H,L,O,D,z=!1){if(H!==null){if(r[H]!==void 0)return r[H];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+H+"'")}let Q=L;if(L===r.RED&&(O===r.FLOAT&&(Q=r.R32F),O===r.HALF_FLOAT&&(Q=r.R16F),O===r.UNSIGNED_BYTE&&(Q=r.R8)),L===r.RED_INTEGER&&(O===r.UNSIGNED_BYTE&&(Q=r.R8UI),O===r.UNSIGNED_SHORT&&(Q=r.R16UI),O===r.UNSIGNED_INT&&(Q=r.R32UI),O===r.BYTE&&(Q=r.R8I),O===r.SHORT&&(Q=r.R16I),O===r.INT&&(Q=r.R32I)),L===r.RG&&(O===r.FLOAT&&(Q=r.RG32F),O===r.HALF_FLOAT&&(Q=r.RG16F),O===r.UNSIGNED_BYTE&&(Q=r.RG8)),L===r.RG_INTEGER&&(O===r.UNSIGNED_BYTE&&(Q=r.RG8UI),O===r.UNSIGNED_SHORT&&(Q=r.RG16UI),O===r.UNSIGNED_INT&&(Q=r.RG32UI),O===r.BYTE&&(Q=r.RG8I),O===r.SHORT&&(Q=r.RG16I),O===r.INT&&(Q=r.RG32I)),L===r.RGB_INTEGER&&(O===r.UNSIGNED_BYTE&&(Q=r.RGB8UI),O===r.UNSIGNED_SHORT&&(Q=r.RGB16UI),O===r.UNSIGNED_INT&&(Q=r.RGB32UI),O===r.BYTE&&(Q=r.RGB8I),O===r.SHORT&&(Q=r.RGB16I),O===r.INT&&(Q=r.RGB32I)),L===r.RGBA_INTEGER&&(O===r.UNSIGNED_BYTE&&(Q=r.RGBA8UI),O===r.UNSIGNED_SHORT&&(Q=r.RGBA16UI),O===r.UNSIGNED_INT&&(Q=r.RGBA32UI),O===r.BYTE&&(Q=r.RGBA8I),O===r.SHORT&&(Q=r.RGBA16I),O===r.INT&&(Q=r.RGBA32I)),L===r.RGB&&O===r.UNSIGNED_INT_5_9_9_9_REV&&(Q=r.RGB9_E5),L===r.RGBA){let ne=z?ec:mt.getTransfer(D);O===r.FLOAT&&(Q=r.RGBA32F),O===r.HALF_FLOAT&&(Q=r.RGBA16F),O===r.UNSIGNED_BYTE&&(Q=ne===Kt?r.SRGB8_ALPHA8:r.RGBA8),O===r.UNSIGNED_SHORT_4_4_4_4&&(Q=r.RGBA4),O===r.UNSIGNED_SHORT_5_5_5_1&&(Q=r.RGB5_A1)}return(Q===r.R16F||Q===r.R32F||Q===r.RG16F||Q===r.RG32F||Q===r.RGBA16F||Q===r.RGBA32F)&&e.get("EXT_color_buffer_float"),Q}function x(H,L){let O;return H?L===null||L===Ls||L===Ga?O=r.DEPTH24_STENCIL8:L===cr?O=r.DEPTH32F_STENCIL8:L===ka&&(O=r.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Ls||L===Ga?O=r.DEPTH_COMPONENT24:L===cr?O=r.DEPTH_COMPONENT32F:L===ka&&(O=r.DEPTH_COMPONENT16),O}function S(H,L){return d(H)===!0||H.isFramebufferTexture&&H.minFilter!==Xn&&H.minFilter!==Pn?Math.log2(Math.max(L.width,L.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?L.mipmaps.length:1}function I(H){let L=H.target;L.removeEventListener("dispose",I),C(L),L.isVideoTexture&&u.delete(L)}function A(H){let L=H.target;L.removeEventListener("dispose",A),b(L)}function C(H){let L=n.get(H);if(L.__webglInit===void 0)return;let O=H.source,D=f.get(O);if(D){let z=D[L.__cacheKey];z.usedTimes--,z.usedTimes===0&&E(H),Object.keys(D).length===0&&f.delete(O)}n.remove(H)}function E(H){let L=n.get(H);r.deleteTexture(L.__webglTexture);let O=H.source,D=f.get(O);delete D[L.__cacheKey],o.memory.textures--}function b(H){let L=n.get(H);if(H.depthTexture&&(H.depthTexture.dispose(),n.remove(H.depthTexture)),H.isWebGLCubeRenderTarget)for(let D=0;D<6;D++){if(Array.isArray(L.__webglFramebuffer[D]))for(let z=0;z<L.__webglFramebuffer[D].length;z++)r.deleteFramebuffer(L.__webglFramebuffer[D][z]);else r.deleteFramebuffer(L.__webglFramebuffer[D]);L.__webglDepthbuffer&&r.deleteRenderbuffer(L.__webglDepthbuffer[D])}else{if(Array.isArray(L.__webglFramebuffer))for(let D=0;D<L.__webglFramebuffer.length;D++)r.deleteFramebuffer(L.__webglFramebuffer[D]);else r.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&r.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&r.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let D=0;D<L.__webglColorRenderbuffer.length;D++)L.__webglColorRenderbuffer[D]&&r.deleteRenderbuffer(L.__webglColorRenderbuffer[D]);L.__webglDepthRenderbuffer&&r.deleteRenderbuffer(L.__webglDepthRenderbuffer)}let O=H.textures;for(let D=0,z=O.length;D<z;D++){let Q=n.get(O[D]);Q.__webglTexture&&(r.deleteTexture(Q.__webglTexture),o.memory.textures--),n.remove(O[D])}n.remove(H)}let R=0;function N(){R=0}function B(){let H=R;return H>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+H+" texture units while this GPU supports only "+i.maxTextures),R+=1,H}function V(H){let L=[];return L.push(H.wrapS),L.push(H.wrapT),L.push(H.wrapR||0),L.push(H.magFilter),L.push(H.minFilter),L.push(H.anisotropy),L.push(H.internalFormat),L.push(H.format),L.push(H.type),L.push(H.generateMipmaps),L.push(H.premultiplyAlpha),L.push(H.flipY),L.push(H.unpackAlignment),L.push(H.colorSpace),L.join()}function ie(H,L){let O=n.get(H);if(H.isVideoTexture&&ee(H),H.isRenderTargetTexture===!1&&H.version>0&&O.__version!==H.version){let D=H.image;if(D===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(D.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{G(O,H,L);return}}t.bindTexture(r.TEXTURE_2D,O.__webglTexture,r.TEXTURE0+L)}function Y(H,L){let O=n.get(H);if(H.version>0&&O.__version!==H.version){G(O,H,L);return}t.bindTexture(r.TEXTURE_2D_ARRAY,O.__webglTexture,r.TEXTURE0+L)}function te(H,L){let O=n.get(H);if(H.version>0&&O.__version!==H.version){G(O,H,L);return}t.bindTexture(r.TEXTURE_3D,O.__webglTexture,r.TEXTURE0+L)}function q(H,L){let O=n.get(H);if(H.version>0&&O.__version!==H.version){P(O,H,L);return}t.bindTexture(r.TEXTURE_CUBE_MAP,O.__webglTexture,r.TEXTURE0+L)}let le={[on]:r.REPEAT,[un]:r.CLAMP_TO_EDGE,[so]:r.MIRRORED_REPEAT},ye={[Xn]:r.NEAREST,[G0]:r.NEAREST_MIPMAP_NEAREST,[wc]:r.NEAREST_MIPMAP_LINEAR,[Pn]:r.LINEAR,[Hh]:r.LINEAR_MIPMAP_NEAREST,[xi]:r.LINEAR_MIPMAP_LINEAR},Te={[X0]:r.NEVER,[J0]:r.ALWAYS,[q0]:r.LESS,[Ap]:r.LEQUAL,[j0]:r.EQUAL,[Z0]:r.GEQUAL,[Y0]:r.GREATER,[K0]:r.NOTEQUAL};function Ae(H,L){if(L.type===cr&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===Pn||L.magFilter===Hh||L.magFilter===wc||L.magFilter===xi||L.minFilter===Pn||L.minFilter===Hh||L.minFilter===wc||L.minFilter===xi)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(H,r.TEXTURE_WRAP_S,le[L.wrapS]),r.texParameteri(H,r.TEXTURE_WRAP_T,le[L.wrapT]),(H===r.TEXTURE_3D||H===r.TEXTURE_2D_ARRAY)&&r.texParameteri(H,r.TEXTURE_WRAP_R,le[L.wrapR]),r.texParameteri(H,r.TEXTURE_MAG_FILTER,ye[L.magFilter]),r.texParameteri(H,r.TEXTURE_MIN_FILTER,ye[L.minFilter]),L.compareFunction&&(r.texParameteri(H,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(H,r.TEXTURE_COMPARE_FUNC,Te[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===Xn||L.minFilter!==wc&&L.minFilter!==xi||L.type===cr&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||n.get(L).__currentAnisotropy){let O=e.get("EXT_texture_filter_anisotropic");r.texParameterf(H,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),n.get(L).__currentAnisotropy=L.anisotropy}}}function _e(H,L){let O=!1;H.__webglInit===void 0&&(H.__webglInit=!0,L.addEventListener("dispose",I));let D=L.source,z=f.get(D);z===void 0&&(z={},f.set(D,z));let Q=V(L);if(Q!==H.__cacheKey){z[Q]===void 0&&(z[Q]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,O=!0),z[Q].usedTimes++;let ne=z[H.__cacheKey];ne!==void 0&&(z[H.__cacheKey].usedTimes--,ne.usedTimes===0&&E(L)),H.__cacheKey=Q,H.__webglTexture=z[Q].texture}return O}function G(H,L,O){let D=r.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(D=r.TEXTURE_2D_ARRAY),L.isData3DTexture&&(D=r.TEXTURE_3D);let z=_e(H,L),Q=L.source;t.bindTexture(D,H.__webglTexture,r.TEXTURE0+O);let ne=n.get(Q);if(Q.version!==ne.__version||z===!0){t.activeTexture(r.TEXTURE0+O);let oe=mt.getPrimaries(mt.workingColorSpace),he=L.colorSpace===cs?null:mt.getPrimaries(L.colorSpace),ge=L.colorSpace===cs||oe===he?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,L.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,L.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge);let de=y(L.image,!1,i.maxTextureSize);de=$(L,de);let Ee=s.convert(L.format,L.colorSpace),Re=s.convert(L.type),De=v(L.internalFormat,Ee,Re,L.colorSpace,L.isVideoTexture);Ae(D,L);let ke,at=L.mipmaps,je=L.isVideoTexture!==!0,Ke=ne.__version===void 0||z===!0,fe=Q.dataReady,Le=S(L,de);if(L.isDepthTexture)De=x(L.format===Va,L.type),Ke&&(je?t.texStorage2D(r.TEXTURE_2D,1,De,de.width,de.height):t.texImage2D(r.TEXTURE_2D,0,De,de.width,de.height,0,Ee,Re,null));else if(L.isDataTexture)if(at.length>0){je&&Ke&&t.texStorage2D(r.TEXTURE_2D,Le,De,at[0].width,at[0].height);for(let be=0,Ce=at.length;be<Ce;be++)ke=at[be],je?fe&&t.texSubImage2D(r.TEXTURE_2D,be,0,0,ke.width,ke.height,Ee,Re,ke.data):t.texImage2D(r.TEXTURE_2D,be,De,ke.width,ke.height,0,Ee,Re,ke.data);L.generateMipmaps=!1}else je?(Ke&&t.texStorage2D(r.TEXTURE_2D,Le,De,de.width,de.height),fe&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,de.width,de.height,Ee,Re,de.data)):t.texImage2D(r.TEXTURE_2D,0,De,de.width,de.height,0,Ee,Re,de.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){je&&Ke&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Le,De,at[0].width,at[0].height,de.depth);for(let be=0,Ce=at.length;be<Ce;be++)if(ke=at[be],L.format!==Pi)if(Ee!==null)if(je){if(fe)if(L.layerUpdates.size>0){let Be=Op(ke.width,ke.height,L.format,L.type);for(let Oe of L.layerUpdates){let rt=ke.data.subarray(Oe*Be/ke.data.BYTES_PER_ELEMENT,(Oe+1)*Be/ke.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,be,0,0,Oe,ke.width,ke.height,1,Ee,rt)}L.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,be,0,0,0,ke.width,ke.height,de.depth,Ee,ke.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,be,De,ke.width,ke.height,de.depth,0,ke.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else je?fe&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,be,0,0,0,ke.width,ke.height,de.depth,Ee,Re,ke.data):t.texImage3D(r.TEXTURE_2D_ARRAY,be,De,ke.width,ke.height,de.depth,0,Ee,Re,ke.data)}else{je&&Ke&&t.texStorage2D(r.TEXTURE_2D,Le,De,at[0].width,at[0].height);for(let be=0,Ce=at.length;be<Ce;be++)ke=at[be],L.format!==Pi?Ee!==null?je?fe&&t.compressedTexSubImage2D(r.TEXTURE_2D,be,0,0,ke.width,ke.height,Ee,ke.data):t.compressedTexImage2D(r.TEXTURE_2D,be,De,ke.width,ke.height,0,ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):je?fe&&t.texSubImage2D(r.TEXTURE_2D,be,0,0,ke.width,ke.height,Ee,Re,ke.data):t.texImage2D(r.TEXTURE_2D,be,De,ke.width,ke.height,0,Ee,Re,ke.data)}else if(L.isDataArrayTexture)if(je){if(Ke&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Le,De,de.width,de.height,de.depth),fe)if(L.layerUpdates.size>0){let be=Op(de.width,de.height,L.format,L.type);for(let Ce of L.layerUpdates){let Be=de.data.subarray(Ce*be/de.data.BYTES_PER_ELEMENT,(Ce+1)*be/de.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,Ce,de.width,de.height,1,Ee,Re,Be)}L.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,de.width,de.height,de.depth,Ee,Re,de.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,De,de.width,de.height,de.depth,0,Ee,Re,de.data);else if(L.isData3DTexture)je?(Ke&&t.texStorage3D(r.TEXTURE_3D,Le,De,de.width,de.height,de.depth),fe&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,de.width,de.height,de.depth,Ee,Re,de.data)):t.texImage3D(r.TEXTURE_3D,0,De,de.width,de.height,de.depth,0,Ee,Re,de.data);else if(L.isFramebufferTexture){if(Ke)if(je)t.texStorage2D(r.TEXTURE_2D,Le,De,de.width,de.height);else{let be=de.width,Ce=de.height;for(let Be=0;Be<Le;Be++)t.texImage2D(r.TEXTURE_2D,Be,De,be,Ce,0,Ee,Re,null),be>>=1,Ce>>=1}}else if(at.length>0){if(je&&Ke){let be=ve(at[0]);t.texStorage2D(r.TEXTURE_2D,Le,De,be.width,be.height)}for(let be=0,Ce=at.length;be<Ce;be++)ke=at[be],je?fe&&t.texSubImage2D(r.TEXTURE_2D,be,0,0,Ee,Re,ke):t.texImage2D(r.TEXTURE_2D,be,De,Ee,Re,ke);L.generateMipmaps=!1}else if(je){if(Ke){let be=ve(de);t.texStorage2D(r.TEXTURE_2D,Le,De,be.width,be.height)}fe&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,Ee,Re,de)}else t.texImage2D(r.TEXTURE_2D,0,De,Ee,Re,de);d(L)&&m(D),ne.__version=Q.version,L.onUpdate&&L.onUpdate(L)}H.__version=L.version}function P(H,L,O){if(L.image.length!==6)return;let D=_e(H,L),z=L.source;t.bindTexture(r.TEXTURE_CUBE_MAP,H.__webglTexture,r.TEXTURE0+O);let Q=n.get(z);if(z.version!==Q.__version||D===!0){t.activeTexture(r.TEXTURE0+O);let ne=mt.getPrimaries(mt.workingColorSpace),oe=L.colorSpace===cs?null:mt.getPrimaries(L.colorSpace),he=L.colorSpace===cs||ne===oe?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,L.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,L.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,he);let ge=L.isCompressedTexture||L.image[0].isCompressedTexture,de=L.image[0]&&L.image[0].isDataTexture,Ee=[];for(let Ce=0;Ce<6;Ce++)!ge&&!de?Ee[Ce]=y(L.image[Ce],!0,i.maxCubemapSize):Ee[Ce]=de?L.image[Ce].image:L.image[Ce],Ee[Ce]=$(L,Ee[Ce]);let Re=Ee[0],De=s.convert(L.format,L.colorSpace),ke=s.convert(L.type),at=v(L.internalFormat,De,ke,L.colorSpace),je=L.isVideoTexture!==!0,Ke=Q.__version===void 0||D===!0,fe=z.dataReady,Le=S(L,Re);Ae(r.TEXTURE_CUBE_MAP,L);let be;if(ge){je&&Ke&&t.texStorage2D(r.TEXTURE_CUBE_MAP,Le,at,Re.width,Re.height);for(let Ce=0;Ce<6;Ce++){be=Ee[Ce].mipmaps;for(let Be=0;Be<be.length;Be++){let Oe=be[Be];L.format!==Pi?De!==null?je?fe&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Be,0,0,Oe.width,Oe.height,De,Oe.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Be,at,Oe.width,Oe.height,0,Oe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):je?fe&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Be,0,0,Oe.width,Oe.height,De,ke,Oe.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Be,at,Oe.width,Oe.height,0,De,ke,Oe.data)}}}else{if(be=L.mipmaps,je&&Ke){be.length>0&&Le++;let Ce=ve(Ee[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,Le,at,Ce.width,Ce.height)}for(let Ce=0;Ce<6;Ce++)if(de){je?fe&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,Ee[Ce].width,Ee[Ce].height,De,ke,Ee[Ce].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,at,Ee[Ce].width,Ee[Ce].height,0,De,ke,Ee[Ce].data);for(let Be=0;Be<be.length;Be++){let rt=be[Be].image[Ce].image;je?fe&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Be+1,0,0,rt.width,rt.height,De,ke,rt.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Be+1,at,rt.width,rt.height,0,De,ke,rt.data)}}else{je?fe&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,De,ke,Ee[Ce]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,at,De,ke,Ee[Ce]);for(let Be=0;Be<be.length;Be++){let Oe=be[Be];je?fe&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Be+1,0,0,De,ke,Oe.image[Ce]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Be+1,at,De,ke,Oe.image[Ce])}}}d(L)&&m(r.TEXTURE_CUBE_MAP),Q.__version=z.version,L.onUpdate&&L.onUpdate(L)}H.__version=L.version}function M(H,L,O,D,z,Q){let ne=s.convert(O.format,O.colorSpace),oe=s.convert(O.type),he=v(O.internalFormat,ne,oe,O.colorSpace),ge=n.get(L),de=n.get(O);if(de.__renderTarget=L,!ge.__hasExternalTextures){let Ee=Math.max(1,L.width>>Q),Re=Math.max(1,L.height>>Q);z===r.TEXTURE_3D||z===r.TEXTURE_2D_ARRAY?t.texImage3D(z,Q,he,Ee,Re,L.depth,0,ne,oe,null):t.texImage2D(z,Q,he,Ee,Re,0,ne,oe,null)}t.bindFramebuffer(r.FRAMEBUFFER,H),ue(L)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,D,z,de.__webglTexture,0,pe(L)):(z===r.TEXTURE_2D||z>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&z<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,D,z,de.__webglTexture,Q),t.bindFramebuffer(r.FRAMEBUFFER,null)}function T(H,L,O){if(r.bindRenderbuffer(r.RENDERBUFFER,H),L.depthBuffer){let D=L.depthTexture,z=D&&D.isDepthTexture?D.type:null,Q=x(L.stencilBuffer,z),ne=L.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,oe=pe(L);ue(L)?a.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,oe,Q,L.width,L.height):O?r.renderbufferStorageMultisample(r.RENDERBUFFER,oe,Q,L.width,L.height):r.renderbufferStorage(r.RENDERBUFFER,Q,L.width,L.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,ne,r.RENDERBUFFER,H)}else{let D=L.textures;for(let z=0;z<D.length;z++){let Q=D[z],ne=s.convert(Q.format,Q.colorSpace),oe=s.convert(Q.type),he=v(Q.internalFormat,ne,oe,Q.colorSpace),ge=pe(L);O&&ue(L)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,ge,he,L.width,L.height):ue(L)?a.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,ge,he,L.width,L.height):r.renderbufferStorage(r.RENDERBUFFER,he,L.width,L.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function k(H,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,H),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let D=n.get(L.depthTexture);D.__renderTarget=L,(!D.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),ie(L.depthTexture,0);let z=D.__webglTexture,Q=pe(L);if(L.depthTexture.format===Sa)ue(L)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,z,0,Q):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,z,0);else if(L.depthTexture.format===Va)ue(L)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,z,0,Q):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,z,0);else throw new Error("Unknown depthTexture format")}function j(H){let L=n.get(H),O=H.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==H.depthTexture){let D=H.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),D){let z=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,D.removeEventListener("dispose",z)};D.addEventListener("dispose",z),L.__depthDisposeCallback=z}L.__boundDepthTexture=D}if(H.depthTexture&&!L.__autoAllocateDepthBuffer){if(O)throw new Error("target.depthTexture not supported in Cube render targets");let D=H.texture.mipmaps;D&&D.length>0?k(L.__webglFramebuffer[0],H):k(L.__webglFramebuffer,H)}else if(O){L.__webglDepthbuffer=[];for(let D=0;D<6;D++)if(t.bindFramebuffer(r.FRAMEBUFFER,L.__webglFramebuffer[D]),L.__webglDepthbuffer[D]===void 0)L.__webglDepthbuffer[D]=r.createRenderbuffer(),T(L.__webglDepthbuffer[D],H,!1);else{let z=H.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Q=L.__webglDepthbuffer[D];r.bindRenderbuffer(r.RENDERBUFFER,Q),r.framebufferRenderbuffer(r.FRAMEBUFFER,z,r.RENDERBUFFER,Q)}}else{let D=H.texture.mipmaps;if(D&&D.length>0?t.bindFramebuffer(r.FRAMEBUFFER,L.__webglFramebuffer[0]):t.bindFramebuffer(r.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=r.createRenderbuffer(),T(L.__webglDepthbuffer,H,!1);else{let z=H.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Q=L.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,Q),r.framebufferRenderbuffer(r.FRAMEBUFFER,z,r.RENDERBUFFER,Q)}}t.bindFramebuffer(r.FRAMEBUFFER,null)}function W(H,L,O){let D=n.get(H);L!==void 0&&M(D.__webglFramebuffer,H,H.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),O!==void 0&&j(H)}function re(H){let L=H.texture,O=n.get(H),D=n.get(L);H.addEventListener("dispose",A);let z=H.textures,Q=H.isWebGLCubeRenderTarget===!0,ne=z.length>1;if(ne||(D.__webglTexture===void 0&&(D.__webglTexture=r.createTexture()),D.__version=L.version,o.memory.textures++),Q){O.__webglFramebuffer=[];for(let oe=0;oe<6;oe++)if(L.mipmaps&&L.mipmaps.length>0){O.__webglFramebuffer[oe]=[];for(let he=0;he<L.mipmaps.length;he++)O.__webglFramebuffer[oe][he]=r.createFramebuffer()}else O.__webglFramebuffer[oe]=r.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){O.__webglFramebuffer=[];for(let oe=0;oe<L.mipmaps.length;oe++)O.__webglFramebuffer[oe]=r.createFramebuffer()}else O.__webglFramebuffer=r.createFramebuffer();if(ne)for(let oe=0,he=z.length;oe<he;oe++){let ge=n.get(z[oe]);ge.__webglTexture===void 0&&(ge.__webglTexture=r.createTexture(),o.memory.textures++)}if(H.samples>0&&ue(H)===!1){O.__webglMultisampledFramebuffer=r.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let oe=0;oe<z.length;oe++){let he=z[oe];O.__webglColorRenderbuffer[oe]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,O.__webglColorRenderbuffer[oe]);let ge=s.convert(he.format,he.colorSpace),de=s.convert(he.type),Ee=v(he.internalFormat,ge,de,he.colorSpace,H.isXRRenderTarget===!0),Re=pe(H);r.renderbufferStorageMultisample(r.RENDERBUFFER,Re,Ee,H.width,H.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+oe,r.RENDERBUFFER,O.__webglColorRenderbuffer[oe])}r.bindRenderbuffer(r.RENDERBUFFER,null),H.depthBuffer&&(O.__webglDepthRenderbuffer=r.createRenderbuffer(),T(O.__webglDepthRenderbuffer,H,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(Q){t.bindTexture(r.TEXTURE_CUBE_MAP,D.__webglTexture),Ae(r.TEXTURE_CUBE_MAP,L);for(let oe=0;oe<6;oe++)if(L.mipmaps&&L.mipmaps.length>0)for(let he=0;he<L.mipmaps.length;he++)M(O.__webglFramebuffer[oe][he],H,L,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+oe,he);else M(O.__webglFramebuffer[oe],H,L,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0);d(L)&&m(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ne){for(let oe=0,he=z.length;oe<he;oe++){let ge=z[oe],de=n.get(ge);t.bindTexture(r.TEXTURE_2D,de.__webglTexture),Ae(r.TEXTURE_2D,ge),M(O.__webglFramebuffer,H,ge,r.COLOR_ATTACHMENT0+oe,r.TEXTURE_2D,0),d(ge)&&m(r.TEXTURE_2D)}t.unbindTexture()}else{let oe=r.TEXTURE_2D;if((H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(oe=H.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(oe,D.__webglTexture),Ae(oe,L),L.mipmaps&&L.mipmaps.length>0)for(let he=0;he<L.mipmaps.length;he++)M(O.__webglFramebuffer[he],H,L,r.COLOR_ATTACHMENT0,oe,he);else M(O.__webglFramebuffer,H,L,r.COLOR_ATTACHMENT0,oe,0);d(L)&&m(oe),t.unbindTexture()}H.depthBuffer&&j(H)}function ce(H){let L=H.textures;for(let O=0,D=L.length;O<D;O++){let z=L[O];if(d(z)){let Q=_(H),ne=n.get(z).__webglTexture;t.bindTexture(Q,ne),m(Q),t.unbindTexture()}}}let me=[],w=[];function ae(H){if(H.samples>0){if(ue(H)===!1){let L=H.textures,O=H.width,D=H.height,z=r.COLOR_BUFFER_BIT,Q=H.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ne=n.get(H),oe=L.length>1;if(oe)for(let ge=0;ge<L.length;ge++)t.bindFramebuffer(r.FRAMEBUFFER,ne.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,ne.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,ne.__webglMultisampledFramebuffer);let he=H.texture.mipmaps;he&&he.length>0?t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ne.__webglFramebuffer[0]):t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ne.__webglFramebuffer);for(let ge=0;ge<L.length;ge++){if(H.resolveDepthBuffer&&(H.depthBuffer&&(z|=r.DEPTH_BUFFER_BIT),H.stencilBuffer&&H.resolveStencilBuffer&&(z|=r.STENCIL_BUFFER_BIT)),oe){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,ne.__webglColorRenderbuffer[ge]);let de=n.get(L[ge]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,de,0)}r.blitFramebuffer(0,0,O,D,0,0,O,D,z,r.NEAREST),l===!0&&(me.length=0,w.length=0,me.push(r.COLOR_ATTACHMENT0+ge),H.depthBuffer&&H.resolveDepthBuffer===!1&&(me.push(Q),w.push(Q),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,w)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,me))}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),oe)for(let ge=0;ge<L.length;ge++){t.bindFramebuffer(r.FRAMEBUFFER,ne.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.RENDERBUFFER,ne.__webglColorRenderbuffer[ge]);let de=n.get(L[ge]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,ne.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.TEXTURE_2D,de,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ne.__webglMultisampledFramebuffer)}else if(H.depthBuffer&&H.resolveDepthBuffer===!1&&l){let L=H.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[L])}}}function pe(H){return Math.min(i.maxSamples,H.samples)}function ue(H){let L=n.get(H);return H.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function ee(H){let L=o.render.frame;u.get(H)!==L&&(u.set(H,L),H.update())}function $(H,L){let O=H.colorSpace,D=H.format,z=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||O!==Ci&&O!==cs&&(mt.getTransfer(O)===Kt?(D!==Pi||z!==lr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",O)),L}function ve(H){return typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement?(c.width=H.naturalWidth||H.width,c.height=H.naturalHeight||H.height):typeof VideoFrame<"u"&&H instanceof VideoFrame?(c.width=H.displayWidth,c.height=H.displayHeight):(c.width=H.width,c.height=H.height),c}this.allocateTextureUnit=B,this.resetTextureUnits=N,this.setTexture2D=ie,this.setTexture2DArray=Y,this.setTexture3D=te,this.setTextureCube=q,this.rebindTextures=W,this.setupRenderTarget=re,this.updateRenderTargetMipmap=ce,this.updateMultisampleRenderTarget=ae,this.setupDepthRenderbuffer=j,this.setupFrameBufferTexture=M,this.useMultisampledRTT=ue}function Fb(r,e){function t(n,i=cs){let s,o=mt.getTransfer(i);if(n===lr)return r.UNSIGNED_BYTE;if(n===Xh)return r.UNSIGNED_SHORT_4_4_4_4;if(n===qh)return r.UNSIGNED_SHORT_5_5_5_1;if(n===_p)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===xp)return r.BYTE;if(n===vp)return r.SHORT;if(n===ka)return r.UNSIGNED_SHORT;if(n===Wh)return r.INT;if(n===Ls)return r.UNSIGNED_INT;if(n===cr)return r.FLOAT;if(n===Ba)return r.HALF_FLOAT;if(n===Tp)return r.ALPHA;if(n===Mp)return r.RGB;if(n===Pi)return r.RGBA;if(n===Sa)return r.DEPTH_COMPONENT;if(n===Va)return r.DEPTH_STENCIL;if(n===Ep)return r.RED;if(n===jh)return r.RED_INTEGER;if(n===bp)return r.RG;if(n===Yh)return r.RG_INTEGER;if(n===Kh)return r.RGBA_INTEGER;if(n===Cc||n===Ic||n===Rc||n===Pc)if(o===Kt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Cc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ic)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Rc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Pc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Cc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ic)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Rc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Pc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Zh||n===Jh||n===$h||n===Qh)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Zh)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Jh)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===$h)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Qh)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ef||n===tf||n===nf)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ef||n===tf)return o===Kt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===nf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===rf||n===sf||n===of||n===af||n===lf||n===cf||n===uf||n===hf||n===ff||n===df||n===pf||n===mf||n===gf||n===yf)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===rf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===sf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===of)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===af)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===lf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===cf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===uf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===hf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ff)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===df)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===pf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===mf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===gf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===yf)return o===Kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Nc||n===xf||n===vf)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Nc)return o===Kt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===xf)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===vf)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Sp||n===_f||n===Tf||n===Mf)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Nc)return s.COMPRESSED_RED_RGTC1_EXT;if(n===_f)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Tf)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Mf)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ga?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:t}}var Ub=`
void main() {
gl_Position = vec4( position, 1.0 );
-}`,jE=`
+}`,kb=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
}
-}`,sd=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){let i=new Dn,s=e.properties.get(i);s.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}render(e,t){if(this.texture!==null){if(this.mesh===null){let n=t.cameras[0].viewport,i=new mr({vertexShader:XE,fragmentShader:jE,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Pt(new va(20,20),i)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},od=class extends ps{constructor(e,t){super();let n=this,i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,f=null,p=null,g=null,v=new sd,d=t.getContextAttributes(),m=null,_=null,y=[],x=[],w=new Ce,I=null,C=new en;C.layers.enable(1),C.viewport=new Ct;let P=new en;P.layers.enable(2),P.viewport=new Ct;let E=[C,P],M=new rd;M.layers.enable(1),M.layers.enable(2);let L=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(R){let T=y[R];return T===void 0&&(T=new Ll,y[R]=T),T.getTargetRaySpace()},this.getControllerGrip=function(R){let T=y[R];return T===void 0&&(T=new Ll,y[R]=T),T.getGripSpace()},this.getHand=function(R){let T=y[R];return T===void 0&&(T=new Ll,y[R]=T),T.getHandSpace()};function O(R){let T=x.indexOf(R.inputSource);if(T===-1)return;let S=y[T];S!==void 0&&(S.update(R.inputSource,R.frame,c||o),S.dispatchEvent({type:R.type,data:R.inputSource}))}function B(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",B),i.removeEventListener("inputsourceschange",ie);for(let R=0;R<y.length;R++){let T=x[R];T!==null&&(x[R]=null,y[R].disconnect(T))}L=null,N=null,v.reset(),e.setRenderTarget(m),p=null,f=null,h=null,i=null,_=null,ve.stop(),n.isPresenting=!1,e.setPixelRatio(I),e.setSize(w.width,w.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(R){s=R,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(R){a=R,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(R){c=R},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(R){if(i=R,i!==null){if(m=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",B),i.addEventListener("inputsourceschange",ie),d.xrCompatible!==!0&&await t.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(w),i.renderState.layers===void 0){let T={antialias:d.antialias,alpha:!0,depth:d.depth,stencil:d.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,t,T),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),_=new Hr(p.framebufferWidth,p.framebufferHeight,{format:Xi,type:fs,colorSpace:e.outputColorSpace,stencilBuffer:d.stencil})}else{let T=null,S=null,b=null;d.depth&&(b=d.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,T=d.stencil?Ul:sa,S=d.stencil?Zl:fa);let V={colorFormat:t.RGBA8,depthFormat:b,scaleFactor:s};h=new XRWebGLBinding(i,t),f=h.createProjectionLayer(V),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),_=new Hr(f.textureWidth,f.textureHeight,{format:Xi,type:fs,depthTexture:new Wu(f.textureWidth,f.textureHeight,S,void 0,void 0,void 0,void 0,void 0,void 0,T),stencilBuffer:d.stencil,colorSpace:e.outputColorSpace,samples:d.antialias?4:0});let q=e.properties.get(_);q.__ignoreDepthValues=f.ignoreDepthValues}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),ve.setContext(i),ve.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function ie(R){for(let T=0;T<R.removed.length;T++){let S=R.removed[T],b=x.indexOf(S);b>=0&&(x[b]=null,y[b].disconnect(S))}for(let T=0;T<R.added.length;T++){let S=R.added[T],b=x.indexOf(S);if(b===-1){for(let q=0;q<y.length;q++)if(q>=x.length){x.push(S),b=q;break}else if(x[q]===null){x[q]=S,b=q;break}if(b===-1)break}let V=y[b];V&&V.connect(S)}}let $=new oe,te=new oe;function W(R,T,S){$.setFromMatrixPosition(T.matrixWorld),te.setFromMatrixPosition(S.matrixWorld);let b=$.distanceTo(te),V=T.projectionMatrix.elements,q=S.projectionMatrix.elements,Y=V[14]/(V[10]-1),z=V[14]/(V[10]+1),X=(V[9]+1)/V[5],se=(V[9]-1)/V[5],re=(V[8]-1)/V[0],le=(q[8]+1)/q[0],xe=Y*re,G=Y*le,A=b/(-re+le),U=A*-re;T.matrixWorld.decompose(R.position,R.quaternion,R.scale),R.translateX(U),R.translateZ(A),R.matrixWorld.compose(R.position,R.quaternion,R.scale),R.matrixWorldInverse.copy(R.matrixWorld).invert();let he=Y+A,me=z+A,Te=xe-U,ee=G+(b-U),k=X*z/me*he,J=se*z/me*he;R.projectionMatrix.makePerspective(Te,ee,k,J,he,me),R.projectionMatrixInverse.copy(R.projectionMatrix).invert()}function ae(R,T){T===null?R.matrixWorld.copy(R.matrix):R.matrixWorld.multiplyMatrices(T.matrixWorld,R.matrix),R.matrixWorldInverse.copy(R.matrixWorld).invert()}this.updateCamera=function(R){if(i===null)return;v.texture!==null&&(R.near=v.depthNear,R.far=v.depthFar),M.near=P.near=C.near=R.near,M.far=P.far=C.far=R.far,(L!==M.near||N!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),L=M.near,N=M.far,C.near=L,C.far=N,P.near=L,P.far=N,C.updateProjectionMatrix(),P.updateProjectionMatrix(),R.updateProjectionMatrix());let T=R.parent,S=M.cameras;ae(M,T);for(let b=0;b<S.length;b++)ae(S[b],T);S.length===2?W(M,C,P):M.projectionMatrix.copy(C.projectionMatrix),de(R,M,T)};function de(R,T,S){S===null?R.matrix.copy(T.matrixWorld):(R.matrix.copy(S.matrixWorld),R.matrix.invert(),R.matrix.multiply(T.matrixWorld)),R.matrix.decompose(R.position,R.quaternion,R.scale),R.updateMatrixWorld(!0),R.projectionMatrix.copy(T.projectionMatrix),R.projectionMatrixInverse.copy(T.projectionMatrixInverse),R.isPerspectiveCamera&&(R.fov=da*2*Math.atan(1/R.projectionMatrix.elements[5]),R.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(f===null&&p===null))return l},this.setFoveation=function(R){l=R,f!==null&&(f.fixedFoveation=R),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=R)},this.hasDepthSensing=function(){return v.texture!==null};let ye=null;function Me(R,T){if(u=T.getViewerPose(c||o),g=T,u!==null){let S=u.views;p!==null&&(e.setRenderTargetFramebuffer(_,p.framebuffer),e.setRenderTarget(_));let b=!1;S.length!==M.cameras.length&&(M.cameras.length=0,b=!0);for(let q=0;q<S.length;q++){let Y=S[q],z=null;if(p!==null)z=p.getViewport(Y);else{let se=h.getViewSubImage(f,Y);z=se.viewport,q===0&&(e.setRenderTargetTextures(_,se.colorTexture,f.ignoreDepthValues?void 0:se.depthStencilTexture),e.setRenderTarget(_))}let X=E[q];X===void 0&&(X=new en,X.layers.enable(q),X.viewport=new Ct,E[q]=X),X.matrix.fromArray(Y.transform.matrix),X.matrix.decompose(X.position,X.quaternion,X.scale),X.projectionMatrix.fromArray(Y.projectionMatrix),X.projectionMatrixInverse.copy(X.projectionMatrix).invert(),X.viewport.set(z.x,z.y,z.width,z.height),q===0&&(M.matrix.copy(X.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),b===!0&&M.cameras.push(X)}let V=i.enabledFeatures;if(V&&V.includes("depth-sensing")){let q=h.getDepthInformation(S[0]);q&&q.isValid&&q.texture&&v.init(e,q,i.renderState)}}for(let S=0;S<y.length;S++){let b=x[S],V=y[S];b!==null&&V!==void 0&&V.update(b,T,c||o)}v.render(e,M),ye&&ye(R,T),T.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:T}),g=null}let ve=new m0;ve.setAnimationLoop(Me),this.setAnimationLoop=function(R){ye=R},this.dispose=function(){}}},Ws=new hn,qE=new Ye;function YE(r,e){function t(d,m){d.matrixAutoUpdate===!0&&d.updateMatrix(),m.value.copy(d.matrix)}function n(d,m){m.color.getRGB(d.fogColor.value,p0(r)),m.isFog?(d.fogNear.value=m.near,d.fogFar.value=m.far):m.isFogExp2&&(d.fogDensity.value=m.density)}function i(d,m,_,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(d,m):m.isMeshToonMaterial?(s(d,m),h(d,m)):m.isMeshPhongMaterial?(s(d,m),u(d,m)):m.isMeshStandardMaterial?(s(d,m),f(d,m),m.isMeshPhysicalMaterial&&p(d,m,x)):m.isMeshMatcapMaterial?(s(d,m),g(d,m)):m.isMeshDepthMaterial?s(d,m):m.isMeshDistanceMaterial?(s(d,m),v(d,m)):m.isMeshNormalMaterial?s(d,m):m.isLineBasicMaterial?(o(d,m),m.isLineDashedMaterial&&a(d,m)):m.isPointsMaterial?l(d,m,_,y):m.isSpriteMaterial?c(d,m):m.isShadowMaterial?(d.color.value.copy(m.color),d.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(d,m){d.opacity.value=m.opacity,m.color&&d.diffuse.value.copy(m.color),m.emissive&&d.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(d.map.value=m.map,t(m.map,d.mapTransform)),m.alphaMap&&(d.alphaMap.value=m.alphaMap,t(m.alphaMap,d.alphaMapTransform)),m.bumpMap&&(d.bumpMap.value=m.bumpMap,t(m.bumpMap,d.bumpMapTransform),d.bumpScale.value=m.bumpScale,m.side===Tn&&(d.bumpScale.value*=-1)),m.normalMap&&(d.normalMap.value=m.normalMap,t(m.normalMap,d.normalMapTransform),d.normalScale.value.copy(m.normalScale),m.side===Tn&&d.normalScale.value.negate()),m.displacementMap&&(d.displacementMap.value=m.displacementMap,t(m.displacementMap,d.displacementMapTransform),d.displacementScale.value=m.displacementScale,d.displacementBias.value=m.displacementBias),m.emissiveMap&&(d.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,d.emissiveMapTransform)),m.specularMap&&(d.specularMap.value=m.specularMap,t(m.specularMap,d.specularMapTransform)),m.alphaTest>0&&(d.alphaTest.value=m.alphaTest);let _=e.get(m),y=_.envMap,x=_.envMapRotation;if(y&&(d.envMap.value=y,Ws.copy(x),Ws.x*=-1,Ws.y*=-1,Ws.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Ws.y*=-1,Ws.z*=-1),d.envMapRotation.value.setFromMatrix4(qE.makeRotationFromEuler(Ws)),d.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,d.reflectivity.value=m.reflectivity,d.ior.value=m.ior,d.refractionRatio.value=m.refractionRatio),m.lightMap){d.lightMap.value=m.lightMap;let w=r._useLegacyLights===!0?Math.PI:1;d.lightMapIntensity.value=m.lightMapIntensity*w,t(m.lightMap,d.lightMapTransform)}m.aoMap&&(d.aoMap.value=m.aoMap,d.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,d.aoMapTransform))}function o(d,m){d.diffuse.value.copy(m.color),d.opacity.value=m.opacity,m.map&&(d.map.value=m.map,t(m.map,d.mapTransform))}function a(d,m){d.dashSize.value=m.dashSize,d.totalSize.value=m.dashSize+m.gapSize,d.scale.value=m.scale}function l(d,m,_,y){d.diffuse.value.copy(m.color),d.opacity.value=m.opacity,d.size.value=m.size*_,d.scale.value=y*.5,m.map&&(d.map.value=m.map,t(m.map,d.uvTransform)),m.alphaMap&&(d.alphaMap.value=m.alphaMap,t(m.alphaMap,d.alphaMapTransform)),m.alphaTest>0&&(d.alphaTest.value=m.alphaTest)}function c(d,m){d.diffuse.value.copy(m.color),d.opacity.value=m.opacity,d.rotation.value=m.rotation,m.map&&(d.map.value=m.map,t(m.map,d.mapTransform)),m.alphaMap&&(d.alphaMap.value=m.alphaMap,t(m.alphaMap,d.alphaMapTransform)),m.alphaTest>0&&(d.alphaTest.value=m.alphaTest)}function u(d,m){d.specular.value.copy(m.specular),d.shininess.value=Math.max(m.shininess,1e-4)}function h(d,m){m.gradientMap&&(d.gradientMap.value=m.gradientMap)}function f(d,m){d.metalness.value=m.metalness,m.metalnessMap&&(d.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,d.metalnessMapTransform)),d.roughness.value=m.roughness,m.roughnessMap&&(d.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,d.roughnessMapTransform)),m.envMap&&(d.envMapIntensity.value=m.envMapIntensity)}function p(d,m,_){d.ior.value=m.ior,m.sheen>0&&(d.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),d.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(d.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,d.sheenColorMapTransform)),m.sheenRoughnessMap&&(d.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,d.sheenRoughnessMapTransform))),m.clearcoat>0&&(d.clearcoat.value=m.clearcoat,d.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(d.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,d.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(d.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,d.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(d.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,d.clearcoatNormalMapTransform),d.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Tn&&d.clearcoatNormalScale.value.negate())),m.iridescence>0&&(d.iridescence.value=m.iridescence,d.iridescenceIOR.value=m.iridescenceIOR,d.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],d.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(d.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,d.iridescenceMapTransform)),m.iridescenceThicknessMap&&(d.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,d.iridescenceThicknessMapTransform))),m.transmission>0&&(d.transmission.value=m.transmission,d.transmissionSamplerMap.value=_.texture,d.transmissionSamplerSize.value.set(_.width,_.height),m.transmissionMap&&(d.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,d.transmissionMapTransform)),d.thickness.value=m.thickness,m.thicknessMap&&(d.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,d.thicknessMapTransform)),d.attenuationDistance.value=m.attenuationDistance,d.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(d.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(d.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,d.anisotropyMapTransform))),d.specularIntensity.value=m.specularIntensity,d.specularColor.value.copy(m.specularColor),m.specularColorMap&&(d.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,d.specularColorMapTransform)),m.specularIntensityMap&&(d.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,d.specularIntensityMapTransform))}function g(d,m){m.matcap&&(d.matcap.value=m.matcap)}function v(d,m){let _=e.get(m).light;d.referencePosition.value.setFromMatrixPosition(_.matrixWorld),d.nearDistance.value=_.shadow.camera.near,d.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function KE(r,e,t,n){let i={},s={},o=[],a=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(_,y){let x=y.program;n.uniformBlockBinding(_,x)}function c(_,y){let x=i[_.id];x===void 0&&(g(_),x=u(_),i[_.id]=x,_.addEventListener("dispose",d));let w=y.program;n.updateUBOMapping(_,w);let I=e.render.frame;s[_.id]!==I&&(f(_),s[_.id]=I)}function u(_){let y=h();_.__bindingPointIndex=y;let x=r.createBuffer(),w=_.__size,I=_.usage;return r.bindBuffer(r.UNIFORM_BUFFER,x),r.bufferData(r.UNIFORM_BUFFER,w,I),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,y,x),x}function h(){for(let _=0;_<a;_++)if(o.indexOf(_)===-1)return o.push(_),_;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(_){let y=i[_.id],x=_.uniforms,w=_.__cache;r.bindBuffer(r.UNIFORM_BUFFER,y);for(let I=0,C=x.length;I<C;I++){let P=Array.isArray(x[I])?x[I]:[x[I]];for(let E=0,M=P.length;E<M;E++){let L=P[E];if(p(L,I,E,w)===!0){let N=L.__offset,O=Array.isArray(L.value)?L.value:[L.value],B=0;for(let ie=0;ie<O.length;ie++){let $=O[ie],te=v($);typeof $=="number"||typeof $=="boolean"?(L.__data[0]=$,r.bufferSubData(r.UNIFORM_BUFFER,N+B,L.__data)):$.isMatrix3?(L.__data[0]=$.elements[0],L.__data[1]=$.elements[1],L.__data[2]=$.elements[2],L.__data[3]=0,L.__data[4]=$.elements[3],L.__data[5]=$.elements[4],L.__data[6]=$.elements[5],L.__data[7]=0,L.__data[8]=$.elements[6],L.__data[9]=$.elements[7],L.__data[10]=$.elements[8],L.__data[11]=0):($.toArray(L.__data,B),B+=te.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,N,L.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function p(_,y,x,w){let I=_.value,C=y+"_"+x;if(w[C]===void 0)return typeof I=="number"||typeof I=="boolean"?w[C]=I:w[C]=I.clone(),!0;{let P=w[C];if(typeof I=="number"||typeof I=="boolean"){if(P!==I)return w[C]=I,!0}else if(P.equals(I)===!1)return P.copy(I),!0}return!1}function g(_){let y=_.uniforms,x=0,w=16;for(let C=0,P=y.length;C<P;C++){let E=Array.isArray(y[C])?y[C]:[y[C]];for(let M=0,L=E.length;M<L;M++){let N=E[M],O=Array.isArray(N.value)?N.value:[N.value];for(let B=0,ie=O.length;B<ie;B++){let $=O[B],te=v($),W=x%w;W!==0&&w-W<te.boundary&&(x+=w-W),N.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=x,x+=te.storage}}}let I=x%w;return I>0&&(x+=w-I),_.__size=x,_.__cache={},this}function v(_){let y={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(y.boundary=4,y.storage=4):_.isVector2?(y.boundary=8,y.storage=8):_.isVector3||_.isColor?(y.boundary=16,y.storage=12):_.isVector4?(y.boundary=16,y.storage=16):_.isMatrix3?(y.boundary=48,y.storage=48):_.isMatrix4?(y.boundary=64,y.storage=64):_.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",_),y}function d(_){let y=_.target;y.removeEventListener("dispose",d);let x=o.indexOf(y.__bindingPointIndex);o.splice(x,1),r.deleteBuffer(i[y.id]),delete i[y.id],delete s[y.id]}function m(){for(let _ in i)r.deleteBuffer(i[_]);o=[],i={},s={}}return{bind:l,update:c,dispose:m}}var ya=class{constructor(e={}){let{canvas:t=nx(),context:n=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=o;let p=new Uint32Array(4),g=new Int32Array(4),v=null,d=null,m=[],_=[];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=jt,this._useLegacyLights=!1,this.toneMapping=hs,this.toneMappingExposure=1;let y=this,x=!1,w=0,I=0,C=null,P=-1,E=null,M=new Ct,L=new Ct,N=null,O=new Ve(0),B=0,ie=t.width,$=t.height,te=1,W=null,ae=null,de=new Ct(0,0,ie,$),ye=new Ct(0,0,ie,$),Me=!1,ve=new Vl,R=!1,T=!1,S=new Ye,b=new Ce,V=new oe,q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return C===null?te:1}let z=n;function X(Q,_e){let Se=t.getContext(Q,_e);return Se!==null?Se:null}try{let Q={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${wd}`),t.addEventListener("webglcontextlost",Pe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Ue,!1),z===null){let _e="webgl2";if(z=X(_e,Q),z===null)throw X(_e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(Q){throw console.error("THREE.WebGLRenderer: "+Q.message),Q}let se,re,le,xe,G,A,U,he,me,Te,ee,k,J,ue,Z,ce,pe,fe,ge,Ae,Ie,Fe,Je,dt;function Oe(){se=new pM(z),se.init(),re=new lM(z,se,e),Fe=new HE(z,se),le=new VE(z),xe=new vM(z),G=new RE,A=new zE(z,se,le,G,re,Fe,xe),U=new uM(y),he=new dM(y),me=new Ex(z),Je=new oM(z,me),Te=new mM(z,me,xe,Je),ee=new xM(z,Te,me,xe),ge=new yM(z,re,A),ce=new cM(G),k=new CE(y,U,he,se,re,Je,ce),J=new YE(y,G),ue=new PE,Z=new UE(se),fe=new sM(y,U,he,le,ee,f,l),pe=new GE(y,ee,re),dt=new KE(z,xe,re,le),Ae=new aM(z,se,xe),Ie=new gM(z,se,xe),xe.programs=k.programs,y.capabilities=re,y.extensions=se,y.properties=G,y.renderLists=ue,y.shadowMap=pe,y.state=le,y.info=xe}Oe();let ne=new od(y,z);this.xr=ne,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let Q=se.get("WEBGL_lose_context");Q&&Q.loseContext()},this.forceContextRestore=function(){let Q=se.get("WEBGL_lose_context");Q&&Q.restoreContext()},this.getPixelRatio=function(){return te},this.setPixelRatio=function(Q){Q!==void 0&&(te=Q,this.setSize(ie,$,!1))},this.getSize=function(Q){return Q.set(ie,$)},this.setSize=function(Q,_e,Se=!0){if(ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ie=Q,$=_e,t.width=Math.floor(Q*te),t.height=Math.floor(_e*te),Se===!0&&(t.style.width=Q+"px",t.style.height=_e+"px"),this.setViewport(0,0,Q,_e)},this.getDrawingBufferSize=function(Q){return Q.set(ie*te,$*te).floor()},this.setDrawingBufferSize=function(Q,_e,Se){ie=Q,$=_e,te=Se,t.width=Math.floor(Q*Se),t.height=Math.floor(_e*Se),this.setViewport(0,0,Q,_e)},this.getCurrentViewport=function(Q){return Q.copy(M)},this.getViewport=function(Q){return Q.copy(de)},this.setViewport=function(Q,_e,Se,we){Q.isVector4?de.set(Q.x,Q.y,Q.z,Q.w):de.set(Q,_e,Se,we),le.viewport(M.copy(de).multiplyScalar(te).round())},this.getScissor=function(Q){return Q.copy(ye)},this.setScissor=function(Q,_e,Se,we){Q.isVector4?ye.set(Q.x,Q.y,Q.z,Q.w):ye.set(Q,_e,Se,we),le.scissor(L.copy(ye).multiplyScalar(te).round())},this.getScissorTest=function(){return Me},this.setScissorTest=function(Q){le.setScissorTest(Me=Q)},this.setOpaqueSort=function(Q){W=Q},this.setTransparentSort=function(Q){ae=Q},this.getClearColor=function(Q){return Q.copy(fe.getClearColor())},this.setClearColor=function(){fe.setClearColor.apply(fe,arguments)},this.getClearAlpha=function(){return fe.getClearAlpha()},this.setClearAlpha=function(){fe.setClearAlpha.apply(fe,arguments)},this.clear=function(Q=!0,_e=!0,Se=!0){let we=0;if(Q){let Ee=!1;if(C!==null){let We=C.texture.format;Ee=We===c0||We===l0||We===a0}if(Ee){let We=C.texture.type,st=We===fs||We===fa||We===i0||We===Zl||We===s0||We===o0,et=fe.getClearColor(),lt=fe.getClearAlpha(),mt=et.r,gt=et.g,xt=et.b;st?(p[0]=mt,p[1]=gt,p[2]=xt,p[3]=lt,z.clearBufferuiv(z.COLOR,0,p)):(g[0]=mt,g[1]=gt,g[2]=xt,g[3]=lt,z.clearBufferiv(z.COLOR,0,g))}else we|=z.COLOR_BUFFER_BIT}_e&&(we|=z.DEPTH_BUFFER_BIT),Se&&(we|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.clear(we)},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",Pe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Ue,!1),ue.dispose(),Z.dispose(),G.dispose(),U.dispose(),he.dispose(),ee.dispose(),Je.dispose(),dt.dispose(),k.dispose(),ne.dispose(),ne.removeEventListener("sessionstart",ke),ne.removeEventListener("sessionend",qe),He.stop()};function Pe(Q){Q.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;let Q=xe.autoReset,_e=pe.enabled,Se=pe.autoUpdate,we=pe.needsUpdate,Ee=pe.type;Oe(),xe.autoReset=Q,pe.enabled=_e,pe.autoUpdate=Se,pe.needsUpdate=we,pe.type=Ee}function Ue(Q){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Q.statusMessage)}function De(Q){let _e=Q.target;_e.removeEventListener("dispose",De),ut(_e)}function ut(Q){at(Q),G.remove(Q)}function at(Q){let _e=G.get(Q).programs;_e!==void 0&&(_e.forEach(function(Se){k.releaseProgram(Se)}),Q.isShaderMaterial&&k.releaseShaderCache(Q))}this.renderBufferDirect=function(Q,_e,Se,we,Ee,We){_e===null&&(_e=q);let st=Ee.isMesh&&Ee.matrixWorld.determinant()<0,et=Wh(Q,_e,Se,we,Ee);le.setMaterial(we,st);let lt=Se.index,mt=1;if(we.wireframe===!0){if(lt=Te.getWireframeAttribute(Se),lt===void 0)return;mt=2}let gt=Se.drawRange,xt=Se.attributes.position,tn=gt.start*mt,qn=(gt.start+gt.count)*mt;We!==null&&(tn=Math.max(tn,We.start*mt),qn=Math.min(qn,(We.start+We.count)*mt)),lt!==null?(tn=Math.max(tn,0),qn=Math.min(qn,lt.count)):xt!=null&&(tn=Math.max(tn,0),qn=Math.min(qn,xt.count));let gn=qn-tn;if(gn<0||gn===1/0)return;Je.setup(Ee,we,et,Se,lt);let Di,qt=Ae;if(lt!==null&&(Di=me.get(lt),qt=Ie,qt.setIndex(Di)),Ee.isMesh)we.wireframe===!0?(le.setLineWidth(we.wireframeLinewidth*Y()),qt.setMode(z.LINES)):qt.setMode(z.TRIANGLES);else if(Ee.isLine){let _t=we.linewidth;_t===void 0&&(_t=1),le.setLineWidth(_t*Y()),Ee.isLineSegments?qt.setMode(z.LINES):Ee.isLineLoop?qt.setMode(z.LINE_LOOP):qt.setMode(z.LINE_STRIP)}else Ee.isPoints?qt.setMode(z.POINTS):Ee.isSprite&&qt.setMode(z.TRIANGLES);if(Ee.isBatchedMesh)qt.renderMultiDraw(Ee._multiDrawStarts,Ee._multiDrawCounts,Ee._multiDrawCount);else if(Ee.isInstancedMesh)qt.renderInstances(tn,gn,Ee.count);else if(Se.isInstancedBufferGeometry){let _t=Se._maxInstanceCount!==void 0?Se._maxInstanceCount:1/0,rr=Math.min(Se.instanceCount,_t);qt.renderInstances(tn,gn,rr)}else qt.render(tn,gn)};function yt(Q,_e,Se){Q.transparent===!0&&Q.side===On&&Q.forceSinglePass===!1?(Q.side=Tn,Q.needsUpdate=!0,Oi(Q,_e,Se),Q.side=wi,Q.needsUpdate=!0,Oi(Q,_e,Se),Q.side=On):Oi(Q,_e,Se)}this.compile=function(Q,_e,Se=null){Se===null&&(Se=Q),d=Z.get(Se),d.init(),_.push(d),Se.traverseVisible(function(Ee){Ee.isLight&&Ee.layers.test(_e.layers)&&(d.pushLight(Ee),Ee.castShadow&&d.pushShadow(Ee))}),Q!==Se&&Q.traverseVisible(function(Ee){Ee.isLight&&Ee.layers.test(_e.layers)&&(d.pushLight(Ee),Ee.castShadow&&d.pushShadow(Ee))}),d.setupLights(y._useLegacyLights);let we=new Set;return Q.traverse(function(Ee){let We=Ee.material;if(We)if(Array.isArray(We))for(let st=0;st<We.length;st++){let et=We[st];yt(et,Se,Ee),we.add(et)}else yt(We,Se,Ee),we.add(We)}),_.pop(),d=null,we},this.compileAsync=function(Q,_e,Se=null){let we=this.compile(Q,_e,Se);return new Promise(Ee=>{function We(){if(we.forEach(function(st){G.get(st).currentProgram.isReady()&&we.delete(st)}),we.size===0){Ee(Q);return}setTimeout(We,10)}se.get("KHR_parallel_shader_compile")!==null?We():setTimeout(We,10)})};let wt=null;function Qe(Q){wt&&wt(Q)}function ke(){He.stop()}function qe(){He.start()}let He=new m0;He.setAnimationLoop(Qe),typeof self<"u"&&He.setContext(self),this.setAnimationLoop=function(Q){wt=Q,ne.setAnimationLoop(Q),Q===null?He.stop():He.start()},ne.addEventListener("sessionstart",ke),ne.addEventListener("sessionend",qe),this.render=function(Q,_e){if(_e!==void 0&&_e.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(x===!0)return;Q.matrixWorldAutoUpdate===!0&&Q.updateMatrixWorld(),_e.parent===null&&_e.matrixWorldAutoUpdate===!0&&_e.updateMatrixWorld(),ne.enabled===!0&&ne.isPresenting===!0&&(ne.cameraAutoUpdate===!0&&ne.updateCamera(_e),_e=ne.getCamera()),Q.isScene===!0&&Q.onBeforeRender(y,Q,_e,C),d=Z.get(Q,_.length),d.init(),_.push(d),S.multiplyMatrices(_e.projectionMatrix,_e.matrixWorldInverse),ve.setFromProjectionMatrix(S),T=this.localClippingEnabled,R=ce.init(this.clippingPlanes,T),v=ue.get(Q,m.length),v.init(),m.push(v),tt(Q,_e,0,y.sortObjects),v.finish(),y.sortObjects===!0&&v.sort(W,ae),this.info.render.frame++,R===!0&&ce.beginShadows();let Se=d.state.shadowsArray;if(pe.render(Se,Q,_e),R===!0&&ce.endShadows(),this.info.autoReset===!0&&this.info.reset(),(ne.enabled===!1||ne.isPresenting===!1||ne.hasDepthSensing()===!1)&&fe.render(v,Q),d.setupLights(y._useLegacyLights),_e.isArrayCamera){let we=_e.cameras;for(let Ee=0,We=we.length;Ee<We;Ee++){let st=we[Ee];rt(v,Q,st,st.viewport)}}else rt(v,Q,_e);C!==null&&(A.updateMultisampleRenderTarget(C),A.updateRenderTargetMipmap(C)),Q.isScene===!0&&Q.onAfterRender(y,Q,_e),Je.resetDefaultState(),P=-1,E=null,_.pop(),_.length>0?d=_[_.length-1]:d=null,m.pop(),m.length>0?v=m[m.length-1]:v=null};function tt(Q,_e,Se,we){if(Q.visible===!1)return;if(Q.layers.test(_e.layers)){if(Q.isGroup)Se=Q.renderOrder;else if(Q.isLOD)Q.autoUpdate===!0&&Q.update(_e);else if(Q.isLight)d.pushLight(Q),Q.castShadow&&d.pushShadow(Q);else if(Q.isSprite){if(!Q.frustumCulled||ve.intersectsSprite(Q)){we&&V.setFromMatrixPosition(Q.matrixWorld).applyMatrix4(S);let st=ee.update(Q),et=Q.material;et.visible&&v.push(Q,st,et,Se,V.z,null)}}else if((Q.isMesh||Q.isLine||Q.isPoints)&&(!Q.frustumCulled||ve.intersectsObject(Q))){let st=ee.update(Q),et=Q.material;if(we&&(Q.boundingSphere!==void 0?(Q.boundingSphere===null&&Q.computeBoundingSphere(),V.copy(Q.boundingSphere.center)):(st.boundingSphere===null&&st.computeBoundingSphere(),V.copy(st.boundingSphere.center)),V.applyMatrix4(Q.matrixWorld).applyMatrix4(S)),Array.isArray(et)){let lt=st.groups;for(let mt=0,gt=lt.length;mt<gt;mt++){let xt=lt[mt],tn=et[xt.materialIndex];tn&&tn.visible&&v.push(Q,st,tn,Se,V.z,xt)}}else et.visible&&v.push(Q,st,et,Se,V.z,null)}}let We=Q.children;for(let st=0,et=We.length;st<et;st++)tt(We[st],_e,Se,we)}function rt(Q,_e,Se,we){let Ee=Q.opaque,We=Q.transmissive,st=Q.transparent;d.setupLightsView(Se),R===!0&&ce.setGlobalState(y.clippingPlanes,Se),We.length>0&&Wt(Ee,We,_e,Se),we&&le.viewport(M.copy(we)),Ee.length>0&&jn(Ee,_e,Se),We.length>0&&jn(We,_e,Se),st.length>0&&jn(st,_e,Se),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function Wt(Q,_e,Se,we){if((Se.isScene===!0?Se.overrideMaterial:null)!==null)return;if(d.state.transmissionRenderTarget===null){d.state.transmissionRenderTarget=new Hr(1,1,{generateMipmaps:!0,type:se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float")?Nu:fs,minFilter:vi,samples:4,stencilBuffer:s});let mt=G.get(d.state.transmissionRenderTarget);mt.__isTransmissionRenderTarget=!0}let We=d.state.transmissionRenderTarget;y.getDrawingBufferSize(b),We.setSize(b.x,b.y);let st=y.getRenderTarget();y.setRenderTarget(We),y.getClearColor(O),B=y.getClearAlpha(),B<1&&y.setClearColor(16777215,.5),y.clear();let et=y.toneMapping;y.toneMapping=hs,jn(Q,Se,we),A.updateMultisampleRenderTarget(We),A.updateRenderTargetMipmap(We);let lt=!1;for(let mt=0,gt=_e.length;mt<gt;mt++){let xt=_e[mt],tn=xt.object,qn=xt.geometry,gn=xt.material,Di=xt.group;if(gn.side===On&&tn.layers.test(we.layers)){let qt=gn.side;gn.side=Tn,gn.needsUpdate=!0,fi(tn,Se,we,qn,gn,Di),gn.side=qt,gn.needsUpdate=!0,lt=!0}}lt===!0&&(A.updateMultisampleRenderTarget(We),A.updateRenderTargetMipmap(We)),y.setRenderTarget(st),y.setClearColor(O,B),y.toneMapping=et}function jn(Q,_e,Se){let we=_e.isScene===!0?_e.overrideMaterial:null;for(let Ee=0,We=Q.length;Ee<We;Ee++){let st=Q[Ee],et=st.object,lt=st.geometry,mt=we===null?st.material:we,gt=st.group;et.layers.test(Se.layers)&&fi(et,_e,Se,lt,mt,gt)}}function fi(Q,_e,Se,we,Ee,We){Q.onBeforeRender(y,_e,Se,we,Ee,We),Q.modelViewMatrix.multiplyMatrices(Se.matrixWorldInverse,Q.matrixWorld),Q.normalMatrix.getNormalMatrix(Q.modelViewMatrix),Ee.onBeforeRender(y,_e,Se,we,Q,We),Ee.transparent===!0&&Ee.side===On&&Ee.forceSinglePass===!1?(Ee.side=Tn,Ee.needsUpdate=!0,y.renderBufferDirect(Se,_e,we,Ee,Q,We),Ee.side=wi,Ee.needsUpdate=!0,y.renderBufferDirect(Se,_e,we,Ee,Q,We),Ee.side=On):y.renderBufferDirect(Se,_e,we,Ee,Q,We),Q.onAfterRender(y,_e,Se,we,Ee,We)}function Oi(Q,_e,Se){_e.isScene!==!0&&(_e=q);let we=G.get(Q),Ee=d.state.lights,We=d.state.shadowsArray,st=Ee.state.version,et=k.getParameters(Q,Ee.state,We,_e,Se),lt=k.getProgramCacheKey(et),mt=we.programs;we.environment=Q.isMeshStandardMaterial?_e.environment:null,we.fog=_e.fog,we.envMap=(Q.isMeshStandardMaterial?he:U).get(Q.envMap||we.environment),we.envMapRotation=we.environment!==null&&Q.envMap===null?_e.environmentRotation:Q.envMapRotation,mt===void 0&&(Q.addEventListener("dispose",De),mt=new Map,we.programs=mt);let gt=mt.get(lt);if(gt!==void 0){if(we.currentProgram===gt&&we.lightsStateVersion===st)return ll(Q,et),gt}else et.uniforms=k.getUniforms(Q),Q.onBuild(Se,et,y),Q.onBeforeCompile(et,y),gt=k.acquireProgram(et,lt),mt.set(lt,gt),we.uniforms=et.uniforms;let xt=we.uniforms;return(!Q.isShaderMaterial&&!Q.isRawShaderMaterial||Q.clipping===!0)&&(xt.clippingPlanes=ce.uniform),ll(Q,et),we.needsLights=jh(Q),we.lightsStateVersion=st,we.needsLights&&(xt.ambientLightColor.value=Ee.state.ambient,xt.lightProbe.value=Ee.state.probe,xt.directionalLights.value=Ee.state.directional,xt.directionalLightShadows.value=Ee.state.directionalShadow,xt.spotLights.value=Ee.state.spot,xt.spotLightShadows.value=Ee.state.spotShadow,xt.rectAreaLights.value=Ee.state.rectArea,xt.ltc_1.value=Ee.state.rectAreaLTC1,xt.ltc_2.value=Ee.state.rectAreaLTC2,xt.pointLights.value=Ee.state.point,xt.pointLightShadows.value=Ee.state.pointShadow,xt.hemisphereLights.value=Ee.state.hemi,xt.directionalShadowMap.value=Ee.state.directionalShadowMap,xt.directionalShadowMatrix.value=Ee.state.directionalShadowMatrix,xt.spotShadowMap.value=Ee.state.spotShadowMap,xt.spotLightMatrix.value=Ee.state.spotLightMatrix,xt.spotLightMap.value=Ee.state.spotLightMap,xt.pointShadowMap.value=Ee.state.pointShadowMap,xt.pointShadowMatrix.value=Ee.state.pointShadowMatrix),we.currentProgram=gt,we.uniformsList=null,gt}function _c(Q){if(Q.uniformsList===null){let _e=Q.currentProgram.getUniforms();Q.uniformsList=la.seqWithValue(_e.seq,Q.uniforms)}return Q.uniformsList}function ll(Q,_e){let Se=G.get(Q);Se.outputColorSpace=_e.outputColorSpace,Se.batching=_e.batching,Se.instancing=_e.instancing,Se.instancingColor=_e.instancingColor,Se.instancingMorph=_e.instancingMorph,Se.skinning=_e.skinning,Se.morphTargets=_e.morphTargets,Se.morphNormals=_e.morphNormals,Se.morphColors=_e.morphColors,Se.morphTargetsCount=_e.morphTargetsCount,Se.numClippingPlanes=_e.numClippingPlanes,Se.numIntersection=_e.numClipIntersection,Se.vertexAlphas=_e.vertexAlphas,Se.vertexTangents=_e.vertexTangents,Se.toneMapping=_e.toneMapping}function Wh(Q,_e,Se,we,Ee){_e.isScene!==!0&&(_e=q),A.resetTextureUnits();let We=_e.fog,st=we.isMeshStandardMaterial?_e.environment:null,et=C===null?y.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:li,lt=(we.isMeshStandardMaterial?he:U).get(we.envMap||st),mt=we.vertexColors===!0&&!!Se.attributes.color&&Se.attributes.color.itemSize===4,gt=!!Se.attributes.tangent&&(!!we.normalMap||we.anisotropy>0),xt=!!Se.morphAttributes.position,tn=!!Se.morphAttributes.normal,qn=!!Se.morphAttributes.color,gn=hs;we.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(gn=y.toneMapping);let Di=Se.morphAttributes.position||Se.morphAttributes.normal||Se.morphAttributes.color,qt=Di!==void 0?Di.length:0,_t=G.get(we),rr=d.state.lights;if(R===!0&&(T===!0||Q!==E)){let Nt=Q===E&&we.id===P;ce.setState(we,Q,Nt)}let Yt=!1;we.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==rr.state.version||_t.outputColorSpace!==et||Ee.isBatchedMesh&&_t.batching===!1||!Ee.isBatchedMesh&&_t.batching===!0||Ee.isInstancedMesh&&_t.instancing===!1||!Ee.isInstancedMesh&&_t.instancing===!0||Ee.isSkinnedMesh&&_t.skinning===!1||!Ee.isSkinnedMesh&&_t.skinning===!0||Ee.isInstancedMesh&&_t.instancingColor===!0&&Ee.instanceColor===null||Ee.isInstancedMesh&&_t.instancingColor===!1&&Ee.instanceColor!==null||Ee.isInstancedMesh&&_t.instancingMorph===!0&&Ee.morphTexture===null||Ee.isInstancedMesh&&_t.instancingMorph===!1&&Ee.morphTexture!==null||_t.envMap!==lt||we.fog===!0&&_t.fog!==We||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==ce.numPlanes||_t.numIntersection!==ce.numIntersection)||_t.vertexAlphas!==mt||_t.vertexTangents!==gt||_t.morphTargets!==xt||_t.morphNormals!==tn||_t.morphColors!==qn||_t.toneMapping!==gn||_t.morphTargetsCount!==qt)&&(Yt=!0):(Yt=!0,_t.__version=we.version);let sr=_t.currentProgram;Yt===!0&&(sr=Oi(we,_e,Ee));let Tc=!1,Zr=!1,cl=!1,Cn=sr.getUniforms(),or=_t.uniforms;if(le.useProgram(sr.program)&&(Tc=!0,Zr=!0,cl=!0),we.id!==P&&(P=we.id,Zr=!0),Tc||E!==Q){Cn.setValue(z,"projectionMatrix",Q.projectionMatrix),Cn.setValue(z,"viewMatrix",Q.matrixWorldInverse);let Nt=Cn.map.cameraPosition;Nt!==void 0&&Nt.setValue(z,V.setFromMatrixPosition(Q.matrixWorld)),re.logarithmicDepthBuffer&&Cn.setValue(z,"logDepthBufFC",2/(Math.log(Q.far+1)/Math.LN2)),(we.isMeshPhongMaterial||we.isMeshToonMaterial||we.isMeshLambertMaterial||we.isMeshBasicMaterial||we.isMeshStandardMaterial||we.isShaderMaterial)&&Cn.setValue(z,"isOrthographic",Q.isOrthographicCamera===!0),E!==Q&&(E=Q,Zr=!0,cl=!0)}if(Ee.isSkinnedMesh){Cn.setOptional(z,Ee,"bindMatrix"),Cn.setOptional(z,Ee,"bindMatrixInverse");let Nt=Ee.skeleton;Nt&&(Nt.boneTexture===null&&Nt.computeBoneTexture(),Cn.setValue(z,"boneTexture",Nt.boneTexture,A))}Ee.isBatchedMesh&&(Cn.setOptional(z,Ee,"batchingTexture"),Cn.setValue(z,"batchingTexture",Ee._matricesTexture,A));let oo=Se.morphAttributes;if((oo.position!==void 0||oo.normal!==void 0||oo.color!==void 0)&&ge.update(Ee,Se,sr),(Zr||_t.receiveShadow!==Ee.receiveShadow)&&(_t.receiveShadow=Ee.receiveShadow,Cn.setValue(z,"receiveShadow",Ee.receiveShadow)),we.isMeshGouraudMaterial&&we.envMap!==null&&(or.envMap.value=lt,or.flipEnvMap.value=lt.isCubeTexture&<.isRenderTargetTexture===!1?-1:1),we.isMeshStandardMaterial&&we.envMap===null&&_e.environment!==null&&(or.envMapIntensity.value=_e.environmentIntensity),Zr&&(Cn.setValue(z,"toneMappingExposure",y.toneMappingExposure),_t.needsLights&&Xh(or,cl),We&&we.fog===!0&&J.refreshFogUniforms(or,We),J.refreshMaterialUniforms(or,we,te,$,d.state.transmissionRenderTarget),la.upload(z,_c(_t),or,A)),we.isShaderMaterial&&we.uniformsNeedUpdate===!0&&(la.upload(z,_c(_t),or,A),we.uniformsNeedUpdate=!1),we.isSpriteMaterial&&Cn.setValue(z,"center",Ee.center),Cn.setValue(z,"modelViewMatrix",Ee.modelViewMatrix),Cn.setValue(z,"normalMatrix",Ee.normalMatrix),Cn.setValue(z,"modelMatrix",Ee.matrixWorld),we.isShaderMaterial||we.isRawShaderMaterial){let Nt=we.uniformsGroups;for(let Rs=0,qh=Nt.length;Rs<qh;Rs++){let ul=Nt[Rs];dt.update(ul,sr),dt.bind(ul,sr)}}return sr}function Xh(Q,_e){Q.ambientLightColor.needsUpdate=_e,Q.lightProbe.needsUpdate=_e,Q.directionalLights.needsUpdate=_e,Q.directionalLightShadows.needsUpdate=_e,Q.pointLights.needsUpdate=_e,Q.pointLightShadows.needsUpdate=_e,Q.spotLights.needsUpdate=_e,Q.spotLightShadows.needsUpdate=_e,Q.rectAreaLights.needsUpdate=_e,Q.hemisphereLights.needsUpdate=_e}function jh(Q){return Q.isMeshLambertMaterial||Q.isMeshToonMaterial||Q.isMeshPhongMaterial||Q.isMeshStandardMaterial||Q.isShadowMaterial||Q.isShaderMaterial&&Q.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return I},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(Q,_e,Se){G.get(Q.texture).__webglTexture=_e,G.get(Q.depthTexture).__webglTexture=Se;let we=G.get(Q);we.__hasExternalTextures=!0,we.__autoAllocateDepthBuffer=Se===void 0,we.__autoAllocateDepthBuffer||se.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),we.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(Q,_e){let Se=G.get(Q);Se.__webglFramebuffer=_e,Se.__useDefaultFramebuffer=_e===void 0},this.setRenderTarget=function(Q,_e=0,Se=0){C=Q,w=_e,I=Se;let we=!0,Ee=null,We=!1,st=!1;if(Q){let lt=G.get(Q);lt.__useDefaultFramebuffer!==void 0?(le.bindFramebuffer(z.FRAMEBUFFER,null),we=!1):lt.__webglFramebuffer===void 0?A.setupRenderTarget(Q):lt.__hasExternalTextures&&A.rebindTextures(Q,G.get(Q.texture).__webglTexture,G.get(Q.depthTexture).__webglTexture);let mt=Q.texture;(mt.isData3DTexture||mt.isDataArrayTexture||mt.isCompressedArrayTexture)&&(st=!0);let gt=G.get(Q).__webglFramebuffer;Q.isWebGLCubeRenderTarget?(Array.isArray(gt[_e])?Ee=gt[_e][Se]:Ee=gt[_e],We=!0):Q.samples>0&&A.useMultisampledRTT(Q)===!1?Ee=G.get(Q).__webglMultisampledFramebuffer:Array.isArray(gt)?Ee=gt[Se]:Ee=gt,M.copy(Q.viewport),L.copy(Q.scissor),N=Q.scissorTest}else M.copy(de).multiplyScalar(te).floor(),L.copy(ye).multiplyScalar(te).floor(),N=Me;if(le.bindFramebuffer(z.FRAMEBUFFER,Ee)&&we&&le.drawBuffers(Q,Ee),le.viewport(M),le.scissor(L),le.setScissorTest(N),We){let lt=G.get(Q.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+_e,lt.__webglTexture,Se)}else if(st){let lt=G.get(Q.texture),mt=_e||0;z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,lt.__webglTexture,Se||0,mt)}P=-1},this.readRenderTargetPixels=function(Q,_e,Se,we,Ee,We,st){if(!(Q&&Q.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let et=G.get(Q).__webglFramebuffer;if(Q.isWebGLCubeRenderTarget&&st!==void 0&&(et=et[st]),et){le.bindFramebuffer(z.FRAMEBUFFER,et);try{let lt=Q.texture,mt=lt.format,gt=lt.type;if(mt!==Xi&&Fe.convert(mt)!==z.getParameter(z.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let xt=gt===Nu&&(se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float"));if(gt!==fs&&Fe.convert(gt)!==z.getParameter(z.IMPLEMENTATION_COLOR_READ_TYPE)&>!==Vr&&!xt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}_e>=0&&_e<=Q.width-we&&Se>=0&&Se<=Q.height-Ee&&z.readPixels(_e,Se,we,Ee,Fe.convert(mt),Fe.convert(gt),We)}finally{let lt=C!==null?G.get(C).__webglFramebuffer:null;le.bindFramebuffer(z.FRAMEBUFFER,lt)}}},this.copyFramebufferToTexture=function(Q,_e,Se=0){let we=Math.pow(2,-Se),Ee=Math.floor(_e.image.width*we),We=Math.floor(_e.image.height*we);A.setTexture2D(_e,0),z.copyTexSubImage2D(z.TEXTURE_2D,Se,0,0,Q.x,Q.y,Ee,We),le.unbindTexture()},this.copyTextureToTexture=function(Q,_e,Se,we=0){let Ee=_e.image.width,We=_e.image.height,st=Fe.convert(Se.format),et=Fe.convert(Se.type);A.setTexture2D(Se,0),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,Se.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Se.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,Se.unpackAlignment),_e.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,we,Q.x,Q.y,Ee,We,st,et,_e.image.data):_e.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,we,Q.x,Q.y,_e.mipmaps[0].width,_e.mipmaps[0].height,st,_e.mipmaps[0].data):z.texSubImage2D(z.TEXTURE_2D,we,Q.x,Q.y,st,et,_e.image),we===0&&Se.generateMipmaps&&z.generateMipmap(z.TEXTURE_2D),le.unbindTexture()},this.copyTextureToTexture3D=function(Q,_e,Se,we,Ee=0){let We=Math.round(Q.max.x-Q.min.x),st=Math.round(Q.max.y-Q.min.y),et=Q.max.z-Q.min.z+1,lt=Fe.convert(we.format),mt=Fe.convert(we.type),gt;if(we.isData3DTexture)A.setTexture3D(we,0),gt=z.TEXTURE_3D;else if(we.isDataArrayTexture||we.isCompressedArrayTexture)A.setTexture2DArray(we,0),gt=z.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,we.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,we.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,we.unpackAlignment);let xt=z.getParameter(z.UNPACK_ROW_LENGTH),tn=z.getParameter(z.UNPACK_IMAGE_HEIGHT),qn=z.getParameter(z.UNPACK_SKIP_PIXELS),gn=z.getParameter(z.UNPACK_SKIP_ROWS),Di=z.getParameter(z.UNPACK_SKIP_IMAGES),qt=Se.isCompressedTexture?Se.mipmaps[Ee]:Se.image;z.pixelStorei(z.UNPACK_ROW_LENGTH,qt.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,qt.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Q.min.x),z.pixelStorei(z.UNPACK_SKIP_ROWS,Q.min.y),z.pixelStorei(z.UNPACK_SKIP_IMAGES,Q.min.z),Se.isDataTexture||Se.isData3DTexture?z.texSubImage3D(gt,Ee,_e.x,_e.y,_e.z,We,st,et,lt,mt,qt.data):we.isCompressedArrayTexture?z.compressedTexSubImage3D(gt,Ee,_e.x,_e.y,_e.z,We,st,et,lt,qt.data):z.texSubImage3D(gt,Ee,_e.x,_e.y,_e.z,We,st,et,lt,mt,qt),z.pixelStorei(z.UNPACK_ROW_LENGTH,xt),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,tn),z.pixelStorei(z.UNPACK_SKIP_PIXELS,qn),z.pixelStorei(z.UNPACK_SKIP_ROWS,gn),z.pixelStorei(z.UNPACK_SKIP_IMAGES,Di),Ee===0&&we.generateMipmaps&&z.generateMipmap(gt),le.unbindTexture()},this.initTexture=function(Q){Q.isCubeTexture?A.setTextureCube(Q,0):Q.isData3DTexture?A.setTexture3D(Q,0):Q.isDataArrayTexture||Q.isCompressedArrayTexture?A.setTexture2DArray(Q,0):A.setTexture2D(Q,0),le.unbindTexture()},this.resetState=function(){w=0,I=0,C=null,le.reset(),Je.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return zr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===Cd?"display-p3":"srgb",t.unpackColorSpace=Bt.workingColorSpace===ch?"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}};var vr=class extends Rt{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 hn,this.environmentIntensity=1,this.environmentRotation=new hn,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}};var Pg=new oe,Ng=new Ct,Lg=new Ct,ZE=new oe,Og=new Ye,_u=new oe,Of=new qi,Dg=new Ye,Df=new Ks,xa=class extends Pt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=fm,this.bindMatrix=new Ye,this.bindMatrixInverse=new Ye,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ji),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,_u),this.boundingBox.expandByPoint(_u)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new qi),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,_u),this.boundingSphere.expandByPoint(_u)}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 n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Of.copy(this.boundingSphere),Of.applyMatrix4(i),e.ray.intersectsSphere(Of)!==!1&&(Dg.copy(i).invert(),Df.copy(e.ray).applyMatrix4(Dg),!(this.boundingBox!==null&&Df.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Df)))}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 Ct,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===fm?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===vy?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;Ng.fromBufferAttribute(i.attributes.skinIndex,e),Lg.fromBufferAttribute(i.attributes.skinWeight,e),Pg.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=Lg.getComponent(s);if(o!==0){let a=Ng.getComponent(s);Og.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(ZE.copy(Pg).applyMatrix4(Og),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},ms=class extends Rt{constructor(){super(),this.isBone=!0,this.type="Bone"}},_a=class extends Dn{constructor(e=null,t=1,n=1,i,s,o,a,l,c=Bn,u=Bn,h,f){super(null,o,a,l,c,u,i,s,h,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Fg=new Ye,JE=new Ye,Ta=class r{constructor(e=[],t=[]){this.uuid=Xr(),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 n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ye)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ye;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:JE;Fg.multiplyMatrices(a,t[s]),Fg.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new r(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 n=new _a(t,e,e,Xi,Vr);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let s=e.bones[n],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new ms),this.bones.push(o),this.boneInverses.push(new Ye().fromArray(e.boneInverses[n]))}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,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){let o=t[i];e.bones.push(o.uuid);let a=n[i];e.boneInverses.push(a.toArray())}return e}};var Wn=class extends Yi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ve(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}},Ug=new oe,kg=new oe,Bg=new Ye,Ff=new Ks,Tu=new qi,Js=class extends Rt{constructor(e=new St,t=new Wn){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,n=[0];for(let i=1,s=t.count;i<s;i++)Ug.fromBufferAttribute(t,i-1),kg.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Ug.distanceTo(kg);e.setAttribute("lineDistance",new ze(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Tu.copy(n.boundingSphere),Tu.applyMatrix4(i),Tu.radius+=s,e.ray.intersectsSphere(Tu)===!1)return;Bg.copy(i).invert(),Ff.copy(e.ray).applyMatrix4(Bg);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new oe,u=new oe,h=new oe,f=new oe,p=this.isLineSegments?2:1,g=n.index,d=n.attributes.position;if(g!==null){let m=Math.max(0,o.start),_=Math.min(g.count,o.start+o.count);for(let y=m,x=_-1;y<x;y+=p){let w=g.getX(y),I=g.getX(y+1);if(c.fromBufferAttribute(d,w),u.fromBufferAttribute(d,I),Ff.distanceSqToSegment(c,u,f,h)>l)continue;f.applyMatrix4(this.matrixWorld);let P=e.ray.origin.distanceTo(f);P<e.near||P>e.far||t.push({distance:P,point:h.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,o.start),_=Math.min(d.count,o.start+o.count);for(let y=m,x=_-1;y<x;y+=p){if(c.fromBufferAttribute(d,y),u.fromBufferAttribute(d,y+1),Ff.distanceSqToSegment(c,u,f,h)>l)continue;f.applyMatrix4(this.matrixWorld);let I=e.ray.origin.distanceTo(f);I<e.near||I>e.far||t.push({distance:I,point:h.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},Gg=new oe,Vg=new oe,yr=class extends Js{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,n=[];for(let i=0,s=t.count;i<s;i+=2)Gg.fromBufferAttribute(t,i),Vg.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Gg.distanceTo(Vg);e.setAttribute("lineDistance",new ze(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var zl=class extends Yi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ve(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}},zg=new Ye,ad=new Ks,Mu=new qi,Eu=new oe,Xu=class extends Rt{constructor(e=new St,t=new zl){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 n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Mu.copy(n.boundingSphere),Mu.applyMatrix4(i),Mu.radius+=s,e.ray.intersectsSphere(Mu)===!1)return;zg.copy(i).invert(),ad.copy(e.ray).applyMatrix4(zg);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,h=n.attributes.position;if(c!==null){let f=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let g=f,v=p;g<v;g++){let d=c.getX(g);Eu.fromBufferAttribute(h,d),Hg(Eu,d,l,i,e,t,this)}}else{let f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let g=f,v=p;g<v;g++)Eu.fromBufferAttribute(h,g),Hg(Eu,g,l,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};function Hg(r,e,t,n,i,s,o){let a=ad.distanceSqToPoint(r);if(a<t){let l=new oe;ad.closestPointToPoint(r,l),l.applyMatrix4(n);let c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}var ai=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/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=[],n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),i=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let u=n[i],f=n[i+1]-u,p=(o-u)/f;return(i+p)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new Ce:new oe);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new oe,i=[],s=[],o=[],a=new oe,l=new Ye;for(let p=0;p<=e;p++){let g=p/e;i[p]=this.getTangentAt(g,new oe)}s[0]=new oe,o[0]=new oe;let c=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=c&&(c=u,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),f<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();let g=Math.acos(kn(i[p-1].dot(i[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,g))}o[p].crossVectors(i[p],s[p])}if(t===!0){let p=Math.acos(kn(s[0].dot(s[e]),-1,1));p/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(p=-p);for(let g=1;g<=e;g++)s[g].applyMatrix4(l.makeRotationAxis(i[g],p*g)),o[g].crossVectors(i[g],s[g])}return{tangents:i,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}},Hl=class extends ai{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new Ce){let n=t,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=l-this.aX,p=c-this.aY;l=f*u-p*h+this.aX,c=f*h+p*u+this.aY}return n.set(l,c)}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}},ld=class extends Hl{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Pd(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let f=(o-s)/c-(a-s)/(c+u)+(a-o)/u,p=(a-o)/u-(l-o)/(u+h)+(l-a)/h;f*=u,p*=u,i(o,a,f,p)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+n*a}}}var bu=new oe,Uf=new Pd,kf=new Pd,Bf=new Pd,cd=class extends ai{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new oe){let n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%s]:(bu.subVectors(i[0],i[1]).add(i[0]),c=bu);let h=i[a%s],f=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(bu.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=bu),this.curveType==="centripetal"||this.curveType==="chordal"){let p=this.curveType==="chordal"?.5:.25,g=Math.pow(c.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(f),p),d=Math.pow(f.distanceToSquared(u),p);v<1e-4&&(v=1),g<1e-4&&(g=v),d<1e-4&&(d=v),Uf.initNonuniformCatmullRom(c.x,h.x,f.x,u.x,g,v,d),kf.initNonuniformCatmullRom(c.y,h.y,f.y,u.y,g,v,d),Bf.initNonuniformCatmullRom(c.z,h.z,f.z,u.z,g,v,d)}else this.curveType==="catmullrom"&&(Uf.initCatmullRom(c.x,h.x,f.x,u.x,this.tension),kf.initCatmullRom(c.y,h.y,f.y,u.y,this.tension),Bf.initCatmullRom(c.z,h.z,f.z,u.z,this.tension));return n.set(Uf.calc(l),kf.calc(l),Bf.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.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,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.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,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new oe().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Wg(r,e,t,n,i){let s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function $E(r,e){let t=1-r;return t*t*e}function QE(r,e){return 2*(1-r)*r*e}function eb(r,e){return r*r*e}function Ol(r,e,t,n){return $E(r,e)+QE(r,t)+eb(r,n)}function tb(r,e){let t=1-r;return t*t*t*e}function nb(r,e){let t=1-r;return 3*t*t*r*e}function ib(r,e){return 3*(1-r)*r*r*e}function rb(r,e){return r*r*r*e}function Dl(r,e,t,n,i){return tb(r,e)+nb(r,t)+ib(r,n)+rb(r,i)}var ju=class extends ai{constructor(e=new Ce,t=new Ce,n=new Ce,i=new Ce){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Ce){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Dl(e,i.x,s.x,o.x,a.x),Dl(e,i.y,s.y,o.y,a.y)),n}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}},ud=class extends ai{constructor(e=new oe,t=new oe,n=new oe,i=new oe){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new oe){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Dl(e,i.x,s.x,o.x,a.x),Dl(e,i.y,s.y,o.y,a.y),Dl(e,i.z,s.z,o.z,a.z)),n}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}},qu=class extends ai{constructor(e=new Ce,t=new Ce){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ce){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ce){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}},hd=class extends ai{constructor(e=new oe,t=new oe){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new oe){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}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}},Yu=class extends ai{constructor(e=new Ce,t=new Ce,n=new Ce){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Ce){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Ol(e,i.x,s.x,o.x),Ol(e,i.y,s.y,o.y)),n}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}},fd=class extends ai{constructor(e=new oe,t=new oe,n=new oe){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new oe){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Ol(e,i.x,s.x,o.x),Ol(e,i.y,s.y,o.y),Ol(e,i.z,s.z,o.z)),n}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}},Ku=class extends ai{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ce){let n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(Wg(a,l.x,c.x,u.x,h.x),Wg(a,l.y,c.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new Ce().fromArray(i))}return this}},dd=Object.freeze({__proto__:null,ArcCurve:ld,CatmullRomCurve3:cd,CubicBezierCurve:ju,CubicBezierCurve3:ud,EllipseCurve:Hl,LineCurve:qu,LineCurve3:hd,QuadraticBezierCurve:Yu,QuadraticBezierCurve3:fd,SplineCurve:Ku}),pd=class extends ai{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 n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new dd[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,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 n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){let u=l[c];n&&n.equals(u)||(t.push(u),n=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,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(new dd[i.type]().fromJSON(i))}return this}},Wr=class extends pd{constructor(e){super(),this.type="Path",this.currentPoint=new Ce,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;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 n=new qu(this.currentPoint.clone(),new Ce(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let s=new Yu(this.currentPoint.clone(),new Ce(e,t),new Ce(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){let a=new ju(this.currentPoint.clone(),new Ce(e,t),new Ce(n,i),new Ce(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new Ku(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){let c=new Hl(e,t,n,i,s,o,a,l);if(this.curves.length>0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.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}};var Wl=class r extends St{constructor(e=1,t=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let u=[],h=[],f=[],p=[],g=0,v=[],d=n/2,m=0;_(),o===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new ze(h,3)),this.setAttribute("normal",new ze(f,3)),this.setAttribute("uv",new ze(p,2));function _(){let x=new oe,w=new oe,I=0,C=(t-e)/n;for(let P=0;P<=s;P++){let E=[],M=P/s,L=M*(t-e)+e;for(let N=0;N<=i;N++){let O=N/i,B=O*l+a,ie=Math.sin(B),$=Math.cos(B);w.x=L*ie,w.y=-M*n+d,w.z=L*$,h.push(w.x,w.y,w.z),x.set(ie,C,$).normalize(),f.push(x.x,x.y,x.z),p.push(O,1-M),E.push(g++)}v.push(E)}for(let P=0;P<i;P++)for(let E=0;E<s;E++){let M=v[E][P],L=v[E+1][P],N=v[E+1][P+1],O=v[E][P+1];u.push(M,L,O),u.push(L,N,O),I+=6}c.addGroup(m,I,0),m+=I}function y(x){let w=g,I=new Ce,C=new oe,P=0,E=x===!0?e:t,M=x===!0?1:-1;for(let N=1;N<=i;N++)h.push(0,d*M,0),f.push(0,M,0),p.push(.5,.5),g++;let L=g;for(let N=0;N<=i;N++){let B=N/i*l+a,ie=Math.cos(B),$=Math.sin(B);C.x=E*$,C.y=d*M,C.z=E*ie,h.push(C.x,C.y,C.z),f.push(0,M,0),I.x=ie*.5+.5,I.y=$*.5*M+.5,p.push(I.x,I.y),g++}for(let N=0;N<i;N++){let O=w+N,B=L+N;x===!0?u.push(B,B+1,O):u.push(B+1,B,O),P+=3}c.addGroup(m,P,x===!0?1:2),m+=P}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Zu=class r extends Wl{constructor(e=1,t=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new r(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}};var Su=new oe,Au=new oe,Gf=new oe,wu=new Ys,Ju=class extends St{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let i=Math.pow(10,4),s=Math.cos(oa*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],h=new Array(3),f={},p=[];for(let g=0;g<l;g+=3){o?(c[0]=o.getX(g),c[1]=o.getX(g+1),c[2]=o.getX(g+2)):(c[0]=g,c[1]=g+1,c[2]=g+2);let{a:v,b:d,c:m}=wu;if(v.fromBufferAttribute(a,c[0]),d.fromBufferAttribute(a,c[1]),m.fromBufferAttribute(a,c[2]),wu.getNormal(Gf),h[0]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,h[1]=`${Math.round(d.x*i)},${Math.round(d.y*i)},${Math.round(d.z*i)}`,h[2]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let _=0;_<3;_++){let y=(_+1)%3,x=h[_],w=h[y],I=wu[u[_]],C=wu[u[y]],P=`${x}_${w}`,E=`${w}_${x}`;E in f&&f[E]?(Gf.dot(f[E].normal)<=s&&(p.push(I.x,I.y,I.z),p.push(C.x,C.y,C.z)),f[E]=null):P in f||(f[P]={index0:c[_],index1:c[y],normal:Gf.clone()})}}for(let g in f)if(f[g]){let{index0:v,index1:d}=f[g];Su.fromBufferAttribute(a,v),Au.fromBufferAttribute(a,d),p.push(Su.x,Su.y,Su.z),p.push(Au.x,Au.y,Au.z)}this.setAttribute("position",new ze(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},ds=class extends Wr{constructor(e){super(e),this.uuid=Xr(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].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,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(new Wr().fromJSON(i))}return this}},sb={triangulate:function(r,e,t=2){let n=e&&e.length,i=n?e[0]*t:r.length,s=T0(r,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,h,f,p;if(n&&(s=ub(r,e,s,t)),r.length>80*t){a=c=r[0],l=u=r[1];for(let g=t;g<i;g+=t)h=r[g],f=r[g+1],h<a&&(a=h),f<l&&(l=f),h>c&&(c=h),f>u&&(u=f);p=Math.max(c-a,u-l),p=p!==0?32767/p:0}return Xl(s,o,t,a,l,p,0),o}};function T0(r,e,t,n,i){let s,o;if(i===Tb(r,e,t,n)>0)for(s=e;s<t;s+=n)o=Xg(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=Xg(s,r[s],r[s+1],o);return o&&hh(o,o.next)&&(ql(o),o=o.next),o}function $s(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(hh(t,t.next)||cn(t.prev,t,t.next)===0)){if(ql(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Xl(r,e,t,n,i,s,o){if(!r)return;!o&&s&&mb(r,n,i,s);let a=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?ab(r,n,i,s):ob(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),ql(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=lb($s(r),e,t),Xl(r,e,t,n,i,s,2)):o===2&&cb(r,e,t,n,i,s):Xl($s(r),e,t,n,i,s,1);break}}}function ob(r){let e=r.prev,t=r,n=r.next;if(cn(e,t,n)>=0)return!1;let i=e.x,s=t.x,o=n.x,a=e.y,l=t.y,c=n.y,u=i<s?i<o?i:o:s<o?s:o,h=a<l?a<c?a:c:l<c?l:c,f=i>s?i>o?i:o:s>o?s:o,p=a>l?a>c?a:c:l>c?l:c,g=n.next;for(;g!==e;){if(g.x>=u&&g.x<=f&&g.y>=h&&g.y<=p&&ia(i,a,s,l,o,c,g.x,g.y)&&cn(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function ab(r,e,t,n){let i=r.prev,s=r,o=r.next;if(cn(i,s,o)>=0)return!1;let a=i.x,l=s.x,c=o.x,u=i.y,h=s.y,f=o.y,p=a<l?a<c?a:c:l<c?l:c,g=u<h?u<f?u:f:h<f?h:f,v=a>l?a>c?a:c:l>c?l:c,d=u>h?u>f?u:f:h>f?h:f,m=md(p,g,e,t,n),_=md(v,d,e,t,n),y=r.prevZ,x=r.nextZ;for(;y&&y.z>=m&&x&&x.z<=_;){if(y.x>=p&&y.x<=v&&y.y>=g&&y.y<=d&&y!==i&&y!==o&&ia(a,u,l,h,c,f,y.x,y.y)&&cn(y.prev,y,y.next)>=0||(y=y.prevZ,x.x>=p&&x.x<=v&&x.y>=g&&x.y<=d&&x!==i&&x!==o&&ia(a,u,l,h,c,f,x.x,x.y)&&cn(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;y&&y.z>=m;){if(y.x>=p&&y.x<=v&&y.y>=g&&y.y<=d&&y!==i&&y!==o&&ia(a,u,l,h,c,f,y.x,y.y)&&cn(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=_;){if(x.x>=p&&x.x<=v&&x.y>=g&&x.y<=d&&x!==i&&x!==o&&ia(a,u,l,h,c,f,x.x,x.y)&&cn(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function lb(r,e,t){let n=r;do{let i=n.prev,s=n.next.next;!hh(i,s)&&M0(i,n,n.next,s)&&jl(i,s)&&jl(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),ql(n),ql(n.next),n=r=s),n=n.next}while(n!==r);return $s(n)}function cb(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&yb(o,a)){let l=E0(o,a);o=$s(o,o.next),l=$s(l,l.next),Xl(o,e,t,n,i,s,0),Xl(l,e,t,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function ub(r,e,t,n){let i=[],s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,c=T0(r,a,l,n,!1),c===c.next&&(c.steiner=!0),i.push(vb(c));for(i.sort(hb),s=0;s<i.length;s++)t=fb(i[s],t);return t}function hb(r,e){return r.x-e.x}function fb(r,e){let t=db(r,e);if(!t)return e;let n=E0(t,r);return $s(n,n.next),$s(t,t.next)}function db(r,e){let t=e,n=-1/0,i,s=r.x,o=r.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let f=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=s&&f>n&&(n=f,i=t.x<t.next.x?t:t.next,f===s))return i}t=t.next}while(t!==e);if(!i)return null;let a=i,l=i.x,c=i.y,u=1/0,h;t=i;do s>=t.x&&t.x>=l&&s!==t.x&&ia(o<c?s:n,o,l,c,o<c?n:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),jl(t,r)&&(h<u||h===u&&(t.x>i.x||t.x===i.x&&pb(i,t)))&&(i=t,u=h)),t=t.next;while(t!==a);return i}function pb(r,e){return cn(r.prev,r,e.prev)<0&&cn(e.next,r,r.next)<0}function mb(r,e,t,n){let i=r;do i.z===0&&(i.z=md(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,gb(i)}function gb(r){let e,t,n,i,s,o,a,l,c=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<c&&(a++,n=n.nextZ,!!n);e++);for(l=c;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(o>1);return r}function md(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function vb(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function ia(r,e,t,n,i,s,o,a){return(i-o)*(e-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(n-a)}function yb(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!xb(r,e)&&(jl(r,e)&&jl(e,r)&&_b(r,e)&&(cn(r.prev,r,e.prev)||cn(r,e.prev,e))||hh(r,e)&&cn(r.prev,r,r.next)>0&&cn(e.prev,e,e.next)>0)}function cn(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function hh(r,e){return r.x===e.x&&r.y===e.y}function M0(r,e,t,n){let i=Ru(cn(r,e,t)),s=Ru(cn(r,e,n)),o=Ru(cn(t,n,r)),a=Ru(cn(t,n,e));return!!(i!==s&&o!==a||i===0&&Cu(r,t,e)||s===0&&Cu(r,n,e)||o===0&&Cu(t,r,n)||a===0&&Cu(t,e,n))}function Cu(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Ru(r){return r>0?1:r<0?-1:0}function xb(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&M0(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function jl(r,e){return cn(r.prev,r,r.next)<0?cn(r,e,r.next)>=0&&cn(r,r.prev,e)>=0:cn(r,e,r.prev)<0||cn(r,r.next,e)<0}function _b(r,e){let t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function E0(r,e){let t=new gd(r.i,r.x,r.y),n=new gd(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Xg(r,e,t,n){let i=new gd(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ql(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function gd(r,e,t){this.i=r,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 Tb(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var Ai=class r{static area(e){let t=e.length,n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return r.area(e)<0}static triangulateShape(e,t){let n=[],i=[],s=[];jg(e),qg(n,e);let o=e.length;t.forEach(jg);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,qg(n,t[l]);let a=sb.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function jg(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function qg(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var $u=class r extends St{constructor(e=new ds([new Ce(.5,.5),new Ce(-.5,.5),new Ce(-.5,-.5),new Ce(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,i=[],s=[];for(let a=0,l=e.length;a<l;a++){let c=e[a];o(c)}this.setAttribute("position",new ze(i,3)),this.setAttribute("uv",new ze(s,2)),this.computeVertexNormals();function o(a){let l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1,f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:p-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,d=t.bevelSegments!==void 0?t.bevelSegments:3,m=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:Mb,y,x=!1,w,I,C,P;m&&(y=m.getSpacedPoints(u),x=!0,f=!1,w=m.computeFrenetFrames(u,!1),I=new oe,C=new oe,P=new oe),f||(d=0,p=0,g=0,v=0);let E=a.extractPoints(c),M=E.shape,L=E.holes;if(!Ai.isClockWise(M)){M=M.reverse();for(let X=0,se=L.length;X<se;X++){let re=L[X];Ai.isClockWise(re)&&(L[X]=re.reverse())}}let O=Ai.triangulateShape(M,L),B=M;for(let X=0,se=L.length;X<se;X++){let re=L[X];M=M.concat(re)}function ie(X,se,re){return se||console.error("THREE.ExtrudeGeometry: vec does not exist"),X.clone().addScaledVector(se,re)}let $=M.length,te=O.length;function W(X,se,re){let le,xe,G,A=X.x-se.x,U=X.y-se.y,he=re.x-X.x,me=re.y-X.y,Te=A*A+U*U,ee=A*me-U*he;if(Math.abs(ee)>Number.EPSILON){let k=Math.sqrt(Te),J=Math.sqrt(he*he+me*me),ue=se.x-U/k,Z=se.y+A/k,ce=re.x-me/J,pe=re.y+he/J,fe=((ce-ue)*me-(pe-Z)*he)/(A*me-U*he);le=ue+A*fe-X.x,xe=Z+U*fe-X.y;let ge=le*le+xe*xe;if(ge<=2)return new Ce(le,xe);G=Math.sqrt(ge/2)}else{let k=!1;A>Number.EPSILON?he>Number.EPSILON&&(k=!0):A<-Number.EPSILON?he<-Number.EPSILON&&(k=!0):Math.sign(U)===Math.sign(me)&&(k=!0),k?(le=-U,xe=A,G=Math.sqrt(Te)):(le=A,xe=U,G=Math.sqrt(Te/2))}return new Ce(le/G,xe/G)}let ae=[];for(let X=0,se=B.length,re=se-1,le=X+1;X<se;X++,re++,le++)re===se&&(re=0),le===se&&(le=0),ae[X]=W(B[X],B[re],B[le]);let de=[],ye,Me=ae.concat();for(let X=0,se=L.length;X<se;X++){let re=L[X];ye=[];for(let le=0,xe=re.length,G=xe-1,A=le+1;le<xe;le++,G++,A++)G===xe&&(G=0),A===xe&&(A=0),ye[le]=W(re[le],re[G],re[A]);de.push(ye),Me=Me.concat(ye)}for(let X=0;X<d;X++){let se=X/d,re=p*Math.cos(se*Math.PI/2),le=g*Math.sin(se*Math.PI/2)+v;for(let xe=0,G=B.length;xe<G;xe++){let A=ie(B[xe],ae[xe],le);b(A.x,A.y,-re)}for(let xe=0,G=L.length;xe<G;xe++){let A=L[xe];ye=de[xe];for(let U=0,he=A.length;U<he;U++){let me=ie(A[U],ye[U],le);b(me.x,me.y,-re)}}}let ve=g+v;for(let X=0;X<$;X++){let se=f?ie(M[X],Me[X],ve):M[X];x?(C.copy(w.normals[0]).multiplyScalar(se.x),I.copy(w.binormals[0]).multiplyScalar(se.y),P.copy(y[0]).add(C).add(I),b(P.x,P.y,P.z)):b(se.x,se.y,0)}for(let X=1;X<=u;X++)for(let se=0;se<$;se++){let re=f?ie(M[se],Me[se],ve):M[se];x?(C.copy(w.normals[X]).multiplyScalar(re.x),I.copy(w.binormals[X]).multiplyScalar(re.y),P.copy(y[X]).add(C).add(I),b(P.x,P.y,P.z)):b(re.x,re.y,h/u*X)}for(let X=d-1;X>=0;X--){let se=X/d,re=p*Math.cos(se*Math.PI/2),le=g*Math.sin(se*Math.PI/2)+v;for(let xe=0,G=B.length;xe<G;xe++){let A=ie(B[xe],ae[xe],le);b(A.x,A.y,h+re)}for(let xe=0,G=L.length;xe<G;xe++){let A=L[xe];ye=de[xe];for(let U=0,he=A.length;U<he;U++){let me=ie(A[U],ye[U],le);x?b(me.x,me.y+y[u-1].y,y[u-1].x+re):b(me.x,me.y,h+re)}}}R(),T();function R(){let X=i.length/3;if(f){let se=0,re=$*se;for(let le=0;le<te;le++){let xe=O[le];V(xe[2]+re,xe[1]+re,xe[0]+re)}se=u+d*2,re=$*se;for(let le=0;le<te;le++){let xe=O[le];V(xe[0]+re,xe[1]+re,xe[2]+re)}}else{for(let se=0;se<te;se++){let re=O[se];V(re[2],re[1],re[0])}for(let se=0;se<te;se++){let re=O[se];V(re[0]+$*u,re[1]+$*u,re[2]+$*u)}}n.addGroup(X,i.length/3-X,0)}function T(){let X=i.length/3,se=0;S(B,se),se+=B.length;for(let re=0,le=L.length;re<le;re++){let xe=L[re];S(xe,se),se+=xe.length}n.addGroup(X,i.length/3-X,1)}function S(X,se){let re=X.length;for(;--re>=0;){let le=re,xe=re-1;xe<0&&(xe=X.length-1);for(let G=0,A=u+d*2;G<A;G++){let U=$*G,he=$*(G+1),me=se+le+U,Te=se+xe+U,ee=se+xe+he,k=se+le+he;q(me,Te,ee,k)}}}function b(X,se,re){l.push(X),l.push(se),l.push(re)}function V(X,se,re){Y(X),Y(se),Y(re);let le=i.length/3,xe=_.generateTopUV(n,i,le-3,le-2,le-1);z(xe[0]),z(xe[1]),z(xe[2])}function q(X,se,re,le){Y(X),Y(se),Y(le),Y(se),Y(re),Y(le);let xe=i.length/3,G=_.generateSideWallUV(n,i,xe-6,xe-3,xe-2,xe-1);z(G[0]),z(G[1]),z(G[3]),z(G[1]),z(G[2]),z(G[3])}function Y(X){i.push(l[X*3+0]),i.push(l[X*3+1]),i.push(l[X*3+2])}function z(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,n=this.parameters.options;return Eb(t,n,e)}static fromJSON(e,t){let n=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];n.push(a)}let i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new dd[i.type]().fromJSON(i)),new r(n,e.options)}},Mb={generateTopUV:function(r,e,t,n,i){let s=e[t*3],o=e[t*3+1],a=e[n*3],l=e[n*3+1],c=e[i*3],u=e[i*3+1];return[new Ce(s,o),new Ce(a,l),new Ce(c,u)]},generateSideWallUV:function(r,e,t,n,i,s){let o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[n*3],u=e[n*3+1],h=e[n*3+2],f=e[i*3],p=e[i*3+1],g=e[i*3+2],v=e[s*3],d=e[s*3+1],m=e[s*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new Ce(o,1-l),new Ce(c,1-h),new Ce(f,1-g),new Ce(v,1-m)]:[new Ce(a,1-l),new Ce(u,1-h),new Ce(p,1-g),new Ce(d,1-m)]}};function Eb(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){let s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var Ma=class r extends St{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),c=0,u=[],h=new oe,f=new oe,p=[],g=[],v=[],d=[];for(let m=0;m<=n;m++){let _=[],y=m/n,x=0;m===0&&o===0?x=.5/t:m===n&&l===Math.PI&&(x=-.5/t);for(let w=0;w<=t;w++){let I=w/t;h.x=-e*Math.cos(i+I*s)*Math.sin(o+y*a),h.y=e*Math.cos(o+y*a),h.z=e*Math.sin(i+I*s)*Math.sin(o+y*a),g.push(h.x,h.y,h.z),f.copy(h).normalize(),v.push(f.x,f.y,f.z),d.push(I+x,1-y),_.push(c++)}u.push(_)}for(let m=0;m<n;m++)for(let _=0;_<t;_++){let y=u[m][_+1],x=u[m][_],w=u[m+1][_],I=u[m+1][_+1];(m!==0||o>0)&&p.push(y,x,I),(m!==n-1||l<Math.PI)&&p.push(x,w,I)}this.setIndex(p),this.setAttribute("position",new ze(g,3)),this.setAttribute("normal",new ze(v,3)),this.setAttribute("uv",new ze(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var gs=class extends Yi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ve(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 Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lh,this.normalScale=new Ce(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 hn,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}};var Zt=class extends Yi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ve(16777215),this.specular=new Ve(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lh,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hn,this.combine=oh,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}};var Ea=class extends Yi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lh,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hn,this.combine=oh,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}};function Iu(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function bb(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Sb(r){function e(i,s){return r[i]-r[s]}let t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Yg(r,e,t){let n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i}function b0(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)}var ba=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},vd=class extends ba{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:km,endingEnd:km}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Bm:s=e,a=2*t-n;break;case Gm:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Bm:o=e,l=2*n-t;break;case Gm:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}let c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,f=this._weightPrev,p=this._weightNext,g=(n-t)/(i-t),v=g*g,d=v*g,m=-f*d+2*f*v-f*g,_=(1+f)*d+(-1.5-2*f)*v+(-.5+f)*g+1,y=(-1-p)*d+(1.5+p)*v+.5*g,x=p*d-p*v;for(let w=0;w!==a;++w)s[w]=m*o[u+w]+_*o[c+w]+y*o[l+w]+x*o[h+w];return s}},yd=class extends ba{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(n-t)/(i-t),h=1-u;for(let f=0;f!==a;++f)s[f]=o[c+f]*h+o[l+f]*u;return s}},xd=class extends ba{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},Ri=class{constructor(e,t,n,i){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=Iu(t,this.TimeBufferType),this.values=Iu(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Iu(e.times,Array),values:Iu(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new xd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new yd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new vd(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Lu:t=this.InterpolantFactoryMethodDiscrete;break;case Ou:t=this.InterpolantFactoryMethodLinear;break;case cf:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="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(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Lu;case this.InterpolantFactoryMethodLinear:return Ou;case this.InterpolantFactoryMethodSmooth:return cf}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=n.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 n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&bb(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===cf,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(i)l=!0;else{let h=a*n,f=h-n,p=h+n;for(let g=0;g!==n;++g){let v=t[h+g];if(v!==t[f+g]||v!==t[p+g]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let h=a*n,f=o*n;for(let p=0;p!==n;++p)t[f+p]=t[h+p]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Ri.prototype.TimeBufferType=Float32Array;Ri.prototype.ValueBufferType=Float32Array;Ri.prototype.DefaultInterpolation=Ou;var vs=class extends Ri{};vs.prototype.ValueTypeName="bool";vs.prototype.ValueBufferType=Array;vs.prototype.DefaultInterpolation=Lu;vs.prototype.InterpolantFactoryMethodLinear=void 0;vs.prototype.InterpolantFactoryMethodSmooth=void 0;var Qu=class extends Ri{};Qu.prototype.ValueTypeName="color";var ys=class extends Ri{};ys.prototype.ValueTypeName="number";var _d=class extends ba{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),c=e*a;for(let u=c+a;c!==u;c+=4)sn.slerpFlat(s,0,o,c-a,o,c,l);return s}},Ii=class extends Ri{InterpolantFactoryMethodLinear(e){return new _d(this.times,this.values,this.getValueSize(),e)}};Ii.prototype.ValueTypeName="quaternion";Ii.prototype.DefaultInterpolation=Ou;Ii.prototype.InterpolantFactoryMethodSmooth=void 0;var xs=class extends Ri{};xs.prototype.ValueTypeName="string";xs.prototype.ValueBufferType=Array;xs.prototype.DefaultInterpolation=Lu;xs.prototype.InterpolantFactoryMethodLinear=void 0;xs.prototype.InterpolantFactoryMethodSmooth=void 0;var Ki=class extends Ri{};Ki.prototype.ValueTypeName="vector";var Qs=class{constructor(e="",t=-1,n=[],i=Ry){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Xr(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(wb(n[o]).scale(i));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(Ri.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let s=t.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);let u=Sb(l);l=Yg(l,1,u),c=Yg(c,1,u),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new ys(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){let c=e[a],u=c.name.match(s);if(u&&u.length>1){let h=u[1],f=i[h];f||(i[h]=f=[]),f.push(c)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,f,p,g,v){if(p.length!==0){let d=[],m=[];b0(p,d,m,g),d.length!==0&&v.push(new h(f,d,m))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let h=0;h<c.length;h++){let f=c[h].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let p={},g;for(g=0;g<f.length;g++)if(f[g].morphTargets)for(let v=0;v<f[g].morphTargets.length;v++)p[f[g].morphTargets[v]]=-1;for(let v in p){let d=[],m=[];for(let _=0;_!==f[g].morphTargets.length;++_){let y=f[g];d.push(y.time),m.push(y.morphTarget===v?1:0)}i.push(new ys(".morphTargetInfluence["+v+"]",d,m))}l=p.length*o}else{let p=".bones["+t[h].name+"]";n(Ki,p+".position",f,"pos",i),n(Ii,p+".quaternion",f,"rot",i),n(Ki,p+".scale",f,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let s=this.tracks[n];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)}};function Ab(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ys;case"vector":case"vector2":case"vector3":case"vector4":return Ki;case"color":return Qu;case"quaternion":return Ii;case"bool":case"boolean":return vs;case"string":return xs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function wb(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=Ab(r.type);if(r.times===void 0){let t=[],n=[];b0(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}var eh={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},Yl=class{constructor(e,t,n){let i=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){a++,s===!1&&i.onStart!==void 0&&i.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){let h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=c.length;h<f;h+=2){let p=c[h],g=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return g}return null}}},Cb=new Yl,Dt=class{constructor(e){this.manager=e!==void 0?e:Cb,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,s){n.load(e,i,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}};Dt.DEFAULT_MATERIAL_NAME="__DEFAULT";var kr={},Td=class extends Error{constructor(e,t){super(e),this.response=t}},$n=class extends Dt{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=eh.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(kr[e]!==void 0){kr[e].push({onLoad:t,onProgress:n,onError:i});return}kr[e]=[],kr[e].push({onLoad:t,onProgress:n,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=kr[e],h=c.body.getReader(),f=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),p=f?parseInt(f):0,g=p!==0,v=0,d=new ReadableStream({start(m){_();function _(){h.read().then(({done:y,value:x})=>{if(y)m.close();else{v+=x.byteLength;let w=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:p});for(let I=0,C=u.length;I<C;I++){let P=u[I];P.onProgress&&P.onProgress(w)}m.enqueue(x),_()}})}}});return new Response(d)}else throw new Td(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(f);return c.arrayBuffer().then(g=>p.decode(g))}}}).then(c=>{eh.add(e,c);let u=kr[e];delete kr[e];for(let h=0,f=u.length;h<f;h++){let p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{let u=kr[e];if(u===void 0)throw this.manager.itemError(e),c;delete kr[e];for(let h=0,f=u.length;h<f;h++){let p=u[h];p.onError&&p.onError(c)}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}};var th=class extends Dt{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=eh.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=kl("img");function l(){u(),eh.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),i&&i(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},nh=class extends Dt{constructor(e){super(e)}load(e,t,n,i){let s=new Gl;s.colorSpace=jt;let o=new th(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){s.images[c]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,i)}for(let c=0;c<e.length;++c)l(c);return s}},ih=class extends Dt{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new _a,a=new $n(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:un,o.wrapT=c.wrapT!==void 0?c.wrapT:un,o.magFilter=c.magFilter!==void 0?c.magFilter:bn,o.minFilter=c.minFilter!==void 0?c.minFilter:bn,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=vi),c.mipmapCount===1&&(o.minFilter=bn),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},n,i),o}},Pi=class extends Dt{constructor(e){super(e)}load(e,t,n,i){let s=new Dn,o=new th(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)},n,i),s}},Sa=class extends Rt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ve(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}};var Vf=new Ye,Kg=new oe,Zg=new oe,Kl=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ce(512,512),this.map=null,this.mapPass=null,this.matrix=new Ye,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Vl,this._frameExtents=new Ce(1,1),this._viewportCount=1,this._viewports=[new Ct(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;Kg.setFromMatrixPosition(e.matrixWorld),t.position.copy(Kg),Zg.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Zg),t.updateMatrixWorld(),Vf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Vf),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Vf)}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}},Md=class extends Kl{constructor(){super(new en(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=da*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Aa=class extends Sa{constructor(e,t,n=0,i=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Rt.DEFAULT_UP),this.updateMatrix(),this.target=new Rt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Md}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}},Jg=new Ye,Il=new oe,zf=new oe,Ed=class extends Kl{constructor(){super(new en(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ce(4,2),this._viewportCount=6,this._viewports=[new Ct(2,1,1,1),new Ct(0,1,1,1),new Ct(3,1,1,1),new Ct(1,1,1,1),new Ct(3,0,1,1),new Ct(1,0,1,1)],this._cubeDirections=[new oe(1,0,0),new oe(-1,0,0),new oe(0,0,1),new oe(0,0,-1),new oe(0,1,0),new oe(0,-1,0)],this._cubeUps=[new oe(0,1,0),new oe(0,1,0),new oe(0,1,0),new oe(0,1,0),new oe(0,0,1),new oe(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Il.setFromMatrixPosition(e.matrixWorld),n.position.copy(Il),zf.copy(n.position),zf.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(zf),n.updateMatrixWorld(),i.makeTranslation(-Il.x,-Il.y,-Il.z),Jg.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Jg)}},eo=class extends Sa{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Ed}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}},bd=class extends Kl{constructor(){super(new gr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},xr=class extends Sa{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Rt.DEFAULT_UP),this.updateMatrix(),this.target=new Rt,this.shadow=new bd}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},_r=class extends Sa{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}};var _s=class{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);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)}};var Nd="\\[\\]\\.:\\/",Rb=new RegExp("["+Nd+"]","g"),Ld="[^"+Nd+"]",Ib="[^"+Nd.replace("\\.","")+"]",Pb=/((?:WC+[\/:])*)/.source.replace("WC",Ld),Nb=/(WCOD+)?/.source.replace("WCOD",Ib),Lb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ld),Ob=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ld),Db=new RegExp("^"+Pb+Nb+Lb+Ob+"$"),Fb=["material","materials","bones","map"],Sd=class{constructor(e,t,n){let i=n||zt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},zt=class r{constructor(e,t,n){this.path=t,this.parsedPath=n||r.parseTrackName(t),this.node=r.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new r.Composite(e,t,n):new r(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Rb,"")}static parseTrackName(e){let t=Db.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);Fb.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_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 n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=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,n=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=r.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(n){let c=t.objectIndex;switch(n){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===c){c=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[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[i];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" 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 l=this.BindingType.Direct;if(s!==void 0){if(i==="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])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};zt.Composite=Sd;zt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};zt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};zt.prototype.GetterByBindingType=[zt.prototype._getValue_direct,zt.prototype._getValue_array,zt.prototype._getValue_arrayElement,zt.prototype._getValue_toArray];zt.prototype.SetterByBindingTypeAndVersioning=[[zt.prototype._setValue_direct,zt.prototype._setValue_direct_setNeedsUpdate,zt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[zt.prototype._setValue_array,zt.prototype._setValue_array_setNeedsUpdate,zt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[zt.prototype._setValue_arrayElement,zt.prototype._setValue_arrayElement_setNeedsUpdate,zt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[zt.prototype._setValue_fromArray,zt.prototype._setValue_fromArray_setNeedsUpdate,zt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var N1=new Float32Array(1);var $g=new Ye,rh=class{constructor(e,t,n=0,i=1/0){this.ray=new Ks(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Bl,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 $g.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4($g),this}intersectObject(e,t=!0,n=[]){return Ad(e,this,n,t),n.sort(Qg),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Ad(e[i],this,n,t);return n.sort(Qg),n}};function Qg(r,e){return r.distance-e.distance}function Ad(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)Ad(i[s],e,t,!0)}}var e0=new Ce,sh=class{constructor(e=new Ce(1/0,1/0),t=new Ce(-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,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=e0.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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,e0).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)}};var Tr=class{constructor(){this.type="ShapePath",this.color=new Ve,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Wr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,o){return this.currentPath.bezierCurveTo(e,t,n,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){let _=[];for(let y=0,x=m.length;y<x;y++){let w=m[y],I=new ds;I.curves=w.curves,_.push(I)}return _}function n(m,_){let y=_.length,x=!1;for(let w=y-1,I=0;I<y;w=I++){let C=_[w],P=_[I],E=P.x-C.x,M=P.y-C.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(C=_[I],E=-E,P=_[w],M=-M),m.y<C.y||m.y>P.y)continue;if(m.y===C.y){if(m.x===C.x)return!0}else{let L=M*(m.x-C.x)-E*(m.y-C.y);if(L===0)return!0;if(L<0)continue;x=!x}}else{if(m.y!==C.y)continue;if(P.x<=m.x&&m.x<=C.x||C.x<=m.x&&m.x<=P.x)return!0}}return x}let i=Ai.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l,c=[];if(s.length===1)return a=s[0],l=new ds,l.curves=a.curves,c.push(l),c;let u=!i(s[0].getPoints());u=e?!u:u;let h=[],f=[],p=[],g=0,v;f[g]=void 0,p[g]=[];for(let m=0,_=s.length;m<_;m++)a=s[m],v=a.getPoints(),o=i(v),o=e?!o:o,o?(!u&&f[g]&&g++,f[g]={s:new ds,p:v},f[g].s.curves=a.curves,u&&g++,p[g]=[]):p[g].push({h:a,p:v[0]});if(!f[0])return t(s);if(f.length>1){let m=!1,_=0;for(let y=0,x=f.length;y<x;y++)h[y]=[];for(let y=0,x=f.length;y<x;y++){let w=p[y];for(let I=0;I<w.length;I++){let C=w[I],P=!0;for(let E=0;E<f.length;E++)n(C.p,f[E].p)&&(y!==E&&_++,P?(P=!1,h[E].push(C)):m=!0);P&&h[y].push(C)}}_>0&&m===!1&&(p=h)}let d;for(let m=0,_=f.length;m<_;m++){l=f[m].s,c.push(l),d=p[m];for(let y=0,x=d.length;y<x;y++)l.holes.push(d[y].h)}return c}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:wd}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=wd);function fh(){let r=document.createElement("canvas");document.body.appendChild(r);let e={canvas:r,antialias:!0},t=new ya(e);t.outputColorSpace=li,t.setClearColor("#ffffff",1),t.setSize(10,10);let n=new vr,i=new _r(8947848);n.add(i);let s=new xr(8947848);s.position.set(0,0,1),n.add(s);let o=new en(45,1,.1,1e3);o.position.set(0,0,1),o.up.set(0,1,0),o.lookAt(new oe(0,0,0)),n.add(o);let a=new va(1,1),l=new Pt(a,new Zt({color:13369344}));n.add(l),t.render(n,o);let c=t.getContext(),u=new Uint8Array(4);c.readPixels(5,5,1,1,c.RGBA,c.UNSIGNED_BYTE,u),document.body.removeChild(r);let h=50;return u[0]<h&&u[1]<h&&u[2]<h}var ci={Phong:1,Physical:2};function dh(r){let e=0,t=0;for(let n=0;n<r.MaterialCount();n++){let i=r.GetMaterial(n);i.type===Un.Phong?e+=1:i.type===Un.Physical&&(t+=1)}return e>=t?ci.Phong:ci.Physical}var Ca=class{Convert(e){return null}},to=class extends Ca{Convert(e){return new Ve().copyLinearToSRGB(e)}},Ra=class extends Ca{Convert(e){return new Ve().copySRGBToLinear(e)}};function Jl(r){return di(r.r,r.g,r.b)}function wn(r){return new Ve(r.r/255,r.g/255,r.b/255)}function Zi(r,e,t){let n=new Kt,i=r.attributes.position.array,s=r.attributes.position.itemSize||3;for(let u=0;u<i.length;u+=s){let h=i[u],f=i[u+1],p=i[u+2];n.AddVertex(new Xe(h,f,p))}let o=r.attributes.color!==void 0;if(o){let u=r.attributes.color.array,h=r.attributes.color.itemSize||3;for(let f=0;f<u.length;f+=h){let p=new Ve(u[f],u[f+1],u[f+2]);t!==null&&(p=t.Convert(p)),n.AddVertexColor(Jl(p))}}let a=r.attributes.normal!==void 0;if(a){let u=r.attributes.normal.array,h=r.attributes.normal.itemSize||3;for(let f=0;f<u.length;f+=h){let p=u[f],g=u[f+1],v=u[f+2];n.AddNormal(new Xe(p,g,v))}}let l=r.attributes.uv!==void 0;if(l){let u=r.attributes.uv.array,h=r.attributes.uv.itemSize||2;for(let f=0;f<u.length;f+=h){let p=u[f],g=u[f+1];n.AddTextureUV(new At(p,g))}}let c=null;if(r.index!==null)c=r.index.array;else{c=[];for(let u=0;u<i.length/3;u++)c.push(u)}for(let u=0;u<c.length;u+=3){let h=c[u],f=c[u+1],p=c[u+2],g=new Xt(h,f,p);o&&g.SetVertexColors(h,f,p),a&&g.SetNormals(h,f,p),l&&g.SetTextureUVs(h,f,p),e!==null&&g.SetMaterial(e),n.AddTriangle(g)}return n}function Od(r,e,t){let n=null;return r.type==="MeshPhongMaterial"?n=new Zt({color:wn(e),side:On}):r.type==="MeshStandardMaterial"?n=new gs({color:wn(e),side:On}):r.type==="LineBasicMaterial"&&(n=new Wn({color:wn(e)})),n!==null&&t&&(n.polygonOffset=!0,n.polygonOffsetUnit=1,n.polygonOffsetFactor=1),n}function ph(r,e,t){let n=new Map,i=[];for(let s of r){if(n.has(s.type)){i.push(n.get(s.type));continue}let o=Od(s,e,t);n.set(s.type,o),i.push(o)}return i}function mh(r){r!==null&&r.traverse(e=>{if(e.isMesh||e.isLineSegments){if(Array.isArray(e.material))for(let t of e.material)t.dispose();else e.material.dispose();e.userData=null,e.geometry.dispose()}})}function gh(r,e,t,n,i){function s(c,u,h,f,p,g){let v=new oe(p[3*g],p[3*g+1],p[3*g+2]);v.applyMatrix4(f.matrixWorld);let d=v.project(c);return new At((d.x+1)*u/2,-(d.y-1)*h/2)}let o=n.geometry.attributes.position.array,a=o.length/6,l=1/0;for(let c=0;c<a;c++){let u=new No(s(r,e,t,n,o,2*c),s(r,e,t,n,o,2*c+1));l=Math.min(l,Yc(u,i))}return l}var Dd=class{constructor(e){this.params={defaultLineMaterialColor:new Mt(0,0,0),defaultMaterialColor:new Mt(0,0,0)},co(e,this.params),this.defaultLineMaterialIndex=null,this.defaultMaterialIndex=null}Finalize(e){this.Reset(),this.FinalizeMeshes(e),this.FinalizeMaterials(e),this.FinalizeNodes(e)}FinalizeMaterials(e){if(e.VertexColorCount()===0)return;let t=new Map;for(let n=0;n<e.MeshCount();n++){let i=e.GetMesh(n);for(let s=0;s<i.TriangleCount();s++){let o=i.GetTriangle(s),a=o.HasVertexColors();t.has(o.mat)?a||t.set(o.mat,!1):t.set(o.mat,a)}}for(let[n,i]of t){let s=e.GetMaterial(n);s.vertexColors=i}}FinalizeMeshes(e){for(let t=0;t<e.MeshCount();t++){let n=e.GetMesh(t);if(ts(n)){e.RemoveMesh(t),t=t-1;continue}this.FinalizeMesh(e,n)}}FinalizeMesh(e,t){function n(s){function o(c,u,h,f,p){function g(_,y){for(let x=0;x<_.length;x++){let w=_[x];if(pi(w,y))return!0}return!1}let v=[],d=p.get(h);for(let _=0;_<d.length;_++){let y=d[_],x=c.GetTriangle(y);if(u.curve===x.curve){let w=f[y];g(v,w)||v.push(w)}}let m=new Xe(0,0,0);for(let _=0;_<v.length;_++)m=Bc(m,v[_]);return m.MultiplyScalar(1/v.length),m.Normalize(),c.AddNormal(m)}let a=[],l=new Map;for(let c=0;c<s.VertexCount();c++)l.set(c,[]);for(let c=0;c<s.TriangleCount();c++){let u=s.GetTriangle(c),h=s.GetVertex(u.v0),f=s.GetVertex(u.v1),p=s.GetVertex(u.v2),g=Ds(h,f,p);a.push(g),l.get(u.v0).push(c),l.get(u.v1).push(c),l.get(u.v2).push(c)}for(let c=0;c<s.TriangleCount();c++){let u=s.GetTriangle(c);if(!u.HasNormals()){let h=o(s,u,u.v0,a,l),f=o(s,u,u.v1,a,l),p=o(s,u,u.v2,a,l);u.SetNormals(h,f,p)}}}let i={calculateCurveNormals:!1};for(let s=0;s<t.LineCount();s++){let o=t.GetLine(s);o.mat===null&&(o.mat=this.GetDefaultMaterialIndex(e,yn.DefaultLine))}for(let s=0;s<t.TriangleCount();s++){let o=t.GetTriangle(s);this.FinalizeTriangle(t,o,i),o.mat===null&&(o.mat=this.GetDefaultMaterialIndex(e,yn.DefaultFace))}i.calculateCurveNormals&&n(t)}FinalizeTriangle(e,t,n){if(!t.HasNormals())if(t.curve===null||t.curve===0){let i=e.GetVertex(t.v0),s=e.GetVertex(t.v1),o=e.GetVertex(t.v2),a=Ds(i,s,o),l=e.AddNormal(a);t.SetNormals(l,l,l)}else n.calculateCurveNormals=!0;t.curve===null&&(t.curve=0)}FinalizeNodes(e){let t=e.GetRootNode(),n=[];t.EnumerateChildren(i=>{i.IsEmpty()&&n.push(i)});for(let i=0;i<n.length;i++){let s=n[i],o=s.GetParent();o!==null&&(o.RemoveChildNode(s),o.IsEmpty()&&n.push(o))}}GetDefaultMaterialIndex(e,t){function n(i,s,o,a){if(s!==null)return s;let l=new vn;return l.color=a,l.source=o,i.AddMaterial(l)}return t===yn.DefaultLine?(this.defaultLineMaterialIndex=n(e,this.defaultLineMaterialIndex,yn.DefaultLine,this.params.defaultLineMaterialColor),this.defaultLineMaterialIndex):t===yn.DefaultFace?(this.defaultMaterialIndex=n(e,this.defaultMaterialIndex,yn.DefaultFace,this.params.defaultMaterialColor),this.defaultMaterialIndex):null}Reset(){this.defaultLineMaterialIndex=null,this.defaultMaterialIndex=null}};function vh(r,e){new Dd(e).Finalize(r)}function S0(r){function e(s){return s!=null}function t(s){return!(!e(s)||isNaN(s))}function n(s,o){return!(!t(s)||s<0||s>=o)}function i(s,o){function a(l,c,u){return!(!n(u.v0,c.VertexCount())||!n(u.v1,c.VertexCount())||!n(u.v2,c.VertexCount())||u.HasVertexColors()&&(!n(u.c0,c.VertexColorCount())||!n(u.c1,c.VertexColorCount())||!n(u.c2,c.VertexColorCount()))||!n(u.n0,c.NormalCount())||!n(u.n1,c.NormalCount())||!n(u.n2,c.NormalCount())||u.HasTextureUVs()&&(!n(u.u0,c.TextureUVCount())||!n(u.u1,c.TextureUVCount())||!n(u.u2,c.TextureUVCount()))||!n(u.mat,l.MaterialCount())||!t(u.curve))}for(let l=0;l<o.VertexCount();l++){let c=o.GetVertex(l);if(!t(c.x)||!t(c.y)||!t(c.z))return!1}for(let l=0;l<o.VertexColorCount();l++){let c=o.GetVertexColor(l);if(!t(c.r)||!t(c.g)||!t(c.b))return!1}for(let l=0;l<o.NormalCount();l++){let c=o.GetNormal(l);if(!t(c.x)||!t(c.y)||!t(c.z))return!1}for(let l=0;l<o.TextureUVCount();l++){let c=o.GetTextureUV(l);if(!t(c.x)||!t(c.y))return!1}for(let l=0;l<o.TriangleCount();l++){let c=o.GetTriangle(l);if(!a(s,o,c))return!1}return!0}for(let s=0;s<r.MeshCount();s++){let o=r.GetMesh(s);if(!i(r,o))return!1}return!0}var Ht=class{constructor(){this.name=null,this.extension=null,this.callbacks=null,this.model=null,this.error=null,this.message=null}Import(e,t,n,i){this.Clear(),this.name=e,this.extension=t,this.callbacks=i,this.model=new dr,this.error=!1,this.message=null,this.ResetContent(),this.ImportContent(n,()=>{this.CreateResult(i)})}Clear(){this.name=null,this.extension=null,this.callbacks=null,this.model=null,this.error=null,this.message=null,this.ClearContent()}CreateResult(e){if(this.error){e.onError(),e.onComplete();return}if(Uo(this.model)){this.SetError(Ze("The model doesn't contain any meshes.")),e.onError(),e.onComplete();return}vh(this.model,{defaultLineMaterialColor:this.callbacks.getDefaultLineMaterialColor(),defaultMaterialColor:this.callbacks.getDefaultMaterialColor()}),e.onSuccess(),e.onComplete()}CanImportExtension(e){return!1}GetUpDirection(){return pt.Z}ClearContent(){}ResetContent(){}ImportContent(e,t){}GetModel(){return this.model}SetError(e){this.error=!0,e!=null&&(this.message=e)}WasError(){return this.error}GetErrorMessage(){return this.message}};var jr=class r{constructor(e){this.vertices=e,this.mat=null}HasVertices(){return this.vertices!==null&&this.vertices.length>=2}GetVertices(){return this.vertices}SetMaterial(e){return this.mat=e,this}SegmentCount(){return this.vertices===null?0:this.vertices.length-1}Clone(){let e=new r([...this.vertices]);return e.SetMaterial(this.mat),e}};var Ia=class extends Ht{constructor(){super(),this.rhino=null}CanImportExtension(e){return e==="3dm"}GetUpDirection(){return pt.Z}ClearContent(){this.instanceIdToObject=null,this.instanceIdToDefinition=null}ResetContent(){this.instanceIdToObject=new Map,this.instanceIdToDefinition=new Map}ImportContent(e,t){this.rhino===null?cr("rhino3dm").then(()=>{rhino3dm().then(n=>{this.rhino=n,this.ImportRhinoContent(e),t()})}).catch(()=>{this.SetError(Ze("Failed to load rhino3dm.")),t()}):(this.ImportRhinoContent(e),t())}ImportRhinoContent(e){let t=this.rhino.File3dm.fromByteArray(e);if(t===null){this.SetError(Ze("Failed to read Rhino file."));return}this.ImportRhinoDocument(t),Uo(this.model)&&this.SetError(Ze("The model doesn't contain any 3D meshes. Try to save the model while you are in shaded view in Rhino."))}ImportRhinoDocument(e){this.InitRhinoInstances(e),this.ImportRhinoUserStrings(e),this.ImportRhinoGeometry(e)}InitRhinoInstances(e){let t=e.objects();for(let i=0;i<t.count;i++){let s=t.get(i),o=s.attributes();o.isInstanceDefinitionObject&&this.instanceIdToObject.set(o.id,s)}let n=e.instanceDefinitions();for(let i=0;i<n.count;i++){let s=n.get(i);this.instanceIdToDefinition.set(s.id,s)}}ImportRhinoUserStrings(e){let t=e.strings();if(t.count>0){let n=new Vn(Ze("Document user texts"));for(let i=0;i<t.count;i++){let s=t.get(i);n.AddProperty(new nn(Vt.Text,s[0],s[1]))}this.model.AddPropertyGroup(n)}}ImportRhinoGeometry(e){let t=e.objects();for(let n=0;n<t.count;n++){let i=t.get(n);this.ImportRhinoGeometryObject(e,i,[])}}ImportRhinoGeometryObject(e,t,n){let i=t.geometry(),s=t.attributes(),o=i.objectType;if(!(s.isInstanceDefinitionObject&&n.length===0)){if(o===this.rhino.ObjectType.Mesh)this.ImportRhinoGeometryAsMesh(e,i,t,n);else if(o===this.rhino.ObjectType.Extrusion){let a=i.getMesh(this.rhino.MeshType.Any);a!==null&&(this.ImportRhinoGeometryAsMesh(e,a,t,n),a.delete())}else if(o===this.rhino.ObjectType.Brep){let a=new this.rhino.Mesh,l=i.faces();for(let c=0;c<l.count;c++){let u=l.get(c),h=u.getMesh(this.rhino.MeshType.Any);h&&(a.append(h),h.delete()),u.delete()}l.delete(),a.compact(),this.ImportRhinoGeometryAsMesh(e,a,t,n),a.delete()}else if(o===this.rhino.ObjectType.SubD){i.subdivide(3);let a=this.rhino.Mesh.createFromSubDControlNet(i,!0);a!==null&&(this.ImportRhinoGeometryAsMesh(e,a,t,n),a.delete())}else if(o===this.rhino.ObjectType.Curve)this.ImportRhinoGeometryAsMesh(e,i,t,n);else if(o===this.rhino.ObjectType.InstanceReference){let a=i.parentIdefId;if(this.instanceIdToDefinition.has(a)){let c=this.instanceIdToDefinition.get(a).getObjectIds();for(let u=0;u<c.length;u++){let h=c[u];if(this.instanceIdToObject.has(h)){let f=this.instanceIdToObject.get(h);n.push(t),this.ImportRhinoGeometryObject(e,f,n),n.pop()}}}}}}ImportRhinoGeometryAsMesh(e,t,n,i){function s(u){let h=u.domain[1]-u.domain[0],f=Math.max(parseInt(h/.2,10),1),p=h/f,g=[];for(let v=0;v<=f;v++)if(v===f&&u.isClosed)g.push(g[0]);else{let d=t.pointAt(u.domain[0]+v*p);g.push(a.AddVertex(Ei(d)))}return new jr(g)}let o=this.GetMaterialIndex(e,n,i),a=null;if(t.objectType===this.rhino.ObjectType.Mesh){let u=t.toThreejsJSON();a=Zi(u.data,o,null)}else if(t.objectType===this.rhino.ObjectType.Curve){if(a=new Kt,t instanceof this.rhino.LineCurve){let u=a.AddVertex(Ei(t.line.from)),h=a.AddVertex(Ei(t.line.to)),f=new jr([u,h]);f.SetMaterial(o),a.AddLine(f)}else if(t instanceof this.rhino.NurbsCurve){let u=s(t);u.SetMaterial(o),a.AddLine(u)}else if(t instanceof this.rhino.ArcCurve){let u=s(t);u.SetMaterial(o),a.AddLine(u)}}if(a===null)return null;let l=n.attributes();a.SetName(l.name);let c=l.getUserStrings();if(c.length>0){let u=new Vn(Ze("User texts"));for(let h=0;h<c.length;h++){let f=c[h];u.AddProperty(new nn(Vt.Text,f[0],f[1]))}a.AddPropertyGroup(u)}if(i.length!==0){let u=new fn().CreateIdentity();for(let f=i.length-1;f>=0;f--){let v=i[f].geometry().xform.toFloatArray(!1),d=new fn(v);u=u.MultiplyMatrix(d)}let h=new ln(u);hr(a,h)}this.model.AddMeshToRootNode(a)}GetMaterialIndex(e,t,n){function i(l,c,u){let h=c.attributes();if(h.materialSource===l.ObjectMaterialSource.MaterialFromObject){let f=h.materialIndex;if(f>-1)return e.materials().get(f)}else if(h.materialSource===l.ObjectMaterialSource.MaterialFromLayer){let f=h.layerIndex;if(f>-1){let p=e.layers().get(f),g=p.renderMaterialIndex;if(g>-1)return e.materials().get(g);if(c.geometry().objectType===l.ObjectType.Curve){let d=new l.Material;return d.name=p.name,d.diffuseColor=p.color,d}}}else if(h.materialSource===l.ObjectMaterialSource.MaterialFromParent&&u.length!==0)return i(l,u[0],[]);return null}function s(l,c){function u(d,m){d.Set(m.r,m.g,m.b)}function h(d){return d.r===0&&d.g===0&&d.b===0}function f(d){return d.r===255&&d.g===255&&d.b===255}let p=null,g=l.physicallyBased();g.supported?(p=new Qr,p.metalness=g.metallic?1:0,p.roughness=g.roughness):(p=new vn,u(p.ambient,l.ambientColor),u(p.specular,l.specularColor)),p.name=l.name,u(p.color,l.diffuseColor),p.opacity=1-l.transparency,si(p),h(p.color)&&!f(l.reflectionColor)&&u(p.color,l.reflectionColor),h(p.color)&&!f(l.transparentColor)&&u(p.color,l.transparentColor);let v=l.getBitmapTexture();if(v){let d=new ii,m=En(v.fileName),_=c.getFileBuffer(m);d.name=m,d.buffer=_,p.diffuseMap=d}return p}function o(l,c,u){let h=s(c,u);for(let f=0;f<l.MaterialCount();f++)if(l.GetMaterial(f).IsEqual(h))return f;return l.AddMaterial(h)}let a=i(this.rhino,t,n);return a===null?null:o(this.model,a,this.callbacks)}};var Qn=class{constructor(e,t){this.arrayBuffer=e,this.dataView=new DataView(e),this.isLittleEndian=t,this.position=0}GetPosition(){return this.position}SetPosition(e){this.position=e}GetByteLength(){return this.arrayBuffer.byteLength}Skip(e){this.position=this.position+e}End(){return this.position>=this.arrayBuffer.byteLength}ReadArrayBuffer(e){let t=new Uint8Array(this.arrayBuffer),n=new ArrayBuffer(e),i=new Uint8Array(n),s=t.subarray(this.position,this.position+e);return i.set(s,0),this.position+=e,n}ReadBoolean8(){let e=this.dataView.getInt8(this.position);return this.position=this.position+1,!!e}ReadCharacter8(){let e=this.dataView.getInt8(this.position);return this.position=this.position+1,e}ReadUnsignedCharacter8(){let e=this.dataView.getUint8(this.position);return this.position=this.position+1,e}ReadInteger16(){let e=this.dataView.getInt16(this.position,this.isLittleEndian);return this.position=this.position+2,e}ReadUnsignedInteger16(){let e=this.dataView.getUint16(this.position,this.isLittleEndian);return this.position=this.position+2,e}ReadInteger32(){let e=this.dataView.getInt32(this.position,this.isLittleEndian);return this.position=this.position+4,e}ReadUnsignedInteger32(){let e=this.dataView.getUint32(this.position,this.isLittleEndian);return this.position=this.position+4,e}ReadFloat32(){let e=this.dataView.getFloat32(this.position,this.isLittleEndian);return this.position=this.position+4,e}ReadDouble64(){let e=this.dataView.getFloat64(this.position,this.isLittleEndian);return this.position=this.position+8,e}};var vt={MAIN3DS:19789,EDIT3DS:15677,EDIT_MATERIAL:45055,MAT_NAME:40960,MAT_AMBIENT:40976,MAT_DIFFUSE:40992,MAT_SPECULAR:41008,MAT_SHININESS:41024,MAT_SHININESS_STRENGTH:41025,MAT_TRANSPARENCY:41040,MAT_COLOR_F:16,MAT_COLOR:17,MAT_LIN_COLOR:18,MAT_LIN_COLOR_F:19,MAT_TEXMAP:41472,MAT_TEXMAP_NAME:41728,MAT_TEXMAP_UOFFSET:41816,MAT_TEXMAP_VOFFSET:41818,MAT_TEXMAP_USCALE:41812,MAT_TEXMAP_VSCALE:41814,MAT_TEXMAP_ROTATION:41820,PERCENTAGE:48,PERCENTAGE_F:49,EDIT_OBJECT:16384,OBJ_TRIMESH:16640,OBJ_LIGHT:17920,OBJ_CAMERA:18176,TRI_VERTEX:16656,TRI_TEXVERTEX:16704,TRI_FACE:16672,TRI_TRANSFORMATION:16736,TRI_MATERIAL:16688,TRI_SMOOTH:16720,KF3DS:45056,OBJECT_NODE:45058,OBJECT_HIERARCHY:45072,OBJECT_INSTANCE_NAME:45073,OBJECT_PIVOT:45075,OBJECT_POSITION:45088,OBJECT_ROTATION:45089,OBJECT_SCALE:45090,OBJECT_ID:45104},Fd=class{constructor(){this.id=-1,this.name="",this.flags=-1,this.parentId=-1,this.instanceName="",this.pivot=[0,0,0],this.positions=[],this.rotations=[],this.scales=[]}},Ud=class{constructor(){this.nodes=[],this.nodeIdToNode=new Map}IsEmpty(){return this.nodes.length===0}AddNode(e){this.nodes.push(e),this.nodeIdToNode.set(e.nodeId,e)}GetNodes(){return this.nodes}},Pa=class extends Ht{constructor(){super()}CanImportExtension(e){return e==="3ds"}GetUpDirection(){return pt.Z}ClearContent(){this.materialNameToIndex=null,this.meshNameToIndex=null,this.nodeList=null}ResetContent(){this.materialNameToIndex=new Map,this.meshNameToIndex=new Map,this.nodeList=new Ud}ImportContent(e,t){this.ProcessBinary(e),t()}ProcessBinary(e){let t=new Qn(e,!0),n=t.GetByteLength();this.ReadChunks(t,n,(i,s)=>{i===vt.MAIN3DS?this.ReadMainChunk(t,s):this.SkipChunk(t,s)})}ReadMainChunk(e,t){let n=this.GetChunkEnd(e,t);this.ReadChunks(e,n,(i,s)=>{i===vt.EDIT3DS?this.ReadEditorChunk(e,s):i===vt.KF3DS?this.ReadKeyFrameChunk(e,s):this.SkipChunk(e,s)}),this.BuildNodeHierarchy()}ReadEditorChunk(e,t){let n=this.GetChunkEnd(e,t);this.ReadChunks(e,n,(i,s)=>{i===vt.EDIT_MATERIAL?this.ReadMaterialChunk(e,s):i===vt.EDIT_OBJECT?this.ReadObjectChunk(e,s):this.SkipChunk(e,s)})}ReadMaterialChunk(e,t){let n=new vn,i=this.GetChunkEnd(e,t),s=null,o=null;this.ReadChunks(e,i,(l,c)=>{l===vt.MAT_NAME?n.name=this.ReadName(e):l===vt.MAT_AMBIENT?n.ambient=this.ReadColorChunk(e,c):l===vt.MAT_DIFFUSE?n.color=this.ReadColorChunk(e,c):l===vt.MAT_SPECULAR?n.specular=this.ReadColorChunk(e,c):l===vt.MAT_SHININESS?s=this.ReadPercentageChunk(e,c):l===vt.MAT_SHININESS_STRENGTH?o=this.ReadPercentageChunk(e,c):l===vt.MAT_TRANSPARENCY?(n.opacity=1-this.ReadPercentageChunk(e,c),si(n)):l===vt.MAT_TEXMAP?(n.diffuseMap=this.ReadTextureMapChunk(e,c),si(n)):this.SkipChunk(e,c)}),s!==null&&o!==null&&(n.shininess=s*o/10);let a=this.model.AddMaterial(n);this.materialNameToIndex.set(n.name,a)}ReadTextureMapChunk(e,t){let n=new ii,i=this.GetChunkEnd(e,t);return this.ReadChunks(e,i,(s,o)=>{if(s===vt.MAT_TEXMAP_NAME){let a=this.ReadName(e),l=this.callbacks.getFileBuffer(a);n.name=a,n.buffer=l}else s===vt.MAT_TEXMAP_UOFFSET?n.offset.x=e.ReadFloat32():s===vt.MAT_TEXMAP_VOFFSET?n.offset.y=e.ReadFloat32():s===vt.MAT_TEXMAP_USCALE?n.scale.x=e.ReadFloat32():s===vt.MAT_TEXMAP_VSCALE?n.scale.y=e.ReadFloat32():s===vt.MAT_TEXMAP_ROTATION?n.rotation=e.ReadFloat32()*ar:this.SkipChunk(e,o)}),n}ReadColorChunk(e,t){let n=new Mt(0,0,0),i=this.GetChunkEnd(e,t),s=!1;return this.ReadChunks(e,i,(o,a)=>{o===vt.MAT_COLOR?s||(n.r=e.ReadUnsignedCharacter8(),n.g=e.ReadUnsignedCharacter8(),n.b=e.ReadUnsignedCharacter8()):o===vt.MAT_LIN_COLOR?(n.r=e.ReadUnsignedCharacter8(),n.g=e.ReadUnsignedCharacter8(),n.b=e.ReadUnsignedCharacter8(),s=!0):o===vt.MAT_COLOR_F?s||(n.r=Rn(e.ReadFloat32()),n.g=Rn(e.ReadFloat32()),n.b=Rn(e.ReadFloat32())):o===vt.MAT_LIN_COLOR_F?(n.r=Rn(e.ReadFloat32()),n.g=Rn(e.ReadFloat32()),n.b=Rn(e.ReadFloat32()),s=!0):this.SkipChunk(e,a)}),n}ReadPercentageChunk(e,t){let n=0,i=this.GetChunkEnd(e,t);return this.ReadChunks(e,i,(s,o)=>{s===vt.PERCENTAGE?n=e.ReadUnsignedInteger16()/100:s===vt.PERCENTAGE_F?n=e.ReadFloat32():this.SkipChunk(e,o)}),n}ReadObjectChunk(e,t){let n=this.GetChunkEnd(e,t),i=this.ReadName(e);this.ReadChunks(e,n,(s,o)=>{s===vt.OBJ_TRIMESH?this.ReadMeshChunk(e,o,i):this.SkipChunk(e,o)})}ReadMeshChunk(e,t,n){function i(u,h){if(!h.IsValid())return;let f=h.Determinant(),p=Cr(f);p&&(h=new fn().CreateScale(-1,1,1).MultiplyMatrix(h));let g=h.Invert();if(g===null)return;let v=new ln(g);hr(u,v),p&&jc(u)}let s=new Kt;s.SetName(n);let o=this.GetChunkEnd(e,t),a=null;if(this.ReadChunks(e,o,(u,h)=>{u===vt.TRI_VERTEX?this.ReadVerticesChunk(s,e):u===vt.TRI_TEXVERTEX?this.ReadTextureVerticesChunk(s,e):u===vt.TRI_FACE?this.ReadFacesChunk(s,e,h):u===vt.TRI_TRANSFORMATION?a=this.ReadTransformationChunk(e):this.SkipChunk(e,h)}),s.VertexCount()===s.TextureUVCount())for(let u=0;u<s.TriangleCount();u++){let h=s.GetTriangle(u);h.SetTextureUVs(h.v0,h.v1,h.v2)}let l=new fn(a);i(s,l);let c=this.model.AddMesh(s);this.meshNameToIndex.set(s.GetName(),c)}ReadVerticesChunk(e,t){let n=t.ReadUnsignedInteger16();for(let i=0;i<n;i++){let s=t.ReadFloat32(),o=t.ReadFloat32(),a=t.ReadFloat32();e.AddVertex(new Xe(s,o,a))}}ReadTextureVerticesChunk(e,t){let n=t.ReadUnsignedInteger16();for(let i=0;i<n;i++){let s=t.ReadFloat32(),o=t.ReadFloat32();e.AddTextureUV(new At(s,o))}}ReadFacesChunk(e,t,n){let i=this.GetChunkEnd(t,n),s=t.ReadUnsignedInteger16();for(let o=0;o<s;o++){let a=t.ReadUnsignedInteger16(),l=t.ReadUnsignedInteger16(),c=t.ReadUnsignedInteger16();t.ReadUnsignedInteger16(),e.AddTriangle(new Xt(a,l,c))}this.ReadChunks(t,i,(o,a)=>{o===vt.TRI_MATERIAL?this.ReadFaceMaterialsChunk(e,t):o===vt.TRI_SMOOTH?this.ReadFaceSmoothingGroupsChunk(e,s,t):this.SkipChunk(t,a)})}ReadFaceMaterialsChunk(e,t){let n=this.ReadName(t),i=this.materialNameToIndex.get(n),s=t.ReadUnsignedInteger16();for(let o=0;o<s;o++){let a=t.ReadUnsignedInteger16(),l=e.GetTriangle(a);i!==void 0&&(l.mat=i)}}ReadFaceSmoothingGroupsChunk(e,t,n){for(let i=0;i<t;i++){let s=n.ReadUnsignedInteger32(),o=e.GetTriangle(i);o.curve=s}}ReadTransformationChunk(e){let t=[];for(let n=0;n<4;n++){for(let i=0;i<3;i++)t.push(e.ReadFloat32());n<3?t.push(0):t.push(1)}return t}ReadKeyFrameChunk(e,t){let n=this.GetChunkEnd(e,t);this.ReadChunks(e,n,(i,s)=>{i===vt.OBJECT_NODE?this.ReadObjectNodeChunk(e,s):this.SkipChunk(e,s)})}BuildNodeHierarchy(){function e(n,i){function s(c){return c.positions.length===0?[0,0,0]:c.positions[0]}function o(c){function u(f){let p=[0,0,0,1],g=Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2]);if(g>0){let v=f[3]*-.5,d=Math.sin(v)/g;p=[d*f[0],d*f[1],d*f[2],Math.cos(v)]}return p}if(c.rotations.length===0)return[0,0,0,1];let h=c.rotations[0];return u(h)}function a(c){return c.scales.length===0?[1,1,1]:c.scales[0]}let l=new fn;if(l.ComposeTRS(Ei(s(n)),bo(o(n)),Ei(a(n))),i){let c=n.pivot;l=new fn().CreateTranslation(-c[0],-c[1],-c[2]).MultiplyMatrix(l)}return new ln(l)}let t=this.model.GetRootNode();if(this.nodeList.IsEmpty())for(let n=0;n<this.model.MeshCount();n++)t.AddMeshIndex(n);else{let n=new Map;for(let i of this.nodeList.GetNodes()){let s=new Nn;i.name.length>0&&i.name!=="$$$DUMMY"&&(s.SetName(i.name),i.instanceName.length>0&&s.SetName(s.GetName()+" "+i.instanceName)),i.parentId===65535||!n.has(i.parentId)?t.AddChildNode(s):n.get(i.parentId).AddChildNode(s),n.set(i.id,s);let o=this.meshNameToIndex.has(i.name);s.SetTransformation(e(i,o)),o&&s.AddMeshIndex(this.meshNameToIndex.get(i.name))}}}ReadObjectNodeChunk(e,t){function n(o,a,l){let c=[];a.Skip(10);let u=a.ReadInteger32();for(let h=0;h<u;h++){a.ReadInteger32(),a.ReadUnsignedInteger16()!==0&&a.ReadFloat32();let p=null;if(l===vt.OBJECT_ROTATION){let g=a.ReadFloat32();p=o.ReadVector(a),p[3]=g}else p=o.ReadVector(a);c.push(p)}return c}let i=new Fd,s=this.GetChunkEnd(e,t);this.ReadChunks(e,s,(o,a)=>{o===vt.OBJECT_HIERARCHY?(i.name=this.ReadName(e),i.flags=e.ReadUnsignedInteger32(),i.parentId=e.ReadUnsignedInteger16()):o===vt.OBJECT_INSTANCE_NAME?i.instanceName=this.ReadName(e):o===vt.OBJECT_PIVOT?i.pivot=this.ReadVector(e):o===vt.OBJECT_POSITION?i.positions=n(this,e,vt.OBJECT_POSITION):o===vt.OBJECT_ROTATION?i.rotations=n(this,e,vt.OBJECT_ROTATION):o===vt.OBJECT_SCALE?i.scales=n(this,e,vt.OBJECT_SCALE):o===vt.OBJECT_ID?i.id=e.ReadUnsignedInteger16():this.SkipChunk(e,a)}),this.nodeList.AddNode(i)}ReadName(e){let t="",n=0,i=0;for(;i<64&&(n=e.ReadCharacter8(),n!==0);)t=t+String.fromCharCode(n),i=i+1;return t}ReadVector(e){return[e.ReadFloat32(),e.ReadFloat32(),e.ReadFloat32()]}ReadChunks(e,t,n){for(;e.GetPosition()<=t-6;){let i=e.ReadUnsignedInteger16(),s=e.ReadUnsignedInteger32();n(i,s)}}GetChunkEnd(e,t){return e.GetPosition()+t-6}SkipChunk(e,t){e.Skip(t-6)}};var ui={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},Ji={SCALAR:0,VEC2:1,VEC3:2,VEC4:3,MAT2:4,MAT3:5,MAT4:6},no={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},kd={GLTF_STRING:1179937895,JSON_CHUNK_TYPE:1313821514,BINARY_CHUNK_TYPE:5130562};function $l(r){return di(Ns(r[0]),Ns(r[1]),Ns(r[2]))}function Ub(r,e){function t(n,i){let s=n;return i===ui.UNSIGNED_BYTE?s/=255:i===ui.UNSIGNED_SHORT&&(s/=65535),Rn(Ns(s))}return new Mt(t(r[0],e),t(r[1],e),t(r[2],e))}var Bd=class{constructor(e){this.reader=new Qn(e,!0),this.componentType=null,this.dataType=null,this.byteStride=null,this.dataCount=null,this.sparseReader=null}SetComponentType(e){this.componentType=e}SetDataType(e){e==="SCALAR"?this.dataType=Ji.SCALAR:e==="VEC2"?this.dataType=Ji.VEC2:e==="VEC3"?this.dataType=Ji.VEC3:e==="VEC4"?this.dataType=Ji.VEC4:e==="MAT2"?this.dataType=Ji.MAT2:e==="MAT3"?this.dataType=Ji.MAT3:e==="MAT4"&&(this.dataType=Ji.MAT4)}SetByteStride(e){this.byteStride=e}SetDataCount(e){this.dataCount=e}SetSparseReader(e,t){this.sparseReader={indexReader:e,valueReader:t}}ReadArrayBuffer(e){return this.reader.ReadArrayBuffer(e)}GetDataCount(){return this.dataCount}ReadData(){if(this.dataType===null)return null;if(this.dataType===Ji.SCALAR){let e=this.ReadComponent();return this.SkipBytesByStride(1),e}else if(this.dataType===Ji.VEC2){let e=this.ReadComponent(),t=this.ReadComponent();return this.SkipBytesByStride(2),new At(e,t)}else if(this.dataType===Ji.VEC3){let e=this.ReadComponent(),t=this.ReadComponent(),n=this.ReadComponent();return this.SkipBytesByStride(3),new Xe(e,t,n)}else if(this.dataType===Ji.VEC4){let e=this.ReadComponent(),t=this.ReadComponent(),n=this.ReadComponent(),i=this.ReadComponent();return this.SkipBytesByStride(4),new Vi(e,t,n,i)}return null}EnumerateData(e){if(this.sparseReader===null)for(let t=0;t<this.dataCount;t++)e(this.ReadData());else{let t=[];for(let i=0;i<this.sparseReader.indexReader.GetDataCount();i++){let s=this.sparseReader.indexReader.ReadData(),o=this.sparseReader.valueReader.ReadData();t.push({index:s,value:o})}let n=0;for(let i=0;i<this.dataCount;i++){let s=this.ReadData();n<t.length&&t[n].index===i?(e(t[n].value),n+=1):e(s)}}}SkipBytes(e){this.reader.Skip(e)}ReadComponent(){return this.componentType===null?null:this.componentType===ui.BYTE?this.reader.ReadCharacter8():this.componentType===ui.UNSIGNED_BYTE?this.reader.ReadUnsignedCharacter8():this.componentType===ui.SHORT?this.reader.ReadInteger16():this.componentType===ui.UNSIGNED_SHORT?this.reader.ReadUnsignedInteger16():this.componentType===ui.UNSIGNED_INT?this.reader.ReadInteger32():this.componentType===ui.FLOAT?this.reader.ReadFloat32():null}SkipBytesByStride(e){if(this.byteStride===null)return;let t=e*this.GetComponentSize();this.reader.Skip(this.byteStride-t)}GetComponentSize(){return this.componentType===ui.BYTE||this.componentType===ui.UNSIGNED_BYTE?1:this.componentType===ui.SHORT||this.componentType===ui.UNSIGNED_SHORT?2:this.componentType===ui.UNSIGNED_INT||this.componentType===ui.FLOAT?4:0}},Gd=class{constructor(){this.supportedExtensions=["KHR_draco_mesh_compression","KHR_materials_pbrSpecularGlossiness","KHR_texture_transform"],this.draco=null}LoadLibraries(e,t){if(e===void 0){t.onSuccess();return}this.draco===null&&e.indexOf("KHR_draco_mesh_compression")!==-1?cr("draco3d").then(()=>{DracoDecoderModule().then(n=>{this.draco=n,t.onSuccess()})}).catch(()=>{t.onError(Ze("Failed to load draco decoder."))}):t.onSuccess()}GetUnsupportedExtensions(e){let t=[];if(e===void 0)return t;for(let n=0;n<e.length;n++){let i=e[n];this.supportedExtensions.indexOf(i)===-1&&t.push(i)}return t}ProcessMaterial(e,t,n){if(e.extensions===void 0)return null;let i=e.extensions.KHR_materials_pbrSpecularGlossiness;if(i===void 0)return null;let s=new vn,o=i.diffuseFactor;o!==void 0&&(s.color=$l(o),s.opacity=o[3]);let a=i.diffuseTexture;a!==void 0&&(s.diffuseMap=n(a));let l=i.specularFactor;l!==void 0&&(s.specular=$l(l));let c=i.specularGlossinessTexture;c!==void 0&&(s.specularMap=n(c));let u=i.glossinessFactor;return u!==void 0&&(s.shininess=u),s}ProcessTexture(e,t){if(e.extensions===void 0)return;let n=e.extensions.KHR_texture_transform;n!==void 0&&(n.offset!==void 0&&(t.offset.x=n.offset[0],t.offset.y=-n.offset[1]),n.scale!==void 0&&(t.scale.x=n.scale[0],t.scale.y=n.scale[1]),n.rotation!==void 0&&(t.rotation=-n.rotation))}ProcessPrimitive(e,t,n,i){function s(N,O,B,ie,$){let te=O.GetAttributeByUniqueId(B,ie),W=te.num_components(),de=B.num_points()*W,ye=de*4,Me=N._malloc(ye);O.GetAttributeDataArrayForAllPoints(B,te,N.DT_FLOAT32,ye,Me);let ve=new Float32Array(N.HEAPF32.buffer,Me,de).slice();if(W===2)for(let R=0;R<ve.length;R+=2)$(new At(ve[R+0],ve[R+1]));else if(W===3)for(let R=0;R<ve.length;R+=3)$(new Xe(ve[R+0],ve[R+1],ve[R+2]));else if(W===4)for(let R=0;R<ve.length;R+=4)$(new Vi(ve[R+0],ve[R+1],ve[R+2],ve[R+3]));N._free(Me)}if(this.draco===null||n.extensions===void 0||n.extensions.KHR_draco_mesh_compression===void 0)return!1;let o=new this.draco.Decoder,a=new this.draco.DecoderBuffer,l=n.extensions.KHR_draco_mesh_compression,c=t.bufferViews[l.bufferView],h=e.GetReaderFromBufferView(c).ReadArrayBuffer(c.byteLength);if(a.Init(new Int8Array(h),h.byteLength),o.GetEncodedGeometryType(a)!==this.draco.TRIANGULAR_MESH)return!0;let p=new this.draco.Mesh;if(!o.DecodeBufferToMesh(a,p).ok())return!0;let v=l.attributes.POSITION!==void 0,d=!1,m=l.attributes.NORMAL!==void 0,_=l.attributes.TEXCOORD_0!==void 0;if(!v)return!0;let y=i.VertexCount(),x=i.VertexColorCount(),w=i.NormalCount(),I=i.TextureUVCount();s(this.draco,o,p,l.attributes.POSITION,N=>{i.AddVertex(N)}),m&&s(this.draco,o,p,l.attributes.NORMAL,N=>{i.AddNormal(N)}),_&&s(this.draco,o,p,l.attributes.TEXCOORD_0,N=>{N.y=-N.y,i.AddTextureUV(N)});let P=p.num_faces()*3,E=P*4,M=this.draco._malloc(E);o.GetTrianglesUInt32Array(p,E,M);let L=new Uint32Array(this.draco.HEAPU32.buffer,M,P).slice();for(let N=0;N<L.length;N+=3){let O=L[N],B=L[N+1],ie=L[N+2];e.AddTriangle(n,i,O,B,ie,d,m,_,y,x,w,I)}return this.draco._free(M),!0}},Na=class extends Ht{constructor(){super(),this.gltfExtensions=new Gd}CanImportExtension(e){return e==="gltf"||e==="glb"}GetUpDirection(){return pt.Y}ClearContent(){this.bufferContents=null,this.imageIndexToTextureParams=null}ResetContent(){this.bufferContents=[],this.imageIndexToTextureParams=new Map}ImportContent(e,t){this.extension==="gltf"?this.ProcessGltf(e,t):this.extension==="glb"&&this.ProcessBinaryGltf(e,t)}ProcessGltf(e,t){let n=xn(e),i=JSON.parse(n);if(i.asset.version!=="2.0"){this.SetError(Ze("Invalid glTF version.")),t();return}for(let s=0;s<i.buffers.length;s++){let o=null,a=i.buffers[s],l=Ls(a.uri);if(l!==null)o=l.buffer;else{let c=this.callbacks.getFileBuffer(a.uri);c!==null&&(o=c)}if(o===null){this.SetError(Ze("One of the requested buffers is missing.")),t();return}this.bufferContents.push(o)}this.ProcessMainFile(i,t)}ProcessBinaryGltf(e,t){function n(c){let u=c.ReadUnsignedInteger32(),h=c.ReadUnsignedInteger32(),f=c.ReadArrayBuffer(u);return{type:h,buffer:f}}let i=new Qn(e,!0);if(i.ReadUnsignedInteger32()!==kd.GLTF_STRING){this.SetError(Ze("Invalid glTF file.")),t();return}if(i.ReadUnsignedInteger32()!==2){this.SetError(Ze("Invalid glTF version.")),t();return}if(i.ReadUnsignedInteger32()!==i.GetByteLength()){this.SetError(Ze("Invalid glTF file.")),t();return}let l=null;for(;!i.End();){let c=n(i);c.type===kd.JSON_CHUNK_TYPE?l=xn(c.buffer):c.type===kd.BINARY_CHUNK_TYPE&&this.bufferContents.push(c.buffer)}if(l!==null){let c=JSON.parse(l);this.ProcessMainFile(c,t)}}ProcessMainFile(e,t){let n=this.gltfExtensions.GetUnsupportedExtensions(e.extensionsRequired);if(n.length>0){this.SetError(uo("Unsupported extension: {0}.",n.join(", "))),t();return}this.gltfExtensions.LoadLibraries(e.extensionsRequired,{onSuccess:()=>{this.ImportModel(e),t()},onError:i=>{this.SetError(i),t()}})}ImportModel(e){let t=e.materials;if(t!==void 0)for(let i of t)this.ImportMaterial(e,i);let n=e.meshes;if(n!==void 0)for(let i of n)this.ImportMesh(e,i);this.ImportProperties(this.model,e.asset,Ze("Asset properties")),this.ImportScene(e)}ImportProperties(e,t,n){if(t==null)return;let i=new Vn(n);for(let s in t)if(Object.prototype.hasOwnProperty.call(t,s)){let o=null,a=t[s];typeof a=="string"?o=new nn(Vt.Text,s,a):typeof a=="number"&&(Number.isInteger(a)?o=new nn(Vt.Integer,s,a):o=new nn(Vt.Number,s,a)),o!==null&&i.AddProperty(o)}i.PropertyCount()!==0&&e.AddPropertyGroup(i)}GetDefaultScene(e){let t=e.scene||0;return t>=e.scenes.length?null:e.scenes[t]}ImportMaterial(e,t){let n=new Qr;if(t.name!==void 0&&(n.name=t.name),n.color=$l([1,1,1]),t.pbrMetallicRoughness!==void 0){let s=t.pbrMetallicRoughness.baseColorFactor;s!==void 0&&(n.color=$l(s),n.opacity=s[3]);let o=t.pbrMetallicRoughness.metallicFactor;o!==void 0&&(n.metalness=o);let a=t.pbrMetallicRoughness.roughnessFactor;a!==void 0&&(n.roughness=a);let l=t.emissiveFactor;l!==void 0&&(n.emissive=$l(l)),n.diffuseMap=this.ImportTexture(e,t.pbrMetallicRoughness.baseColorTexture),n.metalnessMap=this.ImportTexture(e,t.pbrMetallicRoughness.metallicRoughnessTexture),n.normalMap=this.ImportTexture(e,t.normalTexture),n.emissiveMap=this.ImportTexture(e,t.emissiveTexture),n.diffuseMap!==null&&(n.multiplyDiffuseMap=!0);let c=t.alphaMode;c!==void 0&&(c==="BLEND"?n.transparent=!0:c==="MASK"&&(n.transparent=!0,n.alphaTest=t.alphaCutoff||.5))}let i=this.gltfExtensions.ProcessMaterial(t,n,s=>this.ImportTexture(e,s));i!==null&&(n=i),this.model.AddMaterial(n)}ImportTexture(e,t){if(t==null)return null;let n=new ii,s=e.textures[t.index].source,o=e.images[s],a=null;if(this.imageIndexToTextureParams.has(s))a=this.imageIndexToTextureParams.get(s);else{a={name:null,mimeType:null,buffer:null};let l=s.toString();if(o.uri!==void 0){let c=Ls(o.uri);if(c!==null)a.name="Embedded_"+l+"."+es(c.mimeType),a.mimeType=c.mimeType,a.buffer=c.buffer;else{let u=this.callbacks.getFileBuffer(o.uri);a.name=o.uri,a.buffer=u}}else if(o.bufferView!==void 0){let c=e.bufferViews[o.bufferView],u=this.GetReaderFromBufferView(c);if(u!==null){let h=u.ReadArrayBuffer(c.byteLength);a.name="Binary_"+l+"."+es(o.mimeType),a.mimeType=o.mimeType,a.buffer=h}}this.imageIndexToTextureParams.set(s,a)}return n.name=a.name,n.mimeType=a.mimeType,n.buffer=a.buffer,this.gltfExtensions.ProcessTexture(t,n),n}ImportMesh(e,t){let n=new Kt;this.model.AddMesh(n),t.name!==void 0&&n.SetName(t.name);for(let i=0;i<t.primitives.length;i++){let s=t.primitives[i];this.ImportPrimitive(e,s,n)}this.ImportProperties(n,t.extras,Ze("Mesh properties"))}ImportPrimitive(e,t,n){function i(m,_,y){let x=_.attributes[y];if(x===void 0)return!1;let w=m.accessors[x];return!(w===void 0||w.count===0)}if(this.gltfExtensions.ProcessPrimitive(this,e,t,n)||t.attributes===void 0)return;let s=i(e,t,"POSITION"),o=i(e,t,"COLOR_0"),a=i(e,t,"NORMAL"),l=i(e,t,"TEXCOORD_0"),c=t.indices!==void 0,u=no.TRIANGLES;if(t.mode!==void 0&&(u=t.mode),u!==no.TRIANGLES&&u!==no.TRIANGLE_STRIP&&u!==no.TRIANGLE_FAN)return;let h=n.VertexCount(),f=n.VertexColorCount(),p=n.NormalCount(),g=n.TextureUVCount();if(s){let m=e.accessors[t.attributes.POSITION],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(y=>{n.AddVertex(y)})}else return;let v=n.VertexCount()-h;if(o){let m=e.accessors[t.attributes.COLOR_0],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(y=>{let x=Ub([y.x,y.y,y.z],_.componentType);n.AddVertexColor(x)}),n.VertexColorCount()-f!==v&&(o=!1)}if(a){let m=e.accessors[t.attributes.NORMAL],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(y=>{n.AddNormal(y)}),n.NormalCount()-p!==v&&(a=!1)}if(l){let m=e.accessors[t.attributes.TEXCOORD_0],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(y=>{y.y=-y.y,n.AddTextureUV(y)}),n.TextureUVCount()-g!==v&&(l=!1)}let d=[];if(c){let m=e.accessors[t.indices],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(y=>{d.push(y)})}else{let m=n.VertexCount()-h;for(let _=0;_<m;_++)d.push(_)}if(u===no.TRIANGLES)for(let m=0;m<d.length;m+=3){let _=d[m],y=d[m+1],x=d[m+2];this.AddTriangle(t,n,_,y,x,o,a,l,h,f,p,g)}else if(u===no.TRIANGLE_STRIP)for(let m=0;m<d.length-2;m++){let _=d[m],y=d[m+1],x=d[m+2];if(m%2===1){let w=y;y=x,x=w}this.AddTriangle(t,n,_,y,x,o,a,l,h,f,p,g)}else if(u===no.TRIANGLE_FAN)for(let m=1;m<d.length-1;m++){let _=d[0],y=d[m],x=d[m+1];this.AddTriangle(t,n,_,y,x,o,a,l,h,f,p,g)}}AddTriangle(e,t,n,i,s,o,a,l,c,u,h,f){let p=new Xt(c+n,c+i,c+s);o&&p.SetVertexColors(u+n,u+i,u+s),a&&p.SetNormals(h+n,h+i,h+s),l&&p.SetTextureUVs(f+n,f+i,f+s),e.material!==void 0&&(p.mat=e.material),t.AddTriangle(p)}ImportScene(e){let t=this.GetDefaultScene(e);if(t===null)return;let n=this.model.GetRootNode();for(let i of t.nodes){let s=e.nodes[i];this.ImportNode(e,s,n)}this.ImportProperties(this.model,t.extras,Ze("Scene properties"))}ImportNode(e,t,n){function i(o){let a=new fn().CreateIdentity();if(o.matrix!==void 0)a.Set(o.matrix);else{let l=[0,0,0],c=[0,0,0,1],u=[1,1,1];o.translation!==void 0&&(l=o.translation),o.rotation!==void 0&&(c=o.rotation),o.scale!==void 0&&(u=o.scale),a.ComposeTRS(Ei(l),bo(c),Ei(u))}return new ln(a)}if(t.children===void 0&&t.mesh===void 0)return;let s=new Nn;if(t.name!==void 0&&s.SetName(t.name),s.SetTransformation(i(t)),n.AddChildNode(s),t.children!==void 0)for(let o of t.children){let a=e.nodes[o];this.ImportNode(e,a,s)}if(t.mesh!==void 0){let o=this.model.GetMesh(t.mesh);this.ImportProperties(o,t.extras,Ze("Node properties")),s.AddMeshIndex(t.mesh)}}GetReaderFromBufferView(e){let t=e.buffer||0,n=this.bufferContents[t];if(n==null)return null;let i=new Bd(n);i.SkipBytes(e.byteOffset||0);let s=e.byteStride;return s!==void 0&&s!==0&&i.SetByteStride(s),i}GetReaderFromAccessor(e,t){let n=t.bufferView||0,i=e.bufferViews[n],s=this.GetReaderFromBufferView(i);if(s===null)return null;if(s.SetComponentType(t.componentType),s.SetDataType(t.type),s.SetDataCount(t.count),s.SkipBytes(t.byteOffset||0),t.sparse!==void 0){let o=this.GetReaderFromSparseAccessor(e,t.sparse.indices,t.sparse.indices.componentType,"SCALAR",t.sparse.count),a=this.GetReaderFromSparseAccessor(e,t.sparse.values,t.componentType,t.type,t.sparse.count);o!==null&&a!==null&&s.SetSparseReader(o,a)}return s}GetReaderFromSparseAccessor(e,t,n,i,s){if(t.bufferView===void 0)return null;let o=e.bufferViews[t.bufferView],a=this.GetReaderFromBufferView(o);return a===null?null:(a.SetComponentType(n),a.SetDataType(i),a.SetDataCount(s),a.SkipBytes(t.byteOffset||0),a)}};var La=class extends Ht{constructor(){super(),this.ifc=null}CanImportExtension(e){return e==="ifc"}GetUpDirection(){return pt.Y}ClearContent(){this.expressIDToMesh=null,this.colorToMaterial=null}ResetContent(){this.expressIDToMesh=new Map,this.colorToMaterial=new ri(this.model)}ImportContent(e,t){this.ifc===null?cr("webifc").then(()=>{this.ifc=new WebIFC.IfcAPI,this.ifc.Init().then(()=>{this.ImportIfcContent(e),t()})}).catch(()=>{this.SetError(Ze("Failed to load web-ifc.")),t()}):(this.ImportIfcContent(e),t())}ImportIfcContent(e){let t=new Uint8Array(e),n=this.ifc.OpenModel(t,{COORDINATE_TO_ORIGIN:!0}),i=this.ifc.LoadAllGeometry(n);for(let s=0;s<i.size();s++){let o=i.get(s);o.geometries.size()>0&&this.ImportIfcMesh(n,o)}this.ImportProperties(n),this.ifc.CloseModel(n)}ImportIfcMesh(e,t){let n=new Kt;n.SetName(uo("Mesh {0}",t.expressID.toString()));let i=0,s=t.geometries;for(let o=0;o<s.size();o++){let a=s.get(o),l=this.ifc.GetGeometry(e,a.geometryExpressID),c=this.ifc.GetVertexArray(l.GetVertexData(),l.GetVertexDataSize()),u=this.ifc.GetIndexArray(l.GetIndexData(),l.GetIndexDataSize()),h=this.GetMaterialIndexByColor(a.color),f=new fn(a.flatTransformation),p=new ln(f);for(let g=0;g<c.length;g+=6){let v=c[g],d=c[g+1],m=c[g+2],_=new Xe(v,d,m),y=p.TransformCoord3D(_);n.AddVertex(y)}for(let g=0;g<u.length;g+=3){let v=u[g],d=u[g+1],m=u[g+2],_=new Xt(i+v,i+d,i+m);_.SetMaterial(h),n.AddTriangle(_)}i+=c.length/6}this.expressIDToMesh.set(t.expressID,n),this.model.AddMeshToRootNode(n)}ImportProperties(e){let t=this.ifc.GetLineIDsWithType(e,WebIFC.IFCRELDEFINESBYPROPERTIES);for(let n=0;n<t.size();n++){let i=t.get(n),s=this.ifc.GetLine(e,i);Array.isArray(s.RelatingPropertyDefinition)||s.RelatedObjects.forEach(o=>{let a=null;if(this.expressIDToMesh.has(o.value)?a=this.expressIDToMesh.get(o.value):this.ifc.GetLine(e,o.value,!0).type===WebIFC.IFCBUILDING&&(a=this.model),a===null)return;let l=s.RelatingPropertyDefinition,c=this.ifc.GetLine(e,l.value,!0);if(!c||!c.HasProperties)return;let u=new Vn(c.Name.value);c.HasProperties.forEach(h=>{if(!h||!h.Name||!h.NominalValue||!h.NominalValue.constructor||h.type!==WebIFC.IFCPROPERTYSINGLEVALUE)return;let f=this.GetIFCString(h.Name.value),p=null,g=null;switch(h.NominalValue.constructor.name){case"IfcText":case"IfcLabel":case"IfcIdentifier":case WebIFC.IFCLABEL:p=new nn(Vt.Text,f,this.GetIFCString(h.NominalValue.value));break;case"IfcBoolean":case"IfcLogical":g=Ze("Unknown"),h.NominalValue.value==="T"?g=Ze("True"):h.NominalValue.value==="F"&&(g=Ze("False")),p=new nn(Vt.Text,f,g);break;case"IfcInteger":case"IfcCountMeasure":p=new nn(Vt.Integer,f,h.NominalValue.value);break;case"IfcReal":case"IfcLengthMeasure":case"IfcPositiveLengthMeasure":case"IfcAreaMeasure":case"IfcVolumeMeasure":case"IfcRatioMeasure":case"IfcPositiveRatioMeasure":case"IfcMassMeasure":case"IfcMassPerLengthMeasure":case"IfcPlaneAngleMeasure":case"IfcThermalTransmittanceMeasure":p=new nn(Vt.Number,f,h.NominalValue.value);break;default:console.log(h);break}p!==null&&u.AddProperty(p)}),u.PropertyCount()>0&&a.AddPropertyGroup(u)})}}GetMaterialIndexByColor(e){let t=di(e.x,e.y,e.z),n=parseInt(e.w*255,10);return this.colorToMaterial.GetMaterialIndex(t.r,t.g,t.b,n)}GetIFCString(e){let t=this.DecodeIFCString(e);return t.length===0&&(t="-"),t}DecodeIFCString(e){let t=/\\X2\\(.*?)\\X0\\/uig,n=e,i=t.exec(e);for(;i;){let s=String.fromCharCode(parseInt(i[1],16));n=n.replace(i[0],s),i=t.exec(e)}return n}};var Vd=class{constructor(e){this.mesh=e,this.globalToMeshVertices=new Map,this.globalToMeshVertexColors=new Map,this.globalToMeshNormals=new Map,this.globalToMeshUvs=new Map}AddVertex(e,t){return this.GetMeshIndex(e,t,this.globalToMeshVertices,n=>this.mesh.AddVertex(new Xe(n.x,n.y,n.z)))}AddVertexColor(e,t){return this.GetMeshIndex(e,t,this.globalToMeshVertexColors,n=>this.mesh.AddVertexColor(new Mt(n.r,n.g,n.b)))}AddNormal(e,t){return this.GetMeshIndex(e,t,this.globalToMeshNormals,n=>this.mesh.AddNormal(new Xe(n.x,n.y,n.z)))}AddUV(e,t){return this.GetMeshIndex(e,t,this.globalToMeshUvs,n=>this.mesh.AddTextureUV(new At(n.x,n.y)))}AddLine(e){this.mesh.AddLine(e)}AddTriangle(e){this.mesh.AddTriangle(e)}GetMeshIndex(e,t,n,i){if(isNaN(e)||e<0||e>=t.length)return null;if(n.has(e))return n.get(e);{let s=t[e],o=i(s);return n.set(e,o),o}}};function yh(r,e,t){return di(parseFloat(r),parseFloat(e),parseFloat(t))}var Oa=class extends Ht{constructor(){super()}CanImportExtension(e){return e==="obj"}GetUpDirection(){return pt.Y}ClearContent(){this.globalVertices=null,this.globalVertexColors=null,this.globalNormals=null,this.globalUvs=null,this.currentMeshConverter=null,this.currentMaterial=null,this.currentMaterialIndex=null,this.meshNameToConverter=null,this.materialNameToIndex=null}ResetContent(){this.globalVertices=[],this.globalVertexColors=[],this.globalNormals=[],this.globalUvs=[],this.currentMeshConverter=null,this.currentMaterial=null,this.currentMaterialIndex=null,this.meshNameToConverter=new Map,this.materialNameToIndex=new Map}ImportContent(e,t){let n=xn(e);Mi(n,i=>{this.WasError()||this.ProcessLine(i)}),t()}ProcessLine(e){if(e[0]==="#")return;let t=Ui(e,"#");if(t.length===0)return;let n=t[0].toLowerCase();t.shift(),!this.ProcessMeshParameter(n,t,e)&&this.ProcessMaterialParameter(n,t,e)}AddNewMesh(e){if(this.meshNameToConverter.has(e))this.currentMeshConverter=this.meshNameToConverter.get(e);else{let t=new Kt;t.SetName(e),this.model.AddMeshToRootNode(t),this.currentMeshConverter=new Vd(t),this.meshNameToConverter.set(e,this.currentMeshConverter)}}ProcessMeshParameter(e,t,n){if(e==="g"||e==="o"){if(t.length===0)return!0;let i=Pr(n,e.length,"#");return this.AddNewMesh(i),!0}else{if(e==="v")return t.length<3||(this.globalVertices.push(new Xe(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]))),t.length>=6&&this.globalVertexColors.push(yh(t[3],t[4],t[5]))),!0;if(e==="vn")return t.length<3||this.globalNormals.push(new Xe(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]))),!0;if(e==="vt")return t.length<2||this.globalUvs.push(new At(parseFloat(t[0]),parseFloat(t[1]))),!0;if(e==="l"){if(t.length<2)return!0;this.ProcessLineCommand(t)}else if(e==="f")return t.length<3||this.ProcessFaceCommand(t),!0}return!1}ProcessMaterialParameter(e,t,n){function i(o){let a=new Map,l=null;for(let c=0;c<o.length-1;c++){let u=o[c];if(u.startsWith("-")){l=u,a.set(l,[]);continue}l!==null&&a.get(l).push(u)}return a}function s(o,a){let l=new ii,c=o[o.length-1],u=a.getFileBuffer(c);l.name=c,l.buffer=u;let h=i(o);if(h.has("-o")){let f=h.get("-o");f.length>0&&(l.offset.x=parseFloat(f[0])),f.length>1&&(l.offset.y=parseFloat(f[1]))}if(h.has("-s")){let f=h.get("-s");f.length>0&&(l.scale.x=parseFloat(f[0])),f.length>1&&(l.scale.y=parseFloat(f[1]))}return l}if(e==="newmtl"){if(t.length===0)return!0;let o=new vn,a=Pr(n,e.length,"#"),l=this.model.AddMaterial(o);return o.name=a,this.currentMaterial=o,this.materialNameToIndex.set(a,l),!0}else if(e==="usemtl"){if(t.length===0)return!0;let o=Pr(n,e.length,"#");return this.materialNameToIndex.has(o)&&(this.currentMaterialIndex=this.materialNameToIndex.get(o)),!0}else if(e==="mtllib"){if(t.length===0)return!0;let o=Pr(n,e.length,"#"),a=this.callbacks.getFileBuffer(o);if(a!==null){let l=xn(a);Mi(l,c=>{this.WasError()||this.ProcessLine(c)})}return!0}else{if(e==="map_kd")return this.currentMaterial===null||t.length===0||(this.currentMaterial.diffuseMap=s(t,this.callbacks),si(this.currentMaterial)),!0;if(e==="map_ks")return this.currentMaterial===null||t.length===0||(this.currentMaterial.specularMap=s(t,this.callbacks)),!0;if(e==="map_bump"||e==="bump")return this.currentMaterial===null||t.length===0||(this.currentMaterial.bumpMap=s(t,this.callbacks)),!0;if(e==="ka")return this.currentMaterial===null||t.length<3||(this.currentMaterial.ambient=yh(t[0],t[1],t[2])),!0;if(e==="kd")return this.currentMaterial===null||t.length<3||(this.currentMaterial.color=yh(t[0],t[1],t[2])),!0;if(e==="ks")return this.currentMaterial===null||t.length<3||(this.currentMaterial.specular=yh(t[0],t[1],t[2])),!0;if(e==="ns")return this.currentMaterial===null||t.length<1||(this.currentMaterial.shininess=parseFloat(t[0])/1e3),!0;if(e==="tr")return this.currentMaterial===null||t.length<1||(this.currentMaterial.opacity=1-parseFloat(t[0]),si(this.currentMaterial)),!0;if(e==="d")return this.currentMaterial===null||t.length<1||(this.currentMaterial.opacity=parseFloat(t[0]),si(this.currentMaterial)),!0}return!1}ProcessLineCommand(e){this.currentMeshConverter===null&&this.AddNewMesh("");let t=[];for(let i=0;i<e.length;i++){let s=e[i].split("/"),o=this.GetRelativeIndex(parseInt(s[0],10),this.globalVertices.length),a=this.currentMeshConverter.AddVertex(o,this.globalVertices);if(a===null){this.SetError(Ze("Invalid vertex index."));break}t.push(a)}let n=new jr(t);this.currentMaterialIndex!==null&&(n.mat=this.currentMaterialIndex),this.currentMeshConverter.AddLine(n)}ProcessFaceCommand(e){let t=[],n=[],i=[],s=[];this.currentMeshConverter===null&&this.AddNewMesh("");for(let o=0;o<e.length;o++){let a=e[o].split("/");t.push(this.GetRelativeIndex(parseInt(a[0],10),this.globalVertices.length)),this.globalVertices.length===this.globalVertexColors.length&&n.push(this.GetRelativeIndex(parseInt(a[0],10),this.globalVertices.length)),a.length>1&&a[1].length>0&&s.push(this.GetRelativeIndex(parseInt(a[1],10),this.globalUvs.length)),a.length>2&&a[2].length>0&&i.push(this.GetRelativeIndex(parseInt(a[2],10),this.globalNormals.length))}for(let o=0;o<t.length-2;o++){let a=this.currentMeshConverter.AddVertex(t[0],this.globalVertices),l=this.currentMeshConverter.AddVertex(t[o+1],this.globalVertices),c=this.currentMeshConverter.AddVertex(t[o+2],this.globalVertices);if(a===null||l===null||c===null){this.SetError(Ze("Invalid vertex index."));break}let u=new Xt(a,l,c);if(n.length===t.length){let h=this.currentMeshConverter.AddVertexColor(n[0],this.globalVertexColors),f=this.currentMeshConverter.AddVertexColor(n[o+1],this.globalVertexColors),p=this.currentMeshConverter.AddVertexColor(n[o+2],this.globalVertexColors);if(h===null||f===null||p===null){this.SetError(Ze("Invalid vertex color index."));break}u.SetVertexColors(h,f,p)}if(i.length===t.length){let h=this.currentMeshConverter.AddNormal(i[0],this.globalNormals),f=this.currentMeshConverter.AddNormal(i[o+1],this.globalNormals),p=this.currentMeshConverter.AddNormal(i[o+2],this.globalNormals);if(h===null||f===null||p===null){this.SetError(Ze("Invalid normal index."));break}u.SetNormals(h,f,p)}if(s.length===t.length){let h=this.currentMeshConverter.AddUV(s[0],this.globalUvs),f=this.currentMeshConverter.AddUV(s[o+1],this.globalUvs),p=this.currentMeshConverter.AddUV(s[o+2],this.globalUvs);if(h===null||f===null||p===null){this.SetError(Ze("Invalid uv index."));break}u.SetTextureUVs(h,f,p)}this.currentMaterialIndex!==null&&(u.mat=this.currentMaterialIndex),this.currentMeshConverter.AddTriangle(u)}}GetRelativeIndex(e,t){return e>0?e-1:t+e}};var Da=class extends Ht{constructor(){super()}CanImportExtension(e){return e==="off"}GetUpDirection(){return pt.Y}ClearContent(){this.mesh=null,this.status=null,this.colorToMaterial=null}ResetContent(){this.mesh=new Kt,this.model.AddMeshToRootNode(this.mesh),this.status={vertexCount:0,faceCount:0,foundVertex:0,foundFace:0},this.colorToMaterial=new ri(this.model)}ImportContent(e,t){let n=xn(e);Mi(n,i=>{this.WasError()||this.ProcessLine(i)}),t()}ProcessLine(e){function t(s){return s.indexOf(".")!==-1?Rn(parseFloat(s)):parseInt(s,10)}if(e[0]==="#")return;let n=Ui(e,"#");if(n.length===0||n[0]==="OFF")return;if(this.status.vertexCount===0&&this.status.faceCount===0){n.length>1&&(this.status.vertexCount=parseInt(n[0],10),this.status.faceCount=parseInt(n[1],10));return}if(this.status.foundVertex<this.status.vertexCount){n.length>=3&&(this.mesh.AddVertex(new Xe(parseFloat(n[0]),parseFloat(n[1]),parseFloat(n[2]))),this.status.foundVertex+=1),n.length>=6&&this.mesh.AddVertexColor(new Mt(t(n[3]),t(n[4]),t(n[5])));return}let i=this.mesh.VertexCount()===this.mesh.VertexColorCount();if(this.status.foundFace<this.status.faceCount){if(n.length>=4){let s=parseInt(n[0],10);if(n.length<s+1)return;let o=null;if(!i&&n.length>=s+4){let a=new Mt(t(n[s+1]),t(n[s+2]),t(n[s+3]));o=this.colorToMaterial.GetMaterialIndex(a.r,a.g,a.b)}for(let a=0;a<s-2;a++){let l=parseInt(n[1]),c=parseInt(n[a+2]),u=parseInt(n[a+3]),h=new Xt(l,c,u);i?h.SetVertexColors(l,c,u):h.SetMaterial(o),this.mesh.AddTriangle(h)}this.status.foundFace+=1}return}}};var Ms={Ok:1,NoVertices:2,NoFaces:3,UnknownError:4},zd=class{constructor(){this.format=null,this.elements=[]}SetFormat(e){this.format=e}AddElement(e,t){this.elements.push({name:e,count:t,format:[]})}GetElements(){return this.elements}AddSingleFormat(e,t){this.elements[this.elements.length-1].format.push({name:t,isSingle:!0,elemType:e})}AddListFormat(e,t,n){this.elements[this.elements.length-1].format.push({name:n,isSingle:!1,countType:e,elemType:t})}GetElement(e){for(let t=0;t<this.elements.length;t++){let n=this.elements[t];if(n.name===e)return n}return null}Check(){let e=this.GetElement("vertex");if(e===null||e.length===0||e.format.length<3)return Ms.NoVertices;let t=this.GetElement("face");if(this.format==="ascii"){if(t===null||t.count===0||t.format.length<0)return Ms.NoFaces}else if(this.format==="binary_little_endian"||this.format==="binary_big_endian"){let n=this.GetElement("tristrips"),i=t!==null&&t.count>0&&t.format.length>0,s=n!==null&&n.count>0&&n.format.length>0;if(!i&&!s)return Ms.NoFaces}else return Ms.UnknownError;return Ms.Ok}},Hd=class{constructor(e){this.model=e,this.colorToMaterial=new Map}GetMaterialIndexByColor(e){let t="Color "+Mn(e[0])+Mn(e[1])+Mn(e[2])+Mn(e[3]);if(this.colorToMaterial.has(t))return this.colorToMaterial.get(t);{let n=new vn;n.name=t,n.color=new Mt(e[0],e[1],e[2]),n.opacity=e[3]/255,si(n);let i=this.model.AddMaterial(n);return this.colorToMaterial.set(t,i),i}}},Fa=class extends Ht{constructor(){super()}CanImportExtension(e){return e==="ply"}GetUpDirection(){return pt.Y}ClearContent(){this.mesh=null}ResetContent(){this.mesh=new Kt,this.model.AddMeshToRootNode(this.mesh)}ImportContent(e,t){let n=this.GetHeaderContent(e),i=this.ReadHeader(n),s=i.Check();if(s===Ms.Ok)if(i.format==="ascii"){let o=xn(e);o=o.substring(n.length),this.ReadAsciiContent(i,o)}else(i.format==="binary_little_endian"||i.format==="binary_big_endian")&&this.ReadBinaryContent(i,e,n.length);else s===Ms.NoVertices?this.SetError(Ze("The model contains no vertices.")):s===Ms.NoFaces?this.SetError(Ze("The model contains no faces.")):this.SetError(Ze("Invalid header information."));t()}GetHeaderContent(e){let t="",n=new Uint8Array(e),i=0;for(i=0;i<e.byteLength&&(t+=String.fromCharCode(n[i]),!t.endsWith("end_header"));i++);for(i+=1;i<e.byteLength;){let s=String.fromCharCode(n[i]);if(t+=s,i+=1,s===`
-`)break}return t}ReadHeader(e){let t=new zd;return Mi(e,n=>{let i=Ui(n,null);i.length===0||i[0]==="comment"||i[0]!=="ply"&&(i[0]==="format"&&i.length>=2?t.SetFormat(i[1]):i[0]==="element"&&i.length>=3?t.AddElement(i[1],parseInt(i[2],10)):i[0]==="property"&&i.length>=3&&(i[1]==="list"&&i.length>=5?t.AddListFormat(i[2],i[3],i[4]):t.AddSingleFormat(i[1],i[2])))}),t}ReadAsciiContent(e,t){let n=e.GetElement("vertex"),i=e.GetElement("face"),s=0,o=0;Mi(t,a=>{if(this.WasError())return;let l=Ui(a,null);if(!(l.length===0||l[0]==="comment")){if(s<n.count){l.length>=3&&(this.mesh.AddVertex(new Xe(parseFloat(l[0]),parseFloat(l[1]),parseFloat(l[2]))),s+=1);return}if(i!==null&&o<i.count){if(l.length>=4){let c=parseInt(l[0],10);if(l.length<c+1)return;for(let u=0;u<c-2;u++){let h=parseInt(l[1]),f=parseInt(l[u+2]),p=parseInt(l[u+3]),g=new Xt(h,f,p);this.mesh.AddTriangle(g)}o+=1}return}}})}ReadBinaryContent(e,t,n){function i(u,h){function f(p,g){return g==="char"||g==="int8"?p.ReadCharacter8():g==="uchar"||g==="uint8"?p.ReadUnsignedCharacter8():g==="short"||g==="int16"?p.ReadInteger16():g==="ushort"||g==="uint16"?p.ReadUnsignedInteger16():g==="int"||g==="int32"?p.ReadInteger32():g==="uint"||g==="uint32"?p.ReadUnsignedInteger32():g==="float"||g==="float32"?p.ReadFloat32():g==="double"||g==="double64"?p.ReadDouble64():null}if(h.isSingle)return f(u,h.elemType);{let p=[],g=f(u,h.countType);for(let v=0;v<g;v++)p.push(f(u,h.elemType));return p}}function s(u,h,f){for(let p=f;p<h.length;p++)i(u,h[p])}function o(u,h,f){let p=null,g=null,v=null,d=255;for(let m=f;m<h.length;m++){let _=h[m],y=i(u,_);_.name==="red"?p=y:_.name==="green"?g=y:_.name==="blue"?v=y:_.name==="alpha"&&(d=y)}return p!==null&&g!==null&&v!==null?[p,g,v,d]:null}let a=null;if(e.format==="binary_little_endian")a=new Qn(t,!0);else if(e.format==="binary_big_endian")a=new Qn(t,!1);else return;a.Skip(n);let l=new Hd(this.model),c=e.GetElements();for(let u=0;u<c.length;u++){let h=c[u];if(h.name==="vertex")for(let f=0;f<h.count;f++){let p=i(a,h.format[0]),g=i(a,h.format[1]),v=i(a,h.format[2]),d=o(a,h.format,3);d!==null&&this.mesh.AddVertexColor(new Mt(d[0],d[1],d[2])),this.mesh.AddVertex(new Xe(p,g,v))}else if(h.name==="face")for(let f=0;f<h.count;f++){let p=i(a,h.format[0]),g=o(a,h.format,1);for(let v=0;v<p.length-2;v++){let d=p[0],m=p[v+1],_=p[v+2],y=new Xt(d,m,_);g!==null?y.mat=l.GetMaterialIndexByColor(g):this.mesh.VertexColorCount()>0&&y.SetVertexColors(d,m,_),this.mesh.AddTriangle(y)}}else if(h.name==="tristrips")for(let f=0;f<h.count;f++){let p=i(a,h.format[0]);s(a,h.format,1);let g=!0;for(let v=0;v<p.length-2;v++){let d=p[v],m=p[v+1],_=p[v+2];if(_===-1){v+=2,g=!0;continue}if(!g){let x=m;m=_,_=x}g=!g;let y=new Xt(d,m,_);this.mesh.AddTriangle(y)}}else s(a,h.format,0)}}};var Ua=class extends Ht{constructor(){super(),this.worker=null}CanImportExtension(e){return e==="stp"||e==="step"||e==="igs"||e==="iges"||e==="brp"||e==="brep"}GetUpDirection(){return pt.Y}ClearContent(){this.worker!==null&&(this.worker.terminate(),this.worker=null)}ResetContent(){this.worker=null}ImportContent(e,t){yo().then(n=>{this.worker=n,this.worker.addEventListener("message",a=>{this.ImportResultJson(a.data,t)}),this.worker.addEventListener("error",a=>{this.SetError(Ze("Failed to load occt-import-js.")),t()});let i=null;if(this.extension==="stp"||this.extension==="step")i="step";else if(this.extension==="igs"||this.extension==="iges")i="iges";else if(this.extension==="brp"||this.extension==="brep")i="brep";else{t();return}(i==="step"||i==="iges")&&this.model.SetUnit(ns.Millimeter);let s={linearUnit:"millimeter",linearDeflectionType:"bounding_box_ratio",linearDeflection:.001,angularDeflection:.5},o=new Uint8Array(e);this.worker.postMessage({format:i,buffer:o,params:s})}).catch(()=>{this.SetError(Ze("Failed to load occt-import-js.")),t()})}ImportResultJson(e,t){if(!e.success){t();return}let n=new ri(this.model),i=this.model.GetRootNode();this.ImportNode(e,e.root,i,n),t()}ImportNode(e,t,n,i){for(let s of t.meshes){let o=e.meshes[s],a=this.ImportMesh(o,i),l=this.model.AddMesh(a);n.AddMeshIndex(l)}for(let s of t.children){let o=new Nn;o.SetName(s.name),n.AddChildNode(o),this.ImportNode(e,s,o,i)}}ImportMesh(e,t){let n=null;if(e.color){let s=di(e.color[0],e.color[1],e.color[2]);n=t.GetMaterialIndex(s.r,s.g,s.b,null)}let i=Zi(e,n,null);e.name&&i.SetName(e.name);for(let s of e.brep_faces){if(s.color===null)continue;let o=di(s.color[0],s.color[1],s.color[2]),a=t.GetMaterialIndex(o.r,o.g,o.b,null);for(let l=s.first;l<=s.last;l++)i.GetTriangle(l).SetMaterial(a)}return i}};var ka=class extends Ht{constructor(){super()}CanImportExtension(e){return e==="stl"}GetUpDirection(){return pt.Z}ClearContent(){this.mesh=null,this.triangle=null}ResetContent(){this.mesh=new Kt,this.model.AddMeshToRootNode(this.mesh),this.triangle=null}ImportContent(e,t){if(this.IsBinaryStlFile(e))this.ProcessBinary(e);else{let n=xn(e);Mi(n,i=>{this.WasError()||this.ProcessLine(i)})}t()}IsBinaryStlFile(e){let t=e.byteLength;if(t<84)return!1;let n=new Qn(e,!0);n.Skip(80);let i=n.ReadUnsignedInteger32();return t===i*50+84}ProcessLine(e){if(e[0]==="#")return;let t=Ui(e,"#");if(t.length===0)return;let n=t[0];if(n==="solid"){if(t.length>1){let i=Pr(e,n.length,"#");this.mesh.SetName(i)}return}if(n==="facet"){if(this.triangle=new Xt(-1,-1,-1),t.length>=5&&t[1]==="normal"){let i=new Xe(parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4]));if(Ti(i.Length())){let s=this.mesh.AddNormal(i);this.triangle.SetNormals(s,s,s)}}return}if(n==="vertex"&&this.triangle!==null){if(t.length>=4){let i=this.mesh.AddVertex(new Xe(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])));this.triangle.v0===-1?this.triangle.v0=i:this.triangle.v1===-1?this.triangle.v1=i:this.triangle.v2===-1&&(this.triangle.v2=i)}return}if(n==="endfacet"&&this.triangle!==null){this.triangle.v0!==-1&&this.triangle.v1!==-1&&this.triangle.v2!==null&&this.mesh.AddTriangle(this.triangle),this.triangle=null;return}}ProcessBinary(e){function t(o){let a=new Xe;return a.x=o.ReadFloat32(),a.y=o.ReadFloat32(),a.z=o.ReadFloat32(),a}function n(o,a){let l=t(a);return o.AddVertex(l)}let i=new Qn(e,!0);i.Skip(80);let s=i.ReadUnsignedInteger32();for(let o=0;o<s;o++){let a=t(i),l=n(this.mesh,i),c=n(this.mesh,i),u=n(this.mesh,i);i.Skip(2);let h=new Xt(l,c,u);if(Ti(a.Length())){let f=this.mesh.AddNormal(a);h.SetNormals(f,f,f)}this.mesh.AddTriangle(h)}}};var Ba=class extends Ht{constructor(){super()}CanImportExtension(e){return e==="bim"}GetUpDirection(){return pt.Z}ClearContent(){this.meshIdToMesh=null,this.colorToMaterial=null}ResetContent(){this.meshIdToMesh=new Map,this.colorToMaterial=new ri(this.model)}ImportContent(e,t){this.model.SetUnit(ns.Meter);let n=xn(e),i=null;try{i=JSON.parse(n)}catch{this.SetError(Ze("Failed to parse bim file.")),t();return}for(let s of i.meshes)this.meshIdToMesh.set(s.mesh_id,s);this.ImportProperties(i,this.model);for(let s of i.elements){let o=this.ImportElement(s);o.SetName(s.type),this.ImportProperties(s,o)}t()}ImportElement(e){let t=null;e.color&&(t=this.colorToMaterial.GetMaterialIndex(e.color.r,e.color.g,e.color.b,e.color.a));let n=this.model.GetRootNode(),i=this.meshIdToMesh.get(e.mesh_id),s=this.ImportMesh(i,f=>e.face_colors?this.colorToMaterial.GetMaterialIndex(e.face_colors[f*4+0],e.face_colors[f*4+1],e.face_colors[f*4+2],e.face_colors[f*4+3]):t),o=this.model.AddMesh(s),a=new Nn;a.AddMeshIndex(o);let l=new Xe(0,0,0);e.vector&&(l=new Xe(e.vector.x,e.vector.y,e.vector.z));let c=new Kn(0,0,0,1);e.rotation&&(c=new Kn(e.rotation.qx,e.rotation.qy,e.rotation.qz,e.rotation.qw));let u=new Xe(1,1,1),h=new fn().ComposeTRS(l,c,u);return a.SetTransformation(new ln(h)),n.AddChildNode(a),s}ImportMesh(e,t){let n=new Kt;for(let i=0;i<e.coordinates.length;i+=3)n.AddVertex(new Xe(e.coordinates[i+0],e.coordinates[i+1],e.coordinates[i+2]));for(let i=0;i<e.indices.length;i+=3){let s=new Xt(e.indices[i+0],e.indices[i+1],e.indices[i+2]);s.SetMaterial(t(i/3)),n.AddTriangle(s)}return n}ImportProperties(e,t){function n(o,a,l){if(l==null)return;let c=new nn(Vt.Text,a,l);o.AddProperty(c)}if(!e.info||Sc(e.info))return;let i=e.info,s=new Vn(Ze("Info"));n(s,Ze("Guid"),e.guid),n(s,Ze("Type"),e.type);for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&typeof i[o]=="string"&&n(s,o,i[o]);t.AddPropertyGroup(s)}};var Es=class extends ih{constructor(e){super(e)}parse(e){function t($){switch($.image_type){case f:case v:if($.colormap_length>256||$.colormap_size!==24||$.colormap_type!==1)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case p:case g:case d:case m:if($.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+$.image_type)}if($.width<=0||$.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if($.pixel_size!==8&&$.pixel_size!==16&&$.pixel_size!==24&&$.pixel_size!==32)throw new Error("THREE.TGALoader: Invalid pixel size "+$.pixel_size)}function n($,te,W,ae,de){let ye,Me,ve=W.pixel_size>>3,R=W.width*W.height*ve;if(te&&(Me=de.subarray(ae,ae+=W.colormap_length*(W.colormap_size>>3))),$){ye=new Uint8Array(R);let T,S,b,V=0,q=new Uint8Array(ve);for(;V<R;)if(T=de[ae++],S=(T&127)+1,T&128){for(b=0;b<ve;++b)q[b]=de[ae++];for(b=0;b<S;++b)ye.set(q,V+b*ve);V+=ve*S}else{for(S*=ve,b=0;b<S;++b)ye[V+b]=de[ae++];V+=S}}else ye=de.subarray(ae,ae+=te?W.width*W.height:R);return{pixel_data:ye,palettes:Me}}function i($,te,W,ae,de,ye,Me,ve,R){let T=R,S,b=0,V,q,Y=M.width;for(q=te;q!==ae;q+=W)for(V=de;V!==Me;V+=ye,b++)S=ve[b],$[(V+Y*q)*4+3]=255,$[(V+Y*q)*4+2]=T[S*3+0],$[(V+Y*q)*4+1]=T[S*3+1],$[(V+Y*q)*4+0]=T[S*3+2];return $}function s($,te,W,ae,de,ye,Me,ve){let R,T=0,S,b,V=M.width;for(b=te;b!==ae;b+=W)for(S=de;S!==Me;S+=ye,T+=2)R=ve[T+0]+(ve[T+1]<<8),$[(S+V*b)*4+0]=(R&31744)>>7,$[(S+V*b)*4+1]=(R&992)>>2,$[(S+V*b)*4+2]=(R&31)<<3,$[(S+V*b)*4+3]=R&32768?0:255;return $}function o($,te,W,ae,de,ye,Me,ve){let R=0,T,S,b=M.width;for(S=te;S!==ae;S+=W)for(T=de;T!==Me;T+=ye,R+=3)$[(T+b*S)*4+3]=255,$[(T+b*S)*4+2]=ve[R+0],$[(T+b*S)*4+1]=ve[R+1],$[(T+b*S)*4+0]=ve[R+2];return $}function a($,te,W,ae,de,ye,Me,ve){let R=0,T,S,b=M.width;for(S=te;S!==ae;S+=W)for(T=de;T!==Me;T+=ye,R+=4)$[(T+b*S)*4+2]=ve[R+0],$[(T+b*S)*4+1]=ve[R+1],$[(T+b*S)*4+0]=ve[R+2],$[(T+b*S)*4+3]=ve[R+3];return $}function l($,te,W,ae,de,ye,Me,ve){let R,T=0,S,b,V=M.width;for(b=te;b!==ae;b+=W)for(S=de;S!==Me;S+=ye,T++)R=ve[T],$[(S+V*b)*4+0]=R,$[(S+V*b)*4+1]=R,$[(S+V*b)*4+2]=R,$[(S+V*b)*4+3]=255;return $}function c($,te,W,ae,de,ye,Me,ve){let R=0,T,S,b=M.width;for(S=te;S!==ae;S+=W)for(T=de;T!==Me;T+=ye,R+=2)$[(T+b*S)*4+0]=ve[R+0],$[(T+b*S)*4+1]=ve[R+0],$[(T+b*S)*4+2]=ve[R+0],$[(T+b*S)*4+3]=ve[R+1];return $}function u($,te,W,ae,de){let ye,Me,ve,R,T,S;switch((M.flags&_)>>y){default:case I:ye=0,ve=1,T=te,Me=0,R=1,S=W;break;case x:ye=0,ve=1,T=te,Me=W-1,R=-1,S=-1;break;case C:ye=te-1,ve=-1,T=-1,Me=0,R=1,S=W;break;case w:ye=te-1,ve=-1,T=-1,Me=W-1,R=-1,S=-1;break}if(O)switch(M.pixel_size){case 8:l($,Me,R,S,ye,ve,T,ae);break;case 16:c($,Me,R,S,ye,ve,T,ae);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(M.pixel_size){case 8:i($,Me,R,S,ye,ve,T,ae,de);break;case 16:s($,Me,R,S,ye,ve,T,ae);break;case 24:o($,Me,R,S,ye,ve,T,ae);break;case 32:a($,Me,R,S,ye,ve,T,ae);break;default:throw new Error("THREE.TGALoader: Format not supported.")}return $}let h=0,f=1,p=2,g=3,v=9,d=10,m=11,_=48,y=4,x=0,w=1,I=2,C=3;if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let P=0,E=new Uint8Array(e),M={id_length:E[P++],colormap_type:E[P++],image_type:E[P++],colormap_index:E[P++]|E[P++]<<8,colormap_length:E[P++]|E[P++]<<8,colormap_size:E[P++],origin:[E[P++]|E[P++]<<8,E[P++]|E[P++]<<8],width:E[P++]|E[P++]<<8,height:E[P++]|E[P++]<<8,pixel_size:E[P++],flags:E[P++]};if(t(M),M.id_length+P>e.length)throw new Error("THREE.TGALoader: No data.");P+=M.id_length;let L=!1,N=!1,O=!1;switch(M.image_type){case v:L=!0,N=!0;break;case f:N=!0;break;case d:L=!0;break;case p:break;case m:L=!0,O=!0;break;case g:O=!0;break}let B=new Uint8Array(M.width*M.height*4),ie=n(L,N,M,P,E);return u(B,M.width,M.height,ie.pixel_data,ie.palettes),{data:B,width:M.width,height:M.height,flipY:!0,generateMipmaps:!0,minFilter:vi}}};var yi=Uint8Array,Ga=Uint16Array,kb=Int32Array,A0=new yi([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),w0=new yi([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Bb=new yi([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),C0=function(r,e){for(var t=new Ga(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new kb(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)i[s]=s-t[n]<<5|n;return{b:t,r:i}},R0=C0(A0,2),I0=R0.b,Gb=R0.r;I0[28]=258,Gb[258]=28;var P0=C0(w0,0),Vb=P0.b,wI=P0.r,qd=new Ga(32768);for(Ft=0;Ft<32768;++Ft)qr=(Ft&43690)>>1|(Ft&21845)<<1,qr=(qr&52428)>>2|(qr&13107)<<2,qr=(qr&61680)>>4|(qr&3855)<<4,qd[Ft]=((qr&65280)>>8|(qr&255)<<8)>>1;var qr,Ft,Ql=function(r,e,t){for(var n=r.length,i=0,s=new Ga(e);i<n;++i)r[i]&&++s[r[i]-1];var o=new Ga(e);for(i=1;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(t){a=new Ga(1<<e);var l=15-e;for(i=0;i<n;++i)if(r[i])for(var c=i<<4|r[i],u=e-r[i],h=o[r[i]-1]++<<u,f=h|(1<<u)-1;h<=f;++h)a[qd[h]>>l]=c}else for(a=new Ga(n),i=0;i<n;++i)r[i]&&(a[i]=qd[o[r[i]-1]++]>>15-r[i]);return a},ec=new yi(288);for(Ft=0;Ft<144;++Ft)ec[Ft]=8;var Ft;for(Ft=144;Ft<256;++Ft)ec[Ft]=9;var Ft;for(Ft=256;Ft<280;++Ft)ec[Ft]=7;var Ft;for(Ft=280;Ft<288;++Ft)ec[Ft]=8;var Ft,N0=new yi(32);for(Ft=0;Ft<32;++Ft)N0[Ft]=5;var Ft;var zb=Ql(ec,9,1);var Hb=Ql(N0,5,1),Wd=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},$i=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Xd=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},Wb=function(r){return(r+7)/8|0},Kd=function(r,e,t){return(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new yi(r.subarray(e,t))};var Xb=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],hi=function(r,e,t){var n=new Error(e||Xb[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,hi),!t)throw n;return n},L0=function(r,e,t,n){var i=r.length,s=n?n.length:0;if(!i||e.f&&!e.l)return t||new yi(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new yi(i*3));var c=function(z){var X=t.length;if(z>X){var se=new yi(Math.max(X*2,z));se.set(t),t=se}},u=e.f||0,h=e.p||0,f=e.b||0,p=e.l,g=e.d,v=e.m,d=e.n,m=i*8;do{if(!p){u=$i(r,h,1);var _=$i(r,h+1,3);if(h+=3,_)if(_==1)p=zb,g=Hb,v=9,d=5;else if(_==2){var I=$i(r,h,31)+257,C=$i(r,h+10,15)+4,P=I+$i(r,h+5,31)+1;h+=14;for(var E=new yi(P),M=new yi(19),L=0;L<C;++L)M[Bb[L]]=$i(r,h+L*3,7);h+=C*3;for(var N=Wd(M),O=(1<<N)-1,B=Ql(M,N,1),L=0;L<P;){var ie=B[$i(r,h,O)];h+=ie&15;var y=ie>>4;if(y<16)E[L++]=y;else{var $=0,te=0;for(y==16?(te=3+$i(r,h,3),h+=2,$=E[L-1]):y==17?(te=3+$i(r,h,7),h+=3):y==18&&(te=11+$i(r,h,127),h+=7);te--;)E[L++]=$}}var W=E.subarray(0,I),ae=E.subarray(I);v=Wd(W),d=Wd(ae),p=Ql(W,v,1),g=Ql(ae,d,1)}else hi(1);else{var y=Wb(h)+4,x=r[y-4]|r[y-3]<<8,w=y+x;if(w>i){l&&hi(0);break}a&&c(f+x),t.set(r.subarray(y,w),f),e.b=f+=x,e.p=h=w*8,e.f=u;continue}if(h>m){l&&hi(0);break}}a&&c(f+131072);for(var de=(1<<v)-1,ye=(1<<d)-1,Me=h;;Me=h){var $=p[Xd(r,h)&de],ve=$>>4;if(h+=$&15,h>m){l&&hi(0);break}if($||hi(2),ve<256)t[f++]=ve;else if(ve==256){Me=h,p=null;break}else{var R=ve-254;if(ve>264){var L=ve-257,T=A0[L];R=$i(r,h,(1<<T)-1)+I0[L],h+=T}var S=g[Xd(r,h)&ye],b=S>>4;S||hi(3),h+=S&15;var ae=Vb[b];if(b>3){var T=w0[b];ae+=Xd(r,h)&(1<<T)-1,h+=T}if(h>m){l&&hi(0);break}a&&c(f+131072);var V=f+R;if(f<ae){var q=s-ae,Y=Math.min(ae,V);for(q+f<0&&hi(3);f<Y;++f)t[f]=n[q+f]}for(;f<V;++f)t[f]=t[f-ae]}}e.l=p,e.p=Me,e.b=f,e.f=u,p&&(u=1,e.m=v,e.d=g,e.n=d)}while(!u);return f!=t.length&&o?Kd(t,0,f):t.subarray(0,f)};var jb=new yi(0);var Mr=function(r,e){return r[e]|r[e+1]<<8},Qi=function(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0},jd=function(r,e){return Qi(r,e)+Qi(r,e+4)*4294967296};var qb=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&hi(6,"invalid zlib data"),(r[1]>>5&1)==+!e&&hi(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function Yb(r,e){return L0(r,{i:2},e&&e.out,e&&e.dictionary)}function O0(r,e){return L0(r.subarray(qb(r,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary)}var Yd=typeof TextDecoder<"u"&&new TextDecoder,Kb=0;try{Yd.decode(jb,{stream:!0}),Kb=1}catch{}var Zb=function(r){for(var e="",t=0;;){var n=r[t++],i=(n>127)+(n>223)+(n>239);if(t+i>r.length)return{s:e,r:Kd(r,t-1)};i?i==3?(n=((n&15)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|r[t++]&63):e+=String.fromCharCode((n&15)<<12|(r[t++]&63)<<6|r[t++]&63):e+=String.fromCharCode(n)}};function Jb(r,e){if(e){for(var t="",n=0;n<r.length;n+=16384)t+=String.fromCharCode.apply(null,r.subarray(n,n+16384));return t}else{if(Yd)return Yd.decode(r);var i=Zb(r),s=i.s,t=i.r;return t.length&&hi(8),s}}var $b=function(r,e){return e+30+Mr(r,e+26)+Mr(r,e+28)},Qb=function(r,e,t){var n=Mr(r,e+28),i=Jb(r.subarray(e+46,e+46+n),!(Mr(r,e+8)&2048)),s=e+46+n,o=Qi(r,e+20),a=t&&o==4294967295?eS(r,s):[o,Qi(r,e+24),Qi(r,e+42)],l=a[0],c=a[1],u=a[2];return[Mr(r,e+10),l,c,i,s+Mr(r,e+30)+Mr(r,e+32),u]},eS=function(r,e){for(;Mr(r,e)!=1;e+=4+Mr(r,e+2));return[jd(r,e+12),jd(r,e+4),jd(r,e+20)]};function xh(r,e){for(var t={},n=r.length-22;Qi(r,n)!=101010256;--n)(!n||r.length-n>65558)&&hi(13);var i=Mr(r,n+8);if(!i)return{};var s=Qi(r,n+16),o=s==4294967295||i==65535;if(o){var a=Qi(r,n-12);o=Qi(r,a)==101075792,o&&(i=Qi(r,a+32),s=Qi(r,a+48))}for(var l=e&&e.filter,c=0;c<i;++c){var u=Qb(r,s,o),h=u[0],f=u[1],p=u[2],g=u[3],v=u[4],d=u[5],m=$b(r,d);s=v,(!l||l({name:g,size:f,originalSize:p,compression:h}))&&(h?h==8?t[g]=Yb(r.subarray(m,m+f),{out:new yi(p)}):hi(14,"unknown compression type "+h):t[g]=Kd(r,m,m+f))}return t}function D0(r,e,t){let n=t.length-r-1;if(e>=t[n])return n-1;if(e<=t[r])return r;let i=r,s=n,o=Math.floor((i+s)/2);for(;e<t[o]||e>=t[o+1];)e<t[o]?s=o:i=o,o=Math.floor((i+s)/2);return o}function tS(r,e,t,n){let i=[],s=[],o=[];i[0]=1;for(let a=1;a<=t;++a){s[a]=e-n[r+1-a],o[a]=n[r+a]-e;let l=0;for(let c=0;c<a;++c){let u=o[c+1],h=s[a-c],f=i[c]/(u+h);i[c]=l+u*f,l=h*f}i[a]=l}return i}function F0(r,e,t,n){let i=D0(r,n,e),s=tS(i,n,r,e),o=new Ct(0,0,0,0);for(let a=0;a<=r;++a){let l=t[i-r+a],c=s[a],u=l.w*c;o.x+=l.x*u,o.y+=l.y*u,o.z+=l.z*u,o.w+=l.w*c}return o}function nS(r,e,t,n,i){let s=[];for(let h=0;h<=t;++h)s[h]=0;let o=[];for(let h=0;h<=n;++h)o[h]=s.slice(0);let a=[];for(let h=0;h<=t;++h)a[h]=s.slice(0);a[0][0]=1;let l=s.slice(0),c=s.slice(0);for(let h=1;h<=t;++h){l[h]=e-i[r+1-h],c[h]=i[r+h]-e;let f=0;for(let p=0;p<h;++p){let g=c[p+1],v=l[h-p];a[h][p]=g+v;let d=a[p][h-1]/a[h][p];a[p][h]=f+g*d,f=v*d}a[h][h]=f}for(let h=0;h<=t;++h)o[0][h]=a[h][t];for(let h=0;h<=t;++h){let f=0,p=1,g=[];for(let v=0;v<=t;++v)g[v]=s.slice(0);g[0][0]=1;for(let v=1;v<=n;++v){let d=0,m=h-v,_=t-v;h>=v&&(g[p][0]=g[f][0]/a[_+1][m],d=g[p][0]*a[m][_]);let y=m>=-1?1:-m,x=h-1<=_?v-1:t-h;for(let I=y;I<=x;++I)g[p][I]=(g[f][I]-g[f][I-1])/a[_+1][m+I],d+=g[p][I]*a[m+I][_];h<=_&&(g[p][v]=-g[f][v-1]/a[_+1][h],d+=g[p][v]*a[h][_]),o[v][h]=d;let w=f;f=p,p=w}}let u=t;for(let h=1;h<=n;++h){for(let f=0;f<=t;++f)o[h][f]*=u;u*=t-h}return o}function iS(r,e,t,n,i){let s=i<r?i:r,o=[],a=D0(r,n,e),l=nS(a,n,r,s,e),c=[];for(let u=0;u<t.length;++u){let h=t[u].clone(),f=h.w;h.x*=f,h.y*=f,h.z*=f,c[u]=h}for(let u=0;u<=s;++u){let h=c[a-r].clone().multiplyScalar(l[u][0]);for(let f=1;f<=r;++f)h.add(c[a-r+f].clone().multiplyScalar(l[u][f]));o[u]=h}for(let u=s+1;u<=i+1;++u)o[u]=new Ct(0,0,0);return o}function rS(r,e){let t=1;for(let i=2;i<=r;++i)t*=i;let n=1;for(let i=2;i<=e;++i)n*=i;for(let i=2;i<=r-e;++i)n*=i;return t/n}function sS(r){let e=r.length,t=[],n=[];for(let s=0;s<e;++s){let o=r[s];t[s]=new oe(o.x,o.y,o.z),n[s]=o.w}let i=[];for(let s=0;s<e;++s){let o=t[s].clone();for(let a=1;a<=s;++a)o.sub(i[s-a].clone().multiplyScalar(rS(s,a)*n[a]));i[s]=o.divideScalar(n[0])}return i}function U0(r,e,t,n,i){let s=iS(r,e,t,n,i);return sS(s)}var _h=class extends ai{constructor(e,t,n,i,s){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=s||this.knots.length-1;for(let o=0;o<n.length;++o){let a=n[o];this.controlPoints[o]=new Ct(a.x,a.y,a.z,a.w)}}getPoint(e,t=new oe){let n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=F0(this.degree,this.knots,this.controlPoints,i);return s.w!==1&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(e,t=new oe){let n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=U0(this.degree,this.knots,this.controlPoints,i,1);return n.copy(s[1]).normalize(),n}};var bt,mn,ei,Mh=class extends Dt{constructor(e){super(e)}load(e,t,n,i){let s=this,o=s.path===""?_s.extractUrlBase(e):s.path,a=new $n(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(l){try{t(s.parse(l,o))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){if(aS(e))bt=new ip().parse(e);else{let i=V0(e);if(!lS(i))throw new Error("THREE.FBXLoader: Unknown format.");if(k0(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+k0(i));bt=new np().parse(i)}let n=new Pi(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Qd(n,this.manager).parse(bt)}},Qd=class{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){mn=this.parseConnections();let e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),s=new ep().parse(i);return this.parseScene(i,s,n),ei}parseConnections(){let e=new Map;return"Connections"in bt&&bt.Connections.connections.forEach(function(n){let i=n[0],s=n[1],o=n[2];e.has(i)||e.set(i,{parents:[],children:[]});let a={ID:s,relationship:o};e.get(i).parents.push(a),e.has(s)||e.set(s,{parents:[],children:[]});let l={ID:i,relationship:o};e.get(s).children.push(l)}),e}parseImages(){let e={},t={};if("Video"in bt.Objects){let n=bt.Objects.Video;for(let i in n){let s=n[i],o=parseInt(i);if(e[o]=s.RelativeFilename||s.Filename,"Content"in s){let a=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,l=typeof s.Content=="string"&&s.Content!=="";if(a||l){let c=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=c}}}}for(let n in e){let i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){let t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase(),s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{let o=new Uint8Array(t);return window.URL.createObjectURL(new Blob([o],{type:s}))}}parseTextures(e){let t=new Map;if("Texture"in bt.Objects){let n=bt.Objects.Texture;for(let i in n){let s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){let n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;let i=e.WrapModeU,s=e.WrapModeV,o=i!==void 0?i.value:0,a=s!==void 0?s.value:0;if(n.wrapS=o===0?rn:un,n.wrapT=a===0?rn:un,"Scaling"in e){let l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}if("Translation"in e){let l=e.Translation.value;n.offset.x=l[0],n.offset.y=l[1]}return n}loadTexture(e,t){let n,i=this.textureLoader.path,s=mn.get(e.id).children;s!==void 0&&s.length>0&&t[s[0].ID]!==void 0&&(n=t[s[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let o,a=e.FileName.slice(-3).toLowerCase();if(a==="tga"){let l=this.manager.getHandler(".tga");l===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),o=new Dn):(l.setPath(this.textureLoader.path),o=l.load(n))}else if(a==="dds"){let l=this.manager.getHandler(".dds");l===null?(console.warn("FBXLoader: DDS loader not found, creating placeholder texture for",e.RelativeFilename),o=new Dn):(l.setPath(this.textureLoader.path),o=l.load(n))}else a==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),o=new Dn):o=this.textureLoader.load(n);return this.textureLoader.setPath(i),o}parseMaterials(e){let t=new Map;if("Material"in bt.Objects){let n=bt.Objects.Material;for(let i in n){let s=this.parseMaterial(n[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){let n=e.id,i=e.attrName,s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!mn.has(n))return null;let o=this.parseParameters(e,t,n),a;switch(s.toLowerCase()){case"phong":a=new Zt;break;case"lambert":a=new Ea;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new Zt;break}return a.setValues(o),a.name=i,a}parseParameters(e,t,n){let i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=new Ve().fromArray(e.Diffuse.value).convertSRGBToLinear():e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=new Ve().fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=new Ve().fromArray(e.Emissive.value).convertSRGBToLinear():e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=new Ve().fromArray(e.EmissiveColor.value).convertSRGBToLinear()),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=new Ve().fromArray(e.Specular.value).convertSRGBToLinear():e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=new Ve().fromArray(e.SpecularColor.value).convertSRGBToLinear());let s=this;return mn.get(n).children.forEach(function(o){let a=o.relationship;switch(a){case"Bump":i.bumpMap=s.getTexture(t,o.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,o.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,o.ID),i.map!==void 0&&(i.map.colorSpace=jt);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,o.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,o.ID),i.emissiveMap!==void 0&&(i.emissiveMap.colorSpace=jt);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,o.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,o.ID),i.envMap!==void 0&&(i.envMap.mapping=Fl,i.envMap.colorSpace=jt);break;case"SpecularColor":i.specularMap=s.getTexture(t,o.ID),i.specularMap!==void 0&&(i.specularMap.colorSpace=jt);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,o.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",a);break}}),i}getTexture(e,t){return"LayeredTexture"in bt.Objects&&t in bt.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=mn.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if("Deformer"in bt.Objects){let n=bt.Objects.Deformer;for(let i in n){let s=n[i],o=mn.get(parseInt(i));if(s.attrType==="Skin"){let a=this.parseSkeleton(o,n);a.ID=i,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=o.parents[0].ID,e[i]=a}else if(s.attrType==="BlendShape"){let a={id:i};a.rawTargets=this.parseMorphTargets(o,n),a.id=i,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=a}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){let n=[];return e.children.forEach(function(i){let s=t[i.ID];if(s.attrType!=="Cluster")return;let o={ID:i.ID,indices:[],weights:[],transformLink:new Ye().fromArray(s.TransformLink.a)};"Indexes"in s&&(o.indices=s.Indexes.a,o.weights=s.Weights.a),n.push(o)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){let n=[];for(let i=0;i<e.children.length;i++){let s=e.children[i],o=t[s.ID],a={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if(o.attrType!=="BlendShapeChannel")return;a.geoID=mn.get(parseInt(s.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(a)}return n}parseScene(e,t,n){ei=new dn;let i=this.parseModels(e.skeletons,t,n),s=bt.Objects.Model,o=this;i.forEach(function(l){let c=s[l.ID];o.setLookAtProperties(l,c),mn.get(l.ID).parents.forEach(function(h){let f=i.get(h.ID);f!==void 0&&f.add(l)}),l.parent===null&&ei.add(l)}),this.bindSkeleton(e.skeletons,t,i),this.addGlobalSceneSettings(),ei.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);let c=B0(l.userData.transformData);l.applyMatrix4(c),l.updateWorldMatrix()}});let a=new tp().parse();ei.children.length===1&&ei.children[0].isGroup&&(ei.children[0].animations=a,ei=ei.children[0]),ei.animations=a}parseModels(e,t,n){let i=new Map,s=bt.Objects.Model;for(let o in s){let a=parseInt(o),l=s[o],c=mn.get(a),u=this.buildSkeleton(c,e,a,l.attrName);if(!u){switch(l.attrType){case"Camera":u=this.createCamera(c);break;case"Light":u=this.createLight(c);break;case"Mesh":u=this.createMesh(c,t,n);break;case"NurbsCurve":u=this.createCurve(c,t);break;case"LimbNode":case"Root":u=new ms;break;case"Null":default:u=new dn;break}u.name=l.attrName?zt.sanitizeNodeName(l.attrName):"",u.userData.originalName=l.attrName,u.ID=a}this.getTransformData(u,l),i.set(a,u)}return i}buildSkeleton(e,t,n,i){let s=null;return e.parents.forEach(function(o){for(let a in t){let l=t[a];l.rawBones.forEach(function(c,u){if(c.ID===o.ID){let h=s;s=new ms,s.matrixWorld.copy(c.transformLink),s.name=i?zt.sanitizeNodeName(i):"",s.userData.originalName=i,s.ID=n,l.bones[u]=s,h!==null&&s.add(h)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(i){let s=bt.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)t=new Rt;else{let i=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(i=1);let s=1;n.NearPlane!==void 0&&(s=n.NearPlane.value/1e3);let o=1e3;n.FarPlane!==void 0&&(o=n.FarPlane.value/1e3);let a=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,l=n.AspectHeight.value);let c=a/l,u=45;n.FieldOfView!==void 0&&(u=n.FieldOfView.value);let h=n.FocalLength?n.FocalLength.value:null;switch(i){case 0:t=new en(u,c,s,o),h!==null&&t.setFocalLength(h);break;case 1:t=new gr(-a/2,a/2,l/2,-l/2,s,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+i+"."),t=new Rt;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(i){let s=bt.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)t=new Rt;else{let i;n.LightType===void 0?i=0:i=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=new Ve().fromArray(n.Color.value).convertSRGBToLinear());let o=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(o=0);let a=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?a=0:a=n.FarAttenuationEnd.value);let l=1;switch(i){case 0:t=new eo(s,o,a,l);break;case 1:t=new xr(s,o);break;case 2:let c=Math.PI/3;n.InnerAngle!==void 0&&(c=pn.degToRad(n.InnerAngle.value));let u=0;n.OuterAngle!==void 0&&(u=pn.degToRad(n.OuterAngle.value),u=Math.max(u,1)),t=new Aa(s,o,a,c,u,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new eo(s,o);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,s=null,o=null,a=[];return e.children.forEach(function(l){t.has(l.ID)&&(s=t.get(l.ID)),n.has(l.ID)&&a.push(n.get(l.ID))}),a.length>1?o=a:a.length>0?o=a[0]:(o=new Zt({name:Dt.DEFAULT_MATERIAL_NAME,color:13421772}),a.push(o)),"color"in s.attributes&&a.forEach(function(l){l.vertexColors=!0}),s.FBX_Deformer?(i=new xa(s,o),i.normalizeSkinWeights()):i=new Pt(s,o),i}createCurve(e,t){let n=e.children.reduce(function(s,o){return t.has(o.ID)&&(s=t.get(o.ID)),s},null),i=new Wn({name:Dt.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Js(n,i)}getTransformData(e,t){let n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=G0(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&mn.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){let s=bt.Objects.Model[i.ID];if("Lcl_Translation"in s){let o=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),ei.add(e.target)):e.lookAt(new oe().fromArray(o))}}})}bindSkeleton(e,t,n){let i=this.parsePoseNodes();for(let s in e){let o=e[s];mn.get(parseInt(o.ID)).parents.forEach(function(l){if(t.has(l.ID)){let c=l.ID;mn.get(c).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new Ta(o.bones),i[h.ID])})}})}}parsePoseNodes(){let e={};if("Pose"in bt.Objects){let t=bt.Objects.Pose;for(let n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){let i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new Ye().fromArray(s.Matrix.a)}):e[i.Node]=new Ye().fromArray(i.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in bt){if("AmbientColor"in bt.GlobalSettings){let e=bt.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){let s=new Ve(t,n,i).convertSRGBToLinear();ei.add(new _r(s,1))}}"UnitScaleFactor"in bt.GlobalSettings&&(ei.userData.unitScaleFactor=bt.GlobalSettings.UnitScaleFactor.value)}}},ep=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if("Geometry"in bt.Objects){let n=bt.Objects.Geometry;for(let i in n){let s=mn.get(parseInt(i)),o=this.parseGeometry(s,n[i],e);t.set(parseInt(i),o)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){let i=n.skeletons,s=[],o=e.parents.map(function(h){return bt.Objects.Model[h.ID]});if(o.length===0)return;let a=e.children.reduce(function(h,f){return i[f.ID]!==void 0&&(h=i[f.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&s.push(n.morphTargets[h.ID])});let l=o[0],c={};"RotationOrder"in l&&(c.eulerOrder=G0(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);let u=B0(c);return this.genGeometry(t,a,s,u)}genGeometry(e,t,n,i){let s=new St;e.attrName&&(s.name=e.attrName);let o=this.parseGeoNode(e,t),a=this.genBuffers(o),l=new ze(a.vertex,3);if(l.applyMatrix4(i),s.setAttribute("position",l),a.colors.length>0&&s.setAttribute("color",new ze(a.colors,3)),t&&(s.setAttribute("skinIndex",new ma(a.weightsIndices,4)),s.setAttribute("skinWeight",new ze(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){let c=new ft().getNormalMatrix(i),u=new ze(a.normal,3);u.applyNormalMatrix(c),s.setAttribute("normal",u)}if(a.uvs.forEach(function(c,u){let h=u===0?"uv":`uv${u}`;s.setAttribute(h,new ze(a.uvs[u],2))}),o.material&&o.material.mappingType!=="AllSame"){let c=a.materialIndex[0],u=0;if(a.materialIndex.forEach(function(h,f){h!==c&&(s.addGroup(u,f-u,c),c=h,u=f)}),s.groups.length>0){let h=s.groups[s.groups.length-1],f=h.start+h.count;f!==a.materialIndex.length&&s.addGroup(f,a.materialIndex.length-f,c)}s.groups.length===0&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){let n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(o,a){n.weightTable[o]===void 0&&(n.weightTable[o]=[]),n.weightTable[o].push({id:s,weight:i.weights[a]})})})),n}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,i=0,s=!1,o=[],a=[],l=[],c=[],u=[],h=[],f=this;return e.vertexIndices.forEach(function(p,g){let v,d=!1;p<0&&(p=p^-1,d=!0);let m=[],_=[];if(o.push(p*3,p*3+1,p*3+2),e.color){let y=Th(g,n,p,e.color);l.push(y[0],y[1],y[2])}if(e.skeleton){if(e.weightTable[p]!==void 0&&e.weightTable[p].forEach(function(y){_.push(y.weight),m.push(y.id)}),_.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);let y=[0,0,0,0],x=[0,0,0,0];_.forEach(function(w,I){let C=w,P=m[I];x.forEach(function(E,M,L){if(C>E){L[M]=C,C=E;let N=y[M];y[M]=P,P=N}})}),m=y,_=x}for(;_.length<4;)_.push(0),m.push(0);for(let y=0;y<4;++y)u.push(_[y]),h.push(m[y])}if(e.normal){let y=Th(g,n,p,e.normal);a.push(y[0],y[1],y[2])}e.material&&e.material.mappingType!=="AllSame"&&(v=Th(g,n,p,e.material)[0],v<0&&(f.negativeMaterialIndices=!0,v=0)),e.uv&&e.uv.forEach(function(y,x){let w=Th(g,n,p,y);c[x]===void 0&&(c[x]=[]),c[x].push(w[0]),c[x].push(w[1])}),i++,d&&(f.genFace(t,e,o,v,a,l,c,u,h,i),n++,i=0,o=[],a=[],l=[],c=[],u=[],h=[])}),t}getNormalNewell(e){let t=new oe(0,0,0);for(let n=0;n<e.length;n++){let i=e[n],s=e[(n+1)%e.length];t.x+=(i.y-s.y)*(i.z+s.z),t.y+=(i.z-s.z)*(i.x+s.x),t.z+=(i.x-s.x)*(i.y+s.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){let t=this.getNormalNewell(e),i=(Math.abs(t.z)>.5?new oe(0,1,0):new oe(0,0,1)).cross(t).normalize(),s=t.clone().cross(i).normalize();return{normal:t,tangent:i,bitangent:s}}flattenVertex(e,t,n){return new Ce(e.dot(t),e.dot(n))}genFace(e,t,n,i,s,o,a,l,c,u){let h;if(u>3){let f=[];for(let d=0;d<n.length;d+=3)f.push(new oe(t.vertexPositions[n[d]],t.vertexPositions[n[d+1]],t.vertexPositions[n[d+2]]));let{tangent:p,bitangent:g}=this.getNormalTangentAndBitangent(f),v=[];for(let d of f)v.push(this.flattenVertex(d,p,g));h=Ai.triangulateShape(v,[])}else h=[[0,1,2]];for(let[f,p,g]of h)e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),e.vertex.push(t.vertexPositions[n[p*3]]),e.vertex.push(t.vertexPositions[n[p*3+1]]),e.vertex.push(t.vertexPositions[n[p*3+2]]),e.vertex.push(t.vertexPositions[n[g*3]]),e.vertex.push(t.vertexPositions[n[g*3+1]]),e.vertex.push(t.vertexPositions[n[g*3+2]]),t.skeleton&&(e.vertexWeights.push(l[f*4]),e.vertexWeights.push(l[f*4+1]),e.vertexWeights.push(l[f*4+2]),e.vertexWeights.push(l[f*4+3]),e.vertexWeights.push(l[p*4]),e.vertexWeights.push(l[p*4+1]),e.vertexWeights.push(l[p*4+2]),e.vertexWeights.push(l[p*4+3]),e.vertexWeights.push(l[g*4]),e.vertexWeights.push(l[g*4+1]),e.vertexWeights.push(l[g*4+2]),e.vertexWeights.push(l[g*4+3]),e.weightsIndices.push(c[f*4]),e.weightsIndices.push(c[f*4+1]),e.weightsIndices.push(c[f*4+2]),e.weightsIndices.push(c[f*4+3]),e.weightsIndices.push(c[p*4]),e.weightsIndices.push(c[p*4+1]),e.weightsIndices.push(c[p*4+2]),e.weightsIndices.push(c[p*4+3]),e.weightsIndices.push(c[g*4]),e.weightsIndices.push(c[g*4+1]),e.weightsIndices.push(c[g*4+2]),e.weightsIndices.push(c[g*4+3])),t.color&&(e.colors.push(o[f*3]),e.colors.push(o[f*3+1]),e.colors.push(o[f*3+2]),e.colors.push(o[p*3]),e.colors.push(o[p*3+1]),e.colors.push(o[p*3+2]),e.colors.push(o[g*3]),e.colors.push(o[g*3+1]),e.colors.push(o[g*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(s[f*3]),e.normal.push(s[f*3+1]),e.normal.push(s[f*3+2]),e.normal.push(s[p*3]),e.normal.push(s[p*3+1]),e.normal.push(s[p*3+2]),e.normal.push(s[g*3]),e.normal.push(s[g*3+1]),e.normal.push(s[g*3+2])),t.uv&&t.uv.forEach(function(v,d){e.uvs[d]===void 0&&(e.uvs[d]=[]),e.uvs[d].push(a[d][f*2]),e.uvs[d].push(a[d][f*2+1]),e.uvs[d].push(a[d][p*2]),e.uvs[d].push(a[d][p*2+1]),e.uvs[d].push(a[d][g*2]),e.uvs[d].push(a[d][g*2+1])})}addMorphTargets(e,t,n,i){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];let s=this;n.forEach(function(o){o.rawTargets.forEach(function(a){let l=bt.Objects.Geometry[a.geoID];l!==void 0&&s.genMorphGeometry(e,t,l,i,a.name)})})}genMorphGeometry(e,t,n,i,s){let o=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],a=n.Vertices!==void 0?n.Vertices.a:[],l=n.Indexes!==void 0?n.Indexes.a:[],c=e.attributes.position.count*3,u=new Float32Array(c);for(let g=0;g<l.length;g++){let v=l[g]*3;u[v]=a[g*3],u[v+1]=a[g*3+1],u[v+2]=a[g*3+2]}let h={vertexIndices:o,vertexPositions:u},f=this.genBuffers(h),p=new ze(f.vertex,3);p.name=s||n.attrName,p.applyMatrix4(i),e.morphAttributes.position.push(p)}parseNormals(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a,s=[];return n==="IndexToDirect"&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:s,mappingType:t,referenceType:n}}parseUVs(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a,s=[];return n==="IndexToDirect"&&(s=e.UVIndex.a),{dataSize:2,buffer:i,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a,s=[];n==="IndexToDirect"&&(s=e.ColorIndex.a);for(let o=0,a=new Ve;o<i.length;o+=4)a.fromArray(i,o).convertSRGBToLinear().toArray(i,o);return{dataSize:4,buffer:i,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){let t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};let i=e.Materials.a,s=[];for(let o=0;o<i.length;++o)s.push(o);return{dataSize:1,buffer:i,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){let t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new St;let n=t-1,i=e.KnotVector.a,s=[],o=e.Points.a;for(let h=0,f=o.length;h<f;h+=4)s.push(new Ct().fromArray(o,h));let a,l;if(e.Form==="Closed")s.push(s[0]);else if(e.Form==="Periodic"){a=n,l=i.length-1-a;for(let h=0;h<n;++h)s.push(s[h])}let u=new _h(n,i,s,a,l).getPoints(s.length*12);return new St().setFromPoints(u)}},tp=class{parse(){let e=[],t=this.parseClips();if(t!==void 0)for(let n in t){let i=t[n],s=this.addClip(i);e.push(s)}return e}parseClips(){if(bt.Objects.AnimationCurve===void 0)return;let e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);let t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){let e=bt.Objects.AnimationCurveNode,t=new Map;for(let n in e){let i=e[n];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){let s={id:i.id,attr:i.attrName,curves:{}};t.set(s.id,s)}}return t}parseAnimationCurves(e){let t=bt.Objects.AnimationCurve;for(let n in t){let i={id:t[n].id,times:t[n].KeyTime.a.map(cS),values:t[n].KeyValueFloat.a},s=mn.get(i.id);if(s!==void 0){let o=s.parents[0].ID,a=s.parents[0].relationship;a.match(/X/)?e.get(o).curves.x=i:a.match(/Y/)?e.get(o).curves.y=i:a.match(/Z/)?e.get(o).curves.z=i:a.match(/DeformPercent/)&&e.has(o)&&(e.get(o).curves.morph=i)}}}parseAnimationLayers(e){let t=bt.Objects.AnimationLayer,n=new Map;for(let i in t){let s=[],o=mn.get(parseInt(i));o!==void 0&&(o.children.forEach(function(l,c){if(e.has(l.ID)){let u=e.get(l.ID);if(u.curves.x!==void 0||u.curves.y!==void 0||u.curves.z!==void 0){if(s[c]===void 0){let h=mn.get(l.ID).parents.filter(function(f){return f.relationship!==void 0})[0].ID;if(h!==void 0){let f=bt.Objects.Model[h.toString()];if(f===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}let p={modelName:f.attrName?zt.sanitizeNodeName(f.attrName):"",ID:f.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ei.traverse(function(g){g.ID===f.id&&(p.transform=g.matrix,g.userData.transformData&&(p.eulerOrder=g.userData.transformData.eulerOrder))}),p.transform||(p.transform=new Ye),"PreRotation"in f&&(p.preRotation=f.PreRotation.value),"PostRotation"in f&&(p.postRotation=f.PostRotation.value),s[c]=p}}s[c]&&(s[c][u.attr]=u)}else if(u.curves.morph!==void 0){if(s[c]===void 0){let h=mn.get(l.ID).parents.filter(function(m){return m.relationship!==void 0})[0].ID,f=mn.get(h).parents[0].ID,p=mn.get(f).parents[0].ID,g=mn.get(p).parents[0].ID,v=bt.Objects.Model[g],d={modelName:v.attrName?zt.sanitizeNodeName(v.attrName):"",morphName:bt.Objects.Deformer[h].attrName};s[c]=d}s[c][u.attr]=u}}}),n.set(parseInt(i),s))}return n}parseAnimStacks(e){let t=bt.Objects.AnimationStack,n={};for(let i in t){let s=mn.get(parseInt(i)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");let o=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:o}}return n}addClip(e){let t=[],n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new Qs(e.name,-1,t)}generateTracks(e){let t=[],n=new oe,i=new oe;if(e.transform&&e.transform.decompose(n,new sn,i),n=n.toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){let s=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");s!==void 0&&t.push(s)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){let s=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);s!==void 0&&t.push(s)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){let s=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");s!==void 0&&t.push(s)}if(e.DeformPercent!==void 0){let s=this.generateMorphTrack(e);s!==void 0&&t.push(s)}return t}generateVectorTrack(e,t,n,i){let s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,n);return new Ki(e+"."+i,s,o)}generateRotationTrack(e,t,n,i,s){let o,a;if(t.x!==void 0&&t.y!==void 0&&t.z!==void 0){let h=this.interpolateRotations(t.x,t.y,t.z,s);o=h[0],a=h[1]}n!==void 0&&(n=n.map(pn.degToRad),n.push(s),n=new hn().fromArray(n),n=new sn().setFromEuler(n)),i!==void 0&&(i=i.map(pn.degToRad),i.push(s),i=new hn().fromArray(i),i=new sn().setFromEuler(i).invert());let l=new sn,c=new hn,u=[];if(!a||!o)return new Ii(e+".quaternion",[0],[0]);for(let h=0;h<a.length;h+=3)c.set(a[h],a[h+1],a[h+2],s),l.setFromEuler(c),n!==void 0&&l.premultiply(n),i!==void 0&&l.multiply(i),h>2&&new sn().fromArray(u,(h-3)/3*4).dot(l)<0&&l.set(-l.x,-l.y,-l.z,-l.w),l.toArray(u,h/3*4);return new Ii(e+".quaternion",o,u)}generateMorphTrack(e){let t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),i=ei.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new ys(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,i){return n-i}),t.length>1){let n=1,i=t[0];for(let s=1;s<t.length;s++){let o=t[s];o!==i&&(t[n]=o,i=o,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){let i=n,s=[],o=-1,a=-1,l=-1;return e.forEach(function(c){if(t.x&&(o=t.x.times.indexOf(c)),t.y&&(a=t.y.times.indexOf(c)),t.z&&(l=t.z.times.indexOf(c)),o!==-1){let u=t.x.values[o];s.push(u),i[0]=u}else s.push(i[0]);if(a!==-1){let u=t.y.values[a];s.push(u),i[1]=u}else s.push(i[1]);if(l!==-1){let u=t.z.values[l];s.push(u),i[2]=u}else s.push(i[2])}),s}interpolateRotations(e,t,n,i){let s=[],o=[];s.push(e.times[0]),o.push(pn.degToRad(e.values[0])),o.push(pn.degToRad(t.values[0])),o.push(pn.degToRad(n.values[0]));for(let a=1;a<e.values.length;a++){let l=[e.values[a-1],t.values[a-1],n.values[a-1]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;let c=l.map(pn.degToRad),u=[e.values[a],t.values[a],n.values[a]];if(isNaN(u[0])||isNaN(u[1])||isNaN(u[2]))continue;let h=u.map(pn.degToRad),f=[u[0]-l[0],u[1]-l[1],u[2]-l[2]],p=[Math.abs(f[0]),Math.abs(f[1]),Math.abs(f[2])];if(p[0]>=180||p[1]>=180||p[2]>=180){let v=Math.max(...p)/180,d=new hn(...c,i),m=new hn(...h,i),_=new sn().setFromEuler(d),y=new sn().setFromEuler(m);_.dot(y)&&y.set(-y.x,-y.y,-y.z,-y.w);let x=e.times[a-1],w=e.times[a]-x,I=new sn,C=new hn;for(let P=0;P<1;P+=1/v)I.copy(_.clone().slerp(y.clone(),P)),s.push(x+P*w),C.setFromQuaternion(I,i),o.push(C.x),o.push(C.y),o.push(C.z)}else s.push(e.times[a]),o.push(pn.degToRad(e.values[a])),o.push(pn.degToRad(t.values[a])),o.push(pn.degToRad(n.values[a]))}return[s,o]}},np=class{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new bh,this.nodeStack=[],this.currentProp=[],this.currentPropName="";let t=this,n=e.split(/[\r\n]+/);return n.forEach(function(i,s){let o=i.match(/^[\s\t]*;/),a=i.match(/^[\s\t]*$/);if(o||a)return;let l=i.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),c=i.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),u=i.match("^\\t{"+(t.currentIndent-1)+"}}");l?t.parseNodeBegin(i,l):c?t.parseNodeProperty(i,c,n[++s]):u?t.popStack():i.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(e,t){let n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},o=this.parseNodeAttr(i),a=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,s):n in a?(n==="PoseNode"?a.PoseNode.push(s):a[n].id!==void 0&&(a[n]={},a[n][a[n].id]=a[n]),o.id!==""&&(a[n][o.id]=s)):typeof o.id=="number"?(a[n]={},a[n][o.id]=s):n!=="Properties70"&&(n==="PoseNode"?a[n]=[s]:a[n]=s),typeof o.id=="number"&&(s.id=o.id),o.name!==""&&(s.attrName=o.name),o.type!==""&&(s.attrType=o.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());let o=this.getCurrentNode();if(o.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){let l=s.split(",").slice(1),c=parseInt(l[0]),u=parseInt(l[1]),h=s.split(",").slice(3);h=h.map(function(f){return f.trim().replace(/^"/,"")}),i="connections",s=[c,u],hS(s,h),o[i]===void 0&&(o[i]=[])}i==="Node"&&(o.id=s),i in o&&Array.isArray(o[i])?o[i].push(s):i!=="a"?o[i]=s:o.a=s,this.setCurrentProp(o,i),i==="a"&&s.slice(-1)!==","&&(o.a=$d(s))}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=$d(t.a))}parseNodeSpecialProperty(e,t,n){let i=n.split('",').map(function(u){return u.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],o=i[1],a=i[2],l=i[3],c=i[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=$d(c);break}this.getPrevNode()[s]={type:o,type2:a,flag:l,value:c},this.setCurrentProp(this.getPrevNode(),s)}},ip=class{parse(e){let t=new Eh(e);t.skip(23);let n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);let i=new bh;for(;!this.endOfContent(t);){let s=this.parseNode(t,n);s!==null&&i.add(s.name,s)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();let o=e.getUint8(),a=e.getString(o);if(i===0)return null;let l=[];for(let f=0;f<s;f++)l.push(this.parseProperty(e));let c=l.length>0?l[0]:"",u=l.length>1?l[1]:"",h=l.length>2?l[2]:"";for(n.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){let f=this.parseNode(e,t);f!==null&&this.parseSubNode(a,n,f)}return n.propertyList=l,typeof c=="number"&&(n.id=c),u!==""&&(n.attrName=u),h!==""&&(n.attrType=h),a!==""&&(n.name=a),n}parseSubNode(e,t,n){if(n.singleProperty===!0){let i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){let i=[];n.propertyList.forEach(function(s,o){o!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],s=n.propertyList[1],o=n.propertyList[2],a=n.propertyList[3],l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],t[i]={type:s,type2:o,flag:a,value:l}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){let t=e.getString(1),n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":let i=e.getUint32(),s=e.getUint32(),o=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}let a=O0(new Uint8Array(e.getArrayBuffer(o))),l=new Eh(a.buffer);switch(t){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}},Eh=class{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){let t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){let e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){let e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){let e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){let e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){let e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){let e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){let t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=this.offset,n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);let i=n.indexOf(0);return i>=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}},bh=class{add(e,t){this[e]=t}};function aS(r){let e="Kaydara FBX Binary \0";return r.byteLength>=e.length&&e===V0(r,0,e.length)}function lS(r){let e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],t=0;function n(i){let s=r[i-1];return r=r.slice(t+i),t++,s}for(let i=0;i<e.length;++i)if(n(1)===e[i])return!1;return!0}function k0(r){let e=/FBXVersion: (\d+)/,t=r.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function cS(r){return r/46186158e3}var uS=[];function Th(r,e,t,n){let i;switch(n.mappingType){case"ByPolygonVertex":i=r;break;case"ByPolygon":i=e;break;case"ByVertice":i=t;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(i=n.indices[i]);let s=i*n.dataSize,o=s+n.dataSize;return fS(uS,n.buffer,s,o)}var Jd=new hn,Va=new oe;function B0(r){let e=new Ye,t=new Ye,n=new Ye,i=new Ye,s=new Ye,o=new Ye,a=new Ye,l=new Ye,c=new Ye,u=new Ye,h=new Ye,f=new Ye,p=r.inheritType?r.inheritType:0;if(r.translation&&e.setPosition(Va.fromArray(r.translation)),r.preRotation){let M=r.preRotation.map(pn.degToRad);M.push(r.eulerOrder||hn.DEFAULT_ORDER),t.makeRotationFromEuler(Jd.fromArray(M))}if(r.rotation){let M=r.rotation.map(pn.degToRad);M.push(r.eulerOrder||hn.DEFAULT_ORDER),n.makeRotationFromEuler(Jd.fromArray(M))}if(r.postRotation){let M=r.postRotation.map(pn.degToRad);M.push(r.eulerOrder||hn.DEFAULT_ORDER),i.makeRotationFromEuler(Jd.fromArray(M)),i.invert()}r.scale&&s.scale(Va.fromArray(r.scale)),r.scalingOffset&&a.setPosition(Va.fromArray(r.scalingOffset)),r.scalingPivot&&o.setPosition(Va.fromArray(r.scalingPivot)),r.rotationOffset&&l.setPosition(Va.fromArray(r.rotationOffset)),r.rotationPivot&&c.setPosition(Va.fromArray(r.rotationPivot)),r.parentMatrixWorld&&(h.copy(r.parentMatrix),u.copy(r.parentMatrixWorld));let g=t.clone().multiply(n).multiply(i),v=new Ye;v.extractRotation(u);let d=new Ye;d.copyPosition(u);let m=d.clone().invert().multiply(u),_=v.clone().invert().multiply(m),y=s,x=new Ye;if(p===0)x.copy(v).multiply(g).multiply(_).multiply(y);else if(p===1)x.copy(v).multiply(_).multiply(g).multiply(y);else{let L=new Ye().scale(new oe().setFromMatrixScale(h)).clone().invert(),N=_.clone().multiply(L);x.copy(v).multiply(g).multiply(N).multiply(y)}let w=c.clone().invert(),I=o.clone().invert(),C=e.clone().multiply(l).multiply(c).multiply(t).multiply(n).multiply(i).multiply(w).multiply(a).multiply(o).multiply(s).multiply(I),P=new Ye().copyPosition(C),E=u.clone().multiply(P);return f.copyPosition(E),C=f.clone().multiply(x),C.premultiply(u.invert()),C}function G0(r){r=r||0;let e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return r===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[r]}function $d(r){return r.split(",").map(function(t){return parseFloat(t)})}function V0(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=r.byteLength),new TextDecoder().decode(new Uint8Array(r,e,t))}function hS(r,e){for(let t=0,n=r.length,i=e.length;t<i;t++,n++)r[n]=e[t]}function fS(r,e,t,n){for(let i=t,s=0;i<n;i++,s++)r[s]=e[i];return r}var Sh=class extends Dt{load(e,t,n,i){let s=this,o=s.path===""?_s.extractUrlBase(e):s.path,a=new $n(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(l){try{t(s.parse(l,o))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){function n(F,D){let j=[],H=F.childNodes;for(let K=0,be=H.length;K<be;K++){let Re=H[K];Re.nodeName===D&&j.push(Re)}return j}function i(F){if(F.length===0)return[];let D=F.trim().split(/\s+/),j=new Array(D.length);for(let H=0,K=D.length;H<K;H++)j[H]=D[H];return j}function s(F){if(F.length===0)return[];let D=F.trim().split(/\s+/),j=new Array(D.length);for(let H=0,K=D.length;H<K;H++)j[H]=parseFloat(D[H]);return j}function o(F){if(F.length===0)return[];let D=F.trim().split(/\s+/),j=new Array(D.length);for(let H=0,K=D.length;H<K;H++)j[H]=parseInt(D[H]);return j}function a(F){return F.substring(1)}function l(){return"three_default_"+Sv++}function c(F){return Object.keys(F).length===0}function u(F){return{unit:h(n(F,"unit")[0]),upAxis:f(n(F,"up_axis")[0])}}function h(F){return F!==void 0&&F.hasAttribute("meter")===!0?parseFloat(F.getAttribute("meter")):1}function f(F){return F!==void 0?F.textContent:"Y_UP"}function p(F,D,j,H){let K=n(F,D)[0];if(K!==void 0){let be=n(K,j);for(let Re=0;Re<be.length;Re++)H(be[Re])}}function g(F,D){for(let j in F){let H=F[j];H.build=D(F[j])}}function v(F,D){return F.build!==void 0||(F.build=D(F)),F.build}function d(F){let D={sources:{},samplers:{},channels:{}},j=!1;for(let H=0,K=F.childNodes.length;H<K;H++){let be=F.childNodes[H];if(be.nodeType!==1)continue;let Re;switch(be.nodeName){case"source":Re=be.getAttribute("id"),D.sources[Re]=Ue(be);break;case"sampler":Re=be.getAttribute("id"),D.samplers[Re]=m(be);break;case"channel":Re=be.getAttribute("target"),D.channels[Re]=_(be);break;case"animation":d(be),j=!0;break;default:console.log(be)}}j===!1&&(ht.animations[F.getAttribute("id")||pn.generateUUID()]=D)}function m(F){let D={inputs:{}};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"input":let be=a(K.getAttribute("source")),Re=K.getAttribute("semantic");D.inputs[Re]=be;break}}return D}function _(F){let D={},H=F.getAttribute("target").split("/"),K=H.shift(),be=H.shift(),Re=be.indexOf("(")!==-1,Ke=be.indexOf(".")!==-1;if(Ke)H=be.split("."),be=H.shift(),D.member=H.shift();else if(Re){let Be=be.split("(");be=Be.shift();for(let je=0;je<Be.length;je++)Be[je]=parseInt(Be[je].replace(/\)/,""));D.indices=Be}return D.id=K,D.sid=be,D.arraySyntax=Re,D.memberSyntax=Ke,D.sampler=a(F.getAttribute("source")),D}function y(F){let D=[],j=F.channels,H=F.samplers,K=F.sources;for(let be in j)if(j.hasOwnProperty(be)){let Re=j[be],Ke=H[Re.sampler],Be=Ke.inputs.INPUT,je=Ke.inputs.OUTPUT,it=K[Be],Le=K[je],nt=w(Re,it,Le);M(nt,D)}return D}function x(F){return v(ht.animations[F],y)}function w(F,D,j){let H=ht.nodes[F.id],K=rr(H.id),be=H.transforms[F.sid],Re=H.matrix.clone().transpose(),Ke,Be,je,it,Le,nt,$e={};switch(be){case"matrix":for(je=0,it=D.array.length;je<it;je++)if(Ke=D.array[je],Be=je*j.stride,$e[Ke]===void 0&&($e[Ke]={}),F.arraySyntax===!0){let on=j.array[Be],Gt=F.indices[0]+4*F.indices[1];$e[Ke][Gt]=on}else for(Le=0,nt=j.stride;Le<nt;Le++)$e[Ke][Le]=j.array[Be+Le];break;case"translate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',be);break;case"rotate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',be);break;case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',be);break}let ct=I($e,Re);return{name:K.uuid,keyframes:ct}}function I(F,D){let j=[];for(let K in F)j.push({time:parseFloat(K),value:F[K]});j.sort(H);for(let K=0;K<16;K++)L(j,K,D.elements[K]);return j;function H(K,be){return K.time-be.time}}let C=new oe,P=new oe,E=new sn;function M(F,D){let j=F.keyframes,H=F.name,K=[],be=[],Re=[],Ke=[];for(let Be=0,je=j.length;Be<je;Be++){let it=j[Be],Le=it.time,nt=it.value;et.fromArray(nt).transpose(),et.decompose(C,E,P),K.push(Le),be.push(C.x,C.y,C.z),Re.push(E.x,E.y,E.z,E.w),Ke.push(P.x,P.y,P.z)}return be.length>0&&D.push(new Ki(H+".position",K,be)),Re.length>0&&D.push(new Ii(H+".quaternion",K,Re)),Ke.length>0&&D.push(new Ki(H+".scale",K,Ke)),D}function L(F,D,j){let H,K=!0,be,Re;for(be=0,Re=F.length;be<Re;be++)H=F[be],H.value[D]===void 0?H.value[D]=null:K=!1;if(K===!0)for(be=0,Re=F.length;be<Re;be++)H=F[be],H.value[D]=j;else N(F,D)}function N(F,D){let j,H;for(let K=0,be=F.length;K<be;K++){let Re=F[K];if(Re.value[D]===null){if(j=O(F,K,D),H=B(F,K,D),j===null){Re.value[D]=H.value[D];continue}if(H===null){Re.value[D]=j.value[D];continue}ie(Re,j,H,D)}}}function O(F,D,j){for(;D>=0;){let H=F[D];if(H.value[j]!==null)return H;D--}return null}function B(F,D,j){for(;D<F.length;){let H=F[D];if(H.value[j]!==null)return H;D++}return null}function ie(F,D,j,H){if(j.time-D.time===0){F.value[H]=D.value[H];return}F.value[H]=(F.time-D.time)*(j.value[H]-D.value[H])/(j.time-D.time)+D.value[H]}function $(F){let D={name:F.getAttribute("id")||"default",start:parseFloat(F.getAttribute("start")||0),end:parseFloat(F.getAttribute("end")||0),animations:[]};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"instance_animation":D.animations.push(a(K.getAttribute("url")));break}}ht.clips[F.getAttribute("id")]=D}function te(F){let D=[],j=F.name,H=F.end-F.start||-1,K=F.animations;for(let be=0,Re=K.length;be<Re;be++){let Ke=x(K[be]);for(let Be=0,je=Ke.length;Be<je;Be++)D.push(Ke[Be])}return new Qs(j,H,D)}function W(F){return v(ht.clips[F],te)}function ae(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"skin":D.id=a(K.getAttribute("source")),D.skin=de(K);break;case"morph":D.id=a(K.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");break}}ht.controllers[F.getAttribute("id")]=D}function de(F){let D={sources:{}};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"bind_shape_matrix":D.bindShapeMatrix=s(K.textContent);break;case"source":let be=K.getAttribute("id");D.sources[be]=Ue(K);break;case"joints":D.joints=ye(K);break;case"vertex_weights":D.vertexWeights=Me(K);break}}return D}function ye(F){let D={inputs:{}};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"input":let be=K.getAttribute("semantic"),Re=a(K.getAttribute("source"));D.inputs[be]=Re;break}}return D}function Me(F){let D={inputs:{}};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"input":let be=K.getAttribute("semantic"),Re=a(K.getAttribute("source")),Ke=parseInt(K.getAttribute("offset"));D.inputs[be]={id:Re,offset:Ke};break;case"vcount":D.vcount=o(K.textContent);break;case"v":D.v=o(K.textContent);break}}return D}function ve(F){let D={id:F.id},j=ht.geometries[D.id];return F.skin!==void 0&&(D.skin=R(F.skin),j.sources.skinIndices=D.skin.indices,j.sources.skinWeights=D.skin.weights),D}function R(F){let j={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},H=F.sources,K=F.vertexWeights,be=K.vcount,Re=K.v,Ke=K.inputs.JOINT.offset,Be=K.inputs.WEIGHT.offset,je=F.sources[F.joints.inputs.JOINT],it=F.sources[F.joints.inputs.INV_BIND_MATRIX],Le=H[K.inputs.WEIGHT.id].array,nt=0,$e,ct,ot;for($e=0,ot=be.length;$e<ot;$e++){let Gt=be[$e],Lt=[];for(ct=0;ct<Gt;ct++){let Ot=Re[nt+Ke],Ar=Re[nt+Be],ni=Le[Ar];Lt.push({index:Ot,weight:ni}),nt+=2}for(Lt.sort(on),ct=0;ct<4;ct++){let Ot=Lt[ct];Ot!==void 0?(j.indices.array.push(Ot.index),j.weights.array.push(Ot.weight)):(j.indices.array.push(0),j.weights.array.push(0))}}for(F.bindShapeMatrix?j.bindMatrix=new Ye().fromArray(F.bindShapeMatrix).transpose():j.bindMatrix=new Ye().identity(),$e=0,ot=je.array.length;$e<ot;$e++){let Gt=je.array[$e],Lt=new Ye().fromArray(it.array,$e*it.stride).transpose();j.joints.push({name:Gt,boneInverse:Lt})}return j;function on(Gt,Lt){return Lt.weight-Gt.weight}}function T(F){return v(ht.controllers[F],ve)}function S(F){let D={init_from:n(F,"init_from")[0].textContent};ht.images[F.getAttribute("id")]=D}function b(F){return F.build!==void 0?F.build:F.init_from}function V(F){let D=ht.images[F];return D!==void 0?v(D,b):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",F),null)}function q(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"profile_COMMON":D.profile=Y(K);break}}ht.effects[F.getAttribute("id")]=D}function Y(F){let D={surfaces:{},samplers:{}};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"newparam":z(K,D);break;case"technique":D.technique=re(K);break;case"extra":D.extra=he(K);break}}return D}function z(F,D){let j=F.getAttribute("sid");for(let H=0,K=F.childNodes.length;H<K;H++){let be=F.childNodes[H];if(be.nodeType===1)switch(be.nodeName){case"surface":D.surfaces[j]=X(be);break;case"sampler2D":D.samplers[j]=se(be);break}}}function X(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"init_from":D.init_from=K.textContent;break}}return D}function se(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"source":D.source=K.textContent;break}}return D}function re(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"constant":case"lambert":case"blinn":case"phong":D.type=K.nodeName,D.parameters=le(K);break;case"extra":D.extra=he(K);break}}return D}function le(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":D[K.nodeName]=xe(K);break;case"transparent":D[K.nodeName]={opaque:K.hasAttribute("opaque")?K.getAttribute("opaque"):"A_ONE",data:xe(K)};break}}return D}function xe(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"color":D[K.nodeName]=s(K.textContent);break;case"float":D[K.nodeName]=parseFloat(K.textContent);break;case"texture":D[K.nodeName]={id:K.getAttribute("texture"),extra:G(K)};break}}return D}function G(F){let D={technique:{}};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"extra":A(K,D);break}}return D}function A(F,D){for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"technique":U(K,D);break}}}function U(F,D){for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":D.technique[K.nodeName]=parseFloat(K.textContent);break;case"wrapU":case"wrapV":K.textContent.toUpperCase()==="TRUE"?D.technique[K.nodeName]=1:K.textContent.toUpperCase()==="FALSE"?D.technique[K.nodeName]=0:D.technique[K.nodeName]=parseInt(K.textContent);break;case"bump":D[K.nodeName]=Te(K);break}}}function he(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"technique":D.technique=me(K);break}}return D}function me(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"double_sided":D[K.nodeName]=parseInt(K.textContent);break;case"bump":D[K.nodeName]=Te(K);break}}return D}function Te(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"texture":D[K.nodeName]={id:K.getAttribute("texture"),texcoord:K.getAttribute("texcoord"),extra:G(K)};break}}return D}function ee(F){return F}function k(F){return v(ht.effects[F],ee)}function J(F){let D={name:F.getAttribute("name")};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"instance_effect":D.url=a(K.getAttribute("url"));break}}ht.materials[F.getAttribute("id")]=D}function ue(F){let D,j=F.slice((F.lastIndexOf(".")-1>>>0)+2);switch(j=j.toLowerCase(),j){case"tga":D=Yh;break;default:D=Lp}return D}function Z(F){let D=k(F.url),j=D.profile.technique,H;switch(j.type){case"phong":case"blinn":H=new Zt;break;case"lambert":H=new Ea;break;default:H=new Ci;break}H.name=F.name||"";function K(Be,je=null){let it=D.profile.samplers[Be.id],Le=null;if(it!==void 0){let nt=D.profile.surfaces[it.source];Le=V(nt.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),Le=V(Be.id);if(Le!==null){let nt=ue(Le);if(nt!==void 0){let $e=nt.load(Le),ct=Be.extra;if(ct!==void 0&&ct.technique!==void 0&&c(ct.technique)===!1){let ot=ct.technique;$e.wrapS=ot.wrapU?rn:un,$e.wrapT=ot.wrapV?rn:un,$e.offset.set(ot.offsetU||0,ot.offsetV||0),$e.repeat.set(ot.repeatU||1,ot.repeatV||1)}else $e.wrapS=rn,$e.wrapT=rn;return je!==null&&($e.colorSpace=je),$e}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",Le),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",Be.id),null}let be=j.parameters;for(let Be in be){let je=be[Be];switch(Be){case"diffuse":je.color&&H.color.fromArray(je.color),je.texture&&(H.map=K(je.texture,jt));break;case"specular":je.color&&H.specular&&H.specular.fromArray(je.color),je.texture&&(H.specularMap=K(je.texture));break;case"bump":je.texture&&(H.normalMap=K(je.texture));break;case"ambient":je.texture&&(H.lightMap=K(je.texture,jt));break;case"shininess":je.float&&H.shininess&&(H.shininess=je.float);break;case"emission":je.color&&H.emissive&&H.emissive.fromArray(je.color),je.texture&&(H.emissiveMap=K(je.texture,jt));break}}H.color.convertSRGBToLinear(),H.specular&&H.specular.convertSRGBToLinear(),H.emissive&&H.emissive.convertSRGBToLinear();let Re=be.transparent,Ke=be.transparency;if(Ke===void 0&&Re&&(Ke={float:1}),Re===void 0&&Ke&&(Re={opaque:"A_ONE",data:{color:[1,1,1,1]}}),Re&&Ke)if(Re.data.texture)H.transparent=!0;else{let Be=Re.data.color;switch(Re.opaque){case"A_ONE":H.opacity=Be[3]*Ke.float;break;case"RGB_ZERO":H.opacity=1-Be[0]*Ke.float;break;case"A_ZERO":H.opacity=1-Be[3]*Ke.float;break;case"RGB_ONE":H.opacity=Be[0]*Ke.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',Re.opaque)}H.opacity<1&&(H.transparent=!0)}if(j.extra!==void 0&&j.extra.technique!==void 0){let Be=j.extra.technique;for(let je in Be){let it=Be[je];switch(je){case"double_sided":H.side=it===1?On:wi;break;case"bump":H.normalMap=K(it.texture),H.normalScale=new Ce(1,1);break}}}return H}function ce(F){return v(ht.materials[F],Z)}function pe(F){let D={name:F.getAttribute("name")};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"optics":D.optics=fe(K);break}}ht.cameras[F.getAttribute("id")]=D}function fe(F){for(let D=0;D<F.childNodes.length;D++){let j=F.childNodes[D];switch(j.nodeName){case"technique_common":return ge(j)}}return{}}function ge(F){let D={};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];switch(H.nodeName){case"perspective":case"orthographic":D.technique=H.nodeName,D.parameters=Ae(H);break}}return D}function Ae(F){let D={};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];switch(H.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":D[H.nodeName]=parseFloat(H.textContent);break}}return D}function Ie(F){let D;switch(F.optics.technique){case"perspective":D=new en(F.optics.parameters.yfov,F.optics.parameters.aspect_ratio,F.optics.parameters.znear,F.optics.parameters.zfar);break;case"orthographic":let j=F.optics.parameters.ymag,H=F.optics.parameters.xmag,K=F.optics.parameters.aspect_ratio;H=H===void 0?j*K:H,j=j===void 0?H/K:j,H*=.5,j*=.5,D=new gr(-H,H,j,-j,F.optics.parameters.znear,F.optics.parameters.zfar);break;default:D=new en;break}return D.name=F.name||"",D}function Fe(F){let D=ht.cameras[F];return D!==void 0?v(D,Ie):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",F),null)}function Je(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"technique_common":D=dt(K);break}}ht.lights[F.getAttribute("id")]=D}function dt(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"directional":case"point":case"spot":case"ambient":D.technique=K.nodeName,D.parameters=Oe(K)}}return D}function Oe(F){let D={};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"color":let be=s(K.textContent);D.color=new Ve().fromArray(be).convertSRGBToLinear();break;case"falloff_angle":D.falloffAngle=parseFloat(K.textContent);break;case"quadratic_attenuation":let Re=parseFloat(K.textContent);D.distance=Re?Math.sqrt(1/Re):0;break}}return D}function ne(F){let D;switch(F.technique){case"directional":D=new xr;break;case"point":D=new eo;break;case"spot":D=new Aa;break;case"ambient":D=new _r;break}return F.parameters.color&&D.color.copy(F.parameters.color),F.parameters.distance&&(D.distance=F.parameters.distance),D}function Pe(F){let D=ht.lights[F];return D!==void 0?v(D,ne):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",F),null)}function Ne(F){let D={name:F.getAttribute("name"),sources:{},vertices:{},primitives:[]},j=n(F,"mesh")[0];if(j!==void 0){for(let H=0;H<j.childNodes.length;H++){let K=j.childNodes[H];if(K.nodeType!==1)continue;let be=K.getAttribute("id");switch(K.nodeName){case"source":D.sources[be]=Ue(K);break;case"vertices":D.vertices=De(K);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",K.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":D.primitives.push(ut(K));break;default:console.log(K)}}ht.geometries[F.getAttribute("id")]=D}}function Ue(F){let D={array:[],stride:3};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"float_array":D.array=s(H.textContent);break;case"Name_array":D.array=i(H.textContent);break;case"technique_common":let K=n(H,"accessor")[0];K!==void 0&&(D.stride=parseInt(K.getAttribute("stride")));break}}return D}function De(F){let D={};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];H.nodeType===1&&(D[H.getAttribute("semantic")]=a(H.getAttribute("source")))}return D}function ut(F){let D={type:F.nodeName,material:F.getAttribute("material"),count:parseInt(F.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let j=0,H=F.childNodes.length;j<H;j++){let K=F.childNodes[j];if(K.nodeType===1)switch(K.nodeName){case"input":let be=a(K.getAttribute("source")),Re=K.getAttribute("semantic"),Ke=parseInt(K.getAttribute("offset")),Be=parseInt(K.getAttribute("set")),je=Be>0?Re+Be:Re;D.inputs[je]={id:be,offset:Ke},D.stride=Math.max(D.stride,Ke+1),Re==="TEXCOORD"&&(D.hasUV=!0);break;case"vcount":D.vcount=o(K.textContent);break;case"p":D.p=o(K.textContent);break}}return D}function at(F){let D={};for(let j=0;j<F.length;j++){let H=F[j];D[H.type]===void 0&&(D[H.type]=[]),D[H.type].push(H)}return D}function yt(F){let D=0;for(let j=0,H=F.length;j<H;j++)F[j].hasUV===!0&&D++;D>0&&D<F.length&&(F.uvsNeedsFix=!0)}function wt(F){let D={},j=F.sources,H=F.vertices,K=F.primitives;if(K.length===0)return{};let be=at(K);for(let Re in be){let Ke=be[Re];yt(Ke),D[Re]=Qe(Ke,j,H)}return D}function Qe(F,D,j){let H={},K={array:[],stride:0},be={array:[],stride:0},Re={array:[],stride:0},Ke={array:[],stride:0},Be={array:[],stride:0},je={array:[],stride:4},it={array:[],stride:4},Le=new St,nt=[],$e=0;for(let ct=0;ct<F.length;ct++){let ot=F[ct],on=ot.inputs,Gt=0;switch(ot.type){case"lines":case"linestrips":Gt=ot.count*2;break;case"triangles":Gt=ot.count*3;break;case"polylist":for(let Lt=0;Lt<ot.count;Lt++){let Ot=ot.vcount[Lt];switch(Ot){case 3:Gt+=3;break;case 4:Gt+=6;break;default:Gt+=(Ot-2)*3;break}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",ot.type)}Le.addGroup($e,Gt,ct),$e+=Gt,ot.material&&nt.push(ot.material);for(let Lt in on){let Ot=on[Lt];switch(Lt){case"VERTEX":for(let Ar in j){let ni=j[Ar];switch(Ar){case"POSITION":let ao=K.array.length;if(ke(ot,D[ni],Ot.offset,K.array),K.stride=D[ni].stride,D.skinWeights&&D.skinIndices&&(ke(ot,D.skinIndices,Ot.offset,je.array),ke(ot,D.skinWeights,Ot.offset,it.array)),ot.hasUV===!1&&F.uvsNeedsFix===!0){let Av=(K.array.length-ao)/K.stride;for(let Dp=0;Dp<Av;Dp++)Re.array.push(0,0)}break;case"NORMAL":ke(ot,D[ni],Ot.offset,be.array),be.stride=D[ni].stride;break;case"COLOR":ke(ot,D[ni],Ot.offset,Be.array),Be.stride=D[ni].stride;break;case"TEXCOORD":ke(ot,D[ni],Ot.offset,Re.array),Re.stride=D[ni].stride;break;case"TEXCOORD1":ke(ot,D[ni],Ot.offset,Ke.array),Re.stride=D[ni].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',Ar)}}break;case"NORMAL":ke(ot,D[Ot.id],Ot.offset,be.array),be.stride=D[Ot.id].stride;break;case"COLOR":ke(ot,D[Ot.id],Ot.offset,Be.array,!0),Be.stride=D[Ot.id].stride;break;case"TEXCOORD":ke(ot,D[Ot.id],Ot.offset,Re.array),Re.stride=D[Ot.id].stride;break;case"TEXCOORD1":ke(ot,D[Ot.id],Ot.offset,Ke.array),Ke.stride=D[Ot.id].stride;break}}}return K.array.length>0&&Le.setAttribute("position",new ze(K.array,K.stride)),be.array.length>0&&Le.setAttribute("normal",new ze(be.array,be.stride)),Be.array.length>0&&Le.setAttribute("color",new ze(Be.array,Be.stride)),Re.array.length>0&&Le.setAttribute("uv",new ze(Re.array,Re.stride)),Ke.array.length>0&&Le.setAttribute("uv1",new ze(Ke.array,Ke.stride)),je.array.length>0&&Le.setAttribute("skinIndex",new ze(je.array,je.stride)),it.array.length>0&&Le.setAttribute("skinWeight",new ze(it.array,it.stride)),H.data=Le,H.type=F[0].type,H.materialKeys=nt,H}function ke(F,D,j,H,K=!1){let be=F.p,Re=F.stride,Ke=F.vcount;function Be(Le){let nt=be[Le+j]*it,$e=nt+it;for(;nt<$e;nt++)H.push(je[nt]);if(K){let ct=H.length-it-1;Mc.setRGB(H[ct+0],H[ct+1],H[ct+2]).convertSRGBToLinear(),H[ct+0]=Mc.r,H[ct+1]=Mc.g,H[ct+2]=Mc.b}}let je=D.array,it=D.stride;if(F.vcount!==void 0){let Le=0;for(let nt=0,$e=Ke.length;nt<$e;nt++){let ct=Ke[nt];if(ct===4){let ot=Le+Re*0,on=Le+Re*1,Gt=Le+Re*2,Lt=Le+Re*3;Be(ot),Be(on),Be(Lt),Be(on),Be(Gt),Be(Lt)}else if(ct===3){let ot=Le+Re*0,on=Le+Re*1,Gt=Le+Re*2;Be(ot),Be(on),Be(Gt)}else if(ct>4)for(let ot=1,on=ct-2;ot<=on;ot++){let Gt=Le+Re*0,Lt=Le+Re*ot,Ot=Le+Re*(ot+1);Be(Gt),Be(Lt),Be(Ot)}Le+=Re*ct}}else for(let Le=0,nt=be.length;Le<nt;Le+=Re)Be(Le)}function qe(F){return v(ht.geometries[F],wt)}function He(F){let D={name:F.getAttribute("name")||"",joints:{},links:[]};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"technique_common":Wt(H,D);break}}ht.kinematicsModels[F.getAttribute("id")]=D}function tt(F){return F.build!==void 0?F.build:F}function rt(F){return v(ht.kinematicsModels[F],tt)}function Wt(F,D){for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"joint":D.joints[H.getAttribute("sid")]=jn(H);break;case"link":D.links.push(Oi(H));break}}}function jn(F){let D;for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"prismatic":case"revolute":D=fi(H);break}}return D}function fi(F){let D={sid:F.getAttribute("sid"),name:F.getAttribute("name")||"",axis:new oe,limits:{min:0,max:0},type:F.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"axis":let K=s(H.textContent);D.axis.fromArray(K);break;case"limits":let be=H.getElementsByTagName("max")[0],Re=H.getElementsByTagName("min")[0];D.limits.max=parseFloat(be.textContent),D.limits.min=parseFloat(Re.textContent);break}}return D.limits.min>=D.limits.max&&(D.static=!0),D.middlePosition=(D.limits.min+D.limits.max)/2,D}function Oi(F){let D={sid:F.getAttribute("sid"),name:F.getAttribute("name")||"",attachments:[],transforms:[]};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"attachment_full":D.attachments.push(_c(H));break;case"matrix":case"translate":case"rotate":D.transforms.push(ll(H));break}}return D}function _c(F){let D={joint:F.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"link":D.links.push(Oi(H));break;case"matrix":case"translate":case"rotate":D.transforms.push(ll(H));break}}return D}function ll(F){let D={type:F.nodeName},j=s(F.textContent);switch(D.type){case"matrix":D.obj=new Ye,D.obj.fromArray(j).transpose();break;case"translate":D.obj=new oe,D.obj.fromArray(j);break;case"rotate":D.obj=new oe,D.obj.fromArray(j),D.angle=pn.degToRad(j[3]);break}return D}function Wh(F){let D={name:F.getAttribute("name")||"",rigidBodies:{}};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"rigid_body":D.rigidBodies[H.getAttribute("name")]={},Xh(H,D.rigidBodies[H.getAttribute("name")]);break}}ht.physicsModels[F.getAttribute("id")]=D}function Xh(F,D){for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"technique_common":jh(H,D);break}}}function jh(F,D){for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"inertia":D.inertia=s(H.textContent);break;case"mass":D.mass=s(H.textContent)[0];break}}}function Q(F){let D={bindJointAxis:[]};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"bind_joint_axis":D.bindJointAxis.push(_e(H));break}}ht.kinematicsScenes[a(F.getAttribute("url"))]=D}function _e(F){let D={target:F.getAttribute("target").split("/").pop()};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType===1)switch(H.nodeName){case"axis":let K=H.getElementsByTagName("param")[0];D.axis=K.textContent;let be=D.axis.split("inst_").pop().split("axis")[0];D.jointIndex=be.substring(0,be.length-1);break}}return D}function Se(F){return F.build!==void 0?F.build:F}function we(F){return v(ht.kinematicsScenes[F],Se)}function Ee(){let F=Object.keys(ht.kinematicsModels)[0],D=Object.keys(ht.kinematicsScenes)[0],j=Object.keys(ht.visualScenes)[0];if(F===void 0||D===void 0)return;let H=rt(F),K=we(D),be=Zr(j),Re=K.bindJointAxis,Ke={};for(let it=0,Le=Re.length;it<Le;it++){let nt=Re[it],$e=Nt.querySelector('[sid="'+nt.target+'"]');if($e){let ct=$e.parentElement;Be(nt.jointIndex,ct)}}function Be(it,Le){let nt=Le.getAttribute("name"),$e=H.joints[it];be.traverse(function(ct){ct.name===nt&&(Ke[it]={object:ct,transforms:We(Le),joint:$e,position:$e.zeroPosition})})}let je=new Ye;Op={joints:H&&H.joints,getJointValue:function(it){let Le=Ke[it];if(Le)return Le.position;console.warn("THREE.ColladaLoader: Joint "+it+" doesn't exist.")},setJointValue:function(it,Le){let nt=Ke[it];if(nt){let $e=nt.joint;if(Le>$e.limits.max||Le<$e.limits.min)console.warn("THREE.ColladaLoader: Joint "+it+" value "+Le+" outside of limits (min: "+$e.limits.min+", max: "+$e.limits.max+").");else if($e.static)console.warn("THREE.ColladaLoader: Joint "+it+" is static.");else{let ct=nt.object,ot=$e.axis,on=nt.transforms;et.identity();for(let Gt=0;Gt<on.length;Gt++){let Lt=on[Gt];if(Lt.sid&&Lt.sid.indexOf(it)!==-1)switch($e.type){case"revolute":et.multiply(je.makeRotationAxis(ot,pn.degToRad(Le)));break;case"prismatic":et.multiply(je.makeTranslation(ot.x*Le,ot.y*Le,ot.z*Le));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+$e.type);break}else switch(Lt.type){case"matrix":et.multiply(Lt.obj);break;case"translate":et.multiply(je.makeTranslation(Lt.obj.x,Lt.obj.y,Lt.obj.z));break;case"scale":et.scale(Lt.obj);break;case"rotate":et.multiply(je.makeRotationAxis(Lt.obj,Lt.angle));break}}ct.matrix.copy(et),ct.matrix.decompose(ct.position,ct.quaternion,ct.scale),Ke[it].position=Le}}else console.log("THREE.ColladaLoader: "+it+" does not exist.")}}}function We(F){let D=[],j=Nt.querySelector('[id="'+F.id+'"]');for(let H=0;H<j.childNodes.length;H++){let K=j.childNodes[H];if(K.nodeType!==1)continue;let be,Re;switch(K.nodeName){case"matrix":be=s(K.textContent);let Ke=new Ye().fromArray(be).transpose();D.push({sid:K.getAttribute("sid"),type:K.nodeName,obj:Ke});break;case"translate":case"scale":be=s(K.textContent),Re=new oe().fromArray(be),D.push({sid:K.getAttribute("sid"),type:K.nodeName,obj:Re});break;case"rotate":be=s(K.textContent),Re=new oe().fromArray(be);let Be=pn.degToRad(be[3]);D.push({sid:K.getAttribute("sid"),type:K.nodeName,obj:Re,angle:Be});break}}return D}function st(F){let D=F.getElementsByTagName("node");for(let j=0;j<D.length;j++){let H=D[j];H.hasAttribute("id")===!1&&H.setAttribute("id",l())}}let et=new Ye,lt=new oe;function mt(F){let D={name:F.getAttribute("name")||"",type:F.getAttribute("type"),id:F.getAttribute("id"),sid:F.getAttribute("sid"),matrix:new Ye,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];if(H.nodeType!==1)continue;let K;switch(H.nodeName){case"node":D.nodes.push(H.getAttribute("id")),mt(H);break;case"instance_camera":D.instanceCameras.push(a(H.getAttribute("url")));break;case"instance_controller":D.instanceControllers.push(gt(H));break;case"instance_light":D.instanceLights.push(a(H.getAttribute("url")));break;case"instance_geometry":D.instanceGeometries.push(gt(H));break;case"instance_node":D.instanceNodes.push(a(H.getAttribute("url")));break;case"matrix":K=s(H.textContent),D.matrix.multiply(et.fromArray(K).transpose()),D.transforms[H.getAttribute("sid")]=H.nodeName;break;case"translate":K=s(H.textContent),lt.fromArray(K),D.matrix.multiply(et.makeTranslation(lt.x,lt.y,lt.z)),D.transforms[H.getAttribute("sid")]=H.nodeName;break;case"rotate":K=s(H.textContent);let be=pn.degToRad(K[3]);D.matrix.multiply(et.makeRotationAxis(lt.fromArray(K),be)),D.transforms[H.getAttribute("sid")]=H.nodeName;break;case"scale":K=s(H.textContent),D.matrix.scale(lt.fromArray(K)),D.transforms[H.getAttribute("sid")]=H.nodeName;break;case"extra":break;default:console.log(H)}}return _t(D.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",D.id):ht.nodes[D.id]=D,D}function gt(F){let D={id:a(F.getAttribute("url")),materials:{},skeletons:[]};for(let j=0;j<F.childNodes.length;j++){let H=F.childNodes[j];switch(H.nodeName){case"bind_material":let K=H.getElementsByTagName("instance_material");for(let be=0;be<K.length;be++){let Re=K[be],Ke=Re.getAttribute("symbol"),Be=Re.getAttribute("target");D.materials[Ke]=a(Be)}break;case"skeleton":D.skeletons.push(a(H.textContent));break;default:break}}return D}function xt(F,D){let j=[],H=[],K,be,Re;for(K=0;K<F.length;K++){let je=F[K],it;if(_t(je))it=rr(je),tn(it,D,j);else if(Tc(je)){let nt=ht.visualScenes[je].children;for(let $e=0;$e<nt.length;$e++){let ct=nt[$e];if(ct.type==="JOINT"){let ot=rr(ct.id);tn(ot,D,j)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",je)}for(K=0;K<D.length;K++)for(be=0;be<j.length;be++)if(Re=j[be],Re.bone.name===D[K].name){H[K]=Re,Re.processed=!0;break}for(K=0;K<j.length;K++)Re=j[K],Re.processed===!1&&(H.push(Re),Re.processed=!0);let Ke=[],Be=[];for(K=0;K<H.length;K++)Re=H[K],Ke.push(Re.bone),Be.push(Re.boneInverse);return new Ta(Ke,Be)}function tn(F,D,j){F.traverse(function(H){if(H.isBone===!0){let K;for(let be=0;be<D.length;be++){let Re=D[be];if(Re.name===H.name){K=Re.boneInverse;break}}K===void 0&&(K=new Ye),j.push({bone:H,boneInverse:K,processed:!1})}})}function qn(F){let D=[],j=F.matrix,H=F.nodes,K=F.type,be=F.instanceCameras,Re=F.instanceControllers,Ke=F.instanceLights,Be=F.instanceGeometries,je=F.instanceNodes;for(let Le=0,nt=H.length;Le<nt;Le++)D.push(rr(H[Le]));for(let Le=0,nt=be.length;Le<nt;Le++){let $e=Fe(be[Le]);$e!==null&&D.push($e.clone())}for(let Le=0,nt=Re.length;Le<nt;Le++){let $e=Re[Le],ct=T($e.id),ot=qe(ct.id),on=qt(ot,$e.materials),Gt=$e.skeletons,Lt=ct.skin.joints,Ot=xt(Gt,Lt);for(let Ar=0,ni=on.length;Ar<ni;Ar++){let ao=on[Ar];ao.isSkinnedMesh&&(ao.bind(Ot,ct.skin.bindMatrix),ao.normalizeSkinWeights()),D.push(ao)}}for(let Le=0,nt=Ke.length;Le<nt;Le++){let $e=Pe(Ke[Le]);$e!==null&&D.push($e.clone())}for(let Le=0,nt=Be.length;Le<nt;Le++){let $e=Be[Le],ct=qe($e.id),ot=qt(ct,$e.materials);for(let on=0,Gt=ot.length;on<Gt;on++)D.push(ot[on])}for(let Le=0,nt=je.length;Le<nt;Le++)D.push(rr(je[Le]).clone());let it;if(H.length===0&&D.length===1)it=D[0];else{it=K==="JOINT"?new ms:new dn;for(let Le=0;Le<D.length;Le++)it.add(D[Le])}return it.name=K==="JOINT"?F.sid:F.name,it.matrix.copy(j),it.matrix.decompose(it.position,it.quaternion,it.scale),it}let gn=new Ci({name:Dt.DEFAULT_MATERIAL_NAME,color:16711935});function Di(F,D){let j=[];for(let H=0,K=F.length;H<K;H++){let be=D[F[H]];be===void 0?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",F[H]),j.push(gn)):j.push(ce(be))}return j}function qt(F,D){let j=[];for(let H in F){let K=F[H],be=Di(K.materialKeys,D);if(be.length===0&&(H==="lines"||H==="linestrips"?be.push(new Wn):be.push(new Zt)),H==="lines"||H==="linestrips")for(let je=0,it=be.length;je<it;je++){let Le=be[je];if(Le.isMeshPhongMaterial===!0||Le.isMeshLambertMaterial===!0){let nt=new Wn;nt.color.copy(Le.color),nt.opacity=Le.opacity,nt.transparent=Le.transparent,be[je]=nt}}let Re=K.data.attributes.skinIndex!==void 0,Ke=be.length===1?be[0]:be,Be;switch(H){case"lines":Be=new yr(K.data,Ke);break;case"linestrips":Be=new Js(K.data,Ke);break;case"triangles":case"polylist":Re?Be=new xa(K.data,Ke):Be=new Pt(K.data,Ke);break}j.push(Be)}return j}function _t(F){return ht.nodes[F]!==void 0}function rr(F){return v(ht.nodes[F],qn)}function Yt(F){let D={name:F.getAttribute("name"),children:[]};st(F);let j=n(F,"node");for(let H=0;H<j.length;H++)D.children.push(mt(j[H]));ht.visualScenes[F.getAttribute("id")]=D}function sr(F){let D=new dn;D.name=F.name;let j=F.children;for(let H=0;H<j.length;H++){let K=j[H];D.add(rr(K.id))}return D}function Tc(F){return ht.visualScenes[F]!==void 0}function Zr(F){return v(ht.visualScenes[F],sr)}function cl(F){let D=n(F,"instance_visual_scene")[0];return Zr(a(D.getAttribute("url")))}function Cn(){let F=ht.clips;if(c(F)===!0){if(c(ht.animations)===!1){let D=[];for(let j in ht.animations){let H=x(j);for(let K=0,be=H.length;K<be;K++)D.push(H[K])}Ec.push(new Qs("default",-1,D))}}else for(let D in F)Ec.push(W(D))}function or(F){let D="",j=[F];for(;j.length;){let H=j.shift();H.nodeType===Node.TEXT_NODE?D+=H.textContent:(D+=`
-`,j.push.apply(j,H.childNodes))}return D.trim()}if(e.length===0)return{scene:new vr};let oo=new DOMParser().parseFromString(e,"application/xml"),Nt=n(oo,"COLLADA")[0],Rs=oo.getElementsByTagName("parsererror")[0];if(Rs!==void 0){let F=n(Rs,"div")[0],D;return F?D=F.textContent:D=or(Rs),console.error(`THREE.ColladaLoader: Failed to parse collada file.
-`,D),null}let qh=Nt.getAttribute("version");console.debug("THREE.ColladaLoader: File version",qh);let ul=u(n(Nt,"asset")[0]),Lp=new Pi(this.manager);Lp.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);let Yh;Es&&(Yh=new Es(this.manager),Yh.setPath(this.resourcePath||t));let Mc=new Ve,Ec=[],Op={},Sv=0,ht={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};p(Nt,"library_animations","animation",d),p(Nt,"library_animation_clips","animation_clip",$),p(Nt,"library_controllers","controller",ae),p(Nt,"library_images","image",S),p(Nt,"library_effects","effect",q),p(Nt,"library_materials","material",J),p(Nt,"library_cameras","camera",pe),p(Nt,"library_lights","light",Je),p(Nt,"library_geometries","geometry",Ne),p(Nt,"library_nodes","node",mt),p(Nt,"library_visual_scenes","visual_scene",Yt),p(Nt,"library_kinematics_models","kinematics_model",He),p(Nt,"library_physics_models","physics_model",Wh),p(Nt,"scene","instance_kinematics_scene",Q),g(ht.animations,y),g(ht.clips,te),g(ht.controllers,ve),g(ht.images,b),g(ht.effects,ee),g(ht.materials,Z),g(ht.cameras,Ie),g(ht.lights,ne),g(ht.geometries,wt),g(ht.visualScenes,sr),Cn(),Ee();let bc=cl(n(Nt,"scene")[0]);return bc.animations=Ec,ul.upAxis==="Z_UP"&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),bc.rotation.set(-Math.PI/2,0,0)),bc.scale.multiplyScalar(ul.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Ec},kinematics:Op,library:ht,scene:bc}}};var Tt=(r,e)=>()=>(e||(e={exports:{}},r(e.exports,e)),e.exports),z0=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.VERSION=void 0,r.VERSION="9.0.1"}),Ut=Tt((exports,module)=>{"use strict";var __spreadArray=exports&&exports.__spreadArray||function(r,e){for(var t=0,n=e.length,i=r.length;t<n;t++,i++)r[i]=e[t];return r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.toFastProperties=exports.timer=exports.peek=exports.isES2015MapSupported=exports.PRINT_WARNING=exports.PRINT_ERROR=exports.packArray=exports.IDENTITY=exports.NOOP=exports.merge=exports.groupBy=exports.defaults=exports.assignNoOverwrite=exports.assign=exports.zipObject=exports.sortBy=exports.indexOf=exports.some=exports.difference=exports.every=exports.isObject=exports.isRegExp=exports.isArray=exports.partial=exports.uniq=exports.compact=exports.reduce=exports.findAll=exports.find=exports.cloneObj=exports.cloneArr=exports.contains=exports.has=exports.pick=exports.reject=exports.filter=exports.dropRight=exports.drop=exports.isFunction=exports.isUndefined=exports.isString=exports.forEach=exports.last=exports.first=exports.flatten=exports.map=exports.mapValues=exports.values=exports.keys=exports.isEmpty=void 0;function isEmpty(r){return r&&r.length===0}exports.isEmpty=isEmpty;function keys(r){return r==null?[]:Object.keys(r)}exports.keys=keys;function values(r){for(var e=[],t=Object.keys(r),n=0;n<t.length;n++)e.push(r[t[n]]);return e}exports.values=values;function mapValues(r,e){for(var t=[],n=keys(r),i=0;i<n.length;i++){var s=n[i];t.push(e.call(null,r[s],s))}return t}exports.mapValues=mapValues;function map(r,e){for(var t=[],n=0;n<r.length;n++)t.push(e.call(null,r[n],n));return t}exports.map=map;function flatten(r){for(var e=[],t=0;t<r.length;t++){var n=r[t];Array.isArray(n)?e=e.concat(flatten(n)):e.push(n)}return e}exports.flatten=flatten;function first(r){return isEmpty(r)?void 0:r[0]}exports.first=first;function last(r){var e=r&&r.length;return e?r[e-1]:void 0}exports.last=last;function forEach(r,e){if(Array.isArray(r))for(var t=0;t<r.length;t++)e.call(null,r[t],t);else if(isObject(r))for(var n=keys(r),t=0;t<n.length;t++){var i=n[t],s=r[i];e.call(null,s,i)}else throw Error("non exhaustive match")}exports.forEach=forEach;function isString(r){return typeof r=="string"}exports.isString=isString;function isUndefined(r){return r===void 0}exports.isUndefined=isUndefined;function isFunction(r){return r instanceof Function}exports.isFunction=isFunction;function drop(r,e){return e===void 0&&(e=1),r.slice(e,r.length)}exports.drop=drop;function dropRight(r,e){return e===void 0&&(e=1),r.slice(0,r.length-e)}exports.dropRight=dropRight;function filter(r,e){var t=[];if(Array.isArray(r))for(var n=0;n<r.length;n++){var i=r[n];e.call(null,i)&&t.push(i)}return t}exports.filter=filter;function reject(r,e){return filter(r,function(t){return!e(t)})}exports.reject=reject;function pick(r,e){for(var t=Object.keys(r),n={},i=0;i<t.length;i++){var s=t[i],o=r[s];e(o)&&(n[s]=o)}return n}exports.pick=pick;function has(r,e){return isObject(r)?r.hasOwnProperty(e):!1}exports.has=has;function contains(r,e){return find(r,function(t){return t===e})!==void 0}exports.contains=contains;function cloneArr(r){for(var e=[],t=0;t<r.length;t++)e.push(r[t]);return e}exports.cloneArr=cloneArr;function cloneObj(r){var e={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e}exports.cloneObj=cloneObj;function find(r,e){for(var t=0;t<r.length;t++){var n=r[t];if(e.call(null,n))return n}}exports.find=find;function findAll(r,e){for(var t=[],n=0;n<r.length;n++){var i=r[n];e.call(null,i)&&t.push(i)}return t}exports.findAll=findAll;function reduce(r,e,t){for(var n=Array.isArray(r),i=n?r:values(r),s=n?[]:keys(r),o=t,a=0;a<i.length;a++)o=e.call(null,o,i[a],n?a:s[a]);return o}exports.reduce=reduce;function compact(r){return reject(r,function(e){return e==null})}exports.compact=compact;function uniq(r,e){e===void 0&&(e=function(n){return n});var t=[];return reduce(r,function(n,i){var s=e(i);return contains(t,s)?n:(t.push(s),n.concat(i))},[])}exports.uniq=uniq;function partial(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var n=[null],i=n.concat(e);return Function.bind.apply(r,i)}exports.partial=partial;function isArray(r){return Array.isArray(r)}exports.isArray=isArray;function isRegExp(r){return r instanceof RegExp}exports.isRegExp=isRegExp;function isObject(r){return r instanceof Object}exports.isObject=isObject;function every(r,e){for(var t=0;t<r.length;t++)if(!e(r[t],t))return!1;return!0}exports.every=every;function difference(r,e){return reject(r,function(t){return contains(e,t)})}exports.difference=difference;function some(r,e){for(var t=0;t<r.length;t++)if(e(r[t]))return!0;return!1}exports.some=some;function indexOf(r,e){for(var t=0;t<r.length;t++)if(r[t]===e)return t;return-1}exports.indexOf=indexOf;function sortBy(r,e){var t=cloneArr(r);return t.sort(function(n,i){return e(n)-e(i)}),t}exports.sortBy=sortBy;function zipObject(r,e){if(r.length!==e.length)throw Error("can't zipObject with different number of keys and values!");for(var t={},n=0;n<r.length;n++)t[r[n]]=e[n];return t}exports.zipObject=zipObject;function assign(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var n=0;n<e.length;n++)for(var i=e[n],s=keys(i),o=0;o<s.length;o++){var a=s[o];r[a]=i[a]}return r}exports.assign=assign;function assignNoOverwrite(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var n=0;n<e.length;n++)for(var i=e[n],s=keys(i),o=0;o<s.length;o++){var a=s[o];has(r,a)||(r[a]=i[a])}return r}exports.assignNoOverwrite=assignNoOverwrite;function defaults(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return assignNoOverwrite.apply(void 0,__spreadArray([{}],r))}exports.defaults=defaults;function groupBy(r,e){var t={};return forEach(r,function(n){var i=e(n),s=t[i];s?s.push(n):t[i]=[n]}),t}exports.groupBy=groupBy;function merge(r,e){for(var t=cloneObj(r),n=keys(e),i=0;i<n.length;i++){var s=n[i],o=e[s];t[s]=o}return t}exports.merge=merge;function NOOP(){}exports.NOOP=NOOP;function IDENTITY(r){return r}exports.IDENTITY=IDENTITY;function packArray(r){for(var e=[],t=0;t<r.length;t++){var n=r[t];e.push(n!==void 0?n:void 0)}return e}exports.packArray=packArray;function PRINT_ERROR(r){console&&console.error&&console.error("Error: "+r)}exports.PRINT_ERROR=PRINT_ERROR;function PRINT_WARNING(r){console&&console.warn&&console.warn("Warning: "+r)}exports.PRINT_WARNING=PRINT_WARNING;function isES2015MapSupported(){return typeof Map=="function"}exports.isES2015MapSupported=isES2015MapSupported;function peek(r){return r[r.length-1]}exports.peek=peek;function timer(r){var e=new Date().getTime(),t=r(),n=new Date().getTime(),i=n-e;return{time:i,value:t}}exports.timer=timer;function toFastProperties(toBecomeFast){function FakeConstructor(){}FakeConstructor.prototype=toBecomeFast;var fakeInstance=new FakeConstructor;function fakeAccess(){return typeof fakeInstance.bar}return fakeAccess(),fakeAccess(),toBecomeFast}exports.toFastProperties=toFastProperties}),rp=Tt((r,e)=>{(function(t,n){typeof define=="function"&&define.amd?define([],n):typeof e=="object"&&e.exports?e.exports=n():t.regexpToAst=n()})(typeof self<"u"?self:r,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(d){this.idx=d.idx,this.input=d.input,this.groupIdx=d.groupIdx},t.prototype.pattern=function(d){this.idx=0,this.input=d,this.groupIdx=0,this.consumeChar("/");var m=this.disjunction();this.consumeChar("/");for(var _={type:"Flags",loc:{begin:this.idx,end:d.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":l(_,"global");break;case"i":l(_,"ignoreCase");break;case"m":l(_,"multiLine");break;case"u":l(_,"unicode");break;case"y":l(_,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:_,value:m,loc:this.loc(0)}},t.prototype.disjunction=function(){var d=[],m=this.idx;for(d.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),d.push(this.alternative());return{type:"Disjunction",value:d,loc:this.loc(m)}},t.prototype.alternative=function(){for(var d=[],m=this.idx;this.isTerm();)d.push(this.term());return{type:"Alternative",value:d,loc:this.loc(m)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var d=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(d)};case"$":return{type:"EndAnchor",loc:this.loc(d)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(d)};case"B":return{type:"NonWordBoundary",loc:this.loc(d)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var m;switch(this.popChar()){case"=":m="Lookahead";break;case"!":m="NegativeLookahead";break}c(m);var _=this.disjunction();return this.consumeChar(")"),{type:m,value:_,loc:this.loc(d)}}u()},t.prototype.quantifier=function(d){var m,_=this.idx;switch(this.popChar()){case"*":m={atLeast:0,atMost:1/0};break;case"+":m={atLeast:1,atMost:1/0};break;case"?":m={atLeast:0,atMost:1};break;case"{":var y=this.integerIncludingZero();switch(this.popChar()){case"}":m={atLeast:y,atMost:y};break;case",":var x;this.isDigit()?(x=this.integerIncludingZero(),m={atLeast:y,atMost:x}):m={atLeast:y,atMost:1/0},this.consumeChar("}");break}if(d===!0&&m===void 0)return;c(m);break}if(!(d===!0&&m===void 0))return c(m),this.peekChar(0)==="?"?(this.consumeChar("?"),m.greedy=!1):m.greedy=!0,m.type="Quantifier",m.loc=this.loc(_),m},t.prototype.atom=function(){var d,m=this.idx;switch(this.peekChar()){case".":d=this.dotAll();break;case"\\":d=this.atomEscape();break;case"[":d=this.characterClass();break;case"(":d=this.group();break}return d===void 0&&this.isPatternCharacter()&&(d=this.patternCharacter()),c(d),d.loc=this.loc(m),this.isQuantifier()&&(d.quantifier=this.quantifier()),d},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o(`
+}`,jp=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){let i=new qn,s=e.properties.get(i);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new nr({vertexShader:Ub,fragmentShader:kb,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Dt(new po(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Yp=class extends Qr{constructor(e,t){super();let n=this,i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,f=null,p=null,g=null,y=new jp,d=t.getContextAttributes(),m=null,_=null,v=[],x=[],S=new Pe,I=null,A=new nn;A.viewport=new wt;let C=new nn;C.viewport=new wt;let E=[A,C],b=new Lh,R=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let P=v[G];return P===void 0&&(P=new Ra,v[G]=P),P.getTargetRaySpace()},this.getControllerGrip=function(G){let P=v[G];return P===void 0&&(P=new Ra,v[G]=P),P.getGripSpace()},this.getHand=function(G){let P=v[G];return P===void 0&&(P=new Ra,v[G]=P),P.getHandSpace()};function B(G){let P=x.indexOf(G.inputSource);if(P===-1)return;let M=v[P];M!==void 0&&(M.update(G.inputSource,G.frame,c||o),M.dispatchEvent({type:G.type,data:G.inputSource}))}function V(){i.removeEventListener("select",B),i.removeEventListener("selectstart",B),i.removeEventListener("selectend",B),i.removeEventListener("squeeze",B),i.removeEventListener("squeezestart",B),i.removeEventListener("squeezeend",B),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",ie);for(let G=0;G<v.length;G++){let P=x[G];P!==null&&(x[G]=null,v[G].disconnect(P))}R=null,N=null,y.reset(),e.setRenderTarget(m),p=null,f=null,h=null,i=null,_=null,_e.stop(),n.isPresenting=!1,e.setPixelRatio(I),e.setSize(S.width,S.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(G){s=G,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){a=G,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(G){c=G},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(G){if(i=G,i!==null){if(m=e.getRenderTarget(),i.addEventListener("select",B),i.addEventListener("selectstart",B),i.addEventListener("selectend",B),i.addEventListener("squeeze",B),i.addEventListener("squeezestart",B),i.addEventListener("squeezeend",B),i.addEventListener("end",V),i.addEventListener("inputsourceschange",ie),d.xrCompatible!==!0&&await t.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(S),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let M=null,T=null,k=null;d.depth&&(k=d.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,M=d.stencil?Va:Sa,T=d.stencil?Ga:Ls);let j={colorFormat:t.RGBA8,depthFormat:k,scaleFactor:s};h=new XRWebGLBinding(i,t),f=h.createProjectionLayer(j),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),_=new wr(f.textureWidth,f.textureHeight,{format:Pi,type:lr,depthTexture:new oc(f.textureWidth,f.textureHeight,T,void 0,void 0,void 0,void 0,void 0,void 0,M),stencilBuffer:d.stencil,colorSpace:e.outputColorSpace,samples:d.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{let M={antialias:d.antialias,alpha:!0,depth:d.depth,stencil:d.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,t,M),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),_=new wr(p.framebufferWidth,p.framebufferHeight,{format:Pi,type:lr,colorSpace:e.outputColorSpace,stencilBuffer:d.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),_e.setContext(i),_e.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function ie(G){for(let P=0;P<G.removed.length;P++){let M=G.removed[P],T=x.indexOf(M);T>=0&&(x[T]=null,v[T].disconnect(M))}for(let P=0;P<G.added.length;P++){let M=G.added[P],T=x.indexOf(M);if(T===-1){for(let j=0;j<v.length;j++)if(j>=x.length){x.push(M),T=j;break}else if(x[j]===null){x[j]=M,T=j;break}if(T===-1)break}let k=v[T];k&&k.connect(M)}}let Y=new se,te=new se;function q(G,P,M){Y.setFromMatrixPosition(P.matrixWorld),te.setFromMatrixPosition(M.matrixWorld);let T=Y.distanceTo(te),k=P.projectionMatrix.elements,j=M.projectionMatrix.elements,W=k[14]/(k[10]-1),re=k[14]/(k[10]+1),ce=(k[9]+1)/k[5],me=(k[9]-1)/k[5],w=(k[8]-1)/k[0],ae=(j[8]+1)/j[0],pe=W*w,ue=W*ae,ee=T/(-w+ae),$=ee*-w;if(P.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX($),G.translateZ(ee),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert(),k[10]===-1)G.projectionMatrix.copy(P.projectionMatrix),G.projectionMatrixInverse.copy(P.projectionMatrixInverse);else{let ve=W+ee,H=re+ee,L=pe-$,O=ue+(T-$),D=ce*re/H*ve,z=me*re/H*ve;G.projectionMatrix.makePerspective(L,O,D,z,ve,H),G.projectionMatrixInverse.copy(G.projectionMatrix).invert()}}function le(G,P){P===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(P.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(i===null)return;let P=G.near,M=G.far;y.texture!==null&&(y.depthNear>0&&(P=y.depthNear),y.depthFar>0&&(M=y.depthFar)),b.near=C.near=A.near=P,b.far=C.far=A.far=M,(R!==b.near||N!==b.far)&&(i.updateRenderState({depthNear:b.near,depthFar:b.far}),R=b.near,N=b.far),A.layers.mask=G.layers.mask|2,C.layers.mask=G.layers.mask|4,b.layers.mask=A.layers.mask|C.layers.mask;let T=G.parent,k=b.cameras;le(b,T);for(let j=0;j<k.length;j++)le(k[j],T);k.length===2?q(b,A,C):b.projectionMatrix.copy(A.projectionMatrix),ye(G,b,T)};function ye(G,P,M){M===null?G.matrix.copy(P.matrixWorld):(G.matrix.copy(M.matrixWorld),G.matrix.invert(),G.matrix.multiply(P.matrixWorld)),G.matrix.decompose(G.position,G.quaternion,G.scale),G.updateMatrixWorld(!0),G.projectionMatrix.copy(P.projectionMatrix),G.projectionMatrixInverse.copy(P.projectionMatrixInverse),G.isPerspectiveCamera&&(G.fov=oo*2*Math.atan(1/G.projectionMatrix.elements[5]),G.zoom=1)}this.getCamera=function(){return b},this.getFoveation=function(){if(!(f===null&&p===null))return l},this.setFoveation=function(G){l=G,f!==null&&(f.fixedFoveation=G),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=G)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(b)};let Te=null;function Ae(G,P){if(u=P.getViewerPose(c||o),g=P,u!==null){let M=u.views;p!==null&&(e.setRenderTargetFramebuffer(_,p.framebuffer),e.setRenderTarget(_));let T=!1;M.length!==b.cameras.length&&(b.cameras.length=0,T=!0);for(let W=0;W<M.length;W++){let re=M[W],ce=null;if(p!==null)ce=p.getViewport(re);else{let w=h.getViewSubImage(f,re);ce=w.viewport,W===0&&(e.setRenderTargetTextures(_,w.colorTexture,w.depthStencilTexture),e.setRenderTarget(_))}let me=E[W];me===void 0&&(me=new nn,me.layers.enable(W),me.viewport=new wt,E[W]=me),me.matrix.fromArray(re.transform.matrix),me.matrix.decompose(me.position,me.quaternion,me.scale),me.projectionMatrix.fromArray(re.projectionMatrix),me.projectionMatrixInverse.copy(me.projectionMatrix).invert(),me.viewport.set(ce.x,ce.y,ce.width,ce.height),W===0&&(b.matrix.copy(me.matrix),b.matrix.decompose(b.position,b.quaternion,b.scale)),T===!0&&b.cameras.push(me)}let k=i.enabledFeatures;if(k&&k.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&h){let W=h.getDepthInformation(M[0]);W&&W.isValid&&W.texture&&y.init(e,W,i.renderState)}}for(let M=0;M<v.length;M++){let T=x[M],k=v[M];T!==null&&k!==void 0&&k.update(T,P,c||o)}Te&&Te(G,P),P.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:P}),g=null}let _e=new Ly;_e.setAnimationLoop(Ae),this.setAnimationLoop=function(G){Te=G},this.dispose=function(){}}},bo=new vn,Bb=new Je;function Gb(r,e){function t(d,m){d.matrixAutoUpdate===!0&&d.updateMatrix(),m.value.copy(d.matrix)}function n(d,m){m.color.getRGB(d.fogColor.value,Rp(r)),m.isFog?(d.fogNear.value=m.near,d.fogFar.value=m.far):m.isFogExp2&&(d.fogDensity.value=m.density)}function i(d,m,_,v,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(d,m):m.isMeshToonMaterial?(s(d,m),h(d,m)):m.isMeshPhongMaterial?(s(d,m),u(d,m)):m.isMeshStandardMaterial?(s(d,m),f(d,m),m.isMeshPhysicalMaterial&&p(d,m,x)):m.isMeshMatcapMaterial?(s(d,m),g(d,m)):m.isMeshDepthMaterial?s(d,m):m.isMeshDistanceMaterial?(s(d,m),y(d,m)):m.isMeshNormalMaterial?s(d,m):m.isLineBasicMaterial?(o(d,m),m.isLineDashedMaterial&&a(d,m)):m.isPointsMaterial?l(d,m,_,v):m.isSpriteMaterial?c(d,m):m.isShadowMaterial?(d.color.value.copy(m.color),d.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(d,m){d.opacity.value=m.opacity,m.color&&d.diffuse.value.copy(m.color),m.emissive&&d.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(d.map.value=m.map,t(m.map,d.mapTransform)),m.alphaMap&&(d.alphaMap.value=m.alphaMap,t(m.alphaMap,d.alphaMapTransform)),m.bumpMap&&(d.bumpMap.value=m.bumpMap,t(m.bumpMap,d.bumpMapTransform),d.bumpScale.value=m.bumpScale,m.side===_n&&(d.bumpScale.value*=-1)),m.normalMap&&(d.normalMap.value=m.normalMap,t(m.normalMap,d.normalMapTransform),d.normalScale.value.copy(m.normalScale),m.side===_n&&d.normalScale.value.negate()),m.displacementMap&&(d.displacementMap.value=m.displacementMap,t(m.displacementMap,d.displacementMapTransform),d.displacementScale.value=m.displacementScale,d.displacementBias.value=m.displacementBias),m.emissiveMap&&(d.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,d.emissiveMapTransform)),m.specularMap&&(d.specularMap.value=m.specularMap,t(m.specularMap,d.specularMapTransform)),m.alphaTest>0&&(d.alphaTest.value=m.alphaTest);let _=e.get(m),v=_.envMap,x=_.envMapRotation;v&&(d.envMap.value=v,bo.copy(x),bo.x*=-1,bo.y*=-1,bo.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(bo.y*=-1,bo.z*=-1),d.envMapRotation.value.setFromMatrix4(Bb.makeRotationFromEuler(bo)),d.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,d.reflectivity.value=m.reflectivity,d.ior.value=m.ior,d.refractionRatio.value=m.refractionRatio),m.lightMap&&(d.lightMap.value=m.lightMap,d.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,d.lightMapTransform)),m.aoMap&&(d.aoMap.value=m.aoMap,d.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,d.aoMapTransform))}function o(d,m){d.diffuse.value.copy(m.color),d.opacity.value=m.opacity,m.map&&(d.map.value=m.map,t(m.map,d.mapTransform))}function a(d,m){d.dashSize.value=m.dashSize,d.totalSize.value=m.dashSize+m.gapSize,d.scale.value=m.scale}function l(d,m,_,v){d.diffuse.value.copy(m.color),d.opacity.value=m.opacity,d.size.value=m.size*_,d.scale.value=v*.5,m.map&&(d.map.value=m.map,t(m.map,d.uvTransform)),m.alphaMap&&(d.alphaMap.value=m.alphaMap,t(m.alphaMap,d.alphaMapTransform)),m.alphaTest>0&&(d.alphaTest.value=m.alphaTest)}function c(d,m){d.diffuse.value.copy(m.color),d.opacity.value=m.opacity,d.rotation.value=m.rotation,m.map&&(d.map.value=m.map,t(m.map,d.mapTransform)),m.alphaMap&&(d.alphaMap.value=m.alphaMap,t(m.alphaMap,d.alphaMapTransform)),m.alphaTest>0&&(d.alphaTest.value=m.alphaTest)}function u(d,m){d.specular.value.copy(m.specular),d.shininess.value=Math.max(m.shininess,1e-4)}function h(d,m){m.gradientMap&&(d.gradientMap.value=m.gradientMap)}function f(d,m){d.metalness.value=m.metalness,m.metalnessMap&&(d.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,d.metalnessMapTransform)),d.roughness.value=m.roughness,m.roughnessMap&&(d.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,d.roughnessMapTransform)),m.envMap&&(d.envMapIntensity.value=m.envMapIntensity)}function p(d,m,_){d.ior.value=m.ior,m.sheen>0&&(d.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),d.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(d.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,d.sheenColorMapTransform)),m.sheenRoughnessMap&&(d.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,d.sheenRoughnessMapTransform))),m.clearcoat>0&&(d.clearcoat.value=m.clearcoat,d.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(d.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,d.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(d.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,d.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(d.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,d.clearcoatNormalMapTransform),d.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===_n&&d.clearcoatNormalScale.value.negate())),m.dispersion>0&&(d.dispersion.value=m.dispersion),m.iridescence>0&&(d.iridescence.value=m.iridescence,d.iridescenceIOR.value=m.iridescenceIOR,d.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],d.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(d.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,d.iridescenceMapTransform)),m.iridescenceThicknessMap&&(d.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,d.iridescenceThicknessMapTransform))),m.transmission>0&&(d.transmission.value=m.transmission,d.transmissionSamplerMap.value=_.texture,d.transmissionSamplerSize.value.set(_.width,_.height),m.transmissionMap&&(d.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,d.transmissionMapTransform)),d.thickness.value=m.thickness,m.thicknessMap&&(d.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,d.thicknessMapTransform)),d.attenuationDistance.value=m.attenuationDistance,d.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(d.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(d.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,d.anisotropyMapTransform))),d.specularIntensity.value=m.specularIntensity,d.specularColor.value.copy(m.specularColor),m.specularColorMap&&(d.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,d.specularColorMapTransform)),m.specularIntensityMap&&(d.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,d.specularIntensityMapTransform))}function g(d,m){m.matcap&&(d.matcap.value=m.matcap)}function y(d,m){let _=e.get(m).light;d.referencePosition.value.setFromMatrixPosition(_.matrixWorld),d.nearDistance.value=_.shadow.camera.near,d.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Vb(r,e,t,n){let i={},s={},o=[],a=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(_,v){let x=v.program;n.uniformBlockBinding(_,x)}function c(_,v){let x=i[_.id];x===void 0&&(g(_),x=u(_),i[_.id]=x,_.addEventListener("dispose",d));let S=v.program;n.updateUBOMapping(_,S);let I=e.render.frame;s[_.id]!==I&&(f(_),s[_.id]=I)}function u(_){let v=h();_.__bindingPointIndex=v;let x=r.createBuffer(),S=_.__size,I=_.usage;return r.bindBuffer(r.UNIFORM_BUFFER,x),r.bufferData(r.UNIFORM_BUFFER,S,I),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,x),x}function h(){for(let _=0;_<a;_++)if(o.indexOf(_)===-1)return o.push(_),_;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(_){let v=i[_.id],x=_.uniforms,S=_.__cache;r.bindBuffer(r.UNIFORM_BUFFER,v);for(let I=0,A=x.length;I<A;I++){let C=Array.isArray(x[I])?x[I]:[x[I]];for(let E=0,b=C.length;E<b;E++){let R=C[E];if(p(R,I,E,S)===!0){let N=R.__offset,B=Array.isArray(R.value)?R.value:[R.value],V=0;for(let ie=0;ie<B.length;ie++){let Y=B[ie],te=y(Y);typeof Y=="number"||typeof Y=="boolean"?(R.__data[0]=Y,r.bufferSubData(r.UNIFORM_BUFFER,N+V,R.__data)):Y.isMatrix3?(R.__data[0]=Y.elements[0],R.__data[1]=Y.elements[1],R.__data[2]=Y.elements[2],R.__data[3]=0,R.__data[4]=Y.elements[3],R.__data[5]=Y.elements[4],R.__data[6]=Y.elements[5],R.__data[7]=0,R.__data[8]=Y.elements[6],R.__data[9]=Y.elements[7],R.__data[10]=Y.elements[8],R.__data[11]=0):(Y.toArray(R.__data,V),V+=te.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,N,R.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function p(_,v,x,S){let I=_.value,A=v+"_"+x;if(S[A]===void 0)return typeof I=="number"||typeof I=="boolean"?S[A]=I:S[A]=I.clone(),!0;{let C=S[A];if(typeof I=="number"||typeof I=="boolean"){if(C!==I)return S[A]=I,!0}else if(C.equals(I)===!1)return C.copy(I),!0}return!1}function g(_){let v=_.uniforms,x=0,S=16;for(let A=0,C=v.length;A<C;A++){let E=Array.isArray(v[A])?v[A]:[v[A]];for(let b=0,R=E.length;b<R;b++){let N=E[b],B=Array.isArray(N.value)?N.value:[N.value];for(let V=0,ie=B.length;V<ie;V++){let Y=B[V],te=y(Y),q=x%S,le=q%te.boundary,ye=q+le;x+=le,ye!==0&&S-ye<te.storage&&(x+=S-ye),N.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=x,x+=te.storage}}}let I=x%S;return I>0&&(x+=S-I),_.__size=x,_.__cache={},this}function y(_){let v={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(v.boundary=4,v.storage=4):_.isVector2?(v.boundary=8,v.storage=8):_.isVector3||_.isColor?(v.boundary=16,v.storage=12):_.isVector4?(v.boundary=16,v.storage=16):_.isMatrix3?(v.boundary=48,v.storage=48):_.isMatrix4?(v.boundary=64,v.storage=64):_.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",_),v}function d(_){let v=_.target;v.removeEventListener("dispose",d);let x=o.indexOf(v.__bindingPointIndex);o.splice(x,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function m(){for(let _ in i)r.deleteBuffer(i[_]);o=[],i={},s={}}return{bind:l,update:c,dispose:m}}var Xa=class{constructor(e={}){let{canvas:t=$0(),context:n=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:f=!1}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=o;let g=new Uint32Array(4),y=new Int32Array(4),d=null,m=null,_=[],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.toneMapping=ls,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let x=this,S=!1;this._outputColorSpace=yt;let I=0,A=0,C=null,E=-1,b=null,R=new wt,N=new wt,B=null,V=new He(0),ie=0,Y=t.width,te=t.height,q=1,le=null,ye=null,Te=new wt(0,0,Y,te),Ae=new wt(0,0,Y,te),_e=!1,G=new Pa,P=!1,M=!1,T=new Je,k=new Je,j=new se,W=new wt,re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ce=!1;function me(){return C===null?q:1}let w=n;function ae(K,xe){return t.getContext(K,xe)}try{let K={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Oh}`),t.addEventListener("webglcontextlost",Ce,!1),t.addEventListener("webglcontextrestored",Be,!1),t.addEventListener("webglcontextcreationerror",Oe,!1),w===null){let xe="webgl2";if(w=ae(xe,K),w===null)throw ae(xe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(K){throw console.error("THREE.WebGLRenderer: "+K.message),K}let pe,ue,ee,$,ve,H,L,O,D,z,Q,ne,oe,he,ge,de,Ee,Re,De,ke,at,je,Ke,fe;function Le(){pe=new sE(w),pe.init(),je=new Fb(w,pe),ue=new $M(w,pe,e,je),ee=new Ob(w,pe),ue.reverseDepthBuffer&&f&&ee.buffers.depth.setReversed(!0),$=new lE(w),ve=new Tb,H=new Db(w,pe,ee,ve,ue,je,$),L=new eE(x),O=new rE(x),D=new p_(w),Ke=new ZM(w,D),z=new oE(w,D,$,Ke),Q=new uE(w,z,D,$),De=new cE(w,ue,H),de=new QM(ve),ne=new _b(x,L,O,pe,ue,Ke,de),oe=new Gb(x,ve),he=new Eb,ge=new Ib(pe),Re=new KM(x,L,O,ee,Q,p,l),Ee=new Nb(x,Q,ue),fe=new Vb(w,$,ue,ee),ke=new JM(w,pe,$),at=new aE(w,pe,$),$.programs=ne.programs,x.capabilities=ue,x.extensions=pe,x.properties=ve,x.renderLists=he,x.shadowMap=Ee,x.state=ee,x.info=$}Le();let be=new Yp(x,w);this.xr=be,this.getContext=function(){return w},this.getContextAttributes=function(){return w.getContextAttributes()},this.forceContextLoss=function(){let K=pe.get("WEBGL_lose_context");K&&K.loseContext()},this.forceContextRestore=function(){let K=pe.get("WEBGL_lose_context");K&&K.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(K){K!==void 0&&(q=K,this.setSize(Y,te,!1))},this.getSize=function(K){return K.set(Y,te)},this.setSize=function(K,xe,Se=!0){if(be.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Y=K,te=xe,t.width=Math.floor(K*q),t.height=Math.floor(xe*q),Se===!0&&(t.style.width=K+"px",t.style.height=xe+"px"),this.setViewport(0,0,K,xe)},this.getDrawingBufferSize=function(K){return K.set(Y*q,te*q).floor()},this.setDrawingBufferSize=function(K,xe,Se){Y=K,te=xe,q=Se,t.width=Math.floor(K*Se),t.height=Math.floor(xe*Se),this.setViewport(0,0,K,xe)},this.getCurrentViewport=function(K){return K.copy(R)},this.getViewport=function(K){return K.copy(Te)},this.setViewport=function(K,xe,Se,we){K.isVector4?Te.set(K.x,K.y,K.z,K.w):Te.set(K,xe,Se,we),ee.viewport(R.copy(Te).multiplyScalar(q).round())},this.getScissor=function(K){return K.copy(Ae)},this.setScissor=function(K,xe,Se,we){K.isVector4?Ae.set(K.x,K.y,K.z,K.w):Ae.set(K,xe,Se,we),ee.scissor(N.copy(Ae).multiplyScalar(q).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(K){ee.setScissorTest(_e=K)},this.setOpaqueSort=function(K){le=K},this.setTransparentSort=function(K){ye=K},this.getClearColor=function(K){return K.copy(Re.getClearColor())},this.setClearColor=function(){Re.setClearColor(...arguments)},this.getClearAlpha=function(){return Re.getClearAlpha()},this.setClearAlpha=function(){Re.setClearAlpha(...arguments)},this.clear=function(K=!0,xe=!0,Se=!0){let we=0;if(K){let Me=!1;if(C!==null){let Ge=C.texture.format;Me=Ge===Kh||Ge===Yh||Ge===jh}if(Me){let Ge=C.texture.type,Xe=Ge===lr||Ge===Ls||Ge===ka||Ge===Ga||Ge===Xh||Ge===qh,Qe=Re.getClearColor(),tt=Re.getClearAlpha(),Tt=Qe.r,xt=Qe.g,ut=Qe.b;Xe?(g[0]=Tt,g[1]=xt,g[2]=ut,g[3]=tt,w.clearBufferuiv(w.COLOR,0,g)):(y[0]=Tt,y[1]=xt,y[2]=ut,y[3]=tt,w.clearBufferiv(w.COLOR,0,y))}else we|=w.COLOR_BUFFER_BIT}xe&&(we|=w.DEPTH_BUFFER_BIT),Se&&(we|=w.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),w.clear(we)},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",Ce,!1),t.removeEventListener("webglcontextrestored",Be,!1),t.removeEventListener("webglcontextcreationerror",Oe,!1),Re.dispose(),he.dispose(),ge.dispose(),ve.dispose(),L.dispose(),O.dispose(),Q.dispose(),Ke.dispose(),fe.dispose(),ne.dispose(),be.dispose(),be.removeEventListener("sessionstart",st),be.removeEventListener("sessionend",ct),Ft.stop()};function Ce(K){K.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function Be(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;let K=$.autoReset,xe=Ee.enabled,Se=Ee.autoUpdate,we=Ee.needsUpdate,Me=Ee.type;Le(),$.autoReset=K,Ee.enabled=xe,Ee.autoUpdate=Se,Ee.needsUpdate=we,Ee.type=Me}function Oe(K){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",K.statusMessage)}function rt(K){let xe=K.target;xe.removeEventListener("dispose",rt),Et(xe)}function Et(K){ft(K),ve.remove(K)}function ft(K){let xe=ve.get(K).programs;xe!==void 0&&(xe.forEach(function(Se){ne.releaseProgram(Se)}),K.isShaderMaterial&&ne.releaseShaderCache(K))}this.renderBufferDirect=function(K,xe,Se,we,Me,Ge){xe===null&&(xe=re);let Xe=Me.isMesh&&Me.matrixWorld.determinant()<0,Qe=ad(K,xe,Se,we,Me);ee.setMaterial(we,Xe);let tt=Se.index,Tt=1;if(we.wireframe===!0){if(tt=z.getWireframeAttribute(Se),tt===void 0)return;Tt=2}let xt=Se.drawRange,ut=Se.attributes.position,At=xt.start*Tt,kt=(xt.start+xt.count)*Tt;Ge!==null&&(At=Math.max(At,Ge.start*Tt),kt=Math.min(kt,(Ge.start+Ge.count)*Tt)),tt!==null?(At=Math.max(At,0),kt=Math.min(kt,tt.count)):ut!=null&&(At=Math.max(At,0),kt=Math.min(kt,ut.count));let hn=kt-At;if(hn<0||hn===1/0)return;Ke.setup(Me,we,Qe,Se,tt);let ln,Ot=ke;if(tt!==null&&(ln=D.get(tt),Ot=at,Ot.setIndex(ln)),Me.isMesh)we.wireframe===!0?(ee.setLineWidth(we.wireframeLinewidth*me()),Ot.setMode(w.LINES)):Ot.setMode(w.TRIANGLES);else if(Me.isLine){let dt=we.linewidth;dt===void 0&&(dt=1),ee.setLineWidth(dt*me()),Me.isLineSegments?Ot.setMode(w.LINES):Me.isLineLoop?Ot.setMode(w.LINE_LOOP):Ot.setMode(w.LINE_STRIP)}else Me.isPoints?Ot.setMode(w.POINTS):Me.isSprite&&Ot.setMode(w.TRIANGLES);if(Me.isBatchedMesh)if(Me._multiDrawInstances!==null)Oc("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Ot.renderMultiDrawInstances(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount,Me._multiDrawInstances);else if(pe.get("WEBGL_multi_draw"))Ot.renderMultiDraw(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount);else{let dt=Me._multiDrawStarts,wn=Me._multiDrawCounts,Bt=Me._multiDrawCount,ui=tt?D.get(tt).bytesPerElement:1,en=ve.get(we).currentProgram.getUniforms();for(let Hn=0;Hn<Bt;Hn++)en.setValue(w,"_gl_DrawID",Hn),Ot.render(dt[Hn]/ui,wn[Hn])}else if(Me.isInstancedMesh)Ot.renderInstances(At,hn,Me.count);else if(Se.isInstancedBufferGeometry){let dt=Se._maxInstanceCount!==void 0?Se._maxInstanceCount:1/0,wn=Math.min(Se.instanceCount,dt);Ot.renderInstances(At,hn,wn)}else Ot.render(At,hn)};function Fe(K,xe,Se){K.transparent===!0&&K.side===Nn&&K.forceSinglePass===!1?(K.side=_n,K.needsUpdate=!0,No(K,xe,Se),K.side=wi,K.needsUpdate=!0,No(K,xe,Se),K.side=Nn):No(K,xe,Se)}this.compile=function(K,xe,Se=null){Se===null&&(Se=K),m=ge.get(Se),m.init(xe),v.push(m),Se.traverseVisible(function(Me){Me.isLight&&Me.layers.test(xe.layers)&&(m.pushLight(Me),Me.castShadow&&m.pushShadow(Me))}),K!==Se&&K.traverseVisible(function(Me){Me.isLight&&Me.layers.test(xe.layers)&&(m.pushLight(Me),Me.castShadow&&m.pushShadow(Me))}),m.setupLights();let we=new Set;return K.traverse(function(Me){if(!(Me.isMesh||Me.isPoints||Me.isLine||Me.isSprite))return;let Ge=Me.material;if(Ge)if(Array.isArray(Ge))for(let Xe=0;Xe<Ge.length;Xe++){let Qe=Ge[Xe];Fe(Qe,Se,Me),we.add(Qe)}else Fe(Ge,Se,Me),we.add(Ge)}),m=v.pop(),we},this.compileAsync=function(K,xe,Se=null){let we=this.compile(K,xe,Se);return new Promise(Me=>{function Ge(){if(we.forEach(function(Xe){ve.get(Xe).currentProgram.isReady()&&we.delete(Xe)}),we.size===0){Me(K);return}setTimeout(Ge,10)}pe.get("KHR_parallel_shader_compile")!==null?Ge():setTimeout(Ge,10)})};let $e=null;function ze(K){$e&&$e(K)}function st(){Ft.stop()}function ct(){Ft.start()}let Ft=new Ly;Ft.setAnimationLoop(ze),typeof self<"u"&&Ft.setContext(self),this.setAnimationLoop=function(K){$e=K,be.setAnimationLoop(K),K===null?Ft.stop():Ft.start()},be.addEventListener("sessionstart",st),be.addEventListener("sessionend",ct),this.render=function(K,xe){if(xe!==void 0&&xe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),xe.parent===null&&xe.matrixWorldAutoUpdate===!0&&xe.updateMatrixWorld(),be.enabled===!0&&be.isPresenting===!0&&(be.cameraAutoUpdate===!0&&be.updateCamera(xe),xe=be.getCamera()),K.isScene===!0&&K.onBeforeRender(x,K,xe,C),m=ge.get(K,v.length),m.init(xe),v.push(m),k.multiplyMatrices(xe.projectionMatrix,xe.matrixWorldInverse),G.setFromProjectionMatrix(k),M=this.localClippingEnabled,P=de.init(this.clippingPlanes,M),d=he.get(K,_.length),d.init(),_.push(d),be.enabled===!0&&be.isPresenting===!0){let Ge=x.xr.getDepthSensingMesh();Ge!==null&&ci(Ge,xe,-1/0,x.sortObjects)}ci(K,xe,0,x.sortObjects),d.finish(),x.sortObjects===!0&&d.sort(le,ye),ce=be.enabled===!1||be.isPresenting===!1||be.hasDepthSensing()===!1,ce&&Re.addToRenderList(d,K),this.info.render.frame++,P===!0&&de.beginShadows();let Se=m.state.shadowsArray;Ee.render(Se,K,xe),P===!0&&de.endShadows(),this.info.autoReset===!0&&this.info.reset();let we=d.opaque,Me=d.transmissive;if(m.setupLights(),xe.isArrayCamera){let Ge=xe.cameras;if(Me.length>0)for(let Xe=0,Qe=Ge.length;Xe<Qe;Xe++){let tt=Ge[Xe];Dr(we,Me,K,tt)}ce&&Re.render(K);for(let Xe=0,Qe=Ge.length;Xe<Qe;Xe++){let tt=Ge[Xe];Mi(d,K,tt,tt.viewport)}}else Me.length>0&&Dr(we,Me,K,xe),ce&&Re.render(K),Mi(d,K,xe);C!==null&&A===0&&(H.updateMultisampleRenderTarget(C),H.updateRenderTargetMipmap(C)),K.isScene===!0&&K.onAfterRender(x,K,xe),Ke.resetDefaultState(),E=-1,b=null,v.pop(),v.length>0?(m=v[v.length-1],P===!0&&de.setGlobalState(x.clippingPlanes,m.state.camera)):m=null,_.pop(),_.length>0?d=_[_.length-1]:d=null};function ci(K,xe,Se,we){if(K.visible===!1)return;if(K.layers.test(xe.layers)){if(K.isGroup)Se=K.renderOrder;else if(K.isLOD)K.autoUpdate===!0&&K.update(xe);else if(K.isLight)m.pushLight(K),K.castShadow&&m.pushShadow(K);else if(K.isSprite){if(!K.frustumCulled||G.intersectsSprite(K)){we&&W.setFromMatrixPosition(K.matrixWorld).applyMatrix4(k);let Xe=Q.update(K),Qe=K.material;Qe.visible&&d.push(K,Xe,Qe,Se,W.z,null)}}else if((K.isMesh||K.isLine||K.isPoints)&&(!K.frustumCulled||G.intersectsObject(K))){let Xe=Q.update(K),Qe=K.material;if(we&&(K.boundingSphere!==void 0?(K.boundingSphere===null&&K.computeBoundingSphere(),W.copy(K.boundingSphere.center)):(Xe.boundingSphere===null&&Xe.computeBoundingSphere(),W.copy(Xe.boundingSphere.center)),W.applyMatrix4(K.matrixWorld).applyMatrix4(k)),Array.isArray(Qe)){let tt=Xe.groups;for(let Tt=0,xt=tt.length;Tt<xt;Tt++){let ut=tt[Tt],At=Qe[ut.materialIndex];At&&At.visible&&d.push(K,Xe,At,Se,W.z,ut)}}else Qe.visible&&d.push(K,Xe,Qe,Se,W.z,null)}}let Ge=K.children;for(let Xe=0,Qe=Ge.length;Xe<Qe;Xe++)ci(Ge[Xe],xe,Se,we)}function Mi(K,xe,Se,we){let Me=K.opaque,Ge=K.transmissive,Xe=K.transparent;m.setupLightsView(Se),P===!0&&de.setGlobalState(x.clippingPlanes,Se),we&&ee.viewport(R.copy(we)),Me.length>0&&Po(Me,xe,Se),Ge.length>0&&Po(Ge,xe,Se),Xe.length>0&&Po(Xe,xe,Se),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1)}function Dr(K,xe,Se,we){if((Se.isScene===!0?Se.overrideMaterial:null)!==null)return;m.state.transmissionRenderTarget[we.id]===void 0&&(m.state.transmissionRenderTarget[we.id]=new wr(1,1,{generateMipmaps:!0,type:pe.has("EXT_color_buffer_half_float")||pe.has("EXT_color_buffer_float")?Ba:lr,minFilter:xi,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:mt.workingColorSpace}));let Ge=m.state.transmissionRenderTarget[we.id],Xe=we.viewport||R;Ge.setSize(Xe.z*x.transmissionResolutionScale,Xe.w*x.transmissionResolutionScale);let Qe=x.getRenderTarget();x.setRenderTarget(Ge),x.getClearColor(V),ie=x.getClearAlpha(),ie<1&&x.setClearColor(16777215,.5),x.clear(),ce&&Re.render(Se);let tt=x.toneMapping;x.toneMapping=ls;let Tt=we.viewport;if(we.viewport!==void 0&&(we.viewport=void 0),m.setupLightsView(we),P===!0&&de.setGlobalState(x.clippingPlanes,we),Po(K,Se,we),H.updateMultisampleRenderTarget(Ge),H.updateRenderTargetMipmap(Ge),pe.has("WEBGL_multisampled_render_to_texture")===!1){let xt=!1;for(let ut=0,At=xe.length;ut<At;ut++){let kt=xe[ut],hn=kt.object,ln=kt.geometry,Ot=kt.material,dt=kt.group;if(Ot.side===Nn&&hn.layers.test(we.layers)){let wn=Ot.side;Ot.side=_n,Ot.needsUpdate=!0,wl(hn,Se,we,ln,Ot,dt),Ot.side=wn,Ot.needsUpdate=!0,xt=!0}}xt===!0&&(H.updateMultisampleRenderTarget(Ge),H.updateRenderTargetMipmap(Ge))}x.setRenderTarget(Qe),x.setClearColor(V,ie),Tt!==void 0&&(we.viewport=Tt),x.toneMapping=tt}function Po(K,xe,Se){let we=xe.isScene===!0?xe.overrideMaterial:null;for(let Me=0,Ge=K.length;Me<Ge;Me++){let Xe=K[Me],Qe=Xe.object,tt=Xe.geometry,Tt=Xe.group,xt=Xe.material;xt.allowOverride===!0&&we!==null&&(xt=we),Qe.layers.test(Se.layers)&&wl(Qe,xe,Se,tt,xt,Tt)}}function wl(K,xe,Se,we,Me,Ge){K.onBeforeRender(x,xe,Se,we,Me,Ge),K.modelViewMatrix.multiplyMatrices(Se.matrixWorldInverse,K.matrixWorld),K.normalMatrix.getNormalMatrix(K.modelViewMatrix),Me.onBeforeRender(x,xe,Se,we,K,Ge),Me.transparent===!0&&Me.side===Nn&&Me.forceSinglePass===!1?(Me.side=_n,Me.needsUpdate=!0,x.renderBufferDirect(Se,xe,we,Me,K,Ge),Me.side=wi,Me.needsUpdate=!0,x.renderBufferDirect(Se,xe,we,Me,K,Ge),Me.side=Nn):x.renderBufferDirect(Se,xe,we,Me,K,Ge),K.onAfterRender(x,xe,Se,we,Me,Ge)}function No(K,xe,Se){xe.isScene!==!0&&(xe=re);let we=ve.get(K),Me=m.state.lights,Ge=m.state.shadowsArray,Xe=Me.state.version,Qe=ne.getParameters(K,Me.state,Ge,xe,Se),tt=ne.getProgramCacheKey(Qe),Tt=we.programs;we.environment=K.isMeshStandardMaterial?xe.environment:null,we.fog=xe.fog,we.envMap=(K.isMeshStandardMaterial?O:L).get(K.envMap||we.environment),we.envMapRotation=we.environment!==null&&K.envMap===null?xe.environmentRotation:K.envMapRotation,Tt===void 0&&(K.addEventListener("dispose",rt),Tt=new Map,we.programs=Tt);let xt=Tt.get(tt);if(xt!==void 0){if(we.currentProgram===xt&&we.lightsStateVersion===Xe)return au(K,Qe),xt}else Qe.uniforms=ne.getUniforms(K),K.onBeforeCompile(Qe,x),xt=ne.acquireProgram(Qe,tt),Tt.set(tt,xt),we.uniforms=Qe.uniforms;let ut=we.uniforms;return(!K.isShaderMaterial&&!K.isRawShaderMaterial||K.clipping===!0)&&(ut.clippingPlanes=de.uniform),au(K,Qe),we.needsLights=cd(K),we.lightsStateVersion=Xe,we.needsLights&&(ut.ambientLightColor.value=Me.state.ambient,ut.lightProbe.value=Me.state.probe,ut.directionalLights.value=Me.state.directional,ut.directionalLightShadows.value=Me.state.directionalShadow,ut.spotLights.value=Me.state.spot,ut.spotLightShadows.value=Me.state.spotShadow,ut.rectAreaLights.value=Me.state.rectArea,ut.ltc_1.value=Me.state.rectAreaLTC1,ut.ltc_2.value=Me.state.rectAreaLTC2,ut.pointLights.value=Me.state.point,ut.pointLightShadows.value=Me.state.pointShadow,ut.hemisphereLights.value=Me.state.hemi,ut.directionalShadowMap.value=Me.state.directionalShadowMap,ut.directionalShadowMatrix.value=Me.state.directionalShadowMatrix,ut.spotShadowMap.value=Me.state.spotShadowMap,ut.spotLightMatrix.value=Me.state.spotLightMatrix,ut.spotLightMap.value=Me.state.spotLightMap,ut.pointShadowMap.value=Me.state.pointShadowMap,ut.pointShadowMatrix.value=Me.state.pointShadowMatrix),we.currentProgram=xt,we.uniformsList=null,xt}function ou(K){if(K.uniformsList===null){let xe=K.currentProgram.getUniforms();K.uniformsList=Wa.seqWithValue(xe.seq,K.uniforms)}return K.uniformsList}function au(K,xe){let Se=ve.get(K);Se.outputColorSpace=xe.outputColorSpace,Se.batching=xe.batching,Se.batchingColor=xe.batchingColor,Se.instancing=xe.instancing,Se.instancingColor=xe.instancingColor,Se.instancingMorph=xe.instancingMorph,Se.skinning=xe.skinning,Se.morphTargets=xe.morphTargets,Se.morphNormals=xe.morphNormals,Se.morphColors=xe.morphColors,Se.morphTargetsCount=xe.morphTargetsCount,Se.numClippingPlanes=xe.numClippingPlanes,Se.numIntersection=xe.numClipIntersection,Se.vertexAlphas=xe.vertexAlphas,Se.vertexTangents=xe.vertexTangents,Se.toneMapping=xe.toneMapping}function ad(K,xe,Se,we,Me){xe.isScene!==!0&&(xe=re),H.resetTextureUnits();let Ge=xe.fog,Xe=we.isMeshStandardMaterial?xe.environment:null,Qe=C===null?x.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:Ci,tt=(we.isMeshStandardMaterial?O:L).get(we.envMap||Xe),Tt=we.vertexColors===!0&&!!Se.attributes.color&&Se.attributes.color.itemSize===4,xt=!!Se.attributes.tangent&&(!!we.normalMap||we.anisotropy>0),ut=!!Se.morphAttributes.position,At=!!Se.morphAttributes.normal,kt=!!Se.morphAttributes.color,hn=ls;we.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(hn=x.toneMapping);let ln=Se.morphAttributes.position||Se.morphAttributes.normal||Se.morphAttributes.color,Ot=ln!==void 0?ln.length:0,dt=ve.get(we),wn=m.state.lights;if(P===!0&&(M===!0||K!==b)){let Mn=K===b&&we.id===E;de.setState(we,K,Mn)}let Bt=!1;we.version===dt.__version?(dt.needsLights&&dt.lightsStateVersion!==wn.state.version||dt.outputColorSpace!==Qe||Me.isBatchedMesh&&dt.batching===!1||!Me.isBatchedMesh&&dt.batching===!0||Me.isBatchedMesh&&dt.batchingColor===!0&&Me.colorTexture===null||Me.isBatchedMesh&&dt.batchingColor===!1&&Me.colorTexture!==null||Me.isInstancedMesh&&dt.instancing===!1||!Me.isInstancedMesh&&dt.instancing===!0||Me.isSkinnedMesh&&dt.skinning===!1||!Me.isSkinnedMesh&&dt.skinning===!0||Me.isInstancedMesh&&dt.instancingColor===!0&&Me.instanceColor===null||Me.isInstancedMesh&&dt.instancingColor===!1&&Me.instanceColor!==null||Me.isInstancedMesh&&dt.instancingMorph===!0&&Me.morphTexture===null||Me.isInstancedMesh&&dt.instancingMorph===!1&&Me.morphTexture!==null||dt.envMap!==tt||we.fog===!0&&dt.fog!==Ge||dt.numClippingPlanes!==void 0&&(dt.numClippingPlanes!==de.numPlanes||dt.numIntersection!==de.numIntersection)||dt.vertexAlphas!==Tt||dt.vertexTangents!==xt||dt.morphTargets!==ut||dt.morphNormals!==At||dt.morphColors!==kt||dt.toneMapping!==hn||dt.morphTargetsCount!==Ot)&&(Bt=!0):(Bt=!0,dt.__version=we.version);let ui=dt.currentProgram;Bt===!0&&(ui=No(we,xe,Me));let en=!1,Hn=!1,zs=!1,$t=ui.getUniforms(),ti=dt.uniforms;if(ee.useProgram(ui.program)&&(en=!0,Hn=!0,zs=!0),we.id!==E&&(E=we.id,Hn=!0),en||b!==K){ee.buffers.depth.getReversed()?(T.copy(K.projectionMatrix),ey(T),ty(T),$t.setValue(w,"projectionMatrix",T)):$t.setValue(w,"projectionMatrix",K.projectionMatrix),$t.setValue(w,"viewMatrix",K.matrixWorldInverse);let Cn=$t.map.cameraPosition;Cn!==void 0&&Cn.setValue(w,j.setFromMatrixPosition(K.matrixWorld)),ue.logarithmicDepthBuffer&&$t.setValue(w,"logDepthBufFC",2/(Math.log(K.far+1)/Math.LN2)),(we.isMeshPhongMaterial||we.isMeshToonMaterial||we.isMeshLambertMaterial||we.isMeshBasicMaterial||we.isMeshStandardMaterial||we.isShaderMaterial)&&$t.setValue(w,"isOrthographic",K.isOrthographicCamera===!0),b!==K&&(b=K,Hn=!0,zs=!0)}if(Me.isSkinnedMesh){$t.setOptional(w,Me,"bindMatrix"),$t.setOptional(w,Me,"bindMatrixInverse");let Mn=Me.skeleton;Mn&&(Mn.boneTexture===null&&Mn.computeBoneTexture(),$t.setValue(w,"boneTexture",Mn.boneTexture,H))}Me.isBatchedMesh&&($t.setOptional(w,Me,"batchingTexture"),$t.setValue(w,"batchingTexture",Me._matricesTexture,H),$t.setOptional(w,Me,"batchingIdTexture"),$t.setValue(w,"batchingIdTexture",Me._indirectTexture,H),$t.setOptional(w,Me,"batchingColorTexture"),Me._colorsTexture!==null&&$t.setValue(w,"batchingColorTexture",Me._colorsTexture,H));let Yn=Se.morphAttributes;if((Yn.position!==void 0||Yn.normal!==void 0||Yn.color!==void 0)&&De.update(Me,Se,ui),(Hn||dt.receiveShadow!==Me.receiveShadow)&&(dt.receiveShadow=Me.receiveShadow,$t.setValue(w,"receiveShadow",Me.receiveShadow)),we.isMeshGouraudMaterial&&we.envMap!==null&&(ti.envMap.value=tt,ti.flipEnvMap.value=tt.isCubeTexture&&tt.isRenderTargetTexture===!1?-1:1),we.isMeshStandardMaterial&&we.envMap===null&&xe.environment!==null&&(ti.envMapIntensity.value=xe.environmentIntensity),Hn&&($t.setValue(w,"toneMappingExposure",x.toneMappingExposure),dt.needsLights&&ld(ti,zs),Ge&&we.fog===!0&&oe.refreshFogUniforms(ti,Ge),oe.refreshMaterialUniforms(ti,we,q,te,m.state.transmissionRenderTarget[K.id]),Wa.upload(w,ou(dt),ti,H)),we.isShaderMaterial&&we.uniformsNeedUpdate===!0&&(Wa.upload(w,ou(dt),ti,H),we.uniformsNeedUpdate=!1),we.isSpriteMaterial&&$t.setValue(w,"center",Me.center),$t.setValue(w,"modelViewMatrix",Me.modelViewMatrix),$t.setValue(w,"normalMatrix",Me.normalMatrix),$t.setValue(w,"modelMatrix",Me.matrixWorld),we.isShaderMaterial||we.isRawShaderMaterial){let Mn=we.uniformsGroups;for(let Cn=0,Lo=Mn.length;Cn<Lo;Cn++){let Fr=Mn[Cn];fe.update(Fr,ui),fe.bind(Fr,ui)}}return ui}function ld(K,xe){K.ambientLightColor.needsUpdate=xe,K.lightProbe.needsUpdate=xe,K.directionalLights.needsUpdate=xe,K.directionalLightShadows.needsUpdate=xe,K.pointLights.needsUpdate=xe,K.pointLightShadows.needsUpdate=xe,K.spotLights.needsUpdate=xe,K.spotLightShadows.needsUpdate=xe,K.rectAreaLights.needsUpdate=xe,K.hemisphereLights.needsUpdate=xe}function cd(K){return K.isMeshLambertMaterial||K.isMeshToonMaterial||K.isMeshPhongMaterial||K.isMeshStandardMaterial||K.isShadowMaterial||K.isShaderMaterial&&K.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(K,xe,Se){let we=ve.get(K);we.__autoAllocateDepthBuffer=K.resolveDepthBuffer===!1,we.__autoAllocateDepthBuffer===!1&&(we.__useRenderToTexture=!1),ve.get(K.texture).__webglTexture=xe,ve.get(K.depthTexture).__webglTexture=we.__autoAllocateDepthBuffer?void 0:Se,we.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(K,xe){let Se=ve.get(K);Se.__webglFramebuffer=xe,Se.__useDefaultFramebuffer=xe===void 0};let ud=w.createFramebuffer();this.setRenderTarget=function(K,xe=0,Se=0){C=K,I=xe,A=Se;let we=!0,Me=null,Ge=!1,Xe=!1;if(K){let tt=ve.get(K);if(tt.__useDefaultFramebuffer!==void 0)ee.bindFramebuffer(w.FRAMEBUFFER,null),we=!1;else if(tt.__webglFramebuffer===void 0)H.setupRenderTarget(K);else if(tt.__hasExternalTextures)H.rebindTextures(K,ve.get(K.texture).__webglTexture,ve.get(K.depthTexture).__webglTexture);else if(K.depthBuffer){let ut=K.depthTexture;if(tt.__boundDepthTexture!==ut){if(ut!==null&&ve.has(ut)&&(K.width!==ut.image.width||K.height!==ut.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");H.setupDepthRenderbuffer(K)}}let Tt=K.texture;(Tt.isData3DTexture||Tt.isDataArrayTexture||Tt.isCompressedArrayTexture)&&(Xe=!0);let xt=ve.get(K).__webglFramebuffer;K.isWebGLCubeRenderTarget?(Array.isArray(xt[xe])?Me=xt[xe][Se]:Me=xt[xe],Ge=!0):K.samples>0&&H.useMultisampledRTT(K)===!1?Me=ve.get(K).__webglMultisampledFramebuffer:Array.isArray(xt)?Me=xt[Se]:Me=xt,R.copy(K.viewport),N.copy(K.scissor),B=K.scissorTest}else R.copy(Te).multiplyScalar(q).floor(),N.copy(Ae).multiplyScalar(q).floor(),B=_e;if(Se!==0&&(Me=ud),ee.bindFramebuffer(w.FRAMEBUFFER,Me)&&we&&ee.drawBuffers(K,Me),ee.viewport(R),ee.scissor(N),ee.setScissorTest(B),Ge){let tt=ve.get(K.texture);w.framebufferTexture2D(w.FRAMEBUFFER,w.COLOR_ATTACHMENT0,w.TEXTURE_CUBE_MAP_POSITIVE_X+xe,tt.__webglTexture,Se)}else if(Xe){let tt=ve.get(K.texture),Tt=xe;w.framebufferTextureLayer(w.FRAMEBUFFER,w.COLOR_ATTACHMENT0,tt.__webglTexture,Se,Tt)}else if(K!==null&&Se!==0){let tt=ve.get(K.texture);w.framebufferTexture2D(w.FRAMEBUFFER,w.COLOR_ATTACHMENT0,w.TEXTURE_2D,tt.__webglTexture,Se)}E=-1},this.readRenderTargetPixels=function(K,xe,Se,we,Me,Ge,Xe){if(!(K&&K.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Qe=ve.get(K).__webglFramebuffer;if(K.isWebGLCubeRenderTarget&&Xe!==void 0&&(Qe=Qe[Xe]),Qe){ee.bindFramebuffer(w.FRAMEBUFFER,Qe);try{let tt=K.texture,Tt=tt.format,xt=tt.type;if(!ue.textureFormatReadable(Tt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ue.textureTypeReadable(xt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}xe>=0&&xe<=K.width-we&&Se>=0&&Se<=K.height-Me&&w.readPixels(xe,Se,we,Me,je.convert(Tt),je.convert(xt),Ge)}finally{let tt=C!==null?ve.get(C).__webglFramebuffer:null;ee.bindFramebuffer(w.FRAMEBUFFER,tt)}}},this.readRenderTargetPixelsAsync=async function(K,xe,Se,we,Me,Ge,Xe){if(!(K&&K.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Qe=ve.get(K).__webglFramebuffer;if(K.isWebGLCubeRenderTarget&&Xe!==void 0&&(Qe=Qe[Xe]),Qe)if(xe>=0&&xe<=K.width-we&&Se>=0&&Se<=K.height-Me){ee.bindFramebuffer(w.FRAMEBUFFER,Qe);let tt=K.texture,Tt=tt.format,xt=tt.type;if(!ue.textureFormatReadable(Tt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ue.textureTypeReadable(xt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ut=w.createBuffer();w.bindBuffer(w.PIXEL_PACK_BUFFER,ut),w.bufferData(w.PIXEL_PACK_BUFFER,Ge.byteLength,w.STREAM_READ),w.readPixels(xe,Se,we,Me,je.convert(Tt),je.convert(xt),0);let At=C!==null?ve.get(C).__webglFramebuffer:null;ee.bindFramebuffer(w.FRAMEBUFFER,At);let kt=w.fenceSync(w.SYNC_GPU_COMMANDS_COMPLETE,0);return w.flush(),await Q0(w,kt,4),w.bindBuffer(w.PIXEL_PACK_BUFFER,ut),w.getBufferSubData(w.PIXEL_PACK_BUFFER,0,Ge),w.deleteBuffer(ut),w.deleteSync(kt),Ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(K,xe=null,Se=0){let we=Math.pow(2,-Se),Me=Math.floor(K.image.width*we),Ge=Math.floor(K.image.height*we),Xe=xe!==null?xe.x:0,Qe=xe!==null?xe.y:0;H.setTexture2D(K,0),w.copyTexSubImage2D(w.TEXTURE_2D,Se,0,0,Xe,Qe,Me,Ge),ee.unbindTexture()};let hd=w.createFramebuffer(),fd=w.createFramebuffer();this.copyTextureToTexture=function(K,xe,Se=null,we=null,Me=0,Ge=null){Ge===null&&(Me!==0?(Oc("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ge=Me,Me=0):Ge=0);let Xe,Qe,tt,Tt,xt,ut,At,kt,hn,ln=K.isCompressedTexture?K.mipmaps[Ge]:K.image;if(Se!==null)Xe=Se.max.x-Se.min.x,Qe=Se.max.y-Se.min.y,tt=Se.isBox3?Se.max.z-Se.min.z:1,Tt=Se.min.x,xt=Se.min.y,ut=Se.isBox3?Se.min.z:0;else{let Yn=Math.pow(2,-Me);Xe=Math.floor(ln.width*Yn),Qe=Math.floor(ln.height*Yn),K.isDataArrayTexture?tt=ln.depth:K.isData3DTexture?tt=Math.floor(ln.depth*Yn):tt=1,Tt=0,xt=0,ut=0}we!==null?(At=we.x,kt=we.y,hn=we.z):(At=0,kt=0,hn=0);let Ot=je.convert(xe.format),dt=je.convert(xe.type),wn;xe.isData3DTexture?(H.setTexture3D(xe,0),wn=w.TEXTURE_3D):xe.isDataArrayTexture||xe.isCompressedArrayTexture?(H.setTexture2DArray(xe,0),wn=w.TEXTURE_2D_ARRAY):(H.setTexture2D(xe,0),wn=w.TEXTURE_2D),w.pixelStorei(w.UNPACK_FLIP_Y_WEBGL,xe.flipY),w.pixelStorei(w.UNPACK_PREMULTIPLY_ALPHA_WEBGL,xe.premultiplyAlpha),w.pixelStorei(w.UNPACK_ALIGNMENT,xe.unpackAlignment);let Bt=w.getParameter(w.UNPACK_ROW_LENGTH),ui=w.getParameter(w.UNPACK_IMAGE_HEIGHT),en=w.getParameter(w.UNPACK_SKIP_PIXELS),Hn=w.getParameter(w.UNPACK_SKIP_ROWS),zs=w.getParameter(w.UNPACK_SKIP_IMAGES);w.pixelStorei(w.UNPACK_ROW_LENGTH,ln.width),w.pixelStorei(w.UNPACK_IMAGE_HEIGHT,ln.height),w.pixelStorei(w.UNPACK_SKIP_PIXELS,Tt),w.pixelStorei(w.UNPACK_SKIP_ROWS,xt),w.pixelStorei(w.UNPACK_SKIP_IMAGES,ut);let $t=K.isDataArrayTexture||K.isData3DTexture,ti=xe.isDataArrayTexture||xe.isData3DTexture;if(K.isDepthTexture){let Yn=ve.get(K),Mn=ve.get(xe),Cn=ve.get(Yn.__renderTarget),Lo=ve.get(Mn.__renderTarget);ee.bindFramebuffer(w.READ_FRAMEBUFFER,Cn.__webglFramebuffer),ee.bindFramebuffer(w.DRAW_FRAMEBUFFER,Lo.__webglFramebuffer);for(let Fr=0;Fr<tt;Fr++)$t&&(w.framebufferTextureLayer(w.READ_FRAMEBUFFER,w.COLOR_ATTACHMENT0,ve.get(K).__webglTexture,Me,ut+Fr),w.framebufferTextureLayer(w.DRAW_FRAMEBUFFER,w.COLOR_ATTACHMENT0,ve.get(xe).__webglTexture,Ge,hn+Fr)),w.blitFramebuffer(Tt,xt,Xe,Qe,At,kt,Xe,Qe,w.DEPTH_BUFFER_BIT,w.NEAREST);ee.bindFramebuffer(w.READ_FRAMEBUFFER,null),ee.bindFramebuffer(w.DRAW_FRAMEBUFFER,null)}else if(Me!==0||K.isRenderTargetTexture||ve.has(K)){let Yn=ve.get(K),Mn=ve.get(xe);ee.bindFramebuffer(w.READ_FRAMEBUFFER,hd),ee.bindFramebuffer(w.DRAW_FRAMEBUFFER,fd);for(let Cn=0;Cn<tt;Cn++)$t?w.framebufferTextureLayer(w.READ_FRAMEBUFFER,w.COLOR_ATTACHMENT0,Yn.__webglTexture,Me,ut+Cn):w.framebufferTexture2D(w.READ_FRAMEBUFFER,w.COLOR_ATTACHMENT0,w.TEXTURE_2D,Yn.__webglTexture,Me),ti?w.framebufferTextureLayer(w.DRAW_FRAMEBUFFER,w.COLOR_ATTACHMENT0,Mn.__webglTexture,Ge,hn+Cn):w.framebufferTexture2D(w.DRAW_FRAMEBUFFER,w.COLOR_ATTACHMENT0,w.TEXTURE_2D,Mn.__webglTexture,Ge),Me!==0?w.blitFramebuffer(Tt,xt,Xe,Qe,At,kt,Xe,Qe,w.COLOR_BUFFER_BIT,w.NEAREST):ti?w.copyTexSubImage3D(wn,Ge,At,kt,hn+Cn,Tt,xt,Xe,Qe):w.copyTexSubImage2D(wn,Ge,At,kt,Tt,xt,Xe,Qe);ee.bindFramebuffer(w.READ_FRAMEBUFFER,null),ee.bindFramebuffer(w.DRAW_FRAMEBUFFER,null)}else ti?K.isDataTexture||K.isData3DTexture?w.texSubImage3D(wn,Ge,At,kt,hn,Xe,Qe,tt,Ot,dt,ln.data):xe.isCompressedArrayTexture?w.compressedTexSubImage3D(wn,Ge,At,kt,hn,Xe,Qe,tt,Ot,ln.data):w.texSubImage3D(wn,Ge,At,kt,hn,Xe,Qe,tt,Ot,dt,ln):K.isDataTexture?w.texSubImage2D(w.TEXTURE_2D,Ge,At,kt,Xe,Qe,Ot,dt,ln.data):K.isCompressedTexture?w.compressedTexSubImage2D(w.TEXTURE_2D,Ge,At,kt,ln.width,ln.height,Ot,ln.data):w.texSubImage2D(w.TEXTURE_2D,Ge,At,kt,Xe,Qe,Ot,dt,ln);w.pixelStorei(w.UNPACK_ROW_LENGTH,Bt),w.pixelStorei(w.UNPACK_IMAGE_HEIGHT,ui),w.pixelStorei(w.UNPACK_SKIP_PIXELS,en),w.pixelStorei(w.UNPACK_SKIP_ROWS,Hn),w.pixelStorei(w.UNPACK_SKIP_IMAGES,zs),Ge===0&&xe.generateMipmaps&&w.generateMipmap(wn),ee.unbindTexture()},this.copyTextureToTexture3D=function(K,xe,Se=null,we=null,Me=0){return Oc('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(K,xe,Se,we,Me)},this.initRenderTarget=function(K){ve.get(K).__webglFramebuffer===void 0&&H.setupRenderTarget(K)},this.initTexture=function(K){K.isCubeTexture?H.setTextureCube(K,0):K.isData3DTexture?H.setTexture3D(K,0):K.isDataArrayTexture||K.isCompressedArrayTexture?H.setTexture2DArray(K,0):H.setTexture2D(K,0),ee.unbindTexture()},this.resetState=function(){I=0,A=0,C=null,ee.reset(),Ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ar}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=mt._getDrawingBufferColorSpace(e),t.unpackColorSpace=mt._getUnpackColorSpace()}};function If(){let r=document.createElement("canvas");document.body.appendChild(r);let e={canvas:r,antialias:!0},t=new Xa(e);t.outputColorSpace=Ci,t.setClearColor("#ffffff",1),t.setSize(10,10);let n=new ir,i=new or(8947848);n.add(i);let s=new sr(8947848);s.position.set(0,0,1),n.add(s);let o=new nn(45,1,.1,1e3);o.position.set(0,0,1),o.up.set(0,1,0),o.lookAt(new se(0,0,0)),n.add(o);let a=new po(1,1),l=new Dt(a,new Zt({color:13369344}));n.add(l),t.render(n,o);let c=t.getContext(),u=new Uint8Array(4);c.readPixels(5,5,1,1,c.RGBA,c.UNSIGNED_BYTE,u),document.body.removeChild(r);let h=50;return u[0]<h&&u[1]<h&&u[2]<h}var vi={Phong:1,Physical:2};function Rf(r){let e=0,t=0;for(let n=0;n<r.MaterialCount();n++){let i=r.GetMaterial(n);i.type===Wn.Phong?e+=1:i.type===Wn.Physical&&(t+=1)}return e>=t?vi.Phong:vi.Physical}var ja=class{Convert(e){return null}},Cf=class extends ja{Convert(e){return new He().copyLinearToSRGB(e)}},Ya=class extends ja{Convert(e){return new He().copySRGBToLinear(e)}};function Fc(r){return Ei(r.r,r.g,r.b)}function Dn(r){return new He(r.r/255,r.g/255,r.b/255)}function ur(r,e,t){let n=new tn,i=r.attributes.position.array,s=r.attributes.position.itemSize||3;for(let u=0;u<i.length;u+=s){let h=i[u],f=i[u+1],p=i[u+2];n.AddVertex(new Ye(h,f,p))}let o=r.attributes.color!==void 0;if(o){let u=r.attributes.color.array,h=r.attributes.color.itemSize||3;for(let f=0;f<u.length;f+=h){let p=new He(u[f],u[f+1],u[f+2]);t!==null&&(p=t.Convert(p)),n.AddVertexColor(Fc(p))}}let a=r.attributes.normal!==void 0;if(a){let u=r.attributes.normal.array,h=r.attributes.normal.itemSize||3;for(let f=0;f<u.length;f+=h){let p=u[f],g=u[f+1],y=u[f+2];n.AddNormal(new Ye(p,g,y))}}let l=r.attributes.uv!==void 0;if(l){let u=r.attributes.uv.array,h=r.attributes.uv.itemSize||2;for(let f=0;f<u.length;f+=h){let p=u[f],g=u[f+1];n.AddTextureUV(new Nt(p,g))}}let c=null;if(r.index!==null)c=r.index.array;else{c=[];for(let u=0;u<i.length/3;u++)c.push(u)}for(let u=0;u<c.length;u+=3){let h=c[u],f=c[u+1],p=c[u+2],g=new Qt(h,f,p);o&&g.SetVertexColors(h,f,p),a&&g.SetNormals(h,f,p),l&&g.SetTextureUVs(h,f,p),e!==null&&g.SetMaterial(e),n.AddTriangle(g)}return n}function Zp(r,e,t){let n=null;return r.type==="MeshPhongMaterial"?n=new Zt({color:Dn(e),side:Nn}):r.type==="MeshStandardMaterial"?n=new ts({color:Dn(e),side:Nn}):r.type==="LineBasicMaterial"&&(n=new jn({color:Dn(e)})),n!==null&&t&&(n.polygonOffset=!0,n.polygonOffsetUnit=1,n.polygonOffsetFactor=1),n}function Pf(r,e,t){let n=new Map,i=[];for(let s of r){if(n.has(s.type)){i.push(n.get(s.type));continue}let o=Zp(s,e,t);n.set(s.type,o),i.push(o)}return i}function Nf(r){r!==null&&r.traverse(e=>{if(e.isMesh||e.isLineSegments){if(Array.isArray(e.material))for(let t of e.material)t.dispose();else e.material.dispose();e.userData=null,e.geometry.dispose()}})}function Lf(r,e,t,n,i){function s(c,u,h,f,p,g){let y=new se(p[3*g],p[3*g+1],p[3*g+2]);y.applyMatrix4(f.matrixWorld);let d=y.project(c);return new Nt((d.x+1)*u/2,-(d.y-1)*h/2)}let o=n.geometry.attributes.position.array,a=o.length/6,l=1/0;for(let c=0;c<a;c++){let u=new ra(s(r,e,t,n,o,2*c),s(r,e,t,n,o,2*c+1));l=Math.min(l,Nu(u,i))}return l}var Jp=class{constructor(e){this.params={defaultLineMaterialColor:new St(0,0,0),defaultMaterialColor:new St(0,0,0)},Fo(e,this.params),this.defaultLineMaterialIndex=null,this.defaultMaterialIndex=null}Finalize(e){this.Reset(),this.FinalizeMeshes(e),this.FinalizeMaterials(e),this.FinalizeNodes(e)}FinalizeMaterials(e){if(e.VertexColorCount()===0)return;let t=new Map;for(let n=0;n<e.MeshCount();n++){let i=e.GetMesh(n);for(let s=0;s<i.TriangleCount();s++){let o=i.GetTriangle(s),a=o.HasVertexColors();t.has(o.mat)?a||t.set(o.mat,!1):t.set(o.mat,a)}}for(let[n,i]of t){let s=e.GetMaterial(n);s.vertexColors=i}}FinalizeMeshes(e){for(let t=0;t<e.MeshCount();t++){let n=e.GetMesh(t);if(vs(n)){e.RemoveMesh(t),t=t-1;continue}this.FinalizeMesh(e,n)}}FinalizeMesh(e,t){function n(s){function o(c,u,h,f,p){function g(_,v){for(let x=0;x<_.length;x++){let S=_[x];if(bi(S,v))return!0}return!1}let y=[],d=p.get(h);for(let _=0;_<d.length;_++){let v=d[_],x=c.GetTriangle(v);if(u.curve===x.curve){let S=f[v];g(y,S)||y.push(S)}}let m=new Ye(0,0,0);for(let _=0;_<y.length;_++)m=Eu(m,y[_]);return m.MultiplyScalar(1/y.length),m.Normalize(),c.AddNormal(m)}let a=[],l=new Map;for(let c=0;c<s.VertexCount();c++)l.set(c,[]);for(let c=0;c<s.TriangleCount();c++){let u=s.GetTriangle(c),h=s.GetVertex(u.v0),f=s.GetVertex(u.v1),p=s.GetVertex(u.v2),g=Ys(h,f,p);a.push(g),l.get(u.v0).push(c),l.get(u.v1).push(c),l.get(u.v2).push(c)}for(let c=0;c<s.TriangleCount();c++){let u=s.GetTriangle(c);if(!u.HasNormals()){let h=o(s,u,u.v0,a,l),f=o(s,u,u.v1,a,l),p=o(s,u,u.v2,a,l);u.SetNormals(h,f,p)}}}let i={calculateCurveNormals:!1};for(let s=0;s<t.LineCount();s++){let o=t.GetLine(s);o.mat===null&&(o.mat=this.GetDefaultMaterialIndex(e,bn.DefaultLine))}for(let s=0;s<t.TriangleCount();s++){let o=t.GetTriangle(s);this.FinalizeTriangle(t,o,i),o.mat===null&&(o.mat=this.GetDefaultMaterialIndex(e,bn.DefaultFace))}i.calculateCurveNormals&&n(t)}FinalizeTriangle(e,t,n){if(!t.HasNormals())if(t.curve===null||t.curve===0){let i=e.GetVertex(t.v0),s=e.GetVertex(t.v1),o=e.GetVertex(t.v2),a=Ys(i,s,o),l=e.AddNormal(a);t.SetNormals(l,l,l)}else n.calculateCurveNormals=!0;t.curve===null&&(t.curve=0)}FinalizeNodes(e){let t=e.GetRootNode(),n=[];t.EnumerateChildren(i=>{i.IsEmpty()&&n.push(i)});for(let i=0;i<n.length;i++){let s=n[i],o=s.GetParent();o!==null&&(o.RemoveChildNode(s),o.IsEmpty()&&n.push(o))}}GetDefaultMaterialIndex(e,t){function n(i,s,o,a){if(s!==null)return s;let l=new En;return l.color=a,l.source=o,i.AddMaterial(l)}return t===bn.DefaultLine?(this.defaultLineMaterialIndex=n(e,this.defaultLineMaterialIndex,bn.DefaultLine,this.params.defaultLineMaterialColor),this.defaultLineMaterialIndex):t===bn.DefaultFace?(this.defaultMaterialIndex=n(e,this.defaultMaterialIndex,bn.DefaultFace,this.params.defaultMaterialColor),this.defaultMaterialIndex):null}Reset(){this.defaultLineMaterialIndex=null,this.defaultMaterialIndex=null}};function Of(r,e){new Jp(e).Finalize(r)}function ky(r){function e(s){return s!=null}function t(s){return!(!e(s)||isNaN(s))}function n(s,o){return!(!t(s)||s<0||s>=o)}function i(s,o){function a(l,c,u){return!(!n(u.v0,c.VertexCount())||!n(u.v1,c.VertexCount())||!n(u.v2,c.VertexCount())||u.HasVertexColors()&&(!n(u.c0,c.VertexColorCount())||!n(u.c1,c.VertexColorCount())||!n(u.c2,c.VertexColorCount()))||!n(u.n0,c.NormalCount())||!n(u.n1,c.NormalCount())||!n(u.n2,c.NormalCount())||u.HasTextureUVs()&&(!n(u.u0,c.TextureUVCount())||!n(u.u1,c.TextureUVCount())||!n(u.u2,c.TextureUVCount()))||!n(u.mat,l.MaterialCount())||!t(u.curve))}for(let l=0;l<o.VertexCount();l++){let c=o.GetVertex(l);if(!t(c.x)||!t(c.y)||!t(c.z))return!1}for(let l=0;l<o.VertexColorCount();l++){let c=o.GetVertexColor(l);if(!t(c.r)||!t(c.g)||!t(c.b))return!1}for(let l=0;l<o.NormalCount();l++){let c=o.GetNormal(l);if(!t(c.x)||!t(c.y)||!t(c.z))return!1}for(let l=0;l<o.TextureUVCount();l++){let c=o.GetTextureUV(l);if(!t(c.x)||!t(c.y))return!1}for(let l=0;l<o.TriangleCount();l++){let c=o.GetTriangle(l);if(!a(s,o,c))return!1}return!0}for(let s=0;s<r.MeshCount();s++){let o=r.GetMesh(s);if(!i(r,o))return!1}return!0}var Jt=class{constructor(){this.name=null,this.extension=null,this.callbacks=null,this.model=null,this.error=null,this.message=null}Import(e,t,n,i){this.Clear(),this.name=e,this.extension=t,this.callbacks=i,this.model=new br,this.error=!1,this.message=null,this.ResetContent(),this.ImportContent(n,()=>{this.CreateResult(i)})}Clear(){this.name=null,this.extension=null,this.callbacks=null,this.model=null,this.error=null,this.message=null,this.ClearContent()}CreateResult(e){if(this.error){e.onError(),e.onComplete();return}if(ca(this.model)){this.SetError(nt("The model doesn't contain any meshes.")),e.onError(),e.onComplete();return}Of(this.model,{defaultLineMaterialColor:this.callbacks.getDefaultLineMaterialColor(),defaultMaterialColor:this.callbacks.getDefaultMaterialColor()}),e.onSuccess(),e.onComplete()}CanImportExtension(e){return!1}GetUpDirection(){return _t.Z}ClearContent(){}ResetContent(){}ImportContent(e,t){}GetModel(){return this.model}SetError(e){this.error=!0,e!=null&&(this.message=e)}WasError(){return this.error}GetErrorMessage(){return this.message}};var hs=class r{constructor(e){this.vertices=e,this.mat=null}HasVertices(){return this.vertices!==null&&this.vertices.length>=2}GetVertices(){return this.vertices}SetMaterial(e){return this.mat=e,this}SegmentCount(){return this.vertices===null?0:this.vertices.length-1}Clone(){let e=new r([...this.vertices]);return e.SetMaterial(this.mat),e}};var Ka=class extends Jt{constructor(){super(),this.rhino=null}CanImportExtension(e){return e==="3dm"}GetUpDirection(){return _t.Z}ClearContent(){this.instanceIdToObject=null,this.instanceIdToDefinition=null}ResetContent(){this.instanceIdToObject=new Map,this.instanceIdToDefinition=new Map}ImportContent(e,t){this.rhino===null?_r("rhino3dm").then(()=>{rhino3dm().then(n=>{this.rhino=n,this.ImportRhinoContent(e),t()})}).catch(()=>{this.SetError(nt("Failed to load rhino3dm.")),t()}):(this.ImportRhinoContent(e),t())}ImportRhinoContent(e){let t=this.rhino.File3dm.fromByteArray(e);if(t===null){this.SetError(nt("Failed to read Rhino file."));return}this.ImportRhinoDocument(t),ca(this.model)&&this.SetError(nt("The model doesn't contain any 3D meshes. Try to save the model while you are in shaded view in Rhino."))}ImportRhinoDocument(e){this.InitRhinoInstances(e),this.ImportRhinoUserStrings(e),this.ImportRhinoGeometry(e)}InitRhinoInstances(e){let t=e.objects();for(let i=0;i<t.count;i++){let s=t.get(i),o=s.attributes();o.isInstanceDefinitionObject&&this.instanceIdToObject.set(o.id,s)}let n=e.instanceDefinitions();for(let i=0;i<n.count;i++){let s=n.get(i);this.instanceIdToDefinition.set(s.id,s)}}ImportRhinoUserStrings(e){let t=e.strings();if(t.count>0){let n=new Kn(nt("Document user texts"));for(let i=0;i<t.count;i++){let s=t.get(i);n.AddProperty(new cn(Yt.Text,s[0],s[1]))}this.model.AddPropertyGroup(n)}}ImportRhinoGeometry(e){let t=e.objects();for(let n=0;n<t.count;n++){let i=t.get(n);this.ImportRhinoGeometryObject(e,i,[])}}ImportRhinoGeometryObject(e,t,n){let i=t.geometry(),s=t.attributes(),o=i.objectType;if(!(s.isInstanceDefinitionObject&&n.length===0)){if(o===this.rhino.ObjectType.Mesh)this.ImportRhinoGeometryAsMesh(e,i,t,n);else if(o===this.rhino.ObjectType.Extrusion){let a=i.getMesh(this.rhino.MeshType.Any);a!==null&&(this.ImportRhinoGeometryAsMesh(e,a,t,n),a.delete())}else if(o===this.rhino.ObjectType.Brep){let a=new this.rhino.Mesh,l=i.faces();for(let c=0;c<l.count;c++){let u=l.get(c),h=u.getMesh(this.rhino.MeshType.Any);h&&(a.append(h),h.delete()),u.delete()}l.delete(),a.compact(),this.ImportRhinoGeometryAsMesh(e,a,t,n),a.delete()}else if(o===this.rhino.ObjectType.SubD){i.subdivide(3);let a=this.rhino.Mesh.createFromSubDControlNet(i,!0);a!==null&&(this.ImportRhinoGeometryAsMesh(e,a,t,n),a.delete())}else if(o===this.rhino.ObjectType.Curve)this.ImportRhinoGeometryAsMesh(e,i,t,n);else if(o===this.rhino.ObjectType.InstanceReference){let a=i.parentIdefId;if(this.instanceIdToDefinition.has(a)){let c=this.instanceIdToDefinition.get(a).getObjectIds();for(let u=0;u<c.length;u++){let h=c[u];if(this.instanceIdToObject.has(h)){let f=this.instanceIdToObject.get(h);n.push(t),this.ImportRhinoGeometryObject(e,f,n),n.pop()}}}}}}ImportRhinoGeometryAsMesh(e,t,n,i){function s(u){let h=u.domain[1]-u.domain[0],f=Math.max(parseInt(h/.2,10),1),p=h/f,g=[];for(let y=0;y<=f;y++)if(y===f&&u.isClosed)g.push(g[0]);else{let d=t.pointAt(u.domain[0]+y*p);g.push(a.AddVertex(Ui(d)))}return new hs(g)}let o=this.GetMaterialIndex(e,n,i),a=null;if(t.objectType===this.rhino.ObjectType.Mesh){let u=t.toThreejsJSON();a=ur(u.data,o,null)}else if(t.objectType===this.rhino.ObjectType.Curve){if(a=new tn,t instanceof this.rhino.LineCurve){let u=a.AddVertex(Ui(t.line.from)),h=a.AddVertex(Ui(t.line.to)),f=new hs([u,h]);f.SetMaterial(o),a.AddLine(f)}else if(t instanceof this.rhino.NurbsCurve){let u=s(t);u.SetMaterial(o),a.AddLine(u)}else if(t instanceof this.rhino.ArcCurve){let u=s(t);u.SetMaterial(o),a.AddLine(u)}}if(a===null)return null;let l=n.attributes();a.SetName(l.name);let c=l.getUserStrings();if(c.length>0){let u=new Kn(nt("User texts"));for(let h=0;h<c.length;h++){let f=c[h];u.AddProperty(new cn(Yt.Text,f[0],f[1]))}a.AddPropertyGroup(u)}if(i.length!==0){let u=new xn().CreateIdentity();for(let f=i.length-1;f>=0;f--){let y=i[f].geometry().xform.toFloatArray(!1),d=new xn(y);u=u.MultiplyMatrix(d)}let h=new pn(u);Mr(a,h)}this.model.AddMeshToRootNode(a)}GetMaterialIndex(e,t,n){function i(l,c,u){let h=c.attributes();if(h.materialSource===l.ObjectMaterialSource.MaterialFromObject){let f=h.materialIndex;if(f>-1)return e.materials().get(f)}else if(h.materialSource===l.ObjectMaterialSource.MaterialFromLayer){let f=h.layerIndex;if(f>-1){let p=e.layers().get(f),g=p.renderMaterialIndex;if(g>-1)return e.materials().get(g);if(c.geometry().objectType===l.ObjectType.Curve){let d=new l.Material;return d.name=p.name,d.diffuseColor=p.color,d}}}else if(h.materialSource===l.ObjectMaterialSource.MaterialFromParent&&u.length!==0)return i(l,u[0],[]);return null}function s(l,c){function u(d,m){d.Set(m.r,m.g,m.b)}function h(d){return d.r===0&&d.g===0&&d.b===0}function f(d){return d.r===255&&d.g===255&&d.b===255}let p=null,g=l.physicallyBased();g.supported?(p=new ys,p.metalness=g.metallic?1:0,p.roughness=g.roughness):(p=new En,u(p.ambient,l.ambientColor),u(p.specular,l.specularColor)),p.name=l.name,u(p.color,l.diffuseColor),p.opacity=1-l.transparency,pi(p),h(p.color)&&!f(l.reflectionColor)&&u(p.color,l.reflectionColor),h(p.color)&&!f(l.transparentColor)&&u(p.color,l.transparentColor);let y=l.getBitmapTexture();if(y){let d=new fi,m=Rn(y.fileName),_=c.getFileBuffer(m);d.name=m,d.buffer=_,p.diffuseMap=d}return p}function o(l,c,u){let h=s(c,u);for(let f=0;f<l.MaterialCount();f++)if(l.GetMaterial(f).IsEqual(h))return f;return l.AddMaterial(h)}let a=i(this.rhino,t,n);return a===null?null:o(this.model,a,this.callbacks)}};var oi=class{constructor(e,t){this.arrayBuffer=e,this.dataView=new DataView(e),this.isLittleEndian=t,this.position=0}GetPosition(){return this.position}SetPosition(e){this.position=e}GetByteLength(){return this.arrayBuffer.byteLength}Skip(e){this.position=this.position+e}End(){return this.position>=this.arrayBuffer.byteLength}ReadArrayBuffer(e){let t=new Uint8Array(this.arrayBuffer),n=new ArrayBuffer(e),i=new Uint8Array(n),s=t.subarray(this.position,this.position+e);return i.set(s,0),this.position+=e,n}ReadBoolean8(){let e=this.dataView.getInt8(this.position);return this.position=this.position+1,!!e}ReadCharacter8(){let e=this.dataView.getInt8(this.position);return this.position=this.position+1,e}ReadUnsignedCharacter8(){let e=this.dataView.getUint8(this.position);return this.position=this.position+1,e}ReadInteger16(){let e=this.dataView.getInt16(this.position,this.isLittleEndian);return this.position=this.position+2,e}ReadUnsignedInteger16(){let e=this.dataView.getUint16(this.position,this.isLittleEndian);return this.position=this.position+2,e}ReadInteger32(){let e=this.dataView.getInt32(this.position,this.isLittleEndian);return this.position=this.position+4,e}ReadUnsignedInteger32(){let e=this.dataView.getUint32(this.position,this.isLittleEndian);return this.position=this.position+4,e}ReadFloat32(){let e=this.dataView.getFloat32(this.position,this.isLittleEndian);return this.position=this.position+4,e}ReadDouble64(){let e=this.dataView.getFloat64(this.position,this.isLittleEndian);return this.position=this.position+8,e}};var Mt={MAIN3DS:19789,EDIT3DS:15677,EDIT_MATERIAL:45055,MAT_NAME:40960,MAT_AMBIENT:40976,MAT_DIFFUSE:40992,MAT_SPECULAR:41008,MAT_SHININESS:41024,MAT_SHININESS_STRENGTH:41025,MAT_TRANSPARENCY:41040,MAT_COLOR_F:16,MAT_COLOR:17,MAT_LIN_COLOR:18,MAT_LIN_COLOR_F:19,MAT_TEXMAP:41472,MAT_TEXMAP_NAME:41728,MAT_TEXMAP_UOFFSET:41816,MAT_TEXMAP_VOFFSET:41818,MAT_TEXMAP_USCALE:41812,MAT_TEXMAP_VSCALE:41814,MAT_TEXMAP_ROTATION:41820,PERCENTAGE:48,PERCENTAGE_F:49,EDIT_OBJECT:16384,OBJ_TRIMESH:16640,OBJ_LIGHT:17920,OBJ_CAMERA:18176,TRI_VERTEX:16656,TRI_TEXVERTEX:16704,TRI_FACE:16672,TRI_TRANSFORMATION:16736,TRI_MATERIAL:16688,TRI_SMOOTH:16720,KF3DS:45056,OBJECT_NODE:45058,OBJECT_HIERARCHY:45072,OBJECT_INSTANCE_NAME:45073,OBJECT_PIVOT:45075,OBJECT_POSITION:45088,OBJECT_ROTATION:45089,OBJECT_SCALE:45090,OBJECT_ID:45104},$p=class{constructor(){this.id=-1,this.name="",this.flags=-1,this.parentId=-1,this.instanceName="",this.pivot=[0,0,0],this.positions=[],this.rotations=[],this.scales=[]}},Qp=class{constructor(){this.nodes=[],this.nodeIdToNode=new Map}IsEmpty(){return this.nodes.length===0}AddNode(e){this.nodes.push(e),this.nodeIdToNode.set(e.nodeId,e)}GetNodes(){return this.nodes}},Za=class extends Jt{constructor(){super()}CanImportExtension(e){return e==="3ds"}GetUpDirection(){return _t.Z}ClearContent(){this.materialNameToIndex=null,this.meshNameToIndex=null,this.nodeList=null}ResetContent(){this.materialNameToIndex=new Map,this.meshNameToIndex=new Map,this.nodeList=new Qp}ImportContent(e,t){this.ProcessBinary(e),t()}ProcessBinary(e){let t=new oi(e,!0),n=t.GetByteLength();this.ReadChunks(t,n,(i,s)=>{i===Mt.MAIN3DS?this.ReadMainChunk(t,s):this.SkipChunk(t,s)})}ReadMainChunk(e,t){let n=this.GetChunkEnd(e,t);this.ReadChunks(e,n,(i,s)=>{i===Mt.EDIT3DS?this.ReadEditorChunk(e,s):i===Mt.KF3DS?this.ReadKeyFrameChunk(e,s):this.SkipChunk(e,s)}),this.BuildNodeHierarchy()}ReadEditorChunk(e,t){let n=this.GetChunkEnd(e,t);this.ReadChunks(e,n,(i,s)=>{i===Mt.EDIT_MATERIAL?this.ReadMaterialChunk(e,s):i===Mt.EDIT_OBJECT?this.ReadObjectChunk(e,s):this.SkipChunk(e,s)})}ReadMaterialChunk(e,t){let n=new En,i=this.GetChunkEnd(e,t),s=null,o=null;this.ReadChunks(e,i,(l,c)=>{l===Mt.MAT_NAME?n.name=this.ReadName(e):l===Mt.MAT_AMBIENT?n.ambient=this.ReadColorChunk(e,c):l===Mt.MAT_DIFFUSE?n.color=this.ReadColorChunk(e,c):l===Mt.MAT_SPECULAR?n.specular=this.ReadColorChunk(e,c):l===Mt.MAT_SHININESS?s=this.ReadPercentageChunk(e,c):l===Mt.MAT_SHININESS_STRENGTH?o=this.ReadPercentageChunk(e,c):l===Mt.MAT_TRANSPARENCY?(n.opacity=1-this.ReadPercentageChunk(e,c),pi(n)):l===Mt.MAT_TEXMAP?(n.diffuseMap=this.ReadTextureMapChunk(e,c),pi(n)):this.SkipChunk(e,c)}),s!==null&&o!==null&&(n.shininess=s*o/10);let a=this.model.AddMaterial(n);this.materialNameToIndex.set(n.name,a)}ReadTextureMapChunk(e,t){let n=new fi,i=this.GetChunkEnd(e,t);return this.ReadChunks(e,i,(s,o)=>{if(s===Mt.MAT_TEXMAP_NAME){let a=this.ReadName(e),l=this.callbacks.getFileBuffer(a);n.name=a,n.buffer=l}else s===Mt.MAT_TEXMAP_UOFFSET?n.offset.x=e.ReadFloat32():s===Mt.MAT_TEXMAP_VOFFSET?n.offset.y=e.ReadFloat32():s===Mt.MAT_TEXMAP_USCALE?n.scale.x=e.ReadFloat32():s===Mt.MAT_TEXMAP_VSCALE?n.scale.y=e.ReadFloat32():s===Mt.MAT_TEXMAP_ROTATION?n.rotation=e.ReadFloat32()*xr:this.SkipChunk(e,o)}),n}ReadColorChunk(e,t){let n=new St(0,0,0),i=this.GetChunkEnd(e,t),s=!1;return this.ReadChunks(e,i,(o,a)=>{o===Mt.MAT_COLOR?s||(n.r=e.ReadUnsignedCharacter8(),n.g=e.ReadUnsignedCharacter8(),n.b=e.ReadUnsignedCharacter8()):o===Mt.MAT_LIN_COLOR?(n.r=e.ReadUnsignedCharacter8(),n.g=e.ReadUnsignedCharacter8(),n.b=e.ReadUnsignedCharacter8(),s=!0):o===Mt.MAT_COLOR_F?s||(n.r=Fn(e.ReadFloat32()),n.g=Fn(e.ReadFloat32()),n.b=Fn(e.ReadFloat32())):o===Mt.MAT_LIN_COLOR_F?(n.r=Fn(e.ReadFloat32()),n.g=Fn(e.ReadFloat32()),n.b=Fn(e.ReadFloat32()),s=!0):this.SkipChunk(e,a)}),n}ReadPercentageChunk(e,t){let n=0,i=this.GetChunkEnd(e,t);return this.ReadChunks(e,i,(s,o)=>{s===Mt.PERCENTAGE?n=e.ReadUnsignedInteger16()/100:s===Mt.PERCENTAGE_F?n=e.ReadFloat32():this.SkipChunk(e,o)}),n}ReadObjectChunk(e,t){let n=this.GetChunkEnd(e,t),i=this.ReadName(e);this.ReadChunks(e,n,(s,o)=>{s===Mt.OBJ_TRIMESH?this.ReadMeshChunk(e,o,i):this.SkipChunk(e,o)})}ReadMeshChunk(e,t,n){function i(u,h){if(!h.IsValid())return;let f=h.Determinant(),p=Br(f);p&&(h=new xn().CreateScale(-1,1,1).MultiplyMatrix(h));let g=h.Invert();if(g===null)return;let y=new pn(g);Mr(u,y),p&&Ru(u)}let s=new tn;s.SetName(n);let o=this.GetChunkEnd(e,t),a=null;if(this.ReadChunks(e,o,(u,h)=>{u===Mt.TRI_VERTEX?this.ReadVerticesChunk(s,e):u===Mt.TRI_TEXVERTEX?this.ReadTextureVerticesChunk(s,e):u===Mt.TRI_FACE?this.ReadFacesChunk(s,e,h):u===Mt.TRI_TRANSFORMATION?a=this.ReadTransformationChunk(e):this.SkipChunk(e,h)}),s.VertexCount()===s.TextureUVCount())for(let u=0;u<s.TriangleCount();u++){let h=s.GetTriangle(u);h.SetTextureUVs(h.v0,h.v1,h.v2)}let l=new xn(a);i(s,l);let c=this.model.AddMesh(s);this.meshNameToIndex.set(s.GetName(),c)}ReadVerticesChunk(e,t){let n=t.ReadUnsignedInteger16();for(let i=0;i<n;i++){let s=t.ReadFloat32(),o=t.ReadFloat32(),a=t.ReadFloat32();e.AddVertex(new Ye(s,o,a))}}ReadTextureVerticesChunk(e,t){let n=t.ReadUnsignedInteger16();for(let i=0;i<n;i++){let s=t.ReadFloat32(),o=t.ReadFloat32();e.AddTextureUV(new Nt(s,o))}}ReadFacesChunk(e,t,n){let i=this.GetChunkEnd(t,n),s=t.ReadUnsignedInteger16();for(let o=0;o<s;o++){let a=t.ReadUnsignedInteger16(),l=t.ReadUnsignedInteger16(),c=t.ReadUnsignedInteger16();t.ReadUnsignedInteger16(),e.AddTriangle(new Qt(a,l,c))}this.ReadChunks(t,i,(o,a)=>{o===Mt.TRI_MATERIAL?this.ReadFaceMaterialsChunk(e,t):o===Mt.TRI_SMOOTH?this.ReadFaceSmoothingGroupsChunk(e,s,t):this.SkipChunk(t,a)})}ReadFaceMaterialsChunk(e,t){let n=this.ReadName(t),i=this.materialNameToIndex.get(n),s=t.ReadUnsignedInteger16();for(let o=0;o<s;o++){let a=t.ReadUnsignedInteger16(),l=e.GetTriangle(a);i!==void 0&&(l.mat=i)}}ReadFaceSmoothingGroupsChunk(e,t,n){for(let i=0;i<t;i++){let s=n.ReadUnsignedInteger32(),o=e.GetTriangle(i);o.curve=s}}ReadTransformationChunk(e){let t=[];for(let n=0;n<4;n++){for(let i=0;i<3;i++)t.push(e.ReadFloat32());n<3?t.push(0):t.push(1)}return t}ReadKeyFrameChunk(e,t){let n=this.GetChunkEnd(e,t);this.ReadChunks(e,n,(i,s)=>{i===Mt.OBJECT_NODE?this.ReadObjectNodeChunk(e,s):this.SkipChunk(e,s)})}BuildNodeHierarchy(){function e(n,i){function s(c){return c.positions.length===0?[0,0,0]:c.positions[0]}function o(c){function u(f){let p=[0,0,0,1],g=Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2]);if(g>0){let y=f[3]*-.5,d=Math.sin(y)/g;p=[d*f[0],d*f[1],d*f[2],Math.cos(y)]}return p}if(c.rotations.length===0)return[0,0,0,1];let h=c.rotations[0];return u(h)}function a(c){return c.scales.length===0?[1,1,1]:c.scales[0]}let l=new xn;if(l.ComposeTRS(Ui(s(n)),Zo(o(n)),Ui(a(n))),i){let c=n.pivot;l=new xn().CreateTranslation(-c[0],-c[1],-c[2]).MultiplyMatrix(l)}return new pn(l)}let t=this.model.GetRootNode();if(this.nodeList.IsEmpty())for(let n=0;n<this.model.MeshCount();n++)t.AddMeshIndex(n);else{let n=new Map;for(let i of this.nodeList.GetNodes()){let s=new Bn;i.name.length>0&&i.name!=="$$$DUMMY"&&(s.SetName(i.name),i.instanceName.length>0&&s.SetName(s.GetName()+" "+i.instanceName)),i.parentId===65535||!n.has(i.parentId)?t.AddChildNode(s):n.get(i.parentId).AddChildNode(s),n.set(i.id,s);let o=this.meshNameToIndex.has(i.name);s.SetTransformation(e(i,o)),o&&s.AddMeshIndex(this.meshNameToIndex.get(i.name))}}}ReadObjectNodeChunk(e,t){function n(o,a,l){let c=[];a.Skip(10);let u=a.ReadInteger32();for(let h=0;h<u;h++){a.ReadInteger32(),a.ReadUnsignedInteger16()!==0&&a.ReadFloat32();let p=null;if(l===Mt.OBJECT_ROTATION){let g=a.ReadFloat32();p=o.ReadVector(a),p[3]=g}else p=o.ReadVector(a);c.push(p)}return c}let i=new $p,s=this.GetChunkEnd(e,t);this.ReadChunks(e,s,(o,a)=>{o===Mt.OBJECT_HIERARCHY?(i.name=this.ReadName(e),i.flags=e.ReadUnsignedInteger32(),i.parentId=e.ReadUnsignedInteger16()):o===Mt.OBJECT_INSTANCE_NAME?i.instanceName=this.ReadName(e):o===Mt.OBJECT_PIVOT?i.pivot=this.ReadVector(e):o===Mt.OBJECT_POSITION?i.positions=n(this,e,Mt.OBJECT_POSITION):o===Mt.OBJECT_ROTATION?i.rotations=n(this,e,Mt.OBJECT_ROTATION):o===Mt.OBJECT_SCALE?i.scales=n(this,e,Mt.OBJECT_SCALE):o===Mt.OBJECT_ID?i.id=e.ReadUnsignedInteger16():this.SkipChunk(e,a)}),this.nodeList.AddNode(i)}ReadName(e){let t="",n=0,i=0;for(;i<64&&(n=e.ReadCharacter8(),n!==0);)t=t+String.fromCharCode(n),i=i+1;return t}ReadVector(e){return[e.ReadFloat32(),e.ReadFloat32(),e.ReadFloat32()]}ReadChunks(e,t,n){for(;e.GetPosition()<=t-6;){let i=e.ReadUnsignedInteger16(),s=e.ReadUnsignedInteger32();n(i,s)}}GetChunkEnd(e,t){return e.GetPosition()+t-6}SkipChunk(e,t){e.Skip(t-6)}};var _i={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},hr={SCALAR:0,VEC2:1,VEC3:2,VEC4:3,MAT2:4,MAT3:5,MAT4:6},wo={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},em={GLTF_STRING:1179937895,JSON_CHUNK_TYPE:1313821514,BINARY_CHUNK_TYPE:5130562};function Uc(r){return Ei(Xs(r[0]),Xs(r[1]),Xs(r[2]))}function zb(r,e){function t(n,i){let s=n;return i===_i.UNSIGNED_BYTE?s/=255:i===_i.UNSIGNED_SHORT&&(s/=65535),Fn(Xs(s))}return new St(t(r[0],e),t(r[1],e),t(r[2],e))}var tm=class{constructor(e){this.reader=new oi(e,!0),this.componentType=null,this.dataType=null,this.byteStride=null,this.dataCount=null,this.sparseReader=null}SetComponentType(e){this.componentType=e}SetDataType(e){e==="SCALAR"?this.dataType=hr.SCALAR:e==="VEC2"?this.dataType=hr.VEC2:e==="VEC3"?this.dataType=hr.VEC3:e==="VEC4"?this.dataType=hr.VEC4:e==="MAT2"?this.dataType=hr.MAT2:e==="MAT3"?this.dataType=hr.MAT3:e==="MAT4"&&(this.dataType=hr.MAT4)}SetByteStride(e){this.byteStride=e}SetDataCount(e){this.dataCount=e}SetSparseReader(e,t){this.sparseReader={indexReader:e,valueReader:t}}ReadArrayBuffer(e){return this.reader.ReadArrayBuffer(e)}GetDataCount(){return this.dataCount}ReadData(){if(this.dataType===null)return null;if(this.dataType===hr.SCALAR){let e=this.ReadComponent();return this.SkipBytesByStride(1),e}else if(this.dataType===hr.VEC2){let e=this.ReadComponent(),t=this.ReadComponent();return this.SkipBytesByStride(2),new Nt(e,t)}else if(this.dataType===hr.VEC3){let e=this.ReadComponent(),t=this.ReadComponent(),n=this.ReadComponent();return this.SkipBytesByStride(3),new Ye(e,t,n)}else if(this.dataType===hr.VEC4){let e=this.ReadComponent(),t=this.ReadComponent(),n=this.ReadComponent(),i=this.ReadComponent();return this.SkipBytesByStride(4),new $i(e,t,n,i)}return null}EnumerateData(e){if(this.sparseReader===null)for(let t=0;t<this.dataCount;t++)e(this.ReadData());else{let t=[];for(let i=0;i<this.sparseReader.indexReader.GetDataCount();i++){let s=this.sparseReader.indexReader.ReadData(),o=this.sparseReader.valueReader.ReadData();t.push({index:s,value:o})}let n=0;for(let i=0;i<this.dataCount;i++){let s=this.ReadData();n<t.length&&t[n].index===i?(e(t[n].value),n+=1):e(s)}}}SkipBytes(e){this.reader.Skip(e)}ReadComponent(){return this.componentType===null?null:this.componentType===_i.BYTE?this.reader.ReadCharacter8():this.componentType===_i.UNSIGNED_BYTE?this.reader.ReadUnsignedCharacter8():this.componentType===_i.SHORT?this.reader.ReadInteger16():this.componentType===_i.UNSIGNED_SHORT?this.reader.ReadUnsignedInteger16():this.componentType===_i.UNSIGNED_INT?this.reader.ReadInteger32():this.componentType===_i.FLOAT?this.reader.ReadFloat32():null}SkipBytesByStride(e){if(this.byteStride===null)return;let t=e*this.GetComponentSize();this.reader.Skip(this.byteStride-t)}GetComponentSize(){return this.componentType===_i.BYTE||this.componentType===_i.UNSIGNED_BYTE?1:this.componentType===_i.SHORT||this.componentType===_i.UNSIGNED_SHORT?2:this.componentType===_i.UNSIGNED_INT||this.componentType===_i.FLOAT?4:0}},nm=class{constructor(){this.supportedExtensions=["KHR_draco_mesh_compression","KHR_materials_pbrSpecularGlossiness","KHR_texture_transform"],this.draco=null}LoadLibraries(e,t){if(e===void 0){t.onSuccess();return}this.draco===null&&e.indexOf("KHR_draco_mesh_compression")!==-1?_r("draco3d").then(()=>{DracoDecoderModule().then(n=>{this.draco=n,t.onSuccess()})}).catch(()=>{t.onError(nt("Failed to load draco decoder."))}):t.onSuccess()}GetUnsupportedExtensions(e){let t=[];if(e===void 0)return t;for(let n=0;n<e.length;n++){let i=e[n];this.supportedExtensions.indexOf(i)===-1&&t.push(i)}return t}ProcessMaterial(e,t,n){if(e.extensions===void 0)return null;let i=e.extensions.KHR_materials_pbrSpecularGlossiness;if(i===void 0)return null;let s=new En,o=i.diffuseFactor;o!==void 0&&(s.color=Uc(o),s.opacity=o[3]);let a=i.diffuseTexture;a!==void 0&&(s.diffuseMap=n(a));let l=i.specularFactor;l!==void 0&&(s.specular=Uc(l));let c=i.specularGlossinessTexture;c!==void 0&&(s.specularMap=n(c));let u=i.glossinessFactor;return u!==void 0&&(s.shininess=u),s}ProcessTexture(e,t){if(e.extensions===void 0)return;let n=e.extensions.KHR_texture_transform;n!==void 0&&(n.offset!==void 0&&(t.offset.x=n.offset[0],t.offset.y=-n.offset[1]),n.scale!==void 0&&(t.scale.x=n.scale[0],t.scale.y=n.scale[1]),n.rotation!==void 0&&(t.rotation=-n.rotation))}ProcessPrimitive(e,t,n,i){function s(N,B,V,ie,Y){let te=B.GetAttributeByUniqueId(V,ie),q=te.num_components(),ye=V.num_points()*q,Te=ye*4,Ae=N._malloc(Te);B.GetAttributeDataArrayForAllPoints(V,te,N.DT_FLOAT32,Te,Ae);let _e=new Float32Array(N.HEAPF32.buffer,Ae,ye).slice();if(q===2)for(let G=0;G<_e.length;G+=2)Y(new Nt(_e[G+0],_e[G+1]));else if(q===3)for(let G=0;G<_e.length;G+=3)Y(new Ye(_e[G+0],_e[G+1],_e[G+2]));else if(q===4)for(let G=0;G<_e.length;G+=4)Y(new $i(_e[G+0],_e[G+1],_e[G+2],_e[G+3]));N._free(Ae)}if(this.draco===null||n.extensions===void 0||n.extensions.KHR_draco_mesh_compression===void 0)return!1;let o=new this.draco.Decoder,a=new this.draco.DecoderBuffer,l=n.extensions.KHR_draco_mesh_compression,c=t.bufferViews[l.bufferView],h=e.GetReaderFromBufferView(c).ReadArrayBuffer(c.byteLength);if(a.Init(new Int8Array(h),h.byteLength),o.GetEncodedGeometryType(a)!==this.draco.TRIANGULAR_MESH)return!0;let p=new this.draco.Mesh;if(!o.DecodeBufferToMesh(a,p).ok())return!0;let y=l.attributes.POSITION!==void 0,d=!1,m=l.attributes.NORMAL!==void 0,_=l.attributes.TEXCOORD_0!==void 0;if(!y)return!0;let v=i.VertexCount(),x=i.VertexColorCount(),S=i.NormalCount(),I=i.TextureUVCount();s(this.draco,o,p,l.attributes.POSITION,N=>{i.AddVertex(N)}),m&&s(this.draco,o,p,l.attributes.NORMAL,N=>{i.AddNormal(N)}),_&&s(this.draco,o,p,l.attributes.TEXCOORD_0,N=>{N.y=-N.y,i.AddTextureUV(N)});let C=p.num_faces()*3,E=C*4,b=this.draco._malloc(E);o.GetTrianglesUInt32Array(p,E,b);let R=new Uint32Array(this.draco.HEAPU32.buffer,b,C).slice();for(let N=0;N<R.length;N+=3){let B=R[N],V=R[N+1],ie=R[N+2];e.AddTriangle(n,i,B,V,ie,d,m,_,v,x,S,I)}return this.draco._free(b),!0}},Ja=class extends Jt{constructor(){super(),this.gltfExtensions=new nm}CanImportExtension(e){return e==="gltf"||e==="glb"}GetUpDirection(){return _t.Y}ClearContent(){this.bufferContents=null,this.imageIndexToTextureParams=null}ResetContent(){this.bufferContents=[],this.imageIndexToTextureParams=new Map}ImportContent(e,t){this.extension==="gltf"?this.ProcessGltf(e,t):this.extension==="glb"&&this.ProcessBinaryGltf(e,t)}ProcessGltf(e,t){let n=Sn(e),i=JSON.parse(n);if(i.asset.version!=="2.0"){this.SetError(nt("Invalid glTF version.")),t();return}for(let s=0;s<i.buffers.length;s++){let o=null,a=i.buffers[s],l=qs(a.uri);if(l!==null)o=l.buffer;else{let c=this.callbacks.getFileBuffer(a.uri);c!==null&&(o=c)}if(o===null){this.SetError(nt("One of the requested buffers is missing.")),t();return}this.bufferContents.push(o)}this.ProcessMainFile(i,t)}ProcessBinaryGltf(e,t){function n(c){let u=c.ReadUnsignedInteger32(),h=c.ReadUnsignedInteger32(),f=c.ReadArrayBuffer(u);return{type:h,buffer:f}}let i=new oi(e,!0);if(i.ReadUnsignedInteger32()!==em.GLTF_STRING){this.SetError(nt("Invalid glTF file.")),t();return}if(i.ReadUnsignedInteger32()!==2){this.SetError(nt("Invalid glTF version.")),t();return}if(i.ReadUnsignedInteger32()!==i.GetByteLength()){this.SetError(nt("Invalid glTF file.")),t();return}let l=null;for(;!i.End();){let c=n(i);c.type===em.JSON_CHUNK_TYPE?l=Sn(c.buffer):c.type===em.BINARY_CHUNK_TYPE&&this.bufferContents.push(c.buffer)}if(l!==null){let c=JSON.parse(l);this.ProcessMainFile(c,t)}}ProcessMainFile(e,t){let n=this.gltfExtensions.GetUnsupportedExtensions(e.extensionsRequired);if(n.length>0){this.SetError(Uo("Unsupported extension: {0}.",n.join(", "))),t();return}this.gltfExtensions.LoadLibraries(e.extensionsRequired,{onSuccess:()=>{this.ImportModel(e),t()},onError:i=>{this.SetError(i),t()}})}ImportModel(e){let t=e.materials;if(t!==void 0)for(let i of t)this.ImportMaterial(e,i);let n=e.meshes;if(n!==void 0)for(let i of n)this.ImportMesh(e,i);this.ImportProperties(this.model,e.asset,nt("Asset properties")),this.ImportScene(e)}ImportProperties(e,t,n){if(t==null)return;let i=new Kn(n);for(let s in t)if(Object.prototype.hasOwnProperty.call(t,s)){let o=null,a=t[s];typeof a=="string"?o=new cn(Yt.Text,s,a):typeof a=="number"&&(Number.isInteger(a)?o=new cn(Yt.Integer,s,a):o=new cn(Yt.Number,s,a)),o!==null&&i.AddProperty(o)}i.PropertyCount()!==0&&e.AddPropertyGroup(i)}GetDefaultScene(e){let t=e.scene||0;return t>=e.scenes.length?null:e.scenes[t]}ImportMaterial(e,t){let n=new ys;if(t.name!==void 0&&(n.name=t.name),n.color=Uc([1,1,1]),t.pbrMetallicRoughness!==void 0){let s=t.pbrMetallicRoughness.baseColorFactor;s!==void 0&&(n.color=Uc(s),n.opacity=s[3]);let o=t.pbrMetallicRoughness.metallicFactor;o!==void 0&&(n.metalness=o);let a=t.pbrMetallicRoughness.roughnessFactor;a!==void 0&&(n.roughness=a);let l=t.emissiveFactor;l!==void 0&&(n.emissive=Uc(l)),n.diffuseMap=this.ImportTexture(e,t.pbrMetallicRoughness.baseColorTexture),n.metalnessMap=this.ImportTexture(e,t.pbrMetallicRoughness.metallicRoughnessTexture),n.normalMap=this.ImportTexture(e,t.normalTexture),n.emissiveMap=this.ImportTexture(e,t.emissiveTexture),n.diffuseMap!==null&&(n.multiplyDiffuseMap=!0);let c=t.alphaMode;c!==void 0&&(c==="BLEND"?n.transparent=!0:c==="MASK"&&(n.transparent=!0,n.alphaTest=t.alphaCutoff||.5))}let i=this.gltfExtensions.ProcessMaterial(t,n,s=>this.ImportTexture(e,s));i!==null&&(n=i),this.model.AddMaterial(n)}ImportTexture(e,t){if(t==null)return null;let n=new fi,s=e.textures[t.index].source,o=e.images[s],a=null;if(this.imageIndexToTextureParams.has(s))a=this.imageIndexToTextureParams.get(s);else{a={name:null,mimeType:null,buffer:null};let l=s.toString();if(o.uri!==void 0){let c=qs(o.uri);if(c!==null)a.name="Embedded_"+l+"."+xs(c.mimeType),a.mimeType=c.mimeType,a.buffer=c.buffer;else{let u=this.callbacks.getFileBuffer(o.uri);a.name=o.uri,a.buffer=u}}else if(o.bufferView!==void 0){let c=e.bufferViews[o.bufferView],u=this.GetReaderFromBufferView(c);if(u!==null){let h=u.ReadArrayBuffer(c.byteLength);a.name="Binary_"+l+"."+xs(o.mimeType),a.mimeType=o.mimeType,a.buffer=h}}this.imageIndexToTextureParams.set(s,a)}return n.name=a.name,n.mimeType=a.mimeType,n.buffer=a.buffer,this.gltfExtensions.ProcessTexture(t,n),n}ImportMesh(e,t){let n=new tn;this.model.AddMesh(n),t.name!==void 0&&n.SetName(t.name);for(let i=0;i<t.primitives.length;i++){let s=t.primitives[i];this.ImportPrimitive(e,s,n)}this.ImportProperties(n,t.extras,nt("Mesh properties"))}ImportPrimitive(e,t,n){function i(m,_,v){let x=_.attributes[v];if(x===void 0)return!1;let S=m.accessors[x];return!(S===void 0||S.count===0)}if(this.gltfExtensions.ProcessPrimitive(this,e,t,n)||t.attributes===void 0)return;let s=i(e,t,"POSITION"),o=i(e,t,"COLOR_0"),a=i(e,t,"NORMAL"),l=i(e,t,"TEXCOORD_0"),c=t.indices!==void 0,u=wo.TRIANGLES;if(t.mode!==void 0&&(u=t.mode),u!==wo.TRIANGLES&&u!==wo.TRIANGLE_STRIP&&u!==wo.TRIANGLE_FAN)return;let h=n.VertexCount(),f=n.VertexColorCount(),p=n.NormalCount(),g=n.TextureUVCount();if(s){let m=e.accessors[t.attributes.POSITION],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(v=>{n.AddVertex(v)})}else return;let y=n.VertexCount()-h;if(o){let m=e.accessors[t.attributes.COLOR_0],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(v=>{let x=zb([v.x,v.y,v.z],_.componentType);n.AddVertexColor(x)}),n.VertexColorCount()-f!==y&&(o=!1)}if(a){let m=e.accessors[t.attributes.NORMAL],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(v=>{n.AddNormal(v)}),n.NormalCount()-p!==y&&(a=!1)}if(l){let m=e.accessors[t.attributes.TEXCOORD_0],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(v=>{v.y=-v.y,n.AddTextureUV(v)}),n.TextureUVCount()-g!==y&&(l=!1)}let d=[];if(c){let m=e.accessors[t.indices],_=this.GetReaderFromAccessor(e,m);if(_===null)return;_.EnumerateData(v=>{d.push(v)})}else{let m=n.VertexCount()-h;for(let _=0;_<m;_++)d.push(_)}if(u===wo.TRIANGLES)for(let m=0;m<d.length;m+=3){let _=d[m],v=d[m+1],x=d[m+2];this.AddTriangle(t,n,_,v,x,o,a,l,h,f,p,g)}else if(u===wo.TRIANGLE_STRIP)for(let m=0;m<d.length-2;m++){let _=d[m],v=d[m+1],x=d[m+2];if(m%2===1){let S=v;v=x,x=S}this.AddTriangle(t,n,_,v,x,o,a,l,h,f,p,g)}else if(u===wo.TRIANGLE_FAN)for(let m=1;m<d.length-1;m++){let _=d[0],v=d[m],x=d[m+1];this.AddTriangle(t,n,_,v,x,o,a,l,h,f,p,g)}}AddTriangle(e,t,n,i,s,o,a,l,c,u,h,f){let p=new Qt(c+n,c+i,c+s);o&&p.SetVertexColors(u+n,u+i,u+s),a&&p.SetNormals(h+n,h+i,h+s),l&&p.SetTextureUVs(f+n,f+i,f+s),e.material!==void 0&&(p.mat=e.material),t.AddTriangle(p)}ImportScene(e){let t=this.GetDefaultScene(e);if(t===null)return;let n=this.model.GetRootNode();for(let i of t.nodes){let s=e.nodes[i];this.ImportNode(e,s,n)}this.ImportProperties(this.model,t.extras,nt("Scene properties"))}ImportNode(e,t,n){function i(o){let a=new xn().CreateIdentity();if(o.matrix!==void 0)a.Set(o.matrix);else{let l=[0,0,0],c=[0,0,0,1],u=[1,1,1];o.translation!==void 0&&(l=o.translation),o.rotation!==void 0&&(c=o.rotation),o.scale!==void 0&&(u=o.scale),a.ComposeTRS(Ui(l),Zo(c),Ui(u))}return new pn(a)}if(t.children===void 0&&t.mesh===void 0)return;let s=new Bn;if(t.name!==void 0&&s.SetName(t.name),s.SetTransformation(i(t)),n.AddChildNode(s),t.children!==void 0)for(let o of t.children){let a=e.nodes[o];this.ImportNode(e,a,s)}if(t.mesh!==void 0){let o=this.model.GetMesh(t.mesh);this.ImportProperties(o,t.extras,nt("Node properties")),s.AddMeshIndex(t.mesh)}}GetReaderFromBufferView(e){let t=e.buffer||0,n=this.bufferContents[t];if(n==null)return null;let i=new tm(n);i.SkipBytes(e.byteOffset||0);let s=e.byteStride;return s!==void 0&&s!==0&&i.SetByteStride(s),i}GetReaderFromAccessor(e,t){let n=t.bufferView||0,i=e.bufferViews[n],s=this.GetReaderFromBufferView(i);if(s===null)return null;if(s.SetComponentType(t.componentType),s.SetDataType(t.type),s.SetDataCount(t.count),s.SkipBytes(t.byteOffset||0),t.sparse!==void 0){let o=this.GetReaderFromSparseAccessor(e,t.sparse.indices,t.sparse.indices.componentType,"SCALAR",t.sparse.count),a=this.GetReaderFromSparseAccessor(e,t.sparse.values,t.componentType,t.type,t.sparse.count);o!==null&&a!==null&&s.SetSparseReader(o,a)}return s}GetReaderFromSparseAccessor(e,t,n,i,s){if(t.bufferView===void 0)return null;let o=e.bufferViews[t.bufferView],a=this.GetReaderFromBufferView(o);return a===null?null:(a.SetComponentType(n),a.SetDataType(i),a.SetDataCount(s),a.SkipBytes(t.byteOffset||0),a)}};var $a=class extends Jt{constructor(){super(),this.ifc=null}CanImportExtension(e){return e==="ifc"}GetUpDirection(){return _t.Y}ClearContent(){this.expressIDToMesh=null,this.colorToMaterial=null}ResetContent(){this.expressIDToMesh=new Map,this.colorToMaterial=new di(this.model)}ImportContent(e,t){this.ifc===null?_r("webifc").then(()=>{this.ifc=new WebIFC.IfcAPI,this.ifc.Init().then(()=>{this.ImportIfcContent(e),t()})}).catch(()=>{this.SetError(nt("Failed to load web-ifc.")),t()}):(this.ImportIfcContent(e),t())}ImportIfcContent(e){let t=new Uint8Array(e),n=this.ifc.OpenModel(t,{COORDINATE_TO_ORIGIN:!0}),i=this.ifc.LoadAllGeometry(n);for(let s=0;s<i.size();s++){let o=i.get(s);o.geometries.size()>0&&this.ImportIfcMesh(n,o)}this.ImportProperties(n),this.ifc.CloseModel(n)}ImportIfcMesh(e,t){let n=new tn;n.SetName(Uo("Mesh {0}",t.expressID.toString()));let i=0,s=t.geometries;for(let o=0;o<s.size();o++){let a=s.get(o),l=this.ifc.GetGeometry(e,a.geometryExpressID),c=this.ifc.GetVertexArray(l.GetVertexData(),l.GetVertexDataSize()),u=this.ifc.GetIndexArray(l.GetIndexData(),l.GetIndexDataSize()),h=this.GetMaterialIndexByColor(a.color),f=new xn(a.flatTransformation),p=new pn(f);for(let g=0;g<c.length;g+=6){let y=c[g],d=c[g+1],m=c[g+2],_=new Ye(y,d,m),v=p.TransformCoord3D(_);n.AddVertex(v)}for(let g=0;g<u.length;g+=3){let y=u[g],d=u[g+1],m=u[g+2],_=new Qt(i+y,i+d,i+m);_.SetMaterial(h),n.AddTriangle(_)}i+=c.length/6}this.expressIDToMesh.set(t.expressID,n),this.model.AddMeshToRootNode(n)}ImportProperties(e){let t=this.ifc.GetLineIDsWithType(e,WebIFC.IFCRELDEFINESBYPROPERTIES);for(let n=0;n<t.size();n++){let i=t.get(n),s=this.ifc.GetLine(e,i);Array.isArray(s.RelatingPropertyDefinition)||s.RelatedObjects.forEach(o=>{let a=null;if(this.expressIDToMesh.has(o.value)?a=this.expressIDToMesh.get(o.value):this.ifc.GetLine(e,o.value,!0).type===WebIFC.IFCBUILDING&&(a=this.model),a===null)return;let l=s.RelatingPropertyDefinition,c=this.ifc.GetLine(e,l.value,!0);if(!c||!c.HasProperties)return;let u=new Kn(c.Name.value);c.HasProperties.forEach(h=>{if(!h||!h.Name||!h.NominalValue||!h.NominalValue.constructor||h.type!==WebIFC.IFCPROPERTYSINGLEVALUE)return;let f=this.GetIFCString(h.Name.value),p=null,g=null;switch(h.NominalValue.constructor.name){case"IfcText":case"IfcLabel":case"IfcIdentifier":case WebIFC.IFCLABEL:p=new cn(Yt.Text,f,this.GetIFCString(h.NominalValue.value));break;case"IfcBoolean":case"IfcLogical":g=nt("Unknown"),h.NominalValue.value==="T"?g=nt("True"):h.NominalValue.value==="F"&&(g=nt("False")),p=new cn(Yt.Text,f,g);break;case"IfcInteger":case"IfcCountMeasure":p=new cn(Yt.Integer,f,h.NominalValue.value);break;case"IfcReal":case"IfcLengthMeasure":case"IfcPositiveLengthMeasure":case"IfcAreaMeasure":case"IfcVolumeMeasure":case"IfcRatioMeasure":case"IfcPositiveRatioMeasure":case"IfcMassMeasure":case"IfcMassPerLengthMeasure":case"IfcPlaneAngleMeasure":case"IfcThermalTransmittanceMeasure":p=new cn(Yt.Number,f,h.NominalValue.value);break;default:console.log(h);break}p!==null&&u.AddProperty(p)}),u.PropertyCount()>0&&a.AddPropertyGroup(u)})}}GetMaterialIndexByColor(e){let t=Ei(e.x,e.y,e.z),n=parseInt(e.w*255,10);return this.colorToMaterial.GetMaterialIndex(t.r,t.g,t.b,n)}GetIFCString(e){let t=this.DecodeIFCString(e);return t.length===0&&(t="-"),t}DecodeIFCString(e){let t=/\\X2\\(.*?)\\X0\\/uig,n=e,i=t.exec(e);for(;i;){let s=String.fromCharCode(parseInt(i[1],16));n=n.replace(i[0],s),i=t.exec(e)}return n}};var im=class{constructor(e){this.mesh=e,this.globalToMeshVertices=new Map,this.globalToMeshVertexColors=new Map,this.globalToMeshNormals=new Map,this.globalToMeshUvs=new Map}AddVertex(e,t){return this.GetMeshIndex(e,t,this.globalToMeshVertices,n=>this.mesh.AddVertex(new Ye(n.x,n.y,n.z)))}AddVertexColor(e,t){return this.GetMeshIndex(e,t,this.globalToMeshVertexColors,n=>this.mesh.AddVertexColor(new St(n.r,n.g,n.b)))}AddNormal(e,t){return this.GetMeshIndex(e,t,this.globalToMeshNormals,n=>this.mesh.AddNormal(new Ye(n.x,n.y,n.z)))}AddUV(e,t){return this.GetMeshIndex(e,t,this.globalToMeshUvs,n=>this.mesh.AddTextureUV(new Nt(n.x,n.y)))}AddLine(e){this.mesh.AddLine(e)}AddTriangle(e){this.mesh.AddTriangle(e)}GetMeshIndex(e,t,n,i){if(isNaN(e)||e<0||e>=t.length)return null;if(n.has(e))return n.get(e);{let s=t[e],o=i(s);return n.set(e,o),o}}};function Df(r,e,t){return Ei(parseFloat(r),parseFloat(e),parseFloat(t))}var Qa=class extends Jt{constructor(){super()}CanImportExtension(e){return e==="obj"}GetUpDirection(){return _t.Y}ClearContent(){this.globalVertices=null,this.globalVertexColors=null,this.globalNormals=null,this.globalUvs=null,this.currentMeshConverter=null,this.currentMaterial=null,this.currentMaterialIndex=null,this.meshNameToConverter=null,this.materialNameToIndex=null}ResetContent(){this.globalVertices=[],this.globalVertexColors=[],this.globalNormals=[],this.globalUvs=[],this.currentMeshConverter=null,this.currentMaterial=null,this.currentMaterialIndex=null,this.meshNameToConverter=new Map,this.materialNameToIndex=new Map}ImportContent(e,t){let n=Sn(e);Fi(n,i=>{this.WasError()||this.ProcessLine(i)}),t()}ProcessLine(e){if(e[0]==="#")return;let t=Yi(e,"#");if(t.length===0)return;let n=t[0].toLowerCase();t.shift(),!this.ProcessMeshParameter(n,t,e)&&this.ProcessMaterialParameter(n,t,e)}AddNewMesh(e){if(this.meshNameToConverter.has(e))this.currentMeshConverter=this.meshNameToConverter.get(e);else{let t=new tn;t.SetName(e),this.model.AddMeshToRootNode(t),this.currentMeshConverter=new im(t),this.meshNameToConverter.set(e,this.currentMeshConverter)}}ProcessMeshParameter(e,t,n){if(e==="g"||e==="o"){if(t.length===0)return!0;let i=zr(n,e.length,"#");return this.AddNewMesh(i),!0}else{if(e==="v")return t.length<3||(this.globalVertices.push(new Ye(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]))),t.length>=6&&this.globalVertexColors.push(Df(t[3],t[4],t[5]))),!0;if(e==="vn")return t.length<3||this.globalNormals.push(new Ye(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]))),!0;if(e==="vt")return t.length<2||this.globalUvs.push(new Nt(parseFloat(t[0]),parseFloat(t[1]))),!0;if(e==="l"){if(t.length<2)return!0;this.ProcessLineCommand(t)}else if(e==="f")return t.length<3||this.ProcessFaceCommand(t),!0}return!1}ProcessMaterialParameter(e,t,n){function i(o){let a=new Map,l=null;for(let c=0;c<o.length-1;c++){let u=o[c];if(u.startsWith("-")){l=u,a.set(l,[]);continue}l!==null&&a.get(l).push(u)}return a}function s(o,a){let l=new fi,c=o[o.length-1],u=a.getFileBuffer(c);l.name=c,l.buffer=u;let h=i(o);if(h.has("-o")){let f=h.get("-o");f.length>0&&(l.offset.x=parseFloat(f[0])),f.length>1&&(l.offset.y=parseFloat(f[1]))}if(h.has("-s")){let f=h.get("-s");f.length>0&&(l.scale.x=parseFloat(f[0])),f.length>1&&(l.scale.y=parseFloat(f[1]))}return l}if(e==="newmtl"){if(t.length===0)return!0;let o=new En,a=zr(n,e.length,"#"),l=this.model.AddMaterial(o);return o.name=a,this.currentMaterial=o,this.materialNameToIndex.set(a,l),!0}else if(e==="usemtl"){if(t.length===0)return!0;let o=zr(n,e.length,"#");return this.materialNameToIndex.has(o)&&(this.currentMaterialIndex=this.materialNameToIndex.get(o)),!0}else if(e==="mtllib"){if(t.length===0)return!0;let o=zr(n,e.length,"#"),a=this.callbacks.getFileBuffer(o);if(a!==null){let l=Sn(a);Fi(l,c=>{this.WasError()||this.ProcessLine(c)})}return!0}else{if(e==="map_kd")return this.currentMaterial===null||t.length===0||(this.currentMaterial.diffuseMap=s(t,this.callbacks),pi(this.currentMaterial)),!0;if(e==="map_ks")return this.currentMaterial===null||t.length===0||(this.currentMaterial.specularMap=s(t,this.callbacks)),!0;if(e==="map_bump"||e==="bump")return this.currentMaterial===null||t.length===0||(this.currentMaterial.bumpMap=s(t,this.callbacks)),!0;if(e==="ka")return this.currentMaterial===null||t.length<3||(this.currentMaterial.ambient=Df(t[0],t[1],t[2])),!0;if(e==="kd")return this.currentMaterial===null||t.length<3||(this.currentMaterial.color=Df(t[0],t[1],t[2])),!0;if(e==="ks")return this.currentMaterial===null||t.length<3||(this.currentMaterial.specular=Df(t[0],t[1],t[2])),!0;if(e==="ns")return this.currentMaterial===null||t.length<1||(this.currentMaterial.shininess=parseFloat(t[0])/1e3),!0;if(e==="tr")return this.currentMaterial===null||t.length<1||(this.currentMaterial.opacity=1-parseFloat(t[0]),pi(this.currentMaterial)),!0;if(e==="d")return this.currentMaterial===null||t.length<1||(this.currentMaterial.opacity=parseFloat(t[0]),pi(this.currentMaterial)),!0}return!1}ProcessLineCommand(e){this.currentMeshConverter===null&&this.AddNewMesh("");let t=[];for(let i=0;i<e.length;i++){let s=e[i].split("/"),o=this.GetRelativeIndex(parseInt(s[0],10),this.globalVertices.length),a=this.currentMeshConverter.AddVertex(o,this.globalVertices);if(a===null){this.SetError(nt("Invalid vertex index."));break}t.push(a)}let n=new hs(t);this.currentMaterialIndex!==null&&(n.mat=this.currentMaterialIndex),this.currentMeshConverter.AddLine(n)}ProcessFaceCommand(e){let t=[],n=[],i=[],s=[];this.currentMeshConverter===null&&this.AddNewMesh("");for(let o=0;o<e.length;o++){let a=e[o].split("/");t.push(this.GetRelativeIndex(parseInt(a[0],10),this.globalVertices.length)),this.globalVertices.length===this.globalVertexColors.length&&n.push(this.GetRelativeIndex(parseInt(a[0],10),this.globalVertices.length)),a.length>1&&a[1].length>0&&s.push(this.GetRelativeIndex(parseInt(a[1],10),this.globalUvs.length)),a.length>2&&a[2].length>0&&i.push(this.GetRelativeIndex(parseInt(a[2],10),this.globalNormals.length))}for(let o=0;o<t.length-2;o++){let a=this.currentMeshConverter.AddVertex(t[0],this.globalVertices),l=this.currentMeshConverter.AddVertex(t[o+1],this.globalVertices),c=this.currentMeshConverter.AddVertex(t[o+2],this.globalVertices);if(a===null||l===null||c===null){this.SetError(nt("Invalid vertex index."));break}let u=new Qt(a,l,c);if(n.length===t.length){let h=this.currentMeshConverter.AddVertexColor(n[0],this.globalVertexColors),f=this.currentMeshConverter.AddVertexColor(n[o+1],this.globalVertexColors),p=this.currentMeshConverter.AddVertexColor(n[o+2],this.globalVertexColors);if(h===null||f===null||p===null){this.SetError(nt("Invalid vertex color index."));break}u.SetVertexColors(h,f,p)}if(i.length===t.length){let h=this.currentMeshConverter.AddNormal(i[0],this.globalNormals),f=this.currentMeshConverter.AddNormal(i[o+1],this.globalNormals),p=this.currentMeshConverter.AddNormal(i[o+2],this.globalNormals);if(h===null||f===null||p===null){this.SetError(nt("Invalid normal index."));break}u.SetNormals(h,f,p)}if(s.length===t.length){let h=this.currentMeshConverter.AddUV(s[0],this.globalUvs),f=this.currentMeshConverter.AddUV(s[o+1],this.globalUvs),p=this.currentMeshConverter.AddUV(s[o+2],this.globalUvs);if(h===null||f===null||p===null){this.SetError(nt("Invalid uv index."));break}u.SetTextureUVs(h,f,p)}this.currentMaterialIndex!==null&&(u.mat=this.currentMaterialIndex),this.currentMeshConverter.AddTriangle(u)}}GetRelativeIndex(e,t){return e>0?e-1:t+e}};var el=class extends Jt{constructor(){super()}CanImportExtension(e){return e==="off"}GetUpDirection(){return _t.Y}ClearContent(){this.mesh=null,this.status=null,this.colorToMaterial=null}ResetContent(){this.mesh=new tn,this.model.AddMeshToRootNode(this.mesh),this.status={vertexCount:0,faceCount:0,foundVertex:0,foundFace:0},this.colorToMaterial=new di(this.model)}ImportContent(e,t){let n=Sn(e);Fi(n,i=>{this.WasError()||this.ProcessLine(i)}),t()}ProcessLine(e){function t(s){return s.indexOf(".")!==-1?Fn(parseFloat(s)):parseInt(s,10)}if(e[0]==="#")return;let n=Yi(e,"#");if(n.length===0||n[0]==="OFF")return;if(this.status.vertexCount===0&&this.status.faceCount===0){n.length>1&&(this.status.vertexCount=parseInt(n[0],10),this.status.faceCount=parseInt(n[1],10));return}if(this.status.foundVertex<this.status.vertexCount){n.length>=3&&(this.mesh.AddVertex(new Ye(parseFloat(n[0]),parseFloat(n[1]),parseFloat(n[2]))),this.status.foundVertex+=1),n.length>=6&&this.mesh.AddVertexColor(new St(t(n[3]),t(n[4]),t(n[5])));return}let i=this.mesh.VertexCount()===this.mesh.VertexColorCount();if(this.status.foundFace<this.status.faceCount){if(n.length>=4){let s=parseInt(n[0],10);if(n.length<s+1)return;let o=null;if(!i&&n.length>=s+4){let a=new St(t(n[s+1]),t(n[s+2]),t(n[s+3]));o=this.colorToMaterial.GetMaterialIndex(a.r,a.g,a.b)}for(let a=0;a<s-2;a++){let l=parseInt(n[1]),c=parseInt(n[a+2]),u=parseInt(n[a+3]),h=new Qt(l,c,u);i?h.SetVertexColors(l,c,u):h.SetMaterial(o),this.mesh.AddTriangle(h)}this.status.foundFace+=1}return}}};var Ds={Ok:1,NoVertices:2,NoFaces:3,UnknownError:4},rm=class{constructor(){this.format=null,this.elements=[]}SetFormat(e){this.format=e}AddElement(e,t){this.elements.push({name:e,count:t,format:[]})}GetElements(){return this.elements}AddSingleFormat(e,t){this.elements[this.elements.length-1].format.push({name:t,isSingle:!0,elemType:e})}AddListFormat(e,t,n){this.elements[this.elements.length-1].format.push({name:n,isSingle:!1,countType:e,elemType:t})}GetElement(e){for(let t=0;t<this.elements.length;t++){let n=this.elements[t];if(n.name===e)return n}return null}Check(){let e=this.GetElement("vertex");if(e===null||e.length===0||e.format.length<3)return Ds.NoVertices;let t=this.GetElement("face");if(this.format==="ascii"){if(t===null||t.count===0||t.format.length<0)return Ds.NoFaces}else if(this.format==="binary_little_endian"||this.format==="binary_big_endian"){let n=this.GetElement("tristrips"),i=t!==null&&t.count>0&&t.format.length>0,s=n!==null&&n.count>0&&n.format.length>0;if(!i&&!s)return Ds.NoFaces}else return Ds.UnknownError;return Ds.Ok}},sm=class{constructor(e){this.model=e,this.colorToMaterial=new Map}GetMaterialIndexByColor(e){let t="Color "+In(e[0])+In(e[1])+In(e[2])+In(e[3]);if(this.colorToMaterial.has(t))return this.colorToMaterial.get(t);{let n=new En;n.name=t,n.color=new St(e[0],e[1],e[2]),n.opacity=e[3]/255,pi(n);let i=this.model.AddMaterial(n);return this.colorToMaterial.set(t,i),i}}},tl=class extends Jt{constructor(){super()}CanImportExtension(e){return e==="ply"}GetUpDirection(){return _t.Y}ClearContent(){this.mesh=null}ResetContent(){this.mesh=new tn,this.model.AddMeshToRootNode(this.mesh)}ImportContent(e,t){let n=this.GetHeaderContent(e),i=this.ReadHeader(n),s=i.Check();if(s===Ds.Ok)if(i.format==="ascii"){let o=Sn(e);o=o.substring(n.length),this.ReadAsciiContent(i,o)}else(i.format==="binary_little_endian"||i.format==="binary_big_endian")&&this.ReadBinaryContent(i,e,n.length);else s===Ds.NoVertices?this.SetError(nt("The model contains no vertices.")):s===Ds.NoFaces?this.SetError(nt("The model contains no faces.")):this.SetError(nt("Invalid header information."));t()}GetHeaderContent(e){let t="",n=new Uint8Array(e),i=0;for(i=0;i<e.byteLength&&(t+=String.fromCharCode(n[i]),!t.endsWith("end_header"));i++);for(i+=1;i<e.byteLength;){let s=String.fromCharCode(n[i]);if(t+=s,i+=1,s===`
+`)break}return t}ReadHeader(e){let t=new rm;return Fi(e,n=>{let i=Yi(n,null);i.length===0||i[0]==="comment"||i[0]!=="ply"&&(i[0]==="format"&&i.length>=2?t.SetFormat(i[1]):i[0]==="element"&&i.length>=3?t.AddElement(i[1],parseInt(i[2],10)):i[0]==="property"&&i.length>=3&&(i[1]==="list"&&i.length>=5?t.AddListFormat(i[2],i[3],i[4]):t.AddSingleFormat(i[1],i[2])))}),t}ReadAsciiContent(e,t){let n=e.GetElement("vertex"),i=e.GetElement("face"),s=0,o=0;Fi(t,a=>{if(this.WasError())return;let l=Yi(a,null);if(!(l.length===0||l[0]==="comment")){if(s<n.count){l.length>=3&&(this.mesh.AddVertex(new Ye(parseFloat(l[0]),parseFloat(l[1]),parseFloat(l[2]))),s+=1);return}if(i!==null&&o<i.count){if(l.length>=4){let c=parseInt(l[0],10);if(l.length<c+1)return;for(let u=0;u<c-2;u++){let h=parseInt(l[1]),f=parseInt(l[u+2]),p=parseInt(l[u+3]),g=new Qt(h,f,p);this.mesh.AddTriangle(g)}o+=1}return}}})}ReadBinaryContent(e,t,n){function i(u,h){function f(p,g){return g==="char"||g==="int8"?p.ReadCharacter8():g==="uchar"||g==="uint8"?p.ReadUnsignedCharacter8():g==="short"||g==="int16"?p.ReadInteger16():g==="ushort"||g==="uint16"?p.ReadUnsignedInteger16():g==="int"||g==="int32"?p.ReadInteger32():g==="uint"||g==="uint32"?p.ReadUnsignedInteger32():g==="float"||g==="float32"?p.ReadFloat32():g==="double"||g==="double64"?p.ReadDouble64():null}if(h.isSingle)return f(u,h.elemType);{let p=[],g=f(u,h.countType);for(let y=0;y<g;y++)p.push(f(u,h.elemType));return p}}function s(u,h,f){for(let p=f;p<h.length;p++)i(u,h[p])}function o(u,h,f){let p=null,g=null,y=null,d=255;for(let m=f;m<h.length;m++){let _=h[m],v=i(u,_);_.name==="red"?p=v:_.name==="green"?g=v:_.name==="blue"?y=v:_.name==="alpha"&&(d=v)}return p!==null&&g!==null&&y!==null?[p,g,y,d]:null}let a=null;if(e.format==="binary_little_endian")a=new oi(t,!0);else if(e.format==="binary_big_endian")a=new oi(t,!1);else return;a.Skip(n);let l=new sm(this.model),c=e.GetElements();for(let u=0;u<c.length;u++){let h=c[u];if(h.name==="vertex")for(let f=0;f<h.count;f++){let p=i(a,h.format[0]),g=i(a,h.format[1]),y=i(a,h.format[2]),d=o(a,h.format,3);d!==null&&this.mesh.AddVertexColor(new St(d[0],d[1],d[2])),this.mesh.AddVertex(new Ye(p,g,y))}else if(h.name==="face")for(let f=0;f<h.count;f++){let p=i(a,h.format[0]),g=o(a,h.format,1);for(let y=0;y<p.length-2;y++){let d=p[0],m=p[y+1],_=p[y+2],v=new Qt(d,m,_);g!==null?v.mat=l.GetMaterialIndexByColor(g):this.mesh.VertexColorCount()>0&&v.SetVertexColors(d,m,_),this.mesh.AddTriangle(v)}}else if(h.name==="tristrips")for(let f=0;f<h.count;f++){let p=i(a,h.format[0]);s(a,h.format,1);let g=!0;for(let y=0;y<p.length-2;y++){let d=p[y],m=p[y+1],_=p[y+2];if(_===-1){y+=2,g=!0;continue}if(!g){let x=m;m=_,_=x}g=!g;let v=new Qt(d,m,_);this.mesh.AddTriangle(v)}}else s(a,h.format,0)}}};var nl=class extends Jt{constructor(){super(),this.worker=null}CanImportExtension(e){return e==="stp"||e==="step"||e==="igs"||e==="iges"||e==="brp"||e==="brep"}GetUpDirection(){return _t.Y}ClearContent(){this.worker!==null&&(this.worker.terminate(),this.worker=null)}ResetContent(){this.worker=null}ImportContent(e,t){Wo().then(n=>{this.worker=n,this.worker.addEventListener("message",a=>{this.ImportResultJson(a.data,t)}),this.worker.addEventListener("error",a=>{this.SetError(nt("Failed to load occt-import-js.")),t()});let i=null;if(this.extension==="stp"||this.extension==="step")i="step";else if(this.extension==="igs"||this.extension==="iges")i="iges";else if(this.extension==="brp"||this.extension==="brep")i="brep";else{t();return}(i==="step"||i==="iges")&&this.model.SetUnit(_s.Millimeter);let s={linearUnit:"millimeter",linearDeflectionType:"bounding_box_ratio",linearDeflection:.001,angularDeflection:.5},o=new Uint8Array(e);this.worker.postMessage({format:i,buffer:o,params:s})}).catch(()=>{this.SetError(nt("Failed to load occt-import-js.")),t()})}ImportResultJson(e,t){if(!e.success){t();return}let n=new di(this.model),i=this.model.GetRootNode();this.ImportNode(e,e.root,i,n),t()}ImportNode(e,t,n,i){for(let s of t.meshes){let o=e.meshes[s],a=this.ImportMesh(o,i),l=this.model.AddMesh(a);n.AddMeshIndex(l)}for(let s of t.children){let o=new Bn;o.SetName(s.name),n.AddChildNode(o),this.ImportNode(e,s,o,i)}}ImportMesh(e,t){let n=null;if(e.color){let s=Ei(e.color[0],e.color[1],e.color[2]);n=t.GetMaterialIndex(s.r,s.g,s.b,null)}let i=ur(e,n,null);e.name&&i.SetName(e.name);for(let s of e.brep_faces){if(s.color===null)continue;let o=Ei(s.color[0],s.color[1],s.color[2]),a=t.GetMaterialIndex(o.r,o.g,o.b,null);for(let l=s.first;l<=s.last;l++)i.GetTriangle(l).SetMaterial(a)}return i}};var il=class extends Jt{constructor(){super()}CanImportExtension(e){return e==="stl"}GetUpDirection(){return _t.Z}ClearContent(){this.mesh=null,this.triangle=null}ResetContent(){this.mesh=new tn,this.model.AddMeshToRootNode(this.mesh),this.triangle=null}ImportContent(e,t){if(this.IsBinaryStlFile(e))this.ProcessBinary(e);else{let n=Sn(e);Fi(n,i=>{this.WasError()||this.ProcessLine(i)})}t()}IsBinaryStlFile(e){let t=e.byteLength;if(t<84)return!1;let n=new oi(e,!0);n.Skip(80);let i=n.ReadUnsignedInteger32();return t===i*50+84}ProcessLine(e){if(e[0]==="#")return;let t=Yi(e,"#");if(t.length===0)return;let n=t[0];if(n==="solid"){if(t.length>1){let i=zr(e,n.length,"#");this.mesh.SetName(i)}return}if(n==="facet"){if(this.triangle=new Qt(-1,-1,-1),t.length>=5&&t[1]==="normal"){let i=new Ye(parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4]));if(Di(i.Length())){let s=this.mesh.AddNormal(i);this.triangle.SetNormals(s,s,s)}}return}if(n==="vertex"&&this.triangle!==null){if(t.length>=4){let i=this.mesh.AddVertex(new Ye(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])));this.triangle.v0===-1?this.triangle.v0=i:this.triangle.v1===-1?this.triangle.v1=i:this.triangle.v2===-1&&(this.triangle.v2=i)}return}if(n==="endfacet"&&this.triangle!==null){this.triangle.v0!==-1&&this.triangle.v1!==-1&&this.triangle.v2!==null&&this.mesh.AddTriangle(this.triangle),this.triangle=null;return}}ProcessBinary(e){function t(o){let a=new Ye;return a.x=o.ReadFloat32(),a.y=o.ReadFloat32(),a.z=o.ReadFloat32(),a}function n(o,a){let l=t(a);return o.AddVertex(l)}let i=new oi(e,!0);i.Skip(80);let s=i.ReadUnsignedInteger32();for(let o=0;o<s;o++){let a=t(i),l=n(this.mesh,i),c=n(this.mesh,i),u=n(this.mesh,i);i.Skip(2);let h=new Qt(l,c,u);if(Di(a.Length())){let f=this.mesh.AddNormal(a);h.SetNormals(f,f,f)}this.mesh.AddTriangle(h)}}};var rl=class extends Jt{constructor(){super()}CanImportExtension(e){return e==="bim"}GetUpDirection(){return _t.Z}ClearContent(){this.meshIdToMesh=null,this.colorToMaterial=null}ResetContent(){this.meshIdToMesh=new Map,this.colorToMaterial=new di(this.model)}ImportContent(e,t){this.model.SetUnit(_s.Meter);let n=Sn(e),i=null;try{i=JSON.parse(n)}catch{this.SetError(nt("Failed to parse bim file.")),t();return}for(let s of i.meshes)this.meshIdToMesh.set(s.mesh_id,s);this.ImportProperties(i,this.model);for(let s of i.elements){let o=this.ImportElement(s);o.SetName(s.type),this.ImportProperties(s,o)}t()}ImportElement(e){let t=null;e.color&&(t=this.colorToMaterial.GetMaterialIndex(e.color.r,e.color.g,e.color.b,e.color.a));let n=this.model.GetRootNode(),i=this.meshIdToMesh.get(e.mesh_id),s=this.ImportMesh(i,f=>e.face_colors?this.colorToMaterial.GetMaterialIndex(e.face_colors[f*4+0],e.face_colors[f*4+1],e.face_colors[f*4+2],e.face_colors[f*4+3]):t),o=this.model.AddMesh(s),a=new Bn;a.AddMeshIndex(o);let l=new Ye(0,0,0);e.vector&&(l=new Ye(e.vector.x,e.vector.y,e.vector.z));let c=new ii(0,0,0,1);e.rotation&&(c=new ii(e.rotation.qx,e.rotation.qy,e.rotation.qz,e.rotation.qw));let u=new Ye(1,1,1),h=new xn().ComposeTRS(l,c,u);return a.SetTransformation(new pn(h)),n.AddChildNode(a),s}ImportMesh(e,t){let n=new tn;for(let i=0;i<e.coordinates.length;i+=3)n.AddVertex(new Ye(e.coordinates[i+0],e.coordinates[i+1],e.coordinates[i+2]));for(let i=0;i<e.indices.length;i+=3){let s=new Qt(e.indices[i+0],e.indices[i+1],e.indices[i+2]);s.SetMaterial(t(i/3)),n.AddTriangle(s)}return n}ImportProperties(e,t){function n(o,a,l){if(l==null)return;let c=new cn(Yt.Text,a,l);o.AddProperty(c)}if(!e.info||cu(e.info))return;let i=e.info,s=new Kn(nt("Info"));n(s,nt("Guid"),e.guid),n(s,nt("Type"),e.type);for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&typeof i[o]=="string"&&n(s,o,i[o]);t.AddPropertyGroup(s)}};var Fs=class extends Tc{constructor(e){super(e)}parse(e){function t(Y){switch(Y.image_type){case f:case y:if(Y.colormap_length>256||Y.colormap_size!==24||Y.colormap_type!==1)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case p:case g:case d:case m:if(Y.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+Y.image_type)}if(Y.width<=0||Y.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(Y.pixel_size!==8&&Y.pixel_size!==16&&Y.pixel_size!==24&&Y.pixel_size!==32)throw new Error("THREE.TGALoader: Invalid pixel size "+Y.pixel_size)}function n(Y,te,q,le,ye){let Te,Ae,_e=q.pixel_size>>3,G=q.width*q.height*_e;if(te&&(Ae=ye.subarray(le,le+=q.colormap_length*(q.colormap_size>>3))),Y){Te=new Uint8Array(G);let P,M,T,k=0,j=new Uint8Array(_e);for(;k<G;)if(P=ye[le++],M=(P&127)+1,P&128){for(T=0;T<_e;++T)j[T]=ye[le++];for(T=0;T<M;++T)Te.set(j,k+T*_e);k+=_e*M}else{for(M*=_e,T=0;T<M;++T)Te[k+T]=ye[le++];k+=M}}else Te=ye.subarray(le,le+=te?q.width*q.height:G);return{pixel_data:Te,palettes:Ae}}function i(Y,te,q,le,ye,Te,Ae,_e,G){let P=G,M,T=0,k,j,W=b.width;for(j=te;j!==le;j+=q)for(k=ye;k!==Ae;k+=Te,T++)M=_e[T],Y[(k+W*j)*4+3]=255,Y[(k+W*j)*4+2]=P[M*3+0],Y[(k+W*j)*4+1]=P[M*3+1],Y[(k+W*j)*4+0]=P[M*3+2];return Y}function s(Y,te,q,le,ye,Te,Ae,_e){let G,P=0,M,T,k=b.width;for(T=te;T!==le;T+=q)for(M=ye;M!==Ae;M+=Te,P+=2)G=_e[P+0]+(_e[P+1]<<8),Y[(M+k*T)*4+0]=(G&31744)>>7,Y[(M+k*T)*4+1]=(G&992)>>2,Y[(M+k*T)*4+2]=(G&31)<<3,Y[(M+k*T)*4+3]=G&32768?0:255;return Y}function o(Y,te,q,le,ye,Te,Ae,_e){let G=0,P,M,T=b.width;for(M=te;M!==le;M+=q)for(P=ye;P!==Ae;P+=Te,G+=3)Y[(P+T*M)*4+3]=255,Y[(P+T*M)*4+2]=_e[G+0],Y[(P+T*M)*4+1]=_e[G+1],Y[(P+T*M)*4+0]=_e[G+2];return Y}function a(Y,te,q,le,ye,Te,Ae,_e){let G=0,P,M,T=b.width;for(M=te;M!==le;M+=q)for(P=ye;P!==Ae;P+=Te,G+=4)Y[(P+T*M)*4+2]=_e[G+0],Y[(P+T*M)*4+1]=_e[G+1],Y[(P+T*M)*4+0]=_e[G+2],Y[(P+T*M)*4+3]=_e[G+3];return Y}function l(Y,te,q,le,ye,Te,Ae,_e){let G,P=0,M,T,k=b.width;for(T=te;T!==le;T+=q)for(M=ye;M!==Ae;M+=Te,P++)G=_e[P],Y[(M+k*T)*4+0]=G,Y[(M+k*T)*4+1]=G,Y[(M+k*T)*4+2]=G,Y[(M+k*T)*4+3]=255;return Y}function c(Y,te,q,le,ye,Te,Ae,_e){let G=0,P,M,T=b.width;for(M=te;M!==le;M+=q)for(P=ye;P!==Ae;P+=Te,G+=2)Y[(P+T*M)*4+0]=_e[G+0],Y[(P+T*M)*4+1]=_e[G+0],Y[(P+T*M)*4+2]=_e[G+0],Y[(P+T*M)*4+3]=_e[G+1];return Y}function u(Y,te,q,le,ye){let Te,Ae,_e,G,P,M;switch((b.flags&_)>>v){default:case I:Te=0,_e=1,P=te,Ae=0,G=1,M=q;break;case x:Te=0,_e=1,P=te,Ae=q-1,G=-1,M=-1;break;case A:Te=te-1,_e=-1,P=-1,Ae=0,G=1,M=q;break;case S:Te=te-1,_e=-1,P=-1,Ae=q-1,G=-1,M=-1;break}if(B)switch(b.pixel_size){case 8:l(Y,Ae,G,M,Te,_e,P,le);break;case 16:c(Y,Ae,G,M,Te,_e,P,le);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(b.pixel_size){case 8:i(Y,Ae,G,M,Te,_e,P,le,ye);break;case 16:s(Y,Ae,G,M,Te,_e,P,le);break;case 24:o(Y,Ae,G,M,Te,_e,P,le);break;case 32:a(Y,Ae,G,M,Te,_e,P,le);break;default:throw new Error("THREE.TGALoader: Format not supported.")}return Y}let h=0,f=1,p=2,g=3,y=9,d=10,m=11,_=48,v=4,x=0,S=1,I=2,A=3;if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let C=0,E=new Uint8Array(e),b={id_length:E[C++],colormap_type:E[C++],image_type:E[C++],colormap_index:E[C++]|E[C++]<<8,colormap_length:E[C++]|E[C++]<<8,colormap_size:E[C++],origin:[E[C++]|E[C++]<<8,E[C++]|E[C++]<<8],width:E[C++]|E[C++]<<8,height:E[C++]|E[C++]<<8,pixel_size:E[C++],flags:E[C++]};if(t(b),b.id_length+C>e.length)throw new Error("THREE.TGALoader: No data.");C+=b.id_length;let R=!1,N=!1,B=!1;switch(b.image_type){case y:R=!0,N=!0;break;case f:N=!0;break;case d:R=!0;break;case p:break;case m:R=!0,B=!0;break;case g:B=!0;break}let V=new Uint8Array(b.width*b.height*4),ie=n(R,N,b,C,E);return u(V,b.width,b.height,ie.pixel_data,ie.palettes),{data:V,width:b.width,height:b.height,flipY:!0,generateMipmaps:!0,minFilter:xi}}};var Ni=Uint8Array,sl=Uint16Array,Hb=Int32Array,By=new Ni([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Gy=new Ni([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Wb=new Ni([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vy=function(r,e){for(var t=new sl(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new Hb(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)i[s]=s-t[n]<<5|n;return{b:t,r:i}},zy=Vy(By,2),Hy=zy.b,Xb=zy.r;Hy[28]=258,Xb[258]=28;var Wy=Vy(Gy,0),qb=Wy.b,gL=Wy.r,cm=new sl(32768);for(Ht=0;Ht<32768;++Ht)fs=(Ht&43690)>>1|(Ht&21845)<<1,fs=(fs&52428)>>2|(fs&13107)<<2,fs=(fs&61680)>>4|(fs&3855)<<4,cm[Ht]=((fs&65280)>>8|(fs&255)<<8)>>1;var fs,Ht,kc=function(r,e,t){for(var n=r.length,i=0,s=new sl(e);i<n;++i)r[i]&&++s[r[i]-1];var o=new sl(e);for(i=1;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(t){a=new sl(1<<e);var l=15-e;for(i=0;i<n;++i)if(r[i])for(var c=i<<4|r[i],u=e-r[i],h=o[r[i]-1]++<<u,f=h|(1<<u)-1;h<=f;++h)a[cm[h]>>l]=c}else for(a=new sl(n),i=0;i<n;++i)r[i]&&(a[i]=cm[o[r[i]-1]++]>>15-r[i]);return a},Bc=new Ni(288);for(Ht=0;Ht<144;++Ht)Bc[Ht]=8;var Ht;for(Ht=144;Ht<256;++Ht)Bc[Ht]=9;var Ht;for(Ht=256;Ht<280;++Ht)Bc[Ht]=7;var Ht;for(Ht=280;Ht<288;++Ht)Bc[Ht]=8;var Ht,Xy=new Ni(32);for(Ht=0;Ht<32;++Ht)Xy[Ht]=5;var Ht;var jb=kc(Bc,9,1);var Yb=kc(Xy,5,1),om=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},fr=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},am=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},Kb=function(r){return(r+7)/8|0},hm=function(r,e,t){return(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new Ni(r.subarray(e,t))};var Zb=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ti=function(r,e,t){var n=new Error(e||Zb[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,Ti),!t)throw n;return n},qy=function(r,e,t,n){var i=r.length,s=n?n.length:0;if(!i||e.f&&!e.l)return t||new Ni(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new Ni(i*3));var c=function(re){var ce=t.length;if(re>ce){var me=new Ni(Math.max(ce*2,re));me.set(t),t=me}},u=e.f||0,h=e.p||0,f=e.b||0,p=e.l,g=e.d,y=e.m,d=e.n,m=i*8;do{if(!p){u=fr(r,h,1);var _=fr(r,h+1,3);if(h+=3,_)if(_==1)p=jb,g=Yb,y=9,d=5;else if(_==2){var I=fr(r,h,31)+257,A=fr(r,h+10,15)+4,C=I+fr(r,h+5,31)+1;h+=14;for(var E=new Ni(C),b=new Ni(19),R=0;R<A;++R)b[Wb[R]]=fr(r,h+R*3,7);h+=A*3;for(var N=om(b),B=(1<<N)-1,V=kc(b,N,1),R=0;R<C;){var ie=V[fr(r,h,B)];h+=ie&15;var v=ie>>4;if(v<16)E[R++]=v;else{var Y=0,te=0;for(v==16?(te=3+fr(r,h,3),h+=2,Y=E[R-1]):v==17?(te=3+fr(r,h,7),h+=3):v==18&&(te=11+fr(r,h,127),h+=7);te--;)E[R++]=Y}}var q=E.subarray(0,I),le=E.subarray(I);y=om(q),d=om(le),p=kc(q,y,1),g=kc(le,d,1)}else Ti(1);else{var v=Kb(h)+4,x=r[v-4]|r[v-3]<<8,S=v+x;if(S>i){l&&Ti(0);break}a&&c(f+x),t.set(r.subarray(v,S),f),e.b=f+=x,e.p=h=S*8,e.f=u;continue}if(h>m){l&&Ti(0);break}}a&&c(f+131072);for(var ye=(1<<y)-1,Te=(1<<d)-1,Ae=h;;Ae=h){var Y=p[am(r,h)&ye],_e=Y>>4;if(h+=Y&15,h>m){l&&Ti(0);break}if(Y||Ti(2),_e<256)t[f++]=_e;else if(_e==256){Ae=h,p=null;break}else{var G=_e-254;if(_e>264){var R=_e-257,P=By[R];G=fr(r,h,(1<<P)-1)+Hy[R],h+=P}var M=g[am(r,h)&Te],T=M>>4;M||Ti(3),h+=M&15;var le=qb[T];if(T>3){var P=Gy[T];le+=am(r,h)&(1<<P)-1,h+=P}if(h>m){l&&Ti(0);break}a&&c(f+131072);var k=f+G;if(f<le){var j=s-le,W=Math.min(le,k);for(j+f<0&&Ti(3);f<W;++f)t[f]=n[j+f]}for(;f<k;++f)t[f]=t[f-le]}}e.l=p,e.p=Ae,e.b=f,e.f=u,p&&(u=1,e.m=y,e.d=g,e.n=d)}while(!u);return f!=t.length&&o?hm(t,0,f):t.subarray(0,f)};var Jb=new Ni(0);var Pr=function(r,e){return r[e]|r[e+1]<<8},dr=function(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0},lm=function(r,e){return dr(r,e)+dr(r,e+4)*4294967296};var $b=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&Ti(6,"invalid zlib data"),(r[1]>>5&1)==+!e&&Ti(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function Qb(r,e){return qy(r,{i:2},e&&e.out,e&&e.dictionary)}function jy(r,e){return qy(r.subarray($b(r,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary)}var um=typeof TextDecoder<"u"&&new TextDecoder,eS=0;try{um.decode(Jb,{stream:!0}),eS=1}catch{}var tS=function(r){for(var e="",t=0;;){var n=r[t++],i=(n>127)+(n>223)+(n>239);if(t+i>r.length)return{s:e,r:hm(r,t-1)};i?i==3?(n=((n&15)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|r[t++]&63):e+=String.fromCharCode((n&15)<<12|(r[t++]&63)<<6|r[t++]&63):e+=String.fromCharCode(n)}};function nS(r,e){if(e){for(var t="",n=0;n<r.length;n+=16384)t+=String.fromCharCode.apply(null,r.subarray(n,n+16384));return t}else{if(um)return um.decode(r);var i=tS(r),s=i.s,t=i.r;return t.length&&Ti(8),s}}var iS=function(r,e){return e+30+Pr(r,e+26)+Pr(r,e+28)},rS=function(r,e,t){var n=Pr(r,e+28),i=nS(r.subarray(e+46,e+46+n),!(Pr(r,e+8)&2048)),s=e+46+n,o=dr(r,e+20),a=t&&o==4294967295?sS(r,s):[o,dr(r,e+24),dr(r,e+42)],l=a[0],c=a[1],u=a[2];return[Pr(r,e+10),l,c,i,s+Pr(r,e+30)+Pr(r,e+32),u]},sS=function(r,e){for(;Pr(r,e)!=1;e+=4+Pr(r,e+2));return[lm(r,e+12),lm(r,e+4),lm(r,e+20)]};function Ff(r,e){for(var t={},n=r.length-22;dr(r,n)!=101010256;--n)(!n||r.length-n>65558)&&Ti(13);var i=Pr(r,n+8);if(!i)return{};var s=dr(r,n+16),o=s==4294967295||i==65535;if(o){var a=dr(r,n-12);o=dr(r,a)==101075792,o&&(i=dr(r,a+32),s=dr(r,a+48))}for(var l=e&&e.filter,c=0;c<i;++c){var u=rS(r,s,o),h=u[0],f=u[1],p=u[2],g=u[3],y=u[4],d=u[5],m=iS(r,d);s=y,(!l||l({name:g,size:f,originalSize:p,compression:h}))&&(h?h==8?t[g]=Qb(r.subarray(m,m+f),{out:new Ni(p)}):Ti(14,"unknown compression type "+h):t[g]=hm(r,m,m+f))}return t}function Yy(r,e,t){let n=t.length-r-1;if(e>=t[n])return n-1;if(e<=t[r])return r;let i=r,s=n,o=Math.floor((i+s)/2);for(;e<t[o]||e>=t[o+1];)e<t[o]?s=o:i=o,o=Math.floor((i+s)/2);return o}function oS(r,e,t,n){let i=[],s=[],o=[];i[0]=1;for(let a=1;a<=t;++a){s[a]=e-n[r+1-a],o[a]=n[r+a]-e;let l=0;for(let c=0;c<a;++c){let u=o[c+1],h=s[a-c],f=i[c]/(u+h);i[c]=l+u*f,l=h*f}i[a]=l}return i}function Ky(r,e,t,n){let i=Yy(r,n,e),s=oS(i,n,r,e),o=new wt(0,0,0,0);for(let a=0;a<=r;++a){let l=t[i-r+a],c=s[a],u=l.w*c;o.x+=l.x*u,o.y+=l.y*u,o.z+=l.z*u,o.w+=l.w*c}return o}function aS(r,e,t,n,i){let s=[];for(let h=0;h<=t;++h)s[h]=0;let o=[];for(let h=0;h<=n;++h)o[h]=s.slice(0);let a=[];for(let h=0;h<=t;++h)a[h]=s.slice(0);a[0][0]=1;let l=s.slice(0),c=s.slice(0);for(let h=1;h<=t;++h){l[h]=e-i[r+1-h],c[h]=i[r+h]-e;let f=0;for(let p=0;p<h;++p){let g=c[p+1],y=l[h-p];a[h][p]=g+y;let d=a[p][h-1]/a[h][p];a[p][h]=f+g*d,f=y*d}a[h][h]=f}for(let h=0;h<=t;++h)o[0][h]=a[h][t];for(let h=0;h<=t;++h){let f=0,p=1,g=[];for(let y=0;y<=t;++y)g[y]=s.slice(0);g[0][0]=1;for(let y=1;y<=n;++y){let d=0,m=h-y,_=t-y;h>=y&&(g[p][0]=g[f][0]/a[_+1][m],d=g[p][0]*a[m][_]);let v=m>=-1?1:-m,x=h-1<=_?y-1:t-h;for(let I=v;I<=x;++I)g[p][I]=(g[f][I]-g[f][I-1])/a[_+1][m+I],d+=g[p][I]*a[m+I][_];h<=_&&(g[p][y]=-g[f][y-1]/a[_+1][h],d+=g[p][y]*a[h][_]),o[y][h]=d;let S=f;f=p,p=S}}let u=t;for(let h=1;h<=n;++h){for(let f=0;f<=t;++f)o[h][f]*=u;u*=t-h}return o}function lS(r,e,t,n,i){let s=i<r?i:r,o=[],a=Yy(r,n,e),l=aS(a,n,r,s,e),c=[];for(let u=0;u<t.length;++u){let h=t[u].clone(),f=h.w;h.x*=f,h.y*=f,h.z*=f,c[u]=h}for(let u=0;u<=s;++u){let h=c[a-r].clone().multiplyScalar(l[u][0]);for(let f=1;f<=r;++f)h.add(c[a-r+f].clone().multiplyScalar(l[u][f]));o[u]=h}for(let u=s+1;u<=i+1;++u)o[u]=new wt(0,0,0);return o}function cS(r,e){let t=1;for(let i=2;i<=r;++i)t*=i;let n=1;for(let i=2;i<=e;++i)n*=i;for(let i=2;i<=r-e;++i)n*=i;return t/n}function uS(r){let e=r.length,t=[],n=[];for(let s=0;s<e;++s){let o=r[s];t[s]=new se(o.x,o.y,o.z),n[s]=o.w}let i=[];for(let s=0;s<e;++s){let o=t[s].clone();for(let a=1;a<=s;++a)o.sub(i[s-a].clone().multiplyScalar(cS(s,a)*n[a]));i[s]=o.divideScalar(n[0])}return i}function Zy(r,e,t,n,i){let s=lS(r,e,t,n,i);return uS(s)}var Uf=class extends si{constructor(e,t,n,i,s){super();let o=t?t.length-1:0,a=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=s||o;for(let l=0;l<a;++l){let c=n[l];this.controlPoints[l]=new wt(c.x,c.y,c.z,c.w)}}getPoint(e,t=new se){let n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=Ky(this.degree,this.knots,this.controlPoints,i);return s.w!==1&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(e,t=new se){let n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=Zy(this.degree,this.knots,this.controlPoints,i,1);return n.copy(s[1]).normalize(),n}toJSON(){let e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(t=>t.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(t=>new wt(t[0],t[1],t[2],t[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}};var Rt,Tn,ai,Bf=class extends zt{constructor(e){super(e)}load(e,t,n,i){let s=this,o=s.path===""?os.extractUrlBase(e):s.path,a=new $n(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(l){try{t(s.parse(l,o))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){if(fS(e))Rt=new vm().parse(e);else{let i=Qy(e);if(!dS(i))throw new Error("THREE.FBXLoader: Unknown format.");if(Jy(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Jy(i));Rt=new xm().parse(i)}let n=new Ri(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new mm(n,this.manager).parse(Rt)}},mm=class{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Tn=this.parseConnections();let e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),s=new gm().parse(i);return this.parseScene(i,s,n),ai}parseConnections(){let e=new Map;return"Connections"in Rt&&Rt.Connections.connections.forEach(function(n){let i=n[0],s=n[1],o=n[2];e.has(i)||e.set(i,{parents:[],children:[]});let a={ID:s,relationship:o};e.get(i).parents.push(a),e.has(s)||e.set(s,{parents:[],children:[]});let l={ID:i,relationship:o};e.get(s).children.push(l)}),e}parseImages(){let e={},t={};if("Video"in Rt.Objects){let n=Rt.Objects.Video;for(let i in n){let s=n[i],o=parseInt(i);if(e[o]=s.RelativeFilename||s.Filename,"Content"in s){let a=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,l=typeof s.Content=="string"&&s.Content!=="";if(a||l){let c=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=c}}}}for(let n in e){let i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){let t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase(),s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{let o=new Uint8Array(t);return window.URL.createObjectURL(new Blob([o],{type:s}))}}parseTextures(e){let t=new Map;if("Texture"in Rt.Objects){let n=Rt.Objects.Texture;for(let i in n){let s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){let n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;let i=e.WrapModeU,s=e.WrapModeV,o=i!==void 0?i.value:0,a=s!==void 0?s.value:0;if(n.wrapS=o===0?on:un,n.wrapT=a===0?on:un,"Scaling"in e){let l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}if("Translation"in e){let l=e.Translation.value;n.offset.x=l[0],n.offset.y=l[1]}return n}loadTexture(e,t){let n=new Set(["tga","tif","tiff","exr","dds","hdr","ktx2"]),i=e.FileName.split(".").pop().toLowerCase(),s=n.has(i)?this.manager.getHandler(`.${i}`):this.textureLoader;if(!s)return console.warn(`FBXLoader: ${i.toUpperCase()} loader not found, creating placeholder texture for`,e.RelativeFilename),new qn;let o=s.path;o||s.setPath(this.textureLoader.path);let a=Tn.get(e.id).children,l;a!==void 0&&a.length>0&&t[a[0].ID]!==void 0&&(l=t[a[0].ID],(l.indexOf("blob:")===0||l.indexOf("data:")===0)&&s.setPath(void 0));let c=s.load(l);return s.setPath(o),c}parseMaterials(e){let t=new Map;if("Material"in Rt.Objects){let n=Rt.Objects.Material;for(let i in n){let s=this.parseMaterial(n[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){let n=e.id,i=e.attrName,s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!Tn.has(n))return null;let o=this.parseParameters(e,t,n),a;switch(s.toLowerCase()){case"phong":a=new Zt;break;case"lambert":a=new go;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new Zt;break}return a.setValues(o),a.name=i,a}parseParameters(e,t,n){let i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=mt.toWorkingColorSpace(new He().fromArray(e.Diffuse.value),yt):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=mt.toWorkingColorSpace(new He().fromArray(e.DiffuseColor.value),yt)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=mt.toWorkingColorSpace(new He().fromArray(e.Emissive.value),yt):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=mt.toWorkingColorSpace(new He().fromArray(e.EmissiveColor.value),yt)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),i.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),(i.opacity===1||i.opacity===0)&&(i.opacity=e.Opacity?parseFloat(e.Opacity.value):null,i.opacity===null&&(i.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=mt.toWorkingColorSpace(new He().fromArray(e.Specular.value),yt):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=mt.toWorkingColorSpace(new He().fromArray(e.SpecularColor.value),yt));let s=this;return Tn.get(n).children.forEach(function(o){let a=o.relationship;switch(a){case"Bump":i.bumpMap=s.getTexture(t,o.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,o.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,o.ID),i.map!==void 0&&(i.map.colorSpace=yt);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,o.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,o.ID),i.emissiveMap!==void 0&&(i.emissiveMap.colorSpace=yt);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,o.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,o.ID),i.envMap!==void 0&&(i.envMap.mapping=Ua,i.envMap.colorSpace=yt);break;case"SpecularColor":i.specularMap=s.getTexture(t,o.ID),i.specularMap!==void 0&&(i.specularMap.colorSpace=yt);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,o.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",a);break}}),i}getTexture(e,t){return"LayeredTexture"in Rt.Objects&&t in Rt.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Tn.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if("Deformer"in Rt.Objects){let n=Rt.Objects.Deformer;for(let i in n){let s=n[i],o=Tn.get(parseInt(i));if(s.attrType==="Skin"){let a=this.parseSkeleton(o,n);a.ID=i,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=o.parents[0].ID,e[i]=a}else if(s.attrType==="BlendShape"){let a={id:i};a.rawTargets=this.parseMorphTargets(o,n),a.id=i,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=a}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){let n=[];return e.children.forEach(function(i){let s=t[i.ID];if(s.attrType!=="Cluster")return;let o={ID:i.ID,indices:[],weights:[],transformLink:new Je().fromArray(s.TransformLink.a)};"Indexes"in s&&(o.indices=s.Indexes.a,o.weights=s.Weights.a),n.push(o)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){let n=[];for(let i=0;i<e.children.length;i++){let s=e.children[i],o=t[s.ID],a={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if(o.attrType!=="BlendShapeChannel")return;a.geoID=Tn.get(parseInt(s.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(a)}return n}parseScene(e,t,n){ai=new gn;let i=this.parseModels(e.skeletons,t,n),s=Rt.Objects.Model,o=this;i.forEach(function(l){let c=s[l.ID];o.setLookAtProperties(l,c),Tn.get(l.ID).parents.forEach(function(h){let f=i.get(h.ID);f!==void 0&&f.add(l)}),l.parent===null&&ai.add(l)}),this.bindSkeleton(e.skeletons,t,i),this.addGlobalSceneSettings(),ai.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);let c=$y(l.userData.transformData);l.applyMatrix4(c),l.updateWorldMatrix()}});let a=new ym().parse();ai.children.length===1&&ai.children[0].isGroup&&(ai.children[0].animations=a,ai=ai.children[0]),ai.animations=a}parseModels(e,t,n){let i=new Map,s=Rt.Objects.Model;for(let o in s){let a=parseInt(o),l=s[o],c=Tn.get(a),u=this.buildSkeleton(c,e,a,l.attrName);if(!u){switch(l.attrType){case"Camera":u=this.createCamera(c);break;case"Light":u=this.createLight(c);break;case"Mesh":u=this.createMesh(c,t,n);break;case"NurbsCurve":u=this.createCurve(c,t);break;case"LimbNode":case"Root":u=new es;break;case"Null":default:u=new gn;break}u.name=l.attrName?qt.sanitizeNodeName(l.attrName):"",u.userData.originalName=l.attrName,u.ID=a}this.getTransformData(u,l),i.set(a,u)}return i}buildSkeleton(e,t,n,i){let s=null;return e.parents.forEach(function(o){for(let a in t){let l=t[a];l.rawBones.forEach(function(c,u){if(c.ID===o.ID){let h=s;s=new es,s.matrixWorld.copy(c.transformLink),s.name=i?qt.sanitizeNodeName(i):"",s.userData.originalName=i,s.ID=n,l.bones[u]=s,h!==null&&s.add(h)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(i){let s=Rt.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)t=new Lt;else{let i=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(i=1);let s=1;n.NearPlane!==void 0&&(s=n.NearPlane.value/1e3);let o=1e3;n.FarPlane!==void 0&&(o=n.FarPlane.value/1e3);let a=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,l=n.AspectHeight.value);let c=a/l,u=45;n.FieldOfView!==void 0&&(u=n.FieldOfView.value);let h=n.FocalLength?n.FocalLength.value:null;switch(i){case 0:t=new nn(u,c,s,o),h!==null&&t.setFocalLength(h);break;case 1:console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."),t=new Lt;break;default:console.warn("THREE.FBXLoader: Unknown camera type "+i+"."),t=new Lt;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(i){let s=Rt.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)t=new Lt;else{let i;n.LightType===void 0?i=0:i=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=mt.toWorkingColorSpace(new He().fromArray(n.Color.value),yt));let o=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(o=0);let a=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?a=0:a=n.FarAttenuationEnd.value);let l=1;switch(i){case 0:t=new Ns(s,o,a,l);break;case 1:t=new sr(s,o);break;case 2:let c=Math.PI/3;n.InnerAngle!==void 0&&(c=yn.degToRad(n.InnerAngle.value));let u=0;n.OuterAngle!==void 0&&(u=yn.degToRad(n.OuterAngle.value),u=Math.max(u,1)),t=new vo(s,o,a,c,u,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Ns(s,o);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,s=null,o=null,a=[];if(e.children.forEach(function(l){t.has(l.ID)&&(s=t.get(l.ID)),n.has(l.ID)&&a.push(n.get(l.ID))}),a.length>1?o=a:a.length>0?o=a[0]:(o=new Zt({name:zt.DEFAULT_MATERIAL_NAME,color:13421772}),a.push(o)),"color"in s.attributes&&a.forEach(function(l){l.vertexColors=!0}),s.groups.length>0){let l=!1;for(let c=0,u=s.groups.length;c<u;c++){let h=s.groups[c];(h.materialIndex<0||h.materialIndex>=a.length)&&(h.materialIndex=a.length,l=!0)}if(l){let c=new Zt;a.push(c)}}return s.FBX_Deformer?(i=new co(s,o),i.normalizeSkinWeights()):i=new Dt(s,o),i}createCurve(e,t){let n=e.children.reduce(function(s,o){return t.has(o.ID)&&(s=t.get(o.ID)),s},null),i=new jn({name:zt.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Rs(n,i)}getTransformData(e,t){let n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Gc(t.RotationOrder.value):n.eulerOrder=Gc(0),"Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&Tn.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){let s=Rt.Objects.Model[i.ID];if("Lcl_Translation"in s){let o=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),ai.add(e.target)):e.lookAt(new se().fromArray(o))}}})}bindSkeleton(e,t,n){let i=this.parsePoseNodes();for(let s in e){let o=e[s];Tn.get(parseInt(o.ID)).parents.forEach(function(l){if(t.has(l.ID)){let c=l.ID;Tn.get(c).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new ho(o.bones),i[h.ID])})}})}}parsePoseNodes(){let e={};if("Pose"in Rt.Objects){let t=Rt.Objects.Pose;for(let n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){let i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new Je().fromArray(s.Matrix.a)}):e[i.Node]=new Je().fromArray(i.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in Rt){if("AmbientColor"in Rt.GlobalSettings){let e=Rt.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){let s=new He().setRGB(t,n,i,yt);ai.add(new or(s,1))}}"UnitScaleFactor"in Rt.GlobalSettings&&(ai.userData.unitScaleFactor=Rt.GlobalSettings.UnitScaleFactor.value)}}},gm=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if("Geometry"in Rt.Objects){let n=Rt.Objects.Geometry;for(let i in n){let s=Tn.get(parseInt(i)),o=this.parseGeometry(s,n[i],e);t.set(parseInt(i),o)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){let i=n.skeletons,s=[],o=e.parents.map(function(h){return Rt.Objects.Model[h.ID]});if(o.length===0)return;let a=e.children.reduce(function(h,f){return i[f.ID]!==void 0&&(h=i[f.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&s.push(n.morphTargets[h.ID])});let l=o[0],c={};"RotationOrder"in l&&(c.eulerOrder=Gc(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);let u=$y(c);return this.genGeometry(t,a,s,u)}genGeometry(e,t,n,i){let s=new It;e.attrName&&(s.name=e.attrName);let o=this.parseGeoNode(e,t),a=this.genBuffers(o),l=new We(a.vertex,3);if(l.applyMatrix4(i),s.setAttribute("position",l),a.colors.length>0&&s.setAttribute("color",new We(a.colors,3)),t&&(s.setAttribute("skinIndex",new lo(a.weightsIndices,4)),s.setAttribute("skinWeight",new We(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){let c=new gt().getNormalMatrix(i),u=new We(a.normal,3);u.applyNormalMatrix(c),s.setAttribute("normal",u)}if(a.uvs.forEach(function(c,u){let h=u===0?"uv":`uv${u}`;s.setAttribute(h,new We(a.uvs[u],2))}),o.material&&o.material.mappingType!=="AllSame"){let c=a.materialIndex[0],u=0;if(a.materialIndex.forEach(function(h,f){h!==c&&(s.addGroup(u,f-u,c),c=h,u=f)}),s.groups.length>0){let h=s.groups[s.groups.length-1],f=h.start+h.count;f!==a.materialIndex.length&&s.addGroup(f,a.materialIndex.length-f,c)}s.groups.length===0&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){let n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(o,a){n.weightTable[o]===void 0&&(n.weightTable[o]=[]),n.weightTable[o].push({id:s,weight:i.weights[a]})})})),n}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,i=0,s=!1,o=[],a=[],l=[],c=[],u=[],h=[],f=this;return e.vertexIndices.forEach(function(p,g){let y,d=!1;p<0&&(p=p^-1,d=!0);let m=[],_=[];if(o.push(p*3,p*3+1,p*3+2),e.color){let v=kf(g,n,p,e.color);l.push(v[0],v[1],v[2])}if(e.skeleton){if(e.weightTable[p]!==void 0&&e.weightTable[p].forEach(function(v){_.push(v.weight),m.push(v.id)}),_.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);let v=[0,0,0,0],x=[0,0,0,0];_.forEach(function(S,I){let A=S,C=m[I];x.forEach(function(E,b,R){if(A>E){R[b]=A,A=E;let N=v[b];v[b]=C,C=N}})}),m=v,_=x}for(;_.length<4;)_.push(0),m.push(0);for(let v=0;v<4;++v)u.push(_[v]),h.push(m[v])}if(e.normal){let v=kf(g,n,p,e.normal);a.push(v[0],v[1],v[2])}e.material&&e.material.mappingType!=="AllSame"&&(y=kf(g,n,p,e.material)[0],y<0&&(f.negativeMaterialIndices=!0,y=0)),e.uv&&e.uv.forEach(function(v,x){let S=kf(g,n,p,v);c[x]===void 0&&(c[x]=[]),c[x].push(S[0]),c[x].push(S[1])}),i++,d&&(f.genFace(t,e,o,y,a,l,c,u,h,i),n++,i=0,o=[],a=[],l=[],c=[],u=[],h=[])}),t}getNormalNewell(e){let t=new se(0,0,0);for(let n=0;n<e.length;n++){let i=e[n],s=e[(n+1)%e.length];t.x+=(i.y-s.y)*(i.z+s.z),t.y+=(i.z-s.z)*(i.x+s.x),t.z+=(i.x-s.x)*(i.y+s.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){let t=this.getNormalNewell(e),i=(Math.abs(t.z)>.5?new se(0,1,0):new se(0,0,1)).cross(t).normalize(),s=t.clone().cross(i).normalize();return{normal:t,tangent:i,bitangent:s}}flattenVertex(e,t,n){return new Pe(e.dot(t),e.dot(n))}genFace(e,t,n,i,s,o,a,l,c,u){let h;if(u>3){let f=[],p=t.baseVertexPositions||t.vertexPositions;for(let m=0;m<n.length;m+=3)f.push(new se(p[n[m]],p[n[m+1]],p[n[m+2]]));let{tangent:g,bitangent:y}=this.getNormalTangentAndBitangent(f),d=[];for(let m of f)d.push(this.flattenVertex(m,g,y));h=gi.triangulateShape(d,[])}else h=[[0,1,2]];for(let[f,p,g]of h)e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),e.vertex.push(t.vertexPositions[n[p*3]]),e.vertex.push(t.vertexPositions[n[p*3+1]]),e.vertex.push(t.vertexPositions[n[p*3+2]]),e.vertex.push(t.vertexPositions[n[g*3]]),e.vertex.push(t.vertexPositions[n[g*3+1]]),e.vertex.push(t.vertexPositions[n[g*3+2]]),t.skeleton&&(e.vertexWeights.push(l[f*4]),e.vertexWeights.push(l[f*4+1]),e.vertexWeights.push(l[f*4+2]),e.vertexWeights.push(l[f*4+3]),e.vertexWeights.push(l[p*4]),e.vertexWeights.push(l[p*4+1]),e.vertexWeights.push(l[p*4+2]),e.vertexWeights.push(l[p*4+3]),e.vertexWeights.push(l[g*4]),e.vertexWeights.push(l[g*4+1]),e.vertexWeights.push(l[g*4+2]),e.vertexWeights.push(l[g*4+3]),e.weightsIndices.push(c[f*4]),e.weightsIndices.push(c[f*4+1]),e.weightsIndices.push(c[f*4+2]),e.weightsIndices.push(c[f*4+3]),e.weightsIndices.push(c[p*4]),e.weightsIndices.push(c[p*4+1]),e.weightsIndices.push(c[p*4+2]),e.weightsIndices.push(c[p*4+3]),e.weightsIndices.push(c[g*4]),e.weightsIndices.push(c[g*4+1]),e.weightsIndices.push(c[g*4+2]),e.weightsIndices.push(c[g*4+3])),t.color&&(e.colors.push(o[f*3]),e.colors.push(o[f*3+1]),e.colors.push(o[f*3+2]),e.colors.push(o[p*3]),e.colors.push(o[p*3+1]),e.colors.push(o[p*3+2]),e.colors.push(o[g*3]),e.colors.push(o[g*3+1]),e.colors.push(o[g*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(s[f*3]),e.normal.push(s[f*3+1]),e.normal.push(s[f*3+2]),e.normal.push(s[p*3]),e.normal.push(s[p*3+1]),e.normal.push(s[p*3+2]),e.normal.push(s[g*3]),e.normal.push(s[g*3+1]),e.normal.push(s[g*3+2])),t.uv&&t.uv.forEach(function(y,d){e.uvs[d]===void 0&&(e.uvs[d]=[]),e.uvs[d].push(a[d][f*2]),e.uvs[d].push(a[d][f*2+1]),e.uvs[d].push(a[d][p*2]),e.uvs[d].push(a[d][p*2+1]),e.uvs[d].push(a[d][g*2]),e.uvs[d].push(a[d][g*2+1])})}addMorphTargets(e,t,n,i){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];let s=this;n.forEach(function(o){o.rawTargets.forEach(function(a){let l=Rt.Objects.Geometry[a.geoID];l!==void 0&&s.genMorphGeometry(e,t,l,i,a.name)})})}genMorphGeometry(e,t,n,i,s){let o=t.Vertices!==void 0?t.Vertices.a:[],a=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],l=n.Vertices!==void 0?n.Vertices.a:[],c=n.Indexes!==void 0?n.Indexes.a:[],u=e.attributes.position.count*3,h=new Float32Array(u);for(let y=0;y<c.length;y++){let d=c[y]*3;h[d]=l[y*3],h[d+1]=l[y*3+1],h[d+2]=l[y*3+2]}let f={vertexIndices:a,vertexPositions:h,baseVertexPositions:o},p=this.genBuffers(f),g=new We(p.vertex,3);g.name=s||n.attrName,g.applyMatrix4(i),e.morphAttributes.position.push(g)}parseNormals(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a,s=[];return n==="IndexToDirect"&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:s,mappingType:t,referenceType:n}}parseUVs(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a,s=[];return n==="IndexToDirect"&&(s=e.UVIndex.a),{dataSize:2,buffer:i,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a,s=[];n==="IndexToDirect"&&(s=e.ColorIndex.a);for(let o=0,a=new He;o<i.length;o+=4)a.fromArray(i,o),mt.toWorkingColorSpace(a,yt),a.toArray(i,o);return{dataSize:4,buffer:i,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){let t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};let i=e.Materials.a,s=[];for(let o=0;o<i.length;++o)s.push(o);return{dataSize:1,buffer:i,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){let t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new It;let n=t-1,i=e.KnotVector.a,s=[],o=e.Points.a;for(let h=0,f=o.length;h<f;h+=4)s.push(new wt().fromArray(o,h));let a,l;if(e.Form==="Closed")s.push(s[0]);else if(e.Form==="Periodic"){a=n,l=i.length-1-a;for(let h=0;h<n;++h)s.push(s[h])}let u=new Uf(n,i,s,a,l).getPoints(s.length*12);return new It().setFromPoints(u)}},ym=class{parse(){let e=[],t=this.parseClips();if(t!==void 0)for(let n in t){let i=t[n],s=this.addClip(i);e.push(s)}return e}parseClips(){if(Rt.Objects.AnimationCurve===void 0)return;let e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);let t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){let e=Rt.Objects.AnimationCurveNode,t=new Map;for(let n in e){let i=e[n];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){let s={id:i.id,attr:i.attrName,curves:{}};t.set(s.id,s)}}return t}parseAnimationCurves(e){let t=Rt.Objects.AnimationCurve;for(let n in t){let i={id:t[n].id,times:t[n].KeyTime.a.map(pS),values:t[n].KeyValueFloat.a},s=Tn.get(i.id);if(s!==void 0){let o=s.parents[0].ID,a=s.parents[0].relationship;a.match(/X/)?e.get(o).curves.x=i:a.match(/Y/)?e.get(o).curves.y=i:a.match(/Z/)?e.get(o).curves.z=i:a.match(/DeformPercent/)&&e.has(o)&&(e.get(o).curves.morph=i)}}}parseAnimationLayers(e){let t=Rt.Objects.AnimationLayer,n=new Map;for(let i in t){let s=[],o=Tn.get(parseInt(i));o!==void 0&&(o.children.forEach(function(l,c){if(e.has(l.ID)){let u=e.get(l.ID);if(u.curves.x!==void 0||u.curves.y!==void 0||u.curves.z!==void 0){if(s[c]===void 0){let h=Tn.get(l.ID).parents.filter(function(f){return f.relationship!==void 0})[0].ID;if(h!==void 0){let f=Rt.Objects.Model[h.toString()];if(f===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}let p={modelName:f.attrName?qt.sanitizeNodeName(f.attrName):"",ID:f.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ai.traverse(function(g){g.ID===f.id&&(p.transform=g.matrix,g.userData.transformData&&(p.eulerOrder=g.userData.transformData.eulerOrder))}),p.transform||(p.transform=new Je),"PreRotation"in f&&(p.preRotation=f.PreRotation.value),"PostRotation"in f&&(p.postRotation=f.PostRotation.value),s[c]=p}}s[c]&&(s[c][u.attr]=u)}else if(u.curves.morph!==void 0){if(s[c]===void 0){let h=Tn.get(l.ID).parents.filter(function(m){return m.relationship!==void 0})[0].ID,f=Tn.get(h).parents[0].ID,p=Tn.get(f).parents[0].ID,g=Tn.get(p).parents[0].ID,y=Rt.Objects.Model[g],d={modelName:y.attrName?qt.sanitizeNodeName(y.attrName):"",morphName:Rt.Objects.Deformer[h].attrName};s[c]=d}s[c][u.attr]=u}}}),n.set(parseInt(i),s))}return n}parseAnimStacks(e){let t=Rt.Objects.AnimationStack,n={};for(let i in t){let s=Tn.get(parseInt(i)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");let o=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:o}}return n}addClip(e){let t=[],n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new Ps(e.name,-1,t)}generateTracks(e){let t=[],n=new se,i=new se;if(e.transform&&e.transform.decompose(n,new an,i),n=n.toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){let s=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");s!==void 0&&t.push(s)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){let s=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);s!==void 0&&t.push(s)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){let s=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");s!==void 0&&t.push(s)}if(e.DeformPercent!==void 0){let s=this.generateMorphTrack(e);s!==void 0&&t.push(s)}return t}generateVectorTrack(e,t,n,i){let s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,n);return new Wi(e+"."+i,s,o)}generateRotationTrack(e,t,n,i,s){let o,a;if(t.x!==void 0&&t.y!==void 0&&t.z!==void 0){let f=this.interpolateRotations(t.x,t.y,t.z,s);o=f[0],a=f[1]}let l=Gc(0);n!==void 0&&(n=n.map(yn.degToRad),n.push(l),n=new vn().fromArray(n),n=new an().setFromEuler(n)),i!==void 0&&(i=i.map(yn.degToRad),i.push(l),i=new vn().fromArray(i),i=new an().setFromEuler(i).invert());let c=new an,u=new vn,h=[];if(!a||!o)return new Hi(e+".quaternion",[0],[0]);for(let f=0;f<a.length;f+=3)u.set(a[f],a[f+1],a[f+2],s),c.setFromEuler(u),n!==void 0&&c.premultiply(n),i!==void 0&&c.multiply(i),f>2&&new an().fromArray(h,(f-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w),c.toArray(h,f/3*4);return new Hi(e+".quaternion",o,h)}generateMorphTrack(e){let t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),i=ai.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new is(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,i){return n-i}),t.length>1){let n=1,i=t[0];for(let s=1;s<t.length;s++){let o=t[s];o!==i&&(t[n]=o,i=o,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){let i=n,s=[],o=-1,a=-1,l=-1;return e.forEach(function(c){if(t.x&&(o=t.x.times.indexOf(c)),t.y&&(a=t.y.times.indexOf(c)),t.z&&(l=t.z.times.indexOf(c)),o!==-1){let u=t.x.values[o];s.push(u),i[0]=u}else s.push(i[0]);if(a!==-1){let u=t.y.values[a];s.push(u),i[1]=u}else s.push(i[1]);if(l!==-1){let u=t.z.values[l];s.push(u),i[2]=u}else s.push(i[2])}),s}interpolateRotations(e,t,n,i){let s=[],o=[];s.push(e.times[0]),o.push(yn.degToRad(e.values[0])),o.push(yn.degToRad(t.values[0])),o.push(yn.degToRad(n.values[0]));for(let a=1;a<e.values.length;a++){let l=[e.values[a-1],t.values[a-1],n.values[a-1]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;let c=l.map(yn.degToRad),u=[e.values[a],t.values[a],n.values[a]];if(isNaN(u[0])||isNaN(u[1])||isNaN(u[2]))continue;let h=u.map(yn.degToRad),f=[u[0]-l[0],u[1]-l[1],u[2]-l[2]],p=[Math.abs(f[0]),Math.abs(f[1]),Math.abs(f[2])];if(p[0]>=180||p[1]>=180||p[2]>=180){let y=Math.max(...p)/180,d=new vn(...c,i),m=new vn(...h,i),_=new an().setFromEuler(d),v=new an().setFromEuler(m);_.dot(v)&&v.set(-v.x,-v.y,-v.z,-v.w);let x=e.times[a-1],S=e.times[a]-x,I=new an,A=new vn;for(let C=0;C<1;C+=1/y)I.copy(_.clone().slerp(v.clone(),C)),s.push(x+C*S),A.setFromQuaternion(I,i),o.push(A.x),o.push(A.y),o.push(A.z)}else s.push(e.times[a]),o.push(yn.degToRad(e.values[a])),o.push(yn.degToRad(t.values[a])),o.push(yn.degToRad(n.values[a]))}return[s,o]}},xm=class{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Vf,this.nodeStack=[],this.currentProp=[],this.currentPropName="";let t=this,n=e.split(/[\r\n]+/);return n.forEach(function(i,s){let o=i.match(/^[\s\t]*;/),a=i.match(/^[\s\t]*$/);if(o||a)return;let l=i.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),c=i.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),u=i.match("^\\t{"+(t.currentIndent-1)+"}}");l?t.parseNodeBegin(i,l):c?t.parseNodeProperty(i,c,n[++s]):u?t.popStack():i.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(e,t){let n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},o=this.parseNodeAttr(i),a=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,s):n in a?(n==="PoseNode"?a.PoseNode.push(s):a[n].id!==void 0&&(a[n]={},a[n][a[n].id]=a[n]),o.id!==""&&(a[n][o.id]=s)):typeof o.id=="number"?(a[n]={},a[n][o.id]=s):n!=="Properties70"&&(n==="PoseNode"?a[n]=[s]:a[n]=s),typeof o.id=="number"&&(s.id=o.id),o.name!==""&&(s.attrName=o.name),o.type!==""&&(s.attrType=o.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());let o=this.getCurrentNode();if(o.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){let l=s.split(",").slice(1),c=parseInt(l[0]),u=parseInt(l[1]),h=s.split(",").slice(3);h=h.map(function(f){return f.trim().replace(/^"/,"")}),i="connections",s=[c,u],gS(s,h),o[i]===void 0&&(o[i]=[])}i==="Node"&&(o.id=s),i in o&&Array.isArray(o[i])?o[i].push(s):i!=="a"?o[i]=s:o.a=s,this.setCurrentProp(o,i),i==="a"&&s.slice(-1)!==","&&(o.a=pm(s))}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=pm(t.a))}parseNodeSpecialProperty(e,t,n){let i=n.split('",').map(function(u){return u.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],o=i[1],a=i[2],l=i[3],c=i[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=pm(c);break}this.getPrevNode()[s]={type:o,type2:a,flag:l,value:c},this.setCurrentProp(this.getPrevNode(),s)}},vm=class{parse(e){let t=new Gf(e);t.skip(23);let n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);let i=new Vf;for(;!this.endOfContent(t);){let s=this.parseNode(t,n);s!==null&&i.add(s.name,s)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();let o=e.getUint8(),a=e.getString(o);if(i===0)return null;let l=[];for(let f=0;f<s;f++)l.push(this.parseProperty(e));let c=l.length>0?l[0]:"",u=l.length>1?l[1]:"",h=l.length>2?l[2]:"";for(n.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){let f=this.parseNode(e,t);f!==null&&this.parseSubNode(a,n,f)}return n.propertyList=l,typeof c=="number"&&(n.id=c),u!==""&&(n.attrName=u),h!==""&&(n.attrType=h),a!==""&&(n.name=a),n}parseSubNode(e,t,n){if(n.singleProperty===!0){let i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){let i=[];n.propertyList.forEach(function(s,o){o!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],s=n.propertyList[1],o=n.propertyList[2],a=n.propertyList[3],l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],t[i]={type:s,type2:o,flag:a,value:l}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){let t=e.getString(1),n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":let i=e.getUint32(),s=e.getUint32(),o=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}let a=jy(new Uint8Array(e.getArrayBuffer(o))),l=new Gf(a.buffer);switch(t){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}},Gf=class{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){let t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){let e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){let e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){let e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){let e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){let e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){let e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){let t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=this.offset,n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);let i=n.indexOf(0);return i>=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}},Vf=class{add(e,t){this[e]=t}};function fS(r){let e="Kaydara FBX Binary \0";return r.byteLength>=e.length&&e===Qy(r,0,e.length)}function dS(r){let e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],t=0;function n(i){let s=r[i-1];return r=r.slice(t+i),t++,s}for(let i=0;i<e.length;++i)if(n(1)===e[i])return!1;return!0}function Jy(r){let e=/FBXVersion: (\d+)/,t=r.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function pS(r){return r/46186158e3}var mS=[];function kf(r,e,t,n){let i;switch(n.mappingType){case"ByPolygonVertex":i=r;break;case"ByPolygon":i=e;break;case"ByVertice":i=t;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(i=n.indices[i]);let s=i*n.dataSize,o=s+n.dataSize;return yS(mS,n.buffer,s,o)}var dm=new vn,ol=new se;function $y(r){let e=new Je,t=new Je,n=new Je,i=new Je,s=new Je,o=new Je,a=new Je,l=new Je,c=new Je,u=new Je,h=new Je,f=new Je,p=r.inheritType?r.inheritType:0;r.translation&&e.setPosition(ol.fromArray(r.translation));let g=Gc(0);if(r.preRotation){let R=r.preRotation.map(yn.degToRad);R.push(g),t.makeRotationFromEuler(dm.fromArray(R))}if(r.rotation){let R=r.rotation.map(yn.degToRad);R.push(r.eulerOrder||g),n.makeRotationFromEuler(dm.fromArray(R))}if(r.postRotation){let R=r.postRotation.map(yn.degToRad);R.push(g),i.makeRotationFromEuler(dm.fromArray(R)),i.invert()}r.scale&&s.scale(ol.fromArray(r.scale)),r.scalingOffset&&a.setPosition(ol.fromArray(r.scalingOffset)),r.scalingPivot&&o.setPosition(ol.fromArray(r.scalingPivot)),r.rotationOffset&&l.setPosition(ol.fromArray(r.rotationOffset)),r.rotationPivot&&c.setPosition(ol.fromArray(r.rotationPivot)),r.parentMatrixWorld&&(h.copy(r.parentMatrix),u.copy(r.parentMatrixWorld));let y=t.clone().multiply(n).multiply(i),d=new Je;d.extractRotation(u);let m=new Je;m.copyPosition(u);let _=m.clone().invert().multiply(u),v=d.clone().invert().multiply(_),x=s,S=new Je;if(p===0)S.copy(d).multiply(y).multiply(v).multiply(x);else if(p===1)S.copy(d).multiply(v).multiply(y).multiply(x);else{let N=new Je().scale(new se().setFromMatrixScale(h)).clone().invert(),B=v.clone().multiply(N);S.copy(d).multiply(y).multiply(B).multiply(x)}let I=c.clone().invert(),A=o.clone().invert(),C=e.clone().multiply(l).multiply(c).multiply(t).multiply(n).multiply(i).multiply(I).multiply(a).multiply(o).multiply(s).multiply(A),E=new Je().copyPosition(C),b=u.clone().multiply(E);return f.copyPosition(b),C=f.clone().multiply(S),C.premultiply(u.invert()),C}function Gc(r){r=r||0;let e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return r===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[r]}function pm(r){return r.split(",").map(function(t){return parseFloat(t)})}function Qy(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=r.byteLength),new TextDecoder().decode(new Uint8Array(r,e,t))}function gS(r,e){for(let t=0,n=r.length,i=e.length;t<i;t++,n++)r[n]=e[t]}function yS(r,e,t,n){for(let i=t,s=0;i<n;i++,s++)r[s]=e[i];return r}var zf=class extends zt{load(e,t,n,i){let s=this,o=s.path===""?os.extractUrlBase(e):s.path,a=new $n(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(l){try{t(s.parse(l,o))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){function n(U,F){let Z=[],X=U.childNodes;for(let J=0,Ie=X.length;J<Ie;J++){let Ne=X[J];Ne.nodeName===F&&Z.push(Ne)}return Z}function i(U){if(U.length===0)return[];let F=U.trim().split(/\s+/),Z=new Array(F.length);for(let X=0,J=F.length;X<J;X++)Z[X]=F[X];return Z}function s(U){if(U.length===0)return[];let F=U.trim().split(/\s+/),Z=new Array(F.length);for(let X=0,J=F.length;X<J;X++)Z[X]=parseFloat(F[X]);return Z}function o(U){if(U.length===0)return[];let F=U.trim().split(/\s+/),Z=new Array(F.length);for(let X=0,J=F.length;X<J;X++)Z[X]=parseInt(F[X]);return Z}function a(U){return U.substring(1)}function l(){return"three_default_"+Fr++}function c(U){return Object.keys(U).length===0}function u(U){return{unit:h(n(U,"unit")[0]),upAxis:f(n(U,"up_axis")[0])}}function h(U){return U!==void 0&&U.hasAttribute("meter")===!0?parseFloat(U.getAttribute("meter")):1}function f(U){return U!==void 0?U.textContent:"Y_UP"}function p(U,F,Z,X){let J=n(U,F)[0];if(J!==void 0){let Ie=n(J,Z);for(let Ne=0;Ne<Ie.length;Ne++)X(Ie[Ne])}}function g(U,F){for(let Z in U){let X=U[Z];X.build=F(U[Z])}}function y(U,F){return U.build!==void 0||(U.build=F(U)),U.build}function d(U){let F={sources:{},samplers:{},channels:{}},Z=!1;for(let X=0,J=U.childNodes.length;X<J;X++){let Ie=U.childNodes[X];if(Ie.nodeType!==1)continue;let Ne;switch(Ie.nodeName){case"source":Ne=Ie.getAttribute("id"),F.sources[Ne]=be(Ie);break;case"sampler":Ne=Ie.getAttribute("id"),F.samplers[Ne]=m(Ie);break;case"channel":Ne=Ie.getAttribute("target"),F.channels[Ne]=_(Ie);break;case"animation":d(Ie),Z=!0;break;default:console.log(Ie)}}Z===!1&&(vt.animations[U.getAttribute("id")||yn.generateUUID()]=F)}function m(U){let F={inputs:{}};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"input":let Ie=a(J.getAttribute("source")),Ne=J.getAttribute("semantic");F.inputs[Ne]=Ie;break}}return F}function _(U){let F={},X=U.getAttribute("target").split("/"),J=X.shift(),Ie=X.shift(),Ne=Ie.indexOf("(")!==-1,et=Ie.indexOf(".")!==-1;if(et)X=Ie.split("."),Ie=X.shift(),F.member=X.shift();else if(Ne){let Ve=Ie.split("(");Ie=Ve.shift();for(let Ze=0;Ze<Ve.length;Ze++)Ve[Ze]=parseInt(Ve[Ze].replace(/\)/,""));F.indices=Ve}return F.id=J,F.sid=Ie,F.arraySyntax=Ne,F.memberSyntax=et,F.sampler=a(U.getAttribute("source")),F}function v(U){let F=[],Z=U.channels,X=U.samplers,J=U.sources;for(let Ie in Z)if(Z.hasOwnProperty(Ie)){let Ne=Z[Ie],et=X[Ne.sampler],Ve=et.inputs.INPUT,Ze=et.inputs.OUTPUT,lt=J[Ve],Ue=J[Ze],ot=S(Ne,lt,Ue);b(ot,F)}return F}function x(U){return y(vt.animations[U],v)}function S(U,F,Z){let X=vt.nodes[U.id],J=At(X.id),Ie=X.transforms[U.sid],Ne=X.matrix.clone().transpose(),et,Ve,Ze,lt,Ue,ot,it={};switch(Ie){case"matrix":for(Ze=0,lt=F.array.length;Ze<lt;Ze++)if(et=F.array[Ze],Ve=Ze*Z.stride,it[et]===void 0&&(it[et]={}),U.arraySyntax===!0){let fn=Z.array[Ve],jt=U.indices[0]+4*U.indices[1];it[et][jt]=fn}else for(Ue=0,ot=Z.stride;Ue<ot;Ue++)it[et][Ue]=Z.array[Ve+Ue];break;case"translate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',Ie);break;case"rotate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',Ie);break;case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',Ie);break}let pt=I(it,Ne);return{name:J.uuid,keyframes:pt}}function I(U,F){let Z=[];for(let J in U)Z.push({time:parseFloat(J),value:U[J]});Z.sort(X);for(let J=0;J<16;J++)R(Z,J,F.elements[J]);return Z;function X(J,Ie){return J.time-Ie.time}}let A=new se,C=new se,E=new an;function b(U,F){let Z=U.keyframes,X=U.name,J=[],Ie=[],Ne=[],et=[];for(let Ve=0,Ze=Z.length;Ve<Ze;Ve++){let lt=Z[Ve],Ue=lt.time,ot=lt.value;xe.fromArray(ot).transpose(),xe.decompose(A,E,C),J.push(Ue),Ie.push(A.x,A.y,A.z),Ne.push(E.x,E.y,E.z,E.w),et.push(C.x,C.y,C.z)}return Ie.length>0&&F.push(new Wi(X+".position",J,Ie)),Ne.length>0&&F.push(new Hi(X+".quaternion",J,Ne)),et.length>0&&F.push(new Wi(X+".scale",J,et)),F}function R(U,F,Z){let X,J=!0,Ie,Ne;for(Ie=0,Ne=U.length;Ie<Ne;Ie++)X=U[Ie],X.value[F]===void 0?X.value[F]=null:J=!1;if(J===!0)for(Ie=0,Ne=U.length;Ie<Ne;Ie++)X=U[Ie],X.value[F]=Z;else N(U,F)}function N(U,F){let Z,X;for(let J=0,Ie=U.length;J<Ie;J++){let Ne=U[J];if(Ne.value[F]===null){if(Z=B(U,J,F),X=V(U,J,F),Z===null){Ne.value[F]=X.value[F];continue}if(X===null){Ne.value[F]=Z.value[F];continue}ie(Ne,Z,X,F)}}}function B(U,F,Z){for(;F>=0;){let X=U[F];if(X.value[Z]!==null)return X;F--}return null}function V(U,F,Z){for(;F<U.length;){let X=U[F];if(X.value[Z]!==null)return X;F++}return null}function ie(U,F,Z,X){if(Z.time-F.time===0){U.value[X]=F.value[X];return}U.value[X]=(U.time-F.time)*(Z.value[X]-F.value[X])/(Z.time-F.time)+F.value[X]}function Y(U){let F={name:U.getAttribute("id")||"default",start:parseFloat(U.getAttribute("start")||0),end:parseFloat(U.getAttribute("end")||0),animations:[]};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"instance_animation":F.animations.push(a(J.getAttribute("url")));break}}vt.clips[U.getAttribute("id")]=F}function te(U){let F=[],Z=U.name,X=U.end-U.start||-1,J=U.animations;for(let Ie=0,Ne=J.length;Ie<Ne;Ie++){let et=x(J[Ie]);for(let Ve=0,Ze=et.length;Ve<Ze;Ve++)F.push(et[Ve])}return new Ps(Z,X,F)}function q(U){return y(vt.clips[U],te)}function le(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"skin":F.id=a(J.getAttribute("source")),F.skin=ye(J);break;case"morph":F.id=a(J.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");break}}vt.controllers[U.getAttribute("id")]=F}function ye(U){let F={sources:{}};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"bind_shape_matrix":F.bindShapeMatrix=s(J.textContent);break;case"source":let Ie=J.getAttribute("id");F.sources[Ie]=be(J);break;case"joints":F.joints=Te(J);break;case"vertex_weights":F.vertexWeights=Ae(J);break}}return F}function Te(U){let F={inputs:{}};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"input":let Ie=J.getAttribute("semantic"),Ne=a(J.getAttribute("source"));F.inputs[Ie]=Ne;break}}return F}function Ae(U){let F={inputs:{}};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"input":let Ie=J.getAttribute("semantic"),Ne=a(J.getAttribute("source")),et=parseInt(J.getAttribute("offset"));F.inputs[Ie]={id:Ne,offset:et};break;case"vcount":F.vcount=o(J.textContent);break;case"v":F.v=o(J.textContent);break}}return F}function _e(U){let F={id:U.id},Z=vt.geometries[F.id];return U.skin!==void 0&&(F.skin=G(U.skin),Z.sources.skinIndices=F.skin.indices,Z.sources.skinWeights=F.skin.weights),F}function G(U){let Z={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},X=U.sources,J=U.vertexWeights,Ie=J.vcount,Ne=J.v,et=J.inputs.JOINT.offset,Ve=J.inputs.WEIGHT.offset,Ze=U.sources[U.joints.inputs.JOINT],lt=U.sources[U.joints.inputs.INV_BIND_MATRIX],Ue=X[J.inputs.WEIGHT.id].array,ot=0,it,pt,ht;for(it=0,ht=Ie.length;it<ht;it++){let jt=Ie[it],Gt=[];for(pt=0;pt<jt;pt++){let Vt=Ne[ot+et],Ur=Ne[ot+Ve],hi=Ue[Ur];Gt.push({index:Vt,weight:hi}),ot+=2}for(Gt.sort(fn),pt=0;pt<4;pt++){let Vt=Gt[pt];Vt!==void 0?(Z.indices.array.push(Vt.index),Z.weights.array.push(Vt.weight)):(Z.indices.array.push(0),Z.weights.array.push(0))}}for(U.bindShapeMatrix?Z.bindMatrix=new Je().fromArray(U.bindShapeMatrix).transpose():Z.bindMatrix=new Je().identity(),it=0,ht=Ze.array.length;it<ht;it++){let jt=Ze.array[it],Gt=new Je().fromArray(lt.array,it*lt.stride).transpose();Z.joints.push({name:jt,boneInverse:Gt})}return Z;function fn(jt,Gt){return Gt.weight-jt.weight}}function P(U){return y(vt.controllers[U],_e)}function M(U){let F={init_from:n(U,"init_from")[0].textContent};vt.images[U.getAttribute("id")]=F}function T(U){return U.build!==void 0?U.build:U.init_from}function k(U){let F=vt.images[U];return F!==void 0?y(F,T):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",U),null)}function j(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"profile_COMMON":F.profile=W(J);break}}vt.effects[U.getAttribute("id")]=F}function W(U){let F={surfaces:{},samplers:{}};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"newparam":re(J,F);break;case"technique":F.technique=w(J);break;case"extra":F.extra=ve(J);break}}return F}function re(U,F){let Z=U.getAttribute("sid");for(let X=0,J=U.childNodes.length;X<J;X++){let Ie=U.childNodes[X];if(Ie.nodeType===1)switch(Ie.nodeName){case"surface":F.surfaces[Z]=ce(Ie);break;case"sampler2D":F.samplers[Z]=me(Ie);break}}}function ce(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"init_from":F.init_from=J.textContent;break}}return F}function me(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"source":F.source=J.textContent;break}}return F}function w(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"constant":case"lambert":case"blinn":case"phong":F.type=J.nodeName,F.parameters=ae(J);break;case"extra":F.extra=ve(J);break}}return F}function ae(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":F[J.nodeName]=pe(J);break;case"transparent":F[J.nodeName]={opaque:J.hasAttribute("opaque")?J.getAttribute("opaque"):"A_ONE",data:pe(J)};break}}return F}function pe(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"color":F[J.nodeName]=s(J.textContent);break;case"float":F[J.nodeName]=parseFloat(J.textContent);break;case"texture":F[J.nodeName]={id:J.getAttribute("texture"),extra:ue(J)};break}}return F}function ue(U){let F={technique:{}};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"extra":ee(J,F);break}}return F}function ee(U,F){for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"technique":$(J,F);break}}}function $(U,F){for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":F.technique[J.nodeName]=parseFloat(J.textContent);break;case"wrapU":case"wrapV":J.textContent.toUpperCase()==="TRUE"?F.technique[J.nodeName]=1:J.textContent.toUpperCase()==="FALSE"?F.technique[J.nodeName]=0:F.technique[J.nodeName]=parseInt(J.textContent);break;case"bump":F[J.nodeName]=L(J);break}}}function ve(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"technique":F.technique=H(J);break}}return F}function H(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"double_sided":F[J.nodeName]=parseInt(J.textContent);break;case"bump":F[J.nodeName]=L(J);break}}return F}function L(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"texture":F[J.nodeName]={id:J.getAttribute("texture"),texcoord:J.getAttribute("texcoord"),extra:ue(J)};break}}return F}function O(U){return U}function D(U){return y(vt.effects[U],O)}function z(U){let F={name:U.getAttribute("name")};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"instance_effect":F.url=a(J.getAttribute("url"));break}}vt.materials[U.getAttribute("id")]=F}function Q(U){let F,Z=U.slice((U.lastIndexOf(".")-1>>>0)+2);switch(Z=Z.toLowerCase(),Z){case"tga":F=Yn;break;default:F=ti}return F}function ne(U){let F=D(U.url),Z=F.profile.technique,X;switch(Z.type){case"phong":case"blinn":X=new Zt;break;case"lambert":X=new go;break;default:X=new Ii;break}X.name=U.name||"";function J(Ve,Ze=null){let lt=F.profile.samplers[Ve.id],Ue=null;if(lt!==void 0){let ot=F.profile.surfaces[lt.source];Ue=k(ot.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),Ue=k(Ve.id);if(Ue!==null){let ot=Q(Ue);if(ot!==void 0){let it=ot.load(Ue),pt=Ve.extra;if(pt!==void 0&&pt.technique!==void 0&&c(pt.technique)===!1){let ht=pt.technique;it.wrapS=ht.wrapU?on:un,it.wrapT=ht.wrapV?on:un,it.offset.set(ht.offsetU||0,ht.offsetV||0),it.repeat.set(ht.repeatU||1,ht.repeatV||1)}else it.wrapS=on,it.wrapT=on;return Ze!==null&&(it.colorSpace=Ze),it}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",Ue),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",Ve.id),null}let Ie=Z.parameters;for(let Ve in Ie){let Ze=Ie[Ve];switch(Ve){case"diffuse":Ze.color&&X.color.fromArray(Ze.color),Ze.texture&&(X.map=J(Ze.texture,yt));break;case"specular":Ze.color&&X.specular&&X.specular.fromArray(Ze.color),Ze.texture&&(X.specularMap=J(Ze.texture));break;case"bump":Ze.texture&&(X.normalMap=J(Ze.texture));break;case"ambient":Ze.texture&&(X.lightMap=J(Ze.texture,yt));break;case"shininess":Ze.float&&X.shininess&&(X.shininess=Ze.float);break;case"emission":Ze.color&&X.emissive&&X.emissive.fromArray(Ze.color),Ze.texture&&(X.emissiveMap=J(Ze.texture,yt));break}}mt.toWorkingColorSpace(X.color,yt),X.specular&&mt.toWorkingColorSpace(X.specular,yt),X.emissive&&mt.toWorkingColorSpace(X.emissive,yt);let Ne=Ie.transparent,et=Ie.transparency;if(et===void 0&&Ne&&(et={float:1}),Ne===void 0&&et&&(Ne={opaque:"A_ONE",data:{color:[1,1,1,1]}}),Ne&&et)if(Ne.data.texture)X.transparent=!0;else{let Ve=Ne.data.color;switch(Ne.opaque){case"A_ONE":X.opacity=Ve[3]*et.float;break;case"RGB_ZERO":X.opacity=1-Ve[0]*et.float;break;case"A_ZERO":X.opacity=1-Ve[3]*et.float;break;case"RGB_ONE":X.opacity=Ve[0]*et.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',Ne.opaque)}X.opacity<1&&(X.transparent=!0)}if(Z.extra!==void 0&&Z.extra.technique!==void 0){let Ve=Z.extra.technique;for(let Ze in Ve){let lt=Ve[Ze];switch(Ze){case"double_sided":X.side=lt===1?Nn:wi;break;case"bump":X.normalMap=J(lt.texture),X.normalScale=new Pe(1,1);break}}}return X}function oe(U){return y(vt.materials[U],ne)}function he(U){let F={name:U.getAttribute("name")};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"optics":F.optics=ge(J);break}}vt.cameras[U.getAttribute("id")]=F}function ge(U){for(let F=0;F<U.childNodes.length;F++){let Z=U.childNodes[F];switch(Z.nodeName){case"technique_common":return de(Z)}}return{}}function de(U){let F={};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];switch(X.nodeName){case"perspective":case"orthographic":F.technique=X.nodeName,F.parameters=Ee(X);break}}return F}function Ee(U){let F={};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];switch(X.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":F[X.nodeName]=parseFloat(X.textContent);break}}return F}function Re(U){let F;switch(U.optics.technique){case"perspective":F=new nn(U.optics.parameters.yfov,U.optics.parameters.aspect_ratio,U.optics.parameters.znear,U.optics.parameters.zfar);break;case"orthographic":let Z=U.optics.parameters.ymag,X=U.optics.parameters.xmag,J=U.optics.parameters.aspect_ratio;X=X===void 0?Z*J:X,Z=Z===void 0?X/J:Z,X*=.5,Z*=.5,F=new ss(-X,X,Z,-Z,U.optics.parameters.znear,U.optics.parameters.zfar);break;default:F=new nn;break}return F.name=U.name||"",F}function De(U){let F=vt.cameras[U];return F!==void 0?y(F,Re):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",U),null)}function ke(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"technique_common":F=at(J);break}}vt.lights[U.getAttribute("id")]=F}function at(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"directional":case"point":case"spot":case"ambient":F.technique=J.nodeName,F.parameters=je(J)}}return F}function je(U){let F={};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"color":let Ie=s(J.textContent);F.color=new He().fromArray(Ie),mt.toWorkingColorSpace(F.color,yt);break;case"falloff_angle":F.falloffAngle=parseFloat(J.textContent);break;case"quadratic_attenuation":let Ne=parseFloat(J.textContent);F.distance=Ne?Math.sqrt(1/Ne):0;break}}return F}function Ke(U){let F;switch(U.technique){case"directional":F=new sr;break;case"point":F=new Ns;break;case"spot":F=new vo;break;case"ambient":F=new or;break}return U.parameters.color&&F.color.copy(U.parameters.color),U.parameters.distance&&(F.distance=U.parameters.distance),F}function fe(U){let F=vt.lights[U];return F!==void 0?y(F,Ke):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",U),null)}function Le(U){let F={name:U.getAttribute("name"),sources:{},vertices:{},primitives:[]},Z=n(U,"mesh")[0];if(Z!==void 0){for(let X=0;X<Z.childNodes.length;X++){let J=Z.childNodes[X];if(J.nodeType!==1)continue;let Ie=J.getAttribute("id");switch(J.nodeName){case"source":F.sources[Ie]=be(J);break;case"vertices":F.vertices=Ce(J);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",J.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":F.primitives.push(Be(J));break;default:console.log(J)}}vt.geometries[U.getAttribute("id")]=F}}function be(U){let F={array:[],stride:3};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"float_array":F.array=s(X.textContent);break;case"Name_array":F.array=i(X.textContent);break;case"technique_common":let J=n(X,"accessor")[0];J!==void 0&&(F.stride=parseInt(J.getAttribute("stride")));break}}return F}function Ce(U){let F={};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];X.nodeType===1&&(F[X.getAttribute("semantic")]=a(X.getAttribute("source")))}return F}function Be(U){let F={type:U.nodeName,material:U.getAttribute("material"),count:parseInt(U.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let Z=0,X=U.childNodes.length;Z<X;Z++){let J=U.childNodes[Z];if(J.nodeType===1)switch(J.nodeName){case"input":let Ie=a(J.getAttribute("source")),Ne=J.getAttribute("semantic"),et=parseInt(J.getAttribute("offset")),Ve=parseInt(J.getAttribute("set")),Ze=Ve>0?Ne+Ve:Ne;F.inputs[Ze]={id:Ie,offset:et},F.stride=Math.max(F.stride,et+1),Ne==="TEXCOORD"&&(F.hasUV=!0);break;case"vcount":F.vcount=o(J.textContent);break;case"p":F.p=o(J.textContent);break}}return F}function Oe(U){let F={};for(let Z=0;Z<U.length;Z++){let X=U[Z];F[X.type]===void 0&&(F[X.type]=[]),F[X.type].push(X)}return F}function rt(U){let F=0;for(let Z=0,X=U.length;Z<X;Z++)U[Z].hasUV===!0&&F++;F>0&&F<U.length&&(U.uvsNeedsFix=!0)}function Et(U){let F={},Z=U.sources,X=U.vertices,J=U.primitives;if(J.length===0)return{};let Ie=Oe(J);for(let Ne in Ie){let et=Ie[Ne];rt(et),F[Ne]=ft(et,Z,X)}return F}function ft(U,F,Z){let X={},J={array:[],stride:0},Ie={array:[],stride:0},Ne={array:[],stride:0},et={array:[],stride:0},Ve={array:[],stride:0},Ze={array:[],stride:4},lt={array:[],stride:4},Ue=new It,ot=[],it=0;for(let pt=0;pt<U.length;pt++){let ht=U[pt],fn=ht.inputs,jt=0;switch(ht.type){case"lines":case"linestrips":jt=ht.count*2;break;case"triangles":jt=ht.count*3;break;case"polylist":for(let Gt=0;Gt<ht.count;Gt++){let Vt=ht.vcount[Gt];switch(Vt){case 3:jt+=3;break;case 4:jt+=6;break;default:jt+=(Vt-2)*3;break}}break;default:console.warn("THREE.ColladaLoader: Unknown primitive type:",ht.type)}Ue.addGroup(it,jt,pt),it+=jt,ht.material&&ot.push(ht.material);for(let Gt in fn){let Vt=fn[Gt];switch(Gt){case"VERTEX":for(let Ur in Z){let hi=Z[Ur];switch(Ur){case"POSITION":let Oo=J.array.length;if(Fe(ht,F[hi],Vt.offset,J.array),J.stride=F[hi].stride,F.skinWeights&&F.skinIndices&&(Fe(ht,F.skinIndices,Vt.offset,Ze.array),Fe(ht,F.skinWeights,Vt.offset,lt.array)),ht.hasUV===!1&&U.uvsNeedsFix===!0){let Ux=(J.array.length-Oo)/J.stride;for(let Km=0;Km<Ux;Km++)Ne.array.push(0,0)}break;case"NORMAL":Fe(ht,F[hi],Vt.offset,Ie.array),Ie.stride=F[hi].stride;break;case"COLOR":Fe(ht,F[hi],Vt.offset,Ve.array),Ve.stride=F[hi].stride;break;case"TEXCOORD":Fe(ht,F[hi],Vt.offset,Ne.array),Ne.stride=F[hi].stride;break;case"TEXCOORD1":Fe(ht,F[hi],Vt.offset,et.array),Ne.stride=F[hi].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',Ur)}}break;case"NORMAL":Fe(ht,F[Vt.id],Vt.offset,Ie.array),Ie.stride=F[Vt.id].stride;break;case"COLOR":Fe(ht,F[Vt.id],Vt.offset,Ve.array,!0),Ve.stride=F[Vt.id].stride;break;case"TEXCOORD":Fe(ht,F[Vt.id],Vt.offset,Ne.array),Ne.stride=F[Vt.id].stride;break;case"TEXCOORD1":Fe(ht,F[Vt.id],Vt.offset,et.array),et.stride=F[Vt.id].stride;break}}}return J.array.length>0&&Ue.setAttribute("position",new We(J.array,J.stride)),Ie.array.length>0&&Ue.setAttribute("normal",new We(Ie.array,Ie.stride)),Ve.array.length>0&&Ue.setAttribute("color",new We(Ve.array,Ve.stride)),Ne.array.length>0&&Ue.setAttribute("uv",new We(Ne.array,Ne.stride)),et.array.length>0&&Ue.setAttribute("uv1",new We(et.array,et.stride)),Ze.array.length>0&&Ue.setAttribute("skinIndex",new We(Ze.array,Ze.stride)),lt.array.length>0&&Ue.setAttribute("skinWeight",new We(lt.array,lt.stride)),X.data=Ue,X.type=U[0].type,X.materialKeys=ot,X}function Fe(U,F,Z,X,J=!1){let Ie=U.p,Ne=U.stride,et=U.vcount;function Ve(Ue){let ot=Ie[Ue+Z]*lt,it=ot+lt;for(;ot<it;ot++)X.push(Ze[ot]);if(J){let pt=X.length-lt-1;Mn.setRGB(X[pt+0],X[pt+1],X[pt+2],yt),X[pt+0]=Mn.r,X[pt+1]=Mn.g,X[pt+2]=Mn.b}}let Ze=F.array,lt=F.stride;if(U.vcount!==void 0){let Ue=0;for(let ot=0,it=et.length;ot<it;ot++){let pt=et[ot];if(pt===4){let ht=Ue+Ne*0,fn=Ue+Ne*1,jt=Ue+Ne*2,Gt=Ue+Ne*3;Ve(ht),Ve(fn),Ve(Gt),Ve(fn),Ve(jt),Ve(Gt)}else if(pt===3){let ht=Ue+Ne*0,fn=Ue+Ne*1,jt=Ue+Ne*2;Ve(ht),Ve(fn),Ve(jt)}else if(pt>4)for(let ht=1,fn=pt-2;ht<=fn;ht++){let jt=Ue+Ne*0,Gt=Ue+Ne*ht,Vt=Ue+Ne*(ht+1);Ve(jt),Ve(Gt),Ve(Vt)}Ue+=Ne*pt}}else for(let Ue=0,ot=Ie.length;Ue<ot;Ue+=Ne)Ve(Ue)}function $e(U){return y(vt.geometries[U],Et)}function ze(U){let F={name:U.getAttribute("name")||"",joints:{},links:[]};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"technique_common":Ft(X,F);break}}vt.kinematicsModels[U.getAttribute("id")]=F}function st(U){return U.build!==void 0?U.build:U}function ct(U){return y(vt.kinematicsModels[U],st)}function Ft(U,F){for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"joint":F.joints[X.getAttribute("sid")]=ci(X);break;case"link":F.links.push(Dr(X));break}}}function ci(U){let F;for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"prismatic":case"revolute":F=Mi(X);break}}return F}function Mi(U){let F={sid:U.getAttribute("sid"),name:U.getAttribute("name")||"",axis:new se,limits:{min:0,max:0},type:U.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"axis":let J=s(X.textContent);F.axis.fromArray(J);break;case"limits":let Ie=X.getElementsByTagName("max")[0],Ne=X.getElementsByTagName("min")[0];F.limits.max=parseFloat(Ie.textContent),F.limits.min=parseFloat(Ne.textContent);break}}return F.limits.min>=F.limits.max&&(F.static=!0),F.middlePosition=(F.limits.min+F.limits.max)/2,F}function Dr(U){let F={sid:U.getAttribute("sid"),name:U.getAttribute("name")||"",attachments:[],transforms:[]};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"attachment_full":F.attachments.push(Po(X));break;case"matrix":case"translate":case"rotate":F.transforms.push(wl(X));break}}return F}function Po(U){let F={joint:U.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"link":F.links.push(Dr(X));break;case"matrix":case"translate":case"rotate":F.transforms.push(wl(X));break}}return F}function wl(U){let F={type:U.nodeName},Z=s(U.textContent);switch(F.type){case"matrix":F.obj=new Je,F.obj.fromArray(Z).transpose();break;case"translate":F.obj=new se,F.obj.fromArray(Z);break;case"rotate":F.obj=new se,F.obj.fromArray(Z),F.angle=yn.degToRad(Z[3]);break}return F}function No(U){let F={name:U.getAttribute("name")||"",rigidBodies:{}};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"rigid_body":F.rigidBodies[X.getAttribute("name")]={},ou(X,F.rigidBodies[X.getAttribute("name")]);break}}vt.physicsModels[U.getAttribute("id")]=F}function ou(U,F){for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"technique_common":au(X,F);break}}}function au(U,F){for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"inertia":F.inertia=s(X.textContent);break;case"mass":F.mass=s(X.textContent)[0];break}}}function ad(U){let F={bindJointAxis:[]};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"bind_joint_axis":F.bindJointAxis.push(ld(X));break}}vt.kinematicsScenes[a(U.getAttribute("url"))]=F}function ld(U){let F={target:U.getAttribute("target").split("/").pop()};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType===1)switch(X.nodeName){case"axis":let J=X.getElementsByTagName("param")[0];F.axis=J.textContent;let Ie=F.axis.split("inst_").pop().split("axis")[0];F.jointIndex=Ie.substring(0,Ie.length-1);break}}return F}function cd(U){return U.build!==void 0?U.build:U}function ud(U){return y(vt.kinematicsScenes[U],cd)}function hd(){let U=Object.keys(vt.kinematicsModels)[0],F=Object.keys(vt.kinematicsScenes)[0],Z=Object.keys(vt.visualScenes)[0];if(U===void 0||F===void 0)return;let X=ct(U),J=ud(F),Ie=Ot(Z),Ne=J.bindJointAxis,et={};for(let lt=0,Ue=Ne.length;lt<Ue;lt++){let ot=Ne[lt],it=en.querySelector('[sid="'+ot.target+'"]');if(it){let pt=it.parentElement;Ve(ot.jointIndex,pt)}}function Ve(lt,Ue){let ot=Ue.getAttribute("name"),it=X.joints[lt];Ie.traverse(function(pt){pt.name===ot&&(et[lt]={object:pt,transforms:fd(Ue),joint:it,position:it.zeroPosition})})}let Ze=new Je;Lo={joints:X&&X.joints,getJointValue:function(lt){let Ue=et[lt];if(Ue)return Ue.position;console.warn("THREE.ColladaLoader: Joint "+lt+" doesn't exist.")},setJointValue:function(lt,Ue){let ot=et[lt];if(ot){let it=ot.joint;if(Ue>it.limits.max||Ue<it.limits.min)console.warn("THREE.ColladaLoader: Joint "+lt+" value "+Ue+" outside of limits (min: "+it.limits.min+", max: "+it.limits.max+").");else if(it.static)console.warn("THREE.ColladaLoader: Joint "+lt+" is static.");else{let pt=ot.object,ht=it.axis,fn=ot.transforms;xe.identity();for(let jt=0;jt<fn.length;jt++){let Gt=fn[jt];if(Gt.sid&&Gt.sid.indexOf(lt)!==-1)switch(it.type){case"revolute":xe.multiply(Ze.makeRotationAxis(ht,yn.degToRad(Ue)));break;case"prismatic":xe.multiply(Ze.makeTranslation(ht.x*Ue,ht.y*Ue,ht.z*Ue));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+it.type);break}else switch(Gt.type){case"matrix":xe.multiply(Gt.obj);break;case"translate":xe.multiply(Ze.makeTranslation(Gt.obj.x,Gt.obj.y,Gt.obj.z));break;case"scale":xe.scale(Gt.obj);break;case"rotate":xe.multiply(Ze.makeRotationAxis(Gt.obj,Gt.angle));break}}pt.matrix.copy(xe),pt.matrix.decompose(pt.position,pt.quaternion,pt.scale),et[lt].position=Ue}}else console.log("THREE.ColladaLoader: "+lt+" does not exist.")}}}function fd(U){let F=[],Z=en.querySelector('[id="'+U.id+'"]');for(let X=0;X<Z.childNodes.length;X++){let J=Z.childNodes[X];if(J.nodeType!==1)continue;let Ie,Ne;switch(J.nodeName){case"matrix":Ie=s(J.textContent);let et=new Je().fromArray(Ie).transpose();F.push({sid:J.getAttribute("sid"),type:J.nodeName,obj:et});break;case"translate":case"scale":Ie=s(J.textContent),Ne=new se().fromArray(Ie),F.push({sid:J.getAttribute("sid"),type:J.nodeName,obj:Ne});break;case"rotate":Ie=s(J.textContent),Ne=new se().fromArray(Ie);let Ve=yn.degToRad(Ie[3]);F.push({sid:J.getAttribute("sid"),type:J.nodeName,obj:Ne,angle:Ve});break}}return F}function K(U){let F=U.getElementsByTagName("node");for(let Z=0;Z<F.length;Z++){let X=F[Z];X.hasAttribute("id")===!1&&X.setAttribute("id",l())}}let xe=new Je,Se=new se;function we(U){let F={name:U.getAttribute("name")||"",type:U.getAttribute("type"),id:U.getAttribute("id"),sid:U.getAttribute("sid"),matrix:new Je,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];if(X.nodeType!==1)continue;let J;switch(X.nodeName){case"node":F.nodes.push(X.getAttribute("id")),we(X);break;case"instance_camera":F.instanceCameras.push(a(X.getAttribute("url")));break;case"instance_controller":F.instanceControllers.push(Me(X));break;case"instance_light":F.instanceLights.push(a(X.getAttribute("url")));break;case"instance_geometry":F.instanceGeometries.push(Me(X));break;case"instance_node":F.instanceNodes.push(a(X.getAttribute("url")));break;case"matrix":J=s(X.textContent),F.matrix.multiply(xe.fromArray(J).transpose()),F.transforms[X.getAttribute("sid")]=X.nodeName;break;case"translate":J=s(X.textContent),Se.fromArray(J),F.matrix.multiply(xe.makeTranslation(Se.x,Se.y,Se.z)),F.transforms[X.getAttribute("sid")]=X.nodeName;break;case"rotate":J=s(X.textContent);let Ie=yn.degToRad(J[3]);F.matrix.multiply(xe.makeRotationAxis(Se.fromArray(J),Ie)),F.transforms[X.getAttribute("sid")]=X.nodeName;break;case"scale":J=s(X.textContent),F.matrix.scale(Se.fromArray(J)),F.transforms[X.getAttribute("sid")]=X.nodeName;break;case"extra":break;default:console.log(X)}}return ut(F.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",F.id):vt.nodes[F.id]=F,F}function Me(U){let F={id:a(U.getAttribute("url")),materials:{},skeletons:[]};for(let Z=0;Z<U.childNodes.length;Z++){let X=U.childNodes[Z];switch(X.nodeName){case"bind_material":let J=X.getElementsByTagName("instance_material");for(let Ie=0;Ie<J.length;Ie++){let Ne=J[Ie],et=Ne.getAttribute("symbol"),Ve=Ne.getAttribute("target");F.materials[et]=a(Ve)}break;case"skeleton":F.skeletons.push(a(X.textContent));break;default:break}}return F}function Ge(U,F){let Z=[],X=[],J,Ie,Ne;for(J=0;J<U.length;J++){let Ze=U[J],lt;if(ut(Ze))lt=At(Ze),Xe(lt,F,Z);else if(ln(Ze)){let ot=vt.visualScenes[Ze].children;for(let it=0;it<ot.length;it++){let pt=ot[it];if(pt.type==="JOINT"){let ht=At(pt.id);Xe(ht,F,Z)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",Ze)}for(J=0;J<F.length;J++)for(Ie=0;Ie<Z.length;Ie++)if(Ne=Z[Ie],Ne.bone.name===F[J].name){X[J]=Ne,Ne.processed=!0;break}for(J=0;J<Z.length;J++)Ne=Z[J],Ne.processed===!1&&(X.push(Ne),Ne.processed=!0);let et=[],Ve=[];for(J=0;J<X.length;J++)Ne=X[J],et.push(Ne.bone),Ve.push(Ne.boneInverse);return new ho(et,Ve)}function Xe(U,F,Z){U.traverse(function(X){if(X.isBone===!0){let J;for(let Ie=0;Ie<F.length;Ie++){let Ne=F[Ie];if(Ne.name===X.name){J=Ne.boneInverse;break}}J===void 0&&(J=new Je),Z.push({bone:X,boneInverse:J,processed:!1})}})}function Qe(U){let F=[],Z=U.matrix,X=U.nodes,J=U.type,Ie=U.instanceCameras,Ne=U.instanceControllers,et=U.instanceLights,Ve=U.instanceGeometries,Ze=U.instanceNodes;for(let Ue=0,ot=X.length;Ue<ot;Ue++)F.push(At(X[Ue]));for(let Ue=0,ot=Ie.length;Ue<ot;Ue++){let it=De(Ie[Ue]);it!==null&&F.push(it.clone())}for(let Ue=0,ot=Ne.length;Ue<ot;Ue++){let it=Ne[Ue],pt=P(it.id),ht=$e(pt.id),fn=xt(ht,it.materials),jt=it.skeletons,Gt=pt.skin.joints,Vt=Ge(jt,Gt);for(let Ur=0,hi=fn.length;Ur<hi;Ur++){let Oo=fn[Ur];Oo.isSkinnedMesh&&(Oo.bind(Vt,pt.skin.bindMatrix),Oo.normalizeSkinWeights()),F.push(Oo)}}for(let Ue=0,ot=et.length;Ue<ot;Ue++){let it=fe(et[Ue]);it!==null&&F.push(it.clone())}for(let Ue=0,ot=Ve.length;Ue<ot;Ue++){let it=Ve[Ue],pt=$e(it.id),ht=xt(pt,it.materials);for(let fn=0,jt=ht.length;fn<jt;fn++)F.push(ht[fn])}for(let Ue=0,ot=Ze.length;Ue<ot;Ue++)F.push(At(Ze[Ue]).clone());let lt;if(X.length===0&&F.length===1)lt=F[0];else{lt=J==="JOINT"?new es:new gn;for(let Ue=0;Ue<F.length;Ue++)lt.add(F[Ue])}return lt.name=J==="JOINT"?U.sid:U.name,lt.matrix.copy(Z),lt.matrix.decompose(lt.position,lt.quaternion,lt.scale),lt}let tt=new Ii({name:zt.DEFAULT_MATERIAL_NAME,color:16711935});function Tt(U,F){let Z=[];for(let X=0,J=U.length;X<J;X++){let Ie=F[U[X]];Ie===void 0?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",U[X]),Z.push(tt)):Z.push(oe(Ie))}return Z}function xt(U,F){let Z=[];for(let X in U){let J=U[X],Ie=Tt(J.materialKeys,F);if(Ie.length===0&&(X==="lines"||X==="linestrips"?Ie.push(new jn):Ie.push(new Zt)),X==="lines"||X==="linestrips")for(let Ze=0,lt=Ie.length;Ze<lt;Ze++){let Ue=Ie[Ze];if(Ue.isMeshPhongMaterial===!0||Ue.isMeshLambertMaterial===!0){let ot=new jn;ot.color.copy(Ue.color),ot.opacity=Ue.opacity,ot.transparent=Ue.transparent,Ie[Ze]=ot}}let Ne=J.data.attributes.skinIndex!==void 0,et=Ie.length===1?Ie[0]:Ie,Ve;switch(X){case"lines":Ve=new rr(J.data,et);break;case"linestrips":Ve=new Rs(J.data,et);break;case"triangles":case"polylist":Ne?Ve=new co(J.data,et):Ve=new Dt(J.data,et);break}Z.push(Ve)}return Z}function ut(U){return vt.nodes[U]!==void 0}function At(U){return y(vt.nodes[U],Qe)}function kt(U){let F={name:U.getAttribute("name"),children:[]};K(U);let Z=n(U,"node");for(let X=0;X<Z.length;X++)F.children.push(we(Z[X]));vt.visualScenes[U.getAttribute("id")]=F}function hn(U){let F=new gn;F.name=U.name;let Z=U.children;for(let X=0;X<Z.length;X++){let J=Z[X];F.add(At(J.id))}return F}function ln(U){return vt.visualScenes[U]!==void 0}function Ot(U){return y(vt.visualScenes[U],hn)}function dt(U){let F=n(U,"instance_visual_scene")[0];return Ot(a(F.getAttribute("url")))}function wn(){let U=vt.clips;if(c(U)===!0){if(c(vt.animations)===!1){let F=[];for(let Z in vt.animations){let X=x(Z);for(let J=0,Ie=X.length;J<Ie;J++)F.push(X[J])}Cn.push(new Ps("default",-1,F))}}else for(let F in U)Cn.push(q(F))}function Bt(U){let F="",Z=[U];for(;Z.length;){let X=Z.shift();X.nodeType===Node.TEXT_NODE?F+=X.textContent:(F+=`
+`,Z.push(...X.childNodes))}return F.trim()}if(e.length===0)return{scene:new ir};let ui=new DOMParser().parseFromString(e,"application/xml"),en=n(ui,"COLLADA")[0],Hn=ui.getElementsByTagName("parsererror")[0];if(Hn!==void 0){let U=n(Hn,"div")[0],F;return U?F=U.textContent:F=Bt(Hn),console.error(`THREE.ColladaLoader: Failed to parse collada file.
+`,F),null}let zs=en.getAttribute("version");console.debug("THREE.ColladaLoader: File version",zs);let $t=u(n(en,"asset")[0]),ti=new Ri(this.manager);ti.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);let Yn;Fs&&(Yn=new Fs(this.manager),Yn.setPath(this.resourcePath||t));let Mn=new He,Cn=[],Lo={},Fr=0,vt={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};p(en,"library_animations","animation",d),p(en,"library_animation_clips","animation_clip",Y),p(en,"library_controllers","controller",le),p(en,"library_images","image",M),p(en,"library_effects","effect",j),p(en,"library_materials","material",z),p(en,"library_cameras","camera",he),p(en,"library_lights","light",ke),p(en,"library_geometries","geometry",Le),p(en,"library_nodes","node",we),p(en,"library_visual_scenes","visual_scene",kt),p(en,"library_kinematics_models","kinematics_model",ze),p(en,"library_physics_models","physics_model",No),p(en,"scene","instance_kinematics_scene",ad),g(vt.animations,v),g(vt.clips,te),g(vt.controllers,_e),g(vt.images,T),g(vt.effects,O),g(vt.materials,ne),g(vt.cameras,Re),g(vt.lights,Ke),g(vt.geometries,Et),g(vt.visualScenes,hn),wn(),hd();let lu=dt(n(en,"scene")[0]);return lu.animations=Cn,$t.upAxis==="Z_UP"&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),lu.rotation.set(-Math.PI/2,0,0)),lu.scale.multiplyScalar($t.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Cn},kinematics:Lo,library:vt,scene:lu}}};var bt=(r,e)=>()=>(e||(e={exports:{}},r(e.exports,e)),e.exports),ex=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.VERSION=void 0,r.VERSION="9.0.1"}),Wt=bt((exports,module)=>{"use strict";var __spreadArray=exports&&exports.__spreadArray||function(r,e){for(var t=0,n=e.length,i=r.length;t<n;t++,i++)r[i]=e[t];return r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.toFastProperties=exports.timer=exports.peek=exports.isES2015MapSupported=exports.PRINT_WARNING=exports.PRINT_ERROR=exports.packArray=exports.IDENTITY=exports.NOOP=exports.merge=exports.groupBy=exports.defaults=exports.assignNoOverwrite=exports.assign=exports.zipObject=exports.sortBy=exports.indexOf=exports.some=exports.difference=exports.every=exports.isObject=exports.isRegExp=exports.isArray=exports.partial=exports.uniq=exports.compact=exports.reduce=exports.findAll=exports.find=exports.cloneObj=exports.cloneArr=exports.contains=exports.has=exports.pick=exports.reject=exports.filter=exports.dropRight=exports.drop=exports.isFunction=exports.isUndefined=exports.isString=exports.forEach=exports.last=exports.first=exports.flatten=exports.map=exports.mapValues=exports.values=exports.keys=exports.isEmpty=void 0;function isEmpty(r){return r&&r.length===0}exports.isEmpty=isEmpty;function keys(r){return r==null?[]:Object.keys(r)}exports.keys=keys;function values(r){for(var e=[],t=Object.keys(r),n=0;n<t.length;n++)e.push(r[t[n]]);return e}exports.values=values;function mapValues(r,e){for(var t=[],n=keys(r),i=0;i<n.length;i++){var s=n[i];t.push(e.call(null,r[s],s))}return t}exports.mapValues=mapValues;function map(r,e){for(var t=[],n=0;n<r.length;n++)t.push(e.call(null,r[n],n));return t}exports.map=map;function flatten(r){for(var e=[],t=0;t<r.length;t++){var n=r[t];Array.isArray(n)?e=e.concat(flatten(n)):e.push(n)}return e}exports.flatten=flatten;function first(r){return isEmpty(r)?void 0:r[0]}exports.first=first;function last(r){var e=r&&r.length;return e?r[e-1]:void 0}exports.last=last;function forEach(r,e){if(Array.isArray(r))for(var t=0;t<r.length;t++)e.call(null,r[t],t);else if(isObject(r))for(var n=keys(r),t=0;t<n.length;t++){var i=n[t],s=r[i];e.call(null,s,i)}else throw Error("non exhaustive match")}exports.forEach=forEach;function isString(r){return typeof r=="string"}exports.isString=isString;function isUndefined(r){return r===void 0}exports.isUndefined=isUndefined;function isFunction(r){return r instanceof Function}exports.isFunction=isFunction;function drop(r,e){return e===void 0&&(e=1),r.slice(e,r.length)}exports.drop=drop;function dropRight(r,e){return e===void 0&&(e=1),r.slice(0,r.length-e)}exports.dropRight=dropRight;function filter(r,e){var t=[];if(Array.isArray(r))for(var n=0;n<r.length;n++){var i=r[n];e.call(null,i)&&t.push(i)}return t}exports.filter=filter;function reject(r,e){return filter(r,function(t){return!e(t)})}exports.reject=reject;function pick(r,e){for(var t=Object.keys(r),n={},i=0;i<t.length;i++){var s=t[i],o=r[s];e(o)&&(n[s]=o)}return n}exports.pick=pick;function has(r,e){return isObject(r)?r.hasOwnProperty(e):!1}exports.has=has;function contains(r,e){return find(r,function(t){return t===e})!==void 0}exports.contains=contains;function cloneArr(r){for(var e=[],t=0;t<r.length;t++)e.push(r[t]);return e}exports.cloneArr=cloneArr;function cloneObj(r){var e={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e}exports.cloneObj=cloneObj;function find(r,e){for(var t=0;t<r.length;t++){var n=r[t];if(e.call(null,n))return n}}exports.find=find;function findAll(r,e){for(var t=[],n=0;n<r.length;n++){var i=r[n];e.call(null,i)&&t.push(i)}return t}exports.findAll=findAll;function reduce(r,e,t){for(var n=Array.isArray(r),i=n?r:values(r),s=n?[]:keys(r),o=t,a=0;a<i.length;a++)o=e.call(null,o,i[a],n?a:s[a]);return o}exports.reduce=reduce;function compact(r){return reject(r,function(e){return e==null})}exports.compact=compact;function uniq(r,e){e===void 0&&(e=function(n){return n});var t=[];return reduce(r,function(n,i){var s=e(i);return contains(t,s)?n:(t.push(s),n.concat(i))},[])}exports.uniq=uniq;function partial(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var n=[null],i=n.concat(e);return Function.bind.apply(r,i)}exports.partial=partial;function isArray(r){return Array.isArray(r)}exports.isArray=isArray;function isRegExp(r){return r instanceof RegExp}exports.isRegExp=isRegExp;function isObject(r){return r instanceof Object}exports.isObject=isObject;function every(r,e){for(var t=0;t<r.length;t++)if(!e(r[t],t))return!1;return!0}exports.every=every;function difference(r,e){return reject(r,function(t){return contains(e,t)})}exports.difference=difference;function some(r,e){for(var t=0;t<r.length;t++)if(e(r[t]))return!0;return!1}exports.some=some;function indexOf(r,e){for(var t=0;t<r.length;t++)if(r[t]===e)return t;return-1}exports.indexOf=indexOf;function sortBy(r,e){var t=cloneArr(r);return t.sort(function(n,i){return e(n)-e(i)}),t}exports.sortBy=sortBy;function zipObject(r,e){if(r.length!==e.length)throw Error("can't zipObject with different number of keys and values!");for(var t={},n=0;n<r.length;n++)t[r[n]]=e[n];return t}exports.zipObject=zipObject;function assign(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var n=0;n<e.length;n++)for(var i=e[n],s=keys(i),o=0;o<s.length;o++){var a=s[o];r[a]=i[a]}return r}exports.assign=assign;function assignNoOverwrite(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var n=0;n<e.length;n++)for(var i=e[n],s=keys(i),o=0;o<s.length;o++){var a=s[o];has(r,a)||(r[a]=i[a])}return r}exports.assignNoOverwrite=assignNoOverwrite;function defaults(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return assignNoOverwrite.apply(void 0,__spreadArray([{}],r))}exports.defaults=defaults;function groupBy(r,e){var t={};return forEach(r,function(n){var i=e(n),s=t[i];s?s.push(n):t[i]=[n]}),t}exports.groupBy=groupBy;function merge(r,e){for(var t=cloneObj(r),n=keys(e),i=0;i<n.length;i++){var s=n[i],o=e[s];t[s]=o}return t}exports.merge=merge;function NOOP(){}exports.NOOP=NOOP;function IDENTITY(r){return r}exports.IDENTITY=IDENTITY;function packArray(r){for(var e=[],t=0;t<r.length;t++){var n=r[t];e.push(n!==void 0?n:void 0)}return e}exports.packArray=packArray;function PRINT_ERROR(r){console&&console.error&&console.error("Error: "+r)}exports.PRINT_ERROR=PRINT_ERROR;function PRINT_WARNING(r){console&&console.warn&&console.warn("Warning: "+r)}exports.PRINT_WARNING=PRINT_WARNING;function isES2015MapSupported(){return typeof Map=="function"}exports.isES2015MapSupported=isES2015MapSupported;function peek(r){return r[r.length-1]}exports.peek=peek;function timer(r){var e=new Date().getTime(),t=r(),n=new Date().getTime(),i=n-e;return{time:i,value:t}}exports.timer=timer;function toFastProperties(toBecomeFast){function FakeConstructor(){}FakeConstructor.prototype=toBecomeFast;var fakeInstance=new FakeConstructor;function fakeAccess(){return typeof fakeInstance.bar}return fakeAccess(),fakeAccess(),toBecomeFast}exports.toFastProperties=toFastProperties}),_m=bt((r,e)=>{(function(t,n){typeof define=="function"&&define.amd?define([],n):typeof e=="object"&&e.exports?e.exports=n():t.regexpToAst=n()})(typeof self<"u"?self:r,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(d){this.idx=d.idx,this.input=d.input,this.groupIdx=d.groupIdx},t.prototype.pattern=function(d){this.idx=0,this.input=d,this.groupIdx=0,this.consumeChar("/");var m=this.disjunction();this.consumeChar("/");for(var _={type:"Flags",loc:{begin:this.idx,end:d.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":l(_,"global");break;case"i":l(_,"ignoreCase");break;case"m":l(_,"multiLine");break;case"u":l(_,"unicode");break;case"y":l(_,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:_,value:m,loc:this.loc(0)}},t.prototype.disjunction=function(){var d=[],m=this.idx;for(d.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),d.push(this.alternative());return{type:"Disjunction",value:d,loc:this.loc(m)}},t.prototype.alternative=function(){for(var d=[],m=this.idx;this.isTerm();)d.push(this.term());return{type:"Alternative",value:d,loc:this.loc(m)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var d=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(d)};case"$":return{type:"EndAnchor",loc:this.loc(d)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(d)};case"B":return{type:"NonWordBoundary",loc:this.loc(d)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var m;switch(this.popChar()){case"=":m="Lookahead";break;case"!":m="NegativeLookahead";break}c(m);var _=this.disjunction();return this.consumeChar(")"),{type:m,value:_,loc:this.loc(d)}}u()},t.prototype.quantifier=function(d){var m,_=this.idx;switch(this.popChar()){case"*":m={atLeast:0,atMost:1/0};break;case"+":m={atLeast:1,atMost:1/0};break;case"?":m={atLeast:0,atMost:1};break;case"{":var v=this.integerIncludingZero();switch(this.popChar()){case"}":m={atLeast:v,atMost:v};break;case",":var x;this.isDigit()?(x=this.integerIncludingZero(),m={atLeast:v,atMost:x}):m={atLeast:v,atMost:1/0},this.consumeChar("}");break}if(d===!0&&m===void 0)return;c(m);break}if(!(d===!0&&m===void 0))return c(m),this.peekChar(0)==="?"?(this.consumeChar("?"),m.greedy=!1):m.greedy=!0,m.type="Quantifier",m.loc=this.loc(_),m},t.prototype.atom=function(){var d,m=this.idx;switch(this.peekChar()){case".":d=this.dotAll();break;case"\\":d=this.atomEscape();break;case"[":d=this.characterClass();break;case"(":d=this.group();break}return d===void 0&&this.isPatternCharacter()&&(d=this.patternCharacter()),c(d),d.loc=this.loc(m),this.isQuantifier()&&(d.quantifier=this.quantifier()),d},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o(`
`),o("\r"),o("\u2028"),o("\u2029")]}},t.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.decimalEscapeAtom=function(){var d=this.positiveInteger();return{type:"GroupBackReference",value:d}},t.prototype.characterClassEscape=function(){var d,m=!1;switch(this.popChar()){case"d":d=f;break;case"D":d=f,m=!0;break;case"s":d=g;break;case"S":d=g,m=!0;break;case"w":d=p;break;case"W":d=p,m=!0;break}return c(d),{type:"Set",value:d,complement:m}},t.prototype.controlEscapeAtom=function(){var d;switch(this.popChar()){case"f":d=o("\f");break;case"n":d=o(`
`);break;case"r":d=o("\r");break;case"t":d=o(" ");break;case"v":d=o("\v");break}return c(d),{type:"Character",value:d}},t.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var d=this.popChar();if(/[a-zA-Z]/.test(d)===!1)throw Error("Invalid ");var m=d.toUpperCase().charCodeAt(0)-64;return{type:"Character",value:m}},t.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:o("\0")}},t.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},t.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},t.prototype.identityEscapeAtom=function(){var d=this.popChar();return{type:"Character",value:o(d)}},t.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case`
-`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var d=this.popChar();return{type:"Character",value:o(d)}}},t.prototype.characterClass=function(){var d=[],m=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),m=!0);this.isClassAtom();){var _=this.classAtom(),y=_.type==="Character";if(y&&this.isRangeDash()){this.consumeChar("-");var x=this.classAtom(),w=x.type==="Character";if(w){if(x.value<_.value)throw Error("Range out of order in character class");d.push({from:_.value,to:x.value})}else a(_.value,d),d.push(o("-")),a(x.value,d)}else a(_.value,d)}return this.consumeChar("]"),{type:"Set",complement:m,value:d}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case`
+`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var d=this.popChar();return{type:"Character",value:o(d)}}},t.prototype.characterClass=function(){var d=[],m=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),m=!0);this.isClassAtom();){var _=this.classAtom(),v=_.type==="Character";if(v&&this.isRangeDash()){this.consumeChar("-");var x=this.classAtom(),S=x.type==="Character";if(S){if(x.value<_.value)throw Error("Range out of order in character class");d.push({from:_.value,to:x.value})}else a(_.value,d),d.push(o("-")),a(x.value,d)}else a(_.value,d)}return this.consumeChar("]"),{type:"Set",complement:m,value:d}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case`
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}},t.prototype.classEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:o("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.group=function(){var d=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),d=!1;break;default:this.groupIdx++;break}var m=this.disjunction();this.consumeChar(")");var _={type:"Group",capturing:d,value:m};return d&&(_.idx=this.groupIdx),_},t.prototype.positiveInteger=function(){var d=this.popChar();if(s.test(d)===!1)throw Error("Expecting a positive integer");for(;i.test(this.peekChar(0));)d+=this.popChar();return parseInt(d,10)},t.prototype.integerIncludingZero=function(){var d=this.popChar();if(i.test(d)===!1)throw Error("Expecting an integer");for(;i.test(this.peekChar(0));)d+=this.popChar();return parseInt(d,10)},t.prototype.patternCharacter=function(){var d=this.popChar();switch(d){case`
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:o(d)}}},t.prototype.isRegExpFlag=function(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}},t.prototype.isRangeDash=function(){return this.peekChar()==="-"&&this.isClassAtom(1)},t.prototype.isDigit=function(){return i.test(this.peekChar(0))},t.prototype.isClassAtom=function(d){switch(d===void 0&&(d=0),this.peekChar(d)){case"]":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},t.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},t.prototype.isAssertion=function(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!");default:return!1}},t.prototype.isQuantifier=function(){var d=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(d)}},t.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
-`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(d){for(var m="",_=0;_<d;_++){var y=this.popChar();if(n.test(y)===!1)throw Error("Expecting a HexDecimal digits");m+=y}var x=parseInt(m,16);return{type:"Character",value:x}},t.prototype.peekChar=function(d){return d===void 0&&(d=0),this.input[this.idx+d]},t.prototype.popChar=function(){var d=this.peekChar(0);return this.consumeChar(),d},t.prototype.consumeChar=function(d){if(d!==void 0&&this.input[this.idx]!==d)throw Error("Expected: '"+d+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},t.prototype.loc=function(d){return{begin:d,end:this.idx}};var n=/[0-9a-fA-F]/,i=/[0-9]/,s=/[1-9]/;function o(d){return d.charCodeAt(0)}function a(d,m){d.length!==void 0?d.forEach(function(_){m.push(_)}):m.push(d)}function l(d,m){if(d[m]===!0)throw"duplicate flag "+m;d[m]=!0}function c(d){if(d===void 0)throw Error("Internal Error - Should never get here!")}function u(){throw Error("Internal Error - Should never get here!")}var h,f=[];for(h=o("0");h<=o("9");h++)f.push(h);var p=[o("_")].concat(f);for(h=o("a");h<=o("z");h++)p.push(h);for(h=o("A");h<=o("Z");h++)p.push(h);var g=[o(" "),o("\f"),o(`
-`),o("\r"),o(" "),o("\v"),o(" "),o("\xA0"),o("\u1680"),o("\u2000"),o("\u2001"),o("\u2002"),o("\u2003"),o("\u2004"),o("\u2005"),o("\u2006"),o("\u2007"),o("\u2008"),o("\u2009"),o("\u200A"),o("\u2028"),o("\u2029"),o("\u202F"),o("\u205F"),o("\u3000"),o("\uFEFF")];function v(){}return v.prototype.visitChildren=function(d){for(var m in d){var _=d[m];d.hasOwnProperty(m)&&(_.type!==void 0?this.visit(_):Array.isArray(_)&&_.forEach(function(y){this.visit(y)},this))}},v.prototype.visit=function(d){switch(d.type){case"Pattern":this.visitPattern(d);break;case"Flags":this.visitFlags(d);break;case"Disjunction":this.visitDisjunction(d);break;case"Alternative":this.visitAlternative(d);break;case"StartAnchor":this.visitStartAnchor(d);break;case"EndAnchor":this.visitEndAnchor(d);break;case"WordBoundary":this.visitWordBoundary(d);break;case"NonWordBoundary":this.visitNonWordBoundary(d);break;case"Lookahead":this.visitLookahead(d);break;case"NegativeLookahead":this.visitNegativeLookahead(d);break;case"Character":this.visitCharacter(d);break;case"Set":this.visitSet(d);break;case"Group":this.visitGroup(d);break;case"GroupBackReference":this.visitGroupBackReference(d);break;case"Quantifier":this.visitQuantifier(d);break}this.visitChildren(d)},v.prototype.visitPattern=function(d){},v.prototype.visitFlags=function(d){},v.prototype.visitDisjunction=function(d){},v.prototype.visitAlternative=function(d){},v.prototype.visitStartAnchor=function(d){},v.prototype.visitEndAnchor=function(d){},v.prototype.visitWordBoundary=function(d){},v.prototype.visitNonWordBoundary=function(d){},v.prototype.visitLookahead=function(d){},v.prototype.visitNegativeLookahead=function(d){},v.prototype.visitCharacter=function(d){},v.prototype.visitSet=function(d){},v.prototype.visitGroup=function(d){},v.prototype.visitGroupBackReference=function(d){},v.prototype.visitQuantifier=function(d){},{RegExpParser:t,BaseRegExpVisitor:v,VERSION:"0.5.0"}})}),sp=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.clearRegExpParserCache=r.getRegExpAst=void 0;var e=rp(),t={},n=new e.RegExpParser;function i(o){var a=o.toString();if(t.hasOwnProperty(a))return t[a];var l=n.pattern(a);return t[a]=l,l}r.getRegExpAst=i;function s(){t={}}r.clearRegExpParserCache=s}),dS=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var v=function(d,m){return v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,y){_.__proto__=y}||function(_,y){for(var x in y)Object.prototype.hasOwnProperty.call(y,x)&&(_[x]=y[x])},v(d,m)};return function(d,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");v(d,m);function _(){this.constructor=d}d.prototype=m===null?Object.create(m):(_.prototype=m.prototype,new _)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.canMatchCharCode=r.firstCharOptimizedIndices=r.getOptimizedStartCodesIndices=r.failedOptimizationPrefixMsg=void 0;var t=rp(),n=Ut(),i=sp(),s=H0(),o="Complement Sets are not supported for first char optimization";r.failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations:
-`;function a(v,d){d===void 0&&(d=!1);try{var m=i.getRegExpAst(v),_=l(m.value,{},m.flags.ignoreCase);return _}catch(x){if(x.message===o)d&&n.PRINT_WARNING(""+r.failedOptimizationPrefixMsg+(" Unable to optimize: < "+v.toString()+` >
+`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(d){for(var m="",_=0;_<d;_++){var v=this.popChar();if(n.test(v)===!1)throw Error("Expecting a HexDecimal digits");m+=v}var x=parseInt(m,16);return{type:"Character",value:x}},t.prototype.peekChar=function(d){return d===void 0&&(d=0),this.input[this.idx+d]},t.prototype.popChar=function(){var d=this.peekChar(0);return this.consumeChar(),d},t.prototype.consumeChar=function(d){if(d!==void 0&&this.input[this.idx]!==d)throw Error("Expected: '"+d+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},t.prototype.loc=function(d){return{begin:d,end:this.idx}};var n=/[0-9a-fA-F]/,i=/[0-9]/,s=/[1-9]/;function o(d){return d.charCodeAt(0)}function a(d,m){d.length!==void 0?d.forEach(function(_){m.push(_)}):m.push(d)}function l(d,m){if(d[m]===!0)throw"duplicate flag "+m;d[m]=!0}function c(d){if(d===void 0)throw Error("Internal Error - Should never get here!")}function u(){throw Error("Internal Error - Should never get here!")}var h,f=[];for(h=o("0");h<=o("9");h++)f.push(h);var p=[o("_")].concat(f);for(h=o("a");h<=o("z");h++)p.push(h);for(h=o("A");h<=o("Z");h++)p.push(h);var g=[o(" "),o("\f"),o(`
+`),o("\r"),o(" "),o("\v"),o(" "),o("\xA0"),o("\u1680"),o("\u2000"),o("\u2001"),o("\u2002"),o("\u2003"),o("\u2004"),o("\u2005"),o("\u2006"),o("\u2007"),o("\u2008"),o("\u2009"),o("\u200A"),o("\u2028"),o("\u2029"),o("\u202F"),o("\u205F"),o("\u3000"),o("\uFEFF")];function y(){}return y.prototype.visitChildren=function(d){for(var m in d){var _=d[m];d.hasOwnProperty(m)&&(_.type!==void 0?this.visit(_):Array.isArray(_)&&_.forEach(function(v){this.visit(v)},this))}},y.prototype.visit=function(d){switch(d.type){case"Pattern":this.visitPattern(d);break;case"Flags":this.visitFlags(d);break;case"Disjunction":this.visitDisjunction(d);break;case"Alternative":this.visitAlternative(d);break;case"StartAnchor":this.visitStartAnchor(d);break;case"EndAnchor":this.visitEndAnchor(d);break;case"WordBoundary":this.visitWordBoundary(d);break;case"NonWordBoundary":this.visitNonWordBoundary(d);break;case"Lookahead":this.visitLookahead(d);break;case"NegativeLookahead":this.visitNegativeLookahead(d);break;case"Character":this.visitCharacter(d);break;case"Set":this.visitSet(d);break;case"Group":this.visitGroup(d);break;case"GroupBackReference":this.visitGroupBackReference(d);break;case"Quantifier":this.visitQuantifier(d);break}this.visitChildren(d)},y.prototype.visitPattern=function(d){},y.prototype.visitFlags=function(d){},y.prototype.visitDisjunction=function(d){},y.prototype.visitAlternative=function(d){},y.prototype.visitStartAnchor=function(d){},y.prototype.visitEndAnchor=function(d){},y.prototype.visitWordBoundary=function(d){},y.prototype.visitNonWordBoundary=function(d){},y.prototype.visitLookahead=function(d){},y.prototype.visitNegativeLookahead=function(d){},y.prototype.visitCharacter=function(d){},y.prototype.visitSet=function(d){},y.prototype.visitGroup=function(d){},y.prototype.visitGroupBackReference=function(d){},y.prototype.visitQuantifier=function(d){},{RegExpParser:t,BaseRegExpVisitor:y,VERSION:"0.5.0"}})}),Tm=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.clearRegExpParserCache=r.getRegExpAst=void 0;var e=_m(),t={},n=new e.RegExpParser;function i(o){var a=o.toString();if(t.hasOwnProperty(a))return t[a];var l=n.pattern(a);return t[a]=l,l}r.getRegExpAst=i;function s(){t={}}r.clearRegExpParserCache=s}),xS=bt(r=>{"use strict";var e=r&&r.__extends||function(){var y=function(d,m){return y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,v){_.__proto__=v}||function(_,v){for(var x in v)Object.prototype.hasOwnProperty.call(v,x)&&(_[x]=v[x])},y(d,m)};return function(d,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");y(d,m);function _(){this.constructor=d}d.prototype=m===null?Object.create(m):(_.prototype=m.prototype,new _)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.canMatchCharCode=r.firstCharOptimizedIndices=r.getOptimizedStartCodesIndices=r.failedOptimizationPrefixMsg=void 0;var t=_m(),n=Wt(),i=Tm(),s=tx(),o="Complement Sets are not supported for first char optimization";r.failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations:
+`;function a(y,d){d===void 0&&(d=!1);try{var m=i.getRegExpAst(y),_=l(m.value,{},m.flags.ignoreCase);return _}catch(x){if(x.message===o)d&&n.PRINT_WARNING(""+r.failedOptimizationPrefixMsg+(" Unable to optimize: < "+y.toString()+` >
`)+` Complement Sets cannot be automatically optimized.
This will disable the lexer's first char optimizations.
- See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{var y="";d&&(y=`
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{var v="";d&&(v=`
This will disable the lexer's first char optimizations.
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),n.PRINT_ERROR(r.failedOptimizationPrefixMsg+`
-`+(" Failed parsing: < "+v.toString()+` >
+`+(" Failed parsing: < "+y.toString()+` >
`)+(" Using the regexp-to-ast library version: "+t.VERSION+`
-`)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+y)}}return[]}r.getOptimizedStartCodesIndices=a;function l(v,d,m){switch(v.type){case"Disjunction":for(var _=0;_<v.value.length;_++)l(v.value[_],d,m);break;case"Alternative":for(var y=v.value,_=0;_<y.length;_++){var x=y[_];switch(x.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var w=x;switch(w.type){case"Character":c(w.value,d,m);break;case"Set":if(w.complement===!0)throw Error(o);n.forEach(w.value,function(P){if(typeof P=="number")c(P,d,m);else{var E=P;if(m===!0)for(var M=E.from;M<=E.to;M++)c(M,d,m);else{for(var M=E.from;M<=E.to&&M<s.minOptimizationVal;M++)c(M,d,m);if(E.to>=s.minOptimizationVal)for(var L=E.from>=s.minOptimizationVal?E.from:s.minOptimizationVal,N=E.to,O=s.charCodeToOptimizedIndex(L),B=s.charCodeToOptimizedIndex(N),ie=O;ie<=B;ie++)d[ie]=ie}}});break;case"Group":l(w.value,d,m);break;default:throw Error("Non Exhaustive Match")}var I=w.quantifier!==void 0&&w.quantifier.atLeast===0;if(w.type==="Group"&&f(w)===!1||w.type!=="Group"&&I===!1)break}break;default:throw Error("non exhaustive match!")}return n.values(d)}r.firstCharOptimizedIndices=l;function c(v,d,m){var _=s.charCodeToOptimizedIndex(v);d[_]=_,m===!0&&u(v,d)}function u(v,d){var m=String.fromCharCode(v),_=m.toUpperCase();if(_!==m){var y=s.charCodeToOptimizedIndex(_.charCodeAt(0));d[y]=y}else{var x=m.toLowerCase();if(x!==m){var y=s.charCodeToOptimizedIndex(x.charCodeAt(0));d[y]=y}}}function h(v,d){return n.find(v.value,function(m){if(typeof m=="number")return n.contains(d,m);var _=m;return n.find(d,function(y){return _.from<=y&&y<=_.to})!==void 0})}function f(v){return v.quantifier&&v.quantifier.atLeast===0?!0:v.value?n.isArray(v.value)?n.every(v.value,f):f(v.value):!1}var p=function(v){e(d,v);function d(m){var _=v.call(this)||this;return _.targetCharCodes=m,_.found=!1,_}return d.prototype.visitChildren=function(m){if(this.found!==!0){switch(m.type){case"Lookahead":this.visitLookahead(m);return;case"NegativeLookahead":this.visitNegativeLookahead(m);return}v.prototype.visitChildren.call(this,m)}},d.prototype.visitCharacter=function(m){n.contains(this.targetCharCodes,m.value)&&(this.found=!0)},d.prototype.visitSet=function(m){m.complement?h(m,this.targetCharCodes)===void 0&&(this.found=!0):h(m,this.targetCharCodes)!==void 0&&(this.found=!0)},d}(t.BaseRegExpVisitor);function g(v,d){if(d instanceof RegExp){var m=i.getRegExpAst(d),_=new p(v);return _.visit(m),_.found}else return n.find(d,function(y){return n.contains(v,y.charCodeAt(0))})!==void 0}r.canMatchCharCode=g}),H0=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var T=function(S,b){return T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(V,q){V.__proto__=q}||function(V,q){for(var Y in q)Object.prototype.hasOwnProperty.call(q,Y)&&(V[Y]=q[Y])},T(S,b)};return function(S,b){if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");T(S,b);function V(){this.constructor=S}S.prototype=b===null?Object.create(b):(V.prototype=b.prototype,new V)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.charCodeToOptimizedIndex=r.minOptimizationVal=r.buildLineBreakIssueMessage=r.LineTerminatorOptimizedTester=r.isShortPattern=r.isCustomPattern=r.cloneEmptyGroups=r.performWarningRuntimeChecks=r.performRuntimeChecks=r.addStickyFlag=r.addStartOfInput=r.findUnreachablePatterns=r.findModesThatDoNotExist=r.findInvalidGroupType=r.findDuplicatePatterns=r.findUnsupportedFlags=r.findStartOfInputAnchor=r.findEmptyMatchRegExps=r.findEndOfInputAnchor=r.findInvalidPatterns=r.findMissingPatterns=r.validatePatterns=r.analyzeTokenTypes=r.enableSticky=r.disableSticky=r.SUPPORT_STICKY=r.MODES=r.DEFAULT_MODE=void 0;var t=rp(),n=Ah(),i=Ut(),s=dS(),o=sp(),a="PATTERN";r.DEFAULT_MODE="defaultMode",r.MODES="modes",r.SUPPORT_STICKY=typeof new RegExp("(?:)").sticky=="boolean";function l(){r.SUPPORT_STICKY=!1}r.disableSticky=l;function c(){r.SUPPORT_STICKY=!0}r.enableSticky=c;function u(T,S){S=i.defaults(S,{useSticky:r.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
-`],tracer:function(ee,k){return k()}});var b=S.tracer;b("initCharCodeToOptimizedIndexMap",function(){R()});var V;b("Reject Lexer.NA",function(){V=i.reject(T,function(ee){return ee[a]===n.Lexer.NA})});var q=!1,Y;b("Transform Patterns",function(){q=!1,Y=i.map(V,function(ee){var k=ee[a];if(i.isRegExp(k)){var J=k.source;return J.length===1&&J!=="^"&&J!=="$"&&J!=="."&&!k.ignoreCase?J:J.length===2&&J[0]==="\\"&&!i.contains(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],J[1])?J[1]:S.useSticky?N(k):L(k)}else{if(i.isFunction(k))return q=!0,{exec:k};if(i.has(k,"exec"))return q=!0,k;if(typeof k=="string"){if(k.length===1)return k;var ue=k.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),Z=new RegExp(ue);return S.useSticky?N(Z):L(Z)}else throw Error("non exhaustive match")}})});var z,X,se,re,le;b("misc mapping",function(){z=i.map(V,function(ee){return ee.tokenTypeIdx}),X=i.map(V,function(ee){var k=ee.GROUP;if(k!==n.Lexer.SKIPPED){if(i.isString(k))return k;if(i.isUndefined(k))return!1;throw Error("non exhaustive match")}}),se=i.map(V,function(ee){var k=ee.LONGER_ALT;if(k){var J=i.indexOf(V,k);return J}}),re=i.map(V,function(ee){return ee.PUSH_MODE}),le=i.map(V,function(ee){return i.has(ee,"POP_MODE")})});var xe;b("Line Terminator Handling",function(){var ee=de(S.lineTerminatorCharacters);xe=i.map(V,function(k){return!1}),S.positionTracking!=="onlyOffset"&&(xe=i.map(V,function(k){if(i.has(k,"LINE_BREAKS"))return k.LINE_BREAKS;if(W(k,ee)===!1)return s.canMatchCharCode(ee,k.PATTERN)}))});var G,A,U,he;b("Misc Mapping #2",function(){G=i.map(V,$),A=i.map(Y,te),U=i.reduce(V,function(ee,k){var J=k.GROUP;return i.isString(J)&&J!==n.Lexer.SKIPPED&&(ee[J]=[]),ee},{}),he=i.map(Y,function(ee,k){return{pattern:Y[k],longerAlt:se[k],canLineTerminator:xe[k],isCustom:G[k],short:A[k],group:X[k],push:re[k],pop:le[k],tokenTypeIdx:z[k],tokenType:V[k]}})});var me=!0,Te=[];return S.safeMode||b("First Char Optimization",function(){Te=i.reduce(V,function(ee,k,J){if(typeof k.PATTERN=="string"){var ue=k.PATTERN.charCodeAt(0),Z=ve(ue);ye(ee,Z,he[J])}else if(i.isArray(k.START_CHARS_HINT)){var ce;i.forEach(k.START_CHARS_HINT,function(fe){var ge=typeof fe=="string"?fe.charCodeAt(0):fe,Ae=ve(ge);ce!==Ae&&(ce=Ae,ye(ee,Ae,he[J]))})}else if(i.isRegExp(k.PATTERN))if(k.PATTERN.unicode)me=!1,S.ensureOptimizations&&i.PRINT_ERROR(""+s.failedOptimizationPrefixMsg+(" Unable to analyze < "+k.PATTERN.toString()+` > pattern.
+`)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+v)}}return[]}r.getOptimizedStartCodesIndices=a;function l(y,d,m){switch(y.type){case"Disjunction":for(var _=0;_<y.value.length;_++)l(y.value[_],d,m);break;case"Alternative":for(var v=y.value,_=0;_<v.length;_++){var x=v[_];switch(x.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var S=x;switch(S.type){case"Character":c(S.value,d,m);break;case"Set":if(S.complement===!0)throw Error(o);n.forEach(S.value,function(C){if(typeof C=="number")c(C,d,m);else{var E=C;if(m===!0)for(var b=E.from;b<=E.to;b++)c(b,d,m);else{for(var b=E.from;b<=E.to&&b<s.minOptimizationVal;b++)c(b,d,m);if(E.to>=s.minOptimizationVal)for(var R=E.from>=s.minOptimizationVal?E.from:s.minOptimizationVal,N=E.to,B=s.charCodeToOptimizedIndex(R),V=s.charCodeToOptimizedIndex(N),ie=B;ie<=V;ie++)d[ie]=ie}}});break;case"Group":l(S.value,d,m);break;default:throw Error("Non Exhaustive Match")}var I=S.quantifier!==void 0&&S.quantifier.atLeast===0;if(S.type==="Group"&&f(S)===!1||S.type!=="Group"&&I===!1)break}break;default:throw Error("non exhaustive match!")}return n.values(d)}r.firstCharOptimizedIndices=l;function c(y,d,m){var _=s.charCodeToOptimizedIndex(y);d[_]=_,m===!0&&u(y,d)}function u(y,d){var m=String.fromCharCode(y),_=m.toUpperCase();if(_!==m){var v=s.charCodeToOptimizedIndex(_.charCodeAt(0));d[v]=v}else{var x=m.toLowerCase();if(x!==m){var v=s.charCodeToOptimizedIndex(x.charCodeAt(0));d[v]=v}}}function h(y,d){return n.find(y.value,function(m){if(typeof m=="number")return n.contains(d,m);var _=m;return n.find(d,function(v){return _.from<=v&&v<=_.to})!==void 0})}function f(y){return y.quantifier&&y.quantifier.atLeast===0?!0:y.value?n.isArray(y.value)?n.every(y.value,f):f(y.value):!1}var p=function(y){e(d,y);function d(m){var _=y.call(this)||this;return _.targetCharCodes=m,_.found=!1,_}return d.prototype.visitChildren=function(m){if(this.found!==!0){switch(m.type){case"Lookahead":this.visitLookahead(m);return;case"NegativeLookahead":this.visitNegativeLookahead(m);return}y.prototype.visitChildren.call(this,m)}},d.prototype.visitCharacter=function(m){n.contains(this.targetCharCodes,m.value)&&(this.found=!0)},d.prototype.visitSet=function(m){m.complement?h(m,this.targetCharCodes)===void 0&&(this.found=!0):h(m,this.targetCharCodes)!==void 0&&(this.found=!0)},d}(t.BaseRegExpVisitor);function g(y,d){if(d instanceof RegExp){var m=i.getRegExpAst(d),_=new p(y);return _.visit(m),_.found}else return n.find(d,function(v){return n.contains(y,v.charCodeAt(0))})!==void 0}r.canMatchCharCode=g}),tx=bt(r=>{"use strict";var e=r&&r.__extends||function(){var P=function(M,T){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(k,j){k.__proto__=j}||function(k,j){for(var W in j)Object.prototype.hasOwnProperty.call(j,W)&&(k[W]=j[W])},P(M,T)};return function(M,T){if(typeof T!="function"&&T!==null)throw new TypeError("Class extends value "+String(T)+" is not a constructor or null");P(M,T);function k(){this.constructor=M}M.prototype=T===null?Object.create(T):(k.prototype=T.prototype,new k)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.charCodeToOptimizedIndex=r.minOptimizationVal=r.buildLineBreakIssueMessage=r.LineTerminatorOptimizedTester=r.isShortPattern=r.isCustomPattern=r.cloneEmptyGroups=r.performWarningRuntimeChecks=r.performRuntimeChecks=r.addStickyFlag=r.addStartOfInput=r.findUnreachablePatterns=r.findModesThatDoNotExist=r.findInvalidGroupType=r.findDuplicatePatterns=r.findUnsupportedFlags=r.findStartOfInputAnchor=r.findEmptyMatchRegExps=r.findEndOfInputAnchor=r.findInvalidPatterns=r.findMissingPatterns=r.validatePatterns=r.analyzeTokenTypes=r.enableSticky=r.disableSticky=r.SUPPORT_STICKY=r.MODES=r.DEFAULT_MODE=void 0;var t=_m(),n=Hf(),i=Wt(),s=xS(),o=Tm(),a="PATTERN";r.DEFAULT_MODE="defaultMode",r.MODES="modes",r.SUPPORT_STICKY=typeof new RegExp("(?:)").sticky=="boolean";function l(){r.SUPPORT_STICKY=!1}r.disableSticky=l;function c(){r.SUPPORT_STICKY=!0}r.enableSticky=c;function u(P,M){M=i.defaults(M,{useSticky:r.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
+`],tracer:function(O,D){return D()}});var T=M.tracer;T("initCharCodeToOptimizedIndexMap",function(){G()});var k;T("Reject Lexer.NA",function(){k=i.reject(P,function(O){return O[a]===n.Lexer.NA})});var j=!1,W;T("Transform Patterns",function(){j=!1,W=i.map(k,function(O){var D=O[a];if(i.isRegExp(D)){var z=D.source;return z.length===1&&z!=="^"&&z!=="$"&&z!=="."&&!D.ignoreCase?z:z.length===2&&z[0]==="\\"&&!i.contains(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],z[1])?z[1]:M.useSticky?N(D):R(D)}else{if(i.isFunction(D))return j=!0,{exec:D};if(i.has(D,"exec"))return j=!0,D;if(typeof D=="string"){if(D.length===1)return D;var Q=D.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),ne=new RegExp(Q);return M.useSticky?N(ne):R(ne)}else throw Error("non exhaustive match")}})});var re,ce,me,w,ae;T("misc mapping",function(){re=i.map(k,function(O){return O.tokenTypeIdx}),ce=i.map(k,function(O){var D=O.GROUP;if(D!==n.Lexer.SKIPPED){if(i.isString(D))return D;if(i.isUndefined(D))return!1;throw Error("non exhaustive match")}}),me=i.map(k,function(O){var D=O.LONGER_ALT;if(D){var z=i.indexOf(k,D);return z}}),w=i.map(k,function(O){return O.PUSH_MODE}),ae=i.map(k,function(O){return i.has(O,"POP_MODE")})});var pe;T("Line Terminator Handling",function(){var O=ye(M.lineTerminatorCharacters);pe=i.map(k,function(D){return!1}),M.positionTracking!=="onlyOffset"&&(pe=i.map(k,function(D){if(i.has(D,"LINE_BREAKS"))return D.LINE_BREAKS;if(q(D,O)===!1)return s.canMatchCharCode(O,D.PATTERN)}))});var ue,ee,$,ve;T("Misc Mapping #2",function(){ue=i.map(k,Y),ee=i.map(W,te),$=i.reduce(k,function(O,D){var z=D.GROUP;return i.isString(z)&&z!==n.Lexer.SKIPPED&&(O[z]=[]),O},{}),ve=i.map(W,function(O,D){return{pattern:W[D],longerAlt:me[D],canLineTerminator:pe[D],isCustom:ue[D],short:ee[D],group:ce[D],push:w[D],pop:ae[D],tokenTypeIdx:re[D],tokenType:k[D]}})});var H=!0,L=[];return M.safeMode||T("First Char Optimization",function(){L=i.reduce(k,function(O,D,z){if(typeof D.PATTERN=="string"){var Q=D.PATTERN.charCodeAt(0),ne=_e(Q);Te(O,ne,ve[z])}else if(i.isArray(D.START_CHARS_HINT)){var oe;i.forEach(D.START_CHARS_HINT,function(ge){var de=typeof ge=="string"?ge.charCodeAt(0):ge,Ee=_e(de);oe!==Ee&&(oe=Ee,Te(O,Ee,ve[z]))})}else if(i.isRegExp(D.PATTERN))if(D.PATTERN.unicode)H=!1,M.ensureOptimizations&&i.PRINT_ERROR(""+s.failedOptimizationPrefixMsg+(" Unable to analyze < "+D.PATTERN.toString()+` > pattern.
`)+` The regexp unicode flag is not currently supported by the regexp-to-ast library.
This will disable the lexer's first char optimizations.
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{var pe=s.getOptimizedStartCodesIndices(k.PATTERN,S.ensureOptimizations);i.isEmpty(pe)&&(me=!1),i.forEach(pe,function(fe){ye(ee,fe,he[J])})}else S.ensureOptimizations&&i.PRINT_ERROR(""+s.failedOptimizationPrefixMsg+(" TokenType: <"+k.name+`> is using a custom token pattern without providing <start_chars_hint> parameter.
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{var he=s.getOptimizedStartCodesIndices(D.PATTERN,M.ensureOptimizations);i.isEmpty(he)&&(H=!1),i.forEach(he,function(ge){Te(O,ge,ve[z])})}else M.ensureOptimizations&&i.PRINT_ERROR(""+s.failedOptimizationPrefixMsg+(" TokenType: <"+D.name+`> is using a custom token pattern without providing <start_chars_hint> parameter.
`)+` This will disable the lexer's first char optimizations.
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),me=!1;return ee},[])}),b("ArrayPacking",function(){Te=i.packArray(Te)}),{emptyGroups:U,patternIdxToConfig:he,charCodeToPatternIdxToConfig:Te,hasCustom:q,canBeOptimized:me}}r.analyzeTokenTypes=u;function h(T,S){var b=[],V=p(T);b=b.concat(V.errors);var q=g(V.valid),Y=q.valid;return b=b.concat(q.errors),b=b.concat(f(Y)),b=b.concat(I(Y)),b=b.concat(C(Y,S)),b=b.concat(P(Y)),b}r.validatePatterns=h;function f(T){var S=[],b=i.filter(T,function(V){return i.isRegExp(V[a])});return S=S.concat(d(b)),S=S.concat(y(b)),S=S.concat(x(b)),S=S.concat(w(b)),S=S.concat(m(b)),S}function p(T){var S=i.filter(T,function(q){return!i.has(q,a)}),b=i.map(S,function(q){return{message:"Token Type: ->"+q.name+"<- missing static 'PATTERN' property",type:n.LexerDefinitionErrorType.MISSING_PATTERN,tokenTypes:[q]}}),V=i.difference(T,S);return{errors:b,valid:V}}r.findMissingPatterns=p;function g(T){var S=i.filter(T,function(q){var Y=q[a];return!i.isRegExp(Y)&&!i.isFunction(Y)&&!i.has(Y,"exec")&&!i.isString(Y)}),b=i.map(S,function(q){return{message:"Token Type: ->"+q.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:n.LexerDefinitionErrorType.INVALID_PATTERN,tokenTypes:[q]}}),V=i.difference(T,S);return{errors:b,valid:V}}r.findInvalidPatterns=g;var v=/[^\\][\$]/;function d(T){var S=function(q){e(Y,q);function Y(){var z=q!==null&&q.apply(this,arguments)||this;return z.found=!1,z}return Y.prototype.visitEndAnchor=function(z){this.found=!0},Y}(t.BaseRegExpVisitor),b=i.filter(T,function(q){var Y=q[a];try{var z=o.getRegExpAst(Y),X=new S;return X.visit(z),X.found}catch{return v.test(Y.source)}}),V=i.map(b,function(q){return{message:`Unexpected RegExp Anchor Error:
- Token Type: ->`+q.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
- See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:n.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[q]}});return V}r.findEndOfInputAnchor=d;function m(T){var S=i.filter(T,function(V){var q=V[a];return q.test("")}),b=i.map(S,function(V){return{message:"Token Type: ->"+V.name+"<- static 'PATTERN' must not match an empty string",type:n.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,tokenTypes:[V]}});return b}r.findEmptyMatchRegExps=m;var _=/[^\\[][\^]|^\^/;function y(T){var S=function(q){e(Y,q);function Y(){var z=q!==null&&q.apply(this,arguments)||this;return z.found=!1,z}return Y.prototype.visitStartAnchor=function(z){this.found=!0},Y}(t.BaseRegExpVisitor),b=i.filter(T,function(q){var Y=q[a];try{var z=o.getRegExpAst(Y),X=new S;return X.visit(z),X.found}catch{return _.test(Y.source)}}),V=i.map(b,function(q){return{message:`Unexpected RegExp Anchor Error:
- Token Type: ->`+q.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
- See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:n.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[q]}});return V}r.findStartOfInputAnchor=y;function x(T){var S=i.filter(T,function(V){var q=V[a];return q instanceof RegExp&&(q.multiline||q.global)}),b=i.map(S,function(V){return{message:"Token Type: ->"+V.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:n.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[V]}});return b}r.findUnsupportedFlags=x;function w(T){var S=[],b=i.map(T,function(Y){return i.reduce(T,function(z,X){return Y.PATTERN.source===X.PATTERN.source&&!i.contains(S,X)&&X.PATTERN!==n.Lexer.NA&&(S.push(X),z.push(X)),z},[])});b=i.compact(b);var V=i.filter(b,function(Y){return Y.length>1}),q=i.map(V,function(Y){var z=i.map(Y,function(se){return se.name}),X=i.first(Y).PATTERN;return{message:"The same RegExp pattern ->"+X+"<-"+("has been used in all of the following Token Types: "+z.join(", ")+" <-"),type:n.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenTypes:Y}});return q}r.findDuplicatePatterns=w;function I(T){var S=i.filter(T,function(V){if(!i.has(V,"GROUP"))return!1;var q=V.GROUP;return q!==n.Lexer.SKIPPED&&q!==n.Lexer.NA&&!i.isString(q)}),b=i.map(S,function(V){return{message:"Token Type: ->"+V.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:n.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenTypes:[V]}});return b}r.findInvalidGroupType=I;function C(T,S){var b=i.filter(T,function(q){return q.PUSH_MODE!==void 0&&!i.contains(S,q.PUSH_MODE)}),V=i.map(b,function(q){var Y="Token Type: ->"+q.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+q.PUSH_MODE+"<-which does not exist";return{message:Y,type:n.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[q]}});return V}r.findModesThatDoNotExist=C;function P(T){var S=[],b=i.reduce(T,function(V,q,Y){var z=q.PATTERN;return z===n.Lexer.NA||(i.isString(z)?V.push({str:z,idx:Y,tokenType:q}):i.isRegExp(z)&&M(z)&&V.push({str:z.source,idx:Y,tokenType:q})),V},[]);return i.forEach(T,function(V,q){i.forEach(b,function(Y){var z=Y.str,X=Y.idx,se=Y.tokenType;if(q<X&&E(z,V.PATTERN)){var re="Token: ->"+se.name+`<- can never be matched.
-`+("Because it appears AFTER the Token Type ->"+V.name+"<-")+`in the lexer's definition.
-See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;S.push({message:re,type:n.LexerDefinitionErrorType.UNREACHABLE_PATTERN,tokenTypes:[V,se]})}})}),S}r.findUnreachablePatterns=P;function E(T,S){if(i.isRegExp(S)){var b=S.exec(T);return b!==null&&b.index===0}else{if(i.isFunction(S))return S(T,0,[],{});if(i.has(S,"exec"))return S.exec(T,0,[],{});if(typeof S=="string")return S===T;throw Error("non exhaustive match")}}function M(T){var S=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return i.find(S,function(b){return T.source.indexOf(b)!==-1})===void 0}function L(T){var S=T.ignoreCase?"i":"";return new RegExp("^(?:"+T.source+")",S)}r.addStartOfInput=L;function N(T){var S=T.ignoreCase?"iy":"y";return new RegExp(""+T.source,S)}r.addStickyFlag=N;function O(T,S,b){var V=[];return i.has(T,r.DEFAULT_MODE)||V.push({message:"A MultiMode Lexer cannot be initialized without a <"+r.DEFAULT_MODE+`> property in its definition
-`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),i.has(T,r.MODES)||V.push({message:"A MultiMode Lexer cannot be initialized without a <"+r.MODES+`> property in its definition
-`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),i.has(T,r.MODES)&&i.has(T,r.DEFAULT_MODE)&&!i.has(T.modes,T.defaultMode)&&V.push({message:"A MultiMode Lexer cannot be initialized with a "+r.DEFAULT_MODE+": <"+T.defaultMode+`>which does not exist
-`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),i.has(T,r.MODES)&&i.forEach(T.modes,function(q,Y){i.forEach(q,function(z,X){i.isUndefined(z)&&V.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:"+("<"+Y+"> at index: <"+X+`>
-`),type:n.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})})}),V}r.performRuntimeChecks=O;function B(T,S,b){var V=[],q=!1,Y=i.compact(i.flatten(i.mapValues(T.modes,function(se){return se}))),z=i.reject(Y,function(se){return se[a]===n.Lexer.NA}),X=de(b);return S&&i.forEach(z,function(se){var re=W(se,X);if(re!==!1){var le=ae(se,re),xe={message:le,type:re.issue,tokenType:se};V.push(xe)}else i.has(se,"LINE_BREAKS")?se.LINE_BREAKS===!0&&(q=!0):s.canMatchCharCode(X,se.PATTERN)&&(q=!0)}),S&&!q&&V.push({message:`Warning: No LINE_BREAKS Found.
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),H=!1;return O},[])}),T("ArrayPacking",function(){L=i.packArray(L)}),{emptyGroups:$,patternIdxToConfig:ve,charCodeToPatternIdxToConfig:L,hasCustom:j,canBeOptimized:H}}r.analyzeTokenTypes=u;function h(P,M){var T=[],k=p(P);T=T.concat(k.errors);var j=g(k.valid),W=j.valid;return T=T.concat(j.errors),T=T.concat(f(W)),T=T.concat(I(W)),T=T.concat(A(W,M)),T=T.concat(C(W)),T}r.validatePatterns=h;function f(P){var M=[],T=i.filter(P,function(k){return i.isRegExp(k[a])});return M=M.concat(d(T)),M=M.concat(v(T)),M=M.concat(x(T)),M=M.concat(S(T)),M=M.concat(m(T)),M}function p(P){var M=i.filter(P,function(j){return!i.has(j,a)}),T=i.map(M,function(j){return{message:"Token Type: ->"+j.name+"<- missing static 'PATTERN' property",type:n.LexerDefinitionErrorType.MISSING_PATTERN,tokenTypes:[j]}}),k=i.difference(P,M);return{errors:T,valid:k}}r.findMissingPatterns=p;function g(P){var M=i.filter(P,function(j){var W=j[a];return!i.isRegExp(W)&&!i.isFunction(W)&&!i.has(W,"exec")&&!i.isString(W)}),T=i.map(M,function(j){return{message:"Token Type: ->"+j.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:n.LexerDefinitionErrorType.INVALID_PATTERN,tokenTypes:[j]}}),k=i.difference(P,M);return{errors:T,valid:k}}r.findInvalidPatterns=g;var y=/[^\\][\$]/;function d(P){var M=function(j){e(W,j);function W(){var re=j!==null&&j.apply(this,arguments)||this;return re.found=!1,re}return W.prototype.visitEndAnchor=function(re){this.found=!0},W}(t.BaseRegExpVisitor),T=i.filter(P,function(j){var W=j[a];try{var re=o.getRegExpAst(W),ce=new M;return ce.visit(re),ce.found}catch{return y.test(W.source)}}),k=i.map(T,function(j){return{message:`Unexpected RegExp Anchor Error:
+ Token Type: ->`+j.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
+ See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:n.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[j]}});return k}r.findEndOfInputAnchor=d;function m(P){var M=i.filter(P,function(k){var j=k[a];return j.test("")}),T=i.map(M,function(k){return{message:"Token Type: ->"+k.name+"<- static 'PATTERN' must not match an empty string",type:n.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,tokenTypes:[k]}});return T}r.findEmptyMatchRegExps=m;var _=/[^\\[][\^]|^\^/;function v(P){var M=function(j){e(W,j);function W(){var re=j!==null&&j.apply(this,arguments)||this;return re.found=!1,re}return W.prototype.visitStartAnchor=function(re){this.found=!0},W}(t.BaseRegExpVisitor),T=i.filter(P,function(j){var W=j[a];try{var re=o.getRegExpAst(W),ce=new M;return ce.visit(re),ce.found}catch{return _.test(W.source)}}),k=i.map(T,function(j){return{message:`Unexpected RegExp Anchor Error:
+ Token Type: ->`+j.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:n.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[j]}});return k}r.findStartOfInputAnchor=v;function x(P){var M=i.filter(P,function(k){var j=k[a];return j instanceof RegExp&&(j.multiline||j.global)}),T=i.map(M,function(k){return{message:"Token Type: ->"+k.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:n.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[k]}});return T}r.findUnsupportedFlags=x;function S(P){var M=[],T=i.map(P,function(W){return i.reduce(P,function(re,ce){return W.PATTERN.source===ce.PATTERN.source&&!i.contains(M,ce)&&ce.PATTERN!==n.Lexer.NA&&(M.push(ce),re.push(ce)),re},[])});T=i.compact(T);var k=i.filter(T,function(W){return W.length>1}),j=i.map(k,function(W){var re=i.map(W,function(me){return me.name}),ce=i.first(W).PATTERN;return{message:"The same RegExp pattern ->"+ce+"<-"+("has been used in all of the following Token Types: "+re.join(", ")+" <-"),type:n.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenTypes:W}});return j}r.findDuplicatePatterns=S;function I(P){var M=i.filter(P,function(k){if(!i.has(k,"GROUP"))return!1;var j=k.GROUP;return j!==n.Lexer.SKIPPED&&j!==n.Lexer.NA&&!i.isString(j)}),T=i.map(M,function(k){return{message:"Token Type: ->"+k.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:n.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenTypes:[k]}});return T}r.findInvalidGroupType=I;function A(P,M){var T=i.filter(P,function(j){return j.PUSH_MODE!==void 0&&!i.contains(M,j.PUSH_MODE)}),k=i.map(T,function(j){var W="Token Type: ->"+j.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+j.PUSH_MODE+"<-which does not exist";return{message:W,type:n.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[j]}});return k}r.findModesThatDoNotExist=A;function C(P){var M=[],T=i.reduce(P,function(k,j,W){var re=j.PATTERN;return re===n.Lexer.NA||(i.isString(re)?k.push({str:re,idx:W,tokenType:j}):i.isRegExp(re)&&b(re)&&k.push({str:re.source,idx:W,tokenType:j})),k},[]);return i.forEach(P,function(k,j){i.forEach(T,function(W){var re=W.str,ce=W.idx,me=W.tokenType;if(j<ce&&E(re,k.PATTERN)){var w="Token: ->"+me.name+`<- can never be matched.
+`+("Because it appears AFTER the Token Type ->"+k.name+"<-")+`in the lexer's definition.
+See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;M.push({message:w,type:n.LexerDefinitionErrorType.UNREACHABLE_PATTERN,tokenTypes:[k,me]})}})}),M}r.findUnreachablePatterns=C;function E(P,M){if(i.isRegExp(M)){var T=M.exec(P);return T!==null&&T.index===0}else{if(i.isFunction(M))return M(P,0,[],{});if(i.has(M,"exec"))return M.exec(P,0,[],{});if(typeof M=="string")return M===P;throw Error("non exhaustive match")}}function b(P){var M=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return i.find(M,function(T){return P.source.indexOf(T)!==-1})===void 0}function R(P){var M=P.ignoreCase?"i":"";return new RegExp("^(?:"+P.source+")",M)}r.addStartOfInput=R;function N(P){var M=P.ignoreCase?"iy":"y";return new RegExp(""+P.source,M)}r.addStickyFlag=N;function B(P,M,T){var k=[];return i.has(P,r.DEFAULT_MODE)||k.push({message:"A MultiMode Lexer cannot be initialized without a <"+r.DEFAULT_MODE+`> property in its definition
+`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),i.has(P,r.MODES)||k.push({message:"A MultiMode Lexer cannot be initialized without a <"+r.MODES+`> property in its definition
+`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),i.has(P,r.MODES)&&i.has(P,r.DEFAULT_MODE)&&!i.has(P.modes,P.defaultMode)&&k.push({message:"A MultiMode Lexer cannot be initialized with a "+r.DEFAULT_MODE+": <"+P.defaultMode+`>which does not exist
+`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),i.has(P,r.MODES)&&i.forEach(P.modes,function(j,W){i.forEach(j,function(re,ce){i.isUndefined(re)&&k.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:"+("<"+W+"> at index: <"+ce+`>
+`),type:n.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})})}),k}r.performRuntimeChecks=B;function V(P,M,T){var k=[],j=!1,W=i.compact(i.flatten(i.mapValues(P.modes,function(me){return me}))),re=i.reject(W,function(me){return me[a]===n.Lexer.NA}),ce=ye(T);return M&&i.forEach(re,function(me){var w=q(me,ce);if(w!==!1){var ae=le(me,w),pe={message:ae,type:w.issue,tokenType:me};k.push(pe)}else i.has(me,"LINE_BREAKS")?me.LINE_BREAKS===!0&&(j=!0):s.canMatchCharCode(ce,me.PATTERN)&&(j=!0)}),M&&!j&&k.push({message:`Warning: No LINE_BREAKS Found.
This Lexer has been defined to track line and column information,
But none of the Token Types can be identified as matching a line terminator.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
- for details.`,type:n.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),V}r.performWarningRuntimeChecks=B;function ie(T){var S={},b=i.keys(T);return i.forEach(b,function(V){var q=T[V];if(i.isArray(q))S[V]=[];else throw Error("non exhaustive match")}),S}r.cloneEmptyGroups=ie;function $(T){var S=T.PATTERN;if(i.isRegExp(S))return!1;if(i.isFunction(S)||i.has(S,"exec"))return!0;if(i.isString(S))return!1;throw Error("non exhaustive match")}r.isCustomPattern=$;function te(T){return i.isString(T)&&T.length===1?T.charCodeAt(0):!1}r.isShortPattern=te,r.LineTerminatorOptimizedTester={test:function(T){for(var S=T.length,b=this.lastIndex;b<S;b++){var V=T.charCodeAt(b);if(V===10)return this.lastIndex=b+1,!0;if(V===13)return T.charCodeAt(b+1)===10?this.lastIndex=b+2:this.lastIndex=b+1,!0}return!1},lastIndex:0};function W(T,S){if(i.has(T,"LINE_BREAKS"))return!1;if(i.isRegExp(T.PATTERN)){try{s.canMatchCharCode(S,T.PATTERN)}catch(b){return{issue:n.LexerDefinitionErrorType.IDENTIFY_TERMINATOR,errMsg:b.message}}return!1}else{if(i.isString(T.PATTERN))return!1;if($(T))return{issue:n.LexerDefinitionErrorType.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function ae(T,S){if(S.issue===n.LexerDefinitionErrorType.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
-`+(" The problem is in the <"+T.name+`> Token Type
-`)+(" Root cause: "+S.errMsg+`.
-`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(S.issue===n.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
-`+(" The problem is in the <"+T.name+`> Token Type
-`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}r.buildLineBreakIssueMessage=ae;function de(T){var S=i.map(T,function(b){return i.isString(b)&&b.length>0?b.charCodeAt(0):b});return S}function ye(T,S,b){T[S]===void 0?T[S]=[b]:T[S].push(b)}r.minOptimizationVal=256;var Me=[];function ve(T){return T<r.minOptimizationVal?T:Me[T]}r.charCodeToOptimizedIndex=ve;function R(){if(i.isEmpty(Me)){Me=new Array(65536);for(var T=0;T<65536;T++)Me[T]=T>255?255+~~(T/255):T}}}),tc=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isTokenType=r.hasExtendingTokensTypesMapProperty=r.hasExtendingTokensTypesProperty=r.hasCategoriesProperty=r.hasShortKeyProperty=r.singleAssignCategoriesToksMap=r.assignCategoriesMapProp=r.assignCategoriesTokensProp=r.assignTokenDefaultProps=r.expandCategories=r.augmentTokenTypes=r.tokenIdxToClass=r.tokenShortNameIdx=r.tokenStructuredMatcherNoCategories=r.tokenStructuredMatcher=void 0;var e=Ut();function t(v,d){var m=v.tokenTypeIdx;return m===d.tokenTypeIdx?!0:d.isParent===!0&&d.categoryMatchesMap[m]===!0}r.tokenStructuredMatcher=t;function n(v,d){return v.tokenTypeIdx===d.tokenTypeIdx}r.tokenStructuredMatcherNoCategories=n,r.tokenShortNameIdx=1,r.tokenIdxToClass={};function i(v){var d=s(v);o(d),l(d),a(d),e.forEach(d,function(m){m.isParent=m.categoryMatches.length>0})}r.augmentTokenTypes=i;function s(v){for(var d=e.cloneArr(v),m=v,_=!0;_;){m=e.compact(e.flatten(e.map(m,function(x){return x.CATEGORIES})));var y=e.difference(m,d);d=d.concat(y),e.isEmpty(y)?_=!1:m=y}return d}r.expandCategories=s;function o(v){e.forEach(v,function(d){u(d)||(r.tokenIdxToClass[r.tokenShortNameIdx]=d,d.tokenTypeIdx=r.tokenShortNameIdx++),h(d)&&!e.isArray(d.CATEGORIES)&&(d.CATEGORIES=[d.CATEGORIES]),h(d)||(d.CATEGORIES=[]),f(d)||(d.categoryMatches=[]),p(d)||(d.categoryMatchesMap={})})}r.assignTokenDefaultProps=o;function a(v){e.forEach(v,function(d){d.categoryMatches=[],e.forEach(d.categoryMatchesMap,function(m,_){d.categoryMatches.push(r.tokenIdxToClass[_].tokenTypeIdx)})})}r.assignCategoriesTokensProp=a;function l(v){e.forEach(v,function(d){c([],d)})}r.assignCategoriesMapProp=l;function c(v,d){e.forEach(v,function(m){d.categoryMatchesMap[m.tokenTypeIdx]=!0}),e.forEach(d.CATEGORIES,function(m){var _=v.concat(d);e.contains(_,m)||c(_,m)})}r.singleAssignCategoriesToksMap=c;function u(v){return e.has(v,"tokenTypeIdx")}r.hasShortKeyProperty=u;function h(v){return e.has(v,"CATEGORIES")}r.hasCategoriesProperty=h;function f(v){return e.has(v,"categoryMatches")}r.hasExtendingTokensTypesProperty=f;function p(v){return e.has(v,"categoryMatchesMap")}r.hasExtendingTokensTypesMapProperty=p;function g(v){return e.has(v,"tokenTypeIdx")}r.isTokenType=g}),W0=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defaultLexerErrorProvider=void 0,r.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(e){return"Unable to pop Lexer Mode after encountering Token ->"+e.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(e,t,n,i,s){return"unexpected character: ->"+e.charAt(t)+"<- at offset: "+t+","+(" skipped "+n+" characters.")}}}),Ah=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Lexer=r.LexerDefinitionErrorType=void 0;var e=H0(),t=Ut(),n=tc(),i=W0(),s=sp(),o;(function(c){c[c.MISSING_PATTERN=0]="MISSING_PATTERN",c[c.INVALID_PATTERN=1]="INVALID_PATTERN",c[c.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",c[c.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",c[c.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",c[c.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",c[c.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",c[c.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",c[c.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",c[c.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",c[c.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",c[c.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",c[c.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",c[c.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",c[c.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",c[c.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",c[c.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"})(o=r.LexerDefinitionErrorType||(r.LexerDefinitionErrorType={}));var a={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
+ for details.`,type:n.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),k}r.performWarningRuntimeChecks=V;function ie(P){var M={},T=i.keys(P);return i.forEach(T,function(k){var j=P[k];if(i.isArray(j))M[k]=[];else throw Error("non exhaustive match")}),M}r.cloneEmptyGroups=ie;function Y(P){var M=P.PATTERN;if(i.isRegExp(M))return!1;if(i.isFunction(M)||i.has(M,"exec"))return!0;if(i.isString(M))return!1;throw Error("non exhaustive match")}r.isCustomPattern=Y;function te(P){return i.isString(P)&&P.length===1?P.charCodeAt(0):!1}r.isShortPattern=te,r.LineTerminatorOptimizedTester={test:function(P){for(var M=P.length,T=this.lastIndex;T<M;T++){var k=P.charCodeAt(T);if(k===10)return this.lastIndex=T+1,!0;if(k===13)return P.charCodeAt(T+1)===10?this.lastIndex=T+2:this.lastIndex=T+1,!0}return!1},lastIndex:0};function q(P,M){if(i.has(P,"LINE_BREAKS"))return!1;if(i.isRegExp(P.PATTERN)){try{s.canMatchCharCode(M,P.PATTERN)}catch(T){return{issue:n.LexerDefinitionErrorType.IDENTIFY_TERMINATOR,errMsg:T.message}}return!1}else{if(i.isString(P.PATTERN))return!1;if(Y(P))return{issue:n.LexerDefinitionErrorType.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function le(P,M){if(M.issue===n.LexerDefinitionErrorType.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
+`+(" The problem is in the <"+P.name+`> Token Type
+`)+(" Root cause: "+M.errMsg+`.
+`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(M.issue===n.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
+`+(" The problem is in the <"+P.name+`> Token Type
+`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}r.buildLineBreakIssueMessage=le;function ye(P){var M=i.map(P,function(T){return i.isString(T)&&T.length>0?T.charCodeAt(0):T});return M}function Te(P,M,T){P[M]===void 0?P[M]=[T]:P[M].push(T)}r.minOptimizationVal=256;var Ae=[];function _e(P){return P<r.minOptimizationVal?P:Ae[P]}r.charCodeToOptimizedIndex=_e;function G(){if(i.isEmpty(Ae)){Ae=new Array(65536);for(var P=0;P<65536;P++)Ae[P]=P>255?255+~~(P/255):P}}}),Vc=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isTokenType=r.hasExtendingTokensTypesMapProperty=r.hasExtendingTokensTypesProperty=r.hasCategoriesProperty=r.hasShortKeyProperty=r.singleAssignCategoriesToksMap=r.assignCategoriesMapProp=r.assignCategoriesTokensProp=r.assignTokenDefaultProps=r.expandCategories=r.augmentTokenTypes=r.tokenIdxToClass=r.tokenShortNameIdx=r.tokenStructuredMatcherNoCategories=r.tokenStructuredMatcher=void 0;var e=Wt();function t(y,d){var m=y.tokenTypeIdx;return m===d.tokenTypeIdx?!0:d.isParent===!0&&d.categoryMatchesMap[m]===!0}r.tokenStructuredMatcher=t;function n(y,d){return y.tokenTypeIdx===d.tokenTypeIdx}r.tokenStructuredMatcherNoCategories=n,r.tokenShortNameIdx=1,r.tokenIdxToClass={};function i(y){var d=s(y);o(d),l(d),a(d),e.forEach(d,function(m){m.isParent=m.categoryMatches.length>0})}r.augmentTokenTypes=i;function s(y){for(var d=e.cloneArr(y),m=y,_=!0;_;){m=e.compact(e.flatten(e.map(m,function(x){return x.CATEGORIES})));var v=e.difference(m,d);d=d.concat(v),e.isEmpty(v)?_=!1:m=v}return d}r.expandCategories=s;function o(y){e.forEach(y,function(d){u(d)||(r.tokenIdxToClass[r.tokenShortNameIdx]=d,d.tokenTypeIdx=r.tokenShortNameIdx++),h(d)&&!e.isArray(d.CATEGORIES)&&(d.CATEGORIES=[d.CATEGORIES]),h(d)||(d.CATEGORIES=[]),f(d)||(d.categoryMatches=[]),p(d)||(d.categoryMatchesMap={})})}r.assignTokenDefaultProps=o;function a(y){e.forEach(y,function(d){d.categoryMatches=[],e.forEach(d.categoryMatchesMap,function(m,_){d.categoryMatches.push(r.tokenIdxToClass[_].tokenTypeIdx)})})}r.assignCategoriesTokensProp=a;function l(y){e.forEach(y,function(d){c([],d)})}r.assignCategoriesMapProp=l;function c(y,d){e.forEach(y,function(m){d.categoryMatchesMap[m.tokenTypeIdx]=!0}),e.forEach(d.CATEGORIES,function(m){var _=y.concat(d);e.contains(_,m)||c(_,m)})}r.singleAssignCategoriesToksMap=c;function u(y){return e.has(y,"tokenTypeIdx")}r.hasShortKeyProperty=u;function h(y){return e.has(y,"CATEGORIES")}r.hasCategoriesProperty=h;function f(y){return e.has(y,"categoryMatches")}r.hasExtendingTokensTypesProperty=f;function p(y){return e.has(y,"categoryMatchesMap")}r.hasExtendingTokensTypesMapProperty=p;function g(y){return e.has(y,"tokenTypeIdx")}r.isTokenType=g}),nx=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defaultLexerErrorProvider=void 0,r.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(e){return"Unable to pop Lexer Mode after encountering Token ->"+e.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(e,t,n,i,s){return"unexpected character: ->"+e.charAt(t)+"<- at offset: "+t+","+(" skipped "+n+" characters.")}}}),Hf=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Lexer=r.LexerDefinitionErrorType=void 0;var e=tx(),t=Wt(),n=Vc(),i=nx(),s=Tm(),o;(function(c){c[c.MISSING_PATTERN=0]="MISSING_PATTERN",c[c.INVALID_PATTERN=1]="INVALID_PATTERN",c[c.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",c[c.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",c[c.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",c[c.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",c[c.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",c[c.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",c[c.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",c[c.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",c[c.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",c[c.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",c[c.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",c[c.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",c[c.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",c[c.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",c[c.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"})(o=r.LexerDefinitionErrorType||(r.LexerDefinitionErrorType={}));var a={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:i.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(a);var l=function(){function c(u,h){var f=this;if(h===void 0&&(h=a),this.lexerDefinition=u,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},typeof h=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
-a boolean 2nd argument is no longer supported`);this.config=t.merge(a,h);var p=this.config.traceInitPerf;p===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof p=="number"&&(this.traceInitMaxIdent=p,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",function(){var g,v=!0;f.TRACE_INIT("Lexer Config handling",function(){if(f.config.lineTerminatorsPattern===a.lineTerminatorsPattern)f.config.lineTerminatorsPattern=e.LineTerminatorOptimizedTester;else if(f.config.lineTerminatorCharacters===a.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(h.safeMode&&h.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');f.trackStartLines=/full|onlyStart/i.test(f.config.positionTracking),f.trackEndLines=/full/i.test(f.config.positionTracking),t.isArray(u)?(g={modes:{}},g.modes[e.DEFAULT_MODE]=t.cloneArr(u),g[e.DEFAULT_MODE]=e.DEFAULT_MODE):(v=!1,g=t.cloneObj(u))}),f.config.skipValidations===!1&&(f.TRACE_INIT("performRuntimeChecks",function(){f.lexerDefinitionErrors=f.lexerDefinitionErrors.concat(e.performRuntimeChecks(g,f.trackStartLines,f.config.lineTerminatorCharacters))}),f.TRACE_INIT("performWarningRuntimeChecks",function(){f.lexerDefinitionWarning=f.lexerDefinitionWarning.concat(e.performWarningRuntimeChecks(g,f.trackStartLines,f.config.lineTerminatorCharacters))})),g.modes=g.modes?g.modes:{},t.forEach(g.modes,function(y,x){g.modes[x]=t.reject(y,function(w){return t.isUndefined(w)})});var d=t.keys(g.modes);if(t.forEach(g.modes,function(y,x){f.TRACE_INIT("Mode: <"+x+"> processing",function(){if(f.modes.push(x),f.config.skipValidations===!1&&f.TRACE_INIT("validatePatterns",function(){f.lexerDefinitionErrors=f.lexerDefinitionErrors.concat(e.validatePatterns(y,d))}),t.isEmpty(f.lexerDefinitionErrors)){n.augmentTokenTypes(y);var w;f.TRACE_INIT("analyzeTokenTypes",function(){w=e.analyzeTokenTypes(y,{lineTerminatorCharacters:f.config.lineTerminatorCharacters,positionTracking:h.positionTracking,ensureOptimizations:h.ensureOptimizations,safeMode:h.safeMode,tracer:f.TRACE_INIT.bind(f)})}),f.patternIdxToConfig[x]=w.patternIdxToConfig,f.charCodeToPatternIdxToConfig[x]=w.charCodeToPatternIdxToConfig,f.emptyGroups=t.merge(f.emptyGroups,w.emptyGroups),f.hasCustom=w.hasCustom||f.hasCustom,f.canModeBeOptimized[x]=w.canBeOptimized}})}),f.defaultMode=g.defaultMode,!t.isEmpty(f.lexerDefinitionErrors)&&!f.config.deferDefinitionErrorsHandling){var m=t.map(f.lexerDefinitionErrors,function(y){return y.message}),_=m.join(`-----------------------
+a boolean 2nd argument is no longer supported`);this.config=t.merge(a,h);var p=this.config.traceInitPerf;p===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof p=="number"&&(this.traceInitMaxIdent=p,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",function(){var g,y=!0;f.TRACE_INIT("Lexer Config handling",function(){if(f.config.lineTerminatorsPattern===a.lineTerminatorsPattern)f.config.lineTerminatorsPattern=e.LineTerminatorOptimizedTester;else if(f.config.lineTerminatorCharacters===a.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(h.safeMode&&h.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');f.trackStartLines=/full|onlyStart/i.test(f.config.positionTracking),f.trackEndLines=/full/i.test(f.config.positionTracking),t.isArray(u)?(g={modes:{}},g.modes[e.DEFAULT_MODE]=t.cloneArr(u),g[e.DEFAULT_MODE]=e.DEFAULT_MODE):(y=!1,g=t.cloneObj(u))}),f.config.skipValidations===!1&&(f.TRACE_INIT("performRuntimeChecks",function(){f.lexerDefinitionErrors=f.lexerDefinitionErrors.concat(e.performRuntimeChecks(g,f.trackStartLines,f.config.lineTerminatorCharacters))}),f.TRACE_INIT("performWarningRuntimeChecks",function(){f.lexerDefinitionWarning=f.lexerDefinitionWarning.concat(e.performWarningRuntimeChecks(g,f.trackStartLines,f.config.lineTerminatorCharacters))})),g.modes=g.modes?g.modes:{},t.forEach(g.modes,function(v,x){g.modes[x]=t.reject(v,function(S){return t.isUndefined(S)})});var d=t.keys(g.modes);if(t.forEach(g.modes,function(v,x){f.TRACE_INIT("Mode: <"+x+"> processing",function(){if(f.modes.push(x),f.config.skipValidations===!1&&f.TRACE_INIT("validatePatterns",function(){f.lexerDefinitionErrors=f.lexerDefinitionErrors.concat(e.validatePatterns(v,d))}),t.isEmpty(f.lexerDefinitionErrors)){n.augmentTokenTypes(v);var S;f.TRACE_INIT("analyzeTokenTypes",function(){S=e.analyzeTokenTypes(v,{lineTerminatorCharacters:f.config.lineTerminatorCharacters,positionTracking:h.positionTracking,ensureOptimizations:h.ensureOptimizations,safeMode:h.safeMode,tracer:f.TRACE_INIT.bind(f)})}),f.patternIdxToConfig[x]=S.patternIdxToConfig,f.charCodeToPatternIdxToConfig[x]=S.charCodeToPatternIdxToConfig,f.emptyGroups=t.merge(f.emptyGroups,S.emptyGroups),f.hasCustom=S.hasCustom||f.hasCustom,f.canModeBeOptimized[x]=S.canBeOptimized}})}),f.defaultMode=g.defaultMode,!t.isEmpty(f.lexerDefinitionErrors)&&!f.config.deferDefinitionErrorsHandling){var m=t.map(f.lexerDefinitionErrors,function(v){return v.message}),_=m.join(`-----------------------
`);throw new Error(`Errors detected in definition of Lexer:
-`+_)}t.forEach(f.lexerDefinitionWarning,function(y){t.PRINT_WARNING(y.message)}),f.TRACE_INIT("Choosing sub-methods implementations",function(){if(e.SUPPORT_STICKY?(f.chopInput=t.IDENTITY,f.match=f.matchWithTest):(f.updateLastIndex=t.NOOP,f.match=f.matchWithExec),v&&(f.handleModes=t.NOOP),f.trackStartLines===!1&&(f.computeNewColumn=t.IDENTITY),f.trackEndLines===!1&&(f.updateTokenEndLineColumnLocation=t.NOOP),/full/i.test(f.config.positionTracking))f.createTokenInstance=f.createFullToken;else if(/onlyStart/i.test(f.config.positionTracking))f.createTokenInstance=f.createStartOnlyToken;else if(/onlyOffset/i.test(f.config.positionTracking))f.createTokenInstance=f.createOffsetOnlyToken;else throw Error('Invalid <positionTracking> config option: "'+f.config.positionTracking+'"');f.hasCustom?(f.addToken=f.addTokenUsingPush,f.handlePayload=f.handlePayloadWithCustom):(f.addToken=f.addTokenUsingMemberAccess,f.handlePayload=f.handlePayloadNoCustom)}),f.TRACE_INIT("Failed Optimization Warnings",function(){var y=t.reduce(f.canModeBeOptimized,function(x,w,I){return w===!1&&x.push(I),x},[]);if(h.ensureOptimizations&&!t.isEmpty(y))throw Error("Lexer Modes: < "+y.join(", ")+` > cannot be optimized.
+`+_)}t.forEach(f.lexerDefinitionWarning,function(v){t.PRINT_WARNING(v.message)}),f.TRACE_INIT("Choosing sub-methods implementations",function(){if(e.SUPPORT_STICKY?(f.chopInput=t.IDENTITY,f.match=f.matchWithTest):(f.updateLastIndex=t.NOOP,f.match=f.matchWithExec),y&&(f.handleModes=t.NOOP),f.trackStartLines===!1&&(f.computeNewColumn=t.IDENTITY),f.trackEndLines===!1&&(f.updateTokenEndLineColumnLocation=t.NOOP),/full/i.test(f.config.positionTracking))f.createTokenInstance=f.createFullToken;else if(/onlyStart/i.test(f.config.positionTracking))f.createTokenInstance=f.createStartOnlyToken;else if(/onlyOffset/i.test(f.config.positionTracking))f.createTokenInstance=f.createOffsetOnlyToken;else throw Error('Invalid <positionTracking> config option: "'+f.config.positionTracking+'"');f.hasCustom?(f.addToken=f.addTokenUsingPush,f.handlePayload=f.handlePayloadWithCustom):(f.addToken=f.addTokenUsingMemberAccess,f.handlePayload=f.handlePayloadNoCustom)}),f.TRACE_INIT("Failed Optimization Warnings",function(){var v=t.reduce(f.canModeBeOptimized,function(x,S,I){return S===!1&&x.push(I),x},[]);if(h.ensureOptimizations&&!t.isEmpty(v))throw Error("Lexer Modes: < "+v.join(", ")+` > cannot be optimized.
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
- Or inspect the console log for details on how to resolve these issues.`)}),f.TRACE_INIT("clearRegExpParserCache",function(){s.clearRegExpParserCache()}),f.TRACE_INIT("toFastProperties",function(){t.toFastProperties(f)})})}return c.prototype.tokenize=function(u,h){if(h===void 0&&(h=this.defaultMode),!t.isEmpty(this.lexerDefinitionErrors)){var f=t.map(this.lexerDefinitionErrors,function(v){return v.message}),p=f.join(`-----------------------
+ Or inspect the console log for details on how to resolve these issues.`)}),f.TRACE_INIT("clearRegExpParserCache",function(){s.clearRegExpParserCache()}),f.TRACE_INIT("toFastProperties",function(){t.toFastProperties(f)})})}return c.prototype.tokenize=function(u,h){if(h===void 0&&(h=this.defaultMode),!t.isEmpty(this.lexerDefinitionErrors)){var f=t.map(this.lexerDefinitionErrors,function(y){return y.message}),p=f.join(`-----------------------
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
-`+p)}var g=this.tokenizeInternal(u,h);return g},c.prototype.tokenizeInternal=function(u,h){var f=this,p,g,v,d,m,_,y,x,w,I,C,P,E,M,L,N=u,O=N.length,B=0,ie=0,$=this.hasCustom?0:Math.floor(u.length/10),te=new Array($),W=[],ae=this.trackStartLines?1:void 0,de=this.trackStartLines?1:void 0,ye=e.cloneEmptyGroups(this.emptyGroups),Me=this.trackStartLines,ve=this.config.lineTerminatorsPattern,R=0,T=[],S=[],b=[],V=[];Object.freeze(V);var q=void 0;function Y(){return T}function z(fe){var ge=e.charCodeToOptimizedIndex(fe),Ae=S[ge];return Ae===void 0?V:Ae}var X=function(fe){if(b.length===1&&fe.tokenType.PUSH_MODE===void 0){var ge=f.config.errorMessageProvider.buildUnableToPopLexerModeMessage(fe);W.push({offset:fe.startOffset,line:fe.startLine!==void 0?fe.startLine:void 0,column:fe.startColumn!==void 0?fe.startColumn:void 0,length:fe.image.length,message:ge})}else{b.pop();var Ae=t.last(b);T=f.patternIdxToConfig[Ae],S=f.charCodeToPatternIdxToConfig[Ae],R=T.length;var Ie=f.canModeBeOptimized[Ae]&&f.config.safeMode===!1;S&&Ie?q=z:q=Y}};function se(fe){b.push(fe),S=this.charCodeToPatternIdxToConfig[fe],T=this.patternIdxToConfig[fe],R=T.length,R=T.length;var ge=this.canModeBeOptimized[fe]&&this.config.safeMode===!1;S&&ge?q=z:q=Y}se.call(this,h);for(var re;B<O;){m=null;var le=N.charCodeAt(B),xe=q(le),G=xe.length;for(p=0;p<G;p++){re=xe[p];var A=re.pattern;_=null;var U=re.short;if(U!==!1?le===U&&(m=A):re.isCustom===!0?(L=A.exec(N,B,te,ye),L!==null?(m=L[0],L.payload!==void 0&&(_=L.payload)):m=null):(this.updateLastIndex(A,B),m=this.match(A,u,B)),m!==null){if(d=re.longerAlt,d!==void 0){var he=T[d],me=he.pattern;y=null,he.isCustom===!0?(L=me.exec(N,B,te,ye),L!==null?(v=L[0],L.payload!==void 0&&(y=L.payload)):v=null):(this.updateLastIndex(me,B),v=this.match(me,u,B)),v&&v.length>m.length&&(m=v,_=y,re=he)}break}}if(m!==null){if(x=m.length,w=re.group,w!==void 0&&(I=re.tokenTypeIdx,C=this.createTokenInstance(m,B,I,re.tokenType,ae,de,x),this.handlePayload(C,_),w===!1?ie=this.addToken(te,ie,C):ye[w].push(C)),u=this.chopInput(u,x),B=B+x,de=this.computeNewColumn(de,x),Me===!0&&re.canLineTerminator===!0){var Te=0,ee=void 0,k=void 0;ve.lastIndex=0;do ee=ve.test(m),ee===!0&&(k=ve.lastIndex-1,Te++);while(ee===!0);Te!==0&&(ae=ae+Te,de=x-k,this.updateTokenEndLineColumnLocation(C,w,k,Te,ae,de,x))}this.handleModes(re,X,se,C)}else{for(var J=B,ue=ae,Z=de,ce=!1;!ce&&B<O;)for(E=N.charCodeAt(B),u=this.chopInput(u,1),B++,g=0;g<R;g++){var pe=T[g],A=pe.pattern,U=pe.short;if(U!==!1?N.charCodeAt(B)===U&&(ce=!0):pe.isCustom===!0?ce=A.exec(N,B,te,ye)!==null:(this.updateLastIndex(A,B),ce=A.exec(u)!==null),ce===!0)break}P=B-J,M=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(N,J,P,ue,Z),W.push({offset:J,line:ue,column:Z,length:P,message:M})}}return this.hasCustom||(te.length=ie),{tokens:te,groups:ye,errors:W}},c.prototype.handleModes=function(u,h,f,p){if(u.pop===!0){var g=u.push;h(p),g!==void 0&&f.call(this,g)}else u.push!==void 0&&f.call(this,u.push)},c.prototype.chopInput=function(u,h){return u.substring(h)},c.prototype.updateLastIndex=function(u,h){u.lastIndex=h},c.prototype.updateTokenEndLineColumnLocation=function(u,h,f,p,g,v,d){var m,_;h!==void 0&&(m=f===d-1,_=m?-1:0,p===1&&m===!0||(u.endLine=g+_,u.endColumn=v-1+-_))},c.prototype.computeNewColumn=function(u,h){return u+h},c.prototype.createTokenInstance=function(){for(var u=[],h=0;h<arguments.length;h++)u[h]=arguments[h];return null},c.prototype.createOffsetOnlyToken=function(u,h,f,p){return{image:u,startOffset:h,tokenTypeIdx:f,tokenType:p}},c.prototype.createStartOnlyToken=function(u,h,f,p,g,v){return{image:u,startOffset:h,startLine:g,startColumn:v,tokenTypeIdx:f,tokenType:p}},c.prototype.createFullToken=function(u,h,f,p,g,v,d){return{image:u,startOffset:h,endOffset:h+d-1,startLine:g,endLine:g,startColumn:v,endColumn:v+d-1,tokenTypeIdx:f,tokenType:p}},c.prototype.addToken=function(u,h,f){return 666},c.prototype.addTokenUsingPush=function(u,h,f){return u.push(f),h},c.prototype.addTokenUsingMemberAccess=function(u,h,f){return u[h]=f,h++,h},c.prototype.handlePayload=function(u,h){},c.prototype.handlePayloadNoCustom=function(u,h){},c.prototype.handlePayloadWithCustom=function(u,h){h!==null&&(u.payload=h)},c.prototype.match=function(u,h,f){return null},c.prototype.matchWithTest=function(u,h,f){var p=u.test(h);return p===!0?h.substring(f,u.lastIndex):null},c.prototype.matchWithExec=function(u,h){var f=u.exec(h);return f!==null?f[0]:f},c.prototype.TRACE_INIT=function(u,h){if(this.traceInitPerf===!0){this.traceInitIndent++;var f=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(f+"--> <"+u+">");var p=t.timer(h),g=p.time,v=p.value,d=g>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&d(f+"<-- <"+u+"> time: "+g+"ms"),this.traceInitIndent--,v}else return h()},c.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",c.NA=/NOT_APPLICABLE/,c}();r.Lexer=l}),io=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.tokenMatcher=r.createTokenInstance=r.EOF=r.createToken=r.hasTokenLabel=r.tokenName=r.tokenLabel=void 0;var e=Ut(),t=Ah(),n=tc();function i(x){return o(x)?x.LABEL:x.name}r.tokenLabel=i;function s(x){return x.name}r.tokenName=s;function o(x){return e.isString(x.LABEL)&&x.LABEL!==""}r.hasTokenLabel=o;var a="parent",l="categories",c="label",u="group",h="push_mode",f="pop_mode",p="longer_alt",g="line_breaks",v="start_chars_hint";function d(x){return m(x)}r.createToken=d;function m(x){var w=x.pattern,I={};if(I.name=x.name,e.isUndefined(w)||(I.PATTERN=w),e.has(x,a))throw`The parent property is no longer supported.
-See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return e.has(x,l)&&(I.CATEGORIES=x[l]),n.augmentTokenTypes([I]),e.has(x,c)&&(I.LABEL=x[c]),e.has(x,u)&&(I.GROUP=x[u]),e.has(x,f)&&(I.POP_MODE=x[f]),e.has(x,h)&&(I.PUSH_MODE=x[h]),e.has(x,p)&&(I.LONGER_ALT=x[p]),e.has(x,g)&&(I.LINE_BREAKS=x[g]),e.has(x,v)&&(I.START_CHARS_HINT=x[v]),I}r.EOF=d({name:"EOF",pattern:t.Lexer.NA}),n.augmentTokenTypes([r.EOF]);function _(x,w,I,C,P,E,M,L){return{image:w,startOffset:I,endOffset:C,startLine:P,endLine:E,startColumn:M,endColumn:L,tokenTypeIdx:x.tokenTypeIdx,tokenType:x}}r.createTokenInstance=_;function y(x,w){return n.tokenStructuredMatcher(x,w)}r.tokenMatcher=y}),xi=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var m=function(_,y){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,w){x.__proto__=w}||function(x,w){for(var I in w)Object.prototype.hasOwnProperty.call(w,I)&&(x[I]=w[I])},m(_,y)};return function(_,y){if(typeof y!="function"&&y!==null)throw new TypeError("Class extends value "+String(y)+" is not a constructor or null");m(_,y);function x(){this.constructor=_}_.prototype=y===null?Object.create(y):(x.prototype=y.prototype,new x)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.serializeProduction=r.serializeGrammar=r.Terminal=r.Alternation=r.RepetitionWithSeparator=r.Repetition=r.RepetitionMandatoryWithSeparator=r.RepetitionMandatory=r.Option=r.Alternative=r.Rule=r.NonTerminal=r.AbstractProduction=void 0;var t=Ut(),n=io(),i=function(){function m(_){this._definition=_}return Object.defineProperty(m.prototype,"definition",{get:function(){return this._definition},set:function(_){this._definition=_},enumerable:!1,configurable:!0}),m.prototype.accept=function(_){_.visit(this),t.forEach(this.definition,function(y){y.accept(_)})},m}();r.AbstractProduction=i;var s=function(m){e(_,m);function _(y){var x=m.call(this,[])||this;return x.idx=1,t.assign(x,t.pick(y,function(w){return w!==void 0})),x}return Object.defineProperty(_.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(y){},enumerable:!1,configurable:!0}),_.prototype.accept=function(y){y.visit(this)},_}(i);r.NonTerminal=s;var o=function(m){e(_,m);function _(y){var x=m.call(this,y.definition)||this;return x.orgText="",t.assign(x,t.pick(y,function(w){return w!==void 0})),x}return _}(i);r.Rule=o;var a=function(m){e(_,m);function _(y){var x=m.call(this,y.definition)||this;return x.ignoreAmbiguities=!1,t.assign(x,t.pick(y,function(w){return w!==void 0})),x}return _}(i);r.Alternative=a;var l=function(m){e(_,m);function _(y){var x=m.call(this,y.definition)||this;return x.idx=1,t.assign(x,t.pick(y,function(w){return w!==void 0})),x}return _}(i);r.Option=l;var c=function(m){e(_,m);function _(y){var x=m.call(this,y.definition)||this;return x.idx=1,t.assign(x,t.pick(y,function(w){return w!==void 0})),x}return _}(i);r.RepetitionMandatory=c;var u=function(m){e(_,m);function _(y){var x=m.call(this,y.definition)||this;return x.idx=1,t.assign(x,t.pick(y,function(w){return w!==void 0})),x}return _}(i);r.RepetitionMandatoryWithSeparator=u;var h=function(m){e(_,m);function _(y){var x=m.call(this,y.definition)||this;return x.idx=1,t.assign(x,t.pick(y,function(w){return w!==void 0})),x}return _}(i);r.Repetition=h;var f=function(m){e(_,m);function _(y){var x=m.call(this,y.definition)||this;return x.idx=1,t.assign(x,t.pick(y,function(w){return w!==void 0})),x}return _}(i);r.RepetitionWithSeparator=f;var p=function(m){e(_,m);function _(y){var x=m.call(this,y.definition)||this;return x.idx=1,x.ignoreAmbiguities=!1,x.hasPredicates=!1,t.assign(x,t.pick(y,function(w){return w!==void 0})),x}return Object.defineProperty(_.prototype,"definition",{get:function(){return this._definition},set:function(y){this._definition=y},enumerable:!1,configurable:!0}),_}(i);r.Alternation=p;var g=function(){function m(_){this.idx=1,t.assign(this,t.pick(_,function(y){return y!==void 0}))}return m.prototype.accept=function(_){_.visit(this)},m}();r.Terminal=g;function v(m){return t.map(m,d)}r.serializeGrammar=v;function d(m){function _(w){return t.map(w,d)}if(m instanceof s)return{type:"NonTerminal",name:m.nonTerminalName,idx:m.idx};if(m instanceof a)return{type:"Alternative",definition:_(m.definition)};if(m instanceof l)return{type:"Option",idx:m.idx,definition:_(m.definition)};if(m instanceof c)return{type:"RepetitionMandatory",idx:m.idx,definition:_(m.definition)};if(m instanceof u)return{type:"RepetitionMandatoryWithSeparator",idx:m.idx,separator:d(new g({terminalType:m.separator})),definition:_(m.definition)};if(m instanceof f)return{type:"RepetitionWithSeparator",idx:m.idx,separator:d(new g({terminalType:m.separator})),definition:_(m.definition)};if(m instanceof h)return{type:"Repetition",idx:m.idx,definition:_(m.definition)};if(m instanceof p)return{type:"Alternation",idx:m.idx,definition:_(m.definition)};if(m instanceof g){var y={type:"Terminal",name:m.terminalType.name,label:n.tokenLabel(m.terminalType),idx:m.idx},x=m.terminalType.PATTERN;return m.terminalType.PATTERN&&(y.pattern=t.isRegExp(x)?x.source:x),y}else{if(m instanceof o)return{type:"Rule",name:m.name,orgText:m.orgText,definition:_(m.definition)};throw Error("non exhaustive match")}}r.serializeProduction=d}),op=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.RestWalker=void 0;var e=Ut(),t=xi(),n=function(){function s(){}return s.prototype.walk=function(o,a){var l=this;a===void 0&&(a=[]),e.forEach(o.definition,function(c,u){var h=e.drop(o.definition,u+1);if(c instanceof t.NonTerminal)l.walkProdRef(c,h,a);else if(c instanceof t.Terminal)l.walkTerminal(c,h,a);else if(c instanceof t.Alternative)l.walkFlat(c,h,a);else if(c instanceof t.Option)l.walkOption(c,h,a);else if(c instanceof t.RepetitionMandatory)l.walkAtLeastOne(c,h,a);else if(c instanceof t.RepetitionMandatoryWithSeparator)l.walkAtLeastOneSep(c,h,a);else if(c instanceof t.RepetitionWithSeparator)l.walkManySep(c,h,a);else if(c instanceof t.Repetition)l.walkMany(c,h,a);else if(c instanceof t.Alternation)l.walkOr(c,h,a);else throw Error("non exhaustive match")})},s.prototype.walkTerminal=function(o,a,l){},s.prototype.walkProdRef=function(o,a,l){},s.prototype.walkFlat=function(o,a,l){var c=a.concat(l);this.walk(o,c)},s.prototype.walkOption=function(o,a,l){var c=a.concat(l);this.walk(o,c)},s.prototype.walkAtLeastOne=function(o,a,l){var c=[new t.Option({definition:o.definition})].concat(a,l);this.walk(o,c)},s.prototype.walkAtLeastOneSep=function(o,a,l){var c=i(o,a,l);this.walk(o,c)},s.prototype.walkMany=function(o,a,l){var c=[new t.Option({definition:o.definition})].concat(a,l);this.walk(o,c)},s.prototype.walkManySep=function(o,a,l){var c=i(o,a,l);this.walk(o,c)},s.prototype.walkOr=function(o,a,l){var c=this,u=a.concat(l);e.forEach(o.definition,function(h){var f=new t.Alternative({definition:[h]});c.walk(f,u)})},s}();r.RestWalker=n;function i(s,o,a){var l=[new t.Option({definition:[new t.Terminal({terminalType:s.separator})].concat(s.definition)})],c=l.concat(o,a);return c}}),nc=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GAstVisitor=void 0;var e=xi(),t=function(){function n(){}return n.prototype.visit=function(i){var s=i;switch(s.constructor){case e.NonTerminal:return this.visitNonTerminal(s);case e.Alternative:return this.visitAlternative(s);case e.Option:return this.visitOption(s);case e.RepetitionMandatory:return this.visitRepetitionMandatory(s);case e.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(s);case e.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(s);case e.Repetition:return this.visitRepetition(s);case e.Alternation:return this.visitAlternation(s);case e.Terminal:return this.visitTerminal(s);case e.Rule:return this.visitRule(s);default:throw Error("non exhaustive match")}},n.prototype.visitNonTerminal=function(i){},n.prototype.visitAlternative=function(i){},n.prototype.visitOption=function(i){},n.prototype.visitRepetition=function(i){},n.prototype.visitRepetitionMandatory=function(i){},n.prototype.visitRepetitionMandatoryWithSeparator=function(i){},n.prototype.visitRepetitionWithSeparator=function(i){},n.prototype.visitAlternation=function(i){},n.prototype.visitTerminal=function(i){},n.prototype.visitRule=function(i){},n}();r.GAstVisitor=t}),wh=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var f=function(p,g){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,d){v.__proto__=d}||function(v,d){for(var m in d)Object.prototype.hasOwnProperty.call(d,m)&&(v[m]=d[m])},f(p,g)};return function(p,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");f(p,g);function v(){this.constructor=p}p.prototype=g===null?Object.create(g):(v.prototype=g.prototype,new v)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.collectMethods=r.DslMethodsCollectorVisitor=r.getProductionDslName=r.isBranchingProd=r.isOptionalProd=r.isSequenceProd=void 0;var t=Ut(),n=xi(),i=nc();function s(f){return f instanceof n.Alternative||f instanceof n.Option||f instanceof n.Repetition||f instanceof n.RepetitionMandatory||f instanceof n.RepetitionMandatoryWithSeparator||f instanceof n.RepetitionWithSeparator||f instanceof n.Terminal||f instanceof n.Rule}r.isSequenceProd=s;function o(f,p){p===void 0&&(p=[]);var g=f instanceof n.Option||f instanceof n.Repetition||f instanceof n.RepetitionWithSeparator;return g?!0:f instanceof n.Alternation?t.some(f.definition,function(v){return o(v,p)}):f instanceof n.NonTerminal&&t.contains(p,f)?!1:f instanceof n.AbstractProduction?(f instanceof n.NonTerminal&&p.push(f),t.every(f.definition,function(v){return o(v,p)})):!1}r.isOptionalProd=o;function a(f){return f instanceof n.Alternation}r.isBranchingProd=a;function l(f){if(f instanceof n.NonTerminal)return"SUBRULE";if(f instanceof n.Option)return"OPTION";if(f instanceof n.Alternation)return"OR";if(f instanceof n.RepetitionMandatory)return"AT_LEAST_ONE";if(f instanceof n.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(f instanceof n.RepetitionWithSeparator)return"MANY_SEP";if(f instanceof n.Repetition)return"MANY";if(f instanceof n.Terminal)return"CONSUME";throw Error("non exhaustive match")}r.getProductionDslName=l;var c=function(f){e(p,f);function p(){var g=f!==null&&f.apply(this,arguments)||this;return g.separator="-",g.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},g}return p.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},p.prototype.visitTerminal=function(g){var v=g.terminalType.name+this.separator+"Terminal";t.has(this.dslMethods,v)||(this.dslMethods[v]=[]),this.dslMethods[v].push(g)},p.prototype.visitNonTerminal=function(g){var v=g.nonTerminalName+this.separator+"Terminal";t.has(this.dslMethods,v)||(this.dslMethods[v]=[]),this.dslMethods[v].push(g)},p.prototype.visitOption=function(g){this.dslMethods.option.push(g)},p.prototype.visitRepetitionWithSeparator=function(g){this.dslMethods.repetitionWithSeparator.push(g)},p.prototype.visitRepetitionMandatory=function(g){this.dslMethods.repetitionMandatory.push(g)},p.prototype.visitRepetitionMandatoryWithSeparator=function(g){this.dslMethods.repetitionMandatoryWithSeparator.push(g)},p.prototype.visitRepetition=function(g){this.dslMethods.repetition.push(g)},p.prototype.visitAlternation=function(g){this.dslMethods.alternation.push(g)},p}(i.GAstVisitor);r.DslMethodsCollectorVisitor=c;var u=new c;function h(f){u.reset(),f.accept(u);var p=u.dslMethods;return u.reset(),p}r.collectMethods=h}),X0=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.firstForTerminal=r.firstForBranching=r.firstForSequence=r.first=void 0;var e=Ut(),t=xi(),n=wh();function i(l){if(l instanceof t.NonTerminal)return i(l.referencedRule);if(l instanceof t.Terminal)return a(l);if(n.isSequenceProd(l))return s(l);if(n.isBranchingProd(l))return o(l);throw Error("non exhaustive match")}r.first=i;function s(l){for(var c=[],u=l.definition,h=0,f=u.length>h,p,g=!0;f&&g;)p=u[h],g=n.isOptionalProd(p),c=c.concat(i(p)),h=h+1,f=u.length>h;return e.uniq(c)}r.firstForSequence=s;function o(l){var c=e.map(l.definition,function(u){return i(u)});return e.uniq(e.flatten(c))}r.firstForBranching=o;function a(l){return[l.terminalType]}r.firstForTerminal=a}),j0=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IN=void 0,r.IN="_~IN~_"}),pS=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var h=function(f,p){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,v){g.__proto__=v}||function(g,v){for(var d in v)Object.prototype.hasOwnProperty.call(v,d)&&(g[d]=v[d])},h(f,p)};return function(f,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");h(f,p);function g(){this.constructor=f}f.prototype=p===null?Object.create(p):(g.prototype=p.prototype,new g)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.buildInProdFollowPrefix=r.buildBetweenProdsFollowPrefix=r.computeAllProdsFollows=r.ResyncFollowsWalker=void 0;var t=op(),n=X0(),i=Ut(),s=j0(),o=xi(),a=function(h){e(f,h);function f(p){var g=h.call(this)||this;return g.topProd=p,g.follows={},g}return f.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},f.prototype.walkTerminal=function(p,g,v){},f.prototype.walkProdRef=function(p,g,v){var d=c(p.referencedRule,p.idx)+this.topProd.name,m=g.concat(v),_=new o.Alternative({definition:m}),y=n.first(_);this.follows[d]=y},f}(t.RestWalker);r.ResyncFollowsWalker=a;function l(h){var f={};return i.forEach(h,function(p){var g=new a(p).startWalking();i.assign(f,g)}),f}r.computeAllProdsFollows=l;function c(h,f){return h.name+f+s.IN}r.buildBetweenProdsFollowPrefix=c;function u(h){var f=h.terminalType.name;return f+h.idx+s.IN}r.buildInProdFollowPrefix=u}),Ch=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defaultGrammarValidatorErrorProvider=r.defaultGrammarResolverErrorProvider=r.defaultParserErrorProvider=void 0;var e=io(),t=Ut(),n=Ut(),i=xi(),s=wh();r.defaultParserErrorProvider={buildMismatchTokenMessage:function(o){var a=o.expected,l=o.actual,c=o.previous,u=o.ruleName,h=e.hasTokenLabel(a),f=h?"--> "+e.tokenLabel(a)+" <--":"token of type --> "+a.name+" <--",p="Expecting "+f+" but found --> '"+l.image+"' <--";return p},buildNotAllInputParsedMessage:function(o){var a=o.firstRedundant,l=o.ruleName;return"Redundant input, expecting EOF but found: "+a.image},buildNoViableAltMessage:function(o){var a=o.expectedPathsPerAlt,l=o.actual,c=o.previous,u=o.customUserDescription,h=o.ruleName,f="Expecting: ",p=n.first(l).image,g=`
-but found: '`+p+"'";if(u)return f+u+g;var v=n.reduce(a,function(y,x){return y.concat(x)},[]),d=n.map(v,function(y){return"["+n.map(y,function(x){return e.tokenLabel(x)}).join(", ")+"]"}),m=n.map(d,function(y,x){return" "+(x+1)+". "+y}),_=`one of these possible Token sequences:
+`+p)}var g=this.tokenizeInternal(u,h);return g},c.prototype.tokenizeInternal=function(u,h){var f=this,p,g,y,d,m,_,v,x,S,I,A,C,E,b,R,N=u,B=N.length,V=0,ie=0,Y=this.hasCustom?0:Math.floor(u.length/10),te=new Array(Y),q=[],le=this.trackStartLines?1:void 0,ye=this.trackStartLines?1:void 0,Te=e.cloneEmptyGroups(this.emptyGroups),Ae=this.trackStartLines,_e=this.config.lineTerminatorsPattern,G=0,P=[],M=[],T=[],k=[];Object.freeze(k);var j=void 0;function W(){return P}function re(ge){var de=e.charCodeToOptimizedIndex(ge),Ee=M[de];return Ee===void 0?k:Ee}var ce=function(ge){if(T.length===1&&ge.tokenType.PUSH_MODE===void 0){var de=f.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ge);q.push({offset:ge.startOffset,line:ge.startLine!==void 0?ge.startLine:void 0,column:ge.startColumn!==void 0?ge.startColumn:void 0,length:ge.image.length,message:de})}else{T.pop();var Ee=t.last(T);P=f.patternIdxToConfig[Ee],M=f.charCodeToPatternIdxToConfig[Ee],G=P.length;var Re=f.canModeBeOptimized[Ee]&&f.config.safeMode===!1;M&&Re?j=re:j=W}};function me(ge){T.push(ge),M=this.charCodeToPatternIdxToConfig[ge],P=this.patternIdxToConfig[ge],G=P.length,G=P.length;var de=this.canModeBeOptimized[ge]&&this.config.safeMode===!1;M&&de?j=re:j=W}me.call(this,h);for(var w;V<B;){m=null;var ae=N.charCodeAt(V),pe=j(ae),ue=pe.length;for(p=0;p<ue;p++){w=pe[p];var ee=w.pattern;_=null;var $=w.short;if($!==!1?ae===$&&(m=ee):w.isCustom===!0?(R=ee.exec(N,V,te,Te),R!==null?(m=R[0],R.payload!==void 0&&(_=R.payload)):m=null):(this.updateLastIndex(ee,V),m=this.match(ee,u,V)),m!==null){if(d=w.longerAlt,d!==void 0){var ve=P[d],H=ve.pattern;v=null,ve.isCustom===!0?(R=H.exec(N,V,te,Te),R!==null?(y=R[0],R.payload!==void 0&&(v=R.payload)):y=null):(this.updateLastIndex(H,V),y=this.match(H,u,V)),y&&y.length>m.length&&(m=y,_=v,w=ve)}break}}if(m!==null){if(x=m.length,S=w.group,S!==void 0&&(I=w.tokenTypeIdx,A=this.createTokenInstance(m,V,I,w.tokenType,le,ye,x),this.handlePayload(A,_),S===!1?ie=this.addToken(te,ie,A):Te[S].push(A)),u=this.chopInput(u,x),V=V+x,ye=this.computeNewColumn(ye,x),Ae===!0&&w.canLineTerminator===!0){var L=0,O=void 0,D=void 0;_e.lastIndex=0;do O=_e.test(m),O===!0&&(D=_e.lastIndex-1,L++);while(O===!0);L!==0&&(le=le+L,ye=x-D,this.updateTokenEndLineColumnLocation(A,S,D,L,le,ye,x))}this.handleModes(w,ce,me,A)}else{for(var z=V,Q=le,ne=ye,oe=!1;!oe&&V<B;)for(E=N.charCodeAt(V),u=this.chopInput(u,1),V++,g=0;g<G;g++){var he=P[g],ee=he.pattern,$=he.short;if($!==!1?N.charCodeAt(V)===$&&(oe=!0):he.isCustom===!0?oe=ee.exec(N,V,te,Te)!==null:(this.updateLastIndex(ee,V),oe=ee.exec(u)!==null),oe===!0)break}C=V-z,b=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(N,z,C,Q,ne),q.push({offset:z,line:Q,column:ne,length:C,message:b})}}return this.hasCustom||(te.length=ie),{tokens:te,groups:Te,errors:q}},c.prototype.handleModes=function(u,h,f,p){if(u.pop===!0){var g=u.push;h(p),g!==void 0&&f.call(this,g)}else u.push!==void 0&&f.call(this,u.push)},c.prototype.chopInput=function(u,h){return u.substring(h)},c.prototype.updateLastIndex=function(u,h){u.lastIndex=h},c.prototype.updateTokenEndLineColumnLocation=function(u,h,f,p,g,y,d){var m,_;h!==void 0&&(m=f===d-1,_=m?-1:0,p===1&&m===!0||(u.endLine=g+_,u.endColumn=y-1+-_))},c.prototype.computeNewColumn=function(u,h){return u+h},c.prototype.createTokenInstance=function(){for(var u=[],h=0;h<arguments.length;h++)u[h]=arguments[h];return null},c.prototype.createOffsetOnlyToken=function(u,h,f,p){return{image:u,startOffset:h,tokenTypeIdx:f,tokenType:p}},c.prototype.createStartOnlyToken=function(u,h,f,p,g,y){return{image:u,startOffset:h,startLine:g,startColumn:y,tokenTypeIdx:f,tokenType:p}},c.prototype.createFullToken=function(u,h,f,p,g,y,d){return{image:u,startOffset:h,endOffset:h+d-1,startLine:g,endLine:g,startColumn:y,endColumn:y+d-1,tokenTypeIdx:f,tokenType:p}},c.prototype.addToken=function(u,h,f){return 666},c.prototype.addTokenUsingPush=function(u,h,f){return u.push(f),h},c.prototype.addTokenUsingMemberAccess=function(u,h,f){return u[h]=f,h++,h},c.prototype.handlePayload=function(u,h){},c.prototype.handlePayloadNoCustom=function(u,h){},c.prototype.handlePayloadWithCustom=function(u,h){h!==null&&(u.payload=h)},c.prototype.match=function(u,h,f){return null},c.prototype.matchWithTest=function(u,h,f){var p=u.test(h);return p===!0?h.substring(f,u.lastIndex):null},c.prototype.matchWithExec=function(u,h){var f=u.exec(h);return f!==null?f[0]:f},c.prototype.TRACE_INIT=function(u,h){if(this.traceInitPerf===!0){this.traceInitIndent++;var f=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(f+"--> <"+u+">");var p=t.timer(h),g=p.time,y=p.value,d=g>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&d(f+"<-- <"+u+"> time: "+g+"ms"),this.traceInitIndent--,y}else return h()},c.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",c.NA=/NOT_APPLICABLE/,c}();r.Lexer=l}),Co=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.tokenMatcher=r.createTokenInstance=r.EOF=r.createToken=r.hasTokenLabel=r.tokenName=r.tokenLabel=void 0;var e=Wt(),t=Hf(),n=Vc();function i(x){return o(x)?x.LABEL:x.name}r.tokenLabel=i;function s(x){return x.name}r.tokenName=s;function o(x){return e.isString(x.LABEL)&&x.LABEL!==""}r.hasTokenLabel=o;var a="parent",l="categories",c="label",u="group",h="push_mode",f="pop_mode",p="longer_alt",g="line_breaks",y="start_chars_hint";function d(x){return m(x)}r.createToken=d;function m(x){var S=x.pattern,I={};if(I.name=x.name,e.isUndefined(S)||(I.PATTERN=S),e.has(x,a))throw`The parent property is no longer supported.
+See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return e.has(x,l)&&(I.CATEGORIES=x[l]),n.augmentTokenTypes([I]),e.has(x,c)&&(I.LABEL=x[c]),e.has(x,u)&&(I.GROUP=x[u]),e.has(x,f)&&(I.POP_MODE=x[f]),e.has(x,h)&&(I.PUSH_MODE=x[h]),e.has(x,p)&&(I.LONGER_ALT=x[p]),e.has(x,g)&&(I.LINE_BREAKS=x[g]),e.has(x,y)&&(I.START_CHARS_HINT=x[y]),I}r.EOF=d({name:"EOF",pattern:t.Lexer.NA}),n.augmentTokenTypes([r.EOF]);function _(x,S,I,A,C,E,b,R){return{image:S,startOffset:I,endOffset:A,startLine:C,endLine:E,startColumn:b,endColumn:R,tokenTypeIdx:x.tokenTypeIdx,tokenType:x}}r.createTokenInstance=_;function v(x,S){return n.tokenStructuredMatcher(x,S)}r.tokenMatcher=v}),Li=bt(r=>{"use strict";var e=r&&r.__extends||function(){var m=function(_,v){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,S){x.__proto__=S}||function(x,S){for(var I in S)Object.prototype.hasOwnProperty.call(S,I)&&(x[I]=S[I])},m(_,v)};return function(_,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");m(_,v);function x(){this.constructor=_}_.prototype=v===null?Object.create(v):(x.prototype=v.prototype,new x)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.serializeProduction=r.serializeGrammar=r.Terminal=r.Alternation=r.RepetitionWithSeparator=r.Repetition=r.RepetitionMandatoryWithSeparator=r.RepetitionMandatory=r.Option=r.Alternative=r.Rule=r.NonTerminal=r.AbstractProduction=void 0;var t=Wt(),n=Co(),i=function(){function m(_){this._definition=_}return Object.defineProperty(m.prototype,"definition",{get:function(){return this._definition},set:function(_){this._definition=_},enumerable:!1,configurable:!0}),m.prototype.accept=function(_){_.visit(this),t.forEach(this.definition,function(v){v.accept(_)})},m}();r.AbstractProduction=i;var s=function(m){e(_,m);function _(v){var x=m.call(this,[])||this;return x.idx=1,t.assign(x,t.pick(v,function(S){return S!==void 0})),x}return Object.defineProperty(_.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(v){},enumerable:!1,configurable:!0}),_.prototype.accept=function(v){v.visit(this)},_}(i);r.NonTerminal=s;var o=function(m){e(_,m);function _(v){var x=m.call(this,v.definition)||this;return x.orgText="",t.assign(x,t.pick(v,function(S){return S!==void 0})),x}return _}(i);r.Rule=o;var a=function(m){e(_,m);function _(v){var x=m.call(this,v.definition)||this;return x.ignoreAmbiguities=!1,t.assign(x,t.pick(v,function(S){return S!==void 0})),x}return _}(i);r.Alternative=a;var l=function(m){e(_,m);function _(v){var x=m.call(this,v.definition)||this;return x.idx=1,t.assign(x,t.pick(v,function(S){return S!==void 0})),x}return _}(i);r.Option=l;var c=function(m){e(_,m);function _(v){var x=m.call(this,v.definition)||this;return x.idx=1,t.assign(x,t.pick(v,function(S){return S!==void 0})),x}return _}(i);r.RepetitionMandatory=c;var u=function(m){e(_,m);function _(v){var x=m.call(this,v.definition)||this;return x.idx=1,t.assign(x,t.pick(v,function(S){return S!==void 0})),x}return _}(i);r.RepetitionMandatoryWithSeparator=u;var h=function(m){e(_,m);function _(v){var x=m.call(this,v.definition)||this;return x.idx=1,t.assign(x,t.pick(v,function(S){return S!==void 0})),x}return _}(i);r.Repetition=h;var f=function(m){e(_,m);function _(v){var x=m.call(this,v.definition)||this;return x.idx=1,t.assign(x,t.pick(v,function(S){return S!==void 0})),x}return _}(i);r.RepetitionWithSeparator=f;var p=function(m){e(_,m);function _(v){var x=m.call(this,v.definition)||this;return x.idx=1,x.ignoreAmbiguities=!1,x.hasPredicates=!1,t.assign(x,t.pick(v,function(S){return S!==void 0})),x}return Object.defineProperty(_.prototype,"definition",{get:function(){return this._definition},set:function(v){this._definition=v},enumerable:!1,configurable:!0}),_}(i);r.Alternation=p;var g=function(){function m(_){this.idx=1,t.assign(this,t.pick(_,function(v){return v!==void 0}))}return m.prototype.accept=function(_){_.visit(this)},m}();r.Terminal=g;function y(m){return t.map(m,d)}r.serializeGrammar=y;function d(m){function _(S){return t.map(S,d)}if(m instanceof s)return{type:"NonTerminal",name:m.nonTerminalName,idx:m.idx};if(m instanceof a)return{type:"Alternative",definition:_(m.definition)};if(m instanceof l)return{type:"Option",idx:m.idx,definition:_(m.definition)};if(m instanceof c)return{type:"RepetitionMandatory",idx:m.idx,definition:_(m.definition)};if(m instanceof u)return{type:"RepetitionMandatoryWithSeparator",idx:m.idx,separator:d(new g({terminalType:m.separator})),definition:_(m.definition)};if(m instanceof f)return{type:"RepetitionWithSeparator",idx:m.idx,separator:d(new g({terminalType:m.separator})),definition:_(m.definition)};if(m instanceof h)return{type:"Repetition",idx:m.idx,definition:_(m.definition)};if(m instanceof p)return{type:"Alternation",idx:m.idx,definition:_(m.definition)};if(m instanceof g){var v={type:"Terminal",name:m.terminalType.name,label:n.tokenLabel(m.terminalType),idx:m.idx},x=m.terminalType.PATTERN;return m.terminalType.PATTERN&&(v.pattern=t.isRegExp(x)?x.source:x),v}else{if(m instanceof o)return{type:"Rule",name:m.name,orgText:m.orgText,definition:_(m.definition)};throw Error("non exhaustive match")}}r.serializeProduction=d}),Mm=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.RestWalker=void 0;var e=Wt(),t=Li(),n=function(){function s(){}return s.prototype.walk=function(o,a){var l=this;a===void 0&&(a=[]),e.forEach(o.definition,function(c,u){var h=e.drop(o.definition,u+1);if(c instanceof t.NonTerminal)l.walkProdRef(c,h,a);else if(c instanceof t.Terminal)l.walkTerminal(c,h,a);else if(c instanceof t.Alternative)l.walkFlat(c,h,a);else if(c instanceof t.Option)l.walkOption(c,h,a);else if(c instanceof t.RepetitionMandatory)l.walkAtLeastOne(c,h,a);else if(c instanceof t.RepetitionMandatoryWithSeparator)l.walkAtLeastOneSep(c,h,a);else if(c instanceof t.RepetitionWithSeparator)l.walkManySep(c,h,a);else if(c instanceof t.Repetition)l.walkMany(c,h,a);else if(c instanceof t.Alternation)l.walkOr(c,h,a);else throw Error("non exhaustive match")})},s.prototype.walkTerminal=function(o,a,l){},s.prototype.walkProdRef=function(o,a,l){},s.prototype.walkFlat=function(o,a,l){var c=a.concat(l);this.walk(o,c)},s.prototype.walkOption=function(o,a,l){var c=a.concat(l);this.walk(o,c)},s.prototype.walkAtLeastOne=function(o,a,l){var c=[new t.Option({definition:o.definition})].concat(a,l);this.walk(o,c)},s.prototype.walkAtLeastOneSep=function(o,a,l){var c=i(o,a,l);this.walk(o,c)},s.prototype.walkMany=function(o,a,l){var c=[new t.Option({definition:o.definition})].concat(a,l);this.walk(o,c)},s.prototype.walkManySep=function(o,a,l){var c=i(o,a,l);this.walk(o,c)},s.prototype.walkOr=function(o,a,l){var c=this,u=a.concat(l);e.forEach(o.definition,function(h){var f=new t.Alternative({definition:[h]});c.walk(f,u)})},s}();r.RestWalker=n;function i(s,o,a){var l=[new t.Option({definition:[new t.Terminal({terminalType:s.separator})].concat(s.definition)})],c=l.concat(o,a);return c}}),zc=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GAstVisitor=void 0;var e=Li(),t=function(){function n(){}return n.prototype.visit=function(i){var s=i;switch(s.constructor){case e.NonTerminal:return this.visitNonTerminal(s);case e.Alternative:return this.visitAlternative(s);case e.Option:return this.visitOption(s);case e.RepetitionMandatory:return this.visitRepetitionMandatory(s);case e.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(s);case e.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(s);case e.Repetition:return this.visitRepetition(s);case e.Alternation:return this.visitAlternation(s);case e.Terminal:return this.visitTerminal(s);case e.Rule:return this.visitRule(s);default:throw Error("non exhaustive match")}},n.prototype.visitNonTerminal=function(i){},n.prototype.visitAlternative=function(i){},n.prototype.visitOption=function(i){},n.prototype.visitRepetition=function(i){},n.prototype.visitRepetitionMandatory=function(i){},n.prototype.visitRepetitionMandatoryWithSeparator=function(i){},n.prototype.visitRepetitionWithSeparator=function(i){},n.prototype.visitAlternation=function(i){},n.prototype.visitTerminal=function(i){},n.prototype.visitRule=function(i){},n}();r.GAstVisitor=t}),Wf=bt(r=>{"use strict";var e=r&&r.__extends||function(){var f=function(p,g){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,d){y.__proto__=d}||function(y,d){for(var m in d)Object.prototype.hasOwnProperty.call(d,m)&&(y[m]=d[m])},f(p,g)};return function(p,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");f(p,g);function y(){this.constructor=p}p.prototype=g===null?Object.create(g):(y.prototype=g.prototype,new y)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.collectMethods=r.DslMethodsCollectorVisitor=r.getProductionDslName=r.isBranchingProd=r.isOptionalProd=r.isSequenceProd=void 0;var t=Wt(),n=Li(),i=zc();function s(f){return f instanceof n.Alternative||f instanceof n.Option||f instanceof n.Repetition||f instanceof n.RepetitionMandatory||f instanceof n.RepetitionMandatoryWithSeparator||f instanceof n.RepetitionWithSeparator||f instanceof n.Terminal||f instanceof n.Rule}r.isSequenceProd=s;function o(f,p){p===void 0&&(p=[]);var g=f instanceof n.Option||f instanceof n.Repetition||f instanceof n.RepetitionWithSeparator;return g?!0:f instanceof n.Alternation?t.some(f.definition,function(y){return o(y,p)}):f instanceof n.NonTerminal&&t.contains(p,f)?!1:f instanceof n.AbstractProduction?(f instanceof n.NonTerminal&&p.push(f),t.every(f.definition,function(y){return o(y,p)})):!1}r.isOptionalProd=o;function a(f){return f instanceof n.Alternation}r.isBranchingProd=a;function l(f){if(f instanceof n.NonTerminal)return"SUBRULE";if(f instanceof n.Option)return"OPTION";if(f instanceof n.Alternation)return"OR";if(f instanceof n.RepetitionMandatory)return"AT_LEAST_ONE";if(f instanceof n.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(f instanceof n.RepetitionWithSeparator)return"MANY_SEP";if(f instanceof n.Repetition)return"MANY";if(f instanceof n.Terminal)return"CONSUME";throw Error("non exhaustive match")}r.getProductionDslName=l;var c=function(f){e(p,f);function p(){var g=f!==null&&f.apply(this,arguments)||this;return g.separator="-",g.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},g}return p.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},p.prototype.visitTerminal=function(g){var y=g.terminalType.name+this.separator+"Terminal";t.has(this.dslMethods,y)||(this.dslMethods[y]=[]),this.dslMethods[y].push(g)},p.prototype.visitNonTerminal=function(g){var y=g.nonTerminalName+this.separator+"Terminal";t.has(this.dslMethods,y)||(this.dslMethods[y]=[]),this.dslMethods[y].push(g)},p.prototype.visitOption=function(g){this.dslMethods.option.push(g)},p.prototype.visitRepetitionWithSeparator=function(g){this.dslMethods.repetitionWithSeparator.push(g)},p.prototype.visitRepetitionMandatory=function(g){this.dslMethods.repetitionMandatory.push(g)},p.prototype.visitRepetitionMandatoryWithSeparator=function(g){this.dslMethods.repetitionMandatoryWithSeparator.push(g)},p.prototype.visitRepetition=function(g){this.dslMethods.repetition.push(g)},p.prototype.visitAlternation=function(g){this.dslMethods.alternation.push(g)},p}(i.GAstVisitor);r.DslMethodsCollectorVisitor=c;var u=new c;function h(f){u.reset(),f.accept(u);var p=u.dslMethods;return u.reset(),p}r.collectMethods=h}),ix=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.firstForTerminal=r.firstForBranching=r.firstForSequence=r.first=void 0;var e=Wt(),t=Li(),n=Wf();function i(l){if(l instanceof t.NonTerminal)return i(l.referencedRule);if(l instanceof t.Terminal)return a(l);if(n.isSequenceProd(l))return s(l);if(n.isBranchingProd(l))return o(l);throw Error("non exhaustive match")}r.first=i;function s(l){for(var c=[],u=l.definition,h=0,f=u.length>h,p,g=!0;f&&g;)p=u[h],g=n.isOptionalProd(p),c=c.concat(i(p)),h=h+1,f=u.length>h;return e.uniq(c)}r.firstForSequence=s;function o(l){var c=e.map(l.definition,function(u){return i(u)});return e.uniq(e.flatten(c))}r.firstForBranching=o;function a(l){return[l.terminalType]}r.firstForTerminal=a}),rx=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IN=void 0,r.IN="_~IN~_"}),vS=bt(r=>{"use strict";var e=r&&r.__extends||function(){var h=function(f,p){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,y){g.__proto__=y}||function(g,y){for(var d in y)Object.prototype.hasOwnProperty.call(y,d)&&(g[d]=y[d])},h(f,p)};return function(f,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");h(f,p);function g(){this.constructor=f}f.prototype=p===null?Object.create(p):(g.prototype=p.prototype,new g)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.buildInProdFollowPrefix=r.buildBetweenProdsFollowPrefix=r.computeAllProdsFollows=r.ResyncFollowsWalker=void 0;var t=Mm(),n=ix(),i=Wt(),s=rx(),o=Li(),a=function(h){e(f,h);function f(p){var g=h.call(this)||this;return g.topProd=p,g.follows={},g}return f.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},f.prototype.walkTerminal=function(p,g,y){},f.prototype.walkProdRef=function(p,g,y){var d=c(p.referencedRule,p.idx)+this.topProd.name,m=g.concat(y),_=new o.Alternative({definition:m}),v=n.first(_);this.follows[d]=v},f}(t.RestWalker);r.ResyncFollowsWalker=a;function l(h){var f={};return i.forEach(h,function(p){var g=new a(p).startWalking();i.assign(f,g)}),f}r.computeAllProdsFollows=l;function c(h,f){return h.name+f+s.IN}r.buildBetweenProdsFollowPrefix=c;function u(h){var f=h.terminalType.name;return f+h.idx+s.IN}r.buildInProdFollowPrefix=u}),Xf=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defaultGrammarValidatorErrorProvider=r.defaultGrammarResolverErrorProvider=r.defaultParserErrorProvider=void 0;var e=Co(),t=Wt(),n=Wt(),i=Li(),s=Wf();r.defaultParserErrorProvider={buildMismatchTokenMessage:function(o){var a=o.expected,l=o.actual,c=o.previous,u=o.ruleName,h=e.hasTokenLabel(a),f=h?"--> "+e.tokenLabel(a)+" <--":"token of type --> "+a.name+" <--",p="Expecting "+f+" but found --> '"+l.image+"' <--";return p},buildNotAllInputParsedMessage:function(o){var a=o.firstRedundant,l=o.ruleName;return"Redundant input, expecting EOF but found: "+a.image},buildNoViableAltMessage:function(o){var a=o.expectedPathsPerAlt,l=o.actual,c=o.previous,u=o.customUserDescription,h=o.ruleName,f="Expecting: ",p=n.first(l).image,g=`
+but found: '`+p+"'";if(u)return f+u+g;var y=n.reduce(a,function(v,x){return v.concat(x)},[]),d=n.map(y,function(v){return"["+n.map(v,function(x){return e.tokenLabel(x)}).join(", ")+"]"}),m=n.map(d,function(v,x){return" "+(x+1)+". "+v}),_=`one of these possible Token sequences:
`+m.join(`
`);return f+_+g},buildEarlyExitMessage:function(o){var a=o.expectedIterationPaths,l=o.actual,c=o.customUserDescription,u=o.ruleName,h="Expecting: ",f=n.first(l).image,p=`
-but found: '`+f+"'";if(c)return h+c+p;var g=n.map(a,function(d){return"["+n.map(d,function(m){return e.tokenLabel(m)}).join(",")+"]"}),v=`expecting at least one iteration which starts with one of these possible Token sequences::
- `+("<"+g.join(" ,")+">");return h+v+p}},Object.freeze(r.defaultParserErrorProvider),r.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(o,a){var l="Invalid grammar, reference to a rule which is not defined: ->"+a.nonTerminalName+`<-
-inside top level rule: ->`+o.name+"<-";return l}},r.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(o,a){function l(d){return d instanceof i.Terminal?d.terminalType.name:d instanceof i.NonTerminal?d.nonTerminalName:""}var c=o.name,u=n.first(a),h=u.idx,f=s.getProductionDslName(u),p=l(u),g=h>0,v="->"+f+(g?h:"")+"<- "+(p?"with argument: ->"+p+"<-":"")+`
+but found: '`+f+"'";if(c)return h+c+p;var g=n.map(a,function(d){return"["+n.map(d,function(m){return e.tokenLabel(m)}).join(",")+"]"}),y=`expecting at least one iteration which starts with one of these possible Token sequences::
+ `+("<"+g.join(" ,")+">");return h+y+p}},Object.freeze(r.defaultParserErrorProvider),r.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(o,a){var l="Invalid grammar, reference to a rule which is not defined: ->"+a.nonTerminalName+`<-
+inside top level rule: ->`+o.name+"<-";return l}},r.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(o,a){function l(d){return d instanceof i.Terminal?d.terminalType.name:d instanceof i.NonTerminal?d.nonTerminalName:""}var c=o.name,u=n.first(a),h=u.idx,f=s.getProductionDslName(u),p=l(u),g=h>0,y="->"+f+(g?h:"")+"<- "+(p?"with argument: ->"+p+"<-":"")+`
appears more than once (`+a.length+" times) in the top level rule: ->"+c+`<-.
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
- `;return v=v.replace(/[ \t]+/g," "),v=v.replace(/\s\s+/g,`
-`),v},buildNamespaceConflictError:function(o){var a=`Namespace conflict found in grammar.
+ `;return y=y.replace(/[ \t]+/g," "),y=y.replace(/\s\s+/g,`
+`),y},buildNamespaceConflictError:function(o){var a=`Namespace conflict found in grammar.
`+("The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+o.name+`>.
`)+`To resolve this make sure each Terminal and Non-Terminal names are unique
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
`)+(`without consuming any Tokens. The grammar path that causes this is:
`+c+`
`)+` To fix this refactor your grammar to remove the left recursion.
-see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return u},buildInvalidRuleNameError:function(o){return"deprecated"},buildDuplicateRuleNameError:function(o){var a;o.topLevelRule instanceof i.Rule?a=o.topLevelRule.name:a=o.topLevelRule;var l="Duplicate definition, rule: ->"+a+"<- is already defined in the grammar: ->"+o.grammarName+"<-";return l}}}),mS=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var a=function(l,c){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,h){u.__proto__=h}||function(u,h){for(var f in h)Object.prototype.hasOwnProperty.call(h,f)&&(u[f]=h[f])},a(l,c)};return function(l,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");a(l,c);function u(){this.constructor=l}l.prototype=c===null?Object.create(c):(u.prototype=c.prototype,new u)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.GastRefResolverVisitor=r.resolveGrammar=void 0;var t=Ni(),n=Ut(),i=nc();function s(a,l){var c=new o(a,l);return c.resolveRefs(),c.errors}r.resolveGrammar=s;var o=function(a){e(l,a);function l(c,u){var h=a.call(this)||this;return h.nameToTopRule=c,h.errMsgProvider=u,h.errors=[],h}return l.prototype.resolveRefs=function(){var c=this;n.forEach(n.values(this.nameToTopRule),function(u){c.currTopLevel=u,u.accept(c)})},l.prototype.visitNonTerminal=function(c){var u=this.nameToTopRule[c.nonTerminalName];if(u)c.referencedRule=u;else{var h=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,c);this.errors.push({message:h,type:t.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:c.nonTerminalName})}},l}(i.GAstVisitor);r.GastRefResolverVisitor=o}),Rh=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var d=function(m,_){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,x){y.__proto__=x}||function(y,x){for(var w in x)Object.prototype.hasOwnProperty.call(x,w)&&(y[w]=x[w])},d(m,_)};return function(m,_){if(typeof _!="function"&&_!==null)throw new TypeError("Class extends value "+String(_)+" is not a constructor or null");d(m,_);function y(){this.constructor=m}m.prototype=_===null?Object.create(_):(y.prototype=_.prototype,new y)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.nextPossibleTokensAfter=r.possiblePathsFrom=r.NextTerminalAfterAtLeastOneSepWalker=r.NextTerminalAfterAtLeastOneWalker=r.NextTerminalAfterManySepWalker=r.NextTerminalAfterManyWalker=r.AbstractNextTerminalAfterProductionWalker=r.NextAfterTokenWalker=r.AbstractNextPossibleTokensWalker=void 0;var t=op(),n=Ut(),i=X0(),s=xi(),o=function(d){e(m,d);function m(_,y){var x=d.call(this)||this;return x.topProd=_,x.path=y,x.possibleTokTypes=[],x.nextProductionName="",x.nextProductionOccurrence=0,x.found=!1,x.isAtEndOfPath=!1,x}return m.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=n.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=n.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},m.prototype.walk=function(_,y){y===void 0&&(y=[]),this.found||d.prototype.walk.call(this,_,y)},m.prototype.walkProdRef=function(_,y,x){if(_.referencedRule.name===this.nextProductionName&&_.idx===this.nextProductionOccurrence){var w=y.concat(x);this.updateExpectedNext(),this.walk(_.referencedRule,w)}},m.prototype.updateExpectedNext=function(){n.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},m}(t.RestWalker);r.AbstractNextPossibleTokensWalker=o;var a=function(d){e(m,d);function m(_,y){var x=d.call(this,_,y)||this;return x.path=y,x.nextTerminalName="",x.nextTerminalOccurrence=0,x.nextTerminalName=x.path.lastTok.name,x.nextTerminalOccurrence=x.path.lastTokOccurrence,x}return m.prototype.walkTerminal=function(_,y,x){if(this.isAtEndOfPath&&_.terminalType.name===this.nextTerminalName&&_.idx===this.nextTerminalOccurrence&&!this.found){var w=y.concat(x),I=new s.Alternative({definition:w});this.possibleTokTypes=i.first(I),this.found=!0}},m}(o);r.NextAfterTokenWalker=a;var l=function(d){e(m,d);function m(_,y){var x=d.call(this)||this;return x.topRule=_,x.occurrence=y,x.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},x}return m.prototype.startWalking=function(){return this.walk(this.topRule),this.result},m}(t.RestWalker);r.AbstractNextTerminalAfterProductionWalker=l;var c=function(d){e(m,d);function m(){return d!==null&&d.apply(this,arguments)||this}return m.prototype.walkMany=function(_,y,x){if(_.idx===this.occurrence){var w=n.first(y.concat(x));this.result.isEndOfRule=w===void 0,w instanceof s.Terminal&&(this.result.token=w.terminalType,this.result.occurrence=w.idx)}else d.prototype.walkMany.call(this,_,y,x)},m}(l);r.NextTerminalAfterManyWalker=c;var u=function(d){e(m,d);function m(){return d!==null&&d.apply(this,arguments)||this}return m.prototype.walkManySep=function(_,y,x){if(_.idx===this.occurrence){var w=n.first(y.concat(x));this.result.isEndOfRule=w===void 0,w instanceof s.Terminal&&(this.result.token=w.terminalType,this.result.occurrence=w.idx)}else d.prototype.walkManySep.call(this,_,y,x)},m}(l);r.NextTerminalAfterManySepWalker=u;var h=function(d){e(m,d);function m(){return d!==null&&d.apply(this,arguments)||this}return m.prototype.walkAtLeastOne=function(_,y,x){if(_.idx===this.occurrence){var w=n.first(y.concat(x));this.result.isEndOfRule=w===void 0,w instanceof s.Terminal&&(this.result.token=w.terminalType,this.result.occurrence=w.idx)}else d.prototype.walkAtLeastOne.call(this,_,y,x)},m}(l);r.NextTerminalAfterAtLeastOneWalker=h;var f=function(d){e(m,d);function m(){return d!==null&&d.apply(this,arguments)||this}return m.prototype.walkAtLeastOneSep=function(_,y,x){if(_.idx===this.occurrence){var w=n.first(y.concat(x));this.result.isEndOfRule=w===void 0,w instanceof s.Terminal&&(this.result.token=w.terminalType,this.result.occurrence=w.idx)}else d.prototype.walkAtLeastOneSep.call(this,_,y,x)},m}(l);r.NextTerminalAfterAtLeastOneSepWalker=f;function p(d,m,_){_===void 0&&(_=[]),_=n.cloneArr(_);var y=[],x=0;function w(E){return E.concat(n.drop(d,x+1))}function I(E){var M=p(w(E),m,_);return y.concat(M)}for(;_.length<m&&x<d.length;){var C=d[x];if(C instanceof s.Alternative||C instanceof s.NonTerminal)return I(C.definition);if(C instanceof s.Option)y=I(C.definition);else if(C instanceof s.RepetitionMandatory){var P=C.definition.concat([new s.Repetition({definition:C.definition})]);return I(P)}else if(C instanceof s.RepetitionMandatoryWithSeparator){var P=[new s.Alternative({definition:C.definition}),new s.Repetition({definition:[new s.Terminal({terminalType:C.separator})].concat(C.definition)})];return I(P)}else if(C instanceof s.RepetitionWithSeparator){var P=C.definition.concat([new s.Repetition({definition:[new s.Terminal({terminalType:C.separator})].concat(C.definition)})]);y=I(P)}else if(C instanceof s.Repetition){var P=C.definition.concat([new s.Repetition({definition:C.definition})]);y=I(P)}else{if(C instanceof s.Alternation)return n.forEach(C.definition,function(E){n.isEmpty(E.definition)===!1&&(y=I(E.definition))}),y;if(C instanceof s.Terminal)_.push(C.terminalType);else throw Error("non exhaustive match")}x++}return y.push({partialPath:_,suffixDef:n.drop(d,x)}),y}r.possiblePathsFrom=p;function g(d,m,_,y){var x="EXIT_NONE_TERMINAL",w=[x],I="EXIT_ALTERNATIVE",C=!1,P=m.length,E=P-y-1,M=[],L=[];for(L.push({idx:-1,def:d,ruleStack:[],occurrenceStack:[]});!n.isEmpty(L);){var N=L.pop();if(N===I){C&&n.last(L).idx<=E&&L.pop();continue}var O=N.def,B=N.idx,ie=N.ruleStack,$=N.occurrenceStack;if(!n.isEmpty(O)){var te=O[0];if(te===x){var W={idx:B,def:n.drop(O),ruleStack:n.dropRight(ie),occurrenceStack:n.dropRight($)};L.push(W)}else if(te instanceof s.Terminal)if(B<P-1){var ae=B+1,de=m[ae];if(_(de,te.terminalType)){var W={idx:ae,def:n.drop(O),ruleStack:ie,occurrenceStack:$};L.push(W)}}else if(B===P-1)M.push({nextTokenType:te.terminalType,nextTokenOccurrence:te.idx,ruleStack:ie,occurrenceStack:$}),C=!0;else throw Error("non exhaustive match");else if(te instanceof s.NonTerminal){var ye=n.cloneArr(ie);ye.push(te.nonTerminalName);var Me=n.cloneArr($);Me.push(te.idx);var W={idx:B,def:te.definition.concat(w,n.drop(O)),ruleStack:ye,occurrenceStack:Me};L.push(W)}else if(te instanceof s.Option){var ve={idx:B,def:n.drop(O),ruleStack:ie,occurrenceStack:$};L.push(ve),L.push(I);var R={idx:B,def:te.definition.concat(n.drop(O)),ruleStack:ie,occurrenceStack:$};L.push(R)}else if(te instanceof s.RepetitionMandatory){var T=new s.Repetition({definition:te.definition,idx:te.idx}),S=te.definition.concat([T],n.drop(O)),W={idx:B,def:S,ruleStack:ie,occurrenceStack:$};L.push(W)}else if(te instanceof s.RepetitionMandatoryWithSeparator){var b=new s.Terminal({terminalType:te.separator}),T=new s.Repetition({definition:[b].concat(te.definition),idx:te.idx}),S=te.definition.concat([T],n.drop(O)),W={idx:B,def:S,ruleStack:ie,occurrenceStack:$};L.push(W)}else if(te instanceof s.RepetitionWithSeparator){var ve={idx:B,def:n.drop(O),ruleStack:ie,occurrenceStack:$};L.push(ve),L.push(I);var b=new s.Terminal({terminalType:te.separator}),V=new s.Repetition({definition:[b].concat(te.definition),idx:te.idx}),S=te.definition.concat([V],n.drop(O)),R={idx:B,def:S,ruleStack:ie,occurrenceStack:$};L.push(R)}else if(te instanceof s.Repetition){var ve={idx:B,def:n.drop(O),ruleStack:ie,occurrenceStack:$};L.push(ve),L.push(I);var V=new s.Repetition({definition:te.definition,idx:te.idx}),S=te.definition.concat([V],n.drop(O)),R={idx:B,def:S,ruleStack:ie,occurrenceStack:$};L.push(R)}else if(te instanceof s.Alternation)for(var q=te.definition.length-1;q>=0;q--){var Y=te.definition[q],z={idx:B,def:Y.definition.concat(n.drop(O)),ruleStack:ie,occurrenceStack:$};L.push(z),L.push(I)}else if(te instanceof s.Alternative)L.push({idx:B,def:te.definition.concat(n.drop(O)),ruleStack:ie,occurrenceStack:$});else if(te instanceof s.Rule)L.push(v(te,B,ie,$));else throw Error("non exhaustive match")}}return M}r.nextPossibleTokensAfter=g;function v(d,m,_,y){var x=n.cloneArr(_);x.push(d.name);var w=n.cloneArr(y);return w.push(1),{idx:m,def:d.definition,ruleStack:x,occurrenceStack:w}}}),Ih=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var E=function(M,L){return E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(N,O){N.__proto__=O}||function(N,O){for(var B in O)Object.prototype.hasOwnProperty.call(O,B)&&(N[B]=O[B])},E(M,L)};return function(M,L){if(typeof L!="function"&&L!==null)throw new TypeError("Class extends value "+String(L)+" is not a constructor or null");E(M,L);function N(){this.constructor=M}M.prototype=L===null?Object.create(L):(N.prototype=L.prototype,new N)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.areTokenCategoriesNotUsed=r.isStrictPrefixOfPath=r.containsPath=r.getLookaheadPathsForOptionalProd=r.getLookaheadPathsForOr=r.lookAheadSequenceFromAlternatives=r.buildSingleAlternativeLookaheadFunction=r.buildAlternativesLookAheadFunc=r.buildLookaheadFuncForOptionalProd=r.buildLookaheadFuncForOr=r.getProdType=r.PROD_TYPE=void 0;var t=Ut(),n=Rh(),i=op(),s=tc(),o=xi(),a=nc(),l;(function(E){E[E.OPTION=0]="OPTION",E[E.REPETITION=1]="REPETITION",E[E.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",E[E.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",E[E.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",E[E.ALTERNATION=5]="ALTERNATION"})(l=r.PROD_TYPE||(r.PROD_TYPE={}));function c(E){if(E instanceof o.Option)return l.OPTION;if(E instanceof o.Repetition)return l.REPETITION;if(E instanceof o.RepetitionMandatory)return l.REPETITION_MANDATORY;if(E instanceof o.RepetitionMandatoryWithSeparator)return l.REPETITION_MANDATORY_WITH_SEPARATOR;if(E instanceof o.RepetitionWithSeparator)return l.REPETITION_WITH_SEPARATOR;if(E instanceof o.Alternation)return l.ALTERNATION;throw Error("non exhaustive match")}r.getProdType=c;function u(E,M,L,N,O,B){var ie=x(E,M,L),$=P(ie)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher;return B(ie,N,$,O)}r.buildLookaheadFuncForOr=u;function h(E,M,L,N,O,B){var ie=w(E,M,O,L),$=P(ie)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher;return B(ie[0],$,N)}r.buildLookaheadFuncForOptionalProd=h;function f(E,M,L,N){var O=E.length,B=t.every(E,function(te){return t.every(te,function(W){return W.length===1})});if(M)return function(te){for(var W=t.map(te,function(V){return V.GATE}),ae=0;ae<O;ae++){var de=E[ae],ye=de.length,Me=W[ae];if(!(Me!==void 0&&Me.call(this)===!1))e:for(var ve=0;ve<ye;ve++){for(var R=de[ve],T=R.length,S=0;S<T;S++){var b=this.LA(S+1);if(L(b,R[S])===!1)continue e}return ae}}};if(B&&!N){var ie=t.map(E,function(te){return t.flatten(te)}),$=t.reduce(ie,function(te,W,ae){return t.forEach(W,function(de){t.has(te,de.tokenTypeIdx)||(te[de.tokenTypeIdx]=ae),t.forEach(de.categoryMatches,function(ye){t.has(te,ye)||(te[ye]=ae)})}),te},[]);return function(){var te=this.LA(1);return $[te.tokenTypeIdx]}}else return function(){for(var te=0;te<O;te++){var W=E[te],ae=W.length;e:for(var de=0;de<ae;de++){for(var ye=W[de],Me=ye.length,ve=0;ve<Me;ve++){var R=this.LA(ve+1);if(L(R,ye[ve])===!1)continue e}return te}}}}r.buildAlternativesLookAheadFunc=f;function p(E,M,L){var N=t.every(E,function(W){return W.length===1}),O=E.length;if(N&&!L){var B=t.flatten(E);if(B.length===1&&t.isEmpty(B[0].categoryMatches)){var ie=B[0],$=ie.tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===$}}else{var te=t.reduce(B,function(W,ae,de){return W[ae.tokenTypeIdx]=!0,t.forEach(ae.categoryMatches,function(ye){W[ye]=!0}),W},[]);return function(){var W=this.LA(1);return te[W.tokenTypeIdx]===!0}}}else return function(){e:for(var W=0;W<O;W++){for(var ae=E[W],de=ae.length,ye=0;ye<de;ye++){var Me=this.LA(ye+1);if(M(Me,ae[ye])===!1)continue e}return!0}return!1}}r.buildSingleAlternativeLookaheadFunction=p;var g=function(E){e(M,E);function M(L,N,O){var B=E.call(this)||this;return B.topProd=L,B.targetOccurrence=N,B.targetProdType=O,B}return M.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},M.prototype.checkIsTarget=function(L,N,O,B){return L.idx===this.targetOccurrence&&this.targetProdType===N?(this.restDef=O.concat(B),!0):!1},M.prototype.walkOption=function(L,N,O){this.checkIsTarget(L,l.OPTION,N,O)||E.prototype.walkOption.call(this,L,N,O)},M.prototype.walkAtLeastOne=function(L,N,O){this.checkIsTarget(L,l.REPETITION_MANDATORY,N,O)||E.prototype.walkOption.call(this,L,N,O)},M.prototype.walkAtLeastOneSep=function(L,N,O){this.checkIsTarget(L,l.REPETITION_MANDATORY_WITH_SEPARATOR,N,O)||E.prototype.walkOption.call(this,L,N,O)},M.prototype.walkMany=function(L,N,O){this.checkIsTarget(L,l.REPETITION,N,O)||E.prototype.walkOption.call(this,L,N,O)},M.prototype.walkManySep=function(L,N,O){this.checkIsTarget(L,l.REPETITION_WITH_SEPARATOR,N,O)||E.prototype.walkOption.call(this,L,N,O)},M}(i.RestWalker),v=function(E){e(M,E);function M(L,N,O){var B=E.call(this)||this;return B.targetOccurrence=L,B.targetProdType=N,B.targetRef=O,B.result=[],B}return M.prototype.checkIsTarget=function(L,N){L.idx===this.targetOccurrence&&this.targetProdType===N&&(this.targetRef===void 0||L===this.targetRef)&&(this.result=L.definition)},M.prototype.visitOption=function(L){this.checkIsTarget(L,l.OPTION)},M.prototype.visitRepetition=function(L){this.checkIsTarget(L,l.REPETITION)},M.prototype.visitRepetitionMandatory=function(L){this.checkIsTarget(L,l.REPETITION_MANDATORY)},M.prototype.visitRepetitionMandatoryWithSeparator=function(L){this.checkIsTarget(L,l.REPETITION_MANDATORY_WITH_SEPARATOR)},M.prototype.visitRepetitionWithSeparator=function(L){this.checkIsTarget(L,l.REPETITION_WITH_SEPARATOR)},M.prototype.visitAlternation=function(L){this.checkIsTarget(L,l.ALTERNATION)},M}(a.GAstVisitor);function d(E){for(var M=new Array(E),L=0;L<E;L++)M[L]=[];return M}function m(E){for(var M=[""],L=0;L<E.length;L++){for(var N=E[L],O=[],B=0;B<M.length;B++){var ie=M[B];O.push(ie+"_"+N.tokenTypeIdx);for(var $=0;$<N.categoryMatches.length;$++){var te="_"+N.categoryMatches[$];O.push(ie+te)}}M=O}return M}function _(E,M,L){for(var N=0;N<E.length;N++)if(N!==L)for(var O=E[N],B=0;B<M.length;B++){var ie=M[B];if(O[ie]===!0)return!1}return!0}function y(E,M){for(var L=t.map(E,function(ae){return n.possiblePathsFrom([ae],1)}),N=d(L.length),O=t.map(L,function(ae){var de={};return t.forEach(ae,function(ye){var Me=m(ye.partialPath);t.forEach(Me,function(ve){de[ve]=!0})}),de}),B=L,ie=1;ie<=M;ie++){var $=B;B=d($.length);for(var te=function(ae){for(var de=$[ae],ye=0;ye<de.length;ye++){var Me=de[ye].partialPath,ve=de[ye].suffixDef,R=m(Me),T=_(O,R,ae);if(T||t.isEmpty(ve)||Me.length===M){var S=N[ae];if(I(S,Me)===!1){S.push(Me);for(var b=0;b<R.length;b++){var V=R[b];O[ae][V]=!0}}}else{var q=n.possiblePathsFrom(ve,ie+1,Me);B[ae]=B[ae].concat(q),t.forEach(q,function(Y){var z=m(Y.partialPath);t.forEach(z,function(X){O[ae][X]=!0})})}}},W=0;W<$.length;W++)te(W)}return N}r.lookAheadSequenceFromAlternatives=y;function x(E,M,L,N){var O=new v(E,l.ALTERNATION,N);return M.accept(O),y(O.result,L)}r.getLookaheadPathsForOr=x;function w(E,M,L,N){var O=new v(E,L);M.accept(O);var B=O.result,ie=new g(M,E,L),$=ie.startWalking(),te=new o.Alternative({definition:B}),W=new o.Alternative({definition:$});return y([te,W],N)}r.getLookaheadPathsForOptionalProd=w;function I(E,M){e:for(var L=0;L<E.length;L++){var N=E[L];if(N.length===M.length){for(var O=0;O<N.length;O++){var B=M[O],ie=N[O],$=B===ie||ie.categoryMatchesMap[B.tokenTypeIdx]!==void 0;if($===!1)continue e}return!0}}return!1}r.containsPath=I;function C(E,M){return E.length<M.length&&t.every(E,function(L,N){var O=M[N];return L===O||O.categoryMatchesMap[L.tokenTypeIdx]})}r.isStrictPrefixOfPath=C;function P(E){return t.every(E,function(M){return t.every(M,function(L){return t.every(L,function(N){return t.isEmpty(N.categoryMatches)})})})}r.areTokenCategoriesNotUsed=P}),q0=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var N=function(O,B){return N=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(ie,$){ie.__proto__=$}||function(ie,$){for(var te in $)Object.prototype.hasOwnProperty.call($,te)&&(ie[te]=$[te])},N(O,B)};return function(O,B){if(typeof B!="function"&&B!==null)throw new TypeError("Class extends value "+String(B)+" is not a constructor or null");N(O,B);function ie(){this.constructor=O}O.prototype=B===null?Object.create(B):(ie.prototype=B.prototype,new ie)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.checkPrefixAlternativesAmbiguities=r.validateSomeNonEmptyLookaheadPath=r.validateTooManyAlts=r.RepetionCollector=r.validateAmbiguousAlternationAlternatives=r.validateEmptyOrAlternative=r.getFirstNoneTerminal=r.validateNoLeftRecursion=r.validateRuleIsOverridden=r.validateRuleDoesNotAlreadyExist=r.OccurrenceValidationCollector=r.identifyProductionForDuplicates=r.validateGrammar=void 0;var t=Ut(),n=Ut(),i=Ni(),s=wh(),o=Ih(),a=Rh(),l=xi(),c=nc();function u(N,O,B,ie,$){var te=t.map(N,function(T){return h(T,ie)}),W=t.map(N,function(T){return m(T,T,ie)}),ae=[],de=[],ye=[];n.every(W,n.isEmpty)&&(ae=n.map(N,function(T){return x(T,ie)}),de=n.map(N,function(T){return w(T,O,ie)}),ye=P(N,O,ie));var Me=L(N,B,ie),ve=n.map(N,function(T){return C(T,ie)}),R=n.map(N,function(T){return v(T,N,$,ie)});return t.flatten(te.concat(ye,W,ae,de,Me,ve,R))}r.validateGrammar=u;function h(N,O){var B=new g;N.accept(B);var ie=B.allProductions,$=t.groupBy(ie,f),te=t.pick($,function(ae){return ae.length>1}),W=t.map(t.values(te),function(ae){var de=t.first(ae),ye=O.buildDuplicateFoundError(N,ae),Me=s.getProductionDslName(de),ve={message:ye,type:i.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:N.name,dslName:Me,occurrence:de.idx},R=p(de);return R&&(ve.parameter=R),ve});return W}function f(N){return s.getProductionDslName(N)+"_#_"+N.idx+"_#_"+p(N)}r.identifyProductionForDuplicates=f;function p(N){return N instanceof l.Terminal?N.terminalType.name:N instanceof l.NonTerminal?N.nonTerminalName:""}var g=function(N){e(O,N);function O(){var B=N!==null&&N.apply(this,arguments)||this;return B.allProductions=[],B}return O.prototype.visitNonTerminal=function(B){this.allProductions.push(B)},O.prototype.visitOption=function(B){this.allProductions.push(B)},O.prototype.visitRepetitionWithSeparator=function(B){this.allProductions.push(B)},O.prototype.visitRepetitionMandatory=function(B){this.allProductions.push(B)},O.prototype.visitRepetitionMandatoryWithSeparator=function(B){this.allProductions.push(B)},O.prototype.visitRepetition=function(B){this.allProductions.push(B)},O.prototype.visitAlternation=function(B){this.allProductions.push(B)},O.prototype.visitTerminal=function(B){this.allProductions.push(B)},O}(c.GAstVisitor);r.OccurrenceValidationCollector=g;function v(N,O,B,ie){var $=[],te=n.reduce(O,function(ae,de){return de.name===N.name?ae+1:ae},0);if(te>1){var W=ie.buildDuplicateRuleNameError({topLevelRule:N,grammarName:B});$.push({message:W,type:i.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:N.name})}return $}r.validateRuleDoesNotAlreadyExist=v;function d(N,O,B){var ie=[],$;return t.contains(O,N)||($="Invalid rule override, rule: ->"+N+"<- cannot be overridden in the grammar: ->"+B+"<-as it is not defined in any of the super grammars ",ie.push({message:$,type:i.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:N})),ie}r.validateRuleIsOverridden=d;function m(N,O,B,ie){ie===void 0&&(ie=[]);var $=[],te=_(O.definition);if(t.isEmpty(te))return[];var W=N.name,ae=t.contains(te,N);ae&&$.push({message:B.buildLeftRecursionError({topLevelRule:N,leftRecursionPath:ie}),type:i.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:W});var de=t.difference(te,ie.concat([N])),ye=t.map(de,function(Me){var ve=t.cloneArr(ie);return ve.push(Me),m(N,Me,B,ve)});return $.concat(t.flatten(ye))}r.validateNoLeftRecursion=m;function _(N){var O=[];if(t.isEmpty(N))return O;var B=t.first(N);if(B instanceof l.NonTerminal)O.push(B.referencedRule);else if(B instanceof l.Alternative||B instanceof l.Option||B instanceof l.RepetitionMandatory||B instanceof l.RepetitionMandatoryWithSeparator||B instanceof l.RepetitionWithSeparator||B instanceof l.Repetition)O=O.concat(_(B.definition));else if(B instanceof l.Alternation)O=t.flatten(t.map(B.definition,function(W){return _(W.definition)}));else if(!(B instanceof l.Terminal))throw Error("non exhaustive match");var ie=s.isOptionalProd(B),$=N.length>1;if(ie&&$){var te=t.drop(N);return O.concat(_(te))}else return O}r.getFirstNoneTerminal=_;var y=function(N){e(O,N);function O(){var B=N!==null&&N.apply(this,arguments)||this;return B.alternations=[],B}return O.prototype.visitAlternation=function(B){this.alternations.push(B)},O}(c.GAstVisitor);function x(N,O){var B=new y;N.accept(B);var ie=B.alternations,$=t.reduce(ie,function(te,W){var ae=t.dropRight(W.definition),de=t.map(ae,function(ye,Me){var ve=a.nextPossibleTokensAfter([ye],[],null,1);return t.isEmpty(ve)?{message:O.buildEmptyAlternationError({topLevelRule:N,alternation:W,emptyChoiceIdx:Me}),type:i.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:N.name,occurrence:W.idx,alternative:Me+1}:null});return te.concat(t.compact(de))},[]);return $}r.validateEmptyOrAlternative=x;function w(N,O,B){var ie=new y;N.accept(ie);var $=ie.alternations;$=n.reject($,function(W){return W.ignoreAmbiguities===!0});var te=t.reduce($,function(W,ae){var de=ae.idx,ye=ae.maxLookahead||O,Me=o.getLookaheadPathsForOr(de,N,ye,ae),ve=E(Me,ae,N,B),R=M(Me,ae,N,B);return W.concat(ve,R)},[]);return te}r.validateAmbiguousAlternationAlternatives=w;var I=function(N){e(O,N);function O(){var B=N!==null&&N.apply(this,arguments)||this;return B.allProductions=[],B}return O.prototype.visitRepetitionWithSeparator=function(B){this.allProductions.push(B)},O.prototype.visitRepetitionMandatory=function(B){this.allProductions.push(B)},O.prototype.visitRepetitionMandatoryWithSeparator=function(B){this.allProductions.push(B)},O.prototype.visitRepetition=function(B){this.allProductions.push(B)},O}(c.GAstVisitor);r.RepetionCollector=I;function C(N,O){var B=new y;N.accept(B);var ie=B.alternations,$=t.reduce(ie,function(te,W){return W.definition.length>255&&te.push({message:O.buildTooManyAlternativesError({topLevelRule:N,alternation:W}),type:i.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:N.name,occurrence:W.idx}),te},[]);return $}r.validateTooManyAlts=C;function P(N,O,B){var ie=[];return n.forEach(N,function($){var te=new I;$.accept(te);var W=te.allProductions;n.forEach(W,function(ae){var de=o.getProdType(ae),ye=ae.maxLookahead||O,Me=ae.idx,ve=o.getLookaheadPathsForOptionalProd(Me,$,de,ye),R=ve[0];if(n.isEmpty(n.flatten(R))){var T=B.buildEmptyRepetitionError({topLevelRule:$,repetition:ae});ie.push({message:T,type:i.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:$.name})}})}),ie}r.validateSomeNonEmptyLookaheadPath=P;function E(N,O,B,ie){var $=[],te=n.reduce(N,function(ae,de,ye){return O.definition[ye].ignoreAmbiguities===!0||n.forEach(de,function(Me){var ve=[ye];n.forEach(N,function(R,T){ye!==T&&o.containsPath(R,Me)&&O.definition[T].ignoreAmbiguities!==!0&&ve.push(T)}),ve.length>1&&!o.containsPath($,Me)&&($.push(Me),ae.push({alts:ve,path:Me}))}),ae},[]),W=t.map(te,function(ae){var de=n.map(ae.alts,function(Me){return Me+1}),ye=ie.buildAlternationAmbiguityError({topLevelRule:B,alternation:O,ambiguityIndices:de,prefixPath:ae.path});return{message:ye,type:i.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:B.name,occurrence:O.idx,alternatives:[ae.alts]}});return W}function M(N,O,B,ie){var $=[],te=n.reduce(N,function(W,ae,de){var ye=n.map(ae,function(Me){return{idx:de,path:Me}});return W.concat(ye)},[]);return n.forEach(te,function(W){var ae=O.definition[W.idx];if(ae.ignoreAmbiguities!==!0){var de=W.idx,ye=W.path,Me=n.findAll(te,function(R){return O.definition[R.idx].ignoreAmbiguities!==!0&&R.idx<de&&o.isStrictPrefixOfPath(R.path,ye)}),ve=n.map(Me,function(R){var T=[R.idx+1,de+1],S=O.idx===0?"":O.idx,b=ie.buildAlternationPrefixAmbiguityError({topLevelRule:B,alternation:O,ambiguityIndices:T,prefixPath:R.path});return{message:b,type:i.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:B.name,occurrence:S,alternatives:T}});$=$.concat(ve)}}),$}r.checkPrefixAlternativesAmbiguities=M;function L(N,O,B){var ie=[],$=n.map(O,function(te){return te.name});return n.forEach(N,function(te){var W=te.name;if(n.contains($,W)){var ae=B.buildNamespaceConflictError(te);ie.push({message:ae,type:i.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:W})}}),ie}}),gS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.validateGrammar=r.resolveGrammar=void 0;var e=Ut(),t=mS(),n=q0(),i=Ch();function s(a){a=e.defaults(a,{errMsgProvider:i.defaultGrammarResolverErrorProvider});var l={};return e.forEach(a.rules,function(c){l[c.name]=c}),t.resolveGrammar(l,a.errMsgProvider)}r.resolveGrammar=s;function o(a){return a=e.defaults(a,{errMsgProvider:i.defaultGrammarValidatorErrorProvider}),n.validateGrammar(a.rules,a.maxLookahead,a.tokenTypes,a.errMsgProvider,a.grammarName)}r.validateGrammar=o}),ic=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var g=function(v,d){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,_){m.__proto__=_}||function(m,_){for(var y in _)Object.prototype.hasOwnProperty.call(_,y)&&(m[y]=_[y])},g(v,d)};return function(v,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");g(v,d);function m(){this.constructor=v}v.prototype=d===null?Object.create(d):(m.prototype=d.prototype,new m)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.EarlyExitException=r.NotAllInputParsedException=r.NoViableAltException=r.MismatchedTokenException=r.isRecognitionException=void 0;var t=Ut(),n="MismatchedTokenException",i="NoViableAltException",s="EarlyExitException",o="NotAllInputParsedException",a=[n,i,s,o];Object.freeze(a);function l(g){return t.contains(a,g.name)}r.isRecognitionException=l;var c=function(g){e(v,g);function v(d,m){var _=this.constructor,y=g.call(this,d)||this;return y.token=m,y.resyncedTokens=[],Object.setPrototypeOf(y,_.prototype),Error.captureStackTrace&&Error.captureStackTrace(y,y.constructor),y}return v}(Error),u=function(g){e(v,g);function v(d,m,_){var y=g.call(this,d,m)||this;return y.previousToken=_,y.name=n,y}return v}(c);r.MismatchedTokenException=u;var h=function(g){e(v,g);function v(d,m,_){var y=g.call(this,d,m)||this;return y.previousToken=_,y.name=i,y}return v}(c);r.NoViableAltException=h;var f=function(g){e(v,g);function v(d,m){var _=g.call(this,d,m)||this;return _.name=o,_}return v}(c);r.NotAllInputParsedException=f;var p=function(g){e(v,g);function v(d,m,_){var y=g.call(this,d,m)||this;return y.previousToken=_,y.name=s,y}return v}(c);r.EarlyExitException=p}),Y0=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.attemptInRepetitionRecovery=r.Recoverable=r.InRuleRecoveryException=r.IN_RULE_RECOVERY_EXCEPTION=r.EOF_FOLLOW_KEY=void 0;var e=io(),t=Ut(),n=ic(),i=j0(),s=Ni();r.EOF_FOLLOW_KEY={},r.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function o(c){this.name=r.IN_RULE_RECOVERY_EXCEPTION,this.message=c}r.InRuleRecoveryException=o,o.prototype=Error.prototype;var a=function(){function c(){}return c.prototype.initRecoverable=function(u){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=t.has(u,"recoveryEnabled")?u.recoveryEnabled:s.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=l)},c.prototype.getTokenToInsert=function(u){var h=e.createTokenInstance(u,"",NaN,NaN,NaN,NaN,NaN,NaN);return h.isInsertedInRecovery=!0,h},c.prototype.canTokenTypeBeInsertedInRecovery=function(u){return!0},c.prototype.tryInRepetitionRecovery=function(u,h,f,p){for(var g=this,v=this.findReSyncTokenType(),d=this.exportLexerState(),m=[],_=!1,y=this.LA(1),x=this.LA(1),w=function(){var I=g.LA(0),C=g.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:y,previous:I,ruleName:g.getCurrRuleFullName()}),P=new n.MismatchedTokenException(C,y,g.LA(0));P.resyncedTokens=t.dropRight(m),g.SAVE_ERROR(P)};!_;)if(this.tokenMatcher(x,p)){w();return}else if(f.call(this)){w(),u.apply(this,h);return}else this.tokenMatcher(x,v)?_=!0:(x=this.SKIP_TOKEN(),this.addToResyncTokens(x,m));this.importLexerState(d)},c.prototype.shouldInRepetitionRecoveryBeTried=function(u,h,f){return!(f===!1||u===void 0||h===void 0||this.tokenMatcher(this.LA(1),u)||this.isBackTracking()||this.canPerformInRuleRecovery(u,this.getFollowsForInRuleRecovery(u,h)))},c.prototype.getFollowsForInRuleRecovery=function(u,h){var f=this.getCurrentGrammarPath(u,h),p=this.getNextPossibleTokenTypes(f);return p},c.prototype.tryInRuleRecovery=function(u,h){if(this.canRecoverWithSingleTokenInsertion(u,h)){var f=this.getTokenToInsert(u);return f}if(this.canRecoverWithSingleTokenDeletion(u)){var p=this.SKIP_TOKEN();return this.consumeToken(),p}throw new o("sad sad panda")},c.prototype.canPerformInRuleRecovery=function(u,h){return this.canRecoverWithSingleTokenInsertion(u,h)||this.canRecoverWithSingleTokenDeletion(u)},c.prototype.canRecoverWithSingleTokenInsertion=function(u,h){var f=this;if(!this.canTokenTypeBeInsertedInRecovery(u)||t.isEmpty(h))return!1;var p=this.LA(1),g=t.find(h,function(v){return f.tokenMatcher(p,v)})!==void 0;return g},c.prototype.canRecoverWithSingleTokenDeletion=function(u){var h=this.tokenMatcher(this.LA(2),u);return h},c.prototype.isInCurrentRuleReSyncSet=function(u){var h=this.getCurrFollowKey(),f=this.getFollowSetFromFollowKey(h);return t.contains(f,u)},c.prototype.findReSyncTokenType=function(){for(var u=this.flattenFollowSet(),h=this.LA(1),f=2;;){var p=h.tokenType;if(t.contains(u,p))return p;h=this.LA(f),f++}},c.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return r.EOF_FOLLOW_KEY;var u=this.getLastExplicitRuleShortName(),h=this.getLastExplicitRuleOccurrenceIndex(),f=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(u),idxInCallingRule:h,inRule:this.shortRuleNameToFullName(f)}},c.prototype.buildFullFollowKeyStack=function(){var u=this,h=this.RULE_STACK,f=this.RULE_OCCURRENCE_STACK;return t.map(h,function(p,g){return g===0?r.EOF_FOLLOW_KEY:{ruleName:u.shortRuleNameToFullName(p),idxInCallingRule:f[g],inRule:u.shortRuleNameToFullName(h[g-1])}})},c.prototype.flattenFollowSet=function(){var u=this,h=t.map(this.buildFullFollowKeyStack(),function(f){return u.getFollowSetFromFollowKey(f)});return t.flatten(h)},c.prototype.getFollowSetFromFollowKey=function(u){if(u===r.EOF_FOLLOW_KEY)return[e.EOF];var h=u.ruleName+u.idxInCallingRule+i.IN+u.inRule;return this.resyncFollows[h]},c.prototype.addToResyncTokens=function(u,h){return this.tokenMatcher(u,e.EOF)||h.push(u),h},c.prototype.reSyncTo=function(u){for(var h=[],f=this.LA(1);this.tokenMatcher(f,u)===!1;)f=this.SKIP_TOKEN(),this.addToResyncTokens(f,h);return t.dropRight(h)},c.prototype.attemptInRepetitionRecovery=function(u,h,f,p,g,v,d){},c.prototype.getCurrentGrammarPath=function(u,h){var f=this.getHumanReadableRuleStack(),p=t.cloneArr(this.RULE_OCCURRENCE_STACK),g={ruleStack:f,occurrenceStack:p,lastTok:u,lastTokOccurrence:h};return g},c.prototype.getHumanReadableRuleStack=function(){var u=this;return t.map(this.RULE_STACK,function(h){return u.shortRuleNameToFullName(h)})},c}();r.Recoverable=a;function l(c,u,h,f,p,g,v){var d=this.getKeyForAutomaticLookahead(f,p),m=this.firstAfterRepMap[d];if(m===void 0){var _=this.getCurrRuleFullName(),y=this.getGAstProductions()[_],x=new g(y,p);m=x.startWalking(),this.firstAfterRepMap[d]=m}var w=m.token,I=m.occurrence,C=m.isEndOfRule;this.RULE_STACK.length===1&&C&&w===void 0&&(w=e.EOF,I=1),this.shouldInRepetitionRecoveryBeTried(w,I,v)&&this.tryInRepetitionRecovery(c,u,h,w)}r.attemptInRepetitionRecovery=l}),ap=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getKeyForAutomaticLookahead=r.AT_LEAST_ONE_SEP_IDX=r.MANY_SEP_IDX=r.AT_LEAST_ONE_IDX=r.MANY_IDX=r.OPTION_IDX=r.OR_IDX=r.BITS_FOR_ALT_IDX=r.BITS_FOR_RULE_IDX=r.BITS_FOR_OCCURRENCE_IDX=r.BITS_FOR_METHOD_TYPE=void 0,r.BITS_FOR_METHOD_TYPE=4,r.BITS_FOR_OCCURRENCE_IDX=8,r.BITS_FOR_RULE_IDX=12,r.BITS_FOR_ALT_IDX=8,r.OR_IDX=1<<r.BITS_FOR_OCCURRENCE_IDX,r.OPTION_IDX=2<<r.BITS_FOR_OCCURRENCE_IDX,r.MANY_IDX=3<<r.BITS_FOR_OCCURRENCE_IDX,r.AT_LEAST_ONE_IDX=4<<r.BITS_FOR_OCCURRENCE_IDX,r.MANY_SEP_IDX=5<<r.BITS_FOR_OCCURRENCE_IDX,r.AT_LEAST_ONE_SEP_IDX=6<<r.BITS_FOR_OCCURRENCE_IDX;function e(n,i,s){return s|i|n}r.getKeyForAutomaticLookahead=e;var t=32-r.BITS_FOR_ALT_IDX}),vS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.LooksAhead=void 0;var e=Ih(),t=Ut(),n=Ni(),i=ap(),s=wh(),o=function(){function a(){}return a.prototype.initLooksAhead=function(l){this.dynamicTokensEnabled=t.has(l,"dynamicTokensEnabled")?l.dynamicTokensEnabled:n.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=t.has(l,"maxLookahead")?l.maxLookahead:n.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=t.isES2015MapSupported()?new Map:[],t.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},a.prototype.preComputeLookaheadFunctions=function(l){var c=this;t.forEach(l,function(u){c.TRACE_INIT(u.name+" Rule Lookahead",function(){var h=s.collectMethods(u),f=h.alternation,p=h.repetition,g=h.option,v=h.repetitionMandatory,d=h.repetitionMandatoryWithSeparator,m=h.repetitionWithSeparator;t.forEach(f,function(_){var y=_.idx===0?"":_.idx;c.TRACE_INIT(""+s.getProductionDslName(_)+y,function(){var x=e.buildLookaheadFuncForOr(_.idx,u,_.maxLookahead||c.maxLookahead,_.hasPredicates,c.dynamicTokensEnabled,c.lookAheadBuilderForAlternatives),w=i.getKeyForAutomaticLookahead(c.fullRuleNameToShort[u.name],i.OR_IDX,_.idx);c.setLaFuncCache(w,x)})}),t.forEach(p,function(_){c.computeLookaheadFunc(u,_.idx,i.MANY_IDX,e.PROD_TYPE.REPETITION,_.maxLookahead,s.getProductionDslName(_))}),t.forEach(g,function(_){c.computeLookaheadFunc(u,_.idx,i.OPTION_IDX,e.PROD_TYPE.OPTION,_.maxLookahead,s.getProductionDslName(_))}),t.forEach(v,function(_){c.computeLookaheadFunc(u,_.idx,i.AT_LEAST_ONE_IDX,e.PROD_TYPE.REPETITION_MANDATORY,_.maxLookahead,s.getProductionDslName(_))}),t.forEach(d,function(_){c.computeLookaheadFunc(u,_.idx,i.AT_LEAST_ONE_SEP_IDX,e.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,_.maxLookahead,s.getProductionDslName(_))}),t.forEach(m,function(_){c.computeLookaheadFunc(u,_.idx,i.MANY_SEP_IDX,e.PROD_TYPE.REPETITION_WITH_SEPARATOR,_.maxLookahead,s.getProductionDslName(_))})})})},a.prototype.computeLookaheadFunc=function(l,c,u,h,f,p){var g=this;this.TRACE_INIT(""+p+(c===0?"":c),function(){var v=e.buildLookaheadFuncForOptionalProd(c,l,f||g.maxLookahead,g.dynamicTokensEnabled,h,g.lookAheadBuilderForOptional),d=i.getKeyForAutomaticLookahead(g.fullRuleNameToShort[l.name],u,c);g.setLaFuncCache(d,v)})},a.prototype.lookAheadBuilderForOptional=function(l,c,u){return e.buildSingleAlternativeLookaheadFunction(l,c,u)},a.prototype.lookAheadBuilderForAlternatives=function(l,c,u,h){return e.buildAlternativesLookAheadFunc(l,c,u,h)},a.prototype.getKeyForAutomaticLookahead=function(l,c){var u=this.getLastExplicitRuleShortName();return i.getKeyForAutomaticLookahead(u,l,c)},a.prototype.getLaFuncFromCache=function(l){},a.prototype.getLaFuncFromMap=function(l){return this.lookAheadFuncsCache.get(l)},a.prototype.getLaFuncFromObj=function(l){return this.lookAheadFuncsCache[l]},a.prototype.setLaFuncCache=function(l,c){},a.prototype.setLaFuncCacheUsingMap=function(l,c){this.lookAheadFuncsCache.set(l,c)},a.prototype.setLaFuncUsingObj=function(l,c){this.lookAheadFuncsCache[l]=c},a}();r.LooksAhead=o}),yS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.addNoneTerminalToCst=r.addTerminalToCst=r.setNodeLocationFull=r.setNodeLocationOnlyOffset=void 0;function e(s,o){isNaN(s.startOffset)===!0?(s.startOffset=o.startOffset,s.endOffset=o.endOffset):s.endOffset<o.endOffset&&(s.endOffset=o.endOffset)}r.setNodeLocationOnlyOffset=e;function t(s,o){isNaN(s.startOffset)===!0?(s.startOffset=o.startOffset,s.startColumn=o.startColumn,s.startLine=o.startLine,s.endOffset=o.endOffset,s.endColumn=o.endColumn,s.endLine=o.endLine):s.endOffset<o.endOffset&&(s.endOffset=o.endOffset,s.endColumn=o.endColumn,s.endLine=o.endLine)}r.setNodeLocationFull=t;function n(s,o,a){s.children[a]===void 0?s.children[a]=[o]:s.children[a].push(o)}r.addTerminalToCst=n;function i(s,o,a){s.children[o]===void 0?s.children[o]=[a]:s.children[o].push(a)}r.addNoneTerminalToCst=i}),K0=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineNameProp=r.functionName=r.classNameFromInstance=void 0;var e=Ut();function t(o){return i(o.constructor)}r.classNameFromInstance=t;var n="name";function i(o){var a=o.name;return a||"anonymous"}r.functionName=i;function s(o,a){var l=Object.getOwnPropertyDescriptor(o,n);return e.isUndefined(l)||l.configurable?(Object.defineProperty(o,n,{enumerable:!1,configurable:!0,writable:!1,value:a}),!0):!1}r.defineNameProp=s}),xS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.validateRedundantMethods=r.validateMissingCstMethods=r.validateVisitor=r.CstVisitorDefinitionError=r.createBaseVisitorConstructorWithDefaults=r.createBaseSemanticVisitorConstructor=r.defaultVisit=void 0;var e=Ut(),t=K0();function n(h,f){for(var p=e.keys(h),g=p.length,v=0;v<g;v++)for(var d=p[v],m=h[d],_=m.length,y=0;y<_;y++){var x=m[y];x.tokenTypeIdx===void 0&&this[x.name](x.children,f)}}r.defaultVisit=n;function i(h,f){var p=function(){};t.defineNameProp(p,h+"BaseSemantics");var g={visit:function(v,d){if(e.isArray(v)&&(v=v[0]),!e.isUndefined(v))return this[v.name](v.children,d)},validateVisitor:function(){var v=a(this,f);if(!e.isEmpty(v)){var d=e.map(v,function(m){return m.msg});throw Error("Errors Detected in CST Visitor <"+t.functionName(this.constructor)+`>:
+see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return u},buildInvalidRuleNameError:function(o){return"deprecated"},buildDuplicateRuleNameError:function(o){var a;o.topLevelRule instanceof i.Rule?a=o.topLevelRule.name:a=o.topLevelRule;var l="Duplicate definition, rule: ->"+a+"<- is already defined in the grammar: ->"+o.grammarName+"<-";return l}}}),_S=bt(r=>{"use strict";var e=r&&r.__extends||function(){var a=function(l,c){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,h){u.__proto__=h}||function(u,h){for(var f in h)Object.prototype.hasOwnProperty.call(h,f)&&(u[f]=h[f])},a(l,c)};return function(l,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");a(l,c);function u(){this.constructor=l}l.prototype=c===null?Object.create(c):(u.prototype=c.prototype,new u)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.GastRefResolverVisitor=r.resolveGrammar=void 0;var t=Xi(),n=Wt(),i=zc();function s(a,l){var c=new o(a,l);return c.resolveRefs(),c.errors}r.resolveGrammar=s;var o=function(a){e(l,a);function l(c,u){var h=a.call(this)||this;return h.nameToTopRule=c,h.errMsgProvider=u,h.errors=[],h}return l.prototype.resolveRefs=function(){var c=this;n.forEach(n.values(this.nameToTopRule),function(u){c.currTopLevel=u,u.accept(c)})},l.prototype.visitNonTerminal=function(c){var u=this.nameToTopRule[c.nonTerminalName];if(u)c.referencedRule=u;else{var h=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,c);this.errors.push({message:h,type:t.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:c.nonTerminalName})}},l}(i.GAstVisitor);r.GastRefResolverVisitor=o}),qf=bt(r=>{"use strict";var e=r&&r.__extends||function(){var d=function(m,_){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,x){v.__proto__=x}||function(v,x){for(var S in x)Object.prototype.hasOwnProperty.call(x,S)&&(v[S]=x[S])},d(m,_)};return function(m,_){if(typeof _!="function"&&_!==null)throw new TypeError("Class extends value "+String(_)+" is not a constructor or null");d(m,_);function v(){this.constructor=m}m.prototype=_===null?Object.create(_):(v.prototype=_.prototype,new v)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.nextPossibleTokensAfter=r.possiblePathsFrom=r.NextTerminalAfterAtLeastOneSepWalker=r.NextTerminalAfterAtLeastOneWalker=r.NextTerminalAfterManySepWalker=r.NextTerminalAfterManyWalker=r.AbstractNextTerminalAfterProductionWalker=r.NextAfterTokenWalker=r.AbstractNextPossibleTokensWalker=void 0;var t=Mm(),n=Wt(),i=ix(),s=Li(),o=function(d){e(m,d);function m(_,v){var x=d.call(this)||this;return x.topProd=_,x.path=v,x.possibleTokTypes=[],x.nextProductionName="",x.nextProductionOccurrence=0,x.found=!1,x.isAtEndOfPath=!1,x}return m.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=n.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=n.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},m.prototype.walk=function(_,v){v===void 0&&(v=[]),this.found||d.prototype.walk.call(this,_,v)},m.prototype.walkProdRef=function(_,v,x){if(_.referencedRule.name===this.nextProductionName&&_.idx===this.nextProductionOccurrence){var S=v.concat(x);this.updateExpectedNext(),this.walk(_.referencedRule,S)}},m.prototype.updateExpectedNext=function(){n.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},m}(t.RestWalker);r.AbstractNextPossibleTokensWalker=o;var a=function(d){e(m,d);function m(_,v){var x=d.call(this,_,v)||this;return x.path=v,x.nextTerminalName="",x.nextTerminalOccurrence=0,x.nextTerminalName=x.path.lastTok.name,x.nextTerminalOccurrence=x.path.lastTokOccurrence,x}return m.prototype.walkTerminal=function(_,v,x){if(this.isAtEndOfPath&&_.terminalType.name===this.nextTerminalName&&_.idx===this.nextTerminalOccurrence&&!this.found){var S=v.concat(x),I=new s.Alternative({definition:S});this.possibleTokTypes=i.first(I),this.found=!0}},m}(o);r.NextAfterTokenWalker=a;var l=function(d){e(m,d);function m(_,v){var x=d.call(this)||this;return x.topRule=_,x.occurrence=v,x.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},x}return m.prototype.startWalking=function(){return this.walk(this.topRule),this.result},m}(t.RestWalker);r.AbstractNextTerminalAfterProductionWalker=l;var c=function(d){e(m,d);function m(){return d!==null&&d.apply(this,arguments)||this}return m.prototype.walkMany=function(_,v,x){if(_.idx===this.occurrence){var S=n.first(v.concat(x));this.result.isEndOfRule=S===void 0,S instanceof s.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else d.prototype.walkMany.call(this,_,v,x)},m}(l);r.NextTerminalAfterManyWalker=c;var u=function(d){e(m,d);function m(){return d!==null&&d.apply(this,arguments)||this}return m.prototype.walkManySep=function(_,v,x){if(_.idx===this.occurrence){var S=n.first(v.concat(x));this.result.isEndOfRule=S===void 0,S instanceof s.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else d.prototype.walkManySep.call(this,_,v,x)},m}(l);r.NextTerminalAfterManySepWalker=u;var h=function(d){e(m,d);function m(){return d!==null&&d.apply(this,arguments)||this}return m.prototype.walkAtLeastOne=function(_,v,x){if(_.idx===this.occurrence){var S=n.first(v.concat(x));this.result.isEndOfRule=S===void 0,S instanceof s.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else d.prototype.walkAtLeastOne.call(this,_,v,x)},m}(l);r.NextTerminalAfterAtLeastOneWalker=h;var f=function(d){e(m,d);function m(){return d!==null&&d.apply(this,arguments)||this}return m.prototype.walkAtLeastOneSep=function(_,v,x){if(_.idx===this.occurrence){var S=n.first(v.concat(x));this.result.isEndOfRule=S===void 0,S instanceof s.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else d.prototype.walkAtLeastOneSep.call(this,_,v,x)},m}(l);r.NextTerminalAfterAtLeastOneSepWalker=f;function p(d,m,_){_===void 0&&(_=[]),_=n.cloneArr(_);var v=[],x=0;function S(E){return E.concat(n.drop(d,x+1))}function I(E){var b=p(S(E),m,_);return v.concat(b)}for(;_.length<m&&x<d.length;){var A=d[x];if(A instanceof s.Alternative||A instanceof s.NonTerminal)return I(A.definition);if(A instanceof s.Option)v=I(A.definition);else if(A instanceof s.RepetitionMandatory){var C=A.definition.concat([new s.Repetition({definition:A.definition})]);return I(C)}else if(A instanceof s.RepetitionMandatoryWithSeparator){var C=[new s.Alternative({definition:A.definition}),new s.Repetition({definition:[new s.Terminal({terminalType:A.separator})].concat(A.definition)})];return I(C)}else if(A instanceof s.RepetitionWithSeparator){var C=A.definition.concat([new s.Repetition({definition:[new s.Terminal({terminalType:A.separator})].concat(A.definition)})]);v=I(C)}else if(A instanceof s.Repetition){var C=A.definition.concat([new s.Repetition({definition:A.definition})]);v=I(C)}else{if(A instanceof s.Alternation)return n.forEach(A.definition,function(E){n.isEmpty(E.definition)===!1&&(v=I(E.definition))}),v;if(A instanceof s.Terminal)_.push(A.terminalType);else throw Error("non exhaustive match")}x++}return v.push({partialPath:_,suffixDef:n.drop(d,x)}),v}r.possiblePathsFrom=p;function g(d,m,_,v){var x="EXIT_NONE_TERMINAL",S=[x],I="EXIT_ALTERNATIVE",A=!1,C=m.length,E=C-v-1,b=[],R=[];for(R.push({idx:-1,def:d,ruleStack:[],occurrenceStack:[]});!n.isEmpty(R);){var N=R.pop();if(N===I){A&&n.last(R).idx<=E&&R.pop();continue}var B=N.def,V=N.idx,ie=N.ruleStack,Y=N.occurrenceStack;if(!n.isEmpty(B)){var te=B[0];if(te===x){var q={idx:V,def:n.drop(B),ruleStack:n.dropRight(ie),occurrenceStack:n.dropRight(Y)};R.push(q)}else if(te instanceof s.Terminal)if(V<C-1){var le=V+1,ye=m[le];if(_(ye,te.terminalType)){var q={idx:le,def:n.drop(B),ruleStack:ie,occurrenceStack:Y};R.push(q)}}else if(V===C-1)b.push({nextTokenType:te.terminalType,nextTokenOccurrence:te.idx,ruleStack:ie,occurrenceStack:Y}),A=!0;else throw Error("non exhaustive match");else if(te instanceof s.NonTerminal){var Te=n.cloneArr(ie);Te.push(te.nonTerminalName);var Ae=n.cloneArr(Y);Ae.push(te.idx);var q={idx:V,def:te.definition.concat(S,n.drop(B)),ruleStack:Te,occurrenceStack:Ae};R.push(q)}else if(te instanceof s.Option){var _e={idx:V,def:n.drop(B),ruleStack:ie,occurrenceStack:Y};R.push(_e),R.push(I);var G={idx:V,def:te.definition.concat(n.drop(B)),ruleStack:ie,occurrenceStack:Y};R.push(G)}else if(te instanceof s.RepetitionMandatory){var P=new s.Repetition({definition:te.definition,idx:te.idx}),M=te.definition.concat([P],n.drop(B)),q={idx:V,def:M,ruleStack:ie,occurrenceStack:Y};R.push(q)}else if(te instanceof s.RepetitionMandatoryWithSeparator){var T=new s.Terminal({terminalType:te.separator}),P=new s.Repetition({definition:[T].concat(te.definition),idx:te.idx}),M=te.definition.concat([P],n.drop(B)),q={idx:V,def:M,ruleStack:ie,occurrenceStack:Y};R.push(q)}else if(te instanceof s.RepetitionWithSeparator){var _e={idx:V,def:n.drop(B),ruleStack:ie,occurrenceStack:Y};R.push(_e),R.push(I);var T=new s.Terminal({terminalType:te.separator}),k=new s.Repetition({definition:[T].concat(te.definition),idx:te.idx}),M=te.definition.concat([k],n.drop(B)),G={idx:V,def:M,ruleStack:ie,occurrenceStack:Y};R.push(G)}else if(te instanceof s.Repetition){var _e={idx:V,def:n.drop(B),ruleStack:ie,occurrenceStack:Y};R.push(_e),R.push(I);var k=new s.Repetition({definition:te.definition,idx:te.idx}),M=te.definition.concat([k],n.drop(B)),G={idx:V,def:M,ruleStack:ie,occurrenceStack:Y};R.push(G)}else if(te instanceof s.Alternation)for(var j=te.definition.length-1;j>=0;j--){var W=te.definition[j],re={idx:V,def:W.definition.concat(n.drop(B)),ruleStack:ie,occurrenceStack:Y};R.push(re),R.push(I)}else if(te instanceof s.Alternative)R.push({idx:V,def:te.definition.concat(n.drop(B)),ruleStack:ie,occurrenceStack:Y});else if(te instanceof s.Rule)R.push(y(te,V,ie,Y));else throw Error("non exhaustive match")}}return b}r.nextPossibleTokensAfter=g;function y(d,m,_,v){var x=n.cloneArr(_);x.push(d.name);var S=n.cloneArr(v);return S.push(1),{idx:m,def:d.definition,ruleStack:x,occurrenceStack:S}}}),jf=bt(r=>{"use strict";var e=r&&r.__extends||function(){var E=function(b,R){return E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(N,B){N.__proto__=B}||function(N,B){for(var V in B)Object.prototype.hasOwnProperty.call(B,V)&&(N[V]=B[V])},E(b,R)};return function(b,R){if(typeof R!="function"&&R!==null)throw new TypeError("Class extends value "+String(R)+" is not a constructor or null");E(b,R);function N(){this.constructor=b}b.prototype=R===null?Object.create(R):(N.prototype=R.prototype,new N)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.areTokenCategoriesNotUsed=r.isStrictPrefixOfPath=r.containsPath=r.getLookaheadPathsForOptionalProd=r.getLookaheadPathsForOr=r.lookAheadSequenceFromAlternatives=r.buildSingleAlternativeLookaheadFunction=r.buildAlternativesLookAheadFunc=r.buildLookaheadFuncForOptionalProd=r.buildLookaheadFuncForOr=r.getProdType=r.PROD_TYPE=void 0;var t=Wt(),n=qf(),i=Mm(),s=Vc(),o=Li(),a=zc(),l;(function(E){E[E.OPTION=0]="OPTION",E[E.REPETITION=1]="REPETITION",E[E.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",E[E.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",E[E.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",E[E.ALTERNATION=5]="ALTERNATION"})(l=r.PROD_TYPE||(r.PROD_TYPE={}));function c(E){if(E instanceof o.Option)return l.OPTION;if(E instanceof o.Repetition)return l.REPETITION;if(E instanceof o.RepetitionMandatory)return l.REPETITION_MANDATORY;if(E instanceof o.RepetitionMandatoryWithSeparator)return l.REPETITION_MANDATORY_WITH_SEPARATOR;if(E instanceof o.RepetitionWithSeparator)return l.REPETITION_WITH_SEPARATOR;if(E instanceof o.Alternation)return l.ALTERNATION;throw Error("non exhaustive match")}r.getProdType=c;function u(E,b,R,N,B,V){var ie=x(E,b,R),Y=C(ie)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher;return V(ie,N,Y,B)}r.buildLookaheadFuncForOr=u;function h(E,b,R,N,B,V){var ie=S(E,b,B,R),Y=C(ie)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher;return V(ie[0],Y,N)}r.buildLookaheadFuncForOptionalProd=h;function f(E,b,R,N){var B=E.length,V=t.every(E,function(te){return t.every(te,function(q){return q.length===1})});if(b)return function(te){for(var q=t.map(te,function(k){return k.GATE}),le=0;le<B;le++){var ye=E[le],Te=ye.length,Ae=q[le];if(!(Ae!==void 0&&Ae.call(this)===!1))e:for(var _e=0;_e<Te;_e++){for(var G=ye[_e],P=G.length,M=0;M<P;M++){var T=this.LA(M+1);if(R(T,G[M])===!1)continue e}return le}}};if(V&&!N){var ie=t.map(E,function(te){return t.flatten(te)}),Y=t.reduce(ie,function(te,q,le){return t.forEach(q,function(ye){t.has(te,ye.tokenTypeIdx)||(te[ye.tokenTypeIdx]=le),t.forEach(ye.categoryMatches,function(Te){t.has(te,Te)||(te[Te]=le)})}),te},[]);return function(){var te=this.LA(1);return Y[te.tokenTypeIdx]}}else return function(){for(var te=0;te<B;te++){var q=E[te],le=q.length;e:for(var ye=0;ye<le;ye++){for(var Te=q[ye],Ae=Te.length,_e=0;_e<Ae;_e++){var G=this.LA(_e+1);if(R(G,Te[_e])===!1)continue e}return te}}}}r.buildAlternativesLookAheadFunc=f;function p(E,b,R){var N=t.every(E,function(q){return q.length===1}),B=E.length;if(N&&!R){var V=t.flatten(E);if(V.length===1&&t.isEmpty(V[0].categoryMatches)){var ie=V[0],Y=ie.tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===Y}}else{var te=t.reduce(V,function(q,le,ye){return q[le.tokenTypeIdx]=!0,t.forEach(le.categoryMatches,function(Te){q[Te]=!0}),q},[]);return function(){var q=this.LA(1);return te[q.tokenTypeIdx]===!0}}}else return function(){e:for(var q=0;q<B;q++){for(var le=E[q],ye=le.length,Te=0;Te<ye;Te++){var Ae=this.LA(Te+1);if(b(Ae,le[Te])===!1)continue e}return!0}return!1}}r.buildSingleAlternativeLookaheadFunction=p;var g=function(E){e(b,E);function b(R,N,B){var V=E.call(this)||this;return V.topProd=R,V.targetOccurrence=N,V.targetProdType=B,V}return b.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},b.prototype.checkIsTarget=function(R,N,B,V){return R.idx===this.targetOccurrence&&this.targetProdType===N?(this.restDef=B.concat(V),!0):!1},b.prototype.walkOption=function(R,N,B){this.checkIsTarget(R,l.OPTION,N,B)||E.prototype.walkOption.call(this,R,N,B)},b.prototype.walkAtLeastOne=function(R,N,B){this.checkIsTarget(R,l.REPETITION_MANDATORY,N,B)||E.prototype.walkOption.call(this,R,N,B)},b.prototype.walkAtLeastOneSep=function(R,N,B){this.checkIsTarget(R,l.REPETITION_MANDATORY_WITH_SEPARATOR,N,B)||E.prototype.walkOption.call(this,R,N,B)},b.prototype.walkMany=function(R,N,B){this.checkIsTarget(R,l.REPETITION,N,B)||E.prototype.walkOption.call(this,R,N,B)},b.prototype.walkManySep=function(R,N,B){this.checkIsTarget(R,l.REPETITION_WITH_SEPARATOR,N,B)||E.prototype.walkOption.call(this,R,N,B)},b}(i.RestWalker),y=function(E){e(b,E);function b(R,N,B){var V=E.call(this)||this;return V.targetOccurrence=R,V.targetProdType=N,V.targetRef=B,V.result=[],V}return b.prototype.checkIsTarget=function(R,N){R.idx===this.targetOccurrence&&this.targetProdType===N&&(this.targetRef===void 0||R===this.targetRef)&&(this.result=R.definition)},b.prototype.visitOption=function(R){this.checkIsTarget(R,l.OPTION)},b.prototype.visitRepetition=function(R){this.checkIsTarget(R,l.REPETITION)},b.prototype.visitRepetitionMandatory=function(R){this.checkIsTarget(R,l.REPETITION_MANDATORY)},b.prototype.visitRepetitionMandatoryWithSeparator=function(R){this.checkIsTarget(R,l.REPETITION_MANDATORY_WITH_SEPARATOR)},b.prototype.visitRepetitionWithSeparator=function(R){this.checkIsTarget(R,l.REPETITION_WITH_SEPARATOR)},b.prototype.visitAlternation=function(R){this.checkIsTarget(R,l.ALTERNATION)},b}(a.GAstVisitor);function d(E){for(var b=new Array(E),R=0;R<E;R++)b[R]=[];return b}function m(E){for(var b=[""],R=0;R<E.length;R++){for(var N=E[R],B=[],V=0;V<b.length;V++){var ie=b[V];B.push(ie+"_"+N.tokenTypeIdx);for(var Y=0;Y<N.categoryMatches.length;Y++){var te="_"+N.categoryMatches[Y];B.push(ie+te)}}b=B}return b}function _(E,b,R){for(var N=0;N<E.length;N++)if(N!==R)for(var B=E[N],V=0;V<b.length;V++){var ie=b[V];if(B[ie]===!0)return!1}return!0}function v(E,b){for(var R=t.map(E,function(le){return n.possiblePathsFrom([le],1)}),N=d(R.length),B=t.map(R,function(le){var ye={};return t.forEach(le,function(Te){var Ae=m(Te.partialPath);t.forEach(Ae,function(_e){ye[_e]=!0})}),ye}),V=R,ie=1;ie<=b;ie++){var Y=V;V=d(Y.length);for(var te=function(le){for(var ye=Y[le],Te=0;Te<ye.length;Te++){var Ae=ye[Te].partialPath,_e=ye[Te].suffixDef,G=m(Ae),P=_(B,G,le);if(P||t.isEmpty(_e)||Ae.length===b){var M=N[le];if(I(M,Ae)===!1){M.push(Ae);for(var T=0;T<G.length;T++){var k=G[T];B[le][k]=!0}}}else{var j=n.possiblePathsFrom(_e,ie+1,Ae);V[le]=V[le].concat(j),t.forEach(j,function(W){var re=m(W.partialPath);t.forEach(re,function(ce){B[le][ce]=!0})})}}},q=0;q<Y.length;q++)te(q)}return N}r.lookAheadSequenceFromAlternatives=v;function x(E,b,R,N){var B=new y(E,l.ALTERNATION,N);return b.accept(B),v(B.result,R)}r.getLookaheadPathsForOr=x;function S(E,b,R,N){var B=new y(E,R);b.accept(B);var V=B.result,ie=new g(b,E,R),Y=ie.startWalking(),te=new o.Alternative({definition:V}),q=new o.Alternative({definition:Y});return v([te,q],N)}r.getLookaheadPathsForOptionalProd=S;function I(E,b){e:for(var R=0;R<E.length;R++){var N=E[R];if(N.length===b.length){for(var B=0;B<N.length;B++){var V=b[B],ie=N[B],Y=V===ie||ie.categoryMatchesMap[V.tokenTypeIdx]!==void 0;if(Y===!1)continue e}return!0}}return!1}r.containsPath=I;function A(E,b){return E.length<b.length&&t.every(E,function(R,N){var B=b[N];return R===B||B.categoryMatchesMap[R.tokenTypeIdx]})}r.isStrictPrefixOfPath=A;function C(E){return t.every(E,function(b){return t.every(b,function(R){return t.every(R,function(N){return t.isEmpty(N.categoryMatches)})})})}r.areTokenCategoriesNotUsed=C}),sx=bt(r=>{"use strict";var e=r&&r.__extends||function(){var N=function(B,V){return N=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(ie,Y){ie.__proto__=Y}||function(ie,Y){for(var te in Y)Object.prototype.hasOwnProperty.call(Y,te)&&(ie[te]=Y[te])},N(B,V)};return function(B,V){if(typeof V!="function"&&V!==null)throw new TypeError("Class extends value "+String(V)+" is not a constructor or null");N(B,V);function ie(){this.constructor=B}B.prototype=V===null?Object.create(V):(ie.prototype=V.prototype,new ie)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.checkPrefixAlternativesAmbiguities=r.validateSomeNonEmptyLookaheadPath=r.validateTooManyAlts=r.RepetionCollector=r.validateAmbiguousAlternationAlternatives=r.validateEmptyOrAlternative=r.getFirstNoneTerminal=r.validateNoLeftRecursion=r.validateRuleIsOverridden=r.validateRuleDoesNotAlreadyExist=r.OccurrenceValidationCollector=r.identifyProductionForDuplicates=r.validateGrammar=void 0;var t=Wt(),n=Wt(),i=Xi(),s=Wf(),o=jf(),a=qf(),l=Li(),c=zc();function u(N,B,V,ie,Y){var te=t.map(N,function(P){return h(P,ie)}),q=t.map(N,function(P){return m(P,P,ie)}),le=[],ye=[],Te=[];n.every(q,n.isEmpty)&&(le=n.map(N,function(P){return x(P,ie)}),ye=n.map(N,function(P){return S(P,B,ie)}),Te=C(N,B,ie));var Ae=R(N,V,ie),_e=n.map(N,function(P){return A(P,ie)}),G=n.map(N,function(P){return y(P,N,Y,ie)});return t.flatten(te.concat(Te,q,le,ye,Ae,_e,G))}r.validateGrammar=u;function h(N,B){var V=new g;N.accept(V);var ie=V.allProductions,Y=t.groupBy(ie,f),te=t.pick(Y,function(le){return le.length>1}),q=t.map(t.values(te),function(le){var ye=t.first(le),Te=B.buildDuplicateFoundError(N,le),Ae=s.getProductionDslName(ye),_e={message:Te,type:i.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:N.name,dslName:Ae,occurrence:ye.idx},G=p(ye);return G&&(_e.parameter=G),_e});return q}function f(N){return s.getProductionDslName(N)+"_#_"+N.idx+"_#_"+p(N)}r.identifyProductionForDuplicates=f;function p(N){return N instanceof l.Terminal?N.terminalType.name:N instanceof l.NonTerminal?N.nonTerminalName:""}var g=function(N){e(B,N);function B(){var V=N!==null&&N.apply(this,arguments)||this;return V.allProductions=[],V}return B.prototype.visitNonTerminal=function(V){this.allProductions.push(V)},B.prototype.visitOption=function(V){this.allProductions.push(V)},B.prototype.visitRepetitionWithSeparator=function(V){this.allProductions.push(V)},B.prototype.visitRepetitionMandatory=function(V){this.allProductions.push(V)},B.prototype.visitRepetitionMandatoryWithSeparator=function(V){this.allProductions.push(V)},B.prototype.visitRepetition=function(V){this.allProductions.push(V)},B.prototype.visitAlternation=function(V){this.allProductions.push(V)},B.prototype.visitTerminal=function(V){this.allProductions.push(V)},B}(c.GAstVisitor);r.OccurrenceValidationCollector=g;function y(N,B,V,ie){var Y=[],te=n.reduce(B,function(le,ye){return ye.name===N.name?le+1:le},0);if(te>1){var q=ie.buildDuplicateRuleNameError({topLevelRule:N,grammarName:V});Y.push({message:q,type:i.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:N.name})}return Y}r.validateRuleDoesNotAlreadyExist=y;function d(N,B,V){var ie=[],Y;return t.contains(B,N)||(Y="Invalid rule override, rule: ->"+N+"<- cannot be overridden in the grammar: ->"+V+"<-as it is not defined in any of the super grammars ",ie.push({message:Y,type:i.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:N})),ie}r.validateRuleIsOverridden=d;function m(N,B,V,ie){ie===void 0&&(ie=[]);var Y=[],te=_(B.definition);if(t.isEmpty(te))return[];var q=N.name,le=t.contains(te,N);le&&Y.push({message:V.buildLeftRecursionError({topLevelRule:N,leftRecursionPath:ie}),type:i.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:q});var ye=t.difference(te,ie.concat([N])),Te=t.map(ye,function(Ae){var _e=t.cloneArr(ie);return _e.push(Ae),m(N,Ae,V,_e)});return Y.concat(t.flatten(Te))}r.validateNoLeftRecursion=m;function _(N){var B=[];if(t.isEmpty(N))return B;var V=t.first(N);if(V instanceof l.NonTerminal)B.push(V.referencedRule);else if(V instanceof l.Alternative||V instanceof l.Option||V instanceof l.RepetitionMandatory||V instanceof l.RepetitionMandatoryWithSeparator||V instanceof l.RepetitionWithSeparator||V instanceof l.Repetition)B=B.concat(_(V.definition));else if(V instanceof l.Alternation)B=t.flatten(t.map(V.definition,function(q){return _(q.definition)}));else if(!(V instanceof l.Terminal))throw Error("non exhaustive match");var ie=s.isOptionalProd(V),Y=N.length>1;if(ie&&Y){var te=t.drop(N);return B.concat(_(te))}else return B}r.getFirstNoneTerminal=_;var v=function(N){e(B,N);function B(){var V=N!==null&&N.apply(this,arguments)||this;return V.alternations=[],V}return B.prototype.visitAlternation=function(V){this.alternations.push(V)},B}(c.GAstVisitor);function x(N,B){var V=new v;N.accept(V);var ie=V.alternations,Y=t.reduce(ie,function(te,q){var le=t.dropRight(q.definition),ye=t.map(le,function(Te,Ae){var _e=a.nextPossibleTokensAfter([Te],[],null,1);return t.isEmpty(_e)?{message:B.buildEmptyAlternationError({topLevelRule:N,alternation:q,emptyChoiceIdx:Ae}),type:i.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:N.name,occurrence:q.idx,alternative:Ae+1}:null});return te.concat(t.compact(ye))},[]);return Y}r.validateEmptyOrAlternative=x;function S(N,B,V){var ie=new v;N.accept(ie);var Y=ie.alternations;Y=n.reject(Y,function(q){return q.ignoreAmbiguities===!0});var te=t.reduce(Y,function(q,le){var ye=le.idx,Te=le.maxLookahead||B,Ae=o.getLookaheadPathsForOr(ye,N,Te,le),_e=E(Ae,le,N,V),G=b(Ae,le,N,V);return q.concat(_e,G)},[]);return te}r.validateAmbiguousAlternationAlternatives=S;var I=function(N){e(B,N);function B(){var V=N!==null&&N.apply(this,arguments)||this;return V.allProductions=[],V}return B.prototype.visitRepetitionWithSeparator=function(V){this.allProductions.push(V)},B.prototype.visitRepetitionMandatory=function(V){this.allProductions.push(V)},B.prototype.visitRepetitionMandatoryWithSeparator=function(V){this.allProductions.push(V)},B.prototype.visitRepetition=function(V){this.allProductions.push(V)},B}(c.GAstVisitor);r.RepetionCollector=I;function A(N,B){var V=new v;N.accept(V);var ie=V.alternations,Y=t.reduce(ie,function(te,q){return q.definition.length>255&&te.push({message:B.buildTooManyAlternativesError({topLevelRule:N,alternation:q}),type:i.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:N.name,occurrence:q.idx}),te},[]);return Y}r.validateTooManyAlts=A;function C(N,B,V){var ie=[];return n.forEach(N,function(Y){var te=new I;Y.accept(te);var q=te.allProductions;n.forEach(q,function(le){var ye=o.getProdType(le),Te=le.maxLookahead||B,Ae=le.idx,_e=o.getLookaheadPathsForOptionalProd(Ae,Y,ye,Te),G=_e[0];if(n.isEmpty(n.flatten(G))){var P=V.buildEmptyRepetitionError({topLevelRule:Y,repetition:le});ie.push({message:P,type:i.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:Y.name})}})}),ie}r.validateSomeNonEmptyLookaheadPath=C;function E(N,B,V,ie){var Y=[],te=n.reduce(N,function(le,ye,Te){return B.definition[Te].ignoreAmbiguities===!0||n.forEach(ye,function(Ae){var _e=[Te];n.forEach(N,function(G,P){Te!==P&&o.containsPath(G,Ae)&&B.definition[P].ignoreAmbiguities!==!0&&_e.push(P)}),_e.length>1&&!o.containsPath(Y,Ae)&&(Y.push(Ae),le.push({alts:_e,path:Ae}))}),le},[]),q=t.map(te,function(le){var ye=n.map(le.alts,function(Ae){return Ae+1}),Te=ie.buildAlternationAmbiguityError({topLevelRule:V,alternation:B,ambiguityIndices:ye,prefixPath:le.path});return{message:Te,type:i.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:V.name,occurrence:B.idx,alternatives:[le.alts]}});return q}function b(N,B,V,ie){var Y=[],te=n.reduce(N,function(q,le,ye){var Te=n.map(le,function(Ae){return{idx:ye,path:Ae}});return q.concat(Te)},[]);return n.forEach(te,function(q){var le=B.definition[q.idx];if(le.ignoreAmbiguities!==!0){var ye=q.idx,Te=q.path,Ae=n.findAll(te,function(G){return B.definition[G.idx].ignoreAmbiguities!==!0&&G.idx<ye&&o.isStrictPrefixOfPath(G.path,Te)}),_e=n.map(Ae,function(G){var P=[G.idx+1,ye+1],M=B.idx===0?"":B.idx,T=ie.buildAlternationPrefixAmbiguityError({topLevelRule:V,alternation:B,ambiguityIndices:P,prefixPath:G.path});return{message:T,type:i.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:V.name,occurrence:M,alternatives:P}});Y=Y.concat(_e)}}),Y}r.checkPrefixAlternativesAmbiguities=b;function R(N,B,V){var ie=[],Y=n.map(B,function(te){return te.name});return n.forEach(N,function(te){var q=te.name;if(n.contains(Y,q)){var le=V.buildNamespaceConflictError(te);ie.push({message:le,type:i.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:q})}}),ie}}),TS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.validateGrammar=r.resolveGrammar=void 0;var e=Wt(),t=_S(),n=sx(),i=Xf();function s(a){a=e.defaults(a,{errMsgProvider:i.defaultGrammarResolverErrorProvider});var l={};return e.forEach(a.rules,function(c){l[c.name]=c}),t.resolveGrammar(l,a.errMsgProvider)}r.resolveGrammar=s;function o(a){return a=e.defaults(a,{errMsgProvider:i.defaultGrammarValidatorErrorProvider}),n.validateGrammar(a.rules,a.maxLookahead,a.tokenTypes,a.errMsgProvider,a.grammarName)}r.validateGrammar=o}),Hc=bt(r=>{"use strict";var e=r&&r.__extends||function(){var g=function(y,d){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,_){m.__proto__=_}||function(m,_){for(var v in _)Object.prototype.hasOwnProperty.call(_,v)&&(m[v]=_[v])},g(y,d)};return function(y,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");g(y,d);function m(){this.constructor=y}y.prototype=d===null?Object.create(d):(m.prototype=d.prototype,new m)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.EarlyExitException=r.NotAllInputParsedException=r.NoViableAltException=r.MismatchedTokenException=r.isRecognitionException=void 0;var t=Wt(),n="MismatchedTokenException",i="NoViableAltException",s="EarlyExitException",o="NotAllInputParsedException",a=[n,i,s,o];Object.freeze(a);function l(g){return t.contains(a,g.name)}r.isRecognitionException=l;var c=function(g){e(y,g);function y(d,m){var _=this.constructor,v=g.call(this,d)||this;return v.token=m,v.resyncedTokens=[],Object.setPrototypeOf(v,_.prototype),Error.captureStackTrace&&Error.captureStackTrace(v,v.constructor),v}return y}(Error),u=function(g){e(y,g);function y(d,m,_){var v=g.call(this,d,m)||this;return v.previousToken=_,v.name=n,v}return y}(c);r.MismatchedTokenException=u;var h=function(g){e(y,g);function y(d,m,_){var v=g.call(this,d,m)||this;return v.previousToken=_,v.name=i,v}return y}(c);r.NoViableAltException=h;var f=function(g){e(y,g);function y(d,m){var _=g.call(this,d,m)||this;return _.name=o,_}return y}(c);r.NotAllInputParsedException=f;var p=function(g){e(y,g);function y(d,m,_){var v=g.call(this,d,m)||this;return v.previousToken=_,v.name=s,v}return y}(c);r.EarlyExitException=p}),ox=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.attemptInRepetitionRecovery=r.Recoverable=r.InRuleRecoveryException=r.IN_RULE_RECOVERY_EXCEPTION=r.EOF_FOLLOW_KEY=void 0;var e=Co(),t=Wt(),n=Hc(),i=rx(),s=Xi();r.EOF_FOLLOW_KEY={},r.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function o(c){this.name=r.IN_RULE_RECOVERY_EXCEPTION,this.message=c}r.InRuleRecoveryException=o,o.prototype=Error.prototype;var a=function(){function c(){}return c.prototype.initRecoverable=function(u){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=t.has(u,"recoveryEnabled")?u.recoveryEnabled:s.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=l)},c.prototype.getTokenToInsert=function(u){var h=e.createTokenInstance(u,"",NaN,NaN,NaN,NaN,NaN,NaN);return h.isInsertedInRecovery=!0,h},c.prototype.canTokenTypeBeInsertedInRecovery=function(u){return!0},c.prototype.tryInRepetitionRecovery=function(u,h,f,p){for(var g=this,y=this.findReSyncTokenType(),d=this.exportLexerState(),m=[],_=!1,v=this.LA(1),x=this.LA(1),S=function(){var I=g.LA(0),A=g.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:v,previous:I,ruleName:g.getCurrRuleFullName()}),C=new n.MismatchedTokenException(A,v,g.LA(0));C.resyncedTokens=t.dropRight(m),g.SAVE_ERROR(C)};!_;)if(this.tokenMatcher(x,p)){S();return}else if(f.call(this)){S(),u.apply(this,h);return}else this.tokenMatcher(x,y)?_=!0:(x=this.SKIP_TOKEN(),this.addToResyncTokens(x,m));this.importLexerState(d)},c.prototype.shouldInRepetitionRecoveryBeTried=function(u,h,f){return!(f===!1||u===void 0||h===void 0||this.tokenMatcher(this.LA(1),u)||this.isBackTracking()||this.canPerformInRuleRecovery(u,this.getFollowsForInRuleRecovery(u,h)))},c.prototype.getFollowsForInRuleRecovery=function(u,h){var f=this.getCurrentGrammarPath(u,h),p=this.getNextPossibleTokenTypes(f);return p},c.prototype.tryInRuleRecovery=function(u,h){if(this.canRecoverWithSingleTokenInsertion(u,h)){var f=this.getTokenToInsert(u);return f}if(this.canRecoverWithSingleTokenDeletion(u)){var p=this.SKIP_TOKEN();return this.consumeToken(),p}throw new o("sad sad panda")},c.prototype.canPerformInRuleRecovery=function(u,h){return this.canRecoverWithSingleTokenInsertion(u,h)||this.canRecoverWithSingleTokenDeletion(u)},c.prototype.canRecoverWithSingleTokenInsertion=function(u,h){var f=this;if(!this.canTokenTypeBeInsertedInRecovery(u)||t.isEmpty(h))return!1;var p=this.LA(1),g=t.find(h,function(y){return f.tokenMatcher(p,y)})!==void 0;return g},c.prototype.canRecoverWithSingleTokenDeletion=function(u){var h=this.tokenMatcher(this.LA(2),u);return h},c.prototype.isInCurrentRuleReSyncSet=function(u){var h=this.getCurrFollowKey(),f=this.getFollowSetFromFollowKey(h);return t.contains(f,u)},c.prototype.findReSyncTokenType=function(){for(var u=this.flattenFollowSet(),h=this.LA(1),f=2;;){var p=h.tokenType;if(t.contains(u,p))return p;h=this.LA(f),f++}},c.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return r.EOF_FOLLOW_KEY;var u=this.getLastExplicitRuleShortName(),h=this.getLastExplicitRuleOccurrenceIndex(),f=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(u),idxInCallingRule:h,inRule:this.shortRuleNameToFullName(f)}},c.prototype.buildFullFollowKeyStack=function(){var u=this,h=this.RULE_STACK,f=this.RULE_OCCURRENCE_STACK;return t.map(h,function(p,g){return g===0?r.EOF_FOLLOW_KEY:{ruleName:u.shortRuleNameToFullName(p),idxInCallingRule:f[g],inRule:u.shortRuleNameToFullName(h[g-1])}})},c.prototype.flattenFollowSet=function(){var u=this,h=t.map(this.buildFullFollowKeyStack(),function(f){return u.getFollowSetFromFollowKey(f)});return t.flatten(h)},c.prototype.getFollowSetFromFollowKey=function(u){if(u===r.EOF_FOLLOW_KEY)return[e.EOF];var h=u.ruleName+u.idxInCallingRule+i.IN+u.inRule;return this.resyncFollows[h]},c.prototype.addToResyncTokens=function(u,h){return this.tokenMatcher(u,e.EOF)||h.push(u),h},c.prototype.reSyncTo=function(u){for(var h=[],f=this.LA(1);this.tokenMatcher(f,u)===!1;)f=this.SKIP_TOKEN(),this.addToResyncTokens(f,h);return t.dropRight(h)},c.prototype.attemptInRepetitionRecovery=function(u,h,f,p,g,y,d){},c.prototype.getCurrentGrammarPath=function(u,h){var f=this.getHumanReadableRuleStack(),p=t.cloneArr(this.RULE_OCCURRENCE_STACK),g={ruleStack:f,occurrenceStack:p,lastTok:u,lastTokOccurrence:h};return g},c.prototype.getHumanReadableRuleStack=function(){var u=this;return t.map(this.RULE_STACK,function(h){return u.shortRuleNameToFullName(h)})},c}();r.Recoverable=a;function l(c,u,h,f,p,g,y){var d=this.getKeyForAutomaticLookahead(f,p),m=this.firstAfterRepMap[d];if(m===void 0){var _=this.getCurrRuleFullName(),v=this.getGAstProductions()[_],x=new g(v,p);m=x.startWalking(),this.firstAfterRepMap[d]=m}var S=m.token,I=m.occurrence,A=m.isEndOfRule;this.RULE_STACK.length===1&&A&&S===void 0&&(S=e.EOF,I=1),this.shouldInRepetitionRecoveryBeTried(S,I,y)&&this.tryInRepetitionRecovery(c,u,h,S)}r.attemptInRepetitionRecovery=l}),Em=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getKeyForAutomaticLookahead=r.AT_LEAST_ONE_SEP_IDX=r.MANY_SEP_IDX=r.AT_LEAST_ONE_IDX=r.MANY_IDX=r.OPTION_IDX=r.OR_IDX=r.BITS_FOR_ALT_IDX=r.BITS_FOR_RULE_IDX=r.BITS_FOR_OCCURRENCE_IDX=r.BITS_FOR_METHOD_TYPE=void 0,r.BITS_FOR_METHOD_TYPE=4,r.BITS_FOR_OCCURRENCE_IDX=8,r.BITS_FOR_RULE_IDX=12,r.BITS_FOR_ALT_IDX=8,r.OR_IDX=1<<r.BITS_FOR_OCCURRENCE_IDX,r.OPTION_IDX=2<<r.BITS_FOR_OCCURRENCE_IDX,r.MANY_IDX=3<<r.BITS_FOR_OCCURRENCE_IDX,r.AT_LEAST_ONE_IDX=4<<r.BITS_FOR_OCCURRENCE_IDX,r.MANY_SEP_IDX=5<<r.BITS_FOR_OCCURRENCE_IDX,r.AT_LEAST_ONE_SEP_IDX=6<<r.BITS_FOR_OCCURRENCE_IDX;function e(n,i,s){return s|i|n}r.getKeyForAutomaticLookahead=e;var t=32-r.BITS_FOR_ALT_IDX}),MS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.LooksAhead=void 0;var e=jf(),t=Wt(),n=Xi(),i=Em(),s=Wf(),o=function(){function a(){}return a.prototype.initLooksAhead=function(l){this.dynamicTokensEnabled=t.has(l,"dynamicTokensEnabled")?l.dynamicTokensEnabled:n.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=t.has(l,"maxLookahead")?l.maxLookahead:n.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=t.isES2015MapSupported()?new Map:[],t.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},a.prototype.preComputeLookaheadFunctions=function(l){var c=this;t.forEach(l,function(u){c.TRACE_INIT(u.name+" Rule Lookahead",function(){var h=s.collectMethods(u),f=h.alternation,p=h.repetition,g=h.option,y=h.repetitionMandatory,d=h.repetitionMandatoryWithSeparator,m=h.repetitionWithSeparator;t.forEach(f,function(_){var v=_.idx===0?"":_.idx;c.TRACE_INIT(""+s.getProductionDslName(_)+v,function(){var x=e.buildLookaheadFuncForOr(_.idx,u,_.maxLookahead||c.maxLookahead,_.hasPredicates,c.dynamicTokensEnabled,c.lookAheadBuilderForAlternatives),S=i.getKeyForAutomaticLookahead(c.fullRuleNameToShort[u.name],i.OR_IDX,_.idx);c.setLaFuncCache(S,x)})}),t.forEach(p,function(_){c.computeLookaheadFunc(u,_.idx,i.MANY_IDX,e.PROD_TYPE.REPETITION,_.maxLookahead,s.getProductionDslName(_))}),t.forEach(g,function(_){c.computeLookaheadFunc(u,_.idx,i.OPTION_IDX,e.PROD_TYPE.OPTION,_.maxLookahead,s.getProductionDslName(_))}),t.forEach(y,function(_){c.computeLookaheadFunc(u,_.idx,i.AT_LEAST_ONE_IDX,e.PROD_TYPE.REPETITION_MANDATORY,_.maxLookahead,s.getProductionDslName(_))}),t.forEach(d,function(_){c.computeLookaheadFunc(u,_.idx,i.AT_LEAST_ONE_SEP_IDX,e.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,_.maxLookahead,s.getProductionDslName(_))}),t.forEach(m,function(_){c.computeLookaheadFunc(u,_.idx,i.MANY_SEP_IDX,e.PROD_TYPE.REPETITION_WITH_SEPARATOR,_.maxLookahead,s.getProductionDslName(_))})})})},a.prototype.computeLookaheadFunc=function(l,c,u,h,f,p){var g=this;this.TRACE_INIT(""+p+(c===0?"":c),function(){var y=e.buildLookaheadFuncForOptionalProd(c,l,f||g.maxLookahead,g.dynamicTokensEnabled,h,g.lookAheadBuilderForOptional),d=i.getKeyForAutomaticLookahead(g.fullRuleNameToShort[l.name],u,c);g.setLaFuncCache(d,y)})},a.prototype.lookAheadBuilderForOptional=function(l,c,u){return e.buildSingleAlternativeLookaheadFunction(l,c,u)},a.prototype.lookAheadBuilderForAlternatives=function(l,c,u,h){return e.buildAlternativesLookAheadFunc(l,c,u,h)},a.prototype.getKeyForAutomaticLookahead=function(l,c){var u=this.getLastExplicitRuleShortName();return i.getKeyForAutomaticLookahead(u,l,c)},a.prototype.getLaFuncFromCache=function(l){},a.prototype.getLaFuncFromMap=function(l){return this.lookAheadFuncsCache.get(l)},a.prototype.getLaFuncFromObj=function(l){return this.lookAheadFuncsCache[l]},a.prototype.setLaFuncCache=function(l,c){},a.prototype.setLaFuncCacheUsingMap=function(l,c){this.lookAheadFuncsCache.set(l,c)},a.prototype.setLaFuncUsingObj=function(l,c){this.lookAheadFuncsCache[l]=c},a}();r.LooksAhead=o}),ES=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.addNoneTerminalToCst=r.addTerminalToCst=r.setNodeLocationFull=r.setNodeLocationOnlyOffset=void 0;function e(s,o){isNaN(s.startOffset)===!0?(s.startOffset=o.startOffset,s.endOffset=o.endOffset):s.endOffset<o.endOffset&&(s.endOffset=o.endOffset)}r.setNodeLocationOnlyOffset=e;function t(s,o){isNaN(s.startOffset)===!0?(s.startOffset=o.startOffset,s.startColumn=o.startColumn,s.startLine=o.startLine,s.endOffset=o.endOffset,s.endColumn=o.endColumn,s.endLine=o.endLine):s.endOffset<o.endOffset&&(s.endOffset=o.endOffset,s.endColumn=o.endColumn,s.endLine=o.endLine)}r.setNodeLocationFull=t;function n(s,o,a){s.children[a]===void 0?s.children[a]=[o]:s.children[a].push(o)}r.addTerminalToCst=n;function i(s,o,a){s.children[o]===void 0?s.children[o]=[a]:s.children[o].push(a)}r.addNoneTerminalToCst=i}),ax=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineNameProp=r.functionName=r.classNameFromInstance=void 0;var e=Wt();function t(o){return i(o.constructor)}r.classNameFromInstance=t;var n="name";function i(o){var a=o.name;return a||"anonymous"}r.functionName=i;function s(o,a){var l=Object.getOwnPropertyDescriptor(o,n);return e.isUndefined(l)||l.configurable?(Object.defineProperty(o,n,{enumerable:!1,configurable:!0,writable:!1,value:a}),!0):!1}r.defineNameProp=s}),bS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.validateRedundantMethods=r.validateMissingCstMethods=r.validateVisitor=r.CstVisitorDefinitionError=r.createBaseVisitorConstructorWithDefaults=r.createBaseSemanticVisitorConstructor=r.defaultVisit=void 0;var e=Wt(),t=ax();function n(h,f){for(var p=e.keys(h),g=p.length,y=0;y<g;y++)for(var d=p[y],m=h[d],_=m.length,v=0;v<_;v++){var x=m[v];x.tokenTypeIdx===void 0&&this[x.name](x.children,f)}}r.defaultVisit=n;function i(h,f){var p=function(){};t.defineNameProp(p,h+"BaseSemantics");var g={visit:function(y,d){if(e.isArray(y)&&(y=y[0]),!e.isUndefined(y))return this[y.name](y.children,d)},validateVisitor:function(){var y=a(this,f);if(!e.isEmpty(y)){var d=e.map(y,function(m){return m.msg});throw Error("Errors Detected in CST Visitor <"+t.functionName(this.constructor)+`>:
`+(""+d.join(`
`).replace(/\n/g,`
- `)))}}};return p.prototype=g,p.prototype.constructor=p,p._RULE_NAMES=f,p}r.createBaseSemanticVisitorConstructor=i;function s(h,f,p){var g=function(){};t.defineNameProp(g,h+"BaseSemanticsWithDefaults");var v=Object.create(p.prototype);return e.forEach(f,function(d){v[d]=n}),g.prototype=v,g.prototype.constructor=g,g}r.createBaseVisitorConstructorWithDefaults=s;var o;(function(h){h[h.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",h[h.MISSING_METHOD=1]="MISSING_METHOD"})(o=r.CstVisitorDefinitionError||(r.CstVisitorDefinitionError={}));function a(h,f){var p=l(h,f),g=u(h,f);return p.concat(g)}r.validateVisitor=a;function l(h,f){var p=e.map(f,function(g){if(!e.isFunction(h[g]))return{msg:"Missing visitor method: <"+g+"> on "+t.functionName(h.constructor)+" CST Visitor.",type:o.MISSING_METHOD,methodName:g}});return e.compact(p)}r.validateMissingCstMethods=l;var c=["constructor","visit","validateVisitor"];function u(h,f){var p=[];for(var g in h)e.isFunction(h[g])&&!e.contains(c,g)&&!e.contains(f,g)&&p.push({msg:"Redundant visitor method: <"+g+"> on "+t.functionName(h.constructor)+` CST Visitor
+ `)))}}};return p.prototype=g,p.prototype.constructor=p,p._RULE_NAMES=f,p}r.createBaseSemanticVisitorConstructor=i;function s(h,f,p){var g=function(){};t.defineNameProp(g,h+"BaseSemanticsWithDefaults");var y=Object.create(p.prototype);return e.forEach(f,function(d){y[d]=n}),g.prototype=y,g.prototype.constructor=g,g}r.createBaseVisitorConstructorWithDefaults=s;var o;(function(h){h[h.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",h[h.MISSING_METHOD=1]="MISSING_METHOD"})(o=r.CstVisitorDefinitionError||(r.CstVisitorDefinitionError={}));function a(h,f){var p=l(h,f),g=u(h,f);return p.concat(g)}r.validateVisitor=a;function l(h,f){var p=e.map(f,function(g){if(!e.isFunction(h[g]))return{msg:"Missing visitor method: <"+g+"> on "+t.functionName(h.constructor)+" CST Visitor.",type:o.MISSING_METHOD,methodName:g}});return e.compact(p)}r.validateMissingCstMethods=l;var c=["constructor","visit","validateVisitor"];function u(h,f){var p=[];for(var g in h)e.isFunction(h[g])&&!e.contains(c,g)&&!e.contains(f,g)&&p.push({msg:"Redundant visitor method: <"+g+"> on "+t.functionName(h.constructor)+` CST Visitor
There is no Grammar Rule corresponding to this method's name.
-`,type:o.REDUNDANT_METHOD,methodName:g});return p}r.validateRedundantMethods=u}),_S=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.TreeBuilder=void 0;var e=yS(),t=Ut(),n=xS(),i=Ni(),s=function(){function o(){}return o.prototype.initTreeBuilder=function(a){if(this.CST_STACK=[],this.outputCst=a.outputCst,this.nodeLocationTracking=t.has(a,"nodeLocationTracking")?a.nodeLocationTracking:i.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=t.NOOP,this.cstFinallyStateUpdate=t.NOOP,this.cstPostTerminal=t.NOOP,this.cstPostNonTerminal=t.NOOP,this.cstPostRule=t.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationFull,this.setNodeLocationFromNode=e.setNodeLocationFull,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=e.setNodeLocationOnlyOffset,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=t.NOOP;else throw Error('Invalid <nodeLocationTracking> config option: "'+a.nodeLocationTracking+'"')},o.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(a){a.location={startOffset:NaN,endOffset:NaN}},o.prototype.setInitialNodeLocationOnlyOffsetRegular=function(a){a.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},o.prototype.setInitialNodeLocationFullRecovery=function(a){a.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.setInitialNodeLocationFullRegular=function(a){var l=this.LA(1);a.location={startOffset:l.startOffset,startLine:l.startLine,startColumn:l.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.cstInvocationStateUpdate=function(a,l){var c={name:a,children:{}};this.setInitialNodeLocation(c),this.CST_STACK.push(c)},o.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},o.prototype.cstPostRuleFull=function(a){var l=this.LA(0),c=a.location;c.startOffset<=l.startOffset?(c.endOffset=l.endOffset,c.endLine=l.endLine,c.endColumn=l.endColumn):(c.startOffset=NaN,c.startLine=NaN,c.startColumn=NaN)},o.prototype.cstPostRuleOnlyOffset=function(a){var l=this.LA(0),c=a.location;c.startOffset<=l.startOffset?c.endOffset=l.endOffset:c.startOffset=NaN},o.prototype.cstPostTerminal=function(a,l){var c=this.CST_STACK[this.CST_STACK.length-1];e.addTerminalToCst(c,l,a),this.setNodeLocationFromToken(c.location,l)},o.prototype.cstPostNonTerminal=function(a,l){var c=this.CST_STACK[this.CST_STACK.length-1];e.addNoneTerminalToCst(c,l,a),this.setNodeLocationFromNode(c.location,a.location)},o.prototype.getBaseCstVisitorConstructor=function(){if(t.isUndefined(this.baseCstVisitorConstructor)){var a=n.createBaseSemanticVisitorConstructor(this.className,t.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=a,a}return this.baseCstVisitorConstructor},o.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(t.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var a=n.createBaseVisitorConstructorWithDefaults(this.className,t.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=a,a}return this.baseCstVisitorWithDefaultsConstructor},o.prototype.getLastExplicitRuleShortName=function(){var a=this.RULE_STACK;return a[a.length-1]},o.prototype.getPreviousExplicitRuleShortName=function(){var a=this.RULE_STACK;return a[a.length-2]},o.prototype.getLastExplicitRuleOccurrenceIndex=function(){var a=this.RULE_OCCURRENCE_STACK;return a[a.length-1]},o}();r.TreeBuilder=s}),TS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.LexerAdapter=void 0;var e=Ni(),t=function(){function n(){}return n.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(n.prototype,"input",{get:function(){return this.tokVector},set:function(i){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=i,this.tokVectorLength=i.length},enumerable:!1,configurable:!0}),n.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):e.END_OF_FILE},n.prototype.LA=function(i){var s=this.currIdx+i;return s<0||this.tokVectorLength<=s?e.END_OF_FILE:this.tokVector[s]},n.prototype.consumeToken=function(){this.currIdx++},n.prototype.exportLexerState=function(){return this.currIdx},n.prototype.importLexerState=function(i){this.currIdx=i},n.prototype.resetLexerState=function(){this.currIdx=-1},n.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},n.prototype.getLexerPosition=function(){return this.exportLexerState()},n}();r.LexerAdapter=t}),MS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.RecognizerApi=void 0;var e=Ut(),t=ic(),n=Ni(),i=Ch(),s=q0(),o=xi(),a=function(){function l(){}return l.prototype.ACTION=function(c){return c.call(this)},l.prototype.consume=function(c,u,h){return this.consumeInternal(u,c,h)},l.prototype.subrule=function(c,u,h){return this.subruleInternal(u,c,h)},l.prototype.option=function(c,u){return this.optionInternal(u,c)},l.prototype.or=function(c,u){return this.orInternal(u,c)},l.prototype.many=function(c,u){return this.manyInternal(c,u)},l.prototype.atLeastOne=function(c,u){return this.atLeastOneInternal(c,u)},l.prototype.CONSUME=function(c,u){return this.consumeInternal(c,0,u)},l.prototype.CONSUME1=function(c,u){return this.consumeInternal(c,1,u)},l.prototype.CONSUME2=function(c,u){return this.consumeInternal(c,2,u)},l.prototype.CONSUME3=function(c,u){return this.consumeInternal(c,3,u)},l.prototype.CONSUME4=function(c,u){return this.consumeInternal(c,4,u)},l.prototype.CONSUME5=function(c,u){return this.consumeInternal(c,5,u)},l.prototype.CONSUME6=function(c,u){return this.consumeInternal(c,6,u)},l.prototype.CONSUME7=function(c,u){return this.consumeInternal(c,7,u)},l.prototype.CONSUME8=function(c,u){return this.consumeInternal(c,8,u)},l.prototype.CONSUME9=function(c,u){return this.consumeInternal(c,9,u)},l.prototype.SUBRULE=function(c,u){return this.subruleInternal(c,0,u)},l.prototype.SUBRULE1=function(c,u){return this.subruleInternal(c,1,u)},l.prototype.SUBRULE2=function(c,u){return this.subruleInternal(c,2,u)},l.prototype.SUBRULE3=function(c,u){return this.subruleInternal(c,3,u)},l.prototype.SUBRULE4=function(c,u){return this.subruleInternal(c,4,u)},l.prototype.SUBRULE5=function(c,u){return this.subruleInternal(c,5,u)},l.prototype.SUBRULE6=function(c,u){return this.subruleInternal(c,6,u)},l.prototype.SUBRULE7=function(c,u){return this.subruleInternal(c,7,u)},l.prototype.SUBRULE8=function(c,u){return this.subruleInternal(c,8,u)},l.prototype.SUBRULE9=function(c,u){return this.subruleInternal(c,9,u)},l.prototype.OPTION=function(c){return this.optionInternal(c,0)},l.prototype.OPTION1=function(c){return this.optionInternal(c,1)},l.prototype.OPTION2=function(c){return this.optionInternal(c,2)},l.prototype.OPTION3=function(c){return this.optionInternal(c,3)},l.prototype.OPTION4=function(c){return this.optionInternal(c,4)},l.prototype.OPTION5=function(c){return this.optionInternal(c,5)},l.prototype.OPTION6=function(c){return this.optionInternal(c,6)},l.prototype.OPTION7=function(c){return this.optionInternal(c,7)},l.prototype.OPTION8=function(c){return this.optionInternal(c,8)},l.prototype.OPTION9=function(c){return this.optionInternal(c,9)},l.prototype.OR=function(c){return this.orInternal(c,0)},l.prototype.OR1=function(c){return this.orInternal(c,1)},l.prototype.OR2=function(c){return this.orInternal(c,2)},l.prototype.OR3=function(c){return this.orInternal(c,3)},l.prototype.OR4=function(c){return this.orInternal(c,4)},l.prototype.OR5=function(c){return this.orInternal(c,5)},l.prototype.OR6=function(c){return this.orInternal(c,6)},l.prototype.OR7=function(c){return this.orInternal(c,7)},l.prototype.OR8=function(c){return this.orInternal(c,8)},l.prototype.OR9=function(c){return this.orInternal(c,9)},l.prototype.MANY=function(c){this.manyInternal(0,c)},l.prototype.MANY1=function(c){this.manyInternal(1,c)},l.prototype.MANY2=function(c){this.manyInternal(2,c)},l.prototype.MANY3=function(c){this.manyInternal(3,c)},l.prototype.MANY4=function(c){this.manyInternal(4,c)},l.prototype.MANY5=function(c){this.manyInternal(5,c)},l.prototype.MANY6=function(c){this.manyInternal(6,c)},l.prototype.MANY7=function(c){this.manyInternal(7,c)},l.prototype.MANY8=function(c){this.manyInternal(8,c)},l.prototype.MANY9=function(c){this.manyInternal(9,c)},l.prototype.MANY_SEP=function(c){this.manySepFirstInternal(0,c)},l.prototype.MANY_SEP1=function(c){this.manySepFirstInternal(1,c)},l.prototype.MANY_SEP2=function(c){this.manySepFirstInternal(2,c)},l.prototype.MANY_SEP3=function(c){this.manySepFirstInternal(3,c)},l.prototype.MANY_SEP4=function(c){this.manySepFirstInternal(4,c)},l.prototype.MANY_SEP5=function(c){this.manySepFirstInternal(5,c)},l.prototype.MANY_SEP6=function(c){this.manySepFirstInternal(6,c)},l.prototype.MANY_SEP7=function(c){this.manySepFirstInternal(7,c)},l.prototype.MANY_SEP8=function(c){this.manySepFirstInternal(8,c)},l.prototype.MANY_SEP9=function(c){this.manySepFirstInternal(9,c)},l.prototype.AT_LEAST_ONE=function(c){this.atLeastOneInternal(0,c)},l.prototype.AT_LEAST_ONE1=function(c){return this.atLeastOneInternal(1,c)},l.prototype.AT_LEAST_ONE2=function(c){this.atLeastOneInternal(2,c)},l.prototype.AT_LEAST_ONE3=function(c){this.atLeastOneInternal(3,c)},l.prototype.AT_LEAST_ONE4=function(c){this.atLeastOneInternal(4,c)},l.prototype.AT_LEAST_ONE5=function(c){this.atLeastOneInternal(5,c)},l.prototype.AT_LEAST_ONE6=function(c){this.atLeastOneInternal(6,c)},l.prototype.AT_LEAST_ONE7=function(c){this.atLeastOneInternal(7,c)},l.prototype.AT_LEAST_ONE8=function(c){this.atLeastOneInternal(8,c)},l.prototype.AT_LEAST_ONE9=function(c){this.atLeastOneInternal(9,c)},l.prototype.AT_LEAST_ONE_SEP=function(c){this.atLeastOneSepFirstInternal(0,c)},l.prototype.AT_LEAST_ONE_SEP1=function(c){this.atLeastOneSepFirstInternal(1,c)},l.prototype.AT_LEAST_ONE_SEP2=function(c){this.atLeastOneSepFirstInternal(2,c)},l.prototype.AT_LEAST_ONE_SEP3=function(c){this.atLeastOneSepFirstInternal(3,c)},l.prototype.AT_LEAST_ONE_SEP4=function(c){this.atLeastOneSepFirstInternal(4,c)},l.prototype.AT_LEAST_ONE_SEP5=function(c){this.atLeastOneSepFirstInternal(5,c)},l.prototype.AT_LEAST_ONE_SEP6=function(c){this.atLeastOneSepFirstInternal(6,c)},l.prototype.AT_LEAST_ONE_SEP7=function(c){this.atLeastOneSepFirstInternal(7,c)},l.prototype.AT_LEAST_ONE_SEP8=function(c){this.atLeastOneSepFirstInternal(8,c)},l.prototype.AT_LEAST_ONE_SEP9=function(c){this.atLeastOneSepFirstInternal(9,c)},l.prototype.RULE=function(c,u,h){if(h===void 0&&(h=n.DEFAULT_RULE_CONFIG),e.contains(this.definedRulesNames,c)){var f=i.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:c,grammarName:this.className}),p={message:f,type:n.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:c};this.definitionErrors.push(p)}this.definedRulesNames.push(c);var g=this.defineRule(c,u,h);return this[c]=g,g},l.prototype.OVERRIDE_RULE=function(c,u,h){h===void 0&&(h=n.DEFAULT_RULE_CONFIG);var f=[];f=f.concat(s.validateRuleIsOverridden(c,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(f);var p=this.defineRule(c,u,h);return this[c]=p,p},l.prototype.BACKTRACK=function(c,u){return function(){this.isBackTrackingStack.push(1);var h=this.saveRecogState();try{return c.apply(this,u),!0}catch(f){if(t.isRecognitionException(f))return!1;throw f}finally{this.reloadRecogState(h),this.isBackTrackingStack.pop()}}},l.prototype.getGAstProductions=function(){return this.gastProductionsCache},l.prototype.getSerializedGastProductions=function(){return o.serializeGrammar(e.values(this.gastProductionsCache))},l}();r.RecognizerApi=a}),ES=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.RecognizerEngine=void 0;var e=Ut(),t=ap(),n=ic(),i=Ih(),s=Rh(),o=Ni(),a=Y0(),l=io(),c=tc(),u=K0(),h=function(){function f(){}return f.prototype.initRecognizerEngine=function(p,g){if(this.className=u.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=c.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},e.has(g,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
+`,type:o.REDUNDANT_METHOD,methodName:g});return p}r.validateRedundantMethods=u}),SS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.TreeBuilder=void 0;var e=ES(),t=Wt(),n=bS(),i=Xi(),s=function(){function o(){}return o.prototype.initTreeBuilder=function(a){if(this.CST_STACK=[],this.outputCst=a.outputCst,this.nodeLocationTracking=t.has(a,"nodeLocationTracking")?a.nodeLocationTracking:i.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=t.NOOP,this.cstFinallyStateUpdate=t.NOOP,this.cstPostTerminal=t.NOOP,this.cstPostNonTerminal=t.NOOP,this.cstPostRule=t.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationFull,this.setNodeLocationFromNode=e.setNodeLocationFull,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=e.setNodeLocationOnlyOffset,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=t.NOOP;else throw Error('Invalid <nodeLocationTracking> config option: "'+a.nodeLocationTracking+'"')},o.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(a){a.location={startOffset:NaN,endOffset:NaN}},o.prototype.setInitialNodeLocationOnlyOffsetRegular=function(a){a.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},o.prototype.setInitialNodeLocationFullRecovery=function(a){a.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.setInitialNodeLocationFullRegular=function(a){var l=this.LA(1);a.location={startOffset:l.startOffset,startLine:l.startLine,startColumn:l.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.cstInvocationStateUpdate=function(a,l){var c={name:a,children:{}};this.setInitialNodeLocation(c),this.CST_STACK.push(c)},o.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},o.prototype.cstPostRuleFull=function(a){var l=this.LA(0),c=a.location;c.startOffset<=l.startOffset?(c.endOffset=l.endOffset,c.endLine=l.endLine,c.endColumn=l.endColumn):(c.startOffset=NaN,c.startLine=NaN,c.startColumn=NaN)},o.prototype.cstPostRuleOnlyOffset=function(a){var l=this.LA(0),c=a.location;c.startOffset<=l.startOffset?c.endOffset=l.endOffset:c.startOffset=NaN},o.prototype.cstPostTerminal=function(a,l){var c=this.CST_STACK[this.CST_STACK.length-1];e.addTerminalToCst(c,l,a),this.setNodeLocationFromToken(c.location,l)},o.prototype.cstPostNonTerminal=function(a,l){var c=this.CST_STACK[this.CST_STACK.length-1];e.addNoneTerminalToCst(c,l,a),this.setNodeLocationFromNode(c.location,a.location)},o.prototype.getBaseCstVisitorConstructor=function(){if(t.isUndefined(this.baseCstVisitorConstructor)){var a=n.createBaseSemanticVisitorConstructor(this.className,t.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=a,a}return this.baseCstVisitorConstructor},o.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(t.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var a=n.createBaseVisitorConstructorWithDefaults(this.className,t.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=a,a}return this.baseCstVisitorWithDefaultsConstructor},o.prototype.getLastExplicitRuleShortName=function(){var a=this.RULE_STACK;return a[a.length-1]},o.prototype.getPreviousExplicitRuleShortName=function(){var a=this.RULE_STACK;return a[a.length-2]},o.prototype.getLastExplicitRuleOccurrenceIndex=function(){var a=this.RULE_OCCURRENCE_STACK;return a[a.length-1]},o}();r.TreeBuilder=s}),AS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.LexerAdapter=void 0;var e=Xi(),t=function(){function n(){}return n.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(n.prototype,"input",{get:function(){return this.tokVector},set:function(i){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=i,this.tokVectorLength=i.length},enumerable:!1,configurable:!0}),n.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):e.END_OF_FILE},n.prototype.LA=function(i){var s=this.currIdx+i;return s<0||this.tokVectorLength<=s?e.END_OF_FILE:this.tokVector[s]},n.prototype.consumeToken=function(){this.currIdx++},n.prototype.exportLexerState=function(){return this.currIdx},n.prototype.importLexerState=function(i){this.currIdx=i},n.prototype.resetLexerState=function(){this.currIdx=-1},n.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},n.prototype.getLexerPosition=function(){return this.exportLexerState()},n}();r.LexerAdapter=t}),wS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.RecognizerApi=void 0;var e=Wt(),t=Hc(),n=Xi(),i=Xf(),s=sx(),o=Li(),a=function(){function l(){}return l.prototype.ACTION=function(c){return c.call(this)},l.prototype.consume=function(c,u,h){return this.consumeInternal(u,c,h)},l.prototype.subrule=function(c,u,h){return this.subruleInternal(u,c,h)},l.prototype.option=function(c,u){return this.optionInternal(u,c)},l.prototype.or=function(c,u){return this.orInternal(u,c)},l.prototype.many=function(c,u){return this.manyInternal(c,u)},l.prototype.atLeastOne=function(c,u){return this.atLeastOneInternal(c,u)},l.prototype.CONSUME=function(c,u){return this.consumeInternal(c,0,u)},l.prototype.CONSUME1=function(c,u){return this.consumeInternal(c,1,u)},l.prototype.CONSUME2=function(c,u){return this.consumeInternal(c,2,u)},l.prototype.CONSUME3=function(c,u){return this.consumeInternal(c,3,u)},l.prototype.CONSUME4=function(c,u){return this.consumeInternal(c,4,u)},l.prototype.CONSUME5=function(c,u){return this.consumeInternal(c,5,u)},l.prototype.CONSUME6=function(c,u){return this.consumeInternal(c,6,u)},l.prototype.CONSUME7=function(c,u){return this.consumeInternal(c,7,u)},l.prototype.CONSUME8=function(c,u){return this.consumeInternal(c,8,u)},l.prototype.CONSUME9=function(c,u){return this.consumeInternal(c,9,u)},l.prototype.SUBRULE=function(c,u){return this.subruleInternal(c,0,u)},l.prototype.SUBRULE1=function(c,u){return this.subruleInternal(c,1,u)},l.prototype.SUBRULE2=function(c,u){return this.subruleInternal(c,2,u)},l.prototype.SUBRULE3=function(c,u){return this.subruleInternal(c,3,u)},l.prototype.SUBRULE4=function(c,u){return this.subruleInternal(c,4,u)},l.prototype.SUBRULE5=function(c,u){return this.subruleInternal(c,5,u)},l.prototype.SUBRULE6=function(c,u){return this.subruleInternal(c,6,u)},l.prototype.SUBRULE7=function(c,u){return this.subruleInternal(c,7,u)},l.prototype.SUBRULE8=function(c,u){return this.subruleInternal(c,8,u)},l.prototype.SUBRULE9=function(c,u){return this.subruleInternal(c,9,u)},l.prototype.OPTION=function(c){return this.optionInternal(c,0)},l.prototype.OPTION1=function(c){return this.optionInternal(c,1)},l.prototype.OPTION2=function(c){return this.optionInternal(c,2)},l.prototype.OPTION3=function(c){return this.optionInternal(c,3)},l.prototype.OPTION4=function(c){return this.optionInternal(c,4)},l.prototype.OPTION5=function(c){return this.optionInternal(c,5)},l.prototype.OPTION6=function(c){return this.optionInternal(c,6)},l.prototype.OPTION7=function(c){return this.optionInternal(c,7)},l.prototype.OPTION8=function(c){return this.optionInternal(c,8)},l.prototype.OPTION9=function(c){return this.optionInternal(c,9)},l.prototype.OR=function(c){return this.orInternal(c,0)},l.prototype.OR1=function(c){return this.orInternal(c,1)},l.prototype.OR2=function(c){return this.orInternal(c,2)},l.prototype.OR3=function(c){return this.orInternal(c,3)},l.prototype.OR4=function(c){return this.orInternal(c,4)},l.prototype.OR5=function(c){return this.orInternal(c,5)},l.prototype.OR6=function(c){return this.orInternal(c,6)},l.prototype.OR7=function(c){return this.orInternal(c,7)},l.prototype.OR8=function(c){return this.orInternal(c,8)},l.prototype.OR9=function(c){return this.orInternal(c,9)},l.prototype.MANY=function(c){this.manyInternal(0,c)},l.prototype.MANY1=function(c){this.manyInternal(1,c)},l.prototype.MANY2=function(c){this.manyInternal(2,c)},l.prototype.MANY3=function(c){this.manyInternal(3,c)},l.prototype.MANY4=function(c){this.manyInternal(4,c)},l.prototype.MANY5=function(c){this.manyInternal(5,c)},l.prototype.MANY6=function(c){this.manyInternal(6,c)},l.prototype.MANY7=function(c){this.manyInternal(7,c)},l.prototype.MANY8=function(c){this.manyInternal(8,c)},l.prototype.MANY9=function(c){this.manyInternal(9,c)},l.prototype.MANY_SEP=function(c){this.manySepFirstInternal(0,c)},l.prototype.MANY_SEP1=function(c){this.manySepFirstInternal(1,c)},l.prototype.MANY_SEP2=function(c){this.manySepFirstInternal(2,c)},l.prototype.MANY_SEP3=function(c){this.manySepFirstInternal(3,c)},l.prototype.MANY_SEP4=function(c){this.manySepFirstInternal(4,c)},l.prototype.MANY_SEP5=function(c){this.manySepFirstInternal(5,c)},l.prototype.MANY_SEP6=function(c){this.manySepFirstInternal(6,c)},l.prototype.MANY_SEP7=function(c){this.manySepFirstInternal(7,c)},l.prototype.MANY_SEP8=function(c){this.manySepFirstInternal(8,c)},l.prototype.MANY_SEP9=function(c){this.manySepFirstInternal(9,c)},l.prototype.AT_LEAST_ONE=function(c){this.atLeastOneInternal(0,c)},l.prototype.AT_LEAST_ONE1=function(c){return this.atLeastOneInternal(1,c)},l.prototype.AT_LEAST_ONE2=function(c){this.atLeastOneInternal(2,c)},l.prototype.AT_LEAST_ONE3=function(c){this.atLeastOneInternal(3,c)},l.prototype.AT_LEAST_ONE4=function(c){this.atLeastOneInternal(4,c)},l.prototype.AT_LEAST_ONE5=function(c){this.atLeastOneInternal(5,c)},l.prototype.AT_LEAST_ONE6=function(c){this.atLeastOneInternal(6,c)},l.prototype.AT_LEAST_ONE7=function(c){this.atLeastOneInternal(7,c)},l.prototype.AT_LEAST_ONE8=function(c){this.atLeastOneInternal(8,c)},l.prototype.AT_LEAST_ONE9=function(c){this.atLeastOneInternal(9,c)},l.prototype.AT_LEAST_ONE_SEP=function(c){this.atLeastOneSepFirstInternal(0,c)},l.prototype.AT_LEAST_ONE_SEP1=function(c){this.atLeastOneSepFirstInternal(1,c)},l.prototype.AT_LEAST_ONE_SEP2=function(c){this.atLeastOneSepFirstInternal(2,c)},l.prototype.AT_LEAST_ONE_SEP3=function(c){this.atLeastOneSepFirstInternal(3,c)},l.prototype.AT_LEAST_ONE_SEP4=function(c){this.atLeastOneSepFirstInternal(4,c)},l.prototype.AT_LEAST_ONE_SEP5=function(c){this.atLeastOneSepFirstInternal(5,c)},l.prototype.AT_LEAST_ONE_SEP6=function(c){this.atLeastOneSepFirstInternal(6,c)},l.prototype.AT_LEAST_ONE_SEP7=function(c){this.atLeastOneSepFirstInternal(7,c)},l.prototype.AT_LEAST_ONE_SEP8=function(c){this.atLeastOneSepFirstInternal(8,c)},l.prototype.AT_LEAST_ONE_SEP9=function(c){this.atLeastOneSepFirstInternal(9,c)},l.prototype.RULE=function(c,u,h){if(h===void 0&&(h=n.DEFAULT_RULE_CONFIG),e.contains(this.definedRulesNames,c)){var f=i.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:c,grammarName:this.className}),p={message:f,type:n.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:c};this.definitionErrors.push(p)}this.definedRulesNames.push(c);var g=this.defineRule(c,u,h);return this[c]=g,g},l.prototype.OVERRIDE_RULE=function(c,u,h){h===void 0&&(h=n.DEFAULT_RULE_CONFIG);var f=[];f=f.concat(s.validateRuleIsOverridden(c,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(f);var p=this.defineRule(c,u,h);return this[c]=p,p},l.prototype.BACKTRACK=function(c,u){return function(){this.isBackTrackingStack.push(1);var h=this.saveRecogState();try{return c.apply(this,u),!0}catch(f){if(t.isRecognitionException(f))return!1;throw f}finally{this.reloadRecogState(h),this.isBackTrackingStack.pop()}}},l.prototype.getGAstProductions=function(){return this.gastProductionsCache},l.prototype.getSerializedGastProductions=function(){return o.serializeGrammar(e.values(this.gastProductionsCache))},l}();r.RecognizerApi=a}),CS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.RecognizerEngine=void 0;var e=Wt(),t=Em(),n=Hc(),i=jf(),s=qf(),o=Xi(),a=ox(),l=Co(),c=Vc(),u=ax(),h=function(){function f(){}return f.prototype.initRecognizerEngine=function(p,g){if(this.className=u.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=c.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},e.has(g,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
For Further details.`);if(e.isArray(p)){if(e.isEmpty(p))throw Error(`A Token Vocabulary cannot be empty.
Note that the first argument for the parser constructor
is no longer a Token vector (since v4.0).`);if(typeof p[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
- For Further details.`)}if(e.isArray(p))this.tokensMap=e.reduce(p,function(_,y){return _[y.name]=y,_},{});else if(e.has(p,"modes")&&e.every(e.flatten(e.values(p.modes)),c.isTokenType)){var v=e.flatten(e.values(p.modes)),d=e.uniq(v);this.tokensMap=e.reduce(d,function(_,y){return _[y.name]=y,_},{})}else if(e.isObject(p))this.tokensMap=e.cloneObj(p);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=l.EOF;var m=e.every(e.values(p),function(_){return e.isEmpty(_.categoryMatches)});this.tokenMatcher=m?c.tokenStructuredMatcherNoCategories:c.tokenStructuredMatcher,c.augmentTokenTypes(e.values(this.tokensMap))},f.prototype.defineRule=function(p,g,v){if(this.selfAnalysisDone)throw Error("Grammar rule <"+p+`> may not be defined after the 'performSelfAnalysis' method has been called'
-Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var d=e.has(v,"resyncEnabled")?v.resyncEnabled:o.DEFAULT_RULE_CONFIG.resyncEnabled,m=e.has(v,"recoveryValueFunc")?v.recoveryValueFunc:o.DEFAULT_RULE_CONFIG.recoveryValueFunc,_=this.ruleShortNameIdx<<t.BITS_FOR_METHOD_TYPE+t.BITS_FOR_OCCURRENCE_IDX;this.ruleShortNameIdx++,this.shortRuleNameToFull[_]=p,this.fullRuleNameToShort[p]=_;function y(I){try{if(this.outputCst===!0){g.apply(this,I);var C=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(C),C}else return g.apply(this,I)}catch(P){return this.invokeRuleCatch(P,d,m)}finally{this.ruleFinallyStateUpdate()}}var x=function(I,C){return I===void 0&&(I=0),this.ruleInvocationStateUpdate(_,p,I),y.call(this,C)},w="ruleName";return x[w]=p,x.originalGrammarAction=g,x},f.prototype.invokeRuleCatch=function(p,g,v){var d=this.RULE_STACK.length===1,m=g&&!this.isBackTracking()&&this.recoveryEnabled;if(n.isRecognitionException(p)){var _=p;if(m){var y=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(y))if(_.resyncedTokens=this.reSyncTo(y),this.outputCst){var x=this.CST_STACK[this.CST_STACK.length-1];return x.recoveredNode=!0,x}else return v();else{if(this.outputCst){var x=this.CST_STACK[this.CST_STACK.length-1];x.recoveredNode=!0,_.partialCstResult=x}throw _}}else{if(d)return this.moveToTerminatedState(),v();throw _}}else throw p},f.prototype.optionInternal=function(p,g){var v=this.getKeyForAutomaticLookahead(t.OPTION_IDX,g);return this.optionInternalLogic(p,g,v)},f.prototype.optionInternalLogic=function(p,g,v){var d=this,m=this.getLaFuncFromCache(v),_,y;if(p.DEF!==void 0){if(_=p.DEF,y=p.GATE,y!==void 0){var x=m;m=function(){return y.call(d)&&x.call(d)}}}else _=p;if(m.call(this)===!0)return _.call(this)},f.prototype.atLeastOneInternal=function(p,g){var v=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_IDX,p);return this.atLeastOneInternalLogic(p,g,v)},f.prototype.atLeastOneInternalLogic=function(p,g,v){var d=this,m=this.getLaFuncFromCache(v),_,y;if(g.DEF!==void 0){if(_=g.DEF,y=g.GATE,y!==void 0){var x=m;m=function(){return y.call(d)&&x.call(d)}}}else _=g;if(m.call(this)===!0)for(var w=this.doSingleRepetition(_);m.call(this)===!0&&w===!0;)w=this.doSingleRepetition(_);else throw this.raiseEarlyExitException(p,i.PROD_TYPE.REPETITION_MANDATORY,g.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[p,g],m,t.AT_LEAST_ONE_IDX,p,s.NextTerminalAfterAtLeastOneWalker)},f.prototype.atLeastOneSepFirstInternal=function(p,g){var v=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_SEP_IDX,p);this.atLeastOneSepFirstInternalLogic(p,g,v)},f.prototype.atLeastOneSepFirstInternalLogic=function(p,g,v){var d=this,m=g.DEF,_=g.SEP,y=this.getLaFuncFromCache(v);if(y.call(this)===!0){m.call(this);for(var x=function(){return d.tokenMatcher(d.LA(1),_)};this.tokenMatcher(this.LA(1),_)===!0;)this.CONSUME(_),m.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,_,x,m,s.NextTerminalAfterAtLeastOneSepWalker],x,t.AT_LEAST_ONE_SEP_IDX,p,s.NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(p,i.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,g.ERR_MSG)},f.prototype.manyInternal=function(p,g){var v=this.getKeyForAutomaticLookahead(t.MANY_IDX,p);return this.manyInternalLogic(p,g,v)},f.prototype.manyInternalLogic=function(p,g,v){var d=this,m=this.getLaFuncFromCache(v),_,y;if(g.DEF!==void 0){if(_=g.DEF,y=g.GATE,y!==void 0){var x=m;m=function(){return y.call(d)&&x.call(d)}}}else _=g;for(var w=!0;m.call(this)===!0&&w===!0;)w=this.doSingleRepetition(_);this.attemptInRepetitionRecovery(this.manyInternal,[p,g],m,t.MANY_IDX,p,s.NextTerminalAfterManyWalker,w)},f.prototype.manySepFirstInternal=function(p,g){var v=this.getKeyForAutomaticLookahead(t.MANY_SEP_IDX,p);this.manySepFirstInternalLogic(p,g,v)},f.prototype.manySepFirstInternalLogic=function(p,g,v){var d=this,m=g.DEF,_=g.SEP,y=this.getLaFuncFromCache(v);if(y.call(this)===!0){m.call(this);for(var x=function(){return d.tokenMatcher(d.LA(1),_)};this.tokenMatcher(this.LA(1),_)===!0;)this.CONSUME(_),m.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,_,x,m,s.NextTerminalAfterManySepWalker],x,t.MANY_SEP_IDX,p,s.NextTerminalAfterManySepWalker)}},f.prototype.repetitionSepSecondInternal=function(p,g,v,d,m){for(;v();)this.CONSUME(g),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,g,v,d,m],v,t.AT_LEAST_ONE_SEP_IDX,p,m)},f.prototype.doSingleRepetition=function(p){var g=this.getLexerPosition();p.call(this);var v=this.getLexerPosition();return v>g},f.prototype.orInternal=function(p,g){var v=this.getKeyForAutomaticLookahead(t.OR_IDX,g),d=e.isArray(p)?p:p.DEF,m=this.getLaFuncFromCache(v),_=m.call(this,d);if(_!==void 0){var y=d[_];return y.ALT.call(this)}this.raiseNoAltException(g,p.ERR_MSG)},f.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var p=this.LA(1),g=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:p,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new n.NotAllInputParsedException(g,p))}},f.prototype.subruleInternal=function(p,g,v){var d;try{var m=v!==void 0?v.ARGS:void 0;return d=p.call(this,g,m),this.cstPostNonTerminal(d,v!==void 0&&v.LABEL!==void 0?v.LABEL:p.ruleName),d}catch(_){this.subruleInternalError(_,v,p.ruleName)}},f.prototype.subruleInternalError=function(p,g,v){throw n.isRecognitionException(p)&&p.partialCstResult!==void 0&&(this.cstPostNonTerminal(p.partialCstResult,g!==void 0&&g.LABEL!==void 0?g.LABEL:v),delete p.partialCstResult),p},f.prototype.consumeInternal=function(p,g,v){var d;try{var m=this.LA(1);this.tokenMatcher(m,p)===!0?(this.consumeToken(),d=m):this.consumeInternalError(p,m,v)}catch(_){d=this.consumeInternalRecovery(p,g,_)}return this.cstPostTerminal(v!==void 0&&v.LABEL!==void 0?v.LABEL:p.name,d),d},f.prototype.consumeInternalError=function(p,g,v){var d,m=this.LA(0);throw v!==void 0&&v.ERR_MSG?d=v.ERR_MSG:d=this.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:g,previous:m,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new n.MismatchedTokenException(d,g,m))},f.prototype.consumeInternalRecovery=function(p,g,v){if(this.recoveryEnabled&&v.name==="MismatchedTokenException"&&!this.isBackTracking()){var d=this.getFollowsForInRuleRecovery(p,g);try{return this.tryInRuleRecovery(p,d)}catch(m){throw m.name===a.IN_RULE_RECOVERY_EXCEPTION?v:m}}else throw v},f.prototype.saveRecogState=function(){var p=this.errors,g=e.cloneArr(this.RULE_STACK);return{errors:p,lexerState:this.exportLexerState(),RULE_STACK:g,CST_STACK:this.CST_STACK}},f.prototype.reloadRecogState=function(p){this.errors=p.errors,this.importLexerState(p.lexerState),this.RULE_STACK=p.RULE_STACK},f.prototype.ruleInvocationStateUpdate=function(p,g,v){this.RULE_OCCURRENCE_STACK.push(v),this.RULE_STACK.push(p),this.cstInvocationStateUpdate(g,p)},f.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},f.prototype.getCurrRuleFullName=function(){var p=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[p]},f.prototype.shortRuleNameToFullName=function(p){return this.shortRuleNameToFull[p]},f.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),l.EOF)},f.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},f}();r.RecognizerEngine=h}),bS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ErrorHandler=void 0;var e=ic(),t=Ut(),n=Ih(),i=Ni(),s=function(){function o(){}return o.prototype.initErrorHandler=function(a){this._errors=[],this.errorMessageProvider=t.has(a,"errorMessageProvider")?a.errorMessageProvider:i.DEFAULT_PARSER_CONFIG.errorMessageProvider},o.prototype.SAVE_ERROR=function(a){if(e.isRecognitionException(a))return a.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:t.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(a),a;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(o.prototype,"errors",{get:function(){return t.cloneArr(this._errors)},set:function(a){this._errors=a},enumerable:!1,configurable:!0}),o.prototype.raiseEarlyExitException=function(a,l,c){for(var u=this.getCurrRuleFullName(),h=this.getGAstProductions()[u],f=n.getLookaheadPathsForOptionalProd(a,h,l,this.maxLookahead),p=f[0],g=[],v=1;v<=this.maxLookahead;v++)g.push(this.LA(v));var d=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:p,actual:g,previous:this.LA(0),customUserDescription:c,ruleName:u});throw this.SAVE_ERROR(new e.EarlyExitException(d,this.LA(1),this.LA(0)))},o.prototype.raiseNoAltException=function(a,l){for(var c=this.getCurrRuleFullName(),u=this.getGAstProductions()[c],h=n.getLookaheadPathsForOr(a,u,this.maxLookahead),f=[],p=1;p<=this.maxLookahead;p++)f.push(this.LA(p));var g=this.LA(0),v=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:h,actual:f,previous:g,customUserDescription:l,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new e.NoViableAltException(v,this.LA(1),g))},o}();r.ErrorHandler=s}),SS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ContentAssist=void 0;var e=Rh(),t=Ut(),n=function(){function i(){}return i.prototype.initContentAssist=function(){},i.prototype.computeContentAssist=function(s,o){var a=this.gastProductionsCache[s];if(t.isUndefined(a))throw Error("Rule ->"+s+"<- does not exist in this grammar.");return e.nextPossibleTokensAfter([a],o,this.tokenMatcher,this.maxLookahead)},i.prototype.getNextPossibleTokenTypes=function(s){var o=t.first(s.ruleStack),a=this.getGAstProductions(),l=a[o],c=new e.NextAfterTokenWalker(l,s).startWalking();return c},i}();r.ContentAssist=n}),AS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GastRecorder=void 0;var e=Ut(),t=xi(),n=Ah(),i=tc(),s=io(),o=Ni(),a=ap(),l={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(l);var c=!0,u=Math.pow(2,a.BITS_FOR_OCCURRENCE_IDX)-1,h=s.createToken({name:"RECORDING_PHASE_TOKEN",pattern:n.Lexer.NA});i.augmentTokenTypes([h]);var f=s.createTokenInstance(h,`This IToken indicates the Parser is in Recording Phase
+ For Further details.`)}if(e.isArray(p))this.tokensMap=e.reduce(p,function(_,v){return _[v.name]=v,_},{});else if(e.has(p,"modes")&&e.every(e.flatten(e.values(p.modes)),c.isTokenType)){var y=e.flatten(e.values(p.modes)),d=e.uniq(y);this.tokensMap=e.reduce(d,function(_,v){return _[v.name]=v,_},{})}else if(e.isObject(p))this.tokensMap=e.cloneObj(p);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=l.EOF;var m=e.every(e.values(p),function(_){return e.isEmpty(_.categoryMatches)});this.tokenMatcher=m?c.tokenStructuredMatcherNoCategories:c.tokenStructuredMatcher,c.augmentTokenTypes(e.values(this.tokensMap))},f.prototype.defineRule=function(p,g,y){if(this.selfAnalysisDone)throw Error("Grammar rule <"+p+`> may not be defined after the 'performSelfAnalysis' method has been called'
+Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var d=e.has(y,"resyncEnabled")?y.resyncEnabled:o.DEFAULT_RULE_CONFIG.resyncEnabled,m=e.has(y,"recoveryValueFunc")?y.recoveryValueFunc:o.DEFAULT_RULE_CONFIG.recoveryValueFunc,_=this.ruleShortNameIdx<<t.BITS_FOR_METHOD_TYPE+t.BITS_FOR_OCCURRENCE_IDX;this.ruleShortNameIdx++,this.shortRuleNameToFull[_]=p,this.fullRuleNameToShort[p]=_;function v(I){try{if(this.outputCst===!0){g.apply(this,I);var A=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(A),A}else return g.apply(this,I)}catch(C){return this.invokeRuleCatch(C,d,m)}finally{this.ruleFinallyStateUpdate()}}var x=function(I,A){return I===void 0&&(I=0),this.ruleInvocationStateUpdate(_,p,I),v.call(this,A)},S="ruleName";return x[S]=p,x.originalGrammarAction=g,x},f.prototype.invokeRuleCatch=function(p,g,y){var d=this.RULE_STACK.length===1,m=g&&!this.isBackTracking()&&this.recoveryEnabled;if(n.isRecognitionException(p)){var _=p;if(m){var v=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(v))if(_.resyncedTokens=this.reSyncTo(v),this.outputCst){var x=this.CST_STACK[this.CST_STACK.length-1];return x.recoveredNode=!0,x}else return y();else{if(this.outputCst){var x=this.CST_STACK[this.CST_STACK.length-1];x.recoveredNode=!0,_.partialCstResult=x}throw _}}else{if(d)return this.moveToTerminatedState(),y();throw _}}else throw p},f.prototype.optionInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.OPTION_IDX,g);return this.optionInternalLogic(p,g,y)},f.prototype.optionInternalLogic=function(p,g,y){var d=this,m=this.getLaFuncFromCache(y),_,v;if(p.DEF!==void 0){if(_=p.DEF,v=p.GATE,v!==void 0){var x=m;m=function(){return v.call(d)&&x.call(d)}}}else _=p;if(m.call(this)===!0)return _.call(this)},f.prototype.atLeastOneInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_IDX,p);return this.atLeastOneInternalLogic(p,g,y)},f.prototype.atLeastOneInternalLogic=function(p,g,y){var d=this,m=this.getLaFuncFromCache(y),_,v;if(g.DEF!==void 0){if(_=g.DEF,v=g.GATE,v!==void 0){var x=m;m=function(){return v.call(d)&&x.call(d)}}}else _=g;if(m.call(this)===!0)for(var S=this.doSingleRepetition(_);m.call(this)===!0&&S===!0;)S=this.doSingleRepetition(_);else throw this.raiseEarlyExitException(p,i.PROD_TYPE.REPETITION_MANDATORY,g.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[p,g],m,t.AT_LEAST_ONE_IDX,p,s.NextTerminalAfterAtLeastOneWalker)},f.prototype.atLeastOneSepFirstInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_SEP_IDX,p);this.atLeastOneSepFirstInternalLogic(p,g,y)},f.prototype.atLeastOneSepFirstInternalLogic=function(p,g,y){var d=this,m=g.DEF,_=g.SEP,v=this.getLaFuncFromCache(y);if(v.call(this)===!0){m.call(this);for(var x=function(){return d.tokenMatcher(d.LA(1),_)};this.tokenMatcher(this.LA(1),_)===!0;)this.CONSUME(_),m.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,_,x,m,s.NextTerminalAfterAtLeastOneSepWalker],x,t.AT_LEAST_ONE_SEP_IDX,p,s.NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(p,i.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,g.ERR_MSG)},f.prototype.manyInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.MANY_IDX,p);return this.manyInternalLogic(p,g,y)},f.prototype.manyInternalLogic=function(p,g,y){var d=this,m=this.getLaFuncFromCache(y),_,v;if(g.DEF!==void 0){if(_=g.DEF,v=g.GATE,v!==void 0){var x=m;m=function(){return v.call(d)&&x.call(d)}}}else _=g;for(var S=!0;m.call(this)===!0&&S===!0;)S=this.doSingleRepetition(_);this.attemptInRepetitionRecovery(this.manyInternal,[p,g],m,t.MANY_IDX,p,s.NextTerminalAfterManyWalker,S)},f.prototype.manySepFirstInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.MANY_SEP_IDX,p);this.manySepFirstInternalLogic(p,g,y)},f.prototype.manySepFirstInternalLogic=function(p,g,y){var d=this,m=g.DEF,_=g.SEP,v=this.getLaFuncFromCache(y);if(v.call(this)===!0){m.call(this);for(var x=function(){return d.tokenMatcher(d.LA(1),_)};this.tokenMatcher(this.LA(1),_)===!0;)this.CONSUME(_),m.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,_,x,m,s.NextTerminalAfterManySepWalker],x,t.MANY_SEP_IDX,p,s.NextTerminalAfterManySepWalker)}},f.prototype.repetitionSepSecondInternal=function(p,g,y,d,m){for(;y();)this.CONSUME(g),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,g,y,d,m],y,t.AT_LEAST_ONE_SEP_IDX,p,m)},f.prototype.doSingleRepetition=function(p){var g=this.getLexerPosition();p.call(this);var y=this.getLexerPosition();return y>g},f.prototype.orInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.OR_IDX,g),d=e.isArray(p)?p:p.DEF,m=this.getLaFuncFromCache(y),_=m.call(this,d);if(_!==void 0){var v=d[_];return v.ALT.call(this)}this.raiseNoAltException(g,p.ERR_MSG)},f.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var p=this.LA(1),g=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:p,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new n.NotAllInputParsedException(g,p))}},f.prototype.subruleInternal=function(p,g,y){var d;try{var m=y!==void 0?y.ARGS:void 0;return d=p.call(this,g,m),this.cstPostNonTerminal(d,y!==void 0&&y.LABEL!==void 0?y.LABEL:p.ruleName),d}catch(_){this.subruleInternalError(_,y,p.ruleName)}},f.prototype.subruleInternalError=function(p,g,y){throw n.isRecognitionException(p)&&p.partialCstResult!==void 0&&(this.cstPostNonTerminal(p.partialCstResult,g!==void 0&&g.LABEL!==void 0?g.LABEL:y),delete p.partialCstResult),p},f.prototype.consumeInternal=function(p,g,y){var d;try{var m=this.LA(1);this.tokenMatcher(m,p)===!0?(this.consumeToken(),d=m):this.consumeInternalError(p,m,y)}catch(_){d=this.consumeInternalRecovery(p,g,_)}return this.cstPostTerminal(y!==void 0&&y.LABEL!==void 0?y.LABEL:p.name,d),d},f.prototype.consumeInternalError=function(p,g,y){var d,m=this.LA(0);throw y!==void 0&&y.ERR_MSG?d=y.ERR_MSG:d=this.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:g,previous:m,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new n.MismatchedTokenException(d,g,m))},f.prototype.consumeInternalRecovery=function(p,g,y){if(this.recoveryEnabled&&y.name==="MismatchedTokenException"&&!this.isBackTracking()){var d=this.getFollowsForInRuleRecovery(p,g);try{return this.tryInRuleRecovery(p,d)}catch(m){throw m.name===a.IN_RULE_RECOVERY_EXCEPTION?y:m}}else throw y},f.prototype.saveRecogState=function(){var p=this.errors,g=e.cloneArr(this.RULE_STACK);return{errors:p,lexerState:this.exportLexerState(),RULE_STACK:g,CST_STACK:this.CST_STACK}},f.prototype.reloadRecogState=function(p){this.errors=p.errors,this.importLexerState(p.lexerState),this.RULE_STACK=p.RULE_STACK},f.prototype.ruleInvocationStateUpdate=function(p,g,y){this.RULE_OCCURRENCE_STACK.push(y),this.RULE_STACK.push(p),this.cstInvocationStateUpdate(g,p)},f.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},f.prototype.getCurrRuleFullName=function(){var p=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[p]},f.prototype.shortRuleNameToFullName=function(p){return this.shortRuleNameToFull[p]},f.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),l.EOF)},f.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},f}();r.RecognizerEngine=h}),IS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ErrorHandler=void 0;var e=Hc(),t=Wt(),n=jf(),i=Xi(),s=function(){function o(){}return o.prototype.initErrorHandler=function(a){this._errors=[],this.errorMessageProvider=t.has(a,"errorMessageProvider")?a.errorMessageProvider:i.DEFAULT_PARSER_CONFIG.errorMessageProvider},o.prototype.SAVE_ERROR=function(a){if(e.isRecognitionException(a))return a.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:t.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(a),a;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(o.prototype,"errors",{get:function(){return t.cloneArr(this._errors)},set:function(a){this._errors=a},enumerable:!1,configurable:!0}),o.prototype.raiseEarlyExitException=function(a,l,c){for(var u=this.getCurrRuleFullName(),h=this.getGAstProductions()[u],f=n.getLookaheadPathsForOptionalProd(a,h,l,this.maxLookahead),p=f[0],g=[],y=1;y<=this.maxLookahead;y++)g.push(this.LA(y));var d=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:p,actual:g,previous:this.LA(0),customUserDescription:c,ruleName:u});throw this.SAVE_ERROR(new e.EarlyExitException(d,this.LA(1),this.LA(0)))},o.prototype.raiseNoAltException=function(a,l){for(var c=this.getCurrRuleFullName(),u=this.getGAstProductions()[c],h=n.getLookaheadPathsForOr(a,u,this.maxLookahead),f=[],p=1;p<=this.maxLookahead;p++)f.push(this.LA(p));var g=this.LA(0),y=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:h,actual:f,previous:g,customUserDescription:l,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new e.NoViableAltException(y,this.LA(1),g))},o}();r.ErrorHandler=s}),RS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ContentAssist=void 0;var e=qf(),t=Wt(),n=function(){function i(){}return i.prototype.initContentAssist=function(){},i.prototype.computeContentAssist=function(s,o){var a=this.gastProductionsCache[s];if(t.isUndefined(a))throw Error("Rule ->"+s+"<- does not exist in this grammar.");return e.nextPossibleTokensAfter([a],o,this.tokenMatcher,this.maxLookahead)},i.prototype.getNextPossibleTokenTypes=function(s){var o=t.first(s.ruleStack),a=this.getGAstProductions(),l=a[o],c=new e.NextAfterTokenWalker(l,s).startWalking();return c},i}();r.ContentAssist=n}),PS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GastRecorder=void 0;var e=Wt(),t=Li(),n=Hf(),i=Vc(),s=Co(),o=Xi(),a=Em(),l={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(l);var c=!0,u=Math.pow(2,a.BITS_FOR_OCCURRENCE_IDX)-1,h=s.createToken({name:"RECORDING_PHASE_TOKEN",pattern:n.Lexer.NA});i.augmentTokenTypes([h]);var f=s.createTokenInstance(h,`This IToken indicates the Parser is in Recording Phase
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(f);var p={name:`This CSTNode indicates the Parser is in Recording Phase
- See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},g=function(){function y(){}return y.prototype.initGastRecorder=function(x){this.recordingProdStack=[],this.RECORDING_PHASE=!1},y.prototype.enableRecording=function(){var x=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",function(){for(var w=function(C){var P=C>0?C:"";x["CONSUME"+P]=function(E,M){return this.consumeInternalRecord(E,C,M)},x["SUBRULE"+P]=function(E,M){return this.subruleInternalRecord(E,C,M)},x["OPTION"+P]=function(E){return this.optionInternalRecord(E,C)},x["OR"+P]=function(E){return this.orInternalRecord(E,C)},x["MANY"+P]=function(E){this.manyInternalRecord(C,E)},x["MANY_SEP"+P]=function(E){this.manySepFirstInternalRecord(C,E)},x["AT_LEAST_ONE"+P]=function(E){this.atLeastOneInternalRecord(C,E)},x["AT_LEAST_ONE_SEP"+P]=function(E){this.atLeastOneSepFirstInternalRecord(C,E)}},I=0;I<10;I++)w(I);x.consume=function(C,P,E){return this.consumeInternalRecord(P,C,E)},x.subrule=function(C,P,E){return this.subruleInternalRecord(P,C,E)},x.option=function(C,P){return this.optionInternalRecord(P,C)},x.or=function(C,P){return this.orInternalRecord(P,C)},x.many=function(C,P){this.manyInternalRecord(C,P)},x.atLeastOne=function(C,P){this.atLeastOneInternalRecord(C,P)},x.ACTION=x.ACTION_RECORD,x.BACKTRACK=x.BACKTRACK_RECORD,x.LA=x.LA_RECORD})},y.prototype.disableRecording=function(){var x=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",function(){for(var w=0;w<10;w++){var I=w>0?w:"";delete x["CONSUME"+I],delete x["SUBRULE"+I],delete x["OPTION"+I],delete x["OR"+I],delete x["MANY"+I],delete x["MANY_SEP"+I],delete x["AT_LEAST_ONE"+I],delete x["AT_LEAST_ONE_SEP"+I]}delete x.consume,delete x.subrule,delete x.option,delete x.or,delete x.many,delete x.atLeastOne,delete x.ACTION,delete x.BACKTRACK,delete x.LA})},y.prototype.ACTION_RECORD=function(x){},y.prototype.BACKTRACK_RECORD=function(x,w){return function(){return!0}},y.prototype.LA_RECORD=function(x){return o.END_OF_FILE},y.prototype.topLevelRuleRecord=function(x,w){try{var I=new t.Rule({definition:[],name:x});return I.name=x,this.recordingProdStack.push(I),w.call(this),this.recordingProdStack.pop(),I}catch(C){if(C.KNOWN_RECORDER_ERROR!==!0)try{C.message=C.message+`
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},g=function(){function v(){}return v.prototype.initGastRecorder=function(x){this.recordingProdStack=[],this.RECORDING_PHASE=!1},v.prototype.enableRecording=function(){var x=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",function(){for(var S=function(A){var C=A>0?A:"";x["CONSUME"+C]=function(E,b){return this.consumeInternalRecord(E,A,b)},x["SUBRULE"+C]=function(E,b){return this.subruleInternalRecord(E,A,b)},x["OPTION"+C]=function(E){return this.optionInternalRecord(E,A)},x["OR"+C]=function(E){return this.orInternalRecord(E,A)},x["MANY"+C]=function(E){this.manyInternalRecord(A,E)},x["MANY_SEP"+C]=function(E){this.manySepFirstInternalRecord(A,E)},x["AT_LEAST_ONE"+C]=function(E){this.atLeastOneInternalRecord(A,E)},x["AT_LEAST_ONE_SEP"+C]=function(E){this.atLeastOneSepFirstInternalRecord(A,E)}},I=0;I<10;I++)S(I);x.consume=function(A,C,E){return this.consumeInternalRecord(C,A,E)},x.subrule=function(A,C,E){return this.subruleInternalRecord(C,A,E)},x.option=function(A,C){return this.optionInternalRecord(C,A)},x.or=function(A,C){return this.orInternalRecord(C,A)},x.many=function(A,C){this.manyInternalRecord(A,C)},x.atLeastOne=function(A,C){this.atLeastOneInternalRecord(A,C)},x.ACTION=x.ACTION_RECORD,x.BACKTRACK=x.BACKTRACK_RECORD,x.LA=x.LA_RECORD})},v.prototype.disableRecording=function(){var x=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",function(){for(var S=0;S<10;S++){var I=S>0?S:"";delete x["CONSUME"+I],delete x["SUBRULE"+I],delete x["OPTION"+I],delete x["OR"+I],delete x["MANY"+I],delete x["MANY_SEP"+I],delete x["AT_LEAST_ONE"+I],delete x["AT_LEAST_ONE_SEP"+I]}delete x.consume,delete x.subrule,delete x.option,delete x.or,delete x.many,delete x.atLeastOne,delete x.ACTION,delete x.BACKTRACK,delete x.LA})},v.prototype.ACTION_RECORD=function(x){},v.prototype.BACKTRACK_RECORD=function(x,S){return function(){return!0}},v.prototype.LA_RECORD=function(x){return o.END_OF_FILE},v.prototype.topLevelRuleRecord=function(x,S){try{var I=new t.Rule({definition:[],name:x});return I.name=x,this.recordingProdStack.push(I),S.call(this),this.recordingProdStack.pop(),I}catch(A){if(A.KNOWN_RECORDER_ERROR!==!0)try{A.message=A.message+`
This error was thrown during the "grammar recording phase" For more info see:
- https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw C}throw C}},y.prototype.optionInternalRecord=function(x,w){return v.call(this,t.Option,x,w)},y.prototype.atLeastOneInternalRecord=function(x,w){v.call(this,t.RepetitionMandatory,w,x)},y.prototype.atLeastOneSepFirstInternalRecord=function(x,w){v.call(this,t.RepetitionMandatoryWithSeparator,w,x,c)},y.prototype.manyInternalRecord=function(x,w){v.call(this,t.Repetition,w,x)},y.prototype.manySepFirstInternalRecord=function(x,w){v.call(this,t.RepetitionWithSeparator,w,x,c)},y.prototype.orInternalRecord=function(x,w){return d.call(this,x,w)},y.prototype.subruleInternalRecord=function(x,w,I){if(_(w),!x||e.has(x,"ruleName")===!1){var C=new Error("<SUBRULE"+m(w)+"> argument is invalid"+(" expecting a Parser method reference but got: <"+JSON.stringify(x)+">")+(`
- inside top level rule: <`+this.recordingProdStack[0].name+">"));throw C.KNOWN_RECORDER_ERROR=!0,C}var P=e.peek(this.recordingProdStack),E=x.ruleName,M=new t.NonTerminal({idx:w,nonTerminalName:E,referencedRule:void 0});return P.definition.push(M),this.outputCst?p:l},y.prototype.consumeInternalRecord=function(x,w,I){if(_(w),!i.hasShortKeyProperty(x)){var C=new Error("<CONSUME"+m(w)+"> argument is invalid"+(" expecting a TokenType reference but got: <"+JSON.stringify(x)+">")+(`
- inside top level rule: <`+this.recordingProdStack[0].name+">"));throw C.KNOWN_RECORDER_ERROR=!0,C}var P=e.peek(this.recordingProdStack),E=new t.Terminal({idx:w,terminalType:x});return P.definition.push(E),f},y}();r.GastRecorder=g;function v(y,x,w,I){I===void 0&&(I=!1),_(w);var C=e.peek(this.recordingProdStack),P=e.isFunction(x)?x:x.DEF,E=new y({definition:[],idx:w});return I&&(E.separator=x.SEP),e.has(x,"MAX_LOOKAHEAD")&&(E.maxLookahead=x.MAX_LOOKAHEAD),this.recordingProdStack.push(E),P.call(this),C.definition.push(E),this.recordingProdStack.pop(),l}function d(y,x){var w=this;_(x);var I=e.peek(this.recordingProdStack),C=e.isArray(y)===!1,P=C===!1?y:y.DEF,E=new t.Alternation({definition:[],idx:x,ignoreAmbiguities:C&&y.IGNORE_AMBIGUITIES===!0});e.has(y,"MAX_LOOKAHEAD")&&(E.maxLookahead=y.MAX_LOOKAHEAD);var M=e.some(P,function(L){return e.isFunction(L.GATE)});return E.hasPredicates=M,I.definition.push(E),e.forEach(P,function(L){var N=new t.Alternative({definition:[]});E.definition.push(N),e.has(L,"IGNORE_AMBIGUITIES")?N.ignoreAmbiguities=L.IGNORE_AMBIGUITIES:e.has(L,"GATE")&&(N.ignoreAmbiguities=!0),w.recordingProdStack.push(N),L.ALT.call(w),w.recordingProdStack.pop()}),l}function m(y){return y===0?"":""+y}function _(y){if(y<0||y>u){var x=new Error("Invalid DSL Method idx value: <"+y+`>
- `+("Idx value must be a none negative value smaller than "+(u+1)));throw x.KNOWN_RECORDER_ERROR=!0,x}}}),wS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.PerformanceTracer=void 0;var e=Ut(),t=Ni(),n=function(){function i(){}return i.prototype.initPerformanceTracer=function(s){if(e.has(s,"traceInitPerf")){var o=s.traceInitPerf,a=typeof o=="number";this.traceInitMaxIdent=a?o:1/0,this.traceInitPerf=a?o>0:o}else this.traceInitMaxIdent=0,this.traceInitPerf=t.DEFAULT_PARSER_CONFIG.traceInitPerf;this.traceInitIndent=-1},i.prototype.TRACE_INIT=function(s,o){if(this.traceInitPerf===!0){this.traceInitIndent++;var a=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(a+"--> <"+s+">");var l=e.timer(o),c=l.time,u=l.value,h=c>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&h(a+"<-- <"+s+"> time: "+c+"ms"),this.traceInitIndent--,u}else return o()},i}();r.PerformanceTracer=n}),CS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.applyMixins=void 0;function e(t,n){n.forEach(function(i){var s=i.prototype;Object.getOwnPropertyNames(s).forEach(function(o){if(o!=="constructor"){var a=Object.getOwnPropertyDescriptor(s,o);a&&(a.get||a.set)?Object.defineProperty(t.prototype,o,a):t.prototype[o]=i.prototype[o]}})})}r.applyMixins=e}),Ni=Tt(r=>{"use strict";var e=r&&r.__extends||function(){var C=function(P,E){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(M,L){M.__proto__=L}||function(M,L){for(var N in L)Object.prototype.hasOwnProperty.call(L,N)&&(M[N]=L[N])},C(P,E)};return function(P,E){if(typeof E!="function"&&E!==null)throw new TypeError("Class extends value "+String(E)+" is not a constructor or null");C(P,E);function M(){this.constructor=P}P.prototype=E===null?Object.create(E):(M.prototype=E.prototype,new M)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.EmbeddedActionsParser=r.CstParser=r.Parser=r.EMPTY_ALT=r.ParserDefinitionErrorType=r.DEFAULT_RULE_CONFIG=r.DEFAULT_PARSER_CONFIG=r.END_OF_FILE=void 0;var t=Ut(),n=pS(),i=io(),s=Ch(),o=gS(),a=Y0(),l=vS(),c=_S(),u=TS(),h=MS(),f=ES(),p=bS(),g=SS(),v=AS(),d=wS(),m=CS();r.END_OF_FILE=i.createTokenInstance(i.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN),Object.freeze(r.END_OF_FILE),r.DEFAULT_PARSER_CONFIG=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:s.defaultParserErrorProvider,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),r.DEFAULT_RULE_CONFIG=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});var _;(function(C){C[C.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",C[C.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",C[C.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",C[C.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",C[C.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",C[C.LEFT_RECURSION=5]="LEFT_RECURSION",C[C.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",C[C.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",C[C.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",C[C.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",C[C.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",C[C.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",C[C.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"})(_=r.ParserDefinitionErrorType||(r.ParserDefinitionErrorType={}));function y(C){return C===void 0&&(C=void 0),function(){return C}}r.EMPTY_ALT=y;var x=function(){function C(P,E){this.definitionErrors=[],this.selfAnalysisDone=!1;var M=this;if(M.initErrorHandler(E),M.initLexerAdapter(),M.initLooksAhead(E),M.initRecognizerEngine(P,E),M.initRecoverable(E),M.initTreeBuilder(E),M.initContentAssist(),M.initGastRecorder(E),M.initPerformanceTracer(E),t.has(E,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
+ https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw A}throw A}},v.prototype.optionInternalRecord=function(x,S){return y.call(this,t.Option,x,S)},v.prototype.atLeastOneInternalRecord=function(x,S){y.call(this,t.RepetitionMandatory,S,x)},v.prototype.atLeastOneSepFirstInternalRecord=function(x,S){y.call(this,t.RepetitionMandatoryWithSeparator,S,x,c)},v.prototype.manyInternalRecord=function(x,S){y.call(this,t.Repetition,S,x)},v.prototype.manySepFirstInternalRecord=function(x,S){y.call(this,t.RepetitionWithSeparator,S,x,c)},v.prototype.orInternalRecord=function(x,S){return d.call(this,x,S)},v.prototype.subruleInternalRecord=function(x,S,I){if(_(S),!x||e.has(x,"ruleName")===!1){var A=new Error("<SUBRULE"+m(S)+"> argument is invalid"+(" expecting a Parser method reference but got: <"+JSON.stringify(x)+">")+(`
+ inside top level rule: <`+this.recordingProdStack[0].name+">"));throw A.KNOWN_RECORDER_ERROR=!0,A}var C=e.peek(this.recordingProdStack),E=x.ruleName,b=new t.NonTerminal({idx:S,nonTerminalName:E,referencedRule:void 0});return C.definition.push(b),this.outputCst?p:l},v.prototype.consumeInternalRecord=function(x,S,I){if(_(S),!i.hasShortKeyProperty(x)){var A=new Error("<CONSUME"+m(S)+"> argument is invalid"+(" expecting a TokenType reference but got: <"+JSON.stringify(x)+">")+(`
+ inside top level rule: <`+this.recordingProdStack[0].name+">"));throw A.KNOWN_RECORDER_ERROR=!0,A}var C=e.peek(this.recordingProdStack),E=new t.Terminal({idx:S,terminalType:x});return C.definition.push(E),f},v}();r.GastRecorder=g;function y(v,x,S,I){I===void 0&&(I=!1),_(S);var A=e.peek(this.recordingProdStack),C=e.isFunction(x)?x:x.DEF,E=new v({definition:[],idx:S});return I&&(E.separator=x.SEP),e.has(x,"MAX_LOOKAHEAD")&&(E.maxLookahead=x.MAX_LOOKAHEAD),this.recordingProdStack.push(E),C.call(this),A.definition.push(E),this.recordingProdStack.pop(),l}function d(v,x){var S=this;_(x);var I=e.peek(this.recordingProdStack),A=e.isArray(v)===!1,C=A===!1?v:v.DEF,E=new t.Alternation({definition:[],idx:x,ignoreAmbiguities:A&&v.IGNORE_AMBIGUITIES===!0});e.has(v,"MAX_LOOKAHEAD")&&(E.maxLookahead=v.MAX_LOOKAHEAD);var b=e.some(C,function(R){return e.isFunction(R.GATE)});return E.hasPredicates=b,I.definition.push(E),e.forEach(C,function(R){var N=new t.Alternative({definition:[]});E.definition.push(N),e.has(R,"IGNORE_AMBIGUITIES")?N.ignoreAmbiguities=R.IGNORE_AMBIGUITIES:e.has(R,"GATE")&&(N.ignoreAmbiguities=!0),S.recordingProdStack.push(N),R.ALT.call(S),S.recordingProdStack.pop()}),l}function m(v){return v===0?"":""+v}function _(v){if(v<0||v>u){var x=new Error("Invalid DSL Method idx value: <"+v+`>
+ `+("Idx value must be a none negative value smaller than "+(u+1)));throw x.KNOWN_RECORDER_ERROR=!0,x}}}),NS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.PerformanceTracer=void 0;var e=Wt(),t=Xi(),n=function(){function i(){}return i.prototype.initPerformanceTracer=function(s){if(e.has(s,"traceInitPerf")){var o=s.traceInitPerf,a=typeof o=="number";this.traceInitMaxIdent=a?o:1/0,this.traceInitPerf=a?o>0:o}else this.traceInitMaxIdent=0,this.traceInitPerf=t.DEFAULT_PARSER_CONFIG.traceInitPerf;this.traceInitIndent=-1},i.prototype.TRACE_INIT=function(s,o){if(this.traceInitPerf===!0){this.traceInitIndent++;var a=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(a+"--> <"+s+">");var l=e.timer(o),c=l.time,u=l.value,h=c>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&h(a+"<-- <"+s+"> time: "+c+"ms"),this.traceInitIndent--,u}else return o()},i}();r.PerformanceTracer=n}),LS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.applyMixins=void 0;function e(t,n){n.forEach(function(i){var s=i.prototype;Object.getOwnPropertyNames(s).forEach(function(o){if(o!=="constructor"){var a=Object.getOwnPropertyDescriptor(s,o);a&&(a.get||a.set)?Object.defineProperty(t.prototype,o,a):t.prototype[o]=i.prototype[o]}})})}r.applyMixins=e}),Xi=bt(r=>{"use strict";var e=r&&r.__extends||function(){var A=function(C,E){return A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,R){b.__proto__=R}||function(b,R){for(var N in R)Object.prototype.hasOwnProperty.call(R,N)&&(b[N]=R[N])},A(C,E)};return function(C,E){if(typeof E!="function"&&E!==null)throw new TypeError("Class extends value "+String(E)+" is not a constructor or null");A(C,E);function b(){this.constructor=C}C.prototype=E===null?Object.create(E):(b.prototype=E.prototype,new b)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.EmbeddedActionsParser=r.CstParser=r.Parser=r.EMPTY_ALT=r.ParserDefinitionErrorType=r.DEFAULT_RULE_CONFIG=r.DEFAULT_PARSER_CONFIG=r.END_OF_FILE=void 0;var t=Wt(),n=vS(),i=Co(),s=Xf(),o=TS(),a=ox(),l=MS(),c=SS(),u=AS(),h=wS(),f=CS(),p=IS(),g=RS(),y=PS(),d=NS(),m=LS();r.END_OF_FILE=i.createTokenInstance(i.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN),Object.freeze(r.END_OF_FILE),r.DEFAULT_PARSER_CONFIG=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:s.defaultParserErrorProvider,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),r.DEFAULT_RULE_CONFIG=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});var _;(function(A){A[A.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",A[A.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",A[A.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",A[A.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",A[A.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",A[A.LEFT_RECURSION=5]="LEFT_RECURSION",A[A.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",A[A.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",A[A.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",A[A.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",A[A.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",A[A.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",A[A.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"})(_=r.ParserDefinitionErrorType||(r.ParserDefinitionErrorType={}));function v(A){return A===void 0&&(A=void 0),function(){return A}}r.EMPTY_ALT=v;var x=function(){function A(C,E){this.definitionErrors=[],this.selfAnalysisDone=!1;var b=this;if(b.initErrorHandler(E),b.initLexerAdapter(),b.initLooksAhead(E),b.initRecognizerEngine(C,E),b.initRecoverable(E),b.initTreeBuilder(E),b.initContentAssist(),b.initGastRecorder(E),b.initPerformanceTracer(E),t.has(E,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
- For further details.`);this.skipValidations=t.has(E,"skipValidations")?E.skipValidations:r.DEFAULT_PARSER_CONFIG.skipValidations}return C.performSelfAnalysis=function(P){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")},C.prototype.performSelfAnalysis=function(){var P=this;this.TRACE_INIT("performSelfAnalysis",function(){var E;P.selfAnalysisDone=!0;var M=P.className;P.TRACE_INIT("toFastProps",function(){t.toFastProperties(P)}),P.TRACE_INIT("Grammar Recording",function(){try{P.enableRecording(),t.forEach(P.definedRulesNames,function(N){var O=P[N],B=O.originalGrammarAction,ie=void 0;P.TRACE_INIT(N+" Rule",function(){ie=P.topLevelRuleRecord(N,B)}),P.gastProductionsCache[N]=ie})}finally{P.disableRecording()}});var L=[];if(P.TRACE_INIT("Grammar Resolving",function(){L=o.resolveGrammar({rules:t.values(P.gastProductionsCache)}),P.definitionErrors=P.definitionErrors.concat(L)}),P.TRACE_INIT("Grammar Validations",function(){if(t.isEmpty(L)&&P.skipValidations===!1){var N=o.validateGrammar({rules:t.values(P.gastProductionsCache),maxLookahead:P.maxLookahead,tokenTypes:t.values(P.tokensMap),errMsgProvider:s.defaultGrammarValidatorErrorProvider,grammarName:M});P.definitionErrors=P.definitionErrors.concat(N)}}),t.isEmpty(P.definitionErrors)&&(P.recoveryEnabled&&P.TRACE_INIT("computeAllProdsFollows",function(){var N=n.computeAllProdsFollows(t.values(P.gastProductionsCache));P.resyncFollows=N}),P.TRACE_INIT("ComputeLookaheadFunctions",function(){P.preComputeLookaheadFunctions(t.values(P.gastProductionsCache))})),!C.DEFER_DEFINITION_ERRORS_HANDLING&&!t.isEmpty(P.definitionErrors))throw E=t.map(P.definitionErrors,function(N){return N.message}),new Error(`Parser Definition Errors detected:
+ For further details.`);this.skipValidations=t.has(E,"skipValidations")?E.skipValidations:r.DEFAULT_PARSER_CONFIG.skipValidations}return A.performSelfAnalysis=function(C){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")},A.prototype.performSelfAnalysis=function(){var C=this;this.TRACE_INIT("performSelfAnalysis",function(){var E;C.selfAnalysisDone=!0;var b=C.className;C.TRACE_INIT("toFastProps",function(){t.toFastProperties(C)}),C.TRACE_INIT("Grammar Recording",function(){try{C.enableRecording(),t.forEach(C.definedRulesNames,function(N){var B=C[N],V=B.originalGrammarAction,ie=void 0;C.TRACE_INIT(N+" Rule",function(){ie=C.topLevelRuleRecord(N,V)}),C.gastProductionsCache[N]=ie})}finally{C.disableRecording()}});var R=[];if(C.TRACE_INIT("Grammar Resolving",function(){R=o.resolveGrammar({rules:t.values(C.gastProductionsCache)}),C.definitionErrors=C.definitionErrors.concat(R)}),C.TRACE_INIT("Grammar Validations",function(){if(t.isEmpty(R)&&C.skipValidations===!1){var N=o.validateGrammar({rules:t.values(C.gastProductionsCache),maxLookahead:C.maxLookahead,tokenTypes:t.values(C.tokensMap),errMsgProvider:s.defaultGrammarValidatorErrorProvider,grammarName:b});C.definitionErrors=C.definitionErrors.concat(N)}}),t.isEmpty(C.definitionErrors)&&(C.recoveryEnabled&&C.TRACE_INIT("computeAllProdsFollows",function(){var N=n.computeAllProdsFollows(t.values(C.gastProductionsCache));C.resyncFollows=N}),C.TRACE_INIT("ComputeLookaheadFunctions",function(){C.preComputeLookaheadFunctions(t.values(C.gastProductionsCache))})),!A.DEFER_DEFINITION_ERRORS_HANDLING&&!t.isEmpty(C.definitionErrors))throw E=t.map(C.definitionErrors,function(N){return N.message}),new Error(`Parser Definition Errors detected:
`+E.join(`
-------------------------------
-`))})},C.DEFER_DEFINITION_ERRORS_HANDLING=!1,C}();r.Parser=x,m.applyMixins(x,[a.Recoverable,l.LooksAhead,c.TreeBuilder,u.LexerAdapter,f.RecognizerEngine,h.RecognizerApi,p.ErrorHandler,g.ContentAssist,v.GastRecorder,d.PerformanceTracer]);var w=function(C){e(P,C);function P(E,M){M===void 0&&(M=r.DEFAULT_PARSER_CONFIG);var L=this,N=t.cloneObj(M);return N.outputCst=!0,L=C.call(this,E,N)||this,L}return P}(x);r.CstParser=w;var I=function(C){e(P,C);function P(E,M){M===void 0&&(M=r.DEFAULT_PARSER_CONFIG);var L=this,N=t.cloneObj(M);return N.outputCst=!1,L=C.call(this,E,N)||this,L}return P}(x);r.EmbeddedActionsParser=I}),RS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createSyntaxDiagramsCode=void 0;var e=z0();function t(n,i){var s=i===void 0?{}:i,o=s.resourceBase,a=o===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/":o,l=s.css,c=l===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/diagrams.css":l,u=`
+`))})},A.DEFER_DEFINITION_ERRORS_HANDLING=!1,A}();r.Parser=x,m.applyMixins(x,[a.Recoverable,l.LooksAhead,c.TreeBuilder,u.LexerAdapter,f.RecognizerEngine,h.RecognizerApi,p.ErrorHandler,g.ContentAssist,y.GastRecorder,d.PerformanceTracer]);var S=function(A){e(C,A);function C(E,b){b===void 0&&(b=r.DEFAULT_PARSER_CONFIG);var R=this,N=t.cloneObj(b);return N.outputCst=!0,R=A.call(this,E,N)||this,R}return C}(x);r.CstParser=S;var I=function(A){e(C,A);function C(E,b){b===void 0&&(b=r.DEFAULT_PARSER_CONFIG);var R=this,N=t.cloneObj(b);return N.outputCst=!1,R=A.call(this,E,N)||this,R}return C}(x);r.EmbeddedActionsParser=I}),OS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createSyntaxDiagramsCode=void 0;var e=ex();function t(n,i){var s=i===void 0?{}:i,o=s.resourceBase,a=o===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/":o,l=s.css,c=l===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/diagrams.css":l,u=`
<!-- This is a generated file -->
<!DOCTYPE html>
<meta charset="utf-8">
<script>
window.serializedGrammar = `+JSON.stringify(n,null," ")+`;
<\/script>
-`,v=`
+`,y=`
<script>
var diagramsDiv = document.getElementById("diagrams");
main.drawDiagramsFromSerializedGrammar(serializedGrammar, diagramsDiv);
<\/script>
-`;return u+h+f+p+g+v}r.createSyntaxDiagramsCode=t}),IS=Tt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Parser=r.createSyntaxDiagramsCode=r.clearCache=r.GAstVisitor=r.serializeProduction=r.serializeGrammar=r.Terminal=r.Rule=r.RepetitionWithSeparator=r.RepetitionMandatoryWithSeparator=r.RepetitionMandatory=r.Repetition=r.Option=r.NonTerminal=r.Alternative=r.Alternation=r.defaultLexerErrorProvider=r.NoViableAltException=r.NotAllInputParsedException=r.MismatchedTokenException=r.isRecognitionException=r.EarlyExitException=r.defaultParserErrorProvider=r.tokenName=r.tokenMatcher=r.tokenLabel=r.EOF=r.createTokenInstance=r.createToken=r.LexerDefinitionErrorType=r.Lexer=r.EMPTY_ALT=r.ParserDefinitionErrorType=r.EmbeddedActionsParser=r.CstParser=r.VERSION=void 0;var e=z0();Object.defineProperty(r,"VERSION",{enumerable:!0,get:function(){return e.VERSION}});var t=Ni();Object.defineProperty(r,"CstParser",{enumerable:!0,get:function(){return t.CstParser}}),Object.defineProperty(r,"EmbeddedActionsParser",{enumerable:!0,get:function(){return t.EmbeddedActionsParser}}),Object.defineProperty(r,"ParserDefinitionErrorType",{enumerable:!0,get:function(){return t.ParserDefinitionErrorType}}),Object.defineProperty(r,"EMPTY_ALT",{enumerable:!0,get:function(){return t.EMPTY_ALT}});var n=Ah();Object.defineProperty(r,"Lexer",{enumerable:!0,get:function(){return n.Lexer}}),Object.defineProperty(r,"LexerDefinitionErrorType",{enumerable:!0,get:function(){return n.LexerDefinitionErrorType}});var i=io();Object.defineProperty(r,"createToken",{enumerable:!0,get:function(){return i.createToken}}),Object.defineProperty(r,"createTokenInstance",{enumerable:!0,get:function(){return i.createTokenInstance}}),Object.defineProperty(r,"EOF",{enumerable:!0,get:function(){return i.EOF}}),Object.defineProperty(r,"tokenLabel",{enumerable:!0,get:function(){return i.tokenLabel}}),Object.defineProperty(r,"tokenMatcher",{enumerable:!0,get:function(){return i.tokenMatcher}}),Object.defineProperty(r,"tokenName",{enumerable:!0,get:function(){return i.tokenName}});var s=Ch();Object.defineProperty(r,"defaultParserErrorProvider",{enumerable:!0,get:function(){return s.defaultParserErrorProvider}});var o=ic();Object.defineProperty(r,"EarlyExitException",{enumerable:!0,get:function(){return o.EarlyExitException}}),Object.defineProperty(r,"isRecognitionException",{enumerable:!0,get:function(){return o.isRecognitionException}}),Object.defineProperty(r,"MismatchedTokenException",{enumerable:!0,get:function(){return o.MismatchedTokenException}}),Object.defineProperty(r,"NotAllInputParsedException",{enumerable:!0,get:function(){return o.NotAllInputParsedException}}),Object.defineProperty(r,"NoViableAltException",{enumerable:!0,get:function(){return o.NoViableAltException}});var a=W0();Object.defineProperty(r,"defaultLexerErrorProvider",{enumerable:!0,get:function(){return a.defaultLexerErrorProvider}});var l=xi();Object.defineProperty(r,"Alternation",{enumerable:!0,get:function(){return l.Alternation}}),Object.defineProperty(r,"Alternative",{enumerable:!0,get:function(){return l.Alternative}}),Object.defineProperty(r,"NonTerminal",{enumerable:!0,get:function(){return l.NonTerminal}}),Object.defineProperty(r,"Option",{enumerable:!0,get:function(){return l.Option}}),Object.defineProperty(r,"Repetition",{enumerable:!0,get:function(){return l.Repetition}}),Object.defineProperty(r,"RepetitionMandatory",{enumerable:!0,get:function(){return l.RepetitionMandatory}}),Object.defineProperty(r,"RepetitionMandatoryWithSeparator",{enumerable:!0,get:function(){return l.RepetitionMandatoryWithSeparator}}),Object.defineProperty(r,"RepetitionWithSeparator",{enumerable:!0,get:function(){return l.RepetitionWithSeparator}}),Object.defineProperty(r,"Rule",{enumerable:!0,get:function(){return l.Rule}}),Object.defineProperty(r,"Terminal",{enumerable:!0,get:function(){return l.Terminal}});var c=xi();Object.defineProperty(r,"serializeGrammar",{enumerable:!0,get:function(){return c.serializeGrammar}}),Object.defineProperty(r,"serializeProduction",{enumerable:!0,get:function(){return c.serializeProduction}});var u=nc();Object.defineProperty(r,"GAstVisitor",{enumerable:!0,get:function(){return u.GAstVisitor}});function h(){console.warn(`The clearCache function was 'soft' removed from the Chevrotain API.
+`;return u+h+f+p+g+y}r.createSyntaxDiagramsCode=t}),DS=bt(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Parser=r.createSyntaxDiagramsCode=r.clearCache=r.GAstVisitor=r.serializeProduction=r.serializeGrammar=r.Terminal=r.Rule=r.RepetitionWithSeparator=r.RepetitionMandatoryWithSeparator=r.RepetitionMandatory=r.Repetition=r.Option=r.NonTerminal=r.Alternative=r.Alternation=r.defaultLexerErrorProvider=r.NoViableAltException=r.NotAllInputParsedException=r.MismatchedTokenException=r.isRecognitionException=r.EarlyExitException=r.defaultParserErrorProvider=r.tokenName=r.tokenMatcher=r.tokenLabel=r.EOF=r.createTokenInstance=r.createToken=r.LexerDefinitionErrorType=r.Lexer=r.EMPTY_ALT=r.ParserDefinitionErrorType=r.EmbeddedActionsParser=r.CstParser=r.VERSION=void 0;var e=ex();Object.defineProperty(r,"VERSION",{enumerable:!0,get:function(){return e.VERSION}});var t=Xi();Object.defineProperty(r,"CstParser",{enumerable:!0,get:function(){return t.CstParser}}),Object.defineProperty(r,"EmbeddedActionsParser",{enumerable:!0,get:function(){return t.EmbeddedActionsParser}}),Object.defineProperty(r,"ParserDefinitionErrorType",{enumerable:!0,get:function(){return t.ParserDefinitionErrorType}}),Object.defineProperty(r,"EMPTY_ALT",{enumerable:!0,get:function(){return t.EMPTY_ALT}});var n=Hf();Object.defineProperty(r,"Lexer",{enumerable:!0,get:function(){return n.Lexer}}),Object.defineProperty(r,"LexerDefinitionErrorType",{enumerable:!0,get:function(){return n.LexerDefinitionErrorType}});var i=Co();Object.defineProperty(r,"createToken",{enumerable:!0,get:function(){return i.createToken}}),Object.defineProperty(r,"createTokenInstance",{enumerable:!0,get:function(){return i.createTokenInstance}}),Object.defineProperty(r,"EOF",{enumerable:!0,get:function(){return i.EOF}}),Object.defineProperty(r,"tokenLabel",{enumerable:!0,get:function(){return i.tokenLabel}}),Object.defineProperty(r,"tokenMatcher",{enumerable:!0,get:function(){return i.tokenMatcher}}),Object.defineProperty(r,"tokenName",{enumerable:!0,get:function(){return i.tokenName}});var s=Xf();Object.defineProperty(r,"defaultParserErrorProvider",{enumerable:!0,get:function(){return s.defaultParserErrorProvider}});var o=Hc();Object.defineProperty(r,"EarlyExitException",{enumerable:!0,get:function(){return o.EarlyExitException}}),Object.defineProperty(r,"isRecognitionException",{enumerable:!0,get:function(){return o.isRecognitionException}}),Object.defineProperty(r,"MismatchedTokenException",{enumerable:!0,get:function(){return o.MismatchedTokenException}}),Object.defineProperty(r,"NotAllInputParsedException",{enumerable:!0,get:function(){return o.NotAllInputParsedException}}),Object.defineProperty(r,"NoViableAltException",{enumerable:!0,get:function(){return o.NoViableAltException}});var a=nx();Object.defineProperty(r,"defaultLexerErrorProvider",{enumerable:!0,get:function(){return a.defaultLexerErrorProvider}});var l=Li();Object.defineProperty(r,"Alternation",{enumerable:!0,get:function(){return l.Alternation}}),Object.defineProperty(r,"Alternative",{enumerable:!0,get:function(){return l.Alternative}}),Object.defineProperty(r,"NonTerminal",{enumerable:!0,get:function(){return l.NonTerminal}}),Object.defineProperty(r,"Option",{enumerable:!0,get:function(){return l.Option}}),Object.defineProperty(r,"Repetition",{enumerable:!0,get:function(){return l.Repetition}}),Object.defineProperty(r,"RepetitionMandatory",{enumerable:!0,get:function(){return l.RepetitionMandatory}}),Object.defineProperty(r,"RepetitionMandatoryWithSeparator",{enumerable:!0,get:function(){return l.RepetitionMandatoryWithSeparator}}),Object.defineProperty(r,"RepetitionWithSeparator",{enumerable:!0,get:function(){return l.RepetitionWithSeparator}}),Object.defineProperty(r,"Rule",{enumerable:!0,get:function(){return l.Rule}}),Object.defineProperty(r,"Terminal",{enumerable:!0,get:function(){return l.Terminal}});var c=Li();Object.defineProperty(r,"serializeGrammar",{enumerable:!0,get:function(){return c.serializeGrammar}}),Object.defineProperty(r,"serializeProduction",{enumerable:!0,get:function(){return c.serializeProduction}});var u=zc();Object.defineProperty(r,"GAstVisitor",{enumerable:!0,get:function(){return u.GAstVisitor}});function h(){console.warn(`The clearCache function was 'soft' removed from the Chevrotain API.
It performs no action other than printing this message.
- Please avoid using it as it will be completely removed in the future`)}r.clearCache=h;var f=RS();Object.defineProperty(r,"createSyntaxDiagramsCode",{enumerable:!0,get:function(){return f.createSyntaxDiagramsCode}});var p=function(){function g(){throw new Error(`The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.
-See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return g}();r.Parser=p}),za=IS();var Ph=class extends Dt{constructor(e){super(e)}load(e,t,n,i){let s=this,o=s.path===""?_s.extractUrlBase(e):s.path,a=new $n(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(l){try{t(s.parse(l,o))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){let n={};function i(ee){let k=s(),J=new lp(k.tokens),ue=new cp(k.tokenVocabulary),Z=o(ue.getBaseCstVisitorConstructor()),ce=J.lex(ee);ue.input=ce.tokens;let pe=ue.vrml();if(ue.errors.length>0)throw console.error(ue.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return Z.visit(pe)}function s(){let ee=za.createToken,k=ee({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),J=ee({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]([^\0-\x20\x22\x27\x23\x2b\x2c\x2e\x5b\x5d\x5c\x7b\x7d])*/,longer_alt:k}),ue=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],Z=ee({name:"Version",pattern:/#VRML.*/,longer_alt:J}),ce=ee({name:"NodeName",pattern:new RegExp(ue.join("|")),longer_alt:J}),pe=ee({name:"DEF",pattern:/DEF/,longer_alt:J}),fe=ee({name:"USE",pattern:/USE/,longer_alt:J}),ge=ee({name:"ROUTE",pattern:/ROUTE/,longer_alt:J}),Ae=ee({name:"TO",pattern:/TO/,longer_alt:J}),Ie=ee({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),Fe=ee({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),Je=ee({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),dt=ee({name:"TrueLiteral",pattern:/TRUE/}),Oe=ee({name:"FalseLiteral",pattern:/FALSE/}),ne=ee({name:"NullLiteral",pattern:/NULL/}),Pe=ee({name:"LSquare",pattern:/\[/}),Ne=ee({name:"RSquare",pattern:/]/}),Ue=ee({name:"LCurly",pattern:/{/}),De=ee({name:"RCurly",pattern:/}/}),ut=ee({name:"Comment",pattern:/#.*/,group:za.Lexer.SKIPPED}),yt=[ee({name:"WhiteSpace",pattern:/[ ,\s]/,group:za.Lexer.SKIPPED}),ce,pe,fe,ge,Ae,dt,Oe,ne,Z,J,k,Ie,Fe,Je,Pe,Ne,Ue,De,ut],wt={};for(let Qe=0,ke=yt.length;Qe<ke;Qe++){let qe=yt[Qe];wt[qe.name]=qe}return{tokens:yt,tokenVocabulary:wt}}function o(ee){class k extends ee{constructor(){super(),this.validateVisitor()}vrml(Z){let ce={version:this.visit(Z.version),nodes:[],routes:[]};for(let pe=0,fe=Z.node.length;pe<fe;pe++){let ge=Z.node[pe];ce.nodes.push(this.visit(ge))}if(Z.route)for(let pe=0,fe=Z.route.length;pe<fe;pe++){let ge=Z.route[pe];ce.routes.push(this.visit(ge))}return ce}version(Z){return Z.Version[0].image}node(Z){let ce={name:Z.NodeName[0].image,fields:[]};if(Z.field)for(let pe=0,fe=Z.field.length;pe<fe;pe++){let ge=Z.field[pe];ce.fields.push(this.visit(ge))}return Z.def&&(ce.DEF=this.visit(Z.def[0])),ce}field(Z){let ce={name:Z.Identifier[0].image,type:null,values:null},pe;return Z.singleFieldValue&&(pe=this.visit(Z.singleFieldValue[0])),Z.multiFieldValue&&(pe=this.visit(Z.multiFieldValue[0])),ce.type=pe.type,ce.values=pe.values,ce}def(Z){return(Z.Identifier||Z.NodeName)[0].image}use(Z){return{USE:(Z.Identifier||Z.NodeName)[0].image}}singleFieldValue(Z){return J(this,Z)}multiFieldValue(Z){return J(this,Z)}route(Z){return{FROM:Z.RouteIdentifier[0].image,TO:Z.RouteIdentifier[1].image}}}function J(ue,Z){let ce={type:null,values:[]};if(Z.node){ce.type="node";for(let pe=0,fe=Z.node.length;pe<fe;pe++){let ge=Z.node[pe];ce.values.push(ue.visit(ge))}}if(Z.use){ce.type="use";for(let pe=0,fe=Z.use.length;pe<fe;pe++){let ge=Z.use[pe];ce.values.push(ue.visit(ge))}}if(Z.StringLiteral){ce.type="string";for(let pe=0,fe=Z.StringLiteral.length;pe<fe;pe++){let ge=Z.StringLiteral[pe];ce.values.push(ge.image.replace(/'|"/g,""))}}if(Z.NumberLiteral){ce.type="number";for(let pe=0,fe=Z.NumberLiteral.length;pe<fe;pe++){let ge=Z.NumberLiteral[pe];ce.values.push(parseFloat(ge.image))}}if(Z.HexLiteral){ce.type="hex";for(let pe=0,fe=Z.HexLiteral.length;pe<fe;pe++){let ge=Z.HexLiteral[pe];ce.values.push(ge.image)}}if(Z.TrueLiteral){ce.type="boolean";for(let pe=0,fe=Z.TrueLiteral.length;pe<fe;pe++)Z.TrueLiteral[pe].image==="TRUE"&&ce.values.push(!0)}if(Z.FalseLiteral){ce.type="boolean";for(let pe=0,fe=Z.FalseLiteral.length;pe<fe;pe++)Z.FalseLiteral[pe].image==="FALSE"&&ce.values.push(!1)}return Z.NullLiteral&&(ce.type="null",Z.NullLiteral.forEach(function(){ce.values.push(null)})),ce}return new k}function a(ee){let k=ee.nodes,J=new vr;for(let ue=0,Z=k.length;ue<Z;ue++){let ce=k[ue];l(ce)}for(let ue=0,Z=k.length;ue<Z;ue++){let ce=k[ue],pe=c(ce);pe instanceof Rt&&J.add(pe),ce.name==="WorldInfo"&&(J.userData.worldInfo=pe)}return J}function l(ee){ee.DEF&&(n[ee.DEF]=ee);let k=ee.fields;for(let J=0,ue=k.length;J<ue;J++){let Z=k[J];if(Z.type==="node"){let ce=Z.values;for(let pe=0,fe=ce.length;pe<fe;pe++)l(ce[pe])}}}function c(ee){return ee.USE?$(ee.USE):(ee.build!==void 0||(ee.build=u(ee)),ee.build)}function u(ee){let k=ee.name,J;switch(k){case"Anchor":case"Group":case"Transform":case"Collision":J=h(ee);break;case"Background":J=f(ee);break;case"Shape":J=p(ee);break;case"Appearance":J=g(ee);break;case"Material":J=v(ee);break;case"ImageTexture":J=y(ee);break;case"PixelTexture":J=_(ee);break;case"TextureTransform":J=x(ee);break;case"IndexedFaceSet":J=C(ee);break;case"IndexedLineSet":J=P(ee);break;case"PointSet":J=E(ee);break;case"Box":J=M(ee);break;case"Cone":J=L(ee);break;case"Cylinder":J=N(ee);break;case"Sphere":J=O(ee);break;case"ElevationGrid":J=B(ee);break;case"Extrusion":J=ie(ee);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":J=w(ee);break;case"WorldInfo":J=I(ee);break;case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",k);break}return J!==void 0&&ee.DEF!==void 0&&J.hasOwnProperty("name")===!0&&(J.name=ee.DEF),J}function h(ee){let k=new dn,J=ee.fields;for(let ue=0,Z=J.length;ue<Z;ue++){let ce=J[ue],pe=ce.name,fe=ce.values;switch(pe){case"bboxCenter":break;case"bboxSize":break;case"center":break;case"children":te(fe,k);break;case"description":break;case"collide":break;case"parameter":break;case"rotation":let ge=new oe(fe[0],fe[1],fe[2]),Ae=fe[3];k.quaternion.setFromAxisAngle(ge,Ae);break;case"scale":k.scale.set(fe[0],fe[1],fe[2]);break;case"scaleOrientation":break;case"translation":k.position.set(fe[0],fe[1],fe[2]);break;case"proxy":break;case"url":break;default:console.warn("THREE.VRMLLoader: Unknown field:",pe);break}}return k}function f(ee){let k=new dn,J,ue,Z,ce,pe=ee.fields;for(let ge=0,Ae=pe.length;ge<Ae;ge++){let Ie=pe[ge],Fe=Ie.name,Je=Ie.values;switch(Fe){case"groundAngle":J=Je;break;case"groundColor":ue=Je;break;case"backUrl":break;case"bottomUrl":break;case"frontUrl":break;case"leftUrl":break;case"rightUrl":break;case"topUrl":break;case"skyAngle":Z=Je;break;case"skyColor":ce=Je;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Fe);break}}let fe=1e4;if(ce){let ge=new Ma(fe,32,16),Ae=new Ci({fog:!1,side:Tn,depthWrite:!1,depthTest:!1});ce.length>3?(U(ge,fe,Z,G(ce),!0),Ae.vertexColors=!0):(Ae.color.setRGB(ce[0],ce[1],ce[2]),Ae.color.convertSRGBToLinear());let Ie=new Pt(ge,Ae);k.add(Ie)}if(ue&&ue.length>0){let ge=new Ma(fe,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),Ae=new Ci({fog:!1,side:Tn,vertexColors:!0,depthWrite:!1,depthTest:!1});U(ge,fe,J,G(ue),!1);let Ie=new Pt(ge,Ae);k.add(Ie)}return k.renderOrder=-1/0,k}function p(ee){let k=ee.fields,J=new Ci({name:Dt.DEFAULT_MATERIAL_NAME,color:0}),ue;for(let ce=0,pe=k.length;ce<pe;ce++){let fe=k[ce],ge=fe.name,Ae=fe.values;switch(ge){case"appearance":Ae[0]!==null&&(J=c(Ae[0]));break;case"geometry":Ae[0]!==null&&(ue=c(Ae[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}let Z;if(ue&&ue.attributes.position){let ce=ue._type;if(ce==="points"){let pe=new zl({name:Dt.DEFAULT_MATERIAL_NAME,color:16777215,opacity:J.opacity,transparent:J.transparent});ue.attributes.color!==void 0?pe.vertexColors=!0:J.isMeshPhongMaterial&&pe.color.copy(J.emissive),Z=new Xu(ue,pe)}else if(ce==="line"){let pe=new Wn({name:Dt.DEFAULT_MATERIAL_NAME,color:16777215,opacity:J.opacity,transparent:J.transparent});ue.attributes.color!==void 0?pe.vertexColors=!0:J.isMeshPhongMaterial&&pe.color.copy(J.emissive),Z=new yr(ue,pe)}else ue._solid!==void 0&&(J.side=ue._solid?wi:On),ue.attributes.color!==void 0&&(J.vertexColors=!0),Z=new Pt(ue,J)}else Z=new Rt,Z.visible=!1;return Z}function g(ee){let k=new Zt,J,ue=ee.fields;for(let Z=0,ce=ue.length;Z<ce;Z++){let pe=ue[Z],fe=pe.name,ge=pe.values;switch(fe){case"material":if(ge[0]!==null){let Ie=c(ge[0]);Ie.diffuseColor&&k.color.copy(Ie.diffuseColor),Ie.emissiveColor&&k.emissive.copy(Ie.emissiveColor),Ie.shininess&&(k.shininess=Ie.shininess),Ie.specularColor&&k.specular.copy(Ie.specularColor),Ie.transparency&&(k.opacity=1-Ie.transparency),Ie.transparency>0&&(k.transparent=!0)}else k=new Ci({name:Dt.DEFAULT_MATERIAL_NAME,color:0});break;case"texture":let Ae=ge[0];Ae!==null&&(Ae.name==="ImageTexture"||Ae.name==="PixelTexture")&&(k.map=c(Ae));break;case"textureTransform":ge[0]!==null&&(J=c(ge[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",fe);break}}if(k.map){if(k.map.__type){switch(k.map.__type){case er.INTENSITY_ALPHA:k.opacity=1;break;case er.RGB:k.color.set(16777215);break;case er.RGBA:k.color.set(16777215),k.opacity=1;break;default:}delete k.map.__type}J&&(k.map.center.copy(J.center),k.map.rotation=J.rotation,k.map.repeat.copy(J.scale),k.map.offset.copy(J.translation))}return k}function v(ee){let k={},J=ee.fields;for(let ue=0,Z=J.length;ue<Z;ue++){let ce=J[ue],pe=ce.name,fe=ce.values;switch(pe){case"ambientIntensity":break;case"diffuseColor":k.diffuseColor=new Ve(fe[0],fe[1],fe[2]),k.diffuseColor.convertSRGBToLinear();break;case"emissiveColor":k.emissiveColor=new Ve(fe[0],fe[1],fe[2]),k.emissiveColor.convertSRGBToLinear();break;case"shininess":k.shininess=fe[0];break;case"specularColor":k.specularColor=new Ve(fe[0],fe[1],fe[2]),k.specularColor.convertSRGBToLinear();break;case"transparency":k.transparency=fe[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",pe);break}}return k}function d(ee,k,J){let ue;switch(k){case er.INTENSITY:ue=parseInt(ee),J.r=ue,J.g=ue,J.b=ue,J.a=1;break;case er.INTENSITY_ALPHA:ue=parseInt("0x"+ee.substring(2,4)),J.r=ue,J.g=ue,J.b=ue,J.a=parseInt("0x"+ee.substring(4,6));break;case er.RGB:J.r=parseInt("0x"+ee.substring(2,4)),J.g=parseInt("0x"+ee.substring(4,6)),J.b=parseInt("0x"+ee.substring(6,8)),J.a=1;break;case er.RGBA:J.r=parseInt("0x"+ee.substring(2,4)),J.g=parseInt("0x"+ee.substring(4,6)),J.b=parseInt("0x"+ee.substring(6,8)),J.a=parseInt("0x"+ee.substring(8,10));break;default:}}function m(ee){let k;switch(ee){case 1:k=er.INTENSITY;break;case 2:k=er.INTENSITY_ALPHA;break;case 3:k=er.RGB;break;case 4:k=er.RGBA;break;default:}return k}function _(ee){let k,J=rn,ue=rn,Z=ee.fields;for(let ce=0,pe=Z.length;ce<pe;ce++){let fe=Z[ce],ge=fe.name,Ae=fe.values;switch(ge){case"image":let Ie=Ae[0],Fe=Ae[1],Je=Ae[2],dt=m(Je),Oe=new Uint8Array(4*Ie*Fe),ne={r:0,g:0,b:0,a:0};for(let Pe=3,Ne=0,Ue=Ae.length;Pe<Ue;Pe++,Ne++){d(Ae[Pe],dt,ne);let De=Ne*4;Oe[De+0]=ne.r,Oe[De+1]=ne.g,Oe[De+2]=ne.b,Oe[De+3]=ne.a}k=new _a(Oe,Ie,Fe),k.colorSpace=jt,k.needsUpdate=!0,k.__type=dt;break;case"repeatS":Ae[0]===!1&&(J=un);break;case"repeatT":Ae[0]===!1&&(ue=un);break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}return k&&(k.wrapS=J,k.wrapT=ue),k}function y(ee){let k,J=rn,ue=rn,Z=ee.fields;for(let ce=0,pe=Z.length;ce<pe;ce++){let fe=Z[ce],ge=fe.name,Ae=fe.values;switch(ge){case"url":let Ie=Ae[0];Ie&&(k=he.load(Ie));break;case"repeatS":Ae[0]===!1&&(J=un);break;case"repeatT":Ae[0]===!1&&(ue=un);break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}return k&&(k.wrapS=J,k.wrapT=ue,k.colorSpace=jt),k}function x(ee){let k={center:new Ce,rotation:new Ce,scale:new Ce,translation:new Ce},J=ee.fields;for(let ue=0,Z=J.length;ue<Z;ue++){let ce=J[ue],pe=ce.name,fe=ce.values;switch(pe){case"center":k.center.set(fe[0],fe[1]);break;case"rotation":k.rotation=fe[0];break;case"scale":k.scale.set(fe[0],fe[1]);break;case"translation":k.translation.set(fe[0],fe[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",pe);break}}return k}function w(ee){return ee.fields[0].values}function I(ee){let k={},J=ee.fields;for(let ue=0,Z=J.length;ue<Z;ue++){let ce=J[ue],pe=ce.name,fe=ce.values;switch(pe){case"title":k.title=fe[0];break;case"info":k.info=fe;break;default:console.warn("THREE.VRMLLoader: Unknown field:",pe);break}}return k}function C(ee){let k,J,ue,Z,ce=!0,pe=!0,fe=0,ge,Ae,Ie,Fe,Je=!0,dt=!0,Oe=ee.fields;for(let at=0,yt=Oe.length;at<yt;at++){let wt=Oe[at],Qe=wt.name,ke=wt.values;switch(Qe){case"color":let qe=ke[0];qe!==null&&(k=c(qe));break;case"coord":let He=ke[0];He!==null&&(J=c(He));break;case"normal":let tt=ke[0];tt!==null&&(ue=c(tt));break;case"texCoord":let rt=ke[0];rt!==null&&(Z=c(rt));break;case"ccw":ce=ke[0];break;case"colorIndex":ge=ke;break;case"colorPerVertex":Je=ke[0];break;case"convex":break;case"coordIndex":Ae=ke;break;case"creaseAngle":fe=ke[0];break;case"normalIndex":Ie=ke;break;case"normalPerVertex":dt=ke[0];break;case"solid":pe=ke[0];break;case"texCoordIndex":Fe=ke;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Qe);break}}if(Ae===void 0)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new St;let ne=W(Ae,ce),Pe,Ne,Ue;if(k){if(Je===!0)if(ge&&ge.length>0){let at=W(ge,ce);Pe=q(ne,at,k,3)}else Pe=X(ne,new ze(k,3));else if(ge&&ge.length>0){let at=de(k,ge),yt=ae(at,Ae);Pe=Y(ne,yt)}else{let at=ae(k,Ae);Pe=Y(ne,at)}A(Pe)}if(ue)if(dt===!0)if(Ie&&Ie.length>0){let at=W(Ie,ce);Ne=q(ne,at,ue,3)}else Ne=X(ne,new ze(ue,3));else if(Ie&&Ie.length>0){let at=de(ue,Ie),yt=ae(at,Ae);Ne=Y(ne,yt)}else{let at=ae(ue,Ae);Ne=Y(ne,at)}else Ne=le(ne,J,fe);if(Z)if(Fe&&Fe.length>0){let at=W(Fe,ce);Ue=q(ne,at,Z,2)}else Ue=X(ne,new ze(Z,2));let De=new St,ut=X(ne,new ze(J,3));return De.setAttribute("position",ut),De.setAttribute("normal",Ne),Pe&&De.setAttribute("color",Pe),Ue&&De.setAttribute("uv",Ue),De._solid=pe,De._type="mesh",De}function P(ee){let k,J,ue,Z,ce=!0,pe=ee.fields;for(let Fe=0,Je=pe.length;Fe<Je;Fe++){let dt=pe[Fe],Oe=dt.name,ne=dt.values;switch(Oe){case"color":let Pe=ne[0];Pe!==null&&(k=c(Pe));break;case"coord":let Ne=ne[0];Ne!==null&&(J=c(Ne));break;case"colorIndex":ue=ne;break;case"colorPerVertex":ce=ne[0];break;case"coordIndex":Z=ne;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Oe);break}}let fe,ge=ye(Z);if(k){if(ce===!0)if(ue.length>0){let Fe=ye(ue);fe=q(ge,Fe,k,3)}else fe=X(ge,new ze(k,3));else if(ue.length>0){let Fe=de(k,ue),Je=Me(Fe,Z);fe=z(ge,Je)}else{let Fe=Me(k,Z);fe=z(ge,Fe)}A(fe)}let Ae=new St,Ie=X(ge,new ze(J,3));return Ae.setAttribute("position",Ie),fe&&Ae.setAttribute("color",fe),Ae._type="line",Ae}function E(ee){let k,J,ue=ee.fields;for(let ce=0,pe=ue.length;ce<pe;ce++){let fe=ue[ce],ge=fe.name,Ae=fe.values;switch(ge){case"color":let Ie=Ae[0];Ie!==null&&(k=c(Ie));break;case"coord":let Fe=Ae[0];Fe!==null&&(J=c(Fe));break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}let Z=new St;if(Z.setAttribute("position",new ze(J,3)),k){let ce=new ze(k,3);A(ce),Z.setAttribute("color",ce)}return Z._type="points",Z}function M(ee){let k=new oe(2,2,2),J=ee.fields;for(let Z=0,ce=J.length;Z<ce;Z++){let pe=J[Z],fe=pe.name,ge=pe.values;switch(fe){case"size":k.x=ge[0],k.y=ge[1],k.z=ge[2];break;default:console.warn("THREE.VRMLLoader: Unknown field:",fe);break}}return new Zs(k.x,k.y,k.z)}function L(ee){let k=1,J=2,ue=!1,Z=ee.fields;for(let pe=0,fe=Z.length;pe<fe;pe++){let ge=Z[pe],Ae=ge.name,Ie=ge.values;switch(Ae){case"bottom":ue=!Ie[0];break;case"bottomRadius":k=Ie[0];break;case"height":J=Ie[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",Ae);break}}return new Zu(k,J,16,1,ue)}function N(ee){let k=1,J=2,ue=ee.fields;for(let ce=0,pe=ue.length;ce<pe;ce++){let fe=ue[ce],ge=fe.name,Ae=fe.values;switch(ge){case"bottom":break;case"radius":k=Ae[0];break;case"height":J=Ae[0];break;case"side":break;case"top":break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}return new Wl(k,k,J,16,1)}function O(ee){let k=1,J=ee.fields;for(let Z=0,ce=J.length;Z<ce;Z++){let pe=J[Z],fe=pe.name,ge=pe.values;switch(fe){case"radius":k=ge[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",fe);break}}return new Ma(k,16,16)}function B(ee){let k,J,ue,Z,ce=!0,pe=!0,fe=!0,ge=!0,Ae=0,Ie=2,Fe=2,Je=1,dt=1,Oe=ee.fields;for(let ke=0,qe=Oe.length;ke<qe;ke++){let He=Oe[ke],tt=He.name,rt=He.values;switch(tt){case"color":let Wt=rt[0];Wt!==null&&(k=c(Wt));break;case"normal":let jn=rt[0];jn!==null&&(J=c(jn));break;case"texCoord":let fi=rt[0];fi!==null&&(ue=c(fi));break;case"height":Z=rt;break;case"ccw":ge=rt[0];break;case"colorPerVertex":ce=rt[0];break;case"creaseAngle":Ae=rt[0];break;case"normalPerVertex":pe=rt[0];break;case"solid":fe=rt[0];break;case"xDimension":Ie=rt[0];break;case"xSpacing":Je=rt[0];break;case"zDimension":Fe=rt[0];break;case"zSpacing":dt=rt[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",tt);break}}let ne=[],Pe=[],Ne=[],Ue=[];for(let ke=0;ke<Fe;ke++)for(let qe=0;qe<Ie;qe++){let He=ke*Ie+qe,tt=Je*ke,rt=Z[He],Wt=dt*qe;if(ne.push(tt,rt,Wt),k&&ce===!0){let jn=k[He*3+0],fi=k[He*3+1],Oi=k[He*3+2];Ne.push(jn,fi,Oi)}if(J&&pe===!0){let jn=J[He*3+0],fi=J[He*3+1],Oi=J[He*3+2];Pe.push(jn,fi,Oi)}if(ue){let jn=ue[He*2+0],fi=ue[He*2+1];Ue.push(jn,fi)}else Ue.push(ke/(Ie-1),qe/(Fe-1))}let De=[];for(let ke=0;ke<Ie-1;ke++)for(let qe=0;qe<Fe-1;qe++){let He=ke+qe*Ie,tt=ke+(qe+1)*Ie,rt=ke+1+(qe+1)*Ie,Wt=ke+1+qe*Ie;ge===!0?(De.push(He,rt,tt),De.push(rt,He,Wt)):(De.push(He,tt,rt),De.push(rt,Wt,He))}let ut=X(De,new ze(ne,3)),at=X(De,new ze(Ue,2)),yt,wt;if(k){if(ce===!1){for(let ke=0;ke<Ie-1;ke++)for(let qe=0;qe<Fe-1;qe++){let He=ke+qe*(Ie-1),tt=k[He*3+0],rt=k[He*3+1],Wt=k[He*3+2];Ne.push(tt,rt,Wt),Ne.push(tt,rt,Wt),Ne.push(tt,rt,Wt),Ne.push(tt,rt,Wt),Ne.push(tt,rt,Wt),Ne.push(tt,rt,Wt)}yt=new ze(Ne,3)}else yt=X(De,new ze(Ne,3));A(yt)}if(J)if(pe===!1){for(let ke=0;ke<Ie-1;ke++)for(let qe=0;qe<Fe-1;qe++){let He=ke+qe*(Ie-1),tt=J[He*3+0],rt=J[He*3+1],Wt=J[He*3+2];Pe.push(tt,rt,Wt),Pe.push(tt,rt,Wt),Pe.push(tt,rt,Wt),Pe.push(tt,rt,Wt),Pe.push(tt,rt,Wt),Pe.push(tt,rt,Wt)}wt=new ze(Pe,3)}else wt=X(De,new ze(Pe,3));else wt=le(De,ne,Ae);let Qe=new St;return Qe.setAttribute("position",ut),Qe.setAttribute("normal",wt),Qe.setAttribute("uv",at),yt&&Qe.setAttribute("color",yt),Qe._solid=fe,Qe._type="mesh",Qe}function ie(ee){let k=[1,1,1,-1,-1,-1,-1,1,1,1],J=[0,0,0,0,1,0],ue,Z,ce=!0,pe=!0,fe=0,ge=!0,Ae=!0,Ie=ee.fields;for(let Qe=0,ke=Ie.length;Qe<ke;Qe++){let qe=Ie[Qe],He=qe.name,tt=qe.values;switch(He){case"beginCap":ce=tt[0];break;case"ccw":pe=tt[0];break;case"convex":break;case"creaseAngle":fe=tt[0];break;case"crossSection":k=tt;break;case"endCap":ge=tt[0];break;case"orientation":Z=tt;break;case"scale":ue=tt;break;case"solid":Ae=tt[0];break;case"spine":J=tt;break;default:console.warn("THREE.VRMLLoader: Unknown field:",He);break}}let Fe=k[0]===k[k.length-2]&&k[1]===k[k.length-1],Je=[],dt=new oe,Oe=new oe,ne=new oe,Pe=new oe,Ne=new sn;for(let Qe=0,ke=0,qe=0,He=J.length;Qe<He;Qe+=3,ke+=2,qe+=4){dt.fromArray(J,Qe),Oe.x=ue?ue[ke+0]:1,Oe.y=1,Oe.z=ue?ue[ke+1]:1,ne.x=Z?Z[qe+0]:0,ne.y=Z?Z[qe+1]:0,ne.z=Z?Z[qe+2]:1;let tt=Z?Z[qe+3]:0;for(let rt=0,Wt=k.length;rt<Wt;rt+=2)Pe.x=k[rt+0],Pe.y=0,Pe.z=k[rt+1],Pe.multiply(Oe),Ne.setFromAxisAngle(ne,tt),Pe.applyQuaternion(Ne),Pe.add(dt),Je.push(Pe.x,Pe.y,Pe.z)}let Ue=[],De=J.length/3,ut=k.length/2;for(let Qe=0;Qe<De-1;Qe++)for(let ke=0;ke<ut-1;ke++){let qe=ke+Qe*ut,He=ke+1+Qe*ut,tt=ke+(Qe+1)*ut,rt=ke+1+(Qe+1)*ut;ke===ut-2&&Fe===!0&&(He=Qe*ut,rt=(Qe+1)*ut),pe===!0?(Ue.push(qe,He,tt),Ue.push(tt,He,rt)):(Ue.push(qe,tt,He),Ue.push(tt,rt,He))}if(ce===!0||ge===!0){let Qe=[];for(let He=0,tt=k.length;He<tt;He+=2)Qe.push(new Ce(k[He],k[He+1]));let ke=Ai.triangulateShape(Qe,[]),qe=[];for(let He=0,tt=ke.length;He<tt;He++){let rt=ke[He];qe.push(rt[0],rt[1],rt[2])}if(ce===!0)for(let He=0,tt=qe.length;He<tt;He+=3)pe===!0?Ue.push(qe[He+0],qe[He+1],qe[He+2]):Ue.push(qe[He+0],qe[He+2],qe[He+1]);if(ge===!0){let He=ut*(De-1);for(let tt=0,rt=qe.length;tt<rt;tt+=3)pe===!0?Ue.push(He+qe[tt+0],He+qe[tt+2],He+qe[tt+1]):Ue.push(He+qe[tt+0],He+qe[tt+1],He+qe[tt+2])}}let at=X(Ue,new ze(Je,3)),yt=le(Ue,Je,fe),wt=new St;return wt.setAttribute("position",at),wt.setAttribute("normal",yt),wt._solid=Ae,wt._type="mesh",wt}function $(ee){let k=n[ee],J=c(k);return J.isObject3D||J.isMaterial?J.clone():J}function te(ee,k){for(let J=0,ue=ee.length;J<ue;J++){let Z=c(ee[J]);Z instanceof Rt&&k.add(Z)}}function W(ee,k){let J=[],ue=0;for(let Z=0,ce=ee.length;Z<ce;Z++){let pe=ee[ue],fe=ee[Z+(k?1:2)],ge=ee[Z+(k?2:1)];J.push(pe,fe,ge),(ee[Z+3]===-1||Z+3>=ce)&&(Z+=3,ue=Z+1)}return J}function ae(ee,k){let J=[],ue=0;for(let Z=0,ce=k.length;Z<ce;Z++){let pe=ue*3,fe=ee[pe],ge=ee[pe+1],Ae=ee[pe+2];J.push(fe,ge,Ae),(k[Z+3]===-1||Z+3>=ce)&&(Z+=3,ue++)}return J}function de(ee,k){let J=[];for(let ue=0,Z=k.length;ue<Z;ue++){let pe=k[ue]*3,fe=ee[pe],ge=ee[pe+1],Ae=ee[pe+2];J.push(fe,ge,Ae)}return J}function ye(ee){let k=[];for(let J=0,ue=ee.length;J<ue;J++){let Z=ee[J],ce=ee[J+1];k.push(Z,ce),(ee[J+2]===-1||J+2>=ue)&&(J+=2)}return k}function Me(ee,k){let J=[],ue=0;for(let Z=0,ce=k.length;Z<ce;Z++){let pe=ue*3,fe=ee[pe],ge=ee[pe+1],Ae=ee[pe+2];J.push(fe,ge,Ae),(k[Z+2]===-1||Z+2>=ce)&&(Z+=2,ue++)}return J}let ve=new oe,R=new oe,T=new oe,S=new Ce,b=new Ce,V=new Ce;function q(ee,k,J,ue){let Z=[];for(let ce=0,pe=ee.length;ce<pe;ce+=3){let fe=k[ce],ge=k[ce+1],Ae=k[ce+2];ue===2?(S.fromArray(J,fe*ue),b.fromArray(J,ge*ue),V.fromArray(J,Ae*ue),Z.push(S.x,S.y),Z.push(b.x,b.y),Z.push(V.x,V.y)):(ve.fromArray(J,fe*ue),R.fromArray(J,ge*ue),T.fromArray(J,Ae*ue),Z.push(ve.x,ve.y,ve.z),Z.push(R.x,R.y,R.z),Z.push(T.x,T.y,T.z))}return new ze(Z,ue)}function Y(ee,k){let J=[];for(let ue=0,Z=0,ce=ee.length;ue<ce;ue+=3,Z++)ve.fromArray(k,Z*3),J.push(ve.x,ve.y,ve.z),J.push(ve.x,ve.y,ve.z),J.push(ve.x,ve.y,ve.z);return new ze(J,3)}function z(ee,k){let J=[];for(let ue=0,Z=0,ce=ee.length;ue<ce;ue+=2,Z++)ve.fromArray(k,Z*3),J.push(ve.x,ve.y,ve.z),J.push(ve.x,ve.y,ve.z);return new ze(J,3)}function X(ee,k){let J=k.array,ue=k.itemSize,Z=new J.constructor(ee.length*ue),ce=0,pe=0;for(let fe=0,ge=ee.length;fe<ge;fe++){ce=ee[fe]*ue;for(let Ae=0;Ae<ue;Ae++)Z[pe++]=J[ce++]}return new ze(Z,ue)}let se=new oe,re=new oe;function le(ee,k,J){let ue=[],Z={};for(let pe=0,fe=ee.length;pe<fe;pe+=3){let ge=ee[pe],Ae=ee[pe+1],Ie=ee[pe+2],Fe=new up(ge,Ae,Ie);ve.fromArray(k,ge*3),R.fromArray(k,Ae*3),T.fromArray(k,Ie*3),re.subVectors(T,R),se.subVectors(ve,R),re.cross(se),re.normalize(),Fe.normal.copy(re),Z[ge]===void 0&&(Z[ge]=[]),Z[Ae]===void 0&&(Z[Ae]=[]),Z[Ie]===void 0&&(Z[Ie]=[]),Z[ge].push(Fe.normal),Z[Ae].push(Fe.normal),Z[Ie].push(Fe.normal),ue.push(Fe)}let ce=[];for(let pe=0,fe=ue.length;pe<fe;pe++){let ge=ue[pe],Ae=xe(Z[ge.a],ge.normal,J),Ie=xe(Z[ge.b],ge.normal,J),Fe=xe(Z[ge.c],ge.normal,J);ve.fromArray(k,ge.a*3),R.fromArray(k,ge.b*3),T.fromArray(k,ge.c*3),ce.push(Ae.x,Ae.y,Ae.z),ce.push(Ie.x,Ie.y,Ie.z),ce.push(Fe.x,Fe.y,Fe.z)}return new ze(ce,3)}function xe(ee,k,J){let ue=new oe;if(J===0)ue.copy(k);else for(let Z=0,ce=ee.length;Z<ce;Z++)ee[Z].angleTo(k)<J&&ue.add(ee[Z]);return ue.normalize()}function G(ee){let k=[];for(let J=0,ue=ee.length;J<ue;J+=3)k.push(new Ve(ee[J],ee[J+1],ee[J+2]));return k}function A(ee){let k=new Ve;for(let J=0;J<ee.count;J++)k.fromBufferAttribute(ee,J),k.convertSRGBToLinear(),ee.setXYZ(J,k.r,k.g,k.b)}function U(ee,k,J,ue,Z){let ce=[],pe=Z===!0?0:Math.PI;for(let Je=0,dt=ue.length;Je<dt;Je++){let Oe=Je===0?0:J[Je-1];Oe=Z===!0?Oe:pe-Oe;let ne=new oe;ne.setFromSphericalCoords(k,Oe,0),ce.push(ne)}let fe=ee.index,ge=ee.attributes.position,Ae=new Gn(new Float32Array(ee.attributes.position.count*3),3),Ie=new oe,Fe=new Ve;for(let Je=0;Je<fe.count;Je++){let dt=fe.getX(Je);Ie.fromBufferAttribute(ge,dt);let Oe,ne,Pe=1;for(let De=1;De<ce.length;De++){Oe=De-1,ne=De;let ut=ce[Oe],at=ce[ne];if(Z===!0){if(Ie.y<=ut.y&&Ie.y>at.y){Pe=Math.abs(ut.y-Ie.y)/Math.abs(ut.y-at.y);break}}else if(Ie.y>=ut.y&&Ie.y<at.y){Pe=Math.abs(ut.y-Ie.y)/Math.abs(ut.y-at.y);break}}let Ne=ue[Oe],Ue=ue[ne];Fe.copy(Ne).lerp(Ue,Pe).convertSRGBToLinear(),Ae.setXYZ(dt,Fe.r,Fe.g,Fe.b)}ee.setAttribute("color",Ae)}let he=new Pi(this.manager);if(he.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),e.indexOf("#VRML V2.0")===-1)throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");let me=i(e);return a(me)}},lp=class{constructor(e){this.lexer=new za.Lexer(e)}lex(e){let t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}},PS=za.CstParser,cp=class extends PS{constructor(e){super(e);let t=this,n=e.Version,i=e.LCurly,s=e.RCurly,o=e.LSquare,a=e.RSquare,l=e.Identifier,c=e.RouteIdentifier,u=e.StringLiteral,h=e.HexLiteral,f=e.NumberLiteral,p=e.TrueLiteral,g=e.FalseLiteral,v=e.NullLiteral,d=e.DEF,m=e.USE,_=e.ROUTE,y=e.TO,x=e.NodeName;t.RULE("vrml",function(){t.SUBRULE(t.version),t.AT_LEAST_ONE(function(){t.SUBRULE(t.node)}),t.MANY(function(){t.SUBRULE(t.route)})}),t.RULE("version",function(){t.CONSUME(n)}),t.RULE("node",function(){t.OPTION(function(){t.SUBRULE(t.def)}),t.CONSUME(x),t.CONSUME(i),t.MANY(function(){t.SUBRULE(t.field)}),t.CONSUME(s)}),t.RULE("field",function(){t.CONSUME(l),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])}),t.RULE("def",function(){t.CONSUME(d),t.OR([{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(x)}}])}),t.RULE("use",function(){t.CONSUME(m),t.OR([{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(x)}}])}),t.RULE("singleFieldValue",function(){t.AT_LEAST_ONE(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(v)}}])})}),t.RULE("multiFieldValue",function(){t.CONSUME(o),t.MANY(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(v)}}])}),t.CONSUME(a)}),t.RULE("route",function(){t.CONSUME(_),t.CONSUME(c),t.CONSUME(y),t.CONSUME2(c)}),this.performSelfAnalysis()}},up=class{constructor(e,t,n){this.a=e,this.b=t,this.c=n,this.normal=new oe}},er={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};var hp=jt,Nh=class extends Dt{constructor(e){super(e),this.availableExtensions=[]}load(e,t,n,i){let s=this,o=new $n(s.manager);o.setPath(s.path),o.setResponseType("arraybuffer"),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(a))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t=this,n=new Pi(this.manager);function i(R){let T=null,S=null,b,V,q=[],Y=[],z,X={},se={},re={},le=new TextDecoder;try{T=xh(new Uint8Array(R))}catch(U){if(U instanceof ReferenceError)return console.error("THREE.3MFLoader: fflate missing and file is compressed."),null}for(S in T)S.match(/\_rels\/.rels$/)?b=S:S.match(/3D\/_rels\/.*\.model\.rels$/)?V=S:S.match(/^3D\/.*\.model$/)?q.push(S):S.match(/^3D\/Textures?\/.*/)&&Y.push(S);if(b===void 0)throw new Error("THREE.ThreeMFLoader: Cannot find relationship file `rels` in 3MF archive.");let xe=T[b],G=le.decode(xe),A=s(G);if(V){let U=T[V],he=le.decode(U);z=s(he)}for(let U=0;U<q.length;U++){let he=q[U],me=T[he],Te=le.decode(me),ee=new DOMParser().parseFromString(Te,"application/xml");ee.documentElement.nodeName.toLowerCase()!=="model"&&console.error("THREE.3MFLoader: Error loading 3MF - no 3MF document found: ",he);let k=ee.querySelector("model"),J={};for(let Z=0;Z<k.attributes.length;Z++){let ce=k.attributes[Z];ce.name.match(/^xmlns:(.+)$/)&&(J[ce.value]=RegExp.$1)}let ue=x(k);ue.xml=k,0<Object.keys(J).length&&(ue.extensions=J),X[he]=ue}for(let U=0;U<Y.length;U++){let he=Y[U];re[he]=T[he].buffer}return{rels:A,modelRels:z,model:X,printTicket:se,texture:re}}function s(R){let T=[],b=new DOMParser().parseFromString(R,"application/xml").querySelectorAll("Relationship");for(let V=0;V<b.length;V++){let q=b[V],Y={target:q.getAttribute("Target"),id:q.getAttribute("Id"),type:q.getAttribute("Type")};T.push(Y)}return T}function o(R){let T={};for(let S=0;S<R.length;S++){let b=R[S],V=b.getAttribute("name");0<=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate"].indexOf(V)&&(T[V]=b.textContent)}return T}function a(R){let T={id:R.getAttribute("id"),basematerials:[]},S=R.querySelectorAll("base");for(let b=0;b<S.length;b++){let V=S[b],q=f(V);q.index=b,T.basematerials.push(q)}return T}function l(R){return{id:R.getAttribute("id"),path:R.getAttribute("path"),contenttype:R.getAttribute("contenttype"),tilestyleu:R.getAttribute("tilestyleu"),tilestylev:R.getAttribute("tilestylev"),filter:R.getAttribute("filter")}}function c(R){let T={id:R.getAttribute("id"),texid:R.getAttribute("texid"),displaypropertiesid:R.getAttribute("displaypropertiesid")},S=R.querySelectorAll("tex2coord"),b=[];for(let V=0;V<S.length;V++){let q=S[V],Y=q.getAttribute("u"),z=q.getAttribute("v");b.push(parseFloat(Y),parseFloat(z))}return T.uvs=new Float32Array(b),T}function u(R){let T={id:R.getAttribute("id"),displaypropertiesid:R.getAttribute("displaypropertiesid")},S=R.querySelectorAll("color"),b=[],V=new Ve;for(let q=0;q<S.length;q++){let z=S[q].getAttribute("color");V.setStyle(z.substring(0,7),hp),b.push(V.r,V.g,V.b)}return T.colors=new Float32Array(b),T}function h(R){let T={id:R.getAttribute("id")},S=R.querySelectorAll("pbmetallic"),b=[];for(let V=0;V<S.length;V++){let q=S[V];b.push({name:q.getAttribute("name"),metallicness:parseFloat(q.getAttribute("metallicness")),roughness:parseFloat(q.getAttribute("roughness"))})}return T.data=b,T}function f(R){let T={};return T.name=R.getAttribute("name"),T.displaycolor=R.getAttribute("displaycolor"),T.displaypropertiesid=R.getAttribute("displaypropertiesid"),T}function p(R){let T={},S=[],b=R.querySelectorAll("vertices vertex");for(let z=0;z<b.length;z++){let X=b[z],se=X.getAttribute("x"),re=X.getAttribute("y"),le=X.getAttribute("z");S.push(parseFloat(se),parseFloat(re),parseFloat(le))}T.vertices=new Float32Array(S);let V=[],q=[],Y=R.querySelectorAll("triangles triangle");for(let z=0;z<Y.length;z++){let X=Y[z],se=X.getAttribute("v1"),re=X.getAttribute("v2"),le=X.getAttribute("v3"),xe=X.getAttribute("p1"),G=X.getAttribute("p2"),A=X.getAttribute("p3"),U=X.getAttribute("pid"),he={};he.v1=parseInt(se,10),he.v2=parseInt(re,10),he.v3=parseInt(le,10),q.push(he.v1,he.v2,he.v3),xe&&(he.p1=parseInt(xe,10)),G&&(he.p2=parseInt(G,10)),A&&(he.p3=parseInt(A,10)),U&&(he.pid=U),0<Object.keys(he).length&&V.push(he)}return T.triangleProperties=V,T.triangles=new Uint32Array(q),T}function g(R){let T=[],S=R.querySelectorAll("component");for(let b=0;b<S.length;b++){let V=S[b],q=v(V);T.push(q)}return T}function v(R){let T={};T.objectId=R.getAttribute("objectid");let S=R.getAttribute("transform");return S&&(T.transform=d(S)),T}function d(R){let T=[];R.split(" ").forEach(function(b){T.push(parseFloat(b))});let S=new Ye;return S.set(T[0],T[3],T[6],T[9],T[1],T[4],T[7],T[10],T[2],T[5],T[8],T[11],0,0,0,1),S}function m(R){let T={type:R.getAttribute("type")},S=R.getAttribute("id");S&&(T.id=S);let b=R.getAttribute("pid");b&&(T.pid=b);let V=R.getAttribute("pindex");V&&(T.pindex=V);let q=R.getAttribute("thumbnail");q&&(T.thumbnail=q);let Y=R.getAttribute("partnumber");Y&&(T.partnumber=Y);let z=R.getAttribute("name");z&&(T.name=z);let X=R.querySelector("mesh");X&&(T.mesh=p(X));let se=R.querySelector("components");return se&&(T.components=g(se)),T}function _(R){let T={};T.basematerials={};let S=R.querySelectorAll("basematerials");for(let X=0;X<S.length;X++){let se=S[X],re=a(se);T.basematerials[re.id]=re}T.texture2d={};let b=R.querySelectorAll("texture2d");for(let X=0;X<b.length;X++){let se=b[X],re=l(se);T.texture2d[re.id]=re}T.colorgroup={};let V=R.querySelectorAll("colorgroup");for(let X=0;X<V.length;X++){let se=V[X],re=u(se);T.colorgroup[re.id]=re}T.pbmetallicdisplayproperties={};let q=R.querySelectorAll("pbmetallicdisplayproperties");for(let X=0;X<q.length;X++){let se=q[X],re=h(se);T.pbmetallicdisplayproperties[re.id]=re}T.texture2dgroup={};let Y=R.querySelectorAll("texture2dgroup");for(let X=0;X<Y.length;X++){let se=Y[X],re=c(se);T.texture2dgroup[re.id]=re}T.object={};let z=R.querySelectorAll("object");for(let X=0;X<z.length;X++){let se=z[X],re=m(se);T.object[re.id]=re}return T}function y(R){let T=[],S=R.querySelectorAll("item");for(let b=0;b<S.length;b++){let V=S[b],q={objectId:V.getAttribute("objectid")},Y=V.getAttribute("transform");Y&&(q.transform=d(Y)),T.push(q)}return T}function x(R){let T={unit:R.getAttribute("unit")||"millimeter"},S=R.querySelectorAll("metadata");S&&(T.metadata=o(S));let b=R.querySelector("resources");b&&(T.resources=_(b));let V=R.querySelector("build");return V&&(T.build=y(V)),T}function w(R,T,S,b){let V=R.texid,Y=S.resources.texture2d[V];if(Y){let z=b[Y.path],X=Y.contenttype,se=new Blob([z],{type:X}),re=URL.createObjectURL(se),le=n.load(re,function(){URL.revokeObjectURL(re)});switch(le.colorSpace=hp,Y.tilestyleu){case"wrap":le.wrapS=rn;break;case"mirror":le.wrapS=ha;break;case"none":case"clamp":le.wrapS=un;break;default:le.wrapS=rn}switch(Y.tilestylev){case"wrap":le.wrapT=rn;break;case"mirror":le.wrapT=ha;break;case"none":case"clamp":le.wrapT=un;break;default:le.wrapT=rn}switch(Y.filter){case"auto":le.magFilter=bn,le.minFilter=vi;break;case"linear":le.magFilter=bn,le.minFilter=bn;break;case"nearest":le.magFilter=Bn,le.minFilter=Bn;break;default:le.magFilter=bn,le.minFilter=vi}return le}else return null}function I(R,T,S,b,V,q,Y){let z=Y.pindex,X={};for(let le=0,xe=T.length;le<xe;le++){let G=T[le],A=G.p1!==void 0?G.p1:z;X[A]===void 0&&(X[A]=[]),X[A].push(G)}let se=Object.keys(X),re=[];for(let le=0,xe=se.length;le<xe;le++){let G=se[le],A=X[G],U=R.basematerials[G],he=ie(U,b,V,q,Y,$),me=new St,Te=[],ee=S.vertices;for(let J=0,ue=A.length;J<ue;J++){let Z=A[J];Te.push(ee[Z.v1*3+0]),Te.push(ee[Z.v1*3+1]),Te.push(ee[Z.v1*3+2]),Te.push(ee[Z.v2*3+0]),Te.push(ee[Z.v2*3+1]),Te.push(ee[Z.v2*3+2]),Te.push(ee[Z.v3*3+0]),Te.push(ee[Z.v3*3+1]),Te.push(ee[Z.v3*3+2])}me.setAttribute("position",new ze(Te,3));let k=new Pt(me,he);re.push(k)}return re}function C(R,T,S,b,V,q,Y){let z=new St,X=[],se=[],re=S.vertices,le=R.uvs;for(let U=0,he=T.length;U<he;U++){let me=T[U];X.push(re[me.v1*3+0]),X.push(re[me.v1*3+1]),X.push(re[me.v1*3+2]),X.push(re[me.v2*3+0]),X.push(re[me.v2*3+1]),X.push(re[me.v2*3+2]),X.push(re[me.v3*3+0]),X.push(re[me.v3*3+1]),X.push(re[me.v3*3+2]),se.push(le[me.p1*2+0]),se.push(le[me.p1*2+1]),se.push(le[me.p2*2+0]),se.push(le[me.p2*2+1]),se.push(le[me.p3*2+0]),se.push(le[me.p3*2+1])}z.setAttribute("position",new ze(X,3)),z.setAttribute("uv",new ze(se,2));let xe=ie(R,b,V,q,Y,w),G=new Zt({map:xe,flatShading:!0});return new Pt(z,G)}function P(R,T,S,b){let V=new St,q=[],Y=[],z=S.vertices,X=R.colors;for(let le=0,xe=T.length;le<xe;le++){let G=T[le],A=G.v1,U=G.v2,he=G.v3;q.push(z[A*3+0]),q.push(z[A*3+1]),q.push(z[A*3+2]),q.push(z[U*3+0]),q.push(z[U*3+1]),q.push(z[U*3+2]),q.push(z[he*3+0]),q.push(z[he*3+1]),q.push(z[he*3+2]);let me=G.p1!==void 0?G.p1:b.pindex,Te=G.p2!==void 0?G.p2:me,ee=G.p3!==void 0?G.p3:me;Y.push(X[me*3+0]),Y.push(X[me*3+1]),Y.push(X[me*3+2]),Y.push(X[Te*3+0]),Y.push(X[Te*3+1]),Y.push(X[Te*3+2]),Y.push(X[ee*3+0]),Y.push(X[ee*3+1]),Y.push(X[ee*3+2])}V.setAttribute("position",new ze(q,3)),V.setAttribute("color",new ze(Y,3));let se=new Zt({vertexColors:!0,flatShading:!0});return new Pt(V,se)}function E(R){let T=new St;T.setIndex(new Gn(R.triangles,1)),T.setAttribute("position",new Gn(R.vertices,3));let S=new Zt({name:Dt.DEFAULT_MATERIAL_NAME,color:16777215,flatShading:!0});return new Pt(T,S)}function M(R,T,S,b,V,q){let Y=Object.keys(R),z=[];for(let X=0,se=Y.length;X<se;X++){let re=Y[X],le=R[re];switch(L(re,b)){case"material":let G=b.resources.basematerials[re],A=I(G,le,T,S,b,V,q);for(let me=0,Te=A.length;me<Te;me++)z.push(A[me]);break;case"texture":let U=b.resources.texture2dgroup[re];z.push(C(U,le,T,S,b,V,q));break;case"vertexColors":let he=b.resources.colorgroup[re];z.push(P(he,le,T,q));break;case"default":z.push(E(T));break;default:console.error("THREE.3MFLoader: Unsupported resource type.")}}if(q.name)for(let X=0;X<z.length;X++)z[X].name=q.name;return z}function L(R,T){return T.resources.texture2dgroup[R]!==void 0?"texture":T.resources.basematerials[R]!==void 0?"material":T.resources.colorgroup[R]!==void 0?"vertexColors":R==="default"?"default":void 0}function N(R,T){let S={},b=R.triangleProperties,V=T.pid;for(let q=0,Y=b.length;q<Y;q++){let z=b[q],X=z.pid!==void 0?z.pid:V;X===void 0&&(X="default"),S[X]===void 0&&(S[X]=[]),S[X].push(z)}return S}function O(R,T,S,b,V){let q=new dn,Y=N(R,V),z=M(Y,R,T,S,b,V);for(let X=0,se=z.length;X<se;X++)q.add(z[X]);return q}function B(R,T,S){if(!R)return;let b=[],V=Object.keys(R);for(let q=0;q<V.length;q++){let Y=V[q];for(let z=0;z<t.availableExtensions.length;z++){let X=t.availableExtensions[z];X.ns===Y&&b.push(X)}}for(let q=0;q<b.length;q++){let Y=b[q];Y.apply(S,R[Y.ns],T)}}function ie(R,T,S,b,V,q){return R.build!==void 0||(R.build=q(R,T,S,b,V)),R.build}function $(R,T,S){let b,V=R.displaypropertiesid,q=S.resources.pbmetallicdisplayproperties;if(V!==null&&q[V]!==void 0){let se=q[V].data[R.index];b=new gs({flatShading:!0,roughness:se.roughness,metalness:se.metallicness})}else b=new Zt({flatShading:!0});b.name=R.name;let Y=R.displaycolor,z=Y.substring(0,7);return b.color.setStyle(z,hp),Y.length===9&&(b.opacity=parseInt(Y.charAt(7)+Y.charAt(8),16)/255),b}function te(R,T,S,b){let V=new dn;for(let q=0;q<R.length;q++){let Y=R[q],z=T[Y.objectId];z===void 0&&(W(Y.objectId,T,S,b),z=T[Y.objectId]);let X=z.clone(),se=Y.transform;se&&X.applyMatrix4(se),V.add(X)}return V}function W(R,T,S,b){let V=S.resources.object[R];if(V.mesh){let q=V.mesh,Y=S.extensions,z=S.xml;B(Y,q,z),T[V.id]=ie(q,T,S,b,V,O)}else{let q=V.components;T[V.id]=ie(q,T,S,b,V,te)}V.name&&(T[V.id].name=V.name)}function ae(R){let T=R.model,S=R.modelRels,b={},V=Object.keys(T),q={};if(S)for(let Y=0,z=S.length;Y<z;Y++){let X=S[Y],se=X.target.substring(1);R.texture[se]&&(q[X.target]=R.texture[se])}for(let Y=0;Y<V.length;Y++){let z=V[Y],X=T[z],se=Object.keys(X.resources.object);for(let re=0;re<se.length;re++){let le=se[re];W(le,b,X,q)}}return b}function de(R){for(let T=0;T<R.length;T++){let S=R[T];if(S.target.split(".").pop().toLowerCase()==="model")return S}}function ye(R,T){let S=new dn,b=de(T.rels),V=T.model[b.target.substring(1)].build;for(let q=0;q<V.length;q++){let Y=V[q],z=R[Y.objectId].clone(),X=Y.transform;X&&z.applyMatrix4(X),S.add(z)}return S}let Me=i(e),ve=ae(Me);return ye(ve,Me)}addExtension(e){this.availableExtensions.push(e)}};var Lh=class extends Dt{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new $n(s.manager);o.setPath(s.path),o.setResponseType("arraybuffer"),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(a))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){function t(x){let w=new DataView(x);if(String.fromCharCode(w.getUint8(0),w.getUint8(1))==="PK"){let E=null,M=null;console.log("THREE.AMFLoader: Loading Zip");try{E=xh(new Uint8Array(x))}catch(L){if(L instanceof ReferenceError)return console.log("THREE.AMFLoader: fflate missing and file is compressed."),null}for(M in E)if(M.toLowerCase().slice(-4)===".amf")break;console.log("THREE.AMFLoader: Trying to load file asset: "+M),w=new DataView(E[M].buffer)}let C=new TextDecoder().decode(w),P=new DOMParser().parseFromString(C,"application/xml");return P.documentElement.nodeName.toLowerCase()!=="amf"?(console.log("THREE.AMFLoader: Error loading AMF - no AMF document found."),null):P}function n(x){let w=1,I="millimeter";x.documentElement.attributes.unit!==void 0&&(I=x.documentElement.attributes.unit.value.toLowerCase());let C={millimeter:1,inch:25.4,feet:304.8,meter:1e3,micron:.001};return C[I]!==void 0&&(w=C[I]),console.log("THREE.AMFLoader: Unit scale: "+w),w}function i(x){let w="AMF Material",I=x.attributes.id.textContent,C={r:1,g:1,b:1,a:1},P=null;for(let E=0;E<x.childNodes.length;E++){let M=x.childNodes[E];M.nodeName==="metadata"&&M.attributes.type!==void 0?M.attributes.type.value==="name"&&(w=M.textContent):M.nodeName==="color"&&(C=s(M))}return P=new Zt({flatShading:!0,color:new Ve(C.r,C.g,C.b),name:w}),C.a!==1&&(P.transparent=!0,P.opacity=C.a),{id:I,material:P}}function s(x){let w={r:1,g:1,b:1,a:1};for(let I=0;I<x.childNodes.length;I++){let C=x.childNodes[I];C.nodeName==="r"?w.r=C.textContent:C.nodeName==="g"?w.g=C.textContent:C.nodeName==="b"?w.b=C.textContent:C.nodeName==="a"&&(w.a=C.textContent)}return w}function o(x){let w={name:"",triangles:[],materialid:null},I=x.firstElementChild;for(x.attributes.materialid!==void 0&&(w.materialId=x.attributes.materialid.nodeValue);I;){if(I.nodeName==="metadata")I.attributes.type!==void 0&&I.attributes.type.value==="name"&&(w.name=I.textContent);else if(I.nodeName==="triangle"){let C=I.getElementsByTagName("v1")[0].textContent,P=I.getElementsByTagName("v2")[0].textContent,E=I.getElementsByTagName("v3")[0].textContent;w.triangles.push(C,P,E)}I=I.nextElementSibling}return w}function a(x){let w=[],I=[],C=x.firstElementChild;for(;C;){if(C.nodeName==="vertex"){let P=C.firstElementChild;for(;P;){if(P.nodeName==="coordinates"){let E=P.getElementsByTagName("x")[0].textContent,M=P.getElementsByTagName("y")[0].textContent,L=P.getElementsByTagName("z")[0].textContent;w.push(E,M,L)}else if(P.nodeName==="normal"){let E=P.getElementsByTagName("nx")[0].textContent,M=P.getElementsByTagName("ny")[0].textContent,L=P.getElementsByTagName("nz")[0].textContent;I.push(E,M,L)}P=P.nextElementSibling}}C=C.nextElementSibling}return{vertices:w,normals:I}}function l(x){let w=x.attributes.id.textContent,I={name:"amfobject",meshes:[]},C=null,P=x.firstElementChild;for(;P;){if(P.nodeName==="metadata")P.attributes.type!==void 0&&P.attributes.type.value==="name"&&(I.name=P.textContent);else if(P.nodeName==="color")C=s(P);else if(P.nodeName==="mesh"){let E=P.firstElementChild,M={vertices:[],normals:[],volumes:[],color:C};for(;E;){if(E.nodeName==="vertices"){let L=a(E);M.normals=M.normals.concat(L.normals),M.vertices=M.vertices.concat(L.vertices)}else E.nodeName==="volume"&&M.volumes.push(o(E));E=E.nextElementSibling}I.meshes.push(M)}P=P.nextElementSibling}return{id:w,obj:I}}let c=t(e),u="",h="",f=n(c),p={},g={},v=c.documentElement.childNodes,d,m;for(d=0;d<v.length;d++){let x=v[d];if(x.nodeName==="metadata")x.attributes.type!==void 0&&(x.attributes.type.value==="name"?u=x.textContent:x.attributes.type.value==="author"&&(h=x.textContent));else if(x.nodeName==="material"){let w=i(x);p[w.id]=w.material}else if(x.nodeName==="object"){let w=l(x);g[w.id]=w.obj}}let _=new dn,y=new Zt({name:Dt.DEFAULT_MATERIAL_NAME,color:11184895,flatShading:!0});_.name=u,_.userData.author=h,_.userData.loader="AMF";for(let x in g){let w=g[x],I=w.meshes,C=new dn;for(C.name=w.name||"",d=0;d<I.length;d++){let P=y,E=I[d],M=new ze(E.vertices,3),L=null;if(E.normals.length&&(L=new ze(E.normals,3)),E.color){let O=E.color;P=y.clone(),P.color=new Ve(O.r,O.g,O.b),O.a!==1&&(P.transparent=!0,P.opacity=O.a)}let N=E.volumes;for(m=0;m<N.length;m++){let O=N[m],B=new St,ie=P;B.setIndex(O.triangles),B.setAttribute("position",M.clone()),L&&B.setAttribute("normal",L.clone()),p[O.materialId]!==void 0&&(ie=p[O.materialId]),B.scale(f,f,f),C.add(new Pt(B,ie.clone()))}}_.add(C)}return _}};var tr=class extends Ht{constructor(){super(),this.colorConverter=null}CreateLoader(e){return null}GetMainObject(e){return e}IsMeshVisible(e){return!0}ClearContent(){this.loader=null,this.materialIdToIndex=null,this.objectUrlToFileName=null}ResetContent(){this.loader=null,this.materialIdToIndex=new Map,this.objectUrlToFileName=new Map}ImportContent(e,t){this.LoadModel(e,t)}LoadModel(e,t){let n=!1,i=new Yl(()=>{n=!0}),s=Os(e);i.setURLModifier(a=>{if(a===s)return a;let l=En(a);if(ur(a).length>0){let u=this.callbacks.getFileBuffer(a);if(u!==null){let h=Os(u);return this.objectUrlToFileName.set(h,l),h}}return a});let o=this.CreateLoader(i);if(o===null){t();return}o.load(s,a=>{Nc(()=>n?(this.OnThreeObjectsLoaded(a,t),!1):!0)},()=>{},a=>{this.SetError(a),t()})}OnThreeObjectsLoaded(e,t){function n(a){let l=new fn().CreateIdentity();return a.updateMatrix(),a.matrix!==void 0&&a.matrix!==null&&l.Set(a.matrix.elements),new ln(l)}function i(a,l,c,u){let h=new Nn;c.name!==void 0&&h.SetName(c.name),h.SetTransformation(n(c)),u.AddChildNode(h);for(let f of c.children)i(a,l,f,h);if(c.isMesh&&a.IsMeshVisible(c)){let f=a.ConvertThreeMesh(c),p=l.AddMesh(f);h.AddMeshIndex(p)}}let s=this.GetMainObject(e),o=this.model.GetRootNode();o.SetTransformation(n(s));for(let a of s.children)i(this,this.model,a,o);t()}ConvertThreeMesh(e){let t=null;if(Array.isArray(e.material)){if(t=Zi(e.geometry,null,this.colorConverter),e.geometry.attributes.color===void 0||e.geometry.attributes.color===null){let n=[];for(let i=0;i<e.material.length;i++){let s=e.material[i],o=this.FindOrCreateMaterial(s);n.push(o)}for(let i=0;i<e.geometry.groups.length;i++){let s=e.geometry.groups[i],o=null;s.count===1/0?o=t.TriangleCount():o=s.start/3+s.count/3;for(let a=s.start/3;a<o;a++)t.GetTriangle(a).SetMaterial(n[s.materialIndex])}}}else{let n=this.FindOrCreateMaterial(e.material);t=Zi(e.geometry,n,this.colorConverter)}return e.name!==void 0&&e.name!==null&&t.SetName(e.name),t}FindOrCreateMaterial(e){if(this.materialIdToIndex.has(e.id))return this.materialIdToIndex.get(e.id);let t=this.ConvertThreeMaterial(e),n=null;return t!==null&&(n=this.model.AddMaterial(t)),this.materialIdToIndex.set(e.id,n),n}ConvertThreeMaterial(e){function t(i,s){function o(a){if(a.data!==void 0&&a.data!==null){let l=new ImageData(a.width,a.height),c=a.width*a.height*4;for(let u=0;u<c;u++)l.data[u]=a.data[u];return pa.getDataURL(l)}else return pa.getDataURL(a)}if(i==null||i.image===void 0||i.image===null)return null;try{let a=o(i.image),l=Ls(a),c=new ii,u=null;return s.has(i.image.src)?u=s.get(i.image.src):i.name!==void 0&&i.name!==null?u=i.name+"."+es(l.mimeType):u="Embedded_"+i.id.toString()+"."+es(l.mimeType),c.name=u,c.mimeType=l.mimeType,c.buffer=l.buffer,c.rotation=i.rotation,c.offset.x=i.offset.x,c.offset.y=i.offset.y,c.scale.x=i.repeat.x,c.scale.y=i.repeat.y,c}catch{return null}}if(e.name===Dt.DEFAULT_MATERIAL_NAME)return null;let n=new vn;return n.name=e.name,n.color=this.ConvertThreeColor(e.color),n.opacity=e.opacity,n.transparent=e.transparent,n.alphaTest=e.alphaTest,e.type==="MeshPhongMaterial"&&(n.specular=this.ConvertThreeColor(e.specular),n.shininess=e.shininess/100),n.diffuseMap=t(e.map,this.objectUrlToFileName),n.normalMap=t(e.normalMap,this.objectUrlToFileName),n.bumpMap=t(e.bumpMap,this.objectUrlToFileName),n}ConvertThreeColor(e){return this.colorConverter!==null&&(e=this.colorConverter.Convert(e)),Jl(e)}},Ha=class extends tr{constructor(){super(),this.colorConverter=new to}CanImportExtension(e){return e==="fbx"}GetUpDirection(){return pt.Y}CreateLoader(e){return e.addHandler(/\.tga$/i,new Es(e)),new Mh(e)}GetMainObject(e){return e}},Wa=class extends tr{constructor(){super()}CanImportExtension(e){return e==="dae"}GetUpDirection(){return pt.Y}CreateLoader(e){return e.addHandler(/\.tga$/i,new Es(e)),new Sh(e)}GetMainObject(e){return e.scene}},Xa=class extends tr{constructor(){super(),this.colorConverter=new to}CanImportExtension(e){return e==="wrl"}GetUpDirection(){return pt.Y}CreateLoader(e){return new Ph(e)}GetMainObject(e){return e}IsMeshVisible(e){let t=!0;if(Array.isArray(e.material)){for(let n=0;n<e.material.length;n++)if(e.material[n].side===Tn){t=!1;break}}else t=e.material.side!==Tn;return t}},ja=class extends tr{constructor(){super(),this.colorConverter=new Ra}CanImportExtension(e){return e==="3mf"}GetUpDirection(){return pt.Z}CreateLoader(e){return new Nh(e)}GetMainObject(e){return e}},qa=class extends tr{constructor(){super()}CanImportExtension(e){return e==="amf"}GetUpDirection(){return pt.Z}CreateLoader(e){return new Lh(e)}GetMainObject(e){return e}};var _i=Uint8Array,Ya=Uint16Array,NS=Int32Array,Z0=new _i([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),J0=new _i([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),LS=new _i([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$0=function(r,e){for(var t=new Ya(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new NS(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)i[s]=s-t[n]<<5|n;return{b:t,r:i}},Q0=$0(Z0,2),ev=Q0.b,OS=Q0.r;ev[28]=258,OS[258]=28;var tv=$0(J0,0),DS=tv.b,lP=tv.r,mp=new Ya(32768);for(kt=0;kt<32768;++kt)Yr=(kt&43690)>>1|(kt&21845)<<1,Yr=(Yr&52428)>>2|(Yr&13107)<<2,Yr=(Yr&61680)>>4|(Yr&3855)<<4,mp[kt]=((Yr&65280)>>8|(Yr&255)<<8)>>1;var Yr,kt,rc=function(r,e,t){for(var n=r.length,i=0,s=new Ya(e);i<n;++i)r[i]&&++s[r[i]-1];var o=new Ya(e);for(i=1;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(t){a=new Ya(1<<e);var l=15-e;for(i=0;i<n;++i)if(r[i])for(var c=i<<4|r[i],u=e-r[i],h=o[r[i]-1]++<<u,f=h|(1<<u)-1;h<=f;++h)a[mp[h]>>l]=c}else for(a=new Ya(n),i=0;i<n;++i)r[i]&&(a[i]=mp[o[r[i]-1]++]>>15-r[i]);return a},sc=new _i(288);for(kt=0;kt<144;++kt)sc[kt]=8;var kt;for(kt=144;kt<256;++kt)sc[kt]=9;var kt;for(kt=256;kt<280;++kt)sc[kt]=7;var kt;for(kt=280;kt<288;++kt)sc[kt]=8;var kt,nv=new _i(32);for(kt=0;kt<32;++kt)nv[kt]=5;var kt;var FS=rc(sc,9,1);var US=rc(nv,5,1),fp=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},nr=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},dp=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},kS=function(r){return(r+7)/8|0},vp=function(r,e,t){return(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new _i(r.subarray(e,t))};var BS=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Li=function(r,e,t){var n=new Error(e||BS[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,Li),!t)throw n;return n},GS=function(r,e,t,n){var i=r.length,s=n?n.length:0;if(!i||e.f&&!e.l)return t||new _i(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new _i(i*3));var c=function(z){var X=t.length;if(z>X){var se=new _i(Math.max(X*2,z));se.set(t),t=se}},u=e.f||0,h=e.p||0,f=e.b||0,p=e.l,g=e.d,v=e.m,d=e.n,m=i*8;do{if(!p){u=nr(r,h,1);var _=nr(r,h+1,3);if(h+=3,_)if(_==1)p=FS,g=US,v=9,d=5;else if(_==2){var I=nr(r,h,31)+257,C=nr(r,h+10,15)+4,P=I+nr(r,h+5,31)+1;h+=14;for(var E=new _i(P),M=new _i(19),L=0;L<C;++L)M[LS[L]]=nr(r,h+L*3,7);h+=C*3;for(var N=fp(M),O=(1<<N)-1,B=rc(M,N,1),L=0;L<P;){var ie=B[nr(r,h,O)];h+=ie&15;var y=ie>>4;if(y<16)E[L++]=y;else{var $=0,te=0;for(y==16?(te=3+nr(r,h,3),h+=2,$=E[L-1]):y==17?(te=3+nr(r,h,7),h+=3):y==18&&(te=11+nr(r,h,127),h+=7);te--;)E[L++]=$}}var W=E.subarray(0,I),ae=E.subarray(I);v=fp(W),d=fp(ae),p=rc(W,v,1),g=rc(ae,d,1)}else Li(1);else{var y=kS(h)+4,x=r[y-4]|r[y-3]<<8,w=y+x;if(w>i){l&&Li(0);break}a&&c(f+x),t.set(r.subarray(y,w),f),e.b=f+=x,e.p=h=w*8,e.f=u;continue}if(h>m){l&&Li(0);break}}a&&c(f+131072);for(var de=(1<<v)-1,ye=(1<<d)-1,Me=h;;Me=h){var $=p[dp(r,h)&de],ve=$>>4;if(h+=$&15,h>m){l&&Li(0);break}if($||Li(2),ve<256)t[f++]=ve;else if(ve==256){Me=h,p=null;break}else{var R=ve-254;if(ve>264){var L=ve-257,T=Z0[L];R=nr(r,h,(1<<T)-1)+ev[L],h+=T}var S=g[dp(r,h)&ye],b=S>>4;S||Li(3),h+=S&15;var ae=DS[b];if(b>3){var T=J0[b];ae+=dp(r,h)&(1<<T)-1,h+=T}if(h>m){l&&Li(0);break}a&&c(f+131072);var V=f+R;if(f<ae){var q=s-ae,Y=Math.min(ae,V);for(q+f<0&&Li(3);f<Y;++f)t[f]=n[q+f]}for(;f<V;++f)t[f]=t[f-ae]}}e.l=p,e.p=Me,e.b=f,e.f=u,p&&(u=1,e.m=v,e.d=g,e.n=d)}while(!u);return f!=t.length&&o?vp(t,0,f):t.subarray(0,f)};var VS=new _i(0);var Er=function(r,e){return r[e]|r[e+1]<<8},ir=function(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0},pp=function(r,e){return ir(r,e)+ir(r,e+4)*4294967296};function zS(r,e){return GS(r,{i:2},e&&e.out,e&&e.dictionary)}var gp=typeof TextDecoder<"u"&&new TextDecoder,HS=0;try{gp.decode(VS,{stream:!0}),HS=1}catch{}var WS=function(r){for(var e="",t=0;;){var n=r[t++],i=(n>127)+(n>223)+(n>239);if(t+i>r.length)return{s:e,r:vp(r,t-1)};i?i==3?(n=((n&15)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|r[t++]&63):e+=String.fromCharCode((n&15)<<12|(r[t++]&63)<<6|r[t++]&63):e+=String.fromCharCode(n)}};function XS(r,e){if(e){for(var t="",n=0;n<r.length;n+=16384)t+=String.fromCharCode.apply(null,r.subarray(n,n+16384));return t}else{if(gp)return gp.decode(r);var i=WS(r),s=i.s,t=i.r;return t.length&&Li(8),s}}var jS=function(r,e){return e+30+Er(r,e+26)+Er(r,e+28)},qS=function(r,e,t){var n=Er(r,e+28),i=XS(r.subarray(e+46,e+46+n),!(Er(r,e+8)&2048)),s=e+46+n,o=ir(r,e+20),a=t&&o==4294967295?YS(r,s):[o,ir(r,e+24),ir(r,e+42)],l=a[0],c=a[1],u=a[2];return[Er(r,e+10),l,c,i,s+Er(r,e+30)+Er(r,e+32),u]},YS=function(r,e){for(;Er(r,e)!=1;e+=4+Er(r,e+2));return[pp(r,e+12),pp(r,e+4),pp(r,e+20)]};function Oh(r,e){for(var t={},n=r.length-22;ir(r,n)!=101010256;--n)(!n||r.length-n>65558)&&Li(13);var i=Er(r,n+8);if(!i)return{};var s=ir(r,n+16),o=s==4294967295||i==65535;if(o){var a=ir(r,n-12);o=ir(r,a)==101075792,o&&(i=ir(r,a+32),s=ir(r,a+48))}for(var l=e&&e.filter,c=0;c<i;++c){var u=qS(r,s,o),h=u[0],f=u[1],p=u[2],g=u[3],v=u[4],d=u[5],m=jS(r,d);s=v,(!l||l({name:g,size:f,originalSize:p,compression:h}))&&(h?h==8?t[g]=zS(r.subarray(m,m+f),{out:new _i(p)}):Li(14,"unknown compression type "+h):t[g]=vp(r,m,m+f))}return t}var yp={Success:0,NoDocumentXml:1},xp=class{constructor(e,t){this.name=e,this.type=t,this.shapeName=null,this.isVisible=!1,this.color=null,this.fileName=null,this.fileContent=null,this.inLinkCount=0,this.properties=null}IsConvertible(){return!(this.fileName===null||this.fileContent===null||!this.isVisible||this.inLinkCount>0)}},_p=class{constructor(){this.files=null,this.properties=null,this.objectNames=[],this.objectData=new Map}Init(e){let t=new Uint8Array(e);return this.files=Oh(t),this.LoadDocumentXml()?(this.LoadGuiDocumentXml(),yp.Success):yp.NoDocumentXml}GetObjectListToConvert(){let e=[];for(let t of this.objectNames){let n=this.objectData.get(t);n.IsConvertible()&&e.push(n)}return e}IsSupportedType(e){return!(!e.startsWith("Part::")&&!e.startsWith("PartDesign::")||e.indexOf("Part2D")!==-1)}HasFile(e){return e in this.files}LoadDocumentXml(){let e=this.GetXMLContent("Document.xml");if(e===null)return!1;this.properties=new Vn(Ze("Properties"));let t=e.getElementsByTagName("Document");for(let s of t)for(let o of s.childNodes)o.tagName==="Properties"&&this.GetPropertiesFromElement(o,this.properties);let n=e.getElementsByTagName("Objects");for(let s of n){let o=s.getElementsByTagName("Object");for(let a of o){let l=a.getAttribute("name"),c=a.getAttribute("type");if(!this.IsSupportedType(c))continue;let u=new xp(l,c);this.objectNames.push(l),this.objectData.set(l,u)}}let i=e.getElementsByTagName("ObjectData");for(let s of i){let o=s.getElementsByTagName("Object");for(let a of o){let l=a.getAttribute("name");if(!this.objectData.has(l))continue;let c=this.objectData.get(l);c.properties=new Vn(Ze("Properties"));for(let f of a.childNodes)f.tagName==="Properties"&&this.GetPropertiesFromElement(f,c.properties);let u=a.getElementsByTagName("Property");for(let f of u){let p=f.getAttribute("name");if(p==="Label")c.shapeName=this.GetFirstChildValue(f,"String","value");else if(p==="Visibility"){let g=this.GetFirstChildValue(f,"Bool","value");c.isVisible=g==="true"}else if(p==="Visible"){let g=this.GetFirstChildValue(f,"Bool","value");c.isVisible=g==="true"}else if(p==="Shape"){let g=this.GetFirstChildValue(f,"Part","file");if(!this.HasFile(g))continue;let v=ur(g);if(v!=="brp"&&v!=="brep")continue;c.fileName=g,c.fileContent=this.files[g]}}let h=a.getElementsByTagName("Link");for(let f of h){let p=f.getAttribute("value");if(this.objectData.has(p)){let g=this.objectData.get(p);g.inLinkCount+=1}}}}return!0}LoadGuiDocumentXml(){let e=this.GetXMLContent("GuiDocument.xml");if(e===null)return!1;let t=e.getElementsByTagName("ViewProvider");for(let n of t){let i=n.getAttribute("name");if(!this.objectData.has(i))continue;let s=this.objectData.get(i),o=n.getElementsByTagName("Property");for(let a of o){let l=a.getAttribute("name");if(l==="Visibility"){let c=this.GetFirstChildValue(a,"Bool","value");s.isVisible=c==="true"}else if(l==="ShapeColor"){let c=this.GetFirstChildValue(a,"PropertyColor","value"),u=parseInt(c,10);s.color=new Rr(u>>24&255,u>>16&255,u>>8&255,255)}}}return!0}GetPropertiesFromElement(e,t){let n=e.getElementsByTagName("Property");for(let i of n){let s=i.getAttribute("name"),o=i.getAttribute("type"),a=null;if(o==="App::PropertyBool"){let l=this.GetFirstChildValue(i,"String","bool");l!==null&&l.length>0&&(a=new nn(Vt.Boolean,s,l==="true"))}else if(o==="App::PropertyInteger"){let l=this.GetFirstChildValue(i,"Integer","value");l!==null&&l.length>0&&(a=new nn(Vt.Integer,s,parseInt(l)))}else if(o==="App::PropertyString"){let l=this.GetFirstChildValue(i,"String","value");l!==null&&l.length>0&&(a=new nn(Vt.Text,s,l))}else if(o==="App::PropertyUUID"){let l=this.GetFirstChildValue(i,"Uuid","value");l!==null&&l.length>0&&(a=new nn(Vt.Text,s,l))}else if(o==="App::PropertyFloat"||o==="App::PropertyLength"||o==="App::PropertyDistance"||o==="App::PropertyArea"||o==="App::PropertyVolume"){let l=this.GetFirstChildValue(i,"Float","value");l!==null&&l.length>0&&(a=new nn(Vt.Number,s,parseFloat(l)))}a!==null&&t.AddProperty(a)}}GetXMLContent(e){if(!this.HasFile(e))return null;let t=new DOMParser,n=xn(this.files[e]);return t.parseFromString(n,"text/xml")}GetFirstChildValue(e,t,n){let i=e.getElementsByTagName(t);return i.length===0?null:i[0].getAttribute(n)}},Ka=class extends Ht{constructor(){super(),this.worker=null,this.document=null}CanImportExtension(e){return e==="fcstd"}GetUpDirection(){return pt.Z}ClearContent(){this.worker!==null&&(this.worker.terminate(),this.worker=null),this.document=null}ResetContent(){this.worker=null,this.document=new _p}ImportContent(e,t){if(this.document.Init(e)===yp.NoDocumentXml){this.SetError(Ze("No Document.xml found.")),t();return}this.document.properties!==null&&this.document.properties.PropertyCount()>0&&this.model.AddPropertyGroup(this.document.properties);let i=this.document.GetObjectListToConvert();if(i.length===0){this.SetError(Ze("No importable object found.")),t();return}this.ConvertObjects(i,t)}ConvertObjects(e,t){yo().then(n=>{this.worker=n,this.worker.addEventListener("message",l=>{o(l.data)}),this.worker.addEventListener("error",l=>{o(null)});let i=0,s=new ri(this.model),o=l=>{if(l!==null){let c=e[i];this.OnFileConverted(c,l,s)}if(i+=1,i===e.length)t();else{let c=e[i];this.worker.postMessage({format:"brep",buffer:c.fileContent})}},a=e[i];this.worker.postMessage({format:"brep",buffer:a.fileContent})}).catch(()=>{this.SetError(Ze("Failed to load occt-import-js.")),t()})}OnFileConverted(e,t,n){if(!t.success||t.meshes.length===0)return;let i=new Nn;e.shapeName!==null&&i.SetName(e.shapeName);let s=1;for(let a of t.meshes){let l=null;e.color!==null&&(l=n.GetMaterialIndex(e.color.r,e.color.g,e.color.b,e.color.a));let c=Zi(a,l,null);if(e.shapeName!==null){let h=s.toString().padStart(3,"0");c.SetName(e.shapeName+" "+h)}e.properties!==null&&e.properties.PropertyCount()>0&&c.AddPropertyGroup(e.properties);let u=this.model.AddMesh(c);i.AddMeshIndex(u),s+=1}this.model.GetRootNode().AddChildNode(i)}};var Za=class{constructor(){this.defaultLineColor=new Mt(100,100,100),this.defaultColor=new Mt(200,200,200)}},br={NoImportableFile:1,FailedToLoadFile:2,ImportFailed:3,UnknownError:4},bs=class{constructor(e){this.code=e,this.mainFile=null,this.message=null}},oc=class{constructor(){this.model=null,this.mainFile=null,this.upVector=null,this.usedFiles=null,this.missingFiles=null}},ac=class{constructor(e){this.getBufferCallback=e,this.fileBuffers=new Map}GetFileBuffer(e){let t=En(e);if(this.fileBuffers.has(t))return this.fileBuffers.get(t);let n=this.getBufferCallback(t);return this.fileBuffers.set(t,n),n}},Ja=class{constructor(){this.importers=[new Oa,new ka,new Da,new Fa,new Pa,new Na,new Ba,new Ia,new La,new Ua,new Ka,new Ha,new Wa,new Xa,new ja,new qa],this.fileList=new ks,this.model=null,this.usedFiles=[],this.missingFiles=[]}AddImporter(e){this.importers.push(e)}ImportFiles(e,t,n){n.onLoadStart(),this.LoadFiles(e,{onReady:()=>{n.onImportStart(),fl(()=>{this.DecompressArchives(this.fileList,()=>{this.ImportLoadedFiles(t,n)})})},onFileListProgress:n.onFileListProgress,onFileLoadProgress:n.onFileLoadProgress})}LoadFiles(e,t){let n=new ks;n.FillFromInputFiles(e);let i=!1;if(this.HasImportableFile(n))i=!0;else{let s=!1;for(let o=0;o<this.missingFiles.length;o++){let a=this.missingFiles[o];n.ContainsFileByPath(a)&&(s=!0)}s?(this.fileList.ExtendFromFileList(n),i=!1):i=!0}i&&(this.fileList=n),this.fileList.GetContent({onReady:t.onReady,onFileListProgress:t.onFileListProgress,onFileLoadProgress:t.onFileLoadProgress})}ImportLoadedFiles(e,t){let n=this.GetImportableFiles(this.fileList);if(n.length===0){t.onImportError(new bs(br.NoImportableFile));return}if(n.length===1||!t.onSelectMainFile){let i=n[0];this.ImportLoadedMainFile(i,e,t)}else{let i=n.map(s=>s.file.name);t.onSelectMainFile(i,s=>{if(s===null){t.onImportError(new bs(br.NoImportableFile));return}fl(()=>{let o=n[s];this.ImportLoadedMainFile(o,e,t)})})}}ImportLoadedMainFile(e,t,n){if(e===null||e.file===null||e.file.content===null){let o=new bs(br.FailedToLoadFile);e!==null&&e.file!==null&&(o.mainFile=e.file.name),n.onImportError(o);return}this.model=null,this.usedFiles=[],this.missingFiles=[],this.usedFiles.push(e.file.name);let i=e.importer,s=new ac(o=>{let a=null,l=this.fileList.FindFileByPath(o);return l===null||l.content===null?(this.missingFiles.push(o),a=null):(this.usedFiles.push(o),a=l.content),a});i.Import(e.file.name,e.file.extension,e.file.content,{getDefaultLineMaterialColor:()=>t.defaultLineColor,getDefaultMaterialColor:()=>t.defaultColor,getFileBuffer:o=>s.GetFileBuffer(o),onSuccess:()=>{this.model=i.GetModel();let o=new oc;o.mainFile=e.file.name,o.model=this.model,o.usedFiles=this.usedFiles,o.missingFiles=this.missingFiles,o.upVector=i.GetUpDirection(),n.onImportSuccess(o)},onError:()=>{let o=new bs(br.ImportFailed);o.mainFile=e.file.name,o.message=i.GetErrorMessage(),n.onImportError(o)},onComplete:()=>{i.Clear()}})}DecompressArchives(e,t){let n=e.GetFiles(),i=[];for(let s of n)s.extension==="zip"&&i.push(s);if(i.length===0){t();return}for(let s=0;s<i.length;s++){let o=i[s],a=new Uint8Array(o.content),l=Oh(a);for(let c in l)if(Object.prototype.hasOwnProperty.call(l,c)){let u=new Us(c,ki.Decompressed,null);u.SetContent(l[c].buffer),e.AddFile(u)}}t()}GetFileList(){return this.fileList}HasImportableFile(e){return this.GetImportableFiles(e).length>0}GetImportableFiles(e){function t(s,o){for(let a=0;a<o.length;a++){let l=o[a];if(l.CanImportExtension(s.extension))return l}return null}let n=[],i=e.GetFiles();for(let s=0;s<i.length;s++){let o=i[s],a=t(o,this.importers);a!==null&&n.push({file:o,importer:a})}return n}};var KS=jt,lc=class r extends Dt{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,i){let s=this,o=new $n(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(a))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t=this;function n(R,T){if(R.nodeType!==1)return;let S=x(R),b=!1,V=null;switch(R.nodeName){case"svg":T=g(R,T);break;case"style":s(R);break;case"g":T=g(R,T);break;case"path":T=g(R,T),R.hasAttribute("d")&&(V=i(R));break;case"rect":T=g(R,T),V=l(R);break;case"polygon":T=g(R,T),V=c(R);break;case"polyline":T=g(R,T),V=u(R);break;case"circle":T=g(R,T),V=h(R);break;case"ellipse":T=g(R,T),V=f(R);break;case"line":T=g(R,T),V=p(R);break;case"defs":b=!0;break;case"use":T=g(R,T);let z=(R.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),X=R.viewportElement.getElementById(z);X?n(X,T):console.warn("SVGLoader: 'use node' references non-existent node id: "+z);break;default:}V&&(T.fill!==void 0&&T.fill!=="none"&&V.color.setStyle(T.fill,KS),I(V,ye),N.push(V),V.userData={node:R,style:T});let q=R.childNodes;for(let Y=0;Y<q.length;Y++){let z=q[Y];b&&z.nodeName!=="style"&&z.nodeName!=="defs"||n(z,T)}S&&(B.pop(),B.length>0?ye.copy(B[B.length-1]):ye.identity())}function i(R){let T=new Tr,S=new Ce,b=new Ce,V=new Ce,q=!0,Y=!1,z=R.getAttribute("d");if(z===""||z==="none")return null;let X=z.match(/[a-df-z][^a-df-z]*/ig);for(let se=0,re=X.length;se<re;se++){let le=X[se],xe=le.charAt(0),G=le.slice(1).trim();q===!0&&(Y=!0,q=!1);let A;switch(xe){case"M":A=d(G);for(let U=0,he=A.length;U<he;U+=2)S.x=A[U+0],S.y=A[U+1],b.x=S.x,b.y=S.y,U===0?T.moveTo(S.x,S.y):T.lineTo(S.x,S.y),U===0&&V.copy(S);break;case"H":A=d(G);for(let U=0,he=A.length;U<he;U++)S.x=A[U],b.x=S.x,b.y=S.y,T.lineTo(S.x,S.y),U===0&&Y===!0&&V.copy(S);break;case"V":A=d(G);for(let U=0,he=A.length;U<he;U++)S.y=A[U],b.x=S.x,b.y=S.y,T.lineTo(S.x,S.y),U===0&&Y===!0&&V.copy(S);break;case"L":A=d(G);for(let U=0,he=A.length;U<he;U+=2)S.x=A[U+0],S.y=A[U+1],b.x=S.x,b.y=S.y,T.lineTo(S.x,S.y),U===0&&Y===!0&&V.copy(S);break;case"C":A=d(G);for(let U=0,he=A.length;U<he;U+=6)T.bezierCurveTo(A[U+0],A[U+1],A[U+2],A[U+3],A[U+4],A[U+5]),b.x=A[U+2],b.y=A[U+3],S.x=A[U+4],S.y=A[U+5],U===0&&Y===!0&&V.copy(S);break;case"S":A=d(G);for(let U=0,he=A.length;U<he;U+=4)T.bezierCurveTo(v(S.x,b.x),v(S.y,b.y),A[U+0],A[U+1],A[U+2],A[U+3]),b.x=A[U+0],b.y=A[U+1],S.x=A[U+2],S.y=A[U+3],U===0&&Y===!0&&V.copy(S);break;case"Q":A=d(G);for(let U=0,he=A.length;U<he;U+=4)T.quadraticCurveTo(A[U+0],A[U+1],A[U+2],A[U+3]),b.x=A[U+0],b.y=A[U+1],S.x=A[U+2],S.y=A[U+3],U===0&&Y===!0&&V.copy(S);break;case"T":A=d(G);for(let U=0,he=A.length;U<he;U+=2){let me=v(S.x,b.x),Te=v(S.y,b.y);T.quadraticCurveTo(me,Te,A[U+0],A[U+1]),b.x=me,b.y=Te,S.x=A[U+0],S.y=A[U+1],U===0&&Y===!0&&V.copy(S)}break;case"A":A=d(G,[3,4],7);for(let U=0,he=A.length;U<he;U+=7){if(A[U+5]==S.x&&A[U+6]==S.y)continue;let me=S.clone();S.x=A[U+5],S.y=A[U+6],b.x=S.x,b.y=S.y,o(T,A[U],A[U+1],A[U+2],A[U+3],A[U+4],me,S),U===0&&Y===!0&&V.copy(S)}break;case"m":A=d(G);for(let U=0,he=A.length;U<he;U+=2)S.x+=A[U+0],S.y+=A[U+1],b.x=S.x,b.y=S.y,U===0?T.moveTo(S.x,S.y):T.lineTo(S.x,S.y),U===0&&V.copy(S);break;case"h":A=d(G);for(let U=0,he=A.length;U<he;U++)S.x+=A[U],b.x=S.x,b.y=S.y,T.lineTo(S.x,S.y),U===0&&Y===!0&&V.copy(S);break;case"v":A=d(G);for(let U=0,he=A.length;U<he;U++)S.y+=A[U],b.x=S.x,b.y=S.y,T.lineTo(S.x,S.y),U===0&&Y===!0&&V.copy(S);break;case"l":A=d(G);for(let U=0,he=A.length;U<he;U+=2)S.x+=A[U+0],S.y+=A[U+1],b.x=S.x,b.y=S.y,T.lineTo(S.x,S.y),U===0&&Y===!0&&V.copy(S);break;case"c":A=d(G);for(let U=0,he=A.length;U<he;U+=6)T.bezierCurveTo(S.x+A[U+0],S.y+A[U+1],S.x+A[U+2],S.y+A[U+3],S.x+A[U+4],S.y+A[U+5]),b.x=S.x+A[U+2],b.y=S.y+A[U+3],S.x+=A[U+4],S.y+=A[U+5],U===0&&Y===!0&&V.copy(S);break;case"s":A=d(G);for(let U=0,he=A.length;U<he;U+=4)T.bezierCurveTo(v(S.x,b.x),v(S.y,b.y),S.x+A[U+0],S.y+A[U+1],S.x+A[U+2],S.y+A[U+3]),b.x=S.x+A[U+0],b.y=S.y+A[U+1],S.x+=A[U+2],S.y+=A[U+3],U===0&&Y===!0&&V.copy(S);break;case"q":A=d(G);for(let U=0,he=A.length;U<he;U+=4)T.quadraticCurveTo(S.x+A[U+0],S.y+A[U+1],S.x+A[U+2],S.y+A[U+3]),b.x=S.x+A[U+0],b.y=S.y+A[U+1],S.x+=A[U+2],S.y+=A[U+3],U===0&&Y===!0&&V.copy(S);break;case"t":A=d(G);for(let U=0,he=A.length;U<he;U+=2){let me=v(S.x,b.x),Te=v(S.y,b.y);T.quadraticCurveTo(me,Te,S.x+A[U+0],S.y+A[U+1]),b.x=me,b.y=Te,S.x=S.x+A[U+0],S.y=S.y+A[U+1],U===0&&Y===!0&&V.copy(S)}break;case"a":A=d(G,[3,4],7);for(let U=0,he=A.length;U<he;U+=7){if(A[U+5]==0&&A[U+6]==0)continue;let me=S.clone();S.x+=A[U+5],S.y+=A[U+6],b.x=S.x,b.y=S.y,o(T,A[U],A[U+1],A[U+2],A[U+3],A[U+4],me,S),U===0&&Y===!0&&V.copy(S)}break;case"Z":case"z":T.currentPath.autoClose=!0,T.currentPath.curves.length>0&&(S.copy(V),T.currentPath.currentPoint.copy(S),q=!0);break;default:console.warn(le)}Y=!1}return T}function s(R){if(!(!R.sheet||!R.sheet.cssRules||!R.sheet.cssRules.length))for(let T=0;T<R.sheet.cssRules.length;T++){let S=R.sheet.cssRules[T];if(S.type!==1)continue;let b=S.selectorText.split(/,/gm).filter(Boolean).map(V=>V.trim());for(let V=0;V<b.length;V++){let q=Object.fromEntries(Object.entries(S.style).filter(([,Y])=>Y!==""));O[b[V]]=Object.assign(O[b[V]]||{},q)}}}function o(R,T,S,b,V,q,Y,z){if(T==0||S==0){R.lineTo(z.x,z.y);return}b=b*Math.PI/180,T=Math.abs(T),S=Math.abs(S);let X=(Y.x-z.x)/2,se=(Y.y-z.y)/2,re=Math.cos(b)*X+Math.sin(b)*se,le=-Math.sin(b)*X+Math.cos(b)*se,xe=T*T,G=S*S,A=re*re,U=le*le,he=A/xe+U/G;if(he>1){let fe=Math.sqrt(he);T=fe*T,S=fe*S,xe=T*T,G=S*S}let me=xe*U+G*A,Te=(xe*G-me)/me,ee=Math.sqrt(Math.max(0,Te));V===q&&(ee=-ee);let k=ee*T*le/S,J=-ee*S*re/T,ue=Math.cos(b)*k-Math.sin(b)*J+(Y.x+z.x)/2,Z=Math.sin(b)*k+Math.cos(b)*J+(Y.y+z.y)/2,ce=a(1,0,(re-k)/T,(le-J)/S),pe=a((re-k)/T,(le-J)/S,(-re-k)/T,(-le-J)/S)%(Math.PI*2);R.currentPath.absellipse(ue,Z,T,S,ce,ce+pe,q===0,b)}function a(R,T,S,b){let V=R*S+T*b,q=Math.sqrt(R*R+T*T)*Math.sqrt(S*S+b*b),Y=Math.acos(Math.max(-1,Math.min(1,V/q)));return R*b-T*S<0&&(Y=-Y),Y}function l(R){let T=y(R.getAttribute("x")||0),S=y(R.getAttribute("y")||0),b=y(R.getAttribute("rx")||R.getAttribute("ry")||0),V=y(R.getAttribute("ry")||R.getAttribute("rx")||0),q=y(R.getAttribute("width")),Y=y(R.getAttribute("height")),z=1-.551915024494,X=new Tr;return X.moveTo(T+b,S),X.lineTo(T+q-b,S),(b!==0||V!==0)&&X.bezierCurveTo(T+q-b*z,S,T+q,S+V*z,T+q,S+V),X.lineTo(T+q,S+Y-V),(b!==0||V!==0)&&X.bezierCurveTo(T+q,S+Y-V*z,T+q-b*z,S+Y,T+q-b,S+Y),X.lineTo(T+b,S+Y),(b!==0||V!==0)&&X.bezierCurveTo(T+b*z,S+Y,T,S+Y-V*z,T,S+Y-V),X.lineTo(T,S+V),(b!==0||V!==0)&&X.bezierCurveTo(T,S+V*z,T+b*z,S,T+b,S),X}function c(R){function T(q,Y,z){let X=y(Y),se=y(z);V===0?b.moveTo(X,se):b.lineTo(X,se),V++}let S=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,b=new Tr,V=0;return R.getAttribute("points").replace(S,T),b.currentPath.autoClose=!0,b}function u(R){function T(q,Y,z){let X=y(Y),se=y(z);V===0?b.moveTo(X,se):b.lineTo(X,se),V++}let S=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,b=new Tr,V=0;return R.getAttribute("points").replace(S,T),b.currentPath.autoClose=!1,b}function h(R){let T=y(R.getAttribute("cx")||0),S=y(R.getAttribute("cy")||0),b=y(R.getAttribute("r")||0),V=new Wr;V.absarc(T,S,b,0,Math.PI*2);let q=new Tr;return q.subPaths.push(V),q}function f(R){let T=y(R.getAttribute("cx")||0),S=y(R.getAttribute("cy")||0),b=y(R.getAttribute("rx")||0),V=y(R.getAttribute("ry")||0),q=new Wr;q.absellipse(T,S,b,V,0,Math.PI*2);let Y=new Tr;return Y.subPaths.push(q),Y}function p(R){let T=y(R.getAttribute("x1")||0),S=y(R.getAttribute("y1")||0),b=y(R.getAttribute("x2")||0),V=y(R.getAttribute("y2")||0),q=new Tr;return q.moveTo(T,S),q.lineTo(b,V),q.currentPath.autoClose=!1,q}function g(R,T){T=Object.assign({},T);let S={};if(R.hasAttribute("class")){let Y=R.getAttribute("class").split(/\s/).filter(Boolean).map(z=>z.trim());for(let z=0;z<Y.length;z++)S=Object.assign(S,O["."+Y[z]])}R.hasAttribute("id")&&(S=Object.assign(S,O["#"+R.getAttribute("id")]));function b(Y,z,X){X===void 0&&(X=function(re){return re.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),re}),R.hasAttribute(Y)&&(T[z]=X(R.getAttribute(Y))),S[Y]&&(T[z]=X(S[Y])),R.style&&R.style[Y]!==""&&(T[z]=X(R.style[Y]))}function V(Y){return Math.max(0,Math.min(1,y(Y)))}function q(Y){return Math.max(0,y(Y))}return b("fill","fill"),b("fill-opacity","fillOpacity",V),b("fill-rule","fillRule"),b("opacity","opacity",V),b("stroke","stroke"),b("stroke-opacity","strokeOpacity",V),b("stroke-width","strokeWidth",q),b("stroke-linejoin","strokeLineJoin"),b("stroke-linecap","strokeLineCap"),b("stroke-miterlimit","strokeMiterLimit",q),b("visibility","visibility"),T}function v(R,T){return R-(T-R)}function d(R,T,S){if(typeof R!="string")throw new TypeError("Invalid input: "+typeof R);let b={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},V=0,q=1,Y=2,z=3,X=V,se=!0,re="",le="",xe=[];function G(me,Te,ee){let k=new SyntaxError('Unexpected character "'+me+'" at index '+Te+".");throw k.partial=ee,k}function A(){re!==""&&(le===""?xe.push(Number(re)):xe.push(Number(re)*Math.pow(10,Number(le)))),re="",le=""}let U,he=R.length;for(let me=0;me<he;me++){if(U=R[me],Array.isArray(T)&&T.includes(xe.length%S)&&b.FLAGS.test(U)){X=q,re=U,A();continue}if(X===V){if(b.WHITESPACE.test(U))continue;if(b.DIGIT.test(U)||b.SIGN.test(U)){X=q,re=U;continue}if(b.POINT.test(U)){X=Y,re=U;continue}b.COMMA.test(U)&&(se&&G(U,me,xe),se=!0)}if(X===q){if(b.DIGIT.test(U)){re+=U;continue}if(b.POINT.test(U)){re+=U,X=Y;continue}if(b.EXP.test(U)){X=z;continue}b.SIGN.test(U)&&re.length===1&&b.SIGN.test(re[0])&&G(U,me,xe)}if(X===Y){if(b.DIGIT.test(U)){re+=U;continue}if(b.EXP.test(U)){X=z;continue}b.POINT.test(U)&&re[re.length-1]==="."&&G(U,me,xe)}if(X===z){if(b.DIGIT.test(U)){le+=U;continue}if(b.SIGN.test(U)){if(le===""){le+=U;continue}le.length===1&&b.SIGN.test(le)&&G(U,me,xe)}}b.WHITESPACE.test(U)?(A(),X=V,se=!1):b.COMMA.test(U)?(A(),X=V,se=!0):b.SIGN.test(U)?(A(),X=q,re=U):b.POINT.test(U)?(A(),X=Y,re=U):G(U,me,xe)}return A(),xe}let m=["mm","cm","in","pt","pc","px"],_={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function y(R){let T="px";if(typeof R=="string"||R instanceof String)for(let b=0,V=m.length;b<V;b++){let q=m[b];if(R.endsWith(q)){T=q,R=R.substring(0,R.length-q.length);break}}let S;return T==="px"&&t.defaultUnit!=="px"?S=_.in[t.defaultUnit]/t.defaultDPI:(S=_[T][t.defaultUnit],S<0&&(S=_[T].in*t.defaultDPI)),S*parseFloat(R)}function x(R){if(!(R.hasAttribute("transform")||R.nodeName==="use"&&(R.hasAttribute("x")||R.hasAttribute("y"))))return null;let T=w(R);return B.length>0&&T.premultiply(B[B.length-1]),ye.copy(T),B.push(T),T}function w(R){let T=new ft,S=ie;if(R.nodeName==="use"&&(R.hasAttribute("x")||R.hasAttribute("y"))){let b=y(R.getAttribute("x")),V=y(R.getAttribute("y"));T.translate(b,V)}if(R.hasAttribute("transform")){let b=R.getAttribute("transform").split(")");for(let V=b.length-1;V>=0;V--){let q=b[V].trim();if(q==="")continue;let Y=q.indexOf("("),z=q.length;if(Y>0&&Y<z){let X=q.slice(0,Y),se=d(q.slice(Y+1));switch(S.identity(),X){case"translate":if(se.length>=1){let re=se[0],le=0;se.length>=2&&(le=se[1]),S.translate(re,le)}break;case"rotate":if(se.length>=1){let re=0,le=0,xe=0;re=se[0]*Math.PI/180,se.length>=3&&(le=se[1],xe=se[2]),$.makeTranslation(-le,-xe),te.makeRotation(re),W.multiplyMatrices(te,$),$.makeTranslation(le,xe),S.multiplyMatrices($,W)}break;case"scale":if(se.length>=1){let re=se[0],le=re;se.length>=2&&(le=se[1]),S.scale(re,le)}break;case"skewX":se.length===1&&S.set(1,Math.tan(se[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":se.length===1&&S.set(1,0,0,Math.tan(se[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":se.length===6&&S.set(se[0],se[2],se[4],se[1],se[3],se[5],0,0,1);break}}T.premultiply(S)}}return T}function I(R,T){function S(Y){de.set(Y.x,Y.y,1).applyMatrix3(T),Y.set(de.x,de.y)}function b(Y){let z=Y.xRadius,X=Y.yRadius,se=Math.cos(Y.aRotation),re=Math.sin(Y.aRotation),le=new oe(z*se,z*re,0),xe=new oe(-X*re,X*se,0),G=le.applyMatrix3(T),A=xe.applyMatrix3(T),U=ie.set(G.x,A.x,0,G.y,A.y,0,0,0,1),he=$.copy(U).invert(),ee=te.copy(he).transpose().multiply(he).elements,k=L(ee[0],ee[1],ee[4]),J=Math.sqrt(k.rt1),ue=Math.sqrt(k.rt2);if(Y.xRadius=1/J,Y.yRadius=1/ue,Y.aRotation=Math.atan2(k.sn,k.cs),!((Y.aEndAngle-Y.aStartAngle)%(2*Math.PI)<Number.EPSILON)){let ce=$.set(J,0,0,0,ue,0,0,0,1),pe=te.set(k.cs,k.sn,0,-k.sn,k.cs,0,0,0,1),fe=ce.multiply(pe).multiply(U),ge=Ae=>{let{x:Ie,y:Fe}=new oe(Math.cos(Ae),Math.sin(Ae),0).applyMatrix3(fe);return Math.atan2(Fe,Ie)};Y.aStartAngle=ge(Y.aStartAngle),Y.aEndAngle=ge(Y.aEndAngle),C(T)&&(Y.aClockwise=!Y.aClockwise)}}function V(Y){let z=E(T),X=M(T);Y.xRadius*=z,Y.yRadius*=X;let se=z>Number.EPSILON?Math.atan2(T.elements[1],T.elements[0]):Math.atan2(-T.elements[3],T.elements[4]);Y.aRotation+=se,C(T)&&(Y.aStartAngle*=-1,Y.aEndAngle*=-1,Y.aClockwise=!Y.aClockwise)}let q=R.subPaths;for(let Y=0,z=q.length;Y<z;Y++){let se=q[Y].curves;for(let re=0;re<se.length;re++){let le=se[re];le.isLineCurve?(S(le.v1),S(le.v2)):le.isCubicBezierCurve?(S(le.v0),S(le.v1),S(le.v2),S(le.v3)):le.isQuadraticBezierCurve?(S(le.v0),S(le.v1),S(le.v2)):le.isEllipseCurve&&(ae.set(le.aX,le.aY),S(ae),le.aX=ae.x,le.aY=ae.y,P(T)?b(le):V(le))}}}function C(R){let T=R.elements;return T[0]*T[4]-T[1]*T[3]<0}function P(R){let T=R.elements,S=T[0]*T[3]+T[1]*T[4];if(S===0)return!1;let b=E(R),V=M(R);return Math.abs(S/(b*V))>Number.EPSILON}function E(R){let T=R.elements;return Math.sqrt(T[0]*T[0]+T[1]*T[1])}function M(R){let T=R.elements;return Math.sqrt(T[3]*T[3]+T[4]*T[4])}function L(R,T,S){let b,V,q,Y,z,X=R+S,se=R-S,re=Math.sqrt(se*se+4*T*T);return X>0?(b=.5*(X+re),z=1/b,V=R*z*S-T*z*T):X<0?V=.5*(X-re):(b=.5*re,V=-.5*re),se>0?q=se+re:q=se-re,Math.abs(q)>2*Math.abs(T)?(z=-2*T/q,Y=1/Math.sqrt(1+z*z),q=z*Y):Math.abs(T)===0?(q=1,Y=0):(z=-.5*q/T,q=1/Math.sqrt(1+z*z),Y=z*q),se>0&&(z=q,q=-Y,Y=z),{rt1:b,rt2:V,cs:q,sn:Y}}let N=[],O={},B=[],ie=new ft,$=new ft,te=new ft,W=new ft,ae=new Ce,de=new oe,ye=new ft,Me=new DOMParser().parseFromString(e,"image/svg+xml");return n(Me.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:N,xml:Me.documentElement}}static createShapes(e){let n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},i={loc:n.ORIGIN,t:0};function s(v,d,m,_){let y=v.x,x=d.x,w=m.x,I=_.x,C=v.y,P=d.y,E=m.y,M=_.y,L=(I-w)*(C-E)-(M-E)*(y-w),N=(x-y)*(C-E)-(P-C)*(y-w),O=(M-E)*(x-y)-(I-w)*(P-C),B=L/O,ie=N/O;if(O===0&&L!==0||B<=0||B>=1||ie<0||ie>1)return null;if(L===0&&O===0){for(let $=0;$<2;$++)if(o($===0?m:_,v,d),i.loc==n.ORIGIN){let te=$===0?m:_;return{x:te.x,y:te.y,t:i.t}}else if(i.loc==n.BETWEEN){let te=+(y+i.t*(x-y)).toPrecision(10),W=+(C+i.t*(P-C)).toPrecision(10);return{x:te,y:W,t:i.t}}return null}else{for(let W=0;W<2;W++)if(o(W===0?m:_,v,d),i.loc==n.ORIGIN){let ae=W===0?m:_;return{x:ae.x,y:ae.y,t:i.t}}let $=+(y+B*(x-y)).toPrecision(10),te=+(C+B*(P-C)).toPrecision(10);return{x:$,y:te,t:B}}}function o(v,d,m){let _=m.x-d.x,y=m.y-d.y,x=v.x-d.x,w=v.y-d.y,I=_*w-x*y;if(v.x===d.x&&v.y===d.y){i.loc=n.ORIGIN,i.t=0;return}if(v.x===m.x&&v.y===m.y){i.loc=n.DESTINATION,i.t=1;return}if(I<-Number.EPSILON){i.loc=n.LEFT;return}if(I>Number.EPSILON){i.loc=n.RIGHT;return}if(_*x<0||y*w<0){i.loc=n.BEHIND;return}if(Math.sqrt(_*_+y*y)<Math.sqrt(x*x+w*w)){i.loc=n.BEYOND;return}let C;_!==0?C=x/_:C=w/y,i.loc=n.BETWEEN,i.t=C}function a(v,d){let m=[],_=[];for(let y=1;y<v.length;y++){let x=v[y-1],w=v[y];for(let I=1;I<d.length;I++){let C=d[I-1],P=d[I],E=s(x,w,C,P);E!==null&&m.find(M=>M.t<=E.t+Number.EPSILON&&M.t>=E.t-Number.EPSILON)===void 0&&(m.push(E),_.push(new Ce(E.x,E.y)))}}return _}function l(v,d,m){let _=new Ce;d.getCenter(_);let y=[];return m.forEach(x=>{x.boundingBox.containsPoint(_)&&a(v,x.points).forEach(I=>{y.push({identifier:x.identifier,isCW:x.isCW,point:I})})}),y.sort((x,w)=>x.point.x-w.point.x),y}function c(v,d,m,_,y){(y==null||y==="")&&(y="nonzero");let x=new Ce;v.boundingBox.getCenter(x);let w=[new Ce(m,x.y),new Ce(_,x.y)],I=l(w,v.boundingBox,d);I.sort((N,O)=>N.point.x-O.point.x);let C=[],P=[];I.forEach(N=>{N.identifier===v.identifier?C.push(N):P.push(N)});let E=C[0].point.x,M=[],L=0;for(;L<P.length&&P[L].point.x<E;)M.length>0&&M[M.length-1]===P[L].identifier?M.pop():M.push(P[L].identifier),L++;if(M.push(v.identifier),y==="evenodd"){let N=M.length%2===0,O=M[M.length-2];return{identifier:v.identifier,isHole:N,for:O}}else if(y==="nonzero"){let N=!0,O=null,B=null;for(let ie=0;ie<M.length;ie++){let $=M[ie];N?(B=d[$].isCW,N=!1,O=$):B!==d[$].isCW&&(B=d[$].isCW,N=!0)}return{identifier:v.identifier,isHole:N,for:O}}else console.warn('fill-rule: "'+y+'" is currently not implemented.')}let u=999999999,h=-999999999,f=e.subPaths.map(v=>{let d=v.getPoints(),m=-999999999,_=999999999,y=-999999999,x=999999999;for(let w=0;w<d.length;w++){let I=d[w];I.y>m&&(m=I.y),I.y<_&&(_=I.y),I.x>y&&(y=I.x),I.x<x&&(x=I.x)}return h<=y&&(h=y+1),u>=x&&(u=x-1),{curves:v.curves,points:d,isCW:Ai.isClockWise(d),identifier:-1,boundingBox:new sh(new Ce(x,_),new Ce(y,m))}});f=f.filter(v=>v.points.length>1);for(let v=0;v<f.length;v++)f[v].identifier=v;let p=f.map(v=>c(v,f,u,h,e.userData?e.userData.style.fillRule:void 0)),g=[];return f.forEach(v=>{if(!p[v.identifier].isHole){let m=new ds;m.curves=v.curves,p.filter(y=>y.isHole&&y.for===v.identifier).forEach(y=>{let x=f[y.identifier],w=new Wr;w.curves=x.curves,m.holes.push(w)}),g.push(m)}}),g}static getStrokeStyle(e,t,n,i,s){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",i=i!==void 0?i:"butt",s=s!==void 0?s:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:i,strokeMiterLimit:s}}static pointsToStroke(e,t,n,i){let s=[],o=[],a=[];if(r.pointsToStrokeWithBuffers(e,t,n,i,s,o,a)===0)return null;let l=new St;return l.setAttribute("position",new ze(s,3)),l.setAttribute("normal",new ze(o,3)),l.setAttribute("uv",new ze(a,2)),l}static pointsToStrokeWithBuffers(e,t,n,i,s,o,a,l){let c=new Ce,u=new Ce,h=new Ce,f=new Ce,p=new Ce,g=new Ce,v=new Ce,d=new Ce,m=new Ce,_=new Ce,y=new Ce,x=new Ce,w=new Ce,I=new Ce,C=new Ce,P=new Ce,E=new Ce;n=n!==void 0?n:12,i=i!==void 0?i:.001,l=l!==void 0?l:0,e=se(e);let M=e.length;if(M<2)return 0;let L=e[0].equals(e[M-1]),N,O=e[0],B,ie=t.strokeWidth/2,$=1/(M-1),te=0,W,ae,de,ye,Me=!1,ve=0,R=l*3,T=l*2;S(e[0],e[1],c).multiplyScalar(ie),d.copy(e[0]).sub(c),m.copy(e[0]).add(c),_.copy(d),y.copy(m);for(let re=1;re<M;re++){N=e[re],re===M-1?L?B=e[1]:B=void 0:B=e[re+1];let le=c;if(S(O,N,le),h.copy(le).multiplyScalar(ie),x.copy(N).sub(h),w.copy(N).add(h),W=te+$,ae=!1,B!==void 0){S(N,B,u),h.copy(u).multiplyScalar(ie),I.copy(N).sub(h),C.copy(N).add(h),de=!0,h.subVectors(B,O),le.dot(h)<0&&(de=!1),re===1&&(Me=de),h.subVectors(B,N),h.normalize();let xe=Math.abs(le.dot(h));if(xe>Number.EPSILON){let G=ie/xe;h.multiplyScalar(-G),f.subVectors(N,O),p.copy(f).setLength(G).add(h),P.copy(p).negate();let A=p.length(),U=f.length();f.divideScalar(U),g.subVectors(B,N);let he=g.length();switch(g.divideScalar(he),f.dot(P)<U&&g.dot(P)<he&&(ae=!0),E.copy(p).add(N),P.add(N),ye=!1,ae?de?(C.copy(P),w.copy(P)):(I.copy(P),x.copy(P)):q(),t.strokeLineJoin){case"bevel":Y(de,ae,W);break;case"round":z(de,ae),de?V(N,x,I,W,0):V(N,C,w,W,1);break;case"miter":case"miter-clip":default:let me=ie*t.strokeMiterLimit/A;if(me<1)if(t.strokeLineJoin!=="miter-clip"){Y(de,ae,W);break}else z(de,ae),de?(g.subVectors(E,x).multiplyScalar(me).add(x),v.subVectors(E,I).multiplyScalar(me).add(I),b(x,W,0),b(g,W,0),b(N,W,.5),b(N,W,.5),b(g,W,0),b(v,W,0),b(N,W,.5),b(v,W,0),b(I,W,0)):(g.subVectors(E,w).multiplyScalar(me).add(w),v.subVectors(E,C).multiplyScalar(me).add(C),b(w,W,1),b(g,W,1),b(N,W,.5),b(N,W,.5),b(g,W,1),b(v,W,1),b(N,W,.5),b(v,W,1),b(C,W,1));else ae?(de?(b(m,te,1),b(d,te,0),b(E,W,0),b(m,te,1),b(E,W,0),b(P,W,1)):(b(m,te,1),b(d,te,0),b(E,W,1),b(d,te,0),b(P,W,0),b(E,W,1)),de?I.copy(E):C.copy(E)):de?(b(x,W,0),b(E,W,0),b(N,W,.5),b(N,W,.5),b(E,W,0),b(I,W,0)):(b(w,W,1),b(E,W,1),b(N,W,.5),b(N,W,.5),b(E,W,1),b(C,W,1)),ye=!0;break}}else q()}else q();!L&&re===M-1&&X(e[0],_,y,de,!0,te),te=W,O=N,d.copy(I),m.copy(C)}if(!L)X(N,x,w,de,!1,W);else if(ae&&s){let re=E,le=P;Me!==de&&(re=P,le=E),de?(ye||Me)&&(le.toArray(s,0*3),le.toArray(s,3*3),ye&&re.toArray(s,1*3)):(ye||!Me)&&(le.toArray(s,1*3),le.toArray(s,3*3),ye&&re.toArray(s,0*3))}return ve;function S(re,le,xe){return xe.subVectors(le,re),xe.set(-xe.y,xe.x).normalize()}function b(re,le,xe){s&&(s[R]=re.x,s[R+1]=re.y,s[R+2]=0,o&&(o[R]=0,o[R+1]=0,o[R+2]=1),R+=3,a&&(a[T]=le,a[T+1]=xe,T+=2)),ve+=3}function V(re,le,xe,G,A){c.copy(le).sub(re).normalize(),u.copy(xe).sub(re).normalize();let U=Math.PI,he=c.dot(u);Math.abs(he)<1&&(U=Math.abs(Math.acos(he))),U/=n,h.copy(le);for(let me=0,Te=n-1;me<Te;me++)f.copy(h).rotateAround(re,U),b(h,G,A),b(f,G,A),b(re,G,.5),h.copy(f);b(f,G,A),b(xe,G,A),b(re,G,.5)}function q(){b(m,te,1),b(d,te,0),b(x,W,0),b(m,te,1),b(x,W,0),b(w,W,1)}function Y(re,le,xe){le?re?(b(m,te,1),b(d,te,0),b(x,W,0),b(m,te,1),b(x,W,0),b(P,W,1),b(x,xe,0),b(I,xe,0),b(P,xe,.5)):(b(m,te,1),b(d,te,0),b(w,W,1),b(d,te,0),b(P,W,0),b(w,W,1),b(w,xe,1),b(P,xe,0),b(C,xe,1)):re?(b(x,xe,0),b(I,xe,0),b(N,xe,.5)):(b(w,xe,1),b(C,xe,0),b(N,xe,.5))}function z(re,le){le&&(re?(b(m,te,1),b(d,te,0),b(x,W,0),b(m,te,1),b(x,W,0),b(P,W,1),b(x,te,0),b(N,W,.5),b(P,W,1),b(N,W,.5),b(I,te,0),b(P,W,1)):(b(m,te,1),b(d,te,0),b(w,W,1),b(d,te,0),b(P,W,0),b(w,W,1),b(w,te,1),b(P,W,0),b(N,W,.5),b(N,W,.5),b(P,W,0),b(C,te,1)))}function X(re,le,xe,G,A,U){switch(t.strokeLineCap){case"round":A?V(re,xe,le,U,.5):V(re,le,xe,U,.5);break;case"square":if(A)c.subVectors(le,re),u.set(c.y,-c.x),h.addVectors(c,u).add(re),f.subVectors(u,c).add(re),G?(h.toArray(s,1*3),f.toArray(s,0*3),f.toArray(s,3*3)):(h.toArray(s,1*3),a[3*2+1]===1?f.toArray(s,3*3):h.toArray(s,3*3),f.toArray(s,0*3));else{c.subVectors(xe,re),u.set(c.y,-c.x),h.addVectors(c,u).add(re),f.subVectors(u,c).add(re);let he=s.length;G?(h.toArray(s,he-1*3),f.toArray(s,he-2*3),f.toArray(s,he-4*3)):(f.toArray(s,he-2*3),h.toArray(s,he-1*3),f.toArray(s,he-4*3))}break;case"butt":default:break}}function se(re){let le=!1;for(let G=1,A=re.length-1;G<A;G++)if(re[G].distanceTo(re[G+1])<i){le=!0;break}if(!le)return re;let xe=[];xe.push(re[0]);for(let G=1,A=re.length-1;G<A;G++)re[G].distanceTo(re[G+1])>=i&&xe.push(re[G]);return xe.push(re[re.length-1]),xe}}};var Dh=class extends tr{constructor(){super()}CanImportExtension(e){return e==="svg"}GetUpDirection(){return pt.Z}CreateLoader(e){return new lc(e)}GetMainObject(e){function t(o){let a=o.userData.style;return!(a.fill===void 0||a.fill==="none")}function n(o,a,l){let c=null;for(let u of o)if(u.style===a&&u.opacity===l){c=u.material;break}return c===null&&(c=new Zt({color:new Ve().setStyle(a),opacity:l,transparent:l<1}),o.push({style:a,opacity:l,material:c})),c}let i=[],s=new Rt;s.rotation.x=Math.PI;for(let o of e.paths){let a=lc.createShapes(o);if(t(o)){let l=o.userData.style,c=n(i,l.fill,l.opacity);for(let u of a){let h=new $u(u,{depth:10,bevelEnabled:!1}),f=new Pt(h,c);f.name=o.userData.node.id,s.add(f)}}}return s}};var cc=class{constructor(){this.name=null,this.material=null}SetName(e){return this.name=e,this}SetMaterial(e){return this.material=e,this}},Ss=class{constructor(e){this.params=e||new cc,this.mesh=new Kt,this.params.name!==null&&this.mesh.SetName(this.params.name),this.curve=null}GetMesh(){return this.mesh}AddVertex(e,t,n){let i=new Xe(e,t,n);return this.mesh.AddVertex(i)}AddVertices(e){let t=[];for(let n=0;n<e.length;n++){let i=e[n];t.push(this.AddVertex(i.x,i.y,i.z))}return t}SetCurve(e){this.curve=e}ResetCurve(){this.curve=null}AddTriangle(e,t,n){let i=new Xt(e,t,n);return this.params.material!==null&&(i.mat=this.params.material),this.curve!==null&&i.SetCurve(this.curve),this.mesh.AddTriangle(i)}AddTriangleInverted(e,t,n){this.AddTriangle(e,n,t)}AddConvexPolygon(e){for(let t=0;t<e.length-2;t++)this.AddTriangle(e[0],e[t+1],e[t+2])}AddConvexPolygonInverted(e){for(let t=0;t<e.length-2;t++)this.AddTriangleInverted(e[0],e[t+1],e[t+2])}},$a=class{constructor(e){this.generator=e}GenerateSurfaceBetweenPolygons(e,t){if(e.length!==t.length)return;let n=e.length;for(let i=0;i<n;i++){let s=i,o=i<n-1?s+1:0;this.generator.AddConvexPolygon([e[s],e[o],t[o],t[s]])}}GenerateTriangleFan(e,t){let n=e.length;for(let i=0;i<n;i++){let s=i,o=i<n-1?s+1:0;this.generator.AddTriangle(t,e[s],e[o])}}};function rv(r,e){return new At(r*Math.cos(e),r*Math.sin(e))}function sv(r,e,t,n){if(!Ti(e)||!Ti(t)||!Ti(n))return null;let i=new Ss(r);return i.AddVertex(0,0,0),i.AddVertex(e,0,0),i.AddVertex(e,t,0),i.AddVertex(0,t,0),i.AddVertex(0,0,n),i.AddVertex(e,0,n),i.AddVertex(e,t,n),i.AddVertex(0,t,n),i.AddConvexPolygon([0,3,2,1]),i.AddConvexPolygon([0,1,5,4]),i.AddConvexPolygon([1,2,6,5]),i.AddConvexPolygon([2,3,7,6]),i.AddConvexPolygon([3,0,4,7]),i.AddConvexPolygon([4,5,6,7]),i.GetMesh()}function Tp(r,e,t,n,i,s){if(Cr(e)||Cr(t)||!Ti(n)||i<3)return null;let o=wr(e),a=wr(t);if(o&&a)return null;let l=new Ss(r),c=new $a(l),u=2*Math.PI/i,h=s?1:null,f=[];if(o)f.push(l.AddVertex(0,0,n));else for(let g=0;g<i;g++){let v=rv(e,g*u);f.push(l.AddVertex(v.x,v.y,n))}let p=[];if(a)p.push(l.AddVertex(0,0,0));else for(let g=0;g<i;g++){let v=rv(t,g*u);p.push(l.AddVertex(v.x,v.y,0))}return o?(l.SetCurve(h),c.GenerateTriangleFan(p,f[0]),l.ResetCurve(),l.AddConvexPolygonInverted(p)):a?(l.SetCurve(h),c.GenerateTriangleFan(f.slice().reverse(),p[0]),l.ResetCurve(),l.AddConvexPolygon(f)):(l.SetCurve(h),c.GenerateSurfaceBetweenPolygons(p,f),l.ResetCurve(),l.AddConvexPolygonInverted(p),l.AddConvexPolygon(f)),l.GetMesh()}function ov(r,e,t,n,i){return Tp(r,e,e,t,n,i)}function av(r,e,t,n){function i(p,g,v){return new Xe(p*Math.sin(g)*Math.cos(v),p*Math.sin(g)*Math.sin(v),p*Math.cos(g))}if(!Ti(e)||t<3)return null;let s=new Ss(r),o=new $a(s);s.SetCurve(n?1:null);let a=[],l=t+1,c=Math.PI/t,u=2*Math.PI/t;for(let p=1;p<l-1;p++){let g=[],v=p*c;for(let d=0;d<t;d++){let m=d*u,_=i(e,v,-m);g.push(s.AddVertex(_.x,_.y,_.z))}p>1&&o.GenerateSurfaceBetweenPolygons(a[a.length-1],g),a.push(g)}let h=s.AddVertex(0,0,e),f=s.AddVertex(0,0,-e);return o.GenerateTriangleFan(a[0].slice().reverse(),h),o.GenerateTriangleFan(a[a.length-1],f),s.ResetCurve(),s.GetMesh()}function lv(r,e,t){function n(s,o,a,l,c){let u=new Xe(a,l,c);u.MultiplyScalar(o/u.Length()),s.AddVertex(u.x,u.y,u.z)}if(!Ti(t))return null;let i=new Ss(r);if(e==="tetrahedron"){let s=1;n(i,t,+s,+s,+s),n(i,t,-s,-s,+s),n(i,t,-s,+s,-s),n(i,t,+s,-s,-s),i.AddTriangle(0,1,3),i.AddTriangle(0,2,1),i.AddTriangle(0,3,2),i.AddTriangle(1,2,3)}else if(e==="hexahedron"){let s=1;n(i,t,+s,+s,+s),n(i,t,+s,+s,-s),n(i,t,+s,-s,+s),n(i,t,+s,-s,-s),n(i,t,-s,+s,+s),n(i,t,-s,+s,-s),n(i,t,-s,-s,+s),n(i,t,-s,-s,-s),i.AddConvexPolygon([0,1,5,4]),i.AddConvexPolygon([0,2,3,1]),i.AddConvexPolygon([0,4,6,2]),i.AddConvexPolygon([1,3,7,5]),i.AddConvexPolygon([2,6,7,3]),i.AddConvexPolygon([4,5,7,6])}else if(e==="octahedron"){let s=1,o=0;n(i,t,+s,+o,+o),n(i,t,-s,+o,+o),n(i,t,+o,+s,+o),n(i,t,+o,-s,+o),n(i,t,+o,+o,+s),n(i,t,+o,+o,-s),i.AddTriangle(0,2,4),i.AddTriangle(0,3,5),i.AddTriangle(0,4,3),i.AddTriangle(0,5,2),i.AddTriangle(1,2,5),i.AddTriangle(1,3,4),i.AddTriangle(1,4,2),i.AddTriangle(1,5,3)}else if(e==="dodecahedron"){let s=1,o=0,a=(1+Math.sqrt(5))/2,l=1/a;n(i,t,+s,+s,+s),n(i,t,+s,+s,-s),n(i,t,+s,-s,+s),n(i,t,-s,+s,+s),n(i,t,+s,-s,-s),n(i,t,-s,+s,-s),n(i,t,-s,-s,+s),n(i,t,-s,-s,-s),n(i,t,+o,+l,+a),n(i,t,+o,+l,-a),n(i,t,+o,-l,+a),n(i,t,+o,-l,-a),n(i,t,+l,+a,+o),n(i,t,+l,-a,+o),n(i,t,-l,+a,+o),n(i,t,-l,-a,+o),n(i,t,+a,+o,+l),n(i,t,-a,+o,+l),n(i,t,+a,+o,-l),n(i,t,-a,+o,-l),i.AddConvexPolygon([0,8,10,2,16]),i.AddConvexPolygon([0,16,18,1,12]),i.AddConvexPolygon([0,12,14,3,8]),i.AddConvexPolygon([1,9,5,14,12]),i.AddConvexPolygon([1,18,4,11,9]),i.AddConvexPolygon([2,10,6,15,13]),i.AddConvexPolygon([2,13,4,18,16]),i.AddConvexPolygon([3,14,5,19,17]),i.AddConvexPolygon([3,17,6,10,8]),i.AddConvexPolygon([4,13,15,7,11]),i.AddConvexPolygon([5,9,11,7,19]),i.AddConvexPolygon([6,17,19,7,15])}else if(e==="icosahedron"){let s=1,o=0,a=(1+Math.sqrt(5))/2;n(i,t,+o,+s,+a),n(i,t,+o,+s,-a),n(i,t,+o,-s,+a),n(i,t,+o,-s,-a),n(i,t,+s,+a,+o),n(i,t,+s,-a,+o),n(i,t,-s,+a,+o),n(i,t,-s,-a,+o),n(i,t,+a,+o,+s),n(i,t,+a,+o,-s),n(i,t,-a,+o,+s),n(i,t,-a,+o,-s),i.AddTriangle(0,2,8),i.AddTriangle(0,4,6),i.AddTriangle(0,6,10),i.AddTriangle(0,8,4),i.AddTriangle(0,10,2),i.AddTriangle(1,3,11),i.AddTriangle(1,4,9),i.AddTriangle(1,6,4),i.AddTriangle(1,9,3),i.AddTriangle(1,11,6),i.AddTriangle(2,5,8),i.AddTriangle(2,7,5),i.AddTriangle(2,10,7),i.AddTriangle(3,5,7),i.AddTriangle(3,7,11),i.AddTriangle(3,9,5),i.AddTriangle(4,8,9),i.AddTriangle(5,9,8),i.AddTriangle(6,11,10),i.AddTriangle(7,10,11)}return i.GetMesh()}function Mp(r,e,t){let n=Yn(r,e),i=Yn(e,t),s=Yn(r,t),o=(n+i+s)/2,a=o*(o-n)*(o-i)*(o-s);return a<0?0:Math.sqrt(a)}function Ep(r,e,t){return ml(r,Bi(e,t))/6}function bp(r){if(r instanceof dr){let e=0;return r.EnumerateMeshInstances(t=>{e+=bp(t)}),e}else{let e=0;return r.EnumerateTriangleVertices((t,n,i)=>{e+=Ep(t,n,i)}),e}}function cv(r){let e=0;return r.EnumerateTriangleVertices((t,n,i)=>{e+=Mp(t,n,i)}),e}var As={FixedUpVector:1,FreeOrbit:2},Xn={Perspective:1,Orthographic:2},Sr=class r{constructor(e,t,n,i){this.eye=e,this.center=t,this.up=n,this.fov=i}Clone(){return new r(this.eye.Clone(),this.center.Clone(),this.up.Clone(),this.fov)}};function Fh(r,e){return pi(r.eye,e.eye)&&pi(r.center,e.center)&&pi(r.up,e.up)&&It(r.fov,e.fov)}var ZS=10,Sp={MeshOnly:1,MeshAndLine:2};function Ap(r,e){function t(n,i){for(let s of n)s.polygonOffset=i,s.polygonOffsetUnit=1,s.polygonOffsetFactor=1}t(r.material,e),r.userData.threeMaterials&&t(r.userData.threeMaterials,e)}var ws=class{constructor(e){this.scene=e,this.rootObject=null}IsEmpty(){return this.rootObject===null}SetRootObject(e){this.rootObject!==null&&this.Clear(),this.rootObject=e,this.scene.add(this.rootObject)}GetRootObject(){return this.rootObject}AddObject(e){if(this.rootObject===null){let t=new Rt;this.SetRootObject(t)}this.rootObject.add(e)}Traverse(e){this.rootObject!==null&&this.rootObject.traverse(t=>{e(t)})}UpdateWorldMatrix(){this.rootObject!==null&&this.rootObject.updateWorldMatrix(!0,!0)}Clear(){mh(this.rootObject),this.scene.remove(this.rootObject),this.rootObject=null}},ro=class r{constructor(e,t,n){this.showEdges=e,this.edgeColor=t,this.edgeThreshold=n}Clone(){return new r(this.showEdges,this.edgeColor.Clone(),this.edgeThreshold)}},Qa=class{constructor(e){this.scene=e,this.mainModel=new ws(this.scene),this.edgeModel=new ws(this.scene),this.edgeSettings=new ro(!1,new Mt(0,0,0),1),this.hasLines=!1,this.hasPolygonOffset=!1}SetMainObject(e){this.mainModel.SetRootObject(e),this.hasLines=!1,this.hasPolygonOffset=!1,this.EnumerateLines(t=>{this.hasLines=!0}),this.edgeSettings.showEdges&&this.GenerateEdgeModel(),this.UpdatePolygonOffset()}UpdateWorldMatrix(){this.mainModel.UpdateWorldMatrix(),this.edgeModel.UpdateWorldMatrix()}SetEdgeSettings(e){let t=!1;if(e.showEdges&&(!this.edgeSettings.showEdges||this.edgeSettings.edgeThreshold!==e.edgeThreshold)&&(t=!0),this.edgeSettings=e,!this.mainModel.IsEmpty())if(this.edgeSettings.showEdges)if(t)this.ClearEdgeModel(),this.GenerateEdgeModel();else{let n=wn(this.edgeSettings.edgeColor);this.EnumerateEdges(i=>{i.material.color=n})}else this.ClearEdgeModel()}GenerateEdgeModel(){let e=wn(this.edgeSettings.edgeColor);this.UpdateWorldMatrix(),this.EnumerateMeshes(t=>{let n=new Ju(t.geometry,this.edgeSettings.edgeThreshold),i=new yr(n,new Wn({color:e}));i.applyMatrix4(t.matrixWorld),i.userData=t.userData,i.visible=t.visible,this.edgeModel.AddObject(i)}),this.UpdatePolygonOffset()}GetBoundingBox(e){let t=!1,n=new ji;return this.EnumerateMeshesAndLines(i=>{e(i.userData)&&(n.union(new ji().setFromObject(i)),t=!0)}),t?n:null}GetBoundingSphere(e){let t=this.GetBoundingBox(e);if(t===null)return null;let n=new qi;return t.getBoundingSphere(n),n}Clear(){this.mainModel.Clear(),this.ClearEdgeModel()}ClearEdgeModel(){this.edgeModel.IsEmpty()||(this.UpdatePolygonOffset(),this.edgeModel.Clear())}EnumerateMeshes(e){this.mainModel.Traverse(t=>{t.isMesh&&e(t)})}EnumerateLines(e){this.mainModel.Traverse(t=>{t.isLineSegments&&e(t)})}EnumerateMeshesAndLines(e){this.mainModel.Traverse(t=>{(t.isMesh||t.isLineSegments)&&e(t)})}EnumerateEdges(e){this.edgeModel.Traverse(t=>{t.isLineSegments&&e(t)})}HasLinesOrEdges(){return this.hasLines||this.edgeSettings.showEdges}UpdatePolygonOffset(){let e=this.HasLinesOrEdges();e!==this.hasPolygonOffset&&(this.EnumerateMeshes(t=>{Ap(t,e)}),this.hasPolygonOffset=e)}GetMeshIntersectionUnderMouse(e,t,n,i,s){if(this.mainModel.IsEmpty()||t.x<0||t.x>i||t.y<0||t.y>s)return null;let o=new Ce;o.x=t.x/i*2-1,o.y=-(t.y/s)*2+1;let a=new rh;a.setFromCamera(o,n),a.params.Line.threshold=10;let l=a.intersectObject(this.mainModel.GetRootObject(),!0);for(let c=0;c<l.length;c++){let u=l[c];if(u.object.visible){if(u.object.isMesh)return u;if(u.object.isLineSegments){if(e===Sp.MeshOnly||gh(n,i,s,u.object,t)>ZS)continue;return u}}}return null}};var Jt={IntegerToString(r){return r.toString()},StringToInteger(r){return parseInt(r,10)},NumberToString(r){return r.toFixed(5)},StringToNumber(r){return parseFloat(r)},ModelUrlsToString:function(r){return r===null?null:r.join(",")},StringToModelUrls:function(r){return r===null||r.length===0?null:r.split(",")},CameraToString:function(r){return r===null?null:[this.NumberToString(r.eye.x),this.NumberToString(r.eye.y),this.NumberToString(r.eye.z),this.NumberToString(r.center.x),this.NumberToString(r.center.y),this.NumberToString(r.center.z),this.NumberToString(r.up.x),this.NumberToString(r.up.y),this.NumberToString(r.up.z),this.NumberToString(r.fov)].join(",")},ProjectionModeToString:function(r){return r===Xn.Perspective?"perspective":r===Xn.Orthographic?"orthographic":null},StringToCamera:function(r){if(r===null||r.length===0)return null;let e=r.split(",");if(e.length!==9&&e.length!==10)return null;let t=45;return e.length>=10&&(t=this.StringToNumber(e[9])),new Sr(new Xe(this.StringToNumber(e[0]),this.StringToNumber(e[1]),this.StringToNumber(e[2])),new Xe(this.StringToNumber(e[3]),this.StringToNumber(e[4]),this.StringToNumber(e[5])),new Xe(this.StringToNumber(e[6]),this.StringToNumber(e[7]),this.StringToNumber(e[8])),t)},StringToProjectionMode:function(r){return r==="perspective"?Xn.Perspective:r==="orthographic"?Xn.Orthographic:null},RGBColorToString:function(r){return r===null?null:[this.IntegerToString(r.r),this.IntegerToString(r.g),this.IntegerToString(r.b)].join(",")},RGBAColorToString:function(r){return r===null?null:[this.IntegerToString(r.r),this.IntegerToString(r.g),this.IntegerToString(r.b),this.IntegerToString(r.a)].join(",")},StringToRGBColor:function(r){if(r===null||r.length===0)return null;let e=r.split(",");return e.length!==3?null:new Mt(this.StringToInteger(e[0]),this.StringToInteger(e[1]),this.StringToInteger(e[2]))},StringToRGBAColor:function(r){if(r===null||r.length===0)return null;let e=r.split(",");if(e.length!==3&&e.length!==4)return null;let t=new Rr(this.StringToInteger(e[0]),this.StringToInteger(e[1]),this.StringToInteger(e[2]),255);return e.length===4&&(t.a=this.StringToInteger(e[3])),t},EnvironmentSettingsToString(r){return r===null?null:[r.environmentMapName,r.backgroundIsEnvMap?"on":"off"].join(",")},StringToEnvironmentSettings:function(r){if(r===null||r.length===0)return null;let e=r.split(",");return e.length!==2?null:{environmentMapName:e[0],backgroundIsEnvMap:e[1]==="on"}},EdgeSettingsToString:function(r){return r===null?null:[r.showEdges?"on":"off",this.RGBColorToString(r.edgeColor),this.IntegerToString(r.edgeThreshold)].join(",")},StringToEdgeSettings:function(r){if(r===null||r.length===0)return null;let e=r.split(",");return e.length!==5?null:new ro(e[0]==="on",new Mt(this.StringToInteger(e[1]),this.StringToInteger(e[2]),this.StringToInteger(e[3])),this.StringToInteger(e[4]))}},uc=class{constructor(e){this.separator=e,this.paramList=""}AddModelUrls(e){return this.AddUrlPart("model",Jt.ModelUrlsToString(e)),this}AddCamera(e){return this.AddUrlPart("camera",Jt.CameraToString(e)),this}AddProjectionMode(e){return this.AddUrlPart("projectionmode",Jt.ProjectionModeToString(e)),this}AddEnvironmentSettings(e){return this.AddUrlPart("envsettings",Jt.EnvironmentSettingsToString(e)),this}AddBackgroundColor(e){return this.AddUrlPart("backgroundcolor",Jt.RGBAColorToString(e)),this}AddDefaultColor(e){return this.AddUrlPart("defaultcolor",Jt.RGBColorToString(e)),this}AddDefaultLineColor(e){return this.AddUrlPart("defaultlinecolor",Jt.RGBColorToString(e)),this}AddEdgeSettings(e){return this.AddUrlPart("edgesettings",Jt.EdgeSettingsToString(e)),this}AddUrlPart(e,t){e===null||t===null||(this.paramList.length>0&&(this.paramList+=this.separator),this.paramList+=e+"="+t)}GetParameterList(){return this.paramList}},hc=class{constructor(e,t){this.separator=t,this.paramList=e}GetModelUrls(){if(this.paramList.indexOf("=")===-1)return this.paramList.split(",");let e=this.GetKeywordParams("model");return Jt.StringToModelUrls(e)}GetCamera(){let e=this.GetKeywordParams("camera");return Jt.StringToCamera(e)}GetProjectionMode(){let e=this.GetKeywordParams("cameramode");return e===null&&(e=this.GetKeywordParams("projectionmode")),Jt.StringToProjectionMode(e)}GetEnvironmentSettings(){let e=this.GetKeywordParams("envsettings");return Jt.StringToEnvironmentSettings(e)}GetBackgroundColor(){let e=this.GetKeywordParams("backgroundcolor");return Jt.StringToRGBAColor(e)}GetDefaultColor(){let e=this.GetKeywordParams("defaultcolor");return Jt.StringToRGBColor(e)}GetDefaultLineColor(){let e=this.GetKeywordParams("defaultlinecolor");return Jt.StringToRGBColor(e)}GetEdgeSettings(){let e=this.GetKeywordParams("edgesettings");return Jt.StringToEdgeSettings(e)}GetKeywordParams(e){if(this.paramList===null||this.paramList.length===0)return null;let t=e+"=",n=this.paramList.split(this.separator);for(let i=0;i<n.length;i++){let s=n[i];if(s.startsWith(t))return s.substring(t.length)}return null}};function wp(){return new uc("$")}function uv(r){return new hc(r,"$")}function hv(r){let e=wp();return e.AddModelUrls(r),e.GetParameterList()}var Cs={Line:1,Face:2},el=class{constructor(){this.forceMediumpForMaterials=!1}},tl=class{constructor(){this.defaultMaterials=[],this.objectUrls=[]}},fc=class{constructor(e){this.callbacks=e,this.texturesNeeded=0,this.texturesLoaded=0,this.threeObject=null}OnTextureNeeded(){this.texturesNeeded+=1}OnTextureLoaded(){this.texturesLoaded+=1,this.callbacks.onTextureLoaded(),this.Finish()}OnModelLoaded(e){this.threeObject=e,this.Finish()}Finish(){this.threeObject!==null&&this.texturesNeeded===this.texturesLoaded&&this.callbacks.onModelLoaded(this.threeObject)}},dc=class{constructor(e,t){this.model=e,this.threeNodeItems=[],this.AddNode(e.GetRootNode(),t)}AddNode(e,t){let n=e.GetTransformation().GetMatrix(),i=new Ye().fromArray(n.Get());t.applyMatrix4(i);for(let s of e.GetChildNodes()){let o=new Rt;t.add(o),this.AddNode(s,o)}for(let s of e.GetMeshIndices()){let o=new bi(e.GetId(),s),a=this.model.GetMesh(s);this.threeNodeItems.push({meshInstance:new Nr(o,e,a),threeNode:t})}}GetNodeItems(){return this.threeNodeItems}},pc=class{constructor(e,t,n,i){this.model=e,this.stateHandler=t,this.conversionParams=n,this.conversionOutput=i,this.shadingType=dh(e),this.modelToThreeLineMaterial=new Map,this.modelToThreeMaterial=new Map}GetThreeMaterial(e,t){if(t===Cs.Face){if(!this.modelToThreeMaterial.has(e)){let n=this.CreateThreeFaceMaterial(e);this.modelToThreeMaterial.set(e,n)}return this.modelToThreeMaterial.get(e)}else if(t===Cs.Line){if(!this.modelToThreeLineMaterial.has(e)){let n=this.CreateThreeLineMaterial(e);this.modelToThreeLineMaterial.set(e,n)}return this.modelToThreeLineMaterial.get(e)}else return null}CreateThreeFaceMaterial(e){let t=this.model.GetMaterial(e),n=wn(t.color);t.vertexColors&&n.setRGB(1,1,1);let i={color:n,vertexColors:t.vertexColors,opacity:t.opacity,transparent:t.transparent,alphaTest:t.alphaTest,side:On};this.conversionParams.forceMediumpForMaterials&&(i.precision="mediump");let s=null;if(this.shadingType===ci.Phong){if(s=new Zt(i),t.type===Un.Phong){let a=wn(t.specular);It(t.shininess,0)&&a.setRGB(0,0,0),s.specular=a,s.shininess=t.shininess*100,this.LoadFaceTexture(s,t.specularMap,l=>{s.specularMap=l})}}else this.shadingType===ci.Physical&&(s=new gs(i),t.type===Un.Physical&&(s.metalness=t.metalness,s.roughness=t.roughness,this.LoadFaceTexture(s,t.metalnessMap,a=>{s.metalness=1,s.roughness=1,s.metalnessMap=a,s.roughnessMap=a})));let o=wn(t.emissive);return s.emissive=o,this.LoadFaceTexture(s,t.diffuseMap,a=>{t.multiplyDiffuseMap||s.color.setRGB(1,1,1),s.map=a}),this.LoadFaceTexture(s,t.bumpMap,a=>{s.bumpMap=a}),this.LoadFaceTexture(s,t.normalMap,a=>{s.normalMap=a}),this.LoadFaceTexture(s,t.emissiveMap,a=>{s.emissiveMap=a}),t.source!==yn.Model&&(s.userData.source=t.source,this.conversionOutput.defaultMaterials.push(s)),s}CreateThreeLineMaterial(e){let t=this.model.GetMaterial(e),i={color:wn(t.color),opacity:t.opacity};this.conversionParams.forceMediumpForMaterials&&(i.precision="mediump");let s=new Wn(i);return t.source!==yn.Model&&(s.userData.source=t.source,this.conversionOutput.defaultMaterials.push(s)),s}LoadFaceTexture(e,t,n){function i(a,l){l.wrapS=rn,l.wrapT=rn,l.rotation=a.rotation,l.offset.x=a.offset.x,l.offset.y=a.offset.y,l.repeat.x=a.scale.x,l.repeat.y=a.scale.y}if(t===null||!t.IsValid())return;let s=new Pi;this.stateHandler.OnTextureNeeded();let o=null;t.mimeType!==null?o=Vc(t.buffer,t.mimeType):o=Os(t.buffer),this.conversionOutput.objectUrls.push(o),s.load(o,a=>{i(t,a),e.needsUpdate=!0,n(a),this.stateHandler.OnTextureLoaded()},null,a=>{this.stateHandler.OnTextureLoaded()})}},nl=class{constructor(e,t,n){this.threeGeometry=e,this.geometryType=t,this.materialHandler=n,this.itemVertexCount=null,t===Cs.Face?this.itemVertexCount=3:t===Cs.Line&&(this.itemVertexCount=2),this.meshThreeMaterials=[],this.meshOriginalMaterials=[],this.groupStart=null,this.previousMaterialIndex=null}ProcessItem(e,t){if(this.previousMaterialIndex!==t){this.groupStart!==null&&this.AddGroup(this.groupStart,e-1),this.groupStart=e;let n=this.materialHandler.GetThreeMaterial(t,this.geometryType);this.meshThreeMaterials.push(n),this.meshOriginalMaterials.push(t),this.previousMaterialIndex=t}}Finalize(e){this.AddGroup(this.groupStart,e-1)}AddGroup(e,t){let n=this.meshThreeMaterials.length-1;this.threeGeometry.addGroup(e*this.itemVertexCount,(t-e+1)*this.itemVertexCount,n)}};function Uh(r,e,t,n){function i(h,f){let p=h.mesh,g=p.TriangleCount();if(g===0)return null;let v=[];for(let M=0;M<g;M++)v.push(M);v.sort((M,L)=>{let N=p.GetTriangle(M),O=p.GetTriangle(L);return N.mat-O.mat});let d=new St,m=new nl(d,Cs.Face,f),_=[],y=[],x=[],w=[],I=p.VertexColorCount()>0,C=p.TextureUVCount()>0,P=0;for(let M of v){let L=p.GetTriangle(M),N=p.GetVertex(L.v0),O=p.GetVertex(L.v1),B=p.GetVertex(L.v2);if(_.push(N.x,N.y,N.z,O.x,O.y,O.z,B.x,B.y,B.z),L.HasVertexColors()){let W=wn(p.GetVertexColor(L.c0)),ae=wn(p.GetVertexColor(L.c1)),de=wn(p.GetVertexColor(L.c2));y.push(W.r,W.g,W.b,ae.r,ae.g,ae.b,de.r,de.g,de.b)}else I&&y.push(0,0,0,0,0,0,0,0,0);let ie=p.GetNormal(L.n0),$=p.GetNormal(L.n1),te=p.GetNormal(L.n2);if(x.push(ie.x,ie.y,ie.z,$.x,$.y,$.z,te.x,te.y,te.z),L.HasTextureUVs()){let W=p.GetTextureUV(L.u0),ae=p.GetTextureUV(L.u1),de=p.GetTextureUV(L.u2);w.push(W.x,W.y,ae.x,ae.y,de.x,de.y)}else C&&w.push(0,0,0,0,0,0);m.ProcessItem(P,L.mat),P+=1}m.Finalize(P),d.setAttribute("position",new ze(_,3)),y.length!==0&&d.setAttribute("color",new ze(y,3)),d.setAttribute("normal",new ze(x,3)),w.length!==0&&d.setAttribute("uv",new ze(w,2));let E=new Pt(d,m.meshThreeMaterials);return E.name=p.GetName(),E.userData={originalMeshInstance:h,originalMaterials:m.meshOriginalMaterials,threeMaterials:null},E}function s(h,f){let p=h.mesh,g=p.LineCount();if(g===0)return null;let v=[];for(let w=0;w<g;w++)v.push(w);v.sort((w,I)=>{let C=p.GetLine(w),P=p.GetLine(I);return C.mat-P.mat});let d=new St,m=new nl(d,Cs.Line,f),_=[],y=0;for(let w=0;w<v.length;w++){let I=p.GetLine(v[w]),C=I.GetVertices();for(let P=0;P<C.length;P++){let E=C[P],M=p.GetVertex(E);_.push(M.x,M.y,M.z),P>0&&P<C.length-1&&_.push(M.x,M.y,M.z)}m.ProcessItem(y,I.mat),y+=I.SegmentCount()}m.Finalize(y),d.setAttribute("position",new ze(_,3));let x=new yr(d,m.meshThreeMaterials);return x.userData={originalMeshInstance:h,originalMaterials:m.meshOriginalMaterials,threeMaterials:null},x}function o(h,f,p){if(ts(f.mesh))return;let g=i(f,p);g!==null&&h.add(g);let v=s(f,p);v!==null&&h.add(v)}function a(h,f,p,g){let d=new dc(f,h).GetNodeItems();Pc(d.length,100,{runTask:(m,_,y)=>{for(let x=m;x<=_;x++){let w=d[x];o(w.threeNode,w.meshInstance,p)}y()},onReady:()=>{g.OnModelLoaded(h)}})}let l=new fc(n),c=new pc(r,l,e,t),u=new Rt;a(u,r,c,l)}var il=class{constructor(){this.importer=new Ja,this.inProgress=!1,this.defaultMaterials=null,this.objectUrls=null,this.hasHighpDriverIssue=fh()}InProgress(){return this.inProgress}LoadModel(e,t,n){this.inProgress||(this.inProgress=!0,this.RevokeObjectUrls(),this.importer.ImportFiles(e,t,{onLoadStart:()=>{n.onLoadStart()},onFileListProgress:(i,s)=>{n.onFileListProgress(i,s)},onFileLoadProgress:(i,s)=>{n.onFileLoadProgress(i,s)},onImportStart:()=>{n.onImportStart()},onSelectMainFile:(i,s)=>{n.onSelectMainFile?n.onSelectMainFile(i,s):s(0)},onImportSuccess:i=>{n.onVisualizationStart();let s=new el;s.forceMediumpForMaterials=this.hasHighpDriverIssue;let o=new tl;Uh(i.model,s,o,{onTextureLoaded:()=>{n.onTextureLoaded()},onModelLoaded:a=>{if(this.defaultMaterials=o.defaultMaterials,this.objectUrls=o.objectUrls,i.upVector===pt.X){let l=new sn().setFromAxisAngle(new oe(0,0,1),Math.PI/2);a.quaternion.multiply(l)}else if(i.upVector===pt.Z){let l=new sn().setFromAxisAngle(new oe(1,0,0),-Math.PI/2);a.quaternion.multiply(l)}n.onModelFinished(i,a),this.inProgress=!1}})},onImportError:i=>{n.onLoadError(i),this.inProgress=!1}}))}GetImporter(){return this.importer}GetDefaultMaterials(){return this.defaultMaterials}ReplaceDefaultMaterialsColor(e,t){if(this.defaultMaterials!==null)for(let n of this.defaultMaterials)n.vertexColors||(n.userData.source===yn.DefaultFace?n.color=wn(e):n.userData.source===yn.DefaultLine&&(n.color=wn(t)))}RevokeObjectUrls(){if(this.objectUrls!==null){for(let e of this.objectUrls)zc(e);this.objectUrls=null}}Destroy(){this.RevokeObjectUrls(),this.importer=null}};function Fn(r){return Math.round(parseFloat(r))}function kh(r){let e=Fn(r.paddingLeft)+Fn(r.paddingRight),t=Fn(r.borderLeftWidth)+Fn(r.borderRightWidth),n=Fn(r.marginLeft)+Fn(r.marginRight);return e+t+n}function Bh(r){let e=Fn(r.paddingTop)+Fn(r.paddingBottom),t=Fn(r.borderTopWidth)+Fn(r.borderBottomWidth),n=Fn(r.marginTop)+Fn(r.marginBottom);return e+t+n}function Gh(r,e,t){let n=getComputedStyle(r),i=e-kh(n),s=t-Bh(n);return{width:i,height:s}}function Kr(r,e,t){if(r.getBoundingClientRect){let n=r.getBoundingClientRect();e-=n.left,t-=n.top}return window.pageXOffset&&window.pageYOffset&&(e+=window.pageXOffset,t+=window.pageYOffset),new At(e,t)}function Vh(r,e,t){let n=document.createElement(r);return e&&(n.className=e),t&&(n.innerHTML=t),n}function Cp(r,e,t,n){let i=Vh(e,t,n);return r.appendChild(i),i}function fv(r,e,t){return Cp(r,"div",e,t)}function dv(r){for(;r.firstChild;)r.removeChild(r.firstChild)}function pv(r,e){e.parentNode.insertBefore(r,e)}function mv(r,e){e.parentNode.insertBefore(r,e.nextSibling)}function gv(r,e){e?r.style.display="block":r.style.display="none"}function vv(r){return r.offsetParent!==null}function Rp(r,e){r.style.width=e.toString()+"px"}function Ip(r,e){r.style.height=e.toString()+"px"}function yv(r){let e=getComputedStyle(r);return r.offsetWidth+Fn(e.marginLeft)+Fn(e.marginRight)}function xv(r){let e=getComputedStyle(r);return r.offsetHeight+Fn(e.marginTop)+Fn(e.marginBottom)}function _v(r,e){let t=getComputedStyle(r);Rp(r,e-kh(t))}function Tv(r,e){let t=getComputedStyle(r);Ip(r,e-Bh(t))}function Mv(r,e){return Vh("div",r,e)}var mc=class{constructor(){this.prev=new At(0,0),this.curr=new At(0,0),this.diff=new At(0,0),this.buttons=[]}Down(e,t){this.buttons.push(t.which),this.curr=this.GetPositionFromEvent(e,t),this.prev=this.curr.Clone()}Move(e,t){this.curr=this.GetPositionFromEvent(e,t),this.diff=Jr(this.curr,this.prev),this.prev=this.curr.Clone()}Up(e,t){let n=this.buttons.indexOf(t.which);n!==-1&&this.buttons.splice(n,1),this.curr=this.GetPositionFromEvent(e,t)}Leave(e,t){this.buttons=[],this.curr=this.GetPositionFromEvent(e,t)}IsButtonDown(){return this.buttons.length>0}GetButton(){let e=this.buttons.length;return e===0?0:this.buttons[e-1]}GetPosition(){return this.curr}GetMoveDiff(){return this.diff}GetPositionFromEvent(e,t){return Kr(e,t.clientX,t.clientY)}},gc=class{constructor(){this.prevPos=new At(0,0),this.currPos=new At(0,0),this.diffPos=new At(0,0),this.prevDist=0,this.currDist=0,this.diffDist=0,this.fingers=0}Start(e,t){t.touches.length!==0&&(this.fingers=t.touches.length,this.currPos=this.GetPositionFromEvent(e,t),this.prevPos=this.currPos.Clone(),this.currDist=this.GetTouchDistanceFromEvent(e,t),this.prevDist=this.currDist)}Move(e,t){t.touches.length!==0&&(this.currPos=this.GetPositionFromEvent(e,t),this.diffPos=Jr(this.currPos,this.prevPos),this.prevPos=this.currPos.Clone(),this.currDist=this.GetTouchDistanceFromEvent(e,t),this.diffDist=this.currDist-this.prevDist,this.prevDist=this.currDist)}End(e,t){t.touches.length!==0&&(this.fingers=0,this.currPos=this.GetPositionFromEvent(e,t),this.currDist=this.GetTouchDistanceFromEvent(e,t))}IsFingerDown(){return this.fingers!==0}GetFingerCount(){return this.fingers}GetPosition(){return this.currPos}GetMoveDiff(){return this.diffPos}GetDistanceDiff(){return this.diffDist}GetPositionFromEvent(e,t){let n=null;if(t.touches.length!==0){let i=t.touches[0];n=Kr(e,i.pageX,i.pageY)}return n}GetTouchDistanceFromEvent(e,t){if(t.touches.length!==2)return 0;let n=t.touches[0],i=t.touches[1];return Is(Kr(e,n.pageX,n.pageY),Kr(e,i.pageX,i.pageY))}},vc=class{constructor(){this.isClick=!1,this.startPosition=null}Start(e){this.isClick=!0,this.startPosition=e}Move(e){this.isClick&&(this.startPosition!==null?Is(this.startPosition,e)>3&&this.Cancel():this.Cancel())}End(){this.startPosition=null}Cancel(){this.isClick=!1,this.startPosition=null}IsClick(){return this.isClick}},ti={None:0,Orbit:1,Pan:2,Zoom:3},rl=class{constructor(e,t,n){this.canvas=e,this.camera=t,this.callbacks=n,this.navigationMode=As.FixedUpVector,this.mouse=new mc,this.touch=new gc,this.clickDetector=new vc,this.onMouseClick=null,this.onMouseMove=null,this.onContext=null,this.canvas.addEventListener&&(this.canvas.addEventListener("mousedown",this.OnMouseDown.bind(this)),this.canvas.addEventListener("wheel",this.OnMouseWheel.bind(this)),this.canvas.addEventListener("touchstart",this.OnTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.OnTouchMove.bind(this)),this.canvas.addEventListener("touchcancel",this.OnTouchEnd.bind(this)),this.canvas.addEventListener("touchend",this.OnTouchEnd.bind(this)),this.canvas.addEventListener("contextmenu",this.OnContextMenu.bind(this))),document.addEventListener&&(document.addEventListener("mousemove",this.OnMouseMove.bind(this)),document.addEventListener("mouseup",this.OnMouseUp.bind(this)),document.addEventListener("mouseleave",this.OnMouseLeave.bind(this)))}SetMouseClickHandler(e){this.onMouseClick=e}SetMouseMoveHandler(e){this.onMouseMove=e}SetContextMenuHandler(e){this.onContext=e}GetNavigationMode(){return this.navigationMode}SetNavigationMode(e){this.navigationMode=e}GetCamera(){return this.camera}SetCamera(e){this.camera=e}MoveCamera(e,t){function n(i,s,o,a){i.camera.eye=s.eye[a],i.camera.center=s.center[a],i.camera.up=s.up[a],i.Update(),a<o-1&&requestAnimationFrame(()=>{n(i,s,o,a+1)})}if(e!==null){if(t===0||Fh(this.camera,e))this.camera=e;else{let i=Kc,s={eye:Oo(this.camera.eye,e.eye,t,i),center:Oo(this.camera.center,e.center,t,i),up:Oo(this.camera.up,e.up,t,i)};requestAnimationFrame(()=>{n(this,s,t,0)})}this.Update()}}GetFitToSphereCamera(e,t){if(wr(t))return null;let n=this.camera.Clone(),i=In(n.center,e);n.eye=In(n.eye,i),n.center=e.Clone();let s=In(n.eye,n.center).Normalize(),o=this.camera.fov/2;this.canvas.width<this.canvas.height&&(o=o*this.canvas.width/this.canvas.height);let a=t/Math.sin(o*ar);return n.eye=n.center.Clone().Offset(s,a),n}OnMouseDown(e){e.preventDefault(),this.mouse.Down(this.canvas,e),this.clickDetector.Start(this.mouse.GetPosition())}OnMouseMove(e){if(this.mouse.Move(this.canvas,e),this.clickDetector.Move(this.mouse.GetPosition()),this.onMouseMove){let s=Kr(this.canvas,e.clientX,e.clientY);this.onMouseMove(s)}if(!this.mouse.IsButtonDown())return;let t=this.mouse.GetMoveDiff(),n=this.mouse.GetButton(),i=ti.None;if(n===1?e.ctrlKey?i=ti.Zoom:e.shiftKey?i=ti.Pan:i=ti.Orbit:(n===2||n===3)&&(i=ti.Pan),i===ti.Orbit){let s=.5;this.Orbit(t.x*s,t.y*s)}else if(i===ti.Pan){let o=.001*Yn(this.camera.eye,this.camera.center);this.Pan(t.x*o,t.y*o)}else i===ti.Zoom&&this.Zoom(-t.y*.005);this.Update()}OnMouseUp(e){if(this.mouse.Up(this.canvas,e),this.clickDetector.End(),this.clickDetector.IsClick()){let t=this.mouse.GetPosition();this.Click(e.which,t)}}OnMouseLeave(e){this.mouse.Leave(this.canvas,e),this.clickDetector.Cancel()}OnTouchStart(e){e.preventDefault(),this.touch.Start(this.canvas,e),this.clickDetector.Start(this.touch.GetPosition())}OnTouchMove(e){if(e.preventDefault(),this.touch.Move(this.canvas,e),this.clickDetector.Move(this.touch.GetPosition()),!this.touch.IsFingerDown())return;let t=this.touch.GetMoveDiff(),n=this.touch.GetDistanceDiff(),i=this.touch.GetFingerCount(),s=ti.None;if(i===1?s=ti.Orbit:i===2&&(s=ti.Pan),s===ti.Orbit){let o=.5;this.Orbit(t.x*o,t.y*o)}else if(s===ti.Pan){this.Zoom(n*.005);let a=.001*Yn(this.camera.eye,this.camera.center);this.Pan(t.x*a,t.y*a)}this.Update()}OnTouchEnd(e){if(e.preventDefault(),this.touch.End(this.canvas,e),this.clickDetector.End(),this.clickDetector.IsClick()){let t=this.touch.GetPosition();this.touch.GetFingerCount()===1&&this.Click(1,t)}}OnMouseWheel(e){let t=e||window.event;t.preventDefault();let n=-t.deltaY/40,i=.1;n<0&&(i=i*-1),this.Zoom(i),this.Update()}OnContextMenu(e){e.preventDefault(),this.clickDetector.IsClick()&&(this.Context(e.clientX,e.clientY),this.clickDetector.Cancel())}Orbit(e,t){let n=e*ar,i=t*ar,s=In(this.camera.center,this.camera.eye).Normalize(),o=Bi(s,this.camera.up).Normalize();if(this.navigationMode===As.FixedUpVector){let l=Gc(s,this.camera.up)+i;Lc(l,0)&&fo(l,Math.PI)&&this.camera.eye.Rotate(o,-i,this.camera.center),this.camera.eye.Rotate(this.camera.up,-n,this.camera.center)}else if(this.navigationMode===As.FreeOrbit){let a=Bi(o,s).Normalize();this.camera.eye.Rotate(o,-i,this.camera.center),this.camera.eye.Rotate(a,-n,this.camera.center),this.camera.up=a}}Pan(e,t){let n=In(this.camera.center,this.camera.eye).Normalize(),i=Bi(n,this.camera.up).Normalize(),s=Bi(i,n).Normalize();this.camera.eye.Offset(i,-e),this.camera.center.Offset(i,-e),this.camera.eye.Offset(s,t),this.camera.center.Offset(s,t)}Zoom(e){let t=In(this.camera.center,this.camera.eye),i=t.Length()*e;this.camera.eye.Offset(t,i)}Update(){this.callbacks.onUpdate()}Click(e,t){this.onMouseClick&&this.onMouseClick(e,t)}Context(e,t){if(this.onContext){let n={x:e,y:t},i=Kr(this.canvas,e,t);this.onContext(n,i)}}};var so=class r{constructor(e,t){this.textureNames=e,this.backgroundIsEnvMap=t}Clone(){let e=null;if(this.textureNames!==null){e=[];for(let t of this.textureNames)e.push(t)}return new r(e,this.backgroundIsEnvMap)}},sl=class{constructor(e){this.scene=e,this.type=ci.Phong,this.projectionMode=Xn.Perspective,this.ambientLight=new _r(8947848,1*Math.PI),this.directionalLight=new xr(8947848,1*Math.PI),this.environmentSettings=new so(null,!1),this.environment=null,this.scene.add(this.ambientLight),this.scene.add(this.directionalLight)}SetShadingType(e){this.type=e,this.UpdateShading()}SetProjectionMode(e){this.projectionMode=e,this.UpdateShading()}UpdateShading(){this.type===ci.Phong?(this.ambientLight.color.set(8947848),this.directionalLight.color.set(8947848),this.scene.environment=null):this.type===ci.Physical&&(this.ambientLight.color.set(0),this.directionalLight.color.set(5592405),this.scene.environment=this.environment),this.environmentSettings.backgroundIsEnvMap&&this.projectionMode===Xn.Perspective?this.scene.background=this.environment:this.scene.background=null}SetEnvironmentMapSettings(e,t){let n=new nh;this.environment=n.load(e.textureNames,i=>{i.colorSpace=li,t()}),this.environmentSettings=e}UpdateByCamera(e){let t=In(e.eye,e.center);this.directionalLight.position.set(t.x,t.y,t.z)}};function zh(r){let e=45;return r===pt.X?new Sr(new Xe(2,-3,1.5),new Xe(0,0,0),new Xe(1,0,0),e):r===pt.Y?new Sr(new Xe(-1.5,2,3),new Xe(0,0,0),new Xe(0,1,0),e):r===pt.Z?new Sr(new Xe(-1.5,-3,2),new Xe(0,0,0),new Xe(0,0,1),e):null}function Hh(r,e){if(!e(r))return!1;for(let t of r.children)if(!Hh(t,e))return!1;return!0}function Pp(r){let e=null;return Hh(r,t=>{if(t.isMesh)for(let n of t.material)return n.type==="MeshPhongMaterial"?e=ci.Phong:n.type==="MeshStandardMaterial"&&(e=ci.Physical),!1;return!0}),e}var yc=class{constructor(){this.eyeCenterDistance=0,this.forceUpdate=!0}ForceUpdate(){this.forceUpdate=!0}ValidatePerspective(){return this.forceUpdate?(this.forceUpdate=!1,!1):!0}ValidateOrthographic(e){return this.forceUpdate||!It(this.eyeCenterDistance,e)?(this.eyeCenterDistance=e,this.forceUpdate=!1,!1):!0}},xc=class{constructor(){this.direction=pt.Y,this.isFixed=!0,this.isFlipped=!1}SetDirection(e,t){this.direction=e,this.isFlipped=!1;let n=zh(this.direction),i=In(n.eye,n.center),s=Yn(t.center,t.eye),o=t.center.Clone().Offset(i,s),a=t.Clone();return this.direction===pt.X?(a.up=new Xe(1,0,0),a.eye=o):this.direction===pt.Y?(a.up=new Xe(0,1,0),a.eye=o):this.direction===pt.Z&&(a.up=new Xe(0,0,1),a.eye=o),a}SetFixed(e,t){return this.isFixed=e,this.isFixed?this.SetDirection(this.direction,t):null}Flip(e){this.isFlipped=!this.isFlipped;let t=e.Clone();return t.up.MultiplyScalar(-1),t}},ol=class{constructor(){Bt.enabled=!1,this.canvas=null,this.renderer=null,this.scene=null,this.mainModel=null,this.extraModel=null,this.camera=null,this.projectionMode=null,this.cameraValidator=null,this.shadingModel=null,this.navigation=null,this.upVector=null,this.settings={animationSteps:40}}Init(e){this.canvas=e,this.canvas.id="viewer";let t={canvas:this.canvas,antialias:!0};this.renderer=new ya(t),this.renderer.outputColorSpace=li,window.devicePixelRatio&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setClearColor("#ffffff",1),this.renderer.setSize(this.canvas.width,this.canvas.height),this.scene=new vr,this.mainModel=new Qa(this.scene),this.extraModel=new ws(this.scene),this.InitNavigation(),this.InitShading(),this.Render()}SetMouseClickHandler(e){this.navigation.SetMouseClickHandler(e)}SetMouseMoveHandler(e){this.navigation.SetMouseMoveHandler(e)}SetContextMenuHandler(e){this.navigation.SetContextMenuHandler(e)}SetEdgeSettings(e){let t=e.Clone();this.mainModel.SetEdgeSettings(t),this.Render()}SetEnvironmentMapSettings(e){let t=e.Clone();this.shadingModel.SetEnvironmentMapSettings(t,()=>{this.Render()}),this.shadingModel.UpdateShading(),this.Render()}SetBackgroundColor(e){let t=new Ve(Ps(e.r),Ps(e.g),Ps(e.b)),n=Ps(e.a);this.renderer.setClearColor(t,n),this.Render()}GetCanvas(){return this.canvas}GetCamera(){return this.navigation.GetCamera()}GetProjectionMode(){return this.projectionMode}SetCamera(e){this.navigation.SetCamera(e),this.cameraValidator.ForceUpdate(),this.Render()}SetProjectionMode(e){this.projectionMode!==e&&(this.scene.remove(this.camera),e===Xn.Perspective?this.camera=new en(45,1,.1,1e3):e===Xn.Orthographic&&(this.camera=new gr(-1,1,1,-1,.1,1e3)),this.scene.add(this.camera),this.projectionMode=e,this.shadingModel.SetProjectionMode(e),this.cameraValidator.ForceUpdate(),this.AdjustClippingPlanes(),this.Render())}Resize(e,t){let n=Gh(this.canvas,e,t);this.ResizeRenderer(n.width,n.height)}ResizeRenderer(e,t){window.devicePixelRatio&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t),this.cameraValidator.ForceUpdate(),this.Render()}FitSphereToWindow(e,t){if(e===null)return;let n=new Xe(e.center.x,e.center.y,e.center.z),i=e.radius,s=this.navigation.GetFitToSphereCamera(n,i);this.navigation.MoveCamera(s,t?this.settings.animationSteps:0)}AdjustClippingPlanes(){let e=this.GetBoundingSphere(t=>!0);this.AdjustClippingPlanesToSphere(e)}AdjustClippingPlanesToSphere(e){e!==null&&(e.radius<10?(this.camera.near=.01,this.camera.far=100):e.radius<100?(this.camera.near=.1,this.camera.far=1e3):e.radius<1e3?(this.camera.near=10,this.camera.far=1e4):(this.camera.near=100,this.camera.far=1e6),this.cameraValidator.ForceUpdate(),this.Render())}GetNavigationMode(){return this.navigation.GetNavigationMode()}SetNavigationMode(e){let t=this.navigation.GetCamera(),n=this.upVector.SetFixed(e===As.FixedUpVector,t);this.navigation.SetNavigationMode(e),n!==null&&this.navigation.MoveCamera(n,this.settings.animationSteps),this.Render()}SetUpVector(e,t){let n=this.navigation.GetCamera(),i=this.upVector.SetDirection(e,n),s=t?this.settings.animationSteps:0;this.navigation.MoveCamera(i,s),this.Render()}FlipUpVector(){let e=this.navigation.GetCamera(),t=this.upVector.Flip(e);this.navigation.MoveCamera(t,0),this.Render()}Render(){let e=this.navigation.GetCamera();if(this.camera.position.set(e.eye.x,e.eye.y,e.eye.z),this.camera.up.set(e.up.x,e.up.y,e.up.z),this.camera.lookAt(new oe(e.center.x,e.center.y,e.center.z)),this.projectionMode===Xn.Perspective)this.cameraValidator.ValidatePerspective()||(this.camera.aspect=this.canvas.width/this.canvas.height,this.camera.fov=e.fov,this.camera.updateProjectionMatrix());else if(this.projectionMode===Xn.Orthographic){let t=Yn(e.eye,e.center);if(!this.cameraValidator.ValidateOrthographic(t)){let n=this.canvas.width/this.canvas.height,s=Yn(e.eye,e.center)*Math.tan(.5*e.fov*ar);this.camera.left=-s*n,this.camera.right=s*n,this.camera.top=s,this.camera.bottom=-s,this.camera.updateProjectionMatrix()}}this.shadingModel.UpdateByCamera(e),this.renderer.render(this.scene,this.camera)}SetMainObject(e){let t=Pp(e);this.mainModel.SetMainObject(e),this.shadingModel.SetShadingType(t),this.Render()}AddExtraObject(e){this.extraModel.AddObject(e),this.Render()}Clear(){this.mainModel.Clear(),this.extraModel.Clear(),this.Render()}ClearExtra(){this.extraModel.Clear(),this.Render()}SetMeshesVisibility(e){this.mainModel.EnumerateMeshesAndLines(t=>{let n=e(t.userData);t.visible!==n&&(t.visible=n)}),this.mainModel.EnumerateEdges(t=>{let n=e(t.userData);t.visible!==n&&(t.visible=n)}),this.Render()}SetMeshesHighlight(e,t){let n=this.mainModel.HasLinesOrEdges();this.mainModel.EnumerateMeshesAndLines(i=>{t(i.userData)?i.userData.threeMaterials===null&&(i.userData.threeMaterials=i.material,i.material=ph(i.userData.threeMaterials,e,n)):i.userData.threeMaterials!==null&&(i.material=i.userData.threeMaterials,i.userData.threeMaterials=null)}),this.Render()}GetMeshUserDataUnderMouse(e,t){let n=this.GetMeshIntersectionUnderMouse(e,t);return n===null?null:n.object.userData}GetMeshIntersectionUnderMouse(e,t){let n=this.GetCanvasSize(),i=this.mainModel.GetMeshIntersectionUnderMouse(e,t,this.camera,n.width,n.height);return i===null?null:i}GetBoundingBox(e){return this.mainModel.GetBoundingBox(e)}GetBoundingSphere(e){return this.mainModel.GetBoundingSphere(e)}EnumerateMeshesAndLinesUserData(e){this.mainModel.EnumerateMeshesAndLines(t=>{e(t.userData)})}InitNavigation(){let e=zh(pt.Y);this.camera=new en(45,1,.1,1e3),this.projectionMode=Xn.Perspective,this.cameraValidator=new yc,this.scene.add(this.camera);let t=this.renderer.domElement;this.navigation=new rl(t,e,{onUpdate:()=>{this.Render()}}),this.upVector=new xc}InitShading(){this.shadingModel=new sl(this.scene)}GetShadingType(){return this.shadingModel.type}GetImageSize(){let e=new Ce;return this.renderer.getSize(e),{width:parseInt(e.x,10),height:parseInt(e.y,10)}}GetCanvasSize(){let e=this.canvas.width,t=this.canvas.height;return window.devicePixelRatio&&(e/=window.devicePixelRatio,t/=window.devicePixelRatio),{width:e,height:t}}GetImageAsDataUrl(e,t,n){let i=this.GetImageSize(),s=e,o=t;window.devicePixelRatio&&(s/=window.devicePixelRatio,o/=window.devicePixelRatio);let a=this.renderer.getClearAlpha();n&&this.renderer.setClearAlpha(0),this.ResizeRenderer(s,o),this.Render();let l=this.renderer.domElement.toDataURL();return this.ResizeRenderer(i.width,i.height),this.renderer.setClearAlpha(a),l}Destroy(){this.Clear(),this.renderer.dispose()}};var al=class{constructor(e,t){this.parentElement=e,this.parameters={},lo(t)&&(this.parameters=t),this.canvas=document.createElement("canvas"),this.parentElement.appendChild(this.canvas),this.viewer=new ol,this.viewer.Init(this.canvas);let n=this.parentElement.clientWidth,i=this.parentElement.clientHeight;this.viewer.Resize(n,i),this.parameters.projectionMode&&this.viewer.SetProjectionMode(this.parameters.projectionMode),this.parameters.backgroundColor&&this.viewer.SetBackgroundColor(this.parameters.backgroundColor),this.parameters.edgeSettings&&this.viewer.SetEdgeSettings(this.parameters.edgeSettings),this.parameters.environmentSettings&&this.viewer.SetEnvironmentMapSettings(this.parameters.environmentSettings),this.model=null,this.modelLoader=new il,window.addEventListener("resize",()=>{this.Resize()})}LoadModelFromUrlList(e){kc(e);let t=Zc(e);this.LoadModelFromInputFiles(t)}LoadModelFromFileList(e){let t=Jc(e);this.LoadModelFromInputFiles(t)}LoadModelFromInputFiles(e){if(e===null||e.length===0)return;this.viewer.Clear();let t=new Za;this.parameters.defaultColor&&(t.defaultColor=this.parameters.defaultColor),this.parameters.defaultLineColor&&(t.defaultLineColor=this.parameters.defaultLineColor),this.model=null;let n=null;this.modelLoader.LoadModel(e,t,{onLoadStart:()=>{this.canvas.style.display="none",n=document.createElement("div"),n.innerHTML=Ze("Loading model..."),this.parentElement.appendChild(n)},onFileListProgress:(i,s)=>{},onFileLoadProgress:(i,s)=>{},onImportStart:()=>{n.innerHTML=Ze("Importing model...")},onVisualizationStart:()=>{n.innerHTML=Ze("Visualizing model...")},onModelFinished:(i,s)=>{this.parentElement.removeChild(n),this.canvas.style.display="inherit",this.viewer.SetMainObject(s);let o=this.viewer.GetBoundingSphere(a=>!0);this.viewer.AdjustClippingPlanesToSphere(o),this.parameters.camera?this.viewer.SetCamera(this.parameters.camera):(this.viewer.SetUpVector(pt.Y,!1),this.viewer.FitSphereToWindow(o,!1)),this.model=i.model,this.parameters.onModelLoaded&&this.parameters.onModelLoaded()},onTextureLoaded:()=>{this.viewer.Render()},onLoadError:i=>{let s=Ze("Unknown error.");i.code===br.NoImportableFile?s=Ze("No importable file found."):i.code===br.FailedToLoadFile?s=Ze("Failed to load file for import."):i.code===br.ImportFailed&&(s=Ze("Failed to import model.")),i.message!==null&&(s+=" ("+i.message+")"),n.innerHTML=s}})}GetViewer(){return this.viewer}GetModel(){return this.model}Resize(){let e=this.parentElement.clientWidth,t=this.parentElement.clientHeight;this.viewer.Resize(e,t)}Destroy(){this.modelLoader.Destroy(),this.viewer.Destroy(),this.model=null}};function Np(r,e,t){let n=new al(r,t);return n.LoadModelFromUrlList(e),n}function Ev(r,e,t){let n=new al(r,t);return n.LoadModelFromFileList(e),n}function bv(r){function e(i){let s=null,o=i.getAttribute("camera");o&&(s=Jt.StringToCamera(o));let a=null,l=i.getAttribute("projectionmode");l&&(a=Jt.StringToProjectionMode(l));let c=null,u=i.getAttribute("backgroundcolor");u&&(c=Jt.StringToRGBAColor(u));let h=null,f=i.getAttribute("defaultcolor");f&&(h=Jt.StringToRGBColor(f));let p=null,g=i.getAttribute("defaultlinecolor");g&&(p=Jt.StringToRGBColor(g));let v=null,d=i.getAttribute("edgesettings");d&&(v=Jt.StringToEdgeSettings(d));let m=null,_=i.getAttribute("environmentmap");if(_){let w=_.split(",");if(w.length===6){let I=!1,C=i.getAttribute("environmentmapbg");C&&C==="true"&&(I=!0),m=new so(w,I)}}let y=null,x=i.getAttribute("model");return x&&(y=Jt.StringToModelUrls(x)),Np(i,y,{camera:s,projectionMode:a,backgroundColor:c,defaultLineColor:p,defaultColor:h,edgeSettings:v,environmentSettings:m})}let t=[],n=document.getElementsByClassName("online_3d_viewer");for(let i=0;i<n.length;i++){let s=n[i],o=e(s);t.push(o)}return t}return Nv(JS);})();
+ Please avoid using it as it will be completely removed in the future`)}r.clearCache=h;var f=OS();Object.defineProperty(r,"createSyntaxDiagramsCode",{enumerable:!0,get:function(){return f.createSyntaxDiagramsCode}});var p=function(){function g(){throw new Error(`The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.
+See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return g}();r.Parser=p}),al=DS();var Yf=class extends zt{constructor(e){super(e)}load(e,t,n,i){let s=this,o=s.path===""?os.extractUrlBase(e):s.path,a=new $n(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(l){try{t(s.parse(l,o))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){let n={};function i(O){let D=s(),z=new bm(D.tokens),Q=new Sm(D.tokenVocabulary),ne=o(Q.getBaseCstVisitorConstructor()),oe=z.lex(O);Q.input=oe.tokens;let he=Q.vrml();if(Q.errors.length>0)throw console.error(Q.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return ne.visit(he)}function s(){let O=al.createToken,D=O({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),z=O({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]([^\0-\x20\x22\x27\x23\x2b\x2c\x2e\x5b\x5d\x5c\x7b\x7d])*/,longer_alt:D}),Q=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],ne=O({name:"Version",pattern:/#VRML.*/,longer_alt:z}),oe=O({name:"NodeName",pattern:new RegExp(Q.join("|")),longer_alt:z}),he=O({name:"DEF",pattern:/DEF/,longer_alt:z}),ge=O({name:"USE",pattern:/USE/,longer_alt:z}),de=O({name:"ROUTE",pattern:/ROUTE/,longer_alt:z}),Ee=O({name:"TO",pattern:/TO/,longer_alt:z}),Re=O({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),De=O({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),ke=O({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),at=O({name:"TrueLiteral",pattern:/TRUE/}),je=O({name:"FalseLiteral",pattern:/FALSE/}),Ke=O({name:"NullLiteral",pattern:/NULL/}),fe=O({name:"LSquare",pattern:/\[/}),Le=O({name:"RSquare",pattern:/]/}),be=O({name:"LCurly",pattern:/{/}),Ce=O({name:"RCurly",pattern:/}/}),Be=O({name:"Comment",pattern:/#.*/,group:al.Lexer.SKIPPED}),rt=[O({name:"WhiteSpace",pattern:/[ ,\s]/,group:al.Lexer.SKIPPED}),oe,he,ge,de,Ee,at,je,Ke,ne,z,D,Re,De,ke,fe,Le,be,Ce,Be],Et={};for(let ft=0,Fe=rt.length;ft<Fe;ft++){let $e=rt[ft];Et[$e.name]=$e}return{tokens:rt,tokenVocabulary:Et}}function o(O){class D extends O{constructor(){super(),this.validateVisitor()}vrml(ne){let oe={version:this.visit(ne.version),nodes:[],routes:[]};for(let he=0,ge=ne.node.length;he<ge;he++){let de=ne.node[he];oe.nodes.push(this.visit(de))}if(ne.route)for(let he=0,ge=ne.route.length;he<ge;he++){let de=ne.route[he];oe.routes.push(this.visit(de))}return oe}version(ne){return ne.Version[0].image}node(ne){let oe={name:ne.NodeName[0].image,fields:[]};if(ne.field)for(let he=0,ge=ne.field.length;he<ge;he++){let de=ne.field[he];oe.fields.push(this.visit(de))}return ne.def&&(oe.DEF=this.visit(ne.def[0])),oe}field(ne){let oe={name:ne.Identifier[0].image,type:null,values:null},he;return ne.singleFieldValue&&(he=this.visit(ne.singleFieldValue[0])),ne.multiFieldValue&&(he=this.visit(ne.multiFieldValue[0])),oe.type=he.type,oe.values=he.values,oe}def(ne){return(ne.Identifier||ne.NodeName)[0].image}use(ne){return{USE:(ne.Identifier||ne.NodeName)[0].image}}singleFieldValue(ne){return z(this,ne)}multiFieldValue(ne){return z(this,ne)}route(ne){return{FROM:ne.RouteIdentifier[0].image,TO:ne.RouteIdentifier[1].image}}}function z(Q,ne){let oe={type:null,values:[]};if(ne.node){oe.type="node";for(let he=0,ge=ne.node.length;he<ge;he++){let de=ne.node[he];oe.values.push(Q.visit(de))}}if(ne.use){oe.type="use";for(let he=0,ge=ne.use.length;he<ge;he++){let de=ne.use[he];oe.values.push(Q.visit(de))}}if(ne.StringLiteral){oe.type="string";for(let he=0,ge=ne.StringLiteral.length;he<ge;he++){let de=ne.StringLiteral[he];oe.values.push(de.image.replace(/'|"/g,""))}}if(ne.NumberLiteral){oe.type="number";for(let he=0,ge=ne.NumberLiteral.length;he<ge;he++){let de=ne.NumberLiteral[he];oe.values.push(parseFloat(de.image))}}if(ne.HexLiteral){oe.type="hex";for(let he=0,ge=ne.HexLiteral.length;he<ge;he++){let de=ne.HexLiteral[he];oe.values.push(de.image)}}if(ne.TrueLiteral){oe.type="boolean";for(let he=0,ge=ne.TrueLiteral.length;he<ge;he++)ne.TrueLiteral[he].image==="TRUE"&&oe.values.push(!0)}if(ne.FalseLiteral){oe.type="boolean";for(let he=0,ge=ne.FalseLiteral.length;he<ge;he++)ne.FalseLiteral[he].image==="FALSE"&&oe.values.push(!1)}return ne.NullLiteral&&(oe.type="null",ne.NullLiteral.forEach(function(){oe.values.push(null)})),oe}return new D}function a(O){let D=O.nodes,z=new ir;for(let Q=0,ne=D.length;Q<ne;Q++){let oe=D[Q];l(oe)}for(let Q=0,ne=D.length;Q<ne;Q++){let oe=D[Q],he=c(oe);he instanceof Lt&&z.add(he),oe.name==="WorldInfo"&&(z.userData.worldInfo=he)}return z}function l(O){O.DEF&&(n[O.DEF]=O);let D=O.fields;for(let z=0,Q=D.length;z<Q;z++){let ne=D[z];if(ne.type==="node"){let oe=ne.values;for(let he=0,ge=oe.length;he<ge;he++)l(oe[he])}}}function c(O){return O.USE?Y(O.USE):(O.build!==void 0||(O.build=u(O)),O.build)}function u(O){let D=O.name,z;switch(D){case"Anchor":case"Group":case"Transform":case"Collision":z=h(O);break;case"Background":z=f(O);break;case"Shape":z=p(O);break;case"Appearance":z=g(O);break;case"Material":z=y(O);break;case"ImageTexture":z=v(O);break;case"PixelTexture":z=_(O);break;case"TextureTransform":z=x(O);break;case"IndexedFaceSet":z=A(O);break;case"IndexedLineSet":z=C(O);break;case"PointSet":z=E(O);break;case"Box":z=b(O);break;case"Cone":z=R(O);break;case"Cylinder":z=N(O);break;case"Sphere":z=B(O);break;case"ElevationGrid":z=V(O);break;case"Extrusion":z=ie(O);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":z=S(O);break;case"WorldInfo":z=I(O);break;case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",D);break}return z!==void 0&&O.DEF!==void 0&&z.hasOwnProperty("name")===!0&&(z.name=O.DEF),z}function h(O){let D=new gn,z=O.fields;for(let Q=0,ne=z.length;Q<ne;Q++){let oe=z[Q],he=oe.name,ge=oe.values;switch(he){case"bboxCenter":break;case"bboxSize":break;case"center":break;case"children":te(ge,D);break;case"description":break;case"collide":break;case"parameter":break;case"rotation":let de=new se(ge[0],ge[1],ge[2]).normalize(),Ee=ge[3];D.quaternion.setFromAxisAngle(de,Ee);break;case"scale":D.scale.set(ge[0],ge[1],ge[2]);break;case"scaleOrientation":break;case"translation":D.position.set(ge[0],ge[1],ge[2]);break;case"proxy":break;case"url":break;default:console.warn("THREE.VRMLLoader: Unknown field:",he);break}}return D}function f(O){let D=new gn,z,Q,ne,oe,he=O.fields;for(let de=0,Ee=he.length;de<Ee;de++){let Re=he[de],De=Re.name,ke=Re.values;switch(De){case"groundAngle":z=ke;break;case"groundColor":Q=ke;break;case"backUrl":break;case"bottomUrl":break;case"frontUrl":break;case"leftUrl":break;case"rightUrl":break;case"topUrl":break;case"skyAngle":ne=ke;break;case"skyColor":oe=ke;break;default:console.warn("THREE.VRMLLoader: Unknown field:",De);break}}let ge=1e4;if(oe){let de=new mo(ge,32,16),Ee=new Ii({fog:!1,side:_n,depthWrite:!1,depthTest:!1});oe.length>3?($(de,ge,ne,ue(oe),!0),Ee.vertexColors=!0):Ee.color.setRGB(oe[0],oe[1],oe[2],yt);let Re=new Dt(de,Ee);D.add(Re)}if(Q&&Q.length>0){let de=new mo(ge,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),Ee=new Ii({fog:!1,side:_n,vertexColors:!0,depthWrite:!1,depthTest:!1});$(de,ge,z,ue(Q),!1);let Re=new Dt(de,Ee);D.add(Re)}return D.renderOrder=-1/0,D}function p(O){let D=O.fields,z=new Ii({name:zt.DEFAULT_MATERIAL_NAME,color:0}),Q;for(let oe=0,he=D.length;oe<he;oe++){let ge=D[oe],de=ge.name,Ee=ge.values;switch(de){case"appearance":Ee[0]!==null&&(z=c(Ee[0]));break;case"geometry":Ee[0]!==null&&(Q=c(Ee[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",de);break}}let ne;if(Q&&Q.attributes.position){let oe=Q._type;if(oe==="points"){let he=new Na({name:zt.DEFAULT_MATERIAL_NAME,color:16777215,opacity:z.opacity,transparent:z.transparent});Q.attributes.color!==void 0?he.vertexColors=!0:z.isMeshPhongMaterial&&he.color.copy(z.emissive),ne=new sc(Q,he)}else if(oe==="line"){let he=new jn({name:zt.DEFAULT_MATERIAL_NAME,color:16777215,opacity:z.opacity,transparent:z.transparent});Q.attributes.color!==void 0?he.vertexColors=!0:z.isMeshPhongMaterial&&he.color.copy(z.emissive),ne=new rr(Q,he)}else Q._solid!==void 0&&(z.side=Q._solid?wi:Nn),Q.attributes.color!==void 0&&(z.vertexColors=!0),ne=new Dt(Q,z)}else ne=new Lt,ne.visible=!1;return ne}function g(O){let D=new Zt,z,Q=O.fields;for(let ne=0,oe=Q.length;ne<oe;ne++){let he=Q[ne],ge=he.name,de=he.values;switch(ge){case"material":if(de[0]!==null){let Re=c(de[0]);Re.diffuseColor&&D.color.copy(Re.diffuseColor),Re.emissiveColor&&D.emissive.copy(Re.emissiveColor),Re.shininess&&(D.shininess=Re.shininess),Re.specularColor&&D.specular.copy(Re.specularColor),Re.transparency&&(D.opacity=1-Re.transparency),Re.transparency>0&&(D.transparent=!0)}else D=new Ii({name:zt.DEFAULT_MATERIAL_NAME,color:0});break;case"texture":let Ee=de[0];Ee!==null&&(Ee.name==="ImageTexture"||Ee.name==="PixelTexture")&&(D.map=c(Ee));break;case"textureTransform":de[0]!==null&&(z=c(de[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}if(D.map){if(D.map.__type){switch(D.map.__type){case pr.INTENSITY_ALPHA:D.opacity=1;break;case pr.RGB:D.color.set(16777215);break;case pr.RGBA:D.color.set(16777215),D.opacity=1;break;default:}delete D.map.__type}z&&(D.map.center.copy(z.center),D.map.rotation=z.rotation,D.map.repeat.copy(z.scale),D.map.offset.copy(z.translation))}return D}function y(O){let D={},z=O.fields;for(let Q=0,ne=z.length;Q<ne;Q++){let oe=z[Q],he=oe.name,ge=oe.values;switch(he){case"ambientIntensity":break;case"diffuseColor":D.diffuseColor=new He().setRGB(ge[0],ge[1],ge[2],yt);break;case"emissiveColor":D.emissiveColor=new He().setRGB(ge[0],ge[1],ge[2],yt);break;case"shininess":D.shininess=ge[0];break;case"specularColor":D.specularColor=new He().setRGB(ge[0],ge[1],ge[2],yt);break;case"transparency":D.transparency=ge[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",he);break}}return D}function d(O,D,z){let Q;switch(D){case pr.INTENSITY:Q=parseInt(O),z.r=Q,z.g=Q,z.b=Q,z.a=1;break;case pr.INTENSITY_ALPHA:Q=parseInt("0x"+O.substring(2,4)),z.r=Q,z.g=Q,z.b=Q,z.a=parseInt("0x"+O.substring(4,6));break;case pr.RGB:z.r=parseInt("0x"+O.substring(2,4)),z.g=parseInt("0x"+O.substring(4,6)),z.b=parseInt("0x"+O.substring(6,8)),z.a=1;break;case pr.RGBA:z.r=parseInt("0x"+O.substring(2,4)),z.g=parseInt("0x"+O.substring(4,6)),z.b=parseInt("0x"+O.substring(6,8)),z.a=parseInt("0x"+O.substring(8,10));break;default:}}function m(O){let D;switch(O){case 1:D=pr.INTENSITY;break;case 2:D=pr.INTENSITY_ALPHA;break;case 3:D=pr.RGB;break;case 4:D=pr.RGBA;break;default:}return D}function _(O){let D,z=on,Q=on,ne=O.fields;for(let oe=0,he=ne.length;oe<he;oe++){let ge=ne[oe],de=ge.name,Ee=ge.values;switch(de){case"image":let Re=Ee[0],De=Ee[1],ke=Ee[2],at=m(ke),je=new Uint8Array(4*Re*De),Ke={r:0,g:0,b:0,a:0};for(let fe=3,Le=0,be=Ee.length;fe<be;fe++,Le++){d(Ee[fe],at,Ke);let Ce=Le*4;je[Ce+0]=Ke.r,je[Ce+1]=Ke.g,je[Ce+2]=Ke.b,je[Ce+3]=Ke.a}D=new uo(je,Re,De),D.colorSpace=yt,D.needsUpdate=!0,D.__type=at;break;case"repeatS":Ee[0]===!1&&(z=un);break;case"repeatT":Ee[0]===!1&&(Q=un);break;default:console.warn("THREE.VRMLLoader: Unknown field:",de);break}}return D&&(D.wrapS=z,D.wrapT=Q),D}function v(O){let D,z=on,Q=on,ne=O.fields;for(let oe=0,he=ne.length;oe<he;oe++){let ge=ne[oe],de=ge.name,Ee=ge.values;switch(de){case"url":let Re=Ee[0];Re&&(D=ve.load(Re));break;case"repeatS":Ee[0]===!1&&(z=un);break;case"repeatT":Ee[0]===!1&&(Q=un);break;default:console.warn("THREE.VRMLLoader: Unknown field:",de);break}}return D&&(D.wrapS=z,D.wrapT=Q,D.colorSpace=yt),D}function x(O){let D={center:new Pe,rotation:new Pe,scale:new Pe,translation:new Pe},z=O.fields;for(let Q=0,ne=z.length;Q<ne;Q++){let oe=z[Q],he=oe.name,ge=oe.values;switch(he){case"center":D.center.set(ge[0],ge[1]);break;case"rotation":D.rotation=ge[0];break;case"scale":D.scale.set(ge[0],ge[1]);break;case"translation":D.translation.set(ge[0],ge[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",he);break}}return D}function S(O){return O.fields[0].values}function I(O){let D={},z=O.fields;for(let Q=0,ne=z.length;Q<ne;Q++){let oe=z[Q],he=oe.name,ge=oe.values;switch(he){case"title":D.title=ge[0];break;case"info":D.info=ge;break;default:console.warn("THREE.VRMLLoader: Unknown field:",he);break}}return D}function A(O){let D,z,Q,ne,oe=!0,he=!0,ge=0,de,Ee,Re,De,ke=!0,at=!0,je=O.fields;for(let Oe=0,rt=je.length;Oe<rt;Oe++){let Et=je[Oe],ft=Et.name,Fe=Et.values;switch(ft){case"color":let $e=Fe[0];$e!==null&&(D=c($e));break;case"coord":let ze=Fe[0];ze!==null&&(z=c(ze));break;case"normal":let st=Fe[0];st!==null&&(Q=c(st));break;case"texCoord":let ct=Fe[0];ct!==null&&(ne=c(ct));break;case"ccw":oe=Fe[0];break;case"colorIndex":de=Fe;break;case"colorPerVertex":ke=Fe[0];break;case"convex":break;case"coordIndex":Ee=Fe;break;case"creaseAngle":ge=Fe[0];break;case"normalIndex":Re=Fe;break;case"normalPerVertex":at=Fe[0];break;case"solid":he=Fe[0];break;case"texCoordIndex":De=Fe;break;default:console.warn("THREE.VRMLLoader: Unknown field:",ft);break}}if(Ee===void 0)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new It;let Ke=q(Ee,oe),fe,Le,be;if(D){if(ke===!0)if(de&&de.length>0){let Oe=q(de,oe);fe=j(Ke,Oe,D,3)}else fe=ce(Ke,new We(D,3));else if(de&&de.length>0){let Oe=ye(D,de),rt=le(Oe,Ee);fe=W(Ke,rt)}else{let Oe=le(D,Ee);fe=W(Ke,Oe)}ee(fe)}if(Q)if(at===!0)if(Re&&Re.length>0){let Oe=q(Re,oe);Le=j(Ke,Oe,Q,3)}else Le=ce(Ke,new We(Q,3));else if(Re&&Re.length>0){let Oe=ye(Q,Re),rt=le(Oe,Ee);Le=W(Ke,rt)}else{let Oe=le(Q,Ee);Le=W(Ke,Oe)}else Le=ae(Ke,z,ge);if(ne)if(De&&De.length>0){let Oe=q(De,oe);be=j(Ke,Oe,ne,2)}else be=ce(Ke,new We(ne,2));let Ce=new It,Be=ce(Ke,new We(z,3));return Ce.setAttribute("position",Be),Ce.setAttribute("normal",Le),fe&&Ce.setAttribute("color",fe),be&&Ce.setAttribute("uv",be),Ce._solid=he,Ce._type="mesh",Ce}function C(O){let D,z,Q,ne,oe=!0,he=O.fields;for(let De=0,ke=he.length;De<ke;De++){let at=he[De],je=at.name,Ke=at.values;switch(je){case"color":let fe=Ke[0];fe!==null&&(D=c(fe));break;case"coord":let Le=Ke[0];Le!==null&&(z=c(Le));break;case"colorIndex":Q=Ke;break;case"colorPerVertex":oe=Ke[0];break;case"coordIndex":ne=Ke;break;default:console.warn("THREE.VRMLLoader: Unknown field:",je);break}}let ge,de=Te(ne);if(D){if(oe===!0)if(Q.length>0){let De=Te(Q);ge=j(de,De,D,3)}else ge=ce(de,new We(D,3));else if(Q.length>0){let De=ye(D,Q),ke=Ae(De,ne);ge=re(de,ke)}else{let De=Ae(D,ne);ge=re(de,De)}ee(ge)}let Ee=new It,Re=ce(de,new We(z,3));return Ee.setAttribute("position",Re),ge&&Ee.setAttribute("color",ge),Ee._type="line",Ee}function E(O){let D,z,Q=O.fields;for(let oe=0,he=Q.length;oe<he;oe++){let ge=Q[oe],de=ge.name,Ee=ge.values;switch(de){case"color":let Re=Ee[0];Re!==null&&(D=c(Re));break;case"coord":let De=Ee[0];De!==null&&(z=c(De));break;default:console.warn("THREE.VRMLLoader: Unknown field:",de);break}}let ne=new It;if(ne.setAttribute("position",new We(z,3)),D){let oe=new We(D,3);ee(oe),ne.setAttribute("color",oe)}return ne._type="points",ne}function b(O){let D=new se(2,2,2),z=O.fields;for(let ne=0,oe=z.length;ne<oe;ne++){let he=z[ne],ge=he.name,de=he.values;switch(ge){case"size":D.x=de[0],D.y=de[1],D.z=de[2];break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}return new Is(D.x,D.y,D.z)}function R(O){let D=1,z=2,Q=!1,ne=O.fields;for(let he=0,ge=ne.length;he<ge;he++){let de=ne[he],Ee=de.name,Re=de.values;switch(Ee){case"bottom":Q=!Re[0];break;case"bottomRadius":D=Re[0];break;case"height":z=Re[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",Ee);break}}return new ac(D,z,16,1,Q)}function N(O){let D=1,z=2,Q=O.fields;for(let oe=0,he=Q.length;oe<he;oe++){let ge=Q[oe],de=ge.name,Ee=ge.values;switch(de){case"bottom":break;case"radius":D=Ee[0];break;case"height":z=Ee[0];break;case"side":break;case"top":break;default:console.warn("THREE.VRMLLoader: Unknown field:",de);break}}return new La(D,D,z,16,1)}function B(O){let D=1,z=O.fields;for(let ne=0,oe=z.length;ne<oe;ne++){let he=z[ne],ge=he.name,de=he.values;switch(ge){case"radius":D=de[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}return new mo(D,16,16)}function V(O){let D,z,Q,ne,oe=!0,he=!0,ge=!0,de=!0,Ee=0,Re=2,De=2,ke=1,at=1,je=O.fields;for(let Fe=0,$e=je.length;Fe<$e;Fe++){let ze=je[Fe],st=ze.name,ct=ze.values;switch(st){case"color":let Ft=ct[0];Ft!==null&&(D=c(Ft));break;case"normal":let ci=ct[0];ci!==null&&(z=c(ci));break;case"texCoord":let Mi=ct[0];Mi!==null&&(Q=c(Mi));break;case"height":ne=ct;break;case"ccw":de=ct[0];break;case"colorPerVertex":oe=ct[0];break;case"creaseAngle":Ee=ct[0];break;case"normalPerVertex":he=ct[0];break;case"solid":ge=ct[0];break;case"xDimension":Re=ct[0];break;case"xSpacing":ke=ct[0];break;case"zDimension":De=ct[0];break;case"zSpacing":at=ct[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",st);break}}let Ke=[],fe=[],Le=[],be=[];for(let Fe=0;Fe<De;Fe++)for(let $e=0;$e<Re;$e++){let ze=Fe*Re+$e,st=ke*Fe,ct=ne[ze],Ft=at*$e;if(Ke.push(st,ct,Ft),D&&oe===!0){let ci=D[ze*3+0],Mi=D[ze*3+1],Dr=D[ze*3+2];Le.push(ci,Mi,Dr)}if(z&&he===!0){let ci=z[ze*3+0],Mi=z[ze*3+1],Dr=z[ze*3+2];fe.push(ci,Mi,Dr)}if(Q){let ci=Q[ze*2+0],Mi=Q[ze*2+1];be.push(ci,Mi)}else be.push(Fe/(Re-1),$e/(De-1))}let Ce=[];for(let Fe=0;Fe<Re-1;Fe++)for(let $e=0;$e<De-1;$e++){let ze=Fe+$e*Re,st=Fe+($e+1)*Re,ct=Fe+1+($e+1)*Re,Ft=Fe+1+$e*Re;de===!0?(Ce.push(ze,ct,st),Ce.push(ct,ze,Ft)):(Ce.push(ze,st,ct),Ce.push(ct,Ft,ze))}let Be=ce(Ce,new We(Ke,3)),Oe=ce(Ce,new We(be,2)),rt,Et;if(D){if(oe===!1){for(let Fe=0;Fe<Re-1;Fe++)for(let $e=0;$e<De-1;$e++){let ze=Fe+$e*(Re-1),st=D[ze*3+0],ct=D[ze*3+1],Ft=D[ze*3+2];Le.push(st,ct,Ft),Le.push(st,ct,Ft),Le.push(st,ct,Ft),Le.push(st,ct,Ft),Le.push(st,ct,Ft),Le.push(st,ct,Ft)}rt=new We(Le,3)}else rt=ce(Ce,new We(Le,3));ee(rt)}if(z)if(he===!1){for(let Fe=0;Fe<Re-1;Fe++)for(let $e=0;$e<De-1;$e++){let ze=Fe+$e*(Re-1),st=z[ze*3+0],ct=z[ze*3+1],Ft=z[ze*3+2];fe.push(st,ct,Ft),fe.push(st,ct,Ft),fe.push(st,ct,Ft),fe.push(st,ct,Ft),fe.push(st,ct,Ft),fe.push(st,ct,Ft)}Et=new We(fe,3)}else Et=ce(Ce,new We(fe,3));else Et=ae(Ce,Ke,Ee);let ft=new It;return ft.setAttribute("position",Be),ft.setAttribute("normal",Et),ft.setAttribute("uv",Oe),rt&&ft.setAttribute("color",rt),ft._solid=ge,ft._type="mesh",ft}function ie(O){let D=[1,1,1,-1,-1,-1,-1,1,1,1],z=[0,0,0,0,1,0],Q,ne,oe=!0,he=!0,ge=0,de=!0,Ee=!0,Re=O.fields;for(let ft=0,Fe=Re.length;ft<Fe;ft++){let $e=Re[ft],ze=$e.name,st=$e.values;switch(ze){case"beginCap":oe=st[0];break;case"ccw":he=st[0];break;case"convex":break;case"creaseAngle":ge=st[0];break;case"crossSection":D=st;break;case"endCap":de=st[0];break;case"orientation":ne=st;break;case"scale":Q=st;break;case"solid":Ee=st[0];break;case"spine":z=st;break;default:console.warn("THREE.VRMLLoader: Unknown field:",ze);break}}let De=D[0]===D[D.length-2]&&D[1]===D[D.length-1],ke=[],at=new se,je=new se,Ke=new se,fe=new se,Le=new an;for(let ft=0,Fe=0,$e=0,ze=z.length;ft<ze;ft+=3,Fe+=2,$e+=4){at.fromArray(z,ft),je.x=Q?Q[Fe+0]:1,je.y=1,je.z=Q?Q[Fe+1]:1,Ke.x=ne?ne[$e+0]:0,Ke.y=ne?ne[$e+1]:0,Ke.z=ne?ne[$e+2]:1;let st=ne?ne[$e+3]:0;for(let ct=0,Ft=D.length;ct<Ft;ct+=2)fe.x=D[ct+0],fe.y=0,fe.z=D[ct+1],fe.multiply(je),Le.setFromAxisAngle(Ke,st),fe.applyQuaternion(Le),fe.add(at),ke.push(fe.x,fe.y,fe.z)}let be=[],Ce=z.length/3,Be=D.length/2;for(let ft=0;ft<Ce-1;ft++)for(let Fe=0;Fe<Be-1;Fe++){let $e=Fe+ft*Be,ze=Fe+1+ft*Be,st=Fe+(ft+1)*Be,ct=Fe+1+(ft+1)*Be;Fe===Be-2&&De===!0&&(ze=ft*Be,ct=(ft+1)*Be),he===!0?(be.push($e,ze,st),be.push(st,ze,ct)):(be.push($e,st,ze),be.push(st,ct,ze))}if(oe===!0||de===!0){let ft=[];for(let ze=0,st=D.length;ze<st;ze+=2)ft.push(new Pe(D[ze],D[ze+1]));let Fe=gi.triangulateShape(ft,[]),$e=[];for(let ze=0,st=Fe.length;ze<st;ze++){let ct=Fe[ze];$e.push(ct[0],ct[1],ct[2])}if(oe===!0)for(let ze=0,st=$e.length;ze<st;ze+=3)he===!0?be.push($e[ze+0],$e[ze+1],$e[ze+2]):be.push($e[ze+0],$e[ze+2],$e[ze+1]);if(de===!0){let ze=Be*(Ce-1);for(let st=0,ct=$e.length;st<ct;st+=3)he===!0?be.push(ze+$e[st+0],ze+$e[st+2],ze+$e[st+1]):be.push(ze+$e[st+0],ze+$e[st+1],ze+$e[st+2])}}let Oe=ce(be,new We(ke,3)),rt=ae(be,ke,ge),Et=new It;return Et.setAttribute("position",Oe),Et.setAttribute("normal",rt),Et._solid=Ee,Et._type="mesh",Et}function Y(O){let D=n[O],z=c(D);return z.isObject3D||z.isMaterial?z.clone():z}function te(O,D){for(let z=0,Q=O.length;z<Q;z++){let ne=c(O[z]);ne instanceof Lt&&D.add(ne)}}function q(O,D){let z=[],Q=0;for(let ne=0,oe=O.length;ne<oe;ne++){let he=O[Q],ge=O[ne+(D?1:2)],de=O[ne+(D?2:1)];z.push(he,ge,de),(O[ne+3]===-1||ne+3>=oe)&&(ne+=3,Q=ne+1)}return z}function le(O,D){let z=[],Q=0;for(let ne=0,oe=D.length;ne<oe;ne++){let he=Q*3,ge=O[he],de=O[he+1],Ee=O[he+2];z.push(ge,de,Ee),(D[ne+3]===-1||ne+3>=oe)&&(ne+=3,Q++)}return z}function ye(O,D){let z=[];for(let Q=0,ne=D.length;Q<ne;Q++){let he=D[Q]*3,ge=O[he],de=O[he+1],Ee=O[he+2];z.push(ge,de,Ee)}return z}function Te(O){let D=[];for(let z=0,Q=O.length;z<Q;z++){let ne=O[z],oe=O[z+1];D.push(ne,oe),(O[z+2]===-1||z+2>=Q)&&(z+=2)}return D}function Ae(O,D){let z=[],Q=0;for(let ne=0,oe=D.length;ne<oe;ne++){let he=Q*3,ge=O[he],de=O[he+1],Ee=O[he+2];z.push(ge,de,Ee),(D[ne+2]===-1||ne+2>=oe)&&(ne+=2,Q++)}return z}let _e=new se,G=new se,P=new se,M=new Pe,T=new Pe,k=new Pe;function j(O,D,z,Q){let ne=[];for(let oe=0,he=O.length;oe<he;oe+=3){let ge=D[oe],de=D[oe+1],Ee=D[oe+2];Q===2?(M.fromArray(z,ge*Q),T.fromArray(z,de*Q),k.fromArray(z,Ee*Q),ne.push(M.x,M.y),ne.push(T.x,T.y),ne.push(k.x,k.y)):(_e.fromArray(z,ge*Q),G.fromArray(z,de*Q),P.fromArray(z,Ee*Q),ne.push(_e.x,_e.y,_e.z),ne.push(G.x,G.y,G.z),ne.push(P.x,P.y,P.z))}return new We(ne,Q)}function W(O,D){let z=[];for(let Q=0,ne=0,oe=O.length;Q<oe;Q+=3,ne++)_e.fromArray(D,ne*3),z.push(_e.x,_e.y,_e.z),z.push(_e.x,_e.y,_e.z),z.push(_e.x,_e.y,_e.z);return new We(z,3)}function re(O,D){let z=[];for(let Q=0,ne=0,oe=O.length;Q<oe;Q+=2,ne++)_e.fromArray(D,ne*3),z.push(_e.x,_e.y,_e.z),z.push(_e.x,_e.y,_e.z);return new We(z,3)}function ce(O,D){let z=D.array,Q=D.itemSize,ne=new z.constructor(O.length*Q),oe=0,he=0;for(let ge=0,de=O.length;ge<de;ge++){oe=O[ge]*Q;for(let Ee=0;Ee<Q;Ee++)ne[he++]=z[oe++]}return new We(ne,Q)}let me=new se,w=new se;function ae(O,D,z){let Q=[],ne={};for(let he=0,ge=O.length;he<ge;he+=3){let de=O[he],Ee=O[he+1],Re=O[he+2],De=new Am(de,Ee,Re);_e.fromArray(D,de*3),G.fromArray(D,Ee*3),P.fromArray(D,Re*3),w.subVectors(P,G),me.subVectors(_e,G),w.cross(me),w.normalize(),De.normal.copy(w),ne[de]===void 0&&(ne[de]=[]),ne[Ee]===void 0&&(ne[Ee]=[]),ne[Re]===void 0&&(ne[Re]=[]),ne[de].push(De.normal),ne[Ee].push(De.normal),ne[Re].push(De.normal),Q.push(De)}let oe=[];for(let he=0,ge=Q.length;he<ge;he++){let de=Q[he],Ee=pe(ne[de.a],de.normal,z),Re=pe(ne[de.b],de.normal,z),De=pe(ne[de.c],de.normal,z);_e.fromArray(D,de.a*3),G.fromArray(D,de.b*3),P.fromArray(D,de.c*3),oe.push(Ee.x,Ee.y,Ee.z),oe.push(Re.x,Re.y,Re.z),oe.push(De.x,De.y,De.z)}return new We(oe,3)}function pe(O,D,z){let Q=new se;if(z===0)Q.copy(D);else for(let ne=0,oe=O.length;ne<oe;ne++)O[ne].angleTo(D)<z&&Q.add(O[ne]);return Q.normalize()}function ue(O){let D=[];for(let z=0,Q=O.length;z<Q;z+=3)D.push(new He(O[z],O[z+1],O[z+2]));return D}function ee(O){let D=new He;for(let z=0;z<O.count;z++)D.fromBufferAttribute(O,z),mt.toWorkingColorSpace(D,yt),O.setXYZ(z,D.r,D.g,D.b)}function $(O,D,z,Q,ne){let oe=[],he=ne===!0?0:Math.PI;for(let ke=0,at=Q.length;ke<at;ke++){let je=ke===0?0:z[ke-1];je=ne===!0?je:he-je;let Ke=new se;Ke.setFromSphericalCoords(D,je,0),oe.push(Ke)}let ge=O.index,de=O.attributes.position,Ee=new Vn(new Float32Array(O.attributes.position.count*3),3),Re=new se,De=new He;for(let ke=0;ke<ge.count;ke++){let at=ge.getX(ke);Re.fromBufferAttribute(de,at);let je,Ke,fe=1;for(let Ce=1;Ce<oe.length;Ce++){je=Ce-1,Ke=Ce;let Be=oe[je],Oe=oe[Ke];if(ne===!0){if(Re.y<=Be.y&&Re.y>Oe.y){fe=Math.abs(Be.y-Re.y)/Math.abs(Be.y-Oe.y);break}}else if(Re.y>=Be.y&&Re.y<Oe.y){fe=Math.abs(Be.y-Re.y)/Math.abs(Be.y-Oe.y);break}}let Le=Q[je],be=Q[Ke];De.copy(Le).lerp(be,fe),mt.toWorkingColorSpace(De,yt),Ee.setXYZ(at,De.r,De.g,De.b)}O.setAttribute("color",Ee)}let ve=new Ri(this.manager);if(ve.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),e.indexOf("#VRML V2.0")===-1)throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");let H=i(e);return a(H)}},bm=class{constructor(e){this.lexer=new al.Lexer(e)}lex(e){let t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}},FS=al.CstParser,Sm=class extends FS{constructor(e){super(e);let t=this,n=e.Version,i=e.LCurly,s=e.RCurly,o=e.LSquare,a=e.RSquare,l=e.Identifier,c=e.RouteIdentifier,u=e.StringLiteral,h=e.HexLiteral,f=e.NumberLiteral,p=e.TrueLiteral,g=e.FalseLiteral,y=e.NullLiteral,d=e.DEF,m=e.USE,_=e.ROUTE,v=e.TO,x=e.NodeName;t.RULE("vrml",function(){t.SUBRULE(t.version),t.AT_LEAST_ONE(function(){t.SUBRULE(t.node)}),t.MANY(function(){t.SUBRULE(t.route)})}),t.RULE("version",function(){t.CONSUME(n)}),t.RULE("node",function(){t.OPTION(function(){t.SUBRULE(t.def)}),t.CONSUME(x),t.CONSUME(i),t.MANY(function(){t.SUBRULE(t.field)}),t.CONSUME(s)}),t.RULE("field",function(){t.CONSUME(l),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])}),t.RULE("def",function(){t.CONSUME(d),t.OR([{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(x)}}])}),t.RULE("use",function(){t.CONSUME(m),t.OR([{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(x)}}])}),t.RULE("singleFieldValue",function(){t.AT_LEAST_ONE(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(y)}}])})}),t.RULE("multiFieldValue",function(){t.CONSUME(o),t.MANY(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(y)}}])}),t.CONSUME(a)}),t.RULE("route",function(){t.CONSUME(_),t.CONSUME(c),t.CONSUME(v),t.CONSUME2(c)}),this.performSelfAnalysis()}},Am=class{constructor(e,t,n){this.a=e,this.b=t,this.c=n,this.normal=new se}},pr={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};var wm=yt,Kf=class extends zt{constructor(e){super(e),this.availableExtensions=[]}load(e,t,n,i){let s=this,o=new $n(s.manager);o.setPath(s.path),o.setResponseType("arraybuffer"),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(a))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t=this,n=new Ri(this.manager);function i(M){let T=null,k=null,j,W,re=[],ce=[],me,w={},ae={},pe={},ue=new TextDecoder;try{T=Ff(new Uint8Array(M))}catch(L){if(L instanceof ReferenceError)return console.error("THREE.3MFLoader: fflate missing and file is compressed."),null}let ee=null;for(k in T)k.match(/\_rels\/.rels$/)?j=k:k.match(/3D\/_rels\/.*\.model\.rels$/)?W=k:k.match(/^3D\/[^\/]*\.model$/)?ee=k:k.match(/^3D\/.*\/.*\.model$/)?re.push(k):k.match(/^3D\/Textures?\/.*/)&&ce.push(k);if(re.push(ee),j===void 0)throw new Error("THREE.ThreeMFLoader: Cannot find relationship file `rels` in 3MF archive.");let $=T[j],ve=ue.decode($),H=s(ve);if(W){let L=T[W],O=ue.decode(L);me=s(O)}for(let L=0;L<re.length;L++){let O=re[L],D=T[O],z=ue.decode(D),Q=new DOMParser().parseFromString(z,"application/xml");Q.documentElement.nodeName.toLowerCase()!=="model"&&console.error("THREE.3MFLoader: Error loading 3MF - no 3MF document found: ",O);let ne=Q.querySelector("model"),oe={};for(let ge=0;ge<ne.attributes.length;ge++){let de=ne.attributes[ge];de.name.match(/^xmlns:(.+)$/)&&(oe[de.value]=RegExp.$1)}let he=I(ne);he.xml=ne,0<Object.keys(oe).length&&(he.extensions=oe),w[O]=he}for(let L=0;L<ce.length;L++){let O=ce[L];pe[O]=T[O].buffer}return{rels:H,modelRels:me,model:w,printTicket:ae,texture:pe}}function s(M){let T=[],j=new DOMParser().parseFromString(M,"application/xml").querySelectorAll("Relationship");for(let W=0;W<j.length;W++){let re=j[W],ce={target:re.getAttribute("Target"),id:re.getAttribute("Id"),type:re.getAttribute("Type")};T.push(ce)}return T}function o(M){let T={};for(let k=0;k<M.length;k++){let j=M[k],W=j.getAttribute("name");0<=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate"].indexOf(W)&&(T[W]=j.textContent)}return T}function a(M){let T={id:M.getAttribute("id"),basematerials:[]},k=M.querySelectorAll("base");for(let j=0;j<k.length;j++){let W=k[j],re=g(W);re.index=j,T.basematerials.push(re)}return T}function l(M){return{id:M.getAttribute("id"),path:M.getAttribute("path"),contenttype:M.getAttribute("contenttype"),tilestyleu:M.getAttribute("tilestyleu"),tilestylev:M.getAttribute("tilestylev"),filter:M.getAttribute("filter")}}function c(M){let T={id:M.getAttribute("id"),texid:M.getAttribute("texid"),displaypropertiesid:M.getAttribute("displaypropertiesid")},k=M.querySelectorAll("tex2coord"),j=[];for(let W=0;W<k.length;W++){let re=k[W],ce=re.getAttribute("u"),me=re.getAttribute("v");j.push(parseFloat(ce),parseFloat(me))}return T.uvs=new Float32Array(j),T}function u(M){let T={id:M.getAttribute("id"),displaypropertiesid:M.getAttribute("displaypropertiesid")},k=M.querySelectorAll("color"),j=[],W=new He;for(let re=0;re<k.length;re++){let me=k[re].getAttribute("color");W.setStyle(me.substring(0,7),wm),j.push(W.r,W.g,W.b)}return T.colors=new Float32Array(j),T}function h(M){let T=M.children,k={};for(let j=0;j<T.length;j++){let W={type:T[j].nodeName.substring(2)};for(let re=0;re<T[j].attributes.length;re++){let ce=T[j].attributes[re];ce.specified&&(W[ce.name]=ce.value)}k[T[j].getAttribute("identifier")]=W}return k}function f(M){let T={id:M.getAttribute("id"),displayname:M.getAttribute("displayname")},k=M.children,j={};for(let W=0;W<k.length;W++){let re=k[W];if(re.nodeName==="i:in"||re.nodeName==="i:out")j[re.nodeName==="i:in"?"inputs":"outputs"]=h(re);else{let ce=re.children,me={op:re.nodeName.substring(2),identifier:re.getAttribute("identifier")};for(let w=0;w<ce.length;w++)me[ce[w].nodeName.substring(2)]=h(ce[w]);j[me.identifier]=me}}return T.operations=j,T}function p(M){let T={id:M.getAttribute("id")},k=M.querySelectorAll("pbmetallic"),j=[];for(let W=0;W<k.length;W++){let re=k[W];j.push({name:re.getAttribute("name"),metallicness:parseFloat(re.getAttribute("metallicness")),roughness:parseFloat(re.getAttribute("roughness"))})}return T.data=j,T}function g(M){let T={};return T.name=M.getAttribute("name"),T.displaycolor=M.getAttribute("displaycolor"),T.displaypropertiesid=M.getAttribute("displaypropertiesid"),T}function y(M){let T={},k=[],j=M.querySelectorAll("vertices vertex");for(let me=0;me<j.length;me++){let w=j[me],ae=w.getAttribute("x"),pe=w.getAttribute("y"),ue=w.getAttribute("z");k.push(parseFloat(ae),parseFloat(pe),parseFloat(ue))}T.vertices=new Float32Array(k);let W=[],re=[],ce=M.querySelectorAll("triangles triangle");for(let me=0;me<ce.length;me++){let w=ce[me],ae=w.getAttribute("v1"),pe=w.getAttribute("v2"),ue=w.getAttribute("v3"),ee=w.getAttribute("p1"),$=w.getAttribute("p2"),ve=w.getAttribute("p3"),H=w.getAttribute("pid"),L={};L.v1=parseInt(ae,10),L.v2=parseInt(pe,10),L.v3=parseInt(ue,10),re.push(L.v1,L.v2,L.v3),ee&&(L.p1=parseInt(ee,10)),$&&(L.p2=parseInt($,10)),ve&&(L.p3=parseInt(ve,10)),H&&(L.pid=H),0<Object.keys(L).length&&W.push(L)}return T.triangleProperties=W,T.triangles=new Uint32Array(re),T}function d(M){let T=[],k=M.querySelectorAll("component");for(let j=0;j<k.length;j++){let W=k[j],re=m(W);T.push(re)}return T}function m(M){let T={};T.objectId=M.getAttribute("objectid");let k=M.getAttribute("transform");return k&&(T.transform=_(k)),T}function _(M){let T=[];M.split(" ").forEach(function(j){T.push(parseFloat(j))});let k=new Je;return k.set(T[0],T[3],T[6],T[9],T[1],T[4],T[7],T[10],T[2],T[5],T[8],T[11],0,0,0,1),k}function v(M){let T={type:M.getAttribute("type")},k=M.getAttribute("id");k&&(T.id=k);let j=M.getAttribute("pid");j&&(T.pid=j);let W=M.getAttribute("pindex");W&&(T.pindex=W);let re=M.getAttribute("thumbnail");re&&(T.thumbnail=re);let ce=M.getAttribute("partnumber");ce&&(T.partnumber=ce);let me=M.getAttribute("name");me&&(T.name=me);let w=M.querySelector("mesh");w&&(T.mesh=y(w));let ae=M.querySelector("components");return ae&&(T.components=d(ae)),T}function x(M){let T={};T.basematerials={};let k=M.querySelectorAll("basematerials");for(let ae=0;ae<k.length;ae++){let pe=k[ae],ue=a(pe);T.basematerials[ue.id]=ue}T.texture2d={};let j=M.querySelectorAll("texture2d");for(let ae=0;ae<j.length;ae++){let pe=j[ae],ue=l(pe);T.texture2d[ue.id]=ue}T.colorgroup={};let W=M.querySelectorAll("colorgroup");for(let ae=0;ae<W.length;ae++){let pe=W[ae],ue=u(pe);T.colorgroup[ue.id]=ue}let re=M.querySelectorAll("implicitfunction");re.length>0&&(T.implicitfunction={});for(let ae=0;ae<re.length;ae++){let pe=re[ae],ue=f(pe);T.implicitfunction[ue.id]=ue}T.pbmetallicdisplayproperties={};let ce=M.querySelectorAll("pbmetallicdisplayproperties");for(let ae=0;ae<ce.length;ae++){let pe=ce[ae],ue=p(pe);T.pbmetallicdisplayproperties[ue.id]=ue}T.texture2dgroup={};let me=M.querySelectorAll("texture2dgroup");for(let ae=0;ae<me.length;ae++){let pe=me[ae],ue=c(pe);T.texture2dgroup[ue.id]=ue}T.object={};let w=M.querySelectorAll("object");for(let ae=0;ae<w.length;ae++){let pe=w[ae],ue=v(pe);T.object[ue.id]=ue}return T}function S(M){let T=[],k=M.querySelectorAll("item");for(let j=0;j<k.length;j++){let W=k[j],re={objectId:W.getAttribute("objectid")},ce=W.getAttribute("transform");ce&&(re.transform=_(ce)),T.push(re)}return T}function I(M){let T={unit:M.getAttribute("unit")||"millimeter"},k=M.querySelectorAll("metadata");k&&(T.metadata=o(k));let j=M.querySelector("resources");j&&(T.resources=x(j));let W=M.querySelector("build");return W&&(T.build=S(W)),T}function A(M,T,k,j){let W=M.texid,ce=k.resources.texture2d[W];if(ce){let me=j[ce.path],w=ce.contenttype,ae=new Blob([me],{type:w}),pe=URL.createObjectURL(ae),ue=n.load(pe,function(){URL.revokeObjectURL(pe)});switch(ue.colorSpace=wm,ce.tilestyleu){case"wrap":ue.wrapS=on;break;case"mirror":ue.wrapS=so;break;case"none":case"clamp":ue.wrapS=un;break;default:ue.wrapS=on}switch(ce.tilestylev){case"wrap":ue.wrapT=on;break;case"mirror":ue.wrapT=so;break;case"none":case"clamp":ue.wrapT=un;break;default:ue.wrapT=on}switch(ce.filter){case"auto":ue.magFilter=Pn,ue.minFilter=xi;break;case"linear":ue.magFilter=Pn,ue.minFilter=Pn,ue.generateMipmaps=!1;break;case"nearest":ue.magFilter=Xn,ue.minFilter=Xn,ue.generateMipmaps=!1;break;default:ue.magFilter=Pn,ue.minFilter=xi}return ue}else return null}function C(M,T,k,j,W,re,ce){let me=ce.pindex,w={};for(let ue=0,ee=T.length;ue<ee;ue++){let $=T[ue],ve=$.p1!==void 0?$.p1:me;w[ve]===void 0&&(w[ve]=[]),w[ve].push($)}let ae=Object.keys(w),pe=[];for(let ue=0,ee=ae.length;ue<ee;ue++){let $=ae[ue],ve=w[$],H=M.basematerials[$],L=te(H,j,W,re,ce,q),O=new It,D=[],z=k.vertices;for(let ne=0,oe=ve.length;ne<oe;ne++){let he=ve[ne];D.push(z[he.v1*3+0]),D.push(z[he.v1*3+1]),D.push(z[he.v1*3+2]),D.push(z[he.v2*3+0]),D.push(z[he.v2*3+1]),D.push(z[he.v2*3+2]),D.push(z[he.v3*3+0]),D.push(z[he.v3*3+1]),D.push(z[he.v3*3+2])}O.setAttribute("position",new We(D,3));let Q=new Dt(O,L);pe.push(Q)}return pe}function E(M,T,k,j,W,re,ce){let me=new It,w=[],ae=[],pe=k.vertices,ue=M.uvs;for(let H=0,L=T.length;H<L;H++){let O=T[H];w.push(pe[O.v1*3+0]),w.push(pe[O.v1*3+1]),w.push(pe[O.v1*3+2]),w.push(pe[O.v2*3+0]),w.push(pe[O.v2*3+1]),w.push(pe[O.v2*3+2]),w.push(pe[O.v3*3+0]),w.push(pe[O.v3*3+1]),w.push(pe[O.v3*3+2]),ae.push(ue[O.p1*2+0]),ae.push(ue[O.p1*2+1]),ae.push(ue[O.p2*2+0]),ae.push(ue[O.p2*2+1]),ae.push(ue[O.p3*2+0]),ae.push(ue[O.p3*2+1])}me.setAttribute("position",new We(w,3)),me.setAttribute("uv",new We(ae,2));let ee=te(M,j,W,re,ce,A),$=new Zt({map:ee,flatShading:!0});return new Dt(me,$)}function b(M,T,k,j){let W=new It,re=[],ce=[],me=k.vertices,w=M.colors;for(let ue=0,ee=T.length;ue<ee;ue++){let $=T[ue],ve=$.v1,H=$.v2,L=$.v3;re.push(me[ve*3+0]),re.push(me[ve*3+1]),re.push(me[ve*3+2]),re.push(me[H*3+0]),re.push(me[H*3+1]),re.push(me[H*3+2]),re.push(me[L*3+0]),re.push(me[L*3+1]),re.push(me[L*3+2]);let O=$.p1!==void 0?$.p1:j.pindex,D=$.p2!==void 0?$.p2:O,z=$.p3!==void 0?$.p3:O;ce.push(w[O*3+0]),ce.push(w[O*3+1]),ce.push(w[O*3+2]),ce.push(w[D*3+0]),ce.push(w[D*3+1]),ce.push(w[D*3+2]),ce.push(w[z*3+0]),ce.push(w[z*3+1]),ce.push(w[z*3+2])}W.setAttribute("position",new We(re,3)),W.setAttribute("color",new We(ce,3));let ae=new Zt({vertexColors:!0,flatShading:!0});return new Dt(W,ae)}function R(M){let T=new It;T.setIndex(new Vn(M.triangles,1)),T.setAttribute("position",new Vn(M.vertices,3));let k=new Zt({name:zt.DEFAULT_MATERIAL_NAME,color:16777215,flatShading:!0});return new Dt(T,k)}function N(M,T,k,j,W,re){let ce=Object.keys(M),me=[];for(let w=0,ae=ce.length;w<ae;w++){let pe=ce[w],ue=M[pe];switch(B(pe,j)){case"material":let $=j.resources.basematerials[pe],ve=C($,ue,T,k,j,W,re);for(let O=0,D=ve.length;O<D;O++)me.push(ve[O]);break;case"texture":let H=j.resources.texture2dgroup[pe];me.push(E(H,ue,T,k,j,W,re));break;case"vertexColors":let L=j.resources.colorgroup[pe];me.push(b(L,ue,T,re));break;case"default":me.push(R(T));break;default:console.error("THREE.3MFLoader: Unsupported resource type.")}}if(re.name)for(let w=0;w<me.length;w++)me[w].name=re.name;return me}function B(M,T){return T.resources.texture2dgroup[M]!==void 0?"texture":T.resources.basematerials[M]!==void 0?"material":T.resources.colorgroup[M]!==void 0?"vertexColors":M==="default"?"default":void 0}function V(M,T){let k={},j=M.triangleProperties,W=T.pid;for(let re=0,ce=j.length;re<ce;re++){let me=j[re],w=me.pid!==void 0?me.pid:W;w===void 0&&(w="default"),k[w]===void 0&&(k[w]=[]),k[w].push(me)}return k}function ie(M,T,k,j,W){let re=new gn,ce=V(M,W),me=N(ce,M,T,k,j,W);for(let w=0,ae=me.length;w<ae;w++)re.add(me[w]);return re}function Y(M,T,k){if(!M)return;let j=[],W=Object.keys(M);for(let re=0;re<W.length;re++){let ce=W[re];for(let me=0;me<t.availableExtensions.length;me++){let w=t.availableExtensions[me];w.ns===ce&&j.push(w)}}for(let re=0;re<j.length;re++){let ce=j[re];ce.apply(k,M[ce.ns],T)}}function te(M,T,k,j,W,re){return M.build!==void 0||(M.build=re(M,T,k,j,W)),M.build}function q(M,T,k){let j,W=M.displaypropertiesid,re=k.resources.pbmetallicdisplayproperties;if(W!==null&&re[W]!==void 0){let ae=re[W].data[M.index];j=new ts({flatShading:!0,roughness:ae.roughness,metalness:ae.metallicness})}else j=new Zt({flatShading:!0});j.name=M.name;let ce=M.displaycolor,me=ce.substring(0,7);return j.color.setStyle(me,wm),ce.length===9&&(j.opacity=parseInt(ce.charAt(7)+ce.charAt(8),16)/255),j}function le(M,T,k,j){let W=new gn;for(let re=0;re<M.length;re++){let ce=M[re],me=T[ce.objectId];me===void 0&&(ye(ce.objectId,T,k,j),me=T[ce.objectId]);let w=me.clone(),ae=ce.transform;ae&&w.applyMatrix4(ae),W.add(w)}return W}function ye(M,T,k,j){let W=k.resources.object[M];if(W.mesh){let re=W.mesh,ce=k.extensions,me=k.xml;Y(ce,re,me),T[W.id]=te(re,T,k,j,W,ie)}else{let re=W.components;T[W.id]=te(re,T,k,j,W,le)}W.name&&(T[W.id].name=W.name),k.resources.implicitfunction&&console.warn("THREE.ThreeMFLoader: Implicit Functions are implemented in data-only.",k.resources.implicitfunction)}function Te(M){let T=M.model,k=M.modelRels,j={},W=Object.keys(T),re={};if(k)for(let ce=0,me=k.length;ce<me;ce++){let w=k[ce],ae=w.target.substring(1);M.texture[ae]&&(re[w.target]=M.texture[ae])}for(let ce=0;ce<W.length;ce++){let me=W[ce],w=T[me],ae=Object.keys(w.resources.object);for(let pe=0;pe<ae.length;pe++){let ue=ae[pe];ye(ue,j,w,re)}}return j}function Ae(M){for(let T=0;T<M.length;T++){let k=M[T];if(k.target.split(".").pop().toLowerCase()==="model")return k}}function _e(M,T){let k=new gn,j=Ae(T.rels),W=T.model[j.target.substring(1)].build;for(let re=0;re<W.length;re++){let ce=W[re],me=M[ce.objectId].clone(),w=ce.transform;w&&me.applyMatrix4(w),k.add(me)}return k}let G=i(e),P=Te(G);return _e(P,G)}addExtension(e){this.availableExtensions.push(e)}};var Zf=class extends zt{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new $n(s.manager);o.setPath(s.path),o.setResponseType("arraybuffer"),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(a))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){function t(x){let S=new DataView(x);if(String.fromCharCode(S.getUint8(0),S.getUint8(1))==="PK"){let E=null,b=null;console.log("THREE.AMFLoader: Loading Zip");try{E=Ff(new Uint8Array(x))}catch(R){if(R instanceof ReferenceError)return console.log("THREE.AMFLoader: fflate missing and file is compressed."),null}for(b in E)if(b.toLowerCase().slice(-4)===".amf")break;console.log("THREE.AMFLoader: Trying to load file asset: "+b),S=new DataView(E[b].buffer)}let A=new TextDecoder().decode(S),C=new DOMParser().parseFromString(A,"application/xml");return C.documentElement.nodeName.toLowerCase()!=="amf"?(console.log("THREE.AMFLoader: Error loading AMF - no AMF document found."),null):C}function n(x){let S=1,I="millimeter";x.documentElement.attributes.unit!==void 0&&(I=x.documentElement.attributes.unit.value.toLowerCase());let A={millimeter:1,inch:25.4,feet:304.8,meter:1e3,micron:.001};return A[I]!==void 0&&(S=A[I]),console.log("THREE.AMFLoader: Unit scale: "+S),S}function i(x){let S="AMF Material",I=x.attributes.id.textContent,A={r:1,g:1,b:1,a:1},C=null;for(let E=0;E<x.childNodes.length;E++){let b=x.childNodes[E];b.nodeName==="metadata"&&b.attributes.type!==void 0?b.attributes.type.value==="name"&&(S=b.textContent):b.nodeName==="color"&&(A=s(b))}return C=new Zt({flatShading:!0,color:new He(A.r,A.g,A.b),name:S}),A.a!==1&&(C.transparent=!0,C.opacity=A.a),{id:I,material:C}}function s(x){let S={r:1,g:1,b:1,a:1};for(let I=0;I<x.childNodes.length;I++){let A=x.childNodes[I];A.nodeName==="r"?S.r=A.textContent:A.nodeName==="g"?S.g=A.textContent:A.nodeName==="b"?S.b=A.textContent:A.nodeName==="a"&&(S.a=A.textContent)}return S}function o(x){let S={name:"",triangles:[],materialId:null},I=x.firstElementChild;for(x.attributes.materialid!==void 0&&(S.materialId=x.attributes.materialid.nodeValue);I;){if(I.nodeName==="metadata")I.attributes.type!==void 0&&I.attributes.type.value==="name"&&(S.name=I.textContent);else if(I.nodeName==="triangle"){let A=I.getElementsByTagName("v1")[0].textContent,C=I.getElementsByTagName("v2")[0].textContent,E=I.getElementsByTagName("v3")[0].textContent;S.triangles.push(A,C,E)}I=I.nextElementSibling}return S}function a(x){let S=[],I=[],A=x.firstElementChild;for(;A;){if(A.nodeName==="vertex"){let C=A.firstElementChild;for(;C;){if(C.nodeName==="coordinates"){let E=C.getElementsByTagName("x")[0].textContent,b=C.getElementsByTagName("y")[0].textContent,R=C.getElementsByTagName("z")[0].textContent;S.push(E,b,R)}else if(C.nodeName==="normal"){let E=C.getElementsByTagName("nx")[0].textContent,b=C.getElementsByTagName("ny")[0].textContent,R=C.getElementsByTagName("nz")[0].textContent;I.push(E,b,R)}C=C.nextElementSibling}}A=A.nextElementSibling}return{vertices:S,normals:I}}function l(x){let S=x.attributes.id.textContent,I={name:"amfobject",meshes:[]},A=null,C=x.firstElementChild;for(;C;){if(C.nodeName==="metadata")C.attributes.type!==void 0&&C.attributes.type.value==="name"&&(I.name=C.textContent);else if(C.nodeName==="color")A=s(C);else if(C.nodeName==="mesh"){let E=C.firstElementChild,b={vertices:[],normals:[],volumes:[],color:A};for(;E;){if(E.nodeName==="vertices"){let R=a(E);b.normals=b.normals.concat(R.normals),b.vertices=b.vertices.concat(R.vertices)}else E.nodeName==="volume"&&b.volumes.push(o(E));E=E.nextElementSibling}I.meshes.push(b)}C=C.nextElementSibling}return{id:S,obj:I}}let c=t(e),u="",h="",f=n(c),p={},g={},y=c.documentElement.childNodes,d,m;for(d=0;d<y.length;d++){let x=y[d];if(x.nodeName==="metadata")x.attributes.type!==void 0&&(x.attributes.type.value==="name"?u=x.textContent:x.attributes.type.value==="author"&&(h=x.textContent));else if(x.nodeName==="material"){let S=i(x);p[S.id]=S.material}else if(x.nodeName==="object"){let S=l(x);g[S.id]=S.obj}}let _=new gn,v=new Zt({name:zt.DEFAULT_MATERIAL_NAME,color:11184895,flatShading:!0});_.name=u,_.userData.author=h,_.userData.loader="AMF";for(let x in g){let S=g[x],I=S.meshes,A=new gn;for(A.name=S.name||"",d=0;d<I.length;d++){let C=v,E=I[d],b=new We(E.vertices,3),R=null;if(E.normals.length&&(R=new We(E.normals,3)),E.color){let B=E.color;C=v.clone(),C.color=new He(B.r,B.g,B.b),B.a!==1&&(C.transparent=!0,C.opacity=B.a)}let N=E.volumes;for(m=0;m<N.length;m++){let B=N[m],V=new It,ie=C;V.setIndex(B.triangles),V.setAttribute("position",b.clone()),R&&V.setAttribute("normal",R.clone()),p[B.materialId]!==void 0&&(ie=p[B.materialId]),V.scale(f,f,f),A.add(new Dt(V,ie.clone()))}}_.add(A)}return _}};var mr=class extends Jt{constructor(){super(),this.colorConverter=null}CreateLoader(e){return null}GetMainObject(e){return e}IsMeshVisible(e){return!0}ClearContent(){this.loader=null,this.materialIdToIndex=null,this.objectUrlToFileName=null}ResetContent(){this.loader=null,this.materialIdToIndex=new Map,this.objectUrlToFileName=new Map}ImportContent(e,t){this.LoadModel(e,t)}LoadModel(e,t){let n=!1,i=new Fa(()=>{n=!0}),s=js(e);i.setURLModifier(a=>{if(a===s)return a;let l=Rn(a);if(Tr(a).length>0){let u=this.callbacks.getFileBuffer(a);if(u!==null){let h=js(u);return this.objectUrlToFileName.set(h,l),h}}return a});let o=this.CreateLoader(i);if(o===null){t();return}o.load(s,a=>{gu(()=>n?(this.OnThreeObjectsLoaded(a,t),!1):!0)},()=>{},a=>{this.SetError(a),t()})}OnThreeObjectsLoaded(e,t){function n(a){let l=new xn().CreateIdentity();return a.updateMatrix(),a.matrix!==void 0&&a.matrix!==null&&l.Set(a.matrix.elements),new pn(l)}function i(a,l,c,u){let h=new Bn;c.name!==void 0&&h.SetName(c.name),h.SetTransformation(n(c)),u.AddChildNode(h);for(let f of c.children)i(a,l,f,h);if(c.isMesh&&a.IsMeshVisible(c)){let f=a.ConvertThreeMesh(c),p=l.AddMesh(f);h.AddMeshIndex(p)}}let s=this.GetMainObject(e),o=this.model.GetRootNode();o.SetTransformation(n(s));for(let a of s.children)i(this,this.model,a,o);t()}ConvertThreeMesh(e){let t=null;if(Array.isArray(e.material)){if(t=ur(e.geometry,null,this.colorConverter),e.geometry.attributes.color===void 0||e.geometry.attributes.color===null){let n=[];for(let i=0;i<e.material.length;i++){let s=e.material[i],o=this.FindOrCreateMaterial(s);n.push(o)}for(let i=0;i<e.geometry.groups.length;i++){let s=e.geometry.groups[i],o=null;s.count===1/0?o=t.TriangleCount():o=s.start/3+s.count/3;for(let a=s.start/3;a<o;a++)t.GetTriangle(a).SetMaterial(n[s.materialIndex])}}}else{let n=this.FindOrCreateMaterial(e.material);t=ur(e.geometry,n,this.colorConverter)}return e.name!==void 0&&e.name!==null&&t.SetName(e.name),t}FindOrCreateMaterial(e){if(this.materialIdToIndex.has(e.id))return this.materialIdToIndex.get(e.id);let t=this.ConvertThreeMaterial(e),n=null;return t!==null&&(n=this.model.AddMaterial(t)),this.materialIdToIndex.set(e.id,n),n}ConvertThreeMaterial(e){function t(i,s){function o(a){if(a.data!==void 0&&a.data!==null){let l=new ImageData(a.width,a.height),c=a.width*a.height*4;for(let u=0;u<c;u++)l.data[u]=a.data[u];return ao.getDataURL(l)}else return ao.getDataURL(a)}if(i==null||i.image===void 0||i.image===null)return null;try{let a=o(i.image),l=qs(a),c=new fi,u=null;return s.has(i.image.src)?u=s.get(i.image.src):i.name!==void 0&&i.name!==null?u=i.name+"."+xs(l.mimeType):u="Embedded_"+i.id.toString()+"."+xs(l.mimeType),c.name=u,c.mimeType=l.mimeType,c.buffer=l.buffer,c.rotation=i.rotation,c.offset.x=i.offset.x,c.offset.y=i.offset.y,c.scale.x=i.repeat.x,c.scale.y=i.repeat.y,c}catch{return null}}if(e.name===zt.DEFAULT_MATERIAL_NAME)return null;let n=new En;return n.name=e.name,n.color=this.ConvertThreeColor(e.color),n.opacity=e.opacity,n.transparent=e.transparent,n.alphaTest=e.alphaTest,e.type==="MeshPhongMaterial"&&(n.specular=this.ConvertThreeColor(e.specular),n.shininess=e.shininess/100),n.diffuseMap=t(e.map,this.objectUrlToFileName),n.normalMap=t(e.normalMap,this.objectUrlToFileName),n.bumpMap=t(e.bumpMap,this.objectUrlToFileName),n}ConvertThreeColor(e){return this.colorConverter!==null&&(e=this.colorConverter.Convert(e)),Fc(e)}},ll=class extends mr{constructor(){super()}CanImportExtension(e){return e==="fbx"}GetUpDirection(){return _t.Y}CreateLoader(e){return e.addHandler(/\.tga$/i,new Fs(e)),new Bf(e)}GetMainObject(e){return e}},cl=class extends mr{constructor(){super()}CanImportExtension(e){return e==="dae"}GetUpDirection(){return _t.Y}CreateLoader(e){return e.addHandler(/\.tga$/i,new Fs(e)),new zf(e)}GetMainObject(e){return e.scene}},ul=class extends mr{constructor(){super()}CanImportExtension(e){return e==="wrl"}GetUpDirection(){return _t.Y}CreateLoader(e){return new Yf(e)}GetMainObject(e){return e}IsMeshVisible(e){let t=!0;if(Array.isArray(e.material)){for(let n=0;n<e.material.length;n++)if(e.material[n].side===_n){t=!1;break}}else t=e.material.side!==_n;return t}},hl=class extends mr{constructor(){super(),this.colorConverter=new Ya}CanImportExtension(e){return e==="3mf"}GetUpDirection(){return _t.Z}CreateLoader(e){return new Kf(e)}GetMainObject(e){return e}},fl=class extends mr{constructor(){super()}CanImportExtension(e){return e==="amf"}GetUpDirection(){return _t.Z}CreateLoader(e){return new Zf(e)}GetMainObject(e){return e}};var Oi=Uint8Array,dl=Uint16Array,US=Int32Array,lx=new Oi([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),cx=new Oi([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),kS=new Oi([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ux=function(r,e){for(var t=new dl(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new US(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)i[s]=s-t[n]<<5|n;return{b:t,r:i}},hx=ux(lx,2),fx=hx.b,BS=hx.r;fx[28]=258,BS[258]=28;var dx=ux(cx,0),GS=dx.b,JL=dx.r,Pm=new dl(32768);for(Xt=0;Xt<32768;++Xt)ds=(Xt&43690)>>1|(Xt&21845)<<1,ds=(ds&52428)>>2|(ds&13107)<<2,ds=(ds&61680)>>4|(ds&3855)<<4,Pm[Xt]=((ds&65280)>>8|(ds&255)<<8)>>1;var ds,Xt,Wc=function(r,e,t){for(var n=r.length,i=0,s=new dl(e);i<n;++i)r[i]&&++s[r[i]-1];var o=new dl(e);for(i=1;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(t){a=new dl(1<<e);var l=15-e;for(i=0;i<n;++i)if(r[i])for(var c=i<<4|r[i],u=e-r[i],h=o[r[i]-1]++<<u,f=h|(1<<u)-1;h<=f;++h)a[Pm[h]>>l]=c}else for(a=new dl(n),i=0;i<n;++i)r[i]&&(a[i]=Pm[o[r[i]-1]++]>>15-r[i]);return a},Xc=new Oi(288);for(Xt=0;Xt<144;++Xt)Xc[Xt]=8;var Xt;for(Xt=144;Xt<256;++Xt)Xc[Xt]=9;var Xt;for(Xt=256;Xt<280;++Xt)Xc[Xt]=7;var Xt;for(Xt=280;Xt<288;++Xt)Xc[Xt]=8;var Xt,px=new Oi(32);for(Xt=0;Xt<32;++Xt)px[Xt]=5;var Xt;var VS=Wc(Xc,9,1);var zS=Wc(px,5,1),Cm=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},gr=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Im=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},HS=function(r){return(r+7)/8|0},Lm=function(r,e,t){return(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new Oi(r.subarray(e,t))};var WS=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],qi=function(r,e,t){var n=new Error(e||WS[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,qi),!t)throw n;return n},XS=function(r,e,t,n){var i=r.length,s=n?n.length:0;if(!i||e.f&&!e.l)return t||new Oi(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new Oi(i*3));var c=function(re){var ce=t.length;if(re>ce){var me=new Oi(Math.max(ce*2,re));me.set(t),t=me}},u=e.f||0,h=e.p||0,f=e.b||0,p=e.l,g=e.d,y=e.m,d=e.n,m=i*8;do{if(!p){u=gr(r,h,1);var _=gr(r,h+1,3);if(h+=3,_)if(_==1)p=VS,g=zS,y=9,d=5;else if(_==2){var I=gr(r,h,31)+257,A=gr(r,h+10,15)+4,C=I+gr(r,h+5,31)+1;h+=14;for(var E=new Oi(C),b=new Oi(19),R=0;R<A;++R)b[kS[R]]=gr(r,h+R*3,7);h+=A*3;for(var N=Cm(b),B=(1<<N)-1,V=Wc(b,N,1),R=0;R<C;){var ie=V[gr(r,h,B)];h+=ie&15;var v=ie>>4;if(v<16)E[R++]=v;else{var Y=0,te=0;for(v==16?(te=3+gr(r,h,3),h+=2,Y=E[R-1]):v==17?(te=3+gr(r,h,7),h+=3):v==18&&(te=11+gr(r,h,127),h+=7);te--;)E[R++]=Y}}var q=E.subarray(0,I),le=E.subarray(I);y=Cm(q),d=Cm(le),p=Wc(q,y,1),g=Wc(le,d,1)}else qi(1);else{var v=HS(h)+4,x=r[v-4]|r[v-3]<<8,S=v+x;if(S>i){l&&qi(0);break}a&&c(f+x),t.set(r.subarray(v,S),f),e.b=f+=x,e.p=h=S*8,e.f=u;continue}if(h>m){l&&qi(0);break}}a&&c(f+131072);for(var ye=(1<<y)-1,Te=(1<<d)-1,Ae=h;;Ae=h){var Y=p[Im(r,h)&ye],_e=Y>>4;if(h+=Y&15,h>m){l&&qi(0);break}if(Y||qi(2),_e<256)t[f++]=_e;else if(_e==256){Ae=h,p=null;break}else{var G=_e-254;if(_e>264){var R=_e-257,P=lx[R];G=gr(r,h,(1<<P)-1)+fx[R],h+=P}var M=g[Im(r,h)&Te],T=M>>4;M||qi(3),h+=M&15;var le=GS[T];if(T>3){var P=cx[T];le+=Im(r,h)&(1<<P)-1,h+=P}if(h>m){l&&qi(0);break}a&&c(f+131072);var k=f+G;if(f<le){var j=s-le,W=Math.min(le,k);for(j+f<0&&qi(3);f<W;++f)t[f]=n[j+f]}for(;f<k;++f)t[f]=t[f-le]}}e.l=p,e.p=Ae,e.b=f,e.f=u,p&&(u=1,e.m=y,e.d=g,e.n=d)}while(!u);return f!=t.length&&o?Lm(t,0,f):t.subarray(0,f)};var qS=new Oi(0);var Nr=function(r,e){return r[e]|r[e+1]<<8},yr=function(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0},Rm=function(r,e){return yr(r,e)+yr(r,e+4)*4294967296};function jS(r,e){return XS(r,{i:2},e&&e.out,e&&e.dictionary)}var Nm=typeof TextDecoder<"u"&&new TextDecoder,YS=0;try{Nm.decode(qS,{stream:!0}),YS=1}catch{}var KS=function(r){for(var e="",t=0;;){var n=r[t++],i=(n>127)+(n>223)+(n>239);if(t+i>r.length)return{s:e,r:Lm(r,t-1)};i?i==3?(n=((n&15)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|r[t++]&63):e+=String.fromCharCode((n&15)<<12|(r[t++]&63)<<6|r[t++]&63):e+=String.fromCharCode(n)}};function ZS(r,e){if(e){for(var t="",n=0;n<r.length;n+=16384)t+=String.fromCharCode.apply(null,r.subarray(n,n+16384));return t}else{if(Nm)return Nm.decode(r);var i=KS(r),s=i.s,t=i.r;return t.length&&qi(8),s}}var JS=function(r,e){return e+30+Nr(r,e+26)+Nr(r,e+28)},$S=function(r,e,t){var n=Nr(r,e+28),i=ZS(r.subarray(e+46,e+46+n),!(Nr(r,e+8)&2048)),s=e+46+n,o=yr(r,e+20),a=t&&o==4294967295?QS(r,s):[o,yr(r,e+24),yr(r,e+42)],l=a[0],c=a[1],u=a[2];return[Nr(r,e+10),l,c,i,s+Nr(r,e+30)+Nr(r,e+32),u]},QS=function(r,e){for(;Nr(r,e)!=1;e+=4+Nr(r,e+2));return[Rm(r,e+12),Rm(r,e+4),Rm(r,e+20)]};function Jf(r,e){for(var t={},n=r.length-22;yr(r,n)!=101010256;--n)(!n||r.length-n>65558)&&qi(13);var i=Nr(r,n+8);if(!i)return{};var s=yr(r,n+16),o=s==4294967295||i==65535;if(o){var a=yr(r,n-12);o=yr(r,a)==101075792,o&&(i=yr(r,a+32),s=yr(r,a+48))}for(var l=e&&e.filter,c=0;c<i;++c){var u=$S(r,s,o),h=u[0],f=u[1],p=u[2],g=u[3],y=u[4],d=u[5],m=JS(r,d);s=y,(!l||l({name:g,size:f,originalSize:p,compression:h}))&&(h?h==8?t[g]=jS(r.subarray(m,m+f),{out:new Oi(p)}):qi(14,"unknown compression type "+h):t[g]=Lm(r,m,m+f))}return t}var Om={Success:0,NoDocumentXml:1},Dm=class{constructor(e,t){this.name=e,this.type=t,this.shapeName=null,this.isVisible=!1,this.color=null,this.fileName=null,this.fileContent=null,this.inLinkCount=0,this.properties=null}IsConvertible(){return!(this.fileName===null||this.fileContent===null||!this.isVisible||this.inLinkCount>0)}},Fm=class{constructor(){this.files=null,this.properties=null,this.objectNames=[],this.objectData=new Map}Init(e){let t=new Uint8Array(e);return this.files=Jf(t),this.LoadDocumentXml()?(this.LoadGuiDocumentXml(),Om.Success):Om.NoDocumentXml}GetObjectListToConvert(){let e=[];for(let t of this.objectNames){let n=this.objectData.get(t);n.IsConvertible()&&e.push(n)}return e}IsSupportedType(e){return!(!e.startsWith("Part::")&&!e.startsWith("PartDesign::")||e.indexOf("Part2D")!==-1)}HasFile(e){return e in this.files}LoadDocumentXml(){let e=this.GetXMLContent("Document.xml");if(e===null)return!1;this.properties=new Kn(nt("Properties"));let t=e.getElementsByTagName("Document");for(let s of t)for(let o of s.childNodes)o.tagName==="Properties"&&this.GetPropertiesFromElement(o,this.properties);let n=e.getElementsByTagName("Objects");for(let s of n){let o=s.getElementsByTagName("Object");for(let a of o){let l=a.getAttribute("name"),c=a.getAttribute("type");if(!this.IsSupportedType(c))continue;let u=new Dm(l,c);this.objectNames.push(l),this.objectData.set(l,u)}}let i=e.getElementsByTagName("ObjectData");for(let s of i){let o=s.getElementsByTagName("Object");for(let a of o){let l=a.getAttribute("name");if(!this.objectData.has(l))continue;let c=this.objectData.get(l);c.properties=new Kn(nt("Properties"));for(let f of a.childNodes)f.tagName==="Properties"&&this.GetPropertiesFromElement(f,c.properties);let u=a.getElementsByTagName("Property");for(let f of u){let p=f.getAttribute("name");if(p==="Label")c.shapeName=this.GetFirstChildValue(f,"String","value");else if(p==="Visibility"){let g=this.GetFirstChildValue(f,"Bool","value");c.isVisible=g==="true"}else if(p==="Visible"){let g=this.GetFirstChildValue(f,"Bool","value");c.isVisible=g==="true"}else if(p==="Shape"){let g=this.GetFirstChildValue(f,"Part","file");if(!this.HasFile(g))continue;let y=Tr(g);if(y!=="brp"&&y!=="brep")continue;c.fileName=g,c.fileContent=this.files[g]}}let h=a.getElementsByTagName("Link");for(let f of h){let p=f.getAttribute("value");if(this.objectData.has(p)){let g=this.objectData.get(p);g.inLinkCount+=1}}}}return!0}LoadGuiDocumentXml(){let e=this.GetXMLContent("GuiDocument.xml");if(e===null)return!1;let t=e.getElementsByTagName("ViewProvider");for(let n of t){let i=n.getAttribute("name");if(!this.objectData.has(i))continue;let s=this.objectData.get(i),o=n.getElementsByTagName("Property");for(let a of o){let l=a.getAttribute("name");if(l==="Visibility"){let c=this.GetFirstChildValue(a,"Bool","value");s.isVisible=c==="true"}else if(l==="ShapeColor"){let c=this.GetFirstChildValue(a,"PropertyColor","value"),u=parseInt(c,10);s.color=new Gr(u>>24&255,u>>16&255,u>>8&255,255)}}}return!0}GetPropertiesFromElement(e,t){let n=e.getElementsByTagName("Property");for(let i of n){let s=i.getAttribute("name"),o=i.getAttribute("type"),a=null;if(o==="App::PropertyBool"){let l=this.GetFirstChildValue(i,"String","bool");l!==null&&l.length>0&&(a=new cn(Yt.Boolean,s,l==="true"))}else if(o==="App::PropertyInteger"){let l=this.GetFirstChildValue(i,"Integer","value");l!==null&&l.length>0&&(a=new cn(Yt.Integer,s,parseInt(l)))}else if(o==="App::PropertyString"){let l=this.GetFirstChildValue(i,"String","value");l!==null&&l.length>0&&(a=new cn(Yt.Text,s,l))}else if(o==="App::PropertyUUID"){let l=this.GetFirstChildValue(i,"Uuid","value");l!==null&&l.length>0&&(a=new cn(Yt.Text,s,l))}else if(o==="App::PropertyFloat"||o==="App::PropertyLength"||o==="App::PropertyDistance"||o==="App::PropertyArea"||o==="App::PropertyVolume"){let l=this.GetFirstChildValue(i,"Float","value");l!==null&&l.length>0&&(a=new cn(Yt.Number,s,parseFloat(l)))}a!==null&&t.AddProperty(a)}}GetXMLContent(e){if(!this.HasFile(e))return null;let t=new DOMParser,n=Sn(this.files[e]);return t.parseFromString(n,"text/xml")}GetFirstChildValue(e,t,n){let i=e.getElementsByTagName(t);return i.length===0?null:i[0].getAttribute(n)}},pl=class extends Jt{constructor(){super(),this.worker=null,this.document=null}CanImportExtension(e){return e==="fcstd"}GetUpDirection(){return _t.Z}ClearContent(){this.worker!==null&&(this.worker.terminate(),this.worker=null),this.document=null}ResetContent(){this.worker=null,this.document=new Fm}ImportContent(e,t){if(this.document.Init(e)===Om.NoDocumentXml){this.SetError(nt("No Document.xml found.")),t();return}this.document.properties!==null&&this.document.properties.PropertyCount()>0&&this.model.AddPropertyGroup(this.document.properties);let i=this.document.GetObjectListToConvert();if(i.length===0){this.SetError(nt("No importable object found.")),t();return}this.ConvertObjects(i,t)}ConvertObjects(e,t){Wo().then(n=>{this.worker=n,this.worker.addEventListener("message",l=>{o(l.data)}),this.worker.addEventListener("error",l=>{o(null)});let i=0,s=new di(this.model),o=l=>{if(l!==null){let c=e[i];this.OnFileConverted(c,l,s)}if(i+=1,i===e.length)t();else{let c=e[i];this.worker.postMessage({format:"brep",buffer:c.fileContent})}},a=e[i];this.worker.postMessage({format:"brep",buffer:a.fileContent})}).catch(()=>{this.SetError(nt("Failed to load occt-import-js.")),t()})}OnFileConverted(e,t,n){if(!t.success||t.meshes.length===0)return;let i=new Bn;e.shapeName!==null&&i.SetName(e.shapeName);let s=1;for(let a of t.meshes){let l=null;e.color!==null&&(l=n.GetMaterialIndex(e.color.r,e.color.g,e.color.b,e.color.a));let c=ur(a,l,null);if(e.shapeName!==null){let h=s.toString().padStart(3,"0");c.SetName(e.shapeName+" "+h)}e.properties!==null&&e.properties.PropertyCount()>0&&c.AddPropertyGroup(e.properties);let u=this.model.AddMesh(c);i.AddMeshIndex(u),s+=1}this.model.GetRootNode().AddChildNode(i)}};var ml=class{constructor(){this.defaultLineColor=new St(100,100,100),this.defaultColor=new St(200,200,200)}},Lr={NoImportableFile:1,FailedToLoadFile:2,ImportFailed:3,UnknownError:4},Us=class{constructor(e){this.code=e,this.mainFile=null,this.message=null}},qc=class{constructor(){this.model=null,this.mainFile=null,this.upVector=null,this.usedFiles=null,this.missingFiles=null}},jc=class{constructor(e){this.getBufferCallback=e,this.fileBuffers=new Map}GetFileBuffer(e){let t=Rn(e);if(this.fileBuffers.has(t))return this.fileBuffers.get(t);let n=this.getBufferCallback(t);return this.fileBuffers.set(t,n),n}},gl=class{constructor(){this.importers=[new Qa,new il,new el,new tl,new Za,new Ja,new rl,new Ka,new $a,new nl,new pl,new ll,new cl,new ul,new hl,new fl],this.fileList=new Js,this.model=null,this.usedFiles=[],this.missingFiles=[]}AddImporter(e){this.importers.push(e)}ImportFiles(e,t,n){n.onLoadStart(),this.LoadFiles(e,{onReady:()=>{n.onImportStart(),Il(()=>{this.DecompressArchives(this.fileList,()=>{this.ImportLoadedFiles(t,n)})})},onFileListProgress:n.onFileListProgress,onFileLoadProgress:n.onFileLoadProgress})}LoadFiles(e,t){let n=new Js;n.FillFromInputFiles(e);let i=!1;if(this.HasImportableFile(n))i=!0;else{let s=!1;for(let o=0;o<this.missingFiles.length;o++){let a=this.missingFiles[o];n.ContainsFileByPath(a)&&(s=!0)}s?(this.fileList.ExtendFromFileList(n),i=!1):i=!0}i&&(this.fileList=n),this.fileList.GetContent({onReady:t.onReady,onFileListProgress:t.onFileListProgress,onFileLoadProgress:t.onFileLoadProgress})}ImportLoadedFiles(e,t){let n=this.GetImportableFiles(this.fileList);if(n.length===0){t.onImportError(new Us(Lr.NoImportableFile));return}if(n.length===1||!t.onSelectMainFile){let i=n[0];this.ImportLoadedMainFile(i,e,t)}else{let i=n.map(s=>s.file.name);t.onSelectMainFile(i,s=>{if(s===null){t.onImportError(new Us(Lr.NoImportableFile));return}Il(()=>{let o=n[s];this.ImportLoadedMainFile(o,e,t)})})}}ImportLoadedMainFile(e,t,n){if(e===null||e.file===null||e.file.content===null){let o=new Us(Lr.FailedToLoadFile);e!==null&&e.file!==null&&(o.mainFile=e.file.name),n.onImportError(o);return}this.model=null,this.usedFiles=[],this.missingFiles=[],this.usedFiles.push(e.file.name);let i=e.importer,s=new jc(o=>{let a=null,l=this.fileList.FindFileByPath(o);return l===null||l.content===null?(this.missingFiles.push(o),a=null):(this.usedFiles.push(o),a=l.content),a});i.Import(e.file.name,e.file.extension,e.file.content,{getDefaultLineMaterialColor:()=>t.defaultLineColor,getDefaultMaterialColor:()=>t.defaultColor,getFileBuffer:o=>s.GetFileBuffer(o),onSuccess:()=>{this.model=i.GetModel();let o=new qc;o.mainFile=e.file.name,o.model=this.model,o.usedFiles=this.usedFiles,o.missingFiles=this.missingFiles,o.upVector=i.GetUpDirection(),n.onImportSuccess(o)},onError:()=>{let o=new Us(Lr.ImportFailed);o.mainFile=e.file.name,o.message=i.GetErrorMessage(),n.onImportError(o)},onComplete:()=>{i.Clear()}})}DecompressArchives(e,t){let n=e.GetFiles(),i=[];for(let s of n)s.extension==="zip"&&i.push(s);if(i.length===0){t();return}for(let s=0;s<i.length;s++){let o=i[s],a=new Uint8Array(o.content),l=Jf(a);for(let c in l)if(Object.prototype.hasOwnProperty.call(l,c)){let u=new Zs(c,Ki.Decompressed,null);u.SetContent(l[c].buffer),e.AddFile(u)}}t()}GetFileList(){return this.fileList}HasImportableFile(e){return this.GetImportableFiles(e).length>0}GetImportableFiles(e){function t(s,o){for(let a=0;a<o.length;a++){let l=o[a];if(l.CanImportExtension(s.extension))return l}return null}let n=[],i=e.GetFiles();for(let s=0;s<i.length;s++){let o=i[s],a=t(o,this.importers);a!==null&&n.push({file:o,importer:a})}return n}};var eA=yt,Yc=class r extends zt{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,i){let s=this,o=new $n(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(a))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t=this;function n(G,P){if(G.nodeType!==1)return;let M=x(G),T=!1,k=null;switch(G.nodeName){case"svg":P=g(G,P);break;case"style":s(G);break;case"g":P=g(G,P);break;case"path":P=g(G,P),G.hasAttribute("d")&&(k=i(G));break;case"rect":P=g(G,P),k=l(G);break;case"polygon":P=g(G,P),k=c(G);break;case"polyline":P=g(G,P),k=u(G);break;case"circle":P=g(G,P),k=h(G);break;case"ellipse":P=g(G,P),k=f(G);break;case"line":P=g(G,P),k=p(G);break;case"defs":T=!0;break;case"use":P=g(G,P);let re=(G.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),ce=G.viewportElement.getElementById(re);ce?n(ce,P):console.warn("SVGLoader: 'use node' references non-existent node id: "+re);break;default:}k&&(P.fill!==void 0&&P.fill!=="none"&&k.color.setStyle(P.fill,eA),I(k,Te),N.push(k),k.userData={node:G,style:P});let j=G.childNodes;for(let W=0;W<j.length;W++){let re=j[W];T&&re.nodeName!=="style"&&re.nodeName!=="defs"||n(re,P)}M&&(V.pop(),V.length>0?Te.copy(V[V.length-1]):Te.identity())}function i(G){let P=new ar,M=new Pe,T=new Pe,k=new Pe,j=!0,W=!1,re=G.getAttribute("d");if(re===""||re==="none")return null;let ce=re.match(/[a-df-z][^a-df-z]*/ig);for(let me=0,w=ce.length;me<w;me++){let ae=ce[me],pe=ae.charAt(0),ue=ae.slice(1).trim();j===!0&&(W=!0,j=!1);let ee;switch(pe){case"M":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=2)M.x=ee[$+0],M.y=ee[$+1],T.x=M.x,T.y=M.y,$===0?P.moveTo(M.x,M.y):P.lineTo(M.x,M.y),$===0&&k.copy(M);break;case"H":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$++)M.x=ee[$],T.x=M.x,T.y=M.y,P.lineTo(M.x,M.y),$===0&&W===!0&&k.copy(M);break;case"V":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$++)M.y=ee[$],T.x=M.x,T.y=M.y,P.lineTo(M.x,M.y),$===0&&W===!0&&k.copy(M);break;case"L":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=2)M.x=ee[$+0],M.y=ee[$+1],T.x=M.x,T.y=M.y,P.lineTo(M.x,M.y),$===0&&W===!0&&k.copy(M);break;case"C":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=6)P.bezierCurveTo(ee[$+0],ee[$+1],ee[$+2],ee[$+3],ee[$+4],ee[$+5]),T.x=ee[$+2],T.y=ee[$+3],M.x=ee[$+4],M.y=ee[$+5],$===0&&W===!0&&k.copy(M);break;case"S":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=4)P.bezierCurveTo(y(M.x,T.x),y(M.y,T.y),ee[$+0],ee[$+1],ee[$+2],ee[$+3]),T.x=ee[$+0],T.y=ee[$+1],M.x=ee[$+2],M.y=ee[$+3],$===0&&W===!0&&k.copy(M);break;case"Q":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=4)P.quadraticCurveTo(ee[$+0],ee[$+1],ee[$+2],ee[$+3]),T.x=ee[$+0],T.y=ee[$+1],M.x=ee[$+2],M.y=ee[$+3],$===0&&W===!0&&k.copy(M);break;case"T":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=2){let H=y(M.x,T.x),L=y(M.y,T.y);P.quadraticCurveTo(H,L,ee[$+0],ee[$+1]),T.x=H,T.y=L,M.x=ee[$+0],M.y=ee[$+1],$===0&&W===!0&&k.copy(M)}break;case"A":ee=d(ue,[3,4],7);for(let $=0,ve=ee.length;$<ve;$+=7){if(ee[$+5]==M.x&&ee[$+6]==M.y)continue;let H=M.clone();M.x=ee[$+5],M.y=ee[$+6],T.x=M.x,T.y=M.y,o(P,ee[$],ee[$+1],ee[$+2],ee[$+3],ee[$+4],H,M),$===0&&W===!0&&k.copy(M)}break;case"m":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=2)M.x+=ee[$+0],M.y+=ee[$+1],T.x=M.x,T.y=M.y,$===0?P.moveTo(M.x,M.y):P.lineTo(M.x,M.y),$===0&&k.copy(M);break;case"h":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$++)M.x+=ee[$],T.x=M.x,T.y=M.y,P.lineTo(M.x,M.y),$===0&&W===!0&&k.copy(M);break;case"v":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$++)M.y+=ee[$],T.x=M.x,T.y=M.y,P.lineTo(M.x,M.y),$===0&&W===!0&&k.copy(M);break;case"l":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=2)M.x+=ee[$+0],M.y+=ee[$+1],T.x=M.x,T.y=M.y,P.lineTo(M.x,M.y),$===0&&W===!0&&k.copy(M);break;case"c":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=6)P.bezierCurveTo(M.x+ee[$+0],M.y+ee[$+1],M.x+ee[$+2],M.y+ee[$+3],M.x+ee[$+4],M.y+ee[$+5]),T.x=M.x+ee[$+2],T.y=M.y+ee[$+3],M.x+=ee[$+4],M.y+=ee[$+5],$===0&&W===!0&&k.copy(M);break;case"s":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=4)P.bezierCurveTo(y(M.x,T.x),y(M.y,T.y),M.x+ee[$+0],M.y+ee[$+1],M.x+ee[$+2],M.y+ee[$+3]),T.x=M.x+ee[$+0],T.y=M.y+ee[$+1],M.x+=ee[$+2],M.y+=ee[$+3],$===0&&W===!0&&k.copy(M);break;case"q":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=4)P.quadraticCurveTo(M.x+ee[$+0],M.y+ee[$+1],M.x+ee[$+2],M.y+ee[$+3]),T.x=M.x+ee[$+0],T.y=M.y+ee[$+1],M.x+=ee[$+2],M.y+=ee[$+3],$===0&&W===!0&&k.copy(M);break;case"t":ee=d(ue);for(let $=0,ve=ee.length;$<ve;$+=2){let H=y(M.x,T.x),L=y(M.y,T.y);P.quadraticCurveTo(H,L,M.x+ee[$+0],M.y+ee[$+1]),T.x=H,T.y=L,M.x=M.x+ee[$+0],M.y=M.y+ee[$+1],$===0&&W===!0&&k.copy(M)}break;case"a":ee=d(ue,[3,4],7);for(let $=0,ve=ee.length;$<ve;$+=7){if(ee[$+5]==0&&ee[$+6]==0)continue;let H=M.clone();M.x+=ee[$+5],M.y+=ee[$+6],T.x=M.x,T.y=M.y,o(P,ee[$],ee[$+1],ee[$+2],ee[$+3],ee[$+4],H,M),$===0&&W===!0&&k.copy(M)}break;case"Z":case"z":P.currentPath.autoClose=!0,P.currentPath.curves.length>0&&(M.copy(k),P.currentPath.currentPoint.copy(M),j=!0);break;default:console.warn(ae)}W=!1}return P}function s(G){if(!(!G.sheet||!G.sheet.cssRules||!G.sheet.cssRules.length))for(let P=0;P<G.sheet.cssRules.length;P++){let M=G.sheet.cssRules[P];if(M.type!==1)continue;let T=M.selectorText.split(/,/gm).filter(Boolean).map(k=>k.trim());for(let k=0;k<T.length;k++){let j=Object.fromEntries(Object.entries(M.style).filter(([,W])=>W!==""));B[T[k]]=Object.assign(B[T[k]]||{},j)}}}function o(G,P,M,T,k,j,W,re){if(P==0||M==0){G.lineTo(re.x,re.y);return}T=T*Math.PI/180,P=Math.abs(P),M=Math.abs(M);let ce=(W.x-re.x)/2,me=(W.y-re.y)/2,w=Math.cos(T)*ce+Math.sin(T)*me,ae=-Math.sin(T)*ce+Math.cos(T)*me,pe=P*P,ue=M*M,ee=w*w,$=ae*ae,ve=ee/pe+$/ue;if(ve>1){let ge=Math.sqrt(ve);P=ge*P,M=ge*M,pe=P*P,ue=M*M}let H=pe*$+ue*ee,L=(pe*ue-H)/H,O=Math.sqrt(Math.max(0,L));k===j&&(O=-O);let D=O*P*ae/M,z=-O*M*w/P,Q=Math.cos(T)*D-Math.sin(T)*z+(W.x+re.x)/2,ne=Math.sin(T)*D+Math.cos(T)*z+(W.y+re.y)/2,oe=a(1,0,(w-D)/P,(ae-z)/M),he=a((w-D)/P,(ae-z)/M,(-w-D)/P,(-ae-z)/M)%(Math.PI*2);G.currentPath.absellipse(Q,ne,P,M,oe,oe+he,j===0,T)}function a(G,P,M,T){let k=G*M+P*T,j=Math.sqrt(G*G+P*P)*Math.sqrt(M*M+T*T),W=Math.acos(Math.max(-1,Math.min(1,k/j)));return G*T-P*M<0&&(W=-W),W}function l(G){let P=v(G.getAttribute("x")||0),M=v(G.getAttribute("y")||0),T=v(G.getAttribute("rx")||G.getAttribute("ry")||0),k=v(G.getAttribute("ry")||G.getAttribute("rx")||0),j=v(G.getAttribute("width")),W=v(G.getAttribute("height")),re=1-.551915024494,ce=new ar;return ce.moveTo(P+T,M),ce.lineTo(P+j-T,M),(T!==0||k!==0)&&ce.bezierCurveTo(P+j-T*re,M,P+j,M+k*re,P+j,M+k),ce.lineTo(P+j,M+W-k),(T!==0||k!==0)&&ce.bezierCurveTo(P+j,M+W-k*re,P+j-T*re,M+W,P+j-T,M+W),ce.lineTo(P+T,M+W),(T!==0||k!==0)&&ce.bezierCurveTo(P+T*re,M+W,P,M+W-k*re,P,M+W-k),ce.lineTo(P,M+k),(T!==0||k!==0)&&ce.bezierCurveTo(P,M+k*re,P+T*re,M,P+T,M),ce}function c(G){function P(j,W,re){let ce=v(W),me=v(re);k===0?T.moveTo(ce,me):T.lineTo(ce,me),k++}let M=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,T=new ar,k=0;return G.getAttribute("points").replace(M,P),T.currentPath.autoClose=!0,T}function u(G){function P(j,W,re){let ce=v(W),me=v(re);k===0?T.moveTo(ce,me):T.lineTo(ce,me),k++}let M=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,T=new ar,k=0;return G.getAttribute("points").replace(M,P),T.currentPath.autoClose=!1,T}function h(G){let P=v(G.getAttribute("cx")||0),M=v(G.getAttribute("cy")||0),T=v(G.getAttribute("r")||0),k=new Cr;k.absarc(P,M,T,0,Math.PI*2);let j=new ar;return j.subPaths.push(k),j}function f(G){let P=v(G.getAttribute("cx")||0),M=v(G.getAttribute("cy")||0),T=v(G.getAttribute("rx")||0),k=v(G.getAttribute("ry")||0),j=new Cr;j.absellipse(P,M,T,k,0,Math.PI*2);let W=new ar;return W.subPaths.push(j),W}function p(G){let P=v(G.getAttribute("x1")||0),M=v(G.getAttribute("y1")||0),T=v(G.getAttribute("x2")||0),k=v(G.getAttribute("y2")||0),j=new ar;return j.moveTo(P,M),j.lineTo(T,k),j.currentPath.autoClose=!1,j}function g(G,P){P=Object.assign({},P);let M={};if(G.hasAttribute("class")){let W=G.getAttribute("class").split(/\s/).filter(Boolean).map(re=>re.trim());for(let re=0;re<W.length;re++)M=Object.assign(M,B["."+W[re]])}G.hasAttribute("id")&&(M=Object.assign(M,B["#"+G.getAttribute("id")]));function T(W,re,ce){ce===void 0&&(ce=function(w){return w.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),w}),G.hasAttribute(W)&&(P[re]=ce(G.getAttribute(W))),M[W]&&(P[re]=ce(M[W])),G.style&&G.style[W]!==""&&(P[re]=ce(G.style[W]))}function k(W){return Math.max(0,Math.min(1,v(W)))}function j(W){return Math.max(0,v(W))}return T("fill","fill"),T("fill-opacity","fillOpacity",k),T("fill-rule","fillRule"),T("opacity","opacity",k),T("stroke","stroke"),T("stroke-opacity","strokeOpacity",k),T("stroke-width","strokeWidth",j),T("stroke-linejoin","strokeLineJoin"),T("stroke-linecap","strokeLineCap"),T("stroke-miterlimit","strokeMiterLimit",j),T("visibility","visibility"),P}function y(G,P){return G-(P-G)}function d(G,P,M){if(typeof G!="string")throw new TypeError("Invalid input: "+typeof G);let T={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},k=0,j=1,W=2,re=3,ce=k,me=!0,w="",ae="",pe=[];function ue(H,L,O){let D=new SyntaxError('Unexpected character "'+H+'" at index '+L+".");throw D.partial=O,D}function ee(){w!==""&&(ae===""?pe.push(Number(w)):pe.push(Number(w)*Math.pow(10,Number(ae)))),w="",ae=""}let $,ve=G.length;for(let H=0;H<ve;H++){if($=G[H],Array.isArray(P)&&P.includes(pe.length%M)&&T.FLAGS.test($)){ce=j,w=$,ee();continue}if(ce===k){if(T.WHITESPACE.test($))continue;if(T.DIGIT.test($)||T.SIGN.test($)){ce=j,w=$;continue}if(T.POINT.test($)){ce=W,w=$;continue}T.COMMA.test($)&&(me&&ue($,H,pe),me=!0)}if(ce===j){if(T.DIGIT.test($)){w+=$;continue}if(T.POINT.test($)){w+=$,ce=W;continue}if(T.EXP.test($)){ce=re;continue}T.SIGN.test($)&&w.length===1&&T.SIGN.test(w[0])&&ue($,H,pe)}if(ce===W){if(T.DIGIT.test($)){w+=$;continue}if(T.EXP.test($)){ce=re;continue}T.POINT.test($)&&w[w.length-1]==="."&&ue($,H,pe)}if(ce===re){if(T.DIGIT.test($)){ae+=$;continue}if(T.SIGN.test($)){if(ae===""){ae+=$;continue}ae.length===1&&T.SIGN.test(ae)&&ue($,H,pe)}}T.WHITESPACE.test($)?(ee(),ce=k,me=!1):T.COMMA.test($)?(ee(),ce=k,me=!0):T.SIGN.test($)?(ee(),ce=j,w=$):T.POINT.test($)?(ee(),ce=W,w=$):ue($,H,pe)}return ee(),pe}let m=["mm","cm","in","pt","pc","px"],_={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function v(G){let P="px";if(typeof G=="string"||G instanceof String)for(let T=0,k=m.length;T<k;T++){let j=m[T];if(G.endsWith(j)){P=j,G=G.substring(0,G.length-j.length);break}}let M;return P==="px"&&t.defaultUnit!=="px"?M=_.in[t.defaultUnit]/t.defaultDPI:(M=_[P][t.defaultUnit],M<0&&(M=_[P].in*t.defaultDPI)),M*parseFloat(G)}function x(G){if(!(G.hasAttribute("transform")||G.nodeName==="use"&&(G.hasAttribute("x")||G.hasAttribute("y"))))return null;let P=S(G);return V.length>0&&P.premultiply(V[V.length-1]),Te.copy(P),V.push(P),P}function S(G){let P=new gt,M=ie;if(G.nodeName==="use"&&(G.hasAttribute("x")||G.hasAttribute("y"))){let T=v(G.getAttribute("x")),k=v(G.getAttribute("y"));P.translate(T,k)}if(G.hasAttribute("transform")){let T=G.getAttribute("transform").split(")");for(let k=T.length-1;k>=0;k--){let j=T[k].trim();if(j==="")continue;let W=j.indexOf("("),re=j.length;if(W>0&&W<re){let ce=j.slice(0,W),me=d(j.slice(W+1));switch(M.identity(),ce){case"translate":if(me.length>=1){let w=me[0],ae=0;me.length>=2&&(ae=me[1]),M.translate(w,ae)}break;case"rotate":if(me.length>=1){let w=0,ae=0,pe=0;w=me[0]*Math.PI/180,me.length>=3&&(ae=me[1],pe=me[2]),Y.makeTranslation(-ae,-pe),te.makeRotation(w),q.multiplyMatrices(te,Y),Y.makeTranslation(ae,pe),M.multiplyMatrices(Y,q)}break;case"scale":if(me.length>=1){let w=me[0],ae=w;me.length>=2&&(ae=me[1]),M.scale(w,ae)}break;case"skewX":me.length===1&&M.set(1,Math.tan(me[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":me.length===1&&M.set(1,0,0,Math.tan(me[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":me.length===6&&M.set(me[0],me[2],me[4],me[1],me[3],me[5],0,0,1);break}}P.premultiply(M)}}return P}function I(G,P){function M(W){ye.set(W.x,W.y,1).applyMatrix3(P),W.set(ye.x,ye.y)}function T(W){let re=W.xRadius,ce=W.yRadius,me=Math.cos(W.aRotation),w=Math.sin(W.aRotation),ae=new se(re*me,re*w,0),pe=new se(-ce*w,ce*me,0),ue=ae.applyMatrix3(P),ee=pe.applyMatrix3(P),$=ie.set(ue.x,ee.x,0,ue.y,ee.y,0,0,0,1),ve=Y.copy($).invert(),O=te.copy(ve).transpose().multiply(ve).elements,D=R(O[0],O[1],O[4]),z=Math.sqrt(D.rt1),Q=Math.sqrt(D.rt2);if(W.xRadius=1/z,W.yRadius=1/Q,W.aRotation=Math.atan2(D.sn,D.cs),!((W.aEndAngle-W.aStartAngle)%(2*Math.PI)<Number.EPSILON)){let oe=Y.set(z,0,0,0,Q,0,0,0,1),he=te.set(D.cs,D.sn,0,-D.sn,D.cs,0,0,0,1),ge=oe.multiply(he).multiply($),de=Ee=>{let{x:Re,y:De}=new se(Math.cos(Ee),Math.sin(Ee),0).applyMatrix3(ge);return Math.atan2(De,Re)};W.aStartAngle=de(W.aStartAngle),W.aEndAngle=de(W.aEndAngle),A(P)&&(W.aClockwise=!W.aClockwise)}}function k(W){let re=E(P),ce=b(P);W.xRadius*=re,W.yRadius*=ce;let me=re>Number.EPSILON?Math.atan2(P.elements[1],P.elements[0]):Math.atan2(-P.elements[3],P.elements[4]);W.aRotation+=me,A(P)&&(W.aStartAngle*=-1,W.aEndAngle*=-1,W.aClockwise=!W.aClockwise)}let j=G.subPaths;for(let W=0,re=j.length;W<re;W++){let me=j[W].curves;for(let w=0;w<me.length;w++){let ae=me[w];ae.isLineCurve?(M(ae.v1),M(ae.v2)):ae.isCubicBezierCurve?(M(ae.v0),M(ae.v1),M(ae.v2),M(ae.v3)):ae.isQuadraticBezierCurve?(M(ae.v0),M(ae.v1),M(ae.v2)):ae.isEllipseCurve&&(le.set(ae.aX,ae.aY),M(le),ae.aX=le.x,ae.aY=le.y,C(P)?T(ae):k(ae))}}}function A(G){let P=G.elements;return P[0]*P[4]-P[1]*P[3]<0}function C(G){let P=G.elements,M=P[0]*P[3]+P[1]*P[4];if(M===0)return!1;let T=E(G),k=b(G);return Math.abs(M/(T*k))>Number.EPSILON}function E(G){let P=G.elements;return Math.sqrt(P[0]*P[0]+P[1]*P[1])}function b(G){let P=G.elements;return Math.sqrt(P[3]*P[3]+P[4]*P[4])}function R(G,P,M){let T,k,j,W,re,ce=G+M,me=G-M,w=Math.sqrt(me*me+4*P*P);return ce>0?(T=.5*(ce+w),re=1/T,k=G*re*M-P*re*P):ce<0?k=.5*(ce-w):(T=.5*w,k=-.5*w),me>0?j=me+w:j=me-w,Math.abs(j)>2*Math.abs(P)?(re=-2*P/j,W=1/Math.sqrt(1+re*re),j=re*W):Math.abs(P)===0?(j=1,W=0):(re=-.5*j/P,j=1/Math.sqrt(1+re*re),W=re*j),me>0&&(re=j,j=-W,W=re),{rt1:T,rt2:k,cs:j,sn:W}}let N=[],B={},V=[],ie=new gt,Y=new gt,te=new gt,q=new gt,le=new Pe,ye=new se,Te=new gt,Ae=new DOMParser().parseFromString(e,"image/svg+xml");return n(Ae.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:N,xml:Ae.documentElement}}static createShapes(e){let n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},i={loc:n.ORIGIN,t:0};function s(y,d,m,_){let v=y.x,x=d.x,S=m.x,I=_.x,A=y.y,C=d.y,E=m.y,b=_.y,R=(I-S)*(A-E)-(b-E)*(v-S),N=(x-v)*(A-E)-(C-A)*(v-S),B=(b-E)*(x-v)-(I-S)*(C-A),V=R/B,ie=N/B;if(B===0&&R!==0||V<=0||V>=1||ie<0||ie>1)return null;if(R===0&&B===0){for(let Y=0;Y<2;Y++)if(o(Y===0?m:_,y,d),i.loc==n.ORIGIN){let te=Y===0?m:_;return{x:te.x,y:te.y,t:i.t}}else if(i.loc==n.BETWEEN){let te=+(v+i.t*(x-v)).toPrecision(10),q=+(A+i.t*(C-A)).toPrecision(10);return{x:te,y:q,t:i.t}}return null}else{for(let q=0;q<2;q++)if(o(q===0?m:_,y,d),i.loc==n.ORIGIN){let le=q===0?m:_;return{x:le.x,y:le.y,t:i.t}}let Y=+(v+V*(x-v)).toPrecision(10),te=+(A+V*(C-A)).toPrecision(10);return{x:Y,y:te,t:V}}}function o(y,d,m){let _=m.x-d.x,v=m.y-d.y,x=y.x-d.x,S=y.y-d.y,I=_*S-x*v;if(y.x===d.x&&y.y===d.y){i.loc=n.ORIGIN,i.t=0;return}if(y.x===m.x&&y.y===m.y){i.loc=n.DESTINATION,i.t=1;return}if(I<-Number.EPSILON){i.loc=n.LEFT;return}if(I>Number.EPSILON){i.loc=n.RIGHT;return}if(_*x<0||v*S<0){i.loc=n.BEHIND;return}if(Math.sqrt(_*_+v*v)<Math.sqrt(x*x+S*S)){i.loc=n.BEYOND;return}let A;_!==0?A=x/_:A=S/v,i.loc=n.BETWEEN,i.t=A}function a(y,d){let m=[],_=[];for(let v=1;v<y.length;v++){let x=y[v-1],S=y[v];for(let I=1;I<d.length;I++){let A=d[I-1],C=d[I],E=s(x,S,A,C);E!==null&&m.find(b=>b.t<=E.t+Number.EPSILON&&b.t>=E.t-Number.EPSILON)===void 0&&(m.push(E),_.push(new Pe(E.x,E.y)))}}return _}function l(y,d,m){let _=new Pe;d.getCenter(_);let v=[];return m.forEach(x=>{x.boundingBox.containsPoint(_)&&a(y,x.points).forEach(I=>{v.push({identifier:x.identifier,isCW:x.isCW,point:I})})}),v.sort((x,S)=>x.point.x-S.point.x),v}function c(y,d,m,_,v){(v==null||v==="")&&(v="nonzero");let x=new Pe;y.boundingBox.getCenter(x);let S=[new Pe(m,x.y),new Pe(_,x.y)],I=l(S,y.boundingBox,d);I.sort((N,B)=>N.point.x-B.point.x);let A=[],C=[];I.forEach(N=>{N.identifier===y.identifier?A.push(N):C.push(N)});let E=A[0].point.x,b=[],R=0;for(;R<C.length&&C[R].point.x<E;)b.length>0&&b[b.length-1]===C[R].identifier?b.pop():b.push(C[R].identifier),R++;if(b.push(y.identifier),v==="evenodd"){let N=b.length%2===0,B=b[b.length-2];return{identifier:y.identifier,isHole:N,for:B}}else if(v==="nonzero"){let N=!0,B=null,V=null;for(let ie=0;ie<b.length;ie++){let Y=b[ie];N?(V=d[Y].isCW,N=!1,B=Y):V!==d[Y].isCW&&(V=d[Y].isCW,N=!0)}return{identifier:y.identifier,isHole:N,for:B}}else console.warn('fill-rule: "'+v+'" is currently not implemented.')}let u=999999999,h=-999999999,f=e.subPaths.map(y=>{let d=y.getPoints(),m=-999999999,_=999999999,v=-999999999,x=999999999;for(let S=0;S<d.length;S++){let I=d[S];I.y>m&&(m=I.y),I.y<_&&(_=I.y),I.x>v&&(v=I.x),I.x<x&&(x=I.x)}return h<=v&&(h=v+1),u>=x&&(u=x-1),{curves:y.curves,points:d,isCW:gi.isClockWise(d),identifier:-1,boundingBox:new bc(new Pe(x,_),new Pe(v,m))}});f=f.filter(y=>y.points.length>1);for(let y=0;y<f.length;y++)f[y].identifier=y;let p=f.map(y=>c(y,f,u,h,e.userData?e.userData.style.fillRule:void 0)),g=[];return f.forEach(y=>{if(!p[y.identifier].isHole){let m=new $r;m.curves=y.curves,p.filter(v=>v.isHole&&v.for===y.identifier).forEach(v=>{let x=f[v.identifier],S=new Cr;S.curves=x.curves,m.holes.push(S)}),g.push(m)}}),g}static getStrokeStyle(e,t,n,i,s){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",i=i!==void 0?i:"butt",s=s!==void 0?s:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:i,strokeMiterLimit:s}}static pointsToStroke(e,t,n,i){let s=[],o=[],a=[];if(r.pointsToStrokeWithBuffers(e,t,n,i,s,o,a)===0)return null;let l=new It;return l.setAttribute("position",new We(s,3)),l.setAttribute("normal",new We(o,3)),l.setAttribute("uv",new We(a,2)),l}static pointsToStrokeWithBuffers(e,t,n,i,s,o,a,l){let c=new Pe,u=new Pe,h=new Pe,f=new Pe,p=new Pe,g=new Pe,y=new Pe,d=new Pe,m=new Pe,_=new Pe,v=new Pe,x=new Pe,S=new Pe,I=new Pe,A=new Pe,C=new Pe,E=new Pe;n=n!==void 0?n:12,i=i!==void 0?i:.001,l=l!==void 0?l:0,e=me(e);let b=e.length;if(b<2)return 0;let R=e[0].equals(e[b-1]),N,B=e[0],V,ie=t.strokeWidth/2,Y=1/(b-1),te=0,q,le,ye,Te,Ae=!1,_e=0,G=l*3,P=l*2;M(e[0],e[1],c).multiplyScalar(ie),d.copy(e[0]).sub(c),m.copy(e[0]).add(c),_.copy(d),v.copy(m);for(let w=1;w<b;w++){N=e[w],w===b-1?R?V=e[1]:V=void 0:V=e[w+1];let ae=c;if(M(B,N,ae),h.copy(ae).multiplyScalar(ie),x.copy(N).sub(h),S.copy(N).add(h),q=te+Y,le=!1,V!==void 0){M(N,V,u),h.copy(u).multiplyScalar(ie),I.copy(N).sub(h),A.copy(N).add(h),ye=!0,h.subVectors(V,B),ae.dot(h)<0&&(ye=!1),w===1&&(Ae=ye),h.subVectors(V,N),h.normalize();let pe=Math.abs(ae.dot(h));if(pe>Number.EPSILON){let ue=ie/pe;h.multiplyScalar(-ue),f.subVectors(N,B),p.copy(f).setLength(ue).add(h),C.copy(p).negate();let ee=p.length(),$=f.length();f.divideScalar($),g.subVectors(V,N);let ve=g.length();switch(g.divideScalar(ve),f.dot(C)<$&&g.dot(C)<ve&&(le=!0),E.copy(p).add(N),C.add(N),Te=!1,le?ye?(A.copy(C),S.copy(C)):(I.copy(C),x.copy(C)):j(),t.strokeLineJoin){case"bevel":W(ye,le,q);break;case"round":re(ye,le),ye?k(N,x,I,q,0):k(N,A,S,q,1);break;case"miter":case"miter-clip":default:let H=ie*t.strokeMiterLimit/ee;if(H<1)if(t.strokeLineJoin!=="miter-clip"){W(ye,le,q);break}else re(ye,le),ye?(g.subVectors(E,x).multiplyScalar(H).add(x),y.subVectors(E,I).multiplyScalar(H).add(I),T(x,q,0),T(g,q,0),T(N,q,.5),T(N,q,.5),T(g,q,0),T(y,q,0),T(N,q,.5),T(y,q,0),T(I,q,0)):(g.subVectors(E,S).multiplyScalar(H).add(S),y.subVectors(E,A).multiplyScalar(H).add(A),T(S,q,1),T(g,q,1),T(N,q,.5),T(N,q,.5),T(g,q,1),T(y,q,1),T(N,q,.5),T(y,q,1),T(A,q,1));else le?(ye?(T(m,te,1),T(d,te,0),T(E,q,0),T(m,te,1),T(E,q,0),T(C,q,1)):(T(m,te,1),T(d,te,0),T(E,q,1),T(d,te,0),T(C,q,0),T(E,q,1)),ye?I.copy(E):A.copy(E)):ye?(T(x,q,0),T(E,q,0),T(N,q,.5),T(N,q,.5),T(E,q,0),T(I,q,0)):(T(S,q,1),T(E,q,1),T(N,q,.5),T(N,q,.5),T(E,q,1),T(A,q,1)),Te=!0;break}}else j()}else j();!R&&w===b-1&&ce(e[0],_,v,ye,!0,te),te=q,B=N,d.copy(I),m.copy(A)}if(!R)ce(N,x,S,ye,!1,q);else if(le&&s){let w=E,ae=C;Ae!==ye&&(w=C,ae=E),ye?(Te||Ae)&&(ae.toArray(s,0*3),ae.toArray(s,3*3),Te&&w.toArray(s,1*3)):(Te||!Ae)&&(ae.toArray(s,1*3),ae.toArray(s,3*3),Te&&w.toArray(s,0*3))}return _e;function M(w,ae,pe){return pe.subVectors(ae,w),pe.set(-pe.y,pe.x).normalize()}function T(w,ae,pe){s&&(s[G]=w.x,s[G+1]=w.y,s[G+2]=0,o&&(o[G]=0,o[G+1]=0,o[G+2]=1),G+=3,a&&(a[P]=ae,a[P+1]=pe,P+=2)),_e+=3}function k(w,ae,pe,ue,ee){c.copy(ae).sub(w).normalize(),u.copy(pe).sub(w).normalize();let $=Math.PI,ve=c.dot(u);Math.abs(ve)<1&&($=Math.abs(Math.acos(ve))),$/=n,h.copy(ae);for(let H=0,L=n-1;H<L;H++)f.copy(h).rotateAround(w,$),T(h,ue,ee),T(f,ue,ee),T(w,ue,.5),h.copy(f);T(f,ue,ee),T(pe,ue,ee),T(w,ue,.5)}function j(){T(m,te,1),T(d,te,0),T(x,q,0),T(m,te,1),T(x,q,0),T(S,q,1)}function W(w,ae,pe){ae?w?(T(m,te,1),T(d,te,0),T(x,q,0),T(m,te,1),T(x,q,0),T(C,q,1),T(x,pe,0),T(I,pe,0),T(C,pe,.5)):(T(m,te,1),T(d,te,0),T(S,q,1),T(d,te,0),T(C,q,0),T(S,q,1),T(S,pe,1),T(C,pe,0),T(A,pe,1)):w?(T(x,pe,0),T(I,pe,0),T(N,pe,.5)):(T(S,pe,1),T(A,pe,0),T(N,pe,.5))}function re(w,ae){ae&&(w?(T(m,te,1),T(d,te,0),T(x,q,0),T(m,te,1),T(x,q,0),T(C,q,1),T(x,te,0),T(N,q,.5),T(C,q,1),T(N,q,.5),T(I,te,0),T(C,q,1)):(T(m,te,1),T(d,te,0),T(S,q,1),T(d,te,0),T(C,q,0),T(S,q,1),T(S,te,1),T(C,q,0),T(N,q,.5),T(N,q,.5),T(C,q,0),T(A,te,1)))}function ce(w,ae,pe,ue,ee,$){switch(t.strokeLineCap){case"round":ee?k(w,pe,ae,$,.5):k(w,ae,pe,$,.5);break;case"square":if(ee)c.subVectors(ae,w),u.set(c.y,-c.x),h.addVectors(c,u).add(w),f.subVectors(u,c).add(w),ue?(h.toArray(s,1*3),f.toArray(s,0*3),f.toArray(s,3*3)):(h.toArray(s,1*3),a[3*2+1]===1?f.toArray(s,3*3):h.toArray(s,3*3),f.toArray(s,0*3));else{c.subVectors(pe,w),u.set(c.y,-c.x),h.addVectors(c,u).add(w),f.subVectors(u,c).add(w);let ve=s.length;ue?(h.toArray(s,ve-1*3),f.toArray(s,ve-2*3),f.toArray(s,ve-4*3)):(f.toArray(s,ve-2*3),h.toArray(s,ve-1*3),f.toArray(s,ve-4*3))}break;case"butt":default:break}}function me(w){let ae=!1;for(let ue=1,ee=w.length-1;ue<ee;ue++)if(w[ue].distanceTo(w[ue+1])<i){ae=!0;break}if(!ae)return w;let pe=[];pe.push(w[0]);for(let ue=1,ee=w.length-1;ue<ee;ue++)w[ue].distanceTo(w[ue+1])>=i&&pe.push(w[ue]);return pe.push(w[w.length-1]),pe}}};var $f=class extends mr{constructor(){super()}CanImportExtension(e){return e==="svg"}GetUpDirection(){return _t.Z}CreateLoader(e){return new Yc(e)}GetMainObject(e){function t(o){let a=o.userData.style;return!(a.fill===void 0||a.fill==="none")}function n(o,a,l){let c=null;for(let u of o)if(u.style===a&&u.opacity===l){c=u.material;break}return c===null&&(c=new Zt({color:new He().setStyle(a),opacity:l,transparent:l<1}),o.push({style:a,opacity:l,material:c})),c}let i=[],s=new Lt;s.rotation.x=Math.PI;for(let o of e.paths){let a=Yc.createShapes(o);if(t(o)){let l=o.userData.style,c=n(i,l.fill,l.opacity);for(let u of a){let h=new gc(u,{depth:10,bevelEnabled:!1}),f=new Dt(h,c);f.name=o.userData.node.id,s.add(f)}}}return s}};var Kc=class{constructor(){this.name=null,this.material=null}SetName(e){return this.name=e,this}SetMaterial(e){return this.material=e,this}},ks=class{constructor(e){this.params=e||new Kc,this.mesh=new tn,this.params.name!==null&&this.mesh.SetName(this.params.name),this.curve=null}GetMesh(){return this.mesh}AddVertex(e,t,n){let i=new Ye(e,t,n);return this.mesh.AddVertex(i)}AddVertices(e){let t=[];for(let n=0;n<e.length;n++){let i=e[n];t.push(this.AddVertex(i.x,i.y,i.z))}return t}SetCurve(e){this.curve=e}ResetCurve(){this.curve=null}AddTriangle(e,t,n){let i=new Qt(e,t,n);return this.params.material!==null&&(i.mat=this.params.material),this.curve!==null&&i.SetCurve(this.curve),this.mesh.AddTriangle(i)}AddTriangleInverted(e,t,n){this.AddTriangle(e,n,t)}AddConvexPolygon(e){for(let t=0;t<e.length-2;t++)this.AddTriangle(e[0],e[t+1],e[t+2])}AddConvexPolygonInverted(e){for(let t=0;t<e.length-2;t++)this.AddTriangleInverted(e[0],e[t+1],e[t+2])}},yl=class{constructor(e){this.generator=e}GenerateSurfaceBetweenPolygons(e,t){if(e.length!==t.length)return;let n=e.length;for(let i=0;i<n;i++){let s=i,o=i<n-1?s+1:0;this.generator.AddConvexPolygon([e[s],e[o],t[o],t[s]])}}GenerateTriangleFan(e,t){let n=e.length;for(let i=0;i<n;i++){let s=i,o=i<n-1?s+1:0;this.generator.AddTriangle(t,e[s],e[o])}}};function gx(r,e){return new Nt(r*Math.cos(e),r*Math.sin(e))}function yx(r,e,t,n){if(!Di(e)||!Di(t)||!Di(n))return null;let i=new ks(r);return i.AddVertex(0,0,0),i.AddVertex(e,0,0),i.AddVertex(e,t,0),i.AddVertex(0,t,0),i.AddVertex(0,0,n),i.AddVertex(e,0,n),i.AddVertex(e,t,n),i.AddVertex(0,t,n),i.AddConvexPolygon([0,3,2,1]),i.AddConvexPolygon([0,1,5,4]),i.AddConvexPolygon([1,2,6,5]),i.AddConvexPolygon([2,3,7,6]),i.AddConvexPolygon([3,0,4,7]),i.AddConvexPolygon([4,5,6,7]),i.GetMesh()}function Um(r,e,t,n,i,s){if(Br(e)||Br(t)||!Di(n)||i<3)return null;let o=kr(e),a=kr(t);if(o&&a)return null;let l=new ks(r),c=new yl(l),u=2*Math.PI/i,h=s?1:null,f=[];if(o)f.push(l.AddVertex(0,0,n));else for(let g=0;g<i;g++){let y=gx(e,g*u);f.push(l.AddVertex(y.x,y.y,n))}let p=[];if(a)p.push(l.AddVertex(0,0,0));else for(let g=0;g<i;g++){let y=gx(t,g*u);p.push(l.AddVertex(y.x,y.y,0))}return o?(l.SetCurve(h),c.GenerateTriangleFan(p,f[0]),l.ResetCurve(),l.AddConvexPolygonInverted(p)):a?(l.SetCurve(h),c.GenerateTriangleFan(f.slice().reverse(),p[0]),l.ResetCurve(),l.AddConvexPolygon(f)):(l.SetCurve(h),c.GenerateSurfaceBetweenPolygons(p,f),l.ResetCurve(),l.AddConvexPolygonInverted(p),l.AddConvexPolygon(f)),l.GetMesh()}function xx(r,e,t,n,i){return Um(r,e,e,t,n,i)}function vx(r,e,t,n){function i(p,g,y){return new Ye(p*Math.sin(g)*Math.cos(y),p*Math.sin(g)*Math.sin(y),p*Math.cos(g))}if(!Di(e)||t<3)return null;let s=new ks(r),o=new yl(s);s.SetCurve(n?1:null);let a=[],l=t+1,c=Math.PI/t,u=2*Math.PI/t;for(let p=1;p<l-1;p++){let g=[],y=p*c;for(let d=0;d<t;d++){let m=d*u,_=i(e,y,-m);g.push(s.AddVertex(_.x,_.y,_.z))}p>1&&o.GenerateSurfaceBetweenPolygons(a[a.length-1],g),a.push(g)}let h=s.AddVertex(0,0,e),f=s.AddVertex(0,0,-e);return o.GenerateTriangleFan(a[0].slice().reverse(),h),o.GenerateTriangleFan(a[a.length-1],f),s.ResetCurve(),s.GetMesh()}function _x(r,e,t){function n(s,o,a,l,c){let u=new Ye(a,l,c);u.MultiplyScalar(o/u.Length()),s.AddVertex(u.x,u.y,u.z)}if(!Di(t))return null;let i=new ks(r);if(e==="tetrahedron"){let s=1;n(i,t,+s,+s,+s),n(i,t,-s,-s,+s),n(i,t,-s,+s,-s),n(i,t,+s,-s,-s),i.AddTriangle(0,1,3),i.AddTriangle(0,2,1),i.AddTriangle(0,3,2),i.AddTriangle(1,2,3)}else if(e==="hexahedron"){let s=1;n(i,t,+s,+s,+s),n(i,t,+s,+s,-s),n(i,t,+s,-s,+s),n(i,t,+s,-s,-s),n(i,t,-s,+s,+s),n(i,t,-s,+s,-s),n(i,t,-s,-s,+s),n(i,t,-s,-s,-s),i.AddConvexPolygon([0,1,5,4]),i.AddConvexPolygon([0,2,3,1]),i.AddConvexPolygon([0,4,6,2]),i.AddConvexPolygon([1,3,7,5]),i.AddConvexPolygon([2,6,7,3]),i.AddConvexPolygon([4,5,7,6])}else if(e==="octahedron"){let s=1,o=0;n(i,t,+s,+o,+o),n(i,t,-s,+o,+o),n(i,t,+o,+s,+o),n(i,t,+o,-s,+o),n(i,t,+o,+o,+s),n(i,t,+o,+o,-s),i.AddTriangle(0,2,4),i.AddTriangle(0,3,5),i.AddTriangle(0,4,3),i.AddTriangle(0,5,2),i.AddTriangle(1,2,5),i.AddTriangle(1,3,4),i.AddTriangle(1,4,2),i.AddTriangle(1,5,3)}else if(e==="dodecahedron"){let s=1,o=0,a=(1+Math.sqrt(5))/2,l=1/a;n(i,t,+s,+s,+s),n(i,t,+s,+s,-s),n(i,t,+s,-s,+s),n(i,t,-s,+s,+s),n(i,t,+s,-s,-s),n(i,t,-s,+s,-s),n(i,t,-s,-s,+s),n(i,t,-s,-s,-s),n(i,t,+o,+l,+a),n(i,t,+o,+l,-a),n(i,t,+o,-l,+a),n(i,t,+o,-l,-a),n(i,t,+l,+a,+o),n(i,t,+l,-a,+o),n(i,t,-l,+a,+o),n(i,t,-l,-a,+o),n(i,t,+a,+o,+l),n(i,t,-a,+o,+l),n(i,t,+a,+o,-l),n(i,t,-a,+o,-l),i.AddConvexPolygon([0,8,10,2,16]),i.AddConvexPolygon([0,16,18,1,12]),i.AddConvexPolygon([0,12,14,3,8]),i.AddConvexPolygon([1,9,5,14,12]),i.AddConvexPolygon([1,18,4,11,9]),i.AddConvexPolygon([2,10,6,15,13]),i.AddConvexPolygon([2,13,4,18,16]),i.AddConvexPolygon([3,14,5,19,17]),i.AddConvexPolygon([3,17,6,10,8]),i.AddConvexPolygon([4,13,15,7,11]),i.AddConvexPolygon([5,9,11,7,19]),i.AddConvexPolygon([6,17,19,7,15])}else if(e==="icosahedron"){let s=1,o=0,a=(1+Math.sqrt(5))/2;n(i,t,+o,+s,+a),n(i,t,+o,+s,-a),n(i,t,+o,-s,+a),n(i,t,+o,-s,-a),n(i,t,+s,+a,+o),n(i,t,+s,-a,+o),n(i,t,-s,+a,+o),n(i,t,-s,-a,+o),n(i,t,+a,+o,+s),n(i,t,+a,+o,-s),n(i,t,-a,+o,+s),n(i,t,-a,+o,-s),i.AddTriangle(0,2,8),i.AddTriangle(0,4,6),i.AddTriangle(0,6,10),i.AddTriangle(0,8,4),i.AddTriangle(0,10,2),i.AddTriangle(1,3,11),i.AddTriangle(1,4,9),i.AddTriangle(1,6,4),i.AddTriangle(1,9,3),i.AddTriangle(1,11,6),i.AddTriangle(2,5,8),i.AddTriangle(2,7,5),i.AddTriangle(2,10,7),i.AddTriangle(3,5,7),i.AddTriangle(3,7,11),i.AddTriangle(3,9,5),i.AddTriangle(4,8,9),i.AddTriangle(5,9,8),i.AddTriangle(6,11,10),i.AddTriangle(7,10,11)}return i.GetMesh()}function km(r,e,t){let n=ni(r,e),i=ni(e,t),s=ni(r,t),o=(n+i+s)/2,a=o*(o-n)*(o-i)*(o-s);return a<0?0:Math.sqrt(a)}function Bm(r,e,t){return Nl(r,Zi(e,t))/6}function Gm(r){if(r instanceof br){let e=0;return r.EnumerateMeshInstances(t=>{e+=Gm(t)}),e}else{let e=0;return r.EnumerateTriangleVertices((t,n,i)=>{e+=Bm(t,n,i)}),e}}function Tx(r){let e=0;return r.EnumerateTriangleVertices((t,n,i)=>{e+=km(t,n,i)}),e}var Bs={FixedUpVector:1,FreeOrbit:2},ei={Perspective:1,Orthographic:2},Or=class r{constructor(e,t,n,i){this.eye=e,this.center=t,this.up=n,this.fov=i}Clone(){return new r(this.eye.Clone(),this.center.Clone(),this.up.Clone(),this.fov)}};function Qf(r,e){return bi(r.eye,e.eye)&&bi(r.center,e.center)&&bi(r.up,e.up)&&Ut(r.fov,e.fov)}var tA=10,Vm={MeshOnly:1,MeshAndLine:2};function zm(r,e){function t(n,i){for(let s of n)s.polygonOffset=i,s.polygonOffsetUnit=1,s.polygonOffsetFactor=1}t(r.material,e),r.userData.threeMaterials&&t(r.userData.threeMaterials,e)}var Gs=class{constructor(e){this.scene=e,this.rootObject=null}IsEmpty(){return this.rootObject===null}SetRootObject(e){this.rootObject!==null&&this.Clear(),this.rootObject=e,this.scene.add(this.rootObject)}GetRootObject(){return this.rootObject}AddObject(e){if(this.rootObject===null){let t=new Lt;this.SetRootObject(t)}this.rootObject.add(e)}Traverse(e){this.rootObject!==null&&this.rootObject.traverse(t=>{e(t)})}UpdateWorldMatrix(){this.rootObject!==null&&this.rootObject.updateWorldMatrix(!0,!0)}Clear(){Nf(this.rootObject),this.scene.remove(this.rootObject),this.rootObject=null}},Io=class r{constructor(e,t,n){this.showEdges=e,this.edgeColor=t,this.edgeThreshold=n}Clone(){return new r(this.showEdges,this.edgeColor.Clone(),this.edgeThreshold)}},xl=class{constructor(e){this.scene=e,this.mainModel=new Gs(this.scene),this.edgeModel=new Gs(this.scene),this.edgeSettings=new Io(!1,new St(0,0,0),1),this.hasLines=!1,this.hasPolygonOffset=!1}SetMainObject(e){this.mainModel.SetRootObject(e),this.hasLines=!1,this.hasPolygonOffset=!1,this.EnumerateLines(t=>{this.hasLines=!0}),this.edgeSettings.showEdges&&this.GenerateEdgeModel(),this.UpdatePolygonOffset()}UpdateWorldMatrix(){this.mainModel.UpdateWorldMatrix(),this.edgeModel.UpdateWorldMatrix()}SetEdgeSettings(e){let t=!1;if(e.showEdges&&(!this.edgeSettings.showEdges||this.edgeSettings.edgeThreshold!==e.edgeThreshold)&&(t=!0),this.edgeSettings=e,!this.mainModel.IsEmpty())if(this.edgeSettings.showEdges)if(t)this.ClearEdgeModel(),this.GenerateEdgeModel();else{let n=Dn(this.edgeSettings.edgeColor);this.EnumerateEdges(i=>{i.material.color=n})}else this.ClearEdgeModel()}GenerateEdgeModel(){let e=Dn(this.edgeSettings.edgeColor);this.UpdateWorldMatrix(),this.EnumerateMeshes(t=>{let n=new lc(t.geometry,this.edgeSettings.edgeThreshold),i=new rr(n,new jn({color:e}));i.applyMatrix4(t.matrixWorld),i.userData=t.userData,i.visible=t.visible,this.edgeModel.AddObject(i)}),this.UpdatePolygonOffset()}GetBoundingBox(e){let t=!1,n=new Gi;return this.EnumerateMeshesAndLines(i=>{e(i.userData)&&(n.union(new Gi().setFromObject(i)),t=!0)}),t?n:null}GetBoundingSphere(e){let t=this.GetBoundingBox(e);if(t===null)return null;let n=new Vi;return t.getBoundingSphere(n),n}Clear(){this.mainModel.Clear(),this.ClearEdgeModel()}ClearEdgeModel(){this.edgeModel.IsEmpty()||(this.UpdatePolygonOffset(),this.edgeModel.Clear())}EnumerateMeshes(e){this.mainModel.Traverse(t=>{t.isMesh&&e(t)})}EnumerateLines(e){this.mainModel.Traverse(t=>{t.isLineSegments&&e(t)})}EnumerateMeshesAndLines(e){this.mainModel.Traverse(t=>{(t.isMesh||t.isLineSegments)&&e(t)})}EnumerateEdges(e){this.edgeModel.Traverse(t=>{t.isLineSegments&&e(t)})}HasLinesOrEdges(){return this.hasLines||this.edgeSettings.showEdges}UpdatePolygonOffset(){let e=this.HasLinesOrEdges();e!==this.hasPolygonOffset&&(this.EnumerateMeshes(t=>{zm(t,e)}),this.hasPolygonOffset=e)}GetMeshIntersectionUnderMouse(e,t,n,i,s){if(this.mainModel.IsEmpty()||t.x<0||t.x>i||t.y<0||t.y>s)return null;let o=new Pe;o.x=t.x/i*2-1,o.y=-(t.y/s)*2+1;let a=new Ec;a.setFromCamera(o,n),a.params.Line.threshold=10;let l=a.intersectObject(this.mainModel.GetRootObject(),!0);for(let c=0;c<l.length;c++){let u=l[c];if(u.object.visible){if(u.object.isMesh)return u;if(u.object.isLineSegments){if(e===Vm.MeshOnly||Lf(n,i,s,u.object,t)>tA)continue;return u}}}return null}};var rn={IntegerToString(r){return r.toString()},StringToInteger(r){return parseInt(r,10)},NumberToString(r){return r.toFixed(5)},StringToNumber(r){return parseFloat(r)},ModelUrlsToString:function(r){return r===null?null:r.join(",")},StringToModelUrls:function(r){return r===null||r.length===0?null:r.split(",")},CameraToString:function(r){return r===null?null:[this.NumberToString(r.eye.x),this.NumberToString(r.eye.y),this.NumberToString(r.eye.z),this.NumberToString(r.center.x),this.NumberToString(r.center.y),this.NumberToString(r.center.z),this.NumberToString(r.up.x),this.NumberToString(r.up.y),this.NumberToString(r.up.z),this.NumberToString(r.fov)].join(",")},ProjectionModeToString:function(r){return r===ei.Perspective?"perspective":r===ei.Orthographic?"orthographic":null},StringToCamera:function(r){if(r===null||r.length===0)return null;let e=r.split(",");if(e.length!==9&&e.length!==10)return null;let t=45;return e.length>=10&&(t=this.StringToNumber(e[9])),new Or(new Ye(this.StringToNumber(e[0]),this.StringToNumber(e[1]),this.StringToNumber(e[2])),new Ye(this.StringToNumber(e[3]),this.StringToNumber(e[4]),this.StringToNumber(e[5])),new Ye(this.StringToNumber(e[6]),this.StringToNumber(e[7]),this.StringToNumber(e[8])),t)},StringToProjectionMode:function(r){return r==="perspective"?ei.Perspective:r==="orthographic"?ei.Orthographic:null},RGBColorToString:function(r){return r===null?null:[this.IntegerToString(r.r),this.IntegerToString(r.g),this.IntegerToString(r.b)].join(",")},RGBAColorToString:function(r){return r===null?null:[this.IntegerToString(r.r),this.IntegerToString(r.g),this.IntegerToString(r.b),this.IntegerToString(r.a)].join(",")},StringToRGBColor:function(r){if(r===null||r.length===0)return null;let e=r.split(",");return e.length!==3?null:new St(this.StringToInteger(e[0]),this.StringToInteger(e[1]),this.StringToInteger(e[2]))},StringToRGBAColor:function(r){if(r===null||r.length===0)return null;let e=r.split(",");if(e.length!==3&&e.length!==4)return null;let t=new Gr(this.StringToInteger(e[0]),this.StringToInteger(e[1]),this.StringToInteger(e[2]),255);return e.length===4&&(t.a=this.StringToInteger(e[3])),t},EnvironmentSettingsToString(r){return r===null?null:[r.environmentMapName,r.backgroundIsEnvMap?"on":"off"].join(",")},StringToEnvironmentSettings:function(r){if(r===null||r.length===0)return null;let e=r.split(",");return e.length!==2?null:{environmentMapName:e[0],backgroundIsEnvMap:e[1]==="on"}},EdgeSettingsToString:function(r){return r===null?null:[r.showEdges?"on":"off",this.RGBColorToString(r.edgeColor),this.IntegerToString(r.edgeThreshold)].join(",")},StringToEdgeSettings:function(r){if(r===null||r.length===0)return null;let e=r.split(",");return e.length!==5?null:new Io(e[0]==="on",new St(this.StringToInteger(e[1]),this.StringToInteger(e[2]),this.StringToInteger(e[3])),this.StringToInteger(e[4]))}},Zc=class{constructor(e){this.separator=e,this.paramList=""}AddModelUrls(e){return this.AddUrlPart("model",rn.ModelUrlsToString(e)),this}AddCamera(e){return this.AddUrlPart("camera",rn.CameraToString(e)),this}AddProjectionMode(e){return this.AddUrlPart("projectionmode",rn.ProjectionModeToString(e)),this}AddEnvironmentSettings(e){return this.AddUrlPart("envsettings",rn.EnvironmentSettingsToString(e)),this}AddBackgroundColor(e){return this.AddUrlPart("backgroundcolor",rn.RGBAColorToString(e)),this}AddDefaultColor(e){return this.AddUrlPart("defaultcolor",rn.RGBColorToString(e)),this}AddDefaultLineColor(e){return this.AddUrlPart("defaultlinecolor",rn.RGBColorToString(e)),this}AddEdgeSettings(e){return this.AddUrlPart("edgesettings",rn.EdgeSettingsToString(e)),this}AddUrlPart(e,t){e===null||t===null||(this.paramList.length>0&&(this.paramList+=this.separator),this.paramList+=e+"="+t)}GetParameterList(){return this.paramList}},Jc=class{constructor(e,t){this.separator=t,this.paramList=e}GetModelUrls(){if(this.paramList.indexOf("=")===-1)return this.paramList.split(",");let e=this.GetKeywordParams("model");return rn.StringToModelUrls(e)}GetCamera(){let e=this.GetKeywordParams("camera");return rn.StringToCamera(e)}GetProjectionMode(){let e=this.GetKeywordParams("cameramode");return e===null&&(e=this.GetKeywordParams("projectionmode")),rn.StringToProjectionMode(e)}GetEnvironmentSettings(){let e=this.GetKeywordParams("envsettings");return rn.StringToEnvironmentSettings(e)}GetBackgroundColor(){let e=this.GetKeywordParams("backgroundcolor");return rn.StringToRGBAColor(e)}GetDefaultColor(){let e=this.GetKeywordParams("defaultcolor");return rn.StringToRGBColor(e)}GetDefaultLineColor(){let e=this.GetKeywordParams("defaultlinecolor");return rn.StringToRGBColor(e)}GetEdgeSettings(){let e=this.GetKeywordParams("edgesettings");return rn.StringToEdgeSettings(e)}GetKeywordParams(e){if(this.paramList===null||this.paramList.length===0)return null;let t=e+"=",n=this.paramList.split(this.separator);for(let i=0;i<n.length;i++){let s=n[i];if(s.startsWith(t))return s.substring(t.length)}return null}};function Hm(){return new Zc("$")}function Mx(r){return new Jc(r,"$")}function Ex(r){let e=Hm();return e.AddModelUrls(r),e.GetParameterList()}var Vs={Line:1,Face:2},vl=class{constructor(){this.forceMediumpForMaterials=!1}},_l=class{constructor(){this.defaultMaterials=[],this.objectUrls=[]}},$c=class{constructor(e){this.callbacks=e,this.texturesNeeded=0,this.texturesLoaded=0,this.threeObject=null}OnTextureNeeded(){this.texturesNeeded+=1}OnTextureLoaded(){this.texturesLoaded+=1,this.callbacks.onTextureLoaded(),this.Finish()}OnModelLoaded(e){this.threeObject=e,this.Finish()}Finish(){this.threeObject!==null&&this.texturesNeeded===this.texturesLoaded&&this.callbacks.onModelLoaded(this.threeObject)}},Qc=class{constructor(e,t){this.model=e,this.threeNodeItems=[],this.AddNode(e.GetRootNode(),t)}AddNode(e,t){let n=e.GetTransformation().GetMatrix(),i=new Je().fromArray(n.Get());t.applyMatrix4(i);for(let s of e.GetChildNodes()){let o=new Lt;t.add(o),this.AddNode(s,o)}for(let s of e.GetMeshIndices()){let o=new ki(e.GetId(),s),a=this.model.GetMesh(s);this.threeNodeItems.push({meshInstance:new Hr(o,e,a),threeNode:t})}}GetNodeItems(){return this.threeNodeItems}},eu=class{constructor(e,t,n,i){this.model=e,this.stateHandler=t,this.conversionParams=n,this.conversionOutput=i,this.shadingType=Rf(e),this.modelToThreeLineMaterial=new Map,this.modelToThreeMaterial=new Map}GetThreeMaterial(e,t){if(t===Vs.Face){if(!this.modelToThreeMaterial.has(e)){let n=this.CreateThreeFaceMaterial(e);this.modelToThreeMaterial.set(e,n)}return this.modelToThreeMaterial.get(e)}else if(t===Vs.Line){if(!this.modelToThreeLineMaterial.has(e)){let n=this.CreateThreeLineMaterial(e);this.modelToThreeLineMaterial.set(e,n)}return this.modelToThreeLineMaterial.get(e)}else return null}CreateThreeFaceMaterial(e){let t=this.model.GetMaterial(e),n=Dn(t.color);t.vertexColors&&n.setRGB(1,1,1);let i={color:n,vertexColors:t.vertexColors,opacity:t.opacity,transparent:t.transparent,alphaTest:t.alphaTest,side:Nn};this.conversionParams.forceMediumpForMaterials&&(i.precision="mediump");let s=null;if(this.shadingType===vi.Phong){if(s=new Zt(i),t.type===Wn.Phong){let a=Dn(t.specular);Ut(t.shininess,0)&&a.setRGB(0,0,0),s.specular=a,s.shininess=t.shininess*100,this.LoadFaceTexture(s,t.specularMap,l=>{s.specularMap=l})}}else this.shadingType===vi.Physical&&(s=new ts(i),t.type===Wn.Physical&&(s.metalness=t.metalness,s.roughness=t.roughness,this.LoadFaceTexture(s,t.metalnessMap,a=>{s.metalness=1,s.roughness=1,s.metalnessMap=a,s.roughnessMap=a})));let o=Dn(t.emissive);return s.emissive=o,this.LoadFaceTexture(s,t.diffuseMap,a=>{t.multiplyDiffuseMap||s.color.setRGB(1,1,1),s.map=a}),this.LoadFaceTexture(s,t.bumpMap,a=>{s.bumpMap=a}),this.LoadFaceTexture(s,t.normalMap,a=>{s.normalMap=a}),this.LoadFaceTexture(s,t.emissiveMap,a=>{s.emissiveMap=a}),t.source!==bn.Model&&(s.userData.source=t.source,this.conversionOutput.defaultMaterials.push(s)),s}CreateThreeLineMaterial(e){let t=this.model.GetMaterial(e),i={color:Dn(t.color),opacity:t.opacity};this.conversionParams.forceMediumpForMaterials&&(i.precision="mediump");let s=new jn(i);return t.source!==bn.Model&&(s.userData.source=t.source,this.conversionOutput.defaultMaterials.push(s)),s}LoadFaceTexture(e,t,n){function i(a,l){l.wrapS=on,l.wrapT=on,l.rotation=a.rotation,l.offset.x=a.offset.x,l.offset.y=a.offset.y,l.repeat.x=a.scale.x,l.repeat.y=a.scale.y}if(t===null||!t.IsValid())return;let s=new Ri;this.stateHandler.OnTextureNeeded();let o=null;t.mimeType!==null?o=Su(t.buffer,t.mimeType):o=js(t.buffer),this.conversionOutput.objectUrls.push(o),s.load(o,a=>{i(t,a),e.needsUpdate=!0,n(a),this.stateHandler.OnTextureLoaded()},null,a=>{this.stateHandler.OnTextureLoaded()})}},Tl=class{constructor(e,t,n){this.threeGeometry=e,this.geometryType=t,this.materialHandler=n,this.itemVertexCount=null,t===Vs.Face?this.itemVertexCount=3:t===Vs.Line&&(this.itemVertexCount=2),this.meshThreeMaterials=[],this.meshOriginalMaterials=[],this.groupStart=null,this.previousMaterialIndex=null}ProcessItem(e,t){if(this.previousMaterialIndex!==t){this.groupStart!==null&&this.AddGroup(this.groupStart,e-1),this.groupStart=e;let n=this.materialHandler.GetThreeMaterial(t,this.geometryType);this.meshThreeMaterials.push(n),this.meshOriginalMaterials.push(t),this.previousMaterialIndex=t}}Finalize(e){this.AddGroup(this.groupStart,e-1)}AddGroup(e,t){let n=this.meshThreeMaterials.length-1;this.threeGeometry.addGroup(e*this.itemVertexCount,(t-e+1)*this.itemVertexCount,n)}};function ed(r,e,t,n){function i(h,f){let p=h.mesh,g=p.TriangleCount();if(g===0)return null;let y=[];for(let b=0;b<g;b++)y.push(b);y.sort((b,R)=>{let N=p.GetTriangle(b),B=p.GetTriangle(R);return N.mat-B.mat});let d=new It,m=new Tl(d,Vs.Face,f),_=[],v=[],x=[],S=[],I=p.VertexColorCount()>0,A=p.TextureUVCount()>0,C=0;for(let b of y){let R=p.GetTriangle(b),N=p.GetVertex(R.v0),B=p.GetVertex(R.v1),V=p.GetVertex(R.v2);if(_.push(N.x,N.y,N.z,B.x,B.y,B.z,V.x,V.y,V.z),R.HasVertexColors()){let q=Dn(p.GetVertexColor(R.c0)),le=Dn(p.GetVertexColor(R.c1)),ye=Dn(p.GetVertexColor(R.c2));v.push(q.r,q.g,q.b,le.r,le.g,le.b,ye.r,ye.g,ye.b)}else I&&v.push(0,0,0,0,0,0,0,0,0);let ie=p.GetNormal(R.n0),Y=p.GetNormal(R.n1),te=p.GetNormal(R.n2);if(x.push(ie.x,ie.y,ie.z,Y.x,Y.y,Y.z,te.x,te.y,te.z),R.HasTextureUVs()){let q=p.GetTextureUV(R.u0),le=p.GetTextureUV(R.u1),ye=p.GetTextureUV(R.u2);S.push(q.x,q.y,le.x,le.y,ye.x,ye.y)}else A&&S.push(0,0,0,0,0,0);m.ProcessItem(C,R.mat),C+=1}m.Finalize(C),d.setAttribute("position",new We(_,3)),v.length!==0&&d.setAttribute("color",new We(v,3)),d.setAttribute("normal",new We(x,3)),S.length!==0&&d.setAttribute("uv",new We(S,2));let E=new Dt(d,m.meshThreeMaterials);return E.name=p.GetName(),E.userData={originalMeshInstance:h,originalMaterials:m.meshOriginalMaterials,threeMaterials:null},E}function s(h,f){let p=h.mesh,g=p.LineCount();if(g===0)return null;let y=[];for(let S=0;S<g;S++)y.push(S);y.sort((S,I)=>{let A=p.GetLine(S),C=p.GetLine(I);return A.mat-C.mat});let d=new It,m=new Tl(d,Vs.Line,f),_=[],v=0;for(let S=0;S<y.length;S++){let I=p.GetLine(y[S]),A=I.GetVertices();for(let C=0;C<A.length;C++){let E=A[C],b=p.GetVertex(E);_.push(b.x,b.y,b.z),C>0&&C<A.length-1&&_.push(b.x,b.y,b.z)}m.ProcessItem(v,I.mat),v+=I.SegmentCount()}m.Finalize(v),d.setAttribute("position",new We(_,3));let x=new rr(d,m.meshThreeMaterials);return x.userData={originalMeshInstance:h,originalMaterials:m.meshOriginalMaterials,threeMaterials:null},x}function o(h,f,p){if(vs(f.mesh))return;let g=i(f,p);g!==null&&h.add(g);let y=s(f,p);y!==null&&h.add(y)}function a(h,f,p,g){let d=new Qc(f,h).GetNodeItems();mu(d.length,100,{runTask:(m,_,v)=>{for(let x=m;x<=_;x++){let S=d[x];o(S.threeNode,S.meshInstance,p)}v()},onReady:()=>{g.OnModelLoaded(h)}})}let l=new $c(n),c=new eu(r,l,e,t),u=new Lt;a(u,r,c,l)}var Ml=class{constructor(){this.importer=new gl,this.inProgress=!1,this.defaultMaterials=null,this.objectUrls=null,this.hasHighpDriverIssue=If()}InProgress(){return this.inProgress}LoadModel(e,t,n){this.inProgress||(this.inProgress=!0,this.RevokeObjectUrls(),this.importer.ImportFiles(e,t,{onLoadStart:()=>{n.onLoadStart()},onFileListProgress:(i,s)=>{n.onFileListProgress(i,s)},onFileLoadProgress:(i,s)=>{n.onFileLoadProgress(i,s)},onImportStart:()=>{n.onImportStart()},onSelectMainFile:(i,s)=>{n.onSelectMainFile?n.onSelectMainFile(i,s):s(0)},onImportSuccess:i=>{n.onVisualizationStart();let s=new vl;s.forceMediumpForMaterials=this.hasHighpDriverIssue;let o=new _l;ed(i.model,s,o,{onTextureLoaded:()=>{n.onTextureLoaded()},onModelLoaded:a=>{if(this.defaultMaterials=o.defaultMaterials,this.objectUrls=o.objectUrls,i.upVector===_t.X){let l=new an().setFromAxisAngle(new se(0,0,1),Math.PI/2);a.quaternion.multiply(l)}else if(i.upVector===_t.Z){let l=new an().setFromAxisAngle(new se(1,0,0),-Math.PI/2);a.quaternion.multiply(l)}n.onModelFinished(i,a),this.inProgress=!1}})},onImportError:i=>{n.onLoadError(i),this.inProgress=!1}}))}GetImporter(){return this.importer}GetDefaultMaterials(){return this.defaultMaterials}ReplaceDefaultMaterialsColor(e,t){if(this.defaultMaterials!==null)for(let n of this.defaultMaterials)n.vertexColors||(n.userData.source===bn.DefaultFace?n.color=Dn(e):n.userData.source===bn.DefaultLine&&(n.color=Dn(t)))}RevokeObjectUrls(){if(this.objectUrls!==null){for(let e of this.objectUrls)Au(e);this.objectUrls=null}}Destroy(){this.RevokeObjectUrls(),this.importer=null}};function zn(r){return Math.round(parseFloat(r))}function td(r){let e=zn(r.paddingLeft)+zn(r.paddingRight),t=zn(r.borderLeftWidth)+zn(r.borderRightWidth),n=zn(r.marginLeft)+zn(r.marginRight);return e+t+n}function nd(r){let e=zn(r.paddingTop)+zn(r.paddingBottom),t=zn(r.borderTopWidth)+zn(r.borderBottomWidth),n=zn(r.marginTop)+zn(r.marginBottom);return e+t+n}function id(r,e,t){let n=getComputedStyle(r),i=e-td(n),s=t-nd(n);return{width:i,height:s}}function ps(r,e,t){if(r.getBoundingClientRect){let n=r.getBoundingClientRect();e-=n.left,t-=n.top}return window.pageXOffset&&window.pageYOffset&&(e+=window.pageXOffset,t+=window.pageYOffset),new Nt(e,t)}function rd(r,e,t){let n=document.createElement(r);return e&&(n.className=e),t&&(n.innerHTML=t),n}function Wm(r,e,t,n){let i=rd(e,t,n);return r.appendChild(i),i}function bx(r,e,t){return Wm(r,"div",e,t)}function Sx(r){for(;r.firstChild;)r.removeChild(r.firstChild)}function Ax(r,e){e.parentNode.insertBefore(r,e)}function wx(r,e){e.parentNode.insertBefore(r,e.nextSibling)}function Cx(r,e){e?r.style.display="block":r.style.display="none"}function Ix(r){return r.offsetParent!==null}function Xm(r,e){r.style.width=e.toString()+"px"}function qm(r,e){r.style.height=e.toString()+"px"}function Rx(r){let e=getComputedStyle(r);return r.offsetWidth+zn(e.marginLeft)+zn(e.marginRight)}function Px(r){let e=getComputedStyle(r);return r.offsetHeight+zn(e.marginTop)+zn(e.marginBottom)}function Nx(r,e){let t=getComputedStyle(r);Xm(r,e-td(t))}function Lx(r,e){let t=getComputedStyle(r);qm(r,e-nd(t))}function Ox(r,e){return rd("div",r,e)}var tu=class{constructor(){this.prev=new Nt(0,0),this.curr=new Nt(0,0),this.diff=new Nt(0,0),this.buttons=[]}Down(e,t){this.buttons.push(t.which),this.curr=this.GetPositionFromEvent(e,t),this.prev=this.curr.Clone()}Move(e,t){this.curr=this.GetPositionFromEvent(e,t),this.diff=ms(this.curr,this.prev),this.prev=this.curr.Clone()}Up(e,t){let n=this.buttons.indexOf(t.which);n!==-1&&this.buttons.splice(n,1),this.curr=this.GetPositionFromEvent(e,t)}Leave(e,t){this.buttons=[],this.curr=this.GetPositionFromEvent(e,t)}IsButtonDown(){return this.buttons.length>0}GetButton(){let e=this.buttons.length;return e===0?0:this.buttons[e-1]}GetPosition(){return this.curr}GetMoveDiff(){return this.diff}GetPositionFromEvent(e,t){return ps(e,t.clientX,t.clientY)}},nu=class{constructor(){this.prevPos=new Nt(0,0),this.currPos=new Nt(0,0),this.diffPos=new Nt(0,0),this.prevDist=0,this.currDist=0,this.diffDist=0,this.fingers=0}Start(e,t){t.touches.length!==0&&(this.fingers=t.touches.length,this.currPos=this.GetPositionFromEvent(e,t),this.prevPos=this.currPos.Clone(),this.currDist=this.GetTouchDistanceFromEvent(e,t),this.prevDist=this.currDist)}Move(e,t){t.touches.length!==0&&(this.currPos=this.GetPositionFromEvent(e,t),this.diffPos=ms(this.currPos,this.prevPos),this.prevPos=this.currPos.Clone(),this.currDist=this.GetTouchDistanceFromEvent(e,t),this.diffDist=this.currDist-this.prevDist,this.prevDist=this.currDist)}End(e,t){t.touches.length!==0&&(this.fingers=0,this.currPos=this.GetPositionFromEvent(e,t),this.currDist=this.GetTouchDistanceFromEvent(e,t))}IsFingerDown(){return this.fingers!==0}GetFingerCount(){return this.fingers}GetPosition(){return this.currPos}GetMoveDiff(){return this.diffPos}GetDistanceDiff(){return this.diffDist}GetPositionFromEvent(e,t){let n=null;if(t.touches.length!==0){let i=t.touches[0];n=ps(e,i.pageX,i.pageY)}return n}GetTouchDistanceFromEvent(e,t){if(t.touches.length!==2)return 0;let n=t.touches[0],i=t.touches[1];return Hs(ps(e,n.pageX,n.pageY),ps(e,i.pageX,i.pageY))}},iu=class{constructor(){this.isClick=!1,this.startPosition=null}Start(e){this.isClick=!0,this.startPosition=e}Move(e){this.isClick&&(this.startPosition!==null?Hs(this.startPosition,e)>3&&this.Cancel():this.Cancel())}End(){this.startPosition=null}Cancel(){this.isClick=!1,this.startPosition=null}IsClick(){return this.isClick}},li={None:0,Orbit:1,Pan:2,Zoom:3},El=class{constructor(e,t,n){this.canvas=e,this.camera=t,this.callbacks=n,this.navigationMode=Bs.FixedUpVector,this.mouse=new tu,this.touch=new nu,this.clickDetector=new iu,this.onMouseClick=null,this.onMouseMove=null,this.onContext=null,this.canvas.addEventListener&&(this.canvas.addEventListener("mousedown",this.OnMouseDown.bind(this)),this.canvas.addEventListener("wheel",this.OnMouseWheel.bind(this)),this.canvas.addEventListener("touchstart",this.OnTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.OnTouchMove.bind(this)),this.canvas.addEventListener("touchcancel",this.OnTouchEnd.bind(this)),this.canvas.addEventListener("touchend",this.OnTouchEnd.bind(this)),this.canvas.addEventListener("contextmenu",this.OnContextMenu.bind(this))),document.addEventListener&&(document.addEventListener("mousemove",this.OnMouseMove.bind(this)),document.addEventListener("mouseup",this.OnMouseUp.bind(this)),document.addEventListener("mouseleave",this.OnMouseLeave.bind(this)))}SetMouseClickHandler(e){this.onMouseClick=e}SetMouseMoveHandler(e){this.onMouseMove=e}SetContextMenuHandler(e){this.onContext=e}GetNavigationMode(){return this.navigationMode}SetNavigationMode(e){this.navigationMode=e}GetCamera(){return this.camera}SetCamera(e){this.camera=e}MoveCamera(e,t){function n(i,s,o,a){i.camera.eye=s.eye[a],i.camera.center=s.center[a],i.camera.up=s.up[a],i.Update(),a<o-1&&requestAnimationFrame(()=>{n(i,s,o,a+1)})}if(e!==null){if(t===0||Qf(this.camera,e))this.camera=e;else{let i=Lu,s={eye:oa(this.camera.eye,e.eye,t,i),center:oa(this.camera.center,e.center,t,i),up:oa(this.camera.up,e.up,t,i)};requestAnimationFrame(()=>{n(this,s,t,0)})}this.Update()}}GetFitToSphereCamera(e,t){if(kr(t))return null;let n=this.camera.Clone(),i=Un(n.center,e);n.eye=Un(n.eye,i),n.center=e.Clone();let s=Un(n.eye,n.center).Normalize(),o=this.camera.fov/2;this.canvas.width<this.canvas.height&&(o=o*this.canvas.width/this.canvas.height);let a=t/Math.sin(o*xr);return n.eye=n.center.Clone().Offset(s,a),n}OnMouseDown(e){e.preventDefault(),this.mouse.Down(this.canvas,e),this.clickDetector.Start(this.mouse.GetPosition())}OnMouseMove(e){if(this.mouse.Move(this.canvas,e),this.clickDetector.Move(this.mouse.GetPosition()),this.onMouseMove){let s=ps(this.canvas,e.clientX,e.clientY);this.onMouseMove(s)}if(!this.mouse.IsButtonDown())return;let t=this.mouse.GetMoveDiff(),n=this.mouse.GetButton(),i=li.None;if(n===1?e.ctrlKey?i=li.Zoom:e.shiftKey?i=li.Pan:i=li.Orbit:(n===2||n===3)&&(i=li.Pan),i===li.Orbit){let s=.5;this.Orbit(t.x*s,t.y*s)}else if(i===li.Pan){let o=.001*ni(this.camera.eye,this.camera.center);this.Pan(t.x*o,t.y*o)}else i===li.Zoom&&this.Zoom(-t.y*.005);this.Update()}OnMouseUp(e){if(this.mouse.Up(this.canvas,e),this.clickDetector.End(),this.clickDetector.IsClick()){let t=this.mouse.GetPosition();this.Click(e.which,t)}}OnMouseLeave(e){this.mouse.Leave(this.canvas,e),this.clickDetector.Cancel()}OnTouchStart(e){e.preventDefault(),this.touch.Start(this.canvas,e),this.clickDetector.Start(this.touch.GetPosition())}OnTouchMove(e){if(e.preventDefault(),this.touch.Move(this.canvas,e),this.clickDetector.Move(this.touch.GetPosition()),!this.touch.IsFingerDown())return;let t=this.touch.GetMoveDiff(),n=this.touch.GetDistanceDiff(),i=this.touch.GetFingerCount(),s=li.None;if(i===1?s=li.Orbit:i===2&&(s=li.Pan),s===li.Orbit){let o=.5;this.Orbit(t.x*o,t.y*o)}else if(s===li.Pan){this.Zoom(n*.005);let a=.001*ni(this.camera.eye,this.camera.center);this.Pan(t.x*a,t.y*a)}this.Update()}OnTouchEnd(e){if(e.preventDefault(),this.touch.End(this.canvas,e),this.clickDetector.End(),this.clickDetector.IsClick()){let t=this.touch.GetPosition();this.touch.GetFingerCount()===1&&this.Click(1,t)}}OnMouseWheel(e){let t=e||window.event;t.preventDefault();let n=-t.deltaY/40,i=.1;n<0&&(i=i*-1),this.Zoom(i),this.Update()}OnContextMenu(e){e.preventDefault(),this.clickDetector.IsClick()&&(this.Context(e.clientX,e.clientY),this.clickDetector.Cancel())}Orbit(e,t){let n=e*xr,i=t*xr,s=Un(this.camera.center,this.camera.eye).Normalize(),o=Zi(s,this.camera.up).Normalize();if(this.navigationMode===Bs.FixedUpVector){let l=bu(s,this.camera.up)+i;yu(l,0)&&Bo(l,Math.PI)&&this.camera.eye.Rotate(o,-i,this.camera.center),this.camera.eye.Rotate(this.camera.up,-n,this.camera.center)}else if(this.navigationMode===Bs.FreeOrbit){let a=Zi(o,s).Normalize();this.camera.eye.Rotate(o,-i,this.camera.center),this.camera.eye.Rotate(a,-n,this.camera.center),this.camera.up=a}}Pan(e,t){let n=Un(this.camera.center,this.camera.eye).Normalize(),i=Zi(n,this.camera.up).Normalize(),s=Zi(i,n).Normalize();this.camera.eye.Offset(i,-e),this.camera.center.Offset(i,-e),this.camera.eye.Offset(s,t),this.camera.center.Offset(s,t)}Zoom(e){let t=Un(this.camera.center,this.camera.eye),i=t.Length()*e;this.camera.eye.Offset(t,i)}Update(){this.callbacks.onUpdate()}Click(e,t){this.onMouseClick&&this.onMouseClick(e,t)}Context(e,t){if(this.onContext){let n={x:e,y:t},i=ps(this.canvas,e,t);this.onContext(n,i)}}};var Ro=class r{constructor(e,t){this.textureNames=e,this.backgroundIsEnvMap=t}Clone(){let e=null;if(this.textureNames!==null){e=[];for(let t of this.textureNames)e.push(t)}return new r(e,this.backgroundIsEnvMap)}},bl=class{constructor(e){this.scene=e,this.type=vi.Phong,this.projectionMode=ei.Perspective,this.ambientLight=new or(8947848,1*Math.PI),this.directionalLight=new sr(8947848,1*Math.PI),this.environmentSettings=new Ro(null,!1),this.environment=null,this.scene.add(this.ambientLight),this.scene.add(this.directionalLight)}SetShadingType(e){this.type=e,this.UpdateShading()}SetProjectionMode(e){this.projectionMode=e,this.UpdateShading()}UpdateShading(){this.type===vi.Phong?(this.ambientLight.color.set(8947848),this.directionalLight.color.set(8947848),this.scene.environment=null):this.type===vi.Physical&&(this.ambientLight.color.set(0),this.directionalLight.color.set(5592405),this.scene.environment=this.environment),this.environmentSettings.backgroundIsEnvMap&&this.projectionMode===ei.Perspective?this.scene.background=this.environment:this.scene.background=null}SetEnvironmentMapSettings(e,t){let n=new _c;this.environment=n.load(e.textureNames,i=>{i.colorSpace=Ci,t()}),this.environmentSettings=e}UpdateByCamera(e){let t=Un(e.eye,e.center);this.directionalLight.position.set(t.x,t.y,t.z)}};function sd(r){let e=45;return r===_t.X?new Or(new Ye(2,-3,1.5),new Ye(0,0,0),new Ye(1,0,0),e):r===_t.Y?new Or(new Ye(-1.5,2,3),new Ye(0,0,0),new Ye(0,1,0),e):r===_t.Z?new Or(new Ye(-1.5,-3,2),new Ye(0,0,0),new Ye(0,0,1),e):null}function od(r,e){if(!e(r))return!1;for(let t of r.children)if(!od(t,e))return!1;return!0}function jm(r){let e=null;return od(r,t=>{if(t.isMesh)for(let n of t.material)return n.type==="MeshPhongMaterial"?e=vi.Phong:n.type==="MeshStandardMaterial"&&(e=vi.Physical),!1;return!0}),e}var ru=class{constructor(){this.eyeCenterDistance=0,this.forceUpdate=!0}ForceUpdate(){this.forceUpdate=!0}ValidatePerspective(){return this.forceUpdate?(this.forceUpdate=!1,!1):!0}ValidateOrthographic(e){return this.forceUpdate||!Ut(this.eyeCenterDistance,e)?(this.eyeCenterDistance=e,this.forceUpdate=!1,!1):!0}},su=class{constructor(){this.direction=_t.Y,this.isFixed=!0,this.isFlipped=!1}SetDirection(e,t){this.direction=e,this.isFlipped=!1;let n=sd(this.direction),i=Un(n.eye,n.center),s=ni(t.center,t.eye),o=t.center.Clone().Offset(i,s),a=t.Clone();return this.direction===_t.X?(a.up=new Ye(1,0,0),a.eye=o):this.direction===_t.Y?(a.up=new Ye(0,1,0),a.eye=o):this.direction===_t.Z&&(a.up=new Ye(0,0,1),a.eye=o),a}SetFixed(e,t){return this.isFixed=e,this.isFixed?this.SetDirection(this.direction,t):null}Flip(e){this.isFlipped=!this.isFlipped;let t=e.Clone();return t.up.MultiplyScalar(-1),t}},Sl=class{constructor(){mt.enabled=!1,this.canvas=null,this.renderer=null,this.scene=null,this.mainModel=null,this.extraModel=null,this.camera=null,this.projectionMode=null,this.cameraValidator=null,this.shadingModel=null,this.navigation=null,this.upVector=null,this.settings={animationSteps:40}}Init(e){this.canvas=e,this.canvas.id="viewer";let t={canvas:this.canvas,antialias:!0};this.renderer=new Xa(t),this.renderer.outputColorSpace=Ci,window.devicePixelRatio&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setClearColor("#ffffff",1),this.renderer.setSize(this.canvas.width,this.canvas.height),this.scene=new ir,this.mainModel=new xl(this.scene),this.extraModel=new Gs(this.scene),this.InitNavigation(),this.InitShading(),this.Render()}SetMouseClickHandler(e){this.navigation.SetMouseClickHandler(e)}SetMouseMoveHandler(e){this.navigation.SetMouseMoveHandler(e)}SetContextMenuHandler(e){this.navigation.SetContextMenuHandler(e)}SetEdgeSettings(e){let t=e.Clone();this.mainModel.SetEdgeSettings(t),this.Render()}SetEnvironmentMapSettings(e){let t=e.Clone();this.shadingModel.SetEnvironmentMapSettings(t,()=>{this.Render()}),this.shadingModel.UpdateShading(),this.Render()}SetBackgroundColor(e){let t=new He(Ws(e.r),Ws(e.g),Ws(e.b)),n=Ws(e.a);this.renderer.setClearColor(t,n),this.Render()}GetCanvas(){return this.canvas}GetCamera(){return this.navigation.GetCamera()}GetProjectionMode(){return this.projectionMode}SetCamera(e){this.navigation.SetCamera(e),this.cameraValidator.ForceUpdate(),this.Render()}SetProjectionMode(e){this.projectionMode!==e&&(this.scene.remove(this.camera),e===ei.Perspective?this.camera=new nn(45,1,.1,1e3):e===ei.Orthographic&&(this.camera=new ss(-1,1,1,-1,.1,1e3)),this.scene.add(this.camera),this.projectionMode=e,this.shadingModel.SetProjectionMode(e),this.cameraValidator.ForceUpdate(),this.AdjustClippingPlanes(),this.Render())}Resize(e,t){let n=id(this.canvas,e,t);this.ResizeRenderer(n.width,n.height)}ResizeRenderer(e,t){window.devicePixelRatio&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t),this.cameraValidator.ForceUpdate(),this.Render()}FitSphereToWindow(e,t){if(e===null)return;let n=new Ye(e.center.x,e.center.y,e.center.z),i=e.radius,s=this.navigation.GetFitToSphereCamera(n,i);this.navigation.MoveCamera(s,t?this.settings.animationSteps:0)}AdjustClippingPlanes(){let e=this.GetBoundingSphere(t=>!0);this.AdjustClippingPlanesToSphere(e)}AdjustClippingPlanesToSphere(e){e!==null&&(e.radius<10?(this.camera.near=.01,this.camera.far=100):e.radius<100?(this.camera.near=.1,this.camera.far=1e3):e.radius<1e3?(this.camera.near=10,this.camera.far=1e4):(this.camera.near=100,this.camera.far=1e6),this.cameraValidator.ForceUpdate(),this.Render())}GetNavigationMode(){return this.navigation.GetNavigationMode()}SetNavigationMode(e){let t=this.navigation.GetCamera(),n=this.upVector.SetFixed(e===Bs.FixedUpVector,t);this.navigation.SetNavigationMode(e),n!==null&&this.navigation.MoveCamera(n,this.settings.animationSteps),this.Render()}SetUpVector(e,t){let n=this.navigation.GetCamera(),i=this.upVector.SetDirection(e,n),s=t?this.settings.animationSteps:0;this.navigation.MoveCamera(i,s),this.Render()}FlipUpVector(){let e=this.navigation.GetCamera(),t=this.upVector.Flip(e);this.navigation.MoveCamera(t,0),this.Render()}Render(){let e=this.navigation.GetCamera();if(this.camera.position.set(e.eye.x,e.eye.y,e.eye.z),this.camera.up.set(e.up.x,e.up.y,e.up.z),this.camera.lookAt(new se(e.center.x,e.center.y,e.center.z)),this.projectionMode===ei.Perspective)this.cameraValidator.ValidatePerspective()||(this.camera.aspect=this.canvas.width/this.canvas.height,this.camera.fov=e.fov,this.camera.updateProjectionMatrix());else if(this.projectionMode===ei.Orthographic){let t=ni(e.eye,e.center);if(!this.cameraValidator.ValidateOrthographic(t)){let n=this.canvas.width/this.canvas.height,s=ni(e.eye,e.center)*Math.tan(.5*e.fov*xr);this.camera.left=-s*n,this.camera.right=s*n,this.camera.top=s,this.camera.bottom=-s,this.camera.updateProjectionMatrix()}}this.shadingModel.UpdateByCamera(e),this.renderer.render(this.scene,this.camera)}SetMainObject(e){let t=jm(e);this.mainModel.SetMainObject(e),this.shadingModel.SetShadingType(t),this.Render()}AddExtraObject(e){this.extraModel.AddObject(e),this.Render()}Clear(){this.mainModel.Clear(),this.extraModel.Clear(),this.Render()}ClearExtra(){this.extraModel.Clear(),this.Render()}SetMeshesVisibility(e){this.mainModel.EnumerateMeshesAndLines(t=>{let n=e(t.userData);t.visible!==n&&(t.visible=n)}),this.mainModel.EnumerateEdges(t=>{let n=e(t.userData);t.visible!==n&&(t.visible=n)}),this.Render()}SetMeshesHighlight(e,t){let n=this.mainModel.HasLinesOrEdges();this.mainModel.EnumerateMeshesAndLines(i=>{t(i.userData)?i.userData.threeMaterials===null&&(i.userData.threeMaterials=i.material,i.material=Pf(i.userData.threeMaterials,e,n)):i.userData.threeMaterials!==null&&(i.material=i.userData.threeMaterials,i.userData.threeMaterials=null)}),this.Render()}GetMeshUserDataUnderMouse(e,t){let n=this.GetMeshIntersectionUnderMouse(e,t);return n===null?null:n.object.userData}GetMeshIntersectionUnderMouse(e,t){let n=this.GetCanvasSize(),i=this.mainModel.GetMeshIntersectionUnderMouse(e,t,this.camera,n.width,n.height);return i===null?null:i}GetBoundingBox(e){return this.mainModel.GetBoundingBox(e)}GetBoundingSphere(e){return this.mainModel.GetBoundingSphere(e)}EnumerateMeshesAndLinesUserData(e){this.mainModel.EnumerateMeshesAndLines(t=>{e(t.userData)})}InitNavigation(){let e=sd(_t.Y);this.camera=new nn(45,1,.1,1e3),this.projectionMode=ei.Perspective,this.cameraValidator=new ru,this.scene.add(this.camera);let t=this.renderer.domElement;this.navigation=new El(t,e,{onUpdate:()=>{this.Render()}}),this.upVector=new su}InitShading(){this.shadingModel=new bl(this.scene)}GetShadingType(){return this.shadingModel.type}GetImageSize(){let e=new Pe;return this.renderer.getSize(e),{width:parseInt(e.x,10),height:parseInt(e.y,10)}}GetCanvasSize(){let e=this.canvas.width,t=this.canvas.height;return window.devicePixelRatio&&(e/=window.devicePixelRatio,t/=window.devicePixelRatio),{width:e,height:t}}GetImageAsDataUrl(e,t,n){let i=this.GetImageSize(),s=e,o=t;window.devicePixelRatio&&(s/=window.devicePixelRatio,o/=window.devicePixelRatio);let a=this.renderer.getClearAlpha();n&&this.renderer.setClearAlpha(0),this.ResizeRenderer(s,o),this.Render();let l=this.renderer.domElement.toDataURL();return this.ResizeRenderer(i.width,i.height),this.renderer.setClearAlpha(a),l}Destroy(){this.Clear(),this.renderer.dispose()}};var Al=class{constructor(e,t){this.parentElement=e,this.parameters={},Do(t)&&(this.parameters=t),this.canvas=document.createElement("canvas"),this.parentElement.appendChild(this.canvas),this.viewer=new Sl,this.viewer.Init(this.canvas);let n=this.parentElement.clientWidth,i=this.parentElement.clientHeight;this.viewer.Resize(n,i),this.parameters.projectionMode&&this.viewer.SetProjectionMode(this.parameters.projectionMode),this.parameters.backgroundColor&&this.viewer.SetBackgroundColor(this.parameters.backgroundColor),this.parameters.edgeSettings&&this.viewer.SetEdgeSettings(this.parameters.edgeSettings),this.parameters.environmentSettings&&this.viewer.SetEnvironmentMapSettings(this.parameters.environmentSettings),this.model=null,this.modelLoader=new Ml,this.progressDiv=null,window.addEventListener("resize",()=>{this.Resize()})}LoadModelFromUrlList(e){Mu(e);let t=Ou(e);this.LoadModelFromInputFiles(t)}LoadModelFromFileList(e){let t=Du(e);this.LoadModelFromInputFiles(t)}LoadModelFromInputFiles(e){if(e===null||e.length===0)return;this.viewer.Clear();let t=new ml;this.parameters.defaultColor&&(t.defaultColor=this.parameters.defaultColor),this.parameters.defaultLineColor&&(t.defaultLineColor=this.parameters.defaultLineColor),this.model=null,this.progressDiv!==null&&(this.parentElement.removeChild(this.progressDiv),this.progressDiv=null),this.modelLoader.LoadModel(e,t,{onLoadStart:()=>{this.canvas.style.display="none",this.progressDiv=document.createElement("div"),this.progressDiv.innerHTML=nt("Loading model..."),this.parentElement.appendChild(this.progressDiv)},onFileListProgress:(n,i)=>{},onFileLoadProgress:(n,i)=>{},onImportStart:()=>{this.progressDiv.innerHTML=nt("Importing model...")},onVisualizationStart:()=>{this.progressDiv.innerHTML=nt("Visualizing model...")},onModelFinished:(n,i)=>{this.parentElement.removeChild(this.progressDiv),this.progressDiv=null,this.canvas.style.display="inherit",this.viewer.SetMainObject(i);let s=this.viewer.GetBoundingSphere(o=>!0);this.viewer.AdjustClippingPlanesToSphere(s),this.parameters.camera?this.viewer.SetCamera(this.parameters.camera):(this.viewer.SetUpVector(_t.Y,!1),this.viewer.FitSphereToWindow(s,!1)),this.model=n.model,this.parameters.onModelLoaded&&this.parameters.onModelLoaded()},onTextureLoaded:()=>{this.viewer.Render()},onLoadError:n=>{let i=nt("Unknown error.");n.code===Lr.NoImportableFile?i=nt("No importable file found."):n.code===Lr.FailedToLoadFile?i=nt("Failed to load file for import."):n.code===Lr.ImportFailed&&(i=nt("Failed to import model.")),n.message!==null&&(i+=" ("+n.message+")"),this.progressDiv.innerHTML=i,this.parameters.onModelLoadFailed&&this.parameters.onModelLoadFailed()}})}GetViewer(){return this.viewer}GetModel(){return this.model}Resize(){let e=this.parentElement.clientWidth,t=this.parentElement.clientHeight;this.viewer.Resize(e,t)}Destroy(){this.modelLoader.Destroy(),this.viewer.Destroy(),this.model=null}};function Ym(r,e,t){let n=new Al(r,t);return n.LoadModelFromUrlList(e),n}function Dx(r,e,t){let n=new Al(r,t);return n.LoadModelFromFileList(e),n}function Fx(r){function e(i){let s=null,o=i.getAttribute("camera");o&&(s=rn.StringToCamera(o));let a=null,l=i.getAttribute("projectionmode");l&&(a=rn.StringToProjectionMode(l));let c=null,u=i.getAttribute("backgroundcolor");u&&(c=rn.StringToRGBAColor(u));let h=null,f=i.getAttribute("defaultcolor");f&&(h=rn.StringToRGBColor(f));let p=null,g=i.getAttribute("defaultlinecolor");g&&(p=rn.StringToRGBColor(g));let y=null,d=i.getAttribute("edgesettings");d&&(y=rn.StringToEdgeSettings(d));let m=null,_=i.getAttribute("environmentmap");if(_){let S=_.split(",");if(S.length===6){let I=!1,A=i.getAttribute("environmentmapbg");A&&A==="true"&&(I=!0),m=new Ro(S,I)}}let v=null,x=i.getAttribute("model");return x&&(v=rn.StringToModelUrls(x)),Ym(i,v,{camera:s,projectionMode:a,backgroundColor:c,defaultLineColor:p,defaultColor:h,edgeSettings:y,environmentSettings:m})}let t=[],n=document.getElementsByClassName("online_3d_viewer");for(let i=0;i<n.length;i++){let s=n[i],o=e(s);t.push(o)}return t}return Hx(nA);})();
/*! Bundled license information:
+three/build/three.core.js:
three/build/three.module.js:
(**
* @license
- * Copyright 2010-2023 Three.js Authors
+ * Copyright 2010-2025 Three.js Authors
* SPDX-License-Identifier: MIT
*)