@splinetool/viewer 0.9.300 → 0.9.302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/spline-viewer.cjs
CHANGED
|
@@ -3137,7 +3137,7 @@ void main() {
|
|
|
3137
3137
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3138
3138
|
}`;function ZP(e,t,i){let r=new pg,s=new G,n=new G,a=new $e,o=new Cw({depthPacking:fw}),l=new qP,h={},u=i.maxTextureSize,c={[Vr]:hi,[hi]:Vr,[er]:er},d=new ri({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new G},radius:{value:4}},vertexShader:YP,fragmentShader:QP}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ve;f.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new tr(f,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=hg,this.render=function(x,w,A){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||x.length===0)return;let S=e.getRenderTarget(),_=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),C=e.state;C.setBlending(fi),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,P=x.length;T<P;T++){let L=x[T],D=L.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",L,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;s.copy(D.mapSize);let k=D.getFrameExtents();if(s.multiply(k),n.copy(D.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(n.x=Math.floor(u/k.x),s.x=n.x*k.x,D.mapSize.x=n.x),s.y>u&&(n.y=Math.floor(u/k.y),s.y=n.y*k.y,D.mapSize.y=n.y)),D.map===null){let X=this.type!==Gl?{minFilter:Ot,magFilter:Ot}:{};D.map=new ii(s.x,s.y,X),D.map.texture.name=L.name+".shadowMap",D.camera.updateProjectionMatrix()}e.setRenderTarget(D.map),e.clear();let W=D.getViewportCount();for(let X=0;X<W;X++){let z=D.getViewport(X);a.set(n.x*z.x,n.y*z.y,n.x*z.z,n.y*z.w),C.viewport(a),D.updateMatrices(L,X),r=D.getFrustum(),b(w,A,D.camera,L,this.type)}D.isPointLightShadow!==!0&&this.type===Gl&&v(D,A),D.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(S,_,M)};function v(x,w){let A=t.update(g);d.defines.VSM_SAMPLES!==x.blurSamples&&(d.defines.VSM_SAMPLES=x.blurSamples,p.defines.VSM_SAMPLES=x.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),x.mapPass===null&&(x.mapPass=new ii(s.x,s.y)),d.uniforms.shadow_pass.value=x.map.texture,d.uniforms.resolution.value=x.mapSize,d.uniforms.radius.value=x.radius,e.setRenderTarget(x.mapPass),e.clear(),e.renderBufferDirect(w,null,A,d,g,null),p.uniforms.shadow_pass.value=x.mapPass.texture,p.uniforms.resolution.value=x.mapSize,p.uniforms.radius.value=x.radius,e.setRenderTarget(x.map),e.clear(),e.renderBufferDirect(w,null,A,p,g,null)}function y(x,w,A,S,_,M){let C=null,T=A.isPointLight===!0?x.customDistanceMaterial:x.customDepthMaterial;if(T!==void 0)C=T;else if(C=A.isPointLight===!0?l:o,e.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){let P=C.uuid,L=w.uuid,D=h[P];D===void 0&&(D={},h[P]=D);let k=D[L];k===void 0&&(k=C.clone(),D[L]=k),C=k}return C.visible=w.visible,C.wireframe=w.wireframe,M===Gl?C.side=w.shadowSide!==null?w.shadowSide:w.side:C.side=w.shadowSide!==null?w.shadowSide:c[w.side],C.alphaMap=w.alphaMap,C.alphaTest=w.alphaTest,C.map=w.map,C.clipShadows=w.clipShadows,C.clippingPlanes=w.clippingPlanes,C.clipIntersection=w.clipIntersection,C.displacementMap=w.displacementMap,C.displacementScale=w.displacementScale,C.displacementBias=w.displacementBias,C.wireframeLinewidth=w.wireframeLinewidth,C.linewidth=w.linewidth,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(A.matrixWorld),C.nearDistance=S,C.farDistance=_),C}function b(x,w,A,S,_){if(x.visible===!1)return;if(x.layers.test(w.layers)&&(x.isMesh||x.isLine||x.isPoints)&&(x.castShadow||x.receiveShadow&&_===Gl)&&(!x.frustumCulled||r.intersectsObject(x))){x.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,x.matrixWorld);let C=t.update(x),T=x.material;if(Array.isArray(T)){let P=C.groups;for(let L=0,D=P.length;L<D;L++){let k=P[L],W=T[k.materialIndex];if(W&&W.visible){let X=y(x,W,S,A.near,A.far,_);e.renderBufferDirect(A,null,C,X,x,k)}}}else if(T.visible){let P=y(x,T,S,A.near,A.far,_);e.renderBufferDirect(A,null,C,P,x,null)}}let M=x.children;for(let C=0,T=M.length;C<T;C++)b(M[C],w,A,S,_)}}function KP(e,t,i){let r=i.isWebGL2;function s(){let q=!1,ne=new $e,de=null,Ae=new $e(0,0,0,0);return{setMask:function(De){de!==De&&!q&&(e.colorMask(De,De,De,De),de=De)},setLocked:function(De){q=De},setClear:function(De,ot,Xt,Ft,kn){kn===!0&&(De*=Ft,ot*=Ft,Xt*=Ft),ne.set(De,ot,Xt,Ft),Ae.equals(ne)===!1&&(e.clearColor(De,ot,Xt,Ft),Ae.copy(ne))},reset:function(){q=!1,de=null,Ae.set(-1,0,0,0)}}}function n(){let q=!1,ne=null,de=null,Ae=null;return{setTest:function(De){De?se(2929):V(2929)},setMask:function(De){ne!==De&&!q&&(e.depthMask(De),ne=De)},setFunc:function(De){if(de!==De){switch(De){case gM:e.depthFunc(512);break;case vM:e.depthFunc(519);break;case yM:e.depthFunc(513);break;case Nf:e.depthFunc(515);break;case xM:e.depthFunc(514);break;case bM:e.depthFunc(518);break;case wM:e.depthFunc(516);break;case _M:e.depthFunc(517);break;default:e.depthFunc(515)}de=De}},setLocked:function(De){q=De},setClear:function(De){Ae!==De&&(e.clearDepth(De),Ae=De)},reset:function(){q=!1,ne=null,de=null,Ae=null}}}function a(){let q=!1,ne=null,de=null,Ae=null,De=null,ot=null,Xt=null,Ft=null,kn=null;return{setTest:function(Dt){q||(Dt?se(2960):V(2960))},setMask:function(Dt){ne!==Dt&&!q&&(e.stencilMask(Dt),ne=Dt)},setFunc:function(Dt,Ms,lr){(de!==Dt||Ae!==Ms||De!==lr)&&(e.stencilFunc(Dt,Ms,lr),de=Dt,Ae=Ms,De=lr)},setOp:function(Dt,Ms,lr){(ot!==Dt||Xt!==Ms||Ft!==lr)&&(e.stencilOp(Dt,Ms,lr),ot=Dt,Xt=Ms,Ft=lr)},setLocked:function(Dt){q=Dt},setClear:function(Dt){kn!==Dt&&(e.clearStencil(Dt),kn=Dt)},reset:function(){q=!1,ne=null,de=null,Ae=null,De=null,ot=null,Xt=null,Ft=null,kn=null}}}let o=new s,l=new n,h=new a,u=new WeakMap,c=new WeakMap,d={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,b=null,x=null,w=null,A=null,S=null,_=null,M=!1,C=null,T=null,P=null,L=null,D=null,k=e.getParameter(35661),W=!1,X=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec(z)[1]),W=X>=1):z.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),W=X>=2);let j=null,U={},N=e.getParameter(3088),B=e.getParameter(2978),H=new $e().fromArray(N),Q=new $e().fromArray(B);function Y(q,ne,de){let Ae=new Uint8Array(4),De=e.createTexture();e.bindTexture(q,De),e.texParameteri(q,10241,9728),e.texParameteri(q,10240,9728);for(let ot=0;ot<de;ot++)e.texImage2D(ne+ot,0,6408,1,1,0,6408,5121,Ae);return De}let F={};F[3553]=Y(3553,3553,1),F[34067]=Y(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),se(2929),l.setFunc(Nf),Te(!1),xe(i0),se(2884),ue(fi);function se(q){d[q]!==!0&&(e.enable(q),d[q]=!0)}function V(q){d[q]!==!1&&(e.disable(q),d[q]=!1)}function ee(q,ne){return p[q]!==ne?(e.bindFramebuffer(q,ne),p[q]=ne,r&&(q===36009&&(p[36160]=ne),q===36160&&(p[36009]=ne)),!0):!1}function J(q,ne){let de=g,Ae=!1;if(q)if(de=f.get(ne),de===void 0&&(de=[],f.set(ne,de)),q.isWebGLMultipleRenderTargets){let De=q.texture;if(de.length!==De.length||de[0]!==36064){for(let ot=0,Xt=De.length;ot<Xt;ot++)de[ot]=36064+ot;de.length=De.length,Ae=!0}}else de[0]!==36064&&(de[0]=36064,Ae=!0);else de[0]!==1029&&(de[0]=1029,Ae=!0);Ae&&(i.isWebGL2?e.drawBuffers(de):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(de))}function fe(q){return m!==q?(e.useProgram(q),m=q,!0):!1}let re={[no]:32774,[nM]:32778,[aM]:32779};if(r)re[a0]=32775,re[o0]=32776;else{let q=t.get("EXT_blend_minmax");q!==null&&(re[a0]=q.MIN_EXT,re[o0]=q.MAX_EXT)}let oe={[oM]:0,[lM]:1,[hM]:768,[hw]:770,[mM]:776,[pM]:774,[dM]:772,[cM]:769,[cw]:771,[fM]:775,[uM]:773};function ue(q,ne,de,Ae,De,ot,Xt,Ft){if(q===fi){v===!0&&(V(3042),v=!1);return}if(v===!1&&(se(3042),v=!0),q!==sM){if(q!==y||Ft!==M){if((b!==no||A!==no)&&(e.blendEquation(32774),b=no,A=no),Ft)switch(q){case Ao:e.blendFuncSeparate(1,771,1,771);break;case r0:e.blendFunc(1,1);break;case s0:e.blendFuncSeparate(0,769,0,1);break;case n0:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",q);break}else switch(q){case Ao:e.blendFuncSeparate(770,771,1,771);break;case r0:e.blendFunc(770,1);break;case s0:e.blendFuncSeparate(0,769,0,1);break;case n0:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",q);break}x=null,w=null,S=null,_=null,y=q,M=Ft}return}De=De||ne,ot=ot||de,Xt=Xt||Ae,(ne!==b||De!==A)&&(e.blendEquationSeparate(re[ne],re[De]),b=ne,A=De),(de!==x||Ae!==w||ot!==S||Xt!==_)&&(e.blendFuncSeparate(oe[de],oe[Ae],oe[ot],oe[Xt]),x=de,w=Ae,S=ot,_=Xt),y=q,M=!1}function ye(q,ne){q.side===er?V(2884):se(2884);let de=q.side===hi;ne&&(de=!de),Te(de),q.blending===Ao&&q.transparent===!1?ue(fi):ue(q.blending,q.blendEquation,q.blendSrc,q.blendDst,q.blendEquationAlpha,q.blendSrcAlpha,q.blendDstAlpha,q.premultipliedAlpha),l.setFunc(q.depthFunc),l.setTest(q.depthTest),l.setMask(q.depthWrite),o.setMask(q.colorWrite);let Ae=q.stencilWrite;h.setTest(Ae),Ae&&(h.setMask(q.stencilWriteMask),h.setFunc(q.stencilFunc,q.stencilRef,q.stencilFuncMask),h.setOp(q.stencilFail,q.stencilZFail,q.stencilZPass)),Ie(q.polygonOffset,q.polygonOffsetFactor,q.polygonOffsetUnits),q.alphaToCoverage===!0?se(32926):V(32926)}function Te(q){C!==q&&(q?e.frontFace(2304):e.frontFace(2305),C=q)}function xe(q){q!==iM?(se(2884),q!==T&&(q===i0?e.cullFace(1029):q===rM?e.cullFace(1028):e.cullFace(1032))):V(2884),T=q}function we(q){q!==P&&(W&&e.lineWidth(q),P=q)}function Ie(q,ne,de){q?(se(32823),(L!==ne||D!==de)&&(e.polygonOffset(ne,de),L=ne,D=de)):V(32823)}function He(q){q?se(3089):V(3089)}function dt(q){q===void 0&&(q=33984+k-1),j!==q&&(e.activeTexture(q),j=q)}function I(q,ne,de){de===void 0&&(j===null?de=33984+k-1:de=j);let Ae=U[de];Ae===void 0&&(Ae={type:void 0,texture:void 0},U[de]=Ae),(Ae.type!==q||Ae.texture!==ne)&&(j!==de&&(e.activeTexture(de),j=de),e.bindTexture(q,ne||F[q]),Ae.type=q,Ae.texture=ne)}function O(){let q=U[j];q!==void 0&&q.type!==void 0&&(e.bindTexture(q.type,null),q.type=void 0,q.texture=void 0)}function ie(){try{e.compressedTexImage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function pe(){try{e.compressedTexImage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function me(){try{e.texSubImage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function be(){try{e.texSubImage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function We(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function Me(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function ce(){try{e.texStorage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function Fe(){try{e.texStorage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function Ee(){try{e.texImage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function _e(){try{e.texImage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function Le(q){H.equals(q)===!1&&(e.scissor(q.x,q.y,q.z,q.w),H.copy(q))}function Ne(q){Q.equals(q)===!1&&(e.viewport(q.x,q.y,q.z,q.w),Q.copy(q))}function at(q,ne){let de=c.get(ne);de===void 0&&(de=new WeakMap,c.set(ne,de));let Ae=de.get(q);Ae===void 0&&(Ae=e.getUniformBlockIndex(ne,q.name),de.set(q,Ae))}function Mt(q,ne){let de=c.get(ne).get(q);u.get(ne)!==de&&(e.uniformBlockBinding(ne,de,q.__bindingPointIndex),u.set(ne,de))}function Wt(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),d={},j=null,U={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,b=null,x=null,w=null,A=null,S=null,_=null,M=!1,C=null,T=null,P=null,L=null,D=null,H.set(0,0,e.canvas.width,e.canvas.height),Q.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:se,disable:V,bindFramebuffer:ee,drawBuffers:J,useProgram:fe,setBlending:ue,setMaterial:ye,setFlipSided:Te,setCullFace:xe,setLineWidth:we,setPolygonOffset:Ie,setScissorTest:He,activeTexture:dt,bindTexture:I,unbindTexture:O,compressedTexImage2D:ie,compressedTexImage3D:pe,texImage2D:Ee,texImage3D:_e,updateUBOMapping:at,uniformBlockBinding:Mt,texStorage2D:ce,texStorage3D:Fe,texSubImage2D:me,texSubImage3D:be,compressedTexSubImage2D:We,compressedTexSubImage3D:Me,scissor:Le,viewport:Ne,reset:Wt}}function JP(e,t,i,r,s,n,a){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,u=s.maxTextureSize,c=s.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,g,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(I,O){return v?new OffscreenCanvas(I,O):vd("canvas")}function b(I,O,ie,pe){let me=1;if((I.width>pe||I.height>pe)&&(me=pe/Math.max(I.width,I.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){let be=O?gd:Math.floor,We=be(me*I.width),Me=be(me*I.height);g===void 0&&(g=y(We,Me));let ce=ie?y(We,Me):g;return ce.width=We,ce.height=Me,ce.getContext("2d").drawImage(I,0,0,We,Me),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+We+"x"+Me+")."),ce}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function x(I){return Vf(I.width)&&Vf(I.height)}function w(I){return o?!1:I.wrapS!==Ji||I.wrapT!==Ji||I.minFilter!==Ot&&I.minFilter!==mt}function A(I,O){return I.generateMipmaps&&O&&I.minFilter!==Ot&&I.minFilter!==mt}function S(I){e.generateMipmap(I)}function _(I,O,ie,pe,me=!1){if(o===!1)return O;if(I!==null){if(e[I]!==void 0)return e[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let be=O;return O===6403&&(ie===5126&&(be=33326),ie===5131&&(be=33325),ie===5121&&(be=33321)),O===33319&&(ie===5126&&(be=33328),ie===5131&&(be=33327),ie===5121&&(be=33323)),O===6408&&(ie===5126&&(be=34836),ie===5131&&(be=34842),ie===5121&&(be=pe===Ke&&me===!1?35907:32856),ie===32819&&(be=32854),ie===32820&&(be=32855)),(be===33325||be===33326||be===33327||be===33328||be===34842||be===34836)&&t.get("EXT_color_buffer_float"),be}function M(I,O,ie){return A(I,ie)===!0||I.isFramebufferTexture&&I.minFilter!==Ot&&I.minFilter!==mt?Math.log2(Math.max(O.width,O.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?O.mipmaps.length:1}function C(I){return I===Ot||I===l0||I===qu?9728:9729}function T(I){let O=I.target;O.removeEventListener("dispose",T),L(O),O.isVideoTexture&&f.delete(O)}function P(I){let O=I.target;O.removeEventListener("dispose",P),k(O)}function L(I){let O=r.get(I);if(O.__webglInit===void 0)return;let ie=I.source,pe=m.get(ie);if(pe){let me=pe[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&D(I),Object.keys(pe).length===0&&m.delete(ie)}r.remove(I)}function D(I){let O=r.get(I);e.deleteTexture(O.__webglTexture);let ie=I.source,pe=m.get(ie);delete pe[O.__cacheKey],a.memory.textures--}function k(I){let O=I.texture,ie=r.get(I),pe=r.get(O);if(pe.__webglTexture!==void 0&&(e.deleteTexture(pe.__webglTexture),a.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)e.deleteFramebuffer(ie.__webglFramebuffer[me]),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer[me]);else{if(e.deleteFramebuffer(ie.__webglFramebuffer),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer),ie.__webglMultisampledFramebuffer&&e.deleteFramebuffer(ie.__webglMultisampledFramebuffer),ie.__webglColorRenderbuffer)for(let me=0;me<ie.__webglColorRenderbuffer.length;me++)ie.__webglColorRenderbuffer[me]&&e.deleteRenderbuffer(ie.__webglColorRenderbuffer[me]);ie.__webglDepthRenderbuffer&&e.deleteRenderbuffer(ie.__webglDepthRenderbuffer)}if(I.isWebGLMultipleRenderTargets)for(let me=0,be=O.length;me<be;me++){let We=r.get(O[me]);We.__webglTexture&&(e.deleteTexture(We.__webglTexture),a.memory.textures--),r.remove(O[me])}r.remove(O),r.remove(I)}let W=0;function X(){W=0}function z(){let I=W;return I>=l&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+l),W+=1,I}function j(I){let O=[];return O.push(I.wrapS),O.push(I.wrapT),O.push(I.wrapR||0),O.push(I.magFilter),O.push(I.minFilter),O.push(I.anisotropy),O.push(I.internalFormat),O.push(I.format),O.push(I.type),O.push(I.generateMipmaps),O.push(I.premultiplyAlpha),O.push(I.flipY),O.push(I.unpackAlignment),O.push(I.encoding),O.join()}function U(I,O){let ie=r.get(I);if(I.isVideoTexture&&He(I),I.isRenderTargetTexture===!1&&I.version>0&&ie.__version!==I.version){let pe=I.image;if(pe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(pe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{V(ie,I,O);return}}i.bindTexture(3553,ie.__webglTexture,33984+O)}function N(I,O){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){V(ie,I,O);return}i.bindTexture(35866,ie.__webglTexture,33984+O)}function B(I,O){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){V(ie,I,O);return}i.bindTexture(32879,ie.__webglTexture,33984+O)}function H(I,O){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){ee(ie,I,O);return}i.bindTexture(34067,ie.__webglTexture,33984+O)}let Q={[lh]:10497,[Ji]:33071,[kf]:33648},Y={[Ot]:9728,[l0]:9984,[qu]:9986,[mt]:9729,[DM]:9985,[Bo]:9987};function F(I,O,ie){if(ie?(e.texParameteri(I,10242,Q[O.wrapS]),e.texParameteri(I,10243,Q[O.wrapT]),(I===32879||I===35866)&&e.texParameteri(I,32882,Q[O.wrapR]),e.texParameteri(I,10240,Y[O.magFilter]),e.texParameteri(I,10241,Y[O.minFilter])):(e.texParameteri(I,10242,33071),e.texParameteri(I,10243,33071),(I===32879||I===35866)&&e.texParameteri(I,32882,33071),(O.wrapS!==Ji||O.wrapT!==Ji)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(I,10240,C(O.magFilter)),e.texParameteri(I,10241,C(O.minFilter)),O.minFilter!==Ot&&O.minFilter!==mt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let pe=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===Ot||O.minFilter!==qu&&O.minFilter!==Bo||O.type===vn&&t.has("OES_texture_float_linear")===!1||o===!1&&O.type===hh&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(e.texParameterf(I,pe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,s.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function se(I,O){let ie=!1;I.__webglInit===void 0&&(I.__webglInit=!0,O.addEventListener("dispose",T));let pe=O.source,me=m.get(pe);me===void 0&&(me={},m.set(pe,me));let be=j(O);if(be!==I.__cacheKey){me[be]===void 0&&(me[be]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,ie=!0),me[be].usedTimes++;let We=me[I.__cacheKey];We!==void 0&&(me[I.__cacheKey].usedTimes--,We.usedTimes===0&&D(O)),I.__cacheKey=be,I.__webglTexture=me[be].texture}return ie}function V(I,O,ie){let pe=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(pe=35866),O.isData3DTexture&&(pe=32879);let me=se(I,O),be=O.source;i.bindTexture(pe,I.__webglTexture,33984+ie);let We=r.get(be);if(be.version!==We.__version||me===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Me=w(O)&&x(O.image)===!1,ce=b(O.image,Me,!1,u);ce=dt(O,ce);let Fe=x(ce)||o,Ee=n.convert(O.format,O.encoding),_e=n.convert(O.type),Le=_(O.internalFormat,Ee,_e,O.encoding,O.isVideoTexture);F(pe,O,Fe);let Ne,at=O.mipmaps,Mt=o&&O.isVideoTexture!==!0,Wt=We.__version===void 0||me===!0,q=M(O,ce,Fe);if(O.isDepthTexture)Le=6402,o?O.type===vn?Le=36012:O.type===gn?Le=33190:O.type===ca?Le=35056:Le=33189:O.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===da&&Le===6402&&O.type!==pw&&O.type!==gn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=gn,_e=n.convert(O.type)),O.format===ba&&Le===6402&&(Le=34041,O.type!==ca&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=ca,_e=n.convert(O.type))),Wt&&(Mt?i.texStorage2D(3553,1,Le,ce.width,ce.height):i.texImage2D(3553,0,Le,ce.width,ce.height,0,Ee,_e,null));else if(O.isDataTexture)if(at.length>0&&Fe){Mt&&Wt&&i.texStorage2D(3553,q,Le,at[0].width,at[0].height);for(let ne=0,de=at.length;ne<de;ne++)Ne=at[ne],Mt?i.texSubImage2D(3553,ne,0,0,Ne.width,Ne.height,Ee,_e,Ne.data):i.texImage2D(3553,ne,Le,Ne.width,Ne.height,0,Ee,_e,Ne.data);O.generateMipmaps=!1}else Mt?(Wt&&i.texStorage2D(3553,q,Le,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,ce.width,ce.height,Ee,_e,ce.data)):i.texImage2D(3553,0,Le,ce.width,ce.height,0,Ee,_e,ce.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Mt&&Wt&&i.texStorage3D(35866,q,Le,at[0].width,at[0].height,ce.depth);for(let ne=0,de=at.length;ne<de;ne++)Ne=at[ne],O.format!==Ur?Ee!==null?Mt?i.compressedTexSubImage3D(35866,ne,0,0,0,Ne.width,Ne.height,ce.depth,Ee,Ne.data,0,0):i.compressedTexImage3D(35866,ne,Le,Ne.width,Ne.height,ce.depth,0,Ne.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Mt?i.texSubImage3D(35866,ne,0,0,0,Ne.width,Ne.height,ce.depth,Ee,_e,Ne.data):i.texImage3D(35866,ne,Le,Ne.width,Ne.height,ce.depth,0,Ee,_e,Ne.data)}else{Mt&&Wt&&i.texStorage2D(3553,q,Le,at[0].width,at[0].height);for(let ne=0,de=at.length;ne<de;ne++)Ne=at[ne],O.format!==Ur?Ee!==null?Mt?i.compressedTexSubImage2D(3553,ne,0,0,Ne.width,Ne.height,Ee,Ne.data):i.compressedTexImage2D(3553,ne,Le,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Mt?i.texSubImage2D(3553,ne,0,0,Ne.width,Ne.height,Ee,_e,Ne.data):i.texImage2D(3553,ne,Le,Ne.width,Ne.height,0,Ee,_e,Ne.data)}else if(O.isDataArrayTexture)Mt?(Wt&&i.texStorage3D(35866,q,Le,ce.width,ce.height,ce.depth),i.texSubImage3D(35866,0,0,0,0,ce.width,ce.height,ce.depth,Ee,_e,ce.data)):i.texImage3D(35866,0,Le,ce.width,ce.height,ce.depth,0,Ee,_e,ce.data);else if(O.isData3DTexture)Mt?(Wt&&i.texStorage3D(32879,q,Le,ce.width,ce.height,ce.depth),i.texSubImage3D(32879,0,0,0,0,ce.width,ce.height,ce.depth,Ee,_e,ce.data)):i.texImage3D(32879,0,Le,ce.width,ce.height,ce.depth,0,Ee,_e,ce.data);else if(O.isFramebufferTexture){if(Wt)if(Mt)i.texStorage2D(3553,q,Le,ce.width,ce.height);else{let ne=ce.width,de=ce.height;for(let Ae=0;Ae<q;Ae++)i.texImage2D(3553,Ae,Le,ne,de,0,Ee,_e,null),ne>>=1,de>>=1}}else if(at.length>0&&Fe){Mt&&Wt&&i.texStorage2D(3553,q,Le,at[0].width,at[0].height);for(let ne=0,de=at.length;ne<de;ne++)Ne=at[ne],Mt?i.texSubImage2D(3553,ne,0,0,Ee,_e,Ne):i.texImage2D(3553,ne,Le,Ee,_e,Ne);O.generateMipmaps=!1}else Mt?(Wt&&i.texStorage2D(3553,q,Le,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,Ee,_e,ce)):i.texImage2D(3553,0,Le,Ee,_e,ce);A(O,Fe)&&S(pe),We.__version=be.version,O.onUpdate&&O.onUpdate(O)}I.__version=O.version}function ee(I,O,ie){if(O.image.length!==6)return;let pe=se(I,O),me=O.source;i.bindTexture(34067,I.__webglTexture,33984+ie);let be=r.get(me);if(me.version!==be.__version||pe===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let We=O.isCompressedTexture||O.image[0].isCompressedTexture,Me=O.image[0]&&O.image[0].isDataTexture,ce=[];for(let ne=0;ne<6;ne++)!We&&!Me?ce[ne]=b(O.image[ne],!1,!0,h):ce[ne]=Me?O.image[ne].image:O.image[ne],ce[ne]=dt(O,ce[ne]);let Fe=ce[0],Ee=x(Fe)||o,_e=n.convert(O.format,O.encoding),Le=n.convert(O.type),Ne=_(O.internalFormat,_e,Le,O.encoding),at=o&&O.isVideoTexture!==!0,Mt=be.__version===void 0||pe===!0,Wt=M(O,Fe,Ee);F(34067,O,Ee);let q;if(We){at&&Mt&&i.texStorage2D(34067,Wt,Ne,Fe.width,Fe.height);for(let ne=0;ne<6;ne++){q=ce[ne].mipmaps;for(let de=0;de<q.length;de++){let Ae=q[de];O.format!==Ur?_e!==null?at?i.compressedTexSubImage2D(34069+ne,de,0,0,Ae.width,Ae.height,_e,Ae.data):i.compressedTexImage2D(34069+ne,de,Ne,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):at?i.texSubImage2D(34069+ne,de,0,0,Ae.width,Ae.height,_e,Le,Ae.data):i.texImage2D(34069+ne,de,Ne,Ae.width,Ae.height,0,_e,Le,Ae.data)}}}else{q=O.mipmaps,at&&Mt&&(q.length>0&&Wt++,i.texStorage2D(34067,Wt,Ne,ce[0].width,ce[0].height));for(let ne=0;ne<6;ne++)if(Me){at?i.texSubImage2D(34069+ne,0,0,0,ce[ne].width,ce[ne].height,_e,Le,ce[ne].data):i.texImage2D(34069+ne,0,Ne,ce[ne].width,ce[ne].height,0,_e,Le,ce[ne].data);for(let de=0;de<q.length;de++){let Ae=q[de].image[ne].image;at?i.texSubImage2D(34069+ne,de+1,0,0,Ae.width,Ae.height,_e,Le,Ae.data):i.texImage2D(34069+ne,de+1,Ne,Ae.width,Ae.height,0,_e,Le,Ae.data)}}else{at?i.texSubImage2D(34069+ne,0,0,0,_e,Le,ce[ne]):i.texImage2D(34069+ne,0,Ne,_e,Le,ce[ne]);for(let de=0;de<q.length;de++){let Ae=q[de];at?i.texSubImage2D(34069+ne,de+1,0,0,_e,Le,Ae.image[ne]):i.texImage2D(34069+ne,de+1,Ne,_e,Le,Ae.image[ne])}}}A(O,Ee)&&S(34067),be.__version=me.version,O.onUpdate&&O.onUpdate(O)}I.__version=O.version}function J(I,O,ie,pe,me){let be=n.convert(ie.format,ie.encoding),We=n.convert(ie.type),Me=_(ie.internalFormat,be,We,ie.encoding);r.get(O).__hasExternalTextures||(me===32879||me===35866?i.texImage3D(me,0,Me,O.width,O.height,O.depth,0,be,We,null):i.texImage2D(me,0,Me,O.width,O.height,0,be,We,null)),i.bindFramebuffer(36160,I),Ie(O)?d.framebufferTexture2DMultisampleEXT(36160,pe,me,r.get(ie).__webglTexture,0,we(O)):(me===3553||me>=34069&&me<=34074)&&e.framebufferTexture2D(36160,pe,me,r.get(ie).__webglTexture,0),i.bindFramebuffer(36160,null)}function fe(I,O,ie){if(e.bindRenderbuffer(36161,I),O.depthBuffer&&!O.stencilBuffer){let pe=33189;if(ie||Ie(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===vn?pe=36012:me.type===gn&&(pe=33190));let be=we(O);Ie(O)?d.renderbufferStorageMultisampleEXT(36161,be,pe,O.width,O.height):e.renderbufferStorageMultisample(36161,be,pe,O.width,O.height)}else e.renderbufferStorage(36161,pe,O.width,O.height);e.framebufferRenderbuffer(36160,36096,36161,I)}else if(O.depthBuffer&&O.stencilBuffer){let pe=we(O);ie&&Ie(O)===!1?e.renderbufferStorageMultisample(36161,pe,35056,O.width,O.height):Ie(O)?d.renderbufferStorageMultisampleEXT(36161,pe,35056,O.width,O.height):e.renderbufferStorage(36161,34041,O.width,O.height),e.framebufferRenderbuffer(36160,33306,36161,I)}else{let pe=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me<pe.length;me++){let be=pe[me],We=n.convert(be.format,be.encoding),Me=n.convert(be.type),ce=_(be.internalFormat,We,Me,be.encoding),Fe=we(O);ie&&Ie(O)===!1?e.renderbufferStorageMultisample(36161,Fe,ce,O.width,O.height):Ie(O)?d.renderbufferStorageMultisampleEXT(36161,Fe,ce,O.width,O.height):e.renderbufferStorage(36161,ce,O.width,O.height)}}e.bindRenderbuffer(36161,null)}function re(I,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,I),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),U(O.depthTexture,0);let ie=r.get(O.depthTexture).__webglTexture,pe=we(O);if(O.depthTexture.format===da)Ie(O)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ie,0,pe):e.framebufferTexture2D(36160,36096,3553,ie,0);else if(O.depthTexture.format===ba)Ie(O)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ie,0,pe):e.framebufferTexture2D(36160,33306,3553,ie,0);else throw new Error("Unknown depthTexture format")}function oe(I){let O=r.get(I),ie=I.isWebGLCubeRenderTarget===!0;if(I.depthTexture&&!O.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");re(O.__webglFramebuffer,I)}else if(ie){O.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)i.bindFramebuffer(36160,O.__webglFramebuffer[pe]),O.__webglDepthbuffer[pe]=e.createRenderbuffer(),fe(O.__webglDepthbuffer[pe],I,!1)}else i.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=e.createRenderbuffer(),fe(O.__webglDepthbuffer,I,!1);i.bindFramebuffer(36160,null)}function ue(I,O,ie){let pe=r.get(I);O!==void 0&&J(pe.__webglFramebuffer,I,I.texture,36064,3553),ie!==void 0&&oe(I)}function ye(I){let O=I.texture,ie=r.get(I),pe=r.get(O);I.addEventListener("dispose",P),I.isWebGLMultipleRenderTargets!==!0&&(pe.__webglTexture===void 0&&(pe.__webglTexture=e.createTexture()),pe.__version=O.version,a.memory.textures++);let me=I.isWebGLCubeRenderTarget===!0,be=I.isWebGLMultipleRenderTargets===!0,We=x(I)||o;if(me){ie.__webglFramebuffer=[];for(let Me=0;Me<6;Me++)ie.__webglFramebuffer[Me]=e.createFramebuffer()}else{if(ie.__webglFramebuffer=e.createFramebuffer(),be)if(s.drawBuffers){let Me=I.texture;for(let ce=0,Fe=Me.length;ce<Fe;ce++){let Ee=r.get(Me[ce]);Ee.__webglTexture===void 0&&(Ee.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&I.samples>0&&Ie(I)===!1){let Me=be?O:[O];ie.__webglMultisampledFramebuffer=e.createFramebuffer(),ie.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,ie.__webglMultisampledFramebuffer);for(let ce=0;ce<Me.length;ce++){let Fe=Me[ce];ie.__webglColorRenderbuffer[ce]=e.createRenderbuffer(),e.bindRenderbuffer(36161,ie.__webglColorRenderbuffer[ce]);let Ee=n.convert(Fe.format,Fe.encoding),_e=n.convert(Fe.type),Le=_(Fe.internalFormat,Ee,_e,Fe.encoding,I.isXRRenderTarget===!0),Ne=we(I);e.renderbufferStorageMultisample(36161,Ne,Le,I.width,I.height),e.framebufferRenderbuffer(36160,36064+ce,36161,ie.__webglColorRenderbuffer[ce])}e.bindRenderbuffer(36161,null),I.depthBuffer&&(ie.__webglDepthRenderbuffer=e.createRenderbuffer(),fe(ie.__webglDepthRenderbuffer,I,!0)),i.bindFramebuffer(36160,null)}}if(me){i.bindTexture(34067,pe.__webglTexture),F(34067,O,We);for(let Me=0;Me<6;Me++)J(ie.__webglFramebuffer[Me],I,O,36064,34069+Me);A(O,We)&&S(34067),i.unbindTexture()}else if(be){let Me=I.texture;for(let ce=0,Fe=Me.length;ce<Fe;ce++){let Ee=Me[ce],_e=r.get(Ee);i.bindTexture(3553,_e.__webglTexture),F(3553,Ee,We),J(ie.__webglFramebuffer,I,Ee,36064+ce,3553),A(Ee,We)&&S(3553)}i.unbindTexture()}else{let Me=3553;(I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(o?Me=I.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Me,pe.__webglTexture),F(Me,O,We),J(ie.__webglFramebuffer,I,O,36064,Me),A(O,We)&&S(Me),i.unbindTexture()}I.depthBuffer&&oe(I)}function Te(I){let O=x(I)||o,ie=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let pe=0,me=ie.length;pe<me;pe++){let be=ie[pe];if(A(be,O)){let We=I.isWebGLCubeRenderTarget?34067:3553,Me=r.get(be).__webglTexture;i.bindTexture(We,Me),S(We),i.unbindTexture()}}}function xe(I){if(o&&I.samples>0&&Ie(I)===!1){let O=I.isWebGLMultipleRenderTargets?I.texture:[I.texture],ie=I.width,pe=I.height,me=16384,be=[],We=I.stencilBuffer?33306:36096,Me=r.get(I),ce=I.isWebGLMultipleRenderTargets===!0;if(ce)for(let Fe=0;Fe<O.length;Fe++)i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,null),i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,null,0);i.bindFramebuffer(36008,Me.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Me.__webglFramebuffer);for(let Fe=0;Fe<O.length;Fe++){be.push(36064+Fe),I.depthBuffer&&be.push(We);let Ee=Me.__ignoreDepthValues!==void 0?Me.__ignoreDepthValues:!1;if(Ee===!1&&(I.depthBuffer&&(me|=256),I.stencilBuffer&&(me|=1024)),ce&&e.framebufferRenderbuffer(36008,36064,36161,Me.__webglColorRenderbuffer[Fe]),Ee===!0&&(e.invalidateFramebuffer(36008,[We]),e.invalidateFramebuffer(36009,[We])),ce){let _e=r.get(O[Fe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,_e,0)}e.blitFramebuffer(0,0,ie,pe,0,0,ie,pe,me,9728),p&&e.invalidateFramebuffer(36008,be)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ce)for(let Fe=0;Fe<O.length;Fe++){i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,Me.__webglColorRenderbuffer[Fe]);let Ee=r.get(O[Fe]).__webglTexture;i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,Ee,0)}i.bindFramebuffer(36009,Me.__webglMultisampledFramebuffer)}}function we(I){return Math.min(c,I.samples)}function Ie(I){let O=r.get(I);return o&&I.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function He(I){let O=a.render.frame;f.get(I)!==O&&(f.set(I,O),I.update())}function dt(I,O){let ie=I.encoding,pe=I.format,me=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||I.format===Gf||ie!==gs&&(ie===Ke?o===!1?t.has("EXT_sRGB")===!0&&pe===Ur?(I.format=Gf,I.minFilter=mt,I.generateMipmaps=!1):O=vw.sRGBToLinear(O):(pe!==Ur||me!==Mi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ie)),O}this.allocateTextureUnit=z,this.resetTextureUnits=X,this.setTexture2D=U,this.setTexture2DArray=N,this.setTexture3D=B,this.setTextureCube=H,this.rebindTextures=ue,this.setupRenderTarget=ye,this.updateRenderTargetMipmap=Te,this.updateMultisampleRenderTarget=xe,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Ie}function $P(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Mi)return 5121;if(n===RM)return 32819;if(n===BM)return 32820;if(n===LM)return 5120;if(n===OM)return 5122;if(n===pw)return 5123;if(n===IM)return 5124;if(n===gn)return 5125;if(n===vn)return 5126;if(n===hh)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===zM)return 6406;if(n===Ur)return 6408;if(n===NM)return 6409;if(n===UM)return 6410;if(n===da)return 6402;if(n===ba)return 34041;if(n===Gf)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===FM)return 6403;if(n===kM)return 36244;if(n===jM)return 33319;if(n===GM)return 33320;if(n===VM)return 36249;if(n===Yu||n===Qu||n===Zu||n===Ku)if(a===Ke)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===Yu)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Qu)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Zu)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ku)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===Yu)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Qu)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Zu)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ku)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===h0||n===c0||n===d0||n===u0)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===h0)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===c0)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===d0)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===u0)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===HM)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===p0||n===f0)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===p0)return a===Ke?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===f0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===m0||n===g0||n===v0||n===y0||n===x0||n===b0||n===w0||n===_0||n===A0||n===S0||n===M0||n===E0||n===C0||n===T0)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===m0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===g0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===v0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===y0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===x0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===b0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===w0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===_0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===A0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===S0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===M0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===E0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===C0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===T0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ju)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===Ju)return a===Ke?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===WM||n===P0||n===D0||n===L0)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===Ju)return o.COMPRESSED_RED_RGTC1_EXT;if(n===P0)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===D0)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===L0)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===ca?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[n]!==void 0?e[n]:null}return{convert:s}}var eD=class extends wi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},po=class extends bt{constructor(){super(),this.isGroup=!0,this.type="Group"}},tD={type:"move"},Sp=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new po,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 po,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new po,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,n=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){n=!0;for(let f of e.hand.values()){let g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],c=h.position.distanceTo(u.position),d=.02,p=.005;l.inputState.pinching&&c>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(tD)))}return a!==null&&(a.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=n!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new po;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},mg=class extends ci{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:da,h!==da&&h!==ba)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===da&&(i=gn),i===void 0&&h===ba&&(i=ca),super(null,r,s,n,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Ot,this.minFilter=o!==void 0?o:Ot,this.flipY=!1,this.generateMipmaps=!1}},iD=class extends Hi{constructor(e,t){super();let i=this,r=null,s=1,n=null,a="local-floor",o=1,l=null,h=null,u=null,c=null,d=null,p=null,f=t.getContextAttributes(),g=null,m=null,v=[],y=[],b=new Set,x=new Map,w=new wi;w.layers.enable(1),w.viewport=new $e;let A=new wi;A.layers.enable(2),A.viewport=new $e;let S=[w,A],_=new eD;_.layers.enable(1),_.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(N){let B=v[N];return B===void 0&&(B=new Sp,v[N]=B),B.getTargetRaySpace()},this.getControllerGrip=function(N){let B=v[N];return B===void 0&&(B=new Sp,v[N]=B),B.getGripSpace()},this.getHand=function(N){let B=v[N];return B===void 0&&(B=new Sp,v[N]=B),B.getHandSpace()};function T(N){let B=y.indexOf(N.inputSource);if(B===-1)return;let H=v[B];H!==void 0&&H.dispatchEvent({type:N.type,data:N.inputSource})}function P(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",L);for(let N=0;N<v.length;N++){let B=y[N];B!==null&&(y[N]=null,v[N].disconnect(B))}M=null,C=null,e.setRenderTarget(g),d=null,c=null,u=null,r=null,m=null,U.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(N){s=N,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(N){a=N,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(N){l=N},this.getBaseLayer=function(){return c!==null?c:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(N){if(r=N,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",P),r.addEventListener("inputsourceschange",L),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let B={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,B),r.updateRenderState({baseLayer:d}),m=new ii(d.framebufferWidth,d.framebufferHeight,{format:Ur,type:Mi,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let B=null,H=null,Q=null;f.depth&&(Q=f.stencil?35056:33190,B=f.stencil?ba:da,H=f.stencil?ca:gn);let Y={colorFormat:32856,depthFormat:Q,scaleFactor:s};u=new XRWebGLBinding(r,t),c=u.createProjectionLayer(Y),r.updateRenderState({layers:[c]}),m=new ii(c.textureWidth,c.textureHeight,{format:Ur,type:Mi,depthTexture:new mg(c.textureWidth,c.textureHeight,H,void 0,void 0,void 0,void 0,void 0,void 0,B),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let F=e.properties.get(m);F.__ignoreDepthValues=c.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),U.setContext(r),U.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function L(N){for(let B=0;B<N.removed.length;B++){let H=N.removed[B],Q=y.indexOf(H);Q>=0&&(y[Q]=null,v[Q].disconnect(H))}for(let B=0;B<N.added.length;B++){let H=N.added[B],Q=y.indexOf(H);if(Q===-1){for(let F=0;F<v.length;F++)if(F>=y.length){y.push(H),Q=F;break}else if(y[F]===null){y[F]=H,Q=F;break}if(Q===-1)break}let Y=v[Q];Y&&Y.connect(H)}}let D=new E,k=new E;function W(N,B,H){D.setFromMatrixPosition(B.matrixWorld),k.setFromMatrixPosition(H.matrixWorld);let Q=D.distanceTo(k),Y=B.projectionMatrix.elements,F=H.projectionMatrix.elements,se=Y[14]/(Y[10]-1),V=Y[14]/(Y[10]+1),ee=(Y[9]+1)/Y[5],J=(Y[9]-1)/Y[5],fe=(Y[8]-1)/Y[0],re=(F[8]+1)/F[0],oe=se*fe,ue=se*re,ye=Q/(-fe+re),Te=ye*-fe;B.matrixWorld.decompose(N.position,N.quaternion,N.scale),N.translateX(Te),N.translateZ(ye),N.matrixWorld.compose(N.position,N.quaternion,N.scale),N.matrixWorldInverse.copy(N.matrixWorld).invert();let xe=se+ye,we=V+ye,Ie=oe-Te,He=ue+(Q-Te),dt=ee*V/we*xe,I=J*V/we*xe;N.projectionMatrix.makePerspective(Ie,He,dt,I,xe,we)}function X(N,B){B===null?N.matrixWorld.copy(N.matrix):N.matrixWorld.multiplyMatrices(B.matrixWorld,N.matrix),N.matrixWorldInverse.copy(N.matrixWorld).invert()}this.updateCamera=function(N){if(r===null)return;_.near=A.near=w.near=N.near,_.far=A.far=w.far=N.far,(M!==_.near||C!==_.far)&&(r.updateRenderState({depthNear:_.near,depthFar:_.far}),M=_.near,C=_.far);let B=N.parent,H=_.cameras;X(_,B);for(let Y=0;Y<H.length;Y++)X(H[Y],B);_.matrixWorld.decompose(_.position,_.quaternion,_.scale),N.matrix.copy(_.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale);let Q=N.children;for(let Y=0,F=Q.length;Y<F;Y++)Q[Y].updateMatrixWorld(!0);H.length===2?W(_,w,A):_.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return _},this.getFoveation=function(){if(!(c===null&&d===null))return o},this.setFoveation=function(N){o=N,c!==null&&(c.fixedFoveation=N),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=N)},this.getPlanes=function(){return b};let z=null;function j(N,B){if(h=B.getViewerPose(l||n),p=B,h!==null){let H=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let Q=!1;H.length!==_.cameras.length&&(_.cameras.length=0,Q=!0);for(let Y=0;Y<H.length;Y++){let F=H[Y],se=null;if(d!==null)se=d.getViewport(F);else{let ee=u.getViewSubImage(c,F);se=ee.viewport,Y===0&&(e.setRenderTargetTextures(m,ee.colorTexture,c.ignoreDepthValues?void 0:ee.depthStencilTexture),e.setRenderTarget(m))}let V=S[Y];V===void 0&&(V=new wi,V.layers.enable(Y),V.viewport=new $e,S[Y]=V),V.matrix.fromArray(F.transform.matrix),V.projectionMatrix.fromArray(F.projectionMatrix),V.viewport.set(se.x,se.y,se.width,se.height),Y===0&&_.matrix.copy(V.matrix),Q===!0&&_.cameras.push(V)}}for(let H=0;H<v.length;H++){let Q=y[H],Y=v[H];Q!==null&&Y!==void 0&&Y.update(Q,B,l||n)}if(z&&z(N,B),B.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:B.detectedPlanes});let H=null;for(let Q of b)B.detectedPlanes.has(Q)||(H===null&&(H=[]),H.push(Q));if(H!==null)for(let Q of H)b.delete(Q),x.delete(Q),i.dispatchEvent({type:"planeremoved",data:Q});for(let Q of B.detectedPlanes)if(!b.has(Q))b.add(Q),x.set(Q,B.lastChangedTime),i.dispatchEvent({type:"planeadded",data:Q});else{let Y=x.get(Q);Q.lastChangedTime>Y&&(x.set(Q,Q.lastChangedTime),i.dispatchEvent({type:"planechanged",data:Q}))}}p=null}let U=new _w;U.setAnimationLoop(j),this.setAnimationLoop=function(N){z=N},this.dispose=function(){}}};function rD(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,ww(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,v,y,b){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),u(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),c(g,m),m.isMeshPhysicalMaterial&&d(g,m,b)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(n(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?o(g,m,v,y):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===hi&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===hi&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let x=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*x}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix));let b;m.aoMap?b=m.aoMap:m.lightMap&&(b=m.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),g.uv2Transform.value.copy(b.matrix))}function n(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,v,y){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*v,g.scale.value=y*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let b;m.map?b=m.map:m.alphaMap&&(b=m.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),g.uvTransform.value.copy(b.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function c(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,v){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===hi&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function sD(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,b){let x=b.program;r.uniformBlockBinding(y,x)}function h(y,b){let x=s[y.id];x===void 0&&(f(y),x=u(y),s[y.id]=x,y.addEventListener("dispose",m));let w=b.program;r.updateUBOMapping(y,w);let A=t.render.frame;n[y.id]!==A&&(d(y),n[y.id]=A)}function u(y){let b=c();y.__bindingPointIndex=b;let x=e.createBuffer(),w=y.__size,A=y.usage;return e.bindBuffer(35345,x),e.bufferData(35345,w,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,b,x),x}function c(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){let b=s[y.id],x=y.uniforms,w=y.__cache;e.bindBuffer(35345,b);for(let A=0,S=x.length;A<S;A++){let _=x[A];if(p(_,A,w)===!0){let M=_.__offset,C=Array.isArray(_.value)?_.value:[_.value],T=0;for(let P=0;P<C.length;P++){let L=C[P],D=g(L);typeof L=="number"?(_.__data[0]=L,e.bufferSubData(35345,M+T,_.__data)):L.isMatrix3?(_.__data[0]=L.elements[0],_.__data[1]=L.elements[1],_.__data[2]=L.elements[2],_.__data[3]=L.elements[0],_.__data[4]=L.elements[3],_.__data[5]=L.elements[4],_.__data[6]=L.elements[5],_.__data[7]=L.elements[0],_.__data[8]=L.elements[6],_.__data[9]=L.elements[7],_.__data[10]=L.elements[8],_.__data[11]=L.elements[0]):(L.toArray(_.__data,T),T+=D.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,_.__data)}}e.bindBuffer(35345,null)}function p(y,b,x){let w=y.value;if(x[b]===void 0){if(typeof w=="number")x[b]=w;else{let A=Array.isArray(w)?w:[w],S=[];for(let _=0;_<A.length;_++)S.push(A[_].clone());x[b]=S}return!0}else if(typeof w=="number"){if(x[b]!==w)return x[b]=w,!0}else{let A=Array.isArray(x[b])?x[b]:[x[b]],S=Array.isArray(w)?w:[w];for(let _=0;_<A.length;_++){let M=A[_];if(M.equals(S[_])===!1)return M.copy(S[_]),!0}}return!1}function f(y){let b=y.uniforms,x=0,w=16,A=0;for(let S=0,_=b.length;S<_;S++){let M=b[S],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let P=0,L=T.length;P<L;P++){let D=T[P],k=g(D);C.boundary+=k.boundary,C.storage+=k.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=x,S>0){A=x%w;let P=w-A;A!==0&&P-C.boundary<0&&(x+=w-A,M.__offset=x)}x+=C.storage}return A=x%w,A>0&&(x+=w-A),y.__size=x,y.__cache={},this}function g(y){let b={boundary:0,storage:0};return typeof y=="number"?(b.boundary=4,b.storage=4):y.isVector2?(b.boundary=8,b.storage=8):y.isVector3||y.isColor?(b.boundary=16,b.storage=12):y.isVector4?(b.boundary=16,b.storage=16):y.isMatrix3?(b.boundary=48,b.storage=48):y.isMatrix4?(b.boundary=64,b.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),b}function m(y){let b=y.target;b.removeEventListener("dispose",m);let x=a.indexOf(b.__bindingPointIndex);a.splice(x,1),e.deleteBuffer(s[b.id]),delete s[b.id],delete n[b.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},n={}}return{bind:l,update:h,dispose:v}}function nD(){let e=vd("canvas");return e.style.display="block",e}function Tw(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:nD(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,n=e.antialias!==void 0?e.antialias:!1,a=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,u;i!==null?u=i.getContextAttributes().alpha:u=e.alpha!==void 0?e.alpha:!1;let c=null,d=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=gs,this.physicallyCorrectLights=!1,this.toneMapping=Gs,this.toneMappingExposure=1;let g=this,m=!1,v=0,y=0,b=null,x=-1,w=null,A=new $e,S=new $e,_=null,M=t.width,C=t.height,T=1,P=null,L=null,D=new $e(0,0,M,C),k=new $e(0,0,M,C),W=!1,X=new pg,z=!1,j=!1,U=null,N=new ve,B=new G,H=new E,Q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return b===null?T:1}let F=i;function se(R,$){for(let ae=0;ae<R.length;ae++){let K=R[ae],he=t.getContext(K,$);if(he!==null)return he}return null}try{let R={alpha:!0,depth:r,stencil:s,antialias:n,premultipliedAlpha:a,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Wo}`),t.addEventListener("webglcontextlost",Le,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",at,!1),F===null){let $=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&$.shift(),F=se($,R),F===null)throw se($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}F.getShaderPrecisionFormat===void 0&&(F.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(R){throw console.error("THREE.WebGLRenderer: "+R.message),R}let V,ee,J,fe,re,oe,ue,ye,Te,xe,we,Ie,He,dt,I,O,ie,pe,me,be,We,Me,ce,Fe;function Ee(){V=new y3(F),ee=new u3(F,V,e),V.init(ee),Me=new $P(F,V,ee),J=new KP(F,V,ee),fe=new w3,re=new UP,oe=new JP(F,V,J,re,ee,Me,fe),ue=new f3(g),ye=new v3(g),Te=new DE(F,ee),ce=new c3(F,V,Te,ee),xe=new x3(F,Te,fe,ce),we=new M3(F,xe,Te,fe),me=new S3(F,ee,oe),O=new p3(re),Ie=new NP(g,ue,ye,V,ee,ce,O),He=new rD(g,re),dt=new kP,I=new XP(V,ee),pe=new h3(g,ue,ye,J,we,u,a),ie=new ZP(g,we,ee),Fe=new sD(F,fe,ee,J),be=new d3(F,V,fe,ee),We=new b3(F,V,fe,ee),fe.programs=Ie.programs,g.capabilities=ee,g.extensions=V,g.properties=re,g.renderLists=dt,g.shadowMap=ie,g.state=J,g.info=fe}Ee();let _e=new iD(g,F);this.xr=_e,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){let R=V.get("WEBGL_lose_context");R&&R.loseContext()},this.forceContextRestore=function(){let R=V.get("WEBGL_lose_context");R&&R.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(R){R!==void 0&&(T=R,this.setSize(M,C,!1))},this.getSize=function(R){return R.set(M,C)},this.setSize=function(R,$,ae){if(_e.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=R,C=$,t.width=Math.floor(R*T),t.height=Math.floor($*T),ae!==!1&&(t.style.width=R+"px",t.style.height=$+"px"),this.setViewport(0,0,R,$)},this.getDrawingBufferSize=function(R){return R.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(R,$,ae){M=R,C=$,T=ae,t.width=Math.floor(R*ae),t.height=Math.floor($*ae),this.setViewport(0,0,R,$)},this.getCurrentViewport=function(R){return R.copy(A)},this.getViewport=function(R){return R.copy(D)},this.setViewport=function(R,$,ae,K){R.isVector4?D.set(R.x,R.y,R.z,R.w):D.set(R,$,ae,K),J.viewport(A.copy(D).multiplyScalar(T).floor())},this.getScissor=function(R){return R.copy(k)},this.setScissor=function(R,$,ae,K){R.isVector4?k.set(R.x,R.y,R.z,R.w):k.set(R,$,ae,K),J.scissor(S.copy(k).multiplyScalar(T).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(R){J.setScissorTest(W=R)},this.setOpaqueSort=function(R){P=R},this.setTransparentSort=function(R){L=R},this.getClearColor=function(R){return R.copy(pe.getClearColor())},this.setClearColor=function(){pe.setClearColor.apply(pe,arguments)},this.getClearAlpha=function(){return pe.getClearAlpha()},this.setClearAlpha=function(){pe.setClearAlpha.apply(pe,arguments)},this.clear=function(R=!0,$=!0,ae=!0){let K=0;R&&(K|=16384),$&&(K|=256),ae&&(K|=1024),F.clear(K)},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",Le,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",at,!1),dt.dispose(),I.dispose(),re.dispose(),ue.dispose(),ye.dispose(),we.dispose(),ce.dispose(),Fe.dispose(),Ie.dispose(),_e.dispose(),_e.removeEventListener("sessionstart",Ae),_e.removeEventListener("sessionend",De),U&&(U.dispose(),U=null),ot.stop()};function Le(R){R.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let R=fe.autoReset,$=ie.enabled,ae=ie.autoUpdate,K=ie.needsUpdate,he=ie.type;Ee(),fe.autoReset=R,ie.enabled=$,ie.autoUpdate=ae,ie.needsUpdate=K,ie.type=he}function at(R){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",R.statusMessage)}function Mt(R){let $=R.target;$.removeEventListener("dispose",Mt),Wt($)}function Wt(R){q(R),re.remove(R)}function q(R){let $=re.get(R).programs;$!==void 0&&($.forEach(function(ae){Ie.releaseProgram(ae)}),R.isShaderMaterial&&Ie.releaseShaderCache(R))}this.renderBufferDirect=function(R,$,ae,K,he,Be){$===null&&($=Q);let Je=he.isMesh&&he.matrixWorld.determinant()<0,et=z2(R,$,ae,K,he);J.setMaterial(K,Je);let st=ae.index,wt=1;K.wireframe===!0&&(st=xe.getWireframeAttribute(ae),wt=2);let ut=ae.drawRange,lt=ae.attributes.position,vi=ut.start*wt,Wi=(ut.start+ut.count)*wt;Be!==null&&(vi=Math.max(vi,Be.start*wt),Wi=Math.min(Wi,(Be.start+Be.count)*wt)),st!==null?(vi=Math.max(vi,0),Wi=Math.min(Wi,st.count)):lt!=null&&(vi=Math.max(vi,0),Wi=Math.min(Wi,lt.count));let Es=Wi-vi;if(Es<0||Es===1/0)return;ce.setup(he,K,et,ae,st);let jn,qt=be;if(st!==null&&(jn=Te.get(st),qt=We,qt.setIndex(jn)),he.isMesh)K.wireframe===!0?(J.setLineWidth(K.wireframeLinewidth*Y()),qt.setMode(1)):qt.setMode(4);else if(he.isLine){let ht=K.linewidth;ht===void 0&&(ht=1),J.setLineWidth(ht*Y()),he.isLineSegments?qt.setMode(1):he.isLineLoop?qt.setMode(2):qt.setMode(3)}else he.isPoints?qt.setMode(0):he.isSprite&&qt.setMode(4);if(he.isInstancedMesh)qt.renderInstances(vi,Es,he.count);else if(ae.isInstancedBufferGeometry){let ht=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,Gu=Math.min(ae.instanceCount,ht);qt.renderInstances(vi,Es,Gu)}else qt.render(vi,Es)},this.compile=function(R,$){function ae(K,he,Be){K.transparent===!0&&K.side===er&&K.forceSinglePass===!1?(K.side=hi,K.needsUpdate=!0,lr(K,he,Be),K.side=Vr,K.needsUpdate=!0,lr(K,he,Be),K.side=er):lr(K,he,Be)}d=I.get(R),d.init(),f.push(d),R.traverseVisible(function(K){K.isLight&&K.layers.test($.layers)&&(d.pushLight(K),K.castShadow&&d.pushShadow(K))}),d.setupLights(g.physicallyCorrectLights),R.traverse(function(K){let he=K.material;if(he)if(Array.isArray(he))for(let Be=0;Be<he.length;Be++){let Je=he[Be];ae(Je,R,K)}else ae(he,R,K)}),f.pop(),d=null};let ne=null;function de(R){ne&&ne(R)}function Ae(){ot.stop()}function De(){ot.start()}let ot=new _w;ot.setAnimationLoop(de),typeof self<"u"&&ot.setContext(self),this.setAnimationLoop=function(R){ne=R,_e.setAnimationLoop(R),R===null?ot.stop():ot.start()},_e.addEventListener("sessionstart",Ae),_e.addEventListener("sessionend",De),this.render=function(R,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),$.parent===null&&$.matrixWorldAutoUpdate===!0&&$.updateMatrixWorld(),_e.enabled===!0&&_e.isPresenting===!0&&(_e.cameraAutoUpdate===!0&&_e.updateCamera($),$=_e.getCamera()),R.isScene===!0&&R.onBeforeRender(g,R,$,b),d=I.get(R,f.length),d.init(),f.push(d),N.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),X.setFromProjectionMatrix(N),j=this.localClippingEnabled,z=O.init(this.clippingPlanes,j),c=dt.get(R,p.length),c.init(),p.push(c),Xt(R,$,0,g.sortObjects),c.finish(),g.sortObjects===!0&&c.sort(P,L),z===!0&&O.beginShadows();let ae=d.state.shadowsArray;if(ie.render(ae,R,$),z===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),pe.render(c,R),d.setupLights(g.physicallyCorrectLights),$.isArrayCamera){let K=$.cameras;for(let he=0,Be=K.length;he<Be;he++){let Je=K[he];Ft(c,R,Je,Je.viewport)}}else Ft(c,R,$);b!==null&&(oe.updateMultisampleRenderTarget(b),oe.updateRenderTargetMipmap(b)),R.isScene===!0&&R.onAfterRender(g,R,$),ce.resetDefaultState(),x=-1,w=null,f.pop(),f.length>0?d=f[f.length-1]:d=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function Xt(R,$,ae,K){if(R.visible===!1)return;if(R.layers.test($.layers)){if(R.isGroup)ae=R.renderOrder;else if(R.isLOD)R.autoUpdate===!0&&R.update($);else if(R.isLight)d.pushLight(R),R.castShadow&&d.pushShadow(R);else if(R.isSprite){if(!R.frustumCulled||X.intersectsSprite(R)){K&&H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(N);let Be=we.update(R),Je=R.material;Je.visible&&c.push(R,Be,Je,ae,H.z,null)}}else if((R.isMesh||R.isLine||R.isPoints)&&(R.isSkinnedMesh&&R.skeleton.frame!==fe.render.frame&&(R.skeleton.update(),R.skeleton.frame=fe.render.frame),!R.frustumCulled||X.intersectsObject(R))){K&&H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(N);let Be=we.update(R),Je=R.material;if(Array.isArray(Je)){let et=Be.groups;for(let st=0,wt=et.length;st<wt;st++){let ut=et[st],lt=Je[ut.materialIndex];lt&<.visible&&c.push(R,Be,lt,ae,H.z,ut)}}else Je.visible&&c.push(R,Be,Je,ae,H.z,null)}}let he=R.children;for(let Be=0,Je=he.length;Be<Je;Be++)Xt(he[Be],$,ae,K)}function Ft(R,$,ae,K){let he=R.opaque,Be=R.transmissive,Je=R.transparent;d.setupLightsView(ae),z===!0&&O.setGlobalState(g.clippingPlanes,ae),Be.length>0&&kn(he,$,ae),K&&J.viewport(A.copy(K)),he.length>0&&Dt(he,$,ae),Be.length>0&&Dt(Be,$,ae),Je.length>0&&Dt(Je,$,ae),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function kn(R,$,ae){let K=ee.isWebGL2;U===null&&(U=new ii(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")?hh:Mi,minFilter:Bo,samples:K&&n===!0?4:0})),g.getDrawingBufferSize(B),K?U.setSize(B.x,B.y):U.setSize(gd(B.x),gd(B.y));let he=g.getRenderTarget();g.setRenderTarget(U),g.clear();let Be=g.toneMapping;g.toneMapping=Gs,Dt(R,$,ae),g.toneMapping=Be,oe.updateMultisampleRenderTarget(U),oe.updateRenderTargetMipmap(U),g.setRenderTarget(he)}function Dt(R,$,ae){let K=$.isScene===!0?$.overrideMaterial:null;for(let he=0,Be=R.length;he<Be;he++){let Je=R[he],et=Je.object,st=Je.geometry,wt=K===null?Je.material:K,ut=Je.group;et.layers.test(ae.layers)&&Ms(et,$,ae,st,wt,ut)}}function Ms(R,$,ae,K,he,Be){R.onBeforeRender(g,$,ae,K,he,Be),R.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,R.matrixWorld),R.normalMatrix.getNormalMatrix(R.modelViewMatrix),he.onBeforeRender(g,$,ae,K,R,Be),he.transparent===!0&&he.side===er&&he.forceSinglePass===!1?(he.side=hi,he.needsUpdate=!0,g.renderBufferDirect(ae,$,K,he,R,Be),he.side=Vr,he.needsUpdate=!0,g.renderBufferDirect(ae,$,K,he,R,Be),he.side=er):g.renderBufferDirect(ae,$,K,he,R,Be),R.onAfterRender(g,$,ae,K,he,Be)}function lr(R,$,ae){$.isScene!==!0&&($=Q);let K=re.get(R),he=d.state.lights,Be=d.state.shadowsArray,Je=he.state.version,et=Ie.getParameters(R,he.state,Be,$,ae),st=Ie.getProgramCacheKey(et),wt=K.programs;K.environment=R.isMeshStandardMaterial?$.environment:null,K.fog=$.fog,K.envMap=(R.isMeshStandardMaterial?ye:ue).get(R.envMap||K.environment),wt===void 0&&(R.addEventListener("dispose",Mt),wt=new Map,K.programs=wt);let ut=wt.get(st);if(ut!==void 0){if(K.currentProgram===ut&&K.lightsStateVersion===Je)return Kv(R,et),ut}else et.uniforms=Ie.getUniforms(R),R.onBuild(ae,et,g),R.onBeforeCompile(et,g),ut=Ie.acquireProgram(et,st),wt.set(st,ut),K.uniforms=et.uniforms;let lt=K.uniforms;(!R.isShaderMaterial&&!R.isRawShaderMaterial||R.clipping===!0)&&(lt.clippingPlanes=O.uniform),Kv(R,et),K.needsLights=U2(R),K.lightsStateVersion=Je,K.needsLights&&(lt.ambientLightColor.value=he.state.ambient,lt.lightProbe.value=he.state.probe,lt.directionalLights.value=he.state.directional,lt.directionalLightShadows.value=he.state.directionalShadow,lt.spotLights.value=he.state.spot,lt.spotLightShadows.value=he.state.spotShadow,lt.rectAreaLights.value=he.state.rectArea,lt.ltc_1.value=he.state.rectAreaLTC1,lt.ltc_2.value=he.state.rectAreaLTC2,lt.pointLights.value=he.state.point,lt.pointLightShadows.value=he.state.pointShadow,lt.hemisphereLights.value=he.state.hemi,lt.directionalShadowMap.value=he.state.directionalShadowMap,lt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,lt.spotShadowMap.value=he.state.spotShadowMap,lt.spotLightMatrix.value=he.state.spotLightMatrix,lt.spotLightMap.value=he.state.spotLightMap,lt.pointShadowMap.value=he.state.pointShadowMap,lt.pointShadowMatrix.value=he.state.pointShadowMatrix);let vi=ut.getUniforms(),Wi=ed.seqWithValue(vi.seq,lt);return K.currentProgram=ut,K.uniformsList=Wi,ut}function Kv(R,$){let ae=re.get(R);ae.outputEncoding=$.outputEncoding,ae.instancing=$.instancing,ae.skinning=$.skinning,ae.morphTargets=$.morphTargets,ae.morphNormals=$.morphNormals,ae.morphColors=$.morphColors,ae.morphTargetsCount=$.morphTargetsCount,ae.numClippingPlanes=$.numClippingPlanes,ae.numIntersection=$.numClipIntersection,ae.vertexAlphas=$.vertexAlphas,ae.vertexTangents=$.vertexTangents,ae.toneMapping=$.toneMapping}function z2(R,$,ae,K,he){$.isScene!==!0&&($=Q),oe.resetTextureUnits();let Be=$.fog,Je=K.isMeshStandardMaterial?$.environment:null,et=b===null?g.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:gs,st=(K.isMeshStandardMaterial?ye:ue).get(K.envMap||Je),wt=K.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,ut=!!K.normalMap&&!!ae.attributes.tangent,lt=!!ae.morphAttributes.position,vi=!!ae.morphAttributes.normal,Wi=!!ae.morphAttributes.color,Es=K.toneMapped?g.toneMapping:Gs,jn=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,qt=jn!==void 0?jn.length:0,ht=re.get(K),Gu=d.state.lights;if(z===!0&&(j===!0||R!==w)){let Xi=R===w&&K.id===x;O.setState(K,R,Xi)}let Vu=!1;K.version===ht.__version?(ht.needsLights&&ht.lightsStateVersion!==Gu.state.version||ht.outputEncoding!==et||he.isInstancedMesh&&ht.instancing===!1||!he.isInstancedMesh&&ht.instancing===!0||he.isSkinnedMesh&&ht.skinning===!1||!he.isSkinnedMesh&&ht.skinning===!0||ht.envMap!==st||K.fog===!0&&ht.fog!==Be||ht.numClippingPlanes!==void 0&&(ht.numClippingPlanes!==O.numPlanes||ht.numIntersection!==O.numIntersection)||ht.vertexAlphas!==wt||ht.vertexTangents!==ut||ht.morphTargets!==lt||ht.morphNormals!==vi||ht.morphColors!==Wi||ht.toneMapping!==Es||ee.isWebGL2===!0&&ht.morphTargetsCount!==qt)&&(Vu=!0):(Vu=!0,ht.__version=K.version);let Gn=ht.currentProgram;Vu===!0&&(Gn=lr(K,$,he));let Jv=!1,cl=!1,Hu=!1,Ei=Gn.getUniforms(),Vn=ht.uniforms;if(J.useProgram(Gn.program)&&(Jv=!0,cl=!0,Hu=!0),K.id!==x&&(x=K.id,cl=!0),Jv||w!==R){if(Ei.setValue(F,"projectionMatrix",R.projectionMatrix),ee.logarithmicDepthBuffer&&Ei.setValue(F,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2)),w!==R&&(w=R,cl=!0,Hu=!0),K.isShaderMaterial||K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshStandardMaterial||K.envMap){let Xi=Ei.map.cameraPosition;Xi!==void 0&&Xi.setValue(F,H.setFromMatrixPosition(R.matrixWorld))}(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&Ei.setValue(F,"isOrthographic",R.isOrthographicCamera===!0),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial||K.isShadowMaterial||he.isSkinnedMesh)&&Ei.setValue(F,"viewMatrix",R.matrixWorldInverse)}if(he.isSkinnedMesh){Ei.setOptional(F,he,"bindMatrix"),Ei.setOptional(F,he,"bindMatrixInverse");let Xi=he.skeleton;Xi&&(ee.floatVertexTextures?(Xi.boneTexture===null&&Xi.computeBoneTexture(),Ei.setValue(F,"boneTexture",Xi.boneTexture,oe),Ei.setValue(F,"boneTextureSize",Xi.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let Wu=ae.morphAttributes;if((Wu.position!==void 0||Wu.normal!==void 0||Wu.color!==void 0&&ee.isWebGL2===!0)&&me.update(he,ae,K,Gn),(cl||ht.receiveShadow!==he.receiveShadow)&&(ht.receiveShadow=he.receiveShadow,Ei.setValue(F,"receiveShadow",he.receiveShadow)),K.isMeshGouraudMaterial&&K.envMap!==null&&(Vn.envMap.value=st,Vn.flipEnvMap.value=st.isCubeTexture&&st.isRenderTargetTexture===!1?-1:1),cl&&(Ei.setValue(F,"toneMappingExposure",g.toneMappingExposure),ht.needsLights&&N2(Vn,Hu),Be&&K.fog===!0&&He.refreshFogUniforms(Vn,Be),He.refreshMaterialUniforms(Vn,K,T,C,U),ed.upload(F,ht.uniformsList,Vn,oe)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(ed.upload(F,ht.uniformsList,Vn,oe),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&Ei.setValue(F,"center",he.center),Ei.setValue(F,"modelViewMatrix",he.modelViewMatrix),Ei.setValue(F,"normalMatrix",he.normalMatrix),Ei.setValue(F,"modelMatrix",he.matrixWorld),K.isShaderMaterial||K.isRawShaderMaterial){let Xi=K.uniformsGroups;for(let Xu=0,F2=Xi.length;Xu<F2;Xu++)if(ee.isWebGL2){let $v=Xi[Xu];Fe.update($v,Gn),Fe.bind($v,Gn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Gn}function N2(R,$){R.ambientLightColor.needsUpdate=$,R.lightProbe.needsUpdate=$,R.directionalLights.needsUpdate=$,R.directionalLightShadows.needsUpdate=$,R.pointLights.needsUpdate=$,R.pointLightShadows.needsUpdate=$,R.spotLights.needsUpdate=$,R.spotLightShadows.needsUpdate=$,R.rectAreaLights.needsUpdate=$,R.hemisphereLights.needsUpdate=$}function U2(R){return R.isMeshLambertMaterial||R.isMeshToonMaterial||R.isMeshPhongMaterial||R.isMeshStandardMaterial||R.isShadowMaterial||R.isShaderMaterial&&R.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(R,$,ae){re.get(R.texture).__webglTexture=$,re.get(R.depthTexture).__webglTexture=ae;let K=re.get(R);K.__hasExternalTextures=!0,K.__hasExternalTextures&&(K.__autoAllocateDepthBuffer=ae===void 0,K.__autoAllocateDepthBuffer||V.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),K.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(R,$){let ae=re.get(R);ae.__webglFramebuffer=$,ae.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(R,$=0,ae=0){b=R,v=$,y=ae;let K=!0,he=null,Be=!1,Je=!1;if(R){let et=re.get(R);et.__useDefaultFramebuffer!==void 0?(J.bindFramebuffer(36160,null),K=!1):et.__webglFramebuffer===void 0?oe.setupRenderTarget(R):et.__hasExternalTextures&&oe.rebindTextures(R,re.get(R.texture).__webglTexture,re.get(R.depthTexture).__webglTexture);let st=R.texture;(st.isData3DTexture||st.isDataArrayTexture||st.isCompressedArrayTexture)&&(Je=!0);let wt=re.get(R).__webglFramebuffer;R.isWebGLCubeRenderTarget?(he=wt[$],Be=!0):ee.isWebGL2&&R.samples>0&&oe.useMultisampledRTT(R)===!1?he=re.get(R).__webglMultisampledFramebuffer:he=wt,A.copy(R.viewport),S.copy(R.scissor),_=R.scissorTest}else A.copy(D).multiplyScalar(T).floor(),S.copy(k).multiplyScalar(T).floor(),_=W;if(J.bindFramebuffer(36160,he)&&ee.drawBuffers&&K&&J.drawBuffers(R,he),J.viewport(A),J.scissor(S),J.setScissorTest(_),Be){let et=re.get(R.texture);F.framebufferTexture2D(36160,36064,34069+$,et.__webglTexture,ae)}else if(Je){let et=re.get(R.texture),st=$||0;F.framebufferTextureLayer(36160,36064,et.__webglTexture,ae||0,st)}x=-1},this.readRenderTargetPixels=function(R,$,ae,K,he,Be,Je){if(!(R&&R.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let et=re.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Je!==void 0&&(et=et[Je]),et){J.bindFramebuffer(36160,et);try{let st=R.texture,wt=st.format,ut=st.type;if(wt!==Ur&&Me.convert(wt)!==F.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let lt=ut===hh&&(V.has("EXT_color_buffer_half_float")||ee.isWebGL2&&V.has("EXT_color_buffer_float"));if(ut!==Mi&&Me.convert(ut)!==F.getParameter(35738)&&!(ut===vn&&(ee.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float")))&&!lt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=R.width-K&&ae>=0&&ae<=R.height-he&&F.readPixels($,ae,K,he,Me.convert(wt),Me.convert(ut),Be)}finally{let st=b!==null?re.get(b).__webglFramebuffer:null;J.bindFramebuffer(36160,st)}}},this.copyFramebufferToTexture=function(R,$,ae=0){let K=Math.pow(2,-ae),he=Math.floor($.image.width*K),Be=Math.floor($.image.height*K);oe.setTexture2D($,0),F.copyTexSubImage2D(3553,ae,0,0,R.x,R.y,he,Be),J.unbindTexture()},this.copyTextureToTexture=function(R,$,ae,K=0){let he=$.image.width,Be=$.image.height,Je=Me.convert(ae.format),et=Me.convert(ae.type);oe.setTexture2D(ae,0),F.pixelStorei(37440,ae.flipY),F.pixelStorei(37441,ae.premultiplyAlpha),F.pixelStorei(3317,ae.unpackAlignment),$.isDataTexture?F.texSubImage2D(3553,K,R.x,R.y,he,Be,Je,et,$.image.data):$.isCompressedTexture?F.compressedTexSubImage2D(3553,K,R.x,R.y,$.mipmaps[0].width,$.mipmaps[0].height,Je,$.mipmaps[0].data):F.texSubImage2D(3553,K,R.x,R.y,Je,et,$.image),K===0&&ae.generateMipmaps&&F.generateMipmap(3553),J.unbindTexture()},this.copyTextureToTexture3D=function(R,$,ae,K,he=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Be=R.max.x-R.min.x+1,Je=R.max.y-R.min.y+1,et=R.max.z-R.min.z+1,st=Me.convert(K.format),wt=Me.convert(K.type),ut;if(K.isData3DTexture)oe.setTexture3D(K,0),ut=32879;else if(K.isDataArrayTexture)oe.setTexture2DArray(K,0),ut=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}F.pixelStorei(37440,K.flipY),F.pixelStorei(37441,K.premultiplyAlpha),F.pixelStorei(3317,K.unpackAlignment);let lt=F.getParameter(3314),vi=F.getParameter(32878),Wi=F.getParameter(3316),Es=F.getParameter(3315),jn=F.getParameter(32877),qt=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;F.pixelStorei(3314,qt.width),F.pixelStorei(32878,qt.height),F.pixelStorei(3316,R.min.x),F.pixelStorei(3315,R.min.y),F.pixelStorei(32877,R.min.z),ae.isDataTexture||ae.isData3DTexture?F.texSubImage3D(ut,he,$.x,$.y,$.z,Be,Je,et,st,wt,qt.data):ae.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),F.compressedTexSubImage3D(ut,he,$.x,$.y,$.z,Be,Je,et,st,qt.data)):F.texSubImage3D(ut,he,$.x,$.y,$.z,Be,Je,et,st,wt,qt),F.pixelStorei(3314,lt),F.pixelStorei(32878,vi),F.pixelStorei(3316,Wi),F.pixelStorei(3315,Es),F.pixelStorei(32877,jn),he===0&&K.generateMipmaps&&F.generateMipmap(ut),J.unbindTexture()},this.initTexture=function(R){R.isCubeTexture?oe.setTextureCube(R,0):R.isData3DTexture?oe.setTexture3D(R,0):R.isDataArrayTexture||R.isCompressedArrayTexture?oe.setTexture2DArray(R,0):oe.setTexture2D(R,0),J.unbindTexture()},this.resetState=function(){v=0,y=0,b=null,J.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var aD=class extends Tw{};aD.prototype.isWebGL1Renderer=!0;var Pw=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ge(e),this.near=t,this.far=i}clone(){return new Pw(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},pa=class extends bt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,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,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}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},oD=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=jf,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ps()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ps()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ps()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ti=new E,Wf=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ti.fromBufferAttribute(this,t),Ti.applyMatrix4(e),this.setXYZ(t,Ti.x,Ti.y,Ti.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ti.fromBufferAttribute(this,t),Ti.applyNormalMatrix(e),this.setXYZ(t,Ti.x,Ti.y,Ti.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ti.fromBufferAttribute(this,t),Ti.transformDirection(e),this.setXYZ(t,Ti.x,Ti.y,Ti.z);return this}setX(e,t){return this.normalized&&(t=_t(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=_t(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=_t(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=_t(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=ks(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ks(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ks(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ks(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=_t(t,this.array),i=_t(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=_t(t,this.array),i=_t(i,this.array),r=_t(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=_t(t,this.array),i=_t(i,this.array),r=_t(r,this.array),s=_t(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Xe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Wf(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},lD=class extends Xe{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Rn=class extends Ph{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ge(16777215),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.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},my=new E,gy=new E,vy=new ve,Mp=new Xo,uc=new Mr,xd=class extends bt{constructor(e=new Ve,t=new Rn){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=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)my.fromBufferAttribute(t,r-1),gy.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=my.distanceTo(gy);e.setAttribute("lineDistance",new Ce(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,n=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),uc.copy(i.boundingSphere),uc.applyMatrix4(r),uc.radius+=s,e.ray.intersectsSphere(uc)===!1)return;vy.copy(r).invert(),Mp.copy(e.ray).applyMatrix4(vy);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new E,h=new E,u=new E,c=new E,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let g=Math.max(0,n.start),m=Math.min(p.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=d){let b=p.getX(v),x=p.getX(v+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,x),Mp.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let w=e.ray.origin.distanceTo(c);w<e.near||w>e.far||t.push({distance:w,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,n.start),m=Math.min(f.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=d){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),Mp.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(c);b<e.near||b>e.far||t.push({distance:b,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let n=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=r}}}}},yy=new E,xy=new E,Lh=class extends xd{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)yy.fromBufferAttribute(t,r),xy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+yy.distanceTo(xy);e.setAttribute("lineDistance",new Ce(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},hD=class extends ci{constructor(e,t,i,r,s,n,a,o,l){super(e,t,i,r,s,n,a,o,l),this.isVideoTexture=!0,this.minFilter=n!==void 0?n:mt,this.magFilter=s!==void 0?s:mt,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},_s=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,n;t?n=t:n=e*i[s-1];let a=0,o=s-1,l;for(;a<=o;)if(r=Math.floor(a+(o-a)/2),l=i[r]-n,l<0)a=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===n)return r/(s-1);let h=i[r],u=i[r+1]-h,c=(n-h)/u;return(r+c)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),n=this.getPoint(r),a=t||(s.isVector2?new G:new E);return a.copy(n).sub(s).normalize(),a}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new E,r=[],s=[],n=[],a=new E,o=new ve;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new E)}s[0]=new E,n[0]=new E;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),u=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),c<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),n[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),n[d]=n[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(ti(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(a,p))}n[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(ti(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),n[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:n}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},du=class extends _s{constructor(e=0,t=0,i=1,r=1,s=0,n=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(e,t){let i=t||new G,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,n=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(n?s=0:s=r),this.aClockwise===!0&&!n&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),c=o-this.aX,d=l-this.aY;o=c*h-d*u+this.aX,l=c*u+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},cD=class extends du{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function gg(){let e=0,t=0,i=0,r=0;function s(n,a,o,l){e=n,t=o,i=-3*n+3*a-2*o-l,r=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){s(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,u,c){let d=(a-n)/h-(o-n)/(h+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+c)+(l-o)/c;d*=u,p*=u,s(a,o,d,p)},calc:function(n){let a=n*n,o=a*n;return e+t*n+i*a+r*o}}}var pc=new E,Ep=new gg,Cp=new gg,Tp=new gg,dD=class extends _s{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new E){let i=t,r=this.points,s=r.length,n=(s-(this.closed?0:1))*e,a=Math.floor(n),o=n-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:o===0&&a===s-1&&(a=s-2,o=1);let l,h;this.closed||a>0?l=r[(a-1)%s]:(pc.subVectors(r[0],r[1]).add(r[0]),l=pc);let u=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(pc.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=pc),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(u),d),f=Math.pow(u.distanceToSquared(c),d),g=Math.pow(c.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),g<1e-4&&(g=f),Ep.initNonuniformCatmullRom(l.x,u.x,c.x,h.x,p,f,g),Cp.initNonuniformCatmullRom(l.y,u.y,c.y,h.y,p,f,g),Tp.initNonuniformCatmullRom(l.z,u.z,c.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(Ep.initCatmullRom(l.x,u.x,c.x,h.x,this.tension),Cp.initCatmullRom(l.y,u.y,c.y,h.y,this.tension),Tp.initCatmullRom(l.z,u.z,c.z,h.z,this.tension));return i.set(Ep.calc(o),Cp.calc(o),Tp.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new E().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function by(e,t,i,r,s){let n=(r-t)*.5,a=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+n+a)*l+(-3*i+3*r-2*n-a)*o+n*e+i}function uD(e,t){let i=1-e;return i*i*t}function pD(e,t){return 2*(1-e)*e*t}function fD(e,t){return e*e*t}function $l(e,t,i,r){return uD(e,t)+pD(e,i)+fD(e,r)}function mD(e,t){let i=1-e;return i*i*i*t}function gD(e,t){let i=1-e;return 3*i*i*e*t}function vD(e,t){return 3*(1-e)*e*e*t}function yD(e,t){return e*e*e*t}function eh(e,t,i,r,s){return mD(e,t)+gD(e,i)+vD(e,r)+yD(e,s)}var Fr=class extends _s{constructor(e=new G,t=new G,i=new G,r=new G){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new G){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(eh(e,r.x,s.x,n.x,a.x),eh(e,r.y,s.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},td=class extends _s{constructor(e=new E,t=new E,i=new E,r=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(eh(e,r.x,s.x,n.x,a.x),eh(e,r.y,s.y,n.y,a.y),eh(e,r.z,s.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Gr=class extends _s{constructor(e=new G,t=new G){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new G){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new G;return i.copy(this.v2).sub(this.v1).normalize(),i}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}},Dw=class extends _s{constructor(e=new E,t=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new E){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}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}},Pn=class extends _s{constructor(e=new G,t=new G,i=new G){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new G){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set($l(e,r.x,s.x,n.x),$l(e,r.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},xD=class extends _s{constructor(e=new E,t=new E,i=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set($l(e,r.x,s.x,n.x),$l(e,r.y,s.y,n.y),$l(e,r.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},vg=class extends _s{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new G){let i=t,r=this.points,s=(r.length-1)*e,n=Math.floor(s),a=s-n,o=r[n===0?n:n-1],l=r[n],h=r[n>r.length-2?r.length-1:n+1],u=r[n>r.length-3?r.length-1:n+2];return i.set(by(a,o.x,l.x,h.x,u.x),by(a,o.y,l.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new G().fromArray(r))}return this}},bD=Object.freeze({__proto__:null,ArcCurve:cD,CatmullRomCurve3:dD,CubicBezierCurve:Fr,CubicBezierCurve3:td,EllipseCurve:du,LineCurve:Gr,LineCurve3:Dw,QuadraticBezierCurve:Pn,QuadraticBezierCurve3:xD,SplineCurve:vg}),Lw=class extends _s{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);e.equals(t)||this.curves.push(new Gr(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let n=r[s]-i,a=this.curves[s],o=a.getLength(),l=o===0?0:1-n/o;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let n=s[r],a=n.isEllipseCurve?e*2:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?e*n.points.length:e,o=n.getPoints(a);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new bD[r.type]().fromJSON(r))}return this}},bd=class extends Lw{constructor(e){super(),this.type="Path",this.currentPoint=new G,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Gr(this.currentPoint.clone(),new G(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Pn(this.currentPoint.clone(),new G(e,t),new G(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new Fr(this.currentPoint.clone(),new G(e,t),new G(i,r),new G(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new vg(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,n){let a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,r,s,n),this}absarc(e,t,i,r,s,n){return this.absellipse(e,t,i,i,r,s,n),this}ellipse(e,t,i,r,s,n,a,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,n,a,o),this}absellipse(e,t,i,r,s,n,a,o){let l=new du(e,t,i,r,s,n,a,o);if(this.curves.length>0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),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}},Ow=class extends Ve{constructor(e=[new G(0,-.5),new G(.5,0),new G(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=ti(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,u=new E,c=new G,d=new E,p=new E,f=new E,g=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,d.x=m*1,d.y=-g,d.z=m*0,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,b=Math.sin(y),x=Math.cos(y);for(let w=0;w<=e.length-1;w++){u.x=e[w].x*b,u.y=e[w].y,u.z=e[w].x*x,n.push(u.x,u.y,u.z),c.x=v/t,c.y=w/(e.length-1),a.push(c.x,c.y);let A=o[3*w+0]*b,S=o[3*w+1],_=o[3*w+0]*x;l.push(A,S,_)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let b=y+v*e.length,x=b,w=b+e.length,A=b+e.length+1,S=b+1;s.push(x,w,S),s.push(A,S,w)}this.setIndex(s),this.setAttribute("position",new Ce(n,3)),this.setAttribute("uv",new Ce(a,2)),this.setAttribute("normal",new Ce(l,3))}static fromJSON(e){return new Ow(e.points,e.segments,e.phiStart,e.phiLength)}},yg=class extends Ve{constructor(e=1,t=1,i=1,r=32,s=1,n=!1,a=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],u=[],c=[],d=[],p=0,f=[],g=i/2,m=0;v(),n===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Ce(u,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(d,2));function v(){let b=new E,x=new E,w=0,A=(t-e)/i;for(let S=0;S<=s;S++){let _=[],M=S/s,C=M*(t-e)+e;for(let T=0;T<=r;T++){let P=T/r,L=P*o+a,D=Math.sin(L),k=Math.cos(L);x.x=C*D,x.y=-M*i+g,x.z=C*k,u.push(x.x,x.y,x.z),b.set(D,A,k).normalize(),c.push(b.x,b.y,b.z),d.push(P,1-M),_.push(p++)}f.push(_)}for(let S=0;S<r;S++)for(let _=0;_<s;_++){let M=f[_][S],C=f[_+1][S],T=f[_+1][S+1],P=f[_][S+1];h.push(M,C,P),h.push(C,T,P),w+=6}l.addGroup(m,w,0),m+=w}function y(b){let x=p,w=new G,A=new E,S=0,_=b===!0?e:t,M=b===!0?1:-1;for(let T=1;T<=r;T++)u.push(0,g*M,0),c.push(0,M,0),d.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let P=T/r*o+a,L=Math.cos(P),D=Math.sin(P);A.x=_*D,A.y=g*M,A.z=_*L,u.push(A.x,A.y,A.z),c.push(0,M,0),w.x=L*.5+.5,w.y=D*.5*M+.5,d.push(w.x,w.y),p++}for(let T=0;T<r;T++){let P=x+T,L=C+T;b===!0?h.push(L,L+1,P):h.push(L+1,L,P),S+=3}l.addGroup(m,S,b===!0?1:2),m+=S}}static fromJSON(e){return new yg(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Iw=class extends yg{constructor(e=1,t=1,i=32,r=1,s=!1,n=0,a=Math.PI*2){super(0,e,t,i,r,s,n,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:n,thetaLength:a}}static fromJSON(e){return new Iw(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},xg=class extends Ve{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],n=[];a(r),l(i),h(),this.setAttribute("position",new Ce(s,3)),this.setAttribute("normal",new Ce(s.slice(),3)),this.setAttribute("uv",new Ce(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new E,b=new E,x=new E;for(let w=0;w<t.length;w+=3)d(t[w+0],y),d(t[w+1],b),d(t[w+2],x),o(y,b,x,v)}function o(v,y,b,x){let w=x+1,A=[];for(let S=0;S<=w;S++){A[S]=[];let _=v.clone().lerp(b,S/w),M=y.clone().lerp(b,S/w),C=w-S;for(let T=0;T<=C;T++)T===0&&S===w?A[S][T]=_:A[S][T]=_.clone().lerp(M,T/C)}for(let S=0;S<w;S++)for(let _=0;_<2*(w-S)-1;_++){let M=Math.floor(_/2);_%2===0?(c(A[S][M+1]),c(A[S+1][M]),c(A[S][M])):(c(A[S][M+1]),c(A[S+1][M+1]),c(A[S+1][M]))}}function l(v){let y=new E;for(let b=0;b<s.length;b+=3)y.x=s[b+0],y.y=s[b+1],y.z=s[b+2],y.normalize().multiplyScalar(v),s[b+0]=y.x,s[b+1]=y.y,s[b+2]=y.z}function h(){let v=new E;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let b=g(v)/2/Math.PI+.5,x=m(v)/Math.PI+.5;n.push(b,1-x)}p(),u()}function u(){for(let v=0;v<n.length;v+=6){let y=n[v+0],b=n[v+2],x=n[v+4],w=Math.max(y,b,x),A=Math.min(y,b,x);w>.9&&A<.1&&(y<.2&&(n[v+0]+=1),b<.2&&(n[v+2]+=1),x<.2&&(n[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function d(v,y){let b=v*3;y.x=e[b+0],y.y=e[b+1],y.z=e[b+2]}function p(){let v=new E,y=new E,b=new E,x=new E,w=new G,A=new G,S=new G;for(let _=0,M=0;_<s.length;_+=9,M+=6){v.set(s[_+0],s[_+1],s[_+2]),y.set(s[_+3],s[_+4],s[_+5]),b.set(s[_+6],s[_+7],s[_+8]),w.set(n[M+0],n[M+1]),A.set(n[M+2],n[M+3]),S.set(n[M+4],n[M+5]),x.copy(v).add(y).add(b).divideScalar(3);let C=g(x);f(w,M+0,v,C),f(A,M+2,y,C),f(S,M+4,b,C)}}function f(v,y,b,x){x<0&&v.x===1&&(n[y]=v.x-1),b.x===0&&b.z===0&&(n[y]=x/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new xg(e.vertices,e.indices,e.radius,e.details)}},Rw=class extends xg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,n,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Rw(e.radius,e.detail)}},wd=class extends bd{constructor(e){super(e),this.uuid=ps(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new bd().fromJSON(r))}return this}},wD={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=Bw(e,0,s,i,!0),a=[];if(!n||n.next===n.prev)return a;let o,l,h,u,c,d,p;if(r&&(n=ED(e,t,n,i)),e.length>80*i){o=h=e[0],l=u=e[1];for(let f=i;f<s;f+=i)c=e[f],d=e[f+1],c<o&&(o=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);p=Math.max(h-o,u-l),p=p!==0?32767/p:0}return dh(n,a,i,o,l,p,0),a}};function Bw(e,t,i,r,s){let n,a;if(s===ND(e,t,i,r)>0)for(n=t;n<i;n+=r)a=wy(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=wy(n,e[n],e[n+1],a);return a&&uu(a,a.next)&&(ph(a),a=a.next),a}function wa(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(uu(i,i.next)||It(i.prev,i,i.next)===0)){if(ph(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function dh(e,t,i,r,s,n,a){if(!e)return;!a&&n&&LD(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?AD(e,r,s,n):_D(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),ph(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=SD(wa(e),t,i),dh(e,t,i,r,s,n,2)):a===2&&MD(e,t,i,r,s,n):dh(wa(e),t,i,r,s,n,1);break}}}function _D(e){let t=e.prev,i=e,r=e.next;if(It(t,i,r)>=0)return!1;let s=t.x,n=i.x,a=r.x,o=t.y,l=i.y,h=r.y,u=s<n?s<a?s:a:n<a?n:a,c=o<l?o<h?o:h:l<h?l:h,d=s>n?s>a?s:a:n>a?n:a,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&fo(s,o,n,l,a,h,f.x,f.y)&&It(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function AD(e,t,i,r){let s=e.prev,n=e,a=e.next;if(It(s,n,a)>=0)return!1;let o=s.x,l=n.x,h=a.x,u=s.y,c=n.y,d=a.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,g=o>l?o>h?o:h:l>h?l:h,m=u>c?u>d?u:d:c>d?c:d,v=Xf(p,f,t,i,r),y=Xf(g,m,t,i,r),b=e.prevZ,x=e.nextZ;for(;b&&b.z>=v&&x&&x.z<=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&fo(o,u,l,c,h,d,b.x,b.y)&&It(b.prev,b,b.next)>=0||(b=b.prevZ,x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&fo(o,u,l,c,h,d,x.x,x.y)&&It(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;b&&b.z>=v;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&fo(o,u,l,c,h,d,b.x,b.y)&&It(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&fo(o,u,l,c,h,d,x.x,x.y)&&It(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function SD(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!uu(s,n)&&zw(s,r,r.next,n)&&uh(s,n)&&uh(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),ph(r),ph(r.next),r=e=n),r=r.next}while(r!==e);return wa(r)}function MD(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&RD(a,o)){let l=Nw(a,o);a=wa(a,a.next),l=wa(l,l.next),dh(a,t,i,r,s,n,0),dh(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function ED(e,t,i,r){let s=[],n,a,o,l,h;for(n=0,a=t.length;n<a;n++)o=t[n]*r,l=n<a-1?t[n+1]*r:e.length,h=Bw(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(ID(h));for(s.sort(CD),n=0;n<s.length;n++)i=TD(s[n],i);return i}function CD(e,t){return e.x-t.x}function TD(e,t){let i=PD(e,t);if(!i)return t;let r=Nw(i,e);return wa(r,r.next),wa(i,i.next)}function PD(e,t){let i=t,r=-1/0,s,n=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let d=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=n&&d>r&&(r=d,s=i.x<i.next.x?i:i.next,d===n))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,u=1/0,c;i=s;do n>=i.x&&i.x>=l&&n!==i.x&&fo(a<h?n:r,a,l,h,a<h?r:n,a,i.x,i.y)&&(c=Math.abs(a-i.y)/(n-i.x),uh(i,e)&&(c<u||c===u&&(i.x>s.x||i.x===s.x&&DD(s,i)))&&(s=i,u=c)),i=i.next;while(i!==o);return s}function DD(e,t){return It(e.prev,e,t.prev)<0&&It(t.next,e,e.next)<0}function LD(e,t,i,r){let s=e;do s.z===0&&(s.z=Xf(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,OD(s)}function OD(e){let t,i,r,s,n,a,o,l,h=1;do{for(i=e,e=null,n=null,a=0;i;){for(a++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(a>1);return e}function Xf(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function ID(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function fo(e,t,i,r,s,n,a,o){return(s-a)*(t-o)>=(e-a)*(n-o)&&(e-a)*(r-o)>=(i-a)*(t-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function RD(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!BD(e,t)&&(uh(e,t)&&uh(t,e)&&zD(e,t)&&(It(e.prev,e,t.prev)||It(e,t.prev,t))||uu(e,t)&&It(e.prev,e,e.next)>0&&It(t.prev,t,t.next)>0)}function It(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function uu(e,t){return e.x===t.x&&e.y===t.y}function zw(e,t,i,r){let s=mc(It(e,t,i)),n=mc(It(e,t,r)),a=mc(It(i,r,e)),o=mc(It(i,r,t));return!!(s!==n&&a!==o||s===0&&fc(e,i,t)||n===0&&fc(e,r,t)||a===0&&fc(i,e,r)||o===0&&fc(i,t,r))}function fc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function mc(e){return e>0?1:e<0?-1:0}function BD(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&zw(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function uh(e,t){return It(e.prev,e,e.next)<0?It(e,t,e.next)>=0&&It(e,e.prev,t)>=0:It(e,t,e.prev)<0||It(e,e.next,t)<0}function zD(e,t){let i=e,r=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function Nw(e,t){let i=new qf(e.i,e.x,e.y),r=new qf(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function wy(e,t,i,r){let s=new qf(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function ph(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function qf(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ND(e,t,i,r){let s=0;for(let n=t,a=i-r;n<i;n+=r)s+=(e[a]-e[n])*(e[n+1]+e[a+1]),a=n;return s}var Uw=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return Uw.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];_y(e),Ay(i,e);let n=e.length;t.forEach(_y);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,Ay(i,t[o]);let a=wD.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function _y(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Ay(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var Fw=class extends xg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Fw(e.radius,e.detail)}},bg=class extends Ve{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,n=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:n,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(n+a,Math.PI),l=0,h=[],u=new E,c=new E,d=[],p=[],f=[],g=[];for(let m=0;m<=i;m++){let v=[],y=m/i,b=0;m==0&&n==0?b=.5/t:m==i&&o==Math.PI&&(b=-.5/t);for(let x=0;x<=t;x++){let w=x/t;u.x=-e*Math.cos(r+w*s)*Math.sin(n+y*a),u.y=e*Math.cos(n+y*a),u.z=e*Math.sin(r+w*s)*Math.sin(n+y*a),p.push(u.x,u.y,u.z),c.copy(u).normalize(),f.push(c.x,c.y,c.z),g.push(w+b,1-y),v.push(l++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let y=h[m][v+1],b=h[m][v],x=h[m+1][v],w=h[m+1][v+1];(m!==0||n>0)&&d.push(y,b,w),(m!==i-1||o<Math.PI)&&d.push(b,x,w)}this.setIndex(d),this.setAttribute("position",new Ce(p,3)),this.setAttribute("normal",new Ce(f,3)),this.setAttribute("uv",new Ce(g,2))}static fromJSON(e){return new bg(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},kw=class extends Ve{constructor(e=1,t=.4,i=64,r=8,s=2,n=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:n},i=Math.floor(i),r=Math.floor(r);let a=[],o=[],l=[],h=[],u=new E,c=new E,d=new E,p=new E,f=new E,g=new E,m=new E;for(let y=0;y<=i;++y){let b=y/i*s*Math.PI*2;v(b,s,n,e,d),v(b+.01,s,n,e,p),g.subVectors(p,d),m.addVectors(p,d),f.crossVectors(g,m),m.crossVectors(f,g),f.normalize(),m.normalize();for(let x=0;x<=r;++x){let w=x/r*Math.PI*2,A=-t*Math.cos(w),S=t*Math.sin(w);u.x=d.x+(A*m.x+S*f.x),u.y=d.y+(A*m.y+S*f.y),u.z=d.z+(A*m.z+S*f.z),o.push(u.x,u.y,u.z),c.subVectors(u,d).normalize(),l.push(c.x,c.y,c.z),h.push(y/i),h.push(x/r)}}for(let y=1;y<=i;y++)for(let b=1;b<=r;b++){let x=(r+1)*(y-1)+(b-1),w=(r+1)*y+(b-1),A=(r+1)*y+b,S=(r+1)*(y-1)+b;a.push(x,w,S),a.push(w,A,S)}this.setIndex(a),this.setAttribute("position",new Ce(o,3)),this.setAttribute("normal",new Ce(l,3)),this.setAttribute("uv",new Ce(h,2));function v(y,b,x,w,A){let S=Math.cos(y),_=Math.sin(y),M=x/b*y,C=Math.cos(M);A.x=w*(2+C)*.5*S,A.y=w*(2+C)*_*.5,A.z=w*Math.sin(M)*.5}}static fromJSON(e){return new kw(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function tn(e,t,i){return jw(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function gc(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function jw(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var pu=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];i:{e:{let n;t:{r:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break e}n=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break e}n=i,i=0;break t}break i}for(;i<n;){let a=i+n>>>1;e<t[a]?n=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let n=0;n!==r;++n)t[n]=i[s+n];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},UD=class extends pu{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:O0,endingEnd:O0}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,n=e+1,a=r[s],o=r[n];if(a===void 0)switch(this.getSettings_().endingStart){case I0:s=e,a=2*t-i;break;case R0:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case I0:n=e,o=2*i-t;break;case R0:n=1,o=i+r[1]-r[0];break;default:n=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=n*h}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,u=this._offsetNext,c=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,g=f*p,m=-c*g+2*c*f-c*p,v=(1+c)*g+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-d)*g+(1.5+d)*f+.5*p,b=d*g-d*f;for(let x=0;x!==a;++x)s[x]=m*n[h+x]+v*n[l+x]+y*n[o+x]+b*n[u+x];return s}},FD=class extends pu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(i-t)/(r-t),u=1-h;for(let c=0;c!==a;++c)s[c]=n[l+c]*u+n[o+c]*h;return s}},kD=class extends pu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Ys=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=gc(t,this.TimeBufferType),this.values=gc(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:gc(e.times,Array),values:gc(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new kD(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new FD(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new UD(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case pd:t=this.InterpolantFactoryMethodDiscrete;break;case fd:t=this.InterpolantFactoryMethodLinear;break;case $u:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return pd;case this.InterpolantFactoryMethodLinear:return fd;case this.InterpolantFactoryMethodSmooth:return $u}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,n=r-1;for(;s!==r&&i[s]<e;)++s;for(;n!==-1&&i[n]>t;)--n;if(++n,s!==0||n!==r){s>=n&&(n=Math.max(n,1),s=n-1);let a=this.getValueSize();this.times=tn(i,s,n),this.values=tn(this.values,s*a,n*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let a=0;a!==s;a++){let o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(n!==null&&n>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,n),e=!1;break}n=o}if(r!==void 0&&jw(r))for(let a=0,o=r.length;a!==o;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=tn(this.times),t=tn(this.values),i=this.getValueSize(),r=this.getInterpolation()===$u,s=e.length-1,n=1;for(let a=1;a<s;++a){let o=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(r)o=!0;else{let u=a*i,c=u-i,d=u+i;for(let p=0;p!==i;++p){let f=t[u+p];if(f!==t[c+p]||f!==t[d+p]){o=!0;break}}}if(o){if(a!==n){e[n]=e[a];let u=a*i,c=n*i;for(let d=0;d!==i;++d)t[c+d]=t[u+d]}++n}}if(s>0){e[n]=e[s];for(let a=s*i,o=n*i,l=0;l!==i;++l)t[o+l]=t[a+l];++n}return n!==e.length?(this.times=tn(e,0,n),this.values=tn(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=tn(this.times,0),t=tn(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Ys.prototype.TimeBufferType=Float32Array;Ys.prototype.ValueBufferType=Float32Array;Ys.prototype.DefaultInterpolation=fd;var Oh=class extends Ys{};Oh.prototype.ValueTypeName="bool";Oh.prototype.ValueBufferType=Array;Oh.prototype.DefaultInterpolation=pd;Oh.prototype.InterpolantFactoryMethodLinear=void 0;Oh.prototype.InterpolantFactoryMethodSmooth=void 0;var jD=class extends Ys{};jD.prototype.ValueTypeName="color";var GD=class extends Ys{};GD.prototype.ValueTypeName="number";var VD=class extends pu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-t)/(r-t),l=e*a;for(let h=l+a;l!==h;l+=4)ct.slerpFlat(s,0,n,l-a,n,l,o);return s}},wg=class extends Ys{InterpolantFactoryMethodLinear(e){return new VD(this.times,this.values,this.getValueSize(),e)}};wg.prototype.ValueTypeName="quaternion";wg.prototype.DefaultInterpolation=fd;wg.prototype.InterpolantFactoryMethodSmooth=void 0;var Ih=class extends Ys{};Ih.prototype.ValueTypeName="string";Ih.prototype.ValueBufferType=Array;Ih.prototype.DefaultInterpolation=pd;Ih.prototype.InterpolantFactoryMethodLinear=void 0;Ih.prototype.InterpolantFactoryMethodSmooth=void 0;var HD=class extends Ys{};HD.prototype.ValueTypeName="vector";var Sy={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},Gw=class{constructor(e,t,i){let r=this,s=!1,n=0,a=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,n,a),s=!0},this.itemEnd=function(h){n++,r.onProgress!==void 0&&r.onProgress(h,n,a),n===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,c=l.length;u<c;u+=2){let d=l[u],p=l[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},WD=new Gw,_g=class{constructor(e){this.manager=e!==void 0?e:WD,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Os={},XD=class extends Error{constructor(e,t){super(e),this.response=t}},Yf=class extends _g{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=Sy.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Os[e]!==void 0){Os[e].push({onLoad:t,onProgress:i,onError:r});return}Os[e]=[],Os[e].push({onLoad:t,onProgress:i,onError:r});let n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(n).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Os[e],u=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=c?parseInt(c):0,p=d!==0,f=0,g=new ReadableStream({start(m){v();function v(){u.read().then(({done:y,value:b})=>{if(y)m.close();else{f+=b.byteLength;let x=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let w=0,A=h.length;w<A;w++){let S=h[w];S.onProgress&&S.onProgress(x)}m.enqueue(b),v()}})}}});return new Response(g)}else throw new XD(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),u=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(u);return l.arrayBuffer().then(d=>c.decode(d))}}}).then(l=>{Sy.add(e,l);let h=Os[e];delete Os[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=Os[e];if(h===void 0)throw this.manager.itemError(e),l;delete Os[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Rh=class extends bt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ge(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}},qD=class extends Rh{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ge(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Pp=new ve,My=new E,Ey=new E,Ag=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new G(512,512),this.map=null,this.mapPass=null,this.matrix=new ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new pg,this._frameExtents=new G(1,1),this._viewportCount=1,this._viewports=[new $e(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;My.setFromMatrixPosition(e.matrixWorld),t.position.copy(My),Ey.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ey),t.updateMatrixWorld(),Pp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Pp),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Pp)}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}},YD=class extends Ag{constructor(){super(new wi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=ch*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},QD=class extends Rh{constructor(e,t,i=0,r=Math.PI/3,s=0,n=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.target=new bt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new YD}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}},Cy=new ve,xl=new E,Dp=new E,ZD=class extends Ag{constructor(){super(new wi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new G(4,2),this._viewportCount=6,this._viewports=[new $e(2,1,1,1),new $e(0,1,1,1),new $e(3,1,1,1),new $e(1,1,1,1),new $e(3,0,1,1),new $e(1,0,1,1)],this._cubeDirections=[new E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),xl.setFromMatrixPosition(e.matrixWorld),i.position.copy(xl),Dp.copy(i.position),Dp.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Dp),i.updateMatrixWorld(),r.makeTranslation(-xl.x,-xl.y,-xl.z),Cy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cy)}},KD=class extends Rh{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new ZD}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}},JD=class extends Ag{constructor(){super(new yd(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},$D=class extends Rh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.target=new bt,this.shadow=new JD}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},eL=class extends Ve{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Vw=class extends _g{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new Yf(s.manager);n.setPath(s.path),n.setRequestHeader(s.requestHeader),n.setWithCredentials(s.withCredentials),n.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(c,d){if(t[d]!==void 0)return t[d];let p=c.interleavedBuffers[d],f=s(c,p.buffer),g=qh(p.type,f),m=new oD(g,p.stride);return m.uuid=p.uuid,t[d]=m,m}function s(c,d){if(i[d]!==void 0)return i[d];let p=c.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let n=e.isInstancedBufferGeometry?new eL:new Ve,a=e.data.index;if(a!==void 0){let c=qh(a.type,a.array);n.setIndex(new Xe(c,1))}let o=e.data.attributes;for(let c in o){let d=o[c],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new Wf(f,d.itemSize,d.offset,d.normalized)}else{let f=qh(d.type,d.array),g=d.isInstancedBufferAttribute?lD:Xe;p=new g(f,d.itemSize,d.normalized)}d.name!==void 0&&(p.name=d.name),d.usage!==void 0&&p.setUsage(d.usage),d.updateRange!==void 0&&(p.updateRange.offset=d.updateRange.offset,p.updateRange.count=d.updateRange.count),n.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let d=l[c],p=[];for(let f=0,g=d.length;f<g;f++){let m=d[f],v;if(m.isInterleavedBufferAttribute){let y=r(e.data,m.data);v=new Wf(y,m.itemSize,m.offset,m.normalized)}else{let y=qh(m.type,m.array);v=new Xe(y,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),p.push(v)}n.morphAttributes[c]=p}e.data.morphTargetsRelative&&(n.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,d=h.length;c!==d;++c){let p=h[c];n.addGroup(p.start,p.count,p.materialIndex)}let u=e.data.boundingSphere;if(u!==void 0){let c=new E;u.center!==void 0&&c.fromArray(u.center),n.boundingSphere=new Mr(c,u.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},tL=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Ty(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=Ty();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Ty(){return(typeof performance>"u"?Date:performance).now()}var Sg="\\[\\]\\.:\\/",iL=new RegExp("["+Sg+"]","g"),Mg="[^"+Sg+"]",rL="[^"+Sg.replace("\\.","")+"]",sL=/((?:WC+[\/:])*)/.source.replace("WC",Mg),nL=/(WCOD+)?/.source.replace("WCOD",rL),aL=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Mg),oL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Mg),lL=new RegExp("^"+sL+nL+aL+oL+"$"),hL=["material","materials","bones","map"],cL=class{constructor(e,t,i){let r=i||At.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},At=class{constructor(e,t,i){this.path=t,this.parsedPath=i||At.parseTrackName(t),this.node=At.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new At.Composite(e,t,i):new At(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(iL,"")}static parseTrackName(e){let t=lL.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);hL.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let n=0;n<s.length;n++){let a=s[n];if(a.name===t||a.uuid===t)return a;let o=i(a.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=At.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let n=e[r];if(n===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=n,this.propertyIndex=s}else n.fromArray!==void 0&&n.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=n):Array.isArray(n)?(o=this.BindingType.EntireArray,this.resolvedProperty=n):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};At.Composite=cL;At.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};At.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};At.prototype.GetterByBindingType=[At.prototype._getValue_direct,At.prototype._getValue_array,At.prototype._getValue_arrayElement,At.prototype._getValue_toArray];At.prototype.SetterByBindingTypeAndVersioning=[[At.prototype._setValue_direct,At.prototype._setValue_direct_setNeedsUpdate,At.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[At.prototype._setValue_array,At.prototype._setValue_array_setNeedsUpdate,At.prototype._setValue_array_setMatrixWorldNeedsUpdate],[At.prototype._setValue_arrayElement,At.prototype._setValue_arrayElement_setNeedsUpdate,At.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[At.prototype._setValue_fromArray,At.prototype._setValue_fromArray_setNeedsUpdate,At.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var _9=new Float32Array(1),Oe=class{constructor(e){this.value=e}clone(){return new Oe(this.value.clone===void 0?this.value:this.value.clone())}},Hw=class{constructor(e,t,i=0,r=1/0){this.ray=new Xo(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new dg,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)}intersectObject(e,t=!0,i=[]){return Qf(e,this,i,t),i.sort(Py),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Qf(e[r],this,i,t);return i.sort(Py),i}};function Py(e,t){return e.distance-t.distance}function Qf(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let n=0,a=s.length;n<a;n++)Qf(s[n],t,i,!0)}}var Dy=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(ti(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Ly=new G,dL=class{constructor(e=new G(1/0,1/0),t=new G(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Ly.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Ly.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),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)}},Oy=new E,vc=new E,_r=class{constructor(e=new E,t=new E){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Oy.subVectors(e,this.start),vc.subVectors(this.end,this.start);let i=vc.dot(vc),r=vc.dot(Oy)/i;return t&&(r=ti(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Iy=new E,uL=class extends bt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ve,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let n=0,a=1,o=32;n<o;n++,a++){let l=n/o*Math.PI*2,h=a/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Ce(r,3));let s=new Rn({fog:!1,toneMapped:!1});this.cone=new Lh(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Iy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Iy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},pL=class extends tr{constructor(e,t,i){let r=new bg(t,4,2),s=new Dh({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Ry=new E,yc=new E,By=new E,fL=class extends bt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Ve;r.setAttribute("position",new Ce([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Rn({fog:!1,toneMapped:!1});this.lightPlane=new xd(r,s),this.add(this.lightPlane),r=new Ve,r.setAttribute("position",new Ce([0,0,0,0,0,1],3)),this.targetLine=new xd(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Ry.setFromMatrixPosition(this.light.matrixWorld),yc.setFromMatrixPosition(this.light.target.matrixWorld),By.subVectors(yc,Ry),this.lightPlane.lookAt(yc),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(yc),this.targetLine.scale.z=By.length()}},xc=new E,Rt=new Yo,_d=class extends Lh{constructor(e){let t=new Ve,i=new Rn({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),n[p]===void 0&&(n[p]=[]),n[p].push(r.length/3-1)}t.setAttribute("position",new Ce(r,3)),t.setAttribute("color",new Ce(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update();let l=new Ge(16755200),h=new Ge(16711680),u=new Ge(43775),c=new Ge(16777215),d=new Ge(3355443);this.setColors(l,h,u,c,d)}setColors(e,t,i,r,s){let n=this.geometry.getAttribute("color");n.setXYZ(0,e.r,e.g,e.b),n.setXYZ(1,e.r,e.g,e.b),n.setXYZ(2,e.r,e.g,e.b),n.setXYZ(3,e.r,e.g,e.b),n.setXYZ(4,e.r,e.g,e.b),n.setXYZ(5,e.r,e.g,e.b),n.setXYZ(6,e.r,e.g,e.b),n.setXYZ(7,e.r,e.g,e.b),n.setXYZ(8,e.r,e.g,e.b),n.setXYZ(9,e.r,e.g,e.b),n.setXYZ(10,e.r,e.g,e.b),n.setXYZ(11,e.r,e.g,e.b),n.setXYZ(12,e.r,e.g,e.b),n.setXYZ(13,e.r,e.g,e.b),n.setXYZ(14,e.r,e.g,e.b),n.setXYZ(15,e.r,e.g,e.b),n.setXYZ(16,e.r,e.g,e.b),n.setXYZ(17,e.r,e.g,e.b),n.setXYZ(18,e.r,e.g,e.b),n.setXYZ(19,e.r,e.g,e.b),n.setXYZ(20,e.r,e.g,e.b),n.setXYZ(21,e.r,e.g,e.b),n.setXYZ(22,e.r,e.g,e.b),n.setXYZ(23,e.r,e.g,e.b),n.setXYZ(24,t.r,t.g,t.b),n.setXYZ(25,t.r,t.g,t.b),n.setXYZ(26,t.r,t.g,t.b),n.setXYZ(27,t.r,t.g,t.b),n.setXYZ(28,t.r,t.g,t.b),n.setXYZ(29,t.r,t.g,t.b),n.setXYZ(30,t.r,t.g,t.b),n.setXYZ(31,t.r,t.g,t.b),n.setXYZ(32,i.r,i.g,i.b),n.setXYZ(33,i.r,i.g,i.b),n.setXYZ(34,i.r,i.g,i.b),n.setXYZ(35,i.r,i.g,i.b),n.setXYZ(36,i.r,i.g,i.b),n.setXYZ(37,i.r,i.g,i.b),n.setXYZ(38,r.r,r.g,r.b),n.setXYZ(39,r.r,r.g,r.b),n.setXYZ(40,s.r,s.g,s.b),n.setXYZ(41,s.r,s.g,s.b),n.setXYZ(42,s.r,s.g,s.b),n.setXYZ(43,s.r,s.g,s.b),n.setXYZ(44,s.r,s.g,s.b),n.setXYZ(45,s.r,s.g,s.b),n.setXYZ(46,s.r,s.g,s.b),n.setXYZ(47,s.r,s.g,s.b),n.setXYZ(48,s.r,s.g,s.b),n.setXYZ(49,s.r,s.g,s.b),n.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;Rt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),kt("c",t,e,Rt,0,0,-1),kt("t",t,e,Rt,0,0,1),kt("n1",t,e,Rt,-i,-r,-1),kt("n2",t,e,Rt,i,-r,-1),kt("n3",t,e,Rt,-i,r,-1),kt("n4",t,e,Rt,i,r,-1),kt("f1",t,e,Rt,-i,-r,1),kt("f2",t,e,Rt,i,-r,1),kt("f3",t,e,Rt,-i,r,1),kt("f4",t,e,Rt,i,r,1),kt("u1",t,e,Rt,i*.7,r*1.1,-1),kt("u2",t,e,Rt,-i*.7,r*1.1,-1),kt("u3",t,e,Rt,0,r*2,-1),kt("cf1",t,e,Rt,-i,0,1),kt("cf2",t,e,Rt,i,0,1),kt("cf3",t,e,Rt,0,-r,1),kt("cf4",t,e,Rt,0,r,1),kt("cn1",t,e,Rt,-i,0,-1),kt("cn2",t,e,Rt,i,0,-1),kt("cn3",t,e,Rt,0,-r,-1),kt("cn4",t,e,Rt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function kt(e,t,i,r,s,n,a){xc.set(s,n,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],xc.x,xc.y,xc.z)}}var Ad=class extends Lh{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ve;s.setIndex(new Xe(i,1)),s.setAttribute("position",new Ce(r,3)),super(s,new Rn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},mL=class extends Lh{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ve;r.setAttribute("position",new Ce(t,3)),r.setAttribute("color",new Ce(i,3));let s=new Rn({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ge,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Wo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Wo);var bl=".",Eg=Symbol("target"),Ww=Symbol("unsubscribe");function Zf(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function gL(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var as=Array.isArray;function Cg(e){return typeof e=="symbol"}var vL={after:(e,t)=>as(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>as(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=bl),Cg(t)?e+t.toString():e+t):e,initial:e=>{if(as(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(bl);return t===-1?"":e.slice(0,t)},last:e=>{if(as(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(bl);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(as(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(bl);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(bl,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},mr=vL;function yL(e){return typeof e=="object"&&typeof e.next=="function"}function xL(e,t,i,r,s){let n=e.next;if(t.name==="entries")e.next=function(){let a=n.call(this);return a.done===!1&&(a.value[0]=s(a.value[0],t,a.value[0],r),a.value[1]=s(a.value[1],t,a.value[0],r)),a};else if(t.name==="values"){let a=i[Eg].keys();e.next=function(){let o=n.call(this);return o.done===!1&&(o.value=s(o.value,t,a.next().value,r)),o}}else e.next=function(){let a=n.call(this);return a.done===!1&&(a.value=s(a.value,t,a.value,r)),a};return e}function zy(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&Cg(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var bL=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],n=s||e;this._pathCache.set(n,t);let a=this._proxyCache.get(n);return a===void 0&&(a=s===void 0?new Proxy(e,i):e,this._proxyCache.set(n,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,mr.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&"set"in n?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Kf(e){return toString.call(e)==="[object Object]"}function bc(){return!0}function Ya(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var Xw=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),wL=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),qw={push:bc,pop:bc,shift:bc,unshift:bc,copyWithin:Ya,reverse:Ya,sort:Ya,splice:Ya,flat:Ya,fill:Ya},_L=new Set([...Xw,...wL,...Object.keys(qw)]);function wc(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var Yw=["keys","values","entries"],Qw=new Set(["has","toString"]),Zw={add:wc,clear:wc,delete:wc,forEach:wc},AL=new Set([...Qw,...Object.keys(Zw),...Yw]);function _c(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var SL=new Set([...Qw,"get"]),Kw={set:_c,clear:_c,delete:_c,forEach:_c},ML=new Set([...SL,...Object.keys(Kw),...Yw]),Dn=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return Xw.has(e)}_shallowClone(e){let t=e;if(Kf(e))t={...e};else if(as(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(as(r)?this._onIsChanged=qw[t]:r instanceof Set?this._onIsChanged=Zw[t]:r instanceof Map&&(this._onIsChanged=Kw[t]),r):i}update(e,t,i){let r=mr.after(e,this._path);if(t!=="length"){let s=this.clone;mr.walk(r,n=>{s&&s[n]&&(this._clonedCache.has(s[n])||(s[n]=this._shallowClone(s[n])),s=s[n])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],mr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},Ny=class extends Dn{static isHandledMethod(e){return _L.has(e)}},EL=class extends Dn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Uy=class extends Dn{static isHandledMethod(e){return AL.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},Fy=class extends Dn{static isHandledMethod(e){return ML.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},CL=class extends Dn{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},TL=class extends Dn{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},ao=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Kf(e)||as(e)||Zf(e)}static isHandledMethod(e,t){return Kf(e)?Dn.isHandledMethod(t):as(e)?Ny.isHandledMethod(t):e instanceof Set?Uy.isHandledMethod(t):e instanceof Map?Fy.isHandledMethod(t):Zf(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Dn;as(e)?r=Ny:e instanceof Date?r=EL:e instanceof Set?r=Uy:e instanceof Map?r=Fy:e instanceof WeakSet?r=CL:e instanceof WeakMap&&(r=TL),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=ao.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},PL={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Tg=(e,t,i={})=>{i={...PL,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new bL(s),h=typeof i.onValidate=="function",u=new ao(h),c=(y,b,x,w,A)=>!h||u.isCloning||i.onValidate(mr.concat(l.getPath(y),b),x,w,A)===!0,d=(y,b,x,w)=>{!zy(l,i,b)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),b,x,w)},p=(y,b,x,w,A)=>{u.isCloning?u.update(y,b,w):t(mr.concat(y,b),x,w,A)},f=y=>y&&(y[r]||y),g=(y,b,x,w)=>gL(y)||x==="constructor"||n&&!ao.isHandledMethod(b,x)||zy(l,i,x)||l.isGetInvariant(b,x)||a&&l.isDetached(b,e)?y:(w===void 0&&(w=l.getPath(b)),l.getProxy(y,mr.concat(w,x),m,r)),m={get(y,b,x){if(Cg(b)){if(b===r||b===Eg)return y;if(b===Ww&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let w=Zf(y)?Reflect.get(y,b):Reflect.get(y,b,x);return g(w,y,b)},set(y,b,x,w){x=f(x);let A=y[r]||y,S=A[b];if(s(S,x)&&b in y)return!0;let _=c(y,b,x,S);return _&&l.setProperty(A,b,x,w,S)?(d(y,b,y[b],S),!0):!_},defineProperty(y,b,x){if(!l.isSameDescriptor(x,y,b)){let w=y[b];c(y,b,x.value,w)&&l.defineProperty(y,b,x,w)&&d(y,b,x.value,w)}return!0},deleteProperty(y,b){if(!Reflect.has(y,b))return!0;let x=Reflect.get(y,b),w=c(y,b,void 0,x);return w&&l.deleteProperty(y,b,x)?(d(y,b,void 0,x),!0):!w},apply(y,b,x){let w=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(y,w,x);if((o===!1||o!==!0&&!o.includes(y.name))&&ao.isHandledType(w)){let A=mr.initial(l.getPath(y)),S=ao.isHandledMethod(w,y.name);u.start(w,A,x);let _=Reflect.apply(y,u.preferredThisArg(y,b,w),S?x.map(T=>f(T)):x),M=u.isChanged(w,s),C=u.stop();if(ao.isHandledType(_)&&S&&(b instanceof Map&&y.name==="get"&&(A=mr.concat(A,x[0])),_=l.getProxy(_,A,m)),M){let T={name:y.name,args:x,result:_},P=u.isCloning?mr.initial(A):A,L=u.isCloning?mr.last(A):"";c(mr.get(e,P),L,w,C,T)?p(P,L,w,C,T):u.undo(w)}return(b instanceof Map||b instanceof Set)&&yL(_)?xL(_,y,b,A,g):_}return Reflect.apply(y,b,x)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};Tg.target=e=>e&&e[Eg]||e;Tg.unsubscribe=e=>e[Ww]||e;var ky=Tg,DL=typeof global=="object"&&global&&global.Object===Object&&global,Jw=DL,LL=typeof self=="object"&&self&&self.Object===Object&&self,OL=Jw||LL||Function("return this")(),Hr=OL,IL=Hr.Symbol,Er=IL,$w=Object.prototype,RL=$w.hasOwnProperty,BL=$w.toString,wl=Er?Er.toStringTag:void 0;function zL(e){var t=RL.call(e,wl),i=e[wl];try{e[wl]=void 0;var r=!0}catch{}var s=BL.call(e);return r&&(t?e[wl]=i:delete e[wl]),s}var NL=zL,UL=Object.prototype,FL=UL.toString;function kL(e){return FL.call(e)}var jL=kL,GL="[object Null]",VL="[object Undefined]",jy=Er?Er.toStringTag:void 0;function HL(e){return e==null?e===void 0?VL:GL:jy&&jy in Object(e)?NL(e):jL(e)}var Ma=HL;function WL(e){return e!=null&&typeof e=="object"}var Ws=WL,XL="[object Symbol]";function qL(e){return typeof e=="symbol"||Ws(e)&&Ma(e)==XL}var fu=qL;function YL(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var e_=YL,QL=Array.isArray,ys=QL,ZL=1/0,Gy=Er?Er.prototype:void 0,Vy=Gy?Gy.toString:void 0;function t_(e){if(typeof e=="string")return e;if(ys(e))return e_(e,t_)+"";if(fu(e))return Vy?Vy.call(e):"";var t=e+"";return t=="0"&&1/e==-ZL?"-0":t}var KL=t_,JL=/\s/;function $L(e){for(var t=e.length;t--&&JL.test(e.charAt(t)););return t}var eO=$L,tO=/^\s+/;function iO(e){return e&&e.slice(0,eO(e)+1).replace(tO,"")}var rO=iO;function sO(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var xs=sO,Hy=0/0,nO=/^[-+]0x[0-9a-f]+$/i,aO=/^0b[01]+$/i,oO=/^0o[0-7]+$/i,lO=parseInt;function hO(e){if(typeof e=="number")return e;if(fu(e))return Hy;if(xs(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=xs(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=rO(e);var i=aO.test(e);return i||oO.test(e)?lO(e.slice(2),i?2:8):nO.test(e)?Hy:+e}var Wy=hO;function cO(e){return e}var dO=cO,uO="[object AsyncFunction]",pO="[object Function]",fO="[object GeneratorFunction]",mO="[object Proxy]";function gO(e){if(!xs(e))return!1;var t=Ma(e);return t==pO||t==fO||t==uO||t==mO}var i_=gO,vO=Hr["__core-js_shared__"],Lp=vO,Xy=function(){var e=/[^.]+$/.exec(Lp&&Lp.keys&&Lp.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function yO(e){return!!Xy&&Xy in e}var xO=yO,bO=Function.prototype,wO=bO.toString;function _O(e){if(e!=null){try{return wO.call(e)}catch{}try{return e+""}catch{}}return""}var Ea=_O,AO=/[\\^$.*+?()[\]{}|]/g,SO=/^\[object .+?Constructor\]$/,MO=Function.prototype,EO=Object.prototype,CO=MO.toString,TO=EO.hasOwnProperty,PO=RegExp("^"+CO.call(TO).replace(AO,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function DO(e){if(!xs(e)||xO(e))return!1;var t=i_(e)?PO:SO;return t.test(Ea(e))}var LO=DO;function OO(e,t){return e?.[t]}var IO=OO;function RO(e,t){var i=IO(e,t);return LO(i)?i:void 0}var Ca=RO,BO=Ca(Hr,"WeakMap"),Jf=BO,qy=Object.create,zO=function(){function e(){}return function(t){if(!xs(t))return{};if(qy)return qy(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),NO=zO;function UO(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var FO=UO;function kO(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var jO=kO,GO=800,VO=16,HO=Date.now;function WO(e){var t=0,i=0;return function(){var r=HO(),s=VO-(r-i);if(i=r,s>0){if(++t>=GO)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var XO=WO;function qO(e){return function(){return e}}var YO=qO,QO=function(){try{var e=Ca(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Sd=QO,ZO=Sd?function(e,t){return Sd(e,"toString",{configurable:!0,enumerable:!1,value:YO(t),writable:!0})}:dO,KO=ZO,JO=XO(KO),$O=JO;function eI(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var tI=eI,iI=9007199254740991,rI=/^(?:0|[1-9]\d*)$/;function sI(e,t){var i=typeof e;return t=t??iI,!!t&&(i=="number"||i!="symbol"&&rI.test(e))&&e>-1&&e%1==0&&e<t}var Pg=sI;function nI(e,t,i){t=="__proto__"&&Sd?Sd(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var r_=nI;function aI(e,t){return e===t||e!==e&&t!==t}var Dg=aI,oI=Object.prototype,lI=oI.hasOwnProperty;function hI(e,t,i){var r=e[t];(!(lI.call(e,t)&&Dg(r,i))||i===void 0&&!(t in e))&&r_(e,t,i)}var Lg=hI;function cI(e,t,i,r){var s=!i;i||(i={});for(var n=-1,a=t.length;++n<a;){var o=t[n],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?r_(i,o,l):Lg(i,o,l)}return i}var Bh=cI,Yy=Math.max;function dI(e,t,i){return t=Yy(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=Yy(r.length-t,0),a=Array(n);++s<n;)a[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(a),FO(e,this,o)}}var uI=dI,pI=9007199254740991;function fI(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=pI}var Og=fI;function mI(e){return e!=null&&Og(e.length)&&!i_(e)}var s_=mI,gI=Object.prototype;function vI(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||gI;return e===i}var Ig=vI;function yI(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var xI=yI,bI="[object Arguments]";function wI(e){return Ws(e)&&Ma(e)==bI}var Qy=wI,n_=Object.prototype,_I=n_.hasOwnProperty,AI=n_.propertyIsEnumerable,SI=Qy(function(){return arguments}())?Qy:function(e){return Ws(e)&&_I.call(e,"callee")&&!AI.call(e,"callee")},Rg=SI;function MI(){return!1}var EI=MI,a_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Zy=a_&&typeof module=="object"&&module&&!module.nodeType&&module,CI=Zy&&Zy.exports===a_,Ky=CI?Hr.Buffer:void 0,TI=Ky?Ky.isBuffer:void 0,PI=TI||EI,Md=PI,DI="[object Arguments]",LI="[object Array]",OI="[object Boolean]",II="[object Date]",RI="[object Error]",BI="[object Function]",zI="[object Map]",NI="[object Number]",UI="[object Object]",FI="[object RegExp]",kI="[object Set]",jI="[object String]",GI="[object WeakMap]",VI="[object ArrayBuffer]",HI="[object DataView]",WI="[object Float32Array]",XI="[object Float64Array]",qI="[object Int8Array]",YI="[object Int16Array]",QI="[object Int32Array]",ZI="[object Uint8Array]",KI="[object Uint8ClampedArray]",JI="[object Uint16Array]",$I="[object Uint32Array]",Tt={};Tt[WI]=Tt[XI]=Tt[qI]=Tt[YI]=Tt[QI]=Tt[ZI]=Tt[KI]=Tt[JI]=Tt[$I]=!0;Tt[DI]=Tt[LI]=Tt[VI]=Tt[OI]=Tt[HI]=Tt[II]=Tt[RI]=Tt[BI]=Tt[zI]=Tt[NI]=Tt[UI]=Tt[FI]=Tt[kI]=Tt[jI]=Tt[GI]=!1;function e4(e){return Ws(e)&&Og(e.length)&&!!Tt[Ma(e)]}var t4=e4;function i4(e){return function(t){return e(t)}}var Bg=i4,o_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,th=o_&&typeof module=="object"&&module&&!module.nodeType&&module,r4=th&&th.exports===o_,Op=r4&&Jw.process,s4=function(){try{var e=th&&th.require&&th.require("util").types;return e||Op&&Op.binding&&Op.binding("util")}catch{}}(),No=s4,Jy=No&&No.isTypedArray,n4=Jy?Bg(Jy):t4,l_=n4,a4=Object.prototype,o4=a4.hasOwnProperty;function l4(e,t){var i=ys(e),r=!i&&Rg(e),s=!i&&!r&&Md(e),n=!i&&!r&&!s&&l_(e),a=i||r||s||n,o=a?xI(e.length,String):[],l=o.length;for(var h in e)(t||o4.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Pg(h,l)))&&o.push(h);return o}var h_=l4;function h4(e,t){return function(i){return e(t(i))}}var c_=h4,c4=c_(Object.keys,Object),d4=c4,u4=Object.prototype,p4=u4.hasOwnProperty;function f4(e){if(!Ig(e))return d4(e);var t=[];for(var i in Object(e))p4.call(e,i)&&i!="constructor"&&t.push(i);return t}var m4=f4;function g4(e){return s_(e)?h_(e):m4(e)}var zg=g4;function v4(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var y4=v4,x4=Object.prototype,b4=x4.hasOwnProperty;function w4(e){if(!xs(e))return y4(e);var t=Ig(e),i=[];for(var r in e)r=="constructor"&&(t||!b4.call(e,r))||i.push(r);return i}var _4=w4;function A4(e){return s_(e)?h_(e,!0):_4(e)}var Ng=A4,S4=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,M4=/^\w*$/;function E4(e,t){if(ys(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||fu(e)?!0:M4.test(e)||!S4.test(e)||t!=null&&e in Object(t)}var C4=E4,T4=Ca(Object,"create"),fh=T4;function P4(){this.__data__=fh?fh(null):{},this.size=0}var D4=P4;function L4(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var O4=L4,I4="__lodash_hash_undefined__",R4=Object.prototype,B4=R4.hasOwnProperty;function z4(e){var t=this.__data__;if(fh){var i=t[e];return i===I4?void 0:i}return B4.call(t,e)?t[e]:void 0}var N4=z4,U4=Object.prototype,F4=U4.hasOwnProperty;function k4(e){var t=this.__data__;return fh?t[e]!==void 0:F4.call(t,e)}var j4=k4,G4="__lodash_hash_undefined__";function V4(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=fh&&t===void 0?G4:t,this}var H4=V4;function Zo(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Zo.prototype.clear=D4;Zo.prototype.delete=O4;Zo.prototype.get=N4;Zo.prototype.has=j4;Zo.prototype.set=H4;var $y=Zo;function W4(){this.__data__=[],this.size=0}var X4=W4;function q4(e,t){for(var i=e.length;i--;)if(Dg(e[i][0],t))return i;return-1}var mu=q4,Y4=Array.prototype,Q4=Y4.splice;function Z4(e){var t=this.__data__,i=mu(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():Q4.call(t,i,1),--this.size,!0}var K4=Z4;function J4(e){var t=this.__data__,i=mu(t,e);return i<0?void 0:t[i][1]}var $4=J4;function eR(e){return mu(this.__data__,e)>-1}var tR=eR;function iR(e,t){var i=this.__data__,r=mu(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var rR=iR;function Ko(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Ko.prototype.clear=X4;Ko.prototype.delete=K4;Ko.prototype.get=$4;Ko.prototype.has=tR;Ko.prototype.set=rR;var gu=Ko,sR=Ca(Hr,"Map"),mh=sR;function nR(){this.size=0,this.__data__={hash:new $y,map:new(mh||gu),string:new $y}}var aR=nR;function oR(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var lR=oR;function hR(e,t){var i=e.__data__;return lR(t)?i[typeof t=="string"?"string":"hash"]:i.map}var vu=hR;function cR(e){var t=vu(this,e).delete(e);return this.size-=t?1:0,t}var dR=cR;function uR(e){return vu(this,e).get(e)}var pR=uR;function fR(e){return vu(this,e).has(e)}var mR=fR;function gR(e,t){var i=vu(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var vR=gR;function Jo(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Jo.prototype.clear=aR;Jo.prototype.delete=dR;Jo.prototype.get=pR;Jo.prototype.has=mR;Jo.prototype.set=vR;var yu=Jo,yR="Expected a function";function Ug(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(yR);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],n=i.cache;if(n.has(s))return n.get(s);var a=e.apply(this,r);return i.cache=n.set(s,a)||n,a};return i.cache=new(Ug.Cache||yu),i}Ug.Cache=yu;var xR=Ug,bR=500;function wR(e){var t=xR(e,function(r){return i.size===bR&&i.clear(),r}),i=t.cache;return t}var _R=wR,AR=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,SR=/\\(\\)?/g,MR=_R(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(AR,function(i,r,s,n){t.push(s?n.replace(SR,"$1"):r||i)}),t}),ER=MR;function CR(e){return e==null?"":KL(e)}var TR=CR;function PR(e,t){return ys(e)?e:C4(e,t)?[e]:ER(TR(e))}var $o=PR,DR=1/0;function LR(e){if(typeof e=="string"||fu(e))return e;var t=e+"";return t=="0"&&1/e==-DR?"-0":t}var xu=LR;function OR(e,t){t=$o(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[xu(t[i++])];return i&&i==r?e:void 0}var d_=OR;function IR(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Fg=IR,e1=Er?Er.isConcatSpreadable:void 0;function RR(e){return ys(e)||Rg(e)||!!(e1&&e&&e[e1])}var BR=RR;function u_(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=BR),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?u_(o,t-1,i,r,s):Fg(s,o):r||(s[s.length]=o)}return s}var zR=u_;function NR(e){var t=e==null?0:e.length;return t?zR(e,1):[]}var UR=NR;function FR(e){return $O(uI(e,void 0,UR),e+"")}var p_=FR,kR=c_(Object.getPrototypeOf,Object),kg=kR,jR="[object Object]",GR=Function.prototype,VR=Object.prototype,f_=GR.toString,HR=VR.hasOwnProperty,WR=f_.call(Object);function XR(e){if(!Ws(e)||Ma(e)!=jR)return!1;var t=kg(e);if(t===null)return!0;var i=HR.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&f_.call(i)==WR}var qR=XR;function YR(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var n=Array(s);++r<s;)n[r]=e[r+t];return n}var QR=YR;function ZR(){this.__data__=new gu,this.size=0}var KR=ZR;function JR(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var $R=JR;function eB(e){return this.__data__.get(e)}var tB=eB;function iB(e){return this.__data__.has(e)}var rB=iB,sB=200;function nB(e,t){var i=this.__data__;if(i instanceof gu){var r=i.__data__;if(!mh||r.length<sB-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new yu(r)}return i.set(e,t),this.size=i.size,this}var aB=nB;function el(e){var t=this.__data__=new gu(e);this.size=t.size}el.prototype.clear=KR;el.prototype.delete=$R;el.prototype.get=tB;el.prototype.has=rB;el.prototype.set=aB;var id=el;function oB(e,t){return e&&Bh(t,zg(t),e)}var lB=oB;function hB(e,t){return e&&Bh(t,Ng(t),e)}var cB=hB,m_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,t1=m_&&typeof module=="object"&&module&&!module.nodeType&&module,dB=t1&&t1.exports===m_,i1=dB?Hr.Buffer:void 0,r1=i1?i1.allocUnsafe:void 0;function uB(e,t){if(t)return e.slice();var i=e.length,r=r1?r1(i):new e.constructor(i);return e.copy(r),r}var pB=uB;function fB(e,t){for(var i=-1,r=e==null?0:e.length,s=0,n=[];++i<r;){var a=e[i];t(a,i,e)&&(n[s++]=a)}return n}var mB=fB;function gB(){return[]}var g_=gB,vB=Object.prototype,yB=vB.propertyIsEnumerable,s1=Object.getOwnPropertySymbols,xB=s1?function(e){return e==null?[]:(e=Object(e),mB(s1(e),function(t){return yB.call(e,t)}))}:g_,jg=xB;function bB(e,t){return Bh(e,jg(e),t)}var wB=bB,_B=Object.getOwnPropertySymbols,AB=_B?function(e){for(var t=[];e;)Fg(t,jg(e)),e=kg(e);return t}:g_,v_=AB;function SB(e,t){return Bh(e,v_(e),t)}var MB=SB;function EB(e,t,i){var r=t(e);return ys(e)?r:Fg(r,i(e))}var y_=EB;function CB(e){return y_(e,zg,jg)}var $f=CB;function TB(e){return y_(e,Ng,v_)}var x_=TB,PB=Ca(Hr,"DataView"),em=PB,DB=Ca(Hr,"Promise"),tm=DB,LB=Ca(Hr,"Set"),im=LB,n1="[object Map]",OB="[object Object]",a1="[object Promise]",o1="[object Set]",l1="[object WeakMap]",h1="[object DataView]",IB=Ea(em),RB=Ea(mh),BB=Ea(tm),zB=Ea(im),NB=Ea(Jf),$n=Ma;(em&&$n(new em(new ArrayBuffer(1)))!=h1||mh&&$n(new mh)!=n1||tm&&$n(tm.resolve())!=a1||im&&$n(new im)!=o1||Jf&&$n(new Jf)!=l1)&&($n=function(e){var t=Ma(e),i=t==OB?e.constructor:void 0,r=i?Ea(i):"";if(r)switch(r){case IB:return h1;case RB:return n1;case BB:return a1;case zB:return o1;case NB:return l1}return t});var gh=$n,UB=Object.prototype,FB=UB.hasOwnProperty;function kB(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&FB.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var jB=kB,GB=Hr.Uint8Array,Ed=GB;function VB(e){var t=new e.constructor(e.byteLength);return new Ed(t).set(new Ed(e)),t}var Gg=VB;function HB(e,t){var i=t?Gg(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var WB=HB,XB=/\w*$/;function qB(e){var t=new e.constructor(e.source,XB.exec(e));return t.lastIndex=e.lastIndex,t}var YB=qB,c1=Er?Er.prototype:void 0,d1=c1?c1.valueOf:void 0;function QB(e){return d1?Object(d1.call(e)):{}}var ZB=QB;function KB(e,t){var i=t?Gg(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var JB=KB,$B="[object Boolean]",e5="[object Date]",t5="[object Map]",i5="[object Number]",r5="[object RegExp]",s5="[object Set]",n5="[object String]",a5="[object Symbol]",o5="[object ArrayBuffer]",l5="[object DataView]",h5="[object Float32Array]",c5="[object Float64Array]",d5="[object Int8Array]",u5="[object Int16Array]",p5="[object Int32Array]",f5="[object Uint8Array]",m5="[object Uint8ClampedArray]",g5="[object Uint16Array]",v5="[object Uint32Array]";function y5(e,t,i){var r=e.constructor;switch(t){case o5:return Gg(e);case $B:case e5:return new r(+e);case l5:return WB(e,i);case h5:case c5:case d5:case u5:case p5:case f5:case m5:case g5:case v5:return JB(e,i);case t5:return new r;case i5:case n5:return new r(e);case r5:return YB(e);case s5:return new r;case a5:return ZB(e)}}var x5=y5;function b5(e){return typeof e.constructor=="function"&&!Ig(e)?NO(kg(e)):{}}var w5=b5,_5="[object Map]";function A5(e){return Ws(e)&&gh(e)==_5}var S5=A5,u1=No&&No.isMap,M5=u1?Bg(u1):S5,E5=M5,C5="[object Set]";function T5(e){return Ws(e)&&gh(e)==C5}var P5=T5,p1=No&&No.isSet,D5=p1?Bg(p1):P5,L5=D5,O5=1,I5=2,R5=4,b_="[object Arguments]",B5="[object Array]",z5="[object Boolean]",N5="[object Date]",U5="[object Error]",w_="[object Function]",F5="[object GeneratorFunction]",k5="[object Map]",j5="[object Number]",__="[object Object]",G5="[object RegExp]",V5="[object Set]",H5="[object String]",W5="[object Symbol]",X5="[object WeakMap]",q5="[object ArrayBuffer]",Y5="[object DataView]",Q5="[object Float32Array]",Z5="[object Float64Array]",K5="[object Int8Array]",J5="[object Int16Array]",$5="[object Int32Array]",ez="[object Uint8Array]",tz="[object Uint8ClampedArray]",iz="[object Uint16Array]",rz="[object Uint32Array]",Et={};Et[b_]=Et[B5]=Et[q5]=Et[Y5]=Et[z5]=Et[N5]=Et[Q5]=Et[Z5]=Et[K5]=Et[J5]=Et[$5]=Et[k5]=Et[j5]=Et[__]=Et[G5]=Et[V5]=Et[H5]=Et[W5]=Et[ez]=Et[tz]=Et[iz]=Et[rz]=!0;Et[U5]=Et[w_]=Et[X5]=!1;function rd(e,t,i,r,s,n){var a,o=t&O5,l=t&I5,h=t&R5;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!xs(e))return e;var u=ys(e);if(u){if(a=jB(e),!o)return jO(e,a)}else{var c=gh(e),d=c==w_||c==F5;if(Md(e))return pB(e,o);if(c==__||c==b_||d&&!s){if(a=l||d?{}:w5(e),!o)return l?MB(e,cB(a,e)):wB(e,lB(a,e))}else{if(!Et[c])return s?e:{};a=x5(e,c,o)}}n||(n=new id);var p=n.get(e);if(p)return p;n.set(e,a),L5(e)?e.forEach(function(m){a.add(rd(m,t,i,m,e,n))}):E5(e)&&e.forEach(function(m,v){a.set(v,rd(m,t,i,v,e,n))});var f=h?l?x_:$f:l?Ng:zg,g=u?void 0:f(e);return tI(g||e,function(m,v){g&&(v=m,m=e[v]),Lg(a,v,rd(m,t,i,v,e,n))}),a}var A_=rd,sz=1,nz=4;function az(e){return A_(e,sz|nz)}var bu=az,oz="__lodash_hash_undefined__";function lz(e){return this.__data__.set(e,oz),this}var hz=lz;function cz(e){return this.__data__.has(e)}var dz=cz;function Cd(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new yu;++t<i;)this.add(e[t])}Cd.prototype.add=Cd.prototype.push=hz;Cd.prototype.has=dz;var uz=Cd;function pz(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var fz=pz;function mz(e,t){return e.has(t)}var gz=mz,vz=1,yz=2;function xz(e,t,i,r,s,n){var a=i&vz,o=e.length,l=t.length;if(o!=l&&!(a&&l>o))return!1;var h=n.get(e),u=n.get(t);if(h&&u)return h==t&&u==e;var c=-1,d=!0,p=i&yz?new uz:void 0;for(n.set(e,t),n.set(t,e);++c<o;){var f=e[c],g=t[c];if(r)var m=a?r(g,f,c,t,e,n):r(f,g,c,e,t,n);if(m!==void 0){if(m)continue;d=!1;break}if(p){if(!fz(t,function(v,y){if(!gz(p,y)&&(f===v||s(f,v,i,r,n)))return p.push(y)})){d=!1;break}}else if(!(f===g||s(f,g,i,r,n))){d=!1;break}}return n.delete(e),n.delete(t),d}var S_=xz;function bz(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var wz=bz;function _z(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var Az=_z,Sz=1,Mz=2,Ez="[object Boolean]",Cz="[object Date]",Tz="[object Error]",Pz="[object Map]",Dz="[object Number]",Lz="[object RegExp]",Oz="[object Set]",Iz="[object String]",Rz="[object Symbol]",Bz="[object ArrayBuffer]",zz="[object DataView]",f1=Er?Er.prototype:void 0,Ip=f1?f1.valueOf:void 0;function Nz(e,t,i,r,s,n,a){switch(i){case zz:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Bz:return!(e.byteLength!=t.byteLength||!n(new Ed(e),new Ed(t)));case Ez:case Cz:case Dz:return Dg(+e,+t);case Tz:return e.name==t.name&&e.message==t.message;case Lz:case Iz:return e==t+"";case Pz:var o=wz;case Oz:var l=r&Sz;if(o||(o=Az),e.size!=t.size&&!l)return!1;var h=a.get(e);if(h)return h==t;r|=Mz,a.set(e,t);var u=S_(o(e),o(t),r,s,n,a);return a.delete(e),u;case Rz:if(Ip)return Ip.call(e)==Ip.call(t)}return!1}var Uz=Nz,Fz=1,kz=Object.prototype,jz=kz.hasOwnProperty;function Gz(e,t,i,r,s,n){var a=i&Fz,o=$f(e),l=o.length,h=$f(t),u=h.length;if(l!=u&&!a)return!1;for(var c=l;c--;){var d=o[c];if(!(a?d in t:jz.call(t,d)))return!1}var p=n.get(e),f=n.get(t);if(p&&f)return p==t&&f==e;var g=!0;n.set(e,t),n.set(t,e);for(var m=a;++c<l;){d=o[c];var v=e[d],y=t[d];if(r)var b=a?r(y,v,d,t,e,n):r(v,y,d,e,t,n);if(!(b===void 0?v===y||s(v,y,i,r,n):b)){g=!1;break}m||(m=d=="constructor")}if(g&&!m){var x=e.constructor,w=t.constructor;x!=w&&"constructor"in e&&"constructor"in t&&!(typeof x=="function"&&x instanceof x&&typeof w=="function"&&w instanceof w)&&(g=!1)}return n.delete(e),n.delete(t),g}var Vz=Gz,Hz=1,m1="[object Arguments]",g1="[object Array]",Ac="[object Object]",Wz=Object.prototype,v1=Wz.hasOwnProperty;function Xz(e,t,i,r,s,n){var a=ys(e),o=ys(t),l=a?g1:gh(e),h=o?g1:gh(t);l=l==m1?Ac:l,h=h==m1?Ac:h;var u=l==Ac,c=h==Ac,d=l==h;if(d&&Md(e)){if(!Md(t))return!1;a=!0,u=!1}if(d&&!u)return n||(n=new id),a||l_(e)?S_(e,t,i,r,s,n):Uz(e,t,l,i,r,s,n);if(!(i&Hz)){var p=u&&v1.call(e,"__wrapped__"),f=c&&v1.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return n||(n=new id),s(g,m,i,r,n)}}return d?(n||(n=new id),Vz(e,t,i,r,s,n)):!1}var qz=Xz;function M_(e,t,i,r,s){return e===t?!0:e==null||t==null||!Ws(e)&&!Ws(t)?e!==e&&t!==t:qz(e,t,i,r,M_,s)}var Yz=M_;function Qz(e,t){return e!=null&&t in Object(e)}var Zz=Qz;function Kz(e,t,i){t=$o(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=xu(t[r]);if(!(n=e!=null&&i(e,a)))break;e=e[a]}return n||++r!=s?n:(s=e==null?0:e.length,!!s&&Og(s)&&Pg(a,s)&&(ys(e)||Rg(e)))}var Jz=Kz;function $z(e,t){return e!=null&&Jz(e,t,Zz)}var eN=$z,tN=function(){return Hr.Date.now()},Rp=tN,iN="Expected a function",rN=Math.max,sN=Math.min;function nN(e,t,i){var r,s,n,a,o,l,h=0,u=!1,c=!1,d=!0;if(typeof e!="function")throw new TypeError(iN);t=Wy(t)||0,xs(i)&&(u=!!i.leading,c="maxWait"in i,n=c?rN(Wy(i.maxWait)||0,t):n,d="trailing"in i?!!i.trailing:d);function p(A){var S=r,_=s;return r=s=void 0,h=A,a=e.apply(_,S),a}function f(A){return h=A,o=setTimeout(v,t),u?p(A):a}function g(A){var S=A-l,_=A-h,M=t-S;return c?sN(M,n-_):M}function m(A){var S=A-l,_=A-h;return l===void 0||S>=t||S<0||c&&_>=n}function v(){var A=Rp();if(m(A))return y(A);o=setTimeout(v,g(A))}function y(A){return o=void 0,d&&r?p(A):(r=s=void 0,a)}function b(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function x(){return o===void 0?a:y(Rp())}function w(){var A=Rp(),S=m(A);if(r=arguments,s=this,l=A,S){if(o===void 0)return f(l);if(c)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),a}return w.cancel=b,w.flush=x,w}var E_=nN;function aN(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var oN=aN;function lN(e,t){return t.length<2?e:d_(e,QR(t,0,-1))}var hN=lN;function cN(e,t){return Yz(e,t)}var Vg=cN;function dN(e,t){return t=$o(t,e),e=hN(e,t),e==null||delete e[xu(oN(t))]}var uN=dN;function pN(e){return qR(e)?void 0:e}var fN=pN,mN=1,gN=2,vN=4,yN=p_(function(e,t){var i={};if(e==null)return i;var r=!1;t=e_(t,function(n){return n=$o(n,e),r||(r=n.length>1),n}),Bh(e,x_(e),i),r&&(i=A_(i,mN|gN|vN,fN));for(var s=t.length;s--;)uN(i,t[s]);return i}),rm=yN;function xN(e,t,i,r){if(!xs(e))return e;t=$o(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=xu(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=a){var u=o[l];h=r?r(u,l,o):void 0,h===void 0&&(h=xs(u)?u:Pg(t[s+1])?[]:{})}Lg(o,l,h),o=o[l]}return e}var bN=xN;function wN(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=d_(e,a);i(o,a)&&bN(n,$o(a,e),o)}return n}var _N=wN;function AN(e,t){return _N(e,t,function(i,r){return eN(e,r)})}var SN=AN,MN=p_(function(e,t){return e==null?{}:SN(e,t)}),vh=MN,C_,EN=new Promise(e=>{C_=e}),y1=!1;async function CN(){if(y1)return;let e=await import("./physics.js");await e.init(),C_(e),y1=!0}var Qt=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,Qt.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:n}=e,a={...t,[s]:n};return Object.setPrototypeOf(a,Qt.prototype),{data:a,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,Qt.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function Hg(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&Hg(r)}return Object.freeze(e)}function TN(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var T_=class extends Error{};function Bp(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function yn(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let n=e;e=t,t=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=e+(t-e)*(n+.75+Math.random()*.5)*s;r.push(a)}return r}function Wg(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function PN(){return typeof process<"u"}function P_(e,t){for(let i of e)t(i.id,i.data)!==!0&&P_(i.children,t)}function D_(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)D_(i,t)}var ji=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,ji.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Hg(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&D_(i,t)}}traverse(e){P_(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);if(s<0)throw new Error("not expected");let n=r[s];return r=[...r],r[s]={...n,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let n=r,a=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===a);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:n}}Object.setPrototypeOf(r,ji.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:n}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===t);e.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...n,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let c=t;for(;c!==null;){if(c===void 0)throw new Error;if(c===r)throw new T_("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(c=>c.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(s,a);s=t,a=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((c,d)=>c.fi-d.fi),e.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:e,reverse:{type:9,parent:n,fi:u,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>TN(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return yn(0,i,i);{let s=r[0].fi;return yn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return yn(a,a+i,i)}else return yn(s.fi,n.fi,i)}}},Td;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,n={},a=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");n[l]=a[h],a[h]=s[l],o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}else{let s=r.props,n={},a={...i},o=!1;if(s)for(let l of Object.keys(s)){n[l]=a[l];let h=s[l];h===void 0?delete a[l]:a[l]=h,o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}}e.runOp=t})(Td||(Td={}));var rt=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,rt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Hg(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,rt.prototype);let t=e;return PN()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,n={fi:t,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),e.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(n=>n.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:t};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:n,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return yn(0,t,t);{let r=i[0].fi;return yn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return yn(n,n+t,t)}else return yn(r.fi,s.fi,t)}}};function Uo(e){return e&&typeof e=="object"&&e instanceof mi}var mi=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!Uo(i))return null;r+=1}i=i?Bp(i):new mi;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=Bp(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Bp(o);l[e.path[r-1]]=i,i=l}else{let l=new mi;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,mi.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},fa;(e=>{function t(s,n){return yh(s,n)??s}e.apply=t;function i(s,n){return qg(s,n)}e.merge=i;function r(s,n){let a=0,o=n.path,l=s;for(;a<o.length&&l!==void 0;){if(l=fs.zoomOnce(l,o[a]),l===void 0)return n;if(!Uo(l))return;a+=1}if(l===void 0)return n;if(Uo(l))if(n.type===0){let h={...n.props};for(let u of Object.keys(l))delete h[u];return{...n,props:h}}else if(n.type===1||n.type===4||n.type===7){let h=Xg([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})(fa||(fa={}));function Xg(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=yh(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=Xg(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}else return{...s,id:n,data:a}});if(i)return r}function DN(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=yh(s.data,t[n]);return i=i||a!==void 0,a===void 0&&(a=s.data),{...s,id:n,data:a}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function yh(e,t){if(!Uo(t))return t;if(e instanceof ji){let i=Xg(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof rt)return DN(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=yh(s,t[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof mi)return qg(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=yh(n,t[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function qg(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Uo(t))return t;if(!Uo(e))return fa.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new mi;for(let s of i){let n=qg(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function LN(e,t){let i={cur:[],result:[],len:0};return e=xh(e,t,i)??e,[e,i.result]}function Pd(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Dd(e){e&&(e.len-=1)}function ON(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function L_(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=xh(n.data,t,Pd(i,a));Dd(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=L_(n.children,t,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function IN(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=xh(n.data,t,Pd(i,a));return Dd(i),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function xh(e,t,i){if(e instanceof ji){let r=L_(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof rt)return IN(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=xh(n,t,Pd(i,a));return Dd(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!Wg(e)){let r={},s=!1;for(let[n,a]of Object.entries(e))if(n!=="name"&&n!=="text"){let o=t[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=xh(a,t,Pd(i,n));Dd(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];if(r!==void 0){if(e.length!==36)throw new Error("for now you should only call this method when the key is a uuid");ON(i)}return r}else return}}var sm;(e=>{function t(i,r){let s=fs.zoom(r,i.path);if(typeof s=="object"){let n={};for(let a of Object.keys(i.props))n[a]=s[a];return{...i,props:n}}else return{...i,props:{}}}e.replaceProps=t})(sm||(sm={}));var ir;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let u=h.path;for(var c=[];;){let d;if(l instanceof mi&&h.type===0&&(d=l.runOp({...h,path:u.slice(c.length)}),d===null&&(d=void 0)),c.length===u.length&&(l instanceof ji||l instanceof rt||l instanceof Qt?d=l.runOp(h):d=Td.runOp(l,h)),d!==void 0)if(d!==null){let g=d.data;for(let m=c.length-1;m>=0;m--){let v=u[m],y=c[m];if(y instanceof ji){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof rt){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof Qt){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof mi){let b={...y,[v]:g};g=Object.setPrototypeOf(b,mi.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let b=g;g=[...y],g[v]=b}else g={...y,[v]:g};else return null}return{data:g,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let p=u[c.length],f;if(l instanceof ji){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof rt){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)c.push(l),l=f;else return null}}e.apply=r;function s(l,h){for(let u=0;u<l.length&&u<h.length;u++)if(l[u]!==h[u])return!0;return!1}e.pathDisjoint=s;function n(l,h){if(l.length!==h.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==h[u])return!1;return!0}e.pathEq=n;function a(l,h){return s(l.path,h.path)}e.commutative=a;function o(l,h){return l.type===0&&h.type===0&&n(l.path,h.path)?Object.keys(l.props).every(u=>h.props[u]!==void 0):!1}e.subsumed=o})(ir||(ir={}));var x1;(e=>{function t(){return[]}e.empty=t;function i(h,u){let c=[];for(let d of h){let[p,...f]=d.path;p===u&&c.push({...d,path:f})}return c}e.removePrefix=i;function r(h,u){return h.map(c=>({...c,path:[u,...c.path]}))}e.addPrefix=r;function s(h,u){return[...h,...u]}e.concat=s;function n(h,u){return[...h.filter(c=>!u.some(d=>ir.subsumed(c,d))),...u]}e.compress=n;function a(h,u){return h.every(c=>u.every(d=>ir.commutative(c,d)))}e.commutative=a;function o(h,u){for(let c of u){let d=l(h,c);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,u){var c=h;let d=[],p=[];for(let f of u)try{if(f.type===3){let g=fs.zoom(c,[...f.path,f.id]),m=ir.apply(c,{...f,type:2});if(m!==null){c=m.data;let[v,y]=LN(c,{[f.id]:g});c=v;for(let b of y){let x=b[b.length-1];b.splice(b.length-1,1),d.push({type:0,path:b,props:{[x]:g}}),p.push({type:0,path:b,props:{[x]:f.id}})}p.push(m.reverse),d.push(m.actual)}}else{let g=ir.apply(c,f);g!==null&&(d.push(g.actual),c=g.data,p.push(g.reverse))}}catch(g){if(g instanceof T_)return null;throw g}return{data:c,actual:d,reverse:p.reverse()}}e.apply=l})(x1||(x1={}));var O_=Symbol(),RN=Symbol(),wu=Symbol(),zh=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof R_);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[wu];i&&i(),delete this._children[e]}}}},BN=class extends zh{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,Td.runOp(this._current,e),e.path)}},zN=class extends zh{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,Qt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},I_={get(e,t){if(t===wu)return()=>{e._parent=null};if(t===O_)return e._current;if(t===RN)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let n=i[t],a=_u(e,t,n);return a!==n?(r===void 0&&(r={},e._children=r),r[t]=a,a):n},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},NN={...I_,set(e,t,i){let r={type:0,props:{[t]:Si(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},UN={...I_,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},Yg=class extends zh{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[wu]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=_u(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Qg=class extends zh{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[wu]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=_u(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function zp(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&fs.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var R_=class extends zh{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){zp(this.ts,t,e),zp(this.actual,i,e),zp(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function _u(e,t,i){return i instanceof ji?new Yg(e,t,i):i instanceof rt?new Qg(e,t,i):i instanceof Qt?new Proxy(new zN(e,t,i),UN):i!==null&&typeof i=="object"?Wg(i)?i:new Proxy(new BN(e,t,i),NN):i}function B_(e){let t=new R_(e);return[_u(t,"",e),t]}function Ld(e,t){let[i,r]=B_(e);return t(i),r.result()}function Si(e){return e instanceof Yg||e instanceof Qg?e._current:e!==null&&typeof e=="object"?e[O_]:e}var fs;(e=>{function t(n,a){if(a.length===n.length)for(var o=0;o<n.length;){if(n[o]!==a[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(n,a,o){let l=s(o,n);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...a};return Object.keys(l).forEach(u=>{delete h[u]}),h}else return a}e.removeOverridden=i;function r(n,a){if((n instanceof ji||n instanceof Yg)&&typeof a=="string"||(n instanceof rt||n instanceof Qg)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n)||typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}e.zoomOnce=r;function s(n,a,o=0){for(;o<a.length&&n!==void 0;)n=r(n,a[o]),o+=1;return n}e.zoom=s})(fs||(fs={}));function FN(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function pn(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var z_=class{},b1=class extends z_{constructor(e){super(),this.id=e}},w1=class extends z_{constructor(e){super(),this.data=e}},nm;try{nm=new TextDecoder}catch{}var Se,En,Z=0,N_=[],am=N_,om=0,Ni={},pt,xn,gr=0,os=0,Zi,Vs,Ii=[],ft,_1={useRecords:!1,mapsAsObjects:!0},U_=class{},F_=new U_;F_.name="MessagePack 0xC1";var Fo=!1,Od=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Se)return W_(()=>(hm(),this?this.unpack(e,t):Od.prototype.unpack.call(_1,e,t)));En=t>-1?t:e.length,Z=0,om=0,os=0,xn=null,am=N_,Zi=null,Se=e;try{ft=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Se=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Od){if(Ni=this,this.structures)return pt=this.structures,Sc();(!pt||pt.length>0)&&(pt=[])}else Ni=_1,(!pt||pt.length>0)&&(pt=[]);return Sc()}unpackMultiple(e,t){let i,r=0;try{Fo=!0;let s=e.length,n=this?this.unpack(e,s):Su.unpack(e,s);if(t){for(t(n);Z<s;)if(r=Z,t(Sc())===!1)return}else{for(i=[n];Z<s;)r=Z,i.push(Sc());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Fo=!1,hm()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Sc(){try{if(!Ni.trusted&&!Fo){let t=pt.sharedLength||0;t<pt.length&&(pt.length=t)}let e=zt();if(Z==En)pt.restoreStructures&&A1(),pt=null,Se=null,Vs&&(Vs=null);else if(Z>En){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Fo)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw pt.restoreStructures&&A1(),hm(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function A1(){for(let e in pt.restoreStructures)pt[e]=pt.restoreStructures[e];pt.restoreStructures=null}function zt(){let e=Se[Z++];if(e<160)if(e<128){if(e<64)return e;{let t=pt[e&63]||Ni.getStructures&&k_()[e&63];return t?(t.read||(t.read=Zg(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,Ni.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[G_()]=zt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(zt(),zt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=zt();return t}else if(e<192){let t=e-160;if(os>=Z)return xn.slice(Z-gr,(Z+=t)-gr);if(os==0&&En<140){let i=t<16?Kg(t):j_(t);if(i!=null)return i}return lm(t)}else{let t;switch(e){case 192:return null;case 193:return Zi?(t=zt(),t>0?Zi[1].slice(Zi.position1,Zi.position1+=t):Zi[0].slice(Zi.position0,Zi.position0-=t)):F_;case 194:return!1;case 195:return!0;case 196:return Np(Se[Z++]);case 197:return t=ft.getUint16(Z),Z+=2,Np(t);case 198:return t=ft.getUint32(Z),Z+=4,Np(t);case 199:return qn(Se[Z++]);case 200:return t=ft.getUint16(Z),Z+=2,qn(t);case 201:return t=ft.getUint32(Z),Z+=4,qn(t);case 202:if(t=ft.getFloat32(Z),Ni.useFloat32>2){let i=Jg[(Se[Z]&127)<<1|Se[Z+1]>>7];return Z+=4,(i*t+(t>0?.5:-.5)>>0)/i}return Z+=4,t;case 203:return t=ft.getFloat64(Z),Z+=8,t;case 204:return Se[Z++];case 205:return t=ft.getUint16(Z),Z+=2,t;case 206:return t=ft.getUint32(Z),Z+=4,t;case 207:return Ni.int64AsNumber?(t=ft.getUint32(Z)*4294967296,t+=ft.getUint32(Z+4)):t=ft.getBigUint64(Z),Z+=8,t;case 208:return ft.getInt8(Z++);case 209:return t=ft.getInt16(Z),Z+=2,t;case 210:return t=ft.getInt32(Z),Z+=4,t;case 211:return Ni.int64AsNumber?(t=ft.getInt32(Z)*4294967296,t+=ft.getUint32(Z+4)):t=ft.getBigInt64(Z),Z+=8,t;case 212:if(t=Se[Z++],t==114)return T1(Se[Z++]&63);{let i=Ii[t];if(i)return i.read?(Z++,i.read(zt())):i.noBuffer?(Z++,i()):i(Se.subarray(Z,++Z));throw new Error("Unknown extension "+t)}case 213:return t=Se[Z],t==114?(Z++,T1(Se[Z++]&63,Se[Z++])):qn(2);case 214:return qn(4);case 215:return qn(8);case 216:return qn(16);case 217:return t=Se[Z++],os>=Z?xn.slice(Z-gr,(Z+=t)-gr):jN(t);case 218:return t=ft.getUint16(Z),Z+=2,os>=Z?xn.slice(Z-gr,(Z+=t)-gr):GN(t);case 219:return t=ft.getUint32(Z),Z+=4,os>=Z?xn.slice(Z-gr,(Z+=t)-gr):VN(t);case 220:return t=ft.getUint16(Z),Z+=2,M1(t);case 221:return t=ft.getUint32(Z),Z+=4,M1(t);case 222:return t=ft.getUint16(Z),Z+=2,E1(t);case 223:return t=ft.getUint32(Z),Z+=4,E1(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var kN=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Zg(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>kN.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(zt);return e.highByte===0&&(e.read=S1(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=zt()}return r}return i.count=0,e.highByte===0?S1(t,i):i}var S1=(e,t)=>function(){let i=Se[Z++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=pt[r]||k_()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=Zg(s,e)),s.read()};function k_(){let e=W_(()=>(Se=null,Ni.getStructures()));return pt=Ni._mergeStructures(e,pt)}var lm=Au,jN=Au,GN=Au,VN=Au;function Au(e){let t;if(e<16&&(t=Kg(e)))return t;if(e>64&&nm)return nm.decode(Se.subarray(Z,Z+=e));let i=Z+e,r=[];for(t="";Z<i;){let s=Se[Z++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Se[Z++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Se[Z++]&63,a=Se[Z++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Se[Z++]&63,a=Se[Z++]&63,o=Se[Z++]&63,l=(s&7)<<18|n<<12|a<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=li.apply(String,r),r.length=0)}return r.length>0&&(t+=li.apply(String,r)),t}function M1(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=zt();return t}function E1(e){if(Ni.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[G_()]=zt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(zt(),zt());return t}}var li=String.fromCharCode;function j_(e){let t=Z,i=new Array(e);for(let r=0;r<e;r++){let s=Se[Z++];if((s&128)>0){Z=t;return}i[r]=s}return li.apply(String,i)}function Kg(e){if(e<4)if(e<2){if(e===0)return"";{let t=Se[Z++];if((t&128)>1){Z-=1;return}return li(t)}}else{let t=Se[Z++],i=Se[Z++];if((t&128)>0||(i&128)>0){Z-=2;return}if(e<3)return li(t,i);let r=Se[Z++];if((r&128)>0){Z-=3;return}return li(t,i,r)}else{let t=Se[Z++],i=Se[Z++],r=Se[Z++],s=Se[Z++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){Z-=4;return}if(e<6){if(e===4)return li(t,i,r,s);{let n=Se[Z++];if((n&128)>0){Z-=5;return}return li(t,i,r,s,n)}}else if(e<8){let n=Se[Z++],a=Se[Z++];if((n&128)>0||(a&128)>0){Z-=6;return}if(e<7)return li(t,i,r,s,n,a);let o=Se[Z++];if((o&128)>0){Z-=7;return}return li(t,i,r,s,n,a,o)}else{let n=Se[Z++],a=Se[Z++],o=Se[Z++],l=Se[Z++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){Z-=8;return}if(e<10){if(e===8)return li(t,i,r,s,n,a,o,l);{let h=Se[Z++];if((h&128)>0){Z-=9;return}return li(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Se[Z++],u=Se[Z++];if((h&128)>0||(u&128)>0){Z-=10;return}if(e<11)return li(t,i,r,s,n,a,o,l,h,u);let c=Se[Z++];if((c&128)>0){Z-=11;return}return li(t,i,r,s,n,a,o,l,h,u,c)}else{let h=Se[Z++],u=Se[Z++],c=Se[Z++],d=Se[Z++];if((h&128)>0||(u&128)>0||(c&128)>0||(d&128)>0){Z-=12;return}if(e<14){if(e===12)return li(t,i,r,s,n,a,o,l,h,u,c,d);{let p=Se[Z++];if((p&128)>0){Z-=13;return}return li(t,i,r,s,n,a,o,l,h,u,c,d,p)}}else{let p=Se[Z++],f=Se[Z++];if((p&128)>0||(f&128)>0){Z-=14;return}if(e<15)return li(t,i,r,s,n,a,o,l,h,u,c,d,p,f);let g=Se[Z++];if((g&128)>0){Z-=15;return}return li(t,i,r,s,n,a,o,l,h,u,c,d,p,f,g)}}}}}function Np(e){return Ni.copyBuffers?Uint8Array.prototype.slice.call(Se,Z,Z+=e):Se.subarray(Z,Z+=e)}function qn(e){let t=Se[Z++];if(Ii[t])return Ii[t](Se.subarray(Z,Z+=e));throw new Error("Unknown extension type "+t)}var C1=new Array(4096);function G_(){let e=Se[Z++];if(e>=160&&e<192){if(e=e-160,os>=Z)return xn.slice(Z-gr,(Z+=e)-gr);if(!(os==0&&En<180))return lm(e)}else return Z--,zt();let t=(e<<5^(e>1?ft.getUint16(Z):e>0?Se[Z]:0))&4095,i=C1[t],r=Z,s=Z+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=ft.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Se[r++],n!=i[a++]){r=1879048192;break}if(r===s)return Z=r,i.string;s-=3,r=Z}for(i=[],C1[t]=i,i.bytes=e;r<s;)n=ft.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Se[r++],i.push(n);let o=e<16?Kg(e):j_(e);return o!=null?i.string=o:i.string=lm(e)}var T1=(e,t)=>{var i=zt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=pt[e];return s&&s.isShared&&((pt.restoreStructures||(pt.restoreStructures=[]))[e]=s),pt[e]=i,i.read=Zg(i,r),i.read()},V_=typeof self=="object"?self:global;Ii[0]=()=>{};Ii[0].noBuffer=!0;Ii[101]=()=>{let e=zt();return(V_[e[0]]||Error)(e[1])};Ii[105]=e=>{let t=ft.getUint32(Z-4);Vs||(Vs=new Map);let i=Se[Z],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Vs.set(t,s);let n=zt();return s.used?Object.assign(r,n):(s.target=n,n)};Ii[112]=e=>{let t=ft.getUint32(Z-4),i=Vs.get(t);return i.used=!0,i.target};Ii[115]=()=>new Set(zt());var H_=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Ii[116]=e=>{let t=e[0],i=H_[t];if(!i)throw new Error("Could not find typed array for code "+t);return new V_[i](Uint8Array.prototype.slice.call(e,1).buffer)};Ii[120]=()=>{let e=zt();return new RegExp(e[0],e[1])};Ii[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=Z;Z+=t-4,Zi=[zt(),zt()],Zi.position0=0,Zi.position1=0;let r=Z;Z=i;try{return zt()}finally{Z=r}};Ii[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function W_(e){let t=En,i=Z,r=om,s=gr,n=os,a=xn,o=am,l=Vs,h=Zi,u=new Uint8Array(Se.slice(0,En)),c=pt,d=pt.slice(0,pt.length),p=Ni,f=Fo,g=e();return En=t,Z=i,om=r,gr=s,os=n,xn=a,am=o,Vs=l,Zi=h,Se=u,Fo=f,pt=c,pt.splice(0,pt.length,...d),Ni=p,ft=new DataView(Se.buffer,Se.byteOffset,Se.byteLength),g}function hm(){Se=null,Vs=null,pt=null}function HN(e){e.unpack?Ii[e.type]=e.unpack:Ii[e.type]=e}var Jg=new Array(147);for(let e=0;e<256;e++)Jg[e]=+("1e"+Math.floor(45.15-e*.30103));var Su=new Od({useRecords:!1}),A9=Su.unpack,S9=Su.unpackMultiple,M9=Su.unpack,WN={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},XN=new Float32Array(1),E9=new Uint8Array(XN.buffer,0,4),sd;try{sd=new TextEncoder}catch{}var Id,$g,Mu=typeof Buffer<"u",Up=Mu?Buffer.allocUnsafeSlow:Uint8Array,X_=Mu?Buffer:Uint8Array,P1=Mu?4294967296:2144337920,le,jt,te=0,Xr,qr=null,qN=/[\u0080-\uFFFF]/,_l=Symbol("record-id"),q_=class extends Od{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=X_.prototype.utf8Write?function(S,_,M){return le.utf8Write(S,_,M)}:sd&&sd.encodeInto?function(S,_){return sd.encodeInto(S,le.subarray(_)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,c=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=c?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),u&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,g=d+64,m=d+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,b=0;this.pack=this.encode=function(S,_){if(le||(le=new Up(8192),jt=new DataView(le.buffer,0,8192),te=0),Xr=le.length-10,Xr-te<2048?(le=new Up(le.length),jt=new DataView(le.buffer,0,le.length),Xr=le.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(qr=["",""],le[te++]=214,le[te++]=98,qr.position=te-i,te+=4):qr=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let M=r.sharedLength||0;if(M>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let T=r[C];if(!T)continue;let P,L=r.transitions;for(let D=0,k=T.length;D<k;D++){let W=T[D];P=L[W],P||(P=L[W]=Object.create(null)),L=P}L[_l]=C+64}o=M}u||(r.nextId=M+64)}s&&(s=!1),n=r||[];try{if(x(S),qr){jt.setUint32(qr.position+i,te-qr.position-i);let M=qr;qr=null,x(M[0]),x(M[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>Xr&&A(te),h.offset=te;let M=QN(le.subarray(i,te),a.idsToInsert);return a=null,M}return _&ZN?(le.start=i,le.end=te,le):le.subarray(i,te)}finally{if(r){if(b<10&&b++,y>1e4)r.transitions=null,b=0,y=0,v.length>0&&(v=[]);else if(v.length>0&&!u){for(let M=0,C=v.length;M<C;M++)v[M][_l]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||d;r.length>M&&(r=r.slice(0,M));let C=le.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=M,C)}}_&KN&&(te=i)}};let x=S=>{te>Xr&&(le=A(te));var _=typeof S,M;if(_==="string"){let C=S.length;if(qr&&C>=8&&C<4096){let L=qN.test(S);qr[L?0:1]+=S,le[te++]=193,x(L?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let P=C*3;if(te+P>Xr&&(le=A(te+P)),C<64||!l){let L,D,k,W=te+T;for(L=0;L<C;L++)D=S.charCodeAt(L),D<128?le[W++]=D:D<2048?(le[W++]=D>>6|192,le[W++]=D&63|128):(D&64512)===55296&&((k=S.charCodeAt(L+1))&64512)===56320?(D=65536+((D&1023)<<10)+(k&1023),L++,le[W++]=D>>18|240,le[W++]=D>>12&63|128,le[W++]=D>>6&63|128,le[W++]=D&63|128):(le[W++]=D>>12|224,le[W++]=D>>6&63|128,le[W++]=D&63|128);M=W-te-T}else M=l(S,te+T,P);M<32?le[te++]=160|M:M<256?(T<2&&le.copyWithin(te+2,te+1,te+1+M),le[te++]=217,le[te++]=M):M<65536?(T<3&&le.copyWithin(te+3,te+2,te+2+M),le[te++]=218,le[te++]=M>>8,le[te++]=M&255):(T<5&&le.copyWithin(te+5,te+3,te+3+M),le[te++]=219,jt.setUint32(te,M),te+=4),te+=M}else if(_==="number")if(S>>>0===S)S<64?le[te++]=S:S<256?(le[te++]=204,le[te++]=S):S<65536?(le[te++]=205,le[te++]=S>>8,le[te++]=S&255):(le[te++]=206,jt.setUint32(te,S),te+=4);else if(S>>0===S)S>=-32?le[te++]=256+S:S>=-128?(le[te++]=208,le[te++]=S+256):S>=-32768?(le[te++]=209,jt.setInt16(te,S),te+=2):(le[te++]=210,jt.setInt32(te,S),te+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){le[te++]=202,jt.setFloat32(te,S);let T;if(C<4||(T=S*Jg[(le[te]&127)<<1|le[te+1]>>7])>>0===T){te+=4;return}else te--}le[te++]=203,jt.setFloat64(te,S),te+=8}else if(_==="object")if(!S)le[te++]=192;else{if(a){let T=a.get(S);if(T){if(!T.id){let P=a.idsToInsert||(a.idsToInsert=[]);T.id=P.push(T)}le[te++]=214,le[te++]=112,jt.setUint32(te,T.id),te+=4;return}else a.set(S,{offset:te-i})}let C=S.constructor;if(C===Object)w(S,!0);else if(C===Array){M=S.length,M<16?le[te++]=144|M:M<65536?(le[te++]=220,le[te++]=M>>8,le[te++]=M&255):(le[te++]=221,jt.setUint32(te,M),te+=4);for(let T=0;T<M;T++)x(S[T])}else if(C===Map){M=S.size,M<16?le[te++]=128|M:M<65536?(le[te++]=222,le[te++]=M>>8,le[te++]=M&255):(le[te++]=223,jt.setUint32(te,M),te+=4);for(let[T,P]of S)x(T),x(P)}else{for(let T=0,P=Id.length;T<P;T++){let L=$g[T];if(S instanceof L){let D=Id[T];if(D.write){D.type&&(le[te++]=212,le[te++]=D.type,le[te++]=0),x(D.write.call(this,S));return}let k=le,W=jt,X=te;le=null;let z;try{z=D.pack.call(this,S,j=>(le=k,k=null,te+=j,te>Xr&&A(te),{target:le,targetView:jt,position:te-j}),x)}finally{k&&(le=k,jt=W,te=X,Xr=le.length-10)}z&&(z.length+te>Xr&&A(z.length+te),te=YN(z,le,te,D.type));return}}w(S,!S.hasOwnProperty)}}else if(_==="boolean")le[te++]=S?195:194;else if(_==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))le[te++]=211,jt.setBigInt64(te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)le[te++]=207,jt.setBigUint64(te,S);else if(this.largeBigIntToFloat)le[te++]=203,jt.setFloat64(te,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(_==="undefined")this.encodeUndefinedAsNil?le[te++]=192:(le[te++]=212,le[te++]=0,le[te++]=0);else if(_==="function")x(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+_)},w=this.useRecords===!1?this.variableMapSize?S=>{let _=Object.keys(S),M=_.length;M<16?le[te++]=128|M:M<65536?(le[te++]=222,le[te++]=M>>8,le[te++]=M&255):(le[te++]=223,jt.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)x(C=_[T]),x(S[C])}:(S,_)=>{le[te++]=222;let M=te-i;te+=2;let C=0;for(let T in S)(_||S.hasOwnProperty(T))&&(x(T),x(S[T]),C++);le[M+++i]=C>>8,le[M+i]=C&255}:S=>{let _=Object.keys(S),M,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let L=0,D=_.length;L<D;L++){let k=_[L];M=C[k],M||(M=C[k]=Object.create(null),T++),C=M}let P=C[_l];if(P)P>=96&&f?(le[te++]=((P-=96)&31)+96,le[te++]=P>>5):le[te++]=P;else{P=n.nextId,P||(P=64),P<g&&this.shouldShareStructure&&!this.shouldShareStructure(_)?(P=n.nextOwnId,P<m||(P=g),n.nextOwnId=P+1):(P>=m&&(P=g),n.nextId=P+1);let L=_.highByte=P>=96&&f?P-96>>5:-1;C[_l]=P,n[P-64]=_,P<g?(_.isShared=!0,n.sharedLength=P-63,s=!0,L>=0?(le[te++]=(P&31)+96,le[te++]=L):le[te++]=P):(L>=0?(le[te++]=213,le[te++]=114,le[te++]=(P&31)+96,le[te++]=L):(le[te++]=212,le[te++]=114,le[te++]=P),T&&(y+=b*T),v.length>=p&&(v.shift()[_l]=0),v.push(C),x(_))}for(let L=0,D=_.length;L<D;L++)x(S[_[L]])},A=S=>{let _;if(S>16777216){if(S-i>P1)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(P1,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(S-i<<2,le.length-1)>>12)+1<<12;let M=new Up(_);return jt=new DataView(M.buffer,0,_),le.copy?le.copy(M,0,i,S):M.set(le.slice(i,S)),te-=i,i=0,Xr=M.length-10,le=M}}useBuffer(e){le=e,jt=new DataView(le.buffer,le.byteOffset,le.byteLength),te=0}};$g=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,U_];Id=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:n,position:a}=t(6);s[a++]=214,s[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:s,targetView:n,position:a}=t(10);s[a++]=215,s[a++]=255,n.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:n,position:a}=t(3);s[a++]=212,s[a++]=255,s[a++]=255}else{let{target:s,targetView:n,position:a}=t(15);s[a++]=199,s[a++]=12,s[a++]=255,n.setUint32(a,e.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(s[n++]=212,s[n++]=115,s[n++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?D1(e,16,t):L1(Mu?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==X_&&this.structuredClone?D1(e,H_.indexOf(i.name),t):L1(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function D1(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:n,position:a}=i(4+s);n[a++]=199,n[a++]=s+1}else if(s+1<65536){var{target:n,position:a}=i(5+s);n[a++]=200,n[a++]=s+1>>8,n[a++]=s+1&255}else{var{target:n,position:a,targetView:o}=i(7+s);n[a++]=201,o.setUint32(a,s+1),a+=4}n[a++]=116,n[a++]=t,n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a)}function L1(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:n}=t(i+5);r[s++]=198,n.setUint32(s,i),s+=4}r.set(e,s)}function YN(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function QN(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);i=t.pop();){let n=i.offset,a=i.id;e.copyWithin(n+r,n,s),r-=6;let o=n+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,s=n}return e}function tl(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");$g.unshift(e.Class),Id.unshift(e)}HN(e)}var Y_=new q_({useRecords:!1}),C9=Y_.pack,T9=Y_.pack,{NEVER:P9,ALWAYS:D9,DECIMAL_ROUND:L9,DECIMAL_FIT:O9}=WN,ZN=512,KN=1024,O1=new q_({structuredClone:!0});tl({Class:Qt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Qt.prototype),e}});tl({Class:rt.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,rt.prototype),e}});tl({Class:ji.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,ji.prototype),e}});tl({Class:b1.prototype.constructor,type:4,write(e){return e.id},read(e){return new b1(e)}});tl({Class:w1.prototype.constructor,type:5,write(e){return e.data},read(e){return new w1(e)}});tl({Class:mi.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,mi.prototype),e}});function JN(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function cm(e){if(Wg(e))return e;if(Array.isArray(e))return e.map(cm);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=cm(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var dm;(e=>{function t(s){return O1.pack(s)}e.serialize=t;function i(s){return O1.unpack(s)}e.deserialize=i;function r(s){return JN(t(cm(s))).toString()}e.checksum=r})(dm||(dm={}));var Al={LookAt:[],Follow:[],MouseHover:["Transition"],Scroll:["Transition"],Start:["Transition","Audio","Video"],Conditional:["Transition","Audio","Video"],MouseDown:["Transition","Audio","Video","Link","Reset"],MouseUp:["Transition","Audio","Video","Link","Reset"],MousePress:["Transition","Audio","Video","Link","Reset"],KeyDown:["Transition","Audio","Video","Link","Reset"],KeyUp:["Transition","Audio","Video","Link","Reset"],KeyPress:["Transition","Audio","Video","Link","Reset"],GameControl:["Transition","Audio"],Collision:["Transition","Audio"]},I1;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,disabled:!1,toggle:!1,actions:new rt}:{type:r,disabled:!1,key:void 0,toggle:!1,actions:new rt}}e.defaultData=i})(I1||(I1={}));var Rd;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Rd||(Rd={}));var um;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Rd.propertyDefaultData(s),rOperand:{...Rd.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,n){return{type:"State",object:s??null,state:n??null}}e.stateDefaultData=r})(um||(um={}));var R1;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new rt,outActions:new rt,condition:um.distanceDefaultData(r)}}e.defaultData=i})(R1||(R1={}));var pm;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(pm||(pm={}));var fm;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(fm||(fm={}));var B1;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new rt}}e.defaultData=i})(B1||(B1={}));var z1;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new rt}}e.defaultData=i})(z1||(z1={}));var N1;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new rt}}e.defaultData=i})(N1||(N1={}));var U1;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new rt}}e.defaultData=i})(U1||(U1={}));var mo;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n]}e.lerp=i})(mo||(mo={}));var ma;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function n(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=n;function a(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=a;function o(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]}e.lerp=o})(ma||(ma={}));var Bd;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n,r[2]+(s[2]-r[2])*n,r[3]+(s[3]-r[3])*n]}e.lerp=i})(Bd||(Bd={}));var ko;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,n){for(let a=0;a<16;a++)if(s[a]!==n[a])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,n){let a=n.slice(0);for(var o=0,l=n.length;o<l;o+=3){let h=s[3]*n[o]+s[7]*n[o+1]+s[11]*n[o+2]+s[15];a[o]=(s[0]*n[o]+s[4]*n[o+1]+s[8]*n[o+2]+s[12])/h,a[o+1]=(s[1]*n[o]+s[5]*n[o+1]+s[9]*n[o+2]+s[13])/h,a[o+2]=(s[2]*n[o]+s[6]*n[o+1]+s[10]*n[o+2]+s[14])/h}return a}e.applyMatrix4=r})(ko||(ko={}));var $i;(e=>{function t(o){return typeof o=="object"&&typeof o.r=="number"&&typeof o.g=="number"&&typeof o.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(o){return{r:Math.round(o.r*255),g:Math.round(o.g*255),b:Math.round(o.b*255),a:1}}e.toRgb255a1=i;function r(o){return{r:o.r,g:o.g,b:o.b}}e.clone=r;function s(o){return o=Math.floor(o),{r:(o>>16&255)/255,g:(o>>8&255)/255,b:(o&255)/255}}e.fromHex=s;function n(o,l){return o.r===l.r&&o.g===l.g&&o.b===l.b}e.equals=n;function a(o,l,h){return{r:o.r+(l.r-o.r)*h,g:o.g+(l.g-o.g)*h,b:o.b+(l.b-o.b)*h}}e.lerp=a})($i||($i={}));var kr;(e=>{e.white={...$i.white,a:1},e.transparent={...$i.white,a:0};function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}e.from0to1=t;function i(a,o){return{...$i.fromHex(a),a:o}}e.fromHexAndA=i;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}e.toRgb255a1=r;function s(a,o){return $i.equals(a,o)&&a.a===o.a}e.equals=s;function n(a,o,l){return{r:a.r+(o.r-a.r)*l,g:a.g+(o.g-a.g)*l,b:a.b+(o.b-a.b)*l,a:a.a+(o.a-a.a)*l}}e.lerp=n})(kr||(kr={}));var mm;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(mm||(mm={}));var F1;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(F1||(F1={}));var k1;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(k1||(k1={}));var _a;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(_a||(_a={}));var bh;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(bh||(bh={}));var bn;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(n=>n*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let n={...r};if(Q_.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;Z_.forEach(l=>{Object.assign(n.radial,{[l]:o[l]??a[l]})})}if(n.linear={...r.linear},s.linear){let a=r.linear,o=s.linear;K_.forEach(l=>{Object.assign(n.linear,{[l]:o[l]??a[l]})})}if(n.grid={...r.grid},s.grid){let a=r.grid,o=s.grid;J_.forEach(l=>{Object.assign(n.grid,{[l]:o[l]??a[l]})})}if(n.toObject={...r.toObject},s.toObject){let a=r.toObject,o=s.toObject;$_.forEach(l=>{Object.assign(n.toObject,{[l]:o[l]??a[l]})})}if(n.randomnessObject={...r.randomnessObject},s.randomnessObject){let a=r.randomnessObject,o=s.randomnessObject;eA.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(bn||(bn={}));var gm;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of t){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}e.toOps=i})(gm||(gm={}));var Q_=["count"],Z_=["radius","start","end","position","scale","rotation"],K_=["position","scale","rotation"],J_=["count","size"],$_=["count","position","scale","rotation"],eA=["strength","scale","rotation","position","movement","seed","freqScale"],wh;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focalLength:2,focusDistance:2,bokehScale:2},noise:{...t,blendFunction:16}}})(wh||(wh={}));var vm;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(vm||(vm={}));var ym;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:kr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(r==="SpotLight")return{type:r,color:kr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:kr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(ym||(ym={}));var xm;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(xm||(xm={}));var bm;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(bm||(bm={}));var wm;(e=>e.defaultData={...bm.defaultData,...xm.defaultData})(wm||(wm={}));var zd;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(zd||(zd={}));var j1;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="transmission"||i==="matcap"||i==="displace"||i==="light"}e.is=t})(j1||(j1={}));var G1;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(G1||(G1={}));var tA=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],$N=["wrapping","image","video"],xr;(e=>{function t(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let h=n.texture;h&&Object.assign(h,o)}}e.patch=t;function i(n,a){return n==="light"&&a?r(a):s(n)}e.defaultData=i;function r(n){switch(n){case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",alpha:.6,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function s(n){switch(n){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"video",projection:0,texture:{video:zd.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:$i.fromHex(5526619)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...$i.fromHex(6710886),a:1},colorB:{...$i.fromHex(6710886),a:1},colorC:{...$i.fromHex(16777215),a:1},colorD:{...$i.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:kr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:kr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:kr.fromHexAndA(0,1),contourColor:kr.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(xr||(xr={}));var nr;(e=>{function t(h){return!h.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(h){let u="";return h.layers.forEach(c=>{Object.entries(c.data).forEach(([d,p])=>{u+=`${d}${p}`,Array.isArray(p)?p.forEach(f=>u+=`${f}`):typeof p=="object"?Object.values(p).forEach(f=>{typeof f=="number"?u+=`${f.toFixed(4)}`:u+=`${f}`}):u+=`${p}`})}),u}e.getHash=i;function r(){return{layers:new rt}}e.defaultEmptyData=r;function s(h="layer1",u="layer2"){return a("phong",h,u)}e.defaultData=s;function n(h,u){return{...h,name:u}}e.withName=n;function a(h,u="layer1",c="layer2"){let d=new rt;return d.push({fi:0,data:xr.defaultData("light",h),id:u}),d.push({fi:1,data:xr.defaultData("color"),id:c}),{layers:d}}e.defaultTwoLayerData=a;function o(h,u="phong",c="layer1",d="layer2"){let p=xr.defaultData("texture");Object.assign(p.texture,{image:h});let f=new rt;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:xr.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,u="phong",c="layer1",d="layer2"){let p=xr.defaultData("video");Object.assign(p.texture,{video:h});let f=new rt;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:xr.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(nr||(nr={}));var Nd;(e=>{function t(){return{points:new rt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Nd||(Nd={}));var Ud;(e=>{function t(){return{points:new rt,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Ud||(Ud={}));var iA={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0},_m;(e=>{function t(i,r){let s={...i};return sA.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(_m||(_m={}));var rA={shape:iA,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},sA=["depth","offset","angle","twist","startScale","endScale"],Fd;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})(Fd||(Fd={}));var Am;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,_m.merge(s.extrusion,r.extrusion))),s}e.merge=t})(Am||(Am={}));var So;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:Ud.defaultData(),extrusion:rA};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Nd.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};throw new Error("not implemented")}e.defaultData=t})(So||(So={}));var V1=["width","height","depth"],H1;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(H1||(H1={}));var jo;(e=>{e.identity={...mm.identity,hiddenMatrix:ko.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,n){return{position:n?.position||s.position,rotation:n?.rotation||s.rotation,scale:n?.scale||s.scale,hiddenMatrix:n?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,n){return{position:ma.isEqual(s.position,n.position)?null:n.position,rotation:ma.isEqual(s.rotation,n.rotation)?null:n.rotation,scale:ma.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:ko.isEqual(s.hiddenMatrix,n.hiddenMatrix)?null:n.hiddenMatrix}}e.diff=r})(jo||(jo={}));var Sm;(e=>e.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Sm||(Sm={}));var Ar;(e=>e.defaultData={states:new rt,events:new rt,visible:!0,raycastLock:!1,physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...jo.identity,cloner:null})(Ar||(Ar={}));var W1;(e=>e.defaultData={type:"Empty",...Ar.defaultData})(W1||(W1={}));var X1;(e=>e.defaultData={type:"Component",...Ar.defaultData})(X1||(X1={}));var Mo;(e=>e.defaultData={type:"Mesh",...Ar.defaultData,...wm.defaultData})(Mo||(Mo={}));var kd;(e=>e.defaultData={...Ar.defaultData,...jo.identity,...bh.defaultData})(kd||(kd={}));var Mm;(e=>{function t(i){return{...Ar.defaultData,...ym.defaultData(i)}}e.defaultData=t})(Mm||(Mm={}));var jd;(e=>{function t(r,s,n=0){for(;n<s.length;){let a=r?r[s[n]]:void 0;if(s.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=t;function i(r,s,n=0){let a=t(r,s,n);if(a){let o=Object.keys(a);if(o.length===1&&o[0]==="descendants")return}return a}e.resolve=i})(jd||(jd={}));var Go;(e=>{e.rootOverrideProps=["physics"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Ar.defaultData,...s,component:r,overrides:new mi,physics:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=jo.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Go||(Go={}));var Em;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:ko.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Sm.defaultData,states:new rt,events:new rt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...bh.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Ar.defaultData,...Mo.defaultData,geometry:So.defaultData("RectangleGeometry"),material:nr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Ar.defaultData,...Mo.defaultData,geometry:So.defaultData("BooleanGeometry"),material:nr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Ar.defaultData,...Mo.defaultData,geometry:So.defaultData("TextGeometry"),material:nr.defaultTwoLayerData("phong","layer1","layer2")}))(Em||(Em={}));var oa;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new mi}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new mi})))):_a.is(n.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(n,a){if(a===void 0)return n;let o={...n};return"material"in o&&"material"in a&&a.material&&(o.material=Ld(o.material,l=>{if(typeof l!="string")for(let[h,u]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&xr.patch(c,u)}}).data),o.materials&&a.materials&&(o.materials=Ld(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let u=a.materials[h];if(typeof u!="string")for(let[c,d]of Object.entries(u.layers)){let p=l[h]?.layers?.data(c);p&&xr.patch(p,d)}}}).data),o}function r(n,a){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function u(c,d){for(let[p,f]of Object.entries(d.layers)){let{texture:g,...m}=f;if(g!==void 0&&Object.keys(g).length>0){let v={path:[...c,"layers",p,"texture"],props:g,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...c,"layers",p],props:m,type:0};l.push(v)}}}for(let[c,d]of Object.entries(a))if(c!=="name")if(c==="cloner")l.push(...gm.toOps(d,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:d.slide,offset:d.offset},type:0});else if(c==="material")u(["material"],d);else if(c==="materials")for(let[p,f]of Object.entries(d))u(["materials",p],f);else if(h[c]===0){if(c==="geometry"&&d.extrusion!==void 0){let p={path:[c,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[c],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=d;return l}e.toOps=r;function s(n,a){if(a===void 0)return n;let o={...n};if(Object.assign(o,jo.merge(o,a)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:a.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??o.pathSnapping?.offset??0})}),_a.is(n.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=a;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(n.type==="Mesh")"geometry"in a&&Object.assign(o,{geometry:Am.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:bn.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:bn.merge(o.cloner,a.cloner)});else if(vm.is(n.type)){let l=a;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=$i.clone(l.color))}return o}e.patch=s})(oa||(oa={}));var Gd;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:$i.white,near:.1,far:2e3})(Gd||(Gd={}));var Vd;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(Vd||(Vd={}));var Vo;(e=>e.defaultData={orbitControls:Vd.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:typeof window<"u"?Math.floor(window.devicePixelRatio):1,stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),gameControlObject:null})(Vo||(Vo={}));function Aa(e,t){return Object.setPrototypeOf(e,t),e}var eU=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),tU=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),iU=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Eu&&"ontouchend"in document,rU=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,sU=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,nU=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},aU=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},I9=eU(),Eu=tU(),Cm=iU(),oU=rU(),rr=sU(),q1=nU(),Y1=Number(aU());function nA(e){return Array.isArray(e)?e:[e]}function lU(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Mc(e){return Eu?e.metaKey:e.ctrlKey}var Qe=[],Hd={},Hl={},nd={};function aA(e){Qe.includes(e)||Qe.push(e)}function Eo(e){delete Hd[e.pointerId];for(let t=0;t<Qe.length;t++)if(Qe[t].pointerId===e.pointerId){Qe.splice(t,1);break}}function hU(){Qe.splice(0,Qe.length)}function Wd(e){if(e.pointerType!=="touch")return;let t=Hd[e.pointerId];t===void 0&&(t={x:0,y:0},Hd[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Fp(e){let t=e.pointerId===Qe[0].pointerId?Qe[1]:Qe[0];return Hd[t.pointerId]}function oA(e){Hl[e.key]=!0,nd[e.key]=nd[e.key]===void 0?1:nd[e.key]+1}function lA(e){if(Eu&&Hl.Meta)for(let t in Hl)Hl[t]=!1;else Hl[e.key]=!1;nd={}}function cU(e){e.addEventListener("pointerdown",aA,!0),e.addEventListener("pointerdown",Wd,!0),e.addEventListener("pointermove",Wd,!0),e.addEventListener("pointerup",Eo,!0),e.addEventListener("pointercancel",Eo,!0),e.addEventListener("pointerleave",Eo,!0),window.addEventListener("keydown",oA,!0),window.addEventListener("keyup",lA,!0)}function dU(e){e.removeEventListener("pointerdown",aA,!0),e.removeEventListener("pointerdown",Wd,!0),e.removeEventListener("pointermove",Wd,!0),e.removeEventListener("pointerup",Eo,!0),e.removeEventListener("pointercancel",Eo,!0),e.removeEventListener("pointerleave",Eo,!0),window.removeEventListener("keydown",oA,!0),window.removeEventListener("keyup",lA,!0)}var Ki;(e=>e.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(Ki||(Ki={}));var Tm;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=new ji,a=Em.defaultMeshObject;return s.withLight===!0&&n.push({fi:-1,data:{...Mm.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]}),n}e.defaultData={backgroundColor:kr.fromHexAndA(2960946,1),postprocessing:wh.defaultData,fog:Gd.defaultData,objects:t(),environment:Ki.defaultData,publish:Vo.defaultData},e.emptyData=function(s){return{backgroundColor:kr.fromHexAndA(2960946,1),postprocessing:wh.defaultData,fog:Gd.defaultData,objects:s?t(s):new ji,environment:Ki.defaultData,publish:Vo.defaultData}};function i(s){return{...e.defaultData,objects:Aa(s,ji.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(Tm||(Tm={}));var Xd;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Xd||(Xd={}));var qd;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Aa(s,Qt.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Xd.emptyImage,name:"AI generated image"}),Aa(n,Qt.prototype)}e.defaultImages=i;function r(){return{materials:new Qt,images:new Qt,videos:new Qt,colors:new Qt,audios:new Qt,fonts:new Qt,penumbraSize:[2,2,2]}}e.emptyData=r})(qd||(qd={}));function Q1(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...vh(Si(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...Si(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function ad(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function od(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach(s=>{typeof s!="string"&&t(s)}):"material"in r&&typeof r.material!="string"&&t(r.material)})}function uU(e){Object.assign(e.scene.publish,{orbitControls:{...Vd.defaultData,...Si(e.scene.publish.orbitControls)}})}function pU(e){Object.assign(e.scene.publish.settings,{video:{...Vo.defaultData.settings.video,...Si(e.scene.publish.settings.video)}})}function fU(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,n]of Object.entries(r))if((tA.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))($N.includes(a)||typeof o=="boolean")&&delete n[a]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let n=s;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function mU(e){e.scene.publish.withBackground=!0}function gU(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function vU(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function yU(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function xU(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=Si(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Si(i).booleanExclude!==!0)}})}function bU(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function wU(e){function t(r){Object.setPrototypeOf(r,mi.prototype),r.texture&&Object.setPrototypeOf(r.texture,mi.prototype)}function i(r){Object.setPrototypeOf(r,mi.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(n=>{let a=n;if(a.material){let o=Si(a.material).layers;i(o),a.material.layers=o}if(a.materials)for(let o=0;o<a.materials.length;o++){let l=a.materials[o],h=Si(l).layers;i(h),l.layers=h}})})}function Z1(e){e.layers===void 0&&Object.assign(e,nr.defaultTwoLayerData("lambert"))}function kp(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...Si(t),colors:i,steps:r};Object.assign(t,s)}})}function _U(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function K1(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&kp(r)}):"material"in i&&typeof i.material!="string"&&kp(i.material)}),Object.values(e.shared.materials).forEach(t=>kp(t))}function AU(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function SU(e){e.shared.audios=Aa({},Qt.prototype)}function MU(e){e.shared.videos=Aa({},Qt.prototype)}function EU(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function CU(e){Object.entries(Si(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Si(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function TU(e){e.scene.publish.settings.web.preload=!1}function J1(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function PU(e){e.shared.fonts=Aa({},Qt.prototype)}function DU(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function LU(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=nr.defaultTwoLayerData("phong"),a=typeof s.color=="string"?e.shared.colors[s.color]:s.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=s.alpha;let o=DU(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Ar.defaultData,...Mo.defaultData,flatShading:!1,wireframe:!1,geometry:{...So.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:n,states:Si(s.states),events:Si(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=Si(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function OU(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new rt,move:new rt,jump:new rt}});else{let n=new rt;Object.assign(s,{actions:n}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&n.push({fi:0,id:it.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((a,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(u,vh(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let c={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},d={state:a.state,...c,...u},p={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new rt({fi:0,id:it.generateUUID(),data:h},{fi:1,id:it.generateUUID(),data:d})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function IU(e){e.scene.objects.traverse((t,i)=>{function r(s,n){let a=new rt,o=[];if(i.events.forEach((l,h,u)=>{if(l.type==="Audio"&&l.trigger===n){let c;o.push(h),l.interaction==="play"?c={...vh(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...vh(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&a.push({fi:u,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),a.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):i.events.insertBefore(null,[{id:it.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function $1(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=xr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function ex(e){ad(e,$1),od(e,$1)}function RU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function BU(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function zU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=nr.defaultTwoLayerData("phong"))})}function NU(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function UU(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function FU(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function kU(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function jU(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}var tx=36;function GU(e){let t=e.schema??0;t!==tx&&(console.warn("updating from ",t,"to ",tx),t<1&&(od(e,Q1),ad(e,Q1),e.schema=1),t<2&&(uU(e),e.schema=2),t<3&&(fU(e),e.schema=3),t<4&&(mU(e),e.schema=4),t<5&&(gU(e),e.schema=5),t<6&&(vU(e),e.schema=6),t<7&&(yU(e),e.schema=7),t<8&&(e.schema=8),t<9&&(K1(e),e.schema=9),t<10&&(_U(e),e.schema=10),t<11&&(AU(e),e.schema=11),t<12&&(K1(e),e.schema=12),t<13&&(SU(e),e.schema=13),t<14&&(EU(e),e.schema=14),t<15&&(CU(e),e.schema=15),t<16&&(TU(e),e.schema=16),t<17&&(od(e,J1),ad(e,J1),e.schema=17),t<18&&(od(e,Z1),ad(e,Z1),e.schema=18),t<19&&(pU(e),e.schema=19),t<20&&(PU(e),LU(e),e.schema=20),t<21&&(OU(e),IU(e),e.schema=21),t<22&&(ex(e),e.schema=22),t<23&&(RU(e),e.schema=23),t<24&&(BU(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(MU(e),t<25&&(e.schema=25)),t<26&&(xU(e),e.schema=26),t<27&&(bU(e),e.schema=27),t<28&&(ex(e),e.schema=28),t<29&&(wU(e),e.schema=29),t<30&&(zU(e),e.schema=30),t<31&&(NU(e),e.schema=31),t<33&&(UU(e),e.schema=33),t<34&&(FU(e),e.schema=34),t<35&&(kU(e),e.schema=35),t<36&&(jU(e),e.schema=36))}function go(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),n={},a={},o=e[0].morphTargetsRelative,l=new Ve,h=0;for(let u=0;u<e.length;++u){let c=e[u],d=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in c.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(c.attributes[p]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in c.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.morphAttributes[p])}if(t){let p;if(i)p=c.index.count;else if(c.attributes.position!==void 0)p=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,u),h+=p}}if(i){let u=0,c=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)c.push(p.getX(f)+u);u+=e[d].attributes.position.count}l.setIndex(c)}for(let u in n){let c=ix(n[u]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,c)}for(let u in a){let c=a[u][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<c;++d){let p=[];for(let g=0;g<a[u].length;++g)p.push(a[u][g][d]);let f=ix(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(f)}}return l}function ix(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let n=new t(s),a=0;for(let o=0;o<e.length;++o)n.set(e[o].array,a),a+=e[o].array.length;return new Xe(n,i,r)}var Pm;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new rt,move:new rt,jump:new rt}}))(Pm||(Pm={}));var VU=Math.pow(2,-24),Ec=class{constructor(){}};function ls(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function rx(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function sx(e,t){t.set(e)}function nx(e,t,i){let r,s;for(let n=0;n<3;n++){let a=n+3;r=e[n],s=t[n],i[n]=r<s?r:s,r=e[a],s=t[a],i[a]=r>s?r:s}}function Cc(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],n=t[e+2*r+1],a=s-n,o=s+n;a<i[r]&&(i[r]=a),o>i[r+3]&&(i[r+3]=o)}}function Sl(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function HU(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new Xe(s,1));for(let n=0;n<i;n++)s[n]=n}}function WU(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,n)=>s-n);for(let s=0;s<r.length-1;s++){let n=r[s],a=r[s+1];t.push({offset:n/3,count:(a-n)/3})}return t}function jp(e,t,i,r,s=null){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0,c=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0,v=s!==null;for(let y=t*6,b=(t+i)*6;y<b;y+=6){let x=e[y+0],w=e[y+1],A=x-w,S=x+w;A<n&&(n=A),S>l&&(l=S),v&&x<c&&(c=x),v&&x>f&&(f=x);let _=e[y+2],M=e[y+3],C=_-M,T=_+M;C<a&&(a=C),T>h&&(h=T),v&&_<d&&(d=_),v&&_>g&&(g=_);let P=e[y+4],L=e[y+5],D=P-L,k=P+L;D<o&&(o=D),k>u&&(u=k),v&&P<p&&(p=P),v&&P>m&&(m=P)}r[0]=n,r[1]=a,r[2]=o,r[3]=l,r[4]=h,r[5]=u,v&&(s[0]=c,s[1]=d,s[2]=p,s[3]=f,s[4]=g,s[5]=m)}function XU(e,t,i,r){let s=1/0,n=1/0,a=1/0,o=-1/0,l=-1/0,h=-1/0;for(let u=t*6,c=(t+i)*6;u<c;u+=6){let d=e[u+0];d<s&&(s=d),d>o&&(o=d);let p=e[u+2];p<n&&(n=p),p>l&&(l=p);let f=e[u+4];f<a&&(a=f),f>h&&(h=f)}r[0]=s,r[1]=n,r[2]=a,r[3]=o,r[4]=l,r[5]=h}function qU(e,t,i,r,s){let n=i,a=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;n<=a&&t[n*6+l]<o;)n++;for(;n<=a&&t[a*6+l]>=o;)a--;if(n<a){for(let h=0;h<3;h++){let u=e[n*3+h];e[n*3+h]=e[a*3+h],e[a*3+h]=u;let c=t[n*6+h*2+0];t[n*6+h*2+0]=t[a*6+h*2+0],t[a*6+h*2+0]=c;let d=t[n*6+h*2+1];t[n*6+h*2+1]=t[a*6+h*2+1],t[a*6+h*2+1]=d}n++,a--}else return n}}var Us=32,YU=(e,t)=>e.candidate-t.candidate,rn=new Array(Us).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Tc=new Float32Array(6);function QU(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=rx(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=rx(e),a!==-1&&(o=ZU(i,r,s,a));else if(n===2){let l=Sl(e),h=1.25*s,u=r*6,c=(r+s)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/Us;if(s<Us/4){let g=[...rn];g.length=s;let m=0;for(let y=u;y<c;y+=6,m++){let b=g[m];b.candidate=i[y+2*d],b.count=0;let{bounds:x,leftCacheBounds:w,rightCacheBounds:A}=b;for(let S=0;S<3;S++)A[S]=1/0,A[S+3]=-1/0,w[S]=1/0,w[S+3]=-1/0,x[S]=1/0,x[S+3]=-1/0;Cc(y,i,x)}g.sort(YU);let v=s;for(let y=0;y<v;y++){let b=g[y];for(;y+1<v&&g[y+1].candidate===b.candidate;)g.splice(y+1,1),v--}for(let y=u;y<c;y+=6){let b=i[y+2*d];for(let x=0;x<v;x++){let w=g[x];b>=w.candidate?Cc(y,i,w.rightCacheBounds):(Cc(y,i,w.leftCacheBounds),w.count++)}}for(let y=0;y<v;y++){let b=g[y],x=b.count,w=s-b.count,A=b.leftCacheBounds,S=b.rightCacheBounds,_=0;x!==0&&(_=Sl(A)/l);let M=0;w!==0&&(M=Sl(S)/l);let C=1+1.25*(_*x+M*w);C<h&&(a=d,h=C,o=b.candidate)}}else{for(let v=0;v<Us;v++){let y=rn[v];y.count=0,y.candidate=p+f+v*f;let b=y.bounds;for(let x=0;x<3;x++)b[x]=1/0,b[x+3]=-1/0}for(let v=u;v<c;v+=6){let y=~~((i[v+2*d]-p)/f);y>=Us&&(y=Us-1);let b=rn[y];b.count++,Cc(v,i,b.bounds)}let g=rn[Us-1];sx(g.bounds,g.rightCacheBounds);for(let v=Us-2;v>=0;v--){let y=rn[v],b=rn[v+1];nx(y.bounds,b.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<Us-1;v++){let y=rn[v],b=y.count,x=y.bounds,w=rn[v+1].rightCacheBounds;b!==0&&(m===0?sx(x,Tc):nx(x,Tc,Tc)),m+=b;let A=0,S=0;m!==0&&(A=Sl(Tc)/l);let _=s-m;_!==0&&(S=Sl(w)/l);let M=1+1.25*(A*m+S*_);M<h&&(a=d,h=M,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:a,pos:o}}function ZU(e,t,i,r){let s=0;for(let n=t,a=t+i;n<a;n++)s+=e[n*6+r*2];return s/i}function KU(e,t){let i=e.attributes.position,r=i.array,s=e.index.array,n=s.length/3,a=new Float32Array(n*6),o=i.offset||0,l=3;i.isInterleavedBufferAttribute&&(l=i.data.stride);for(let h=0;h<n;h++){let u=h*3,c=h*6,d=s[u+0]*l+o,p=s[u+1]*l+o,f=s[u+2]*l+o;for(let g=0;g<3;g++){let m=r[d+g],v=r[p+g],y=r[f+g],b=m;v<b&&(b=v),y<b&&(b=y);let x=m;v>x&&(x=v),y>x&&(x=y);let w=(x-b)/2,A=g*2;a[c+A+0]=b+w,a[c+A+1]=w+(Math.abs(b)+w)*VU,b<t[g]&&(t[g]=b),x>t[g+3]&&(t[g+3]=x)}}return a}function JU(e,t){function i(v){d&&d(v/p)}function r(v,y,b,x=null,w=0){if(!f&&w>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=u||w>=l)return i(y+b),v.offset=y,v.count=b,v;let A=QU(v.boundingData,x,a,y,b,c);if(A.axis===-1)return i(y+b),v.offset=y,v.count=b,v;let S=qU(o,a,y,b,A);if(S===y||S===y+b)i(y+b),v.offset=y,v.count=b;else{v.splitAxis=A.axis;let _=new Ec,M=y,C=S-y;v.left=_,_.boundingData=new Float32Array(6),jp(a,M,C,_.boundingData,n),r(_,M,C,n,w+1);let T=new Ec,P=S,L=b-C;v.right=T,T.boundingData=new Float32Array(6),jp(a,P,L,T.boundingData,n),r(T,P,L,n,w+1)}return v}HU(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=KU(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,u=t.maxLeafTris,c=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,g=[],m=WU(e);if(m.length===1){let v=m[0],y=new Ec;y.boundingData=s,XU(a,v.offset,v.count,n),r(y,v.offset,v.count,n),g.push(y)}else for(let v of m){let y=new Ec;y.boundingData=new Float32Array(6),jp(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),g.push(y)}return g}function $U(e,t){let i=JU(e,t),r,s,n,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<i.length;u++){let c=i[u],d=l(c),p=new o(32*d);r=new Float32Array(p),s=new Uint32Array(p),n=new Uint16Array(p),h(0,c),a.push(p)}return a;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function h(u,c){let d=u/4,p=u/2,f=!!c.count,g=c.boundingData;for(let m=0;m<6;m++)r[d+m]=g[m];if(f){let m=c.offset,v=c.count;return s[d+6]=m,n[p+14]=v,n[p+15]=65535,u+32}else{let m=c.left,v=c.right,y=c.splitAxis,b;if(b=h(u+32,m),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[d+6]=b/4,b=h(b,v),s[d+7]=y,b}}}var bs=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,n=e.length;s<n;s++){let a=e[s][t];i=a<i?a:i,r=a>r?a:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,n=t.length;s<n;s++){let a=t[s],o=e.dot(a);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};bs.prototype.setFromBox=function(){let e=new E;return function(t,i){let r=i.min,s=i.max,n=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let u=t.dot(e);n=Math.min(u,n),a=Math.max(u,a)}this.min=n,this.max=a}}();var R9=function(){let e=new bs;return function(t,i){let r=t.points,s=t.satAxes,n=t.satBounds,a=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let u=n[h],c=s[h];if(e.setFromPoints(c,a),u.isSeparated(e))return!1}for(let h=0;h<3;h++){let u=l[h],c=o[h];if(e.setFromPoints(c,r),u.isSeparated(e))return!1}}}(),eF=function(){let e=new E,t=new E,i=new E;return function(r,s,n){let a=r.start,o=e,l=s.start,h=t;i.subVectors(a,l),e.subVectors(r.end,s.start),t.subVectors(s.end,s.start);let u=i.dot(h),c=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-c*c,g,m;f!==0?g=(u*c-p*d)/f:g=0,m=(u+g*c)/d,n.x=g,n.y=m}}(),ev=function(){let e=new G,t=new E,i=new E;return function(r,s,n,a){eF(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,n),s.at(l,a);return}else if(o>=0&&o<=1){l<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,n);return}else if(l>=0&&l<=1){o<0?r.at(0,n):r.at(1,n),s.closestPointToPoint(n,!0,a);return}else{let h;o<0?h=r.start:h=r.end;let u;l<0?u=s.start:u=s.end;let c=t,d=i;if(r.closestPointToPoint(u,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(u)<=d.distanceToSquared(h)){n.copy(c),a.copy(u);return}else{n.copy(h),a.copy(d);return}}}}(),tF=function(){let e=new E,t=new E,i=new yr,r=new _r;return function(s,n){let{radius:a,center:o}=s,{a:l,b:h,c:u}=n;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a||(r.start=l,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a)||(r.start=h,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a))return!0;let c=n.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=a){let d=c.projectPoint(o,t);if(n.containsPoint(d))return!0}return!1}}(),iF=1e-15;function Qa(e){return Math.abs(e)<iF}var Xs=class extends zi{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new bs),this.points=[this.a,this.b,this.c],this.sphere=new Mr,this.plane=new yr,this.needsUpdate=!0}intersectsSphere(e){return tF(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,n=this.satBounds,a=s[0],o=n[0];this.getNormal(a),o.setFromPoints(a,r);let l=s[1],h=n[1];l.subVectors(e,t),h.setFromPoints(l,r);let u=s[2],c=n[2];u.subVectors(t,i),c.setFromPoints(u,r);let d=s[3],p=n[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};Xs.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new _r;return function(r,s=null,n=null){let{start:a,end:o}=r,l=this.points,h,u=1/0;for(let c=0;c<3;c++){let d=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[d]),ev(i,r,e,t),h=e.distanceToSquared(t),h<u&&(u=h,s&&s.copy(e),n&&n.copy(t))}return this.closestPointToPoint(a,e),h=a.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),n&&n.copy(a)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),n&&n.copy(o)),Math.sqrt(u)}}();Xs.prototype.intersectsTriangle=function(){let e=new Xs,t=new Array(3),i=new Array(3),r=new bs,s=new bs,n=new E,a=new E,o=new E,l=new E,h=new _r,u=new _r,c=new _r;return function(d,p=null){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let f=this.plane,g=d.plane;if(Math.abs(f.normal.dot(g.normal))>1-1e-10){let m=this.satBounds,v=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let x=0;x<4;x++){let w=m[x],A=v[x];if(r.setFromPoints(A,i),w.isSeparated(r))return!1}let y=d.satBounds,b=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let x=0;x<4;x++){let w=y[x],A=b[x];if(r.setFromPoints(A,t),w.isSeparated(r))return!1}for(let x=0;x<4;x++){let w=v[x];for(let A=0;A<4;A++){let S=b[A];if(n.crossVectors(w,S),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let m=this.points,v=!1,y=0;for(let P=0;P<3;P++){let L=m[P],D=m[(P+1)%3];h.start.copy(L),h.end.copy(D),h.delta(a);let k=v?u.start:u.end,W=Qa(g.distanceToPoint(L));if(Qa(g.normal.dot(a))&&W){u.copy(h),y=2;break}if((g.intersectLine(h,k)||W)&&!Qa(k.distanceTo(D))){if(y++,v)break;v=!0}}if(y===1&&this.containsPoint(u.start))return p&&(p.start.copy(u.start),p.end.copy(u.start)),!0;if(y!==2)return!1;let b=d.points,x=!1,w=0;for(let P=0;P<3;P++){let L=b[P],D=b[(P+1)%3];h.start.copy(L),h.end.copy(D),h.delta(o);let k=x?c.start:c.end,W=Qa(f.distanceToPoint(L));if(Qa(f.normal.dot(o))&&W){c.copy(h),w=2;break}if((f.intersectLine(h,k)||W)&&!Qa(k.distanceTo(D))){if(w++,x)break;x=!0}}if(w===1&&this.containsPoint(c.start))return p&&(p.start.copy(c.start),p.end.copy(c.start)),!0;if(w!==2)return!1;if(u.delta(a),c.delta(o),a.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let A=u.start.dot(a),S=u.end.dot(a),_=c.start.dot(a),M=c.end.dot(a),C=S<_,T=A<M;return A!==M&&_!==S&&C===T?!1:(p&&(l.subVectors(u.start,c.start),l.dot(a)>0?p.start.copy(u.start):p.start.copy(c.start),l.subVectors(u.end,c.end),l.dot(a)<0?p.end.copy(u.end):p.end.copy(c.end)),!0)}}}();Xs.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Xs.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new _r,s=new _r;return function(n,a=null,o=null){let l=a||o?r:null;if(this.intersectsTriangle(n,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let h=1/0;for(let u=0;u<3;u++){let c,d=i[u],p=n[d];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,a&&a.copy(e),o&&o.copy(p));let f=this[d];n.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,a&&a.copy(f),o&&o.copy(e))}for(let u=0;u<3;u++){let c=i[u],d=i[(u+1)%3];r.set(this[c],this[d]);for(let p=0;p<3;p++){let f=i[p],g=i[(p+1)%3];s.set(n[f],n[g]),ev(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,a&&a.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var ws=class extends Kt{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new ve,this.invMatrix=new ve,this.points=new Array(8).fill().map(()=>new E),this.satAxes=new Array(3).fill().map(()=>new E),this.satBounds=new Array(3).fill().map(()=>new bs),this.alignedSatBounds=new Array(3).fill().map(()=>new bs),this.needsUpdate=!1}set(e,t,i){super.set(e,t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};ws.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){let c=1*l|2*h|4*u,d=r[c];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=u?i.z:t.z,d.applyMatrix4(e)}let s=this.satBounds,n=this.satAxes,a=r[0];for(let l=0;l<3;l++){let h=n[l],u=s[l],c=1<<l,d=r[c];h.subVectors(a,d),u.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ws.prototype.intersectsBox=function(){let e=new bs;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,n=this.satAxes,a=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,a[0].isSeparated(e)||(e.min=i.y,e.max=r.y,a[1].isSeparated(e))||(e.min=i.z,e.max=r.z,a[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=n[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();ws.prototype.intersectsTriangle=function(){let e=new Xs,t=new Array(3),i=new bs,r=new bs,s=new E;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);let a=this.satBounds,o=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let c=0;c<3;c++){let d=a[c],p=o[c];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=n.satBounds,h=n.satAxes,u=this.points;for(let c=0;c<3;c++){let d=l[c],p=h[c];if(i.setFromPoints(p,u),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=o[c];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(d,f),i.setFromPoints(s,t),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}();ws.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();ws.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();ws.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new _r),i=new Array(12).fill().map(()=>new _r),r=new E,s=new E;return function(n,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(o||l)&&(n.getCenter(s),this.closestPointToPoint(s,r),n.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=a*a,u=n.min,c=n.max,d=this.points,p=1/0;for(let g=0;g<8;g++){let m=d[g];s.copy(m).clamp(u,c);let v=m.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(m),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let y=(g+1)%3,b=(g+2)%3,x=m<<y|v<<b,w=1<<g|m<<y|v<<b,A=d[x],S=d[w];t[f].set(A,S);let _=e[g],M=e[y],C=e[b],T=i[f],P=T.start,L=T.end;P[_]=u[_],P[M]=m?u[M]:c[M],P[C]=v?u[C]:c[M],L[_]=c[_],L[M]=m?u[M]:c[M],L[C]=v?u[C]:c[M],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){s.x=g?c.x:u.x,s.y=m?c.y:u.y,s.z=v?c.z:u.z,this.closestPointToPoint(s,r);let y=s.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(r),l&&l.copy(s),y<h))return Math.sqrt(y)}for(let g=0;g<12;g++){let m=t[g];for(let v=0;v<12;v++){let y=i[v];ev(m,y,r,s);let b=r.distanceToSquared(s);if(b<p&&(p=b,o&&o.copy(r),l&&l.copy(s),b<h))return Math.sqrt(b)}}return Math.sqrt(p)}}();var Pc=new E,Dc=new E,Lc=new E,ax=new G,ox=new G,lx=new G,hx=new E;function rF(e,t,i,r,s,n){let a;return n===hi?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==er,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function sF(e,t,i,r,s,n,a){Pc.fromBufferAttribute(t,r),Dc.fromBufferAttribute(t,s),Lc.fromBufferAttribute(t,n);let o=rF(e,Pc,Dc,Lc,hx,a);if(o){i&&(ax.fromBufferAttribute(i,r),ox.fromBufferAttribute(i,s),lx.fromBufferAttribute(i,n),o.uv=zi.getUV(hx,Pc,Dc,Lc,ax,ox,lx,new G));let l={a:r,b:s,c:n,normal:new E,materialIndex:0};zi.getNormal(Pc,Dc,Lc,l.normal),o.face=l,o.faceIndex=r}return o}function hA(e,t,i,r,s){let n=r*3,a=e.index.getX(n),o=e.index.getX(n+1),l=e.index.getX(n+2),h=sF(i,e.attributes.position,e.attributes.uv,a,o,l,t);return h?(h.faceIndex=r,s&&s.push(h),h):null}function nF(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)hA(e,t,i,a,n)}function aF(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=hA(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}function cA(e,t,i){return e===null||(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far)?null:e}function ns(e,t,i,r){let s=e.a,n=e.b,a=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),n.x=r.getX(l),n.y=r.getY(l),n.z=r.getZ(l),a.x=r.getX(h),a.y=r.getY(h),a.z=r.getZ(h)}function cx(e,t,i,r,s,n,a){let o=i.index,l=i.attributes.position;for(let h=e,u=t+e;h<u;h++)if(ns(a,h*3,o,l),a.needsUpdate=!0,r(a,h,s,n))return!0;return!1}var dA=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function fn(e,t){return t[e+15]===65535}function Co(e,t){return t[e+6]}function _h(e,t){return t[e+14]}function Ah(e){return e+8}function Sh(e,t){return t[e+6]}function oF(e,t){return t[e+7]}var vo=new Kt,Yd=new E,lF=["x","y","z"];function Dm(e,t,i,r,s){let n=e*2,a=il,o=Cn,l=Tn;if(fn(n,o)){let h=Co(e,l),u=_h(n,o);nF(t,i,r,h,u,s)}else{let h=Ah(e);Qd(h,a,r,Yd)&&Dm(h,t,i,r,s);let u=Sh(e,l);Qd(u,a,r,Yd)&&Dm(u,t,i,r,s)}}function Lm(e,t,i,r){let s=e*2,n=il,a=Cn,o=Tn;if(fn(s,a)){let l=Co(e,o),h=_h(s,a);return aF(t,i,r,l,h)}else{let l=oF(e,o),h=lF[l],u=r.direction[h]>=0,c,d;u?(c=Ah(e),d=Sh(e,o)):(c=Sh(e,o),d=Ah(e));let p=Qd(c,n,r,Yd)?Lm(c,t,i,r):null;if(p){let g=p.point[h];if(u?g<=n[d+l]:g>=n[d+l+3])return p}let f=Qd(d,n,r,Yd)?Lm(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var hF=function(){let e,t,i=[],r=new dA(()=>new Kt);return function(...n){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let a=s(...n);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),a};function s(n,a,o,l,h=null,u=0,c=0){function d(y){let b=y*2,x=Cn,w=Tn;for(;!fn(b,x);)y=Ah(y),b=y*2;return Co(y,w)}function p(y){let b=y*2,x=Cn,w=Tn;for(;!fn(b,x);)y=Sh(y,w),b=y*2;return Co(y,w)+_h(b,x)}let f=n*2,g=il,m=Cn,v=Tn;if(fn(f,m)){let y=Co(n,v),b=_h(f,m);return ls(n,g,e),l(y,b,!1,c,u+n,e)}else{let y=Ah(n),b=Sh(n,v),x=y,w=b,A,S,_,M;if(h&&(_=e,M=t,ls(x,g,_),ls(w,g,M),A=h(_),S=h(M),S<A)){x=b,w=y;let W=A;A=S,S=W,_=M}_||(_=e,ls(x,g,_));let C=fn(x*2,m),T=o(_,C,A,c+1,u+x),P;if(T===2){let W=d(x),X=p(x)-W;P=l(W,X,!0,c+1,u+x,_)}else P=T&&s(x,a,o,l,h,u,c+1);if(P)return!0;M=t,ls(w,g,M);let L=fn(w*2,m),D=o(M,L,S,c+1,u+w),k;if(D===2){let W=d(w),X=p(w)-W;k=l(W,X,!0,c+1,u+w,M)}else k=D&&s(w,a,o,l,h,u,c+1);return!!k}}}(),cF=function(){let e=new Xs,t=new Xs,i=new ve,r=new ws,s=new ws;return function n(a,o,l,h,u=null){let c=a*2,d=il,p=Cn,f=Tn;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),u=r),fn(c,p)){let g=o,m=g.index,v=g.attributes.position,y=l.index,b=l.attributes.position,x=Co(a,f),w=_h(c,p);if(i.copy(h).invert(),l.boundsTree)return ls(a,d,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>s.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let S=x*3,_=(w+x)*3;S<_;S+=3)if(ns(t,S,m,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=x*3,S=w+x*3;A<S;A+=3){ns(e,A,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let _=0,M=y.count;_<M;_+=3)if(ns(t,_,y,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=a+8,m=f[a+6];return ls(g,d,vo),!!(u.intersectsBox(vo)&&n(g,o,l,h,u)||(ls(m,d,vo),u.intersectsBox(vo)&&n(m,o,l,h,u)))}}}();function Qd(e,t,i,r){return ls(e,t,vo),i.intersectBox(vo,r)}var Om=[],ld,il,Cn,Tn;function Wl(e){ld&&Om.push(ld),ld=e,il=new Float32Array(e),Cn=new Uint16Array(e),Tn=new Uint32Array(e)}function Oc(){ld=null,il=null,Cn=null,Tn=null,Om.length&&Wl(Om.pop())}var Gp=Symbol("skip tree generation"),Vp=new Kt,Hp=new Kt,Za=new ve,Yn=new ws,Ml=new ws,El=new E,Ic=new E,dF=new E,uF=new E,pF=new E,dx=new Kt,Yr=new dA(()=>new Xs),gi=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),gi.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),n;return t.cloneBuffers?n={roots:r.map(a=>a.slice()),index:s.array.slice()}:n={roots:r,index:s.array},n}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),gi.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,n=new gi(t,{...i,[Gp]:!0});if(n._roots=s,i.setIndex){let a=t.getIndex();if(a===null){let o=new Xe(e.index,1,!1);t.setIndex(o)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return n}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Gp]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Gp]||(this._roots=$U(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Kt))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s=r.array,n=r.offset||0,a=3;r.isInterleavedBufferAttribute&&(a=r.data.stride);let o,l,h,u,c=0,d=this._roots;for(let f=0,g=d.length;f<g;f++)o=d[f],l=new Uint32Array(o),h=new Uint16Array(o),u=new Float32Array(o),p(0,c),c+=o.byteLength;function p(f,g,m=!1){let v=f*2;if(h[v+15]===65535){let y=l[f+6],b=h[v+14],x=1/0,w=1/0,A=1/0,S=-1/0,_=-1/0,M=-1/0;for(let C=3*y,T=3*(y+b);C<T;C++){let P=i[C]*a+n,L=s[P+0],D=s[P+1],k=s[P+2];L<x&&(x=L),L>S&&(S=L),D<w&&(w=D),D>_&&(_=D),k<A&&(A=k),k>M&&(M=k)}return u[f+0]!==x||u[f+1]!==w||u[f+2]!==A||u[f+3]!==S||u[f+4]!==_||u[f+5]!==M?(u[f+0]=x,u[f+1]=w,u[f+2]=A,u[f+3]=S,u[f+4]=_,u[f+5]=M,!0):!1}else{let y=f+8,b=l[f+6],x=y+g,w=b+g,A=m,S=!1,_=!1;e?A||(S=e.has(x),_=e.has(w),A=!S&&!_):(S=!0,_=!0);let M=A||S,C=A||_,T=!1;M&&(T=p(y,g,A));let P=!1;C&&(P=p(b,g,A));let L=T||P;if(L)for(let D=0;D<3;D++){let k=y+D,W=b+D,X=u[k],z=u[k+3],j=u[W],U=u[W+3];u[f+D]=X<j?X:j,u[f+D+3]=z>U?z:U}return L}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);n(0);function n(a,o=0){let l=a*2,h=s[l+15]===65535;if(h){let u=r[a+6],c=s[l+14];e(o,h,new Float32Array(i,a*4,6),u,c)}else{let u=a+8,c=r[a+6],d=r[a+7];e(o,h,new Float32Array(i,a*4,6),d)||(n(u,o+1),n(c,o+1))}}}raycast(e,t=Vr){let i=this._roots,r=this.geometry,s=[],n=t.isMaterial,a=Array.isArray(t),o=r.groups,l=n?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=a?t[o[h].materialIndex].side:l,d=s.length;if(Wl(i[h]),Dm(0,r,c,e,s),Oc(),a){let p=o[h].materialIndex;for(let f=d,g=s.length;f<g;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=Vr){let i=this._roots,r=this.geometry,s=t.isMaterial,n=Array.isArray(t),a=null,o=r.groups,l=s?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=n?t[o[h].materialIndex].side:l;Wl(i[h]);let d=Lm(0,r,c,e);Oc(),d!=null&&(a==null||d.distance<a.distance)&&(a=d,n&&(d.face.materialIndex=o[h].materialIndex))}return a}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(Wl(s),r=cF(0,i,e,t),Oc(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(d,p,f,g)=>{let m=p*3;return c(d,m,m+1,m+2,f,g)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Yr.getPrimitive(),{boundsTraverseOrder:n,intersectsBounds:a,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(d,p,f,g,m)=>c(d,p,f,g,m)?!0:cx(d,p,r,l,f,g,s)}else o||(l?o=(c,d,p,f)=>cx(c,d,r,l,p,f,s):o=(c,d,p)=>p);let h=!1,u=0;for(let c of this._roots){if(Wl(c),h=hF(0,r,a,o,n,u),Oc(),h)break;u+=c.byteLength}return Yr.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,n=this.geometry.index,a=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Za.copy(t).invert();let h=Yr.getPrimitive(),u=Yr.getPrimitive();if(s){let d=function(p,f,g,m,v,y,b,x){for(let w=g,A=g+m;w<A;w++){ns(u,w*3,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let S=p,_=p+f;S<_;S++)if(ns(h,S*3,n,a),h.needsUpdate=!0,s(h,u,S,w,v,y,b,x))return!0}return!1};if(r){let p=r;r=function(f,g,m,v,y,b,x,w){return p(f,g,m,v,y,b,x,w)?!0:d(f,g,m,v,y,b,x,w)}}else r=d}e.getBoundingBox(Hp),Hp.applyMatrix4(t);let c=this.shapecast({intersectsBounds:d=>Hp.intersectsBox(d),intersectsRange:(d,p,f,g,m,v)=>(Vp.copy(v),Vp.applyMatrix4(Za),e.shapecast({intersectsBounds:y=>Vp.intersectsBox(y),intersectsRange:(y,b,x,w,A)=>r(d,p,y,b,g,m,w,A)}))});return Yr.releasePrimitive(h),Yr.releasePrimitive(u),c}intersectsBox(e,t){return Yn.set(e.min,e.max,t),Yn.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Yn.intersectsBox(i),intersectsTriangle:i=>Yn.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Yn.set(e.boundingBox.min,e.boundingBox.max,t),Yn.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,u=e.index,c=Yr.getPrimitive(),d=Yr.getPrimitive(),p=Ic,f=dF,g=null,m=null;r&&(g=uF,m=pF);let v=1/0,y=null,b=null;return Za.copy(t).invert(),Ml.matrix.copy(Za),this.shapecast({boundsTraverseOrder:x=>Yn.distanceToBox(x),intersectsBounds:(x,w,A)=>A<v&&A<n?(w&&(Ml.min.copy(x.min),Ml.max.copy(x.max),Ml.needsUpdate=!0),!0):!1,intersectsRange:(x,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>Ml.distanceToBox(A),intersectsBounds:(A,S,_)=>_<v&&_<n,intersectsRange:(A,S)=>{for(let _=A*3,M=(A+S)*3;_<M;_+=3){ns(d,_,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let C=x*3,T=(x+w)*3;C<T;C+=3){ns(c,C,l,o),c.needsUpdate=!0;let P=c.distanceToTriangle(d,p,g);if(P<v&&(f.copy(p),m&&m.copy(g),v=P,y=C/3,b=_/3),P<s)return!0}}}});{let A=u?u.count:h.count;for(let S=0,_=A;S<_;S+=3){ns(d,S,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let M=x*3,C=(x+w)*3;M<C;M+=3){ns(c,M,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(d,p,g);if(T<v&&(f.copy(p),m&&m.copy(g),v=T,y=M/3,b=S/3),T<s)return!0}}}}}),Yr.releasePrimitive(c),Yr.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=v,i.faceIndex=y,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(Za),f.applyMatrix4(Za),r.distance=f.sub(r.point).length(),r.faceIndex=b),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,n=r*r,a=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(El.copy(e).clamp(h.min,h.max),El.distanceToSquared(e)),intersectsBounds:(h,u,c)=>c<a&&c<n,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,El);let c=e.distanceToSquared(El);return c<a&&(Ic.copy(El),a=c,o=u),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(Ic):t.point=Ic.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{ls(0,new Float32Array(t),dx),e.union(dx)}),e}},ux=gi.prototype.raycast;gi.prototype.raycast=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,i,r,s]=e;return ux.call(this,r,t.material).forEach(n=>{n=cA(n,t,i),n&&s.push(n)}),s}else return ux.apply(this,e)};var px=gi.prototype.raycastFirst;gi.prototype.raycastFirst=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,i,r]=e;return cA(px.call(this,r,t.material),t,i)}else return px.apply(this,e)};var fx=gi.prototype.closestPointToPoint;gi.prototype.closestPointToPoint=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),e.unshift();let t=e[1],i={};return e[1]=i,fx.apply(this,e),t&&t.copy(i.point),i.distance}else return fx.apply(this,e)};var mx=gi.prototype.closestPointToGeometry;gi.prototype.closestPointToGeometry=function(...e){let t=e[2],i=e[3];if(t&&t.isVector3||i&&i.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let r={},s={},n=e[1];return e[2]=r,e[3]=s,mx.apply(this,e),t&&t.copy(r.point),i&&i.copy(s.point).applyMatrix4(n),r.distance}else return mx.apply(this,e)};var gx=gi.prototype.refit;gi.prototype.refit=function(...e){let t=e[0],i=e[1];if(i&&(i instanceof Set||Array.isArray(i))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let r=new Set;i.forEach(s=>r.add(s)),t&&t.forEach(s=>r.add(s)),gx.call(this,r)}else gx.apply(this,e)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(e=>{let t=gi.prototype[e];gi.prototype[e]=function(...i){return(i[0]===null||i[0].isMesh)&&(i.shift(),console.warn(`MeshBVH: The function signature for "${e}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,i)}});var Cl=Ch($2()),fF=.5*(Math.sqrt(3)-1),Tl=(3-Math.sqrt(3))/6,mF=1/3,Qr=1/6,B9=(Math.sqrt(5)-1)/4,z9=(5-Math.sqrt(5))/20,ih=e=>Math.floor(e)|0,vx=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),Wp=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function Xp(e=Math.random){let t=uA(e),i=new Float64Array(t).map(s=>vx[s%12*2]),r=new Float64Array(t).map(s=>vx[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*fF,u=ih(s+h),c=ih(n+h),d=(u+c)*Tl,p=u-d,f=c-d,g=s-p,m=n-f,v,y;g>m?(v=1,y=0):(v=0,y=1);let b=g-v+Tl,x=m-y+Tl,w=g-1+2*Tl,A=m-1+2*Tl,S=u&255,_=c&255,M=.5-g*g-m*m;if(M>=0){let P=S+t[_],L=i[P],D=r[P];M*=M,a=M*M*(L*g+D*m)}let C=.5-b*b-x*x;if(C>=0){let P=S+v+t[_+y],L=i[P],D=r[P];C*=C,o=C*C*(L*b+D*x)}let T=.5-w*w-A*A;if(T>=0){let P=S+1+t[_+1],L=i[P],D=r[P];T*=T,l=T*T*(L*w+D*A)}return 70*(a+o+l)}}function gF(e=Math.random){let t=uA(e),i=new Float64Array(t).map(n=>Wp[n%12*3]),r=new Float64Array(t).map(n=>Wp[n%12*3+1]),s=new Float64Array(t).map(n=>Wp[n%12*3+2]);return function(n,a,o){let l,h,u,c,d=(n+a+o)*mF,p=ih(n+d),f=ih(a+d),g=ih(o+d),m=(p+f+g)*Qr,v=p-m,y=f-m,b=g-m,x=n-v,w=a-y,A=o-b,S,_,M,C,T,P;x>=w?w>=A?(S=1,_=0,M=0,C=1,T=1,P=0):x>=A?(S=1,_=0,M=0,C=1,T=0,P=1):(S=0,_=0,M=1,C=1,T=0,P=1):w<A?(S=0,_=0,M=1,C=0,T=1,P=1):x<A?(S=0,_=1,M=0,C=0,T=1,P=1):(S=0,_=1,M=0,C=1,T=1,P=0);let L=x-S+Qr,D=w-_+Qr,k=A-M+Qr,W=x-C+2*Qr,X=w-T+2*Qr,z=A-P+2*Qr,j=x-1+3*Qr,U=w-1+3*Qr,N=A-1+3*Qr,B=p&255,H=f&255,Q=g&255,Y=.6-x*x-w*w-A*A;if(Y<0)l=0;else{let ee=B+t[H+t[Q]];Y*=Y,l=Y*Y*(i[ee]*x+r[ee]*w+s[ee]*A)}let F=.6-L*L-D*D-k*k;if(F<0)h=0;else{let ee=B+S+t[H+_+t[Q+M]];F*=F,h=F*F*(i[ee]*L+r[ee]*D+s[ee]*k)}let se=.6-W*W-X*X-z*z;if(se<0)u=0;else{let ee=B+C+t[H+T+t[Q+P]];se*=se,u=se*se*(i[ee]*W+r[ee]*X+s[ee]*z)}let V=.6-j*j-U*U-N*N;if(V<0)c=0;else{let ee=B+1+t[H+1+t[Q+1]];V*=V,c=V*V*(i[ee]*j+r[ee]*U+s[ee]*N)}return 32*(l+h+u+c)}}function uA(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Ir=new zi,vF=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;Ir.a.fromBufferAttribute(e,r),Ir.b.fromBufferAttribute(e,r+1),Ir.c.fromBufferAttribute(e,r+2),s*=Ir.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let n=Math.ceil((i+r)/2);if(n===0||t[n-1]<=e&&t[n]>e){s=n;break}else e<t[n]?r=n-1:i=n+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Ir.a.fromBufferAttribute(this.positionAttribute,e*3),Ir.b.fromBufferAttribute(this.positionAttribute,e*3+1),Ir.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Ir.a,r).addScaledVector(Ir.b,s).addScaledVector(Ir.c,1-(r+s)),Ir.getNormal(i),this}},yF=Ch(ow()),xF=new ve,bF=new ve,wF=new ve,Zd;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(Zd||(Zd={}));var tv=e=>class extends e{constructor(){super(...arguments),this.hiddenMatrix=new ve,this.matrixWorldRigid=new ve,this.shearScale=new ve,this.shearScaleInv=new ve}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof bt&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Zd.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:n}=(0,yF.SVD)(i),a=xF.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=bF.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=wF.copy(o).transpose();this.shearScale.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,l).copyPosition(this.matrixWorld),n.every(h=>Math.abs(n[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new ve().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof ve?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}},_F=class extends tv(bt){},AF=e=>e.type==="Mesh",la=class extends _F{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new la(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return AF(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}},ra=new E,sa=new E,To=new ve,pA=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],SF=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],MF=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],yx=(e,t,i)=>{e.updateEntityBoxSize(ra,sa),To.copy(t).multiply(e.matrixWorld),sa.x===0&&sa.y===0&&sa.z===0?i.push(new E(ra.x,ra.y,ra.z).applyMatrix4(To)):pA.forEach(r=>{i.push(r.clone().multiply(sa).add(ra).applyMatrix4(To))})},xx=class extends Kt{constructor(){super(...arguments),this.matrix=new ve,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new ve().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{(s.visible||s.cloner&&s.data.visible)&&yx(s,t,r)}):yx(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(To.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(sa).multiplyScalar(.5),this.getCenter(ra),To.copy(this.matrix).setPosition(ra),this.vertices=pA.map(e=>e.clone().multiply(sa).applyMatrix4(To))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=SF.map(([e,t])=>new _r(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=MF.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},wn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},EF=class extends Lw{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],h=Math.ceil(e*l/s),u=o.getPoints(h);for(let c=0;c<u.length;c++){let d=u[c];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},Im=.001;function Rm(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Im}function qp(e,t){let i=new E(...e.position),r=new E(...e.controlNext.position),s=new E(...t.controlPrevious.position),n=new E(...t.position);return Rm(i,r,n)&&Rm(i,s,n)}function fA(e){let t=e.points.map(u=>new E(...u.data.position)),i=[e.points[0]],r=new E(...i[0].data.position);for(let u=0;u<e.points.length-1;u++)Rm(r,t[u],t[u+1])||(i.push(e.points[u]),r=t[u]);i.push(e.points[e.points.length-1]);let s=e.isClosed,n=i.length-(s?0:1),a=i.length,o=[];for(let u=0;u<a;u++){let c=i[u].data,d=new E(...c.position),p=new E(...c.controlPrevious.position),f=new E(...c.controlNext.position),g={position:d,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(u===0||u===a-1)){o[u]={...g,removedLength:0};continue}let m=s&&u==0?a-1:u-1,v=s&&u==a-1?0:u+1,y=i[m].data,b=i[v].data,x=new E(...y.position),w=new E(...b.position),A=x.clone().sub(d).normalize(),S=w.clone().sub(d).normalize();Object.assign(g,{prevDir:A,nextDir:S});let _=qp(y,c),M=qp(c,b);if(!_||!M)o[u]={...g,removedLength:0};else{let C=A.clone().add(S).normalize(),T=C.clone().cross(A).length()/A.dot(C);o[u]={...g,tan:T,removedLength:c.roundness/T}}}for(let u=0;u<n;u++){let c=u,d=s&&u===a-1?0:u+1,p=o[c],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let g=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,g/2),f.removedLength=Math.min(f.removedLength,g/2)}}let l=[];for(let u=0;u<n;u++){let c=u,d=s&&u===a-1?0:u+1,p=o[c],f=o[d],g=null;if(!qp(i[c].data,i[d].data))p.position.distanceTo(f.position)>Im&&(g=new td(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(v)>Im&&(g=new td(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*u+1]=g}for(let u=0;u<a;u++){let c=o[u];if(c.removedLength===0){l[2*u]=null;continue}let d=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(d),f=c.nextDir.clone().multiplyScalar(c.removedLength).add(d),g=c.tan*c.removedLength,m=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,b=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(y,2))).add(v),x=m.clone().multiplyScalar(-g).add(b),w=d.distanceTo(x)/d.distanceTo(v),A=c.prevDir.clone().multiplyScalar(w*d.distanceTo(p)).add(d),S=A.clone().lerp(x,2),_=p.clone().lerp(A,4/3),M=f.clone().lerp(S,4/3);l[2*u]=new td(p,_,M,f)}let h=new EF;return l.forEach(u=>{u&&h.add(u)}),h}var Ct;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(Ct||(Ct={}));var mn=e=>Ct.is(e),CF={type:"completeState",isfromEntity:!0},mA=e=>class extends tv(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new xx,this._recursiveBBox=new xx,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(Ct.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(Ct.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)oa.toOps(this.data,s.data).forEach(n=>{let a=sm.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=oa.patch(this.data,s),oa.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{mn(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(Ct.is(i[r]))return i[r];if(Ct.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Ct.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)mn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{Ct.is(i)&&t(i)})}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)mn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)mn(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,i=!0){return super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>mn(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return rm(i,t)}updateTransformState(t){let i=!1;return t.position&&(this.position.fromArray(t.position),i=!0),t.rotation&&(this.rotation.fromArray(t.rotation),i=!0),t.scale&&(i=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??ko.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)Ct.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Ct.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return rm(i,t)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=pn(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(Object.values(t.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let c=fs.zoom(u,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(h[d]=c[d])}}a={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:u,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:u,...c}=l;l=c}let h=fs.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,oa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),pn(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let u of Object.keys(t.props)){l[l.length-1]=u;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[u],c.updateState(fa.apply(c.component.data,c.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let c=fs.zoom(u.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(c)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=c[p]);t={...t,props:d}}u.overrideData=jd.resolve(i.overrides,l),u.updateByOp(t,ir.applySimple(u.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let u of Go.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of Go.rootOverrideProps)if(pn(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=fa.filterOp(h.overrideData,l);u&&h.updateByOp(u,ir.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=fa.filterOp(h.overrideData,t);if(u){let c;n===h.data&&t===u?c=i:c=ir.applySimple(h.data,u),h.updateByOp(u,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!_a.is(t.props.type)&&wn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){wn.changeEntityProptotype(this,i,r);for(let s of this.children)Ct.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),pn(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),pn(t.path,["cloner"])!==null){let s=ir.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(i);if(!a||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=a.data,l=fA(o.geometry.path),h=(r+s)%1,u=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new ve;a.updateMatrixWorld();let d=new ve().multiplyMatrices(c.clone().invert(),a.matrixWorld);u.applyMatrix4(d);let p={position:u.toArray(),rotation:o.rotation};if(n==="tangential"){let f=new ve().extractRotation(a.matrixWorld),g=l.getTangentAt(h).applyMatrix4(f).add(u),m=new ve().lookAt(u,g,new E(0,1,0)),v=new _i().setFromRotationMatrix(m);p={...p,rotation:[v.x,v.y,v.z]}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(CF)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof wn.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new wn.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}},TF=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters),r=i.width/2,s=i.radiusTop??r,n=i.radiusBottom??r;return s===n?(s=r,n=r):s>n?(s=r,n=n*r/s):(s=s*r/n,n=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:s,radiusBottom:n})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:u,cornerRadius:c,cornerSegments:d,hollow:p}=e.parameters,f;return c||p?f=new gA(h,u,r,s,n,a,o,l*Math.PI/180,c,c,d,p):f=new yg(h,u,r,s,n,a,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function sn(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function bx(e){return new G(e.y,-e.x)}var gA=class extends Ve{constructor(e,t,i,r,s,n,a,o,l,h,u,c,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0?n:!1,a=a!==void 0?a:0,o=o!==void 0?o:Math.PI*2,n&&(l=0,h=0);let p=[],f=[],g=[],m=[],v=0,y=i/2,b=new E,x=new E;d&&e==0&&(e=l),d&&t==0&&(t=h);let w=new G(e,y),A=new G(t,-y),S=null,_=null,M=null,C=null,T=w.clone().sub(A),P=0,L=0,D=0;c>0&&(P=Math.min(e,t)*(1-c),L=e-P,D=t-P);let k=w.clone();k.x-=P;let W=Math.PI-T.angle(),X=T.angle(),z=Math.tan(X/2),j=Math.tan(W/2),U=z+j,N=c?U:j,B=c?U:z;if(l=Math.min(l,(e-L)/N,T.length()/U),h=Math.min(h,(t-D)/B,T.length()/U),l>0){let V=l/z;S=w.clone().sub(new G(V,l)),c&&(M=S.clone(),M.x-=P-U*l),w.sub(T.clone().setLength(V))}if(h>0){let V=h/j;_=A.clone().sub(new G(V,-h)),A.add(T.clone().setLength(V)),c&&(C=_.clone(),C.x-=P-U*h,k.sub(T.clone().setLength(V)))}T=w.clone().sub(A);let H=T.length()<.5,Q=[];for(let V=0;V<=r;V++){let ee=[],J=V/r,fe=J*o+a,re=new G(Math.sin(fe),Math.cos(fe));C&&_?(Y(ee,J,re,W,h,C,-1,!0),Y(ee,J,re,X,h,_,-1,!1)):_?(F(ee,re,_.x,0,-1),Y(ee,J,re,X,h,_,-1,!1)):n||F(ee,re,t,D,-1);let oe=bx(T).normalize();if(sn(oe,re,b),!H)for(let ue=0;ue<=s;ue++){let ye=ue/s,Te=T.clone().multiplyScalar(ye).add(A);sn(Te,re,x),f.push(x.x,x.y,x.z),g.push(b.x,b.y,b.z),m.push(J,.5+x.y/i),ee.push(v++)}if(M&&S?(Y(ee,J,re,W,l,S,1,!1),Y(ee,J,re,X,l,M,1,!0)):S?(Y(ee,J,re,W,l,S,1,!1),F(ee,re,S.x,0,1)):n||F(ee,re,e,L,1),c&&!H){let ue=bx(T).multiplyScalar(-1).normalize();sn(ue,re,b);for(let ye=0;ye<=s;ye++){let Te=ye/s,xe=T.clone().multiplyScalar(-Te).add(k);sn(xe,re,x),f.push(x.x,x.y,x.z),g.push(b.x,b.y,b.z),m.push(J,.5+x.y/i),ee.push(v++)}}c&&!n&&ee.push(ee[0]),Q.push(ee)}for(let V=0;V<Q.length-1;V++)for(let ee=0;ee<Q[0].length-1;ee++){if(n&&c&&ee==s)continue;let J=Q[V][ee],fe=Q[V+1][ee],re=Q[V+1][ee+1],oe=Q[V][ee+1],ue=f[re*3+0],ye=f[re*3+2];p.push(J,fe,oe),(ue!=0||ye!=0)&&p.push(fe,re,oe)}o<Math.PI*2&&(se(-1,Q[0],a),se(1,Q[Q.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new Ce(f,3)),this.setAttribute("normal",new Ce(g,3)),this.setAttribute("uv",new Ce(m,2));function Y(V,ee,J,fe,re,oe,ue,ye){for(let Te=0;Te<u+1;Te++){let xe=Te/u,we=ue<0?xe:1-xe;ye&&(we-=1),we*=fe;let Ie=new G(Math.sin(we),Math.cos(we)*ue),He=Ie.clone().multiplyScalar(re).add(oe);sn(He,J,x),f.push(x.x,x.y,x.z),sn(Ie,J,b),g.push(b.x,b.y,b.z),m.push(ee,.5+x.y/i),V.push(v++)}}function F(V,ee,J,fe,re){let oe=new E,ue=new G,ye=[J,fe];re<0&&ye.reverse();for(let Te of ye)ue.set(Te,y*re),sn(ue,ee,oe),f.push(oe.x,oe.y,oe.z),g.push(0,re,0),m.push(.5,.5),V.push(v++)}function se(V,ee,J){let fe=new G(Math.sin(J),Math.cos(J)),re=new G(-Math.cos(J),Math.sin(J)),oe=new E,ue=V<0?(xe,we,Ie)=>p.push(xe,we,Ie):(xe,we,Ie)=>p.push(xe,Ie,we),ye=new G((e+t+L+D)/4,0);sn(ye,fe,oe),f.push(oe.x,oe.y,oe.z),g.push(re.x,0,re.y),m.push(.5,.5);let Te=v++;for(let xe of ee){let we=f.slice(xe*3,xe*3+3);f.push(...we),g.push(re.x,0,re.y);let Ie=m.slice(xe*2,xe*2+2);m.push(...Ie),v++}for(let xe=Te+1;xe<v-1;xe++)ue(Te,xe,xe+1);ue(Te,v-1,Te+1)}}},PF=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:u,cornerSegments:c}=e.parameters,d;return h>0||u>0||l<360?d=new gA(0,t/2,r,s,n,a,o,l*Math.PI/180,h,u,c,0,!0):d=new Iw(t/2,r,s,n,a),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},DF=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:n,depthSegments:a,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new vs(t,i,r,s,n,a):h=new LF(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Yp=Math.PI/2,LF=class extends Ve{constructor(e=1,t=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o),a=Math.min(a,e/2,t/2,i/2);let h=[],u=[],c=[],d=[],p=0,f=0;g("z","y","x",-1,-1,i,t,e,n,s,0),g("z","y","x",1,-1,i,t,-e,n,s,1),g("x","z","y",1,1,e,i,t,r,n,2),g("x","z","y",1,-1,e,i,-t,r,n,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),a>0&&(m("z","y","x",-1,-1,1,i,t,e,n,0),m("z","y","x",1,-1,-1,i,t,e,n,1),m("z","y","x",-1,1,-1,i,t,e,n,1),m("z","y","x",1,1,1,i,t,e,n,0),m("x","y","z",-1,-1,-1,e,t,i,r,0),m("x","y","z",1,-1,1,e,t,i,r,1),m("x","y","z",-1,1,1,e,t,i,r,0),m("x","y","z",1,1,-1,e,t,i,r,1),m("y","x","z",-1,-1,1,t,e,i,s,0),m("y","x","z",1,-1,-1,t,e,i,s,1),m("y","x","z",1,1,1,t,e,i,s,1),m("y","x","z",-1,1,-1,t,e,i,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Ce(u,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(d,2));function g(y,b,x,w,A,S,_,M,C,T,P){let L=(S-2*a)/C,D=(_-2*a)/T,k=S/2-a,W=_/2-a,X=M/2,z=C+1,j=T+1,U=0,N=0,B=new E;for(let H=0;H<j;H++){let Q=H*D-W;for(let Y=0;Y<z;Y++){let F=Y*L-k;B[y]=F*w,B[b]=Q*A,B[x]=X,u.push(B.x,B.y,B.z),B[y]=0,B[b]=0,B[x]=M>0?1:-1,c.push(B.x,B.y,B.z),d.push(Y/C),d.push(1-H/T),U+=1}}for(let H=0;H<T;H++)for(let Q=0;Q<C;Q++){let Y=p+Q+z*H,F=p+Q+z*(H+1),se=p+(Q+1)+z*(H+1),V=p+(Q+1)+z*H;h.push(Y,F,V),h.push(F,se,V),N+=6}l.addGroup(f,N,P),f+=N,p+=U}function m(y,b,x,w,A,S,_,M,C,T,P){let L=(_-2*a)/T,D=_/2-a,k=M/2-a,W=C/2,X=T+1,z=0,j=0,U=new E,N=new E;for(let B=0;B<o+1;B++){let H=B/o*Yp,Q=Math.sin(H)*a,Y=(1-Math.cos(H))*a,F=Math.sin(H),se=Math.cos(H);U[b]=(k+Q)*A,U[x]=(W-Y)*S,N[y]=0,N[b]=F*Math.sign(U[b]),N[x]=se*Math.sign(U[x]);for(let V=0;V<X;V++){let ee=V*L-D;U[y]=ee*w,u.push(U.x,U.y,U.z),c.push(N.x,N.y,N.z),d.push(V/T),d.push(0),z+=1}}for(let B=0;B<o;B++)for(let H=0;H<T;H++){let Q=p+H+X*B,Y=p+H+X*(B+1),F=p+(H+1)+X*(B+1),se=p+(H+1)+X*B;h.push(Q,Y,se),h.push(Y,F,se),j+=6}l.addGroup(f,j,P),f+=j,p+=z}function v(y,b,x){let w=new E,A=new E(e/2,t/2,i/2);A.subScalar(a);let S=[],_=y*b*x>0?(C,T,P)=>h.push(C,T,P):(C,T,P)=>h.push(C,P,T);for(let C=0;C<=o;C++){let T=[],P=Yp*(1-C/o),L=Math.cos(P),D=Math.sin(P),k=0;for(let W=0;W<=C;W++){let X=Math.cos(k),z=Math.sin(k);w.x=L*X,w.y=D,w.z=L*z;let j=A.clone().addScaledVector(w,a);u.push(y*j.x,b*j.y,x*j.z),c.push(y*w.x,b*w.y,x*w.z),d.push(0,0),T.push(p++),k+=Yp/C}S.push(T)}let M=S.length-1;for(let C=0;C<M;C++){let T=S[C],P=S[C+1],L=T.length-1;_(T[0],P[1],P[0]);for(let D=1;D<=L;D++)_(T[D-1],T[D],P[D]),_(T[D],P[D+1],P[D])}}}},iv=class extends Ve{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),u(),this.setAttribute("position",new Ce(a,3)),this.setAttribute("normal",new Ce(l,3)),this.setAttribute("uv",new Ce(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(n=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new E,p=d.clone(),f=new zi,g=s*r,m=r-g,v=n+1,y=new E,b=(X,z)=>y.subVectors(X,z).normalize(),x=(X,z)=>Array(X).fill(void 0).map(z),w=x(e.length/3,(X,z)=>new E().fromArray(e,z*3).setLength(r)),A=[],S=1e6;for(let X=0;X<w.length;X++){let z=w[X],j=[],U,N,B,H=1e10,Q=-1;for(;(Q=t.indexOf(X,Q+1))!=-1;){let V=Q-Q%3;U=t[V+(Q+1)%3],N=t[V+(Q+2)%3],B=z.distanceToSquared(w[U]),H=Math.min(H,B),j.push([U,N,B])}H+=1e-6;let Y=[],F=0,se=j.length;for(let V=0;V<se;V++){[U,N,B]=j[F];let ee=A[U]?.includes(X)==!0;B<=H&&Y.push(U+ +ee*S),F=j.findIndex(J=>J[0]==N)}A.push(Y)}let _=[];{let X=0,z=0,j,U,N=c==3;for(let B=0;B<=n;B++){j=B*(B+1)/2,U=(B+1)*(B+2)/2;for(let H=0;H<n-B;H++)[X,z]=[j+H+B+2,U+H+B+3],_.push(j,U,...N?[z,j]:[X,U],z,X),[j,U]=[X,z];_.push(j,U,j+n+2)}}let M=d.clone(),C=d.clone(),T=d.clone(),P=d.clone(),L=d.clone(),D=[],k=x(w.length,()=>x(c,()=>d.clone()));for(let X=0;X<w.length;X++){d.copy(w[X]).normalize(),M.copy(d).multiplyScalar(m);let z=A[X];for(let Y=0;Y<z.length;Y++){let F=z[Y],se=z[(Y+1)%c];f.setFromPointsAndIndices(w,X,F%S,se%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,k[X][Y])}let j=[],U=[],N=[],B=new E;n==0&&[...k[X]].reduce((Y,F)=>Y.add(F),B).multiplyScalar(1/c);for(let Y=0;Y<c;Y++){let F=[],se=(Y-1+c)%c,V=k[X][se],ee=k[X][Y];d.copy(V).sub(M),p.copy(ee).sub(M);let J=M.angleTo(d),fe=d.angleTo(p),re=Math.cos(J)*g;n==0?C.copy(B):C.copy(M).setLength(m+re),U.push(re);let oe=[C,V,ee];for(let ue=0;ue<2;ue++){let ye=oe[ue],Te=oe[ue+1];P.subVectors(ye,M),L.subVectors(Te,M),T.crossVectors(P,L).normalize();for(let xe=0;xe<v;xe++){let we=[J,fe][ue]*xe/v;d.copy(P).applyAxisAngle(T,we).add(M),j.push(d.clone()),ue&&(b(d,M),F.push([xe==0?ye:d.clone(),y.clone()]))}ue&&(b(Te,M),F.push([Te,y.clone()]))}N.push(F)}D.push(N);let H=2*v,Q=2;for(let Y=0;Y<c;Y++){let F=H*Y,se=H*((Y+1)%c),V=[j[F]];for(let J=1;J<v;J++){P=j[F+J],L=j[se+J],V.push(P);for(let fe=1,re=J-Q+1;fe<=re;fe++)d.lerpVectors(P,L,fe/(re+1)),d.sub(M).setLength(U[Y]).add(M),V.push(d.clone());V.push(L)}for(let J=0;J<v;J++)V.push(j[J+v+F]);V.push(j[se+v]);let ee=_.map(J=>V[J]);a.push(...ee.map(J=>[J.x,J.y,J.z]).flat()),l.push(...ee.map(J=>(b(J,M),[y.x,y.y,y.z])).flat())}}let W=[];for(let X=0;X<A.length;X++)for(let z=0;z<c;z++){let j=A[X][z];if(j<S){let U=A[j].findIndex(H=>H%S==X),N=D[X][z],B=D[j][U];for(let H=0;H<v;H++){let Q=N[H],Y=B[v-H],F=N[H+1],se=B[v-(H+1)];[Q,Y,F,F,Y,se].forEach(V=>{a.push(V[0].x,V[0].y,V[0].z),l.push(V[1].x,V[1].y,V[1].z)})}W.push(N[0][0],B[v][0],N[v][0],B[0][0])}}for(;W.length;){let X,z,j,U;[X,z]=W.splice(0,2);let N=[X];for(;X!=z;)N.push(z),j=W.indexOf(z),U=j%2,z=W.splice(j-U,2)[1-U];y.subVectors(N[0],N[1]).cross(d.subVectors(N[0],N[2])).normalize();let B=y.dot(N[0])<0;B&&y.negate();for(let H=1;H<=N.length-2;H++)[N[H+ +B],N[H+1-+B],N[0]].forEach(Q=>{a.push(Q.x,Q.y,Q.z),l.push(y.x,y.y,y.z)})}}function u(){let c=new E;for(let A=0;A<a.length;A+=3){c.x=a[A+0],c.y=a[A+1],c.z=a[A+2];let S=x(c)/2/Math.PI+.5,_=w(c)/Math.PI+.5;o.push(S,1-_)}let d=new E,p=new E,f=new E,g=new E,m=new G,v=new G,y=new G,b=(A,S,_,M)=>{M<0&&A.x===1&&(o[S]=A.x-1),_.x===0&&_.z===0&&(o[S]=M/2/Math.PI+.5)};for(let A=0,S=0;A<a.length;A+=9,S+=6){d.set(a[A+0],a[A+1],a[A+2]),p.set(a[A+3],a[A+4],a[A+5]),f.set(a[A+6],a[A+7],a[A+8]),m.set(o[S+0],o[S+1]),v.set(o[S+2],o[S+3]),y.set(o[S+4],o[S+5]),g.copy(d).add(p).add(f).divideScalar(3);let _=x(g);b(m,S+0,d,_),b(v,S+2,p,_),b(y,S+4,f,_)}for(let A=0;A<o.length;A+=6){let S=o[A+0],_=o[A+2],M=o[A+4],C=Math.max(S,_,M),T=Math.min(S,_,M);C>.9&&T<.1&&(S<.2&&(o[A+0]+=1),_<.2&&(o[A+2]+=1),M<.2&&(o[A+4]+=1))}function x(A){return Math.atan2(A.z,-A.x)}function w(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new iv(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},OF=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new vA(t*.5,n,a):new Rw(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},vA=class extends iv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(n,a,o,e,t,i),this.type=o}static fromJSON(e){return new vA(e.radius,e.corner,e.cornerSides)}},Pl=1e-12,rv=class{constructor(e){this.position=new G,this.startPosition=new G,this.uuid=it.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new rv(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Bm=class extends rv{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Bm(this.parent).copy(this)}},Po=class extends rv{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Bm(this),new Bm(this))}static create(e,t){let i=new Po(e,new G(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Po(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new G,t=new G){let[i,r]=this.computeTangents();return i&&r&&(wx(i,e),wx(r,t)),[e,t]}computeTangent(e=new G){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new G){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function wx(e,t=new G){let i=e.length();return t.set(-e.y/i,e.x/i)}var sv=e=>e,rl=new G,Cu=new G,IF=new G,RF=new G,BF=new G,zF=new G,yA=new E,xA=new E;function NF(e){let t=new G;t.addVectors(e.v0,rl.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new G;return i.addVectors(e.v2,Cu.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Fr(e.v0,t,i,e.v2)}function Xl(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function UF(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function FF(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function bA(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function kF(e,t,i){return Ax(e,t)&&Ax(t,i)&&zm(e.position,t.position,i.position)}function zm(e,t,i){return rl.copy(t).sub(e).cross(Cu.copy(i).sub(e))===0}function jF(e,t,i,r,s){let n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.y-t.y)/n,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.x-e.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function GF(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function VF(e,t,i,r,s,n){let a=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,u=Math.sqrt((a+l)*(a+l)+(o+h)*(o+h)),c;return bA(t,e,i)>Math.PI&&(u*=-1),Xl(h,o)?c=(o+h)*(r/u-.5)*8/3/(a-l):c=(a+l)*(r/u-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*a),n.set(i.x+c*h,i.y-c*l),[s,n]}function _x(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Ax(e,t){return zm(e.position,e.controls[1].position,t.position)&&zm(e.position,t.controls[0].position,t.position)}function HF(e,t,i,r,s=.5){let n=rl.subVectors(t,e).multiplyScalar(s).add(e),a=Cu.subVectors(i,t).multiplyScalar(s).add(t),o=IF.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=RF.subVectors(a,n).multiplyScalar(s).add(n),u=BF.subVectors(o,a).multiplyScalar(s).add(a),c=o,d=zF.subVectors(u,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,u.x,u.y,c.x,c.y,r.x,r.y]}function WF(e,t,i=12,r=!0){let s=xA.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=sv(t[l]),u=rl,c=ga(h,i);o.push(c);for(let d=0;d<=c;d++)if(h instanceof Fr||h instanceof Pn||h instanceof Gr){if(h.getPoint(d/c,u),s.set(u.x,u.y,0),n!==void 0&&FF(n,s))continue;n===void 0&&(n=yA),n.copy(s),e.setXYZ(a,s.x,s.y,s.z),a++}}return r&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),e}function XF(e,t,i,r=12,s=!0){let n=xA.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,u=sv(t[l]),c=rl,d=ga(u,r);o.push(d);for(let p=0;p<=d;p++)if(u instanceof Fr||u instanceof Pn||u instanceof Gr){if(u.getPoint(p/d,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=yA:(e.setXYZ(a,h.x,h.y,h.z),a++,e.setXYZ(a,n.x,n.y,n.z),a++),h.copy(n)}}return s&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),o}function Sx(e,t=12,i=!1){let r=[];for(let s=0,n=e.length;s<n;s++){let a=e[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=ga(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=ga(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=ga(e[0].roundedCurveCorner,t)*.5),r}function ga(e,t=12){return e&&e instanceof du?t*2:e&&(e instanceof Gr||e instanceof Dw)?1:e&&e instanceof vg?t*e.points.length:t}function qF(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=sv(t[a]),l=ga(o,i),h=rl;for(let u=0;u<=l;u++)if(o instanceof Fr||o instanceof Pn||o instanceof Gr){if(o.getPoint(u/l,h),s!==void 0&&UF(s,h,Pl))continue;s===void 0&&(s=Cu),s.copy(h),e.push(h.x,h.y),n++}}return Xl(e[0],e[e.length-2],Pl)&&Xl(e[1],e[e.length-1],Pl)&&(e.pop(),e.pop()),r&&n>1&&!(Xl(e[n-1],e[1],Pl)&&Xl(e[n-2],e[0],Pl))&&(e.push(e[0],e[1]),n++),e}var Qp=new G,YF=new G,QF=new G,ZF=new G,KF=new G,JF=new G,Nt=class extends wd{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new yr(new E(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=it.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Nt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>Po.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Nt.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=e-t;if(n<=s.points.length-1)return s.points[n];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(e);if(n>=0)return t+n;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=Qp.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=it.generateUUID()){let r;e instanceof G?r=e:r=new G(e,t);let s=new Po(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return WF(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Sx(this.points,e,!1),this.roundedCurveDivisions=Sx(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return XF(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),qF(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=ga(this.points[0].roundedCurveCorner,this.subdivision)*.5);let n=e-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],n=this.curveDivisions,a=n[e];if(_x(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Qp.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=n[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){_x(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&kF(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let c=s.roundedCurveBefore,d=s.roundedCurveAfter,p=h.getLength(),f=u.getLength(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),v=Math.min(g,m),y=1-v/p,b=v/f,x=h.getPointAt(y,Qp),w=u.getPointAt(b,YF);this._subSplitCurve(h,c,y,x,void 0),this._subSplitCurve(u,d,b,void 0,w);let A;if(this.useCubicForRoundedCorners){let S=bA(x,s.position,w)/2,_=Math.tan(S)*x.distanceTo(s.position),[M,C]=jF(x,w,_,QF,ZF),T=GF(M,C,s.position),[P,L]=VF(T,x,w,_,KF,JF);A=new Fr(x.clone(),P.clone(),L.clone(),w.clone())}else A=new Pn(x.clone(),s.position.clone(),w.clone());s.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof Gr)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let n=e,a=t,o=n.getUtoTmapping(i,0),l=HF(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return t}clone(){let e=new Nt(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,s=e.points[r+0],n=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],u=e.points[r+6],c=new Po(it.generateUUID(),new G(s,n));c.controls[0].position.set(a,o),c.controls[1].position.set(l,h),c.roundness=u,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new Nt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof Fr&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)},i=r=>{let s=[],n,a;for(n=0,a=r.length;n<a;n++)r[n]instanceof Pn&&(r[n]=NF(r[n]));for(n=0,a=r.length;n<a;n++){let h=r[n],u=n>0?r[n-1]:null,c;h instanceof Fr?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof Gr&&(c=this.createPoint(h.v1)),c!==void 0&&(u!==null&&t(c,u),s.push(c))}let o=r[r.length-1],l=!1;return o instanceof Fr?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof Gr&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof wd&&(this.shapeHoles=e.holes.map(r=>{let s=new Nt;return s.fromShape(r),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},Nm=Math.PI*2;function Zp({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function $F(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),n=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function Mx(e,t,i,r){let s=e*r-t*i<0?-1:1,n=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(n)}function e6(e,t,i,r,s,n,a,o,l,h){let u=Math.pow(s,2),c=Math.pow(n,2),d=Math.pow(a,2),p=Math.pow(o,2),f=u*c-u*p-c*d;f<0&&(f=0),f/=u*p+c*d,f=Math.sqrt(f)*(l===h?-1:1);let g=f*s/n*o,m=f*-n/s*a,v=g+(e+i)/2,y=m+(t+r)/2,b=(a-g)/s,x=(o-m)/n,w=(-a-g)/s,A=(-o-m)/n,S=Mx(1,0,b,x),_=Mx(b,x,w,A);return!h&&_>0&&(_-=Nm),h&&_<0&&(_+=Nm),{centerx:v,centery:y,ang1:S,ang2:_}}function t6({px:e,py:t,cx:i,cy:r,rx:s,ry:n,largeArcFlag:a,sweepFlag:o}){let l=[];if(s===0||n===0)return[];let h=(e-i)/2,u=(t-r)/2;if(h===0&&u===0)return[];s=Math.abs(s),n=Math.abs(n);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(u,2)/Math.pow(n,2);c>1&&(s*=Math.sqrt(c),n*=Math.sqrt(c));let d=e6(e,t,i,r,s,n,h,u,a,o),{ang1:p,ang2:f}=d,{centerx:g,centery:m}=d,v=Math.abs(f)/(Nm/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let b=0;b<y;b++)l.push($F(p,f)),p+=f;return l.map(b=>{let{x,y:w}=Zp(b[0],s,n,g,m),{x:A,y:S}=Zp(b[1],s,n,g,m),{x:_,y:M}=Zp(b[2],s,n,g,m);return{x1:x,y1:w,x2:A,y2:S,x:_,y:M}})}var yt;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(yt||(yt={}));var Zt;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Zt||(Zt={}));function ke(e,t){if(!e)throw t||"Assertion Failed!"}var ze=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){ke(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?s<n?i.t-t.t+(t.t-r.t)*(s/(s+n)):i.t-r.t+(r.t-t.t)*(n/(s+n)):0},e.edgeSign=function(t,i,r){ke(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?(i.t-r.t)*s+(i.t-t.t)*n:0},e.transEval=function(t,i,r){ke(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?s<n?i.s-t.s+(t.s-r.s)*(s/(s+n)):i.s-r.s+(r.s-t.s)*(n/(s+n)):0},e.transSign=function(t,i,r){ke(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?(i.s-r.s)*s+(i.s-t.s)*n:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,n){var a,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(a=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,i.s)):(a=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,s.s)):n.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(a=e.transEval(t,r,i),o=e.transEval(r,i,s),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,i.t)):(a=e.transSign(t,r,i),o=-e.transSign(t,s,i),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,s.t)):n.t=(r.t+i.t)/2},e}(),Dl=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),Rc=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),oo=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),Ex=function(){function e(){var t=new oo,i=new Dl,r=new Rc(0),s=new Rc(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new Rc(0),r=new Rc(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;ke(s,"Vertex can't be null!");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i;var a=i;do a.Org=s,a=a.Onext;while(a!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;ke(s,"Face can't be null");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var a=i;do a.Lface=s,a=a.Lnext;while(a!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.makeEdge=function(){var t=new oo,i=new oo,r=new Dl,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var n=new oo;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new Dl;this.makeFace_(a,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new Dl;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new oo;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),n=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(n,i),s.Org=t.Dst,n.Org=i.Org,s.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new Dl;this.makeFace_(a,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,n,a,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=i);a=t.prev,o=t.next,o.prev=a,a.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,n,a,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,a=r.Org;s=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(n.Lface),o+l-2<=t&&ze.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&ze.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(s=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,n,a,o,l,h;for(n=t,n=t;(s=n.next)!==t;n=s){ke(s.prev===n),l=s.anEdge;do ke(l.Sym!==l),ke(l.Sym.Sym===l),ke(l.Lnext.Onext.Sym===l),ke(l.Onext.Sym.Lnext===l),ke(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(ke(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){ke(a.prev===o),l=a.anEdge;do ke(l.Sym!==l),ke(l.Sym.Sym===l),ke(l.Lnext.Onext.Sym===l),ke(l.Onext.Sym.Lnext===l),ke(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(ke(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)ke(l.Sym.next===h.Sym),ke(l.Sym!==l),ke(l.Sym.Sym===l),ke(l.Org!==null),ke(l.Dst!==null),ke(l.Lnext.Onext.Sym===l),ke(l.Onext.Sym.Lnext===l);ke(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),Cx=function(){function e(){this.handle=null}return e}(),Tx=function(){function e(){this.key=null,this.node=0}return e}(),i6=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new Cx,this.handles[r]=new Tx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[i[a+1].handle].key,r[i[a].handle].key)&&++a,ke(a<=this.max),n=i[a].handle,a>this.size||this.leq(r[s].key,r[n].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t>>1,n=i[a].handle,a===0||this.leq(r[n].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,n;for(n=this.nodes.length,this.nodes.length=this.max+1,s=n;s<this.nodes.length;s++)this.nodes[s]=new Cx;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new Tx}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;ke(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),Kp=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),Px=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),r6=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new Px,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new Px;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),s6=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,n=i.eUp,a=r.eUp;if(n.Dst===s)return a.Dst===s?ze.vertLeq(n.Org,a.Org)?ze.edgeSign(a.Dst,n.Org,a.Org)<=0:ze.edgeSign(n.Dst,a.Org,n.Org)>=0:ze.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return ze.edgeSign(n.Dst,s,n.Org)>=0;var o=ze.edgeEval(n.Dst,s,n.Org),l=ze.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&ke(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){ke(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new Kp;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case yt.ODD:return(i&1)!==0;case yt.NONZERO:return i!==0;case yt.POSITIVE:return i>0;case yt.NEGATIVE:return i<0;case yt.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,n=null,a=i,o=i.eUp;a!==r;){if(a.fixUpperEdge=!1,n=e.regionBelow(a),s=n.eUp,s.Org!=o.Org){if(!n.fixUpperEdge){e.finishRegion(t,a);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,n,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,a),o=n.eUp,a=n}return o},e.addRightEdges=function(t,i,r,s,n,a){var o,l,h,u,c=!0;h=r;do ke(ze.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(n===null&&(n=e.regionBelow(i).eUp.Rprev),l=i,u=n;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===u.Org;)h.Onext!==u&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(u.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!c&&e.checkForRightSplice(t,l)&&(e.addWinding(h,u),e.deleteRegion(t,l),t.mesh.delete(u)),c=!1,l=o,u=h;l.dirty=!0,ke(l.windingNumber-h.winding===o.windingNumber),a&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=ze.vertL1dist(i,t),n=ze.vertL1dist(r,t),a=.5*n/(s+n),o=.5*s/(s+n);t.coords[0]+=a*i.coords[0]+o*r.coords[0],t.coords[1]+=a*i.coords[1]+o*r.coords[1],t.coords[2]+=a*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,n,a){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,n,a)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp;if(ze.vertLeq(s.Org,n.Org)){if(ze.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;ze.vertEq(s.Org,n.Org)?s.Org!==n.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,n.Oprev,s)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(s,n.Oprev),i.dirty=r.dirty=!0)}else{if(ze.edgeSign(s.Dst,n.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a;if(ke(!ze.vertEq(s.Dst,n.Dst)),ze.vertLeq(s.Dst,n.Dst)){if(ze.edgeSign(s.Dst,n.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,a=t.mesh.splitEdge(s),t.mesh.splice(n.Sym,a),a.Lface.inside=i.inside}else{if(ze.edgeSign(n.Dst,s.Dst,n.Org)>0)return!1;i.dirty=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(s.Lnext,n.Sym),a.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a=s.Org,o=n.Org,l=s.Dst,h=n.Dst,u,c,d=new oo,p,f;if(ke(!ze.vertEq(h,l)),ke(ze.edgeSign(l,t.event,a)<=0),ke(ze.edgeSign(h,t.event,o)>=0),ke(a!==t.event&&o!==t.event),ke(!i.fixUpperEdge&&!r.fixUpperEdge),a===o||(u=Math.min(a.t,l.t),c=Math.max(o.t,h.t),u>c))return!1;if(ze.vertLeq(a,o)){if(ze.edgeSign(h,a,o)>0)return!1}else if(ze.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),ze.intersect(l,a,h,o,d),ke(Math.min(a.t,l.t)<=d.t),ke(d.t<=Math.max(o.t,h.t)),ke(Math.min(h.s,l.s)<=d.s),ke(d.s<=Math.max(o.s,a.s)),ze.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=ze.vertLeq(a,o)?a:o,ze.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),ze.vertEq(d,a)||ze.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!ze.vertEq(l,t.event)&&ze.edgeSign(l,t.event,d)>=0||!ze.vertEq(h,t.event)&&ze.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Lnext,n.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=n.Oprev,n=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,n.Onext,s.Rprev,f,!0),!0):(ze.edgeSign(l,t.event,d)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),ze.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,s),s.Org.s=d.s,s.Org.t=d.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,a,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,n;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,n=r.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(n),r=e.regionBelow(i),n=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==n.Org)if(s.Dst!==n.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||n.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,n=r.Onext,a=e.regionBelow(i),o=i.eUp,l=a.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),ze.vertEq(o.Org,t.event)&&(t.mesh.splice(n.Oprev,o),i=e.topLeftRegion(t,i),n=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),a),h=!0),ze.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,a,null),h=!0),h){e.addRightEdges(t,i,r.Onext,n,n,!0);return}ze.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,n,a,o,l;if(s=i.eUp,ze.vertEq(s.Org,r)){ke(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!ze.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}ke(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(ke(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),ze.edgeGoesLeft(n)||(n=null),e.addRightEdges(t,i,a.Onext,o,n,!0)},e.connectLeftVertex=function(t,i){var r,s,n,a,o,l,h=new Kp;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,ze.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=ze.vertLeq(o.Dst,a.Dst)?r:s,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(i.anEdge.Sym,a.Lnext);else{var u=t.mesh.connect(o.Dnext,i.anEdge);l=u.Sym}n.fixUpperEdge?e.fixUpperEdge(t,n,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);ke(s!==null);var n=e.regionBelow(s),a=n.eUp,o=e.finishLeftRegions(t,n,null);o.Onext===a?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,a,a,!0)},e.addSentinel=function(t,i,r,s){var n=new Kp,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=s,a.Dst.s=i,a.Dst.t=s,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},e.initEdgeDict=function(t){t.dict=new r6(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,n=t.bmax[0]+i,a=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,n,a),e.addSentinel(t,s,n,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(ke(i.fixUpperEdge),ke(++r===1)),ke(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,n=t.mesh.eHead;for(i=n.next;i!==n;i=r)r=i.next,s=i.Lnext,ze.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,n=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)n++;for(n+=8,i=t.pq=new i6(n,ze.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,n;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,n=r.anEdge,ke(n.Lnext!==n),n.Lnext.Lnext===n&&(e.addWinding(n.Onext,n),t.mesh.delete(n));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!ze.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),n6=function(){function e(){this.mesh=new Ex,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=yt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,n,a,o,l=[0,0,0],h=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)n=i.coords[m],h[m]=n,f[m]=i,l[m]=n,p[m]=i;for(i=g.next;i!==g;i=i.next)for(var v=0;v<3;++v)n=i.coords[v],n<h[v]&&(h[v]=n,f[v]=i),n>l[v]&&(l[v]=n,p[v]=i);var y=0;if(l[1]-h[1]>l[0]-h[0]&&(y=1),l[2]-h[2]>l[y]-h[y]&&(y=2),h[y]>=l[y]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[y],s=p[y],u[0]=r.coords[0]-s.coords[0],u[1]=r.coords[1]-s.coords[1],u[2]=r.coords[2]-s.coords[2],i=g.next;i!==g;i=i.next)c[0]=i.coords[0]-s.coords[0],c[1]=i.coords[1]-s.coords[1],c[2]=i.coords[2]-s.coords[2],d[0]=u[1]*c[2]-u[2]*c[1],d[1]=u[2]*c[0]-u[0]*c[2],d[2]=u[0]*c[1]-u[1]*c[0],a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],a>o&&(o=a,t[0]=d[0],t[1]=d[1],t[2]=d[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,n=0,a=t.next;a!==t;a=a.next)if(s=a.anEdge,!(s.winding<=0))do n+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==a.anEdge);if(n<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,n=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),n=!0),r=this.sUnit,s=this.tUnit;var a=this.longAxis_(i);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,s[a]=0,s[(a+1)%3]=0,s[(a+2)%3]=i[a]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);n&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ze.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ze.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(ze.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(ze.edgeGoesLeft(s.Lnext)||ze.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)n=t.connect(s.Lnext,s),s=n.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(ze.edgeGoesRight(r.Lprev)||ze.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)n=t.connect(s.Lnext,s),s=n.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,n=t.eHead.next;n!==t.eHead;n=s)s=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?i:-i:r?t.delete(n):n.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var n,a=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){n=u.anEdge,l=0;do{var h=n.Org;h.n===-1&&(h.n=o,o++),l++,n=n.Lnext}while(n!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,i===Zt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(u.inside){n=u.anEdge,l=0;do{var h=n.Org;this.elements[d++]=h.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===Zt.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,u=0;n=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==s);this.elements[u++]=n,this.elements[u++]=a,n+=a}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new Ex),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,n,a){if(t===void 0&&(t=yt.ODD),i===void 0&&(i=Zt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),s6.computeInterior(this,a);var o=this.mesh;return i===Zt.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===Zt.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function _n(e){var t=e.windingRule,i=t===void 0?yt.ODD:t,r=e.elementType,s=r===void 0?Zt.POLYGONS:r,n=e.polySize,a=n===void 0?3:n,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,u=h===void 0?[0,0,1]:h,c=e.contours,d=c===void 0?[]:c,p=e.strict,f=p===void 0?!0:p,g=e.debug,m=g===void 0?!1:g;if(!d&&f)throw new Error("Contours can't be empty");if(d){var v=new n6;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<d.length;y++)v.addContour(l||2,d[y]);return v.tesselate(i,s,a,l,u,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:m?v.mesh:void 0}}}var N9=yt.ODD,U9=yt.NONZERO,F9=yt.POSITIVE,k9=yt.NEGATIVE,j9=yt.ABS_GEQ_TWO,G9=Zt.POLYGONS,V9=Zt.CONNECTED_POLYGONS,H9=Zt.BOUNDARY_CONTOURS,Um=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*Um.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*Um.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,n=0,a=new Float32Array(r,n*s,3*e);n+=3*e;let o=new Float32Array(r,n*s,3*e);n+=3*e;let l=new Float32Array(r,n*s,2*e);a.set(this.positions.slice(0,this.size*3)),o.set(this.normals.slice(0,this.size*3)),l.set(this.uvs.slice(0,this.size*2)),this.buffer=r,this.positions=a,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},wA=Um;wA.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var nv={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},_A={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},AA={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},Jp=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),SA=class extends Ve{constructor(e,t,i=0,r=12,s=3,n=yt.ODD){super(),this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegmentsInput=s,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,t/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],r),o=this._shape.shapeHoles.map(w=>{let A=w.extractShapePointsToFlatArray([],r),S=[];for(let _=A.length-1;_>=1;_-=2){let M=A[_-1],C=A[_-0];S.push(M,C)}return S}),l;try{l=_n({windingRule:n,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]})}catch{l=nv}let h;try{h=_n({windingRule:yt.ODD,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{h=_A}if(!l)throw new Error("error generating geometry");let u=l.elementCount;if(h){l.elementCount+=h.elementCount;for(let w=0;w<h.elements.length;w++){let A=h.elements[w],S=w%2===0?l.vertexCount:0;l.elements.push(A+S)}for(let w=0;w<h.vertexIndices.length;w++){let A=h.vertexIndices[w],S=l.vertexCount;l.vertexIndices.push(A+S)}for(let w=0;w<h.vertices.length;w++){let A=h.vertices[w];l.vertices.push(A)}}let c=1/0,d=-1/0,p=1/0,f=-1/0;for(let w=0,A=l.vertexCount;w<A;w++){let S=w*2,_=l.vertices[S+0],M=l.vertices[S+1];_<c&&(c=_),_>d&&(d=_),M<p&&(p=M),M>f&&(f=M)}this._minX=c,this._minY=p,this._width=d-c,this._height=f-p,this._buffer=new wA(this._computeBufferEstimatedSize(l));let g=[],m=[];for(let w=l.elementCount-1;w>=0;w--){let A=w>=u,S=w*2,_=l.elements[S+0],M=l.elements[S+1],C=_+M,T={start:_,count:M,normals:[],continuous:[],concave:[]},P=_,L=C-1,D=_+1,k=this._shape.roundedCurves.length;do{let j=P-_,U=l.vertices[L*2+0],N=l.vertices[L*2+1],B=l.vertices[P*2+0],H=l.vertices[P*2+1],Q=l.vertices[D*2+0],Y=l.vertices[D*2+1],F=B-U,se=H-N,V=Math.sqrt(F*F+se*se);F/=V,se/=V;let ee=B-Q,J=H-Y,fe=Math.sqrt(ee*ee+J*J);ee/=fe,J/=fe,T.normals[j*2+0]=-J,T.normals[j*2+1]=ee,T.concave[j]=F*J-se*ee>0;let re=l.vertexIndices[P];if(Array.isArray(re))T.continuous[j]=!1;else{let[oe,ue]=this._shape.getCurveIndexFromVertexId(re-1,!0);if(ue>0&&ue<1)T.continuous[j]=!0;else{let ye=ue===1?oe+1:oe-1;ye=(ye+k)%k;let Te=ue===1?0:1,xe=this._shape.roundedCurves[oe].getTangent(ue),we=this._shape.roundedCurves[ye].getTangent(Te);T.continuous[j]=xe.dot(we)>.95}}A&&(T.normals[j*2+0]*=-1,T.normals[j*2+1]*=-1),[L,P,D]=[P,D,D+1],D>=C&&(D-=M)}while(D!==_+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(_*2,C*2),vertexCount:M,vertexIndices:new Array(M).fill(!0).map((j,U)=>[U,U]),elements:[0,M],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(_*2,C*2)});for(let j=1;j<=this._bevelSegments;j++){let U=j/this._bevelSegments*Math.PI/2,N=(1-Math.cos(U))*this._bevelSize,B=[],H=[],Q=[],Y=[],F=0;for(let V=0;V<M;V++){let ee=V*2,J=(V-1+M)%M*2,fe=l.vertices[T.start*2+ee+0],re=l.vertices[T.start*2+ee+1],oe=-T.normals[J+0]*N,ue=-T.normals[J+1]*N,ye=-T.normals[ee+0]*N,Te=-T.normals[ee+1]*N;if(T.concave[V]||!T.concave[V]&&A){let xe=Math.atan2(ue,oe),we=Math.atan2(Te,ye);we>xe&&(we-=Math.PI*2);let Ie=we-xe;if(T.continuous[V]||A){let He=xe+Ie/2,dt=Math.cos(He)*N,I=Math.sin(He)*N;B[2*F+0]=fe+dt*(A?-1:1),B[2*F+1]=re+I*(A?-1:1),Y[F]=V,F++}else{let He=Math.max(1,Math.floor(r/4*Math.abs(Ie)/Math.PI));for(let dt=0;dt<=He;dt++){let I=xe+Ie*(dt/He),O=Math.cos(I)*N,ie=Math.sin(I)*N;B[2*F+0]=fe+O,B[2*F+1]=re+ie,Y[F]=V,F++}}}else B[2*F+0]=fe+oe,B[2*F+1]=re+ue,Y[F]=V,H[V]=F,F++,B[2*F+0]=fe,B[2*F+1]=re,Y[F]=V,F++,B[2*F+0]=fe+ye,B[2*F+1]=re+Te,Y[F]=V,Q[V]=F,F++}let se=_n({windingRule:yt.POSITIVE,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[B],edgeCreateCallback:V=>{let ee=V.Org.idx,J=Y[ee],fe=Y[(ee+1)%Y.length];V.idx=[J,fe],V.Sym.idx=[fe,J]},vertexIdCallback:V=>{let ee=V.Lprev.idx;return[ee?ee[1]:0,V.idx?V.idx[0]:0]}});if(!se)throw console.log("Error"),new Error(`error generating bevel geometry for ${j}'th loop`);if(!se.vertexCount)break;for(let V=0;V<se.vertexIndices.length;V++){let[ee,J]=se.vertexIndices[V];if(ee===J)continue;let fe=J;J<ee&&(fe+=M);for(let re=ee;re<fe;re++){let oe=re%M,ue=(re+1)%M;if(!T.continuous[oe]||!T.continuous[ue]){se.vertexIndices[V]=[ee,oe],se.vertexIndices.splice(V+1,0,[ue,J]),se.vertices.splice((V+1)*2,0,se.vertices[V*2],se.vertices[V*2+1]);break}}}W.push({bevelI:j,angle:U,size:N,boundary:se,reverseMap:Y,insetPoints:B})}let X=(j,U,N)=>{let B=0,H=j.boundary.vertexIndices.length;for(;B<H&&N(j.boundary.vertexIndices[U]);)U=(U+1)%H,B++;return B},z=g.length;for(let j=1;j<W.length;j++){let U=W[j-1],N=W[j],B=U.boundary.vertexIndices.length,H=N.boundary.vertexIndices.length;if(!B||!H)break;let Q=T.concave.length,Y=0,F=Jp(Y,M);for(;!U.boundary.vertexIndices.filter(F).length||!N.boundary.vertexIndices.filter(F).length;)Y++,F=Jp(Y,M);let se=U.boundary.vertexIndices.findIndex(F),V=N.boundary.vertexIndices.findIndex(F);do se=(se+1)%B;while(F(U.boundary.vertexIndices[se]));do V=(V+1)%H;while(F(N.boundary.vertexIndices[V]));Y=(Y+1)%M;let ee=Y,J=this._buildBevelVert(T,U,(se-1+B)%B),fe=this._buildBevelVert(T,N,(V-1+H)%H),re=J,oe=fe,ue,ye,Te=!1;do{F=Jp(Y,M);let xe=X(U,se,F),we=X(N,V,F),Ie=Te;if(Te=!1,xe&&!we){for(let He=0;He<xe;He++)ue=this._buildBevelVert(T,U,(se+He)%B,He/(xe-1)),g.push(re.topN,ue.topP,oe.topN),g.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue;Te=!0}else if(!xe&&we)for(let He=0;He<we;He++)ye=this._buildBevelVert(T,N,(V+He)%H,He/(we-1)),g.push(oe.topN,re.topP,ye.topP),g.push(re.bottomP,oe.bottomN,ye.bottomP),oe=ye;else if(xe&&we)if(ue=this._buildBevelVert(T,U,se,0),ye=this._buildBevelVert(T,N,V,0),Ie?(g.push(re.topN,ye.topP,oe.topN),g.push(re.topN,ue.topP,ye.topP),g.push(ye.bottomP,re.bottomN,oe.bottomN),g.push(ye.bottomP,ue.bottomP,re.bottomN)):(g.push(oe.topN,re.topN,ue.topP),g.push(oe.topN,ue.topP,ye.topP),g.push(ue.bottomP,re.bottomN,oe.bottomN),g.push(ue.bottomP,oe.bottomN,ye.bottomP)),re=ue,oe=ye,xe===we)for(let He=1;He<xe;He++)ue=this._buildBevelVert(T,U,(se+He)%B,He/(xe-1)),ye=this._buildBevelVert(T,N,(V+He)%H,He/(we-1)),g.push(re.topN,ue.topP,oe.topN),g.push(oe.topN,ue.topP,ye.topP),g.push(ue.bottomP,re.bottomN,oe.bottomN),g.push(ue.bottomP,oe.bottomN,ye.bottomP),re=ue,oe=ye;else if(xe>we){let He=xe/we,dt=0;for(let I=1;I<xe;I++)ue=this._buildBevelVert(T,U,(se+I)%B,I/(xe-1)),g.push(re.topN,ue.topP,oe.topN),g.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue,I>(dt+1)*He&&(dt++,ye=this._buildBevelVert(T,N,(V+dt)%H,dt/(we-1)),g.push(oe.topN,ue.topP,ye.topP),g.push(ue.bottomP,oe.bottomN,ye.bottomP),oe=ye)}else{let He=we/xe,dt=0;for(let I=1;I<we;I++)ye=this._buildBevelVert(T,N,(V+I)%H,I/(we-1)),g.push(oe.topN,ue.topP,ye.topP),g.push(ue.bottomP,oe.bottomN,ye.bottomP),oe=ye,I>(dt+1)*He&&(dt++,ue=this._buildBevelVert(T,U,(se+dt)%B,dt/(xe-1)),g.push(re.topN,ue.topP,oe.topN),g.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue)}se=(se+xe)%B,V=(V+we)%H,Y=(Y+1)%Q}while(Y!==ee)}if(this._buildWall(W,T,g),A){let j=[];for(let U=g.length-1;U>=z+2;U-=3){let N=g[U-2],B=g[U-1],H=g[U-0];j.push(H,B,N)}g.splice(z,g.length-z,...j)}if(A){let j=[];for(let U=W[W.length-1].boundary.vertices.length-1;U>=1;U-=2){let N=W[W.length-1].boundary.vertices[U-1],B=W[W.length-1].boundary.vertices[U-0];j.push(N,B)}m.push(j)}if(!A){let j=W[W.length-1],U;try{U=_n({windingRule:W.length>1?yt.POSITIVE:yt.ODD,elementType:Zt.POLYGONS,vertexSize:2,strict:!0,contours:[j.insetPoints,...m]})}catch{U=AA}if(!U)throw new Error("Error generating geometry for surface");o.length===0&&Object.assign(this,{capStartIndex:g.length});for(let N=0;N<U.elementCount*3;N+=3){let B=this._buildSurfaceVert(U,U.elements[N+0]),H=this._buildSurfaceVert(U,U.elements[N+1]),Q=this._buildSurfaceVert(U,U.elements[N+2]);g.push(B.top,H.top,Q.top),g.push(Q.bottom,H.bottom,B.bottom)}}this.vertexCache={}}this._buffer.shrink();let v=new Xe(Uint32Array.from(g),1),y=new Xe(this._buffer.positions,3),b=new Xe(this._buffer.normals,3),x=new Xe(this._buffer.uvs,2);y.needsUpdate=!0,b.needsUpdate=!0,x.needsUpdate=!0,v.needsUpdate=!0,this.setAttribute("position",y),this.setAttribute("normal",b),this.setAttribute("uv",x),this.setIndex(v)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}_buildSurfaceVert(e,t){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let r=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(r-this._minX)/this._width,a=(s-this._minY)/this._height,o=this._buffer.get(2),l=o*3,h=o*2,u={top:o+0,bottom:o+1};return this._buffer.positions[l+0]=r,this._buffer.positions[l+1]=s,this._buffer.positions[l+2]=this._depth,this._buffer.normals[l+0]=0,this._buffer.normals[l+1]=0,this._buffer.normals[l+2]=1,this._buffer.uvs[h+0]=n,this._buffer.uvs[h+1]=a,this._buffer.positions[l+3]=r,this._buffer.positions[l+4]=s,this._buffer.positions[l+5]=0,this._buffer.normals[l+3]=0,this._buffer.normals[l+4]=0,this._buffer.normals[l+5]=-1,this._buffer.uvs[h+2]=n,this._buffer.uvs[h+3]=a,this.vertexCache[i]=u,u}_buildBevelVert(e,t,i,r=1){let s=`${t.bevelI}:${i}`;if(s in this.vertexCache)return this.vertexCache[s];let[n,a]=t.boundary.vertexIndices[i],o,l,h,u;n!==a?(l=n,o=a,u=!1,h=e.continuous[l]&&e.continuous[o]):(o=n,l=(o-1+e.count)%e.count,u=e.concave[o]&&t.bevelI>0,h=e.continuous[o]||u);let c=Math.cos(t.angle),d=Math.sin(t.angle),p=i*2,f=o*2,g=l*2,m=t.boundary.vertices[p+0],v=t.boundary.vertices[p+1],y=(1-d)*this._bevelSize,b=(m-this._minX)/this._width,x=(v-this._minY)/this._height,w=e.normals[f+0],A=e.normals[f+1],S=e.normals[g+0],_=e.normals[g+1];if(u){let L=S-w,D=_-A;w=w+L*(1-r),A=A+D*(1-r);let k=Math.sqrt(w*w+A*A);w/=k,A/=k}let M=this._buffer.get(h?2:4),C=M*3,T=M*2,P={i,fi:o,topP:M+0,topN:M+0,bottomP:M+1,bottomN:M+1};return this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=w*c,this._buffer.normals[C+1]=A*c,this._buffer.normals[C+2]=d,this._buffer.uvs[T+0]=b,this._buffer.uvs[T+1]=x,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=w*c,this._buffer.normals[C+4]=A*c,this._buffer.normals[C+5]=-d,this._buffer.uvs[T+2]=x,this._buffer.uvs[T+3]=b,h||(M+=2,C+=6,T+=4,P.topP=M+0,P.bottomP=M+1,this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=S*c,this._buffer.normals[C+1]=_*c,this._buffer.normals[C+2]=d,this._buffer.uvs[T+0]=b,this._buffer.uvs[T+1]=x,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=S*c,this._buffer.normals[C+4]=_*c,this._buffer.normals[C+5]=-d,this._buffer.uvs[T+2]=x,this._buffer.uvs[T+3]=b),this.vertexCache[s]=P,P}clone(){let e=new SA(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=bu(this.userData),e}},MA=class extends Ve{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=yt.ODD,this.elementType=Zt.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:yt.ODD,elementType:Zt.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(d=>d.extractShapePointsToFlatArray([],this._curveSegments)),n,a=!0,o=!0,l,h;for(let d=0,p=r.length/2;d<p;d++){let f=d*2,g=r[f+0],m=r[f+1];if(l!==void 0&&g!==l&&(a=!1),h!==void 0&&m!==h&&(o=!1),l=g,h=m,!a&&!o)break}if(!a&&!o)try{n=_n({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{n=nv}let u=n?.vertexCount??1,c=n?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(u*3),3),this._normalAttribute=new Xe(new Float32Array(u*3),3),this._uvAttribute=new Xe(new Float32Array(u*2),2),this._indexAttribute=new Xe(new Uint32Array(c*3),1),n){let d=1/0,p=-1/0,f=1/0,g=-1/0;for(let y=0,b=u;y<b;y++){let x=y*2,w=n.vertices[x+0],A=n.vertices[x+1];w<d&&(d=w),w>p&&(p=w),A<f&&(f=A),A>g&&(g=A)}let m=p-d,v=g-f;for(let y=0,b=u;y<b;y++){let x=y*2,w=n.vertices[x+0],A=n.vertices[x+1],S=(w-d)/m,_=(A-f)/v;this._positionAttribute.setXYZ(y,w,A,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,_)}for(let y=0,b=c;y<b;y++){let x=y*3,w=n.elements[x+0],A=n.elements[x+1],S=n.elements[x+2];this._indexAttribute.setX(x+0,w),this._indexAttribute.setX(x+1,A),this._indexAttribute.setX(x+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(n?.elementCount??1)*3)}clone(){let e=new MA(this._shape,this._curveSegments);return e.userData=bu(this.userData),e}},EA=class extends SA{constructor(e,t,i=0,r=12,s=3,n=yt.ODD){super(e,t,i,r,s,n),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}clone(){let e=new EA(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=bu(this.userData),e}},Ta=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:yt.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=e.shape??t?.shape,o=a?.roundness??i.roundness;a!==void 0&&(a instanceof Nt?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new Nt(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new Nt(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:n,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:n,windingRule:a}=e.parameters;e.shape.roundness=n;let o;return t<=0?o=new MA(e.shape,s,{windingRule:a}):o=new EA(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},CA=Math.PI*2,av=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Nt?e.shape:new Nt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,u=t*.5,c=i*.5,d=a6(h,u,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=Ta.create({shape:h,parameters:{subdivisions:d,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function a6(e,t,i,r,s,n){if(r>=CA)return s>30||s%4===0?(l6(e,t,i,n),Math.round(s/4)):Dx(e,r,s,t,i,n);r=Math.max(r,.001);let a={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=t6({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?o6(e,a.x,a.y,h,s,t,i,n):Dx(e,r,s,t,i,n)}function o6(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(Do(t,i));for(let h=0,u=r.length;h<u;h++){let c=r[h],d=e.points[h],p=Do(c.x,c.y);d.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?TA(e,n,a,o):e.addPoint(Do(0,0)),l}function Dx(e,t,i,r,s,n){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*s;e.addPoint(Do(h,u))}return t<CA?n>0?TA(e,r,s,n):e.addPoint(Do(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&PA(e,r,s,n)),1}function l6(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(Bc(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(Bc(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(Bc(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(Bc(s,n-i,s+o,n-i,s-o,n-i)),r>0&&PA(e,t,i,r)}function Do(e,t){return new Po(it.generateUUID(),new G(e,t))}function Bc(e,t,i,r,s,n){let a=Do(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function TA(e,t,i,r){DA(e,t,i,r).forEach(s=>e.addPoint(s))}function PA(e,t,i,r){let s=DA(e,t,i,r),n=new Nt;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function DA(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new G(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=it.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var h6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:c}=e.parameters,d=new ov(!1,t,i,r,s,n,a,o,l,h,u,c);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},ov=class extends Ve{constructor(e=!0,t=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,u=1,c=1,d=!1){super();let p=e&&n===1;p&&(c=0),u>100&&(u=100);let f=()=>new E,g=new E,m=f(),v=f(),y=f(),b,x,w,A,S,_,M,C,T=f(),P=f(),L=f(),D=f(),k=f(),W=f(),X=f(),z=f(),j=i-2*o+.001,U=j/n,N=Math.ceil(a*n),B=N+1,H=j/N,Q=-j/2,Y=h+1,F=2*Math.PI/h,se=Math.PI/2/c,V=.01,ee=Math.min((1-u/100)*o,o-V),J=o-ee,fe=0,re=2,oe=c*re+re,ue=Y*oe/re,ye=ue+Y*B,Te=Y*(B+oe),[xe,we,Ie]=[3,3,2].map(Ee=>Array(Te*Ee).fill(0)),He=[],dt=s-o;function I(Ee,_e){let Le=Math.PI/2;_=_e*H,C=2*Math.PI*(_%U)/U+Le,_+=Q,M=Math.sin(C)*dt,S=Math.cos(C)*dt,e?Ee.set(S,M,_):Ee.set(S,_,M)}I(g,-1e-10),I(m,0),T.copy(g),I(g,1);let O=g.distanceTo(m),ie=p?0:J+ee,pe=O*N+2*ie,me=ee,be=pe-ie;for(let Ee=0;Ee<=N;Ee++){I(v,Ee),z.subVectors(v,T).normalize(),T.copy(v),W.copy(v).setComponent(+e+1,0).normalize(),X.crossVectors(z,W).normalize();let _e=Ee===0,Le=Ee===N,Ne=_e?3*Math.PI/2:se,at=_e?me:be,Mt=_e?Y:ye,Wt=_e?0:Te-Y,q=z.clone().multiplyScalar(_e?-J:J).add(v),ne=z.clone().multiplyScalar(_e?-1:1).normalize();for(let de=0;de<Y;de++){let Ae=de*F;if(P.addVectors(g.copy(W).multiplyScalar(o*Math.cos(Ae)),m.copy(X).multiplyScalar(o*Math.sin(Ae))),L.copy(P).normalize(),_e||Le){p||(fe=Wt+de,[0,1,2].forEach(De=>{xe[fe*3+De]=q.getComponent(De),we[fe*3+De]=ne.getComponent(De)}),Ie[fe*2]=+Le,Ie[fe*2+1]=de/h),m.copy(L).multiplyScalar(ee),y.addVectors(v,m);for(let De=0;De<c;De++){let ot=De*se+Ne;D.addVectors(g.copy(z).multiplyScalar(J*Math.sin(ot)),m.copy(L).multiplyScalar(J*Math.cos(ot))),k.copy(D).normalize(),m.addVectors(y,D),D.normalize(),fe=Mt+De*Y+de,[0,1,2].forEach(Ft=>{xe[fe*3+Ft]=m.getComponent(Ft),we[fe*3+Ft]=k.getComponent(Ft)});let Xt=+_e+Math.sin(ot);Ie[fe*2]=(at+J*Xt)/pe,Ie[fe*2+1]=de/h}}m.addVectors(v,P),fe=ue+Ee*Y+de,[0,1,2].forEach(De=>{xe[fe*3+De]=m.getComponent(De),we[fe*3+De]=L.getComponent(De)}),Ie[fe*2]=(ie+Ee*O)/pe,Ie[fe*2+1]=de/h}}let We=B+2*c+re,Me=1,[ce,Fe]=[+p,We-1];d&&(Fe-=1);for(let Ee=ce;Ee<=Fe-1;Ee++){let _e=p&&Ee===Fe-1;for(let Le=0;Le<Y-1;Le++)b=Ee*Y+Le,x=b+1,w=(_e?Le:b)+Y,A=(_e?Le+1:x)+Y,Ee===0?He.push(x,A,w):Ee===We-2?He.push(b,x,w):He.push(b,x,w,x,A,w)}this.setIndex(He),this.setAttribute("position",new Ce(xe,3)),this.setAttribute("normal",new Ce(we,3)),this.setAttribute("uv",new Ce(Ie,2))}},c6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new LA(t*.5,n,a):new Fw(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},LA=class extends iv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,n,a,e,t,i),this.type=a}static fromJSON(e){return new LA(e.radius,e.corner,e.cornerSides)}},d6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new wd;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new Ow(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},Zr=new ve,$p=new bt,zc=new E,Kd=class extends Hi{constructor(){super(),this.uuid=it.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new Ai().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];s.normal.applyMatrix3(t).normalize();for(let n=0,a=s.vertexNormals.length;n<a;n++)s.vertexNormals[n].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return Zr.makeRotationX(e),this.applyMatrix4(Zr),this}rotateY(e){return Zr.makeRotationY(e),this.applyMatrix4(Zr),this}rotateZ(e){return Zr.makeRotationZ(e),this.applyMatrix4(Zr),this}translate(e,t,i){return Zr.makeTranslation(e,t,i),this.applyMatrix4(Zr),this}scale(e,t,i){return Zr.makeScale(e,t,i),this.applyMatrix4(Zr),this}lookAt(e){return $p.lookAt(e),$p.updateMatrix(),this.applyMatrix4($p.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,n=r.normal,a=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let c=0;c<s.count;c++)t.vertices.push(new E().fromBufferAttribute(s,c)),a!==void 0&&t.colors.push(new Ge().fromBufferAttribute(a,c));function h(c,d,p,f){let g=a===void 0?[]:[t.colors[c].clone(),t.colors[d].clone(),t.colors[p].clone()],m=n===void 0?[]:[new E().fromBufferAttribute(n,c),new E().fromBufferAttribute(n,d),new E().fromBufferAttribute(n,p)],v=new Fm(c,d,p,m,g,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new G().fromBufferAttribute(o,c),new G().fromBufferAttribute(o,d),new G().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new G().fromBufferAttribute(l,c),new G().fromBufferAttribute(l,d),new G().fromBufferAttribute(l,p)])}let u=e.groups;if(u.length>0)for(let c=0;c<u.length;c++){let d=u[c],p=d.start,f=d.count;for(let g=p,m=p+f;g<m;g+=3)i!==void 0?h(i.getX(g),i.getX(g+1),i.getX(g+2),d.materialIndex):h(g,g+1,g+2,d.materialIndex)}else if(i!==void 0)for(let c=0;c<i.count;c+=3)h(i.getX(c),i.getX(c+1),i.getX(c+2));else for(let c=0;c<s.count;c+=3)h(c,c+1,c+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(zc).negate(),this.translate(zc.x,zc.y,zc.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new ve;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new E,t=new E;for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=this.vertices[s.a],a=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,a),t.subVectors(n,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new E;if(e){let i=new E,r=new E;for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=this.vertices[a.a],l=this.vertices[a.b],h=this.vertices[a.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[a.a].add(i),t[a.b].add(i),t[a.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=s.vertexNormals;n.length===3?(n[0].copy(t[s.a]),n[1].copy(t[s.b]),n[2].copy(t[s.c])):(n[0]=t[s.a].clone(),n[1]=t[s.b].clone(),n[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,n=r.vertexNormals.length;s<n;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new Kd;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,n=this.morphNormals[t].vertexNormals;for(let a=0,o=this.faces.length;a<o;a++){let l=new E,h={a:new E,b:new E,c:new E};s.push(l),n.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(a.normal),l.a.copy(a.vertexNormals[0]),l.b.copy(a.vertexNormals[1]),l.c.copy(a.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Kt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Mr),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,s=this.vertices.length,n=this.vertices,a=e.vertices,o=this.faces,l=e.faces,h=this.colors,u=e.colors;t!==void 0&&(r=new Ai().getNormalMatrix(t));for(let c=0,d=a.length;c<d;c++){let p=a[c].clone();t!==void 0&&p.applyMatrix4(t),n.push(p)}for(let c=0,d=u.length;c<d;c++)h.push(u[c].clone());for(let c=0,d=l.length;c<d;c++){let p=l[c],f,g,m=p.vertexNormals,v=p.vertexColors,y=new Fm(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let b=0,x=m.length;b<x;b++)f=m[b].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let b=0,x=v.length;b<x;b++)g=v[b],y.vertexColors.push(g.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,b=m.length;y<b;y++)v.push(m[y].clone());this.faceVertexUvs[c].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],s=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[u]]}let n=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let u=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(u[c]===u[(c+1)%3]){n.push(o);break}}for(let o=n.length-1;o>=0;o--){let l=n[o];this.faces.splice(l,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(l,1)}let a=this.vertices.length-i.length;return this.vertices=i,a}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new E(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],n,a;r&&r.length===t&&(n=[]),s&&s.length===t&&(a=[]);for(let o=0;o<t;o++){let l=e[o]._id;n&&n.push(r[l]),a&&a.push(s[l])}n&&(this.faceVertexUvs[0]=n),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],s={},n=[],a={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],g=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,b=f.vertexNormals.length>0,x=f.color.r!==1||f.color.g!==1||f.color.b!==1,w=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,g),A=h(A,2,m),A=h(A,3,v),A=h(A,4,y),A=h(A,5,b),A=h(A,6,x),A=h(A,7,w),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let S=this.faceVertexUvs[0][p];i.push(d(S[0]),d(S[1]),d(S[2]))}if(y&&i.push(u(f.normal)),b){let S=f.vertexNormals;i.push(u(S[0]),u(S[1]),u(S[2]))}if(x&&i.push(c(f.color)),w){let S=f.vertexColors;i.push(c(S[0]),c(S[1]),c(S[2]))}}function h(p,f,g){return g?p|1<<f:p&~(1<<f)}function u(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return s[f]!==void 0||(s[f]=r.length/3,r.push(p.x,p.y,p.z)),s[f]}function c(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return a[f]!==void 0||(a[f]=n.length,n.push(p.getHex())),a[f]}function d(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,n.length>0&&(e.data.colors=n),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new Kd().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let c=0,d=t.length;c<d;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,d=i.length;c<d;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,d=r.length;c<d;c++)this.faces.push(r[c].clone());for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,b=m.length;y<b;y++){let x=m[y];v.push(x.clone())}this.faceVertexUvs[c].push(v)}}let s=e.morphTargets;for(let c=0,d=s.length;c<d;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let f=0,g=s[c].vertices.length;f<g;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,g=s[c].normals.length;f<g;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let n=e.morphNormals;for(let c=0,d=n.length;c<d;c++){let p={};if(n[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,g=n[c].vertexNormals.length;f<g;f++){let m=n[c].vertexNormals[f],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(n[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,g=n[c].faceNormals.length;f<g;f++)p.faceNormals.push(n[c].faceNormals[f].clone())}this.morphNormals.push(p)}let a=e.skinWeights;for(let c=0,d=a.length;c<d;c++)this.skinWeights.push(a[c].clone());let o=e.skinIndices;for(let c=0,d=o.length;c<d;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,d=l.length;c<d;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new u6().fromGeometry(this),t=new Ve,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Nc.call(new Xe(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Nc.call(new Xe(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",Lx.call(new Xe(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",Ox.call(new Xe(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",Ox.call(new Xe(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],n=e.morphTargets[r];for(let a=0,o=n.length;a<o;a++){let l=n[a],h=new Ce(l.data.length*3,3);h.name=l.name,s.push(Nc.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Ce(e.skinIndices.length*4,4);t.setAttribute("skinIndex",Ix.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Ce(e.skinWeights.length*4,4);t.setAttribute("skinWeight",Ix.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new Ve,i=e.geometry;if(e.isPoints||e.isLine){let r=new Ce(i.vertices.length*3,3),s=new Ce(i.colors.length*3,3);if(t.setAttribute("position",Nc.call(r,i.vertices)),t.setAttribute("color",Lx.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new Ce(i.lineDistances.length,1);t.setAttribute("lineDistance",p6.call(n,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};Kd.prototype.isGeometry=!0;var u6=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,n=e.faces;for(r=0;r<n.length;r++){let a=n[r];a.materialIndex!==s&&(s=a.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,s=r[0]&&r[0].length>0,n=r[1]&&r[1].length>0,a=e.morphTargets,o=a.length,l;if(o>0){l=[];for(let m=0;m<o;m++)l[m]={name:a[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,u=h.length,c;if(u>0){c=[];for(let m=0;m<u;m++)c[m]={name:h[m].name,data:[]};this.morphTargets.normal=c}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,g=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let v=t[m];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let x=v.normal;this.normals.push(x,x,x)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let x=v.color;this.colors.push(x,x,x)}if(s===!0){let x=r[0][m];x!==void 0?this.uvs.push(x[0],x[1],x[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new G,new G,new G))}if(n===!0){let x=r[1][m];x!==void 0?this.uvs2.push(x[0],x[1],x[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new G,new G,new G))}for(let x=0;x<o;x++){let w=a[x].vertices;l[x].data.push(w[v.a],w[v.b],w[v.c])}for(let x=0;x<u;x++){let w=h[x].vertexNormals[m];c[x].data.push(w.a,w.b,w.c)}f&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},Fm=class{constructor(e,t,i,r,s,n=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new E,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Ge,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=n}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function p6(e){return this.array.set(e),this}function Lx(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new Ge),t[i++]=n.r,t[i++]=n.g,t[i++]=n.b}return this}function Ox(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new G),t[i++]=n.x,t[i++]=n.y}return this}function Nc(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new E),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z}return this}function Ix(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new $e),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z,t[i++]=n.w}return this}var f6=["a","b","c"];function m6(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function ef(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function tf(e,t,i,r,s,n){let a=Math.min(e,t),o=Math.max(e,t),l=a+"_"+o,h;if(r.has(l))h=r.get(l);else{let u=i[a],c=i[o];h={a:u,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),n[e].edges.push(h),n[t].edges.push(h)}function g6(e,t,i,r){let s,n,a;for(s=0,n=e.length;s<n;s++)i[s]={edges:[]};for(s=0,n=t.length;s<n;s++)a=t[s],tf(a.a,a.b,e,r,a,i),tf(a.b,a.c,e,r,a,i),tf(a.c,a.a,e,r,a,i)}function Uc(e,t,i,r,s){e.push(new Fm(t,i,r,void 0,void 0,s))}function Ka(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function Fc(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var v6=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Ve?e=new Kd().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new E,i,r,s,n,a,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,c=[],d=new Map;g6(o,l,c,d);let p=[],f,g,m,v,y,b,x;for(let se of Array.from(d.keys())){for(g=d.get(se),m=new E,y=3/8,b=1/8,x=g.faces.length,x!=2&&(y=.5,b=0,x!=1),m.addVectors(g.a,g.b).multiplyScalar(y),t.set(0,0,0),n=0;n<x;n++){for(v=g.faces[n],a=0;a<3&&(f=o[m6(v,f6[a])],!(f!==g.a&&f!==g.b));a++);f&&t.add(f)}t.multiplyScalar(b),m.add(t),g.newEdge=p.length,p.push(m)}let w,A,S,_,M,C,T,P=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],M=c[r].edges,i=M.length,i==3?w=3/16:i>3&&(w=3/(8*i)),A=1-i*Number(w),S=w,i<=2&&(i==2?(A=3/4,S=1/8):i==1||i==0),T=C.clone().multiplyScalar(A),t.set(0,0,0),n=0;n<i;n++)_=M[n],f=_.a!==C?_.a:_.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),P.push(T)}let L=P.concat(p),D=P.length,k,W,X,z=[],j=[],U,N,B,H,Q=new G,Y=new G,F=new G;for(r=0,s=l.length;r<s;r++)v=l[r],k=Number(ef(v.a,v.b,d).newEdge)+D,W=Number(ef(v.b,v.c,d).newEdge)+D,X=Number(ef(v.c,v.a,d).newEdge)+D,Uc(z,k,W,X,v.materialIndex),Uc(z,v.a,k,X,v.materialIndex),Uc(z,v.b,W,k,v.materialIndex),Uc(z,v.c,X,W,v.materialIndex),u&&(U=h[r],N=U[0],B=U[1],H=U[2],Q.set(Ka(N.x,B.x),Ka(N.y,B.y)),Y.set(Ka(B.x,H.x),Ka(B.y,H.y)),F.set(Ka(N.x,H.x),Ka(N.y,H.y)),Fc(j,Q,Y,F),Fc(j,N,Q,F),Fc(j,B,Y,Q),Fc(j,H,F,Y));e.vertices=L,e.faces=z,u&&(e.faceVertexUvs[0]=j)}},$t=new E,y6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new Ve().copy(new vs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize($t),r={width:$t.x,height:$t.y,depth:$t.z,subdivisions:0}):r=t.parameters;let s={...r,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,n=e.geometry??new Ve().copy(new vs(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize($t)):$t.set(a.width,a.height,a.depth),(t!==$t.x||i!==$t.y||r!==$t.z)&&n.scale($t.x===0?1:t/$t.x,$t.y===0?1:i/$t.y,$t.z===0?1:r/$t.z);let o=n.originalGeometry;return s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new v6(s).modify(o).toBufferGeometry()):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()),o!==void 0&&Object.assign(n,{originalGeometry:o}),delete e.geometry,Object.assign(n,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new Vw(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize($t);let n=100/$t.x;Object.assign(s.parameters,{width:100,height:$t.y*n,depth:$t.z*n}),t(this.build(s))})}},OA=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof Nt?e.shape:new Nt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5,c=0,d=0,p=2*Math.PI/r;for(let g=0;g<r;g++){let m=p*g,v=c+Math.sin(m)*h,y=d+Math.cos(m)*u;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let g=0,m=l.points.length;g<m;g++)l.points[g].roundness=s;l.roundness=s,l.update();let f=Ta.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},x6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=new w6(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Ll(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function rf(e,t,i,r,s,n){let a=t.clone().sub(e),o=i.clone().sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(e),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function b6(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var w6=class extends Ve{constructor(e=.5,t=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],u=[],c=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),g=2*Math.PI/i,m=(i-2)*Math.PI/i,v=Math.PI-m,y=new E(0,-d,0),b=new E(0,d,0),x=new G(e,-d),w=new G(f,-d),A=new G(0,b.y).sub(w),S=new G(0,b.y).sub(x),_=new G(A.y,-A.x).normalize(),M=new G(S.y,-S.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;n=Math.min(n,C);let T;{let z=new E(_.x,_.y,0),j=new E(Math.cos(g)*z.x,z.y,Math.sin(g)*z.x);T=z.angleTo(j)}let P=n/Math.tan((Math.PI-A.angle())/2),L=n/Math.tan((Math.PI-T)/2),D=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),u.push(0,0);let z=c++,j=[],U=x.clone(),N=P/Math.cos(Math.PI/i);U.x-=N;for(let B=0;B<i;B++){let H=B/i*Math.PI*2+p,Q=new G(Math.sin(H),Math.cos(H));Ll(U,Q,D),l.push(D.x,D.y,D.z),h.push(0,-1,0),u.push(0,0),j.push(c++)}for(let B=0;B<j.length;B++)o.push(j[B],z,j[(B+1)%j.length])}let k=[];{let z=new E,j=new E,U=new E,N=new E,B=new E,H=new E;for(let Q=0;Q<i;Q++){let Y=Q/i*Math.PI*2+p,F=(Q+.5)/i*Math.PI*2+p,se=(Q+1)/i*Math.PI*2+p,V=new G(Math.sin(Y),Math.cos(Y)),ee=new G(Math.sin(F),Math.cos(F)),J=new G(Math.sin(se),Math.cos(se));Ll(x,V,j),Ll(x,J,U),Ll(_,ee,z),rf(b,j,U,L,L,N),l.push(N.x,N.y,N.z),rf(j,b,U,L,P,B),l.push(B.x,B.y,B.z),rf(U,j,b,P,L,H),l.push(H.x,H.y,H.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),u.push(0,0),u.push(0,0),u.push(0,0);let fe=c++,re=c++,oe=c++;if(o.push(fe,re,oe),n>0){{let Te=j.clone().add(U).multiplyScalar(.5),xe=b.clone().sub(Te).normalize(),we=y.clone().sub(Te).normalize().add(xe).normalize().multiplyScalar(-1),Ie=H.clone().sub(B);W(Te,Ie,we,A.angle())}let ue,ye;{let Te=new E;Ll(M,J,Te);let xe=H.clone().add(N).multiplyScalar(.5);xe=b6(xe,U,b);let we=H.clone().sub(N);[ue,ye]=W(xe,we,Te,T,N.y)}{let Te=ue,xe=Te.clone().setY(0).normalize(),we=new E(0,-1,0),Ie=xe.clone().cross(we);X(Te,xe,we,Ie)}k.concat(ye);{let Te=A.angle(),xe=Math.PI-Te,we=b.clone();we.y-=n/Math.sin(Te-Math.PI/2);let Ie=new E,He=[];for(let I=0;I<a;I++){let O=[],ie=Math.PI/2-xe*I/a,pe=Math.cos(ie),me=Math.sin(ie),be=F;for(let We=0;We<=I;We++){let Me=Math.cos(be),ce=Math.sin(be);z.x=pe*ce,z.y=me,z.z=pe*Me,Ie.copy(we).addScaledVector(z,n),l.push(Ie.x,Ie.y,Ie.z),h.push(z.x,z.y,z.z),u.push(0,0),O.push(c++),be+=Math.PI*2/I/i}He.push(O)}ye.reverse(),He.push(ye);let dt=He.length-1;for(let I=0;I<dt;I++){let O=He[I],ie=He[I+1],pe=O.length-1;o.push(ie[1],O[0],ie[0]);for(let me=1;me<=pe;me++)o.push(O[me],O[me-1],ie[me]),o.push(ie[me+1],O[me],ie[me])}}}}}this.setIndex(o),this.setAttribute("position",new Ce(l,3)),this.setAttribute("normal",new Ce(h,3)),this.setAttribute("uv",new Ce(u,2));function W(z,j,U,N,B){let H=-N/2,Q=(Math.PI-N)/2,Y=j.clone().normalize().cross(U);z.addScaledVector(U,-n/Math.sin(Q));let F=new E,se=new E,V=1,ee=c,J=[];for(let fe=0;fe<=a;fe++){let re=H+fe/a*N;se.set(0,0,0),se.addScaledVector(Y,Math.sin(re)),se.addScaledVector(U,Math.cos(re));for(let oe=0;oe<=V;oe++){let ue=oe/V-.5;if(F.copy(z),F.addScaledVector(j,ue),F.addScaledVector(se,n),B!=null){let ye=Math.max(0,F.y-B);F.addScaledVector(j,-ye/j.y)}l.push(F.x,F.y,F.z),h.push(se.x,se.y,se.z),u.push(0,0),oe===0&&J.push(c),c++}}for(let fe=0;fe<a;fe++)for(let re=0;re<V;re++){let oe=ee+re+(V+1)*fe,ue=oe+(V+1),ye=ue+1,Te=oe+1;o.push(oe,ue,Te),o.push(ue,ye,Te)}return[z.clone().addScaledVector(j,.5),J]}function X(z,j,U,N){let B=Math.PI/2,H=S.angle()-B,Q=[],Y=new E,F=new E;for(let V=0;V<=a;V++){let ee=[],J=V/a;for(let fe=0;fe<=V;fe++){let re=((V?fe/V:0)-.5)*v,oe=Math.cos(re),ue=Math.sin(re),ye=Math.atan(Math.tan(H)*oe),Te=(B+ye)*J,xe=Math.cos(Te),we=Math.sin(Te);Y.set(0,0,0),Y.addScaledVector(j,we*oe),Y.addScaledVector(U,xe),Y.addScaledVector(N,we*ue),F.copy(z).addScaledVector(Y,n),l.push(F.x,F.y,F.z),h.push(Y.x,Y.y,Y.z),u.push(0,0),ee.push(c++)}Q.push(ee)}let se=Q.length-1;for(let V=0;V<se;V++){let ee=Q[V],J=Q[V+1],fe=ee.length-1;o.push(ee[0],J[1],J[0]);for(let re=1;re<=fe;re++)o.push(ee[re-1],ee[re],J[re]),o.push(ee[re],J[re+1],J[re])}}}},IA=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof Nt?e.shape:new Nt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},u={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function d(x,w,A){return w>i&&A>r?Math.min(x*i/w,x*r/A):w>i?x*i/w:A>r?x*r/A:x}let p=[];p[0]=s[0]===0?0:d(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:d(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:d(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:d(s[3],s[3]+s[0],s[3]+s[2]);let f=u.x,g=c.x,m=c.y,v=u.y;t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let x=0,w=t.points.length;x<w;x++)t.points[x].roundness=p[x],x>0&&p[x]!==p[x-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let b=Ta.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}},_6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:n=64,phiStart:a,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,u=new bg(.5*t,s,n,a,o,l,h);return u.scale(1,i/t,r/t),Object.assign(u,{userData:{...e,type:"SphereGeometry"}})}},A6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,n=new hu(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},S6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=e.parameters,o=new M6(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},M6=class extends Ve{constructor(e=1,t=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],c=Math.PI/2,d=(se=0,V=0,ee=0)=>new E(se,V,ee),p=d(),f=d(),[g,m,v]=[t/2,e/2,i/2],y=-m,b=+m,[x,w,A]=[d(y,-g,+v),d(y,-g,-v),d(y,+g,-v)],S=(se,V=!1)=>Math.sin(se-Math.PI/(1+ +V)),_=(se,V=!1)=>Math.cos(se-Math.PI/(1+ +V));A.y=Math.sin(r)*t-g;let M=Math.cos(r)*t-v,C=x.z-h;r<=c?(A.z=Math.min(M,C),A.z==C&&(A.y-=(M-C)/Math.tan(c-r))):w.z=Math.min(w.z-M-v,x.z-h),p.subVectors(x,w),f.subVectors(A,w);let T=Math.min(p.length(),f.length())*s/100,P=T*Math.tan(r/2),L=T/Math.cos(r/2),D=p.clone().normalize().add(f.normalize()).setLength(L).add(w);p.set(0,S(r,!0),_(r,!0)),u.push([A,p.clone()]);let k=(Math.PI-r)/n;for(let se=0;se<=n;se++){let V=c+r+se*k;p.set(0,Math.sin(V)*P,Math.cos(V)*P),p.add(D),f.set(0,S(V),_(V)),u.push([p.clone(),f.clone()])}u.push([x,d(0,1,0)]);let W=Math.sin(k/2)*P*2,X=u.length-1,z=u[0][0].distanceTo(u[1][0]),j=u[X-1][0].distanceTo(u[X][0]),U=z+W*n+j;u[0].push(1);for(let se=0;se<=n;se++)u[se+1].push(1-(z+se*W)/U);u[X].push(0);let[N,B,H]=u[0],Q,Y,F;for(let se=1;se<u.length;se++)[Q,Y,F]=u[se],a.push(y,N.y,N.z,y,Q.y,Q.z,b,N.y,N.z,b,N.y,N.z,y,Q.y,Q.z,b,Q.y,Q.z),o.push(0,B.y,B.z,0,Y.y,Y.z,0,B.y,B.z,0,B.y,B.z,0,Y.y,Y.z,0,Y.y,Y.z),l.push(0,H,0,F,1,H,1,H,0,F,1,F),[N,B,H]=[Q,Y,F];this.setAttribute("position",new Ce(a,3)),this.setAttribute("normal",new Ce(o,3)),this.setAttribute("uv",new Ce(l,2))}},RA=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Nt?e.shape:new Nt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,u=e.shape,c=t*.5,d=i*.5,p=0,f=0,g=a*Math.PI/360/s,m=Math.PI/2*3*-1,v=c*r/100,y=d*r/100;if(s===3&&r===50){g=2*Math.PI/s;for(let x=0;x<s;x++){let w=g*x,A=p+Math.sin(w)*c,S=f+Math.cos(w)*d;u.addPoint(u.createPoint(A,S))}}else for(let x=0;x<s;x++){let w=p+Math.cos(m)*c,A=f+Math.sin(m)*d;u.addPoint(u.createPoint(w,A)),m+=g,w=p+Math.cos(m)*v,A=f+Math.sin(m)*y,x<=s,u.addPoint(u.createPoint(w,A)),m+=g}u.isClosed=!0;for(let x=0,w=u.points.length;x<w;x++)u.points[x].roundness=n;u.roundness=n,u.update();let b=Ta.create({shape:u,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(b,{userData:{...e,type:"StarGeometry"}})}},E6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new hu(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},C6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=T6(t,i,r,t*.5,a,n,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function T6(e,t,i,r,s,n,a,o,l,h,u){return[t,i]=[i,t],a=t/2,s/=2*Math.PI,s==1&&(h=0),new ov(!0,e,t,i,r,s,n,a,o,l,h,u)}var P6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new kw(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},D6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof Nt?e.shape:new Nt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5;o?(l.addPoint(l.createPoint(-h,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=r;l.roundness=r,l.update();let c=Ta.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function L6(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}function O6(e,t,i){let r=[new E,new E,new E],s=[new E,new E,new E];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((n,a)=>{let o=s[a],l=it.lerp(n.length(),o.length(),i);n.lerp(o,i).setLength(l)}),new ve().makeBasis(r[0],r[1],r[2])}var I6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=t?.shapeData??av.create({parameters:iA}).userData.shape;return{path:e.path??Ud.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{...rA,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new R6(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new Ve,{userData:{...e,type:"PathGeometry"}})}},R6=class extends Ve{constructor(e){super(),this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!L6(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,n=Math.floor(r*s),a=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,a-n+1),s+2),l=[],h=[];for(let C=0;C<o;C++){let T=this.inputs.path.isClosed?(C+n)%e.length:Math.min(C+n,e.length-1);l.push(e[T].clone()),h.push(t[T].clone())}let u=(C,T,P)=>{l[C]=l[C].clone().lerp(l[T],P),h[C]=O6(h[C],h[T],P)},c=0,d=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(d||r===0)&&(c=d,u(0,1,c));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,u(l.length-1,l.length-2,1-p)),i===0){let C=l.length-1;l[C].copy(l[0]),h[C].copy(h[0])}this._applyPathModifiers(h,c,p);let{regions:g,infos:m,vertices:v}=this._computeShapePoints(5),y=0,b=0;m.sort((C,T)=>C.start-T.start),m.forEach(C=>{C.verticesStart=y,C.verticesCount=C.continuous.reduce((T,P,L)=>T+(L===0||!P?2:1),0),b+=C.verticesCount,y=b});let x=b*o,w,A=0;if(this._isOpenEnded()){try{w=_n({windingRule:yt.ODD,elementType:Zt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:g})}catch{w=AA}A=w.vertexCount}let S=x+2*A,_={positions:new Float32Array(S*3),normals:new Float32Array(S*3),uvs:new Float32Array(S*2)},M=[];m.forEach(C=>{this._extrudeRegion(C,v,h,l,_,M,this._isGeometryClosed()&&!this._isOpenEnded())}),w&&(this._closeEnd(w,x,M,_,h[0],l[0],!1),this._closeEnd(w,x+A,M,_,h[h.length-1],l[l.length-1],!0)),this.setAttribute("position",new Xe(_.positions,3)),this.setAttribute("normal",new Xe(_.normals,3)),this.setAttribute("uv",new Xe(_.uvs,2)),this.setIndex(M)}_extractPathPoints(){let e=fA(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new E,n=new E,a=new E,o=new E,l=new E(0,1,0);for(let f=0;f<i;f++){let g=e[f],m;f===0?m=r?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):m=e[f-1];let v;f===i-1?v=r?e[1]:g.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=g.clone().sub(m).normalize(),b=v.clone().sub(g).normalize(),x=y.clone().add(b).normalize();a.copy(x),f===0&&(x.equals(l)||x.clone().negate().equals(l))&&l.set(0,0,1);let w=l.clone().cross(x).normalize(),A=x.clone().cross(w).normalize();l.copy(A),o.copy(w),f===0&&(s.copy(A),n.copy(x));let S=new ve().makeBasis(w,A,x);t.push(S)}let h=r?n:a,u=r?s:new E(0,1,0),c=h.clone().cross(o).normalize(),d=Math.acos(u.dot(c));if(isNaN(d))return t;let p=u.clone().cross(c);h.dot(p)>0&&(d*=-1);for(let f=1;f<t.length;f++){let g=new ve().makeRotationZ(d*f/t.length);t[f].multiply(g)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:n,startScale:a,endScale:o}=this.inputs.parameters.extrusion,l=new ve,h=new ve;return e.forEach((u,c)=>{let d=c===0?0:c===r-1?1:(c-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(it.lerp(s,s+n,d));let p=it.lerp(a,o,d);h.makeScale(p,p,p),u.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=yt.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),g=[];for(let m=f.length-1;m>=1;m-=2){let v=f[m-1],y=f[m-0];g.push(v,y)}return g}),n;try{n=_n({windingRule:t,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{n=nv}let a;try{a=_n({windingRule:yt.ODD,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{a=_A}if(!n)throw new Error("error generating geometry");let o=n.elementCount;if(a){n.elementCount+=a.elementCount;for(let p=0;p<a.elements.length;p++){let f=a.elements[p],g=p%2===0?n.vertexCount:0;n.elements.push(f+g)}for(let p=0;p<a.vertexIndices.length;p++){let f=a.vertexIndices[p],g=n.vertexCount;n.vertexIndices.push(f+g)}for(let p=0;p<a.vertices.length;p++){let f=a.vertices[p];n.vertices.push(f)}}let l=1/0,h=-1/0,u=1/0,c=-1/0;for(let p=0,f=n.vertexCount;p<f;p++){let g=p*2,m=n.vertices[g+0],v=n.vertices[g+1];m<l&&(l=m),m>h&&(h=m),v<u&&(u=v),v>c&&(c=v)}let d=[];for(let p=n.elementCount-1;p>=0;p--){let f=p>=o,g=p*2,m=n.elements[g+0],v=n.elements[g+1],y=m+v,b={start:m,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};d.push(b);let x=m,w=y-1,A=m+1,S=i.roundedCurves.length;do{let _=x-m,M=n.vertices[w*2+0],C=n.vertices[w*2+1],T=n.vertices[x*2+0],P=n.vertices[x*2+1],L=n.vertices[A*2+0],D=n.vertices[A*2+1],k=T-M,W=P-C,X=Math.sqrt(k*k+W*W);k/=X,W/=X;let z=T-L,j=P-D,U=Math.sqrt(z*z+j*j);z/=U,j/=U,b.normals[_*2+0]=-j,b.normals[_*2+1]=z;let N=n.vertexIndices[x];if(Array.isArray(N))b.continuous[_]=!1;else{let[B,H]=i.getCurveIndexFromVertexId(N-1,!0);if(H>0&&H<1)b.continuous[_]=!0;else{let Q=H===1?B+1:B-1;Q=(Q+S)%S;let Y=H===1?0:1,F=i.roundedCurves[B].getTangent(H),se=i.roundedCurves[Q].getTangent(Y);b.continuous[_]=F.dot(se)>.95}}f&&(b.normals[_*2+0]*=-1,b.normals[_*2+1]*=-1),[w,x,A]=[x,A,A+1],A>=y&&(A-=v)}while(A!==m+1)}return{regions:[r,...s],infos:d,vertices:n.vertices}}_insertVertex(e,t,i,r,s){let n=t*2,a=t*3;e.positions[a+0]=i.x,e.positions[a+1]=i.y,e.positions[a+2]=i.z,e.normals[a+0]=r.x,e.normals[a+1]=r.y,e.normals[a+2]=r.z,e.uvs[n+0]=s.x,e.uvs[n+1]=s.y}_extrudeRegion(e,t,i,r,s,n,a){let o=new E,l=new E,h=new E,u=new E,c=new G;i.forEach((p,f)=>{let g=r[f],m=e.verticesStart*i.length+e.verticesCount*f;for(let v=0;v<e.count;v++){let y=(e.start+v)*2;if(o.set(t[y+0],t[y+1],0),h.copy(o).applyMatrix4(p).add(g),e.continuous[v])u.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let b=v==0?(e.start+e.count-1)*2:y-2;l.set(t[b+0],t[b+1],0),u.copy(o).sub(l),u.set(-u.y,u.x,0),e.isHole||u.negate()}if(u.applyMatrix4(p).normalize(),c.set(v===0?1:v/e.count,f/(i.length-1)),this._insertVertex(s,m,h,u,c),m++,!e.continuous[v]||v===0){if(v===0)u.set(e.normals[v*2+0],e.normals[v*2+1],0),c.set(0,f/(i.length-1));else{let b=v===e.count-1?e.start*2:y+2;l.set(t[b+0],t[b+1],0),u.copy(l).sub(o),u.set(-u.y,u.x,0),e.isHole||u.negate()}u.applyMatrix4(p).normalize(),this._insertVertex(s,m,h,u,c),m++}}});let d=i.length-1;for(let p=0;p<d;p++){let f=e.verticesStart*i.length+e.verticesCount*p,g=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&m++;let y=v===e.count-1?0:m+1,b=f+m,x=f+y,w=g+y,A=g+m;e.isHole?n.push(b,w,x,b,A,w):n.push(b,x,w,b,w,A),m++}}}_closeEnd(e,t,i,r,s,n,a){let o=e.vertexCount,l=new E(0,0,a?-1:1).applyMatrix4(s),h=new E,u=new G;for(let d=0;d<o;d++){let p=2*d;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(n),this._insertVertex(r,t+d,h,l,u)}let c=e.elements;for(let d=0;d<e.elementCount;d++){let p=3*d,f=c[p+0]+t,g=c[p+(a?1:2)]+t,m=c[p+(a?2:1)]+t;i.push(f,g,m)}}};function B6(){let e=new Ve;return e.setAttribute("position",new Xe(new Float32Array([]),3)),e.setIndex(new Xe(new Uint16Array([]),1)),e}var z6=12,N6=1,BA=class extends Ve{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,text:o,textTransform:l}=e,h=l===2?o.toUpperCase():l===3?o.toLowerCase():o,u=U6(e,t,h),{shapes:c,charWidths:d,charCoords:p}=t.generateShapes(u,e),f=i*.5,g=r*.5,m=c.map(b=>new Nt().fromShape(b));this.vectorShapes=m;let v=m.map(b=>Ta.create({shape:b,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?yt.NONZERO:yt.ODD,subdivisions:this.isLowResolution&&s>0?N6:z6}})),y=v.length?go(v):B6();y.translate(-f,g,0),this.dispose(),this.wrappedText=u,this.charCoords=p,this.charWidths=d,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([b,x])=>{this.setAttribute(b,x)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=Aa(new Ve,BA.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function U6(e,t,i){i=i??e.text;let r=[""],s="";for(let n of i)s+=n,n===" "||n===`
|
|
3139
3139
|
`?(r[r.length-1]+=s,s="",n===`
|
|
3140
|
-
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var zA,lv=new Promise(e=>{zA=e}),Rx=!1;async function F6(){if(Rx)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.300/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});zA(s),Rx=!0}function Jd(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Nt.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new Vw().parse(e);else{if(e.type==="SubdivGeometry")return new Oi(e,i);if(e.type==="TextGeometry")return new BA(e,t)}let s;try{s=kx(r)}catch(n){console.error(n)}if(!s){let n=Nt.createFromState(Nd.defaultData(),100,100);r.shape=n,s=kx(r)}return s}var k6=new ve;function km(e,t,i,r){let s=e.position.array,n=e.normal.array,a=k6.makeScale(t,i,r).invert().elements,o,l,h;for(var u=0,c=s.length;u<c;u+=3)s[u]*=t,s[u+1]*=i,s[u+2]*=r,o=n[u],l=n[u+1],h=n[u+2],n[u]=a[0]*o+a[4]*l+a[8]*h,n[u+1]=a[1]*o+a[5]*l+a[9]*h,n[u+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var kc=new Kt,Ja=new E,Ue;lv.then(e=>{Ue=e});var Bx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),zx=new Uint32Array([0,1,2,3]),Nx=new Uint8Array([4]),Oi=class extends Ve{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=ma.div(t,i);this.subdividedGeometry&&km(this.subdividedGeometry.attributes,...r),this.originalGeometry&&km(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(Ja.fromArray(r));let n=Ja.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Oi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new vs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Oi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Mr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;kc.setFromBufferAttribute(t),kc.getCenter(i),e.boundingSphere.radius=i.distanceTo(kc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),kc.getSize(Ja);let r={width:Ja.x,height:Ja.y,depth:Ja.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Ue.free_bvh(t),Ue.free_subdivision_surface(t));try{s=Oi.allocate(e,r)}catch(l){console.error(l,e),s=Oi.allocate({positionWASM:Bx,indexWASM:zx,verticesPerFaceWASM:Nx},r)}if(Ue.set_destination_refinement_level(s,0),n=Oi.buildLevel(s,!0,o),e.subdivisions>0)try{Ue.set_destination_refinement_level(s,e.subdivisions),a=Oi.buildLevel(s,!1,o)}catch{try{Ue.set_destination_refinement_level(s,e.subdivisions-1),a=Oi.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:h,height:u,depth:c,arc:d,tubularSegments:p,radialSegments:f}=e;r=new ov(!0,h,c,u,h*.5,d/(2*Math.PI),p,c/2,0,f,0,0,!0)}else r=e.shape!==void 0?t.geometry:Jd(e,i,!1);let s,n,a,o;({positions:s,triIndices:o}=hv(r.getAttribute("position"),r.getIndex()));let l;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,u=h+e.radialSegments*3;l=[h,u]}return{indices:n,verticesPerFace:a}=NA(s,o,r,l),{positions:s,indices:n,verticesPerFace:a}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=Bx,r=zx,s=Nx);let o=i.length,l=r.length,h=s.length,u=i.length+n.length+a.length,c=r.length+s.length,d=u*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=u*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,g=Ue._malloc(d),m=new Float32Array(Ue.HEAPF32.buffer,g,u),v=new Uint32Array(Ue.HEAPU32.buffer,g+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(x=>x!==1)&&(y=new ve().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let b=y?Ue.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Ue.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Ue._free(g),b}static buildLevel(e,t,i,r,s){let n=s?Ue.get_mesh_data2(e,t?Ue.Level.CONTROL:Ue.Level.REFINED,i,s.elements):Ue.get_mesh_data(e,t?Ue.Level.CONTROL:Ue.Level.REFINED,i),a=8,o=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,u=Ue.HEAPU32[o[h]>>2],c=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Ue.HEAPU32[o[h]>>2],p=Ue.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Ue.HEAPU32[o[h]>>2],g=Ue.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Ue.HEAPU32[o[h]>>2],v=Ue.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new Ve;if(y.setIndex(new Jl(v,1)),y.setAttribute("position",new Ce(c,3)),y.setAttribute("normal",new Ce(p,3)),t){y.setAttribute("faceMap",new Jl(g,1));let b=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Xe(b,4))}return Ue.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Ue.free_mesh_data(n)}static freeSubdivPointer(e){Ue.free_bvh(e),Ue.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Ue.get_wireframe_data_for_base_level(e),s=4,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Ue.HEAPU32[n[o]>>2],h=Ue.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let u=Ue.HEAPU32[n[o]>>2],c=Ue.HEAPU32.subarray(u>>2,(u>>2)+a[o]);if(t===void 0){let d=new Ve;d.setAttribute("position",new Ce(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Xe(p,3)),d.setIndex(new Jl(c,1)),Ue.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Ue.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Ue.set_destination_refinement_level(e,t);let s=i?Ue.get_topological_data2(e,r?Ue.Level.CONTROL:Ue.Level.REFINED,i.elements):Ue.get_topological_data(e,r?Ue.Level.CONTROL:Ue.Level.REFINED),n=6,a=Ue.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Ue.HEAPU32[a[l]>>2],u=new Float32Array(Ue.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Ue.HEAPU32[a[l]>>2],d=new Uint32Array(Ue.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Ue.HEAPU32[a[l]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Ue.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},Ux=["getX","getY","getZ"];function hv(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let u=t?t.getX(h):h,c="";for(let d=0;d<3;d++)c+=`${~~(e[Ux[d]](u)*o)},`;if(c in i)n.push(i[c]);else{for(let d=0;d<3;d++)a.push(e[Ux[d]](u));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var jc=new E,sf=new E,nf=new E,af=new E;function NA(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let u=a.length/2/o;a=a.filter((c,d)=>Math.floor(d/2)%u===0)}let l=0;for(let u=0;u<a.length;u+=2)l+=(a[u]-a[(u===0?a.length:u)-2])*(a[u+1]+a[(u===0?a.length:u)-1]);e.length=0;let h=0;if(l<0)for(let u=0;u<a.length;u+=2)e.push(a[u],a[u+1],0),s.push(h++);else for(let u=a.length-2;u>=0;u-=2)e.push(a[u],a[u+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){jc.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),sf.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),nf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),af.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),sf.sub(jc).normalize(),nf.sub(jc).normalize(),af.sub(jc).normalize();let l=sf.cross(nf).dot(af);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:a>=r[u]&&a<r[u+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let u=0,c=0;u<e.length;u+=3,c++)e[u+2]===0&&(a.push(c),l++),e[u+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let u=o[0];o[0]=o[1],o[1]=u}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var dn={};K2(dn,{calcBoolean:()=>W6,calcBooleanTopological:()=>H6,freeMeshSet:()=>Y6,getMeshSet:()=>X6,transformMeshSet:()=>q6});var UA,j6=new Promise(e=>{UA=e}),Fx=!1;async function G6(){if(Fx)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.300/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});UA(s),Fx=!0}var tt,Lo;j6.then(e=>tt=e);function V6(e,t,i){let r,{positions:s,triIndices:n}=hv(e.getAttribute("position"),e.getIndex()),a;if(t&&i){let{indices:o,verticesPerFace:l}=NA(s,n,e);a=l.length,r=[];for(let h=0,u=0;h<a;h++){r.push(l[h]);for(let c=0;c<l[h];c++)r.push(o[u++])}}else{let o=n.length;r=Array(o+o/3),a=0;for(let l=0,h=0;h<r.length;)r[h++]=3,a++,r[h++]=n[l++],r[h++]=n[l++],r[h++]=n[l++]}return{positions:s,faceIndices:r,nFaces:a}}function FA(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=tt._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(tt.HEAPU32.buffer,n,t):new Float32Array(tt.HEAPF32.buffer,n,t)).set(e,0),n}function kA(e){switch(e){case 0:return tt.OP.UNION;case 1:return tt.OP.INTERSECTION;case 2:return tt.OP.A_MINUS_B;case 3:return tt.OP.B_MINUS_A;case 4:return tt.OP.SYMMETRIC_DIFFERENCE;case 5:return tt.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function H6(e,t){Lo===void 0&&(Lo=tt.init_csg());let i=FA(e),r=tt.csg_calc_topological(Lo,i,e.length,kA(t));tt._free(i);let s=6,n=tt.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=tt.HEAPU32[n[o]>>2],h=new Float32Array(tt.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=tt.HEAPU32[n[o]>>2],c=new Uint32Array(tt.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let d=tt.HEAPU32[n[o]>>2],p=new Uint8Array(tt.HEAPU32.subarray(d>>2,(d>>2)+a[o]));return tt.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function W6(e,t,i,r){Lo===void 0&&(Lo=tt.init_csg());let s=FA(e),n=tt.csg_calc(Lo,s,e.length,r,kA(t));tt._free(s);let a=5,o=tt.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,u=tt.HEAPU32[o[h]>>2],c=tt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=tt.HEAPU32[o[h]>>2],p=tt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ce(c,3)),i.setAttribute("normal",new Ce(p,3));let g=tt.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Mr),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},tt.free_mesh_data(n),f}function X6(e,t,i){if(tt===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,b=0;v<m.verticesPerFace.length;v++){s[b++]=m.verticesPerFace[v];for(let x=0;x<m.verticesPerFace[v];x++)s[b++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=V6(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,u=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=tt._malloc(u),f=new Float32Array(tt.HEAPF32.buffer,p,l),g=new Uint32Array(tt.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),tt.get_csg_mesh(p,a,p+c,o,n)}function q6(e,t){tt.transform_csg_mesh(e,t.elements)}function Y6(e){tt.free_csg_mesh(e)}var Q6={ConeGeometry:PF,CubeGeometry:DF,CylinderGeometry:TF,DodecahedronGeometry:OF,EllipseGeometry:av,HelixGeometry:h6,IcosahedronGeometry:c6,LatheGeometry:d6,NonParametricGeometry:y6,PolygonGeometry:OA,PyramidGeometry:x6,RectangleGeometry:IA,SphereGeometry:_6,PlaneGeometry:A6,BackdropGeometry:S6,StarGeometry:RA,TextFrameGeometry:E6,TorusGeometry:C6,TorusKnotGeometry:P6,TriangleGeometry:D6,PathGeometry:I6,VectorGeometry:Ta},kx=e=>Q6[e.type].create(e);function Ol(e){return e!==null&&"booleanOp"in e}var jA=class extends mA(tr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new ve}updateVisible(){super.updateVisible(),this.visible=!Ol(this.parent)&&this.visible,Ol(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(dn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ol(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof jA&&(e.freeBooleanPointer(),Ol(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Ol(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},Gc=new Kt;function cv(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let c=t;c<i;c++){let d=e.getX(c),p=e.getY(c),f=e.getZ(c);d<n&&(n=d),p<a&&(a=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}Gc.min.set(n,a,o),Gc.max.set(l,h,u),Gc.getCenter(r),Gc.getSize(s).multiplyScalar(.5)}var Z6=new Ve,K6=new Dh,ar=class extends jA{constructor(e,t){super(Z6,K6),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?cv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},jx=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},Bn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=it.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof Bn&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},J6=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Ui=new J6,St=class extends Bn{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=it.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},or=class extends St{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},vr=class extends or{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof G?e:new G(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},fr=class extends or{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof E?e:new E(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},Gi=class extends Ge{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},na=class extends or{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof Gi?e:new Gi(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},$6=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Gx=/[a-z_0-9]+/gi,Re=class extends St{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=Gx.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let u=l[h],c=u[0],d=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&d&&Ui.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=Ui.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||Ui.getKeyword(c,e),g.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+a-1]!=="."&&(o=o.substring(0,u.index+a)+p+o.substring(u.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&Ui.contains(p)&&e.include(Ui.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=$6.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(Gx);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},ek=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,GA=class extends St{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||GA.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=ek.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},vt=GA;vt.PI="PI",vt.PI2="PI2",vt.RECIPROCAL_PI="RECIPROCAL_PI",vt.RECIPROCAL_PI2="RECIPROCAL_PI2",vt.LOG2="LOG2",vt.EPSILON="EPSILON";var tk=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3140
|
+
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var zA,lv=new Promise(e=>{zA=e}),Rx=!1;async function F6(){if(Rx)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.302/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});zA(s),Rx=!0}function Jd(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Nt.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new Vw().parse(e);else{if(e.type==="SubdivGeometry")return new Oi(e,i);if(e.type==="TextGeometry")return new BA(e,t)}let s;try{s=kx(r)}catch(n){console.error(n)}if(!s){let n=Nt.createFromState(Nd.defaultData(),100,100);r.shape=n,s=kx(r)}return s}var k6=new ve;function km(e,t,i,r){let s=e.position.array,n=e.normal.array,a=k6.makeScale(t,i,r).invert().elements,o,l,h;for(var u=0,c=s.length;u<c;u+=3)s[u]*=t,s[u+1]*=i,s[u+2]*=r,o=n[u],l=n[u+1],h=n[u+2],n[u]=a[0]*o+a[4]*l+a[8]*h,n[u+1]=a[1]*o+a[5]*l+a[9]*h,n[u+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var kc=new Kt,Ja=new E,Ue;lv.then(e=>{Ue=e});var Bx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),zx=new Uint32Array([0,1,2,3]),Nx=new Uint8Array([4]),Oi=class extends Ve{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=ma.div(t,i);this.subdividedGeometry&&km(this.subdividedGeometry.attributes,...r),this.originalGeometry&&km(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(Ja.fromArray(r));let n=Ja.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Oi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new vs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Oi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Mr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;kc.setFromBufferAttribute(t),kc.getCenter(i),e.boundingSphere.radius=i.distanceTo(kc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),kc.getSize(Ja);let r={width:Ja.x,height:Ja.y,depth:Ja.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Ue.free_bvh(t),Ue.free_subdivision_surface(t));try{s=Oi.allocate(e,r)}catch(l){console.error(l,e),s=Oi.allocate({positionWASM:Bx,indexWASM:zx,verticesPerFaceWASM:Nx},r)}if(Ue.set_destination_refinement_level(s,0),n=Oi.buildLevel(s,!0,o),e.subdivisions>0)try{Ue.set_destination_refinement_level(s,e.subdivisions),a=Oi.buildLevel(s,!1,o)}catch{try{Ue.set_destination_refinement_level(s,e.subdivisions-1),a=Oi.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:h,height:u,depth:c,arc:d,tubularSegments:p,radialSegments:f}=e;r=new ov(!0,h,c,u,h*.5,d/(2*Math.PI),p,c/2,0,f,0,0,!0)}else r=e.shape!==void 0?t.geometry:Jd(e,i,!1);let s,n,a,o;({positions:s,triIndices:o}=hv(r.getAttribute("position"),r.getIndex()));let l;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,u=h+e.radialSegments*3;l=[h,u]}return{indices:n,verticesPerFace:a}=NA(s,o,r,l),{positions:s,indices:n,verticesPerFace:a}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=Bx,r=zx,s=Nx);let o=i.length,l=r.length,h=s.length,u=i.length+n.length+a.length,c=r.length+s.length,d=u*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=u*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,g=Ue._malloc(d),m=new Float32Array(Ue.HEAPF32.buffer,g,u),v=new Uint32Array(Ue.HEAPU32.buffer,g+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(x=>x!==1)&&(y=new ve().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let b=y?Ue.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Ue.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Ue._free(g),b}static buildLevel(e,t,i,r,s){let n=s?Ue.get_mesh_data2(e,t?Ue.Level.CONTROL:Ue.Level.REFINED,i,s.elements):Ue.get_mesh_data(e,t?Ue.Level.CONTROL:Ue.Level.REFINED,i),a=8,o=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,u=Ue.HEAPU32[o[h]>>2],c=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Ue.HEAPU32[o[h]>>2],p=Ue.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Ue.HEAPU32[o[h]>>2],g=Ue.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Ue.HEAPU32[o[h]>>2],v=Ue.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new Ve;if(y.setIndex(new Jl(v,1)),y.setAttribute("position",new Ce(c,3)),y.setAttribute("normal",new Ce(p,3)),t){y.setAttribute("faceMap",new Jl(g,1));let b=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Xe(b,4))}return Ue.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Ue.free_mesh_data(n)}static freeSubdivPointer(e){Ue.free_bvh(e),Ue.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Ue.get_wireframe_data_for_base_level(e),s=4,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Ue.HEAPU32[n[o]>>2],h=Ue.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let u=Ue.HEAPU32[n[o]>>2],c=Ue.HEAPU32.subarray(u>>2,(u>>2)+a[o]);if(t===void 0){let d=new Ve;d.setAttribute("position",new Ce(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Xe(p,3)),d.setIndex(new Jl(c,1)),Ue.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Ue.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Ue.set_destination_refinement_level(e,t);let s=i?Ue.get_topological_data2(e,r?Ue.Level.CONTROL:Ue.Level.REFINED,i.elements):Ue.get_topological_data(e,r?Ue.Level.CONTROL:Ue.Level.REFINED),n=6,a=Ue.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Ue.HEAPU32[a[l]>>2],u=new Float32Array(Ue.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Ue.HEAPU32[a[l]>>2],d=new Uint32Array(Ue.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Ue.HEAPU32[a[l]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Ue.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},Ux=["getX","getY","getZ"];function hv(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let u=t?t.getX(h):h,c="";for(let d=0;d<3;d++)c+=`${~~(e[Ux[d]](u)*o)},`;if(c in i)n.push(i[c]);else{for(let d=0;d<3;d++)a.push(e[Ux[d]](u));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var jc=new E,sf=new E,nf=new E,af=new E;function NA(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let u=a.length/2/o;a=a.filter((c,d)=>Math.floor(d/2)%u===0)}let l=0;for(let u=0;u<a.length;u+=2)l+=(a[u]-a[(u===0?a.length:u)-2])*(a[u+1]+a[(u===0?a.length:u)-1]);e.length=0;let h=0;if(l<0)for(let u=0;u<a.length;u+=2)e.push(a[u],a[u+1],0),s.push(h++);else for(let u=a.length-2;u>=0;u-=2)e.push(a[u],a[u+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){jc.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),sf.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),nf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),af.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),sf.sub(jc).normalize(),nf.sub(jc).normalize(),af.sub(jc).normalize();let l=sf.cross(nf).dot(af);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:a>=r[u]&&a<r[u+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let u=0,c=0;u<e.length;u+=3,c++)e[u+2]===0&&(a.push(c),l++),e[u+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let u=o[0];o[0]=o[1],o[1]=u}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var dn={};K2(dn,{calcBoolean:()=>W6,calcBooleanTopological:()=>H6,freeMeshSet:()=>Y6,getMeshSet:()=>X6,transformMeshSet:()=>q6});var UA,j6=new Promise(e=>{UA=e}),Fx=!1;async function G6(){if(Fx)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.302/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});UA(s),Fx=!0}var tt,Lo;j6.then(e=>tt=e);function V6(e,t,i){let r,{positions:s,triIndices:n}=hv(e.getAttribute("position"),e.getIndex()),a;if(t&&i){let{indices:o,verticesPerFace:l}=NA(s,n,e);a=l.length,r=[];for(let h=0,u=0;h<a;h++){r.push(l[h]);for(let c=0;c<l[h];c++)r.push(o[u++])}}else{let o=n.length;r=Array(o+o/3),a=0;for(let l=0,h=0;h<r.length;)r[h++]=3,a++,r[h++]=n[l++],r[h++]=n[l++],r[h++]=n[l++]}return{positions:s,faceIndices:r,nFaces:a}}function FA(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=tt._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(tt.HEAPU32.buffer,n,t):new Float32Array(tt.HEAPF32.buffer,n,t)).set(e,0),n}function kA(e){switch(e){case 0:return tt.OP.UNION;case 1:return tt.OP.INTERSECTION;case 2:return tt.OP.A_MINUS_B;case 3:return tt.OP.B_MINUS_A;case 4:return tt.OP.SYMMETRIC_DIFFERENCE;case 5:return tt.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function H6(e,t){Lo===void 0&&(Lo=tt.init_csg());let i=FA(e),r=tt.csg_calc_topological(Lo,i,e.length,kA(t));tt._free(i);let s=6,n=tt.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=tt.HEAPU32[n[o]>>2],h=new Float32Array(tt.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=tt.HEAPU32[n[o]>>2],c=new Uint32Array(tt.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let d=tt.HEAPU32[n[o]>>2],p=new Uint8Array(tt.HEAPU32.subarray(d>>2,(d>>2)+a[o]));return tt.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function W6(e,t,i,r){Lo===void 0&&(Lo=tt.init_csg());let s=FA(e),n=tt.csg_calc(Lo,s,e.length,r,kA(t));tt._free(s);let a=5,o=tt.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,u=tt.HEAPU32[o[h]>>2],c=tt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=tt.HEAPU32[o[h]>>2],p=tt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ce(c,3)),i.setAttribute("normal",new Ce(p,3));let g=tt.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Mr),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},tt.free_mesh_data(n),f}function X6(e,t,i){if(tt===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,b=0;v<m.verticesPerFace.length;v++){s[b++]=m.verticesPerFace[v];for(let x=0;x<m.verticesPerFace[v];x++)s[b++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=V6(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,u=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=tt._malloc(u),f=new Float32Array(tt.HEAPF32.buffer,p,l),g=new Uint32Array(tt.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),tt.get_csg_mesh(p,a,p+c,o,n)}function q6(e,t){tt.transform_csg_mesh(e,t.elements)}function Y6(e){tt.free_csg_mesh(e)}var Q6={ConeGeometry:PF,CubeGeometry:DF,CylinderGeometry:TF,DodecahedronGeometry:OF,EllipseGeometry:av,HelixGeometry:h6,IcosahedronGeometry:c6,LatheGeometry:d6,NonParametricGeometry:y6,PolygonGeometry:OA,PyramidGeometry:x6,RectangleGeometry:IA,SphereGeometry:_6,PlaneGeometry:A6,BackdropGeometry:S6,StarGeometry:RA,TextFrameGeometry:E6,TorusGeometry:C6,TorusKnotGeometry:P6,TriangleGeometry:D6,PathGeometry:I6,VectorGeometry:Ta},kx=e=>Q6[e.type].create(e);function Ol(e){return e!==null&&"booleanOp"in e}var jA=class extends mA(tr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new ve}updateVisible(){super.updateVisible(),this.visible=!Ol(this.parent)&&this.visible,Ol(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(dn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ol(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof jA&&(e.freeBooleanPointer(),Ol(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Ol(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},Gc=new Kt;function cv(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let c=t;c<i;c++){let d=e.getX(c),p=e.getY(c),f=e.getZ(c);d<n&&(n=d),p<a&&(a=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}Gc.min.set(n,a,o),Gc.max.set(l,h,u),Gc.getCenter(r),Gc.getSize(s).multiplyScalar(.5)}var Z6=new Ve,K6=new Dh,ar=class extends jA{constructor(e,t){super(Z6,K6),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?cv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},jx=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},Bn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=it.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof Bn&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},J6=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Ui=new J6,St=class extends Bn{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=it.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},or=class extends St{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},vr=class extends or{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof G?e:new G(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},fr=class extends or{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof E?e:new E(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},Gi=class extends Ge{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},na=class extends or{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof Gi?e:new Gi(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},$6=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Gx=/[a-z_0-9]+/gi,Re=class extends St{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=Gx.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let u=l[h],c=u[0],d=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&d&&Ui.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=Ui.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||Ui.getKeyword(c,e),g.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+a-1]!=="."&&(o=o.substring(0,u.index+a)+p+o.substring(u.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&Ui.contains(p)&&e.include(Ui.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=$6.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(Gx);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},ek=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,GA=class extends St{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||GA.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=ek.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},vt=GA;vt.PI="PI",vt.PI2="PI2",vt.RECIPROCAL_PI="RECIPROCAL_PI",vt.RECIPROCAL_PI2="RECIPROCAL_PI2",vt.LOG2="LOG2",vt.EPSILON="EPSILON";var tk=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3141
3141
|
)*?)}`,"gim"),ik=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),VA=class extends St{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=tk.exec(e);if(t){let i=t[2],r;for(;r=ik.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},dv=class extends St{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};Ui.addKeyword("uv",function(){return new dv});Ui.addKeyword("uv2",function(){return new dv(1)});var lo=class extends St{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??lo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case gs:return["Linear"];case Ke:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=lo.Nodes[this.method],n=e.include(s);if(n===lo.LINEAR_TO_LINEAR)return e.format(i,r,t);if(s.inputs?.length===2){let a=this.factor.build(e,"f");return e.format(n+"( "+i+", "+a+" )",r,t)}else return e.format(n+"( "+i+" )",r,t)}fromEncoding(e){let t=lo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=lo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},hs=lo;hs.Nodes={LinearToLinear:new Re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3142
3142
|
`)),sRGBToLinear:new Re(["vec4 sRGBToLinear( 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.w );","}"].join(`
|
|
3143
3143
|
`)),LinearTosRGB:new Re(["vec4 LinearTosRGB( 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.w );","}"].join(`
|
|
@@ -5209,7 +5209,7 @@ outputColor=vec4(color,inputColor.a);}`,Jc={DEFAULT:0,ESKIL:1},VH=class extends
|
|
|
5209
5209
|
void main() {
|
|
5210
5210
|
gl_FragColor = vec4(0.0);
|
|
5211
5211
|
}
|
|
5212
|
-
`}),zf=class extends Tr{constructor(e,t){super("OpaquePass",e??sw,t),this.hasTransmissionPass=!1,this.clear=!0,this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??sw}getScene(){return this.scene}render(e,t){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof ar&&(this.originalMaterials.set(r.id,r.material),r.material=e9)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((r,s)=>{let n=this.scene.getObjectById(s);n&&(n.material=r)})}};function nw(e,t){return t&&t.enabled&&e.push(t.effect),e}var t9=e=>Object.values(nt).includes(e)?e:nt.NORMAL,i9=class extends Hi{constructor(e){super(),this.postprocessingState=wh.defaultData,this._scene=new pa,this._camera=new Vi,this.effects=new Map,this._renderToScreen=!0,this.clock=new tL,this.renderer=e,this.debug=!1,this.effects.set("bloom",new HH),this.effects.set("chromaticAberration",new XH),this.effects.set("vignette",new ZH),this.effects.set("noise",new QH),this.effects.set("colorAverage",new qH),this.effects.set("hueSaturation",new YH),this.effects.set("brightnessContrast",new WH),this.effects.set("depthOfField",new KH),this.effects.set("pixelation",new JH),this.effectComposer=new wH(this.renderer),this.opaquePass=new zf(this.scene,this.camera),this.transmissionPass=new $H(this.scene,this.camera,this.renderer),this.helperPass=new zf(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Ru(!1,!0,!1),this.helperPassOnTop=new zf(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new jH({preset:co.ULTRA,edgeDetectionMode:Iv.COLOR}),t=()=>{e.removeEventListener("load",t),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",t),e.edgeDetectionMaterial.predicationMode=f2.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new If(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(nw,[]);e.length>0&&(this.uvEffectPass=new If(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(nw,[]);t.length>0&&(this.effectPass=new If(this.camera,...t),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new G;this.renderer.getDrawingBufferSize(e),this._rt=new ii(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:lh,wrapT:lh}),this._rt.samples=0,this._savePass=new ou(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?(t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=t9(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},aw=new ci,r9=class extends Tw{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new G,this.pipeline=new i9(this),this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio=s,t(s)},this.setSize=(s,n,a=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==n)&&(this.viewportWidth=s,this.viewportHeight=n,i(s,n,a),this.normalRenderTarget?.setSize(s*this._pixelRatio,n*this._pixelRatio),this.transmissionRenderTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.pipeline.resize(s,n,a))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ii(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Bo,magFilter:mt,wrapS:Ji,wrapT:Ji,depthBuffer:!1}),this.transmissionDepthTarget=new ii(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Ot,magFilter:Ot,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ii(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Ot,magFilter:Ot,type:vn,depthTexture:new mg(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof Vi?gf.uniforms.depthContrast.value=(t.far-t.near)/1e4:gf.uniforms.depthContrast.value=1,e.overrideMaterial=gf,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?Qm:null,t.layers.enable(0),t.layers.enable(3))}renderSplineScene(e,t,i,r,s){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{Lt.penumbraSize.value[o]=a}),Lt.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Lt.resolution.value.set(this.resolution.x,this.resolution.y):Lt.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Lt.normalRenderTarget.value=this.overrideNormal,Lt.normalRenderTargetDepth.value=aw):e.needsNormal()&&(this.createNormalRenderTarget(),Lt.normalRenderTarget.value=this.normalRenderTarget.texture,Lt.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t));let n=!1;if(this.overrideTransmission!==void 0)Lt.transmissionRenderTarget.value=this.overrideTransmission,Lt.transmissionRenderTargetDepth.value=aw,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),Lt.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Lt.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?Qm:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},s9=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Tu(e.shared,t),this.scene=new sl(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Cr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},n9=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function a9(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function oh(e){return e instanceof Mh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function o9(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof ar)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof ar&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!nr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!nr.isMergable(l.material))return;n=nr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][oh(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][oh(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][oh(r)].push(l)}),i}function l9(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function h9(e,t){let i=o9(t,e),r=l9(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),c=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(m=>{m instanceof ar&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&a9(a[m]);let g=go(a.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new tr(g,l[0].material);break}default:{m=new tr(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let b of y)b.children&&v(b.children),b instanceof ar&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][oh(b)]&&i[b.material.uuid][oh(b)].length>1||(u[c++]=b));for(let b=0;b<c;b++)t.attach(u[b])};for(let y=0;y<h;y++){let b=l[y];v(b.children),s[n++]=b}}}for(let d=0;d<n;d++)s[d].removeFromParent()}var c9=Ch(tM(),1),d9=new G;function u9(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var Bv=class{constructor(e,{renderOnDemand:t=!0}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this._skipRender=!1,this.renderOnDemand=!0,this.disposed=!1,this.requestRender=()=>{this._skipRender=!1},this.render=i=>{!this._renderer||(this._rafId=requestAnimationFrame(this.render),this.time=i,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&this._skipRender)&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))},this._resize=E_(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=d9.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())},10),this.canvas=e,this.renderOnDemand=t,window.location.search.includes("perfs")&&(this._perfs=new n9({x:10,y:10})),cU(e)}async load(e,t){u9(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await _V(e);this._data=i,i.version&&(0,c9.default)(i.version,"0.9.300")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([ob(i)&&G6(),e8(i)&&F6(),i.scene.environment.usePhysics&&CN(),ib(i)&&jk()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let r=new s9(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let s=performance.now();h9(i,r.scene);let n=performance.now();console.log("Merged geometries in ",n-s," ms")}if(ob(i)&&this._scene.traverse(s=>{Sn(s)&&s.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(s=>{s instanceof iu&&s.pendingMediaLoad&&s.update()})}),ib(i)&&JG(i)){let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n)).map(n=>n.loadingPromise);await Promise.all(s)}if(this._scene.rewriteEventsBeforeGoToPlayMode(),a2(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new r9({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?hg:lw,j8(i.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let s=Object.values(i.frames)[0];s.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=s.size[0],this._viewportHeight=s.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new SV(this._renderer,this._camera,new G(this._viewportWidth,this._viewportHeight),new G(window.innerWidth,window.innerHeight))}if(t&&(this._scene.updateMatrixWorld(!0),this._controls=new $G(i,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new AV(this._renderer,this._scene,this._camera,i.scene.publish.stopRaycast,i.scene.publish.preventScroll,i.scene.publish.preventTouchScroll,i.scene.publish.hideCursor,this._sharedAssetsManager,this.requestRender,this._controls,!0)),this._resize(),!this._resizeObserver&&this.canvas.parentElement){let s=!0;this._resizeObserver=new ResizeObserver(()=>{if(s){s=!1;return}this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)}this._rafId===void 0?this.render(performance.now()):this.requestRender()}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof u2&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new Gi(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this.requestRender()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(e=>{ky.unsubscribe(e)}),this._renderer?.dispose(),this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),dU(this.canvas)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=ky(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var Bu=window,zu=Bu.ShadowRoot&&(Bu.ShadyCSS===void 0||Bu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,zv=Symbol(),v2=new WeakMap,jh=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==zv)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(zu&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=v2.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&v2.set(i,t))}return t}toString(){return this.cssText}},y2=e=>new jh(typeof e=="string"?e:e+"",void 0,zv),Nv=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new jh(i,e,zv)},Uv=(e,t)=>{zu?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Bu.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Nu=zu?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return y2(i)})(e):e;var Fv,Uu=window,x2=Uu.trustedTypes,p9=x2?x2.emptyScript:"",b2=Uu.reactiveElementPolyfillSupport,jv={toAttribute(e,t){switch(t){case Boolean:e=e?p9:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},w2=(e,t)=>t!==e&&(t==t||e==e),kv={attribute:!0,type:String,converter:jv,reflect:!1,hasChanged:w2},Zs=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=kv){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||kv}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Nu(s))}else t!==void 0&&i.push(Nu(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Uv(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=kv){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:jv).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:jv;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||w2)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Zs.finalized=!0,Zs.elementProperties=new Map,Zs.elementStyles=[],Zs.shadowRootOptions={mode:"open"},b2?.({ReactiveElement:Zs}),((Fv=Uu.reactiveElementVersions)!==null&&Fv!==void 0?Fv:Uu.reactiveElementVersions=[]).push("1.6.0");var Gv,Fu=window,al=Fu.trustedTypes,_2=al?al.createPolicy("lit-html",{createHTML:e=>e}):void 0,Un=`lit$${(Math.random()+"").slice(9)}$`,P2="?"+Un,f9=`<${P2}>`,ol=document,Vh=(e="")=>ol.createComment(e),Hh=e=>e===null||typeof e!="object"&&typeof e!="function",D2=Array.isArray,m9=e=>D2(e)||typeof e?.[Symbol.iterator]=="function",Gh=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,A2=/-->/g,S2=/>/g,Da=RegExp(`>|[
|
|
5212
|
+
`}),zf=class extends Tr{constructor(e,t){super("OpaquePass",e??sw,t),this.hasTransmissionPass=!1,this.clear=!0,this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??sw}getScene(){return this.scene}render(e,t){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof ar&&(this.originalMaterials.set(r.id,r.material),r.material=e9)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((r,s)=>{let n=this.scene.getObjectById(s);n&&(n.material=r)})}};function nw(e,t){return t&&t.enabled&&e.push(t.effect),e}var t9=e=>Object.values(nt).includes(e)?e:nt.NORMAL,i9=class extends Hi{constructor(e){super(),this.postprocessingState=wh.defaultData,this._scene=new pa,this._camera=new Vi,this.effects=new Map,this._renderToScreen=!0,this.clock=new tL,this.renderer=e,this.debug=!1,this.effects.set("bloom",new HH),this.effects.set("chromaticAberration",new XH),this.effects.set("vignette",new ZH),this.effects.set("noise",new QH),this.effects.set("colorAverage",new qH),this.effects.set("hueSaturation",new YH),this.effects.set("brightnessContrast",new WH),this.effects.set("depthOfField",new KH),this.effects.set("pixelation",new JH),this.effectComposer=new wH(this.renderer),this.opaquePass=new zf(this.scene,this.camera),this.transmissionPass=new $H(this.scene,this.camera,this.renderer),this.helperPass=new zf(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Ru(!1,!0,!1),this.helperPassOnTop=new zf(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new jH({preset:co.ULTRA,edgeDetectionMode:Iv.COLOR}),t=()=>{e.removeEventListener("load",t),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",t),e.edgeDetectionMaterial.predicationMode=f2.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new If(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(nw,[]);e.length>0&&(this.uvEffectPass=new If(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(nw,[]);t.length>0&&(this.effectPass=new If(this.camera,...t),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new G;this.renderer.getDrawingBufferSize(e),this._rt=new ii(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:lh,wrapT:lh}),this._rt.samples=0,this._savePass=new ou(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?(t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=t9(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},aw=new ci,r9=class extends Tw{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new G,this.pipeline=new i9(this),this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio=s,t(s)},this.setSize=(s,n,a=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==n)&&(this.viewportWidth=s,this.viewportHeight=n,i(s,n,a),this.normalRenderTarget?.setSize(s*this._pixelRatio,n*this._pixelRatio),this.transmissionRenderTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.pipeline.resize(s,n,a))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ii(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Bo,magFilter:mt,wrapS:Ji,wrapT:Ji,depthBuffer:!1}),this.transmissionDepthTarget=new ii(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Ot,magFilter:Ot,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ii(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Ot,magFilter:Ot,type:vn,depthTexture:new mg(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof Vi?gf.uniforms.depthContrast.value=(t.far-t.near)/1e4:gf.uniforms.depthContrast.value=1,e.overrideMaterial=gf,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?Qm:null,t.layers.enable(0),t.layers.enable(3))}renderSplineScene(e,t,i,r,s){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{Lt.penumbraSize.value[o]=a}),Lt.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Lt.resolution.value.set(this.resolution.x,this.resolution.y):Lt.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Lt.normalRenderTarget.value=this.overrideNormal,Lt.normalRenderTargetDepth.value=aw):e.needsNormal()&&(this.createNormalRenderTarget(),Lt.normalRenderTarget.value=this.normalRenderTarget.texture,Lt.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t));let n=!1;if(this.overrideTransmission!==void 0)Lt.transmissionRenderTarget.value=this.overrideTransmission,Lt.transmissionRenderTargetDepth.value=aw,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),Lt.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Lt.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?Qm:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},s9=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Tu(e.shared,t),this.scene=new sl(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Cr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},n9=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function a9(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function oh(e){return e instanceof Mh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function o9(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof ar)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof ar&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!nr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!nr.isMergable(l.material))return;n=nr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][oh(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][oh(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][oh(r)].push(l)}),i}function l9(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function h9(e,t){let i=o9(t,e),r=l9(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),c=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(m=>{m instanceof ar&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&a9(a[m]);let g=go(a.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new tr(g,l[0].material);break}default:{m=new tr(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let b of y)b.children&&v(b.children),b instanceof ar&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][oh(b)]&&i[b.material.uuid][oh(b)].length>1||(u[c++]=b));for(let b=0;b<c;b++)t.attach(u[b])};for(let y=0;y<h;y++){let b=l[y];v(b.children),s[n++]=b}}}for(let d=0;d<n;d++)s[d].removeFromParent()}var c9=Ch(tM(),1),d9=new G;function u9(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var Bv=class{constructor(e,{renderOnDemand:t=!0}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this._skipRender=!1,this.renderOnDemand=!0,this.disposed=!1,this.requestRender=()=>{this._skipRender=!1},this.render=i=>{!this._renderer||(this._rafId=requestAnimationFrame(this.render),this.time=i,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&this._skipRender)&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))},this._resize=E_(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=d9.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())},10),this.canvas=e,this.renderOnDemand=t,window.location.search.includes("perfs")&&(this._perfs=new n9({x:10,y:10})),cU(e)}async load(e,t){u9(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await _V(e);this._data=i,i.version&&(0,c9.default)(i.version,"0.9.302")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([ob(i)&&G6(),e8(i)&&F6(),i.scene.environment.usePhysics&&CN(),ib(i)&&jk()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let r=new s9(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let s=performance.now();h9(i,r.scene);let n=performance.now();console.log("Merged geometries in ",n-s," ms")}if(ob(i)&&this._scene.traverse(s=>{Sn(s)&&s.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(s=>{s instanceof iu&&s.pendingMediaLoad&&s.update()})}),ib(i)&&JG(i)){let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n)).map(n=>n.loadingPromise);await Promise.all(s)}if(this._scene.rewriteEventsBeforeGoToPlayMode(),a2(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new r9({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?hg:lw,j8(i.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let s=Object.values(i.frames)[0];s.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=s.size[0],this._viewportHeight=s.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new SV(this._renderer,this._camera,new G(this._viewportWidth,this._viewportHeight),new G(window.innerWidth,window.innerHeight))}if(t&&(this._scene.updateMatrixWorld(!0),this._controls=new $G(i,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new AV(this._renderer,this._scene,this._camera,i.scene.publish.stopRaycast,i.scene.publish.preventScroll,i.scene.publish.preventTouchScroll,i.scene.publish.hideCursor,this._sharedAssetsManager,this.requestRender,this._controls,!0)),this._resize(),!this._resizeObserver&&this.canvas.parentElement){let s=!0;this._resizeObserver=new ResizeObserver(()=>{if(s){s=!1;return}this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)}this._rafId===void 0?this.render(performance.now()):this.requestRender()}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof u2&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new Gi(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this.requestRender()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(e=>{ky.unsubscribe(e)}),this._renderer?.dispose(),this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),dU(this.canvas)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=ky(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var Bu=window,zu=Bu.ShadowRoot&&(Bu.ShadyCSS===void 0||Bu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,zv=Symbol(),v2=new WeakMap,jh=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==zv)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(zu&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=v2.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&v2.set(i,t))}return t}toString(){return this.cssText}},y2=e=>new jh(typeof e=="string"?e:e+"",void 0,zv),Nv=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new jh(i,e,zv)},Uv=(e,t)=>{zu?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Bu.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Nu=zu?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return y2(i)})(e):e;var Fv,Uu=window,x2=Uu.trustedTypes,p9=x2?x2.emptyScript:"",b2=Uu.reactiveElementPolyfillSupport,jv={toAttribute(e,t){switch(t){case Boolean:e=e?p9:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},w2=(e,t)=>t!==e&&(t==t||e==e),kv={attribute:!0,type:String,converter:jv,reflect:!1,hasChanged:w2},Zs=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=kv){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||kv}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Nu(s))}else t!==void 0&&i.push(Nu(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Uv(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=kv){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:jv).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:jv;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||w2)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Zs.finalized=!0,Zs.elementProperties=new Map,Zs.elementStyles=[],Zs.shadowRootOptions={mode:"open"},b2?.({ReactiveElement:Zs}),((Fv=Uu.reactiveElementVersions)!==null&&Fv!==void 0?Fv:Uu.reactiveElementVersions=[]).push("1.6.0");var Gv,Fu=window,al=Fu.trustedTypes,_2=al?al.createPolicy("lit-html",{createHTML:e=>e}):void 0,Un=`lit$${(Math.random()+"").slice(9)}$`,P2="?"+Un,f9=`<${P2}>`,ol=document,Vh=(e="")=>ol.createComment(e),Hh=e=>e===null||typeof e!="object"&&typeof e!="function",D2=Array.isArray,m9=e=>D2(e)||typeof e?.[Symbol.iterator]=="function",Gh=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,A2=/-->/g,S2=/>/g,Da=RegExp(`>|[
|
|
5213
5213
|
\f\r](?:([^\\s"'>=/]+)([
|
|
5214
5214
|
\f\r]*=[
|
|
5215
5215
|
\f\r]*(?:[^
|