@splinetool/viewer 0.9.502 → 0.9.503
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.js
CHANGED
|
@@ -3149,10 +3149,10 @@ void main() {
|
|
|
3149
3149
|
squared_mean = squared_mean / samples;
|
|
3150
3150
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3151
3151
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3152
|
-
}`;function SR(e,t,i){let r=new S0,s=new F,a=new F,n=new rt,o=new xA({depthPacking:aA}),l=new bR,h={},u=i.maxTextureSize,c={[Ms]:Pi,[Pi]:Ms,[Sr]:Sr},d=new Lt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:wR,fragmentShader:_R}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ue;f.setAttribute("position",new Ze(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new hr(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=v0,this.render=function(b,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=e.getRenderTarget(),S=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,D=b.length;T<D;T++){let P=b[T],I=P.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;s.copy(I.mapSize);let R=I.getFrameExtents();if(s.multiply(R),a.copy(I.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(a.x=Math.floor(u/R.x),s.x=a.x*R.x,I.mapSize.x=a.x),s.y>u&&(a.y=Math.floor(u/R.y),s.y=a.y*R.y,I.mapSize.y=a.y)),I.map===null){let N=this.type!==oc?{minFilter:kt,magFilter:kt}:{};I.map=new Dt(s.x,s.y,N),I.map.texture.name=P.name+".shadowMap",I.camera.updateProjectionMatrix()}e.setRenderTarget(I.map),e.clear();let U=I.getViewportCount();for(let N=0;N<U;N++){let L=I.getViewport(N);n.set(a.x*L.x,a.y*L.y,a.x*L.z,a.y*L.w),C.viewport(n),I.updateMatrices(P,N),r=I.getFrustum(),x(w,A,I.camera,P,this.type)}I.isPointLightShadow!==!0&&this.type===oc&&v(I,A),I.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(_,S,M)};function v(b,w){let A=t.update(m);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Dt(s.x,s.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,e.setRenderTarget(b.mapPass),e.clear(),e.renderBufferDirect(w,null,A,d,m,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,e.setRenderTarget(b.map),e.clear(),e.renderBufferDirect(w,null,A,p,m,null)}function y(b,w,A,_,S,M){let C=null,T=A.isPointLight===!0?b.customDistanceMaterial:b.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 D=C.uuid,P=w.uuid,I=h[D];I===void 0&&(I={},h[D]=I);let R=I[P];R===void 0&&(R=C.clone(),I[P]=R),C=R}return C.visible=w.visible,C.wireframe=w.wireframe,M===oc?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=_,C.farDistance=S),C}function x(b,w,A,_,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===oc)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let C=t.update(b),T=b.material;if(Array.isArray(T)){let D=C.groups;for(let P=0,I=D.length;P<I;P++){let R=D[P],U=T[R.materialIndex];if(U&&U.visible){let N=y(b,U,_,A.near,A.far,S);e.renderBufferDirect(A,null,C,N,b,R)}}}else if(T.visible){let D=y(b,T,_,A.near,A.far,S);e.renderBufferDirect(A,null,C,D,b,null)}}let M=b.children;for(let C=0,T=M.length;C<T;C++)x(M[C],w,A,_,S)}}function AR(e,t,i){let r=i.isWebGL2;function s(){let X=!1,ne=new rt,ve=null,_e=new rt(0,0,0,0);return{setMask:function(qe){ve!==qe&&!X&&(e.colorMask(qe,qe,qe,qe),ve=qe)},setLocked:function(qe){X=qe},setClear:function(qe,wt,Gt,Ui,zn){zn===!0&&(qe*=Ui,wt*=Ui,Gt*=Ui),ne.set(qe,wt,Gt,Ui),_e.equals(ne)===!1&&(e.clearColor(qe,wt,Gt,Ui),_e.copy(ne))},reset:function(){X=!1,ve=null,_e.set(-1,0,0,0)}}}function a(){let X=!1,ne=null,ve=null,_e=null;return{setTest:function(qe){qe?ie(2929):Q(2929)},setMask:function(qe){ne!==qe&&!X&&(e.depthMask(qe),ne=qe)},setFunc:function(qe){if(ve!==qe){switch(qe){case HT:e.depthFunc(512);break;case WT:e.depthFunc(519);break;case qT:e.depthFunc(513);break;case Cg:e.depthFunc(515);break;case YT:e.depthFunc(514);break;case XT:e.depthFunc(518);break;case QT:e.depthFunc(516);break;case ZT:e.depthFunc(517);break;default:e.depthFunc(515)}ve=qe}},setLocked:function(qe){X=qe},setClear:function(qe){_e!==qe&&(e.clearDepth(qe),_e=qe)},reset:function(){X=!1,ne=null,ve=null,_e=null}}}function n(){let X=!1,ne=null,ve=null,_e=null,qe=null,wt=null,Gt=null,Ui=null,zn=null;return{setTest:function(jt){X||(jt?ie(2960):Q(2960))},setMask:function(jt){ne!==jt&&!X&&(e.stencilMask(jt),ne=jt)},setFunc:function(jt,ha,Vr){(ve!==jt||_e!==ha||qe!==Vr)&&(e.stencilFunc(jt,ha,Vr),ve=jt,_e=ha,qe=Vr)},setOp:function(jt,ha,Vr){(wt!==jt||Gt!==ha||Ui!==Vr)&&(e.stencilOp(jt,ha,Vr),wt=jt,Gt=ha,Ui=Vr)},setLocked:function(jt){X=jt},setClear:function(jt){zn!==jt&&(e.clearStencil(jt),zn=jt)},reset:function(){X=!1,ne=null,ve=null,_e=null,qe=null,wt=null,Gt=null,Ui=null,zn=null}}}let o=new s,l=new a,h=new n,u=new WeakMap,c=new WeakMap,d={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,b=null,w=null,A=null,_=null,S=null,M=!1,C=null,T=null,D=null,P=null,I=null,R=e.getParameter(35661),U=!1,N=0,L=e.getParameter(7938);L.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL (\d)/.exec(L)[1]),U=N>=1):L.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),U=N>=2);let W=null,G={},j=e.getParameter(3088),k=e.getParameter(2978),q=new rt().fromArray(j),H=new rt().fromArray(k);function Y(X,ne,ve){let _e=new Uint8Array(4),qe=e.createTexture();e.bindTexture(X,qe),e.texParameteri(X,10241,9728),e.texParameteri(X,10240,9728);for(let wt=0;wt<ve;wt++)e.texImage2D(ne+wt,0,6408,1,1,0,6408,5121,_e);return qe}let V={};V[3553]=Y(3553,3553,1),V[34067]=Y(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ie(2929),l.setFunc(Cg),Ee(!1),Ie(f1),ie(2884),Me(fi);function ie(X){d[X]!==!0&&(e.enable(X),d[X]=!0)}function Q(X){d[X]!==!1&&(e.disable(X),d[X]=!1)}function re(X,ne){return p[X]!==ne?(e.bindFramebuffer(X,ne),p[X]=ne,r&&(X===36009&&(p[36160]=ne),X===36160&&(p[36009]=ne)),!0):!1}function Z(X,ne){let ve=m,_e=!1;if(X)if(ve=f.get(ne),ve===void 0&&(ve=[],f.set(ne,ve)),X.isWebGLMultipleRenderTargets){let qe=X.texture;if(ve.length!==qe.length||ve[0]!==36064){for(let wt=0,Gt=qe.length;wt<Gt;wt++)ve[wt]=36064+wt;ve.length=qe.length,_e=!0}}else ve[0]!==36064&&(ve[0]=36064,_e=!0);else ve[0]!==1029&&(ve[0]=1029,_e=!0);_e&&(i.isWebGL2?e.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function pe(X){return g!==X?(e.useProgram(X),g=X,!0):!1}let oe={[ml]:32774,[RT]:32778,[LT]:32779};if(r)oe[y1]=32775,oe[x1]=32776;else{let X=t.get("EXT_blend_minmax");X!==null&&(oe[y1]=X.MIN_EXT,oe[x1]=X.MAX_EXT)}let ae={[BT]:0,[zT]:1,[kT]:768,[KS]:770,[GT]:776,[VT]:774,[UT]:772,[NT]:769,[JS]:771,[jT]:775,[FT]:773};function Me(X,ne,ve,_e,qe,wt,Gt,Ui){if(X===fi){v===!0&&(Q(3042),v=!1);return}if(v===!1&&(ie(3042),v=!0),X!==OT){if(X!==y||Ui!==M){if((x!==ml||A!==ml)&&(e.blendEquation(32774),x=ml,A=ml),Ui)switch(X){case ho:e.blendFuncSeparate(1,771,1,771);break;case m1:e.blendFunc(1,1);break;case g1:e.blendFuncSeparate(0,769,0,1);break;case v1:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",X);break}else switch(X){case ho:e.blendFuncSeparate(770,771,1,771);break;case m1:e.blendFunc(770,1);break;case g1:e.blendFuncSeparate(0,769,0,1);break;case v1:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",X);break}b=null,w=null,_=null,S=null,y=X,M=Ui}return}qe=qe||ne,wt=wt||ve,Gt=Gt||_e,(ne!==x||qe!==A)&&(e.blendEquationSeparate(oe[ne],oe[qe]),x=ne,A=qe),(ve!==b||_e!==w||wt!==_||Gt!==S)&&(e.blendFuncSeparate(ae[ve],ae[_e],ae[wt],ae[Gt]),b=ve,w=_e,_=wt,S=Gt),y=X,M=!1}function Ae(X,ne){X.side===Sr?Q(2884):ie(2884);let ve=X.side===Pi;ne&&(ve=!ve),Ee(ve),X.blending===ho&&X.transparent===!1?Me(fi):Me(X.blending,X.blendEquation,X.blendSrc,X.blendDst,X.blendEquationAlpha,X.blendSrcAlpha,X.blendDstAlpha,X.premultipliedAlpha),l.setFunc(X.depthFunc),l.setTest(X.depthTest),l.setMask(X.depthWrite),o.setMask(X.colorWrite);let _e=X.stencilWrite;h.setTest(_e),_e&&(h.setMask(X.stencilWriteMask),h.setFunc(X.stencilFunc,X.stencilRef,X.stencilFuncMask),h.setOp(X.stencilFail,X.stencilZFail,X.stencilZPass)),ye(X.polygonOffset,X.polygonOffsetFactor,X.polygonOffsetUnits),X.alphaToCoverage===!0?ie(32926):Q(32926)}function Ee(X){C!==X&&(X?e.frontFace(2304):e.frontFace(2305),C=X)}function Ie(X){X!==DT?(ie(2884),X!==T&&(X===f1?e.cullFace(1029):X===PT?e.cullFace(1028):e.cullFace(1032))):Q(2884),T=X}function be(X){X!==D&&(U&&e.lineWidth(X),D=X)}function ye(X,ne,ve){X?(ie(32823),(P!==ne||I!==ve)&&(e.polygonOffset(ne,ve),P=ne,I=ve)):Q(32823)}function ke(X){X?ie(3089):Q(3089)}function Je(X){X===void 0&&(X=33984+R-1),W!==X&&(e.activeTexture(X),W=X)}function z(X,ne,ve){ve===void 0&&(W===null?ve=33984+R-1:ve=W);let _e=G[ve];_e===void 0&&(_e={type:void 0,texture:void 0},G[ve]=_e),(_e.type!==X||_e.texture!==ne)&&(W!==ve&&(e.activeTexture(ve),W=ve),e.bindTexture(X,ne||V[X]),_e.type=X,_e.texture=ne)}function O(){let X=G[W];X!==void 0&&X.type!==void 0&&(e.bindTexture(X.type,null),X.type=void 0,X.texture=void 0)}function $(){try{e.compressedTexImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function ge(){try{e.compressedTexImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function de(){try{e.texSubImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function xe(){try{e.texSubImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Be(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Ce(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function ue(){try{e.texStorage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Oe(){try{e.texStorage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function ze(){try{e.texImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Re(){try{e.texImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Ke(X){q.equals(X)===!1&&(e.scissor(X.x,X.y,X.z,X.w),q.copy(X))}function je(X){H.equals(X)===!1&&(e.viewport(X.x,X.y,X.z,X.w),H.copy(X))}function vt(X,ne){let ve=c.get(ne);ve===void 0&&(ve=new WeakMap,c.set(ne,ve));let _e=ve.get(X);_e===void 0&&(_e=e.getUniformBlockIndex(ne,X.name),ve.set(X,_e))}function Nt(X,ne){let ve=c.get(ne).get(X);u.get(ne)!==ve&&(e.uniformBlockBinding(ne,ve,X.__bindingPointIndex),u.set(ne,ve))}function oi(){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={},W=null,G={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,b=null,w=null,A=null,_=null,S=null,M=!1,C=null,T=null,D=null,P=null,I=null,q.set(0,0,e.canvas.width,e.canvas.height),H.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ie,disable:Q,bindFramebuffer:re,drawBuffers:Z,useProgram:pe,setBlending:Me,setMaterial:Ae,setFlipSided:Ee,setCullFace:Ie,setLineWidth:be,setPolygonOffset:ye,setScissorTest:ke,activeTexture:Je,bindTexture:z,unbindTexture:O,compressedTexImage2D:$,compressedTexImage3D:ge,texImage2D:ze,texImage3D:Re,updateUBOMapping:vt,uniformBlockBinding:Nt,texStorage2D:ue,texStorage3D:Oe,texSubImage2D:de,texSubImage3D:xe,compressedTexSubImage2D:Be,compressedTexSubImage3D:Ce,scissor:Ke,viewport:je,reset:oi}}function MR(e,t,i,r,s,a,n){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,m,g=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(z,O){return v?new OffscreenCanvas(z,O):Zu("canvas")}function x(z,O,$,ge){let de=1;if((z.width>ge||z.height>ge)&&(de=ge/Math.max(z.width,z.height)),de<1||O===!0)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap){let xe=O?Qu:Math.floor,Be=xe(de*z.width),Ce=xe(de*z.height);m===void 0&&(m=y(Be,Ce));let ue=$?y(Be,Ce):m;return ue.width=Be,ue.height=Ce,ue.getContext("2d").drawImage(z,0,0,Be,Ce),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+Be+"x"+Ce+")."),ue}else return"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+")."),z;return z}function b(z){return Rg(z.width)&&Rg(z.height)}function w(z){return o?!1:z.wrapS!==ii||z.wrapT!==ii||z.minFilter!==kt&&z.minFilter!==lt}function A(z,O){return z.generateMipmaps&&O&&z.minFilter!==kt&&z.minFilter!==lt}function _(z){e.generateMipmap(z)}function S(z,O,$,ge,de=!1){if(o===!1)return O;if(z!==null){if(e[z]!==void 0)return e[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let xe=O;return O===6403&&($===5126&&(xe=33326),$===5131&&(xe=33325),$===5121&&(xe=33321)),O===33319&&($===5126&&(xe=33328),$===5131&&(xe=33327),$===5121&&(xe=33323)),O===6408&&($===5126&&(xe=34836),$===5131&&(xe=34842),$===5121&&(xe=ge===it&&de===!1?35907:32856),$===32819&&(xe=32854),$===32820&&(xe=32855)),(xe===33325||xe===33326||xe===33327||xe===33328||xe===34842||xe===34836)&&t.get("EXT_color_buffer_float"),xe}function M(z,O,$){return A(z,$)===!0||z.isFramebufferTexture&&z.minFilter!==kt&&z.minFilter!==lt?Math.log2(Math.max(O.width,O.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?O.mipmaps.length:1}function C(z){return z===kt||z===b1||z===Mf?9728:9729}function T(z){let O=z.target;O.removeEventListener("dispose",T),P(O),O.isVideoTexture&&f.delete(O)}function D(z){let O=z.target;O.removeEventListener("dispose",D),R(O)}function P(z){let O=r.get(z);if(O.__webglInit===void 0)return;let $=z.source,ge=g.get($);if(ge){let de=ge[O.__cacheKey];de.usedTimes--,de.usedTimes===0&&I(z),Object.keys(ge).length===0&&g.delete($)}r.remove(z)}function I(z){let O=r.get(z);e.deleteTexture(O.__webglTexture);let $=z.source,ge=g.get($);delete ge[O.__cacheKey],n.memory.textures--}function R(z){let O=z.texture,$=r.get(z),ge=r.get(O);if(ge.__webglTexture!==void 0&&(e.deleteTexture(ge.__webglTexture),n.memory.textures--),z.depthTexture&&z.depthTexture.dispose(),z.isWebGLCubeRenderTarget)for(let de=0;de<6;de++)e.deleteFramebuffer($.__webglFramebuffer[de]),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer[de]);else{if(e.deleteFramebuffer($.__webglFramebuffer),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer),$.__webglMultisampledFramebuffer&&e.deleteFramebuffer($.__webglMultisampledFramebuffer),$.__webglColorRenderbuffer)for(let de=0;de<$.__webglColorRenderbuffer.length;de++)$.__webglColorRenderbuffer[de]&&e.deleteRenderbuffer($.__webglColorRenderbuffer[de]);$.__webglDepthRenderbuffer&&e.deleteRenderbuffer($.__webglDepthRenderbuffer)}if(z.isWebGLMultipleRenderTargets)for(let de=0,xe=O.length;de<xe;de++){let Be=r.get(O[de]);Be.__webglTexture&&(e.deleteTexture(Be.__webglTexture),n.memory.textures--),r.remove(O[de])}r.remove(O),r.remove(z)}let U=0;function N(){U=0}function L(){let z=U;return z>=l&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+l),U+=1,z}function W(z){let O=[];return O.push(z.wrapS),O.push(z.wrapT),O.push(z.wrapR||0),O.push(z.magFilter),O.push(z.minFilter),O.push(z.anisotropy),O.push(z.internalFormat),O.push(z.format),O.push(z.type),O.push(z.generateMipmaps),O.push(z.premultiplyAlpha),O.push(z.flipY),O.push(z.unpackAlignment),O.push(z.encoding),O.join()}function G(z,O){let $=r.get(z);if(z.isVideoTexture&&ke(z),z.isRenderTargetTexture===!1&&z.version>0&&$.__version!==z.version){let ge=z.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q($,z,O);return}}i.bindTexture(3553,$.__webglTexture,33984+O)}function j(z,O){let $=r.get(z);if(z.version>0&&$.__version!==z.version){Q($,z,O);return}i.bindTexture(35866,$.__webglTexture,33984+O)}function k(z,O){let $=r.get(z);if(z.version>0&&$.__version!==z.version){Q($,z,O);return}i.bindTexture(32879,$.__webglTexture,33984+O)}function q(z,O){let $=r.get(z);if(z.version>0&&$.__version!==z.version){re($,z,O);return}i.bindTexture(34067,$.__webglTexture,33984+O)}let H={[Ra]:10497,[ii]:33071,[Pg]:33648},Y={[kt]:9728,[b1]:9984,[Mf]:9986,[lt]:9729,[s3]:9985,[Yl]:9987};function V(z,O,$){if($?(e.texParameteri(z,10242,H[O.wrapS]),e.texParameteri(z,10243,H[O.wrapT]),(z===32879||z===35866)&&e.texParameteri(z,32882,H[O.wrapR]),e.texParameteri(z,10240,Y[O.magFilter]),e.texParameteri(z,10241,Y[O.minFilter])):(e.texParameteri(z,10242,33071),e.texParameteri(z,10243,33071),(z===32879||z===35866)&&e.texParameteri(z,32882,33071),(O.wrapS!==ii||O.wrapT!==ii)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(z,10240,C(O.magFilter)),e.texParameteri(z,10241,C(O.minFilter)),O.minFilter!==kt&&O.minFilter!==lt&&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 ge=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===kt||O.minFilter!==Mf&&O.minFilter!==Yl||O.type===lr&&t.has("OES_texture_float_linear")===!1||o===!1&&O.type===bo&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(e.texParameterf(z,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,s.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function ie(z,O){let $=!1;z.__webglInit===void 0&&(z.__webglInit=!0,O.addEventListener("dispose",T));let ge=O.source,de=g.get(ge);de===void 0&&(de={},g.set(ge,de));let xe=W(O);if(xe!==z.__cacheKey){de[xe]===void 0&&(de[xe]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,$=!0),de[xe].usedTimes++;let Be=de[z.__cacheKey];Be!==void 0&&(de[z.__cacheKey].usedTimes--,Be.usedTimes===0&&I(O)),z.__cacheKey=xe,z.__webglTexture=de[xe].texture}return $}function Q(z,O,$){let ge=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ge=35866),O.isData3DTexture&&(ge=32879);let de=ie(z,O),xe=O.source;i.bindTexture(ge,z.__webglTexture,33984+$);let Be=r.get(xe);if(xe.version!==Be.__version||de===!0){i.activeTexture(33984+$),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Ce=w(O)&&b(O.image)===!1,ue=x(O.image,Ce,!1,u);ue=Je(O,ue);let Oe=b(ue)||o,ze=a.convert(O.format,O.encoding),Re=a.convert(O.type),Ke=S(O.internalFormat,ze,Re,O.encoding,O.isVideoTexture);V(ge,O,Oe);let je,vt=O.mipmaps,Nt=o&&O.isVideoTexture!==!0,oi=Be.__version===void 0||de===!0,X=M(O,ue,Oe);if(O.isDepthTexture)Ke=6402,o?O.type===lr?Ke=36012:O.type===La?Ke=33190:O.type===co?Ke=35056:Ke=33189:O.type===lr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===uo&&Ke===6402&&O.type!==tA&&O.type!==La&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=La,Re=a.convert(O.type)),O.format===wo&&Ke===6402&&(Ke=34041,O.type!==co&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=co,Re=a.convert(O.type))),oi&&(Nt?i.texStorage2D(3553,1,Ke,ue.width,ue.height):i.texImage2D(3553,0,Ke,ue.width,ue.height,0,ze,Re,null));else if(O.isDataTexture)if(vt.length>0&&Oe){Nt&&oi&&i.texStorage2D(3553,X,Ke,vt[0].width,vt[0].height);for(let ne=0,ve=vt.length;ne<ve;ne++)je=vt[ne],Nt?i.texSubImage2D(3553,ne,0,0,je.width,je.height,ze,Re,je.data):i.texImage2D(3553,ne,Ke,je.width,je.height,0,ze,Re,je.data);O.generateMipmaps=!1}else Nt?(oi&&i.texStorage2D(3553,X,Ke,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ue.width,ue.height,ze,Re,ue.data)):i.texImage2D(3553,0,Ke,ue.width,ue.height,0,ze,Re,ue.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Nt&&oi&&i.texStorage3D(35866,X,Ke,vt[0].width,vt[0].height,ue.depth);for(let ne=0,ve=vt.length;ne<ve;ne++)je=vt[ne],O.format!==Nr?ze!==null?Nt?i.compressedTexSubImage3D(35866,ne,0,0,0,je.width,je.height,ue.depth,ze,je.data,0,0):i.compressedTexImage3D(35866,ne,Ke,je.width,je.height,ue.depth,0,je.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?i.texSubImage3D(35866,ne,0,0,0,je.width,je.height,ue.depth,ze,Re,je.data):i.texImage3D(35866,ne,Ke,je.width,je.height,ue.depth,0,ze,Re,je.data)}else{Nt&&oi&&i.texStorage2D(3553,X,Ke,vt[0].width,vt[0].height);for(let ne=0,ve=vt.length;ne<ve;ne++)je=vt[ne],O.format!==Nr?ze!==null?Nt?i.compressedTexSubImage2D(3553,ne,0,0,je.width,je.height,ze,je.data):i.compressedTexImage2D(3553,ne,Ke,je.width,je.height,0,je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?i.texSubImage2D(3553,ne,0,0,je.width,je.height,ze,Re,je.data):i.texImage2D(3553,ne,Ke,je.width,je.height,0,ze,Re,je.data)}else if(O.isDataArrayTexture)Nt?(oi&&i.texStorage3D(35866,X,Ke,ue.width,ue.height,ue.depth),i.texSubImage3D(35866,0,0,0,0,ue.width,ue.height,ue.depth,ze,Re,ue.data)):i.texImage3D(35866,0,Ke,ue.width,ue.height,ue.depth,0,ze,Re,ue.data);else if(O.isData3DTexture)Nt?(oi&&i.texStorage3D(32879,X,Ke,ue.width,ue.height,ue.depth),i.texSubImage3D(32879,0,0,0,0,ue.width,ue.height,ue.depth,ze,Re,ue.data)):i.texImage3D(32879,0,Ke,ue.width,ue.height,ue.depth,0,ze,Re,ue.data);else if(O.isFramebufferTexture){if(oi)if(Nt)i.texStorage2D(3553,X,Ke,ue.width,ue.height);else{let ne=ue.width,ve=ue.height;for(let _e=0;_e<X;_e++)i.texImage2D(3553,_e,Ke,ne,ve,0,ze,Re,null),ne>>=1,ve>>=1}}else if(vt.length>0&&Oe){Nt&&oi&&i.texStorage2D(3553,X,Ke,vt[0].width,vt[0].height);for(let ne=0,ve=vt.length;ne<ve;ne++)je=vt[ne],Nt?i.texSubImage2D(3553,ne,0,0,ze,Re,je):i.texImage2D(3553,ne,Ke,ze,Re,je);O.generateMipmaps=!1}else Nt?(oi&&i.texStorage2D(3553,X,Ke,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ze,Re,ue)):i.texImage2D(3553,0,Ke,ze,Re,ue);A(O,Oe)&&_(ge),Be.__version=xe.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function re(z,O,$){if(O.image.length!==6)return;let ge=ie(z,O),de=O.source;i.bindTexture(34067,z.__webglTexture,33984+$);let xe=r.get(de);if(de.version!==xe.__version||ge===!0){i.activeTexture(33984+$),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Be=O.isCompressedTexture||O.image[0].isCompressedTexture,Ce=O.image[0]&&O.image[0].isDataTexture,ue=[];for(let ne=0;ne<6;ne++)!Be&&!Ce?ue[ne]=x(O.image[ne],!1,!0,h):ue[ne]=Ce?O.image[ne].image:O.image[ne],ue[ne]=Je(O,ue[ne]);let Oe=ue[0],ze=b(Oe)||o,Re=a.convert(O.format,O.encoding),Ke=a.convert(O.type),je=S(O.internalFormat,Re,Ke,O.encoding),vt=o&&O.isVideoTexture!==!0,Nt=xe.__version===void 0||ge===!0,oi=M(O,Oe,ze);V(34067,O,ze);let X;if(Be){vt&&Nt&&i.texStorage2D(34067,oi,je,Oe.width,Oe.height);for(let ne=0;ne<6;ne++){X=ue[ne].mipmaps;for(let ve=0;ve<X.length;ve++){let _e=X[ve];O.format!==Nr?Re!==null?vt?i.compressedTexSubImage2D(34069+ne,ve,0,0,_e.width,_e.height,Re,_e.data):i.compressedTexImage2D(34069+ne,ve,je,_e.width,_e.height,0,_e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):vt?i.texSubImage2D(34069+ne,ve,0,0,_e.width,_e.height,Re,Ke,_e.data):i.texImage2D(34069+ne,ve,je,_e.width,_e.height,0,Re,Ke,_e.data)}}}else{X=O.mipmaps,vt&&Nt&&(X.length>0&&oi++,i.texStorage2D(34067,oi,je,ue[0].width,ue[0].height));for(let ne=0;ne<6;ne++)if(Ce){vt?i.texSubImage2D(34069+ne,0,0,0,ue[ne].width,ue[ne].height,Re,Ke,ue[ne].data):i.texImage2D(34069+ne,0,je,ue[ne].width,ue[ne].height,0,Re,Ke,ue[ne].data);for(let ve=0;ve<X.length;ve++){let _e=X[ve].image[ne].image;vt?i.texSubImage2D(34069+ne,ve+1,0,0,_e.width,_e.height,Re,Ke,_e.data):i.texImage2D(34069+ne,ve+1,je,_e.width,_e.height,0,Re,Ke,_e.data)}}else{vt?i.texSubImage2D(34069+ne,0,0,0,Re,Ke,ue[ne]):i.texImage2D(34069+ne,0,je,Re,Ke,ue[ne]);for(let ve=0;ve<X.length;ve++){let _e=X[ve];vt?i.texSubImage2D(34069+ne,ve+1,0,0,Re,Ke,_e.image[ne]):i.texImage2D(34069+ne,ve+1,je,Re,Ke,_e.image[ne])}}}A(O,ze)&&_(34067),xe.__version=de.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Z(z,O,$,ge,de){let xe=a.convert($.format,$.encoding),Be=a.convert($.type),Ce=S($.internalFormat,xe,Be,$.encoding);r.get(O).__hasExternalTextures||(de===32879||de===35866?i.texImage3D(de,0,Ce,O.width,O.height,O.depth,0,xe,Be,null):i.texImage2D(de,0,Ce,O.width,O.height,0,xe,Be,null)),i.bindFramebuffer(36160,z),ye(O)?d.framebufferTexture2DMultisampleEXT(36160,ge,de,r.get($).__webglTexture,0,be(O)):(de===3553||de>=34069&&de<=34074)&&e.framebufferTexture2D(36160,ge,de,r.get($).__webglTexture,0),i.bindFramebuffer(36160,null)}function pe(z,O,$){if(e.bindRenderbuffer(36161,z),O.depthBuffer&&!O.stencilBuffer){let ge=33189;if($||ye(O)){let de=O.depthTexture;de&&de.isDepthTexture&&(de.type===lr?ge=36012:de.type===La&&(ge=33190));let xe=be(O);ye(O)?d.renderbufferStorageMultisampleEXT(36161,xe,ge,O.width,O.height):e.renderbufferStorageMultisample(36161,xe,ge,O.width,O.height)}else e.renderbufferStorage(36161,ge,O.width,O.height);e.framebufferRenderbuffer(36160,36096,36161,z)}else if(O.depthBuffer&&O.stencilBuffer){let ge=be(O);$&&ye(O)===!1?e.renderbufferStorageMultisample(36161,ge,35056,O.width,O.height):ye(O)?d.renderbufferStorageMultisampleEXT(36161,ge,35056,O.width,O.height):e.renderbufferStorage(36161,34041,O.width,O.height),e.framebufferRenderbuffer(36160,33306,36161,z)}else{let ge=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let de=0;de<ge.length;de++){let xe=ge[de],Be=a.convert(xe.format,xe.encoding),Ce=a.convert(xe.type),ue=S(xe.internalFormat,Be,Ce,xe.encoding),Oe=be(O);$&&ye(O)===!1?e.renderbufferStorageMultisample(36161,Oe,ue,O.width,O.height):ye(O)?d.renderbufferStorageMultisampleEXT(36161,Oe,ue,O.width,O.height):e.renderbufferStorage(36161,ue,O.width,O.height)}}e.bindRenderbuffer(36161,null)}function oe(z,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,z),!(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),G(O.depthTexture,0);let $=r.get(O.depthTexture).__webglTexture,ge=be(O);if(O.depthTexture.format===uo)ye(O)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,$,0,ge):e.framebufferTexture2D(36160,36096,3553,$,0);else if(O.depthTexture.format===wo)ye(O)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,$,0,ge):e.framebufferTexture2D(36160,33306,3553,$,0);else throw new Error("Unknown depthTexture format")}function ae(z){let O=r.get(z),$=z.isWebGLCubeRenderTarget===!0;if(z.depthTexture&&!O.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");oe(O.__webglFramebuffer,z)}else if($){O.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)i.bindFramebuffer(36160,O.__webglFramebuffer[ge]),O.__webglDepthbuffer[ge]=e.createRenderbuffer(),pe(O.__webglDepthbuffer[ge],z,!1)}else i.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=e.createRenderbuffer(),pe(O.__webglDepthbuffer,z,!1);i.bindFramebuffer(36160,null)}function Me(z,O,$){let ge=r.get(z);O!==void 0&&Z(ge.__webglFramebuffer,z,z.texture,36064,3553),$!==void 0&&ae(z)}function Ae(z){let O=z.texture,$=r.get(z),ge=r.get(O);z.addEventListener("dispose",D),z.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=e.createTexture()),ge.__version=O.version,n.memory.textures++);let de=z.isWebGLCubeRenderTarget===!0,xe=z.isWebGLMultipleRenderTargets===!0,Be=b(z)||o;if(de){$.__webglFramebuffer=[];for(let Ce=0;Ce<6;Ce++)$.__webglFramebuffer[Ce]=e.createFramebuffer()}else{if($.__webglFramebuffer=e.createFramebuffer(),xe)if(s.drawBuffers){let Ce=z.texture;for(let ue=0,Oe=Ce.length;ue<Oe;ue++){let ze=r.get(Ce[ue]);ze.__webglTexture===void 0&&(ze.__webglTexture=e.createTexture(),n.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&z.samples>0&&ye(z)===!1){let Ce=xe?O:[O];$.__webglMultisampledFramebuffer=e.createFramebuffer(),$.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,$.__webglMultisampledFramebuffer);for(let ue=0;ue<Ce.length;ue++){let Oe=Ce[ue];$.__webglColorRenderbuffer[ue]=e.createRenderbuffer(),e.bindRenderbuffer(36161,$.__webglColorRenderbuffer[ue]);let ze=a.convert(Oe.format,Oe.encoding),Re=a.convert(Oe.type),Ke=S(Oe.internalFormat,ze,Re,Oe.encoding,z.isXRRenderTarget===!0),je=be(z);e.renderbufferStorageMultisample(36161,je,Ke,z.width,z.height),e.framebufferRenderbuffer(36160,36064+ue,36161,$.__webglColorRenderbuffer[ue])}e.bindRenderbuffer(36161,null),z.depthBuffer&&($.__webglDepthRenderbuffer=e.createRenderbuffer(),pe($.__webglDepthRenderbuffer,z,!0)),i.bindFramebuffer(36160,null)}}if(de){i.bindTexture(34067,ge.__webglTexture),V(34067,O,Be);for(let Ce=0;Ce<6;Ce++)Z($.__webglFramebuffer[Ce],z,O,36064,34069+Ce);A(O,Be)&&_(34067),i.unbindTexture()}else if(xe){let Ce=z.texture;for(let ue=0,Oe=Ce.length;ue<Oe;ue++){let ze=Ce[ue],Re=r.get(ze);i.bindTexture(3553,Re.__webglTexture),V(3553,ze,Be),Z($.__webglFramebuffer,z,ze,36064+ue,3553),A(ze,Be)&&_(3553)}i.unbindTexture()}else{let Ce=3553;(z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(o?Ce=z.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ce,ge.__webglTexture),V(Ce,O,Be),Z($.__webglFramebuffer,z,O,36064,Ce),A(O,Be)&&_(Ce),i.unbindTexture()}z.depthBuffer&&ae(z)}function Ee(z){let O=b(z)||o,$=z.isWebGLMultipleRenderTargets===!0?z.texture:[z.texture];for(let ge=0,de=$.length;ge<de;ge++){let xe=$[ge];if(A(xe,O)){let Be=z.isWebGLCubeRenderTarget?34067:3553,Ce=r.get(xe).__webglTexture;i.bindTexture(Be,Ce),_(Be),i.unbindTexture()}}}function Ie(z){if(o&&z.samples>0&&ye(z)===!1){let O=z.isWebGLMultipleRenderTargets?z.texture:[z.texture],$=z.width,ge=z.height,de=16384,xe=[],Be=z.stencilBuffer?33306:36096,Ce=r.get(z),ue=z.isWebGLMultipleRenderTargets===!0;if(ue)for(let Oe=0;Oe<O.length;Oe++)i.bindFramebuffer(36160,Ce.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Oe,36161,null),i.bindFramebuffer(36160,Ce.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Oe,3553,null,0);i.bindFramebuffer(36008,Ce.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ce.__webglFramebuffer);for(let Oe=0;Oe<O.length;Oe++){xe.push(36064+Oe),z.depthBuffer&&xe.push(Be);let ze=Ce.__ignoreDepthValues!==void 0?Ce.__ignoreDepthValues:!1;if(ze===!1&&(z.depthBuffer&&(de|=256),z.stencilBuffer&&(de|=1024)),ue&&e.framebufferRenderbuffer(36008,36064,36161,Ce.__webglColorRenderbuffer[Oe]),ze===!0&&(e.invalidateFramebuffer(36008,[Be]),e.invalidateFramebuffer(36009,[Be])),ue){let Re=r.get(O[Oe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Re,0)}e.blitFramebuffer(0,0,$,ge,0,0,$,ge,de,9728),p&&e.invalidateFramebuffer(36008,xe)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ue)for(let Oe=0;Oe<O.length;Oe++){i.bindFramebuffer(36160,Ce.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Oe,36161,Ce.__webglColorRenderbuffer[Oe]);let ze=r.get(O[Oe]).__webglTexture;i.bindFramebuffer(36160,Ce.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Oe,3553,ze,0)}i.bindFramebuffer(36009,Ce.__webglMultisampledFramebuffer)}}function be(z){return Math.min(c,z.samples)}function ye(z){let O=r.get(z);return o&&z.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function ke(z){let O=n.render.frame;f.get(z)!==O&&(f.set(z,O),z.update())}function Je(z,O){let $=z.encoding,ge=z.format,de=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||z.format===Og||$!==ea&&($===it?o===!1?t.has("EXT_sRGB")===!0&&ge===Nr?(z.format=Og,z.minFilter=lt,z.generateMipmaps=!1):O=hA.sRGBToLinear(O):(ge!==Nr||de!==Qi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",$)),O}this.allocateTextureUnit=L,this.resetTextureUnits=N,this.setTexture2D=G,this.setTexture2DArray=j,this.setTexture3D=k,this.setTextureCube=q,this.rebindTextures=Me,this.setupRenderTarget=Ae,this.updateRenderTargetMipmap=Ee,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=ye}function ER(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===Qi)return 5121;if(a===l3)return 32819;if(a===h3)return 32820;if(a===a3)return 5120;if(a===n3)return 5122;if(a===tA)return 5123;if(a===o3)return 5124;if(a===La)return 5125;if(a===lr)return 5126;if(a===bo)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===c3)return 6406;if(a===Nr)return 6408;if(a===d3)return 6409;if(a===u3)return 6410;if(a===uo)return 6402;if(a===wo)return 34041;if(a===Og)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===p3)return 6403;if(a===f3)return 36244;if(a===Hu)return 33319;if(a===m3)return 33320;if(a===iA)return 36249;if(a===Ef||a===Cf||a===Tf||a===Df)if(n===it)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===Ef)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Cf)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===Tf)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===Df)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===Ef)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Cf)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===Tf)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===Df)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===w1||a===_1||a===S1||a===A1)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===w1)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===_1)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===S1)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===A1)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===g3)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===M1||a===E1)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===M1)return n===it?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===E1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===C1||a===T1||a===D1||a===P1||a===I1||a===O1||a===R1||a===L1||a===B1||a===z1||a===k1||a===N1||a===U1||a===F1)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===C1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===T1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===D1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===P1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===I1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===O1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===R1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===L1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===B1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===z1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===k1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===N1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===U1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===F1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===Pf)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===Pf)return n===it?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===v3||a===V1||a===j1||a===G1)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===Pf)return o.COMPRESSED_RED_RGTC1_EXT;if(a===V1)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===j1)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===G1)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===co?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[a]!==void 0?e[a]:null}return{convert:s}}var CR=class extends Gi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Al=class extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}},TR={type:"move"},im=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Al,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 Al,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 Al,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,a=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let f of e.hand.values()){let m=t.getJointPose(f,i),g=this._getHandJoint(l,f);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=m!==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));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(TR)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Al;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Ql=class extends wi{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:uo,h!==uo&&h!==wo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===uo&&(i=La),i===void 0&&h===wo&&(i=co),super(null,r,s,a,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:kt,this.minFilter=o!==void 0?o:kt,this.flipY=!1,this.generateMipmaps=!1}},DR=class extends Ni{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,u=null,c=null,d=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new Set,b=new Map,w=new Gi;w.layers.enable(1),w.viewport=new rt;let A=new Gi;A.layers.enable(2),A.viewport=new rt;let _=[w,A],S=new CR;S.layers.enable(1),S.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let k=v[j];return k===void 0&&(k=new im,v[j]=k),k.getTargetRaySpace()},this.getControllerGrip=function(j){let k=v[j];return k===void 0&&(k=new im,v[j]=k),k.getGripSpace()},this.getHand=function(j){let k=v[j];return k===void 0&&(k=new im,v[j]=k),k.getHandSpace()};function T(j){let k=y.indexOf(j.inputSource);if(k===-1)return;let q=v[k];q!==void 0&&q.dispatchEvent({type:j.type,data:j.inputSource})}function D(){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",D),r.removeEventListener("inputsourceschange",P);for(let j=0;j<v.length;j++){let k=y[j];k!==null&&(y[j]=null,v[j].disconnect(k))}M=null,C=null,e.setRenderTarget(m),d=null,c=null,u=null,r=null,g=null,G.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){n=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(j){l=j},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(j){if(r=j,r!==null){if(m=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",D),r.addEventListener("inputsourceschange",P),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let k={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,k),r.updateRenderState({baseLayer:d}),g=new Dt(d.framebufferWidth,d.framebufferHeight,{format:Nr,type:Qi,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let k=null,q=null,H=null;f.depth&&(H=f.stencil?35056:33190,k=f.stencil?wo:uo,q=f.stencil?co:La);let Y={colorFormat:32856,depthFormat:H,scaleFactor:s};u=new XRWebGLBinding(r,t),c=u.createProjectionLayer(Y),r.updateRenderState({layers:[c]}),g=new Dt(c.textureWidth,c.textureHeight,{format:Nr,type:Qi,depthTexture:new Ql(c.textureWidth,c.textureHeight,q,void 0,void 0,void 0,void 0,void 0,void 0,k),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let V=e.properties.get(g);V.__ignoreDepthValues=c.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(n),G.setContext(r),G.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function P(j){for(let k=0;k<j.removed.length;k++){let q=j.removed[k],H=y.indexOf(q);H>=0&&(y[H]=null,v[H].disconnect(q))}for(let k=0;k<j.added.length;k++){let q=j.added[k],H=y.indexOf(q);if(H===-1){for(let V=0;V<v.length;V++)if(V>=y.length){y.push(q),H=V;break}else if(y[V]===null){y[V]=q,H=V;break}if(H===-1)break}let Y=v[H];Y&&Y.connect(q)}}let I=new E,R=new E;function U(j,k,q){I.setFromMatrixPosition(k.matrixWorld),R.setFromMatrixPosition(q.matrixWorld);let H=I.distanceTo(R),Y=k.projectionMatrix.elements,V=q.projectionMatrix.elements,ie=Y[14]/(Y[10]-1),Q=Y[14]/(Y[10]+1),re=(Y[9]+1)/Y[5],Z=(Y[9]-1)/Y[5],pe=(Y[8]-1)/Y[0],oe=(V[8]+1)/V[0],ae=ie*pe,Me=ie*oe,Ae=H/(-pe+oe),Ee=Ae*-pe;k.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Ee),j.translateZ(Ae),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert();let Ie=ie+Ae,be=Q+Ae,ye=ae-Ee,ke=Me+(H-Ee),Je=re*Q/be*Ie,z=Z*Q/be*Ie;j.projectionMatrix.makePerspective(ye,ke,Je,z,Ie,be)}function N(j,k){k===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(k.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(r===null)return;S.near=A.near=w.near=j.near,S.far=A.far=w.far=j.far,(M!==S.near||C!==S.far)&&(r.updateRenderState({depthNear:S.near,depthFar:S.far}),M=S.near,C=S.far);let k=j.parent,q=S.cameras;N(S,k);for(let Y=0;Y<q.length;Y++)N(q[Y],k);S.matrixWorld.decompose(S.position,S.quaternion,S.scale),j.matrix.copy(S.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale);let H=j.children;for(let Y=0,V=H.length;Y<V;Y++)H[Y].updateMatrixWorld(!0);q.length===2?U(S,w,A):S.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return S},this.getFoveation=function(){if(!(c===null&&d===null))return o},this.setFoveation=function(j){o=j,c!==null&&(c.fixedFoveation=j),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=j)},this.getPlanes=function(){return x};let L=null;function W(j,k){if(h=k.getViewerPose(l||a),p=k,h!==null){let q=h.views;d!==null&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let H=!1;q.length!==S.cameras.length&&(S.cameras.length=0,H=!0);for(let Y=0;Y<q.length;Y++){let V=q[Y],ie=null;if(d!==null)ie=d.getViewport(V);else{let re=u.getViewSubImage(c,V);ie=re.viewport,Y===0&&(e.setRenderTargetTextures(g,re.colorTexture,c.ignoreDepthValues?void 0:re.depthStencilTexture),e.setRenderTarget(g))}let Q=_[Y];Q===void 0&&(Q=new Gi,Q.layers.enable(Y),Q.viewport=new rt,_[Y]=Q),Q.matrix.fromArray(V.transform.matrix),Q.projectionMatrix.fromArray(V.projectionMatrix),Q.viewport.set(ie.x,ie.y,ie.width,ie.height),Y===0&&S.matrix.copy(Q.matrix),H===!0&&S.cameras.push(Q)}}for(let q=0;q<v.length;q++){let H=y[q],Y=v[q];H!==null&&Y!==void 0&&Y.update(H,k,l||a)}if(L&&L(j,k),k.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:k.detectedPlanes});let q=null;for(let H of x)k.detectedPlanes.has(H)||(q===null&&(q=[]),q.push(H));if(q!==null)for(let H of q)x.delete(H),b.delete(H),i.dispatchEvent({type:"planeremoved",data:H});for(let H of k.detectedPlanes)if(!x.has(H))x.add(H),b.set(H,k.lastChangedTime),i.dispatchEvent({type:"planeadded",data:H});else{let Y=b.get(H);H.lastChangedTime>Y&&(b.set(H,H.lastChangedTime),i.dispatchEvent({type:"planechanged",data:H}))}}p=null}let G=new fA;G.setAnimationLoop(W),this.setAnimationLoop=function(j){L=j},this.dispose=function(){}}};function PR(e,t){function i(m,g){g.color.getRGB(m.fogColor.value,pA(e)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,v,y,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(m,g):g.isMeshToonMaterial?(s(m,g),u(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g)):g.isMeshStandardMaterial?(s(m,g),c(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),f(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&n(m,g)):g.isPointsMaterial?o(m,g,v,y):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===Pi&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===Pi&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v=t.get(g).envMap;if(v&&(m.envMap.value=v,m.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let b=e.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function n(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,v,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*v,m.scale.value=y*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix))}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function c(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,v){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===Pi&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=v.texture,m.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function f(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function IR(e,t,i,r){let s={},a={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let b=x.program;r.uniformBlockBinding(y,b)}function h(y,x){let b=s[y.id];b===void 0&&(f(y),b=u(y),s[y.id]=b,y.addEventListener("dispose",g));let w=x.program;r.updateUBOMapping(y,w);let A=t.render.frame;a[y.id]!==A&&(d(y),a[y.id]=A)}function u(y){let x=c();y.__bindingPointIndex=x;let b=e.createBuffer(),w=y.__size,A=y.usage;return e.bindBuffer(35345,b),e.bufferData(35345,w,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,b),b}function c(){for(let y=0;y<o;y++)if(n.indexOf(y)===-1)return n.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){let x=s[y.id],b=y.uniforms,w=y.__cache;e.bindBuffer(35345,x);for(let A=0,_=b.length;A<_;A++){let S=b[A];if(p(S,A,w)===!0){let M=S.__offset,C=Array.isArray(S.value)?S.value:[S.value],T=0;for(let D=0;D<C.length;D++){let P=C[D],I=m(P);typeof P=="number"?(S.__data[0]=P,e.bufferSubData(35345,M+T,S.__data)):P.isMatrix3?(S.__data[0]=P.elements[0],S.__data[1]=P.elements[1],S.__data[2]=P.elements[2],S.__data[3]=P.elements[0],S.__data[4]=P.elements[3],S.__data[5]=P.elements[4],S.__data[6]=P.elements[5],S.__data[7]=P.elements[0],S.__data[8]=P.elements[6],S.__data[9]=P.elements[7],S.__data[10]=P.elements[8],S.__data[11]=P.elements[0]):(P.toArray(S.__data,T),T+=I.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,S.__data)}}e.bindBuffer(35345,null)}function p(y,x,b){let w=y.value;if(b[x]===void 0){if(typeof w=="number")b[x]=w;else{let A=Array.isArray(w)?w:[w],_=[];for(let S=0;S<A.length;S++)_.push(A[S].clone());b[x]=_}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],_=Array.isArray(w)?w:[w];for(let S=0;S<A.length;S++){let M=A[S];if(M.equals(_[S])===!1)return M.copy(_[S]),!0}}return!1}function f(y){let x=y.uniforms,b=0,w=16,A=0;for(let _=0,S=x.length;_<S;_++){let M=x[_],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let D=0,P=T.length;D<P;D++){let I=T[D],R=m(I);C.boundary+=R.boundary,C.storage+=R.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=b,_>0){A=b%w;let D=w-A;A!==0&&D-C.boundary<0&&(b+=w-A,M.__offset=b)}b+=C.storage}return A=b%w,A>0&&(b+=w-A),y.__size=b,y.__cache={},this}function m(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.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),x}function g(y){let x=y.target;x.removeEventListener("dispose",g);let b=n.indexOf(x.__bindingPointIndex);n.splice(b,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete a[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);n=[],s={},a={}}return{bind:l,update:h,dispose:v}}function OR(){let e=Zu("canvas");return e.style.display="block",e}function bA(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:OR(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,a=e.antialias!==void 0?e.antialias:!1,n=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=ea,this.physicallyCorrectLights=!1,this.toneMapping=za,this.toneMappingExposure=1;let m=this,g=!1,v=0,y=0,x=null,b=-1,w=null,A=new rt,_=new rt,S=null,M=t.width,C=t.height,T=1,D=null,P=null,I=new rt(0,0,M,C),R=new rt(0,0,M,C),U=!1,N=new S0,L=!1,W=!1,G=null,j=new me,k=new F,q=new E,H={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return x===null?T:1}let V=i;function ie(B,ee){for(let le=0;le<B.length;le++){let J=B[le],he=t.getContext(J,ee);if(he!==null)return he}return null}try{let B={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:n,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${hh}`),t.addEventListener("webglcontextlost",Ke,!1),t.addEventListener("webglcontextrestored",je,!1),t.addEventListener("webglcontextcreationerror",vt,!1),V===null){let ee=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ee.shift(),V=ie(ee,B),V===null)throw ie(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}V.getShaderPrecisionFormat===void 0&&(V.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let Q,re,Z,pe,oe,ae,Me,Ae,Ee,Ie,be,ye,ke,Je,z,O,$,ge,de,xe,Be,Ce,ue,Oe;function ze(){Q=new WI(V),re=new UI(V,Q,e),Q.init(re),Ce=new ER(V,Q,re),Z=new AR(V,Q,re),pe=new XI,oe=new dR,ae=new MR(V,Q,Z,oe,re,Ce,pe),Me=new VI(m),Ae=new HI(m),Ee=new rD(V,re),ue=new kI(V,Q,Ee,re),Ie=new qI(V,Ee,pe,ue),be=new JI(V,Ie,Ee,pe),de=new KI(V,re,ae),O=new FI(oe),ye=new cR(m,Me,Ae,Q,re,ue,O),ke=new PR(m,oe),Je=new pR,z=new xR(Q,re),ge=new zI(m,Me,Ae,Z,be,u,n),$=new SR(m,be,re),Oe=new IR(V,pe,re,Z),xe=new NI(V,Q,pe,re),Be=new YI(V,Q,pe,re),pe.programs=ye.programs,m.capabilities=re,m.extensions=Q,m.properties=oe,m.renderLists=Je,m.shadowMap=$,m.state=Z,m.info=pe}ze();let Re=new DR(m,V);this.xr=Re,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){let B=Q.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){let B=Q.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(B){B!==void 0&&(T=B,this.setSize(M,C,!1))},this.getSize=function(B){return B.set(M,C)},this.setSize=function(B,ee,le){if(Re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=B,C=ee,t.width=Math.floor(B*T),t.height=Math.floor(ee*T),le!==!1&&(t.style.width=B+"px",t.style.height=ee+"px"),this.setViewport(0,0,B,ee)},this.getDrawingBufferSize=function(B){return B.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(B,ee,le){M=B,C=ee,T=le,t.width=Math.floor(B*le),t.height=Math.floor(ee*le),this.setViewport(0,0,B,ee)},this.getCurrentViewport=function(B){return B.copy(A)},this.getViewport=function(B){return B.copy(I)},this.setViewport=function(B,ee,le,J){B.isVector4?I.set(B.x,B.y,B.z,B.w):I.set(B,ee,le,J),Z.viewport(A.copy(I).multiplyScalar(T).floor())},this.getScissor=function(B){return B.copy(R)},this.setScissor=function(B,ee,le,J){B.isVector4?R.set(B.x,B.y,B.z,B.w):R.set(B,ee,le,J),Z.scissor(_.copy(R).multiplyScalar(T).floor())},this.getScissorTest=function(){return U},this.setScissorTest=function(B){Z.setScissorTest(U=B)},this.setOpaqueSort=function(B){D=B},this.setTransparentSort=function(B){P=B},this.getClearColor=function(B){return B.copy(ge.getClearColor())},this.setClearColor=function(){ge.setClearColor.apply(ge,arguments)},this.getClearAlpha=function(){return ge.getClearAlpha()},this.setClearAlpha=function(){ge.setClearAlpha.apply(ge,arguments)},this.clear=function(B=!0,ee=!0,le=!0){let J=0;B&&(J|=16384),ee&&(J|=256),le&&(J|=1024),V.clear(J)},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",Ke,!1),t.removeEventListener("webglcontextrestored",je,!1),t.removeEventListener("webglcontextcreationerror",vt,!1),Je.dispose(),z.dispose(),oe.dispose(),Me.dispose(),Ae.dispose(),be.dispose(),ue.dispose(),Oe.dispose(),ye.dispose(),Re.dispose(),Re.removeEventListener("sessionstart",_e),Re.removeEventListener("sessionend",qe),G&&(G.dispose(),G=null),wt.stop()};function Ke(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function je(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let B=pe.autoReset,ee=$.enabled,le=$.autoUpdate,J=$.needsUpdate,he=$.type;ze(),pe.autoReset=B,$.enabled=ee,$.autoUpdate=le,$.needsUpdate=J,$.type=he}function vt(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function Nt(B){let ee=B.target;ee.removeEventListener("dispose",Nt),oi(ee)}function oi(B){X(B),oe.remove(B)}function X(B){let ee=oe.get(B).programs;ee!==void 0&&(ee.forEach(function(le){ye.releaseProgram(le)}),B.isShaderMaterial&&ye.releaseShaderCache(B))}this.renderBufferDirect=function(B,ee,le,J,he,Ne){ee===null&&(ee=H);let at=he.isMesh&&he.matrixWorld.determinant()<0,ct=iT(B,ee,le,J,he);Z.setMaterial(J,at);let ut=le.index,Bt=1;J.wireframe===!0&&(ut=Ie.getWireframeAttribute(le),Bt=2);let _t=le.drawRange,yt=le.attributes.position,Fi=_t.start*Bt,Ir=(_t.start+_t.count)*Bt;Ne!==null&&(Fi=Math.max(Fi,Ne.start*Bt),Ir=Math.min(Ir,(Ne.start+Ne.count)*Bt)),ut!==null?(Fi=Math.max(Fi,0),Ir=Math.min(Ir,ut.count)):yt!=null&&(Fi=Math.max(Fi,0),Ir=Math.min(Ir,yt.count));let ca=Ir-Fi;if(ca<0||ca===1/0)return;ue.setup(he,J,ct,le,ut);let kn,li=xe;if(ut!==null&&(kn=Ee.get(ut),li=Be,li.setIndex(kn)),he.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*Y()),li.setMode(1)):li.setMode(4);else if(he.isLine){let xt=J.linewidth;xt===void 0&&(xt=1),Z.setLineWidth(xt*Y()),he.isLineSegments?li.setMode(1):he.isLineLoop?li.setMode(2):li.setMode(3)}else he.isPoints?li.setMode(0):he.isSprite&&li.setMode(4);if(he.isInstancedMesh)li.renderInstances(Fi,ca,he.count);else if(le.isInstancedBufferGeometry){let xt=le._maxInstanceCount!==void 0?le._maxInstanceCount:1/0,bf=Math.min(le.instanceCount,xt);li.renderInstances(Fi,ca,bf)}else li.render(Fi,ca)},this.compile=function(B,ee){function le(J,he,Ne){J.transparent===!0&&J.side===Sr&&J.forceSinglePass===!1?(J.side=Pi,J.needsUpdate=!0,Vr(J,he,Ne),J.side=Ms,J.needsUpdate=!0,Vr(J,he,Ne),J.side=Sr):Vr(J,he,Ne)}d=z.get(B),d.init(),f.push(d),B.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(d.pushLight(J),J.castShadow&&d.pushShadow(J))}),d.setupLights(m.physicallyCorrectLights),B.traverse(function(J){let he=J.material;if(he)if(Array.isArray(he))for(let Ne=0;Ne<he.length;Ne++){let at=he[Ne];le(at,B,J)}else le(he,B,J)}),f.pop(),d=null};let ne=null;function ve(B){ne&&ne(B)}function _e(){wt.stop()}function qe(){wt.start()}let wt=new fA;wt.setAnimationLoop(ve),typeof self<"u"&&wt.setContext(self),this.setAnimationLoop=function(B){ne=B,Re.setAnimationLoop(B),B===null?wt.stop():wt.start()},Re.addEventListener("sessionstart",_e),Re.addEventListener("sessionend",qe),this.render=function(B,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Re.enabled===!0&&Re.isPresenting===!0&&(Re.cameraAutoUpdate===!0&&Re.updateCamera(ee),ee=Re.getCamera()),B.isScene===!0&&B.onBeforeRender(m,B,ee,x),d=z.get(B,f.length),d.init(),f.push(d),j.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),N.setFromProjectionMatrix(j),W=this.localClippingEnabled,L=O.init(this.clippingPlanes,W),c=Je.get(B,p.length),c.init(),p.push(c),Gt(B,ee,0,m.sortObjects),c.finish(),m.sortObjects===!0&&c.sort(D,P),L===!0&&O.beginShadows();let le=d.state.shadowsArray;if($.render(le,B,ee),L===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),ge.render(c,B),d.setupLights(m.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let he=0,Ne=J.length;he<Ne;he++){let at=J[he];Ui(c,B,at,at.viewport)}}else Ui(c,B,ee);x!==null&&(ae.updateMultisampleRenderTarget(x),ae.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(m,B,ee),ue.resetDefaultState(),b=-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 Gt(B,ee,le,J){if(B.visible===!1)return;if(B.layers.test(ee.layers)){if(B.isGroup)le=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(ee);else if(B.isLight)d.pushLight(B),B.castShadow&&d.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||N.intersectsSprite(B)){J&&q.setFromMatrixPosition(B.matrixWorld).applyMatrix4(j);let Ne=be.update(B),at=B.material;at.visible&&c.push(B,Ne,at,le,q.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(B.isSkinnedMesh&&B.skeleton.frame!==pe.render.frame&&(B.skeleton.update(),B.skeleton.frame=pe.render.frame),!B.frustumCulled||N.intersectsObject(B))){J&&q.setFromMatrixPosition(B.matrixWorld).applyMatrix4(j);let Ne=be.update(B),at=B.material;if(Array.isArray(at)){let ct=Ne.groups;for(let ut=0,Bt=ct.length;ut<Bt;ut++){let _t=ct[ut],yt=at[_t.materialIndex];yt&&yt.visible&&c.push(B,Ne,yt,le,q.z,_t)}}else at.visible&&c.push(B,Ne,at,le,q.z,null)}}let he=B.children;for(let Ne=0,at=he.length;Ne<at;Ne++)Gt(he[Ne],ee,le,J)}function Ui(B,ee,le,J){let he=B.opaque,Ne=B.transmissive,at=B.transparent;d.setupLightsView(le),L===!0&&O.setGlobalState(m.clippingPlanes,le),Ne.length>0&&zn(he,ee,le),J&&Z.viewport(A.copy(J)),he.length>0&&jt(he,ee,le),Ne.length>0&&jt(Ne,ee,le),at.length>0&&jt(at,ee,le),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function zn(B,ee,le){let J=re.isWebGL2;G===null&&(G=new Dt(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?bo:Qi,minFilter:Yl,samples:J&&a===!0?4:0})),m.getDrawingBufferSize(k),J?G.setSize(k.x,k.y):G.setSize(Qu(k.x),Qu(k.y));let he=m.getRenderTarget();m.setRenderTarget(G),m.clear();let Ne=m.toneMapping;m.toneMapping=za,jt(B,ee,le),m.toneMapping=Ne,ae.updateMultisampleRenderTarget(G),ae.updateRenderTargetMipmap(G),m.setRenderTarget(he)}function jt(B,ee,le){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let he=0,Ne=B.length;he<Ne;he++){let at=B[he],ct=at.object,ut=at.geometry,Bt=J===null?at.material:J,_t=at.group;ct.layers.test(le.layers)&&ha(ct,ee,le,ut,Bt,_t)}}function ha(B,ee,le,J,he,Ne){B.onBeforeRender(m,ee,le,J,he,Ne),B.modelViewMatrix.multiplyMatrices(le.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),he.onBeforeRender(m,ee,le,J,B,Ne),he.transparent===!0&&he.side===Sr&&he.forceSinglePass===!1?(he.side=Pi,he.needsUpdate=!0,m.renderBufferDirect(le,ee,J,he,B,Ne),he.side=Ms,he.needsUpdate=!0,m.renderBufferDirect(le,ee,J,he,B,Ne),he.side=Sr):m.renderBufferDirect(le,ee,J,he,B,Ne),B.onAfterRender(m,ee,le,J,he,Ne)}function Vr(B,ee,le){ee.isScene!==!0&&(ee=H);let J=oe.get(B),he=d.state.lights,Ne=d.state.shadowsArray,at=he.state.version,ct=ye.getParameters(B,he.state,Ne,ee,le),ut=ye.getProgramCacheKey(ct),Bt=J.programs;J.environment=B.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(B.isMeshStandardMaterial?Ae:Me).get(B.envMap||J.environment),Bt===void 0&&(B.addEventListener("dispose",Nt),Bt=new Map,J.programs=Bt);let _t=Bt.get(ut);if(_t!==void 0){if(J.currentProgram===_t&&J.lightsStateVersion===at)return d1(B,ct),_t}else ct.uniforms=ye.getUniforms(B),B.onBuild(le,ct,m),B.onBeforeCompile(ct,m),_t=ye.acquireProgram(ct,ut),Bt.set(ut,_t),J.uniforms=ct.uniforms;let yt=J.uniforms;(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(yt.clippingPlanes=O.uniform),d1(B,ct),J.needsLights=sT(B),J.lightsStateVersion=at,J.needsLights&&(yt.ambientLightColor.value=he.state.ambient,yt.lightProbe.value=he.state.probe,yt.directionalLights.value=he.state.directional,yt.directionalLightShadows.value=he.state.directionalShadow,yt.spotLights.value=he.state.spot,yt.spotLightShadows.value=he.state.spotShadow,yt.rectAreaLights.value=he.state.rectArea,yt.ltc_1.value=he.state.rectAreaLTC1,yt.ltc_2.value=he.state.rectAreaLTC2,yt.pointLights.value=he.state.point,yt.pointLightShadows.value=he.state.pointShadow,yt.hemisphereLights.value=he.state.hemi,yt.directionalShadowMap.value=he.state.directionalShadowMap,yt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,yt.spotShadowMap.value=he.state.spotShadowMap,yt.spotLightMatrix.value=he.state.spotLightMatrix,yt.spotLightMap.value=he.state.spotLightMap,yt.pointShadowMap.value=he.state.pointShadowMap,yt.pointShadowMatrix.value=he.state.pointShadowMatrix);let Fi=_t.getUniforms(),Ir=Ou.seqWithValue(Fi.seq,yt);return J.currentProgram=_t,J.uniformsList=Ir,_t}function d1(B,ee){let le=oe.get(B);le.outputEncoding=ee.outputEncoding,le.instancing=ee.instancing,le.skinning=ee.skinning,le.morphTargets=ee.morphTargets,le.morphNormals=ee.morphNormals,le.morphColors=ee.morphColors,le.morphTargetsCount=ee.morphTargetsCount,le.numClippingPlanes=ee.numClippingPlanes,le.numIntersection=ee.numClipIntersection,le.vertexAlphas=ee.vertexAlphas,le.vertexTangents=ee.vertexTangents,le.toneMapping=ee.toneMapping}function iT(B,ee,le,J,he){ee.isScene!==!0&&(ee=H),ae.resetTextureUnits();let Ne=ee.fog,at=J.isMeshStandardMaterial?ee.environment:null,ct=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:ea,ut=(J.isMeshStandardMaterial?Ae:Me).get(J.envMap||at),Bt=J.vertexColors===!0&&!!le.attributes.color&&le.attributes.color.itemSize===4,_t=!!J.normalMap&&!!le.attributes.tangent,yt=!!le.morphAttributes.position,Fi=!!le.morphAttributes.normal,Ir=!!le.morphAttributes.color,ca=J.toneMapped?m.toneMapping:za,kn=le.morphAttributes.position||le.morphAttributes.normal||le.morphAttributes.color,li=kn!==void 0?kn.length:0,xt=oe.get(J),bf=d.state.lights;if(L===!0&&(W===!0||B!==w)){let Or=B===w&&J.id===b;O.setState(J,B,Or)}let wf=!1;J.version===xt.__version?(xt.needsLights&&xt.lightsStateVersion!==bf.state.version||xt.outputEncoding!==ct||he.isInstancedMesh&&xt.instancing===!1||!he.isInstancedMesh&&xt.instancing===!0||he.isSkinnedMesh&&xt.skinning===!1||!he.isSkinnedMesh&&xt.skinning===!0||xt.envMap!==ut||J.fog===!0&&xt.fog!==Ne||xt.numClippingPlanes!==void 0&&(xt.numClippingPlanes!==O.numPlanes||xt.numIntersection!==O.numIntersection)||xt.vertexAlphas!==Bt||xt.vertexTangents!==_t||xt.morphTargets!==yt||xt.morphNormals!==Fi||xt.morphColors!==Ir||xt.toneMapping!==ca||re.isWebGL2===!0&&xt.morphTargetsCount!==li)&&(wf=!0):(wf=!0,xt.__version=J.version);let Nn=xt.currentProgram;wf===!0&&(Nn=Vr(J,ee,he));let u1=!1,Ih=!1,_f=!1,Bi=Nn.getUniforms(),Un=xt.uniforms;if(Z.useProgram(Nn.program)&&(u1=!0,Ih=!0,_f=!0),J.id!==b&&(b=J.id,Ih=!0),u1||w!==B){if(Bi.setValue(V,"projectionMatrix",B.projectionMatrix),re.logarithmicDepthBuffer&&Bi.setValue(V,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),w!==B&&(w=B,Ih=!0,_f=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let Or=Bi.map.cameraPosition;Or!==void 0&&Or.setValue(V,q.setFromMatrixPosition(B.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Bi.setValue(V,"isOrthographic",B.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||he.isSkinnedMesh)&&Bi.setValue(V,"viewMatrix",B.matrixWorldInverse)}if(he.isSkinnedMesh){Bi.setOptional(V,he,"bindMatrix"),Bi.setOptional(V,he,"bindMatrixInverse");let Or=he.skeleton;Or&&(re.floatVertexTextures?(Or.boneTexture===null&&Or.computeBoneTexture(),Bi.setValue(V,"boneTexture",Or.boneTexture,ae),Bi.setValue(V,"boneTextureSize",Or.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 Sf=le.morphAttributes;if((Sf.position!==void 0||Sf.normal!==void 0||Sf.color!==void 0&&re.isWebGL2===!0)&&de.update(he,le,J,Nn),(Ih||xt.receiveShadow!==he.receiveShadow)&&(xt.receiveShadow=he.receiveShadow,Bi.setValue(V,"receiveShadow",he.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(Un.envMap.value=ut,Un.flipEnvMap.value=ut.isCubeTexture&&ut.isRenderTargetTexture===!1?-1:1),Ih&&(Bi.setValue(V,"toneMappingExposure",m.toneMappingExposure),xt.needsLights&&rT(Un,_f),Ne&&J.fog===!0&&ke.refreshFogUniforms(Un,Ne),ke.refreshMaterialUniforms(Un,J,T,C,G),Ou.upload(V,xt.uniformsList,Un,ae)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Ou.upload(V,xt.uniformsList,Un,ae),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Bi.setValue(V,"center",he.center),Bi.setValue(V,"modelViewMatrix",he.modelViewMatrix),Bi.setValue(V,"normalMatrix",he.normalMatrix),Bi.setValue(V,"modelMatrix",he.matrixWorld),he.previousModelViewMatrix&&Bi.setValue(V,"previousModelViewMatrix",he.previousModelViewMatrix),B.previousProjectionMatrix&&Bi.setValue(V,"previousProjectionMatrix",B.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let Or=J.uniformsGroups;for(let Af=0,aT=Or.length;Af<aT;Af++)if(re.isWebGL2){let p1=Or[Af];Oe.update(p1,Nn),Oe.bind(p1,Nn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Nn}function rT(B,ee){B.ambientLightColor.needsUpdate=ee,B.lightProbe.needsUpdate=ee,B.directionalLights.needsUpdate=ee,B.directionalLightShadows.needsUpdate=ee,B.pointLights.needsUpdate=ee,B.pointLightShadows.needsUpdate=ee,B.spotLights.needsUpdate=ee,B.spotLightShadows.needsUpdate=ee,B.rectAreaLights.needsUpdate=ee,B.hemisphereLights.needsUpdate=ee}function sT(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(B,ee,le){oe.get(B.texture).__webglTexture=ee,oe.get(B.depthTexture).__webglTexture=le;let J=oe.get(B);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=le===void 0,J.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(B,ee){let le=oe.get(B);le.__webglFramebuffer=ee,le.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(B,ee=0,le=0){x=B,v=ee,y=le;let J=!0,he=null,Ne=!1,at=!1;if(B){let ct=oe.get(B);ct.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):ct.__webglFramebuffer===void 0?ae.setupRenderTarget(B):ct.__hasExternalTextures&&ae.rebindTextures(B,oe.get(B.texture).__webglTexture,oe.get(B.depthTexture).__webglTexture);let ut=B.texture;(ut.isData3DTexture||ut.isDataArrayTexture||ut.isCompressedArrayTexture)&&(at=!0);let Bt=oe.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(he=Bt[ee],Ne=!0):re.isWebGL2&&B.samples>0&&ae.useMultisampledRTT(B)===!1?he=oe.get(B).__webglMultisampledFramebuffer:he=Bt,A.copy(B.viewport),_.copy(B.scissor),S=B.scissorTest}else A.copy(I).multiplyScalar(T).floor(),_.copy(R).multiplyScalar(T).floor(),S=U;if(Z.bindFramebuffer(36160,he)&&re.drawBuffers&&J&&Z.drawBuffers(B,he),Z.viewport(A),Z.scissor(_),Z.setScissorTest(S),Ne){let ct=oe.get(B.texture);V.framebufferTexture2D(36160,36064,34069+ee,ct.__webglTexture,le)}else if(at){let ct=oe.get(B.texture),ut=ee||0;V.framebufferTextureLayer(36160,36064,ct.__webglTexture,le||0,ut)}b=-1},this.readRenderTargetPixels=function(B,ee,le,J,he,Ne,at){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ct=oe.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&at!==void 0&&(ct=ct[at]),ct){Z.bindFramebuffer(36160,ct);try{let ut=B.texture,Bt=ut.format,_t=ut.type;if(Bt!==Nr&&Ce.convert(Bt)!==V.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let yt=_t===bo&&(Q.has("EXT_color_buffer_half_float")||re.isWebGL2&&Q.has("EXT_color_buffer_float"));if(_t!==Qi&&Ce.convert(_t)!==V.getParameter(35738)&&!(_t===lr&&(re.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!yt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=B.width-J&&le>=0&&le<=B.height-he&&V.readPixels(ee,le,J,he,Ce.convert(Bt),Ce.convert(_t),Ne)}finally{let ut=x!==null?oe.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,ut)}}},this.copyFramebufferToTexture=function(B,ee,le=0){let J=Math.pow(2,-le),he=Math.floor(ee.image.width*J),Ne=Math.floor(ee.image.height*J);ae.setTexture2D(ee,0),V.copyTexSubImage2D(3553,le,0,0,B.x,B.y,he,Ne),Z.unbindTexture()},this.copyTextureToTexture=function(B,ee,le,J=0){let he=ee.image.width,Ne=ee.image.height,at=Ce.convert(le.format),ct=Ce.convert(le.type);ae.setTexture2D(le,0),V.pixelStorei(37440,le.flipY),V.pixelStorei(37441,le.premultiplyAlpha),V.pixelStorei(3317,le.unpackAlignment),ee.isDataTexture?V.texSubImage2D(3553,J,B.x,B.y,he,Ne,at,ct,ee.image.data):ee.isCompressedTexture?V.compressedTexSubImage2D(3553,J,B.x,B.y,ee.mipmaps[0].width,ee.mipmaps[0].height,at,ee.mipmaps[0].data):V.texSubImage2D(3553,J,B.x,B.y,at,ct,ee.image),J===0&&le.generateMipmaps&&V.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(B,ee,le,J,he=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Ne=B.max.x-B.min.x+1,at=B.max.y-B.min.y+1,ct=B.max.z-B.min.z+1,ut=Ce.convert(J.format),Bt=Ce.convert(J.type),_t;if(J.isData3DTexture)ae.setTexture3D(J,0),_t=32879;else if(J.isDataArrayTexture)ae.setTexture2DArray(J,0),_t=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}V.pixelStorei(37440,J.flipY),V.pixelStorei(37441,J.premultiplyAlpha),V.pixelStorei(3317,J.unpackAlignment);let yt=V.getParameter(3314),Fi=V.getParameter(32878),Ir=V.getParameter(3316),ca=V.getParameter(3315),kn=V.getParameter(32877),li=le.isCompressedTexture?le.mipmaps[0]:le.image;V.pixelStorei(3314,li.width),V.pixelStorei(32878,li.height),V.pixelStorei(3316,B.min.x),V.pixelStorei(3315,B.min.y),V.pixelStorei(32877,B.min.z),le.isDataTexture||le.isData3DTexture?V.texSubImage3D(_t,he,ee.x,ee.y,ee.z,Ne,at,ct,ut,Bt,li.data):le.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),V.compressedTexSubImage3D(_t,he,ee.x,ee.y,ee.z,Ne,at,ct,ut,li.data)):V.texSubImage3D(_t,he,ee.x,ee.y,ee.z,Ne,at,ct,ut,Bt,li),V.pixelStorei(3314,yt),V.pixelStorei(32878,Fi),V.pixelStorei(3316,Ir),V.pixelStorei(3315,ca),V.pixelStorei(32877,kn),he===0&&J.generateMipmaps&&V.generateMipmap(_t),Z.unbindTexture()},this.initTexture=function(B){B.isCubeTexture?ae.setTextureCube(B,0):B.isData3DTexture?ae.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?ae.setTexture2DArray(B,0):ae.setTexture2D(B,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var RR=class extends bA{};RR.prototype.isWebGL1Renderer=!0;var wA=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ve(e),this.near=t,this.far=i}clone(){return new wA(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},_n=class extends Pt{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}},LR=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ig,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ts()}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=ts()),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=ts()),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}}},Ji=new E,Bg=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++)Ji.fromBufferAttribute(this,t),Ji.applyMatrix4(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ji.fromBufferAttribute(this,t),Ji.applyNormalMatrix(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ji.fromBufferAttribute(this,t),Ji.transformDirection(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this}setX(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=zt(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=Ba(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ba(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ba(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ba(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=zt(t,this.array),i=zt(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=zt(t,this.array),i=zt(i,this.array),r=zt(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=zt(t,this.array),i=zt(i,this.array),r=zt(r,this.array),s=zt(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 Ze(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 Bg(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}}},_A=class extends Pt{constructor(){super(),this.isBone=!0,this.type="Bone"}},pn=class extends wi{constructor(e=null,t=1,i=1,r,s,a,n,o,l=kt,h=kt,u,c){super(null,a,n,o,l,h,r,s,u,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Ax=new me,BR=new me,E0=class{constructor(e=[],t=[]){this.uuid=ts(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new me)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new me;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){let n=e[s]?e[s].matrixWorld:BR;Ax.multiplyMatrices(n,t[s]),Ax.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new E0(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=nA(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new pn(t,e,e,Nr,lr);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new _A),this.bones.push(a),this.boneInverses.push(new me().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let a=t[r];e.bones.push(a.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},SA=class extends Ze{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}},In=class extends Zc{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ve(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}},Mx=new E,Ex=new E,Cx=new me,rm=new ch,Rd=new Tr,Ku=class extends Pt{constructor(e=new Ue,t=new In){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++)Mx.fromBufferAttribute(t,r-1),Ex.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Mx.distanceTo(Ex);e.setAttribute("lineDistance",new Te(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,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Rd.copy(i.boundingSphere),Rd.applyMatrix4(r),Rd.radius+=s,e.ray.intersectsSphere(Rd)===!1)return;Cx.copy(r).invert(),rm.copy(e.ray).applyMatrix4(Cx);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,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 m=Math.max(0,a.start),g=Math.min(p.count,a.start+a.count);for(let v=m,y=g-1;v<y;v+=d){let x=p.getX(v),b=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,b),rm.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 m=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count);for(let v=m,y=g-1;v<y;v+=d){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),rm.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,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 a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}},Tx=new E,Dx=new E,Jc=class extends Ku{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)Tx.fromBufferAttribute(t,r),Dx.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Tx.distanceTo(Dx);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},zR=class extends wi{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:lt,this.magFilter=s!==void 0?s:lt,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)}},na=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 a=1;a<=e;a++)i=this.getPoint(a/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,a;t?a=t:a=e*i[s-1];let n=0,o=s-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-a,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===a)return r/(s-1);let h=i[r],u=i[r+1]-h,c=(a-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),a=this.getPoint(r),n=t||(s.isVector2?new F:new E);return n.copy(a).sub(s).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new E,r=[],s=[],a=[],n=new E,o=new me;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new E)}s[0]=new E,a[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),n.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],n),a[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),a[d]=a[d-1].clone(),n.crossVectors(r[d-1],r[d]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(ui(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(n,p))}a[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(ui(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(n.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),a[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:a}}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}},Hp=class extends na{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,n=!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=a,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new F,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);let n=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);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}},kR=class extends Hp{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};function C0(){let e=0,t=0,i=0,r=0;function s(a,n,o,l){e=a,t=o,i=-3*a+3*n-2*o-l,r=2*a-2*n+o+l}return{initCatmullRom:function(a,n,o,l,h){s(n,o,h*(o-a),h*(l-n))},initNonuniformCatmullRom:function(a,n,o,l,h,u,c){let d=(n-a)/h-(o-a)/(h+u)+(o-n)/u,p=(o-n)/u-(l-n)/(u+c)+(l-o)/c;d*=u,p*=u,s(n,o,d,p)},calc:function(a){let n=a*a,o=n*a;return e+t*a+i*n+r*o}}}var Ld=new E,sm=new C0,am=new C0,nm=new C0,NR=class extends na{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,a=(s-(this.closed?0:1))*e,n=Math.floor(a),o=a-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/s)+1)*s:o===0&&n===s-1&&(n=s-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%s]:(Ld.subVectors(r[0],r[1]).add(r[0]),l=Ld);let u=r[n%s],c=r[(n+1)%s];if(this.closed||n+2<s?h=r[(n+2)%s]:(Ld.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Ld),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),m=Math.pow(c.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),sm.initNonuniformCatmullRom(l.x,u.x,c.x,h.x,p,f,m),am.initNonuniformCatmullRom(l.y,u.y,c.y,h.y,p,f,m),nm.initNonuniformCatmullRom(l.z,u.z,c.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(sm.initCatmullRom(l.x,u.x,c.x,h.x,this.tension),am.initCatmullRom(l.y,u.y,c.y,h.y,this.tension),nm.initCatmullRom(l.z,u.z,c.z,h.z,this.tension));return i.set(sm.calc(o),am.calc(o),nm.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 Px(e,t,i,r,s){let a=(r-t)*.5,n=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+a+n)*l+(-3*i+3*r-2*a-n)*o+a*e+i}function UR(e,t){let i=1-e;return i*i*t}function FR(e,t){return 2*(1-e)*e*t}function VR(e,t){return e*e*t}function yc(e,t,i,r){return UR(e,t)+FR(e,i)+VR(e,r)}function jR(e,t){let i=1-e;return i*i*i*t}function GR(e,t){let i=1-e;return 3*i*i*e*t}function HR(e,t){return 3*(1-e)*e*e*t}function WR(e,t){return e*e*e*t}function xc(e,t,i,r,s){return jR(e,t)+GR(e,i)+HR(e,r)+WR(e,s)}var xs=class extends na{constructor(e=new F,t=new F,i=new F,r=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(xc(e,r.x,s.x,a.x,n.x),xc(e,r.y,s.y,a.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.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}},Ru=class extends na{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,a=this.v2,n=this.v3;return i.set(xc(e,r.x,s.x,a.x,n.x),xc(e,r.y,s.y,a.y,n.y),xc(e,r.z,s.z,a.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.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}},As=class extends na{constructor(e=new F,t=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new F){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 F;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}},AA=class extends na{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}},Tn=class extends na{constructor(e=new F,t=new F,i=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(yc(e,r.x,s.x,a.x),yc(e,r.y,s.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}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}},qR=class extends na{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,a=this.v2;return i.set(yc(e,r.x,s.x,a.x),yc(e,r.y,s.y,a.y),yc(e,r.z,s.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}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}},T0=class extends na{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new F){let i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),n=s-a,o=r[a===0?a:a-1],l=r[a],h=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return i.set(Px(n,o.x,l.x,h.x,u.x),Px(n,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 F().fromArray(r))}return this}},YR=Object.freeze({__proto__:null,ArcCurve:kR,CatmullRomCurve3:NR,CubicBezierCurve:xs,CubicBezierCurve3:Ru,EllipseCurve:Hp,LineCurve:As,LineCurve3:AA,QuadraticBezierCurve:Tn,QuadraticBezierCurve3:qR,SplineCurve:T0}),MA=class extends na{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 As(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let a=r[s]-i,n=this.curves[s],o=n.getLength(),l=o===0?0:1-a/o;return n.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 a=s[r],n=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(n);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 YR[r.type]().fromJSON(r))}return this}},Ju=class extends MA{constructor(e){super(),this.type="Path",this.currentPoint=new F,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 As(this.currentPoint.clone(),new F(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Tn(this.currentPoint.clone(),new F(e,t),new F(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new xs(this.currentPoint.clone(),new F(e,t),new F(i,r),new F(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new T0(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,a,n,o),this}absellipse(e,t,i,r,s,a,n,o){let l=new Hp(e,t,i,r,s,a,n,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}},EA=class extends Ue{constructor(e=[new F(0,-.5),new F(.5,0),new F(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=ui(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,u=new E,c=new F,d=new E,p=new E,f=new E,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=g*1,d.y=-m,d.z=g*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:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=g*1,d.y=-m,d.z=g*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,x=Math.sin(y),b=Math.cos(y);for(let w=0;w<=e.length-1;w++){u.x=e[w].x*x,u.y=e[w].y,u.z=e[w].x*b,a.push(u.x,u.y,u.z),c.x=v/t,c.y=w/(e.length-1),n.push(c.x,c.y);let A=o[3*w+0]*x,_=o[3*w+1],S=o[3*w+0]*b;l.push(A,_,S)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,b=x,w=x+e.length,A=x+e.length+1,_=x+1;s.push(b,w,_),s.push(A,_,w)}this.setIndex(s),this.setAttribute("position",new Te(a,3)),this.setAttribute("uv",new Te(n,2)),this.setAttribute("normal",new Te(l,3))}static fromJSON(e){return new EA(e.points,e.segments,e.phiStart,e.phiLength)}},D0=class extends Ue{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],u=[],c=[],d=[],p=0,f=[],m=i/2,g=0;v(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Te(u,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(d,2));function v(){let x=new E,b=new E,w=0,A=(t-e)/i;for(let _=0;_<=s;_++){let S=[],M=_/s,C=M*(t-e)+e;for(let T=0;T<=r;T++){let D=T/r,P=D*o+n,I=Math.sin(P),R=Math.cos(P);b.x=C*I,b.y=-M*i+m,b.z=C*R,u.push(b.x,b.y,b.z),x.set(I,A,R).normalize(),c.push(x.x,x.y,x.z),d.push(D,1-M),S.push(p++)}f.push(S)}for(let _=0;_<r;_++)for(let S=0;S<s;S++){let M=f[S][_],C=f[S+1][_],T=f[S+1][_+1],D=f[S][_+1];h.push(M,C,D),h.push(C,T,D),w+=6}l.addGroup(g,w,0),g+=w}function y(x){let b=p,w=new F,A=new E,_=0,S=x===!0?e:t,M=x===!0?1:-1;for(let T=1;T<=r;T++)u.push(0,m*M,0),c.push(0,M,0),d.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+n,P=Math.cos(D),I=Math.sin(D);A.x=S*I,A.y=m*M,A.z=S*P,u.push(A.x,A.y,A.z),c.push(0,M,0),w.x=P*.5+.5,w.y=I*.5*M+.5,d.push(w.x,w.y),p++}for(let T=0;T<r;T++){let D=b+T,P=C+T;x===!0?h.push(P,P+1,D):h.push(P+1,P,D),_+=3}l.addGroup(g,_,x===!0?1:2),g+=_}}static fromJSON(e){return new D0(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},CA=class extends D0{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,n=Math.PI*2){super(0,e,t,i,r,s,a,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:n}}static fromJSON(e){return new CA(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},P0=class extends Ue{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],a=[];n(r),l(i),h(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(v){let y=new E,x=new E,b=new E;for(let w=0;w<t.length;w+=3)d(t[w+0],y),d(t[w+1],x),d(t[w+2],b),o(y,x,b,v)}function o(v,y,x,b){let w=b+1,A=[];for(let _=0;_<=w;_++){A[_]=[];let S=v.clone().lerp(x,_/w),M=y.clone().lerp(x,_/w),C=w-_;for(let T=0;T<=C;T++)T===0&&_===w?A[_][T]=S:A[_][T]=S.clone().lerp(M,T/C)}for(let _=0;_<w;_++)for(let S=0;S<2*(w-_)-1;S++){let M=Math.floor(S/2);S%2===0?(c(A[_][M+1]),c(A[_+1][M]),c(A[_][M])):(c(A[_][M+1]),c(A[_+1][M+1]),c(A[_+1][M]))}}function l(v){let y=new E;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+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 x=m(v)/2/Math.PI+.5,b=g(v)/Math.PI+.5;a.push(x,1-b)}p(),u()}function u(){for(let v=0;v<a.length;v+=6){let y=a[v+0],x=a[v+2],b=a[v+4],w=Math.max(y,x,b),A=Math.min(y,x,b);w>.9&&A<.1&&(y<.2&&(a[v+0]+=1),x<.2&&(a[v+2]+=1),b<.2&&(a[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function d(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new E,y=new E,x=new E,b=new E,w=new F,A=new F,_=new F;for(let S=0,M=0;S<s.length;S+=9,M+=6){v.set(s[S+0],s[S+1],s[S+2]),y.set(s[S+3],s[S+4],s[S+5]),x.set(s[S+6],s[S+7],s[S+8]),w.set(a[M+0],a[M+1]),A.set(a[M+2],a[M+3]),_.set(a[M+4],a[M+5]),b.copy(v).add(y).add(x).divideScalar(3);let C=m(b);f(w,M+0,v,C),f(A,M+2,y,C),f(_,M+4,x,C)}}function f(v,y,x,b){b<0&&v.x===1&&(a[y]=v.x-1),x.x===0&&x.z===0&&(a[y]=b/2/Math.PI+.5)}function m(v){return Math.atan2(v.z,-v.x)}function g(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new P0(e.vertices,e.indices,e.radius,e.details)}},TA=class extends P0{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],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];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new TA(e.radius,e.detail)}},$u=class extends Ju{constructor(e){super(e),this.uuid=ts(),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 Ju().fromJSON(r))}return this}},XR={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,a=DA(e,0,s,i,!0),n=[];if(!a||a.next===a.prev)return n;let o,l,h,u,c,d,p;if(r&&(a=$R(e,t,a,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 Pc(a,n,i,o,l,p,0),n}};function DA(e,t,i,r,s){let a,n;if(s===c4(e,t,i,r)>0)for(a=t;a<i;a+=r)n=Ix(a,e[a],e[a+1],n);else for(a=i-r;a>=t;a-=r)n=Ix(a,e[a],e[a+1],n);return n&&Wp(n,n.next)&&(Oc(n),n=n.next),n}function _o(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Wp(i,i.next)||Wt(i.prev,i,i.next)===0)){if(Oc(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function Pc(e,t,i,r,s,a,n){if(!e)return;!n&&a&&s4(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?ZR(e,r,s,a):QR(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),Oc(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=KR(_o(e),t,i),Pc(e,t,i,r,s,a,2)):n===2&&JR(e,t,i,r,s,a):Pc(_o(e),t,i,r,s,a,1);break}}}function QR(e){let t=e.prev,i=e,r=e.next;if(Wt(t,i,r)>=0)return!1;let s=t.x,a=i.x,n=r.x,o=t.y,l=i.y,h=r.y,u=s<a?s<n?s:n:a<n?a:n,c=o<l?o<h?o:h:l<h?l:h,d=s>a?s>n?s:n:a>n?a:n,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&&Ml(s,o,a,l,n,h,f.x,f.y)&&Wt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ZR(e,t,i,r){let s=e.prev,a=e,n=e.next;if(Wt(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,u=s.y,c=a.y,d=n.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=o>l?o>h?o:h:l>h?l:h,g=u>c?u>d?u:d:c>d?c:d,v=zg(p,f,t,i,r),y=zg(m,g,t,i,r),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==n&&Ml(o,u,l,c,h,d,x.x,x.y)&&Wt(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==n&&Ml(o,u,l,c,h,d,b.x,b.y)&&Wt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==n&&Ml(o,u,l,c,h,d,x.x,x.y)&&Wt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==n&&Ml(o,u,l,c,h,d,b.x,b.y)&&Wt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function KR(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!Wp(s,a)&&PA(s,r,r.next,a)&&Ic(s,a)&&Ic(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),Oc(r),Oc(r.next),r=e=a),r=r.next}while(r!==e);return _o(r)}function JR(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&o4(n,o)){let l=IA(n,o);n=_o(n,n.next),l=_o(l,l.next),Pc(n,t,i,r,s,a,0),Pc(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function $R(e,t,i,r){let s=[],a,n,o,l,h;for(a=0,n=t.length;a<n;a++)o=t[a]*r,l=a<n-1?t[a+1]*r:e.length,h=DA(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(n4(h));for(s.sort(e4),a=0;a<s.length;a++)i=t4(s[a],i);return i}function e4(e,t){return e.x-t.x}function t4(e,t){let i=i4(e,t);if(!i)return t;let r=IA(i,e);return _o(r,r.next),_o(i,i.next)}function i4(e,t){let i=t,r=-1/0,s,a=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let d=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=a&&d>r&&(r=d,s=i.x<i.next.x?i:i.next,d===a))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 a>=i.x&&i.x>=l&&a!==i.x&&Ml(n<h?a:r,n,l,h,n<h?r:a,n,i.x,i.y)&&(c=Math.abs(n-i.y)/(a-i.x),Ic(i,e)&&(c<u||c===u&&(i.x>s.x||i.x===s.x&&r4(s,i)))&&(s=i,u=c)),i=i.next;while(i!==o);return s}function r4(e,t){return Wt(e.prev,e,t.prev)<0&&Wt(t.next,e,e.next)<0}function s4(e,t,i,r){let s=e;do s.z===0&&(s.z=zg(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,a4(s)}function a4(e){let t,i,r,s,a,n,o,l,h=1;do{for(i=e,e=null,a=null,n=0;i;){for(n++,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--),a?a.nextZ=s:e=s,s.prevZ=a,a=s;i=r}a.nextZ=null,h*=2}while(n>1);return e}function zg(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 n4(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 Ml(e,t,i,r,s,a,n,o){return(s-n)*(t-o)>=(e-n)*(a-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(a-o)>=(s-n)*(r-o)}function o4(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!l4(e,t)&&(Ic(e,t)&&Ic(t,e)&&h4(e,t)&&(Wt(e.prev,e,t.prev)||Wt(e,t.prev,t))||Wp(e,t)&&Wt(e.prev,e,e.next)>0&&Wt(t.prev,t,t.next)>0)}function Wt(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Wp(e,t){return e.x===t.x&&e.y===t.y}function PA(e,t,i,r){let s=zd(Wt(e,t,i)),a=zd(Wt(e,t,r)),n=zd(Wt(i,r,e)),o=zd(Wt(i,r,t));return!!(s!==a&&n!==o||s===0&&Bd(e,i,t)||a===0&&Bd(e,r,t)||n===0&&Bd(i,e,r)||o===0&&Bd(i,t,r))}function Bd(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 zd(e){return e>0?1:e<0?-1:0}function l4(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&&PA(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Ic(e,t){return Wt(e.prev,e,e.next)<0?Wt(e,t,e.next)>=0&&Wt(e,e.prev,t)>=0:Wt(e,t,e.prev)<0||Wt(e,e.next,t)<0}function h4(e,t){let i=e,r=!1,s=(e.x+t.x)/2,a=(e.y+t.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function IA(e,t){let i=new kg(e.i,e.x,e.y),r=new kg(t.i,t.x,t.y),s=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function Ix(e,t,i,r){let s=new kg(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 Oc(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 kg(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 c4(e,t,i,r){let s=0;for(let a=t,n=i-r;a<i;a+=r)s+=(e[n]-e[a])*(e[a+1]+e[n+1]),n=a;return s}var OA=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 OA.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Ox(e),Rx(i,e);let a=e.length;t.forEach(Ox);for(let o=0;o<t.length;o++)r.push(a),a+=t[o].length,Rx(i,t[o]);let n=XR.triangulate(i,r);for(let o=0;o<n.length;o+=3)s.push(n.slice(o,o+3));return s}};function Ox(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Rx(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var RA=class extends P0{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 RA(e.radius,e.detail)}},I0=class extends Ue{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(a+n,Math.PI),l=0,h=[],u=new E,c=new E,d=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let v=[],y=g/i,x=0;g==0&&a==0?x=.5/t:g==i&&o==Math.PI&&(x=-.5/t);for(let b=0;b<=t;b++){let w=b/t;u.x=-e*Math.cos(r+w*s)*Math.sin(a+y*n),u.y=e*Math.cos(a+y*n),u.z=e*Math.sin(r+w*s)*Math.sin(a+y*n),p.push(u.x,u.y,u.z),c.copy(u).normalize(),f.push(c.x,c.y,c.z),m.push(w+x,1-y),v.push(l++)}h.push(v)}for(let g=0;g<i;g++)for(let v=0;v<t;v++){let y=h[g][v+1],x=h[g][v],b=h[g+1][v],w=h[g+1][v+1];(g!==0||a>0)&&d.push(y,x,w),(g!==i-1||o<Math.PI)&&d.push(x,b,w)}this.setIndex(d),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(f,3)),this.setAttribute("uv",new Te(m,2))}static fromJSON(e){return new I0(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},LA=class extends Ue{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],u=new E,c=new E,d=new E,p=new E,f=new E,m=new E,g=new E;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,a,e,d),v(x+.01,s,a,e,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let b=0;b<=r;++b){let w=b/r*Math.PI*2,A=-t*Math.cos(w),_=t*Math.sin(w);u.x=d.x+(A*g.x+_*f.x),u.y=d.y+(A*g.y+_*f.y),u.z=d.z+(A*g.z+_*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(b/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let b=(r+1)*(y-1)+(x-1),w=(r+1)*y+(x-1),A=(r+1)*y+x,_=(r+1)*(y-1)+x;n.push(b,w,_),n.push(w,A,_)}this.setIndex(n),this.setAttribute("position",new Te(o,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(h,2));function v(y,x,b,w,A){let _=Math.cos(y),S=Math.sin(y),M=b/x*y,C=Math.cos(M);A.x=w*(2+C)*.5*_,A.y=w*(2+C)*S*.5,A.z=w*Math.sin(M)*.5}}static fromJSON(e){return new LA(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function Za(e,t,i){return BA(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function kd(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 BA(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function d4(e){function t(s,a){return e[s]-e[a]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function Lx(e,t,i){let r=e.length,s=new e.constructor(r);for(let a=0,n=0;n!==r;++a){let o=i[a]*t;for(let l=0;l!==t;++l)s[n++]=e[o+l]}return s}function zA(e,t,i,r){let s=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[s++];if(a===void 0)return;let n=a[r];if(n!==void 0)if(Array.isArray(n))do n=a[r],n!==void 0&&(t.push(a.time),i.push.apply(i,n)),a=e[s++];while(a!==void 0);else if(n.toArray!==void 0)do n=a[r],n!==void 0&&(t.push(a.time),n.toArray(i,i.length)),a=e[s++];while(a!==void 0);else do n=a[r],n!==void 0&&(t.push(a.time),i.push(n)),a=e[s++];while(a!==void 0)}var qp=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){let n=t[1];e<n&&(i=2,s=n);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 t}a=i,i=0;break i}break e}for(;i<a;){let n=i+a>>>1;e<t[n]?a=n:i=n+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 a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},u4=class extends qp{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:wl,endingEnd:wl}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,n=r[s],o=r[a];if(n===void 0)switch(this.getSettings_().endingStart){case _l:s=e,n=2*t-i;break;case Yu:s=r.length-2,n=t+r[s]-r[s+1];break;default:s=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case _l:a=e,o=2*i-t;break;case Yu:a=1,o=i+r[1]-r[0];break;default:a=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,u=this._offsetNext,c=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-c*m+2*c*f-c*p,v=(1+c)*m+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f;for(let b=0;b!==n;++b)s[b]=g*a[h+b]+v*a[l+b]+y*a[o+b]+x*a[u+b];return s}},kA=class extends qp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),u=1-h;for(let c=0;c!==n;++c)s[c]=a[l+c]*u+a[o+c]*h;return s}},p4=class extends qp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},oa=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=kd(t,this.TimeBufferType),this.values=kd(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:kd(e.times,Array),values:kd(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new p4(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new kA(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new u4(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Wu:t=this.InterpolantFactoryMethodDiscrete;break;case qu:t=this.InterpolantFactoryMethodLinear;break;case If: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 Wu;case this.InterpolantFactoryMethodLinear:return qu;case this.InterpolantFactoryMethodSmooth:return If}}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,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let n=this.getValueSize();this.times=Za(i,s,a),this.values=Za(this.values,s*n,a*n)}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 a=null;for(let n=0;n!==s;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(a!==null&&a>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,a),e=!1;break}a=o}if(r!==void 0&&BA(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=Za(this.times),t=Za(this.values),i=this.getValueSize(),r=this.getInterpolation()===If,s=e.length-1,a=1;for(let n=1;n<s;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let u=n*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(n!==a){e[a]=e[n];let u=n*i,c=a*i;for(let d=0;d!==i;++d)t[c+d]=t[u+d]}++a}}if(s>0){e[a]=e[s];for(let n=s*i,o=a*i,l=0;l!==i;++l)t[o+l]=t[n+l];++a}return a!==e.length?(this.times=Za(e,0,a),this.values=Za(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=Za(this.times,0),t=Za(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};oa.prototype.TimeBufferType=Float32Array;oa.prototype.ValueBufferType=Float32Array;oa.prototype.DefaultInterpolation=qu;var fh=class extends oa{};fh.prototype.ValueTypeName="bool";fh.prototype.ValueBufferType=Array;fh.prototype.DefaultInterpolation=Wu;fh.prototype.InterpolantFactoryMethodLinear=void 0;fh.prototype.InterpolantFactoryMethodSmooth=void 0;var NA=class extends oa{};NA.prototype.ValueTypeName="color";var ep=class extends oa{};ep.prototype.ValueTypeName="number";var f4=class extends qp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)$e.slerpFlat(s,0,a,l-n,a,l,o);return s}},$c=class extends oa{InterpolantFactoryMethodLinear(e){return new f4(this.times,this.values,this.getValueSize(),e)}};$c.prototype.ValueTypeName="quaternion";$c.prototype.DefaultInterpolation=qu;$c.prototype.InterpolantFactoryMethodSmooth=void 0;var mh=class extends oa{};mh.prototype.ValueTypeName="string";mh.prototype.ValueBufferType=Array;mh.prototype.DefaultInterpolation=Wu;mh.prototype.InterpolantFactoryMethodLinear=void 0;mh.prototype.InterpolantFactoryMethodSmooth=void 0;var tp=class extends oa{};tp.prototype.ValueTypeName="vector";var Ng=class{constructor(e,t=-1,i,r=x0){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=ts(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,n=i.length;a!==n;++a)t.push(g4(i[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(oa.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let n=0;n<s;n++){let o=[],l=[];o.push((n+s-1)%s,n,(n+1)%s),l.push(0,1,0);let h=d4(o);o=Lx(o,1,h),l=Lx(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),a.push(new ep(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(s);if(h&&h.length>1){let u=h[1],c=r[u];c||(r[u]=c=[]),c.push(l)}}let a=[];for(let n in r)a.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,u,c,d,p){if(c.length!==0){let f=[],m=[];zA(c,f,m,d),f.length!==0&&p.push(new h(u,f,m))}},r=[],s=e.name||"default",a=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let u=l[h].keys;if(!(!u||u.length===0))if(u[0].morphTargets){let c={},d;for(d=0;d<u.length;d++)if(u[d].morphTargets)for(let p=0;p<u[d].morphTargets.length;p++)c[u[d].morphTargets[p]]=-1;for(let p in c){let f=[],m=[];for(let g=0;g!==u[d].morphTargets.length;++g){let v=u[d];f.push(v.time),m.push(v.morphTarget===p?1:0)}r.push(new ep(".morphTargetInfluence["+p+"]",f,m))}o=c.length*a}else{let c=".bones["+t[h].name+"]";i(tp,c+".position",u,"pos",r),i($c,c+".quaternion",u,"rot",r),i(tp,c+".scale",u,"scl",r)}}return r.length===0?null:new this(s,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function m4(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ep;case"vector":case"vector2":case"vector3":case"vector4":return tp;case"color":return NA;case"quaternion":return $c;case"bool":case"boolean":return fh;case"string":return mh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function g4(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=m4(e.type);if(e.times===void 0){let i=[],r=[];zA(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var Bx={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={}}},UA=class{constructor(e,t,i){let r=this,s=!1,a=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,n),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,n),a===n&&(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}}},v4=new UA,O0=class{constructor(e){this.manager=e!==void 0?e:v4,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}},ga={},y4=class extends Error{constructor(e,t){super(e),this.response=t}},Ug=class extends O0{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=Bx.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ga[e]!==void 0){ga[e].push({onLoad:t,onProgress:i,onError:r});return}ga[e]=[],ga[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(a).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=ga[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,m=new ReadableStream({start(g){v();function v(){u.read().then(({done:y,value:x})=>{if(y)g.close();else{f+=x.byteLength;let b=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let w=0,A=h.length;w<A;w++){let _=h[w];_.onProgress&&_.onProgress(b)}g.enqueue(x),v()}})}}});return new Response(m)}else throw new y4(`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,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),u=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(u);return l.arrayBuffer().then(d=>c.decode(d))}}}).then(l=>{Bx.add(e,l);let h=ga[e];delete ga[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=ga[e];if(h===void 0)throw this.manager.itemError(e),l;delete ga[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}},ed=class extends Pt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ve(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},x4=class extends ed{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ve(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},om=new me,zx=new E,kx=new E,R0=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new me,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new S0,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new rt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;zx.setFromMatrixPosition(e.matrixWorld),t.position.copy(zx),kx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(kx),t.updateMatrixWorld(),om.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(om),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(om)}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}},b4=class extends R0{constructor(){super(new Gi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=Dc*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}},w4=class extends ed{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new b4}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}},Nx=new me,Uh=new E,lm=new E,_4=class extends R0{constructor(){super(new Gi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new rt(2,1,1,1),new rt(0,1,1,1),new rt(3,1,1,1),new rt(1,1,1,1),new rt(3,0,1,1),new rt(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()),Uh.setFromMatrixPosition(e.matrixWorld),i.position.copy(Uh),lm.copy(i.position),lm.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(lm),i.updateMatrixWorld(),r.makeTranslation(-Uh.x,-Uh.y,-Uh.z),Nx.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Nx)}},S4=class extends ed{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 _4}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}},A4=class extends R0{constructor(){super(new A0(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},M4=class extends ed{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.shadow=new A4}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},FA=class extends Ue{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}},VA=class extends O0{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new Ug(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(n){try{t(s.parse(JSON.parse(n)))}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),m=fd(p.type,f),g=new LR(m,p.stride);return g.uuid=p.uuid,t[d]=g,g}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 a=e.isInstancedBufferGeometry?new FA:new Ue,n=e.data.index;if(n!==void 0){let c=fd(n.type,n.array);a.setIndex(new Ze(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 Bg(f,d.itemSize,d.offset,d.normalized)}else{let f=fd(d.type,d.array),m=d.isInstancedBufferAttribute?SA:Ze;p=new m(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),a.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let d=l[c],p=[];for(let f=0,m=d.length;f<m;f++){let g=d[f],v;if(g.isInterleavedBufferAttribute){let y=r(e.data,g.data);v=new Bg(y,g.itemSize,g.offset,g.normalized)}else{let y=fd(g.type,g.array);v=new Ze(y,g.itemSize,g.normalized)}g.name!==void 0&&(v.name=g.name),p.push(v)}a.morphAttributes[c]=p}e.data.morphTargetsRelative&&(a.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];a.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),a.boundingSphere=new Tr(c,u.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},E4=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Ux(),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=Ux();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Ux(){return(typeof performance>"u"?Date:performance).now()}var C4=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let n=0;n!==r;++n)i[s+n]=i[n];a=t}else{a+=t;let n=t/a;this._mixBufferRegion(i,s,0,n,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){$e.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;$e.multiplyQuaternionsFlat(e,a,e,t,e,i),$e.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let n=0;n!==s;++n){let o=t+n;e[o]=e[o]*a+e[i+n]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let n=t+a;e[n]=e[n]+e[i+a]*r}}},L0="\\[\\]\\.:\\/",T4=new RegExp("["+L0+"]","g"),B0="[^"+L0+"]",D4="[^"+L0.replace("\\.","")+"]",P4=/((?:WC+[\/:])*)/.source.replace("WC",B0),I4=/(WCOD+)?/.source.replace("WCOD",D4),O4=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",B0),R4=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",B0),L4=new RegExp("^"+P4+I4+O4+R4+"$"),B4=["material","materials","bones","map"],z4=class{constructor(e,t,i){let r=i||Ot.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()}},Ot=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Ot.parseTrackName(t),this.node=Ot.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 Ot.Composite(e,t,i):new Ot(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(T4,"")}static parseTrackName(e){let t=L4.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);B4.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 a=0;a<s.length;a++){let n=s[a];if(n.name===t||n.uuid===t)return n;let o=i(n.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=Ot.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 a=e[r];if(a===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 n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=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=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ot.Composite=z4;Ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ot.prototype.GetterByBindingType=[Ot.prototype._getValue_direct,Ot.prototype._getValue_array,Ot.prototype._getValue_arrayElement,Ot.prototype._getValue_toArray];Ot.prototype.SetterByBindingTypeAndVersioning=[[Ot.prototype._setValue_direct,Ot.prototype._setValue_direct_setNeedsUpdate,Ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ot.prototype._setValue_array,Ot.prototype._setValue_array_setNeedsUpdate,Ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ot.prototype._setValue_arrayElement,Ot.prototype._setValue_arrayElement_setNeedsUpdate,Ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ot.prototype._setValue_fromArray,Ot.prototype._setValue_fromArray_setNeedsUpdate,Ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var k4=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,a=s.length,n=new Array(a),o={endingStart:wl,endingEnd:wl};for(let l=0;l!==a;++l){let h=s[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=sA,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,a=s/r,n=r/s;e.warp(1,a,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,a=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let a=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case y3:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case x0:default:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(a),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===y0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===rA){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,s+=Math.abs(n);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=_l,r.endingEnd=_l):(e?r.endingStart=this.zeroSlopeAtStart?_l:wl:r.endingStart=Yu,t?r.endingEnd=this.zeroSlopeAtEnd?_l:wl:r.endingEnd=Yu)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let n=a.parameterPositions,o=a.sampleValues;return n[0]=s,o[0]=t,n[1]=s+e,o[1]=i,this}},N4=new Float32Array(1),U4=class extends Ni{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let u=0;u!==s;++u){let c=r[u],d=c.name,p=h[d];if(p!==void 0)++p.referenceCount,a[u]=p;else{if(p=a[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[u].binding.parsedPath;p=new C4(Ot.create(i,d,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),a[u]=p}n[u].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let n=a.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,n=a[s],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let u=n.actionByRoot,c=(e._localRoot||this._root).uuid;delete u[c],o.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,n=a[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[s],Object.keys(n).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new kA(new Float32Array(2),new Float32Array(2),1,N4),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,a=typeof e=="string"?Ng.findByName(r,e):e,n=a!==null?a.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(a!==null?i=a.blendMode:i=x0),o!==void 0){let u=o.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=o.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new k4(this,a,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?Ng.findByName(i,e):e,a=s?s.uuid:e,n=this._actionsByClip[a];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,a);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let a=s.knownActions;for(let n=0,o=a.length;n!==o;++n){let l=a[n];this._deactivateAction(l);let h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let a in i){let n=i[a].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let a in s){let n=s[a];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},fe=class{constructor(e){this.value=e}clone(){return new fe(this.value.clone===void 0?this.value:this.value.clone())}},jA=class{constructor(e,t,i=0,r=1/0){this.ray=new ch(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new w0,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 Fg(e,this,i,t),i.sort(Fx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Fg(e[r],this,i,t);return i.sort(Fx),i}};function Fx(e,t){return e.distance-t.distance}function Fg(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let a=0,n=s.length;a<n;a++)Fg(s[a],t,i,!0)}}var Vx=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(ui(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},jx=new F,GA=class{constructor(e=new F(1/0,1/0),t=new F(-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=jx.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 jx.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)}},Gx=new E,Nd=new E,is=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){Gx.subVectors(e,this.start),Nd.subVectors(this.end,this.start);let i=Nd.dot(Nd),r=Nd.dot(Gx)/i;return t&&(r=ui(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)}},Hx=new E,F4=class extends Pt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ue,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 a=0,n=1,o=32;a<o;a++,n++){let l=a/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Te(r,3));let s=new In({fog:!1,toneMapped:!1});this.cone=new Jc(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),Hx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Hx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},V4=class extends hr{constructor(e,t,i){let r=new I0(t,4,2),s=new Kc({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)}},Wx=new E,Ud=new E,qx=new E,j4=class extends Pt{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 Ue;r.setAttribute("position",new Te([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new In({fog:!1,toneMapped:!1});this.lightPlane=new Ku(r,s),this.add(this.lightPlane),r=new Ue,r.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Ku(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),Wx.setFromMatrixPosition(this.light.matrixWorld),Ud.setFromMatrixPosition(this.light.target.matrixWorld),qx.subVectors(Ud,Wx),this.lightPlane.lookAt(Ud),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(Ud),this.targetLine.scale.z=qx.length()}},Fd=new E,qt=new uh,ip=class extends Jc{constructor(e){let t=new Ue,i=new In({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(r.length/3-1)}t.setAttribute("position",new Te(r,3)),t.setAttribute("color",new Te(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=a,this.update();let l=new Ve(16755200),h=new Ve(16711680),u=new Ve(43775),c=new Ve(16777215),d=new Ve(3355443);this.setColors(l,h,u,c,d)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;qt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Jt("c",t,e,qt,0,0,-1),Jt("t",t,e,qt,0,0,1),Jt("n1",t,e,qt,-i,-r,-1),Jt("n2",t,e,qt,i,-r,-1),Jt("n3",t,e,qt,-i,r,-1),Jt("n4",t,e,qt,i,r,-1),Jt("f1",t,e,qt,-i,-r,1),Jt("f2",t,e,qt,i,-r,1),Jt("f3",t,e,qt,-i,r,1),Jt("f4",t,e,qt,i,r,1),Jt("u1",t,e,qt,i*.7,r*1.1,-1),Jt("u2",t,e,qt,-i*.7,r*1.1,-1),Jt("u3",t,e,qt,0,r*2,-1),Jt("cf1",t,e,qt,-i,0,1),Jt("cf2",t,e,qt,i,0,1),Jt("cf3",t,e,qt,0,-r,1),Jt("cf4",t,e,qt,0,r,1),Jt("cn1",t,e,qt,-i,0,-1),Jt("cn2",t,e,qt,i,0,-1),Jt("cn3",t,e,qt,0,-r,-1),Jt("cn4",t,e,qt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Jt(e,t,i,r,s,a,n){Fd.set(s,a,n).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],Fd.x,Fd.y,Fd.z)}}var rp=class extends Jc{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 Ue;s.setIndex(new Ze(i,1)),s.setAttribute("position",new Te(r,3)),super(s,new In({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()}},G4=class extends Jc{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 Ue;r.setAttribute("position",new Te(t,3)),r.setAttribute("color",new Te(i,3));let s=new In({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ve,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()}},Ia=H4();function H4(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(r[l]=0,r[l|256]=32768,s[l]=24,s[l|256]=24):h<-14?(r[l]=1024>>-h-14,r[l|256]=1024>>-h-14|32768,s[l]=-h-1,s[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,s[l]=13,s[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,s[l]=24,s[l|256]=24):(r[l]=31744,r[l|256]=64512,s[l]=13,s[l|256]=13)}let a=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,u=0;for(;(h&8388608)===0;)h<<=1,u-=8388608;h&=-8388609,u+=947912704,a[l]=h|u}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)n[l]=l<<23;n[31]=1199570944,n[32]=2147483648;for(let l=33;l<63;++l)n[l]=2147483648+(l-32<<23);n[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:s,mantissaTable:a,exponentTable:n,offsetTable:o}}function W4(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=ui(e,-65504,65504),Ia.floatView[0]=e;let t=Ia.uint32View[0],i=t>>23&511;return Ia.baseTable[i]+((t&8388607)>>Ia.shiftTable[i])}function q4(e){let t=e>>10;return Ia.uint32View[0]=Ia.mantissaTable[Ia.offsetTable[t]+(e&1023)]+Ia.exponentTable[t],Ia.floatView[0]}var Y4=Object.freeze({__proto__:null,fromHalfFloat:q4,toHalfFloat:W4});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:hh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=hh);var Fh=".",z0=Symbol("target"),HA=Symbol("unsubscribe");function Vg(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function X4(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Ys=Array.isArray;function k0(e){return typeof e=="symbol"}var Q4={after:(e,t)=>Ys(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Ys(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Fh),k0(t)?e+t.toString():e+t):e,initial:e=>{if(Ys(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Fh);return t===-1?"":e.slice(0,t)},last:e=>{if(Ys(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Fh);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Ys(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Fh);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(Fh,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Kr=Q4;function Z4(e){return typeof e=="object"&&typeof e.next=="function"}function K4(e,t,i,r,s){let a=e.next;if(t.name==="entries")e.next=function(){let n=a.call(this);return n.done===!1&&(n.value[0]=s(n.value[0],t,n.value[0],r),n.value[1]=s(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[z0].keys();e.next=function(){let o=a.call(this);return o.done===!1&&(o.value=s(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=a.call(this);return n.done===!1&&(n.value=s(n.value,t,n.value,r)),n};return e}function Yx(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&k0(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var J4=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],a=s||e;this._pathCache.set(a,t);let n=this._proxyCache.get(a);return n===void 0&&(n=s===void 0?new Proxy(e,i):e,this._proxyCache.set(a,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Kr.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 a=this._getOwnPropertyDescriptor(e,t);return a!==void 0&&"set"in a?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 jg(e){return toString.call(e)==="[object Object]"}function Vd(){return!0}function Qo(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var WA=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),$4=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),qA={push:Vd,pop:Vd,shift:Vd,unshift:Vd,copyWithin:Qo,reverse:Qo,sort:Qo,splice:Qo,flat:Qo,fill:Qo},eL=new Set([...WA,...$4,...Object.keys(qA)]);function jd(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var YA=["keys","values","entries"],XA=new Set(["has","toString"]),QA={add:jd,clear:jd,delete:jd,forEach:jd},tL=new Set([...XA,...Object.keys(QA),...YA]);function Gd(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 iL=new Set([...XA,"get"]),ZA={set:Gd,clear:Gd,delete:Gd,forEach:Gd},rL=new Set([...iL,...Object.keys(ZA),...YA]),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 WA.has(e)}_shallowClone(e){let t=e;if(jg(e))t={...e};else if(Ys(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?(Ys(r)?this._onIsChanged=qA[t]:r instanceof Set?this._onIsChanged=QA[t]:r instanceof Map&&(this._onIsChanged=ZA[t]),r):i}update(e,t,i){let r=Kr.after(e,this._path);if(t!=="length"){let s=this.clone;Kr.walk(r,a=>{s&&s[a]&&(this._clonedCache.has(s[a])||(s[a]=this._shallowClone(s[a])),s=s[a])}),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],Kr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},Xx=class extends Dn{static isHandledMethod(e){return eL.has(e)}},sL=class extends Dn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Qx=class extends Dn{static isHandledMethod(e){return tL.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)}},Zx=class extends Dn{static isHandledMethod(e){return rL.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)}},aL=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)}},nL=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)}},gl=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return jg(e)||Ys(e)||Vg(e)}static isHandledMethod(e,t){return jg(e)?Dn.isHandledMethod(t):Ys(e)?Xx.isHandledMethod(t):e instanceof Set?Qx.isHandledMethod(t):e instanceof Map?Zx.isHandledMethod(t):Vg(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Dn;Ys(e)?r=Xx:e instanceof Date?r=sL:e instanceof Set?r=Qx:e instanceof Map?r=Zx:e instanceof WeakSet?r=aL:e instanceof WeakMap&&(r=nL),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=gl.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}},oL={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},N0=(e,t,i={})=>{i={...oL,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new J4(s),h=typeof i.onValidate=="function",u=new gl(h),c=(y,x,b,w,A)=>!h||u.isCloning||i.onValidate(Kr.concat(l.getPath(y),x),b,w,A)===!0,d=(y,x,b,w)=>{!Yx(l,i,x)&&!(n&&l.isDetached(y,e))&&p(l.getPath(y),x,b,w)},p=(y,x,b,w,A)=>{u.isCloning?u.update(y,x,w):t(Kr.concat(y,x),b,w,A)},f=y=>y&&(y[r]||y),m=(y,x,b,w)=>X4(y)||b==="constructor"||a&&!gl.isHandledMethod(x,b)||Yx(l,i,b)||l.isGetInvariant(x,b)||n&&l.isDetached(x,e)?y:(w===void 0&&(w=l.getPath(x)),l.getProxy(y,Kr.concat(w,b),g,r)),g={get(y,x,b){if(k0(x)){if(x===r||x===z0)return y;if(x===HA&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let w=Vg(y)?Reflect.get(y,x):Reflect.get(y,x,b);return m(w,y,x)},set(y,x,b,w){b=f(b);let A=y[r]||y,_=A[x];if(s(_,b)&&x in y)return!0;let S=c(y,x,b,_);return S&&l.setProperty(A,x,b,w,_)?(d(y,x,y[x],_),!0):!S},defineProperty(y,x,b){if(!l.isSameDescriptor(b,y,x)){let w=y[x];c(y,x,b.value,w)&&l.defineProperty(y,x,b,w)&&d(y,x,b.value,w)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let b=Reflect.get(y,x),w=c(y,x,void 0,b);return w&&l.deleteProperty(y,x,b)?(d(y,x,void 0,b),!0):!w},apply(y,x,b){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,w,b);if((o===!1||o!==!0&&!o.includes(y.name))&&gl.isHandledType(w)){let A=Kr.initial(l.getPath(y)),_=gl.isHandledMethod(w,y.name);u.start(w,A,b);let S=Reflect.apply(y,u.preferredThisArg(y,x,w),_?b.map(T=>f(T)):b),M=u.isChanged(w,s),C=u.stop();if(gl.isHandledType(S)&&_&&(x instanceof Map&&y.name==="get"&&(A=Kr.concat(A,b[0])),S=l.getProxy(S,A,g)),M){let T={name:y.name,args:b,result:S},D=u.isCloning?Kr.initial(A):A,P=u.isCloning?Kr.last(A):"";c(Kr.get(e,D),P,w,C,T)?p(D,P,w,C,T):u.undo(w)}return(x instanceof Map||x instanceof Set)&&Z4(S)?K4(S,y,x,A,m):S}return Reflect.apply(y,x,b)}},v=l.getProxy(e,i.pathAsArray?[]:"",g);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};N0.target=e=>e&&e[z0]||e;N0.unsubscribe=e=>e[HA]||e;var Kx=N0,lL=typeof global=="object"&&global&&global.Object===Object&&global,KA=lL,hL=typeof self=="object"&&self&&self.Object===Object&&self,cL=KA||hL||Function("return this")(),Cs=cL,dL=Cs.Symbol,ss=dL,JA=Object.prototype,uL=JA.hasOwnProperty,pL=JA.toString,Vh=ss?ss.toStringTag:void 0;function fL(e){var t=uL.call(e,Vh),i=e[Vh];try{e[Vh]=void 0;var r=!0}catch{}var s=pL.call(e);return r&&(t?e[Vh]=i:delete e[Vh]),s}var mL=fL,gL=Object.prototype,vL=gL.toString;function yL(e){return vL.call(e)}var xL=yL,bL="[object Null]",wL="[object Undefined]",Jx=ss?ss.toStringTag:void 0;function _L(e){return e==null?e===void 0?wL:bL:Jx&&Jx in Object(e)?mL(e):xL(e)}var Eo=_L;function SL(e){return e!=null&&typeof e=="object"}var Fa=SL,AL="[object Symbol]";function ML(e){return typeof e=="symbol"||Fa(e)&&Eo(e)==AL}var Yp=ML;function EL(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 $A=EL,CL=Array.isArray,ia=CL,TL=1/0,$x=ss?ss.prototype:void 0,eb=$x?$x.toString:void 0;function e2(e){if(typeof e=="string")return e;if(ia(e))return $A(e,e2)+"";if(Yp(e))return eb?eb.call(e):"";var t=e+"";return t=="0"&&1/e==-TL?"-0":t}var DL=e2,PL=/\s/;function IL(e){for(var t=e.length;t--&&PL.test(e.charAt(t)););return t}var OL=IL,RL=/^\s+/;function LL(e){return e&&e.slice(0,OL(e)+1).replace(RL,"")}var BL=LL;function zL(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Es=zL,tb=0/0,kL=/^[-+]0x[0-9a-f]+$/i,NL=/^0b[01]+$/i,UL=/^0o[0-7]+$/i,FL=parseInt;function VL(e){if(typeof e=="number")return e;if(Yp(e))return tb;if(Es(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Es(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=BL(e);var i=NL.test(e);return i||UL.test(e)?FL(e.slice(2),i?2:8):kL.test(e)?tb:+e}var ib=VL;function jL(e){return e}var GL=jL,HL="[object AsyncFunction]",WL="[object Function]",qL="[object GeneratorFunction]",YL="[object Proxy]";function XL(e){if(!Es(e))return!1;var t=Eo(e);return t==WL||t==qL||t==HL||t==YL}var t2=XL,QL=Cs["__core-js_shared__"],hm=QL,rb=function(){var e=/[^.]+$/.exec(hm&&hm.keys&&hm.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ZL(e){return!!rb&&rb in e}var KL=ZL,JL=Function.prototype,$L=JL.toString;function eB(e){if(e!=null){try{return $L.call(e)}catch{}try{return e+""}catch{}}return""}var Co=eB,tB=/[\\^$.*+?()[\]{}|]/g,iB=/^\[object .+?Constructor\]$/,rB=Function.prototype,sB=Object.prototype,aB=rB.toString,nB=sB.hasOwnProperty,oB=RegExp("^"+aB.call(nB).replace(tB,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function lB(e){if(!Es(e)||KL(e))return!1;var t=t2(e)?oB:iB;return t.test(Co(e))}var hB=lB;function cB(e,t){return e?.[t]}var dB=cB;function uB(e,t){var i=dB(e,t);return hB(i)?i:void 0}var To=uB,pB=To(Cs,"WeakMap"),Gg=pB,sb=Object.create,fB=function(){function e(){}return function(t){if(!Es(t))return{};if(sb)return sb(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),mB=fB;function gB(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 vB=gB;function yB(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var xB=yB,bB=800,wB=16,_B=Date.now;function SB(e){var t=0,i=0;return function(){var r=_B(),s=wB-(r-i);if(i=r,s>0){if(++t>=bB)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var AB=SB;function MB(e){return function(){return e}}var EB=MB,CB=function(){try{var e=To(Object,"defineProperty");return e({},"",{}),e}catch{}}(),sp=CB,TB=sp?function(e,t){return sp(e,"toString",{configurable:!0,enumerable:!1,value:EB(t),writable:!0})}:GL,DB=TB,PB=AB(DB),IB=PB;function OB(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var RB=OB,LB=9007199254740991,BB=/^(?:0|[1-9]\d*)$/;function zB(e,t){var i=typeof e;return t=t??LB,!!t&&(i=="number"||i!="symbol"&&BB.test(e))&&e>-1&&e%1==0&&e<t}var U0=zB;function kB(e,t,i){t=="__proto__"&&sp?sp(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var i2=kB;function NB(e,t){return e===t||e!==e&&t!==t}var F0=NB,UB=Object.prototype,FB=UB.hasOwnProperty;function VB(e,t,i){var r=e[t];(!(FB.call(e,t)&&F0(r,i))||i===void 0&&!(t in e))&&i2(e,t,i)}var V0=VB;function jB(e,t,i,r){var s=!i;i||(i={});for(var a=-1,n=t.length;++a<n;){var o=t[a],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?i2(i,o,l):V0(i,o,l)}return i}var td=jB,ab=Math.max;function GB(e,t,i){return t=ab(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=ab(r.length-t,0),n=Array(a);++s<a;)n[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(n),vB(e,this,o)}}var HB=GB,WB=9007199254740991;function qB(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=WB}var j0=qB;function YB(e){return e!=null&&j0(e.length)&&!t2(e)}var r2=YB,XB=Object.prototype;function QB(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||XB;return e===i}var G0=QB;function ZB(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var KB=ZB,JB="[object Arguments]";function $B(e){return Fa(e)&&Eo(e)==JB}var nb=$B,s2=Object.prototype,ez=s2.hasOwnProperty,tz=s2.propertyIsEnumerable,iz=nb(function(){return arguments}())?nb:function(e){return Fa(e)&&ez.call(e,"callee")&&!tz.call(e,"callee")},H0=iz;function rz(){return!1}var sz=rz,a2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ob=a2&&typeof module=="object"&&module&&!module.nodeType&&module,az=ob&&ob.exports===a2,lb=az?Cs.Buffer:void 0,nz=lb?lb.isBuffer:void 0,oz=nz||sz,ap=oz,lz="[object Arguments]",hz="[object Array]",cz="[object Boolean]",dz="[object Date]",uz="[object Error]",pz="[object Function]",fz="[object Map]",mz="[object Number]",gz="[object Object]",vz="[object RegExp]",yz="[object Set]",xz="[object String]",bz="[object WeakMap]",wz="[object ArrayBuffer]",_z="[object DataView]",Sz="[object Float32Array]",Az="[object Float64Array]",Mz="[object Int8Array]",Ez="[object Int16Array]",Cz="[object Int32Array]",Tz="[object Uint8Array]",Dz="[object Uint8ClampedArray]",Pz="[object Uint16Array]",Iz="[object Uint32Array]",Vt={};Vt[Sz]=Vt[Az]=Vt[Mz]=Vt[Ez]=Vt[Cz]=Vt[Tz]=Vt[Dz]=Vt[Pz]=Vt[Iz]=!0;Vt[lz]=Vt[hz]=Vt[wz]=Vt[cz]=Vt[_z]=Vt[dz]=Vt[uz]=Vt[pz]=Vt[fz]=Vt[mz]=Vt[gz]=Vt[vz]=Vt[yz]=Vt[xz]=Vt[bz]=!1;function Oz(e){return Fa(e)&&j0(e.length)&&!!Vt[Eo(e)]}var Rz=Oz;function Lz(e){return function(t){return e(t)}}var W0=Lz,n2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,bc=n2&&typeof module=="object"&&module&&!module.nodeType&&module,Bz=bc&&bc.exports===n2,cm=Bz&&KA.process,zz=function(){try{var e=bc&&bc.require&&bc.require("util").types;return e||cm&&cm.binding&&cm.binding("util")}catch{}}(),Zl=zz,hb=Zl&&Zl.isTypedArray,kz=hb?W0(hb):Rz,o2=kz,Nz=Object.prototype,Uz=Nz.hasOwnProperty;function Fz(e,t){var i=ia(e),r=!i&&H0(e),s=!i&&!r&&ap(e),a=!i&&!r&&!s&&o2(e),n=i||r||s||a,o=n?KB(e.length,String):[],l=o.length;for(var h in e)(t||Uz.call(e,h))&&!(n&&(h=="length"||s&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||U0(h,l)))&&o.push(h);return o}var l2=Fz;function Vz(e,t){return function(i){return e(t(i))}}var h2=Vz,jz=h2(Object.keys,Object),Gz=jz,Hz=Object.prototype,Wz=Hz.hasOwnProperty;function qz(e){if(!G0(e))return Gz(e);var t=[];for(var i in Object(e))Wz.call(e,i)&&i!="constructor"&&t.push(i);return t}var Yz=qz;function Xz(e){return r2(e)?l2(e):Yz(e)}var q0=Xz;function Qz(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var Zz=Qz,Kz=Object.prototype,Jz=Kz.hasOwnProperty;function $z(e){if(!Es(e))return Zz(e);var t=G0(e),i=[];for(var r in e)r=="constructor"&&(t||!Jz.call(e,r))||i.push(r);return i}var e5=$z;function t5(e){return r2(e)?l2(e,!0):e5(e)}var Y0=t5,i5=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r5=/^\w*$/;function s5(e,t){if(ia(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Yp(e)?!0:r5.test(e)||!i5.test(e)||t!=null&&e in Object(t)}var a5=s5,n5=To(Object,"create"),Rc=n5;function o5(){this.__data__=Rc?Rc(null):{},this.size=0}var l5=o5;function h5(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var c5=h5,d5="__lodash_hash_undefined__",u5=Object.prototype,p5=u5.hasOwnProperty;function f5(e){var t=this.__data__;if(Rc){var i=t[e];return i===d5?void 0:i}return p5.call(t,e)?t[e]:void 0}var m5=f5,g5=Object.prototype,v5=g5.hasOwnProperty;function y5(e){var t=this.__data__;return Rc?t[e]!==void 0:v5.call(t,e)}var x5=y5,b5="__lodash_hash_undefined__";function w5(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Rc&&t===void 0?b5:t,this}var _5=w5;function gh(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])}}gh.prototype.clear=l5;gh.prototype.delete=c5;gh.prototype.get=m5;gh.prototype.has=x5;gh.prototype.set=_5;var cb=gh;function S5(){this.__data__=[],this.size=0}var A5=S5;function M5(e,t){for(var i=e.length;i--;)if(F0(e[i][0],t))return i;return-1}var Xp=M5,E5=Array.prototype,C5=E5.splice;function T5(e){var t=this.__data__,i=Xp(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():C5.call(t,i,1),--this.size,!0}var D5=T5;function P5(e){var t=this.__data__,i=Xp(t,e);return i<0?void 0:t[i][1]}var I5=P5;function O5(e){return Xp(this.__data__,e)>-1}var R5=O5;function L5(e,t){var i=this.__data__,r=Xp(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var B5=L5;function vh(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])}}vh.prototype.clear=A5;vh.prototype.delete=D5;vh.prototype.get=I5;vh.prototype.has=R5;vh.prototype.set=B5;var Qp=vh,z5=To(Cs,"Map"),Lc=z5;function k5(){this.size=0,this.__data__={hash:new cb,map:new(Lc||Qp),string:new cb}}var N5=k5;function U5(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var F5=U5;function V5(e,t){var i=e.__data__;return F5(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Zp=V5;function j5(e){var t=Zp(this,e).delete(e);return this.size-=t?1:0,t}var G5=j5;function H5(e){return Zp(this,e).get(e)}var W5=H5;function q5(e){return Zp(this,e).has(e)}var Y5=q5;function X5(e,t){var i=Zp(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Q5=X5;function yh(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])}}yh.prototype.clear=N5;yh.prototype.delete=G5;yh.prototype.get=W5;yh.prototype.has=Y5;yh.prototype.set=Q5;var Kp=yh,Z5="Expected a function";function X0(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Z5);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=i.cache;if(a.has(s))return a.get(s);var n=e.apply(this,r);return i.cache=a.set(s,n)||a,n};return i.cache=new(X0.Cache||Kp),i}X0.Cache=Kp;var K5=X0,J5=500;function $5(e){var t=K5(e,function(r){return i.size===J5&&i.clear(),r}),i=t.cache;return t}var ek=$5,tk=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ik=/\\(\\)?/g,rk=ek(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(tk,function(i,r,s,a){t.push(s?a.replace(ik,"$1"):r||i)}),t}),sk=rk;function ak(e){return e==null?"":DL(e)}var nk=ak;function ok(e,t){return ia(e)?e:a5(e,t)?[e]:sk(nk(e))}var xh=ok,lk=1/0;function hk(e){if(typeof e=="string"||Yp(e))return e;var t=e+"";return t=="0"&&1/e==-lk?"-0":t}var Jp=hk;function ck(e,t){t=xh(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Jp(t[i++])];return i&&i==r?e:void 0}var c2=ck;function dk(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Q0=dk,db=ss?ss.isConcatSpreadable:void 0;function uk(e){return ia(e)||H0(e)||!!(db&&e&&e[db])}var pk=uk;function d2(e,t,i,r,s){var a=-1,n=e.length;for(i||(i=pk),s||(s=[]);++a<n;){var o=e[a];t>0&&i(o)?t>1?d2(o,t-1,i,r,s):Q0(s,o):r||(s[s.length]=o)}return s}var fk=d2;function mk(e){var t=e==null?0:e.length;return t?fk(e,1):[]}var gk=mk;function vk(e){return IB(HB(e,void 0,gk),e+"")}var u2=vk,yk=h2(Object.getPrototypeOf,Object),Z0=yk,xk="[object Object]",bk=Function.prototype,wk=Object.prototype,p2=bk.toString,_k=wk.hasOwnProperty,Sk=p2.call(Object);function Ak(e){if(!Fa(e)||Eo(e)!=xk)return!1;var t=Z0(e);if(t===null)return!0;var i=_k.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&p2.call(i)==Sk}var Mk=Ak;function Ek(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 a=Array(s);++r<s;)a[r]=e[r+t];return a}var Ck=Ek;function Tk(){this.__data__=new Qp,this.size=0}var Dk=Tk;function Pk(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Ik=Pk;function Ok(e){return this.__data__.get(e)}var Rk=Ok;function Lk(e){return this.__data__.has(e)}var Bk=Lk,zk=200;function kk(e,t){var i=this.__data__;if(i instanceof Qp){var r=i.__data__;if(!Lc||r.length<zk-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Kp(r)}return i.set(e,t),this.size=i.size,this}var Nk=kk;function bh(e){var t=this.__data__=new Qp(e);this.size=t.size}bh.prototype.clear=Dk;bh.prototype.delete=Ik;bh.prototype.get=Rk;bh.prototype.has=Bk;bh.prototype.set=Nk;var Lu=bh;function Uk(e,t){return e&&td(t,q0(t),e)}var Fk=Uk;function Vk(e,t){return e&&td(t,Y0(t),e)}var jk=Vk,f2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ub=f2&&typeof module=="object"&&module&&!module.nodeType&&module,Gk=ub&&ub.exports===f2,pb=Gk?Cs.Buffer:void 0,fb=pb?pb.allocUnsafe:void 0;function Hk(e,t){if(t)return e.slice();var i=e.length,r=fb?fb(i):new e.constructor(i);return e.copy(r),r}var Wk=Hk;function qk(e,t){for(var i=-1,r=e==null?0:e.length,s=0,a=[];++i<r;){var n=e[i];t(n,i,e)&&(a[s++]=n)}return a}var Yk=qk;function Xk(){return[]}var m2=Xk,Qk=Object.prototype,Zk=Qk.propertyIsEnumerable,mb=Object.getOwnPropertySymbols,Kk=mb?function(e){return e==null?[]:(e=Object(e),Yk(mb(e),function(t){return Zk.call(e,t)}))}:m2,K0=Kk;function Jk(e,t){return td(e,K0(e),t)}var $k=Jk,eN=Object.getOwnPropertySymbols,tN=eN?function(e){for(var t=[];e;)Q0(t,K0(e)),e=Z0(e);return t}:m2,g2=tN;function iN(e,t){return td(e,g2(e),t)}var rN=iN;function sN(e,t,i){var r=t(e);return ia(e)?r:Q0(r,i(e))}var v2=sN;function aN(e){return v2(e,q0,K0)}var Hg=aN;function nN(e){return v2(e,Y0,g2)}var y2=nN,oN=To(Cs,"DataView"),Wg=oN,lN=To(Cs,"Promise"),qg=lN,hN=To(Cs,"Set"),Yg=hN,gb="[object Map]",cN="[object Object]",vb="[object Promise]",yb="[object Set]",xb="[object WeakMap]",bb="[object DataView]",dN=Co(Wg),uN=Co(Lc),pN=Co(qg),fN=Co(Yg),mN=Co(Gg),Qn=Eo;(Wg&&Qn(new Wg(new ArrayBuffer(1)))!=bb||Lc&&Qn(new Lc)!=gb||qg&&Qn(qg.resolve())!=vb||Yg&&Qn(new Yg)!=yb||Gg&&Qn(new Gg)!=xb)&&(Qn=function(e){var t=Eo(e),i=t==cN?e.constructor:void 0,r=i?Co(i):"";if(r)switch(r){case dN:return bb;case uN:return gb;case pN:return vb;case fN:return yb;case mN:return xb}return t});var Bc=Qn,gN=Object.prototype,vN=gN.hasOwnProperty;function yN(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&vN.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var xN=yN,bN=Cs.Uint8Array,np=bN;function wN(e){var t=new e.constructor(e.byteLength);return new np(t).set(new np(e)),t}var J0=wN;function _N(e,t){var i=t?J0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var SN=_N,AN=/\w*$/;function MN(e){var t=new e.constructor(e.source,AN.exec(e));return t.lastIndex=e.lastIndex,t}var EN=MN,wb=ss?ss.prototype:void 0,_b=wb?wb.valueOf:void 0;function CN(e){return _b?Object(_b.call(e)):{}}var TN=CN;function DN(e,t){var i=t?J0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var PN=DN,IN="[object Boolean]",ON="[object Date]",RN="[object Map]",LN="[object Number]",BN="[object RegExp]",zN="[object Set]",kN="[object String]",NN="[object Symbol]",UN="[object ArrayBuffer]",FN="[object DataView]",VN="[object Float32Array]",jN="[object Float64Array]",GN="[object Int8Array]",HN="[object Int16Array]",WN="[object Int32Array]",qN="[object Uint8Array]",YN="[object Uint8ClampedArray]",XN="[object Uint16Array]",QN="[object Uint32Array]";function ZN(e,t,i){var r=e.constructor;switch(t){case UN:return J0(e);case IN:case ON:return new r(+e);case FN:return SN(e,i);case VN:case jN:case GN:case HN:case WN:case qN:case YN:case XN:case QN:return PN(e,i);case RN:return new r;case LN:case kN:return new r(e);case BN:return EN(e);case zN:return new r;case NN:return TN(e)}}var KN=ZN;function JN(e){return typeof e.constructor=="function"&&!G0(e)?mB(Z0(e)):{}}var $N=JN,eU="[object Map]";function tU(e){return Fa(e)&&Bc(e)==eU}var iU=tU,Sb=Zl&&Zl.isMap,rU=Sb?W0(Sb):iU,sU=rU,aU="[object Set]";function nU(e){return Fa(e)&&Bc(e)==aU}var oU=nU,Ab=Zl&&Zl.isSet,lU=Ab?W0(Ab):oU,hU=lU,cU=1,dU=2,uU=4,x2="[object Arguments]",pU="[object Array]",fU="[object Boolean]",mU="[object Date]",gU="[object Error]",b2="[object Function]",vU="[object GeneratorFunction]",yU="[object Map]",xU="[object Number]",w2="[object Object]",bU="[object RegExp]",wU="[object Set]",_U="[object String]",SU="[object Symbol]",AU="[object WeakMap]",MU="[object ArrayBuffer]",EU="[object DataView]",CU="[object Float32Array]",TU="[object Float64Array]",DU="[object Int8Array]",PU="[object Int16Array]",IU="[object Int32Array]",OU="[object Uint8Array]",RU="[object Uint8ClampedArray]",LU="[object Uint16Array]",BU="[object Uint32Array]",Ut={};Ut[x2]=Ut[pU]=Ut[MU]=Ut[EU]=Ut[fU]=Ut[mU]=Ut[CU]=Ut[TU]=Ut[DU]=Ut[PU]=Ut[IU]=Ut[yU]=Ut[xU]=Ut[w2]=Ut[bU]=Ut[wU]=Ut[_U]=Ut[SU]=Ut[OU]=Ut[RU]=Ut[LU]=Ut[BU]=!0;Ut[gU]=Ut[b2]=Ut[AU]=!1;function Bu(e,t,i,r,s,a){var n,o=t&cU,l=t&dU,h=t&uU;if(i&&(n=s?i(e,r,s,a):i(e)),n!==void 0)return n;if(!Es(e))return e;var u=ia(e);if(u){if(n=xN(e),!o)return xB(e,n)}else{var c=Bc(e),d=c==b2||c==vU;if(ap(e))return Wk(e,o);if(c==w2||c==x2||d&&!s){if(n=l||d?{}:$N(e),!o)return l?rN(e,jk(n,e)):$k(e,Fk(n,e))}else{if(!Ut[c])return s?e:{};n=KN(e,c,o)}}a||(a=new Lu);var p=a.get(e);if(p)return p;a.set(e,n),hU(e)?e.forEach(function(g){n.add(Bu(g,t,i,g,e,a))}):sU(e)&&e.forEach(function(g,v){n.set(v,Bu(g,t,i,v,e,a))});var f=h?l?y2:Hg:l?Y0:q0,m=u?void 0:f(e);return RB(m||e,function(g,v){m&&(v=g,g=e[v]),V0(n,v,Bu(g,t,i,v,e,a))}),n}var _2=Bu,zU=1,kU=4;function NU(e){return _2(e,zU|kU)}var $p=NU,UU="__lodash_hash_undefined__";function FU(e){return this.__data__.set(e,UU),this}var VU=FU;function jU(e){return this.__data__.has(e)}var GU=jU;function op(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Kp;++t<i;)this.add(e[t])}op.prototype.add=op.prototype.push=VU;op.prototype.has=GU;var HU=op;function WU(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 qU=WU;function YU(e,t){return e.has(t)}var XU=YU,QU=1,ZU=2;function KU(e,t,i,r,s,a){var n=i&QU,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=a.get(e),u=a.get(t);if(h&&u)return h==t&&u==e;var c=-1,d=!0,p=i&ZU?new HU:void 0;for(a.set(e,t),a.set(t,e);++c<o;){var f=e[c],m=t[c];if(r)var g=n?r(m,f,c,t,e,a):r(f,m,c,e,t,a);if(g!==void 0){if(g)continue;d=!1;break}if(p){if(!qU(t,function(v,y){if(!XU(p,y)&&(f===v||s(f,v,i,r,a)))return p.push(y)})){d=!1;break}}else if(!(f===m||s(f,m,i,r,a))){d=!1;break}}return a.delete(e),a.delete(t),d}var S2=KU;function JU(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var $U=JU;function eF(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var tF=eF,iF=1,rF=2,sF="[object Boolean]",aF="[object Date]",nF="[object Error]",oF="[object Map]",lF="[object Number]",hF="[object RegExp]",cF="[object Set]",dF="[object String]",uF="[object Symbol]",pF="[object ArrayBuffer]",fF="[object DataView]",Mb=ss?ss.prototype:void 0,dm=Mb?Mb.valueOf:void 0;function mF(e,t,i,r,s,a,n){switch(i){case fF:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case pF:return!(e.byteLength!=t.byteLength||!a(new np(e),new np(t)));case sF:case aF:case lF:return F0(+e,+t);case nF:return e.name==t.name&&e.message==t.message;case hF:case dF:return e==t+"";case oF:var o=$U;case cF:var l=r&iF;if(o||(o=tF),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=rF,n.set(e,t);var u=S2(o(e),o(t),r,s,a,n);return n.delete(e),u;case uF:if(dm)return dm.call(e)==dm.call(t)}return!1}var gF=mF,vF=1,yF=Object.prototype,xF=yF.hasOwnProperty;function bF(e,t,i,r,s,a){var n=i&vF,o=Hg(e),l=o.length,h=Hg(t),u=h.length;if(l!=u&&!n)return!1;for(var c=l;c--;){var d=o[c];if(!(n?d in t:xF.call(t,d)))return!1}var p=a.get(e),f=a.get(t);if(p&&f)return p==t&&f==e;var m=!0;a.set(e,t),a.set(t,e);for(var g=n;++c<l;){d=o[c];var v=e[d],y=t[d];if(r)var x=n?r(y,v,d,t,e,a):r(v,y,d,e,t,a);if(!(x===void 0?v===y||s(v,y,i,r,a):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var b=e.constructor,w=t.constructor;b!=w&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(m=!1)}return a.delete(e),a.delete(t),m}var wF=bF,_F=1,Eb="[object Arguments]",Cb="[object Array]",Hd="[object Object]",SF=Object.prototype,Tb=SF.hasOwnProperty;function AF(e,t,i,r,s,a){var n=ia(e),o=ia(t),l=n?Cb:Bc(e),h=o?Cb:Bc(t);l=l==Eb?Hd:l,h=h==Eb?Hd:h;var u=l==Hd,c=h==Hd,d=l==h;if(d&&ap(e)){if(!ap(t))return!1;n=!0,u=!1}if(d&&!u)return a||(a=new Lu),n||o2(e)?S2(e,t,i,r,s,a):gF(e,t,l,i,r,s,a);if(!(i&_F)){var p=u&&Tb.call(e,"__wrapped__"),f=c&&Tb.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return a||(a=new Lu),s(m,g,i,r,a)}}return d?(a||(a=new Lu),wF(e,t,i,r,s,a)):!1}var MF=AF;function A2(e,t,i,r,s){return e===t?!0:e==null||t==null||!Fa(e)&&!Fa(t)?e!==e&&t!==t:MF(e,t,i,r,A2,s)}var EF=A2;function CF(e,t){return e!=null&&t in Object(e)}var TF=CF;function DF(e,t,i){t=xh(t,e);for(var r=-1,s=t.length,a=!1;++r<s;){var n=Jp(t[r]);if(!(a=e!=null&&i(e,n)))break;e=e[n]}return a||++r!=s?a:(s=e==null?0:e.length,!!s&&j0(s)&&U0(n,s)&&(ia(e)||H0(e)))}var PF=DF;function IF(e,t){return e!=null&&PF(e,t,TF)}var OF=IF,RF=function(){return Cs.Date.now()},um=RF,LF="Expected a function",BF=Math.max,zF=Math.min;function kF(e,t,i){var r,s,a,n,o,l,h=0,u=!1,c=!1,d=!0;if(typeof e!="function")throw new TypeError(LF);t=ib(t)||0,Es(i)&&(u=!!i.leading,c="maxWait"in i,a=c?BF(ib(i.maxWait)||0,t):a,d="trailing"in i?!!i.trailing:d);function p(A){var _=r,S=s;return r=s=void 0,h=A,n=e.apply(S,_),n}function f(A){return h=A,o=setTimeout(v,t),u?p(A):n}function m(A){var _=A-l,S=A-h,M=t-_;return c?zF(M,a-S):M}function g(A){var _=A-l,S=A-h;return l===void 0||_>=t||_<0||c&&S>=a}function v(){var A=um();if(g(A))return y(A);o=setTimeout(v,m(A))}function y(A){return o=void 0,d&&r?p(A):(r=s=void 0,n)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function b(){return o===void 0?n:y(um())}function w(){var A=um(),_=g(A);if(r=arguments,s=this,l=A,_){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)),n}return w.cancel=x,w.flush=b,w}var $0=kF;function NF(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var UF=NF;function FF(e,t){return t.length<2?e:c2(e,Ck(t,0,-1))}var VF=FF;function jF(e,t){return EF(e,t)}var M2=jF;function GF(e,t){return t=xh(t,e),e=VF(e,t),e==null||delete e[Jp(UF(t))]}var HF=GF;function WF(e){return Mk(e)?void 0:e}var qF=WF,YF=1,XF=2,QF=4,ZF=u2(function(e,t){var i={};if(e==null)return i;var r=!1;t=$A(t,function(a){return a=xh(a,e),r||(r=a.length>1),a}),td(e,y2(e),i),r&&(i=_2(i,YF|XF|QF,qF));for(var s=t.length;s--;)HF(i,t[s]);return i}),Xg=ZF;function KF(e,t,i,r){if(!Es(e))return e;t=xh(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s<a;){var l=Jp(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=n){var u=o[l];h=r?r(u,l,o):void 0,h===void 0&&(h=Es(u)?u:U0(t[s+1])?[]:{})}V0(o,l,h),o=o[l]}return e}var JF=KF;function $F(e,t,i){for(var r=-1,s=t.length,a={};++r<s;){var n=t[r],o=c2(e,n);i(o,n)&&JF(a,xh(n,e),o)}return a}var e6=$F;function t6(e,t){return e6(e,t,function(i,r){return OF(e,r)})}var i6=t6,r6=u2(function(e,t){return e==null?{}:i6(e,t)}),ka=r6,s6="Expected a function";function a6(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(s6);return Es(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),$0(e,t,{leading:r,maxWait:t,trailing:s})}var n6=a6;function o6(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Va(e,t){return Object.setPrototypeOf(e,t),e}var l6=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),h6=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),c6=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||ef&&"ontouchend"in document,d6=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,u6=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,p6=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},f6=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},m6=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},g6=l6(),pQ=g6?m6():void 0,ef=h6(),E2=c6(),v6=d6(),Ur=u6(),Db=p6(),Pb=Number(f6());function C2(e){return Array.isArray(e)?e:[e]}function y6(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 Wd(e){return ef?e.metaKey:e.ctrlKey}var Ye=[],lp={},hc={},zu={};function T2(e){Ye.includes(e)||Ye.push(e)}function Il(e){delete lp[e.pointerId];for(let t=0;t<Ye.length;t++)if(Ye[t].pointerId===e.pointerId){Ye.splice(t,1);break}}function x6(){Ye.splice(0,Ye.length)}function hp(e){if(e.pointerType!=="touch")return;let t=lp[e.pointerId];t===void 0&&(t={x:0,y:0},lp[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function pm(e){let t=e.pointerId===Ye[0].pointerId?Ye[1]:Ye[0];return lp[t.pointerId]}function D2(e){hc[e.key]=!0,zu[e.key]=zu[e.key]===void 0?1:zu[e.key]+1}function P2(e){if(ef&&hc.Meta)for(let t in hc)hc[t]=!1;else hc[e.key]=!1;zu={}}function b6(e){e.addEventListener("pointerdown",T2,!0),e.addEventListener("pointerdown",hp,!0),e.addEventListener("pointermove",hp,!0),e.addEventListener("pointerup",Il,!0),e.addEventListener("pointercancel",Il,!0),e.addEventListener("pointerleave",Il,!0),window.addEventListener("keydown",D2,!0),window.addEventListener("keyup",P2,!0)}function w6(e){e.removeEventListener("pointerdown",T2,!0),e.removeEventListener("pointerdown",hp,!0),e.removeEventListener("pointermove",hp,!0),e.removeEventListener("pointerup",Il,!0),e.removeEventListener("pointercancel",Il,!0),e.removeEventListener("pointerleave",Il,!0),window.removeEventListener("keydown",D2,!0),window.removeEventListener("keyup",P2,!0)}var I2,_6=new Promise(e=>{I2=e}),qd;function S6(){if(qd)return qd;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@0.9.502/build",i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});I2(n)}return qd=e(),qd}var O2,A6=new Promise(e=>{O2=e}),Yd;function M6(){if(Yd)return Yd;async function e(){let t=await import("./physics.js");await t.init(),O2(t)}return Yd=e(),Yd}var ot=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,ot.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:a}=e,n={...t,[s]:a};return Object.setPrototypeOf(n,ot.prototype),{data:n,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,ot.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function ey(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"&&ey(r)}return Object.freeze(e)}function E6(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 R2=class extends Error{};function fm(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function fn(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 a=e;e=t,t=a}let r=[],s=1/(i+1);for(let a=0;a<i;a++){let n=e+(t-e)*(a+.75+Math.random()*.5)*s;r.push(n)}return r}function ty(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 C6(){return typeof process<"u"}function L2(e,t){for(let i of e)t(i.id,i.data)!==!0&&L2(i.children,t)}function B2(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)B2(i,t)}var Er=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Er.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ey(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}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}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&&B2(i,t)}}traverse(e){L2(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(n=>n.id===e);if(s<0)throw new Error("not expected");let a=r[s];return r=[...r],r[s]={...a,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let a=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:a}}Object.setPrototypeOf(r,Er.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:a}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:s,children:a};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,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(n=>n.id===t);e.localIndex=s,r=[...r];let a=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...a,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 R2("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(c=>c.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((c,d)=>c.fi-d.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,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)=>E6(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 fn(0,i,i);{let s=r[0].fi;return fn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=r.find(n=>n.fi>s.fi);if(a===void 0){let n=r[r.length-1].fi;return fn(n,n+i,i)}else return fn(s.fi,a.fi,i)}}},cp;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,a={},n=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");a[l]=n[h],n[h]=s[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}else{let s=r.props,a={},n={...i},o=!1;if(s)for(let l of Object.keys(s)){a[l]=n[l];let h=s[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}}e.runOp=t})(cp||(cp={}));var We=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,We.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ey(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(a=>a.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,We.prototype);let t=e;return C6()||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,a={fi:t,id:i,data:r};return s=[...s,a],s.sort((n,o)=>n.fi-o.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(a=>a.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 a=r[s].fi,n={...r[s],fi:t};return r[s]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:a,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 fn(0,t,t);{let r=i[0].fi;return fn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>r.fi);if(s===void 0){let a=i[i.length-1].fi;return fn(a,a+t,t)}else return fn(r.fi,s.fi,t)}}};function Kl(e){return e&&typeof e=="object"&&e instanceof _i}var _i=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&&!Kl(i))return null;r+=1}i=i?fm(i):new _i;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=fm(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=fm(o);l[e.path[r-1]]=i,i=l}else{let l=new _i;l[e.path[r-1]]=i,i=l}}r-=1}let a=Object.setPrototypeOf(i,_i.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},Sn;(e=>{function t(s,a){return zc(s,a)??s}e.apply=t;function i(s,a){return ry(s,a)}e.merge=i;function r(s,a){let n=0,o=a.path,l=s;for(;n<o.length&&l!==void 0;){if(l=ar.zoomOnce(l,o[n]),l===void 0)return a;if(!Kl(l))return;n+=1}if(l===void 0)return a;if(Kl(l))if(a.type===0){let h={...a.props};for(let u of Object.keys(l))delete h[u];return{...a,props:h}}else if(a.type===1||a.type===4||a.type===7){let h=iy([a],l);return h?(console.log(h),h):a}else return a}e.filterOp=r})(Sn||(Sn={}));function iy(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=zc(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=iy(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:a,data:n,children:o}}else return{...s,id:a,data:n}});if(i)return r}function T6(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=zc(s.data,t[a]);return i=i||n!==void 0,n===void 0&&(n=s.data),{...s,id:a,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function zc(e,t){if(!Kl(t))return t;if(e instanceof Er){let i=iy(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof We)return T6(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=zc(s,t[a]);return i=i||n!==void 0,n===void 0&&(n=s),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof _i)return ry(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=zc(a,t[s]);r=r||n!==void 0,n===void 0&&(n=a),i[s]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function ry(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Kl(t))return t;if(!Kl(e))return Sn.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 _i;for(let s of i){let a=ry(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function D6(e,t){let i={cur:[],result:[],len:0};return e=kc(e,t,i)??e,[e,i.result]}function dp(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function up(e){e&&(e.len-=1)}function P6(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function z2(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=kc(a.data,t,dp(i,n));up(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=z2(a.children,t,i);return h!==void 0?r=!0:h=a.children,{...a,id:n,data:l,children:h}});if(r)return s}function I6(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=kc(a.data,t,dp(i,n));return up(i),r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:n,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function kc(e,t,i){if(e instanceof Er){let r=z2(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof We)return I6(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=kc(a,t,dp(i,n));return up(i),r=r||o!==void 0,o===void 0&&(o=a),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!ty(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=kc(n,t,dp(i,a));up(i),s=s||l!==void 0,l===void 0&&(l=n),r[a]=l}else r[a]=n;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&P6(i),r}else return}}var Qg;(e=>{function t(i,r){let s=ar.zoom(r,i.path);if(typeof s=="object"){let a={};for(let n of Object.keys(i.props))a[n]=s[n];return{...i,props:a}}else return{...i,props:{}}}e.replaceProps=t})(Qg||(Qg={}));var Wi;(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 _i&&h.type===0&&(d=l.runOp({...h,path:u.slice(c.length)}),d===null&&(d=void 0)),d===void 0&&c.length===u.length&&(l instanceof Er||l instanceof We||l instanceof ot?d=l.runOp(h):d=cp.runOp(l,h)),d!==void 0)if(d!==null){let m=d.data;for(let g=c.length-1;g>=0;g--){let v=u[g],y=c[g];if(y instanceof Er){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof We){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof ot){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof _i){let x={...y,[v]:m};m=Object.setPrototypeOf(x,_i.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 x=m;m=[...y],m[v]=x}else m={...y,[v]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let p=u[c.length],f;if(l instanceof Er){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof We){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 a(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=a;function n(l,h){return s(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&a(l.path,h.path)?Object.keys(l.props).every(u=>h.props[u]!==void 0):!1}e.subsumed=o})(Wi||(Wi={}));var Zg;(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 a(h,u){return[...h.filter(c=>!u.some(d=>Wi.subsumed(c,d))),...u]}e.compress=a;function n(h,u){return h.every(c=>u.every(d=>Wi.commutative(c,d)))}e.commutative=n;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||f.type===5&&f.path[f.path.length-1]==="variables"){let m,g,v;if(f.type===3?(m=ar.zoom(c,[...f.path,f.id]),v=Wi.apply(c,{...f,type:2})):(m=ar.zoom(c,[...f.path,f.id,"value"]),v=Wi.apply(c,f)),v!==null){c=v.data;let[y,x]=D6(c,{[f.id]:m});c=y;for(let b=0;b<x.length;b++){let w=x[b],A=w.pop();if(typeof A=="number"){let _=[A];for(let M=b+1;M<x.length;M++){let C=x[M],T=C[C.length-1];if(typeof T=="number"&&ar.equal(w,C.slice(0,C.length-1)))_.push(T),x.splice(M,1);else break}let S=ar.zoom(c,w);g=S.map((M,C)=>_.includes(C)?f.id:M),m=S,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let _=m,S=ar.zoom(c,w.slice(0,w.length-2)),M=S.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:_}}:C);Object.setPrototypeOf(M,Object.getPrototypeOf(S.layers)),S.layers=M}g=f.id}d.push({type:0,path:w,props:{[A]:m}}),p.push({type:0,path:w,props:{[A]:g}})}p.push(v.reverse),d.push(v.actual)}}else{let m=Wi.apply(c,f);m!==null&&(d.push(m.actual),c=m.data,p.push(m.reverse))}}catch(m){if(m instanceof R2)return null;throw m}return{data:c,actual:d,reverse:p.reverse()}}e.apply=l})(Zg||(Zg={}));var k2=Symbol(),O6=Symbol(),tf=Symbol(),id=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof U2);){let a=r._path,n=r._current;if(a!==""&&s.splice(0,0,a),r=r._parent,r===null)return;r.update(a,n)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[tf];i&&i(),delete this._children[e]}}}},R6=class extends id{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,cp.runOp(this._current,e),e.path)}},L6=class extends id{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,ot.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},N2={get(e,t){if(t===tf)return()=>{e._parent=null};if(t===k2)return e._current;if(t===O6)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 a=i[t],n=rf(e,t,a);return n!==a?(r===void 0&&(r={},e._children=r),r[t]=n,n):a},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]}}},B6={...N2,set(e,t,i){let r={type:0,props:{[t]:mi(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}},z6={...N2,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}},sy=class extends id{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[tf]=()=>{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,a=rf(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):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 a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}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)}},ay=class extends id{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[tf]=()=>{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,a=rf(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):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 mm(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&ar.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var U2=class extends id{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){mm(this.ts,t,e),mm(this.actual,i,e),mm(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function rf(e,t,i){return i instanceof Er?new sy(e,t,i):i instanceof We?new ay(e,t,i):i instanceof ot?new Proxy(new L6(e,t,i),z6):i!==null&&typeof i=="object"?ty(i)?i:new Proxy(new R6(e,t,i),B6):i}function F2(e){let t=new U2(e);return[rf(t,"",e),t]}function Nc(e,t){let[i,r]=F2(e);return t(i),r.result()}function mi(e){return e instanceof sy||e instanceof ay?e._current:e!==null&&typeof e=="object"?e[k2]:e}var ar;(e=>{function t(a,n){if(n.length===a.length)for(var o=0;o<a.length;){if(a[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(a,n,o){let l=s(o,a);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(u=>{delete h[u]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof Er||a instanceof sy)&&typeof n=="string"||(a instanceof We||a instanceof ay)&&typeof n=="string")return a.data(n);if(typeof n=="number"&&Array.isArray(a)||typeof n=="string"&&typeof a=="object"&&a!==null)return a[n]}e.zoomOnce=r;function s(a,n,o=0){for(;o<n.length&&a!==void 0;)a=r(a,n[o]),o+=1;return a}e.zoom=s})(ar||(ar={}));function k6(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 es(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 V2=class{},Ib=class extends V2{constructor(e){super(),this.id=e}},Ob=class extends V2{constructor(e){super(),this.data=e}},Kg;try{Kg=new TextDecoder}catch{}var Pe,An,K=0,j2=[],Jg=j2,$g=0,wr={},St,mn,Jr=0,Xs=0,zr,Na,pr=[],Mt,Rb={useRecords:!1,mapsAsObjects:!0},G2=class{},H2=new G2;H2.name="MessagePack 0xC1";var Jl=!1,pp=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(Pe)return Z2(()=>(tv(),this?this.unpack(e,t):pp.prototype.unpack.call(Rb,e,t)));An=t>-1?t:e.length,K=0,$g=0,Xs=0,mn=null,Jg=j2,zr=null,Pe=e;try{Mt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Pe=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 pp){if(wr=this,this.structures)return St=this.structures,Xd();(!St||St.length>0)&&(St=[])}else wr=Rb,(!St||St.length>0)&&(St=[]);return Xd()}unpackMultiple(e,t){let i,r=0;try{Jl=!0;let s=e.length,a=this?this.unpack(e,s):af.unpack(e,s);if(t){for(t(a);K<s;)if(r=K,t(Xd())===!1)return}else{for(i=[a];K<s;)r=K,i.push(Xd());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Jl=!1,tv()}}_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 Xd(){try{if(!wr.trusted&&!Jl){let t=St.sharedLength||0;t<St.length&&(St.length=t)}let e=Qt();if(K==An)St.restoreStructures&&Lb(),St=null,Pe=null,Na&&(Na=null);else if(K>An){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Jl)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw St.restoreStructures&&Lb(),tv(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function Lb(){for(let e in St.restoreStructures)St[e]=St.restoreStructures[e];St.restoreStructures=null}function Qt(){let e=Pe[K++];if(e<160)if(e<128){if(e<64)return e;{let t=St[e&63]||wr.getStructures&&W2()[e&63];return t?(t.read||(t.read=ny(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,wr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[Y2()]=Qt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Qt(),Qt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Qt();return t}else if(e<192){let t=e-160;if(Xs>=K)return mn.slice(K-Jr,(K+=t)-Jr);if(Xs==0&&An<140){let i=t<16?oy(t):q2(t);if(i!=null)return i}return ev(t)}else{let t;switch(e){case 192:return null;case 193:return zr?(t=Qt(),t>0?zr[1].slice(zr.position1,zr.position1+=t):zr[0].slice(zr.position0,zr.position0-=t)):H2;case 194:return!1;case 195:return!0;case 196:return gm(Pe[K++]);case 197:return t=Mt.getUint16(K),K+=2,gm(t);case 198:return t=Mt.getUint32(K),K+=4,gm(t);case 199:return Gn(Pe[K++]);case 200:return t=Mt.getUint16(K),K+=2,Gn(t);case 201:return t=Mt.getUint32(K),K+=4,Gn(t);case 202:if(t=Mt.getFloat32(K),wr.useFloat32>2){let i=ly[(Pe[K]&127)<<1|Pe[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=Mt.getFloat64(K),K+=8,t;case 204:return Pe[K++];case 205:return t=Mt.getUint16(K),K+=2,t;case 206:return t=Mt.getUint32(K),K+=4,t;case 207:return wr.int64AsNumber?(t=Mt.getUint32(K)*4294967296,t+=Mt.getUint32(K+4)):t=Mt.getBigUint64(K),K+=8,t;case 208:return Mt.getInt8(K++);case 209:return t=Mt.getInt16(K),K+=2,t;case 210:return t=Mt.getInt32(K),K+=4,t;case 211:return wr.int64AsNumber?(t=Mt.getInt32(K)*4294967296,t+=Mt.getUint32(K+4)):t=Mt.getBigInt64(K),K+=8,t;case 212:if(t=Pe[K++],t==114)return Ub(Pe[K++]&63);{let i=pr[t];if(i)return i.read?(K++,i.read(Qt())):i.noBuffer?(K++,i()):i(Pe.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=Pe[K],t==114?(K++,Ub(Pe[K++]&63,Pe[K++])):Gn(2);case 214:return Gn(4);case 215:return Gn(8);case 216:return Gn(16);case 217:return t=Pe[K++],Xs>=K?mn.slice(K-Jr,(K+=t)-Jr):U6(t);case 218:return t=Mt.getUint16(K),K+=2,Xs>=K?mn.slice(K-Jr,(K+=t)-Jr):F6(t);case 219:return t=Mt.getUint32(K),K+=4,Xs>=K?mn.slice(K-Jr,(K+=t)-Jr):V6(t);case 220:return t=Mt.getUint16(K),K+=2,zb(t);case 221:return t=Mt.getUint32(K),K+=4,zb(t);case 222:return t=Mt.getUint16(K),K+=2,kb(t);case 223:return t=Mt.getUint32(K),K+=4,kb(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 N6=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ny(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>N6.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(Qt);return e.highByte===0&&(e.read=Bb(t,e.read)),s()}let r={};for(let s=0,a=e.length;s<a;s++){let n=e[s];r[n]=Qt()}return r}return i.count=0,e.highByte===0?Bb(t,i):i}var Bb=(e,t)=>function(){let i=Pe[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=St[r]||W2()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=ny(s,e)),s.read()};function W2(){let e=Z2(()=>(Pe=null,wr.getStructures()));return St=wr._mergeStructures(e,St)}var ev=sf,U6=sf,F6=sf,V6=sf;function sf(e){let t;if(e<16&&(t=oy(e)))return t;if(e>64&&Kg)return Kg.decode(Pe.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=Pe[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let a=Pe[K++]&63;r.push((s&31)<<6|a)}else if((s&240)===224){let a=Pe[K++]&63,n=Pe[K++]&63;r.push((s&31)<<12|a<<6|n)}else if((s&248)===240){let a=Pe[K++]&63,n=Pe[K++]&63,o=Pe[K++]&63,l=(s&7)<<18|a<<12|n<<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+=Ti.apply(String,r),r.length=0)}return r.length>0&&(t+=Ti.apply(String,r)),t}function zb(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Qt();return t}function kb(e){if(wr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[Y2()]=Qt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Qt(),Qt());return t}}var Ti=String.fromCharCode;function q2(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=Pe[K++];if((s&128)>0){K=t;return}i[r]=s}return Ti.apply(String,i)}function oy(e){if(e<4)if(e<2){if(e===0)return"";{let t=Pe[K++];if((t&128)>1){K-=1;return}return Ti(t)}}else{let t=Pe[K++],i=Pe[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return Ti(t,i);let r=Pe[K++];if((r&128)>0){K-=3;return}return Ti(t,i,r)}else{let t=Pe[K++],i=Pe[K++],r=Pe[K++],s=Pe[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return Ti(t,i,r,s);{let a=Pe[K++];if((a&128)>0){K-=5;return}return Ti(t,i,r,s,a)}}else if(e<8){let a=Pe[K++],n=Pe[K++];if((a&128)>0||(n&128)>0){K-=6;return}if(e<7)return Ti(t,i,r,s,a,n);let o=Pe[K++];if((o&128)>0){K-=7;return}return Ti(t,i,r,s,a,n,o)}else{let a=Pe[K++],n=Pe[K++],o=Pe[K++],l=Pe[K++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return Ti(t,i,r,s,a,n,o,l);{let h=Pe[K++];if((h&128)>0){K-=9;return}return Ti(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=Pe[K++],u=Pe[K++];if((h&128)>0||(u&128)>0){K-=10;return}if(e<11)return Ti(t,i,r,s,a,n,o,l,h,u);let c=Pe[K++];if((c&128)>0){K-=11;return}return Ti(t,i,r,s,a,n,o,l,h,u,c)}else{let h=Pe[K++],u=Pe[K++],c=Pe[K++],d=Pe[K++];if((h&128)>0||(u&128)>0||(c&128)>0||(d&128)>0){K-=12;return}if(e<14){if(e===12)return Ti(t,i,r,s,a,n,o,l,h,u,c,d);{let p=Pe[K++];if((p&128)>0){K-=13;return}return Ti(t,i,r,s,a,n,o,l,h,u,c,d,p)}}else{let p=Pe[K++],f=Pe[K++];if((p&128)>0||(f&128)>0){K-=14;return}if(e<15)return Ti(t,i,r,s,a,n,o,l,h,u,c,d,p,f);let m=Pe[K++];if((m&128)>0){K-=15;return}return Ti(t,i,r,s,a,n,o,l,h,u,c,d,p,f,m)}}}}}function gm(e){return wr.copyBuffers?Uint8Array.prototype.slice.call(Pe,K,K+=e):Pe.subarray(K,K+=e)}function Gn(e){let t=Pe[K++];if(pr[t])return pr[t](Pe.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var Nb=new Array(4096);function Y2(){let e=Pe[K++];if(e>=160&&e<192){if(e=e-160,Xs>=K)return mn.slice(K-Jr,(K+=e)-Jr);if(!(Xs==0&&An<180))return ev(e)}else return K--,Qt();let t=(e<<5^(e>1?Mt.getUint16(K):e>0?Pe[K]:0))&4095,i=Nb[t],r=K,s=K+e-3,a,n=0;if(i&&i.bytes==e){for(;r<s;){if(a=Mt.getUint32(r),a!=i[n++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(a=Pe[r++],a!=i[n++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],Nb[t]=i,i.bytes=e;r<s;)a=Mt.getUint32(r),i.push(a),r+=4;for(s+=3;r<s;)a=Pe[r++],i.push(a);let o=e<16?oy(e):q2(e);return o!=null?i.string=o:i.string=ev(e)}var Ub=(e,t)=>{var i=Qt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=St[e];return s&&s.isShared&&((St.restoreStructures||(St.restoreStructures=[]))[e]=s),St[e]=i,i.read=ny(i,r),i.read()},X2=typeof self=="object"?self:global;pr[0]=()=>{};pr[0].noBuffer=!0;pr[101]=()=>{let e=Qt();return(X2[e[0]]||Error)(e[1])};pr[105]=e=>{let t=Mt.getUint32(K-4);Na||(Na=new Map);let i=Pe[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Na.set(t,s);let a=Qt();return s.used?Object.assign(r,a):(s.target=a,a)};pr[112]=e=>{let t=Mt.getUint32(K-4),i=Na.get(t);return i.used=!0,i.target};pr[115]=()=>new Set(Qt());var Q2=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");pr[116]=e=>{let t=e[0],i=Q2[t];if(!i)throw new Error("Could not find typed array for code "+t);return new X2[i](Uint8Array.prototype.slice.call(e,1).buffer)};pr[120]=()=>{let e=Qt();return new RegExp(e[0],e[1])};pr[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,zr=[Qt(),Qt()],zr.position0=0,zr.position1=0;let r=K;K=i;try{return Qt()}finally{K=r}};pr[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 Z2(e){let t=An,i=K,r=$g,s=Jr,a=Xs,n=mn,o=Jg,l=Na,h=zr,u=new Uint8Array(Pe.slice(0,An)),c=St,d=St.slice(0,St.length),p=wr,f=Jl,m=e();return An=t,K=i,$g=r,Jr=s,Xs=a,mn=n,Jg=o,Na=l,zr=h,Pe=u,Jl=f,St=c,St.splice(0,St.length,...d),wr=p,Mt=new DataView(Pe.buffer,Pe.byteOffset,Pe.byteLength),m}function tv(){Pe=null,Na=null,St=null}function j6(e){e.unpack?pr[e.type]=e.unpack:pr[e.type]=e}var ly=new Array(147);for(let e=0;e<256;e++)ly[e]=+("1e"+Math.floor(45.15-e*.30103));var af=new pp({useRecords:!1}),fQ=af.unpack,mQ=af.unpackMultiple,gQ=af.unpack,G6={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},H6=new Float32Array(1),vQ=new Uint8Array(H6.buffer,0,4),ku;try{ku=new TextEncoder}catch{}var fp,hy,nf=typeof Buffer<"u",vm=nf?Buffer.allocUnsafeSlow:Uint8Array,K2=nf?Buffer:Uint8Array,Fb=nf?4294967296:2144337920,ce,$t,te=0,Ps,Is=null,W6=/[\u0080-\uFFFF]/,jh=Symbol("record-id"),J2=class extends pp{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n,o=0,l=K2.prototype.utf8Write?function(_,S,M){return ce.utf8Write(_,S,M)}:ku&&ku.encodeInto?function(_,S){return ku.encodeInto(_,ce.subarray(S)).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,m=d+64,g=d+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(_,S){if(ce||(ce=new vm(8192),$t=new DataView(ce.buffer,0,8192),te=0),Ps=ce.length-10,Ps-te<2048?(ce=new vm(ce.length),$t=new DataView(ce.buffer,0,ce.length),Ps=ce.length-10,te=0):te=te+7&2147483640,i=te,n=h.structuredClone?new Map:null,h.bundleStrings?(Is=["",""],ce[te++]=214,ce[te++]=98,Is.position=te-i,te+=4):Is=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 D,P=r.transitions;for(let I=0,R=T.length;I<R;I++){let U=T[I];D=P[U],D||(D=P[U]=Object.create(null)),P=D}P[jh]=C+64}o=M}u||(r.nextId=M+64)}s&&(s=!1),a=r||[];try{if(b(_),Is){$t.setUint32(Is.position+i,te-Is.position-i);let M=Is;Is=null,b(M[0]),b(M[1])}if(h.offset=te,n&&n.idsToInsert){te+=n.idsToInsert.length*6,te>Ps&&A(te),h.offset=te;let M=Y6(ce.subarray(i,te),n.idsToInsert);return n=null,M}return S&X6?(ce.start=i,ce.end=te,ce):ce.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=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][jh]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||d;r.length>M&&(r=r.slice(0,M));let C=ce.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(_)):(o=M,C)}}S&Q6&&(te=i)}};let b=_=>{te>Ps&&(ce=A(te));var S=typeof _,M;if(S==="string"){let C=_.length;if(Is&&C>=8&&C<4096){let P=W6.test(_);Is[P?0:1]+=_,ce[te++]=193,b(P?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let D=C*3;if(te+D>Ps&&(ce=A(te+D)),C<64||!l){let P,I,R,U=te+T;for(P=0;P<C;P++)I=_.charCodeAt(P),I<128?ce[U++]=I:I<2048?(ce[U++]=I>>6|192,ce[U++]=I&63|128):(I&64512)===55296&&((R=_.charCodeAt(P+1))&64512)===56320?(I=65536+((I&1023)<<10)+(R&1023),P++,ce[U++]=I>>18|240,ce[U++]=I>>12&63|128,ce[U++]=I>>6&63|128,ce[U++]=I&63|128):(ce[U++]=I>>12|224,ce[U++]=I>>6&63|128,ce[U++]=I&63|128);M=U-te-T}else M=l(_,te+T,D);M<32?ce[te++]=160|M:M<256?(T<2&&ce.copyWithin(te+2,te+1,te+1+M),ce[te++]=217,ce[te++]=M):M<65536?(T<3&&ce.copyWithin(te+3,te+2,te+2+M),ce[te++]=218,ce[te++]=M>>8,ce[te++]=M&255):(T<5&&ce.copyWithin(te+5,te+3,te+3+M),ce[te++]=219,$t.setUint32(te,M),te+=4),te+=M}else if(S==="number")if(_>>>0===_)_<64?ce[te++]=_:_<256?(ce[te++]=204,ce[te++]=_):_<65536?(ce[te++]=205,ce[te++]=_>>8,ce[te++]=_&255):(ce[te++]=206,$t.setUint32(te,_),te+=4);else if(_>>0===_)_>=-32?ce[te++]=256+_:_>=-128?(ce[te++]=208,ce[te++]=_+256):_>=-32768?(ce[te++]=209,$t.setInt16(te,_),te+=2):(ce[te++]=210,$t.setInt32(te,_),te+=4);else{let C;if((C=this.useFloat32)>0&&_<4294967296&&_>=-2147483648){ce[te++]=202,$t.setFloat32(te,_);let T;if(C<4||(T=_*ly[(ce[te]&127)<<1|ce[te+1]>>7])>>0===T){te+=4;return}else te--}ce[te++]=203,$t.setFloat64(te,_),te+=8}else if(S==="object")if(!_)ce[te++]=192;else{if(n){let T=n.get(_);if(T){if(!T.id){let D=n.idsToInsert||(n.idsToInsert=[]);T.id=D.push(T)}ce[te++]=214,ce[te++]=112,$t.setUint32(te,T.id),te+=4;return}else n.set(_,{offset:te-i})}let C=_.constructor;if(C===Object)w(_,!0);else if(C===Array){M=_.length,M<16?ce[te++]=144|M:M<65536?(ce[te++]=220,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=221,$t.setUint32(te,M),te+=4);for(let T=0;T<M;T++)b(_[T])}else if(C===Map){M=_.size,M<16?ce[te++]=128|M:M<65536?(ce[te++]=222,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=223,$t.setUint32(te,M),te+=4);for(let[T,D]of _)b(T),b(D)}else{for(let T=0,D=fp.length;T<D;T++){let P=hy[T];if(_ instanceof P){let I=fp[T];if(I.write){I.type&&(ce[te++]=212,ce[te++]=I.type,ce[te++]=0),b(I.write.call(this,_));return}let R=ce,U=$t,N=te;ce=null;let L;try{L=I.pack.call(this,_,W=>(ce=R,R=null,te+=W,te>Ps&&A(te),{target:ce,targetView:$t,position:te-W}),b)}finally{R&&(ce=R,$t=U,te=N,Ps=ce.length-10)}L&&(L.length+te>Ps&&A(L.length+te),te=q6(L,ce,te,I.type));return}}w(_,!_.hasOwnProperty)}}else if(S==="boolean")ce[te++]=_?195:194;else if(S==="bigint"){if(_<BigInt(1)<<BigInt(63)&&_>=-(BigInt(1)<<BigInt(63)))ce[te++]=211,$t.setBigInt64(te,_);else if(_<BigInt(1)<<BigInt(64)&&_>0)ce[te++]=207,$t.setBigUint64(te,_);else if(this.largeBigIntToFloat)ce[te++]=203,$t.setFloat64(te,Number(_));else throw new RangeError(_+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(S==="undefined")this.encodeUndefinedAsNil?ce[te++]=192:(ce[te++]=212,ce[te++]=0,ce[te++]=0);else if(S==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+S)},w=this.useRecords===!1?this.variableMapSize?_=>{let S=Object.keys(_),M=S.length;M<16?ce[te++]=128|M:M<65536?(ce[te++]=222,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=223,$t.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)b(C=S[T]),b(_[C])}:(_,S)=>{ce[te++]=222;let M=te-i;te+=2;let C=0;for(let T in _)(S||_.hasOwnProperty(T))&&(b(T),b(_[T]),C++);ce[M+++i]=C>>8,ce[M+i]=C&255}:_=>{let S=Object.keys(_),M,C=a.transitions||(a.transitions=Object.create(null)),T=0;for(let P=0,I=S.length;P<I;P++){let R=S[P];M=C[R],M||(M=C[R]=Object.create(null),T++),C=M}let D=C[jh];if(D)D>=96&&f?(ce[te++]=((D-=96)&31)+96,ce[te++]=D>>5):ce[te++]=D;else{D=a.nextId,D||(D=64),D<m&&this.shouldShareStructure&&!this.shouldShareStructure(S)?(D=a.nextOwnId,D<g||(D=m),a.nextOwnId=D+1):(D>=g&&(D=m),a.nextId=D+1);let P=S.highByte=D>=96&&f?D-96>>5:-1;C[jh]=D,a[D-64]=S,D<m?(S.isShared=!0,a.sharedLength=D-63,s=!0,P>=0?(ce[te++]=(D&31)+96,ce[te++]=P):ce[te++]=D):(P>=0?(ce[te++]=213,ce[te++]=114,ce[te++]=(D&31)+96,ce[te++]=P):(ce[te++]=212,ce[te++]=114,ce[te++]=D),T&&(y+=x*T),v.length>=p&&(v.shift()[jh]=0),v.push(C),b(S))}for(let P=0,I=S.length;P<I;P++)b(_[S[P]])},A=_=>{let S;if(_>16777216){if(_-i>Fb)throw new Error("Packed buffer would be larger than maximum buffer size");S=Math.min(Fb,Math.round(Math.max((_-i)*(_>67108864?1.25:2),4194304)/4096)*4096)}else S=(Math.max(_-i<<2,ce.length-1)>>12)+1<<12;let M=new vm(S);return $t=new DataView(M.buffer,0,S),ce.copy?ce.copy(M,0,i,_):M.set(ce.slice(i,_)),te-=i,i=0,Ps=M.length-10,ce=M}}useBuffer(e){ce=e,$t=new DataView(ce.buffer,ce.byteOffset,ce.byteLength),te=0}};hy=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,G2];fp=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:a,position:n}=t(6);s[n++]=214,s[n++]=255,a.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:s,targetView:a,position:n}=t(10);s[n++]=215,s[n++]=255,a.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),a.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:a,position:n}=t(3);s[n++]=212,s[n++]=255,s[n++]=255}else{let{target:s,targetView:a,position:n}=t(15);s[n++]=199,s[n++]=12,s[n++]=255,a.setUint32(n,e.getMilliseconds()*1e6),a.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(s[a++]=212,s[a++]=115,s[a++]=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?Vb(e,16,t):jb(nf?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==K2&&this.structuredClone?Vb(e,Q2.indexOf(i.name),t):jb(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function Vb(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:a,position:n}=i(4+s);a[n++]=199,a[n++]=s+1}else if(s+1<65536){var{target:a,position:n}=i(5+s);a[n++]=200,a[n++]=s+1>>8,a[n++]=s+1&255}else{var{target:a,position:n,targetView:o}=i(7+s);a[n++]=201,o.setUint32(n,s+1),n+=4}a[n++]=116,a[n++]=t,a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function jb(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:a}=t(i+5);r[s++]=198,a.setUint32(s,i),s+=4}r.set(e,s)}function q6(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 Y6(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((a,n)=>a.offset>n.offset?1:-1);i=t.pop();){let a=i.offset,n=i.id;e.copyWithin(a+r,a,s),r-=6;let o=a+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,s=a}return e}function wh(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)");hy.unshift(e.Class),fp.unshift(e)}j6(e)}var $2=new J2({useRecords:!1}),yQ=$2.pack,xQ=$2.pack,{NEVER:bQ,ALWAYS:wQ,DECIMAL_ROUND:_Q,DECIMAL_FIT:SQ}=G6,X6=512,Q6=1024,Gb=new J2({structuredClone:!0});wh({Class:ot.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,ot.prototype),e}});wh({Class:We.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,We.prototype),e}});wh({Class:Er.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,Er.prototype),e}});wh({Class:Ib.prototype.constructor,type:4,write(e){return e.id},read(e){return new Ib(e)}});wh({Class:Ob.prototype.constructor,type:5,write(e){return e.data},read(e){return new Ob(e)}});wh({Class:_i.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,_i.prototype),e}});function Z6(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 iv(e){if(ty(e))return e;if(Array.isArray(e))return e.map(iv);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=iv(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var rv;(e=>{function t(s){return Gb.pack(s)}e.serialize=t;function i(s){return Gb.unpack(s)}e.deserialize=i;function r(s){return Z6(t(iv(s))).toString()}e.checksum=r})(rv||(rv={}));var Hb;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(Hb||(Hb={}));var Br={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Create","SetVariable","DynamicVariablePlay","Conditional"],MouseHover:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],Start:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Conditional:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MousePress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyPress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],GameControl:["Transition","Animation","Audio","Create","Conditional"],Collision:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],Trigger:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Resize:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],VariableChange:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},Wb;(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,mode:"Object",disabled:!1,runMode:"Once",actions:new We}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new We}}e.defaultData=i})(Wb||(Wb={}));var mp;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(mp||(mp={}));var sv;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:mp.propertyDefaultData(s),rOperand:{...mp.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,a){return{type:"State",object:s??null,state:a??null}}e.stateDefaultData=r})(sv||(sv={}));var qb;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new We,outActions:new We,condition:sv.distanceDefaultData(r)}}e.defaultData=i})(qb||(qb={}));var Yb;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new We,drop:new We}})(Yb||(Yb={}));var av;(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,actions:new We})(av||(av={}));var nv;(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})(nv||(nv={}));var Xb;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new We}}e.defaultData=i})(Xb||(Xb={}));var Qb;(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 We}}e.defaultData=i})(Qb||(Qb={}));var Zb;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new We}}e.defaultData=i})(Zb||(Zb={}));var Kb;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new We}}e.defaultData=i})(Kb||(Kb={}));var Jb;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new We,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(Jb||(Jb={}));var ov;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function s(){let n={size:"mobile",operator:"<",actions:new We},o={size:"tablet",operator:"<",actions:new We},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new We},h=new We;return h.push({id:Le.generateUUID(),fi:0,data:n},{id:Le.generateUUID(),fi:1,data:o},{id:Le.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function a(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new We}}e.defaultBreakpointData=a})(ov||(ov={}));var lv;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new We,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(lv||(lv={}));var _h="personal camera",wc="a218fcc3-276b-49b9-b485-49037fd14f5f",K6=2960946,as=5526619,El;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a]}e.lerp=i})(El||(El={}));var fo;(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 a(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=a;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;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})(fo||(fo={}));var gp;(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,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a,r[2]+(s[2]-r[2])*a,r[3]+(s[3]-r[3])*a]}e.lerp=i})(gp||(gp={}));var $l;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let n=0;n<16;n++)if(s[n]!==a[n])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,a){let n=a.slice(0);for(var o=0,l=a.length;o<l;o+=3){let h=s[3]*a[o]+s[7]*a[o+1]+s[11]*a[o+2]+s[15];n[o]=(s[0]*a[o]+s[4]*a[o+1]+s[8]*a[o+2]+s[12])/h,n[o+1]=(s[1]*a[o]+s[5]*a[o+1]+s[9]*a[o+2]+s[13])/h,n[o+2]=(s[2]*a[o]+s[6]*a[o+1]+s[10]*a[o+2]+s[14])/h}return n}e.applyMatrix4=r})($l||($l={}));var rr;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.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(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function a(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=a;function n(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=n;function o(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}}e.lerp=o})(rr||(rr={}));var bs;(e=>{e.white={...rr.white,a:1},e.transparent={...rr.white,a:0};function t(n){return{r:n[0],g:n[1],b:n[2],a:n[3]}}e.from0to1=t;function i(n,o){return{...rr.fromHex(n),a:o}}e.fromHexAndA=i;function r(n){return{r:Math.round(n.r*255),g:Math.round(n.g*255),b:Math.round(n.b*255),a:n.a}}e.toRgb255a1=r;function s(n,o){return rr.equals(n,o)&&n.a===o.a}e.equals=s;function a(n,o,l){return{r:n.r+(o.r-n.r)*l,g:n.g+(o.g-n.g)*l,b:n.b+(o.b-n.b)*l,a:n.a+(o.a-n.a)*l}}e.lerp=a})(bs||(bs={}));var hv;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(hv||(hv={}));var $b;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})($b||($b={}));var ew;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(ew||(ew={}));var ln;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(ln||(ln={}));function J6(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var So;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(So||(So={}));var eh;(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},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(eh||(eh={}));var gn;(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(a=>a*(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 a={...r};if(eM.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;tM.forEach(l=>{Object.assign(a.radial,{[l]:o[l]??n[l]})})}if(a.linear={...r.linear},s.linear){let n=r.linear,o=s.linear;iM.forEach(l=>{Object.assign(a.linear,{[l]:o[l]??n[l]})})}if(a.grid={...r.grid},s.grid){let n=r.grid,o=s.grid;rM.forEach(l=>{Object.assign(a.grid,{[l]:o[l]??n[l]})})}if(a.toObject={...r.toObject},s.toObject){let n=r.toObject,o=s.toObject;sM.forEach(l=>{Object.assign(a.toObject,{[l]:o[l]??n[l]})})}if(a.randomnessObject={...r.randomnessObject},s.randomnessObject){let n=r.randomnessObject,o=s.randomnessObject;aM.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(gn||(gn={}));var cv;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let a=[];r.count!==void 0&&a.push({type:0,path:s,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&a.push({type:0,path:[...s,n],props:o})}return a}e.toOps=i})(cv||(cv={}));var eM=["count"],tM=["radius","start","end","position","scale","rotation"],iM=["position","scale","rotation"],rM=["count","size"],sM=["count","position","scale","rotation"],aM=["strength","scale","rotation","position","movement","seed","freqScale"],dv;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(dv||(dv={}));var uv;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:bs.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:bs.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:bs.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(uv||(uv={}));var th;(e=>e.defaultData={enabled:"visibility",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]})(th||(th={}));var pv;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(pv||(pv={}));var fv;(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})(fv||(fv={}));var mv;(e=>e.defaultData={...fv.defaultData,...pv.defaultData})(mv||(mv={}));var tw;(e=>{function t(i,r){let s=[];if("material"in i){let a=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;a&&s.push(a)}else if("materials"in i)for(let a of i.materials){let n=typeof a=="string"?r.materials[a]??r.lib.materials[a]?.asset:a;n&&s.push(n)}return s}e.getMaterialData=t})(tw||(tw={}));var vp;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(vp||(vp={}));var iw;(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==="pattern"||i==="light"}e.is=t})(iw||(iw={}));function $6(e){return e.type!=="displace"}var rw;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(rw||(rw={}));var nM=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],eV=["wrapping","image","video","name"],xr;(e=>{function t(a,n){let{texture:o,...l}=n;if(Object.assign(a,l),o){let h=a.texture;h&&Object.assign(h,o)}}e.patch=t;function i(a,n){return a==="light"&&n?r(n):s(a)}e.defaultData=i;function r(a){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(a){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...n,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:vp.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...n,type:"color",color:rr.fromHex(as)};case"depth":return{...n,type:"depth",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{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,type:"gradient",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{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...rr.fromHex(6710886),a:1},colorB:{...rr.fromHex(6710886),a:1},colorC:{...rr.fromHex(16777215),a:1},colorD:{...rr.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...n,type:"fresnel",color:bs.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,type:"toon",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:bs.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:bs.fromHexAndA(0,1),contourColor:bs.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{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...n,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...rr.fromHex(0),a:1},colorB:{...rr.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(xr||(xr={}));var Yi;(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 We}}e.defaultEmptyData=r;function s(h="layer1",u="layer2"){return n("phong",h,u)}e.defaultData=s;function a(h,u){return{...h,name:u}}e.withName=a;function n(h,u="layer1",c="layer2"){let d=new We;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=n;function o(h,u="phong",c="layer1",d="layer2"){let p=xr.defaultData("texture");Object.assign(p.texture,{image:h});let f=new We;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 We;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})(Yi||(Yi={}));var yp;(e=>{function t(){return{points:new We,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(yp||(yp={}));var xp;(e=>{function t(){return{points:new We,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(xp||(xp={}));var oM={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},gv;(e=>{function t(i,r){let s={...i};return hM.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(gv||(gv={}));var lM={shape:oM,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},hM=["depth","offset","angle","twist","startScale","endScale"],bp;(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})(bp||(bp={}));var vv;(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,gv.merge(s.extrusion,r.extrusion))),s}e.merge=t})(vv||(vv={}));var Ol;(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:xp.defaultData(),extrusion:lM};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:yp.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:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(Ol||(Ol={}));var sw=["width","height","depth"],yv;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:rr.white,near:.1,far:2e3})(yv||(yv={}));var wp;(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}}})(wp||(wp={}));var xv;(e=>e.defaultData={softShadowQuality:"low"})(xv||(xv={}));var bv;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(bv||(bv={}));var wv;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(wv||(wv={}));var ih;(e=>e.defaultData={usePhysics:!1,gravity:-10})(ih||(ih={}));var _v;(e=>e.defaultData={playCamera:_h,gameControlObject:null})(_v||(_v={}));var Sv;(e=>e.defaultData={backgroundColor:bs.fromHexAndA(K6,1),postprocessing:wp.defaultData,fog:yv.defaultData,globalPhysics:ih.defaultData,ambient:bv.defaultData,ao:wv.defaultData,shadow:xv.defaultData,publish:_v.defaultData})(Sv||(Sv={}));var aw;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(aw||(aw={}));var rh;(e=>{e.identity={...hv.identity,hiddenMatrix:$l.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,a){return{position:a?.position||s.position,rotation:a?.rotation||s.rotation,scale:a?.scale||s.scale,hiddenMatrix:a?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,a){return o6({position:fo.isEqual(s.position,a.position)?void 0:a.position,rotation:fo.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:fo.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:$l.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(rh||(rh={}));var ur;(e=>e.defaultData={states:new We,events:new We,visible:!0,raycastLock:!1,physics:th.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...rh.identity,cloner:null})(ur||(ur={}));var Av;(e=>e.defaultData={type:"Empty",...ur.defaultData})(Av||(Av={}));var nw;(e=>e.defaultData={type:"Component",...ur.defaultData})(nw||(nw={}));var Rl;(e=>e.defaultData={type:"Mesh",...ur.defaultData,...mv.defaultData})(Rl||(Rl={}));var Uc;(e=>e.defaultData={...ur.defaultData,...rh.identity,position:[0,0,eh.DefaultTargetOffset],...eh.defaultData})(Uc||(Uc={}));var Mv;(e=>{function t(i){return{...ur.defaultData,...uv.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Mv||(Mv={}));var _p;(e=>{function t(r,s,a=0){for(;a<s.length;){let n=r?r[s[a]]:void 0;if(s.length===a+1)return n;if(n)r=n.descendants,a+=1;else return}}e.resolveWithDes=t;function i(r,s,a=0){let n=t(r,s,a);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})(_p||(_p={}));var vn;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...ur.defaultData,...s,component:r,overrides:new _i,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=rh.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(vn||(vn={}));var sh;(e=>e.defaultData={type:"Page",...ur.defaultData,physics:{...th.defaultData,fusedBody:!1},...Sv.defaultData,camera:Uc.defaultData})(sh||(sh={}));var Ev;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:$l.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:th.defaultData,states:new We,events:new We,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...eh.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",...ur.defaultData,...Rl.defaultData,geometry:Ol.defaultData("RectangleGeometry"),material:Yi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...ur.defaultData,...Rl.defaultData,geometry:Ol.defaultData("BooleanGeometry"),material:Yi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...ur.defaultData,...Rl.defaultData,geometry:Ol.defaultData("TextGeometry"),material:Yi.defaultTwoLayerData("phong","layer1","layer2")}))(Ev||(Ev={}));var so;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new _i}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new _i})))):So.is(a.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(a,n){if(n===void 0)return a;let o={...a};return"material"in o&&"material"in n&&n.material&&(o.material=Nc(o.material,l=>{if(typeof l!="string")for(let[h,u]of Object.entries(n.material.layers)){let c=l.layers.data(h);c&&xr.patch(c,u)}}).data),o.materials&&n.materials&&(o.materials=Nc(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let u=n.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(a,n){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:m,...g}=f;if(m!==void 0&&Object.keys(m).length>0){let v={path:[...c,"layers",p,"texture"],props:m,type:0};l.push(v)}if(Object.keys(g).length>0){let v={path:[...c,"layers",p],props:g,type:0};l.push(v)}}}for(let[c,d]of Object.entries(n))if(c!=="name")if(c==="cloner")l.push(...cv.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(a,n){if(n===void 0)return a;let o={...a};if(Object.assign(o,rh.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),So.is(a.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;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(a.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:vv.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:gn.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:gn.merge(o.cloner,n.cloner)});else if(dv.is(a.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=rr.clone(l.color))}return o}e.patch=s})(so||(so={}));var Sp;(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,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Sp||(Sp={}));var mo;(e=>e.defaultData={orbitControls:Sp.defaultData,playPage:wc,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",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"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,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,hdTransmission:!1})(mo||(mo={}));var Cv;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Cv||(Cv={}));var Tv;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Tv||(Tv={}));var Ll;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Cv.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Tv.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ll||(Ll={}));var Fc;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,a){r.scene.objects.traverseFrom(s,(n,o)=>{if(o.type==="Instance"){let l=Cp.getComponentData(r,o.component)?.data;l&&a(n,o,l.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(Fc||(Fc={}));var Bl;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let a=[],n=Ev.defaultMeshObject;s.withLight===!0&&a.push({fi:-1,data:Mv.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&a.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:n,children:[]});let o=new Er;return o.push({fi:1,id:wc,data:{...sh.defaultData,name:"Scene 1"},children:a}),o}e.defaultData={objects:t(),publish:mo.defaultData,styles:Ll.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new Er,publish:mo.defaultData,styles:Ll.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:mo.defaultData,styles:Ll.defaultData()}};function i(s){return{...e.defaultData,objects:Va(s,Er.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(Bl||(Bl={}));var _c;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(_c||(_c={}));var Ap;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Ap||(Ap={}));var Fr;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function s(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=s;function a(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=a})(Fr||(Fr={}));var Dv;(e=>e.all=["images","videos","colors","audios","fonts","materials","variables"])(Dv||(Dv={}));var ow;(e=>e.all=[...Dv.all,"components"])(ow||(ow={}));var lw;(e=>{function t(){return{images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,materials:new ot,components:new ot,variables:new ot}}e.defaultData=t})(lw||(lw={}));var ah;(e=>{function t(){return{images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,materials:new ot,components:new ot,variables:new ot}}e.defaultData=t})(ah||(ah={}));var vs;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Va(n,ot.prototype)}e.defaultColors=t;function i(n){let o={};return n?.withAITexture&&(o["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Ap.emptyImage,name:"AI generated image"}),Va(o,ot.prototype)}e.defaultImages=i;function r(){return{catelogs:new ot,materials:new ot,images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,variables:new We,lib:ah.defaultData()}}e.emptyData=r;function s(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=s;function a(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),u=Math.round(n-l*3600-h*60);return{textValue:[l,h,u]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=a})(vs||(vs={}));var Mp;(e=>e.list=["idle","move","jump","run"])(Mp||(Mp={}));var Ep;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,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"],["run","\u21E7"],["none","Ctrl"]],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 We,move:new We,jump:new We,run:new We},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:bs.fromHexAndA(3728051,1)}}))(Ep||(Ep={}));function hw(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]],a=[0,1];for(let o=2;o<10;o++)s.push(s[1]),a.push(1);let n={...ka(mi(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:a,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...mi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function hn(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function cn(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=Yi.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Yi.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Yi.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&t(s.material)})})}function tV(e){Object.assign(e.scene.publish,{orbitControls:{...Sp.defaultData,...mi(e.scene.publish.orbitControls)}})}function iV(e){Object.assign(e.scene.publish.settings,{video:{...mo.defaultData.settings.video,...mi(e.scene.publish.settings.video)}})}function rV(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,a]of Object.entries(r))if((nM.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(eV.includes(n)||typeof o=="boolean")&&delete a[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let a=s;a.material?t(a.material):a.materials&&a.materials.forEach(n=>{t(n)})})})}function sV(e){e.scene.publish.withBackground=!0}function aV(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function nV(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 oV(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 lV(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=mi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=mi(i).booleanExclude!==!0)}})}function hV(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 cV(e){function t(r){Object.setPrototypeOf(r,_i.prototype),r.texture&&Object.setPrototypeOf(r.texture,_i.prototype)}function i(r){Object.setPrototypeOf(r,_i.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(a=>{let n=a;if(n.material){let o=mi(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=mi(l).layers;i(h),l.layers=h}})})}function cw(e){e.layers===void 0&&Object.assign(e,Yi.defaultTwoLayerData("lambert"))}function ym(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={...mi(t),colors:i,steps:r};Object.assign(t,s)}})}function dV(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function dw(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&ym(r)}):"material"in i&&typeof i.material!="string"&&ym(i.material)}),Object.values(e.shared.materials).forEach(t=>ym(t))}function uV(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 pV(e){e.shared.audios=Va({},ot.prototype)}function fV(e){e.shared.videos=Va({},ot.prototype)}function mV(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 gV(e){Object.entries(mi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(mi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function vV(e){e.scene.publish.settings.web.preload=!1}function uw(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 pw(e){e.layers&&e.layers.forEach(t=>{$6(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function yV(e){e.shared.fonts=Va({},ot.prototype)}function xV(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 bV(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=Yi.defaultTwoLayerData("phong"),n=typeof s.color=="string"?e.shared.colors[s.color]:s.color;a.layers[1].data.color={r:n.r,g:n.g,b:n.b},a.layers[1].data.alpha=s.alpha;let o=xV(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...ur.defaultData,...Rl.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ol.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:a,states:mi(s.states),events:mi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=mi(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 wV(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 We,move:new We,jump:new We}});else{let a=new We;Object.assign(s,{actions:a}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&a.push({fi:0,id:Le.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(u,ka(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(u,{control1:{...n.control1},control2:{...n.control2}});let c={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},d={state:n.state,...c,...u},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new We({fi:0,id:Le.generateUUID(),data:h},{fi:1,id:Le.generateUUID(),data:d})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function _V(e){e.scene.objects.traverse((t,i)=>{function r(s,a){let n=new We,o=[];if(i.events.forEach((l,h,u)=>{if(l.type==="Audio"&&l.trigger===a){let c;o.push(h),l.interaction==="play"?c={...ka(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={...ka(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&n.push({fi:u,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:Le.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function fw(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 mw(e){hn(e,fw),cn(e,fw)}function SV(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function AV(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 MV(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=Yi.defaultTwoLayerData("phong"))})}function EV(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 CV(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 TV(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 DV(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function PV(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function IV(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function OV(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Ep.defaultDataThirdPerson.navmesh)})})}function RV(e){e.scene.styles||(e.scene.styles=Ll.defaultData())}function gw(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function LV(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),cn(e,gw),hn(e,gw)}function BV(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new We})})})}function zV(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function vw(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function kV(e,t){if(t<1&&(cn(e,hw),hn(e,hw),e.schema=1),t<2&&(tV(e),e.schema=2),t<3&&(rV(e),e.schema=3),t<4&&(sV(e),e.schema=4),t<5&&(aV(e),e.schema=5),t<6&&(nV(e),e.schema=6),t<7&&(oV(e),e.schema=7),t<8&&(e.schema=8),t<9&&(dw(e),e.schema=9),t<10&&(dV(e),e.schema=10),t<11&&(uV(e),e.schema=11),t<12&&(dw(e),e.schema=12),t<13&&(pV(e),e.schema=13),t<14&&(mV(e),e.schema=14),t<15&&(gV(e),e.schema=15),t<16&&(vV(e),e.schema=16),t<17&&(cn(e,uw),hn(e,uw),e.schema=17),t<18&&(cn(e,cw),hn(e,cw),e.schema=18),t<19&&(iV(e),e.schema=19),t<20&&(yV(e),bV(e),e.schema=20),t<21&&(wV(e),_V(e),e.schema=21),t<22&&(mw(e),e.schema=22),t<23&&(SV(e),e.schema=23),t<24&&(AV(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(fV(e),t<25&&(e.schema=25)),t<26&&(lV(e),e.schema=26),t<27&&(hV(e),e.schema=27),t<28&&(mw(e),e.schema=28),t<29&&(cV(e),e.schema=29),t<30&&(MV(e),e.schema=30),t<31&&(EV(e),e.schema=31),t<33&&(CV(e),e.schema=33),t<34&&(TV(e),e.schema=34),t<35&&(DV(e),e.schema=35),t<36&&(PV(e),e.schema=36),t<37&&(IV(e),e.schema=37),t<38&&(cn(e,pw),hn(e,pw),e.schema=38),t<39&&(OV(e),e.schema=39),t<40&&(RV(e),e.schema=40),t<41&&(LV(e),e.schema=41),t<42&&(BV(e),e.schema=42),t<43&&(zV(e),e.schema=43),t<99){cn(e,vw),hn(e,vw),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=_h);let i=mi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=wc,r.insertBefore(null,null,[{id:wc,data:{...sh.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:ka(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:ka(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...ih.defaultData,...ka(e.scene.environment,"usePhysics","gravity")},camera:mi(e.scene.ownerCamera)??sh.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==Bl.TRASH_CAN_ID&&r.move(wc,n.fi,n.id);let s=0,a=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(a,1)],a+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,th.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function yw(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function NV(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}var vl=180/Math.PI;function xw(e){e.rotation=e.rotation.slice(0,3).map(t=>t*vl)}function cM(e){xw(e),e.type==="Page"&&xw(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*vl))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*vl),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*vl),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=vl,t.extrusion.twist*=vl),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(mi(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Once")})}function UV(e){e.shared.variables=Va({},ot.prototype)}function FV(e){let t=mi(e.shared.variables);e.shared.variables=Va(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),We.prototype)}var dn=107;function dM(e,t){t(e.data);for(let i of e.children)dM(i,t)}function VV(e){let t=e.schema??104;t!==dn&&t<105&&(dM(e.asset,cM),e.schema=105)}function uM(e){let t=e.schema??0;if(t!==dn){console.warn("updating from ",t,"to ",dn),kV(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=mo.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(cn(e,yw),hn(e,yw),e.schema=101),t<102&&(NV(e),e.schema=102),t<104&&(e.shared.catelogs=new ot,e.shared.lib=ah.defaultData(),e.schema=104),t<105&&(UV(e),e.scene.objects.traverse((i,r)=>{cM(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))VV(i);t<106&&(FV(e),e.schema=106),t<107&&(e.shared.lib.variables=ah.defaultData().variables,e.schema=107)}}var Cp;(e=>{e.defaultData={schema:dn,scene:Bl.defaultData,frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",_c.defaultData),shared:{...vs.emptyData(),colors:vs.defaultColors()}},e.emptyDataForImports=function(s){let a=Bl.emptyDataWithPage(s);return{schema:dn,scene:a,frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",_c.defaultData),shared:{...vs.emptyData(),colors:vs.defaultColors(),images:vs.defaultImages(s)}}},e.emptyData=function(){return{schema:dn,scene:Bl.emptyDataWithPage(),frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",_c.defaultData),shared:vs.emptyData()}},e.collabHelper={...Zg,updateSchema(s){return(s.schema??0)<dn?Nc(s,uM):(s.schema??0)-dn}};function t(s){let a=e.collabHelper.updateSchema(s);return typeof a=="number"?a===0?s:null:a.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:ah.defaultData()}}}e.withoutLib=i;function r(s,a){let n=s.scene.objects.get(a);if(n&&n.data.type==="Component")return n;{let o=s.shared.lib.components[a];if(o)return o.asset}}e.getComponentData=r})(Cp||(Cp={}));function ao(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)),a={},n={},o=e[0].morphTargetsRelative,l=new Ue,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;a[p]===void 0&&(a[p]=[]),a[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;n[p]===void 0&&(n[p]=[]),n[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 a){let c=bw(a[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 n){let c=n[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 m=0;m<n[u].length;++m)p.push(n[u][m][d]);let f=bw(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 bw(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 a=new t(s),n=0;for(let o=0;o<e.length;++o)a.set(e[o].array,n),n+=e[o].array.length;return new Ze(a,i,r)}var jV=Math.pow(2,-24),Qd=class{constructor(){}};function Qs(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 ww(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 _w(e,t){t.set(e)}function Sw(e,t,i){let r,s;for(let a=0;a<3;a++){let n=a+3;r=e[a],s=t[a],i[a]=r<s?r:s,r=e[n],s=t[n],i[n]=r>s?r:s}}function Zd(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],a=t[e+2*r+1],n=s-a,o=s+a;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function Gh(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 GV(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 Ze(s,1));for(let a=0;a<i;a++)s[a]=a}}function HV(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,a)=>s-a);for(let s=0;s<r.length-1;s++){let a=r[s],n=r[s+1];t.push({offset:a/3,count:(n-a)/3})}return t}function xm(e,t,i,r,s=null){let a=1/0,n=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,m=-1/0,g=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let b=e[y+0],w=e[y+1],A=b-w,_=b+w;A<a&&(a=A),_>l&&(l=_),v&&b<c&&(c=b),v&&b>f&&(f=b);let S=e[y+2],M=e[y+3],C=S-M,T=S+M;C<n&&(n=C),T>h&&(h=T),v&&S<d&&(d=S),v&&S>m&&(m=S);let D=e[y+4],P=e[y+5],I=D-P,R=D+P;I<o&&(o=I),R>u&&(u=R),v&&D<p&&(p=D),v&&D>g&&(g=D)}r[0]=a,r[1]=n,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]=m,s[5]=g)}function WV(e,t,i,r){let s=1/0,a=1/0,n=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<a&&(a=p),p>l&&(l=p);let f=e[u+4];f<n&&(n=f),f>h&&(h=f)}r[0]=s,r[1]=a,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function qV(e,t,i,r,s){let a=i,n=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;a<=n&&t[a*6+l]<o;)a++;for(;a<=n&&t[n*6+l]>=o;)n--;if(a<n){for(let h=0;h<3;h++){let u=e[a*3+h];e[a*3+h]=e[n*3+h],e[n*3+h]=u;let c=t[a*6+h*2+0];t[a*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=c;let d=t[a*6+h*2+1];t[a*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=d}a++,n--}else return a}}var Sa=32,YV=(e,t)=>e.candidate-t.candidate,Ka=new Array(Sa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Kd=new Float32Array(6);function XV(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=ww(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=ww(e),n!==-1&&(o=QV(i,r,s,n));else if(a===2){let l=Gh(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)/Sa;if(s<Sa/4){let m=[...Ka];m.length=s;let g=0;for(let y=u;y<c;y+=6,g++){let x=m[g];x.candidate=i[y+2*d],x.count=0;let{bounds:b,leftCacheBounds:w,rightCacheBounds:A}=x;for(let _=0;_<3;_++)A[_]=1/0,A[_+3]=-1/0,w[_]=1/0,w[_+3]=-1/0,b[_]=1/0,b[_+3]=-1/0;Zd(y,i,b)}m.sort(YV);let v=s;for(let y=0;y<v;y++){let x=m[y];for(;y+1<v&&m[y+1].candidate===x.candidate;)m.splice(y+1,1),v--}for(let y=u;y<c;y+=6){let x=i[y+2*d];for(let b=0;b<v;b++){let w=m[b];x>=w.candidate?Zd(y,i,w.rightCacheBounds):(Zd(y,i,w.leftCacheBounds),w.count++)}}for(let y=0;y<v;y++){let x=m[y],b=x.count,w=s-x.count,A=x.leftCacheBounds,_=x.rightCacheBounds,S=0;b!==0&&(S=Gh(A)/l);let M=0;w!==0&&(M=Gh(_)/l);let C=1+1.25*(S*b+M*w);C<h&&(n=d,h=C,o=x.candidate)}}else{for(let v=0;v<Sa;v++){let y=Ka[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=u;v<c;v+=6){let y=~~((i[v+2*d]-p)/f);y>=Sa&&(y=Sa-1);let x=Ka[y];x.count++,Zd(v,i,x.bounds)}let m=Ka[Sa-1];_w(m.bounds,m.rightCacheBounds);for(let v=Sa-2;v>=0;v--){let y=Ka[v],x=Ka[v+1];Sw(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let g=0;for(let v=0;v<Sa-1;v++){let y=Ka[v],x=y.count,b=y.bounds,w=Ka[v+1].rightCacheBounds;x!==0&&(g===0?_w(b,Kd):Sw(b,Kd,Kd)),g+=x;let A=0,_=0;g!==0&&(A=Gh(Kd)/l);let S=s-g;S!==0&&(_=Gh(w)/l);let M=1+1.25*(A*g+_*S);M<h&&(n=d,h=M,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:o}}function QV(e,t,i,r){let s=0;for(let a=t,n=t+i;a<n;a++)s+=e[a*6+r*2];return s/i}function ZV(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,a=new Float32Array(s*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let u=["getX","getY","getZ"];for(let c=0;c<s;c++){let d=c*3,p=c*6,f,m,g;n?(f=r[d+0],m=r[d+1],g=r[d+2]):(f=r[d+0]*h+l,m=r[d+1]*h+l,g=r[d+2]*h+l);for(let v=0;v<3;v++){let y,x,b;n?(y=i[u[v]](f),x=i[u[v]](m),b=i[u[v]](g)):(y=o[f+v],x=o[m+v],b=o[g+v]);let w=y;x<w&&(w=x),b<w&&(w=b);let A=y;x>A&&(A=x),b>A&&(A=b);let _=(A-w)/2,S=v*2;a[p+S+0]=w+_,a[p+S+1]=_+(Math.abs(w)+_)*jV,w<t[v]&&(t[v]=w),A>t[v+3]&&(t[v+3]=A)}}return a}function KV(e,t){function i(v){d&&d(v/p)}function r(v,y,x,b=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))),x<=u||w>=l)return i(y+x),v.offset=y,v.count=x,v;let A=XV(v.boundingData,b,n,y,x,c);if(A.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let _=qV(o,n,y,x,A);if(_===y||_===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=A.axis;let S=new Qd,M=y,C=_-y;v.left=S,S.boundingData=new Float32Array(6),xm(n,M,C,S.boundingData,a),r(S,M,C,a,w+1);let T=new Qd,D=_,P=x-C;v.right=T,T.boundingData=new Float32Array(6),xm(n,D,P,T.boundingData,a),r(T,D,P,a,w+1)}return v}GV(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=ZV(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,m=[],g=HV(e);if(g.length===1){let v=g[0],y=new Qd;y.boundingData=s,WV(n,v.offset,v.count,a),r(y,v.offset,v.count,a),m.push(y)}else for(let v of g){let y=new Qd;y.boundingData=new Float32Array(6),xm(n,v.offset,v.count,y.boundingData,a),r(y,v.offset,v.count,a),m.push(y)}return m}function JV(e,t){let i=KV(e,t),r,s,a,n=[],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),a=new Uint16Array(p),h(0,c),n.push(p)}return n;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,m=c.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(f){let g=c.offset,v=c.count;return s[d+6]=g,a[p+14]=v,a[p+15]=65535,u+32}else{let g=c.left,v=c.right,y=c.splitAxis,x;if(x=h(u+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[d+6]=x/4,x=h(x,v),s[d+7]=y,x}}}var ra=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){let n=e[s][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){let n=t[s],o=e.dot(n);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}};ra.prototype.setFromBox=function(){let e=new E;return function(t,i){let r=i.min,s=i.max,a=1/0,n=-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);a=Math.min(u,a),n=Math.max(u,n)}this.min=a,this.max=n}}();var AQ=function(){let e=new ra;return function(t,i){let r=t.points,s=t.satAxes,a=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let u=a[h],c=s[h];if(e.setFromPoints(c,n),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}}}(),$V=function(){let e=new E,t=new E,i=new E;return function(r,s,a){let n=r.start,o=e,l=s.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.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,m,g;f!==0?m=(u*c-p*d)/f:m=0,g=(u+m*c)/d,a.x=m,a.y=g}}(),cy=function(){let e=new F,t=new E,i=new E;return function(r,s,a,n){$V(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,a),s.at(l,n);return}else if(o>=0&&o<=1){l<0?s.at(0,n):s.at(1,n),r.closestPointToPoint(n,!0,a);return}else if(l>=0&&l<=1){o<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,n);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)){a.copy(c),n.copy(u);return}else{a.copy(h),n.copy(d);return}}}}(),ej=function(){let e=new E,t=new E,i=new kr,r=new is;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c:u}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let c=a.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=n){let d=c.projectPoint(o,t);if(a.containsPoint(d))return!0}return!1}}(),tj=1e-15;function Zo(e){return Math.abs(e)<tj}var ja=class extends Hi{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new ra),this.points=[this.a,this.b,this.c],this.sphere=new Tr,this.plane=new kr,this.needsUpdate=!0}intersectsSphere(e){return ej(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,n=s[0],o=a[0];this.getNormal(n),o.setFromPoints(n,r);let l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,r);let u=s[2],c=a[2];u.subVectors(t,i),c.setFromPoints(u,r);let d=s[3],p=a[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};ja.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new is;return function(r,s=null,a=null){let{start:n,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]),cy(i,r,e,t),h=e.distanceToSquared(t),h<u&&(u=h,s&&s.copy(e),a&&a.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),a&&a.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),a&&a.copy(o)),Math.sqrt(u)}}();ja.prototype.intersectsTriangle=function(){let e=new ja,t=new Array(3),i=new Array(3),r=new ra,s=new ra,a=new E,n=new E,o=new E,l=new E,h=new is,u=new is,c=new is;return function(d,p=null,f=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let m=this.plane,g=d.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let w=0;w<4;w++){let A=v[w],_=y[w];if(r.setFromPoints(_,i),A.isSeparated(r))return!1}let x=d.satBounds,b=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let A=x[w],_=b[w];if(r.setFromPoints(_,t),A.isSeparated(r))return!1}for(let w=0;w<4;w++){let A=y[w];for(let _=0;_<4;_++){let S=b[_];if(a.crossVectors(A,S),r.setFromPoints(a,t),s.setFromPoints(a,i),r.isSeparated(s))return!1}}return p&&(f||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 v=this.points,y=!1,x=0;for(let P=0;P<3;P++){let I=v[P],R=v[(P+1)%3];h.start.copy(I),h.end.copy(R),h.delta(n);let U=y?u.start:u.end,N=Zo(g.distanceToPoint(I));if(Zo(g.normal.dot(n))&&N){u.copy(h),x=2;break}if((g.intersectLine(h,U)||N)&&!Zo(U.distanceTo(R))){if(x++,y)break;y=!0}}if(x===1&&d.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(x!==2)return!1;let b=d.points,w=!1,A=0;for(let P=0;P<3;P++){let I=b[P],R=b[(P+1)%3];h.start.copy(I),h.end.copy(R),h.delta(o);let U=w?c.start:c.end,N=Zo(m.distanceToPoint(I));if(Zo(m.normal.dot(o))&&N){c.copy(h),A=2;break}if((m.intersectLine(h,U)||N)&&!Zo(U.distanceTo(R))){if(A++,w)break;w=!0}}if(A===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(A!==2)return!1;if(u.delta(n),c.delta(o),n.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let _=u.start.dot(n),S=u.end.dot(n),M=c.start.dot(n),C=c.end.dot(n),T=S<M,D=_<C;return _!==C&&M!==S&&T===D?!1:(p&&(l.subVectors(u.start,c.start),l.dot(n)>0?p.start.copy(u.start):p.start.copy(c.start),l.subVectors(u.end,c.end),l.dot(n)<0?p.end.copy(u.end):p.end.copy(c.end)),!0)}}}();ja.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();ja.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new is,s=new is;return function(a,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(a,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let u=0;u<3;u++){let c,d=i[u],p=a[d];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,n&&n.copy(e),o&&o.copy(p));let f=this[d];a.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,n&&n.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],m=i[(p+1)%3];s.set(a[f],a[m]),cy(r,s,e,t);let g=e.distanceToSquared(t);g<h&&(h=g,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var sa=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new E,this.max=new E,this.matrix=new me,this.invMatrix=new me,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 ra),this.alignedSatBounds=new Array(3).fill().map(()=>new ra),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};sa.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,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],u=s[l],c=1<<l,d=r[c];h.subVectors(n,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}}();sa.prototype.intersectsBox=function(){let e=new ra;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,a=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=a[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();sa.prototype.intersectsTriangle=function(){let e=new ja,t=new Array(3),i=new ra,r=new ra,s=new E;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let n=this.satBounds,o=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let c=0;c<3;c++){let d=n[c],p=o[c];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=a.satBounds,h=a.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}}();sa.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}}();sa.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();sa.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new is),i=new Array(12).fill().map(()=>new is),r=new E,s=new E;return function(a,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(s),this.closestPointToPoint(s,r),a.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=n*n,u=a.min,c=a.max,d=this.points,p=1/0;for(let m=0;m<8;m++){let g=d[m];s.copy(g).clamp(u,c);let v=g.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(g),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let m=0;m<3;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){let y=(m+1)%3,x=(m+2)%3,b=g<<y|v<<x,w=1<<m|g<<y|v<<x,A=d[b],_=d[w];t[f].set(A,_);let S=e[m],M=e[y],C=e[x],T=i[f],D=T.start,P=T.end;D[S]=u[S],D[M]=g?u[M]:c[M],D[C]=v?u[C]:c[M],P[S]=c[S],P[M]=g?u[M]:c[M],P[C]=v?u[C]:c[M],f++}for(let m=0;m<=1;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){s.x=m?c.x:u.x,s.y=g?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 m=0;m<12;m++){let g=t[m];for(let v=0;v<12;v++){let y=i[v];cy(g,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var Ko=new E,Jo=new E,$o=new E,Jd=new F,$d=new F,eu=new F,Aw=new E,Mw=new E,Ew=new E,tu=new E;function ij(e,t,i,r,s,a){let n;return a===Pi?n=e.intersectTriangle(r,i,t,!0,s):n=e.intersectTriangle(t,i,r,a!==Sr,s),n===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function rj(e,t,i,r,s,a,n,o,l){Ko.fromBufferAttribute(t,a),Jo.fromBufferAttribute(t,n),$o.fromBufferAttribute(t,o);let h=ij(e,Ko,Jo,$o,tu,l);if(h){r&&(Jd.fromBufferAttribute(r,a),$d.fromBufferAttribute(r,n),eu.fromBufferAttribute(r,o),h.uv=Hi.getInterpolation(tu,Ko,Jo,$o,Jd,$d,eu,new F)),s&&(Jd.fromBufferAttribute(s,a),$d.fromBufferAttribute(s,n),eu.fromBufferAttribute(s,o),h.uv1=Hi.getInterpolation(tu,Ko,Jo,$o,Jd,$d,eu,new F)),i&&(Aw.fromBufferAttribute(i,a),Mw.fromBufferAttribute(i,n),Ew.fromBufferAttribute(i,o),h.normal=Hi.getInterpolation(tu,Ko,Jo,$o,Aw,Mw,Ew,new E),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:n,c:o,normal:new E,materialIndex:0};Hi.getNormal(Ko,Jo,$o,u.normal),h.face=u,h.faceIndex=a}return h}function pM(e,t,i,r,s){let a=r*3,n=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),{position:h,normal:u,uv:c,uv1:d}=e.attributes,p=rj(i,h,u,c,d,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function sj(e,t,i,r,s,a){for(let n=r,o=r+s;n<o;n++)pM(e,t,i,n,a)}function aj(e,t,i,r,s){let a=1/0,n=null;for(let o=r,l=r+s;o<l;o++){let h=pM(e,t,i,o);h&&h.distance<a&&(n=h,a=h.distance)}return n}function Ws(e,t,i,r){let s=e.a,a=e.b,n=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),a.x=r.getX(l),a.y=r.getY(l),a.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function Cw(e,t,i,r,s,a,n){let o=i.index,l=i.attributes.position;for(let h=e,u=t+e;h<u;h++)if(Ws(n,h*3,o,l),n.needsUpdate=!0,r(n,h,s,a))return!0;return!1}var fM=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 un(e,t){return t[e+15]===65535}function zl(e,t){return t[e+6]}function Vc(e,t){return t[e+14]}function jc(e){return e+8}function Gc(e,t){return t[e+6]}function nj(e,t){return t[e+7]}var Cl=new ai,Tp=new E,oj=["x","y","z"];function Pv(e,t,i,r,s){let a=e*2,n=Sh,o=Mn,l=En;if(un(a,o)){let h=zl(e,l),u=Vc(a,o);sj(t,i,r,h,u,s)}else{let h=jc(e);Dp(h,n,r,Tp)&&Pv(h,t,i,r,s);let u=Gc(e,l);Dp(u,n,r,Tp)&&Pv(u,t,i,r,s)}}function Iv(e,t,i,r){let s=e*2,a=Sh,n=Mn,o=En;if(un(s,n)){let l=zl(e,o),h=Vc(s,n);return aj(t,i,r,l,h)}else{let l=nj(e,o),h=oj[l],u=r.direction[h]>=0,c,d;u?(c=jc(e),d=Gc(e,o)):(c=Gc(e,o),d=jc(e));let p=Dp(c,a,r,Tp)?Iv(c,t,i,r):null;if(p){let m=p.point[h];if(u?m<=a[d+l]:m>=a[d+l+3])return p}let f=Dp(d,a,r,Tp)?Iv(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var lj=function(){let e,t,i=[],r=new fM(()=>new ai);return function(...a){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=s(...a);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]),n};function s(a,n,o,l,h=null,u=0,c=0){function d(y){let x=y*2,b=Mn,w=En;for(;!un(x,b);)y=jc(y),x=y*2;return zl(y,w)}function p(y){let x=y*2,b=Mn,w=En;for(;!un(x,b);)y=Gc(y,w),x=y*2;return zl(y,w)+Vc(x,b)}let f=a*2,m=Sh,g=Mn,v=En;if(un(f,g)){let y=zl(a,v),x=Vc(f,g);return Qs(a,m,e),l(y,x,!1,c,u+a,e)}else{let y=jc(a),x=Gc(a,v),b=y,w=x,A,_,S,M;if(h&&(S=e,M=t,Qs(b,m,S),Qs(w,m,M),A=h(S),_=h(M),_<A)){b=x,w=y;let U=A;A=_,_=U,S=M}S||(S=e,Qs(b,m,S));let C=un(b*2,g),T=o(S,C,A,c+1,u+b),D;if(T===2){let U=d(b),N=p(b)-U;D=l(U,N,!0,c+1,u+b,S)}else D=T&&s(b,n,o,l,h,u,c+1);if(D)return!0;M=t,Qs(w,m,M);let P=un(w*2,g),I=o(M,P,_,c+1,u+w),R;if(I===2){let U=d(w),N=p(w)-U;R=l(U,N,!0,c+1,u+w,M)}else R=I&&s(w,n,o,l,h,u,c+1);return!!R}}}(),hj=function(){let e=new ja,t=new ja,i=new me,r=new sa,s=new sa;return function a(n,o,l,h,u=null){let c=n*2,d=Sh,p=Mn,f=En;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),u=r),un(c,p)){let m=o,g=m.index,v=m.attributes.position,y=l.index,x=l.attributes.position,b=zl(n,f),w=Vc(c,p);if(i.copy(h).invert(),l.boundsTree)return Qs(n,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 _=b*3,S=(w+b)*3;_<S;_+=3)if(Ws(t,_,g,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=b*3,_=w+b*3;A<_;A+=3){Ws(e,A,g,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let S=0,M=y.count;S<M;S+=3)if(Ws(t,S,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,g=f[n+6];return Qs(m,d,Cl),!!(u.intersectsBox(Cl)&&a(m,o,l,h,u)||(Qs(g,d,Cl),u.intersectsBox(Cl)&&a(g,o,l,h,u)))}}}();function Dp(e,t,i,r){return Qs(e,t,Cl),i.intersectBox(Cl,r)}var Ov=[],Nu,Sh,Mn,En;function cc(e){Nu&&Ov.push(Nu),Nu=e,Sh=new Float32Array(e),Mn=new Uint16Array(e),En=new Uint32Array(e)}function iu(){Nu=null,Sh=null,Mn=null,En=null,Ov.length&&cc(Ov.pop())}var bm=Symbol("skip tree generation"),wm=new ai,_m=new ai,el=new me,Hn=new sa,Hh=new sa,Wh=new E,ru=new E,cj=new E,dj=new E,uj=new E,Tw=new ai,Os=new fM(()=>new ja),Sc=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."),Sc.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(),a;return t.cloneBuffers?a={roots:r.map(n=>n.slice()),index:s.array.slice()}:a={roots:r,index:s.array},a}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."),Sc.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,a=new Sc(t,{...i,[bm]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new Ze(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return a}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,[bm]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[bm]||(this._roots=JV(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new ai))),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,a,n,o,l=0,h=this._roots;for(let c=0,d=h.length;c<d;c++)s=h[c],a=new Uint32Array(s),n=new Uint16Array(s),o=new Float32Array(s),u(0,l),l+=s.byteLength;function u(c,d,p=!1){let f=c*2;if(n[f+15]===65535){let m=a[c+6],g=n[f+14],v=1/0,y=1/0,x=1/0,b=-1/0,w=-1/0,A=-1/0;for(let _=3*m,S=3*(m+g);_<S;_++){let M=i[_],C=r.getX(M),T=r.getY(M),D=r.getZ(M);C<v&&(v=C),C>b&&(b=C),T<y&&(y=T),T>w&&(w=T),D<x&&(x=D),D>A&&(A=D)}return o[c+0]!==v||o[c+1]!==y||o[c+2]!==x||o[c+3]!==b||o[c+4]!==w||o[c+5]!==A?(o[c+0]=v,o[c+1]=y,o[c+2]=x,o[c+3]=b,o[c+4]=w,o[c+5]=A,!0):!1}else{let m=c+8,g=a[c+6],v=m+d,y=g+d,x=p,b=!1,w=!1;e?x||(b=e.has(v),w=e.has(y),x=!b&&!w):(b=!0,w=!0);let A=x||b,_=x||w,S=!1;A&&(S=u(m,d,x));let M=!1;_&&(M=u(g,d,x));let C=S||M;if(C)for(let T=0;T<3;T++){let D=m+T,P=g+T,I=o[D],R=o[D+3],U=o[P],N=o[P+3];o[c+T]=I<U?I:U,o[c+T+3]=R>N?R:N}return C}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(n,o=0){let l=n*2,h=s[l+15]===65535;if(h){let u=r[n+6],c=s[l+14];e(o,h,new Float32Array(i,n*4,6),u,c)}else{let u=n+8,c=r[n+6],d=r[n+7];e(o,h,new Float32Array(i,n*4,6),d)||(a(u,o+1),a(c,o+1))}}}raycast(e,t=Ms){let i=this._roots,r=this.geometry,s=[],a=t.isMaterial,n=Array.isArray(t),o=r.groups,l=a?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=n?t[o[h].materialIndex].side:l,d=s.length;if(cc(i[h]),Pv(0,r,c,e,s),iu(),n){let p=o[h].materialIndex;for(let f=d,m=s.length;f<m;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=Ms){let i=this._roots,r=this.geometry,s=t.isMaterial,a=Array.isArray(t),n=null,o=r.groups,l=s?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=a?t[o[h].materialIndex].side:l;cc(i[h]);let d=Iv(0,r,c,e);iu(),d!=null&&(n==null||d.distance<n.distance)&&(n=d,a&&(d.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(cc(s),r=hj(0,i,e,t),iu(),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,m)=>{let g=p*3;return c(d,g,g+1,g+2,f,m)}}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=Os.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(d,p,f,m,g)=>c(d,p,f,m,g)?!0:Cw(d,p,r,l,f,m,s)}else o||(l?o=(c,d,p,f)=>Cw(c,d,r,l,p,f,s):o=(c,d,p)=>p);let h=!1,u=0;for(let c of this._roots){if(cc(c),h=lj(0,r,n,o,a,u),iu(),h)break;u+=c.byteLength}return Os.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,a=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;el.copy(t).invert();let h=Os.getPrimitive(),u=Os.getPrimitive();if(s){let d=function(p,f,m,g,v,y,x,b){for(let w=m,A=m+g;w<A;w++){Ws(u,w*3,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let _=p,S=p+f;_<S;_++)if(Ws(h,_*3,a,n),h.needsUpdate=!0,s(h,u,_,w,v,y,x,b))return!0}return!1};if(r){let p=r;r=function(f,m,g,v,y,x,b,w){return p(f,m,g,v,y,x,b,w)?!0:d(f,m,g,v,y,x,b,w)}}else r=d}e.getBoundingBox(_m),_m.applyMatrix4(t);let c=this.shapecast({intersectsBounds:d=>_m.intersectsBox(d),intersectsRange:(d,p,f,m,g,v)=>(wm.copy(v),wm.applyMatrix4(el),e.shapecast({intersectsBounds:y=>wm.intersectsBox(y),intersectsRange:(y,x,b,w,A)=>r(d,p,y,x,m,g,w,A)}))});return Os.releasePrimitive(h),Os.releasePrimitive(u),c}intersectsBox(e,t){return Hn.set(e.min,e.max,t),Hn.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Hn.intersectsBox(i),intersectsTriangle:i=>Hn.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Hn.set(e.boundingBox.min,e.boundingBox.max,t),Hn.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,u=e.index,c=Os.getPrimitive(),d=Os.getPrimitive(),p=ru,f=cj,m=null,g=null;r&&(m=dj,g=uj);let v=1/0,y=null,x=null;return el.copy(t).invert(),Hh.matrix.copy(el),this.shapecast({boundsTraverseOrder:b=>Hn.distanceToBox(b),intersectsBounds:(b,w,A)=>A<v&&A<a?(w&&(Hh.min.copy(b.min),Hh.max.copy(b.max),Hh.needsUpdate=!0),!0):!1,intersectsRange:(b,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>Hh.distanceToBox(A),intersectsBounds:(A,_,S)=>S<v&&S<a,intersectsRange:(A,_)=>{for(let S=A*3,M=(A+_)*3;S<M;S+=3){Ws(d,S,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let C=b*3,T=(b+w)*3;C<T;C+=3){Ws(c,C,l,o),c.needsUpdate=!0;let D=c.distanceToTriangle(d,p,m);if(D<v&&(f.copy(p),g&&g.copy(m),v=D,y=C/3,x=S/3),D<s)return!0}}}});{let A=u?u.count:h.count;for(let _=0,S=A;_<S;_+=3){Ws(d,_,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let M=b*3,C=(b+w)*3;M<C;M+=3){Ws(c,M,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(d,p,m);if(T<v&&(f.copy(p),g&&g.copy(m),v=T,y=M/3,x=_/3),T<s)return!0}}}}}),Os.releasePrimitive(c),Os.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(g):r.point=g.clone(),r.point.applyMatrix4(el),f.applyMatrix4(el),r.distance=f.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,a=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Wh.copy(e).clamp(h.min,h.max),Wh.distanceToSquared(e)),intersectsBounds:(h,u,c)=>c<n&&c<a,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,Wh);let c=e.distanceToSquared(Wh);return c<n&&(ru.copy(Wh),n=c,o=u),c<s}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(ru):t.point=ru.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Qs(0,new Float32Array(t),Tw),e.union(Tw)}),e}},qh=Ri(gT()),pj=.5*(Math.sqrt(3)-1),Yh=(3-Math.sqrt(3))/6,fj=1/3,Rs=1/6,MQ=(Math.sqrt(5)-1)/4,EQ=(5-Math.sqrt(5))/20,Ac=e=>Math.floor(e)|0,Dw=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]),Sm=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 Am(e=Math.random){let t=mM(e),i=new Float64Array(t).map(s=>Dw[s%12*2]),r=new Float64Array(t).map(s=>Dw[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*pj,u=Ac(s+h),c=Ac(a+h),d=(u+c)*Yh,p=u-d,f=c-d,m=s-p,g=a-f,v,y;m>g?(v=1,y=0):(v=0,y=1);let x=m-v+Yh,b=g-y+Yh,w=m-1+2*Yh,A=g-1+2*Yh,_=u&255,S=c&255,M=.5-m*m-g*g;if(M>=0){let D=_+t[S],P=i[D],I=r[D];M*=M,n=M*M*(P*m+I*g)}let C=.5-x*x-b*b;if(C>=0){let D=_+v+t[S+y],P=i[D],I=r[D];C*=C,o=C*C*(P*x+I*b)}let T=.5-w*w-A*A;if(T>=0){let D=_+1+t[S+1],P=i[D],I=r[D];T*=T,l=T*T*(P*w+I*A)}return 70*(n+o+l)}}function mj(e=Math.random){let t=mM(e),i=new Float64Array(t).map(a=>Sm[a%12*3]),r=new Float64Array(t).map(a=>Sm[a%12*3+1]),s=new Float64Array(t).map(a=>Sm[a%12*3+2]);return function(a,n,o){let l,h,u,c,d=(a+n+o)*fj,p=Ac(a+d),f=Ac(n+d),m=Ac(o+d),g=(p+f+m)*Rs,v=p-g,y=f-g,x=m-g,b=a-v,w=n-y,A=o-x,_,S,M,C,T,D;b>=w?w>=A?(_=1,S=0,M=0,C=1,T=1,D=0):b>=A?(_=1,S=0,M=0,C=1,T=0,D=1):(_=0,S=0,M=1,C=1,T=0,D=1):w<A?(_=0,S=0,M=1,C=0,T=1,D=1):b<A?(_=0,S=1,M=0,C=0,T=1,D=1):(_=0,S=1,M=0,C=1,T=1,D=0);let P=b-_+Rs,I=w-S+Rs,R=A-M+Rs,U=b-C+2*Rs,N=w-T+2*Rs,L=A-D+2*Rs,W=b-1+3*Rs,G=w-1+3*Rs,j=A-1+3*Rs,k=p&255,q=f&255,H=m&255,Y=.6-b*b-w*w-A*A;if(Y<0)l=0;else{let re=k+t[q+t[H]];Y*=Y,l=Y*Y*(i[re]*b+r[re]*w+s[re]*A)}let V=.6-P*P-I*I-R*R;if(V<0)h=0;else{let re=k+_+t[q+S+t[H+M]];V*=V,h=V*V*(i[re]*P+r[re]*I+s[re]*R)}let ie=.6-U*U-N*N-L*L;if(ie<0)u=0;else{let re=k+C+t[q+T+t[H+D]];ie*=ie,u=ie*ie*(i[re]*U+r[re]*N+s[re]*L)}let Q=.6-W*W-G*G-j*j;if(Q<0)c=0;else{let re=k+1+t[q+1+t[H+1]];Q*=Q,c=Q*Q*(i[re]*W+r[re]*G+s[re]*j)}return 32*(l+h+u+c)}}function mM(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 cs=new Hi,gj=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;cs.a.fromBufferAttribute(e,r),cs.b.fromBufferAttribute(e,r+1),cs.c.fromBufferAttribute(e,r+2),s*=cs.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 a=Math.ceil((i+r)/2);if(a===0||t[a-1]<=e&&t[a]>e){s=a;break}else e<t[a]?r=a-1:i=a+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),cs.a.fromBufferAttribute(this.positionAttribute,e*3),cs.b.fromBufferAttribute(this.positionAttribute,e*3+1),cs.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(cs.a,r).addScaledVector(cs.b,s).addScaledVector(cs.c,1-(r+s)),cs.getNormal(i),this}},vj=Ri(ZS()),yj=new me,xj=new me,bj=new me,Hc;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(Hc||(Hc={}));var dy=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new me,this.copyPreviousMatrix=!0,this.hiddenMatrix=new me,this.matrixWorldRigid=new me,this.shearScale=new me,this.shearScaleInv=new me}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Pt&&(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)}traverseChildren(t,i=0){for(let r of this.children)Hc.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Hc.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:a}=(0,vj.SVD)(i),n=yj.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=xj.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=bj.copy(o).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new me().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof me?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}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,a,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},wj=class extends dy(Pt){},_j=e=>e.type==="Mesh",qi=class extends wj{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}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 qi(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.playModeVisible!==void 0?this.playModeVisible: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 _j(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}},eo=new E,to=new E,kl=new me,gM=[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)],Sj=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Aj=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Pw=(e,t,i)=>{e.updateEntityBoxSize(eo,to),kl.copy(t).multiply(e.matrixWorld),to.x===0&&to.y===0&&to.z===0?i.push(new E(eo.x,eo.y,eo.z).applyMatrix4(kl)):gM.forEach(r=>{i.push(r.clone().multiply(to).add(eo).applyMatrix4(kl))})},Iw=class extends ai{constructor(){super(...arguments),this.matrix=new me,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 me().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new E);return}Pw(s,t,r)}}):Pw(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(kl.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(to).multiplyScalar(.5),this.getCenter(eo),kl.copy(this.matrix).setPosition(eo),this.vertices=gM.map(e=>e.clone().multiply(to).applyMatrix4(kl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Sj.map(([e,t])=>new is(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=Aj.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},yn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},Mj=class extends MA{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let a=0,n=this.curves;a<n.length;a++){let o=n[a],l=a===0?r[a]:r[a]-r[a-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}},Rv=.001;function Lv(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Rv}function Mm(e,t){let i=new E(...e.position),r=new E(...e.controlNext.position),s=new E(...t.controlPrevious.position),a=new E(...t.position);return Lv(i,r,a)&&Lv(i,s,a)}function vM(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++)Lv(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,a=i.length-(s?0:1),n=i.length,o=[];for(let u=0;u<n;u++){let c=i[u].data,d=new E(...c.position),p=new E(...c.controlPrevious.position),f=new E(...c.controlNext.position),m={position:d,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(u===0||u===n-1)){o[u]={...m,removedLength:0};continue}let g=s&&u==0?n-1:u-1,v=s&&u==n-1?0:u+1,y=i[g].data,x=i[v].data,b=new E(...y.position),w=new E(...x.position),A=b.clone().sub(d).normalize(),_=w.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:_});let S=Mm(y,c),M=Mm(c,x);if(!S||!M)o[u]={...m,removedLength:0};else{let C=A.clone().add(_).normalize(),T=C.clone().cross(A).length()/A.dot(C);o[u]={...m,tan:T,removedLength:c.roundness/T}}}for(let u=0;u<a;u++){let c=u,d=s&&u===n-1?0:u+1,p=o[c],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let u=0;u<a;u++){let c=u,d=s&&u===n-1?0:u+1,p=o[c],f=o[d],m=null;if(!Mm(i[c].data,i[d].data))p.position.distanceTo(f.position)>Rv&&(m=new Ru(p.position,p.controlNext,f.controlPrevious,f.position));else{let g=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&g.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),g.distanceTo(v)>Rv&&(m=new Ru(g,g.clone().lerp(v,.3),v.clone().lerp(g,.3),v))}l[2*u+1]=m}for(let u=0;u<n;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),m=c.tan*c.removedLength,g=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(y,2))).add(v),b=g.clone().multiplyScalar(-m).add(x),w=d.distanceTo(b)/d.distanceTo(v),A=c.prevDir.clone().multiplyScalar(w*d.distanceTo(p)).add(d),_=A.clone().lerp(b,2),S=p.clone().lerp(A,4/3),M=f.clone().lerp(_,4/3);l[2*u]=new Ru(p,S,M,f)}let h=new Mj;return l.forEach(u=>{u&&h.add(u)}),h}var pt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(pt||(pt={}));var Da=e=>pt.is(e),Ej={type:"completeState",isfromEntity:!0},Cj=["x","y","z"],Em=new E,Tj=new E().set(0,1,0),uy=e=>class extends dy(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new Iw,this._recursiveBBox=new Iw,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(pt.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(pt.is(this.children[t]))return t+1;return 0}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(pt.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)so.toOps(this.data,s.data).forEach(a=>{let n=Qg.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=so.patch(this.data,s),so.toOps(this.data,s).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),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=>{Da(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(pt.is(i[r]))return i[r];if(pt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&pt.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)Da(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{pt.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Da(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Da(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)Da(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>Da(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*Le.RAD2DEG,this.rotation.y*Le.RAD2DEG,this.rotation.z*Le.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Xg(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>r?.shared.getVariable(s,[this.uuid,t,Cj[a]])??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(Em.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(Le.DEG2RAD),this.rotation.setFromVector3(Em),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??$l.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)pt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{pt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Xg(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let a=this.data;this.data=i;let n=t,o=es(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let c=ar.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])}}n={...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=ar.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,so.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),es(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(Sn.apply(c.component.data,c.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let c=ar.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=_p.resolve(i.overrides,l),u.updateByOp(t,Wi.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 vn.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of vn.rootOverrideProps)if(es(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=Sn.filterOp(h.overrideData,l);u&&h.updateByOp(u,Wi.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=Sn.filterOp(h.overrideData,t);if(u){let c;a===h.data&&t===u?c=i:c=Wi.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&&!So.is(t.props.type)&&yn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){yn.changeEntityProptotype(this,i,r);for(let s of this.children)pt.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),es(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),es(t.path,["cloner"])!==null){let s=Wi.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(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){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??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=vM(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let u=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new me;n.updateMatrixWorld();let d=new me().multiplyMatrices(c.clone().invert(),n.matrixWorld);u.applyMatrix4(d);let p={position:u.toArray(),rotation:o.rotation};if(a==="tangential"){let f=new me().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(u),g=new me().lookAt(u,m,Tj),v=Em.setFromEuler(new Di().setFromRotationMatrix(g)).multiplyScalar(Le.RAD2DEG);p={...p,rotation:v.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(Ej)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}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(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof yn.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 yn.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)}},yM=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);i.thetaLength=Le.clamp(i.thetaLength,0,360);let r=i.width/2,s=i.radiusTop??r,a=i.radiusBottom??r;return s===a?(s=r,a=r):s>a?(s=r,a=a*r/s):(s=s*r/a,a=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:a})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:u,cornerRadius:c,cornerSegments:d,hollow:p}=e.parameters,f;return l===0?(f=new Ue,f.setAttribute("position",new Te([],3))):c||p?f=new xM(h,u,r,s,a,n,o,l*Math.PI/180,c,c,d,p):f=new D0(h,u,r,s,a,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function Ja(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Ow(e){return new F(e.y,-e.x)}var xM=class extends Ue{constructor(e,t,i,r,s,a,n,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,a=a!==void 0?a:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,a&&(l=0,h=0);let p=[],f=[],m=[],g=[],v=0,y=i/2,x=new E,b=new E;d&&e==0&&(e=l),d&&t==0&&(t=h);let w=new F(e,y),A=new F(t,-y),_=null,S=null,M=null,C=null,T=w.clone().sub(A),D=0,P=0,I=0;c>0&&(D=Math.min(e,t)*(1-c),P=e-D,I=t-D);let R=w.clone();R.x-=D;let U=Math.PI-T.angle(),N=T.angle(),L=Math.tan(N/2),W=Math.tan(U/2),G=L+W,j=c?G:W,k=c?G:L;if(l=Math.min(l,(e-P)/j,T.length()/G),h=Math.min(h,(t-I)/k,T.length()/G),l>0){let Q=l/L;_=w.clone().sub(new F(Q,l)),c&&(M=_.clone(),M.x-=D-G*l),w.sub(T.clone().setLength(Q))}if(h>0){let Q=h/W;S=A.clone().sub(new F(Q,-h)),A.add(T.clone().setLength(Q)),c&&(C=S.clone(),C.x-=D-G*h,R.sub(T.clone().setLength(Q)))}T=w.clone().sub(A);let q=T.length()<.5,H=[];for(let Q=0;Q<=r;Q++){let re=[],Z=Q/r,pe=Z*o+n,oe=new F(Math.sin(pe),Math.cos(pe));C&&S?(Y(re,Z,oe,U,h,C,-1,!0),Y(re,Z,oe,N,h,S,-1,!1)):S?(V(re,oe,S.x,0,-1),Y(re,Z,oe,N,h,S,-1,!1)):a||V(re,oe,t,I,-1);let ae=Ow(T).normalize();if(Ja(ae,oe,x),!q)for(let Me=0;Me<=s;Me++){let Ae=Me/s,Ee=T.clone().multiplyScalar(Ae).add(A);Ja(Ee,oe,b),f.push(b.x,b.y,b.z),m.push(x.x,x.y,x.z),g.push(Z,.5+b.y/i),re.push(v++)}if(M&&_?(Y(re,Z,oe,U,l,_,1,!1),Y(re,Z,oe,N,l,M,1,!0)):_?(Y(re,Z,oe,U,l,_,1,!1),V(re,oe,_.x,0,1)):a||V(re,oe,e,P,1),c&&!q){let Me=Ow(T).multiplyScalar(-1).normalize();Ja(Me,oe,x);for(let Ae=0;Ae<=s;Ae++){let Ee=Ae/s,Ie=T.clone().multiplyScalar(-Ee).add(R);Ja(Ie,oe,b),f.push(b.x,b.y,b.z),m.push(x.x,x.y,x.z),g.push(Z,.5+b.y/i),re.push(v++)}}c&&!a&&re.push(re[0]),H.push(re)}for(let Q=0;Q<H.length-1;Q++)for(let re=0;re<H[0].length-1;re++){if(a&&c&&re==s)continue;let Z=H[Q][re],pe=H[Q+1][re],oe=H[Q+1][re+1],ae=H[Q][re+1],Me=f[oe*3+0],Ae=f[oe*3+2];p.push(Z,pe,ae),(Me!=0||Ae!=0)&&p.push(pe,oe,ae)}o<Math.PI*2&&(ie(-1,H[0],n),ie(1,H[H.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new Te(f,3)),this.setAttribute("normal",new Te(m,3)),this.setAttribute("uv",new Te(g,2));function Y(Q,re,Z,pe,oe,ae,Me,Ae){for(let Ee=0;Ee<u+1;Ee++){let Ie=Ee/u,be=Me<0?Ie:1-Ie;Ae&&(be-=1),be*=pe;let ye=new F(Math.sin(be),Math.cos(be)*Me),ke=ye.clone().multiplyScalar(oe).add(ae);Ja(ke,Z,b),f.push(b.x,b.y,b.z),Ja(ye,Z,x),m.push(x.x,x.y,x.z),g.push(re,.5+b.y/i),Q.push(v++)}}function V(Q,re,Z,pe,oe){let ae=new E,Me=new F,Ae=[Z,pe];oe<0&&Ae.reverse();for(let Ee of Ae)Me.set(Ee,y*oe),Ja(Me,re,ae),f.push(ae.x,ae.y,ae.z),m.push(0,oe,0),g.push(.5,.5),Q.push(v++)}function ie(Q,re,Z){let pe=new F(Math.sin(Z),Math.cos(Z)),oe=new F(-Math.cos(Z),Math.sin(Z)),ae=new E,Me=Q<0?(Ie,be,ye)=>p.push(Ie,be,ye):(Ie,be,ye)=>p.push(Ie,ye,be),Ae=new F((e+t+P+I)/4,0);Ja(Ae,pe,ae),f.push(ae.x,ae.y,ae.z),m.push(oe.x,0,oe.y),g.push(.5,.5);let Ee=v++;for(let Ie of re){let be=f.slice(Ie*3,Ie*3+3);f.push(...be),m.push(oe.x,0,oe.y);let ye=g.slice(Ie*2,Ie*2+2);g.push(...ye),v++}for(let Ie=Ee+1;Ie<v-1;Ie++)Me(Ee,Ie,Ie+1);Me(Ee,v-1,Ee+1)}}},Dj=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 i.thetaLength=Le.clamp(i.thetaLength,0,360),{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:a,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:u,cornerSegments:c}=e.parameters,d;return l===0?(d=new Ue,d.setAttribute("position",new Te([],3))):h>0||u>0||l<360?d=new xM(0,t/2,r,s,a,n,o,l*Math.PI/180,h,u,c,0,!0):d=new CA(t/2,r,s,a,n),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},Pj=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:a,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new ta(t,i,r,s,a,n):h=new Ij(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Cm=Math.PI/2,Ij=class extends Ue{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let h=[],u=[],c=[],d=[],p=0,f=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),n>0&&(g("z","y","x",-1,-1,1,i,t,e,a,0),g("z","y","x",1,-1,-1,i,t,e,a,1),g("z","y","x",-1,1,-1,i,t,e,a,1),g("z","y","x",1,1,1,i,t,e,a,0),g("x","y","z",-1,-1,-1,e,t,i,r,0),g("x","y","z",1,-1,1,e,t,i,r,1),g("x","y","z",-1,1,1,e,t,i,r,0),g("x","y","z",1,1,-1,e,t,i,r,1),g("y","x","z",-1,-1,1,t,e,i,s,0),g("y","x","z",1,-1,-1,t,e,i,s,1),g("y","x","z",1,1,1,t,e,i,s,1),g("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 Te(u,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(d,2));function m(y,x,b,w,A,_,S,M,C,T,D){let P=(_-2*n)/C,I=(S-2*n)/T,R=_/2-n,U=S/2-n,N=M/2,L=C+1,W=T+1,G=0,j=0,k=new E;for(let q=0;q<W;q++){let H=q*I-U;for(let Y=0;Y<L;Y++){let V=Y*P-R;k[y]=V*w,k[x]=H*A,k[b]=N,u.push(k.x,k.y,k.z),k[y]=0,k[x]=0,k[b]=M>0?1:-1,c.push(k.x,k.y,k.z),d.push(Y/C),d.push(1-q/T),G+=1}}for(let q=0;q<T;q++)for(let H=0;H<C;H++){let Y=p+H+L*q,V=p+H+L*(q+1),ie=p+(H+1)+L*(q+1),Q=p+(H+1)+L*q;h.push(Y,V,Q),h.push(V,ie,Q),j+=6}l.addGroup(f,j,D),f+=j,p+=G}function g(y,x,b,w,A,_,S,M,C,T,D){let P=(S-2*n)/T,I=S/2-n,R=M/2-n,U=C/2,N=T+1,L=0,W=0,G=new E,j=new E;for(let k=0;k<o+1;k++){let q=k/o*Cm,H=Math.sin(q)*n,Y=(1-Math.cos(q))*n,V=Math.sin(q),ie=Math.cos(q);G[x]=(R+H)*A,G[b]=(U-Y)*_,j[y]=0,j[x]=V*Math.sign(G[x]),j[b]=ie*Math.sign(G[b]);for(let Q=0;Q<N;Q++){let re=Q*P-I;G[y]=re*w,u.push(G.x,G.y,G.z),c.push(j.x,j.y,j.z),d.push(Q/T),d.push(0),L+=1}}for(let k=0;k<o;k++)for(let q=0;q<T;q++){let H=p+q+N*k,Y=p+q+N*(k+1),V=p+(q+1)+N*(k+1),ie=p+(q+1)+N*k;h.push(H,Y,ie),h.push(Y,V,ie),W+=6}l.addGroup(f,W,D),f+=W,p+=L}function v(y,x,b){let w=new E,A=new E(e/2,t/2,i/2);A.subScalar(n);let _=[],S=y*x*b>0?(C,T,D)=>h.push(C,T,D):(C,T,D)=>h.push(C,D,T);for(let C=0;C<=o;C++){let T=[],D=Cm*(1-C/o),P=Math.cos(D),I=Math.sin(D),R=0;for(let U=0;U<=C;U++){let N=Math.cos(R),L=Math.sin(R);w.x=P*N,w.y=I,w.z=P*L;let W=A.clone().addScaledVector(w,n);u.push(y*W.x,x*W.y,b*W.z),c.push(y*w.x,x*w.y,b*w.z),d.push(0,0),T.push(p++),R+=Cm/C}_.push(T)}let M=_.length-1;for(let C=0;C<M;C++){let T=_[C],D=_[C+1],P=T.length-1;S(T[0],D[1],D[0]);for(let I=1;I<=P;I++)S(T[I-1],T[I],D[I]),S(T[I],D[I+1],D[I])}}}},py=class extends Ue{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),u(),this.setAttribute("position",new Te(n,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(a=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new E,p=d.clone(),f=new Hi,m=s*r,g=r-m,v=a+1,y=new E,x=(N,L)=>y.subVectors(N,L).normalize(),b=(N,L)=>Array(N).fill(void 0).map(L),w=b(e.length/3,(N,L)=>new E().fromArray(e,L*3).setLength(r)),A=[],_=1e6;for(let N=0;N<w.length;N++){let L=w[N],W=[],G,j,k,q=1e10,H=-1;for(;(H=t.indexOf(N,H+1))!=-1;){let Q=H-H%3;G=t[Q+(H+1)%3],j=t[Q+(H+2)%3],k=L.distanceToSquared(w[G]),q=Math.min(q,k),W.push([G,j,k])}q+=1e-6;let Y=[],V=0,ie=W.length;for(let Q=0;Q<ie;Q++){[G,j,k]=W[V];let re=A[G]?.includes(N)==!0;k<=q&&Y.push(G+ +re*_),V=W.findIndex(Z=>Z[0]==j)}A.push(Y)}let S=[];{let N=0,L=0,W,G,j=c==3;for(let k=0;k<=a;k++){W=k*(k+1)/2,G=(k+1)*(k+2)/2;for(let q=0;q<a-k;q++)[N,L]=[W+q+k+2,G+q+k+3],S.push(W,G,...j?[L,W]:[N,G],L,N),[W,G]=[N,L];S.push(W,G,W+a+2)}}let M=d.clone(),C=d.clone(),T=d.clone(),D=d.clone(),P=d.clone(),I=[],R=b(w.length,()=>b(c,()=>d.clone()));for(let N=0;N<w.length;N++){d.copy(w[N]).normalize(),M.copy(d).multiplyScalar(g);let L=A[N];for(let Y=0;Y<L.length;Y++){let V=L[Y],ie=L[(Y+1)%c];f.setFromPointsAndIndices(w,N,V%_,ie%_),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,R[N][Y])}let W=[],G=[],j=[],k=new E;a==0&&[...R[N]].reduce((Y,V)=>Y.add(V),k).multiplyScalar(1/c);for(let Y=0;Y<c;Y++){let V=[],ie=(Y-1+c)%c,Q=R[N][ie],re=R[N][Y];d.copy(Q).sub(M),p.copy(re).sub(M);let Z=M.angleTo(d),pe=d.angleTo(p),oe=Math.cos(Z)*m;a==0?C.copy(k):C.copy(M).setLength(g+oe),G.push(oe);let ae=[C,Q,re];for(let Me=0;Me<2;Me++){let Ae=ae[Me],Ee=ae[Me+1];D.subVectors(Ae,M),P.subVectors(Ee,M),T.crossVectors(D,P).normalize();for(let Ie=0;Ie<v;Ie++){let be=[Z,pe][Me]*Ie/v;d.copy(D).applyAxisAngle(T,be).add(M),W.push(d.clone()),Me&&(x(d,M),V.push([Ie==0?Ae:d.clone(),y.clone()]))}Me&&(x(Ee,M),V.push([Ee,y.clone()]))}j.push(V)}I.push(j);let q=2*v,H=2;for(let Y=0;Y<c;Y++){let V=q*Y,ie=q*((Y+1)%c),Q=[W[V]];for(let Z=1;Z<v;Z++){D=W[V+Z],P=W[ie+Z],Q.push(D);for(let pe=1,oe=Z-H+1;pe<=oe;pe++)d.lerpVectors(D,P,pe/(oe+1)),d.sub(M).setLength(G[Y]).add(M),Q.push(d.clone());Q.push(P)}for(let Z=0;Z<v;Z++)Q.push(W[Z+v+V]);Q.push(W[ie+v]);let re=S.map(Z=>Q[Z]);n.push(...re.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...re.map(Z=>(x(Z,M),[y.x,y.y,y.z])).flat())}}let U=[];for(let N=0;N<A.length;N++)for(let L=0;L<c;L++){let W=A[N][L];if(W<_){let G=A[W].findIndex(q=>q%_==N),j=I[N][L],k=I[W][G];for(let q=0;q<v;q++){let H=j[q],Y=k[v-q],V=j[q+1],ie=k[v-(q+1)];[H,Y,V,V,Y,ie].forEach(Q=>{n.push(Q[0].x,Q[0].y,Q[0].z),l.push(Q[1].x,Q[1].y,Q[1].z)})}U.push(j[0][0],k[v][0],j[v][0],k[0][0])}}for(;U.length;){let N,L,W,G;[N,L]=U.splice(0,2);let j=[N];for(;N!=L;)j.push(L),W=U.indexOf(L),G=W%2,L=U.splice(W-G,2)[1-G];y.subVectors(j[0],j[1]).cross(d.subVectors(j[0],j[2])).normalize();let k=y.dot(j[0])<0;k&&y.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +k],j[q+1-+k],j[0]].forEach(H=>{n.push(H.x,H.y,H.z),l.push(y.x,y.y,y.z)})}}function u(){let c=new E;for(let A=0;A<n.length;A+=3){c.x=n[A+0],c.y=n[A+1],c.z=n[A+2];let _=b(c)/2/Math.PI+.5,S=w(c)/Math.PI+.5;o.push(_,1-S)}let d=new E,p=new E,f=new E,m=new E,g=new F,v=new F,y=new F,x=(A,_,S,M)=>{M<0&&A.x===1&&(o[_]=A.x-1),S.x===0&&S.z===0&&(o[_]=M/2/Math.PI+.5)};for(let A=0,_=0;A<n.length;A+=9,_+=6){d.set(n[A+0],n[A+1],n[A+2]),p.set(n[A+3],n[A+4],n[A+5]),f.set(n[A+6],n[A+7],n[A+8]),g.set(o[_+0],o[_+1]),v.set(o[_+2],o[_+3]),y.set(o[_+4],o[_+5]),m.copy(d).add(p).add(f).divideScalar(3);let S=b(m);x(g,_+0,d,S),x(v,_+2,p,S),x(y,_+4,f,S)}for(let A=0;A<o.length;A+=6){let _=o[A+0],S=o[A+2],M=o[A+4],C=Math.max(_,S,M),T=Math.min(_,S,M);C>.9&&T<.1&&(_<.2&&(o[A+0]+=1),S<.2&&(o[A+2]+=1),M<.2&&(o[A+4]+=1))}function b(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 py(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},Oj=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:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new bM(t*.5,a,n):new TA(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},bM=class extends py{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,a=[-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],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],o="DodecahedronGeometry";super(a,n,o,e,t,i),this.type=o}static fromJSON(e){return new bM(e.radius,e.corner,e.cornerSides)}},Xh=1e-12,fy=class{constructor(e){this.position=new F,this.startPosition=new F,this.uuid=Le.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 fy(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Bv=class extends fy{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Bv(this.parent).copy(this)}},Nl=class extends fy{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Bv(this),new Bv(this))}static create(e,t){let i=new Nl(e,new F(...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 Nl(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 F,t=new F){let[i,r]=this.computeTangents();return i&&r&&(Rw(i,e),Rw(r,t)),[e,t]}computeTangent(e=new F){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new F){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function Rw(e,t=new F){let i=e.length();return t.set(-e.y/i,e.x/i)}var my=e=>e,Ah=new F,of=new F,Rj=new F,Lj=new F,Bj=new F,zj=new F,wM=new E,_M=new E;function kj(e){let t=new F;t.addVectors(e.v0,Ah.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new F;return i.addVectors(e.v2,of.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new xs(e.v0,t,i,e.v2)}function dc(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function Nj(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function Uj(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function SM(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)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-a*a)/(2*s*r))}function Fj(e,t,i){return Bw(e,t)&&Bw(t,i)&&zv(e.position,t.position,i.position)}function zv(e,t,i){return Ah.copy(t).sub(e).cross(of.copy(i).sub(e))===0}function Vj(e,t,i,r,s){let a=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(e.y-t.y)/a,h=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(t.x-e.x)/a;return r.set(o+l,n+h),s.set(o-l,n-h),[r,s]}function jj(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function Gj(e,t,i,r,s,a){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,u=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),c;return SM(t,e,i)>Math.PI&&(u*=-1),dc(h,o)?c=(o+h)*(r/u-.5)*8/3/(n-l):c=(n+l)*(r/u-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*n),a.set(i.x+c*h,i.y-c*l),[s,a]}function Lw(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Bw(e,t){return zv(e.position,e.controls[1].position,t.position)&&zv(e.position,t.controls[0].position,t.position)}function Hj(e,t,i,r,s=.5){let a=Ah.subVectors(t,e).multiplyScalar(s).add(e),n=of.subVectors(i,t).multiplyScalar(s).add(t),o=Rj.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=Lj.subVectors(n,a).multiplyScalar(s).add(a),u=Bj.subVectors(o,n).multiplyScalar(s).add(n),c=o,d=zj.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 Wj(e,t,i=12,r=!0){let s=_M.set(0,0,0),a,n=0,o=[];for(let l=0;l<t.length;l++){let h=my(t[l]),u=Ah,c=go(h,i);o.push(c);for(let d=0;d<=c;d++)if(h instanceof xs||h instanceof Tn||h instanceof As){if(h.getPoint(d/c,u),s.set(u.x,u.y,0),a!==void 0&&Uj(a,s))continue;a===void 0&&(a=wM),a.copy(s),e.setXYZ(n,s.x,s.y,s.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function qj(e,t,i,r=12,s=!0){let a=_M.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,u=my(t[l]),c=Ah,d=go(u,r);o.push(d);for(let p=0;p<=d;p++)if(u instanceof xs||u instanceof Tn||u instanceof As){if(u.getPoint(p/d,c),a.set(c.x,c.y,0),h?.equals(a))continue;h===void 0?h=wM:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,a.x,a.y,a.z),n++),h.copy(a)}}return s&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function zw(e,t=12,i=!1){let r=[];for(let s=0,a=e.length;s<a;s++){let n=e[s],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=go(n.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=go(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=go(e[0].roundedCurveCorner,t)*.5),r}function go(e,t=12){return e&&e instanceof Hp?t*2:e&&(e instanceof As||e instanceof AA)?1:e&&e instanceof T0?t*e.points.length:t}function Yj(e,t,i=12,r=!0){let s,a=0;for(let n=0;n<t.length;n++){let o=my(t[n]),l=go(o,i),h=Ah;for(let u=0;u<=l;u++)if(o instanceof xs||o instanceof Tn||o instanceof As){if(o.getPoint(u/l,h),s!==void 0&&Nj(s,h,Xh))continue;s===void 0&&(s=of),s.copy(h),e.push(h.x,h.y),a++}}return dc(e[0],e[e.length-2],Xh)&&dc(e[1],e[e.length-1],Xh)&&(e.pop(),e.pop()),r&&a>1&&!(dc(e[a-1],e[1],Xh)&&dc(e[a-2],e[0],Xh))&&(e.push(e[0],e[1]),a++),e}var Tm=new F,Xj=new F,Qj=new F,Zj=new F,Kj=new F,Jj=new F,Zt=class extends $u{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new kr(new E(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=Le.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Zt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>Nl.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Zt.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,a=this.shapeHoles.length;s<a;s++){let n=this.shapeHoles[s],o=n.points.length,l=n.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],a=e-t;if(a<=s.points.length-1)return s.points[a];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],a=s.points.indexOf(e);if(a>=0)return t+a;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=Tm.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let a=this.points[r];a.position.multiply(i),a.controls[0].position.multiply(i),a.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=Le.generateUUID()){let r;e instanceof F?r=e:r=new F(e,t);let s=new Nl(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 Wj(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=zw(this.points,e,!1),this.roundedCurveDivisions=zw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return qj(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),Yj(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=go(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(a<i+l)return[n,(a-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],a=this.curveDivisions,n=a[e];if(Lw(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Tm.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=a[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){Lw(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],a=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=s.roundness,l=a&&n&&Fj(a,s,n);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(),m=Math.min(o,p*.499),g=Math.min(o,f*.499),v=Math.min(m,g),y=1-v/p,x=v/f,b=h.getPointAt(y,Tm),w=u.getPointAt(x,Xj);this._subSplitCurve(h,c,y,b,void 0),this._subSplitCurve(u,d,x,void 0,w);let A;if(this.useCubicForRoundedCorners){let _=SM(b,s.position,w)/2,S=Math.tan(_)*b.distanceTo(s.position),[M,C]=Vj(b,w,S,Qj,Zj),T=jj(M,C,s.position),[D,P]=Gj(T,b,w,S,Kj,Jj);A=new xs(b.clone(),D.clone(),P.clone(),w.clone())}else A=new Tn(b.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 As)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let a=e,n=t,o=a.getUtoTmapping(i,0),l=Hj(a.v0,a.v1,a.v2,a.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),s!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new Zt(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],a=e.points[r+1],n=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 Nl(Le.generateUUID(),new F(s,a));c.controls[0].position.set(n,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 Zt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(s,a)=>{a instanceof xs&&a.v3.equals(s.position)&&s.controls[0].position.copy(a.v2)},r=s=>{let a=[],n,o;for(n=0,o=s.length;n<o;n++)s[n]instanceof Tn&&(s[n]=kj(s[n]));for(n=0,o=s.length;n<o;n++){let u=s[n],c=n>0?s[n-1]:null,d;u instanceof xs?(d=this.createPoint(u.v0),d.controls[1].position.copy(u.v1)):u instanceof As&&(d=this.createPoint(u.v1)),d!==void 0&&(c!==null&&i(d,c),a.push(d))}let l=s[s.length-1],h=!1;return l instanceof xs?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof As&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof $u&&(this.shapeHoles=e.holes.map(s=>{let a=new Zt;return a.fromShape(s),a})),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)}},kv=Math.PI*2;function Dm({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function $j(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),a=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:a+n*i,y:n-a*i},{x:a,y:n}]}function kw(e,t,i,r){let s=e*r-t*i<0?-1:1,a=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(a)}function e8(e,t,i,r,s,a,n,o,l,h){let u=Math.pow(s,2),c=Math.pow(a,2),d=Math.pow(n,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 m=f*s/a*o,g=f*-a/s*n,v=m+(e+i)/2,y=g+(t+r)/2,x=(n-m)/s,b=(o-g)/a,w=(-n-m)/s,A=(-o-g)/a,_=kw(1,0,x,b),S=kw(x,b,w,A);return!h&&S>0&&(S-=kv),h&&S<0&&(S+=kv),{centerx:v,centery:y,ang1:_,ang2:S}}function t8({px:e,py:t,cx:i,cy:r,rx:s,ry:a,largeArcFlag:n,sweepFlag:o}){let l=[];if(s===0||a===0)return[];let h=(e-i)/2,u=(t-r)/2;if(h===0&&u===0)return[];s=Math.abs(s),a=Math.abs(a);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(u,2)/Math.pow(a,2);c>1&&(s*=Math.sqrt(c),a*=Math.sqrt(c));let d=e8(e,t,i,r,s,a,h,u,n,o),{ang1:p,ang2:f}=d,{centerx:m,centery:g}=d,v=Math.abs(f)/(kv/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x<y;x++)l.push($j(p,f)),p+=f;return l.map(x=>{let{x:b,y:w}=Dm(x[0],s,a,m,g),{x:A,y:_}=Dm(x[1],s,a,m,g),{x:S,y:M}=Dm(x[2],s,a,m,g);return{x1:b,y1:w,x2:A,y2:_,x:S,y:M}})}var Tt;(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"})(Tt||(Tt={}));var pi;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(pi||(pi={}));function Xe(e,t){if(!e)throw t||"Assertion Failed!"}var Fe=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){Xe(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?s<a?i.t-t.t+(t.t-r.t)*(s/(s+a)):i.t-r.t+(r.t-t.t)*(a/(s+a)):0},e.edgeSign=function(t,i,r){Xe(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?(i.t-r.t)*s+(i.t-t.t)*a:0},e.transEval=function(t,i,r){Xe(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?s<a?i.s-t.s+(t.s-r.s)*(s/(s+a)):i.s-r.s+(r.s-t.s)*(a/(s+a)):0},e.transSign=function(t,i,r){Xe(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?(i.s-r.s)*s+(i.s-t.s)*a: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,a){var n,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)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,s.s)):a.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)?(n=e.transEval(t,r,i),o=e.transEval(r,i,s),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,s,i),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,s.t)):a.t=(r.t+i.t)/2},e}(),Qh=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}(),su=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}(),yl=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}(),Nw=function(){function e(){var t=new yl,i=new Qh,r=new su(0),s=new su(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 su(0),r=new su(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;Xe(s,"Vertex can't be null!");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i;var n=i;do n.Org=s,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;Xe(s,"Face can't be null");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var n=i;do n.Lface=s,n=n.Lnext;while(n!==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 a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.makeEdge=function(){var t=new yl,i=new yl,r=new Qh,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 a=new yl;this.makeVertex_(a,i,t.Org),t.Org.anEdge=t}if(!r){var n=new Qh;this.makeFace_(n,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 Qh;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 yl;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),a=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(a,i),s.Org=t.Dst,a.Org=i.Org,s.Lface=a.Lface=t.Lface,t.Lface.anEdge=a,!r){var n=new Qh;this.makeFace_(n,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,a,n,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)),a=r.Sym,a.Onext===a?this.killVertex_(a.Org,null):(a.Org.anEdge=a.Onext,this.splice_(a,a.Oprev)),this.killEdge_(r));while(r!=i);n=t.prev,o=t.next,o.prev=n,n.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,a,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;s=r.Lnext,a=r.Sym,a&&a.Lface&&a.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(a.Lface),o+l-2<=t&&Fe.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&Fe.vertCCW(a.Lprev.Org,a.Org,r.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),r=null,a=null)),!(r&&r.Lnext.Org===n);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,a,n,o,l,h;for(a=t,a=t;(s=a.next)!==t;a=s){Xe(s.prev===a),l=s.anEdge;do Xe(l.Sym!==l),Xe(l.Sym.Sym===l),Xe(l.Lnext.Onext.Sym===l),Xe(l.Onext.Sym.Lnext===l),Xe(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(Xe(s.prev===a&&s.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){Xe(n.prev===o),l=n.anEdge;do Xe(l.Sym!==l),Xe(l.Sym.Sym===l),Xe(l.Lnext.Onext.Sym===l),Xe(l.Onext.Sym.Lnext===l),Xe(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(Xe(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Xe(l.Sym.next===h.Sym),Xe(l.Sym!==l),Xe(l.Sym.Sym===l),Xe(l.Org!==null),Xe(l.Dst!==null),Xe(l.Lnext.Onext.Sym===l),Xe(l.Onext.Sym.Lnext===l);Xe(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}(),Uw=function(){function e(){this.handle=null}return e}(),Fw=function(){function e(){this.key=null,this.node=0}return e}(),i8=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 Uw,this.handles[r]=new Fw;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,a,n;for(s=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,Xe(n<=this.max),a=i[n].handle,n>this.size||this.leq(r[s].key,r[a].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t>>1,a=i[n].handle,n===0||this.leq(r[a].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},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,a;for(a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new Uw;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new Fw}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;Xe(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}(),Pm=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}(),Vw=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),r8=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new Vw,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 Vw;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}(),s8=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,a=i.eUp,n=r.eUp;if(a.Dst===s)return n.Dst===s?Fe.vertLeq(a.Org,n.Org)?Fe.edgeSign(n.Dst,a.Org,n.Org)<=0:Fe.edgeSign(a.Dst,n.Org,a.Org)>=0:Fe.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return Fe.edgeSign(a.Dst,s,a.Org)>=0;var o=Fe.edgeEval(a.Dst,s,a.Org),l=Fe.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Xe(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Xe(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 Pm;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 Tt.ODD:return(i&1)!==0;case Tt.NONZERO:return i!==0;case Tt.POSITIVE:return i>0;case Tt.NEGATIVE:return i<0;case Tt.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,a=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,a=e.regionBelow(n),s=a.eUp,s.Org!=o.Org){if(!a.fixUpperEdge){e.finishRegion(t,n);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,a,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,n),o=a.eUp,n=a}return o},e.addRightEdges=function(t,i,r,s,a,n){var o,l,h,u,c=!0;h=r;do Xe(Fe.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=e.regionBelow(i).eUp.Rprev),l=i,u=a;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,Xe(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Fe.vertL1dist(i,t),a=Fe.vertL1dist(r,t),n=.5*a/(s+a),o=.5*s/(s+a);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,a,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,a,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp;if(Fe.vertLeq(s.Org,a.Org)){if(Fe.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;Fe.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,a.Oprev,s)):(t.mesh.splitEdge(a.Sym),t.mesh.splice(s,a.Oprev),i.dirty=r.dirty=!0)}else{if(Fe.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n;if(Xe(!Fe.vertEq(s.Dst,a.Dst)),Fe.vertLeq(s.Dst,a.Dst)){if(Fe.edgeSign(s.Dst,a.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Sym,n),n.Lface.inside=i.inside}else{if(Fe.edgeSign(a.Dst,s.Dst,a.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Lnext,a.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n=s.Org,o=a.Org,l=s.Dst,h=a.Dst,u,c,d=new yl,p,f;if(Xe(!Fe.vertEq(h,l)),Xe(Fe.edgeSign(l,t.event,n)<=0),Xe(Fe.edgeSign(h,t.event,o)>=0),Xe(n!==t.event&&o!==t.event),Xe(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(u=Math.min(n.t,l.t),c=Math.max(o.t,h.t),u>c))return!1;if(Fe.vertLeq(n,o)){if(Fe.edgeSign(h,n,o)>0)return!1}else if(Fe.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Fe.intersect(l,n,h,o,d),Xe(Math.min(n.t,l.t)<=d.t),Xe(d.t<=Math.max(o.t,h.t)),Xe(Math.min(h.s,l.s)<=d.s),Xe(d.s<=Math.max(o.s,n.s)),Fe.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=Fe.vertLeq(n,o)?n:o,Fe.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),Fe.vertEq(d,n)||Fe.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!Fe.vertEq(l,t.event)&&Fe.edgeSign(l,t.event,d)>=0||!Fe.vertEq(h,t.event)&&Fe.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.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(a.Sym),t.mesh.splice(s.Lnext,a.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=a.Oprev,a=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,a.Onext,s.Rprev,f,!0),!0):(Fe.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),Fe.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(a.Sym),t.mesh.splice(a.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,n,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,a;;){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,a=r.eUp,s.Dst!==a.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(a),r=e.regionBelow(i),a=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==a.Org)if(s.Dst!==a.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||a.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===a.Org&&s.Dst===a.Dst&&(e.addWinding(a,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,a=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Fe.vertEq(o.Org,t.event)&&(t.mesh.splice(a.Oprev,o),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Fe.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,a,a,!0);return}Fe.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,a,n,o,l;if(s=i.eUp,Fe.vertEq(s.Org,r)){Xe(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Fe.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}Xe(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(Xe(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),Fe.edgeGoesLeft(a)||(a=null),e.addRightEdges(t,i,n.Onext,o,a,!0)},e.connectLeftVertex=function(t,i){var r,s,a,n,o,l,h=new Pm;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,Fe.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=Fe.vertLeq(o.Dst,n.Dst)?r:s,r.inside||a.fixUpperEdge){if(a===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var u=t.mesh.connect(o.Dnext,i.anEdge);l=u.Sym}a.fixUpperEdge?e.fixUpperEdge(t,a,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);Xe(s!==null);var a=e.regionBelow(s),n=a.eUp,o=e.finishLeftRegions(t,a,null);o.Onext===n?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,s){var a=new Pm,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=s,n.Dst.s=i,n.Dst.t=s,t.event=n.Dst,a.eUp=n,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=t.dict.insert(a)},e.initEdgeDict=function(t){t.dict=new r8(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,a=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,a,n),e.addSentinel(t,s,a,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Xe(i.fixUpperEdge),Xe(++r===1)),Xe(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,a=t.mesh.eHead;for(i=a.next;i!==a;i=r)r=i.next,s=i.Lnext,Fe.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,a=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)a++;for(a+=8,i=t.pq=new i8(a,Fe.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,a;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,a=r.anEdge,Xe(a.Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),t.mesh.delete(a));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||!Fe.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}(),a8=function(){function e(){this.mesh=new Nw,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=Tt.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,a,n,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],m=this.mesh.vHead;i=m.next;for(var g=0;g<3;++g)a=i.coords[g],h[g]=a,f[g]=i,l[g]=a,p[g]=i;for(i=m.next;i!==m;i=i.next)for(var v=0;v<3;++v)a=i.coords[v],a<h[v]&&(h[v]=a,f[v]=i),a>l[v]&&(l[v]=a,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=m.next;i!==m;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],n=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],n>o&&(o=n,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,a=0,n=t.next;n!==t;n=n.next)if(s=n.anEdge,!(s.winding<=0))do a+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==n.anEdge);if(a<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,a=!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),a=!0),r=this.sUnit,s=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,s[n]=0,s[(n+1)%3]=0,s[(n+2)%3]=i[n]>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);a&&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(;Fe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Fe.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(Fe.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Fe.edgeGoesLeft(s.Lnext)||Fe.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)a=t.connect(s.Lnext,s),s=a.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Fe.edgeGoesRight(r.Lprev)||Fe.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)a=t.connect(r,r.Lprev),r=a.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)a=t.connect(s.Lnext,s),s=a.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,a=t.eHead.next;a!==t.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?i:-i:r?t.delete(a):a.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 a,n=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){a=u.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=n,++n}this.elementCount=n,i===pi.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*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){a=u.anEdge,l=0;do{var h=a.Org;this.elements[d++]=h.n,l++,a=a.Lnext}while(a!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===pi.CONNECTED_POLYGONS){a=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,a=0,n=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;a=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=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,n++,r=r.Lnext;while(r!==s);this.elements[u++]=a,this.elements[u++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new Nw),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,a,n){if(t===void 0&&(t=Tt.ODD),i===void 0&&(i=pi.POLYGONS),n===void 0&&(n=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),s8.computeInterior(this,n);var o=this.mesh;return i===pi.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===pi.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function xn(e){var t=e.windingRule,i=t===void 0?Tt.ODD:t,r=e.elementType,s=r===void 0?pi.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,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,m=e.debug,g=m===void 0?!1:m;if(!d&&f)throw new Error("Contours can't be empty");if(d){var v=new a8;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,n,l,u,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var CQ=Tt.ODD,TQ=Tt.NONZERO,DQ=Tt.POSITIVE,PQ=Tt.NEGATIVE,IQ=Tt.ABS_GEQ_TWO,OQ=pi.POLYGONS,RQ=pi.CONNECTED_POLYGONS,LQ=pi.BOUNDARY_CONTOURS,Nv=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*Nv.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*Nv.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,a=0,n=new Float32Array(r,a*s,3*e);a+=3*e;let o=new Float32Array(r,a*s,3*e);a+=3*e;let l=new Float32Array(r,a*s,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,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)}},AM=Nv;AM.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var n8=Ri(yT()),gy={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},MM={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},EM={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},Im=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),vy=class extends Ue{constructor(e,t,i=0,r=12,s=3,a=Tt.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(M=>{let C=M.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let P=C[D-1],I=C[D-0];T.push(P,I)}return T}),h=[],u=[];for(let M=0;M<o.length;M+=2)u.push([o[M],o[M+1]]);h.push(u);for(let M=0;M<l.length;M++){let C=l[M],T=[];for(let D=0;D<C.length;D+=2)T.push([C[D],C[D+1]]);h.push(T)}let c;e.isText?c=new GA().setFromPoints(e.points.map(M=>M.position)).getSize(new F).length()*.1:h[0].length===0?c=i:c=(0,n8.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let d;try{d=xn({windingRule:a,elementType:pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{d=gy}let p;try{p=xn({windingRule:Tt.ODD,elementType:pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=MM}if(!d)throw new Error("error generating geometry");let f=d.elementCount;if(p){d.elementCount+=p.elementCount;for(let M=0;M<p.elements.length;M++){let C=p.elements[M],T=M%2===0?d.vertexCount:0;d.elements.push(C+T)}for(let M=0;M<p.vertexIndices.length;M++){let C=p.vertexIndices[M],T=d.vertexCount;d.vertexIndices.push(C+T)}for(let M=0;M<p.vertices.length;M++){let C=p.vertices[M];d.vertices.push(C)}}let m=1/0,g=-1/0,v=1/0,y=-1/0;for(let M=0,C=d.vertexCount;M<C;M++){let T=M*2,D=d.vertices[T+0],P=d.vertices[T+1];D<m&&(m=D),D>g&&(g=D),P<v&&(v=P),P>y&&(y=P)}this._minX=m,this._minY=v,this._width=g-m,this._height=y-v,this._buffer=new AM(this._computeBufferEstimatedSize(d));let x=[],b=[];for(let M=d.elementCount-1;M>=0;M--){let C=M>=f,T=M*2,D=d.elements[T+0],P=d.elements[T+1],I=D+P,R={start:D,count:P,normals:[],continuous:[],concave:[]},U=D,N=I-1,L=D+1,W=this._shape.roundedCurves.length;do{let H=U-D,Y=d.vertices[N*2+0],V=d.vertices[N*2+1],ie=d.vertices[U*2+0],Q=d.vertices[U*2+1],re=d.vertices[L*2+0],Z=d.vertices[L*2+1],pe=ie-Y,oe=Q-V,ae=Math.sqrt(pe*pe+oe*oe);pe/=ae,oe/=ae;let Me=ie-re,Ae=Q-Z,Ee=Math.sqrt(Me*Me+Ae*Ae);Me/=Ee,Ae/=Ee,R.normals[H*2+0]=-Ae,R.normals[H*2+1]=Me,R.concave[H]=pe*Ae-oe*Me>0;let Ie=d.vertexIndices[U];if(Array.isArray(Ie))R.continuous[H]=!1;else{let[be,ye]=this._shape.getCurveIndexFromVertexId(Ie-1,!0);if(ye>0&&ye<1)R.continuous[H]=!0;else{let ke=ye===1?be+1:be-1;ke=(ke+W)%W;let Je=ye===1?0:1,z=this._shape.roundedCurves[be].getTangent(ye),O=this._shape.roundedCurves[ke].getTangent(Je);R.continuous[H]=z.dot(O)>.95}}C&&(R.normals[H*2+0]*=-1,R.normals[H*2+1]*=-1),[N,U,L]=[U,L,L+1],L>=I&&(L-=P)}while(L!==D+1);let G=[];G.push({bevelI:0,angle:0,size:0,boundary:{vertices:d.vertices.slice(D*2,I*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((H,Y)=>[Y,Y]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:d.vertices.slice(D*2,I*2)});let j=0;for(let H=1;H<=this._bevelSegments;H++){let Y=H/this._bevelSegments*Math.PI/2,V=(1-Math.cos(Y))*this._bevel,ie=[],Q=[],re=[],Z=[],pe=0;for(let ae=0;ae<P;ae++){let Me=ae*2,Ae=(ae-1+P)%P*2,Ee=d.vertices[R.start*2+Me+0],Ie=d.vertices[R.start*2+Me+1],be=-R.normals[Ae+0]*V,ye=-R.normals[Ae+1]*V,ke=-R.normals[Me+0]*V,Je=-R.normals[Me+1]*V;if(R.concave[ae]||!R.concave[ae]&&C){let z=Math.atan2(ye,be),O=Math.atan2(Je,ke);O>z&&(O-=Math.PI*2);let $=O-z;if(R.continuous[ae]||C){let ge=z+$/2,de=Math.cos(ge)*V,xe=Math.sin(ge)*V;ie[2*pe+0]=Ee+de*(C?-1:1),ie[2*pe+1]=Ie+xe*(C?-1:1),Z[pe]=ae,pe++}else{let ge=Math.max(1,Math.floor(r/4*Math.abs($)/Math.PI));for(let de=0;de<=ge;de++){let xe=z+$*(de/ge),Be=Math.cos(xe)*V,Ce=Math.sin(xe)*V;ie[2*pe+0]=Ee+Be,ie[2*pe+1]=Ie+Ce,Z[pe]=ae,pe++}}}else ie[2*pe+0]=Ee+be,ie[2*pe+1]=Ie+ye,Z[pe]=ae,Q[ae]=pe,pe++,ie[2*pe+0]=Ee,ie[2*pe+1]=Ie,Z[pe]=ae,pe++,ie[2*pe+0]=Ee+ke,ie[2*pe+1]=Ie+Je,Z[pe]=ae,re[ae]=pe,pe++}let oe=xn({windingRule:Tt.POSITIVE,elementType:pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ie],edgeCreateCallback:ae=>{let Me=ae.Org.idx,Ae=Z[Me],Ee=Z[(Me+1)%Z.length];ae.idx=[Ae,Ee],ae.Sym.idx=[Ee,Ae]},vertexIdCallback:ae=>{let Me=ae.Lprev.idx;return[Me?Me[1]:0,ae.idx?ae.idx[0]:0]}});if(!oe)throw console.log("Error"),new Error(`error generating bevel geometry for ${H}'th loop`);if(!oe.vertexCount){let ae=(H-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<oe.vertexIndices.length;ae++){let[Me,Ae]=oe.vertexIndices[ae];if(Me===Ae)continue;let Ee=Ae;Ae<Me&&(Ee+=P);for(let Ie=Me;Ie<Ee;Ie++){let be=Ie%P,ye=(Ie+1)%P;if(!R.continuous[be]||!R.continuous[ye]){oe.vertexIndices[ae]=[Me,be],oe.vertexIndices.splice(ae+1,0,[ye,Ae]),oe.vertices.splice((ae+1)*2,0,oe.vertices[ae*2],oe.vertices[ae*2+1]);break}}}G.push({bevelI:H,angle:Y,size:V,boundary:oe,reverseMap:Z,insetPoints:ie})}let k=(H,Y,V)=>{let ie=0,Q=H.boundary.vertexIndices.length;for(;ie<Q&&V(H.boundary.vertexIndices[Y]);)Y=(Y+1)%Q,ie++;return ie},q=x.length;for(let H=1;H<G.length;H++){let Y=G[H-1],V=G[H],ie=Y.boundary.vertexIndices.length,Q=V.boundary.vertexIndices.length;if(!ie||!Q)break;let re=R.concave.length,Z=0,pe=Im(Z,P);for(;!Y.boundary.vertexIndices.filter(pe).length||!V.boundary.vertexIndices.filter(pe).length;)Z++,pe=Im(Z,P);let oe=Y.boundary.vertexIndices.findIndex(pe),ae=V.boundary.vertexIndices.findIndex(pe);do oe=(oe+1)%ie;while(pe(Y.boundary.vertexIndices[oe]));do ae=(ae+1)%Q;while(pe(V.boundary.vertexIndices[ae]));Z=(Z+1)%P;let Me=Z,Ae=0,Ee=this._buildBevelVert(R,Y,(oe-1+ie)%ie,void 0,Ae),Ie=this._buildBevelVert(R,V,(ae-1+Q)%Q,void 0,Ae),be=Ee,ye=Ie,ke,Je,z=!1;do{Ae=(Z||re)/re,pe=Im(Z,P);let O=k(Y,oe,pe),$=k(V,ae,pe),ge=z;if(z=!1,O&&!$){for(let de=0;de<O;de++)ke=this._buildBevelVert(R,Y,(oe+de)%ie,de/(O-1),Ae),x.push(be.topN,ke.topP,ye.topN),n===!1&&x.push(ke.bottomP,be.bottomN,ye.bottomN),be=ke;z=!0}else if(!O&&$)for(let de=0;de<$;de++)Je=this._buildBevelVert(R,V,(ae+de)%Q,de/($-1),Ae),x.push(ye.topN,be.topP,Je.topP),n===!1&&x.push(be.bottomP,ye.bottomN,Je.bottomP),ye=Je;else if(O&&$)if(ke=this._buildBevelVert(R,Y,oe,0,Ae),Je=this._buildBevelVert(R,V,ae,0,Ae),ge?(x.push(be.topN,Je.topP,ye.topN),x.push(be.topN,ke.topP,Je.topP),n===!1&&(x.push(Je.bottomP,be.bottomN,ye.bottomN),x.push(Je.bottomP,ke.bottomP,be.bottomN))):(x.push(ye.topN,be.topN,ke.topP),x.push(ye.topN,ke.topP,Je.topP),n===!1&&(x.push(ke.bottomP,be.bottomN,ye.bottomN),x.push(ke.bottomP,ye.bottomN,Je.bottomP))),be=ke,ye=Je,O===$)for(let de=1;de<O;de++)ke=this._buildBevelVert(R,Y,(oe+de)%ie,de/(O-1),Ae),Je=this._buildBevelVert(R,V,(ae+de)%Q,de/($-1),Ae),x.push(be.topN,ke.topP,ye.topN),x.push(ye.topN,ke.topP,Je.topP),n===!1&&(x.push(ke.bottomP,be.bottomN,ye.bottomN),x.push(ke.bottomP,ye.bottomN,Je.bottomP)),be=ke,ye=Je;else if(O>$){let de=O/$,xe=0;for(let Be=1;Be<O;Be++)ke=this._buildBevelVert(R,Y,(oe+Be)%ie,Be/(O-1),Ae),x.push(be.topN,ke.topP,ye.topN),n===!1&&x.push(ke.bottomP,be.bottomN,ye.bottomN),be=ke,Be>(xe+1)*de&&(xe++,Je=this._buildBevelVert(R,V,(ae+xe)%Q,xe/($-1),Ae),x.push(ye.topN,ke.topP,Je.topP),n===!1&&x.push(ke.bottomP,ye.bottomN,Je.bottomP),ye=Je)}else{let de=$/O,xe=0;for(let Be=1;Be<$;Be++)Je=this._buildBevelVert(R,V,(ae+Be)%Q,Be/($-1),Ae),x.push(ye.topN,ke.topP,Je.topP),n===!1&&x.push(ke.bottomP,ye.bottomN,Je.bottomP),ye=Je,Be>(xe+1)*de&&(xe++,ke=this._buildBevelVert(R,Y,(oe+xe)%ie,xe/(O-1),Ae),x.push(be.topN,ke.topP,ye.topN),n===!1&&x.push(ke.bottomP,be.bottomN,ye.bottomN),be=ke)}oe=(oe+O)%ie,ae=(ae+$)%Q,Z=(Z+1)%re}while(Z!==Me)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(G,R,x),C){let H=[];for(let Y=x.length-1;Y>=q+2;Y-=3){let V=x[Y-2],ie=x[Y-1],Q=x[Y-0];H.push(Q,ie,V)}x.splice(q,x.length-q,...H)}if(C){let H=[];for(let Y=G[G.length-1].boundary.vertices.length-1;Y>=1;Y-=2){let V=G[G.length-1].boundary.vertices[Y-1],ie=G[G.length-1].boundary.vertices[Y-0];H.push(V,ie)}b.push(H)}if(!C){let H=G[G.length-1],Y;try{Y=xn({windingRule:G.length>1?Tt.POSITIVE:Tt.ODD,elementType:pi.POLYGONS,vertexSize:2,strict:!0,contours:[H.insetPoints,...b]})}catch{Y=EM}if(!Y)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let V=0;V<Y.elementCount*3;V+=3){let ie=this._buildSurfaceVert(Y,Y.elements[V+0],j),Q=this._buildSurfaceVert(Y,Y.elements[V+1],j),re=this._buildSurfaceVert(Y,Y.elements[V+2],j);x.push(ie.top,Q.top,re.top),n===!1&&x.push(re.bottom,Q.bottom,ie.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Ze(Uint32Array.from(x),1),A=new Ze(this._buffer.positions,3),_=new Ze(this._buffer.normals,3),S=new Ze(this._buffer.uvs,2);A.needsUpdate=!0,_.needsUpdate=!0,S.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",_),this.setAttribute("uv",S),this.setIndex(w)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],a=e.vertices[t*2+1],n=(s-this._minX)/this._width,o=(a-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,u=l*2,c={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[u+0]=n,this._buffer.uvs[u+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[u+2]=n,this._buffer.uvs[u+3]=o),this.vertexCache[r]=c,c}_buildBevelVert(e,t,i,r=1,s){let a=`${t.bevelI}:${i}`;if(a in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[n,o]=t.boundary.vertexIndices[i],l,h,u,c;n!==o?(h=n,l=o,c=!1,u=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,u=e.continuous[l]||c);let d=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,m=l*2,g=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,b=(v-this._minX)/this._width,w=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(b=s),w=1);let A=e.normals[m+0],_=e.normals[m+1],S=e.normals[g+0],M=e.normals[g+1];if(c){let I=S-A,R=M-_;A=A+I*(1-r),_=_+R*(1-r);let U=Math.sqrt(A*A+_*_);A/=U,_/=U}let C=this.forPathBevel?this._buffer.get(u?1:2):this._buffer.get(u?2:4),T=C*3,D=C*2,P={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=A*d,this._buffer.normals[T+1]=_*d,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=w,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=A*d,this._buffer.normals[T+4]=_*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=w,this._buffer.uvs[D+3]=b),u||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),P.topP=C+0,P.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=S*d,this._buffer.normals[T+1]=M*d,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=w,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=S*d,this._buffer.normals[T+4]=M*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=w,this._buffer.uvs[D+3]=b)),this.vertexCache[a]=P,P}clone(){let e=new vy(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=$p(this.userData),e}},CM=class extends Ue{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Tt.ODD,this.elementType=pi.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Tt.ODD,elementType:pi.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)),a,n=!0,o=!0,l,h;for(let d=0,p=r.length/2;d<p;d++){let f=d*2,m=r[f+0],g=r[f+1];if(l!==void 0&&m!==l&&(n=!1),h!==void 0&&g!==h&&(o=!1),l=m,h=g,!n&&!o)break}if(!n&&!o)try{a=xn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=gy}let u=a?.vertexCount??1,c=a?.elementCount??1;if(this._positionAttribute=new Ze(new Float32Array(u*3),3),this._normalAttribute=new Ze(new Float32Array(u*3),3),this._uvAttribute=new Ze(new Float32Array(u*2),2),this._indexAttribute=new Ze(new Uint32Array(c*3),1),a){let d=1/0,p=-1/0,f=1/0,m=-1/0;for(let y=0,x=u;y<x;y++){let b=y*2,w=a.vertices[b+0],A=a.vertices[b+1];w<d&&(d=w),w>p&&(p=w),A<f&&(f=A),A>m&&(m=A)}let g=p-d,v=m-f;for(let y=0,x=u;y<x;y++){let b=y*2,w=a.vertices[b+0],A=a.vertices[b+1],_=(w-d)/g,S=(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,x=c;y<x;y++){let b=y*3,w=a.elements[b+0],A=a.elements[b+1],_=a.elements[b+2];this._indexAttribute.setX(b+0,w),this._indexAttribute.setX(b+1,A),this._indexAttribute.setX(b+2,_)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new CM(this._shape,this._curveSegments);return e.userData=$p(this.userData),e}},TM=class extends vy{constructor(e,t,i=0,r=12,s=3,a=Tt.ODD){super(e,t,i,r,s,a),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}clone(){let e=new TM(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=$p(this.userData),e}},Do=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:Tt.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.abs(i.depth??0),n=e.shape??t?.shape,o=n?.roundness??i.roundness;n!==void 0&&(n instanceof Zt?(n.width!==r||n.height!==s)&&n.applySize(r,s):n=new Zt(r,s).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new Zt(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:a,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:a,windingRule:n}=e.parameters;e.shape.roundness=a;let o;return t<=0?o=new CM(e.shape,s,{windingRule:n}):o=new TM(e.shape,t,i,s,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},DM=Math.PI*2,yy=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 i.angle=Le.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof Zt?e.shape:new Zt,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:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,u=t*.5,c=i*.5,d=o8(h,u,c,s*Math.PI/180,r,a);h.isClosed=!0,h.update();let p;return s===0?(p=new Ue,p.setAttribute("position",new Te([],3))):p=Do.create({shape:h,parameters:{subdivisions:d,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function o8(e,t,i,r,s,a){if(r>=DM)return s>30||s%4===0?(h8(e,t,i,a),Math.round(s/4)):jw(e,r,s,t,i,a);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=t8({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?l8(e,n.x,n.y,h,s,t,i,a):jw(e,r,s,t,i,a)}function l8(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint(Ul(t,i));for(let h=0,u=r.length;h<u;h++){let c=r[h],d=e.points[h],p=Ul(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?PM(e,a,n,o):e.addPoint(Ul(0,0)),l}function jw(e,t,i,r,s,a){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,u=Math.cos(l)*s;e.addPoint(Ul(h,u))}return t<DM?a>0?PM(e,r,s,a):e.addPoint(Ul(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&IM(e,r,s,a)),1}function h8(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(au(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(au(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(au(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(au(s,a-i,s+o,a-i,s-o,a-i)),r>0&&IM(e,t,i,r)}function Ul(e,t){return new Nl(Le.generateUUID(),new F(e,t))}function au(e,t,i,r,s,a){let n=Ul(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function PM(e,t,i,r){OM(e,t,i,r).forEach(s=>e.addPoint(s))}function IM(e,t,i,r){let s=OM(e,t,i,r),a=new Zt;s.forEach(n=>a.addPoint(n)),a.isClosed=!0,e.shapeHoles.push(a)}function OM(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new F(s/t,a/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=Le.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),u=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var c8=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),a=Math.abs(i.depth??r),n=Math.abs(Math.min(r,a))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:a,radius:n,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:a,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:c}=e.parameters,d=new RM(!1,t,i,r,s,a,n,o,l,h,u,c);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},Om=new Pl([0,0,0],1),RM=class extends Ue{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,u=1,c=1){if(super(),a===0)return;let d=e&&a===1;d&&(c=0),u>100&&(u=100),u===0&&(c=0);let p=()=>new E,f=new E,m=p(),g=p(),v=p(),y,x,b,w,A,_,S,M,C=p(),T=p(),D=p(),P=p(),I=p(),R=p(),U=p(),N=p(),L=i-2*o+.001,W=L/a,G=Math.ceil(n*a),j=G+1,k=L/G,q=-L/2,H=h+1,Y=2*Math.PI/h,V=Math.PI/2/c,ie=.01,Q=Math.min((1-u/100)*o,o-ie),re=o-Q,Z=0,pe=2,oe=c*pe+pe,ae=H*oe/pe,Me=ae+H*j,Ae=Math.max(0,H*(j+oe)),[Ee,Ie,be]=[3,3,2].map(Oe=>Array(Ae*Oe).fill(0)),ye=[],ke=s-o;function Je(Oe,ze){let Re=Math.PI/2;_=ze*k,M=2*Math.PI*(_%W)/W+Re,_+=q,S=Math.sin(M)*ke,A=Math.cos(M)*ke,e?Oe.set(A,S,_):Oe.set(A,_,S)}Je(f,-1e-10),Je(m,0),C.copy(f),Je(f,1);let z=f.distanceTo(m),O=d?0:re+Q,$=z*G+2*O,ge=Q,de=$-O;for(let Oe=0;Oe<=G;Oe++){Je(g,Oe),N.subVectors(g,C).normalize(),C.copy(g),R.copy(g).setComponent(+e+1,0).normalize(),U.crossVectors(N,R).normalize();let ze=Oe===0,Re=Oe===G,Ke=ze?3*Math.PI/2:V,je=ze?ge:de,vt=ze?H:Me,Nt=ze?0:Ae-H,oi=N.clone().multiplyScalar(ze?-re:re).add(g),X=N.clone().multiplyScalar(ze?-1:1).normalize();for(let ne=0;ne<H;ne++){let ve=ne*Y;if(T.addVectors(f.copy(R).multiplyScalar(o*Math.cos(ve)),m.copy(U).multiplyScalar(o*Math.sin(ve))),D.copy(T).normalize(),ze||Re){d||(Z=Nt+ne,[0,1,2].forEach(_e=>{Ee[Z*3+_e]=oi.getComponent(_e),Ie[Z*3+_e]=X.getComponent(_e)}),be[Z*2]=+Re,be[Z*2+1]=ne/h),m.copy(D).multiplyScalar(Q),v.addVectors(g,m);for(let _e=0;_e<c;_e++){let qe=_e*V+Ke;P.addVectors(f.copy(N).multiplyScalar(re*Math.sin(qe)),m.copy(D).multiplyScalar(re*Math.cos(qe))),I.copy(P).normalize(),m.addVectors(v,P),P.normalize(),Z=vt+_e*H+ne,[0,1,2].forEach(Gt=>{Ee[Z*3+Gt]=m.getComponent(Gt),Ie[Z*3+Gt]=I.getComponent(Gt)});let wt=+ze+Math.sin(qe);be[Z*2]=(je+re*wt)/$,be[Z*2+1]=ne/h}}m.addVectors(g,T),Z=ae+Oe*H+ne,[0,1,2].forEach(_e=>{Ee[Z*3+_e]=m.getComponent(_e),Ie[Z*3+_e]=D.getComponent(_e)}),be[Z*2]=(O+Oe*z)/$,be[Z*2+1]=ne/h}}let xe=j+2*c+pe,Be=1,[Ce,ue]=[+d,xe-1];for(let Oe=Ce;Oe<=ue-1;Oe++){let ze=d&&Oe===ue-1;for(let Re=0;Re<H-1;Re++)y=Oe*H+Re,x=y+1,b=(ze?Re:y)+H,w=(ze?Re+1:x)+H,Oe===0?ye.push(x,w,b):Oe===xe-2?ye.push(y,x,b):ye.push(y,x,b,x,w,b)}this.setIndex(ye),this.setAttribute("position",new Te(Ee,3)),this.setAttribute("normal",new Te(Ie,3)),this.setAttribute("uv",new Te(be,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,a,n,o,l=6*(t-1)*e.radialSegments,h=t,u=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,a=s+1,n=(u?c:s)+i,o=(u?c+1:a)+i,r[l++]=s,r[l++]=a,r[l++]=n,r[l++]=a,r[l++]=o,r[l++]=n;return r.length=l,Om.array=r,Om.count=r.length,Om}},d8=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:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new LM(t*.5,a,n):new RA(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},LM=class extends py{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],a=[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],n="IcosahedronGeometry";super(s,a,n,e,t,i),this.type=n}static fromJSON(e){return new LM(e.radius,e.corner,e.cornerSides)}},u8=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 $u;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 a=new EA(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}},Ls=new me,Rm=new Pt,nu=new E,Pp=class extends Ni{constructor(){super(),this.uuid=Le.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 ri().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 a=0,n=s.vertexNormals.length;a<n;a++)s.vertexNormals[a].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return Ls.makeRotationX(e),this.applyMatrix4(Ls),this}rotateY(e){return Ls.makeRotationY(e),this.applyMatrix4(Ls),this}rotateZ(e){return Ls.makeRotationZ(e),this.applyMatrix4(Ls),this}translate(e,t,i){return Ls.makeTranslation(e,t,i),this.applyMatrix4(Ls),this}scale(e,t,i){return Ls.makeScale(e,t,i),this.applyMatrix4(Ls),this}lookAt(e){return Rm.lookAt(e),Rm.updateMatrix(),this.applyMatrix4(Rm.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,a=r.normal,n=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)),n!==void 0&&t.colors.push(new Ve().fromBufferAttribute(n,c));function h(c,d,p,f){let m=n===void 0?[]:[t.colors[c].clone(),t.colors[d].clone(),t.colors[p].clone()],g=a===void 0?[]:[new E().fromBufferAttribute(a,c),new E().fromBufferAttribute(a,d),new E().fromBufferAttribute(a,p)],v=new Uv(c,d,p,g,m,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new F().fromBufferAttribute(o,c),new F().fromBufferAttribute(o,d),new F().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new F().fromBufferAttribute(l,c),new F().fromBufferAttribute(l,d),new F().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 m=p,g=p+f;m<g;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),d.materialIndex):h(m,m+1,m+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(nu).negate(),this.translate(nu.x,nu.y,nu.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new me;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],a=this.vertices[s.a],n=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,n),t.subVectors(a,n),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,a=this.faces.length;s<a;s++){let n=this.faces[s],o=this.vertices[n.a],l=this.vertices[n.b],h=this.vertices[n.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[n.a].add(i),t[n.b].add(i),t[n.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],a=s.vertexNormals;a.length===3?(a[0].copy(t[s.a]),a[1].copy(t[s.b]),a[2].copy(t[s.c])):(a[0]=t[s.a].clone(),a[1]=t[s.b].clone(),a[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,a=r.vertexNormals.length;s<a;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new Pp;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,a=this.morphNormals[t].vertexNormals;for(let n=0,o=this.faces.length;n<o;n++){let l=new E,h={a:new E,b:new E,c:new E};s.push(l),a.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,a=this.faces.length;s<a;s++){let n=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.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 ai),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Tr),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,a=this.vertices,n=e.vertices,o=this.faces,l=e.faces,h=this.colors,u=e.colors;t!==void 0&&(r=new ri().getNormalMatrix(t));for(let c=0,d=n.length;c<d;c++){let p=n[c].clone();t!==void 0&&p.applyMatrix4(t),a.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,m,g=p.vertexNormals,v=p.vertexColors,y=new Uv(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,b=g.length;x<b;x++)f=g[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,b=v.length;x<b;x++)m=v[x],y.vertexColors.push(m.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,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++)v.push(g[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 a=[];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]){a.push(o);break}}for(let o=a.length-1;o>=0;o--){let l=a[o];this.faces.splice(l,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(l,1)}let n=this.vertices.length-i.length;return this.vertices=i,n}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],a,n;r&&r.length===t&&(a=[]),s&&s.length===t&&(n=[]);for(let o=0;o<t;o++){let l=e[o]._id;a&&a.push(r[l]),n&&n.push(s[l])}a&&(this.faceVertexUvs[0]=a),n&&(this.faceVertexUvs[1]=n)}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={},a=[],n={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],m=!0,g=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,b=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,m),A=h(A,2,g),A=h(A,3,v),A=h(A,4,y),A=h(A,5,x),A=h(A,6,b),A=h(A,7,w),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let _=this.faceVertexUvs[0][p];i.push(d(_[0]),d(_[1]),d(_[2]))}if(y&&i.push(u(f.normal)),x){let _=f.vertexNormals;i.push(u(_[0]),u(_[1]),u(_[2]))}if(b&&i.push(c(f.color)),w){let _=f.vertexColors;i.push(c(_[0]),c(_[1]),c(_[2]))}}function h(p,f,m){return m?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 n[f]!==void 0||(n[f]=a.length,a.push(p.getHex())),n[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,a.length>0&&(e.data.colors=a),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new Pp().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,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++){let b=g[y];v.push(b.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,m=s[c].vertices.length;f<m;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,m=s[c].normals.length;f<m;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let a=e.morphNormals;for(let c=0,d=a.length;c<d;c++){let p={};if(a[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=a[c].vertexNormals.length;f<m;f++){let g=a[c].vertexNormals[f],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),p.vertexNormals.push(v)}}if(a[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=a[c].faceNormals.length;f<m;f++)p.faceNormals.push(a[c].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let c=0,d=n.length;c<d;c++)this.skinWeights.push(n[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 p8().fromGeometry(this),t=new Ue,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",ou.call(new Ze(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",ou.call(new Ze(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",Gw.call(new Ze(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",Hw.call(new Ze(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",Hw.call(new Ze(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],a=e.morphTargets[r];for(let n=0,o=a.length;n<o;n++){let l=a[n],h=new Te(l.data.length*3,3);h.name=l.name,s.push(ou.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Te(e.skinIndices.length*4,4);t.setAttribute("skinIndex",Ww.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Te(e.skinWeights.length*4,4);t.setAttribute("skinWeight",Ww.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 Ue,i=e.geometry;if(e.isPoints||e.isLine){let r=new Te(i.vertices.length*3,3),s=new Te(i.colors.length*3,3);if(t.setAttribute("position",ou.call(r,i.vertices)),t.setAttribute("color",Gw.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let a=new Te(i.lineDistances.length,1);t.setAttribute("lineDistance",f8.call(a,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}};Pp.prototype.isGeometry=!0;var p8=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,a=e.faces;for(r=0;r<a.length;r++){let n=a[r];n.materialIndex!==s&&(s=n.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,a=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let g=0;g<o;g++)l[g]={name:n[g].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,u=h.length,c;if(u>0){c=[];for(let g=0;g<u;g++)c[g]={name:h[g].name,data:[]};this.morphTargets.normal=c}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<t.length;g++){let v=t[g];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 b=v.normal;this.normals.push(b,b,b)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let b=v.color;this.colors.push(b,b,b)}if(s===!0){let b=r[0][g];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new F,new F,new F))}if(a===!0){let b=r[1][g];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new F,new F,new F))}for(let b=0;b<o;b++){let w=n[b].vertices;l[b].data.push(w[v.a],w[v.b],w[v.c])}for(let b=0;b<u;b++){let w=h[b].vertexNormals[g];c[b].data.push(w.a,w.b,w.c)}f&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),m&&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}},Uv=class{constructor(e,t,i,r,s,a=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 Ve,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=a}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 f8(e){return this.array.set(e),this}function Gw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new Ve),t[i++]=a.r,t[i++]=a.g,t[i++]=a.b}return this}function Hw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new F),t[i++]=a.x,t[i++]=a.y}return this}function ou(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new E),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z}return this}function Ww(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new rt),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z,t[i++]=a.w}return this}var m8=["a","b","c"];function g8(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function Lm(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),a=r+"_"+s;return i.get(a)}function Bm(e,t,i,r,s,a){let n=Math.min(e,t),o=Math.max(e,t),l=n+"_"+o,h;if(r.has(l))h=r.get(l);else{let u=i[n],c=i[o];h={a:u,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),a[e].edges.push(h),a[t].edges.push(h)}function v8(e,t,i,r){let s,a,n;for(s=0,a=e.length;s<a;s++)i[s]={edges:[]};for(s=0,a=t.length;s<a;s++)n=t[s],Bm(n.a,n.b,e,r,n,i),Bm(n.b,n.c,e,r,n,i),Bm(n.c,n.a,e,r,n,i)}function lu(e,t,i,r,s){e.push(new Uv(t,i,r,void 0,void 0,s))}function tl(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function hu(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var y8=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Ue?e=new Pp().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,a,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,c=[],d=new Map;v8(o,l,c,d);let p=[],f,m,g,v,y,x,b;for(let ie of Array.from(d.keys())){for(m=d.get(ie),g=new E,y=3/8,x=1/8,b=m.faces.length,b!=2&&(y=.5,x=0,b!=1),g.addVectors(m.a,m.b).multiplyScalar(y),t.set(0,0,0),a=0;a<b;a++){for(v=m.faces[a],n=0;n<3&&(f=o[g8(v,m8[n])],!(f!==m.a&&f!==m.b));n++);f&&t.add(f)}t.multiplyScalar(x),g.add(t),m.newEdge=p.length,p.push(g)}let w,A,_,S,M,C,T,D=[];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),_=w,i<=2&&(i==2?(A=3/4,_=1/8):i==1||i==0),T=C.clone().multiplyScalar(A),t.set(0,0,0),a=0;a<i;a++)S=M[a],f=S.a!==C?S.a:S.b,t.add(f);t.multiplyScalar(Number(_)),T.add(t),D.push(T)}let P=D.concat(p),I=D.length,R,U,N,L=[],W=[],G,j,k,q,H=new F,Y=new F,V=new F;for(r=0,s=l.length;r<s;r++)v=l[r],R=Number(Lm(v.a,v.b,d).newEdge)+I,U=Number(Lm(v.b,v.c,d).newEdge)+I,N=Number(Lm(v.c,v.a,d).newEdge)+I,lu(L,R,U,N,v.materialIndex),lu(L,v.a,R,N,v.materialIndex),lu(L,v.b,U,R,v.materialIndex),lu(L,v.c,N,U,v.materialIndex),u&&(G=h[r],j=G[0],k=G[1],q=G[2],H.set(tl(j.x,k.x),tl(j.y,k.y)),Y.set(tl(k.x,q.x),tl(k.y,q.y)),V.set(tl(j.x,q.x),tl(j.y,q.y)),hu(W,H,Y,V),hu(W,j,H,V),hu(W,k,Y,H),hu(W,q,V,Y));e.vertices=P,e.faces=L,u&&(e.faceVertexUvs[0]=W)}},yi=new E,x8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new Ue().copy(new ta(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(yi),r={width:yi.x,height:yi.y,depth:yi.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,a=e.geometry??new Ue().copy(new ta(100,100,100)),n=a.userData.parameters;n===void 0?(a.computeBoundingBox(),a.boundingBox.getSize(yi)):yi.set(n.width,n.height,n.depth),(t!==yi.x||i!==yi.y||r!==yi.z)&&a.scale(yi.x===0?1:t/yi.x,yi.y===0?1:i/yi.y,yi.z===0?1:r/yi.z);let o=a.originalGeometry;try{s>0?(o===void 0||n?.subdivisions!==s)&&(o===void 0&&(o=a),a=new y8(s).modify(o).toBufferGeometry()):(o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals())}catch{o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals()}return o!==void 0&&Object.assign(a,{originalGeometry:o}),delete e.geometry,Object.assign(a,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new VA(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(yi);let a=100/yi.x;Object.assign(s.parameters,{width:100,height:yi.y*a,depth:yi.z*a}),t(this.build(s))})}},BM=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 Zt?e.shape:new Zt,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:a,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5,c=0,d=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let g=p*m,v=c+Math.sin(g)*h,y=d+Math.cos(g)*u;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=s;l.roundness=s,l.update();let f=Do.create({shape:l,parameters:{roundness:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},b8=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:a,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new _8(t*.5,i,s,a,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Zh(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function zm(e,t,i,r,s,a){let n=t.clone().sub(e),o=i.clone().sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===s){let h=n.add(o).normalize();a.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=n.angleTo(o);a.copy(e),a.addScaledVector(n,s/Math.sin(h)),a.addScaledVector(o,r/Math.sin(h))}}function w8(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var _8=class extends Ue{constructor(e=.5,t=1,i=4,r=1,s=!1,a=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o=[],l=[],h=[],u=[],c=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,g=(i-2)*Math.PI/i,v=Math.PI-g,y=new E(0,-d,0),x=new E(0,d,0),b=new F(e,-d),w=new F(f,-d),A=new F(0,x.y).sub(w),_=new F(0,x.y).sub(b),S=new F(A.y,-A.x).normalize(),M=new F(_.y,-_.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,C);let T;{let L=new E(S.x,S.y,0),W=new E(Math.cos(m)*L.x,L.y,Math.sin(m)*L.x);T=L.angleTo(W)}let D=a/Math.tan((Math.PI-A.angle())/2),P=a/Math.tan((Math.PI-T)/2),I=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),u.push(0,0);let L=c++,W=[],G=b.clone(),j=D/Math.cos(Math.PI/i);G.x-=j;for(let k=0;k<i;k++){let q=k/i*Math.PI*2+p,H=new F(Math.sin(q),Math.cos(q));Zh(G,H,I),l.push(I.x,I.y,I.z),h.push(0,-1,0),u.push(0,0),W.push(c++)}for(let k=0;k<W.length;k++)o.push(W[k],L,W[(k+1)%W.length])}let R=[];{let L=new E,W=new E,G=new E,j=new E,k=new E,q=new E;for(let H=0;H<i;H++){let Y=H/i*Math.PI*2+p,V=(H+.5)/i*Math.PI*2+p,ie=(H+1)/i*Math.PI*2+p,Q=new F(Math.sin(Y),Math.cos(Y)),re=new F(Math.sin(V),Math.cos(V)),Z=new F(Math.sin(ie),Math.cos(ie));Zh(b,Q,W),Zh(b,Z,G),Zh(S,re,L),zm(x,W,G,P,P,j),l.push(j.x,j.y,j.z),zm(W,x,G,P,D,k),l.push(k.x,k.y,k.z),zm(G,W,x,D,P,q),l.push(q.x,q.y,q.z),h.push(L.x,L.y,L.z),h.push(L.x,L.y,L.z),h.push(L.x,L.y,L.z),u.push(0,0),u.push(0,0),u.push(0,0);let pe=c++,oe=c++,ae=c++;if(o.push(pe,oe,ae),a>0){{let Ee=W.clone().add(G).multiplyScalar(.5),Ie=x.clone().sub(Ee).normalize(),be=y.clone().sub(Ee).normalize().add(Ie).normalize().multiplyScalar(-1),ye=q.clone().sub(k);U(Ee,ye,be,A.angle())}let Me,Ae;{let Ee=new E;Zh(M,Z,Ee);let Ie=q.clone().add(j).multiplyScalar(.5);Ie=w8(Ie,G,x);let be=q.clone().sub(j);[Me,Ae]=U(Ie,be,Ee,T,j.y)}{let Ee=Me,Ie=Ee.clone().setY(0).normalize(),be=new E(0,-1,0),ye=Ie.clone().cross(be);N(Ee,Ie,be,ye)}R.concat(Ae);{let Ee=A.angle(),Ie=Math.PI-Ee,be=x.clone();be.y-=a/Math.sin(Ee-Math.PI/2);let ye=new E,ke=[];for(let z=0;z<n;z++){let O=[],$=Math.PI/2-Ie*z/n,ge=Math.cos($),de=Math.sin($),xe=V;for(let Be=0;Be<=z;Be++){let Ce=Math.cos(xe),ue=Math.sin(xe);L.x=ge*ue,L.y=de,L.z=ge*Ce,ye.copy(be).addScaledVector(L,a),l.push(ye.x,ye.y,ye.z),h.push(L.x,L.y,L.z),u.push(0,0),O.push(c++),xe+=Math.PI*2/z/i}ke.push(O)}Ae.reverse(),ke.push(Ae);let Je=ke.length-1;for(let z=0;z<Je;z++){let O=ke[z],$=ke[z+1],ge=O.length-1;o.push($[1],O[0],$[0]);for(let de=1;de<=ge;de++)o.push(O[de],O[de-1],$[de]),o.push($[de+1],O[de],$[de])}}}}}this.setIndex(o),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(u,2));function U(L,W,G,j,k){let q=-j/2,H=(Math.PI-j)/2,Y=W.clone().normalize().cross(G);L.addScaledVector(G,-a/Math.sin(H));let V=new E,ie=new E,Q=1,re=c,Z=[];for(let pe=0;pe<=n;pe++){let oe=q+pe/n*j;ie.set(0,0,0),ie.addScaledVector(Y,Math.sin(oe)),ie.addScaledVector(G,Math.cos(oe));for(let ae=0;ae<=Q;ae++){let Me=ae/Q-.5;if(V.copy(L),V.addScaledVector(W,Me),V.addScaledVector(ie,a),k!=null){let Ae=Math.max(0,V.y-k);V.addScaledVector(W,-Ae/W.y)}l.push(V.x,V.y,V.z),h.push(ie.x,ie.y,ie.z),u.push(0,0),ae===0&&Z.push(c),c++}}for(let pe=0;pe<n;pe++)for(let oe=0;oe<Q;oe++){let ae=re+oe+(Q+1)*pe,Me=ae+(Q+1),Ae=Me+1,Ee=ae+1;o.push(ae,Me,Ee),o.push(Me,Ae,Ee)}return[L.clone().addScaledVector(W,.5),Z]}function N(L,W,G,j){let k=Math.PI/2,q=_.angle()-k,H=[],Y=new E,V=new E;for(let Q=0;Q<=n;Q++){let re=[],Z=Q/n;for(let pe=0;pe<=Q;pe++){let oe=((Q?pe/Q:0)-.5)*v,ae=Math.cos(oe),Me=Math.sin(oe),Ae=Math.atan(Math.tan(q)*ae),Ee=(k+Ae)*Z,Ie=Math.cos(Ee),be=Math.sin(Ee);Y.set(0,0,0),Y.addScaledVector(W,be*ae),Y.addScaledVector(G,Ie),Y.addScaledVector(j,be*Me),V.copy(L).addScaledVector(Y,a),l.push(V.x,V.y,V.z),h.push(Y.x,Y.y,Y.z),u.push(0,0),re.push(c++)}H.push(re)}let ie=H.length-1;for(let Q=0;Q<ie;Q++){let re=H[Q],Z=H[Q+1],pe=re.length-1;o.push(re[0],Z[1],Z[0]);for(let oe=1;oe<=pe;oe++)o.push(re[oe-1],re[oe],Z[oe]),o.push(re[oe],Z[oe+1],Z[oe])}}}},zM=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 Zt?e.shape:new Zt,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:a,depth:n,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(b,w,A){return w>i&&A>r?Math.min(b*i/w,b*r/A):w>i?b*i/w:A>r?b*r/A:b}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,m=c.x,g=c.y,v=u.y;t.addPoint(t.createPoint(f,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let b=0,w=t.points.length;b<w;b++)t.points[b].roundness=p[b],b>0&&p[b]!==p[b-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=a!==1,t.update();let x=Do.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},S8=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:180},e.parameters);return i.thetaLength=Le.clamp(i.thetaLength,0,180),{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:a=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,u;return h===0?(u=new Ue,u.setAttribute("position",new Te([],3))):u=new I0(.5*t,s,a,n,o,l,h*Le.DEG2RAD),u.scale(1,i/t,r/t),Object.assign(u,{userData:{...e,type:"SphereGeometry"}})}},A8=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,a=new jp(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}},M8=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:a,cornerSegments:n}=e.parameters,o=new E8(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},E8=class extends Ue{constructor(e=1,t=1,i=1,r=90,s=10,a=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;s==0&&(a=1),a=Math.max(1,Math.floor(a)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],c=Math.PI/2,d=(ie=0,Q=0,re=0)=>new E(ie,Q,re),p=d(),f=d(),[m,g,v]=[t/2,e/2,i/2],y=-g,x=+g,[b,w,A]=[d(y,-m,+v),d(y,-m,-v),d(y,+m,-v)],_=(ie,Q=!1)=>Math.sin(ie-Math.PI/(1+ +Q)),S=(ie,Q=!1)=>Math.cos(ie-Math.PI/(1+ +Q));A.y=Math.sin(r)*t-m;let M=Math.cos(r)*t-v,C=b.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,b.z-h),p.subVectors(b,w),f.subVectors(A,w);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),P=T/Math.cos(r/2),I=p.clone().normalize().add(f.normalize()).setLength(P).add(w);p.set(0,_(r,!0),S(r,!0)),u.push([A,p.clone()]);let R=(Math.PI-r)/a;for(let ie=0;ie<=a;ie++){let Q=c+r+ie*R;p.set(0,Math.sin(Q)*D,Math.cos(Q)*D),p.add(I),f.set(0,_(Q),S(Q)),u.push([p.clone(),f.clone()])}u.push([b,d(0,1,0)]);let U=Math.sin(R/2)*D*2,N=u.length-1,L=u[0][0].distanceTo(u[1][0]),W=u[N-1][0].distanceTo(u[N][0]),G=L+U*a+W;u[0].push(1);for(let ie=0;ie<=a;ie++)u[ie+1].push(1-(L+ie*U)/G);u[N].push(0);let[j,k,q]=u[0],H,Y,V;for(let ie=1;ie<u.length;ie++)[H,Y,V]=u[ie],n.push(y,j.y,j.z,y,H.y,H.z,x,j.y,j.z,x,j.y,j.z,y,H.y,H.z,x,H.y,H.z),o.push(0,k.y,k.z,0,Y.y,Y.z,0,k.y,k.z,0,k.y,k.z,0,Y.y,Y.z,0,Y.y,Y.z),l.push(0,q,0,V,1,q,1,q,0,V,1,V),[j,k,q]=[H,Y,V];this.setAttribute("position",new Te(n,3)),this.setAttribute("normal",new Te(o,3)),this.setAttribute("uv",new Te(l,2))}},kM=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 Zt?e.shape:new Zt,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:a,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,u=e.shape,c=t*.5,d=i*.5,p=0,f=0,m=n*Math.PI/360/s,g=Math.PI/2*3*-1,v=c*r/100,y=d*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let w=m*b,A=p+Math.sin(w)*c,_=f+Math.cos(w)*d;u.addPoint(u.createPoint(A,_))}}else for(let b=0;b<s;b++){let w=p+Math.cos(g)*c,A=f+Math.sin(g)*d;u.addPoint(u.createPoint(w,A)),g+=m,w=p+Math.cos(g)*v,A=f+Math.sin(g)*y,b<=s,u.addPoint(u.createPoint(w,A)),g+=m}u.isClosed=!0;for(let b=0,w=u.points.length;b<w;b++)u.points[b].roundness=a;u.roundness=a,u.update();let x=Do.create({shape:u,parameters:{roundness:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},C8=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 jp(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},T8=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:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:a})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:a,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=D8(t,i,r,t*.5,n,a,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function D8(e,t,i,r,s,a,n,o,l,h,u){[t,i]=[i,t],n=t/2;let c=Le.clamp(s/360,0,1);if(c===0){let d=new Ue;return d.setAttribute("position",new Te([],3)),d}return c===1&&(h=0),new RM(!0,e,t,i,r,c,a,n,o,l,h,u)}var P8=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:a,q:n}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new LA(o,i,r,s,a,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},I8=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 Zt?e.shape:new Zt,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:a,extrudeBevelSegments:n,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=Do.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function O8(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var R8=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},L8=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},se=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+se.version}static addUnaryOp(e){return se.max_unop_len=Math.max(e.length,se.max_unop_len),se.unary_ops[e]=1,se}static addBinaryOp(e,t,i){return se.max_binop_len=Math.max(e.length,se.max_binop_len),se.binary_ops[e]=t,i?se.right_associative.add(e):se.right_associative.delete(e),se}static addIdentifierChar(e){return se.additional_identifier_chars.add(e),se}static addLiteral(e,t){return se.literals[e]=t,se}static removeUnaryOp(e){return delete se.unary_ops[e],e.length===se.max_unop_len&&(se.max_unop_len=se.getMaxKeyLen(se.unary_ops)),se}static removeAllUnaryOps(){return se.unary_ops={},se.max_unop_len=0,se}static removeIdentifierChar(e){return se.additional_identifier_chars.delete(e),se}static removeBinaryOp(e){return delete se.binary_ops[e],e.length===se.max_binop_len&&(se.max_binop_len=se.getMaxKeyLen(se.binary_ops)),se.right_associative.delete(e),se}static removeAllBinaryOps(){return se.binary_ops={},se.max_binop_len=0,se}static removeLiteral(e){return delete se.literals[e],se}static removeAllLiterals(){return se.literals={},se}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new se(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return se.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!se.binary_ops[String.fromCharCode(e)]||se.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return se.isIdentifierStart(e)||se.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(se.hooks[e]){let i={context:this,node:t};return se.hooks.run(e,i),i.node}return t}searchHook(e){if(se.hooks[e]){let t={context:this};return se.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===se.SPACE_CODE||e===se.TAB_CODE||e===se.LF_CODE||e===se.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:se.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index<this.expr.length;)if(i=this.code,i===se.SEMCOL_CODE||i===se.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(i===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,se.max_binop_len),t=e.length;for(;t>0;){if(se.binary_ops.hasOwnProperty(e)&&(!se.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!se.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,i,r,s,a,n,o,l;if(a=this.gobbleToken(),!a||(t=this.gobbleBinaryOp(),!t))return a;for(s={value:t,prec:se.binaryPrecedence(t),right_a:se.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[a,s,n];t=this.gobbleBinaryOp();){if(i=se.binaryPrecedence(t),i===0){this.index-=t.length;break}s={value:t,prec:i,right_a:se.right_associative.has(t)},l=t;let h=u=>s.right_a&&u.right_a?i>u.prec:i<=u.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,a=r.pop(),e={type:se.BINARY_EXP,operator:t,left:a,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(s,e)}for(o=r.length-1,e=r[o];o>1;)e={type:se.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,se.isDecimalDigit(e)||e===se.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===se.SQUOTE_CODE||e===se.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===se.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,se.max_unop_len),i=t.length;i>0;){if(se.unary_ops.hasOwnProperty(t)&&(!se.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!se.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=i;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:se.UNARY_EXP,operator:t,argument:s,prefix:!0})}t=t.substr(0,--i)}se.isIdentifierStart(e)?(r=this.gobbleIdentifier(),se.literals.hasOwnProperty(r.name)?r={type:se.LITERAL,value:se.literals[r.name],raw:r.name}:r.name===se.this_str&&(r={type:se.THIS_EXP})):e===se.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===se.PERIOD_CODE||t===se.OBRACK_CODE||t===se.OPAREN_CODE||t===se.QUMARK_CODE;){let i;if(t===se.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==se.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===se.OBRACK_CODE?(e={type:se.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==se.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===se.OPAREN_CODE?e={type:se.CALL_EXP,arguments:this.gobbleArguments(se.CPAREN_CODE),callee:e}:(t===se.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:se.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,i;for(;se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===se.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);se.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,se.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===se.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===se.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:se.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===i){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":e+=`
|
|
3152
|
+
}`;function SR(e,t,i){let r=new S0,s=new F,a=new F,n=new rt,o=new xA({depthPacking:aA}),l=new bR,h={},u=i.maxTextureSize,c={[Ms]:Pi,[Pi]:Ms,[Sr]:Sr},d=new Lt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:wR,fragmentShader:_R}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ue;f.setAttribute("position",new Ze(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new hr(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=v0,this.render=function(b,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=e.getRenderTarget(),S=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,D=b.length;T<D;T++){let P=b[T],I=P.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;s.copy(I.mapSize);let R=I.getFrameExtents();if(s.multiply(R),a.copy(I.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(a.x=Math.floor(u/R.x),s.x=a.x*R.x,I.mapSize.x=a.x),s.y>u&&(a.y=Math.floor(u/R.y),s.y=a.y*R.y,I.mapSize.y=a.y)),I.map===null){let N=this.type!==oc?{minFilter:kt,magFilter:kt}:{};I.map=new Dt(s.x,s.y,N),I.map.texture.name=P.name+".shadowMap",I.camera.updateProjectionMatrix()}e.setRenderTarget(I.map),e.clear();let U=I.getViewportCount();for(let N=0;N<U;N++){let L=I.getViewport(N);n.set(a.x*L.x,a.y*L.y,a.x*L.z,a.y*L.w),C.viewport(n),I.updateMatrices(P,N),r=I.getFrustum(),x(w,A,I.camera,P,this.type)}I.isPointLightShadow!==!0&&this.type===oc&&v(I,A),I.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(_,S,M)};function v(b,w){let A=t.update(m);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Dt(s.x,s.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,e.setRenderTarget(b.mapPass),e.clear(),e.renderBufferDirect(w,null,A,d,m,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,e.setRenderTarget(b.map),e.clear(),e.renderBufferDirect(w,null,A,p,m,null)}function y(b,w,A,_,S,M){let C=null,T=A.isPointLight===!0?b.customDistanceMaterial:b.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 D=C.uuid,P=w.uuid,I=h[D];I===void 0&&(I={},h[D]=I);let R=I[P];R===void 0&&(R=C.clone(),I[P]=R),C=R}return C.visible=w.visible,C.wireframe=w.wireframe,M===oc?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=_,C.farDistance=S),C}function x(b,w,A,_,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===oc)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let C=t.update(b),T=b.material;if(Array.isArray(T)){let D=C.groups;for(let P=0,I=D.length;P<I;P++){let R=D[P],U=T[R.materialIndex];if(U&&U.visible){let N=y(b,U,_,A.near,A.far,S);e.renderBufferDirect(A,null,C,N,b,R)}}}else if(T.visible){let D=y(b,T,_,A.near,A.far,S);e.renderBufferDirect(A,null,C,D,b,null)}}let M=b.children;for(let C=0,T=M.length;C<T;C++)x(M[C],w,A,_,S)}}function AR(e,t,i){let r=i.isWebGL2;function s(){let X=!1,ne=new rt,ve=null,_e=new rt(0,0,0,0);return{setMask:function(qe){ve!==qe&&!X&&(e.colorMask(qe,qe,qe,qe),ve=qe)},setLocked:function(qe){X=qe},setClear:function(qe,wt,Gt,Ui,zn){zn===!0&&(qe*=Ui,wt*=Ui,Gt*=Ui),ne.set(qe,wt,Gt,Ui),_e.equals(ne)===!1&&(e.clearColor(qe,wt,Gt,Ui),_e.copy(ne))},reset:function(){X=!1,ve=null,_e.set(-1,0,0,0)}}}function a(){let X=!1,ne=null,ve=null,_e=null;return{setTest:function(qe){qe?ie(2929):Q(2929)},setMask:function(qe){ne!==qe&&!X&&(e.depthMask(qe),ne=qe)},setFunc:function(qe){if(ve!==qe){switch(qe){case HT:e.depthFunc(512);break;case WT:e.depthFunc(519);break;case qT:e.depthFunc(513);break;case Cg:e.depthFunc(515);break;case YT:e.depthFunc(514);break;case XT:e.depthFunc(518);break;case QT:e.depthFunc(516);break;case ZT:e.depthFunc(517);break;default:e.depthFunc(515)}ve=qe}},setLocked:function(qe){X=qe},setClear:function(qe){_e!==qe&&(e.clearDepth(qe),_e=qe)},reset:function(){X=!1,ne=null,ve=null,_e=null}}}function n(){let X=!1,ne=null,ve=null,_e=null,qe=null,wt=null,Gt=null,Ui=null,zn=null;return{setTest:function(jt){X||(jt?ie(2960):Q(2960))},setMask:function(jt){ne!==jt&&!X&&(e.stencilMask(jt),ne=jt)},setFunc:function(jt,ha,Vr){(ve!==jt||_e!==ha||qe!==Vr)&&(e.stencilFunc(jt,ha,Vr),ve=jt,_e=ha,qe=Vr)},setOp:function(jt,ha,Vr){(wt!==jt||Gt!==ha||Ui!==Vr)&&(e.stencilOp(jt,ha,Vr),wt=jt,Gt=ha,Ui=Vr)},setLocked:function(jt){X=jt},setClear:function(jt){zn!==jt&&(e.clearStencil(jt),zn=jt)},reset:function(){X=!1,ne=null,ve=null,_e=null,qe=null,wt=null,Gt=null,Ui=null,zn=null}}}let o=new s,l=new a,h=new n,u=new WeakMap,c=new WeakMap,d={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,b=null,w=null,A=null,_=null,S=null,M=!1,C=null,T=null,D=null,P=null,I=null,R=e.getParameter(35661),U=!1,N=0,L=e.getParameter(7938);L.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL (\d)/.exec(L)[1]),U=N>=1):L.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),U=N>=2);let W=null,G={},j=e.getParameter(3088),k=e.getParameter(2978),q=new rt().fromArray(j),H=new rt().fromArray(k);function Y(X,ne,ve){let _e=new Uint8Array(4),qe=e.createTexture();e.bindTexture(X,qe),e.texParameteri(X,10241,9728),e.texParameteri(X,10240,9728);for(let wt=0;wt<ve;wt++)e.texImage2D(ne+wt,0,6408,1,1,0,6408,5121,_e);return qe}let V={};V[3553]=Y(3553,3553,1),V[34067]=Y(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ie(2929),l.setFunc(Cg),Ee(!1),Ie(f1),ie(2884),Me(fi);function ie(X){d[X]!==!0&&(e.enable(X),d[X]=!0)}function Q(X){d[X]!==!1&&(e.disable(X),d[X]=!1)}function re(X,ne){return p[X]!==ne?(e.bindFramebuffer(X,ne),p[X]=ne,r&&(X===36009&&(p[36160]=ne),X===36160&&(p[36009]=ne)),!0):!1}function Z(X,ne){let ve=m,_e=!1;if(X)if(ve=f.get(ne),ve===void 0&&(ve=[],f.set(ne,ve)),X.isWebGLMultipleRenderTargets){let qe=X.texture;if(ve.length!==qe.length||ve[0]!==36064){for(let wt=0,Gt=qe.length;wt<Gt;wt++)ve[wt]=36064+wt;ve.length=qe.length,_e=!0}}else ve[0]!==36064&&(ve[0]=36064,_e=!0);else ve[0]!==1029&&(ve[0]=1029,_e=!0);_e&&(i.isWebGL2?e.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function pe(X){return g!==X?(e.useProgram(X),g=X,!0):!1}let oe={[ml]:32774,[RT]:32778,[LT]:32779};if(r)oe[y1]=32775,oe[x1]=32776;else{let X=t.get("EXT_blend_minmax");X!==null&&(oe[y1]=X.MIN_EXT,oe[x1]=X.MAX_EXT)}let ae={[BT]:0,[zT]:1,[kT]:768,[KS]:770,[GT]:776,[VT]:774,[UT]:772,[NT]:769,[JS]:771,[jT]:775,[FT]:773};function Me(X,ne,ve,_e,qe,wt,Gt,Ui){if(X===fi){v===!0&&(Q(3042),v=!1);return}if(v===!1&&(ie(3042),v=!0),X!==OT){if(X!==y||Ui!==M){if((x!==ml||A!==ml)&&(e.blendEquation(32774),x=ml,A=ml),Ui)switch(X){case ho:e.blendFuncSeparate(1,771,1,771);break;case m1:e.blendFunc(1,1);break;case g1:e.blendFuncSeparate(0,769,0,1);break;case v1:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",X);break}else switch(X){case ho:e.blendFuncSeparate(770,771,1,771);break;case m1:e.blendFunc(770,1);break;case g1:e.blendFuncSeparate(0,769,0,1);break;case v1:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",X);break}b=null,w=null,_=null,S=null,y=X,M=Ui}return}qe=qe||ne,wt=wt||ve,Gt=Gt||_e,(ne!==x||qe!==A)&&(e.blendEquationSeparate(oe[ne],oe[qe]),x=ne,A=qe),(ve!==b||_e!==w||wt!==_||Gt!==S)&&(e.blendFuncSeparate(ae[ve],ae[_e],ae[wt],ae[Gt]),b=ve,w=_e,_=wt,S=Gt),y=X,M=!1}function Ae(X,ne){X.side===Sr?Q(2884):ie(2884);let ve=X.side===Pi;ne&&(ve=!ve),Ee(ve),X.blending===ho&&X.transparent===!1?Me(fi):Me(X.blending,X.blendEquation,X.blendSrc,X.blendDst,X.blendEquationAlpha,X.blendSrcAlpha,X.blendDstAlpha,X.premultipliedAlpha),l.setFunc(X.depthFunc),l.setTest(X.depthTest),l.setMask(X.depthWrite),o.setMask(X.colorWrite);let _e=X.stencilWrite;h.setTest(_e),_e&&(h.setMask(X.stencilWriteMask),h.setFunc(X.stencilFunc,X.stencilRef,X.stencilFuncMask),h.setOp(X.stencilFail,X.stencilZFail,X.stencilZPass)),ye(X.polygonOffset,X.polygonOffsetFactor,X.polygonOffsetUnits),X.alphaToCoverage===!0?ie(32926):Q(32926)}function Ee(X){C!==X&&(X?e.frontFace(2304):e.frontFace(2305),C=X)}function Ie(X){X!==DT?(ie(2884),X!==T&&(X===f1?e.cullFace(1029):X===PT?e.cullFace(1028):e.cullFace(1032))):Q(2884),T=X}function be(X){X!==D&&(U&&e.lineWidth(X),D=X)}function ye(X,ne,ve){X?(ie(32823),(P!==ne||I!==ve)&&(e.polygonOffset(ne,ve),P=ne,I=ve)):Q(32823)}function ke(X){X?ie(3089):Q(3089)}function Je(X){X===void 0&&(X=33984+R-1),W!==X&&(e.activeTexture(X),W=X)}function z(X,ne,ve){ve===void 0&&(W===null?ve=33984+R-1:ve=W);let _e=G[ve];_e===void 0&&(_e={type:void 0,texture:void 0},G[ve]=_e),(_e.type!==X||_e.texture!==ne)&&(W!==ve&&(e.activeTexture(ve),W=ve),e.bindTexture(X,ne||V[X]),_e.type=X,_e.texture=ne)}function O(){let X=G[W];X!==void 0&&X.type!==void 0&&(e.bindTexture(X.type,null),X.type=void 0,X.texture=void 0)}function $(){try{e.compressedTexImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function ge(){try{e.compressedTexImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function de(){try{e.texSubImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function xe(){try{e.texSubImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Be(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Ce(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function ue(){try{e.texStorage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Oe(){try{e.texStorage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function ze(){try{e.texImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Re(){try{e.texImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Ke(X){q.equals(X)===!1&&(e.scissor(X.x,X.y,X.z,X.w),q.copy(X))}function je(X){H.equals(X)===!1&&(e.viewport(X.x,X.y,X.z,X.w),H.copy(X))}function vt(X,ne){let ve=c.get(ne);ve===void 0&&(ve=new WeakMap,c.set(ne,ve));let _e=ve.get(X);_e===void 0&&(_e=e.getUniformBlockIndex(ne,X.name),ve.set(X,_e))}function Nt(X,ne){let ve=c.get(ne).get(X);u.get(ne)!==ve&&(e.uniformBlockBinding(ne,ve,X.__bindingPointIndex),u.set(ne,ve))}function oi(){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={},W=null,G={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,b=null,w=null,A=null,_=null,S=null,M=!1,C=null,T=null,D=null,P=null,I=null,q.set(0,0,e.canvas.width,e.canvas.height),H.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ie,disable:Q,bindFramebuffer:re,drawBuffers:Z,useProgram:pe,setBlending:Me,setMaterial:Ae,setFlipSided:Ee,setCullFace:Ie,setLineWidth:be,setPolygonOffset:ye,setScissorTest:ke,activeTexture:Je,bindTexture:z,unbindTexture:O,compressedTexImage2D:$,compressedTexImage3D:ge,texImage2D:ze,texImage3D:Re,updateUBOMapping:vt,uniformBlockBinding:Nt,texStorage2D:ue,texStorage3D:Oe,texSubImage2D:de,texSubImage3D:xe,compressedTexSubImage2D:Be,compressedTexSubImage3D:Ce,scissor:Ke,viewport:je,reset:oi}}function MR(e,t,i,r,s,a,n){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,m,g=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(z,O){return v?new OffscreenCanvas(z,O):Zu("canvas")}function x(z,O,$,ge){let de=1;if((z.width>ge||z.height>ge)&&(de=ge/Math.max(z.width,z.height)),de<1||O===!0)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap){let xe=O?Qu:Math.floor,Be=xe(de*z.width),Ce=xe(de*z.height);m===void 0&&(m=y(Be,Ce));let ue=$?y(Be,Ce):m;return ue.width=Be,ue.height=Ce,ue.getContext("2d").drawImage(z,0,0,Be,Ce),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+Be+"x"+Ce+")."),ue}else return"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+")."),z;return z}function b(z){return Rg(z.width)&&Rg(z.height)}function w(z){return o?!1:z.wrapS!==ii||z.wrapT!==ii||z.minFilter!==kt&&z.minFilter!==lt}function A(z,O){return z.generateMipmaps&&O&&z.minFilter!==kt&&z.minFilter!==lt}function _(z){e.generateMipmap(z)}function S(z,O,$,ge,de=!1){if(o===!1)return O;if(z!==null){if(e[z]!==void 0)return e[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let xe=O;return O===6403&&($===5126&&(xe=33326),$===5131&&(xe=33325),$===5121&&(xe=33321)),O===33319&&($===5126&&(xe=33328),$===5131&&(xe=33327),$===5121&&(xe=33323)),O===6408&&($===5126&&(xe=34836),$===5131&&(xe=34842),$===5121&&(xe=ge===it&&de===!1?35907:32856),$===32819&&(xe=32854),$===32820&&(xe=32855)),(xe===33325||xe===33326||xe===33327||xe===33328||xe===34842||xe===34836)&&t.get("EXT_color_buffer_float"),xe}function M(z,O,$){return A(z,$)===!0||z.isFramebufferTexture&&z.minFilter!==kt&&z.minFilter!==lt?Math.log2(Math.max(O.width,O.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?O.mipmaps.length:1}function C(z){return z===kt||z===b1||z===Mf?9728:9729}function T(z){let O=z.target;O.removeEventListener("dispose",T),P(O),O.isVideoTexture&&f.delete(O)}function D(z){let O=z.target;O.removeEventListener("dispose",D),R(O)}function P(z){let O=r.get(z);if(O.__webglInit===void 0)return;let $=z.source,ge=g.get($);if(ge){let de=ge[O.__cacheKey];de.usedTimes--,de.usedTimes===0&&I(z),Object.keys(ge).length===0&&g.delete($)}r.remove(z)}function I(z){let O=r.get(z);e.deleteTexture(O.__webglTexture);let $=z.source,ge=g.get($);delete ge[O.__cacheKey],n.memory.textures--}function R(z){let O=z.texture,$=r.get(z),ge=r.get(O);if(ge.__webglTexture!==void 0&&(e.deleteTexture(ge.__webglTexture),n.memory.textures--),z.depthTexture&&z.depthTexture.dispose(),z.isWebGLCubeRenderTarget)for(let de=0;de<6;de++)e.deleteFramebuffer($.__webglFramebuffer[de]),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer[de]);else{if(e.deleteFramebuffer($.__webglFramebuffer),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer),$.__webglMultisampledFramebuffer&&e.deleteFramebuffer($.__webglMultisampledFramebuffer),$.__webglColorRenderbuffer)for(let de=0;de<$.__webglColorRenderbuffer.length;de++)$.__webglColorRenderbuffer[de]&&e.deleteRenderbuffer($.__webglColorRenderbuffer[de]);$.__webglDepthRenderbuffer&&e.deleteRenderbuffer($.__webglDepthRenderbuffer)}if(z.isWebGLMultipleRenderTargets)for(let de=0,xe=O.length;de<xe;de++){let Be=r.get(O[de]);Be.__webglTexture&&(e.deleteTexture(Be.__webglTexture),n.memory.textures--),r.remove(O[de])}r.remove(O),r.remove(z)}let U=0;function N(){U=0}function L(){let z=U;return z>=l&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+l),U+=1,z}function W(z){let O=[];return O.push(z.wrapS),O.push(z.wrapT),O.push(z.wrapR||0),O.push(z.magFilter),O.push(z.minFilter),O.push(z.anisotropy),O.push(z.internalFormat),O.push(z.format),O.push(z.type),O.push(z.generateMipmaps),O.push(z.premultiplyAlpha),O.push(z.flipY),O.push(z.unpackAlignment),O.push(z.encoding),O.join()}function G(z,O){let $=r.get(z);if(z.isVideoTexture&&ke(z),z.isRenderTargetTexture===!1&&z.version>0&&$.__version!==z.version){let ge=z.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q($,z,O);return}}i.bindTexture(3553,$.__webglTexture,33984+O)}function j(z,O){let $=r.get(z);if(z.version>0&&$.__version!==z.version){Q($,z,O);return}i.bindTexture(35866,$.__webglTexture,33984+O)}function k(z,O){let $=r.get(z);if(z.version>0&&$.__version!==z.version){Q($,z,O);return}i.bindTexture(32879,$.__webglTexture,33984+O)}function q(z,O){let $=r.get(z);if(z.version>0&&$.__version!==z.version){re($,z,O);return}i.bindTexture(34067,$.__webglTexture,33984+O)}let H={[Ra]:10497,[ii]:33071,[Pg]:33648},Y={[kt]:9728,[b1]:9984,[Mf]:9986,[lt]:9729,[s3]:9985,[Yl]:9987};function V(z,O,$){if($?(e.texParameteri(z,10242,H[O.wrapS]),e.texParameteri(z,10243,H[O.wrapT]),(z===32879||z===35866)&&e.texParameteri(z,32882,H[O.wrapR]),e.texParameteri(z,10240,Y[O.magFilter]),e.texParameteri(z,10241,Y[O.minFilter])):(e.texParameteri(z,10242,33071),e.texParameteri(z,10243,33071),(z===32879||z===35866)&&e.texParameteri(z,32882,33071),(O.wrapS!==ii||O.wrapT!==ii)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(z,10240,C(O.magFilter)),e.texParameteri(z,10241,C(O.minFilter)),O.minFilter!==kt&&O.minFilter!==lt&&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 ge=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===kt||O.minFilter!==Mf&&O.minFilter!==Yl||O.type===lr&&t.has("OES_texture_float_linear")===!1||o===!1&&O.type===bo&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(e.texParameterf(z,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,s.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function ie(z,O){let $=!1;z.__webglInit===void 0&&(z.__webglInit=!0,O.addEventListener("dispose",T));let ge=O.source,de=g.get(ge);de===void 0&&(de={},g.set(ge,de));let xe=W(O);if(xe!==z.__cacheKey){de[xe]===void 0&&(de[xe]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,$=!0),de[xe].usedTimes++;let Be=de[z.__cacheKey];Be!==void 0&&(de[z.__cacheKey].usedTimes--,Be.usedTimes===0&&I(O)),z.__cacheKey=xe,z.__webglTexture=de[xe].texture}return $}function Q(z,O,$){let ge=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ge=35866),O.isData3DTexture&&(ge=32879);let de=ie(z,O),xe=O.source;i.bindTexture(ge,z.__webglTexture,33984+$);let Be=r.get(xe);if(xe.version!==Be.__version||de===!0){i.activeTexture(33984+$),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Ce=w(O)&&b(O.image)===!1,ue=x(O.image,Ce,!1,u);ue=Je(O,ue);let Oe=b(ue)||o,ze=a.convert(O.format,O.encoding),Re=a.convert(O.type),Ke=S(O.internalFormat,ze,Re,O.encoding,O.isVideoTexture);V(ge,O,Oe);let je,vt=O.mipmaps,Nt=o&&O.isVideoTexture!==!0,oi=Be.__version===void 0||de===!0,X=M(O,ue,Oe);if(O.isDepthTexture)Ke=6402,o?O.type===lr?Ke=36012:O.type===La?Ke=33190:O.type===co?Ke=35056:Ke=33189:O.type===lr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===uo&&Ke===6402&&O.type!==tA&&O.type!==La&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=La,Re=a.convert(O.type)),O.format===wo&&Ke===6402&&(Ke=34041,O.type!==co&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=co,Re=a.convert(O.type))),oi&&(Nt?i.texStorage2D(3553,1,Ke,ue.width,ue.height):i.texImage2D(3553,0,Ke,ue.width,ue.height,0,ze,Re,null));else if(O.isDataTexture)if(vt.length>0&&Oe){Nt&&oi&&i.texStorage2D(3553,X,Ke,vt[0].width,vt[0].height);for(let ne=0,ve=vt.length;ne<ve;ne++)je=vt[ne],Nt?i.texSubImage2D(3553,ne,0,0,je.width,je.height,ze,Re,je.data):i.texImage2D(3553,ne,Ke,je.width,je.height,0,ze,Re,je.data);O.generateMipmaps=!1}else Nt?(oi&&i.texStorage2D(3553,X,Ke,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ue.width,ue.height,ze,Re,ue.data)):i.texImage2D(3553,0,Ke,ue.width,ue.height,0,ze,Re,ue.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Nt&&oi&&i.texStorage3D(35866,X,Ke,vt[0].width,vt[0].height,ue.depth);for(let ne=0,ve=vt.length;ne<ve;ne++)je=vt[ne],O.format!==Nr?ze!==null?Nt?i.compressedTexSubImage3D(35866,ne,0,0,0,je.width,je.height,ue.depth,ze,je.data,0,0):i.compressedTexImage3D(35866,ne,Ke,je.width,je.height,ue.depth,0,je.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?i.texSubImage3D(35866,ne,0,0,0,je.width,je.height,ue.depth,ze,Re,je.data):i.texImage3D(35866,ne,Ke,je.width,je.height,ue.depth,0,ze,Re,je.data)}else{Nt&&oi&&i.texStorage2D(3553,X,Ke,vt[0].width,vt[0].height);for(let ne=0,ve=vt.length;ne<ve;ne++)je=vt[ne],O.format!==Nr?ze!==null?Nt?i.compressedTexSubImage2D(3553,ne,0,0,je.width,je.height,ze,je.data):i.compressedTexImage2D(3553,ne,Ke,je.width,je.height,0,je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?i.texSubImage2D(3553,ne,0,0,je.width,je.height,ze,Re,je.data):i.texImage2D(3553,ne,Ke,je.width,je.height,0,ze,Re,je.data)}else if(O.isDataArrayTexture)Nt?(oi&&i.texStorage3D(35866,X,Ke,ue.width,ue.height,ue.depth),i.texSubImage3D(35866,0,0,0,0,ue.width,ue.height,ue.depth,ze,Re,ue.data)):i.texImage3D(35866,0,Ke,ue.width,ue.height,ue.depth,0,ze,Re,ue.data);else if(O.isData3DTexture)Nt?(oi&&i.texStorage3D(32879,X,Ke,ue.width,ue.height,ue.depth),i.texSubImage3D(32879,0,0,0,0,ue.width,ue.height,ue.depth,ze,Re,ue.data)):i.texImage3D(32879,0,Ke,ue.width,ue.height,ue.depth,0,ze,Re,ue.data);else if(O.isFramebufferTexture){if(oi)if(Nt)i.texStorage2D(3553,X,Ke,ue.width,ue.height);else{let ne=ue.width,ve=ue.height;for(let _e=0;_e<X;_e++)i.texImage2D(3553,_e,Ke,ne,ve,0,ze,Re,null),ne>>=1,ve>>=1}}else if(vt.length>0&&Oe){Nt&&oi&&i.texStorage2D(3553,X,Ke,vt[0].width,vt[0].height);for(let ne=0,ve=vt.length;ne<ve;ne++)je=vt[ne],Nt?i.texSubImage2D(3553,ne,0,0,ze,Re,je):i.texImage2D(3553,ne,Ke,ze,Re,je);O.generateMipmaps=!1}else Nt?(oi&&i.texStorage2D(3553,X,Ke,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ze,Re,ue)):i.texImage2D(3553,0,Ke,ze,Re,ue);A(O,Oe)&&_(ge),Be.__version=xe.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function re(z,O,$){if(O.image.length!==6)return;let ge=ie(z,O),de=O.source;i.bindTexture(34067,z.__webglTexture,33984+$);let xe=r.get(de);if(de.version!==xe.__version||ge===!0){i.activeTexture(33984+$),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Be=O.isCompressedTexture||O.image[0].isCompressedTexture,Ce=O.image[0]&&O.image[0].isDataTexture,ue=[];for(let ne=0;ne<6;ne++)!Be&&!Ce?ue[ne]=x(O.image[ne],!1,!0,h):ue[ne]=Ce?O.image[ne].image:O.image[ne],ue[ne]=Je(O,ue[ne]);let Oe=ue[0],ze=b(Oe)||o,Re=a.convert(O.format,O.encoding),Ke=a.convert(O.type),je=S(O.internalFormat,Re,Ke,O.encoding),vt=o&&O.isVideoTexture!==!0,Nt=xe.__version===void 0||ge===!0,oi=M(O,Oe,ze);V(34067,O,ze);let X;if(Be){vt&&Nt&&i.texStorage2D(34067,oi,je,Oe.width,Oe.height);for(let ne=0;ne<6;ne++){X=ue[ne].mipmaps;for(let ve=0;ve<X.length;ve++){let _e=X[ve];O.format!==Nr?Re!==null?vt?i.compressedTexSubImage2D(34069+ne,ve,0,0,_e.width,_e.height,Re,_e.data):i.compressedTexImage2D(34069+ne,ve,je,_e.width,_e.height,0,_e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):vt?i.texSubImage2D(34069+ne,ve,0,0,_e.width,_e.height,Re,Ke,_e.data):i.texImage2D(34069+ne,ve,je,_e.width,_e.height,0,Re,Ke,_e.data)}}}else{X=O.mipmaps,vt&&Nt&&(X.length>0&&oi++,i.texStorage2D(34067,oi,je,ue[0].width,ue[0].height));for(let ne=0;ne<6;ne++)if(Ce){vt?i.texSubImage2D(34069+ne,0,0,0,ue[ne].width,ue[ne].height,Re,Ke,ue[ne].data):i.texImage2D(34069+ne,0,je,ue[ne].width,ue[ne].height,0,Re,Ke,ue[ne].data);for(let ve=0;ve<X.length;ve++){let _e=X[ve].image[ne].image;vt?i.texSubImage2D(34069+ne,ve+1,0,0,_e.width,_e.height,Re,Ke,_e.data):i.texImage2D(34069+ne,ve+1,je,_e.width,_e.height,0,Re,Ke,_e.data)}}else{vt?i.texSubImage2D(34069+ne,0,0,0,Re,Ke,ue[ne]):i.texImage2D(34069+ne,0,je,Re,Ke,ue[ne]);for(let ve=0;ve<X.length;ve++){let _e=X[ve];vt?i.texSubImage2D(34069+ne,ve+1,0,0,Re,Ke,_e.image[ne]):i.texImage2D(34069+ne,ve+1,je,Re,Ke,_e.image[ne])}}}A(O,ze)&&_(34067),xe.__version=de.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Z(z,O,$,ge,de){let xe=a.convert($.format,$.encoding),Be=a.convert($.type),Ce=S($.internalFormat,xe,Be,$.encoding);r.get(O).__hasExternalTextures||(de===32879||de===35866?i.texImage3D(de,0,Ce,O.width,O.height,O.depth,0,xe,Be,null):i.texImage2D(de,0,Ce,O.width,O.height,0,xe,Be,null)),i.bindFramebuffer(36160,z),ye(O)?d.framebufferTexture2DMultisampleEXT(36160,ge,de,r.get($).__webglTexture,0,be(O)):(de===3553||de>=34069&&de<=34074)&&e.framebufferTexture2D(36160,ge,de,r.get($).__webglTexture,0),i.bindFramebuffer(36160,null)}function pe(z,O,$){if(e.bindRenderbuffer(36161,z),O.depthBuffer&&!O.stencilBuffer){let ge=33189;if($||ye(O)){let de=O.depthTexture;de&&de.isDepthTexture&&(de.type===lr?ge=36012:de.type===La&&(ge=33190));let xe=be(O);ye(O)?d.renderbufferStorageMultisampleEXT(36161,xe,ge,O.width,O.height):e.renderbufferStorageMultisample(36161,xe,ge,O.width,O.height)}else e.renderbufferStorage(36161,ge,O.width,O.height);e.framebufferRenderbuffer(36160,36096,36161,z)}else if(O.depthBuffer&&O.stencilBuffer){let ge=be(O);$&&ye(O)===!1?e.renderbufferStorageMultisample(36161,ge,35056,O.width,O.height):ye(O)?d.renderbufferStorageMultisampleEXT(36161,ge,35056,O.width,O.height):e.renderbufferStorage(36161,34041,O.width,O.height),e.framebufferRenderbuffer(36160,33306,36161,z)}else{let ge=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let de=0;de<ge.length;de++){let xe=ge[de],Be=a.convert(xe.format,xe.encoding),Ce=a.convert(xe.type),ue=S(xe.internalFormat,Be,Ce,xe.encoding),Oe=be(O);$&&ye(O)===!1?e.renderbufferStorageMultisample(36161,Oe,ue,O.width,O.height):ye(O)?d.renderbufferStorageMultisampleEXT(36161,Oe,ue,O.width,O.height):e.renderbufferStorage(36161,ue,O.width,O.height)}}e.bindRenderbuffer(36161,null)}function oe(z,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,z),!(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),G(O.depthTexture,0);let $=r.get(O.depthTexture).__webglTexture,ge=be(O);if(O.depthTexture.format===uo)ye(O)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,$,0,ge):e.framebufferTexture2D(36160,36096,3553,$,0);else if(O.depthTexture.format===wo)ye(O)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,$,0,ge):e.framebufferTexture2D(36160,33306,3553,$,0);else throw new Error("Unknown depthTexture format")}function ae(z){let O=r.get(z),$=z.isWebGLCubeRenderTarget===!0;if(z.depthTexture&&!O.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");oe(O.__webglFramebuffer,z)}else if($){O.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)i.bindFramebuffer(36160,O.__webglFramebuffer[ge]),O.__webglDepthbuffer[ge]=e.createRenderbuffer(),pe(O.__webglDepthbuffer[ge],z,!1)}else i.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=e.createRenderbuffer(),pe(O.__webglDepthbuffer,z,!1);i.bindFramebuffer(36160,null)}function Me(z,O,$){let ge=r.get(z);O!==void 0&&Z(ge.__webglFramebuffer,z,z.texture,36064,3553),$!==void 0&&ae(z)}function Ae(z){let O=z.texture,$=r.get(z),ge=r.get(O);z.addEventListener("dispose",D),z.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=e.createTexture()),ge.__version=O.version,n.memory.textures++);let de=z.isWebGLCubeRenderTarget===!0,xe=z.isWebGLMultipleRenderTargets===!0,Be=b(z)||o;if(de){$.__webglFramebuffer=[];for(let Ce=0;Ce<6;Ce++)$.__webglFramebuffer[Ce]=e.createFramebuffer()}else{if($.__webglFramebuffer=e.createFramebuffer(),xe)if(s.drawBuffers){let Ce=z.texture;for(let ue=0,Oe=Ce.length;ue<Oe;ue++){let ze=r.get(Ce[ue]);ze.__webglTexture===void 0&&(ze.__webglTexture=e.createTexture(),n.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&z.samples>0&&ye(z)===!1){let Ce=xe?O:[O];$.__webglMultisampledFramebuffer=e.createFramebuffer(),$.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,$.__webglMultisampledFramebuffer);for(let ue=0;ue<Ce.length;ue++){let Oe=Ce[ue];$.__webglColorRenderbuffer[ue]=e.createRenderbuffer(),e.bindRenderbuffer(36161,$.__webglColorRenderbuffer[ue]);let ze=a.convert(Oe.format,Oe.encoding),Re=a.convert(Oe.type),Ke=S(Oe.internalFormat,ze,Re,Oe.encoding,z.isXRRenderTarget===!0),je=be(z);e.renderbufferStorageMultisample(36161,je,Ke,z.width,z.height),e.framebufferRenderbuffer(36160,36064+ue,36161,$.__webglColorRenderbuffer[ue])}e.bindRenderbuffer(36161,null),z.depthBuffer&&($.__webglDepthRenderbuffer=e.createRenderbuffer(),pe($.__webglDepthRenderbuffer,z,!0)),i.bindFramebuffer(36160,null)}}if(de){i.bindTexture(34067,ge.__webglTexture),V(34067,O,Be);for(let Ce=0;Ce<6;Ce++)Z($.__webglFramebuffer[Ce],z,O,36064,34069+Ce);A(O,Be)&&_(34067),i.unbindTexture()}else if(xe){let Ce=z.texture;for(let ue=0,Oe=Ce.length;ue<Oe;ue++){let ze=Ce[ue],Re=r.get(ze);i.bindTexture(3553,Re.__webglTexture),V(3553,ze,Be),Z($.__webglFramebuffer,z,ze,36064+ue,3553),A(ze,Be)&&_(3553)}i.unbindTexture()}else{let Ce=3553;(z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(o?Ce=z.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ce,ge.__webglTexture),V(Ce,O,Be),Z($.__webglFramebuffer,z,O,36064,Ce),A(O,Be)&&_(Ce),i.unbindTexture()}z.depthBuffer&&ae(z)}function Ee(z){let O=b(z)||o,$=z.isWebGLMultipleRenderTargets===!0?z.texture:[z.texture];for(let ge=0,de=$.length;ge<de;ge++){let xe=$[ge];if(A(xe,O)){let Be=z.isWebGLCubeRenderTarget?34067:3553,Ce=r.get(xe).__webglTexture;i.bindTexture(Be,Ce),_(Be),i.unbindTexture()}}}function Ie(z){if(o&&z.samples>0&&ye(z)===!1){let O=z.isWebGLMultipleRenderTargets?z.texture:[z.texture],$=z.width,ge=z.height,de=16384,xe=[],Be=z.stencilBuffer?33306:36096,Ce=r.get(z),ue=z.isWebGLMultipleRenderTargets===!0;if(ue)for(let Oe=0;Oe<O.length;Oe++)i.bindFramebuffer(36160,Ce.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Oe,36161,null),i.bindFramebuffer(36160,Ce.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Oe,3553,null,0);i.bindFramebuffer(36008,Ce.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ce.__webglFramebuffer);for(let Oe=0;Oe<O.length;Oe++){xe.push(36064+Oe),z.depthBuffer&&xe.push(Be);let ze=Ce.__ignoreDepthValues!==void 0?Ce.__ignoreDepthValues:!1;if(ze===!1&&(z.depthBuffer&&(de|=256),z.stencilBuffer&&(de|=1024)),ue&&e.framebufferRenderbuffer(36008,36064,36161,Ce.__webglColorRenderbuffer[Oe]),ze===!0&&(e.invalidateFramebuffer(36008,[Be]),e.invalidateFramebuffer(36009,[Be])),ue){let Re=r.get(O[Oe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Re,0)}e.blitFramebuffer(0,0,$,ge,0,0,$,ge,de,9728),p&&e.invalidateFramebuffer(36008,xe)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ue)for(let Oe=0;Oe<O.length;Oe++){i.bindFramebuffer(36160,Ce.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Oe,36161,Ce.__webglColorRenderbuffer[Oe]);let ze=r.get(O[Oe]).__webglTexture;i.bindFramebuffer(36160,Ce.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Oe,3553,ze,0)}i.bindFramebuffer(36009,Ce.__webglMultisampledFramebuffer)}}function be(z){return Math.min(c,z.samples)}function ye(z){let O=r.get(z);return o&&z.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function ke(z){let O=n.render.frame;f.get(z)!==O&&(f.set(z,O),z.update())}function Je(z,O){let $=z.encoding,ge=z.format,de=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||z.format===Og||$!==ea&&($===it?o===!1?t.has("EXT_sRGB")===!0&&ge===Nr?(z.format=Og,z.minFilter=lt,z.generateMipmaps=!1):O=hA.sRGBToLinear(O):(ge!==Nr||de!==Qi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",$)),O}this.allocateTextureUnit=L,this.resetTextureUnits=N,this.setTexture2D=G,this.setTexture2DArray=j,this.setTexture3D=k,this.setTextureCube=q,this.rebindTextures=Me,this.setupRenderTarget=Ae,this.updateRenderTargetMipmap=Ee,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=ye}function ER(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===Qi)return 5121;if(a===l3)return 32819;if(a===h3)return 32820;if(a===a3)return 5120;if(a===n3)return 5122;if(a===tA)return 5123;if(a===o3)return 5124;if(a===La)return 5125;if(a===lr)return 5126;if(a===bo)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===c3)return 6406;if(a===Nr)return 6408;if(a===d3)return 6409;if(a===u3)return 6410;if(a===uo)return 6402;if(a===wo)return 34041;if(a===Og)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===p3)return 6403;if(a===f3)return 36244;if(a===Hu)return 33319;if(a===m3)return 33320;if(a===iA)return 36249;if(a===Ef||a===Cf||a===Tf||a===Df)if(n===it)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===Ef)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Cf)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===Tf)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===Df)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===Ef)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Cf)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===Tf)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===Df)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===w1||a===_1||a===S1||a===A1)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===w1)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===_1)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===S1)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===A1)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===g3)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===M1||a===E1)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===M1)return n===it?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===E1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===C1||a===T1||a===D1||a===P1||a===I1||a===O1||a===R1||a===L1||a===B1||a===z1||a===k1||a===N1||a===U1||a===F1)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===C1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===T1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===D1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===P1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===I1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===O1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===R1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===L1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===B1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===z1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===k1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===N1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===U1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===F1)return n===it?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===Pf)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===Pf)return n===it?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===v3||a===V1||a===j1||a===G1)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===Pf)return o.COMPRESSED_RED_RGTC1_EXT;if(a===V1)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===j1)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===G1)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===co?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[a]!==void 0?e[a]:null}return{convert:s}}var CR=class extends Gi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Al=class extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}},TR={type:"move"},im=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Al,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 Al,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 Al,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,a=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let f of e.hand.values()){let m=t.getJointPose(f,i),g=this._getHandJoint(l,f);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=m!==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));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(TR)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Al;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Ql=class extends wi{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:uo,h!==uo&&h!==wo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===uo&&(i=La),i===void 0&&h===wo&&(i=co),super(null,r,s,a,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:kt,this.minFilter=o!==void 0?o:kt,this.flipY=!1,this.generateMipmaps=!1}},DR=class extends Ni{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,u=null,c=null,d=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new Set,b=new Map,w=new Gi;w.layers.enable(1),w.viewport=new rt;let A=new Gi;A.layers.enable(2),A.viewport=new rt;let _=[w,A],S=new CR;S.layers.enable(1),S.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let k=v[j];return k===void 0&&(k=new im,v[j]=k),k.getTargetRaySpace()},this.getControllerGrip=function(j){let k=v[j];return k===void 0&&(k=new im,v[j]=k),k.getGripSpace()},this.getHand=function(j){let k=v[j];return k===void 0&&(k=new im,v[j]=k),k.getHandSpace()};function T(j){let k=y.indexOf(j.inputSource);if(k===-1)return;let q=v[k];q!==void 0&&q.dispatchEvent({type:j.type,data:j.inputSource})}function D(){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",D),r.removeEventListener("inputsourceschange",P);for(let j=0;j<v.length;j++){let k=y[j];k!==null&&(y[j]=null,v[j].disconnect(k))}M=null,C=null,e.setRenderTarget(m),d=null,c=null,u=null,r=null,g=null,G.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){n=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(j){l=j},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(j){if(r=j,r!==null){if(m=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",D),r.addEventListener("inputsourceschange",P),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let k={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,k),r.updateRenderState({baseLayer:d}),g=new Dt(d.framebufferWidth,d.framebufferHeight,{format:Nr,type:Qi,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let k=null,q=null,H=null;f.depth&&(H=f.stencil?35056:33190,k=f.stencil?wo:uo,q=f.stencil?co:La);let Y={colorFormat:32856,depthFormat:H,scaleFactor:s};u=new XRWebGLBinding(r,t),c=u.createProjectionLayer(Y),r.updateRenderState({layers:[c]}),g=new Dt(c.textureWidth,c.textureHeight,{format:Nr,type:Qi,depthTexture:new Ql(c.textureWidth,c.textureHeight,q,void 0,void 0,void 0,void 0,void 0,void 0,k),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let V=e.properties.get(g);V.__ignoreDepthValues=c.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(n),G.setContext(r),G.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function P(j){for(let k=0;k<j.removed.length;k++){let q=j.removed[k],H=y.indexOf(q);H>=0&&(y[H]=null,v[H].disconnect(q))}for(let k=0;k<j.added.length;k++){let q=j.added[k],H=y.indexOf(q);if(H===-1){for(let V=0;V<v.length;V++)if(V>=y.length){y.push(q),H=V;break}else if(y[V]===null){y[V]=q,H=V;break}if(H===-1)break}let Y=v[H];Y&&Y.connect(q)}}let I=new E,R=new E;function U(j,k,q){I.setFromMatrixPosition(k.matrixWorld),R.setFromMatrixPosition(q.matrixWorld);let H=I.distanceTo(R),Y=k.projectionMatrix.elements,V=q.projectionMatrix.elements,ie=Y[14]/(Y[10]-1),Q=Y[14]/(Y[10]+1),re=(Y[9]+1)/Y[5],Z=(Y[9]-1)/Y[5],pe=(Y[8]-1)/Y[0],oe=(V[8]+1)/V[0],ae=ie*pe,Me=ie*oe,Ae=H/(-pe+oe),Ee=Ae*-pe;k.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Ee),j.translateZ(Ae),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert();let Ie=ie+Ae,be=Q+Ae,ye=ae-Ee,ke=Me+(H-Ee),Je=re*Q/be*Ie,z=Z*Q/be*Ie;j.projectionMatrix.makePerspective(ye,ke,Je,z,Ie,be)}function N(j,k){k===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(k.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(r===null)return;S.near=A.near=w.near=j.near,S.far=A.far=w.far=j.far,(M!==S.near||C!==S.far)&&(r.updateRenderState({depthNear:S.near,depthFar:S.far}),M=S.near,C=S.far);let k=j.parent,q=S.cameras;N(S,k);for(let Y=0;Y<q.length;Y++)N(q[Y],k);S.matrixWorld.decompose(S.position,S.quaternion,S.scale),j.matrix.copy(S.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale);let H=j.children;for(let Y=0,V=H.length;Y<V;Y++)H[Y].updateMatrixWorld(!0);q.length===2?U(S,w,A):S.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return S},this.getFoveation=function(){if(!(c===null&&d===null))return o},this.setFoveation=function(j){o=j,c!==null&&(c.fixedFoveation=j),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=j)},this.getPlanes=function(){return x};let L=null;function W(j,k){if(h=k.getViewerPose(l||a),p=k,h!==null){let q=h.views;d!==null&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let H=!1;q.length!==S.cameras.length&&(S.cameras.length=0,H=!0);for(let Y=0;Y<q.length;Y++){let V=q[Y],ie=null;if(d!==null)ie=d.getViewport(V);else{let re=u.getViewSubImage(c,V);ie=re.viewport,Y===0&&(e.setRenderTargetTextures(g,re.colorTexture,c.ignoreDepthValues?void 0:re.depthStencilTexture),e.setRenderTarget(g))}let Q=_[Y];Q===void 0&&(Q=new Gi,Q.layers.enable(Y),Q.viewport=new rt,_[Y]=Q),Q.matrix.fromArray(V.transform.matrix),Q.projectionMatrix.fromArray(V.projectionMatrix),Q.viewport.set(ie.x,ie.y,ie.width,ie.height),Y===0&&S.matrix.copy(Q.matrix),H===!0&&S.cameras.push(Q)}}for(let q=0;q<v.length;q++){let H=y[q],Y=v[q];H!==null&&Y!==void 0&&Y.update(H,k,l||a)}if(L&&L(j,k),k.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:k.detectedPlanes});let q=null;for(let H of x)k.detectedPlanes.has(H)||(q===null&&(q=[]),q.push(H));if(q!==null)for(let H of q)x.delete(H),b.delete(H),i.dispatchEvent({type:"planeremoved",data:H});for(let H of k.detectedPlanes)if(!x.has(H))x.add(H),b.set(H,k.lastChangedTime),i.dispatchEvent({type:"planeadded",data:H});else{let Y=b.get(H);H.lastChangedTime>Y&&(b.set(H,H.lastChangedTime),i.dispatchEvent({type:"planechanged",data:H}))}}p=null}let G=new fA;G.setAnimationLoop(W),this.setAnimationLoop=function(j){L=j},this.dispose=function(){}}};function PR(e,t){function i(m,g){g.color.getRGB(m.fogColor.value,pA(e)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,v,y,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(m,g):g.isMeshToonMaterial?(s(m,g),u(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g)):g.isMeshStandardMaterial?(s(m,g),c(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),f(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&n(m,g)):g.isPointsMaterial?o(m,g,v,y):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===Pi&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===Pi&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v=t.get(g).envMap;if(v&&(m.envMap.value=v,m.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let b=e.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function n(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,v,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*v,m.scale.value=y*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix))}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function c(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,v){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===Pi&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=v.texture,m.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function f(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function IR(e,t,i,r){let s={},a={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let b=x.program;r.uniformBlockBinding(y,b)}function h(y,x){let b=s[y.id];b===void 0&&(f(y),b=u(y),s[y.id]=b,y.addEventListener("dispose",g));let w=x.program;r.updateUBOMapping(y,w);let A=t.render.frame;a[y.id]!==A&&(d(y),a[y.id]=A)}function u(y){let x=c();y.__bindingPointIndex=x;let b=e.createBuffer(),w=y.__size,A=y.usage;return e.bindBuffer(35345,b),e.bufferData(35345,w,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,b),b}function c(){for(let y=0;y<o;y++)if(n.indexOf(y)===-1)return n.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){let x=s[y.id],b=y.uniforms,w=y.__cache;e.bindBuffer(35345,x);for(let A=0,_=b.length;A<_;A++){let S=b[A];if(p(S,A,w)===!0){let M=S.__offset,C=Array.isArray(S.value)?S.value:[S.value],T=0;for(let D=0;D<C.length;D++){let P=C[D],I=m(P);typeof P=="number"?(S.__data[0]=P,e.bufferSubData(35345,M+T,S.__data)):P.isMatrix3?(S.__data[0]=P.elements[0],S.__data[1]=P.elements[1],S.__data[2]=P.elements[2],S.__data[3]=P.elements[0],S.__data[4]=P.elements[3],S.__data[5]=P.elements[4],S.__data[6]=P.elements[5],S.__data[7]=P.elements[0],S.__data[8]=P.elements[6],S.__data[9]=P.elements[7],S.__data[10]=P.elements[8],S.__data[11]=P.elements[0]):(P.toArray(S.__data,T),T+=I.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,S.__data)}}e.bindBuffer(35345,null)}function p(y,x,b){let w=y.value;if(b[x]===void 0){if(typeof w=="number")b[x]=w;else{let A=Array.isArray(w)?w:[w],_=[];for(let S=0;S<A.length;S++)_.push(A[S].clone());b[x]=_}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],_=Array.isArray(w)?w:[w];for(let S=0;S<A.length;S++){let M=A[S];if(M.equals(_[S])===!1)return M.copy(_[S]),!0}}return!1}function f(y){let x=y.uniforms,b=0,w=16,A=0;for(let _=0,S=x.length;_<S;_++){let M=x[_],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let D=0,P=T.length;D<P;D++){let I=T[D],R=m(I);C.boundary+=R.boundary,C.storage+=R.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=b,_>0){A=b%w;let D=w-A;A!==0&&D-C.boundary<0&&(b+=w-A,M.__offset=b)}b+=C.storage}return A=b%w,A>0&&(b+=w-A),y.__size=b,y.__cache={},this}function m(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.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),x}function g(y){let x=y.target;x.removeEventListener("dispose",g);let b=n.indexOf(x.__bindingPointIndex);n.splice(b,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete a[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);n=[],s={},a={}}return{bind:l,update:h,dispose:v}}function OR(){let e=Zu("canvas");return e.style.display="block",e}function bA(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:OR(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,a=e.antialias!==void 0?e.antialias:!1,n=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=ea,this.physicallyCorrectLights=!1,this.toneMapping=za,this.toneMappingExposure=1;let m=this,g=!1,v=0,y=0,x=null,b=-1,w=null,A=new rt,_=new rt,S=null,M=t.width,C=t.height,T=1,D=null,P=null,I=new rt(0,0,M,C),R=new rt(0,0,M,C),U=!1,N=new S0,L=!1,W=!1,G=null,j=new me,k=new F,q=new E,H={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return x===null?T:1}let V=i;function ie(B,ee){for(let le=0;le<B.length;le++){let J=B[le],he=t.getContext(J,ee);if(he!==null)return he}return null}try{let B={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:n,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${hh}`),t.addEventListener("webglcontextlost",Ke,!1),t.addEventListener("webglcontextrestored",je,!1),t.addEventListener("webglcontextcreationerror",vt,!1),V===null){let ee=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ee.shift(),V=ie(ee,B),V===null)throw ie(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}V.getShaderPrecisionFormat===void 0&&(V.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let Q,re,Z,pe,oe,ae,Me,Ae,Ee,Ie,be,ye,ke,Je,z,O,$,ge,de,xe,Be,Ce,ue,Oe;function ze(){Q=new WI(V),re=new UI(V,Q,e),Q.init(re),Ce=new ER(V,Q,re),Z=new AR(V,Q,re),pe=new XI,oe=new dR,ae=new MR(V,Q,Z,oe,re,Ce,pe),Me=new VI(m),Ae=new HI(m),Ee=new rD(V,re),ue=new kI(V,Q,Ee,re),Ie=new qI(V,Ee,pe,ue),be=new JI(V,Ie,Ee,pe),de=new KI(V,re,ae),O=new FI(oe),ye=new cR(m,Me,Ae,Q,re,ue,O),ke=new PR(m,oe),Je=new pR,z=new xR(Q,re),ge=new zI(m,Me,Ae,Z,be,u,n),$=new SR(m,be,re),Oe=new IR(V,pe,re,Z),xe=new NI(V,Q,pe,re),Be=new YI(V,Q,pe,re),pe.programs=ye.programs,m.capabilities=re,m.extensions=Q,m.properties=oe,m.renderLists=Je,m.shadowMap=$,m.state=Z,m.info=pe}ze();let Re=new DR(m,V);this.xr=Re,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){let B=Q.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){let B=Q.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(B){B!==void 0&&(T=B,this.setSize(M,C,!1))},this.getSize=function(B){return B.set(M,C)},this.setSize=function(B,ee,le){if(Re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=B,C=ee,t.width=Math.floor(B*T),t.height=Math.floor(ee*T),le!==!1&&(t.style.width=B+"px",t.style.height=ee+"px"),this.setViewport(0,0,B,ee)},this.getDrawingBufferSize=function(B){return B.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(B,ee,le){M=B,C=ee,T=le,t.width=Math.floor(B*le),t.height=Math.floor(ee*le),this.setViewport(0,0,B,ee)},this.getCurrentViewport=function(B){return B.copy(A)},this.getViewport=function(B){return B.copy(I)},this.setViewport=function(B,ee,le,J){B.isVector4?I.set(B.x,B.y,B.z,B.w):I.set(B,ee,le,J),Z.viewport(A.copy(I).multiplyScalar(T).floor())},this.getScissor=function(B){return B.copy(R)},this.setScissor=function(B,ee,le,J){B.isVector4?R.set(B.x,B.y,B.z,B.w):R.set(B,ee,le,J),Z.scissor(_.copy(R).multiplyScalar(T).floor())},this.getScissorTest=function(){return U},this.setScissorTest=function(B){Z.setScissorTest(U=B)},this.setOpaqueSort=function(B){D=B},this.setTransparentSort=function(B){P=B},this.getClearColor=function(B){return B.copy(ge.getClearColor())},this.setClearColor=function(){ge.setClearColor.apply(ge,arguments)},this.getClearAlpha=function(){return ge.getClearAlpha()},this.setClearAlpha=function(){ge.setClearAlpha.apply(ge,arguments)},this.clear=function(B=!0,ee=!0,le=!0){let J=0;B&&(J|=16384),ee&&(J|=256),le&&(J|=1024),V.clear(J)},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",Ke,!1),t.removeEventListener("webglcontextrestored",je,!1),t.removeEventListener("webglcontextcreationerror",vt,!1),Je.dispose(),z.dispose(),oe.dispose(),Me.dispose(),Ae.dispose(),be.dispose(),ue.dispose(),Oe.dispose(),ye.dispose(),Re.dispose(),Re.removeEventListener("sessionstart",_e),Re.removeEventListener("sessionend",qe),G&&(G.dispose(),G=null),wt.stop()};function Ke(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function je(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let B=pe.autoReset,ee=$.enabled,le=$.autoUpdate,J=$.needsUpdate,he=$.type;ze(),pe.autoReset=B,$.enabled=ee,$.autoUpdate=le,$.needsUpdate=J,$.type=he}function vt(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function Nt(B){let ee=B.target;ee.removeEventListener("dispose",Nt),oi(ee)}function oi(B){X(B),oe.remove(B)}function X(B){let ee=oe.get(B).programs;ee!==void 0&&(ee.forEach(function(le){ye.releaseProgram(le)}),B.isShaderMaterial&&ye.releaseShaderCache(B))}this.renderBufferDirect=function(B,ee,le,J,he,Ne){ee===null&&(ee=H);let at=he.isMesh&&he.matrixWorld.determinant()<0,ct=iT(B,ee,le,J,he);Z.setMaterial(J,at);let ut=le.index,Bt=1;J.wireframe===!0&&(ut=Ie.getWireframeAttribute(le),Bt=2);let _t=le.drawRange,yt=le.attributes.position,Fi=_t.start*Bt,Ir=(_t.start+_t.count)*Bt;Ne!==null&&(Fi=Math.max(Fi,Ne.start*Bt),Ir=Math.min(Ir,(Ne.start+Ne.count)*Bt)),ut!==null?(Fi=Math.max(Fi,0),Ir=Math.min(Ir,ut.count)):yt!=null&&(Fi=Math.max(Fi,0),Ir=Math.min(Ir,yt.count));let ca=Ir-Fi;if(ca<0||ca===1/0)return;ue.setup(he,J,ct,le,ut);let kn,li=xe;if(ut!==null&&(kn=Ee.get(ut),li=Be,li.setIndex(kn)),he.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*Y()),li.setMode(1)):li.setMode(4);else if(he.isLine){let xt=J.linewidth;xt===void 0&&(xt=1),Z.setLineWidth(xt*Y()),he.isLineSegments?li.setMode(1):he.isLineLoop?li.setMode(2):li.setMode(3)}else he.isPoints?li.setMode(0):he.isSprite&&li.setMode(4);if(he.isInstancedMesh)li.renderInstances(Fi,ca,he.count);else if(le.isInstancedBufferGeometry){let xt=le._maxInstanceCount!==void 0?le._maxInstanceCount:1/0,bf=Math.min(le.instanceCount,xt);li.renderInstances(Fi,ca,bf)}else li.render(Fi,ca)},this.compile=function(B,ee){function le(J,he,Ne){J.transparent===!0&&J.side===Sr&&J.forceSinglePass===!1?(J.side=Pi,J.needsUpdate=!0,Vr(J,he,Ne),J.side=Ms,J.needsUpdate=!0,Vr(J,he,Ne),J.side=Sr):Vr(J,he,Ne)}d=z.get(B),d.init(),f.push(d),B.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(d.pushLight(J),J.castShadow&&d.pushShadow(J))}),d.setupLights(m.physicallyCorrectLights),B.traverse(function(J){let he=J.material;if(he)if(Array.isArray(he))for(let Ne=0;Ne<he.length;Ne++){let at=he[Ne];le(at,B,J)}else le(he,B,J)}),f.pop(),d=null};let ne=null;function ve(B){ne&&ne(B)}function _e(){wt.stop()}function qe(){wt.start()}let wt=new fA;wt.setAnimationLoop(ve),typeof self<"u"&&wt.setContext(self),this.setAnimationLoop=function(B){ne=B,Re.setAnimationLoop(B),B===null?wt.stop():wt.start()},Re.addEventListener("sessionstart",_e),Re.addEventListener("sessionend",qe),this.render=function(B,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Re.enabled===!0&&Re.isPresenting===!0&&(Re.cameraAutoUpdate===!0&&Re.updateCamera(ee),ee=Re.getCamera()),B.isScene===!0&&B.onBeforeRender(m,B,ee,x),d=z.get(B,f.length),d.init(),f.push(d),j.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),N.setFromProjectionMatrix(j),W=this.localClippingEnabled,L=O.init(this.clippingPlanes,W),c=Je.get(B,p.length),c.init(),p.push(c),Gt(B,ee,0,m.sortObjects),c.finish(),m.sortObjects===!0&&c.sort(D,P),L===!0&&O.beginShadows();let le=d.state.shadowsArray;if($.render(le,B,ee),L===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),ge.render(c,B),d.setupLights(m.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let he=0,Ne=J.length;he<Ne;he++){let at=J[he];Ui(c,B,at,at.viewport)}}else Ui(c,B,ee);x!==null&&(ae.updateMultisampleRenderTarget(x),ae.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(m,B,ee),ue.resetDefaultState(),b=-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 Gt(B,ee,le,J){if(B.visible===!1)return;if(B.layers.test(ee.layers)){if(B.isGroup)le=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(ee);else if(B.isLight)d.pushLight(B),B.castShadow&&d.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||N.intersectsSprite(B)){J&&q.setFromMatrixPosition(B.matrixWorld).applyMatrix4(j);let Ne=be.update(B),at=B.material;at.visible&&c.push(B,Ne,at,le,q.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(B.isSkinnedMesh&&B.skeleton.frame!==pe.render.frame&&(B.skeleton.update(),B.skeleton.frame=pe.render.frame),!B.frustumCulled||N.intersectsObject(B))){J&&q.setFromMatrixPosition(B.matrixWorld).applyMatrix4(j);let Ne=be.update(B),at=B.material;if(Array.isArray(at)){let ct=Ne.groups;for(let ut=0,Bt=ct.length;ut<Bt;ut++){let _t=ct[ut],yt=at[_t.materialIndex];yt&&yt.visible&&c.push(B,Ne,yt,le,q.z,_t)}}else at.visible&&c.push(B,Ne,at,le,q.z,null)}}let he=B.children;for(let Ne=0,at=he.length;Ne<at;Ne++)Gt(he[Ne],ee,le,J)}function Ui(B,ee,le,J){let he=B.opaque,Ne=B.transmissive,at=B.transparent;d.setupLightsView(le),L===!0&&O.setGlobalState(m.clippingPlanes,le),Ne.length>0&&zn(he,ee,le),J&&Z.viewport(A.copy(J)),he.length>0&&jt(he,ee,le),Ne.length>0&&jt(Ne,ee,le),at.length>0&&jt(at,ee,le),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function zn(B,ee,le){let J=re.isWebGL2;G===null&&(G=new Dt(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?bo:Qi,minFilter:Yl,samples:J&&a===!0?4:0})),m.getDrawingBufferSize(k),J?G.setSize(k.x,k.y):G.setSize(Qu(k.x),Qu(k.y));let he=m.getRenderTarget();m.setRenderTarget(G),m.clear();let Ne=m.toneMapping;m.toneMapping=za,jt(B,ee,le),m.toneMapping=Ne,ae.updateMultisampleRenderTarget(G),ae.updateRenderTargetMipmap(G),m.setRenderTarget(he)}function jt(B,ee,le){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let he=0,Ne=B.length;he<Ne;he++){let at=B[he],ct=at.object,ut=at.geometry,Bt=J===null?at.material:J,_t=at.group;ct.layers.test(le.layers)&&ha(ct,ee,le,ut,Bt,_t)}}function ha(B,ee,le,J,he,Ne){B.onBeforeRender(m,ee,le,J,he,Ne),B.modelViewMatrix.multiplyMatrices(le.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),he.onBeforeRender(m,ee,le,J,B,Ne),he.transparent===!0&&he.side===Sr&&he.forceSinglePass===!1?(he.side=Pi,he.needsUpdate=!0,m.renderBufferDirect(le,ee,J,he,B,Ne),he.side=Ms,he.needsUpdate=!0,m.renderBufferDirect(le,ee,J,he,B,Ne),he.side=Sr):m.renderBufferDirect(le,ee,J,he,B,Ne),B.onAfterRender(m,ee,le,J,he,Ne)}function Vr(B,ee,le){ee.isScene!==!0&&(ee=H);let J=oe.get(B),he=d.state.lights,Ne=d.state.shadowsArray,at=he.state.version,ct=ye.getParameters(B,he.state,Ne,ee,le),ut=ye.getProgramCacheKey(ct),Bt=J.programs;J.environment=B.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(B.isMeshStandardMaterial?Ae:Me).get(B.envMap||J.environment),Bt===void 0&&(B.addEventListener("dispose",Nt),Bt=new Map,J.programs=Bt);let _t=Bt.get(ut);if(_t!==void 0){if(J.currentProgram===_t&&J.lightsStateVersion===at)return d1(B,ct),_t}else ct.uniforms=ye.getUniforms(B),B.onBuild(le,ct,m),B.onBeforeCompile(ct,m),_t=ye.acquireProgram(ct,ut),Bt.set(ut,_t),J.uniforms=ct.uniforms;let yt=J.uniforms;(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(yt.clippingPlanes=O.uniform),d1(B,ct),J.needsLights=sT(B),J.lightsStateVersion=at,J.needsLights&&(yt.ambientLightColor.value=he.state.ambient,yt.lightProbe.value=he.state.probe,yt.directionalLights.value=he.state.directional,yt.directionalLightShadows.value=he.state.directionalShadow,yt.spotLights.value=he.state.spot,yt.spotLightShadows.value=he.state.spotShadow,yt.rectAreaLights.value=he.state.rectArea,yt.ltc_1.value=he.state.rectAreaLTC1,yt.ltc_2.value=he.state.rectAreaLTC2,yt.pointLights.value=he.state.point,yt.pointLightShadows.value=he.state.pointShadow,yt.hemisphereLights.value=he.state.hemi,yt.directionalShadowMap.value=he.state.directionalShadowMap,yt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,yt.spotShadowMap.value=he.state.spotShadowMap,yt.spotLightMatrix.value=he.state.spotLightMatrix,yt.spotLightMap.value=he.state.spotLightMap,yt.pointShadowMap.value=he.state.pointShadowMap,yt.pointShadowMatrix.value=he.state.pointShadowMatrix);let Fi=_t.getUniforms(),Ir=Ou.seqWithValue(Fi.seq,yt);return J.currentProgram=_t,J.uniformsList=Ir,_t}function d1(B,ee){let le=oe.get(B);le.outputEncoding=ee.outputEncoding,le.instancing=ee.instancing,le.skinning=ee.skinning,le.morphTargets=ee.morphTargets,le.morphNormals=ee.morphNormals,le.morphColors=ee.morphColors,le.morphTargetsCount=ee.morphTargetsCount,le.numClippingPlanes=ee.numClippingPlanes,le.numIntersection=ee.numClipIntersection,le.vertexAlphas=ee.vertexAlphas,le.vertexTangents=ee.vertexTangents,le.toneMapping=ee.toneMapping}function iT(B,ee,le,J,he){ee.isScene!==!0&&(ee=H),ae.resetTextureUnits();let Ne=ee.fog,at=J.isMeshStandardMaterial?ee.environment:null,ct=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:ea,ut=(J.isMeshStandardMaterial?Ae:Me).get(J.envMap||at),Bt=J.vertexColors===!0&&!!le.attributes.color&&le.attributes.color.itemSize===4,_t=!!J.normalMap&&!!le.attributes.tangent,yt=!!le.morphAttributes.position,Fi=!!le.morphAttributes.normal,Ir=!!le.morphAttributes.color,ca=J.toneMapped?m.toneMapping:za,kn=le.morphAttributes.position||le.morphAttributes.normal||le.morphAttributes.color,li=kn!==void 0?kn.length:0,xt=oe.get(J),bf=d.state.lights;if(L===!0&&(W===!0||B!==w)){let Or=B===w&&J.id===b;O.setState(J,B,Or)}let wf=!1;J.version===xt.__version?(xt.needsLights&&xt.lightsStateVersion!==bf.state.version||xt.outputEncoding!==ct||he.isInstancedMesh&&xt.instancing===!1||!he.isInstancedMesh&&xt.instancing===!0||he.isSkinnedMesh&&xt.skinning===!1||!he.isSkinnedMesh&&xt.skinning===!0||xt.envMap!==ut||J.fog===!0&&xt.fog!==Ne||xt.numClippingPlanes!==void 0&&(xt.numClippingPlanes!==O.numPlanes||xt.numIntersection!==O.numIntersection)||xt.vertexAlphas!==Bt||xt.vertexTangents!==_t||xt.morphTargets!==yt||xt.morphNormals!==Fi||xt.morphColors!==Ir||xt.toneMapping!==ca||re.isWebGL2===!0&&xt.morphTargetsCount!==li)&&(wf=!0):(wf=!0,xt.__version=J.version);let Nn=xt.currentProgram;wf===!0&&(Nn=Vr(J,ee,he));let u1=!1,Ih=!1,_f=!1,Bi=Nn.getUniforms(),Un=xt.uniforms;if(Z.useProgram(Nn.program)&&(u1=!0,Ih=!0,_f=!0),J.id!==b&&(b=J.id,Ih=!0),u1||w!==B){if(Bi.setValue(V,"projectionMatrix",B.projectionMatrix),re.logarithmicDepthBuffer&&Bi.setValue(V,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),w!==B&&(w=B,Ih=!0,_f=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let Or=Bi.map.cameraPosition;Or!==void 0&&Or.setValue(V,q.setFromMatrixPosition(B.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Bi.setValue(V,"isOrthographic",B.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||he.isSkinnedMesh)&&Bi.setValue(V,"viewMatrix",B.matrixWorldInverse)}if(he.isSkinnedMesh){Bi.setOptional(V,he,"bindMatrix"),Bi.setOptional(V,he,"bindMatrixInverse");let Or=he.skeleton;Or&&(re.floatVertexTextures?(Or.boneTexture===null&&Or.computeBoneTexture(),Bi.setValue(V,"boneTexture",Or.boneTexture,ae),Bi.setValue(V,"boneTextureSize",Or.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 Sf=le.morphAttributes;if((Sf.position!==void 0||Sf.normal!==void 0||Sf.color!==void 0&&re.isWebGL2===!0)&&de.update(he,le,J,Nn),(Ih||xt.receiveShadow!==he.receiveShadow)&&(xt.receiveShadow=he.receiveShadow,Bi.setValue(V,"receiveShadow",he.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(Un.envMap.value=ut,Un.flipEnvMap.value=ut.isCubeTexture&&ut.isRenderTargetTexture===!1?-1:1),Ih&&(Bi.setValue(V,"toneMappingExposure",m.toneMappingExposure),xt.needsLights&&rT(Un,_f),Ne&&J.fog===!0&&ke.refreshFogUniforms(Un,Ne),ke.refreshMaterialUniforms(Un,J,T,C,G),Ou.upload(V,xt.uniformsList,Un,ae)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Ou.upload(V,xt.uniformsList,Un,ae),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Bi.setValue(V,"center",he.center),Bi.setValue(V,"modelViewMatrix",he.modelViewMatrix),Bi.setValue(V,"normalMatrix",he.normalMatrix),Bi.setValue(V,"modelMatrix",he.matrixWorld),he.previousModelViewMatrix&&Bi.setValue(V,"previousModelViewMatrix",he.previousModelViewMatrix),B.previousProjectionMatrix&&Bi.setValue(V,"previousProjectionMatrix",B.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let Or=J.uniformsGroups;for(let Af=0,aT=Or.length;Af<aT;Af++)if(re.isWebGL2){let p1=Or[Af];Oe.update(p1,Nn),Oe.bind(p1,Nn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Nn}function rT(B,ee){B.ambientLightColor.needsUpdate=ee,B.lightProbe.needsUpdate=ee,B.directionalLights.needsUpdate=ee,B.directionalLightShadows.needsUpdate=ee,B.pointLights.needsUpdate=ee,B.pointLightShadows.needsUpdate=ee,B.spotLights.needsUpdate=ee,B.spotLightShadows.needsUpdate=ee,B.rectAreaLights.needsUpdate=ee,B.hemisphereLights.needsUpdate=ee}function sT(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(B,ee,le){oe.get(B.texture).__webglTexture=ee,oe.get(B.depthTexture).__webglTexture=le;let J=oe.get(B);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=le===void 0,J.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(B,ee){let le=oe.get(B);le.__webglFramebuffer=ee,le.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(B,ee=0,le=0){x=B,v=ee,y=le;let J=!0,he=null,Ne=!1,at=!1;if(B){let ct=oe.get(B);ct.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):ct.__webglFramebuffer===void 0?ae.setupRenderTarget(B):ct.__hasExternalTextures&&ae.rebindTextures(B,oe.get(B.texture).__webglTexture,oe.get(B.depthTexture).__webglTexture);let ut=B.texture;(ut.isData3DTexture||ut.isDataArrayTexture||ut.isCompressedArrayTexture)&&(at=!0);let Bt=oe.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(he=Bt[ee],Ne=!0):re.isWebGL2&&B.samples>0&&ae.useMultisampledRTT(B)===!1?he=oe.get(B).__webglMultisampledFramebuffer:he=Bt,A.copy(B.viewport),_.copy(B.scissor),S=B.scissorTest}else A.copy(I).multiplyScalar(T).floor(),_.copy(R).multiplyScalar(T).floor(),S=U;if(Z.bindFramebuffer(36160,he)&&re.drawBuffers&&J&&Z.drawBuffers(B,he),Z.viewport(A),Z.scissor(_),Z.setScissorTest(S),Ne){let ct=oe.get(B.texture);V.framebufferTexture2D(36160,36064,34069+ee,ct.__webglTexture,le)}else if(at){let ct=oe.get(B.texture),ut=ee||0;V.framebufferTextureLayer(36160,36064,ct.__webglTexture,le||0,ut)}b=-1},this.readRenderTargetPixels=function(B,ee,le,J,he,Ne,at){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ct=oe.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&at!==void 0&&(ct=ct[at]),ct){Z.bindFramebuffer(36160,ct);try{let ut=B.texture,Bt=ut.format,_t=ut.type;if(Bt!==Nr&&Ce.convert(Bt)!==V.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let yt=_t===bo&&(Q.has("EXT_color_buffer_half_float")||re.isWebGL2&&Q.has("EXT_color_buffer_float"));if(_t!==Qi&&Ce.convert(_t)!==V.getParameter(35738)&&!(_t===lr&&(re.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!yt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=B.width-J&&le>=0&&le<=B.height-he&&V.readPixels(ee,le,J,he,Ce.convert(Bt),Ce.convert(_t),Ne)}finally{let ut=x!==null?oe.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,ut)}}},this.copyFramebufferToTexture=function(B,ee,le=0){let J=Math.pow(2,-le),he=Math.floor(ee.image.width*J),Ne=Math.floor(ee.image.height*J);ae.setTexture2D(ee,0),V.copyTexSubImage2D(3553,le,0,0,B.x,B.y,he,Ne),Z.unbindTexture()},this.copyTextureToTexture=function(B,ee,le,J=0){let he=ee.image.width,Ne=ee.image.height,at=Ce.convert(le.format),ct=Ce.convert(le.type);ae.setTexture2D(le,0),V.pixelStorei(37440,le.flipY),V.pixelStorei(37441,le.premultiplyAlpha),V.pixelStorei(3317,le.unpackAlignment),ee.isDataTexture?V.texSubImage2D(3553,J,B.x,B.y,he,Ne,at,ct,ee.image.data):ee.isCompressedTexture?V.compressedTexSubImage2D(3553,J,B.x,B.y,ee.mipmaps[0].width,ee.mipmaps[0].height,at,ee.mipmaps[0].data):V.texSubImage2D(3553,J,B.x,B.y,at,ct,ee.image),J===0&&le.generateMipmaps&&V.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(B,ee,le,J,he=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Ne=B.max.x-B.min.x+1,at=B.max.y-B.min.y+1,ct=B.max.z-B.min.z+1,ut=Ce.convert(J.format),Bt=Ce.convert(J.type),_t;if(J.isData3DTexture)ae.setTexture3D(J,0),_t=32879;else if(J.isDataArrayTexture)ae.setTexture2DArray(J,0),_t=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}V.pixelStorei(37440,J.flipY),V.pixelStorei(37441,J.premultiplyAlpha),V.pixelStorei(3317,J.unpackAlignment);let yt=V.getParameter(3314),Fi=V.getParameter(32878),Ir=V.getParameter(3316),ca=V.getParameter(3315),kn=V.getParameter(32877),li=le.isCompressedTexture?le.mipmaps[0]:le.image;V.pixelStorei(3314,li.width),V.pixelStorei(32878,li.height),V.pixelStorei(3316,B.min.x),V.pixelStorei(3315,B.min.y),V.pixelStorei(32877,B.min.z),le.isDataTexture||le.isData3DTexture?V.texSubImage3D(_t,he,ee.x,ee.y,ee.z,Ne,at,ct,ut,Bt,li.data):le.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),V.compressedTexSubImage3D(_t,he,ee.x,ee.y,ee.z,Ne,at,ct,ut,li.data)):V.texSubImage3D(_t,he,ee.x,ee.y,ee.z,Ne,at,ct,ut,Bt,li),V.pixelStorei(3314,yt),V.pixelStorei(32878,Fi),V.pixelStorei(3316,Ir),V.pixelStorei(3315,ca),V.pixelStorei(32877,kn),he===0&&J.generateMipmaps&&V.generateMipmap(_t),Z.unbindTexture()},this.initTexture=function(B){B.isCubeTexture?ae.setTextureCube(B,0):B.isData3DTexture?ae.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?ae.setTexture2DArray(B,0):ae.setTexture2D(B,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var RR=class extends bA{};RR.prototype.isWebGL1Renderer=!0;var wA=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ve(e),this.near=t,this.far=i}clone(){return new wA(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},_n=class extends Pt{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}},LR=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ig,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ts()}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=ts()),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=ts()),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}}},Ji=new E,Bg=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++)Ji.fromBufferAttribute(this,t),Ji.applyMatrix4(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ji.fromBufferAttribute(this,t),Ji.applyNormalMatrix(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ji.fromBufferAttribute(this,t),Ji.transformDirection(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this}setX(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=zt(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=Ba(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ba(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ba(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ba(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=zt(t,this.array),i=zt(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=zt(t,this.array),i=zt(i,this.array),r=zt(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=zt(t,this.array),i=zt(i,this.array),r=zt(r,this.array),s=zt(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 Ze(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 Bg(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}}},_A=class extends Pt{constructor(){super(),this.isBone=!0,this.type="Bone"}},pn=class extends wi{constructor(e=null,t=1,i=1,r,s,a,n,o,l=kt,h=kt,u,c){super(null,a,n,o,l,h,r,s,u,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Ax=new me,BR=new me,E0=class{constructor(e=[],t=[]){this.uuid=ts(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new me)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new me;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){let n=e[s]?e[s].matrixWorld:BR;Ax.multiplyMatrices(n,t[s]),Ax.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new E0(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=nA(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new pn(t,e,e,Nr,lr);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new _A),this.bones.push(a),this.boneInverses.push(new me().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let a=t[r];e.bones.push(a.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},SA=class extends Ze{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}},In=class extends Zc{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ve(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}},Mx=new E,Ex=new E,Cx=new me,rm=new ch,Rd=new Tr,Ku=class extends Pt{constructor(e=new Ue,t=new In){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++)Mx.fromBufferAttribute(t,r-1),Ex.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Mx.distanceTo(Ex);e.setAttribute("lineDistance",new Te(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,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Rd.copy(i.boundingSphere),Rd.applyMatrix4(r),Rd.radius+=s,e.ray.intersectsSphere(Rd)===!1)return;Cx.copy(r).invert(),rm.copy(e.ray).applyMatrix4(Cx);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,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 m=Math.max(0,a.start),g=Math.min(p.count,a.start+a.count);for(let v=m,y=g-1;v<y;v+=d){let x=p.getX(v),b=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,b),rm.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 m=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count);for(let v=m,y=g-1;v<y;v+=d){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),rm.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,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 a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}},Tx=new E,Dx=new E,Jc=class extends Ku{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)Tx.fromBufferAttribute(t,r),Dx.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Tx.distanceTo(Dx);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},zR=class extends wi{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:lt,this.magFilter=s!==void 0?s:lt,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)}},na=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 a=1;a<=e;a++)i=this.getPoint(a/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,a;t?a=t:a=e*i[s-1];let n=0,o=s-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-a,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===a)return r/(s-1);let h=i[r],u=i[r+1]-h,c=(a-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),a=this.getPoint(r),n=t||(s.isVector2?new F:new E);return n.copy(a).sub(s).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new E,r=[],s=[],a=[],n=new E,o=new me;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new E)}s[0]=new E,a[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),n.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],n),a[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),a[d]=a[d-1].clone(),n.crossVectors(r[d-1],r[d]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(ui(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(n,p))}a[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(ui(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(n.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),a[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:a}}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}},Hp=class extends na{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,n=!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=a,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new F,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);let n=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);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}},kR=class extends Hp{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};function C0(){let e=0,t=0,i=0,r=0;function s(a,n,o,l){e=a,t=o,i=-3*a+3*n-2*o-l,r=2*a-2*n+o+l}return{initCatmullRom:function(a,n,o,l,h){s(n,o,h*(o-a),h*(l-n))},initNonuniformCatmullRom:function(a,n,o,l,h,u,c){let d=(n-a)/h-(o-a)/(h+u)+(o-n)/u,p=(o-n)/u-(l-n)/(u+c)+(l-o)/c;d*=u,p*=u,s(n,o,d,p)},calc:function(a){let n=a*a,o=n*a;return e+t*a+i*n+r*o}}}var Ld=new E,sm=new C0,am=new C0,nm=new C0,NR=class extends na{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,a=(s-(this.closed?0:1))*e,n=Math.floor(a),o=a-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/s)+1)*s:o===0&&n===s-1&&(n=s-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%s]:(Ld.subVectors(r[0],r[1]).add(r[0]),l=Ld);let u=r[n%s],c=r[(n+1)%s];if(this.closed||n+2<s?h=r[(n+2)%s]:(Ld.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Ld),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),m=Math.pow(c.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),sm.initNonuniformCatmullRom(l.x,u.x,c.x,h.x,p,f,m),am.initNonuniformCatmullRom(l.y,u.y,c.y,h.y,p,f,m),nm.initNonuniformCatmullRom(l.z,u.z,c.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(sm.initCatmullRom(l.x,u.x,c.x,h.x,this.tension),am.initCatmullRom(l.y,u.y,c.y,h.y,this.tension),nm.initCatmullRom(l.z,u.z,c.z,h.z,this.tension));return i.set(sm.calc(o),am.calc(o),nm.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 Px(e,t,i,r,s){let a=(r-t)*.5,n=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+a+n)*l+(-3*i+3*r-2*a-n)*o+a*e+i}function UR(e,t){let i=1-e;return i*i*t}function FR(e,t){return 2*(1-e)*e*t}function VR(e,t){return e*e*t}function yc(e,t,i,r){return UR(e,t)+FR(e,i)+VR(e,r)}function jR(e,t){let i=1-e;return i*i*i*t}function GR(e,t){let i=1-e;return 3*i*i*e*t}function HR(e,t){return 3*(1-e)*e*e*t}function WR(e,t){return e*e*e*t}function xc(e,t,i,r,s){return jR(e,t)+GR(e,i)+HR(e,r)+WR(e,s)}var xs=class extends na{constructor(e=new F,t=new F,i=new F,r=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(xc(e,r.x,s.x,a.x,n.x),xc(e,r.y,s.y,a.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.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}},Ru=class extends na{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,a=this.v2,n=this.v3;return i.set(xc(e,r.x,s.x,a.x,n.x),xc(e,r.y,s.y,a.y,n.y),xc(e,r.z,s.z,a.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.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}},As=class extends na{constructor(e=new F,t=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new F){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 F;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}},AA=class extends na{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}},Tn=class extends na{constructor(e=new F,t=new F,i=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(yc(e,r.x,s.x,a.x),yc(e,r.y,s.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}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}},qR=class extends na{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,a=this.v2;return i.set(yc(e,r.x,s.x,a.x),yc(e,r.y,s.y,a.y),yc(e,r.z,s.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}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}},T0=class extends na{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new F){let i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),n=s-a,o=r[a===0?a:a-1],l=r[a],h=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return i.set(Px(n,o.x,l.x,h.x,u.x),Px(n,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 F().fromArray(r))}return this}},YR=Object.freeze({__proto__:null,ArcCurve:kR,CatmullRomCurve3:NR,CubicBezierCurve:xs,CubicBezierCurve3:Ru,EllipseCurve:Hp,LineCurve:As,LineCurve3:AA,QuadraticBezierCurve:Tn,QuadraticBezierCurve3:qR,SplineCurve:T0}),MA=class extends na{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 As(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let a=r[s]-i,n=this.curves[s],o=n.getLength(),l=o===0?0:1-a/o;return n.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 a=s[r],n=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(n);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 YR[r.type]().fromJSON(r))}return this}},Ju=class extends MA{constructor(e){super(),this.type="Path",this.currentPoint=new F,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 As(this.currentPoint.clone(),new F(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Tn(this.currentPoint.clone(),new F(e,t),new F(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new xs(this.currentPoint.clone(),new F(e,t),new F(i,r),new F(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new T0(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,a,n,o),this}absellipse(e,t,i,r,s,a,n,o){let l=new Hp(e,t,i,r,s,a,n,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}},EA=class extends Ue{constructor(e=[new F(0,-.5),new F(.5,0),new F(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=ui(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,u=new E,c=new F,d=new E,p=new E,f=new E,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=g*1,d.y=-m,d.z=g*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:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=g*1,d.y=-m,d.z=g*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,x=Math.sin(y),b=Math.cos(y);for(let w=0;w<=e.length-1;w++){u.x=e[w].x*x,u.y=e[w].y,u.z=e[w].x*b,a.push(u.x,u.y,u.z),c.x=v/t,c.y=w/(e.length-1),n.push(c.x,c.y);let A=o[3*w+0]*x,_=o[3*w+1],S=o[3*w+0]*b;l.push(A,_,S)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,b=x,w=x+e.length,A=x+e.length+1,_=x+1;s.push(b,w,_),s.push(A,_,w)}this.setIndex(s),this.setAttribute("position",new Te(a,3)),this.setAttribute("uv",new Te(n,2)),this.setAttribute("normal",new Te(l,3))}static fromJSON(e){return new EA(e.points,e.segments,e.phiStart,e.phiLength)}},D0=class extends Ue{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],u=[],c=[],d=[],p=0,f=[],m=i/2,g=0;v(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Te(u,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(d,2));function v(){let x=new E,b=new E,w=0,A=(t-e)/i;for(let _=0;_<=s;_++){let S=[],M=_/s,C=M*(t-e)+e;for(let T=0;T<=r;T++){let D=T/r,P=D*o+n,I=Math.sin(P),R=Math.cos(P);b.x=C*I,b.y=-M*i+m,b.z=C*R,u.push(b.x,b.y,b.z),x.set(I,A,R).normalize(),c.push(x.x,x.y,x.z),d.push(D,1-M),S.push(p++)}f.push(S)}for(let _=0;_<r;_++)for(let S=0;S<s;S++){let M=f[S][_],C=f[S+1][_],T=f[S+1][_+1],D=f[S][_+1];h.push(M,C,D),h.push(C,T,D),w+=6}l.addGroup(g,w,0),g+=w}function y(x){let b=p,w=new F,A=new E,_=0,S=x===!0?e:t,M=x===!0?1:-1;for(let T=1;T<=r;T++)u.push(0,m*M,0),c.push(0,M,0),d.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+n,P=Math.cos(D),I=Math.sin(D);A.x=S*I,A.y=m*M,A.z=S*P,u.push(A.x,A.y,A.z),c.push(0,M,0),w.x=P*.5+.5,w.y=I*.5*M+.5,d.push(w.x,w.y),p++}for(let T=0;T<r;T++){let D=b+T,P=C+T;x===!0?h.push(P,P+1,D):h.push(P+1,P,D),_+=3}l.addGroup(g,_,x===!0?1:2),g+=_}}static fromJSON(e){return new D0(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},CA=class extends D0{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,n=Math.PI*2){super(0,e,t,i,r,s,a,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:n}}static fromJSON(e){return new CA(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},P0=class extends Ue{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],a=[];n(r),l(i),h(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(v){let y=new E,x=new E,b=new E;for(let w=0;w<t.length;w+=3)d(t[w+0],y),d(t[w+1],x),d(t[w+2],b),o(y,x,b,v)}function o(v,y,x,b){let w=b+1,A=[];for(let _=0;_<=w;_++){A[_]=[];let S=v.clone().lerp(x,_/w),M=y.clone().lerp(x,_/w),C=w-_;for(let T=0;T<=C;T++)T===0&&_===w?A[_][T]=S:A[_][T]=S.clone().lerp(M,T/C)}for(let _=0;_<w;_++)for(let S=0;S<2*(w-_)-1;S++){let M=Math.floor(S/2);S%2===0?(c(A[_][M+1]),c(A[_+1][M]),c(A[_][M])):(c(A[_][M+1]),c(A[_+1][M+1]),c(A[_+1][M]))}}function l(v){let y=new E;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+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 x=m(v)/2/Math.PI+.5,b=g(v)/Math.PI+.5;a.push(x,1-b)}p(),u()}function u(){for(let v=0;v<a.length;v+=6){let y=a[v+0],x=a[v+2],b=a[v+4],w=Math.max(y,x,b),A=Math.min(y,x,b);w>.9&&A<.1&&(y<.2&&(a[v+0]+=1),x<.2&&(a[v+2]+=1),b<.2&&(a[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function d(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new E,y=new E,x=new E,b=new E,w=new F,A=new F,_=new F;for(let S=0,M=0;S<s.length;S+=9,M+=6){v.set(s[S+0],s[S+1],s[S+2]),y.set(s[S+3],s[S+4],s[S+5]),x.set(s[S+6],s[S+7],s[S+8]),w.set(a[M+0],a[M+1]),A.set(a[M+2],a[M+3]),_.set(a[M+4],a[M+5]),b.copy(v).add(y).add(x).divideScalar(3);let C=m(b);f(w,M+0,v,C),f(A,M+2,y,C),f(_,M+4,x,C)}}function f(v,y,x,b){b<0&&v.x===1&&(a[y]=v.x-1),x.x===0&&x.z===0&&(a[y]=b/2/Math.PI+.5)}function m(v){return Math.atan2(v.z,-v.x)}function g(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new P0(e.vertices,e.indices,e.radius,e.details)}},TA=class extends P0{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],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];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new TA(e.radius,e.detail)}},$u=class extends Ju{constructor(e){super(e),this.uuid=ts(),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 Ju().fromJSON(r))}return this}},XR={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,a=DA(e,0,s,i,!0),n=[];if(!a||a.next===a.prev)return n;let o,l,h,u,c,d,p;if(r&&(a=$R(e,t,a,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 Pc(a,n,i,o,l,p,0),n}};function DA(e,t,i,r,s){let a,n;if(s===c4(e,t,i,r)>0)for(a=t;a<i;a+=r)n=Ix(a,e[a],e[a+1],n);else for(a=i-r;a>=t;a-=r)n=Ix(a,e[a],e[a+1],n);return n&&Wp(n,n.next)&&(Oc(n),n=n.next),n}function _o(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Wp(i,i.next)||Wt(i.prev,i,i.next)===0)){if(Oc(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function Pc(e,t,i,r,s,a,n){if(!e)return;!n&&a&&s4(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?ZR(e,r,s,a):QR(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),Oc(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=KR(_o(e),t,i),Pc(e,t,i,r,s,a,2)):n===2&&JR(e,t,i,r,s,a):Pc(_o(e),t,i,r,s,a,1);break}}}function QR(e){let t=e.prev,i=e,r=e.next;if(Wt(t,i,r)>=0)return!1;let s=t.x,a=i.x,n=r.x,o=t.y,l=i.y,h=r.y,u=s<a?s<n?s:n:a<n?a:n,c=o<l?o<h?o:h:l<h?l:h,d=s>a?s>n?s:n:a>n?a:n,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&&Ml(s,o,a,l,n,h,f.x,f.y)&&Wt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ZR(e,t,i,r){let s=e.prev,a=e,n=e.next;if(Wt(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,u=s.y,c=a.y,d=n.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=o>l?o>h?o:h:l>h?l:h,g=u>c?u>d?u:d:c>d?c:d,v=zg(p,f,t,i,r),y=zg(m,g,t,i,r),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==n&&Ml(o,u,l,c,h,d,x.x,x.y)&&Wt(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==n&&Ml(o,u,l,c,h,d,b.x,b.y)&&Wt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==n&&Ml(o,u,l,c,h,d,x.x,x.y)&&Wt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==n&&Ml(o,u,l,c,h,d,b.x,b.y)&&Wt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function KR(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!Wp(s,a)&&PA(s,r,r.next,a)&&Ic(s,a)&&Ic(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),Oc(r),Oc(r.next),r=e=a),r=r.next}while(r!==e);return _o(r)}function JR(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&o4(n,o)){let l=IA(n,o);n=_o(n,n.next),l=_o(l,l.next),Pc(n,t,i,r,s,a,0),Pc(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function $R(e,t,i,r){let s=[],a,n,o,l,h;for(a=0,n=t.length;a<n;a++)o=t[a]*r,l=a<n-1?t[a+1]*r:e.length,h=DA(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(n4(h));for(s.sort(e4),a=0;a<s.length;a++)i=t4(s[a],i);return i}function e4(e,t){return e.x-t.x}function t4(e,t){let i=i4(e,t);if(!i)return t;let r=IA(i,e);return _o(r,r.next),_o(i,i.next)}function i4(e,t){let i=t,r=-1/0,s,a=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let d=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=a&&d>r&&(r=d,s=i.x<i.next.x?i:i.next,d===a))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 a>=i.x&&i.x>=l&&a!==i.x&&Ml(n<h?a:r,n,l,h,n<h?r:a,n,i.x,i.y)&&(c=Math.abs(n-i.y)/(a-i.x),Ic(i,e)&&(c<u||c===u&&(i.x>s.x||i.x===s.x&&r4(s,i)))&&(s=i,u=c)),i=i.next;while(i!==o);return s}function r4(e,t){return Wt(e.prev,e,t.prev)<0&&Wt(t.next,e,e.next)<0}function s4(e,t,i,r){let s=e;do s.z===0&&(s.z=zg(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,a4(s)}function a4(e){let t,i,r,s,a,n,o,l,h=1;do{for(i=e,e=null,a=null,n=0;i;){for(n++,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--),a?a.nextZ=s:e=s,s.prevZ=a,a=s;i=r}a.nextZ=null,h*=2}while(n>1);return e}function zg(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 n4(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 Ml(e,t,i,r,s,a,n,o){return(s-n)*(t-o)>=(e-n)*(a-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(a-o)>=(s-n)*(r-o)}function o4(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!l4(e,t)&&(Ic(e,t)&&Ic(t,e)&&h4(e,t)&&(Wt(e.prev,e,t.prev)||Wt(e,t.prev,t))||Wp(e,t)&&Wt(e.prev,e,e.next)>0&&Wt(t.prev,t,t.next)>0)}function Wt(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Wp(e,t){return e.x===t.x&&e.y===t.y}function PA(e,t,i,r){let s=zd(Wt(e,t,i)),a=zd(Wt(e,t,r)),n=zd(Wt(i,r,e)),o=zd(Wt(i,r,t));return!!(s!==a&&n!==o||s===0&&Bd(e,i,t)||a===0&&Bd(e,r,t)||n===0&&Bd(i,e,r)||o===0&&Bd(i,t,r))}function Bd(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 zd(e){return e>0?1:e<0?-1:0}function l4(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&&PA(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Ic(e,t){return Wt(e.prev,e,e.next)<0?Wt(e,t,e.next)>=0&&Wt(e,e.prev,t)>=0:Wt(e,t,e.prev)<0||Wt(e,e.next,t)<0}function h4(e,t){let i=e,r=!1,s=(e.x+t.x)/2,a=(e.y+t.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function IA(e,t){let i=new kg(e.i,e.x,e.y),r=new kg(t.i,t.x,t.y),s=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function Ix(e,t,i,r){let s=new kg(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 Oc(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 kg(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 c4(e,t,i,r){let s=0;for(let a=t,n=i-r;a<i;a+=r)s+=(e[n]-e[a])*(e[a+1]+e[n+1]),n=a;return s}var OA=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 OA.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Ox(e),Rx(i,e);let a=e.length;t.forEach(Ox);for(let o=0;o<t.length;o++)r.push(a),a+=t[o].length,Rx(i,t[o]);let n=XR.triangulate(i,r);for(let o=0;o<n.length;o+=3)s.push(n.slice(o,o+3));return s}};function Ox(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Rx(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var RA=class extends P0{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 RA(e.radius,e.detail)}},I0=class extends Ue{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(a+n,Math.PI),l=0,h=[],u=new E,c=new E,d=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let v=[],y=g/i,x=0;g==0&&a==0?x=.5/t:g==i&&o==Math.PI&&(x=-.5/t);for(let b=0;b<=t;b++){let w=b/t;u.x=-e*Math.cos(r+w*s)*Math.sin(a+y*n),u.y=e*Math.cos(a+y*n),u.z=e*Math.sin(r+w*s)*Math.sin(a+y*n),p.push(u.x,u.y,u.z),c.copy(u).normalize(),f.push(c.x,c.y,c.z),m.push(w+x,1-y),v.push(l++)}h.push(v)}for(let g=0;g<i;g++)for(let v=0;v<t;v++){let y=h[g][v+1],x=h[g][v],b=h[g+1][v],w=h[g+1][v+1];(g!==0||a>0)&&d.push(y,x,w),(g!==i-1||o<Math.PI)&&d.push(x,b,w)}this.setIndex(d),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(f,3)),this.setAttribute("uv",new Te(m,2))}static fromJSON(e){return new I0(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},LA=class extends Ue{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],u=new E,c=new E,d=new E,p=new E,f=new E,m=new E,g=new E;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,a,e,d),v(x+.01,s,a,e,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let b=0;b<=r;++b){let w=b/r*Math.PI*2,A=-t*Math.cos(w),_=t*Math.sin(w);u.x=d.x+(A*g.x+_*f.x),u.y=d.y+(A*g.y+_*f.y),u.z=d.z+(A*g.z+_*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(b/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let b=(r+1)*(y-1)+(x-1),w=(r+1)*y+(x-1),A=(r+1)*y+x,_=(r+1)*(y-1)+x;n.push(b,w,_),n.push(w,A,_)}this.setIndex(n),this.setAttribute("position",new Te(o,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(h,2));function v(y,x,b,w,A){let _=Math.cos(y),S=Math.sin(y),M=b/x*y,C=Math.cos(M);A.x=w*(2+C)*.5*_,A.y=w*(2+C)*S*.5,A.z=w*Math.sin(M)*.5}}static fromJSON(e){return new LA(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function Za(e,t,i){return BA(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function kd(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 BA(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function d4(e){function t(s,a){return e[s]-e[a]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function Lx(e,t,i){let r=e.length,s=new e.constructor(r);for(let a=0,n=0;n!==r;++a){let o=i[a]*t;for(let l=0;l!==t;++l)s[n++]=e[o+l]}return s}function zA(e,t,i,r){let s=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[s++];if(a===void 0)return;let n=a[r];if(n!==void 0)if(Array.isArray(n))do n=a[r],n!==void 0&&(t.push(a.time),i.push.apply(i,n)),a=e[s++];while(a!==void 0);else if(n.toArray!==void 0)do n=a[r],n!==void 0&&(t.push(a.time),n.toArray(i,i.length)),a=e[s++];while(a!==void 0);else do n=a[r],n!==void 0&&(t.push(a.time),i.push(n)),a=e[s++];while(a!==void 0)}var qp=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){let n=t[1];e<n&&(i=2,s=n);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 t}a=i,i=0;break i}break e}for(;i<a;){let n=i+a>>>1;e<t[n]?a=n:i=n+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 a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},u4=class extends qp{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:wl,endingEnd:wl}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,n=r[s],o=r[a];if(n===void 0)switch(this.getSettings_().endingStart){case _l:s=e,n=2*t-i;break;case Yu:s=r.length-2,n=t+r[s]-r[s+1];break;default:s=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case _l:a=e,o=2*i-t;break;case Yu:a=1,o=i+r[1]-r[0];break;default:a=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,u=this._offsetNext,c=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-c*m+2*c*f-c*p,v=(1+c)*m+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f;for(let b=0;b!==n;++b)s[b]=g*a[h+b]+v*a[l+b]+y*a[o+b]+x*a[u+b];return s}},kA=class extends qp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),u=1-h;for(let c=0;c!==n;++c)s[c]=a[l+c]*u+a[o+c]*h;return s}},p4=class extends qp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},oa=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=kd(t,this.TimeBufferType),this.values=kd(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:kd(e.times,Array),values:kd(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new p4(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new kA(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new u4(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Wu:t=this.InterpolantFactoryMethodDiscrete;break;case qu:t=this.InterpolantFactoryMethodLinear;break;case If: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 Wu;case this.InterpolantFactoryMethodLinear:return qu;case this.InterpolantFactoryMethodSmooth:return If}}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,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let n=this.getValueSize();this.times=Za(i,s,a),this.values=Za(this.values,s*n,a*n)}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 a=null;for(let n=0;n!==s;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(a!==null&&a>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,a),e=!1;break}a=o}if(r!==void 0&&BA(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=Za(this.times),t=Za(this.values),i=this.getValueSize(),r=this.getInterpolation()===If,s=e.length-1,a=1;for(let n=1;n<s;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let u=n*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(n!==a){e[a]=e[n];let u=n*i,c=a*i;for(let d=0;d!==i;++d)t[c+d]=t[u+d]}++a}}if(s>0){e[a]=e[s];for(let n=s*i,o=a*i,l=0;l!==i;++l)t[o+l]=t[n+l];++a}return a!==e.length?(this.times=Za(e,0,a),this.values=Za(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=Za(this.times,0),t=Za(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};oa.prototype.TimeBufferType=Float32Array;oa.prototype.ValueBufferType=Float32Array;oa.prototype.DefaultInterpolation=qu;var fh=class extends oa{};fh.prototype.ValueTypeName="bool";fh.prototype.ValueBufferType=Array;fh.prototype.DefaultInterpolation=Wu;fh.prototype.InterpolantFactoryMethodLinear=void 0;fh.prototype.InterpolantFactoryMethodSmooth=void 0;var NA=class extends oa{};NA.prototype.ValueTypeName="color";var ep=class extends oa{};ep.prototype.ValueTypeName="number";var f4=class extends qp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)$e.slerpFlat(s,0,a,l-n,a,l,o);return s}},$c=class extends oa{InterpolantFactoryMethodLinear(e){return new f4(this.times,this.values,this.getValueSize(),e)}};$c.prototype.ValueTypeName="quaternion";$c.prototype.DefaultInterpolation=qu;$c.prototype.InterpolantFactoryMethodSmooth=void 0;var mh=class extends oa{};mh.prototype.ValueTypeName="string";mh.prototype.ValueBufferType=Array;mh.prototype.DefaultInterpolation=Wu;mh.prototype.InterpolantFactoryMethodLinear=void 0;mh.prototype.InterpolantFactoryMethodSmooth=void 0;var tp=class extends oa{};tp.prototype.ValueTypeName="vector";var Ng=class{constructor(e,t=-1,i,r=x0){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=ts(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,n=i.length;a!==n;++a)t.push(g4(i[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(oa.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let n=0;n<s;n++){let o=[],l=[];o.push((n+s-1)%s,n,(n+1)%s),l.push(0,1,0);let h=d4(o);o=Lx(o,1,h),l=Lx(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),a.push(new ep(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(s);if(h&&h.length>1){let u=h[1],c=r[u];c||(r[u]=c=[]),c.push(l)}}let a=[];for(let n in r)a.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,u,c,d,p){if(c.length!==0){let f=[],m=[];zA(c,f,m,d),f.length!==0&&p.push(new h(u,f,m))}},r=[],s=e.name||"default",a=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let u=l[h].keys;if(!(!u||u.length===0))if(u[0].morphTargets){let c={},d;for(d=0;d<u.length;d++)if(u[d].morphTargets)for(let p=0;p<u[d].morphTargets.length;p++)c[u[d].morphTargets[p]]=-1;for(let p in c){let f=[],m=[];for(let g=0;g!==u[d].morphTargets.length;++g){let v=u[d];f.push(v.time),m.push(v.morphTarget===p?1:0)}r.push(new ep(".morphTargetInfluence["+p+"]",f,m))}o=c.length*a}else{let c=".bones["+t[h].name+"]";i(tp,c+".position",u,"pos",r),i($c,c+".quaternion",u,"rot",r),i(tp,c+".scale",u,"scl",r)}}return r.length===0?null:new this(s,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function m4(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ep;case"vector":case"vector2":case"vector3":case"vector4":return tp;case"color":return NA;case"quaternion":return $c;case"bool":case"boolean":return fh;case"string":return mh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function g4(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=m4(e.type);if(e.times===void 0){let i=[],r=[];zA(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var Bx={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={}}},UA=class{constructor(e,t,i){let r=this,s=!1,a=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,n),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,n),a===n&&(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}}},v4=new UA,O0=class{constructor(e){this.manager=e!==void 0?e:v4,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}},ga={},y4=class extends Error{constructor(e,t){super(e),this.response=t}},Ug=class extends O0{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=Bx.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ga[e]!==void 0){ga[e].push({onLoad:t,onProgress:i,onError:r});return}ga[e]=[],ga[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(a).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=ga[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,m=new ReadableStream({start(g){v();function v(){u.read().then(({done:y,value:x})=>{if(y)g.close();else{f+=x.byteLength;let b=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let w=0,A=h.length;w<A;w++){let _=h[w];_.onProgress&&_.onProgress(b)}g.enqueue(x),v()}})}}});return new Response(m)}else throw new y4(`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,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),u=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(u);return l.arrayBuffer().then(d=>c.decode(d))}}}).then(l=>{Bx.add(e,l);let h=ga[e];delete ga[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=ga[e];if(h===void 0)throw this.manager.itemError(e),l;delete ga[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}},ed=class extends Pt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ve(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},x4=class extends ed{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ve(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},om=new me,zx=new E,kx=new E,R0=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new me,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new S0,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new rt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;zx.setFromMatrixPosition(e.matrixWorld),t.position.copy(zx),kx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(kx),t.updateMatrixWorld(),om.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(om),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(om)}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}},b4=class extends R0{constructor(){super(new Gi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=Dc*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}},w4=class extends ed{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new b4}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}},Nx=new me,Uh=new E,lm=new E,_4=class extends R0{constructor(){super(new Gi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new rt(2,1,1,1),new rt(0,1,1,1),new rt(3,1,1,1),new rt(1,1,1,1),new rt(3,0,1,1),new rt(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()),Uh.setFromMatrixPosition(e.matrixWorld),i.position.copy(Uh),lm.copy(i.position),lm.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(lm),i.updateMatrixWorld(),r.makeTranslation(-Uh.x,-Uh.y,-Uh.z),Nx.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Nx)}},S4=class extends ed{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 _4}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}},A4=class extends R0{constructor(){super(new A0(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},M4=class extends ed{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.shadow=new A4}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},FA=class extends Ue{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}},VA=class extends O0{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new Ug(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(n){try{t(s.parse(JSON.parse(n)))}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),m=fd(p.type,f),g=new LR(m,p.stride);return g.uuid=p.uuid,t[d]=g,g}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 a=e.isInstancedBufferGeometry?new FA:new Ue,n=e.data.index;if(n!==void 0){let c=fd(n.type,n.array);a.setIndex(new Ze(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 Bg(f,d.itemSize,d.offset,d.normalized)}else{let f=fd(d.type,d.array),m=d.isInstancedBufferAttribute?SA:Ze;p=new m(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),a.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let d=l[c],p=[];for(let f=0,m=d.length;f<m;f++){let g=d[f],v;if(g.isInterleavedBufferAttribute){let y=r(e.data,g.data);v=new Bg(y,g.itemSize,g.offset,g.normalized)}else{let y=fd(g.type,g.array);v=new Ze(y,g.itemSize,g.normalized)}g.name!==void 0&&(v.name=g.name),p.push(v)}a.morphAttributes[c]=p}e.data.morphTargetsRelative&&(a.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];a.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),a.boundingSphere=new Tr(c,u.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},E4=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Ux(),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=Ux();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Ux(){return(typeof performance>"u"?Date:performance).now()}var C4=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let n=0;n!==r;++n)i[s+n]=i[n];a=t}else{a+=t;let n=t/a;this._mixBufferRegion(i,s,0,n,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){$e.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;$e.multiplyQuaternionsFlat(e,a,e,t,e,i),$e.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let n=0;n!==s;++n){let o=t+n;e[o]=e[o]*a+e[i+n]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let n=t+a;e[n]=e[n]+e[i+a]*r}}},L0="\\[\\]\\.:\\/",T4=new RegExp("["+L0+"]","g"),B0="[^"+L0+"]",D4="[^"+L0.replace("\\.","")+"]",P4=/((?:WC+[\/:])*)/.source.replace("WC",B0),I4=/(WCOD+)?/.source.replace("WCOD",D4),O4=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",B0),R4=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",B0),L4=new RegExp("^"+P4+I4+O4+R4+"$"),B4=["material","materials","bones","map"],z4=class{constructor(e,t,i){let r=i||Ot.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()}},Ot=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Ot.parseTrackName(t),this.node=Ot.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 Ot.Composite(e,t,i):new Ot(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(T4,"")}static parseTrackName(e){let t=L4.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);B4.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 a=0;a<s.length;a++){let n=s[a];if(n.name===t||n.uuid===t)return n;let o=i(n.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=Ot.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 a=e[r];if(a===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 n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=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=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ot.Composite=z4;Ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ot.prototype.GetterByBindingType=[Ot.prototype._getValue_direct,Ot.prototype._getValue_array,Ot.prototype._getValue_arrayElement,Ot.prototype._getValue_toArray];Ot.prototype.SetterByBindingTypeAndVersioning=[[Ot.prototype._setValue_direct,Ot.prototype._setValue_direct_setNeedsUpdate,Ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ot.prototype._setValue_array,Ot.prototype._setValue_array_setNeedsUpdate,Ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ot.prototype._setValue_arrayElement,Ot.prototype._setValue_arrayElement_setNeedsUpdate,Ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ot.prototype._setValue_fromArray,Ot.prototype._setValue_fromArray_setNeedsUpdate,Ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var k4=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,a=s.length,n=new Array(a),o={endingStart:wl,endingEnd:wl};for(let l=0;l!==a;++l){let h=s[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=sA,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,a=s/r,n=r/s;e.warp(1,a,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,a=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let a=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case y3:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case x0:default:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(a),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===y0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===rA){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,s+=Math.abs(n);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=_l,r.endingEnd=_l):(e?r.endingStart=this.zeroSlopeAtStart?_l:wl:r.endingStart=Yu,t?r.endingEnd=this.zeroSlopeAtEnd?_l:wl:r.endingEnd=Yu)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let n=a.parameterPositions,o=a.sampleValues;return n[0]=s,o[0]=t,n[1]=s+e,o[1]=i,this}},N4=new Float32Array(1),U4=class extends Ni{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let u=0;u!==s;++u){let c=r[u],d=c.name,p=h[d];if(p!==void 0)++p.referenceCount,a[u]=p;else{if(p=a[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[u].binding.parsedPath;p=new C4(Ot.create(i,d,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),a[u]=p}n[u].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let n=a.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,n=a[s],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let u=n.actionByRoot,c=(e._localRoot||this._root).uuid;delete u[c],o.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,n=a[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[s],Object.keys(n).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new kA(new Float32Array(2),new Float32Array(2),1,N4),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,a=typeof e=="string"?Ng.findByName(r,e):e,n=a!==null?a.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(a!==null?i=a.blendMode:i=x0),o!==void 0){let u=o.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=o.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new k4(this,a,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?Ng.findByName(i,e):e,a=s?s.uuid:e,n=this._actionsByClip[a];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,a);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let a=s.knownActions;for(let n=0,o=a.length;n!==o;++n){let l=a[n];this._deactivateAction(l);let h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let a in i){let n=i[a].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let a in s){let n=s[a];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},fe=class{constructor(e){this.value=e}clone(){return new fe(this.value.clone===void 0?this.value:this.value.clone())}},jA=class{constructor(e,t,i=0,r=1/0){this.ray=new ch(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new w0,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 Fg(e,this,i,t),i.sort(Fx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Fg(e[r],this,i,t);return i.sort(Fx),i}};function Fx(e,t){return e.distance-t.distance}function Fg(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let a=0,n=s.length;a<n;a++)Fg(s[a],t,i,!0)}}var Vx=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(ui(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},jx=new F,GA=class{constructor(e=new F(1/0,1/0),t=new F(-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=jx.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 jx.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)}},Gx=new E,Nd=new E,is=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){Gx.subVectors(e,this.start),Nd.subVectors(this.end,this.start);let i=Nd.dot(Nd),r=Nd.dot(Gx)/i;return t&&(r=ui(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)}},Hx=new E,F4=class extends Pt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ue,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 a=0,n=1,o=32;a<o;a++,n++){let l=a/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Te(r,3));let s=new In({fog:!1,toneMapped:!1});this.cone=new Jc(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),Hx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Hx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},V4=class extends hr{constructor(e,t,i){let r=new I0(t,4,2),s=new Kc({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)}},Wx=new E,Ud=new E,qx=new E,j4=class extends Pt{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 Ue;r.setAttribute("position",new Te([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new In({fog:!1,toneMapped:!1});this.lightPlane=new Ku(r,s),this.add(this.lightPlane),r=new Ue,r.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Ku(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),Wx.setFromMatrixPosition(this.light.matrixWorld),Ud.setFromMatrixPosition(this.light.target.matrixWorld),qx.subVectors(Ud,Wx),this.lightPlane.lookAt(Ud),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(Ud),this.targetLine.scale.z=qx.length()}},Fd=new E,qt=new uh,ip=class extends Jc{constructor(e){let t=new Ue,i=new In({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(r.length/3-1)}t.setAttribute("position",new Te(r,3)),t.setAttribute("color",new Te(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=a,this.update();let l=new Ve(16755200),h=new Ve(16711680),u=new Ve(43775),c=new Ve(16777215),d=new Ve(3355443);this.setColors(l,h,u,c,d)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;qt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Jt("c",t,e,qt,0,0,-1),Jt("t",t,e,qt,0,0,1),Jt("n1",t,e,qt,-i,-r,-1),Jt("n2",t,e,qt,i,-r,-1),Jt("n3",t,e,qt,-i,r,-1),Jt("n4",t,e,qt,i,r,-1),Jt("f1",t,e,qt,-i,-r,1),Jt("f2",t,e,qt,i,-r,1),Jt("f3",t,e,qt,-i,r,1),Jt("f4",t,e,qt,i,r,1),Jt("u1",t,e,qt,i*.7,r*1.1,-1),Jt("u2",t,e,qt,-i*.7,r*1.1,-1),Jt("u3",t,e,qt,0,r*2,-1),Jt("cf1",t,e,qt,-i,0,1),Jt("cf2",t,e,qt,i,0,1),Jt("cf3",t,e,qt,0,-r,1),Jt("cf4",t,e,qt,0,r,1),Jt("cn1",t,e,qt,-i,0,-1),Jt("cn2",t,e,qt,i,0,-1),Jt("cn3",t,e,qt,0,-r,-1),Jt("cn4",t,e,qt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Jt(e,t,i,r,s,a,n){Fd.set(s,a,n).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],Fd.x,Fd.y,Fd.z)}}var rp=class extends Jc{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 Ue;s.setIndex(new Ze(i,1)),s.setAttribute("position",new Te(r,3)),super(s,new In({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()}},G4=class extends Jc{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 Ue;r.setAttribute("position",new Te(t,3)),r.setAttribute("color",new Te(i,3));let s=new In({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ve,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()}},Ia=H4();function H4(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(r[l]=0,r[l|256]=32768,s[l]=24,s[l|256]=24):h<-14?(r[l]=1024>>-h-14,r[l|256]=1024>>-h-14|32768,s[l]=-h-1,s[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,s[l]=13,s[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,s[l]=24,s[l|256]=24):(r[l]=31744,r[l|256]=64512,s[l]=13,s[l|256]=13)}let a=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,u=0;for(;(h&8388608)===0;)h<<=1,u-=8388608;h&=-8388609,u+=947912704,a[l]=h|u}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)n[l]=l<<23;n[31]=1199570944,n[32]=2147483648;for(let l=33;l<63;++l)n[l]=2147483648+(l-32<<23);n[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:s,mantissaTable:a,exponentTable:n,offsetTable:o}}function W4(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=ui(e,-65504,65504),Ia.floatView[0]=e;let t=Ia.uint32View[0],i=t>>23&511;return Ia.baseTable[i]+((t&8388607)>>Ia.shiftTable[i])}function q4(e){let t=e>>10;return Ia.uint32View[0]=Ia.mantissaTable[Ia.offsetTable[t]+(e&1023)]+Ia.exponentTable[t],Ia.floatView[0]}var Y4=Object.freeze({__proto__:null,fromHalfFloat:q4,toHalfFloat:W4});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:hh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=hh);var Fh=".",z0=Symbol("target"),HA=Symbol("unsubscribe");function Vg(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function X4(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Ys=Array.isArray;function k0(e){return typeof e=="symbol"}var Q4={after:(e,t)=>Ys(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Ys(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Fh),k0(t)?e+t.toString():e+t):e,initial:e=>{if(Ys(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Fh);return t===-1?"":e.slice(0,t)},last:e=>{if(Ys(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Fh);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Ys(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Fh);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(Fh,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Kr=Q4;function Z4(e){return typeof e=="object"&&typeof e.next=="function"}function K4(e,t,i,r,s){let a=e.next;if(t.name==="entries")e.next=function(){let n=a.call(this);return n.done===!1&&(n.value[0]=s(n.value[0],t,n.value[0],r),n.value[1]=s(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[z0].keys();e.next=function(){let o=a.call(this);return o.done===!1&&(o.value=s(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=a.call(this);return n.done===!1&&(n.value=s(n.value,t,n.value,r)),n};return e}function Yx(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&k0(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var J4=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],a=s||e;this._pathCache.set(a,t);let n=this._proxyCache.get(a);return n===void 0&&(n=s===void 0?new Proxy(e,i):e,this._proxyCache.set(a,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Kr.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 a=this._getOwnPropertyDescriptor(e,t);return a!==void 0&&"set"in a?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 jg(e){return toString.call(e)==="[object Object]"}function Vd(){return!0}function Qo(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var WA=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),$4=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),qA={push:Vd,pop:Vd,shift:Vd,unshift:Vd,copyWithin:Qo,reverse:Qo,sort:Qo,splice:Qo,flat:Qo,fill:Qo},eL=new Set([...WA,...$4,...Object.keys(qA)]);function jd(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var YA=["keys","values","entries"],XA=new Set(["has","toString"]),QA={add:jd,clear:jd,delete:jd,forEach:jd},tL=new Set([...XA,...Object.keys(QA),...YA]);function Gd(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 iL=new Set([...XA,"get"]),ZA={set:Gd,clear:Gd,delete:Gd,forEach:Gd},rL=new Set([...iL,...Object.keys(ZA),...YA]),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 WA.has(e)}_shallowClone(e){let t=e;if(jg(e))t={...e};else if(Ys(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?(Ys(r)?this._onIsChanged=qA[t]:r instanceof Set?this._onIsChanged=QA[t]:r instanceof Map&&(this._onIsChanged=ZA[t]),r):i}update(e,t,i){let r=Kr.after(e,this._path);if(t!=="length"){let s=this.clone;Kr.walk(r,a=>{s&&s[a]&&(this._clonedCache.has(s[a])||(s[a]=this._shallowClone(s[a])),s=s[a])}),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],Kr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},Xx=class extends Dn{static isHandledMethod(e){return eL.has(e)}},sL=class extends Dn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Qx=class extends Dn{static isHandledMethod(e){return tL.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)}},Zx=class extends Dn{static isHandledMethod(e){return rL.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)}},aL=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)}},nL=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)}},gl=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return jg(e)||Ys(e)||Vg(e)}static isHandledMethod(e,t){return jg(e)?Dn.isHandledMethod(t):Ys(e)?Xx.isHandledMethod(t):e instanceof Set?Qx.isHandledMethod(t):e instanceof Map?Zx.isHandledMethod(t):Vg(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Dn;Ys(e)?r=Xx:e instanceof Date?r=sL:e instanceof Set?r=Qx:e instanceof Map?r=Zx:e instanceof WeakSet?r=aL:e instanceof WeakMap&&(r=nL),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=gl.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}},oL={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},N0=(e,t,i={})=>{i={...oL,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new J4(s),h=typeof i.onValidate=="function",u=new gl(h),c=(y,x,b,w,A)=>!h||u.isCloning||i.onValidate(Kr.concat(l.getPath(y),x),b,w,A)===!0,d=(y,x,b,w)=>{!Yx(l,i,x)&&!(n&&l.isDetached(y,e))&&p(l.getPath(y),x,b,w)},p=(y,x,b,w,A)=>{u.isCloning?u.update(y,x,w):t(Kr.concat(y,x),b,w,A)},f=y=>y&&(y[r]||y),m=(y,x,b,w)=>X4(y)||b==="constructor"||a&&!gl.isHandledMethod(x,b)||Yx(l,i,b)||l.isGetInvariant(x,b)||n&&l.isDetached(x,e)?y:(w===void 0&&(w=l.getPath(x)),l.getProxy(y,Kr.concat(w,b),g,r)),g={get(y,x,b){if(k0(x)){if(x===r||x===z0)return y;if(x===HA&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let w=Vg(y)?Reflect.get(y,x):Reflect.get(y,x,b);return m(w,y,x)},set(y,x,b,w){b=f(b);let A=y[r]||y,_=A[x];if(s(_,b)&&x in y)return!0;let S=c(y,x,b,_);return S&&l.setProperty(A,x,b,w,_)?(d(y,x,y[x],_),!0):!S},defineProperty(y,x,b){if(!l.isSameDescriptor(b,y,x)){let w=y[x];c(y,x,b.value,w)&&l.defineProperty(y,x,b,w)&&d(y,x,b.value,w)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let b=Reflect.get(y,x),w=c(y,x,void 0,b);return w&&l.deleteProperty(y,x,b)?(d(y,x,void 0,b),!0):!w},apply(y,x,b){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,w,b);if((o===!1||o!==!0&&!o.includes(y.name))&&gl.isHandledType(w)){let A=Kr.initial(l.getPath(y)),_=gl.isHandledMethod(w,y.name);u.start(w,A,b);let S=Reflect.apply(y,u.preferredThisArg(y,x,w),_?b.map(T=>f(T)):b),M=u.isChanged(w,s),C=u.stop();if(gl.isHandledType(S)&&_&&(x instanceof Map&&y.name==="get"&&(A=Kr.concat(A,b[0])),S=l.getProxy(S,A,g)),M){let T={name:y.name,args:b,result:S},D=u.isCloning?Kr.initial(A):A,P=u.isCloning?Kr.last(A):"";c(Kr.get(e,D),P,w,C,T)?p(D,P,w,C,T):u.undo(w)}return(x instanceof Map||x instanceof Set)&&Z4(S)?K4(S,y,x,A,m):S}return Reflect.apply(y,x,b)}},v=l.getProxy(e,i.pathAsArray?[]:"",g);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};N0.target=e=>e&&e[z0]||e;N0.unsubscribe=e=>e[HA]||e;var Kx=N0,lL=typeof global=="object"&&global&&global.Object===Object&&global,KA=lL,hL=typeof self=="object"&&self&&self.Object===Object&&self,cL=KA||hL||Function("return this")(),Cs=cL,dL=Cs.Symbol,ss=dL,JA=Object.prototype,uL=JA.hasOwnProperty,pL=JA.toString,Vh=ss?ss.toStringTag:void 0;function fL(e){var t=uL.call(e,Vh),i=e[Vh];try{e[Vh]=void 0;var r=!0}catch{}var s=pL.call(e);return r&&(t?e[Vh]=i:delete e[Vh]),s}var mL=fL,gL=Object.prototype,vL=gL.toString;function yL(e){return vL.call(e)}var xL=yL,bL="[object Null]",wL="[object Undefined]",Jx=ss?ss.toStringTag:void 0;function _L(e){return e==null?e===void 0?wL:bL:Jx&&Jx in Object(e)?mL(e):xL(e)}var Eo=_L;function SL(e){return e!=null&&typeof e=="object"}var Fa=SL,AL="[object Symbol]";function ML(e){return typeof e=="symbol"||Fa(e)&&Eo(e)==AL}var Yp=ML;function EL(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 $A=EL,CL=Array.isArray,ia=CL,TL=1/0,$x=ss?ss.prototype:void 0,eb=$x?$x.toString:void 0;function e2(e){if(typeof e=="string")return e;if(ia(e))return $A(e,e2)+"";if(Yp(e))return eb?eb.call(e):"";var t=e+"";return t=="0"&&1/e==-TL?"-0":t}var DL=e2,PL=/\s/;function IL(e){for(var t=e.length;t--&&PL.test(e.charAt(t)););return t}var OL=IL,RL=/^\s+/;function LL(e){return e&&e.slice(0,OL(e)+1).replace(RL,"")}var BL=LL;function zL(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Es=zL,tb=0/0,kL=/^[-+]0x[0-9a-f]+$/i,NL=/^0b[01]+$/i,UL=/^0o[0-7]+$/i,FL=parseInt;function VL(e){if(typeof e=="number")return e;if(Yp(e))return tb;if(Es(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Es(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=BL(e);var i=NL.test(e);return i||UL.test(e)?FL(e.slice(2),i?2:8):kL.test(e)?tb:+e}var ib=VL;function jL(e){return e}var GL=jL,HL="[object AsyncFunction]",WL="[object Function]",qL="[object GeneratorFunction]",YL="[object Proxy]";function XL(e){if(!Es(e))return!1;var t=Eo(e);return t==WL||t==qL||t==HL||t==YL}var t2=XL,QL=Cs["__core-js_shared__"],hm=QL,rb=function(){var e=/[^.]+$/.exec(hm&&hm.keys&&hm.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ZL(e){return!!rb&&rb in e}var KL=ZL,JL=Function.prototype,$L=JL.toString;function eB(e){if(e!=null){try{return $L.call(e)}catch{}try{return e+""}catch{}}return""}var Co=eB,tB=/[\\^$.*+?()[\]{}|]/g,iB=/^\[object .+?Constructor\]$/,rB=Function.prototype,sB=Object.prototype,aB=rB.toString,nB=sB.hasOwnProperty,oB=RegExp("^"+aB.call(nB).replace(tB,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function lB(e){if(!Es(e)||KL(e))return!1;var t=t2(e)?oB:iB;return t.test(Co(e))}var hB=lB;function cB(e,t){return e?.[t]}var dB=cB;function uB(e,t){var i=dB(e,t);return hB(i)?i:void 0}var To=uB,pB=To(Cs,"WeakMap"),Gg=pB,sb=Object.create,fB=function(){function e(){}return function(t){if(!Es(t))return{};if(sb)return sb(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),mB=fB;function gB(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 vB=gB;function yB(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var xB=yB,bB=800,wB=16,_B=Date.now;function SB(e){var t=0,i=0;return function(){var r=_B(),s=wB-(r-i);if(i=r,s>0){if(++t>=bB)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var AB=SB;function MB(e){return function(){return e}}var EB=MB,CB=function(){try{var e=To(Object,"defineProperty");return e({},"",{}),e}catch{}}(),sp=CB,TB=sp?function(e,t){return sp(e,"toString",{configurable:!0,enumerable:!1,value:EB(t),writable:!0})}:GL,DB=TB,PB=AB(DB),IB=PB;function OB(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var RB=OB,LB=9007199254740991,BB=/^(?:0|[1-9]\d*)$/;function zB(e,t){var i=typeof e;return t=t??LB,!!t&&(i=="number"||i!="symbol"&&BB.test(e))&&e>-1&&e%1==0&&e<t}var U0=zB;function kB(e,t,i){t=="__proto__"&&sp?sp(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var i2=kB;function NB(e,t){return e===t||e!==e&&t!==t}var F0=NB,UB=Object.prototype,FB=UB.hasOwnProperty;function VB(e,t,i){var r=e[t];(!(FB.call(e,t)&&F0(r,i))||i===void 0&&!(t in e))&&i2(e,t,i)}var V0=VB;function jB(e,t,i,r){var s=!i;i||(i={});for(var a=-1,n=t.length;++a<n;){var o=t[a],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?i2(i,o,l):V0(i,o,l)}return i}var td=jB,ab=Math.max;function GB(e,t,i){return t=ab(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=ab(r.length-t,0),n=Array(a);++s<a;)n[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(n),vB(e,this,o)}}var HB=GB,WB=9007199254740991;function qB(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=WB}var j0=qB;function YB(e){return e!=null&&j0(e.length)&&!t2(e)}var r2=YB,XB=Object.prototype;function QB(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||XB;return e===i}var G0=QB;function ZB(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var KB=ZB,JB="[object Arguments]";function $B(e){return Fa(e)&&Eo(e)==JB}var nb=$B,s2=Object.prototype,ez=s2.hasOwnProperty,tz=s2.propertyIsEnumerable,iz=nb(function(){return arguments}())?nb:function(e){return Fa(e)&&ez.call(e,"callee")&&!tz.call(e,"callee")},H0=iz;function rz(){return!1}var sz=rz,a2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ob=a2&&typeof module=="object"&&module&&!module.nodeType&&module,az=ob&&ob.exports===a2,lb=az?Cs.Buffer:void 0,nz=lb?lb.isBuffer:void 0,oz=nz||sz,ap=oz,lz="[object Arguments]",hz="[object Array]",cz="[object Boolean]",dz="[object Date]",uz="[object Error]",pz="[object Function]",fz="[object Map]",mz="[object Number]",gz="[object Object]",vz="[object RegExp]",yz="[object Set]",xz="[object String]",bz="[object WeakMap]",wz="[object ArrayBuffer]",_z="[object DataView]",Sz="[object Float32Array]",Az="[object Float64Array]",Mz="[object Int8Array]",Ez="[object Int16Array]",Cz="[object Int32Array]",Tz="[object Uint8Array]",Dz="[object Uint8ClampedArray]",Pz="[object Uint16Array]",Iz="[object Uint32Array]",Vt={};Vt[Sz]=Vt[Az]=Vt[Mz]=Vt[Ez]=Vt[Cz]=Vt[Tz]=Vt[Dz]=Vt[Pz]=Vt[Iz]=!0;Vt[lz]=Vt[hz]=Vt[wz]=Vt[cz]=Vt[_z]=Vt[dz]=Vt[uz]=Vt[pz]=Vt[fz]=Vt[mz]=Vt[gz]=Vt[vz]=Vt[yz]=Vt[xz]=Vt[bz]=!1;function Oz(e){return Fa(e)&&j0(e.length)&&!!Vt[Eo(e)]}var Rz=Oz;function Lz(e){return function(t){return e(t)}}var W0=Lz,n2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,bc=n2&&typeof module=="object"&&module&&!module.nodeType&&module,Bz=bc&&bc.exports===n2,cm=Bz&&KA.process,zz=function(){try{var e=bc&&bc.require&&bc.require("util").types;return e||cm&&cm.binding&&cm.binding("util")}catch{}}(),Zl=zz,hb=Zl&&Zl.isTypedArray,kz=hb?W0(hb):Rz,o2=kz,Nz=Object.prototype,Uz=Nz.hasOwnProperty;function Fz(e,t){var i=ia(e),r=!i&&H0(e),s=!i&&!r&&ap(e),a=!i&&!r&&!s&&o2(e),n=i||r||s||a,o=n?KB(e.length,String):[],l=o.length;for(var h in e)(t||Uz.call(e,h))&&!(n&&(h=="length"||s&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||U0(h,l)))&&o.push(h);return o}var l2=Fz;function Vz(e,t){return function(i){return e(t(i))}}var h2=Vz,jz=h2(Object.keys,Object),Gz=jz,Hz=Object.prototype,Wz=Hz.hasOwnProperty;function qz(e){if(!G0(e))return Gz(e);var t=[];for(var i in Object(e))Wz.call(e,i)&&i!="constructor"&&t.push(i);return t}var Yz=qz;function Xz(e){return r2(e)?l2(e):Yz(e)}var q0=Xz;function Qz(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var Zz=Qz,Kz=Object.prototype,Jz=Kz.hasOwnProperty;function $z(e){if(!Es(e))return Zz(e);var t=G0(e),i=[];for(var r in e)r=="constructor"&&(t||!Jz.call(e,r))||i.push(r);return i}var e5=$z;function t5(e){return r2(e)?l2(e,!0):e5(e)}var Y0=t5,i5=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r5=/^\w*$/;function s5(e,t){if(ia(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Yp(e)?!0:r5.test(e)||!i5.test(e)||t!=null&&e in Object(t)}var a5=s5,n5=To(Object,"create"),Rc=n5;function o5(){this.__data__=Rc?Rc(null):{},this.size=0}var l5=o5;function h5(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var c5=h5,d5="__lodash_hash_undefined__",u5=Object.prototype,p5=u5.hasOwnProperty;function f5(e){var t=this.__data__;if(Rc){var i=t[e];return i===d5?void 0:i}return p5.call(t,e)?t[e]:void 0}var m5=f5,g5=Object.prototype,v5=g5.hasOwnProperty;function y5(e){var t=this.__data__;return Rc?t[e]!==void 0:v5.call(t,e)}var x5=y5,b5="__lodash_hash_undefined__";function w5(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Rc&&t===void 0?b5:t,this}var _5=w5;function gh(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])}}gh.prototype.clear=l5;gh.prototype.delete=c5;gh.prototype.get=m5;gh.prototype.has=x5;gh.prototype.set=_5;var cb=gh;function S5(){this.__data__=[],this.size=0}var A5=S5;function M5(e,t){for(var i=e.length;i--;)if(F0(e[i][0],t))return i;return-1}var Xp=M5,E5=Array.prototype,C5=E5.splice;function T5(e){var t=this.__data__,i=Xp(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():C5.call(t,i,1),--this.size,!0}var D5=T5;function P5(e){var t=this.__data__,i=Xp(t,e);return i<0?void 0:t[i][1]}var I5=P5;function O5(e){return Xp(this.__data__,e)>-1}var R5=O5;function L5(e,t){var i=this.__data__,r=Xp(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var B5=L5;function vh(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])}}vh.prototype.clear=A5;vh.prototype.delete=D5;vh.prototype.get=I5;vh.prototype.has=R5;vh.prototype.set=B5;var Qp=vh,z5=To(Cs,"Map"),Lc=z5;function k5(){this.size=0,this.__data__={hash:new cb,map:new(Lc||Qp),string:new cb}}var N5=k5;function U5(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var F5=U5;function V5(e,t){var i=e.__data__;return F5(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Zp=V5;function j5(e){var t=Zp(this,e).delete(e);return this.size-=t?1:0,t}var G5=j5;function H5(e){return Zp(this,e).get(e)}var W5=H5;function q5(e){return Zp(this,e).has(e)}var Y5=q5;function X5(e,t){var i=Zp(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Q5=X5;function yh(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])}}yh.prototype.clear=N5;yh.prototype.delete=G5;yh.prototype.get=W5;yh.prototype.has=Y5;yh.prototype.set=Q5;var Kp=yh,Z5="Expected a function";function X0(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Z5);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=i.cache;if(a.has(s))return a.get(s);var n=e.apply(this,r);return i.cache=a.set(s,n)||a,n};return i.cache=new(X0.Cache||Kp),i}X0.Cache=Kp;var K5=X0,J5=500;function $5(e){var t=K5(e,function(r){return i.size===J5&&i.clear(),r}),i=t.cache;return t}var ek=$5,tk=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ik=/\\(\\)?/g,rk=ek(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(tk,function(i,r,s,a){t.push(s?a.replace(ik,"$1"):r||i)}),t}),sk=rk;function ak(e){return e==null?"":DL(e)}var nk=ak;function ok(e,t){return ia(e)?e:a5(e,t)?[e]:sk(nk(e))}var xh=ok,lk=1/0;function hk(e){if(typeof e=="string"||Yp(e))return e;var t=e+"";return t=="0"&&1/e==-lk?"-0":t}var Jp=hk;function ck(e,t){t=xh(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Jp(t[i++])];return i&&i==r?e:void 0}var c2=ck;function dk(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Q0=dk,db=ss?ss.isConcatSpreadable:void 0;function uk(e){return ia(e)||H0(e)||!!(db&&e&&e[db])}var pk=uk;function d2(e,t,i,r,s){var a=-1,n=e.length;for(i||(i=pk),s||(s=[]);++a<n;){var o=e[a];t>0&&i(o)?t>1?d2(o,t-1,i,r,s):Q0(s,o):r||(s[s.length]=o)}return s}var fk=d2;function mk(e){var t=e==null?0:e.length;return t?fk(e,1):[]}var gk=mk;function vk(e){return IB(HB(e,void 0,gk),e+"")}var u2=vk,yk=h2(Object.getPrototypeOf,Object),Z0=yk,xk="[object Object]",bk=Function.prototype,wk=Object.prototype,p2=bk.toString,_k=wk.hasOwnProperty,Sk=p2.call(Object);function Ak(e){if(!Fa(e)||Eo(e)!=xk)return!1;var t=Z0(e);if(t===null)return!0;var i=_k.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&p2.call(i)==Sk}var Mk=Ak;function Ek(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 a=Array(s);++r<s;)a[r]=e[r+t];return a}var Ck=Ek;function Tk(){this.__data__=new Qp,this.size=0}var Dk=Tk;function Pk(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Ik=Pk;function Ok(e){return this.__data__.get(e)}var Rk=Ok;function Lk(e){return this.__data__.has(e)}var Bk=Lk,zk=200;function kk(e,t){var i=this.__data__;if(i instanceof Qp){var r=i.__data__;if(!Lc||r.length<zk-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Kp(r)}return i.set(e,t),this.size=i.size,this}var Nk=kk;function bh(e){var t=this.__data__=new Qp(e);this.size=t.size}bh.prototype.clear=Dk;bh.prototype.delete=Ik;bh.prototype.get=Rk;bh.prototype.has=Bk;bh.prototype.set=Nk;var Lu=bh;function Uk(e,t){return e&&td(t,q0(t),e)}var Fk=Uk;function Vk(e,t){return e&&td(t,Y0(t),e)}var jk=Vk,f2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ub=f2&&typeof module=="object"&&module&&!module.nodeType&&module,Gk=ub&&ub.exports===f2,pb=Gk?Cs.Buffer:void 0,fb=pb?pb.allocUnsafe:void 0;function Hk(e,t){if(t)return e.slice();var i=e.length,r=fb?fb(i):new e.constructor(i);return e.copy(r),r}var Wk=Hk;function qk(e,t){for(var i=-1,r=e==null?0:e.length,s=0,a=[];++i<r;){var n=e[i];t(n,i,e)&&(a[s++]=n)}return a}var Yk=qk;function Xk(){return[]}var m2=Xk,Qk=Object.prototype,Zk=Qk.propertyIsEnumerable,mb=Object.getOwnPropertySymbols,Kk=mb?function(e){return e==null?[]:(e=Object(e),Yk(mb(e),function(t){return Zk.call(e,t)}))}:m2,K0=Kk;function Jk(e,t){return td(e,K0(e),t)}var $k=Jk,eN=Object.getOwnPropertySymbols,tN=eN?function(e){for(var t=[];e;)Q0(t,K0(e)),e=Z0(e);return t}:m2,g2=tN;function iN(e,t){return td(e,g2(e),t)}var rN=iN;function sN(e,t,i){var r=t(e);return ia(e)?r:Q0(r,i(e))}var v2=sN;function aN(e){return v2(e,q0,K0)}var Hg=aN;function nN(e){return v2(e,Y0,g2)}var y2=nN,oN=To(Cs,"DataView"),Wg=oN,lN=To(Cs,"Promise"),qg=lN,hN=To(Cs,"Set"),Yg=hN,gb="[object Map]",cN="[object Object]",vb="[object Promise]",yb="[object Set]",xb="[object WeakMap]",bb="[object DataView]",dN=Co(Wg),uN=Co(Lc),pN=Co(qg),fN=Co(Yg),mN=Co(Gg),Qn=Eo;(Wg&&Qn(new Wg(new ArrayBuffer(1)))!=bb||Lc&&Qn(new Lc)!=gb||qg&&Qn(qg.resolve())!=vb||Yg&&Qn(new Yg)!=yb||Gg&&Qn(new Gg)!=xb)&&(Qn=function(e){var t=Eo(e),i=t==cN?e.constructor:void 0,r=i?Co(i):"";if(r)switch(r){case dN:return bb;case uN:return gb;case pN:return vb;case fN:return yb;case mN:return xb}return t});var Bc=Qn,gN=Object.prototype,vN=gN.hasOwnProperty;function yN(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&vN.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var xN=yN,bN=Cs.Uint8Array,np=bN;function wN(e){var t=new e.constructor(e.byteLength);return new np(t).set(new np(e)),t}var J0=wN;function _N(e,t){var i=t?J0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var SN=_N,AN=/\w*$/;function MN(e){var t=new e.constructor(e.source,AN.exec(e));return t.lastIndex=e.lastIndex,t}var EN=MN,wb=ss?ss.prototype:void 0,_b=wb?wb.valueOf:void 0;function CN(e){return _b?Object(_b.call(e)):{}}var TN=CN;function DN(e,t){var i=t?J0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var PN=DN,IN="[object Boolean]",ON="[object Date]",RN="[object Map]",LN="[object Number]",BN="[object RegExp]",zN="[object Set]",kN="[object String]",NN="[object Symbol]",UN="[object ArrayBuffer]",FN="[object DataView]",VN="[object Float32Array]",jN="[object Float64Array]",GN="[object Int8Array]",HN="[object Int16Array]",WN="[object Int32Array]",qN="[object Uint8Array]",YN="[object Uint8ClampedArray]",XN="[object Uint16Array]",QN="[object Uint32Array]";function ZN(e,t,i){var r=e.constructor;switch(t){case UN:return J0(e);case IN:case ON:return new r(+e);case FN:return SN(e,i);case VN:case jN:case GN:case HN:case WN:case qN:case YN:case XN:case QN:return PN(e,i);case RN:return new r;case LN:case kN:return new r(e);case BN:return EN(e);case zN:return new r;case NN:return TN(e)}}var KN=ZN;function JN(e){return typeof e.constructor=="function"&&!G0(e)?mB(Z0(e)):{}}var $N=JN,eU="[object Map]";function tU(e){return Fa(e)&&Bc(e)==eU}var iU=tU,Sb=Zl&&Zl.isMap,rU=Sb?W0(Sb):iU,sU=rU,aU="[object Set]";function nU(e){return Fa(e)&&Bc(e)==aU}var oU=nU,Ab=Zl&&Zl.isSet,lU=Ab?W0(Ab):oU,hU=lU,cU=1,dU=2,uU=4,x2="[object Arguments]",pU="[object Array]",fU="[object Boolean]",mU="[object Date]",gU="[object Error]",b2="[object Function]",vU="[object GeneratorFunction]",yU="[object Map]",xU="[object Number]",w2="[object Object]",bU="[object RegExp]",wU="[object Set]",_U="[object String]",SU="[object Symbol]",AU="[object WeakMap]",MU="[object ArrayBuffer]",EU="[object DataView]",CU="[object Float32Array]",TU="[object Float64Array]",DU="[object Int8Array]",PU="[object Int16Array]",IU="[object Int32Array]",OU="[object Uint8Array]",RU="[object Uint8ClampedArray]",LU="[object Uint16Array]",BU="[object Uint32Array]",Ut={};Ut[x2]=Ut[pU]=Ut[MU]=Ut[EU]=Ut[fU]=Ut[mU]=Ut[CU]=Ut[TU]=Ut[DU]=Ut[PU]=Ut[IU]=Ut[yU]=Ut[xU]=Ut[w2]=Ut[bU]=Ut[wU]=Ut[_U]=Ut[SU]=Ut[OU]=Ut[RU]=Ut[LU]=Ut[BU]=!0;Ut[gU]=Ut[b2]=Ut[AU]=!1;function Bu(e,t,i,r,s,a){var n,o=t&cU,l=t&dU,h=t&uU;if(i&&(n=s?i(e,r,s,a):i(e)),n!==void 0)return n;if(!Es(e))return e;var u=ia(e);if(u){if(n=xN(e),!o)return xB(e,n)}else{var c=Bc(e),d=c==b2||c==vU;if(ap(e))return Wk(e,o);if(c==w2||c==x2||d&&!s){if(n=l||d?{}:$N(e),!o)return l?rN(e,jk(n,e)):$k(e,Fk(n,e))}else{if(!Ut[c])return s?e:{};n=KN(e,c,o)}}a||(a=new Lu);var p=a.get(e);if(p)return p;a.set(e,n),hU(e)?e.forEach(function(g){n.add(Bu(g,t,i,g,e,a))}):sU(e)&&e.forEach(function(g,v){n.set(v,Bu(g,t,i,v,e,a))});var f=h?l?y2:Hg:l?Y0:q0,m=u?void 0:f(e);return RB(m||e,function(g,v){m&&(v=g,g=e[v]),V0(n,v,Bu(g,t,i,v,e,a))}),n}var _2=Bu,zU=1,kU=4;function NU(e){return _2(e,zU|kU)}var $p=NU,UU="__lodash_hash_undefined__";function FU(e){return this.__data__.set(e,UU),this}var VU=FU;function jU(e){return this.__data__.has(e)}var GU=jU;function op(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Kp;++t<i;)this.add(e[t])}op.prototype.add=op.prototype.push=VU;op.prototype.has=GU;var HU=op;function WU(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 qU=WU;function YU(e,t){return e.has(t)}var XU=YU,QU=1,ZU=2;function KU(e,t,i,r,s,a){var n=i&QU,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=a.get(e),u=a.get(t);if(h&&u)return h==t&&u==e;var c=-1,d=!0,p=i&ZU?new HU:void 0;for(a.set(e,t),a.set(t,e);++c<o;){var f=e[c],m=t[c];if(r)var g=n?r(m,f,c,t,e,a):r(f,m,c,e,t,a);if(g!==void 0){if(g)continue;d=!1;break}if(p){if(!qU(t,function(v,y){if(!XU(p,y)&&(f===v||s(f,v,i,r,a)))return p.push(y)})){d=!1;break}}else if(!(f===m||s(f,m,i,r,a))){d=!1;break}}return a.delete(e),a.delete(t),d}var S2=KU;function JU(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var $U=JU;function eF(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var tF=eF,iF=1,rF=2,sF="[object Boolean]",aF="[object Date]",nF="[object Error]",oF="[object Map]",lF="[object Number]",hF="[object RegExp]",cF="[object Set]",dF="[object String]",uF="[object Symbol]",pF="[object ArrayBuffer]",fF="[object DataView]",Mb=ss?ss.prototype:void 0,dm=Mb?Mb.valueOf:void 0;function mF(e,t,i,r,s,a,n){switch(i){case fF:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case pF:return!(e.byteLength!=t.byteLength||!a(new np(e),new np(t)));case sF:case aF:case lF:return F0(+e,+t);case nF:return e.name==t.name&&e.message==t.message;case hF:case dF:return e==t+"";case oF:var o=$U;case cF:var l=r&iF;if(o||(o=tF),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=rF,n.set(e,t);var u=S2(o(e),o(t),r,s,a,n);return n.delete(e),u;case uF:if(dm)return dm.call(e)==dm.call(t)}return!1}var gF=mF,vF=1,yF=Object.prototype,xF=yF.hasOwnProperty;function bF(e,t,i,r,s,a){var n=i&vF,o=Hg(e),l=o.length,h=Hg(t),u=h.length;if(l!=u&&!n)return!1;for(var c=l;c--;){var d=o[c];if(!(n?d in t:xF.call(t,d)))return!1}var p=a.get(e),f=a.get(t);if(p&&f)return p==t&&f==e;var m=!0;a.set(e,t),a.set(t,e);for(var g=n;++c<l;){d=o[c];var v=e[d],y=t[d];if(r)var x=n?r(y,v,d,t,e,a):r(v,y,d,e,t,a);if(!(x===void 0?v===y||s(v,y,i,r,a):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var b=e.constructor,w=t.constructor;b!=w&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(m=!1)}return a.delete(e),a.delete(t),m}var wF=bF,_F=1,Eb="[object Arguments]",Cb="[object Array]",Hd="[object Object]",SF=Object.prototype,Tb=SF.hasOwnProperty;function AF(e,t,i,r,s,a){var n=ia(e),o=ia(t),l=n?Cb:Bc(e),h=o?Cb:Bc(t);l=l==Eb?Hd:l,h=h==Eb?Hd:h;var u=l==Hd,c=h==Hd,d=l==h;if(d&&ap(e)){if(!ap(t))return!1;n=!0,u=!1}if(d&&!u)return a||(a=new Lu),n||o2(e)?S2(e,t,i,r,s,a):gF(e,t,l,i,r,s,a);if(!(i&_F)){var p=u&&Tb.call(e,"__wrapped__"),f=c&&Tb.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return a||(a=new Lu),s(m,g,i,r,a)}}return d?(a||(a=new Lu),wF(e,t,i,r,s,a)):!1}var MF=AF;function A2(e,t,i,r,s){return e===t?!0:e==null||t==null||!Fa(e)&&!Fa(t)?e!==e&&t!==t:MF(e,t,i,r,A2,s)}var EF=A2;function CF(e,t){return e!=null&&t in Object(e)}var TF=CF;function DF(e,t,i){t=xh(t,e);for(var r=-1,s=t.length,a=!1;++r<s;){var n=Jp(t[r]);if(!(a=e!=null&&i(e,n)))break;e=e[n]}return a||++r!=s?a:(s=e==null?0:e.length,!!s&&j0(s)&&U0(n,s)&&(ia(e)||H0(e)))}var PF=DF;function IF(e,t){return e!=null&&PF(e,t,TF)}var OF=IF,RF=function(){return Cs.Date.now()},um=RF,LF="Expected a function",BF=Math.max,zF=Math.min;function kF(e,t,i){var r,s,a,n,o,l,h=0,u=!1,c=!1,d=!0;if(typeof e!="function")throw new TypeError(LF);t=ib(t)||0,Es(i)&&(u=!!i.leading,c="maxWait"in i,a=c?BF(ib(i.maxWait)||0,t):a,d="trailing"in i?!!i.trailing:d);function p(A){var _=r,S=s;return r=s=void 0,h=A,n=e.apply(S,_),n}function f(A){return h=A,o=setTimeout(v,t),u?p(A):n}function m(A){var _=A-l,S=A-h,M=t-_;return c?zF(M,a-S):M}function g(A){var _=A-l,S=A-h;return l===void 0||_>=t||_<0||c&&S>=a}function v(){var A=um();if(g(A))return y(A);o=setTimeout(v,m(A))}function y(A){return o=void 0,d&&r?p(A):(r=s=void 0,n)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function b(){return o===void 0?n:y(um())}function w(){var A=um(),_=g(A);if(r=arguments,s=this,l=A,_){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)),n}return w.cancel=x,w.flush=b,w}var $0=kF;function NF(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var UF=NF;function FF(e,t){return t.length<2?e:c2(e,Ck(t,0,-1))}var VF=FF;function jF(e,t){return EF(e,t)}var M2=jF;function GF(e,t){return t=xh(t,e),e=VF(e,t),e==null||delete e[Jp(UF(t))]}var HF=GF;function WF(e){return Mk(e)?void 0:e}var qF=WF,YF=1,XF=2,QF=4,ZF=u2(function(e,t){var i={};if(e==null)return i;var r=!1;t=$A(t,function(a){return a=xh(a,e),r||(r=a.length>1),a}),td(e,y2(e),i),r&&(i=_2(i,YF|XF|QF,qF));for(var s=t.length;s--;)HF(i,t[s]);return i}),Xg=ZF;function KF(e,t,i,r){if(!Es(e))return e;t=xh(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s<a;){var l=Jp(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=n){var u=o[l];h=r?r(u,l,o):void 0,h===void 0&&(h=Es(u)?u:U0(t[s+1])?[]:{})}V0(o,l,h),o=o[l]}return e}var JF=KF;function $F(e,t,i){for(var r=-1,s=t.length,a={};++r<s;){var n=t[r],o=c2(e,n);i(o,n)&&JF(a,xh(n,e),o)}return a}var e6=$F;function t6(e,t){return e6(e,t,function(i,r){return OF(e,r)})}var i6=t6,r6=u2(function(e,t){return e==null?{}:i6(e,t)}),ka=r6,s6="Expected a function";function a6(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(s6);return Es(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),$0(e,t,{leading:r,maxWait:t,trailing:s})}var n6=a6;function o6(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Va(e,t){return Object.setPrototypeOf(e,t),e}var l6=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),h6=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),c6=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||ef&&"ontouchend"in document,d6=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,u6=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,p6=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},f6=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},m6=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},g6=l6(),pQ=g6?m6():void 0,ef=h6(),E2=c6(),v6=d6(),Ur=u6(),Db=p6(),Pb=Number(f6());function C2(e){return Array.isArray(e)?e:[e]}function y6(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 Wd(e){return ef?e.metaKey:e.ctrlKey}var Ye=[],lp={},hc={},zu={};function T2(e){Ye.includes(e)||Ye.push(e)}function Il(e){delete lp[e.pointerId];for(let t=0;t<Ye.length;t++)if(Ye[t].pointerId===e.pointerId){Ye.splice(t,1);break}}function x6(){Ye.splice(0,Ye.length)}function hp(e){if(e.pointerType!=="touch")return;let t=lp[e.pointerId];t===void 0&&(t={x:0,y:0},lp[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function pm(e){let t=e.pointerId===Ye[0].pointerId?Ye[1]:Ye[0];return lp[t.pointerId]}function D2(e){hc[e.key]=!0,zu[e.key]=zu[e.key]===void 0?1:zu[e.key]+1}function P2(e){if(ef&&hc.Meta)for(let t in hc)hc[t]=!1;else hc[e.key]=!1;zu={}}function b6(e){e.addEventListener("pointerdown",T2,!0),e.addEventListener("pointerdown",hp,!0),e.addEventListener("pointermove",hp,!0),e.addEventListener("pointerup",Il,!0),e.addEventListener("pointercancel",Il,!0),e.addEventListener("pointerleave",Il,!0),window.addEventListener("keydown",D2,!0),window.addEventListener("keyup",P2,!0)}function w6(e){e.removeEventListener("pointerdown",T2,!0),e.removeEventListener("pointerdown",hp,!0),e.removeEventListener("pointermove",hp,!0),e.removeEventListener("pointerup",Il,!0),e.removeEventListener("pointercancel",Il,!0),e.removeEventListener("pointerleave",Il,!0),window.removeEventListener("keydown",D2,!0),window.removeEventListener("keyup",P2,!0)}var I2,_6=new Promise(e=>{I2=e}),qd;function S6(){if(qd)return qd;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@0.9.503/build",i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});I2(n)}return qd=e(),qd}var O2,A6=new Promise(e=>{O2=e}),Yd;function M6(){if(Yd)return Yd;async function e(){let t=await import("./physics.js");await t.init(),O2(t)}return Yd=e(),Yd}var ot=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,ot.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:a}=e,n={...t,[s]:a};return Object.setPrototypeOf(n,ot.prototype),{data:n,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,ot.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function ey(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"&&ey(r)}return Object.freeze(e)}function E6(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 R2=class extends Error{};function fm(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function fn(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 a=e;e=t,t=a}let r=[],s=1/(i+1);for(let a=0;a<i;a++){let n=e+(t-e)*(a+.75+Math.random()*.5)*s;r.push(n)}return r}function ty(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 C6(){return typeof process<"u"}function L2(e,t){for(let i of e)t(i.id,i.data)!==!0&&L2(i.children,t)}function B2(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)B2(i,t)}var Er=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Er.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ey(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}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}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&&B2(i,t)}}traverse(e){L2(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(n=>n.id===e);if(s<0)throw new Error("not expected");let a=r[s];return r=[...r],r[s]={...a,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let a=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:a}}Object.setPrototypeOf(r,Er.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:a}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:s,children:a};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,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(n=>n.id===t);e.localIndex=s,r=[...r];let a=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...a,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 R2("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(c=>c.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((c,d)=>c.fi-d.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,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)=>E6(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 fn(0,i,i);{let s=r[0].fi;return fn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=r.find(n=>n.fi>s.fi);if(a===void 0){let n=r[r.length-1].fi;return fn(n,n+i,i)}else return fn(s.fi,a.fi,i)}}},cp;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,a={},n=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");a[l]=n[h],n[h]=s[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}else{let s=r.props,a={},n={...i},o=!1;if(s)for(let l of Object.keys(s)){a[l]=n[l];let h=s[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}}e.runOp=t})(cp||(cp={}));var We=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,We.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ey(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(a=>a.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,We.prototype);let t=e;return C6()||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,a={fi:t,id:i,data:r};return s=[...s,a],s.sort((n,o)=>n.fi-o.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(a=>a.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 a=r[s].fi,n={...r[s],fi:t};return r[s]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:a,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 fn(0,t,t);{let r=i[0].fi;return fn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>r.fi);if(s===void 0){let a=i[i.length-1].fi;return fn(a,a+t,t)}else return fn(r.fi,s.fi,t)}}};function Kl(e){return e&&typeof e=="object"&&e instanceof _i}var _i=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&&!Kl(i))return null;r+=1}i=i?fm(i):new _i;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=fm(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=fm(o);l[e.path[r-1]]=i,i=l}else{let l=new _i;l[e.path[r-1]]=i,i=l}}r-=1}let a=Object.setPrototypeOf(i,_i.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},Sn;(e=>{function t(s,a){return zc(s,a)??s}e.apply=t;function i(s,a){return ry(s,a)}e.merge=i;function r(s,a){let n=0,o=a.path,l=s;for(;n<o.length&&l!==void 0;){if(l=ar.zoomOnce(l,o[n]),l===void 0)return a;if(!Kl(l))return;n+=1}if(l===void 0)return a;if(Kl(l))if(a.type===0){let h={...a.props};for(let u of Object.keys(l))delete h[u];return{...a,props:h}}else if(a.type===1||a.type===4||a.type===7){let h=iy([a],l);return h?(console.log(h),h):a}else return a}e.filterOp=r})(Sn||(Sn={}));function iy(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=zc(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=iy(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:a,data:n,children:o}}else return{...s,id:a,data:n}});if(i)return r}function T6(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=zc(s.data,t[a]);return i=i||n!==void 0,n===void 0&&(n=s.data),{...s,id:a,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function zc(e,t){if(!Kl(t))return t;if(e instanceof Er){let i=iy(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof We)return T6(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=zc(s,t[a]);return i=i||n!==void 0,n===void 0&&(n=s),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof _i)return ry(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=zc(a,t[s]);r=r||n!==void 0,n===void 0&&(n=a),i[s]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function ry(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Kl(t))return t;if(!Kl(e))return Sn.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 _i;for(let s of i){let a=ry(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function D6(e,t){let i={cur:[],result:[],len:0};return e=kc(e,t,i)??e,[e,i.result]}function dp(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function up(e){e&&(e.len-=1)}function P6(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function z2(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=kc(a.data,t,dp(i,n));up(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=z2(a.children,t,i);return h!==void 0?r=!0:h=a.children,{...a,id:n,data:l,children:h}});if(r)return s}function I6(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=kc(a.data,t,dp(i,n));return up(i),r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:n,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function kc(e,t,i){if(e instanceof Er){let r=z2(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof We)return I6(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=kc(a,t,dp(i,n));return up(i),r=r||o!==void 0,o===void 0&&(o=a),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!ty(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=kc(n,t,dp(i,a));up(i),s=s||l!==void 0,l===void 0&&(l=n),r[a]=l}else r[a]=n;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&P6(i),r}else return}}var Qg;(e=>{function t(i,r){let s=ar.zoom(r,i.path);if(typeof s=="object"){let a={};for(let n of Object.keys(i.props))a[n]=s[n];return{...i,props:a}}else return{...i,props:{}}}e.replaceProps=t})(Qg||(Qg={}));var Wi;(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 _i&&h.type===0&&(d=l.runOp({...h,path:u.slice(c.length)}),d===null&&(d=void 0)),d===void 0&&c.length===u.length&&(l instanceof Er||l instanceof We||l instanceof ot?d=l.runOp(h):d=cp.runOp(l,h)),d!==void 0)if(d!==null){let m=d.data;for(let g=c.length-1;g>=0;g--){let v=u[g],y=c[g];if(y instanceof Er){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof We){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof ot){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof _i){let x={...y,[v]:m};m=Object.setPrototypeOf(x,_i.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 x=m;m=[...y],m[v]=x}else m={...y,[v]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let p=u[c.length],f;if(l instanceof Er){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof We){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 a(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=a;function n(l,h){return s(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&a(l.path,h.path)?Object.keys(l.props).every(u=>h.props[u]!==void 0):!1}e.subsumed=o})(Wi||(Wi={}));var Zg;(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 a(h,u){return[...h.filter(c=>!u.some(d=>Wi.subsumed(c,d))),...u]}e.compress=a;function n(h,u){return h.every(c=>u.every(d=>Wi.commutative(c,d)))}e.commutative=n;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||f.type===5&&f.path[f.path.length-1]==="variables"){let m,g,v;if(f.type===3?(m=ar.zoom(c,[...f.path,f.id]),v=Wi.apply(c,{...f,type:2})):(m=ar.zoom(c,[...f.path,f.id,"value"]),v=Wi.apply(c,f)),v!==null){c=v.data;let[y,x]=D6(c,{[f.id]:m});c=y;for(let b=0;b<x.length;b++){let w=x[b],A=w.pop();if(typeof A=="number"){let _=[A];for(let M=b+1;M<x.length;M++){let C=x[M],T=C[C.length-1];if(typeof T=="number"&&ar.equal(w,C.slice(0,C.length-1)))_.push(T),x.splice(M,1);else break}let S=ar.zoom(c,w);g=S.map((M,C)=>_.includes(C)?f.id:M),m=S,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let _=m,S=ar.zoom(c,w.slice(0,w.length-2)),M=S.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:_}}:C);Object.setPrototypeOf(M,Object.getPrototypeOf(S.layers)),S.layers=M}g=f.id}d.push({type:0,path:w,props:{[A]:m}}),p.push({type:0,path:w,props:{[A]:g}})}p.push(v.reverse),d.push(v.actual)}}else{let m=Wi.apply(c,f);m!==null&&(d.push(m.actual),c=m.data,p.push(m.reverse))}}catch(m){if(m instanceof R2)return null;throw m}return{data:c,actual:d,reverse:p.reverse()}}e.apply=l})(Zg||(Zg={}));var k2=Symbol(),O6=Symbol(),tf=Symbol(),id=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof U2);){let a=r._path,n=r._current;if(a!==""&&s.splice(0,0,a),r=r._parent,r===null)return;r.update(a,n)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[tf];i&&i(),delete this._children[e]}}}},R6=class extends id{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,cp.runOp(this._current,e),e.path)}},L6=class extends id{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,ot.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},N2={get(e,t){if(t===tf)return()=>{e._parent=null};if(t===k2)return e._current;if(t===O6)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 a=i[t],n=rf(e,t,a);return n!==a?(r===void 0&&(r={},e._children=r),r[t]=n,n):a},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]}}},B6={...N2,set(e,t,i){let r={type:0,props:{[t]:mi(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}},z6={...N2,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}},sy=class extends id{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[tf]=()=>{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,a=rf(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):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 a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}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)}},ay=class extends id{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[tf]=()=>{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,a=rf(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):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 mm(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&ar.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var U2=class extends id{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){mm(this.ts,t,e),mm(this.actual,i,e),mm(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function rf(e,t,i){return i instanceof Er?new sy(e,t,i):i instanceof We?new ay(e,t,i):i instanceof ot?new Proxy(new L6(e,t,i),z6):i!==null&&typeof i=="object"?ty(i)?i:new Proxy(new R6(e,t,i),B6):i}function F2(e){let t=new U2(e);return[rf(t,"",e),t]}function Nc(e,t){let[i,r]=F2(e);return t(i),r.result()}function mi(e){return e instanceof sy||e instanceof ay?e._current:e!==null&&typeof e=="object"?e[k2]:e}var ar;(e=>{function t(a,n){if(n.length===a.length)for(var o=0;o<a.length;){if(a[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(a,n,o){let l=s(o,a);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(u=>{delete h[u]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof Er||a instanceof sy)&&typeof n=="string"||(a instanceof We||a instanceof ay)&&typeof n=="string")return a.data(n);if(typeof n=="number"&&Array.isArray(a)||typeof n=="string"&&typeof a=="object"&&a!==null)return a[n]}e.zoomOnce=r;function s(a,n,o=0){for(;o<n.length&&a!==void 0;)a=r(a,n[o]),o+=1;return a}e.zoom=s})(ar||(ar={}));function k6(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 es(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 V2=class{},Ib=class extends V2{constructor(e){super(),this.id=e}},Ob=class extends V2{constructor(e){super(),this.data=e}},Kg;try{Kg=new TextDecoder}catch{}var Pe,An,K=0,j2=[],Jg=j2,$g=0,wr={},St,mn,Jr=0,Xs=0,zr,Na,pr=[],Mt,Rb={useRecords:!1,mapsAsObjects:!0},G2=class{},H2=new G2;H2.name="MessagePack 0xC1";var Jl=!1,pp=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(Pe)return Z2(()=>(tv(),this?this.unpack(e,t):pp.prototype.unpack.call(Rb,e,t)));An=t>-1?t:e.length,K=0,$g=0,Xs=0,mn=null,Jg=j2,zr=null,Pe=e;try{Mt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Pe=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 pp){if(wr=this,this.structures)return St=this.structures,Xd();(!St||St.length>0)&&(St=[])}else wr=Rb,(!St||St.length>0)&&(St=[]);return Xd()}unpackMultiple(e,t){let i,r=0;try{Jl=!0;let s=e.length,a=this?this.unpack(e,s):af.unpack(e,s);if(t){for(t(a);K<s;)if(r=K,t(Xd())===!1)return}else{for(i=[a];K<s;)r=K,i.push(Xd());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Jl=!1,tv()}}_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 Xd(){try{if(!wr.trusted&&!Jl){let t=St.sharedLength||0;t<St.length&&(St.length=t)}let e=Qt();if(K==An)St.restoreStructures&&Lb(),St=null,Pe=null,Na&&(Na=null);else if(K>An){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Jl)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw St.restoreStructures&&Lb(),tv(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function Lb(){for(let e in St.restoreStructures)St[e]=St.restoreStructures[e];St.restoreStructures=null}function Qt(){let e=Pe[K++];if(e<160)if(e<128){if(e<64)return e;{let t=St[e&63]||wr.getStructures&&W2()[e&63];return t?(t.read||(t.read=ny(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,wr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[Y2()]=Qt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Qt(),Qt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Qt();return t}else if(e<192){let t=e-160;if(Xs>=K)return mn.slice(K-Jr,(K+=t)-Jr);if(Xs==0&&An<140){let i=t<16?oy(t):q2(t);if(i!=null)return i}return ev(t)}else{let t;switch(e){case 192:return null;case 193:return zr?(t=Qt(),t>0?zr[1].slice(zr.position1,zr.position1+=t):zr[0].slice(zr.position0,zr.position0-=t)):H2;case 194:return!1;case 195:return!0;case 196:return gm(Pe[K++]);case 197:return t=Mt.getUint16(K),K+=2,gm(t);case 198:return t=Mt.getUint32(K),K+=4,gm(t);case 199:return Gn(Pe[K++]);case 200:return t=Mt.getUint16(K),K+=2,Gn(t);case 201:return t=Mt.getUint32(K),K+=4,Gn(t);case 202:if(t=Mt.getFloat32(K),wr.useFloat32>2){let i=ly[(Pe[K]&127)<<1|Pe[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=Mt.getFloat64(K),K+=8,t;case 204:return Pe[K++];case 205:return t=Mt.getUint16(K),K+=2,t;case 206:return t=Mt.getUint32(K),K+=4,t;case 207:return wr.int64AsNumber?(t=Mt.getUint32(K)*4294967296,t+=Mt.getUint32(K+4)):t=Mt.getBigUint64(K),K+=8,t;case 208:return Mt.getInt8(K++);case 209:return t=Mt.getInt16(K),K+=2,t;case 210:return t=Mt.getInt32(K),K+=4,t;case 211:return wr.int64AsNumber?(t=Mt.getInt32(K)*4294967296,t+=Mt.getUint32(K+4)):t=Mt.getBigInt64(K),K+=8,t;case 212:if(t=Pe[K++],t==114)return Ub(Pe[K++]&63);{let i=pr[t];if(i)return i.read?(K++,i.read(Qt())):i.noBuffer?(K++,i()):i(Pe.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=Pe[K],t==114?(K++,Ub(Pe[K++]&63,Pe[K++])):Gn(2);case 214:return Gn(4);case 215:return Gn(8);case 216:return Gn(16);case 217:return t=Pe[K++],Xs>=K?mn.slice(K-Jr,(K+=t)-Jr):U6(t);case 218:return t=Mt.getUint16(K),K+=2,Xs>=K?mn.slice(K-Jr,(K+=t)-Jr):F6(t);case 219:return t=Mt.getUint32(K),K+=4,Xs>=K?mn.slice(K-Jr,(K+=t)-Jr):V6(t);case 220:return t=Mt.getUint16(K),K+=2,zb(t);case 221:return t=Mt.getUint32(K),K+=4,zb(t);case 222:return t=Mt.getUint16(K),K+=2,kb(t);case 223:return t=Mt.getUint32(K),K+=4,kb(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 N6=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ny(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>N6.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(Qt);return e.highByte===0&&(e.read=Bb(t,e.read)),s()}let r={};for(let s=0,a=e.length;s<a;s++){let n=e[s];r[n]=Qt()}return r}return i.count=0,e.highByte===0?Bb(t,i):i}var Bb=(e,t)=>function(){let i=Pe[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=St[r]||W2()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=ny(s,e)),s.read()};function W2(){let e=Z2(()=>(Pe=null,wr.getStructures()));return St=wr._mergeStructures(e,St)}var ev=sf,U6=sf,F6=sf,V6=sf;function sf(e){let t;if(e<16&&(t=oy(e)))return t;if(e>64&&Kg)return Kg.decode(Pe.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=Pe[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let a=Pe[K++]&63;r.push((s&31)<<6|a)}else if((s&240)===224){let a=Pe[K++]&63,n=Pe[K++]&63;r.push((s&31)<<12|a<<6|n)}else if((s&248)===240){let a=Pe[K++]&63,n=Pe[K++]&63,o=Pe[K++]&63,l=(s&7)<<18|a<<12|n<<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+=Ti.apply(String,r),r.length=0)}return r.length>0&&(t+=Ti.apply(String,r)),t}function zb(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Qt();return t}function kb(e){if(wr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[Y2()]=Qt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Qt(),Qt());return t}}var Ti=String.fromCharCode;function q2(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=Pe[K++];if((s&128)>0){K=t;return}i[r]=s}return Ti.apply(String,i)}function oy(e){if(e<4)if(e<2){if(e===0)return"";{let t=Pe[K++];if((t&128)>1){K-=1;return}return Ti(t)}}else{let t=Pe[K++],i=Pe[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return Ti(t,i);let r=Pe[K++];if((r&128)>0){K-=3;return}return Ti(t,i,r)}else{let t=Pe[K++],i=Pe[K++],r=Pe[K++],s=Pe[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return Ti(t,i,r,s);{let a=Pe[K++];if((a&128)>0){K-=5;return}return Ti(t,i,r,s,a)}}else if(e<8){let a=Pe[K++],n=Pe[K++];if((a&128)>0||(n&128)>0){K-=6;return}if(e<7)return Ti(t,i,r,s,a,n);let o=Pe[K++];if((o&128)>0){K-=7;return}return Ti(t,i,r,s,a,n,o)}else{let a=Pe[K++],n=Pe[K++],o=Pe[K++],l=Pe[K++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return Ti(t,i,r,s,a,n,o,l);{let h=Pe[K++];if((h&128)>0){K-=9;return}return Ti(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=Pe[K++],u=Pe[K++];if((h&128)>0||(u&128)>0){K-=10;return}if(e<11)return Ti(t,i,r,s,a,n,o,l,h,u);let c=Pe[K++];if((c&128)>0){K-=11;return}return Ti(t,i,r,s,a,n,o,l,h,u,c)}else{let h=Pe[K++],u=Pe[K++],c=Pe[K++],d=Pe[K++];if((h&128)>0||(u&128)>0||(c&128)>0||(d&128)>0){K-=12;return}if(e<14){if(e===12)return Ti(t,i,r,s,a,n,o,l,h,u,c,d);{let p=Pe[K++];if((p&128)>0){K-=13;return}return Ti(t,i,r,s,a,n,o,l,h,u,c,d,p)}}else{let p=Pe[K++],f=Pe[K++];if((p&128)>0||(f&128)>0){K-=14;return}if(e<15)return Ti(t,i,r,s,a,n,o,l,h,u,c,d,p,f);let m=Pe[K++];if((m&128)>0){K-=15;return}return Ti(t,i,r,s,a,n,o,l,h,u,c,d,p,f,m)}}}}}function gm(e){return wr.copyBuffers?Uint8Array.prototype.slice.call(Pe,K,K+=e):Pe.subarray(K,K+=e)}function Gn(e){let t=Pe[K++];if(pr[t])return pr[t](Pe.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var Nb=new Array(4096);function Y2(){let e=Pe[K++];if(e>=160&&e<192){if(e=e-160,Xs>=K)return mn.slice(K-Jr,(K+=e)-Jr);if(!(Xs==0&&An<180))return ev(e)}else return K--,Qt();let t=(e<<5^(e>1?Mt.getUint16(K):e>0?Pe[K]:0))&4095,i=Nb[t],r=K,s=K+e-3,a,n=0;if(i&&i.bytes==e){for(;r<s;){if(a=Mt.getUint32(r),a!=i[n++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(a=Pe[r++],a!=i[n++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],Nb[t]=i,i.bytes=e;r<s;)a=Mt.getUint32(r),i.push(a),r+=4;for(s+=3;r<s;)a=Pe[r++],i.push(a);let o=e<16?oy(e):q2(e);return o!=null?i.string=o:i.string=ev(e)}var Ub=(e,t)=>{var i=Qt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=St[e];return s&&s.isShared&&((St.restoreStructures||(St.restoreStructures=[]))[e]=s),St[e]=i,i.read=ny(i,r),i.read()},X2=typeof self=="object"?self:global;pr[0]=()=>{};pr[0].noBuffer=!0;pr[101]=()=>{let e=Qt();return(X2[e[0]]||Error)(e[1])};pr[105]=e=>{let t=Mt.getUint32(K-4);Na||(Na=new Map);let i=Pe[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Na.set(t,s);let a=Qt();return s.used?Object.assign(r,a):(s.target=a,a)};pr[112]=e=>{let t=Mt.getUint32(K-4),i=Na.get(t);return i.used=!0,i.target};pr[115]=()=>new Set(Qt());var Q2=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");pr[116]=e=>{let t=e[0],i=Q2[t];if(!i)throw new Error("Could not find typed array for code "+t);return new X2[i](Uint8Array.prototype.slice.call(e,1).buffer)};pr[120]=()=>{let e=Qt();return new RegExp(e[0],e[1])};pr[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,zr=[Qt(),Qt()],zr.position0=0,zr.position1=0;let r=K;K=i;try{return Qt()}finally{K=r}};pr[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 Z2(e){let t=An,i=K,r=$g,s=Jr,a=Xs,n=mn,o=Jg,l=Na,h=zr,u=new Uint8Array(Pe.slice(0,An)),c=St,d=St.slice(0,St.length),p=wr,f=Jl,m=e();return An=t,K=i,$g=r,Jr=s,Xs=a,mn=n,Jg=o,Na=l,zr=h,Pe=u,Jl=f,St=c,St.splice(0,St.length,...d),wr=p,Mt=new DataView(Pe.buffer,Pe.byteOffset,Pe.byteLength),m}function tv(){Pe=null,Na=null,St=null}function j6(e){e.unpack?pr[e.type]=e.unpack:pr[e.type]=e}var ly=new Array(147);for(let e=0;e<256;e++)ly[e]=+("1e"+Math.floor(45.15-e*.30103));var af=new pp({useRecords:!1}),fQ=af.unpack,mQ=af.unpackMultiple,gQ=af.unpack,G6={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},H6=new Float32Array(1),vQ=new Uint8Array(H6.buffer,0,4),ku;try{ku=new TextEncoder}catch{}var fp,hy,nf=typeof Buffer<"u",vm=nf?Buffer.allocUnsafeSlow:Uint8Array,K2=nf?Buffer:Uint8Array,Fb=nf?4294967296:2144337920,ce,$t,te=0,Ps,Is=null,W6=/[\u0080-\uFFFF]/,jh=Symbol("record-id"),J2=class extends pp{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n,o=0,l=K2.prototype.utf8Write?function(_,S,M){return ce.utf8Write(_,S,M)}:ku&&ku.encodeInto?function(_,S){return ku.encodeInto(_,ce.subarray(S)).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,m=d+64,g=d+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(_,S){if(ce||(ce=new vm(8192),$t=new DataView(ce.buffer,0,8192),te=0),Ps=ce.length-10,Ps-te<2048?(ce=new vm(ce.length),$t=new DataView(ce.buffer,0,ce.length),Ps=ce.length-10,te=0):te=te+7&2147483640,i=te,n=h.structuredClone?new Map:null,h.bundleStrings?(Is=["",""],ce[te++]=214,ce[te++]=98,Is.position=te-i,te+=4):Is=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 D,P=r.transitions;for(let I=0,R=T.length;I<R;I++){let U=T[I];D=P[U],D||(D=P[U]=Object.create(null)),P=D}P[jh]=C+64}o=M}u||(r.nextId=M+64)}s&&(s=!1),a=r||[];try{if(b(_),Is){$t.setUint32(Is.position+i,te-Is.position-i);let M=Is;Is=null,b(M[0]),b(M[1])}if(h.offset=te,n&&n.idsToInsert){te+=n.idsToInsert.length*6,te>Ps&&A(te),h.offset=te;let M=Y6(ce.subarray(i,te),n.idsToInsert);return n=null,M}return S&X6?(ce.start=i,ce.end=te,ce):ce.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=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][jh]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||d;r.length>M&&(r=r.slice(0,M));let C=ce.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(_)):(o=M,C)}}S&Q6&&(te=i)}};let b=_=>{te>Ps&&(ce=A(te));var S=typeof _,M;if(S==="string"){let C=_.length;if(Is&&C>=8&&C<4096){let P=W6.test(_);Is[P?0:1]+=_,ce[te++]=193,b(P?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let D=C*3;if(te+D>Ps&&(ce=A(te+D)),C<64||!l){let P,I,R,U=te+T;for(P=0;P<C;P++)I=_.charCodeAt(P),I<128?ce[U++]=I:I<2048?(ce[U++]=I>>6|192,ce[U++]=I&63|128):(I&64512)===55296&&((R=_.charCodeAt(P+1))&64512)===56320?(I=65536+((I&1023)<<10)+(R&1023),P++,ce[U++]=I>>18|240,ce[U++]=I>>12&63|128,ce[U++]=I>>6&63|128,ce[U++]=I&63|128):(ce[U++]=I>>12|224,ce[U++]=I>>6&63|128,ce[U++]=I&63|128);M=U-te-T}else M=l(_,te+T,D);M<32?ce[te++]=160|M:M<256?(T<2&&ce.copyWithin(te+2,te+1,te+1+M),ce[te++]=217,ce[te++]=M):M<65536?(T<3&&ce.copyWithin(te+3,te+2,te+2+M),ce[te++]=218,ce[te++]=M>>8,ce[te++]=M&255):(T<5&&ce.copyWithin(te+5,te+3,te+3+M),ce[te++]=219,$t.setUint32(te,M),te+=4),te+=M}else if(S==="number")if(_>>>0===_)_<64?ce[te++]=_:_<256?(ce[te++]=204,ce[te++]=_):_<65536?(ce[te++]=205,ce[te++]=_>>8,ce[te++]=_&255):(ce[te++]=206,$t.setUint32(te,_),te+=4);else if(_>>0===_)_>=-32?ce[te++]=256+_:_>=-128?(ce[te++]=208,ce[te++]=_+256):_>=-32768?(ce[te++]=209,$t.setInt16(te,_),te+=2):(ce[te++]=210,$t.setInt32(te,_),te+=4);else{let C;if((C=this.useFloat32)>0&&_<4294967296&&_>=-2147483648){ce[te++]=202,$t.setFloat32(te,_);let T;if(C<4||(T=_*ly[(ce[te]&127)<<1|ce[te+1]>>7])>>0===T){te+=4;return}else te--}ce[te++]=203,$t.setFloat64(te,_),te+=8}else if(S==="object")if(!_)ce[te++]=192;else{if(n){let T=n.get(_);if(T){if(!T.id){let D=n.idsToInsert||(n.idsToInsert=[]);T.id=D.push(T)}ce[te++]=214,ce[te++]=112,$t.setUint32(te,T.id),te+=4;return}else n.set(_,{offset:te-i})}let C=_.constructor;if(C===Object)w(_,!0);else if(C===Array){M=_.length,M<16?ce[te++]=144|M:M<65536?(ce[te++]=220,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=221,$t.setUint32(te,M),te+=4);for(let T=0;T<M;T++)b(_[T])}else if(C===Map){M=_.size,M<16?ce[te++]=128|M:M<65536?(ce[te++]=222,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=223,$t.setUint32(te,M),te+=4);for(let[T,D]of _)b(T),b(D)}else{for(let T=0,D=fp.length;T<D;T++){let P=hy[T];if(_ instanceof P){let I=fp[T];if(I.write){I.type&&(ce[te++]=212,ce[te++]=I.type,ce[te++]=0),b(I.write.call(this,_));return}let R=ce,U=$t,N=te;ce=null;let L;try{L=I.pack.call(this,_,W=>(ce=R,R=null,te+=W,te>Ps&&A(te),{target:ce,targetView:$t,position:te-W}),b)}finally{R&&(ce=R,$t=U,te=N,Ps=ce.length-10)}L&&(L.length+te>Ps&&A(L.length+te),te=q6(L,ce,te,I.type));return}}w(_,!_.hasOwnProperty)}}else if(S==="boolean")ce[te++]=_?195:194;else if(S==="bigint"){if(_<BigInt(1)<<BigInt(63)&&_>=-(BigInt(1)<<BigInt(63)))ce[te++]=211,$t.setBigInt64(te,_);else if(_<BigInt(1)<<BigInt(64)&&_>0)ce[te++]=207,$t.setBigUint64(te,_);else if(this.largeBigIntToFloat)ce[te++]=203,$t.setFloat64(te,Number(_));else throw new RangeError(_+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(S==="undefined")this.encodeUndefinedAsNil?ce[te++]=192:(ce[te++]=212,ce[te++]=0,ce[te++]=0);else if(S==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+S)},w=this.useRecords===!1?this.variableMapSize?_=>{let S=Object.keys(_),M=S.length;M<16?ce[te++]=128|M:M<65536?(ce[te++]=222,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=223,$t.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)b(C=S[T]),b(_[C])}:(_,S)=>{ce[te++]=222;let M=te-i;te+=2;let C=0;for(let T in _)(S||_.hasOwnProperty(T))&&(b(T),b(_[T]),C++);ce[M+++i]=C>>8,ce[M+i]=C&255}:_=>{let S=Object.keys(_),M,C=a.transitions||(a.transitions=Object.create(null)),T=0;for(let P=0,I=S.length;P<I;P++){let R=S[P];M=C[R],M||(M=C[R]=Object.create(null),T++),C=M}let D=C[jh];if(D)D>=96&&f?(ce[te++]=((D-=96)&31)+96,ce[te++]=D>>5):ce[te++]=D;else{D=a.nextId,D||(D=64),D<m&&this.shouldShareStructure&&!this.shouldShareStructure(S)?(D=a.nextOwnId,D<g||(D=m),a.nextOwnId=D+1):(D>=g&&(D=m),a.nextId=D+1);let P=S.highByte=D>=96&&f?D-96>>5:-1;C[jh]=D,a[D-64]=S,D<m?(S.isShared=!0,a.sharedLength=D-63,s=!0,P>=0?(ce[te++]=(D&31)+96,ce[te++]=P):ce[te++]=D):(P>=0?(ce[te++]=213,ce[te++]=114,ce[te++]=(D&31)+96,ce[te++]=P):(ce[te++]=212,ce[te++]=114,ce[te++]=D),T&&(y+=x*T),v.length>=p&&(v.shift()[jh]=0),v.push(C),b(S))}for(let P=0,I=S.length;P<I;P++)b(_[S[P]])},A=_=>{let S;if(_>16777216){if(_-i>Fb)throw new Error("Packed buffer would be larger than maximum buffer size");S=Math.min(Fb,Math.round(Math.max((_-i)*(_>67108864?1.25:2),4194304)/4096)*4096)}else S=(Math.max(_-i<<2,ce.length-1)>>12)+1<<12;let M=new vm(S);return $t=new DataView(M.buffer,0,S),ce.copy?ce.copy(M,0,i,_):M.set(ce.slice(i,_)),te-=i,i=0,Ps=M.length-10,ce=M}}useBuffer(e){ce=e,$t=new DataView(ce.buffer,ce.byteOffset,ce.byteLength),te=0}};hy=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,G2];fp=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:a,position:n}=t(6);s[n++]=214,s[n++]=255,a.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:s,targetView:a,position:n}=t(10);s[n++]=215,s[n++]=255,a.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),a.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:a,position:n}=t(3);s[n++]=212,s[n++]=255,s[n++]=255}else{let{target:s,targetView:a,position:n}=t(15);s[n++]=199,s[n++]=12,s[n++]=255,a.setUint32(n,e.getMilliseconds()*1e6),a.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(s[a++]=212,s[a++]=115,s[a++]=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?Vb(e,16,t):jb(nf?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==K2&&this.structuredClone?Vb(e,Q2.indexOf(i.name),t):jb(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function Vb(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:a,position:n}=i(4+s);a[n++]=199,a[n++]=s+1}else if(s+1<65536){var{target:a,position:n}=i(5+s);a[n++]=200,a[n++]=s+1>>8,a[n++]=s+1&255}else{var{target:a,position:n,targetView:o}=i(7+s);a[n++]=201,o.setUint32(n,s+1),n+=4}a[n++]=116,a[n++]=t,a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function jb(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:a}=t(i+5);r[s++]=198,a.setUint32(s,i),s+=4}r.set(e,s)}function q6(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 Y6(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((a,n)=>a.offset>n.offset?1:-1);i=t.pop();){let a=i.offset,n=i.id;e.copyWithin(a+r,a,s),r-=6;let o=a+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,s=a}return e}function wh(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)");hy.unshift(e.Class),fp.unshift(e)}j6(e)}var $2=new J2({useRecords:!1}),yQ=$2.pack,xQ=$2.pack,{NEVER:bQ,ALWAYS:wQ,DECIMAL_ROUND:_Q,DECIMAL_FIT:SQ}=G6,X6=512,Q6=1024,Gb=new J2({structuredClone:!0});wh({Class:ot.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,ot.prototype),e}});wh({Class:We.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,We.prototype),e}});wh({Class:Er.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,Er.prototype),e}});wh({Class:Ib.prototype.constructor,type:4,write(e){return e.id},read(e){return new Ib(e)}});wh({Class:Ob.prototype.constructor,type:5,write(e){return e.data},read(e){return new Ob(e)}});wh({Class:_i.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,_i.prototype),e}});function Z6(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 iv(e){if(ty(e))return e;if(Array.isArray(e))return e.map(iv);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=iv(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var rv;(e=>{function t(s){return Gb.pack(s)}e.serialize=t;function i(s){return Gb.unpack(s)}e.deserialize=i;function r(s){return Z6(t(iv(s))).toString()}e.checksum=r})(rv||(rv={}));var Hb;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(Hb||(Hb={}));var Br={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Create","SetVariable","DynamicVariablePlay","Conditional"],MouseHover:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],Start:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Conditional:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MousePress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyPress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],GameControl:["Transition","Animation","Audio","Create","Conditional"],Collision:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],Trigger:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Resize:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],VariableChange:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},Wb;(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,mode:"Object",disabled:!1,runMode:"Once",actions:new We}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new We}}e.defaultData=i})(Wb||(Wb={}));var mp;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(mp||(mp={}));var sv;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:mp.propertyDefaultData(s),rOperand:{...mp.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,a){return{type:"State",object:s??null,state:a??null}}e.stateDefaultData=r})(sv||(sv={}));var qb;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new We,outActions:new We,condition:sv.distanceDefaultData(r)}}e.defaultData=i})(qb||(qb={}));var Yb;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new We,drop:new We}})(Yb||(Yb={}));var av;(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,actions:new We})(av||(av={}));var nv;(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})(nv||(nv={}));var Xb;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new We}}e.defaultData=i})(Xb||(Xb={}));var Qb;(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 We}}e.defaultData=i})(Qb||(Qb={}));var Zb;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new We}}e.defaultData=i})(Zb||(Zb={}));var Kb;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new We}}e.defaultData=i})(Kb||(Kb={}));var Jb;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new We,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(Jb||(Jb={}));var ov;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function s(){let n={size:"mobile",operator:"<",actions:new We},o={size:"tablet",operator:"<",actions:new We},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new We},h=new We;return h.push({id:Le.generateUUID(),fi:0,data:n},{id:Le.generateUUID(),fi:1,data:o},{id:Le.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function a(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new We}}e.defaultBreakpointData=a})(ov||(ov={}));var lv;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new We,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(lv||(lv={}));var _h="personal camera",wc="a218fcc3-276b-49b9-b485-49037fd14f5f",K6=2960946,as=5526619,El;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a]}e.lerp=i})(El||(El={}));var fo;(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 a(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=a;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;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})(fo||(fo={}));var gp;(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,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a,r[2]+(s[2]-r[2])*a,r[3]+(s[3]-r[3])*a]}e.lerp=i})(gp||(gp={}));var $l;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let n=0;n<16;n++)if(s[n]!==a[n])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,a){let n=a.slice(0);for(var o=0,l=a.length;o<l;o+=3){let h=s[3]*a[o]+s[7]*a[o+1]+s[11]*a[o+2]+s[15];n[o]=(s[0]*a[o]+s[4]*a[o+1]+s[8]*a[o+2]+s[12])/h,n[o+1]=(s[1]*a[o]+s[5]*a[o+1]+s[9]*a[o+2]+s[13])/h,n[o+2]=(s[2]*a[o]+s[6]*a[o+1]+s[10]*a[o+2]+s[14])/h}return n}e.applyMatrix4=r})($l||($l={}));var rr;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.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(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function a(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=a;function n(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=n;function o(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}}e.lerp=o})(rr||(rr={}));var bs;(e=>{e.white={...rr.white,a:1},e.transparent={...rr.white,a:0};function t(n){return{r:n[0],g:n[1],b:n[2],a:n[3]}}e.from0to1=t;function i(n,o){return{...rr.fromHex(n),a:o}}e.fromHexAndA=i;function r(n){return{r:Math.round(n.r*255),g:Math.round(n.g*255),b:Math.round(n.b*255),a:n.a}}e.toRgb255a1=r;function s(n,o){return rr.equals(n,o)&&n.a===o.a}e.equals=s;function a(n,o,l){return{r:n.r+(o.r-n.r)*l,g:n.g+(o.g-n.g)*l,b:n.b+(o.b-n.b)*l,a:n.a+(o.a-n.a)*l}}e.lerp=a})(bs||(bs={}));var hv;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(hv||(hv={}));var $b;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})($b||($b={}));var ew;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(ew||(ew={}));var ln;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(ln||(ln={}));function J6(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var So;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(So||(So={}));var eh;(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},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(eh||(eh={}));var gn;(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(a=>a*(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 a={...r};if(eM.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;tM.forEach(l=>{Object.assign(a.radial,{[l]:o[l]??n[l]})})}if(a.linear={...r.linear},s.linear){let n=r.linear,o=s.linear;iM.forEach(l=>{Object.assign(a.linear,{[l]:o[l]??n[l]})})}if(a.grid={...r.grid},s.grid){let n=r.grid,o=s.grid;rM.forEach(l=>{Object.assign(a.grid,{[l]:o[l]??n[l]})})}if(a.toObject={...r.toObject},s.toObject){let n=r.toObject,o=s.toObject;sM.forEach(l=>{Object.assign(a.toObject,{[l]:o[l]??n[l]})})}if(a.randomnessObject={...r.randomnessObject},s.randomnessObject){let n=r.randomnessObject,o=s.randomnessObject;aM.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(gn||(gn={}));var cv;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let a=[];r.count!==void 0&&a.push({type:0,path:s,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&a.push({type:0,path:[...s,n],props:o})}return a}e.toOps=i})(cv||(cv={}));var eM=["count"],tM=["radius","start","end","position","scale","rotation"],iM=["position","scale","rotation"],rM=["count","size"],sM=["count","position","scale","rotation"],aM=["strength","scale","rotation","position","movement","seed","freqScale"],dv;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(dv||(dv={}));var uv;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:bs.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:bs.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:bs.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(uv||(uv={}));var th;(e=>e.defaultData={enabled:"visibility",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]})(th||(th={}));var pv;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(pv||(pv={}));var fv;(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})(fv||(fv={}));var mv;(e=>e.defaultData={...fv.defaultData,...pv.defaultData})(mv||(mv={}));var tw;(e=>{function t(i,r){let s=[];if("material"in i){let a=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;a&&s.push(a)}else if("materials"in i)for(let a of i.materials){let n=typeof a=="string"?r.materials[a]??r.lib.materials[a]?.asset:a;n&&s.push(n)}return s}e.getMaterialData=t})(tw||(tw={}));var vp;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(vp||(vp={}));var iw;(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==="pattern"||i==="light"}e.is=t})(iw||(iw={}));function $6(e){return e.type!=="displace"}var rw;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(rw||(rw={}));var nM=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],eV=["wrapping","image","video","name"],xr;(e=>{function t(a,n){let{texture:o,...l}=n;if(Object.assign(a,l),o){let h=a.texture;h&&Object.assign(h,o)}}e.patch=t;function i(a,n){return a==="light"&&n?r(n):s(a)}e.defaultData=i;function r(a){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(a){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...n,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:vp.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...n,type:"color",color:rr.fromHex(as)};case"depth":return{...n,type:"depth",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{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,type:"gradient",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{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...rr.fromHex(6710886),a:1},colorB:{...rr.fromHex(6710886),a:1},colorC:{...rr.fromHex(16777215),a:1},colorD:{...rr.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...n,type:"fresnel",color:bs.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,type:"toon",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:bs.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:bs.fromHexAndA(0,1),contourColor:bs.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{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...n,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...rr.fromHex(0),a:1},colorB:{...rr.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(xr||(xr={}));var Yi;(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 We}}e.defaultEmptyData=r;function s(h="layer1",u="layer2"){return n("phong",h,u)}e.defaultData=s;function a(h,u){return{...h,name:u}}e.withName=a;function n(h,u="layer1",c="layer2"){let d=new We;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=n;function o(h,u="phong",c="layer1",d="layer2"){let p=xr.defaultData("texture");Object.assign(p.texture,{image:h});let f=new We;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 We;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})(Yi||(Yi={}));var yp;(e=>{function t(){return{points:new We,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(yp||(yp={}));var xp;(e=>{function t(){return{points:new We,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(xp||(xp={}));var oM={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},gv;(e=>{function t(i,r){let s={...i};return hM.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(gv||(gv={}));var lM={shape:oM,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},hM=["depth","offset","angle","twist","startScale","endScale"],bp;(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})(bp||(bp={}));var vv;(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,gv.merge(s.extrusion,r.extrusion))),s}e.merge=t})(vv||(vv={}));var Ol;(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:xp.defaultData(),extrusion:lM};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:yp.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:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(Ol||(Ol={}));var sw=["width","height","depth"],yv;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:rr.white,near:.1,far:2e3})(yv||(yv={}));var wp;(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}}})(wp||(wp={}));var xv;(e=>e.defaultData={softShadowQuality:"low"})(xv||(xv={}));var bv;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(bv||(bv={}));var wv;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(wv||(wv={}));var ih;(e=>e.defaultData={usePhysics:!1,gravity:-10})(ih||(ih={}));var _v;(e=>e.defaultData={playCamera:_h,gameControlObject:null})(_v||(_v={}));var Sv;(e=>e.defaultData={backgroundColor:bs.fromHexAndA(K6,1),postprocessing:wp.defaultData,fog:yv.defaultData,globalPhysics:ih.defaultData,ambient:bv.defaultData,ao:wv.defaultData,shadow:xv.defaultData,publish:_v.defaultData})(Sv||(Sv={}));var aw;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(aw||(aw={}));var rh;(e=>{e.identity={...hv.identity,hiddenMatrix:$l.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,a){return{position:a?.position||s.position,rotation:a?.rotation||s.rotation,scale:a?.scale||s.scale,hiddenMatrix:a?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,a){return o6({position:fo.isEqual(s.position,a.position)?void 0:a.position,rotation:fo.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:fo.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:$l.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(rh||(rh={}));var ur;(e=>e.defaultData={states:new We,events:new We,visible:!0,raycastLock:!1,physics:th.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...rh.identity,cloner:null})(ur||(ur={}));var Av;(e=>e.defaultData={type:"Empty",...ur.defaultData})(Av||(Av={}));var nw;(e=>e.defaultData={type:"Component",...ur.defaultData})(nw||(nw={}));var Rl;(e=>e.defaultData={type:"Mesh",...ur.defaultData,...mv.defaultData})(Rl||(Rl={}));var Uc;(e=>e.defaultData={...ur.defaultData,...rh.identity,position:[0,0,eh.DefaultTargetOffset],...eh.defaultData})(Uc||(Uc={}));var Mv;(e=>{function t(i){return{...ur.defaultData,...uv.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Mv||(Mv={}));var _p;(e=>{function t(r,s,a=0){for(;a<s.length;){let n=r?r[s[a]]:void 0;if(s.length===a+1)return n;if(n)r=n.descendants,a+=1;else return}}e.resolveWithDes=t;function i(r,s,a=0){let n=t(r,s,a);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})(_p||(_p={}));var vn;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...ur.defaultData,...s,component:r,overrides:new _i,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=rh.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(vn||(vn={}));var sh;(e=>e.defaultData={type:"Page",...ur.defaultData,physics:{...th.defaultData,fusedBody:!1},...Sv.defaultData,camera:Uc.defaultData})(sh||(sh={}));var Ev;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:$l.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:th.defaultData,states:new We,events:new We,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...eh.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",...ur.defaultData,...Rl.defaultData,geometry:Ol.defaultData("RectangleGeometry"),material:Yi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...ur.defaultData,...Rl.defaultData,geometry:Ol.defaultData("BooleanGeometry"),material:Yi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...ur.defaultData,...Rl.defaultData,geometry:Ol.defaultData("TextGeometry"),material:Yi.defaultTwoLayerData("phong","layer1","layer2")}))(Ev||(Ev={}));var so;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new _i}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new _i})))):So.is(a.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(a,n){if(n===void 0)return a;let o={...a};return"material"in o&&"material"in n&&n.material&&(o.material=Nc(o.material,l=>{if(typeof l!="string")for(let[h,u]of Object.entries(n.material.layers)){let c=l.layers.data(h);c&&xr.patch(c,u)}}).data),o.materials&&n.materials&&(o.materials=Nc(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let u=n.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(a,n){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:m,...g}=f;if(m!==void 0&&Object.keys(m).length>0){let v={path:[...c,"layers",p,"texture"],props:m,type:0};l.push(v)}if(Object.keys(g).length>0){let v={path:[...c,"layers",p],props:g,type:0};l.push(v)}}}for(let[c,d]of Object.entries(n))if(c!=="name")if(c==="cloner")l.push(...cv.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(a,n){if(n===void 0)return a;let o={...a};if(Object.assign(o,rh.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),So.is(a.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;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(a.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:vv.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:gn.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:gn.merge(o.cloner,n.cloner)});else if(dv.is(a.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=rr.clone(l.color))}return o}e.patch=s})(so||(so={}));var Sp;(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,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Sp||(Sp={}));var mo;(e=>e.defaultData={orbitControls:Sp.defaultData,playPage:wc,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",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"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,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,hdTransmission:!1})(mo||(mo={}));var Cv;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Cv||(Cv={}));var Tv;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Tv||(Tv={}));var Ll;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Cv.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Tv.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ll||(Ll={}));var Fc;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,a){r.scene.objects.traverseFrom(s,(n,o)=>{if(o.type==="Instance"){let l=Cp.getComponentData(r,o.component)?.data;l&&a(n,o,l.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(Fc||(Fc={}));var Bl;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let a=[],n=Ev.defaultMeshObject;s.withLight===!0&&a.push({fi:-1,data:Mv.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&a.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:n,children:[]});let o=new Er;return o.push({fi:1,id:wc,data:{...sh.defaultData,name:"Scene 1"},children:a}),o}e.defaultData={objects:t(),publish:mo.defaultData,styles:Ll.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new Er,publish:mo.defaultData,styles:Ll.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:mo.defaultData,styles:Ll.defaultData()}};function i(s){return{...e.defaultData,objects:Va(s,Er.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(Bl||(Bl={}));var _c;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(_c||(_c={}));var Ap;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Ap||(Ap={}));var Fr;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function s(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=s;function a(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=a})(Fr||(Fr={}));var Dv;(e=>e.all=["images","videos","colors","audios","fonts","materials","variables"])(Dv||(Dv={}));var ow;(e=>e.all=[...Dv.all,"components"])(ow||(ow={}));var lw;(e=>{function t(){return{images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,materials:new ot,components:new ot,variables:new ot}}e.defaultData=t})(lw||(lw={}));var ah;(e=>{function t(){return{images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,materials:new ot,components:new ot,variables:new ot}}e.defaultData=t})(ah||(ah={}));var vs;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Va(n,ot.prototype)}e.defaultColors=t;function i(n){let o={};return n?.withAITexture&&(o["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Ap.emptyImage,name:"AI generated image"}),Va(o,ot.prototype)}e.defaultImages=i;function r(){return{catelogs:new ot,materials:new ot,images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,variables:new We,lib:ah.defaultData()}}e.emptyData=r;function s(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=s;function a(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),u=Math.round(n-l*3600-h*60);return{textValue:[l,h,u]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=a})(vs||(vs={}));var Mp;(e=>e.list=["idle","move","jump","run"])(Mp||(Mp={}));var Ep;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,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"],["run","\u21E7"],["none","Ctrl"]],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 We,move:new We,jump:new We,run:new We},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:bs.fromHexAndA(3728051,1)}}))(Ep||(Ep={}));function hw(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]],a=[0,1];for(let o=2;o<10;o++)s.push(s[1]),a.push(1);let n={...ka(mi(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:a,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...mi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function hn(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function cn(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=Yi.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Yi.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Yi.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&t(s.material)})})}function tV(e){Object.assign(e.scene.publish,{orbitControls:{...Sp.defaultData,...mi(e.scene.publish.orbitControls)}})}function iV(e){Object.assign(e.scene.publish.settings,{video:{...mo.defaultData.settings.video,...mi(e.scene.publish.settings.video)}})}function rV(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,a]of Object.entries(r))if((nM.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(eV.includes(n)||typeof o=="boolean")&&delete a[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let a=s;a.material?t(a.material):a.materials&&a.materials.forEach(n=>{t(n)})})})}function sV(e){e.scene.publish.withBackground=!0}function aV(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function nV(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 oV(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 lV(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=mi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=mi(i).booleanExclude!==!0)}})}function hV(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 cV(e){function t(r){Object.setPrototypeOf(r,_i.prototype),r.texture&&Object.setPrototypeOf(r.texture,_i.prototype)}function i(r){Object.setPrototypeOf(r,_i.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(a=>{let n=a;if(n.material){let o=mi(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=mi(l).layers;i(h),l.layers=h}})})}function cw(e){e.layers===void 0&&Object.assign(e,Yi.defaultTwoLayerData("lambert"))}function ym(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={...mi(t),colors:i,steps:r};Object.assign(t,s)}})}function dV(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function dw(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&ym(r)}):"material"in i&&typeof i.material!="string"&&ym(i.material)}),Object.values(e.shared.materials).forEach(t=>ym(t))}function uV(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 pV(e){e.shared.audios=Va({},ot.prototype)}function fV(e){e.shared.videos=Va({},ot.prototype)}function mV(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 gV(e){Object.entries(mi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(mi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function vV(e){e.scene.publish.settings.web.preload=!1}function uw(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 pw(e){e.layers&&e.layers.forEach(t=>{$6(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function yV(e){e.shared.fonts=Va({},ot.prototype)}function xV(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 bV(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=Yi.defaultTwoLayerData("phong"),n=typeof s.color=="string"?e.shared.colors[s.color]:s.color;a.layers[1].data.color={r:n.r,g:n.g,b:n.b},a.layers[1].data.alpha=s.alpha;let o=xV(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...ur.defaultData,...Rl.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ol.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:a,states:mi(s.states),events:mi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=mi(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 wV(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 We,move:new We,jump:new We}});else{let a=new We;Object.assign(s,{actions:a}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&a.push({fi:0,id:Le.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(u,ka(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(u,{control1:{...n.control1},control2:{...n.control2}});let c={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},d={state:n.state,...c,...u},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new We({fi:0,id:Le.generateUUID(),data:h},{fi:1,id:Le.generateUUID(),data:d})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function _V(e){e.scene.objects.traverse((t,i)=>{function r(s,a){let n=new We,o=[];if(i.events.forEach((l,h,u)=>{if(l.type==="Audio"&&l.trigger===a){let c;o.push(h),l.interaction==="play"?c={...ka(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={...ka(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&n.push({fi:u,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:Le.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function fw(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 mw(e){hn(e,fw),cn(e,fw)}function SV(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function AV(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 MV(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=Yi.defaultTwoLayerData("phong"))})}function EV(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 CV(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 TV(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 DV(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function PV(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function IV(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function OV(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Ep.defaultDataThirdPerson.navmesh)})})}function RV(e){e.scene.styles||(e.scene.styles=Ll.defaultData())}function gw(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function LV(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),cn(e,gw),hn(e,gw)}function BV(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new We})})})}function zV(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function vw(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function kV(e,t){if(t<1&&(cn(e,hw),hn(e,hw),e.schema=1),t<2&&(tV(e),e.schema=2),t<3&&(rV(e),e.schema=3),t<4&&(sV(e),e.schema=4),t<5&&(aV(e),e.schema=5),t<6&&(nV(e),e.schema=6),t<7&&(oV(e),e.schema=7),t<8&&(e.schema=8),t<9&&(dw(e),e.schema=9),t<10&&(dV(e),e.schema=10),t<11&&(uV(e),e.schema=11),t<12&&(dw(e),e.schema=12),t<13&&(pV(e),e.schema=13),t<14&&(mV(e),e.schema=14),t<15&&(gV(e),e.schema=15),t<16&&(vV(e),e.schema=16),t<17&&(cn(e,uw),hn(e,uw),e.schema=17),t<18&&(cn(e,cw),hn(e,cw),e.schema=18),t<19&&(iV(e),e.schema=19),t<20&&(yV(e),bV(e),e.schema=20),t<21&&(wV(e),_V(e),e.schema=21),t<22&&(mw(e),e.schema=22),t<23&&(SV(e),e.schema=23),t<24&&(AV(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(fV(e),t<25&&(e.schema=25)),t<26&&(lV(e),e.schema=26),t<27&&(hV(e),e.schema=27),t<28&&(mw(e),e.schema=28),t<29&&(cV(e),e.schema=29),t<30&&(MV(e),e.schema=30),t<31&&(EV(e),e.schema=31),t<33&&(CV(e),e.schema=33),t<34&&(TV(e),e.schema=34),t<35&&(DV(e),e.schema=35),t<36&&(PV(e),e.schema=36),t<37&&(IV(e),e.schema=37),t<38&&(cn(e,pw),hn(e,pw),e.schema=38),t<39&&(OV(e),e.schema=39),t<40&&(RV(e),e.schema=40),t<41&&(LV(e),e.schema=41),t<42&&(BV(e),e.schema=42),t<43&&(zV(e),e.schema=43),t<99){cn(e,vw),hn(e,vw),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=_h);let i=mi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=wc,r.insertBefore(null,null,[{id:wc,data:{...sh.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:ka(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:ka(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...ih.defaultData,...ka(e.scene.environment,"usePhysics","gravity")},camera:mi(e.scene.ownerCamera)??sh.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==Bl.TRASH_CAN_ID&&r.move(wc,n.fi,n.id);let s=0,a=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(a,1)],a+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,th.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function yw(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function NV(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}var vl=180/Math.PI;function xw(e){e.rotation=e.rotation.slice(0,3).map(t=>t*vl)}function cM(e){xw(e),e.type==="Page"&&xw(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*vl))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*vl),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*vl),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=vl,t.extrusion.twist*=vl),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(mi(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Once")})}function UV(e){e.shared.variables=Va({},ot.prototype)}function FV(e){let t=mi(e.shared.variables);e.shared.variables=Va(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),We.prototype)}var dn=107;function dM(e,t){t(e.data);for(let i of e.children)dM(i,t)}function VV(e){let t=e.schema??104;t!==dn&&t<105&&(dM(e.asset,cM),e.schema=105)}function uM(e){let t=e.schema??0;if(t!==dn){console.warn("updating from ",t,"to ",dn),kV(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=mo.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(cn(e,yw),hn(e,yw),e.schema=101),t<102&&(NV(e),e.schema=102),t<104&&(e.shared.catelogs=new ot,e.shared.lib=ah.defaultData(),e.schema=104),t<105&&(UV(e),e.scene.objects.traverse((i,r)=>{cM(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))VV(i);t<106&&(FV(e),e.schema=106),t<107&&(e.shared.lib.variables=ah.defaultData().variables,e.schema=107)}}var Cp;(e=>{e.defaultData={schema:dn,scene:Bl.defaultData,frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",_c.defaultData),shared:{...vs.emptyData(),colors:vs.defaultColors()}},e.emptyDataForImports=function(s){let a=Bl.emptyDataWithPage(s);return{schema:dn,scene:a,frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",_c.defaultData),shared:{...vs.emptyData(),colors:vs.defaultColors(),images:vs.defaultImages(s)}}},e.emptyData=function(){return{schema:dn,scene:Bl.emptyDataWithPage(),frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",_c.defaultData),shared:vs.emptyData()}},e.collabHelper={...Zg,updateSchema(s){return(s.schema??0)<dn?Nc(s,uM):(s.schema??0)-dn}};function t(s){let a=e.collabHelper.updateSchema(s);return typeof a=="number"?a===0?s:null:a.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:ah.defaultData()}}}e.withoutLib=i;function r(s,a){let n=s.scene.objects.get(a);if(n&&n.data.type==="Component")return n;{let o=s.shared.lib.components[a];if(o)return o.asset}}e.getComponentData=r})(Cp||(Cp={}));function ao(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)),a={},n={},o=e[0].morphTargetsRelative,l=new Ue,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;a[p]===void 0&&(a[p]=[]),a[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;n[p]===void 0&&(n[p]=[]),n[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 a){let c=bw(a[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 n){let c=n[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 m=0;m<n[u].length;++m)p.push(n[u][m][d]);let f=bw(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 bw(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 a=new t(s),n=0;for(let o=0;o<e.length;++o)a.set(e[o].array,n),n+=e[o].array.length;return new Ze(a,i,r)}var jV=Math.pow(2,-24),Qd=class{constructor(){}};function Qs(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 ww(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 _w(e,t){t.set(e)}function Sw(e,t,i){let r,s;for(let a=0;a<3;a++){let n=a+3;r=e[a],s=t[a],i[a]=r<s?r:s,r=e[n],s=t[n],i[n]=r>s?r:s}}function Zd(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],a=t[e+2*r+1],n=s-a,o=s+a;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function Gh(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 GV(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 Ze(s,1));for(let a=0;a<i;a++)s[a]=a}}function HV(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,a)=>s-a);for(let s=0;s<r.length-1;s++){let a=r[s],n=r[s+1];t.push({offset:a/3,count:(n-a)/3})}return t}function xm(e,t,i,r,s=null){let a=1/0,n=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,m=-1/0,g=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let b=e[y+0],w=e[y+1],A=b-w,_=b+w;A<a&&(a=A),_>l&&(l=_),v&&b<c&&(c=b),v&&b>f&&(f=b);let S=e[y+2],M=e[y+3],C=S-M,T=S+M;C<n&&(n=C),T>h&&(h=T),v&&S<d&&(d=S),v&&S>m&&(m=S);let D=e[y+4],P=e[y+5],I=D-P,R=D+P;I<o&&(o=I),R>u&&(u=R),v&&D<p&&(p=D),v&&D>g&&(g=D)}r[0]=a,r[1]=n,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]=m,s[5]=g)}function WV(e,t,i,r){let s=1/0,a=1/0,n=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<a&&(a=p),p>l&&(l=p);let f=e[u+4];f<n&&(n=f),f>h&&(h=f)}r[0]=s,r[1]=a,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function qV(e,t,i,r,s){let a=i,n=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;a<=n&&t[a*6+l]<o;)a++;for(;a<=n&&t[n*6+l]>=o;)n--;if(a<n){for(let h=0;h<3;h++){let u=e[a*3+h];e[a*3+h]=e[n*3+h],e[n*3+h]=u;let c=t[a*6+h*2+0];t[a*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=c;let d=t[a*6+h*2+1];t[a*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=d}a++,n--}else return a}}var Sa=32,YV=(e,t)=>e.candidate-t.candidate,Ka=new Array(Sa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Kd=new Float32Array(6);function XV(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=ww(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=ww(e),n!==-1&&(o=QV(i,r,s,n));else if(a===2){let l=Gh(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)/Sa;if(s<Sa/4){let m=[...Ka];m.length=s;let g=0;for(let y=u;y<c;y+=6,g++){let x=m[g];x.candidate=i[y+2*d],x.count=0;let{bounds:b,leftCacheBounds:w,rightCacheBounds:A}=x;for(let _=0;_<3;_++)A[_]=1/0,A[_+3]=-1/0,w[_]=1/0,w[_+3]=-1/0,b[_]=1/0,b[_+3]=-1/0;Zd(y,i,b)}m.sort(YV);let v=s;for(let y=0;y<v;y++){let x=m[y];for(;y+1<v&&m[y+1].candidate===x.candidate;)m.splice(y+1,1),v--}for(let y=u;y<c;y+=6){let x=i[y+2*d];for(let b=0;b<v;b++){let w=m[b];x>=w.candidate?Zd(y,i,w.rightCacheBounds):(Zd(y,i,w.leftCacheBounds),w.count++)}}for(let y=0;y<v;y++){let x=m[y],b=x.count,w=s-x.count,A=x.leftCacheBounds,_=x.rightCacheBounds,S=0;b!==0&&(S=Gh(A)/l);let M=0;w!==0&&(M=Gh(_)/l);let C=1+1.25*(S*b+M*w);C<h&&(n=d,h=C,o=x.candidate)}}else{for(let v=0;v<Sa;v++){let y=Ka[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=u;v<c;v+=6){let y=~~((i[v+2*d]-p)/f);y>=Sa&&(y=Sa-1);let x=Ka[y];x.count++,Zd(v,i,x.bounds)}let m=Ka[Sa-1];_w(m.bounds,m.rightCacheBounds);for(let v=Sa-2;v>=0;v--){let y=Ka[v],x=Ka[v+1];Sw(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let g=0;for(let v=0;v<Sa-1;v++){let y=Ka[v],x=y.count,b=y.bounds,w=Ka[v+1].rightCacheBounds;x!==0&&(g===0?_w(b,Kd):Sw(b,Kd,Kd)),g+=x;let A=0,_=0;g!==0&&(A=Gh(Kd)/l);let S=s-g;S!==0&&(_=Gh(w)/l);let M=1+1.25*(A*g+_*S);M<h&&(n=d,h=M,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:o}}function QV(e,t,i,r){let s=0;for(let a=t,n=t+i;a<n;a++)s+=e[a*6+r*2];return s/i}function ZV(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,a=new Float32Array(s*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let u=["getX","getY","getZ"];for(let c=0;c<s;c++){let d=c*3,p=c*6,f,m,g;n?(f=r[d+0],m=r[d+1],g=r[d+2]):(f=r[d+0]*h+l,m=r[d+1]*h+l,g=r[d+2]*h+l);for(let v=0;v<3;v++){let y,x,b;n?(y=i[u[v]](f),x=i[u[v]](m),b=i[u[v]](g)):(y=o[f+v],x=o[m+v],b=o[g+v]);let w=y;x<w&&(w=x),b<w&&(w=b);let A=y;x>A&&(A=x),b>A&&(A=b);let _=(A-w)/2,S=v*2;a[p+S+0]=w+_,a[p+S+1]=_+(Math.abs(w)+_)*jV,w<t[v]&&(t[v]=w),A>t[v+3]&&(t[v+3]=A)}}return a}function KV(e,t){function i(v){d&&d(v/p)}function r(v,y,x,b=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))),x<=u||w>=l)return i(y+x),v.offset=y,v.count=x,v;let A=XV(v.boundingData,b,n,y,x,c);if(A.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let _=qV(o,n,y,x,A);if(_===y||_===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=A.axis;let S=new Qd,M=y,C=_-y;v.left=S,S.boundingData=new Float32Array(6),xm(n,M,C,S.boundingData,a),r(S,M,C,a,w+1);let T=new Qd,D=_,P=x-C;v.right=T,T.boundingData=new Float32Array(6),xm(n,D,P,T.boundingData,a),r(T,D,P,a,w+1)}return v}GV(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=ZV(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,m=[],g=HV(e);if(g.length===1){let v=g[0],y=new Qd;y.boundingData=s,WV(n,v.offset,v.count,a),r(y,v.offset,v.count,a),m.push(y)}else for(let v of g){let y=new Qd;y.boundingData=new Float32Array(6),xm(n,v.offset,v.count,y.boundingData,a),r(y,v.offset,v.count,a),m.push(y)}return m}function JV(e,t){let i=KV(e,t),r,s,a,n=[],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),a=new Uint16Array(p),h(0,c),n.push(p)}return n;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,m=c.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(f){let g=c.offset,v=c.count;return s[d+6]=g,a[p+14]=v,a[p+15]=65535,u+32}else{let g=c.left,v=c.right,y=c.splitAxis,x;if(x=h(u+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[d+6]=x/4,x=h(x,v),s[d+7]=y,x}}}var ra=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){let n=e[s][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){let n=t[s],o=e.dot(n);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}};ra.prototype.setFromBox=function(){let e=new E;return function(t,i){let r=i.min,s=i.max,a=1/0,n=-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);a=Math.min(u,a),n=Math.max(u,n)}this.min=a,this.max=n}}();var AQ=function(){let e=new ra;return function(t,i){let r=t.points,s=t.satAxes,a=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let u=a[h],c=s[h];if(e.setFromPoints(c,n),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}}}(),$V=function(){let e=new E,t=new E,i=new E;return function(r,s,a){let n=r.start,o=e,l=s.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.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,m,g;f!==0?m=(u*c-p*d)/f:m=0,g=(u+m*c)/d,a.x=m,a.y=g}}(),cy=function(){let e=new F,t=new E,i=new E;return function(r,s,a,n){$V(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,a),s.at(l,n);return}else if(o>=0&&o<=1){l<0?s.at(0,n):s.at(1,n),r.closestPointToPoint(n,!0,a);return}else if(l>=0&&l<=1){o<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,n);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)){a.copy(c),n.copy(u);return}else{a.copy(h),n.copy(d);return}}}}(),ej=function(){let e=new E,t=new E,i=new kr,r=new is;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c:u}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let c=a.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=n){let d=c.projectPoint(o,t);if(a.containsPoint(d))return!0}return!1}}(),tj=1e-15;function Zo(e){return Math.abs(e)<tj}var ja=class extends Hi{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new ra),this.points=[this.a,this.b,this.c],this.sphere=new Tr,this.plane=new kr,this.needsUpdate=!0}intersectsSphere(e){return ej(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,n=s[0],o=a[0];this.getNormal(n),o.setFromPoints(n,r);let l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,r);let u=s[2],c=a[2];u.subVectors(t,i),c.setFromPoints(u,r);let d=s[3],p=a[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};ja.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new is;return function(r,s=null,a=null){let{start:n,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]),cy(i,r,e,t),h=e.distanceToSquared(t),h<u&&(u=h,s&&s.copy(e),a&&a.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),a&&a.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),a&&a.copy(o)),Math.sqrt(u)}}();ja.prototype.intersectsTriangle=function(){let e=new ja,t=new Array(3),i=new Array(3),r=new ra,s=new ra,a=new E,n=new E,o=new E,l=new E,h=new is,u=new is,c=new is;return function(d,p=null,f=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let m=this.plane,g=d.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let w=0;w<4;w++){let A=v[w],_=y[w];if(r.setFromPoints(_,i),A.isSeparated(r))return!1}let x=d.satBounds,b=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let A=x[w],_=b[w];if(r.setFromPoints(_,t),A.isSeparated(r))return!1}for(let w=0;w<4;w++){let A=y[w];for(let _=0;_<4;_++){let S=b[_];if(a.crossVectors(A,S),r.setFromPoints(a,t),s.setFromPoints(a,i),r.isSeparated(s))return!1}}return p&&(f||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 v=this.points,y=!1,x=0;for(let P=0;P<3;P++){let I=v[P],R=v[(P+1)%3];h.start.copy(I),h.end.copy(R),h.delta(n);let U=y?u.start:u.end,N=Zo(g.distanceToPoint(I));if(Zo(g.normal.dot(n))&&N){u.copy(h),x=2;break}if((g.intersectLine(h,U)||N)&&!Zo(U.distanceTo(R))){if(x++,y)break;y=!0}}if(x===1&&d.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(x!==2)return!1;let b=d.points,w=!1,A=0;for(let P=0;P<3;P++){let I=b[P],R=b[(P+1)%3];h.start.copy(I),h.end.copy(R),h.delta(o);let U=w?c.start:c.end,N=Zo(m.distanceToPoint(I));if(Zo(m.normal.dot(o))&&N){c.copy(h),A=2;break}if((m.intersectLine(h,U)||N)&&!Zo(U.distanceTo(R))){if(A++,w)break;w=!0}}if(A===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(A!==2)return!1;if(u.delta(n),c.delta(o),n.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let _=u.start.dot(n),S=u.end.dot(n),M=c.start.dot(n),C=c.end.dot(n),T=S<M,D=_<C;return _!==C&&M!==S&&T===D?!1:(p&&(l.subVectors(u.start,c.start),l.dot(n)>0?p.start.copy(u.start):p.start.copy(c.start),l.subVectors(u.end,c.end),l.dot(n)<0?p.end.copy(u.end):p.end.copy(c.end)),!0)}}}();ja.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();ja.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new is,s=new is;return function(a,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(a,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let u=0;u<3;u++){let c,d=i[u],p=a[d];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,n&&n.copy(e),o&&o.copy(p));let f=this[d];a.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,n&&n.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],m=i[(p+1)%3];s.set(a[f],a[m]),cy(r,s,e,t);let g=e.distanceToSquared(t);g<h&&(h=g,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var sa=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new E,this.max=new E,this.matrix=new me,this.invMatrix=new me,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 ra),this.alignedSatBounds=new Array(3).fill().map(()=>new ra),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};sa.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,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],u=s[l],c=1<<l,d=r[c];h.subVectors(n,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}}();sa.prototype.intersectsBox=function(){let e=new ra;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,a=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=a[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();sa.prototype.intersectsTriangle=function(){let e=new ja,t=new Array(3),i=new ra,r=new ra,s=new E;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let n=this.satBounds,o=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let c=0;c<3;c++){let d=n[c],p=o[c];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=a.satBounds,h=a.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}}();sa.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}}();sa.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();sa.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new is),i=new Array(12).fill().map(()=>new is),r=new E,s=new E;return function(a,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(s),this.closestPointToPoint(s,r),a.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=n*n,u=a.min,c=a.max,d=this.points,p=1/0;for(let m=0;m<8;m++){let g=d[m];s.copy(g).clamp(u,c);let v=g.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(g),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let m=0;m<3;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){let y=(m+1)%3,x=(m+2)%3,b=g<<y|v<<x,w=1<<m|g<<y|v<<x,A=d[b],_=d[w];t[f].set(A,_);let S=e[m],M=e[y],C=e[x],T=i[f],D=T.start,P=T.end;D[S]=u[S],D[M]=g?u[M]:c[M],D[C]=v?u[C]:c[M],P[S]=c[S],P[M]=g?u[M]:c[M],P[C]=v?u[C]:c[M],f++}for(let m=0;m<=1;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){s.x=m?c.x:u.x,s.y=g?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 m=0;m<12;m++){let g=t[m];for(let v=0;v<12;v++){let y=i[v];cy(g,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var Ko=new E,Jo=new E,$o=new E,Jd=new F,$d=new F,eu=new F,Aw=new E,Mw=new E,Ew=new E,tu=new E;function ij(e,t,i,r,s,a){let n;return a===Pi?n=e.intersectTriangle(r,i,t,!0,s):n=e.intersectTriangle(t,i,r,a!==Sr,s),n===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function rj(e,t,i,r,s,a,n,o,l){Ko.fromBufferAttribute(t,a),Jo.fromBufferAttribute(t,n),$o.fromBufferAttribute(t,o);let h=ij(e,Ko,Jo,$o,tu,l);if(h){r&&(Jd.fromBufferAttribute(r,a),$d.fromBufferAttribute(r,n),eu.fromBufferAttribute(r,o),h.uv=Hi.getInterpolation(tu,Ko,Jo,$o,Jd,$d,eu,new F)),s&&(Jd.fromBufferAttribute(s,a),$d.fromBufferAttribute(s,n),eu.fromBufferAttribute(s,o),h.uv1=Hi.getInterpolation(tu,Ko,Jo,$o,Jd,$d,eu,new F)),i&&(Aw.fromBufferAttribute(i,a),Mw.fromBufferAttribute(i,n),Ew.fromBufferAttribute(i,o),h.normal=Hi.getInterpolation(tu,Ko,Jo,$o,Aw,Mw,Ew,new E),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:n,c:o,normal:new E,materialIndex:0};Hi.getNormal(Ko,Jo,$o,u.normal),h.face=u,h.faceIndex=a}return h}function pM(e,t,i,r,s){let a=r*3,n=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),{position:h,normal:u,uv:c,uv1:d}=e.attributes,p=rj(i,h,u,c,d,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function sj(e,t,i,r,s,a){for(let n=r,o=r+s;n<o;n++)pM(e,t,i,n,a)}function aj(e,t,i,r,s){let a=1/0,n=null;for(let o=r,l=r+s;o<l;o++){let h=pM(e,t,i,o);h&&h.distance<a&&(n=h,a=h.distance)}return n}function Ws(e,t,i,r){let s=e.a,a=e.b,n=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),a.x=r.getX(l),a.y=r.getY(l),a.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function Cw(e,t,i,r,s,a,n){let o=i.index,l=i.attributes.position;for(let h=e,u=t+e;h<u;h++)if(Ws(n,h*3,o,l),n.needsUpdate=!0,r(n,h,s,a))return!0;return!1}var fM=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 un(e,t){return t[e+15]===65535}function zl(e,t){return t[e+6]}function Vc(e,t){return t[e+14]}function jc(e){return e+8}function Gc(e,t){return t[e+6]}function nj(e,t){return t[e+7]}var Cl=new ai,Tp=new E,oj=["x","y","z"];function Pv(e,t,i,r,s){let a=e*2,n=Sh,o=Mn,l=En;if(un(a,o)){let h=zl(e,l),u=Vc(a,o);sj(t,i,r,h,u,s)}else{let h=jc(e);Dp(h,n,r,Tp)&&Pv(h,t,i,r,s);let u=Gc(e,l);Dp(u,n,r,Tp)&&Pv(u,t,i,r,s)}}function Iv(e,t,i,r){let s=e*2,a=Sh,n=Mn,o=En;if(un(s,n)){let l=zl(e,o),h=Vc(s,n);return aj(t,i,r,l,h)}else{let l=nj(e,o),h=oj[l],u=r.direction[h]>=0,c,d;u?(c=jc(e),d=Gc(e,o)):(c=Gc(e,o),d=jc(e));let p=Dp(c,a,r,Tp)?Iv(c,t,i,r):null;if(p){let m=p.point[h];if(u?m<=a[d+l]:m>=a[d+l+3])return p}let f=Dp(d,a,r,Tp)?Iv(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var lj=function(){let e,t,i=[],r=new fM(()=>new ai);return function(...a){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=s(...a);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]),n};function s(a,n,o,l,h=null,u=0,c=0){function d(y){let x=y*2,b=Mn,w=En;for(;!un(x,b);)y=jc(y),x=y*2;return zl(y,w)}function p(y){let x=y*2,b=Mn,w=En;for(;!un(x,b);)y=Gc(y,w),x=y*2;return zl(y,w)+Vc(x,b)}let f=a*2,m=Sh,g=Mn,v=En;if(un(f,g)){let y=zl(a,v),x=Vc(f,g);return Qs(a,m,e),l(y,x,!1,c,u+a,e)}else{let y=jc(a),x=Gc(a,v),b=y,w=x,A,_,S,M;if(h&&(S=e,M=t,Qs(b,m,S),Qs(w,m,M),A=h(S),_=h(M),_<A)){b=x,w=y;let U=A;A=_,_=U,S=M}S||(S=e,Qs(b,m,S));let C=un(b*2,g),T=o(S,C,A,c+1,u+b),D;if(T===2){let U=d(b),N=p(b)-U;D=l(U,N,!0,c+1,u+b,S)}else D=T&&s(b,n,o,l,h,u,c+1);if(D)return!0;M=t,Qs(w,m,M);let P=un(w*2,g),I=o(M,P,_,c+1,u+w),R;if(I===2){let U=d(w),N=p(w)-U;R=l(U,N,!0,c+1,u+w,M)}else R=I&&s(w,n,o,l,h,u,c+1);return!!R}}}(),hj=function(){let e=new ja,t=new ja,i=new me,r=new sa,s=new sa;return function a(n,o,l,h,u=null){let c=n*2,d=Sh,p=Mn,f=En;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),u=r),un(c,p)){let m=o,g=m.index,v=m.attributes.position,y=l.index,x=l.attributes.position,b=zl(n,f),w=Vc(c,p);if(i.copy(h).invert(),l.boundsTree)return Qs(n,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 _=b*3,S=(w+b)*3;_<S;_+=3)if(Ws(t,_,g,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=b*3,_=w+b*3;A<_;A+=3){Ws(e,A,g,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let S=0,M=y.count;S<M;S+=3)if(Ws(t,S,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,g=f[n+6];return Qs(m,d,Cl),!!(u.intersectsBox(Cl)&&a(m,o,l,h,u)||(Qs(g,d,Cl),u.intersectsBox(Cl)&&a(g,o,l,h,u)))}}}();function Dp(e,t,i,r){return Qs(e,t,Cl),i.intersectBox(Cl,r)}var Ov=[],Nu,Sh,Mn,En;function cc(e){Nu&&Ov.push(Nu),Nu=e,Sh=new Float32Array(e),Mn=new Uint16Array(e),En=new Uint32Array(e)}function iu(){Nu=null,Sh=null,Mn=null,En=null,Ov.length&&cc(Ov.pop())}var bm=Symbol("skip tree generation"),wm=new ai,_m=new ai,el=new me,Hn=new sa,Hh=new sa,Wh=new E,ru=new E,cj=new E,dj=new E,uj=new E,Tw=new ai,Os=new fM(()=>new ja),Sc=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."),Sc.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(),a;return t.cloneBuffers?a={roots:r.map(n=>n.slice()),index:s.array.slice()}:a={roots:r,index:s.array},a}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."),Sc.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,a=new Sc(t,{...i,[bm]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new Ze(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return a}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,[bm]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[bm]||(this._roots=JV(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new ai))),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,a,n,o,l=0,h=this._roots;for(let c=0,d=h.length;c<d;c++)s=h[c],a=new Uint32Array(s),n=new Uint16Array(s),o=new Float32Array(s),u(0,l),l+=s.byteLength;function u(c,d,p=!1){let f=c*2;if(n[f+15]===65535){let m=a[c+6],g=n[f+14],v=1/0,y=1/0,x=1/0,b=-1/0,w=-1/0,A=-1/0;for(let _=3*m,S=3*(m+g);_<S;_++){let M=i[_],C=r.getX(M),T=r.getY(M),D=r.getZ(M);C<v&&(v=C),C>b&&(b=C),T<y&&(y=T),T>w&&(w=T),D<x&&(x=D),D>A&&(A=D)}return o[c+0]!==v||o[c+1]!==y||o[c+2]!==x||o[c+3]!==b||o[c+4]!==w||o[c+5]!==A?(o[c+0]=v,o[c+1]=y,o[c+2]=x,o[c+3]=b,o[c+4]=w,o[c+5]=A,!0):!1}else{let m=c+8,g=a[c+6],v=m+d,y=g+d,x=p,b=!1,w=!1;e?x||(b=e.has(v),w=e.has(y),x=!b&&!w):(b=!0,w=!0);let A=x||b,_=x||w,S=!1;A&&(S=u(m,d,x));let M=!1;_&&(M=u(g,d,x));let C=S||M;if(C)for(let T=0;T<3;T++){let D=m+T,P=g+T,I=o[D],R=o[D+3],U=o[P],N=o[P+3];o[c+T]=I<U?I:U,o[c+T+3]=R>N?R:N}return C}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(n,o=0){let l=n*2,h=s[l+15]===65535;if(h){let u=r[n+6],c=s[l+14];e(o,h,new Float32Array(i,n*4,6),u,c)}else{let u=n+8,c=r[n+6],d=r[n+7];e(o,h,new Float32Array(i,n*4,6),d)||(a(u,o+1),a(c,o+1))}}}raycast(e,t=Ms){let i=this._roots,r=this.geometry,s=[],a=t.isMaterial,n=Array.isArray(t),o=r.groups,l=a?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=n?t[o[h].materialIndex].side:l,d=s.length;if(cc(i[h]),Pv(0,r,c,e,s),iu(),n){let p=o[h].materialIndex;for(let f=d,m=s.length;f<m;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=Ms){let i=this._roots,r=this.geometry,s=t.isMaterial,a=Array.isArray(t),n=null,o=r.groups,l=s?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=a?t[o[h].materialIndex].side:l;cc(i[h]);let d=Iv(0,r,c,e);iu(),d!=null&&(n==null||d.distance<n.distance)&&(n=d,a&&(d.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(cc(s),r=hj(0,i,e,t),iu(),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,m)=>{let g=p*3;return c(d,g,g+1,g+2,f,m)}}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=Os.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(d,p,f,m,g)=>c(d,p,f,m,g)?!0:Cw(d,p,r,l,f,m,s)}else o||(l?o=(c,d,p,f)=>Cw(c,d,r,l,p,f,s):o=(c,d,p)=>p);let h=!1,u=0;for(let c of this._roots){if(cc(c),h=lj(0,r,n,o,a,u),iu(),h)break;u+=c.byteLength}return Os.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,a=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;el.copy(t).invert();let h=Os.getPrimitive(),u=Os.getPrimitive();if(s){let d=function(p,f,m,g,v,y,x,b){for(let w=m,A=m+g;w<A;w++){Ws(u,w*3,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let _=p,S=p+f;_<S;_++)if(Ws(h,_*3,a,n),h.needsUpdate=!0,s(h,u,_,w,v,y,x,b))return!0}return!1};if(r){let p=r;r=function(f,m,g,v,y,x,b,w){return p(f,m,g,v,y,x,b,w)?!0:d(f,m,g,v,y,x,b,w)}}else r=d}e.getBoundingBox(_m),_m.applyMatrix4(t);let c=this.shapecast({intersectsBounds:d=>_m.intersectsBox(d),intersectsRange:(d,p,f,m,g,v)=>(wm.copy(v),wm.applyMatrix4(el),e.shapecast({intersectsBounds:y=>wm.intersectsBox(y),intersectsRange:(y,x,b,w,A)=>r(d,p,y,x,m,g,w,A)}))});return Os.releasePrimitive(h),Os.releasePrimitive(u),c}intersectsBox(e,t){return Hn.set(e.min,e.max,t),Hn.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Hn.intersectsBox(i),intersectsTriangle:i=>Hn.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Hn.set(e.boundingBox.min,e.boundingBox.max,t),Hn.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,u=e.index,c=Os.getPrimitive(),d=Os.getPrimitive(),p=ru,f=cj,m=null,g=null;r&&(m=dj,g=uj);let v=1/0,y=null,x=null;return el.copy(t).invert(),Hh.matrix.copy(el),this.shapecast({boundsTraverseOrder:b=>Hn.distanceToBox(b),intersectsBounds:(b,w,A)=>A<v&&A<a?(w&&(Hh.min.copy(b.min),Hh.max.copy(b.max),Hh.needsUpdate=!0),!0):!1,intersectsRange:(b,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>Hh.distanceToBox(A),intersectsBounds:(A,_,S)=>S<v&&S<a,intersectsRange:(A,_)=>{for(let S=A*3,M=(A+_)*3;S<M;S+=3){Ws(d,S,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let C=b*3,T=(b+w)*3;C<T;C+=3){Ws(c,C,l,o),c.needsUpdate=!0;let D=c.distanceToTriangle(d,p,m);if(D<v&&(f.copy(p),g&&g.copy(m),v=D,y=C/3,x=S/3),D<s)return!0}}}});{let A=u?u.count:h.count;for(let _=0,S=A;_<S;_+=3){Ws(d,_,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let M=b*3,C=(b+w)*3;M<C;M+=3){Ws(c,M,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(d,p,m);if(T<v&&(f.copy(p),g&&g.copy(m),v=T,y=M/3,x=_/3),T<s)return!0}}}}}),Os.releasePrimitive(c),Os.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(g):r.point=g.clone(),r.point.applyMatrix4(el),f.applyMatrix4(el),r.distance=f.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,a=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Wh.copy(e).clamp(h.min,h.max),Wh.distanceToSquared(e)),intersectsBounds:(h,u,c)=>c<n&&c<a,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,Wh);let c=e.distanceToSquared(Wh);return c<n&&(ru.copy(Wh),n=c,o=u),c<s}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(ru):t.point=ru.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Qs(0,new Float32Array(t),Tw),e.union(Tw)}),e}},qh=Ri(gT()),pj=.5*(Math.sqrt(3)-1),Yh=(3-Math.sqrt(3))/6,fj=1/3,Rs=1/6,MQ=(Math.sqrt(5)-1)/4,EQ=(5-Math.sqrt(5))/20,Ac=e=>Math.floor(e)|0,Dw=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]),Sm=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 Am(e=Math.random){let t=mM(e),i=new Float64Array(t).map(s=>Dw[s%12*2]),r=new Float64Array(t).map(s=>Dw[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*pj,u=Ac(s+h),c=Ac(a+h),d=(u+c)*Yh,p=u-d,f=c-d,m=s-p,g=a-f,v,y;m>g?(v=1,y=0):(v=0,y=1);let x=m-v+Yh,b=g-y+Yh,w=m-1+2*Yh,A=g-1+2*Yh,_=u&255,S=c&255,M=.5-m*m-g*g;if(M>=0){let D=_+t[S],P=i[D],I=r[D];M*=M,n=M*M*(P*m+I*g)}let C=.5-x*x-b*b;if(C>=0){let D=_+v+t[S+y],P=i[D],I=r[D];C*=C,o=C*C*(P*x+I*b)}let T=.5-w*w-A*A;if(T>=0){let D=_+1+t[S+1],P=i[D],I=r[D];T*=T,l=T*T*(P*w+I*A)}return 70*(n+o+l)}}function mj(e=Math.random){let t=mM(e),i=new Float64Array(t).map(a=>Sm[a%12*3]),r=new Float64Array(t).map(a=>Sm[a%12*3+1]),s=new Float64Array(t).map(a=>Sm[a%12*3+2]);return function(a,n,o){let l,h,u,c,d=(a+n+o)*fj,p=Ac(a+d),f=Ac(n+d),m=Ac(o+d),g=(p+f+m)*Rs,v=p-g,y=f-g,x=m-g,b=a-v,w=n-y,A=o-x,_,S,M,C,T,D;b>=w?w>=A?(_=1,S=0,M=0,C=1,T=1,D=0):b>=A?(_=1,S=0,M=0,C=1,T=0,D=1):(_=0,S=0,M=1,C=1,T=0,D=1):w<A?(_=0,S=0,M=1,C=0,T=1,D=1):b<A?(_=0,S=1,M=0,C=0,T=1,D=1):(_=0,S=1,M=0,C=1,T=1,D=0);let P=b-_+Rs,I=w-S+Rs,R=A-M+Rs,U=b-C+2*Rs,N=w-T+2*Rs,L=A-D+2*Rs,W=b-1+3*Rs,G=w-1+3*Rs,j=A-1+3*Rs,k=p&255,q=f&255,H=m&255,Y=.6-b*b-w*w-A*A;if(Y<0)l=0;else{let re=k+t[q+t[H]];Y*=Y,l=Y*Y*(i[re]*b+r[re]*w+s[re]*A)}let V=.6-P*P-I*I-R*R;if(V<0)h=0;else{let re=k+_+t[q+S+t[H+M]];V*=V,h=V*V*(i[re]*P+r[re]*I+s[re]*R)}let ie=.6-U*U-N*N-L*L;if(ie<0)u=0;else{let re=k+C+t[q+T+t[H+D]];ie*=ie,u=ie*ie*(i[re]*U+r[re]*N+s[re]*L)}let Q=.6-W*W-G*G-j*j;if(Q<0)c=0;else{let re=k+1+t[q+1+t[H+1]];Q*=Q,c=Q*Q*(i[re]*W+r[re]*G+s[re]*j)}return 32*(l+h+u+c)}}function mM(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 cs=new Hi,gj=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;cs.a.fromBufferAttribute(e,r),cs.b.fromBufferAttribute(e,r+1),cs.c.fromBufferAttribute(e,r+2),s*=cs.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 a=Math.ceil((i+r)/2);if(a===0||t[a-1]<=e&&t[a]>e){s=a;break}else e<t[a]?r=a-1:i=a+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),cs.a.fromBufferAttribute(this.positionAttribute,e*3),cs.b.fromBufferAttribute(this.positionAttribute,e*3+1),cs.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(cs.a,r).addScaledVector(cs.b,s).addScaledVector(cs.c,1-(r+s)),cs.getNormal(i),this}},vj=Ri(ZS()),yj=new me,xj=new me,bj=new me,Hc;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(Hc||(Hc={}));var dy=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new me,this.copyPreviousMatrix=!0,this.hiddenMatrix=new me,this.matrixWorldRigid=new me,this.shearScale=new me,this.shearScaleInv=new me}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Pt&&(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)}traverseChildren(t,i=0){for(let r of this.children)Hc.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Hc.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:a}=(0,vj.SVD)(i),n=yj.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=xj.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=bj.copy(o).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new me().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof me?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}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,a,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},wj=class extends dy(Pt){},_j=e=>e.type==="Mesh",qi=class extends wj{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}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 qi(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.playModeVisible!==void 0?this.playModeVisible: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 _j(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}},eo=new E,to=new E,kl=new me,gM=[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)],Sj=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Aj=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Pw=(e,t,i)=>{e.updateEntityBoxSize(eo,to),kl.copy(t).multiply(e.matrixWorld),to.x===0&&to.y===0&&to.z===0?i.push(new E(eo.x,eo.y,eo.z).applyMatrix4(kl)):gM.forEach(r=>{i.push(r.clone().multiply(to).add(eo).applyMatrix4(kl))})},Iw=class extends ai{constructor(){super(...arguments),this.matrix=new me,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 me().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new E);return}Pw(s,t,r)}}):Pw(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(kl.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(to).multiplyScalar(.5),this.getCenter(eo),kl.copy(this.matrix).setPosition(eo),this.vertices=gM.map(e=>e.clone().multiply(to).applyMatrix4(kl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Sj.map(([e,t])=>new is(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=Aj.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},yn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},Mj=class extends MA{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let a=0,n=this.curves;a<n.length;a++){let o=n[a],l=a===0?r[a]:r[a]-r[a-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}},Rv=.001;function Lv(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Rv}function Mm(e,t){let i=new E(...e.position),r=new E(...e.controlNext.position),s=new E(...t.controlPrevious.position),a=new E(...t.position);return Lv(i,r,a)&&Lv(i,s,a)}function vM(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++)Lv(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,a=i.length-(s?0:1),n=i.length,o=[];for(let u=0;u<n;u++){let c=i[u].data,d=new E(...c.position),p=new E(...c.controlPrevious.position),f=new E(...c.controlNext.position),m={position:d,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(u===0||u===n-1)){o[u]={...m,removedLength:0};continue}let g=s&&u==0?n-1:u-1,v=s&&u==n-1?0:u+1,y=i[g].data,x=i[v].data,b=new E(...y.position),w=new E(...x.position),A=b.clone().sub(d).normalize(),_=w.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:_});let S=Mm(y,c),M=Mm(c,x);if(!S||!M)o[u]={...m,removedLength:0};else{let C=A.clone().add(_).normalize(),T=C.clone().cross(A).length()/A.dot(C);o[u]={...m,tan:T,removedLength:c.roundness/T}}}for(let u=0;u<a;u++){let c=u,d=s&&u===n-1?0:u+1,p=o[c],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let u=0;u<a;u++){let c=u,d=s&&u===n-1?0:u+1,p=o[c],f=o[d],m=null;if(!Mm(i[c].data,i[d].data))p.position.distanceTo(f.position)>Rv&&(m=new Ru(p.position,p.controlNext,f.controlPrevious,f.position));else{let g=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&g.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),g.distanceTo(v)>Rv&&(m=new Ru(g,g.clone().lerp(v,.3),v.clone().lerp(g,.3),v))}l[2*u+1]=m}for(let u=0;u<n;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),m=c.tan*c.removedLength,g=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(y,2))).add(v),b=g.clone().multiplyScalar(-m).add(x),w=d.distanceTo(b)/d.distanceTo(v),A=c.prevDir.clone().multiplyScalar(w*d.distanceTo(p)).add(d),_=A.clone().lerp(b,2),S=p.clone().lerp(A,4/3),M=f.clone().lerp(_,4/3);l[2*u]=new Ru(p,S,M,f)}let h=new Mj;return l.forEach(u=>{u&&h.add(u)}),h}var pt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(pt||(pt={}));var Da=e=>pt.is(e),Ej={type:"completeState",isfromEntity:!0},Cj=["x","y","z"],Em=new E,Tj=new E().set(0,1,0),uy=e=>class extends dy(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new Iw,this._recursiveBBox=new Iw,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(pt.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(pt.is(this.children[t]))return t+1;return 0}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(pt.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)so.toOps(this.data,s.data).forEach(a=>{let n=Qg.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=so.patch(this.data,s),so.toOps(this.data,s).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),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=>{Da(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(pt.is(i[r]))return i[r];if(pt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&pt.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)Da(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{pt.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Da(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Da(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)Da(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>Da(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*Le.RAD2DEG,this.rotation.y*Le.RAD2DEG,this.rotation.z*Le.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Xg(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>r?.shared.getVariable(s,[this.uuid,t,Cj[a]])??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(Em.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(Le.DEG2RAD),this.rotation.setFromVector3(Em),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??$l.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)pt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{pt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Xg(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let a=this.data;this.data=i;let n=t,o=es(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let c=ar.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])}}n={...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=ar.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,so.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),es(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(Sn.apply(c.component.data,c.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let c=ar.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=_p.resolve(i.overrides,l),u.updateByOp(t,Wi.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 vn.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of vn.rootOverrideProps)if(es(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=Sn.filterOp(h.overrideData,l);u&&h.updateByOp(u,Wi.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=Sn.filterOp(h.overrideData,t);if(u){let c;a===h.data&&t===u?c=i:c=Wi.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&&!So.is(t.props.type)&&yn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){yn.changeEntityProptotype(this,i,r);for(let s of this.children)pt.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),es(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),es(t.path,["cloner"])!==null){let s=Wi.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(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){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??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=vM(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let u=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new me;n.updateMatrixWorld();let d=new me().multiplyMatrices(c.clone().invert(),n.matrixWorld);u.applyMatrix4(d);let p={position:u.toArray(),rotation:o.rotation};if(a==="tangential"){let f=new me().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(u),g=new me().lookAt(u,m,Tj),v=Em.setFromEuler(new Di().setFromRotationMatrix(g)).multiplyScalar(Le.RAD2DEG);p={...p,rotation:v.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(Ej)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}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(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof yn.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 yn.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)}},yM=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);i.thetaLength=Le.clamp(i.thetaLength,0,360);let r=i.width/2,s=i.radiusTop??r,a=i.radiusBottom??r;return s===a?(s=r,a=r):s>a?(s=r,a=a*r/s):(s=s*r/a,a=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:a})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:u,cornerRadius:c,cornerSegments:d,hollow:p}=e.parameters,f;return l===0?(f=new Ue,f.setAttribute("position",new Te([],3))):c||p?f=new xM(h,u,r,s,a,n,o,l*Math.PI/180,c,c,d,p):f=new D0(h,u,r,s,a,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function Ja(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Ow(e){return new F(e.y,-e.x)}var xM=class extends Ue{constructor(e,t,i,r,s,a,n,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,a=a!==void 0?a:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,a&&(l=0,h=0);let p=[],f=[],m=[],g=[],v=0,y=i/2,x=new E,b=new E;d&&e==0&&(e=l),d&&t==0&&(t=h);let w=new F(e,y),A=new F(t,-y),_=null,S=null,M=null,C=null,T=w.clone().sub(A),D=0,P=0,I=0;c>0&&(D=Math.min(e,t)*(1-c),P=e-D,I=t-D);let R=w.clone();R.x-=D;let U=Math.PI-T.angle(),N=T.angle(),L=Math.tan(N/2),W=Math.tan(U/2),G=L+W,j=c?G:W,k=c?G:L;if(l=Math.min(l,(e-P)/j,T.length()/G),h=Math.min(h,(t-I)/k,T.length()/G),l>0){let Q=l/L;_=w.clone().sub(new F(Q,l)),c&&(M=_.clone(),M.x-=D-G*l),w.sub(T.clone().setLength(Q))}if(h>0){let Q=h/W;S=A.clone().sub(new F(Q,-h)),A.add(T.clone().setLength(Q)),c&&(C=S.clone(),C.x-=D-G*h,R.sub(T.clone().setLength(Q)))}T=w.clone().sub(A);let q=T.length()<.5,H=[];for(let Q=0;Q<=r;Q++){let re=[],Z=Q/r,pe=Z*o+n,oe=new F(Math.sin(pe),Math.cos(pe));C&&S?(Y(re,Z,oe,U,h,C,-1,!0),Y(re,Z,oe,N,h,S,-1,!1)):S?(V(re,oe,S.x,0,-1),Y(re,Z,oe,N,h,S,-1,!1)):a||V(re,oe,t,I,-1);let ae=Ow(T).normalize();if(Ja(ae,oe,x),!q)for(let Me=0;Me<=s;Me++){let Ae=Me/s,Ee=T.clone().multiplyScalar(Ae).add(A);Ja(Ee,oe,b),f.push(b.x,b.y,b.z),m.push(x.x,x.y,x.z),g.push(Z,.5+b.y/i),re.push(v++)}if(M&&_?(Y(re,Z,oe,U,l,_,1,!1),Y(re,Z,oe,N,l,M,1,!0)):_?(Y(re,Z,oe,U,l,_,1,!1),V(re,oe,_.x,0,1)):a||V(re,oe,e,P,1),c&&!q){let Me=Ow(T).multiplyScalar(-1).normalize();Ja(Me,oe,x);for(let Ae=0;Ae<=s;Ae++){let Ee=Ae/s,Ie=T.clone().multiplyScalar(-Ee).add(R);Ja(Ie,oe,b),f.push(b.x,b.y,b.z),m.push(x.x,x.y,x.z),g.push(Z,.5+b.y/i),re.push(v++)}}c&&!a&&re.push(re[0]),H.push(re)}for(let Q=0;Q<H.length-1;Q++)for(let re=0;re<H[0].length-1;re++){if(a&&c&&re==s)continue;let Z=H[Q][re],pe=H[Q+1][re],oe=H[Q+1][re+1],ae=H[Q][re+1],Me=f[oe*3+0],Ae=f[oe*3+2];p.push(Z,pe,ae),(Me!=0||Ae!=0)&&p.push(pe,oe,ae)}o<Math.PI*2&&(ie(-1,H[0],n),ie(1,H[H.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new Te(f,3)),this.setAttribute("normal",new Te(m,3)),this.setAttribute("uv",new Te(g,2));function Y(Q,re,Z,pe,oe,ae,Me,Ae){for(let Ee=0;Ee<u+1;Ee++){let Ie=Ee/u,be=Me<0?Ie:1-Ie;Ae&&(be-=1),be*=pe;let ye=new F(Math.sin(be),Math.cos(be)*Me),ke=ye.clone().multiplyScalar(oe).add(ae);Ja(ke,Z,b),f.push(b.x,b.y,b.z),Ja(ye,Z,x),m.push(x.x,x.y,x.z),g.push(re,.5+b.y/i),Q.push(v++)}}function V(Q,re,Z,pe,oe){let ae=new E,Me=new F,Ae=[Z,pe];oe<0&&Ae.reverse();for(let Ee of Ae)Me.set(Ee,y*oe),Ja(Me,re,ae),f.push(ae.x,ae.y,ae.z),m.push(0,oe,0),g.push(.5,.5),Q.push(v++)}function ie(Q,re,Z){let pe=new F(Math.sin(Z),Math.cos(Z)),oe=new F(-Math.cos(Z),Math.sin(Z)),ae=new E,Me=Q<0?(Ie,be,ye)=>p.push(Ie,be,ye):(Ie,be,ye)=>p.push(Ie,ye,be),Ae=new F((e+t+P+I)/4,0);Ja(Ae,pe,ae),f.push(ae.x,ae.y,ae.z),m.push(oe.x,0,oe.y),g.push(.5,.5);let Ee=v++;for(let Ie of re){let be=f.slice(Ie*3,Ie*3+3);f.push(...be),m.push(oe.x,0,oe.y);let ye=g.slice(Ie*2,Ie*2+2);g.push(...ye),v++}for(let Ie=Ee+1;Ie<v-1;Ie++)Me(Ee,Ie,Ie+1);Me(Ee,v-1,Ee+1)}}},Dj=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 i.thetaLength=Le.clamp(i.thetaLength,0,360),{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:a,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:u,cornerSegments:c}=e.parameters,d;return l===0?(d=new Ue,d.setAttribute("position",new Te([],3))):h>0||u>0||l<360?d=new xM(0,t/2,r,s,a,n,o,l*Math.PI/180,h,u,c,0,!0):d=new CA(t/2,r,s,a,n),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},Pj=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:a,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new ta(t,i,r,s,a,n):h=new Ij(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Cm=Math.PI/2,Ij=class extends Ue{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let h=[],u=[],c=[],d=[],p=0,f=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),n>0&&(g("z","y","x",-1,-1,1,i,t,e,a,0),g("z","y","x",1,-1,-1,i,t,e,a,1),g("z","y","x",-1,1,-1,i,t,e,a,1),g("z","y","x",1,1,1,i,t,e,a,0),g("x","y","z",-1,-1,-1,e,t,i,r,0),g("x","y","z",1,-1,1,e,t,i,r,1),g("x","y","z",-1,1,1,e,t,i,r,0),g("x","y","z",1,1,-1,e,t,i,r,1),g("y","x","z",-1,-1,1,t,e,i,s,0),g("y","x","z",1,-1,-1,t,e,i,s,1),g("y","x","z",1,1,1,t,e,i,s,1),g("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 Te(u,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(d,2));function m(y,x,b,w,A,_,S,M,C,T,D){let P=(_-2*n)/C,I=(S-2*n)/T,R=_/2-n,U=S/2-n,N=M/2,L=C+1,W=T+1,G=0,j=0,k=new E;for(let q=0;q<W;q++){let H=q*I-U;for(let Y=0;Y<L;Y++){let V=Y*P-R;k[y]=V*w,k[x]=H*A,k[b]=N,u.push(k.x,k.y,k.z),k[y]=0,k[x]=0,k[b]=M>0?1:-1,c.push(k.x,k.y,k.z),d.push(Y/C),d.push(1-q/T),G+=1}}for(let q=0;q<T;q++)for(let H=0;H<C;H++){let Y=p+H+L*q,V=p+H+L*(q+1),ie=p+(H+1)+L*(q+1),Q=p+(H+1)+L*q;h.push(Y,V,Q),h.push(V,ie,Q),j+=6}l.addGroup(f,j,D),f+=j,p+=G}function g(y,x,b,w,A,_,S,M,C,T,D){let P=(S-2*n)/T,I=S/2-n,R=M/2-n,U=C/2,N=T+1,L=0,W=0,G=new E,j=new E;for(let k=0;k<o+1;k++){let q=k/o*Cm,H=Math.sin(q)*n,Y=(1-Math.cos(q))*n,V=Math.sin(q),ie=Math.cos(q);G[x]=(R+H)*A,G[b]=(U-Y)*_,j[y]=0,j[x]=V*Math.sign(G[x]),j[b]=ie*Math.sign(G[b]);for(let Q=0;Q<N;Q++){let re=Q*P-I;G[y]=re*w,u.push(G.x,G.y,G.z),c.push(j.x,j.y,j.z),d.push(Q/T),d.push(0),L+=1}}for(let k=0;k<o;k++)for(let q=0;q<T;q++){let H=p+q+N*k,Y=p+q+N*(k+1),V=p+(q+1)+N*(k+1),ie=p+(q+1)+N*k;h.push(H,Y,ie),h.push(Y,V,ie),W+=6}l.addGroup(f,W,D),f+=W,p+=L}function v(y,x,b){let w=new E,A=new E(e/2,t/2,i/2);A.subScalar(n);let _=[],S=y*x*b>0?(C,T,D)=>h.push(C,T,D):(C,T,D)=>h.push(C,D,T);for(let C=0;C<=o;C++){let T=[],D=Cm*(1-C/o),P=Math.cos(D),I=Math.sin(D),R=0;for(let U=0;U<=C;U++){let N=Math.cos(R),L=Math.sin(R);w.x=P*N,w.y=I,w.z=P*L;let W=A.clone().addScaledVector(w,n);u.push(y*W.x,x*W.y,b*W.z),c.push(y*w.x,x*w.y,b*w.z),d.push(0,0),T.push(p++),R+=Cm/C}_.push(T)}let M=_.length-1;for(let C=0;C<M;C++){let T=_[C],D=_[C+1],P=T.length-1;S(T[0],D[1],D[0]);for(let I=1;I<=P;I++)S(T[I-1],T[I],D[I]),S(T[I],D[I+1],D[I])}}}},py=class extends Ue{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),u(),this.setAttribute("position",new Te(n,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(a=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new E,p=d.clone(),f=new Hi,m=s*r,g=r-m,v=a+1,y=new E,x=(N,L)=>y.subVectors(N,L).normalize(),b=(N,L)=>Array(N).fill(void 0).map(L),w=b(e.length/3,(N,L)=>new E().fromArray(e,L*3).setLength(r)),A=[],_=1e6;for(let N=0;N<w.length;N++){let L=w[N],W=[],G,j,k,q=1e10,H=-1;for(;(H=t.indexOf(N,H+1))!=-1;){let Q=H-H%3;G=t[Q+(H+1)%3],j=t[Q+(H+2)%3],k=L.distanceToSquared(w[G]),q=Math.min(q,k),W.push([G,j,k])}q+=1e-6;let Y=[],V=0,ie=W.length;for(let Q=0;Q<ie;Q++){[G,j,k]=W[V];let re=A[G]?.includes(N)==!0;k<=q&&Y.push(G+ +re*_),V=W.findIndex(Z=>Z[0]==j)}A.push(Y)}let S=[];{let N=0,L=0,W,G,j=c==3;for(let k=0;k<=a;k++){W=k*(k+1)/2,G=(k+1)*(k+2)/2;for(let q=0;q<a-k;q++)[N,L]=[W+q+k+2,G+q+k+3],S.push(W,G,...j?[L,W]:[N,G],L,N),[W,G]=[N,L];S.push(W,G,W+a+2)}}let M=d.clone(),C=d.clone(),T=d.clone(),D=d.clone(),P=d.clone(),I=[],R=b(w.length,()=>b(c,()=>d.clone()));for(let N=0;N<w.length;N++){d.copy(w[N]).normalize(),M.copy(d).multiplyScalar(g);let L=A[N];for(let Y=0;Y<L.length;Y++){let V=L[Y],ie=L[(Y+1)%c];f.setFromPointsAndIndices(w,N,V%_,ie%_),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,R[N][Y])}let W=[],G=[],j=[],k=new E;a==0&&[...R[N]].reduce((Y,V)=>Y.add(V),k).multiplyScalar(1/c);for(let Y=0;Y<c;Y++){let V=[],ie=(Y-1+c)%c,Q=R[N][ie],re=R[N][Y];d.copy(Q).sub(M),p.copy(re).sub(M);let Z=M.angleTo(d),pe=d.angleTo(p),oe=Math.cos(Z)*m;a==0?C.copy(k):C.copy(M).setLength(g+oe),G.push(oe);let ae=[C,Q,re];for(let Me=0;Me<2;Me++){let Ae=ae[Me],Ee=ae[Me+1];D.subVectors(Ae,M),P.subVectors(Ee,M),T.crossVectors(D,P).normalize();for(let Ie=0;Ie<v;Ie++){let be=[Z,pe][Me]*Ie/v;d.copy(D).applyAxisAngle(T,be).add(M),W.push(d.clone()),Me&&(x(d,M),V.push([Ie==0?Ae:d.clone(),y.clone()]))}Me&&(x(Ee,M),V.push([Ee,y.clone()]))}j.push(V)}I.push(j);let q=2*v,H=2;for(let Y=0;Y<c;Y++){let V=q*Y,ie=q*((Y+1)%c),Q=[W[V]];for(let Z=1;Z<v;Z++){D=W[V+Z],P=W[ie+Z],Q.push(D);for(let pe=1,oe=Z-H+1;pe<=oe;pe++)d.lerpVectors(D,P,pe/(oe+1)),d.sub(M).setLength(G[Y]).add(M),Q.push(d.clone());Q.push(P)}for(let Z=0;Z<v;Z++)Q.push(W[Z+v+V]);Q.push(W[ie+v]);let re=S.map(Z=>Q[Z]);n.push(...re.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...re.map(Z=>(x(Z,M),[y.x,y.y,y.z])).flat())}}let U=[];for(let N=0;N<A.length;N++)for(let L=0;L<c;L++){let W=A[N][L];if(W<_){let G=A[W].findIndex(q=>q%_==N),j=I[N][L],k=I[W][G];for(let q=0;q<v;q++){let H=j[q],Y=k[v-q],V=j[q+1],ie=k[v-(q+1)];[H,Y,V,V,Y,ie].forEach(Q=>{n.push(Q[0].x,Q[0].y,Q[0].z),l.push(Q[1].x,Q[1].y,Q[1].z)})}U.push(j[0][0],k[v][0],j[v][0],k[0][0])}}for(;U.length;){let N,L,W,G;[N,L]=U.splice(0,2);let j=[N];for(;N!=L;)j.push(L),W=U.indexOf(L),G=W%2,L=U.splice(W-G,2)[1-G];y.subVectors(j[0],j[1]).cross(d.subVectors(j[0],j[2])).normalize();let k=y.dot(j[0])<0;k&&y.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +k],j[q+1-+k],j[0]].forEach(H=>{n.push(H.x,H.y,H.z),l.push(y.x,y.y,y.z)})}}function u(){let c=new E;for(let A=0;A<n.length;A+=3){c.x=n[A+0],c.y=n[A+1],c.z=n[A+2];let _=b(c)/2/Math.PI+.5,S=w(c)/Math.PI+.5;o.push(_,1-S)}let d=new E,p=new E,f=new E,m=new E,g=new F,v=new F,y=new F,x=(A,_,S,M)=>{M<0&&A.x===1&&(o[_]=A.x-1),S.x===0&&S.z===0&&(o[_]=M/2/Math.PI+.5)};for(let A=0,_=0;A<n.length;A+=9,_+=6){d.set(n[A+0],n[A+1],n[A+2]),p.set(n[A+3],n[A+4],n[A+5]),f.set(n[A+6],n[A+7],n[A+8]),g.set(o[_+0],o[_+1]),v.set(o[_+2],o[_+3]),y.set(o[_+4],o[_+5]),m.copy(d).add(p).add(f).divideScalar(3);let S=b(m);x(g,_+0,d,S),x(v,_+2,p,S),x(y,_+4,f,S)}for(let A=0;A<o.length;A+=6){let _=o[A+0],S=o[A+2],M=o[A+4],C=Math.max(_,S,M),T=Math.min(_,S,M);C>.9&&T<.1&&(_<.2&&(o[A+0]+=1),S<.2&&(o[A+2]+=1),M<.2&&(o[A+4]+=1))}function b(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 py(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},Oj=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:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new bM(t*.5,a,n):new TA(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},bM=class extends py{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,a=[-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],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],o="DodecahedronGeometry";super(a,n,o,e,t,i),this.type=o}static fromJSON(e){return new bM(e.radius,e.corner,e.cornerSides)}},Xh=1e-12,fy=class{constructor(e){this.position=new F,this.startPosition=new F,this.uuid=Le.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 fy(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Bv=class extends fy{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Bv(this.parent).copy(this)}},Nl=class extends fy{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Bv(this),new Bv(this))}static create(e,t){let i=new Nl(e,new F(...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 Nl(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 F,t=new F){let[i,r]=this.computeTangents();return i&&r&&(Rw(i,e),Rw(r,t)),[e,t]}computeTangent(e=new F){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new F){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function Rw(e,t=new F){let i=e.length();return t.set(-e.y/i,e.x/i)}var my=e=>e,Ah=new F,of=new F,Rj=new F,Lj=new F,Bj=new F,zj=new F,wM=new E,_M=new E;function kj(e){let t=new F;t.addVectors(e.v0,Ah.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new F;return i.addVectors(e.v2,of.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new xs(e.v0,t,i,e.v2)}function dc(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function Nj(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function Uj(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function SM(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)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-a*a)/(2*s*r))}function Fj(e,t,i){return Bw(e,t)&&Bw(t,i)&&zv(e.position,t.position,i.position)}function zv(e,t,i){return Ah.copy(t).sub(e).cross(of.copy(i).sub(e))===0}function Vj(e,t,i,r,s){let a=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(e.y-t.y)/a,h=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(t.x-e.x)/a;return r.set(o+l,n+h),s.set(o-l,n-h),[r,s]}function jj(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function Gj(e,t,i,r,s,a){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,u=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),c;return SM(t,e,i)>Math.PI&&(u*=-1),dc(h,o)?c=(o+h)*(r/u-.5)*8/3/(n-l):c=(n+l)*(r/u-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*n),a.set(i.x+c*h,i.y-c*l),[s,a]}function Lw(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Bw(e,t){return zv(e.position,e.controls[1].position,t.position)&&zv(e.position,t.controls[0].position,t.position)}function Hj(e,t,i,r,s=.5){let a=Ah.subVectors(t,e).multiplyScalar(s).add(e),n=of.subVectors(i,t).multiplyScalar(s).add(t),o=Rj.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=Lj.subVectors(n,a).multiplyScalar(s).add(a),u=Bj.subVectors(o,n).multiplyScalar(s).add(n),c=o,d=zj.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 Wj(e,t,i=12,r=!0){let s=_M.set(0,0,0),a,n=0,o=[];for(let l=0;l<t.length;l++){let h=my(t[l]),u=Ah,c=go(h,i);o.push(c);for(let d=0;d<=c;d++)if(h instanceof xs||h instanceof Tn||h instanceof As){if(h.getPoint(d/c,u),s.set(u.x,u.y,0),a!==void 0&&Uj(a,s))continue;a===void 0&&(a=wM),a.copy(s),e.setXYZ(n,s.x,s.y,s.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function qj(e,t,i,r=12,s=!0){let a=_M.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,u=my(t[l]),c=Ah,d=go(u,r);o.push(d);for(let p=0;p<=d;p++)if(u instanceof xs||u instanceof Tn||u instanceof As){if(u.getPoint(p/d,c),a.set(c.x,c.y,0),h?.equals(a))continue;h===void 0?h=wM:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,a.x,a.y,a.z),n++),h.copy(a)}}return s&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function zw(e,t=12,i=!1){let r=[];for(let s=0,a=e.length;s<a;s++){let n=e[s],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=go(n.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=go(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=go(e[0].roundedCurveCorner,t)*.5),r}function go(e,t=12){return e&&e instanceof Hp?t*2:e&&(e instanceof As||e instanceof AA)?1:e&&e instanceof T0?t*e.points.length:t}function Yj(e,t,i=12,r=!0){let s,a=0;for(let n=0;n<t.length;n++){let o=my(t[n]),l=go(o,i),h=Ah;for(let u=0;u<=l;u++)if(o instanceof xs||o instanceof Tn||o instanceof As){if(o.getPoint(u/l,h),s!==void 0&&Nj(s,h,Xh))continue;s===void 0&&(s=of),s.copy(h),e.push(h.x,h.y),a++}}return dc(e[0],e[e.length-2],Xh)&&dc(e[1],e[e.length-1],Xh)&&(e.pop(),e.pop()),r&&a>1&&!(dc(e[a-1],e[1],Xh)&&dc(e[a-2],e[0],Xh))&&(e.push(e[0],e[1]),a++),e}var Tm=new F,Xj=new F,Qj=new F,Zj=new F,Kj=new F,Jj=new F,Zt=class extends $u{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new kr(new E(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=Le.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Zt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>Nl.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Zt.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,a=this.shapeHoles.length;s<a;s++){let n=this.shapeHoles[s],o=n.points.length,l=n.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],a=e-t;if(a<=s.points.length-1)return s.points[a];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],a=s.points.indexOf(e);if(a>=0)return t+a;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=Tm.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let a=this.points[r];a.position.multiply(i),a.controls[0].position.multiply(i),a.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=Le.generateUUID()){let r;e instanceof F?r=e:r=new F(e,t);let s=new Nl(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 Wj(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=zw(this.points,e,!1),this.roundedCurveDivisions=zw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return qj(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),Yj(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=go(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(a<i+l)return[n,(a-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],a=this.curveDivisions,n=a[e];if(Lw(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Tm.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=a[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){Lw(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],a=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=s.roundness,l=a&&n&&Fj(a,s,n);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(),m=Math.min(o,p*.499),g=Math.min(o,f*.499),v=Math.min(m,g),y=1-v/p,x=v/f,b=h.getPointAt(y,Tm),w=u.getPointAt(x,Xj);this._subSplitCurve(h,c,y,b,void 0),this._subSplitCurve(u,d,x,void 0,w);let A;if(this.useCubicForRoundedCorners){let _=SM(b,s.position,w)/2,S=Math.tan(_)*b.distanceTo(s.position),[M,C]=Vj(b,w,S,Qj,Zj),T=jj(M,C,s.position),[D,P]=Gj(T,b,w,S,Kj,Jj);A=new xs(b.clone(),D.clone(),P.clone(),w.clone())}else A=new Tn(b.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 As)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let a=e,n=t,o=a.getUtoTmapping(i,0),l=Hj(a.v0,a.v1,a.v2,a.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),s!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new Zt(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],a=e.points[r+1],n=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 Nl(Le.generateUUID(),new F(s,a));c.controls[0].position.set(n,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 Zt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(s,a)=>{a instanceof xs&&a.v3.equals(s.position)&&s.controls[0].position.copy(a.v2)},r=s=>{let a=[],n,o;for(n=0,o=s.length;n<o;n++)s[n]instanceof Tn&&(s[n]=kj(s[n]));for(n=0,o=s.length;n<o;n++){let u=s[n],c=n>0?s[n-1]:null,d;u instanceof xs?(d=this.createPoint(u.v0),d.controls[1].position.copy(u.v1)):u instanceof As&&(d=this.createPoint(u.v1)),d!==void 0&&(c!==null&&i(d,c),a.push(d))}let l=s[s.length-1],h=!1;return l instanceof xs?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof As&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof $u&&(this.shapeHoles=e.holes.map(s=>{let a=new Zt;return a.fromShape(s),a})),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)}},kv=Math.PI*2;function Dm({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function $j(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),a=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:a+n*i,y:n-a*i},{x:a,y:n}]}function kw(e,t,i,r){let s=e*r-t*i<0?-1:1,a=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(a)}function e8(e,t,i,r,s,a,n,o,l,h){let u=Math.pow(s,2),c=Math.pow(a,2),d=Math.pow(n,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 m=f*s/a*o,g=f*-a/s*n,v=m+(e+i)/2,y=g+(t+r)/2,x=(n-m)/s,b=(o-g)/a,w=(-n-m)/s,A=(-o-g)/a,_=kw(1,0,x,b),S=kw(x,b,w,A);return!h&&S>0&&(S-=kv),h&&S<0&&(S+=kv),{centerx:v,centery:y,ang1:_,ang2:S}}function t8({px:e,py:t,cx:i,cy:r,rx:s,ry:a,largeArcFlag:n,sweepFlag:o}){let l=[];if(s===0||a===0)return[];let h=(e-i)/2,u=(t-r)/2;if(h===0&&u===0)return[];s=Math.abs(s),a=Math.abs(a);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(u,2)/Math.pow(a,2);c>1&&(s*=Math.sqrt(c),a*=Math.sqrt(c));let d=e8(e,t,i,r,s,a,h,u,n,o),{ang1:p,ang2:f}=d,{centerx:m,centery:g}=d,v=Math.abs(f)/(kv/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x<y;x++)l.push($j(p,f)),p+=f;return l.map(x=>{let{x:b,y:w}=Dm(x[0],s,a,m,g),{x:A,y:_}=Dm(x[1],s,a,m,g),{x:S,y:M}=Dm(x[2],s,a,m,g);return{x1:b,y1:w,x2:A,y2:_,x:S,y:M}})}var Tt;(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"})(Tt||(Tt={}));var pi;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(pi||(pi={}));function Xe(e,t){if(!e)throw t||"Assertion Failed!"}var Fe=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){Xe(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?s<a?i.t-t.t+(t.t-r.t)*(s/(s+a)):i.t-r.t+(r.t-t.t)*(a/(s+a)):0},e.edgeSign=function(t,i,r){Xe(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?(i.t-r.t)*s+(i.t-t.t)*a:0},e.transEval=function(t,i,r){Xe(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?s<a?i.s-t.s+(t.s-r.s)*(s/(s+a)):i.s-r.s+(r.s-t.s)*(a/(s+a)):0},e.transSign=function(t,i,r){Xe(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?(i.s-r.s)*s+(i.s-t.s)*a: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,a){var n,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)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,s.s)):a.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)?(n=e.transEval(t,r,i),o=e.transEval(r,i,s),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,s,i),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,s.t)):a.t=(r.t+i.t)/2},e}(),Qh=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}(),su=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}(),yl=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}(),Nw=function(){function e(){var t=new yl,i=new Qh,r=new su(0),s=new su(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 su(0),r=new su(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;Xe(s,"Vertex can't be null!");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i;var n=i;do n.Org=s,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;Xe(s,"Face can't be null");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var n=i;do n.Lface=s,n=n.Lnext;while(n!==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 a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.makeEdge=function(){var t=new yl,i=new yl,r=new Qh,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 a=new yl;this.makeVertex_(a,i,t.Org),t.Org.anEdge=t}if(!r){var n=new Qh;this.makeFace_(n,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 Qh;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 yl;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),a=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(a,i),s.Org=t.Dst,a.Org=i.Org,s.Lface=a.Lface=t.Lface,t.Lface.anEdge=a,!r){var n=new Qh;this.makeFace_(n,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,a,n,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)),a=r.Sym,a.Onext===a?this.killVertex_(a.Org,null):(a.Org.anEdge=a.Onext,this.splice_(a,a.Oprev)),this.killEdge_(r));while(r!=i);n=t.prev,o=t.next,o.prev=n,n.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,a,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;s=r.Lnext,a=r.Sym,a&&a.Lface&&a.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(a.Lface),o+l-2<=t&&Fe.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&Fe.vertCCW(a.Lprev.Org,a.Org,r.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),r=null,a=null)),!(r&&r.Lnext.Org===n);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,a,n,o,l,h;for(a=t,a=t;(s=a.next)!==t;a=s){Xe(s.prev===a),l=s.anEdge;do Xe(l.Sym!==l),Xe(l.Sym.Sym===l),Xe(l.Lnext.Onext.Sym===l),Xe(l.Onext.Sym.Lnext===l),Xe(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(Xe(s.prev===a&&s.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){Xe(n.prev===o),l=n.anEdge;do Xe(l.Sym!==l),Xe(l.Sym.Sym===l),Xe(l.Lnext.Onext.Sym===l),Xe(l.Onext.Sym.Lnext===l),Xe(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(Xe(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Xe(l.Sym.next===h.Sym),Xe(l.Sym!==l),Xe(l.Sym.Sym===l),Xe(l.Org!==null),Xe(l.Dst!==null),Xe(l.Lnext.Onext.Sym===l),Xe(l.Onext.Sym.Lnext===l);Xe(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}(),Uw=function(){function e(){this.handle=null}return e}(),Fw=function(){function e(){this.key=null,this.node=0}return e}(),i8=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 Uw,this.handles[r]=new Fw;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,a,n;for(s=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,Xe(n<=this.max),a=i[n].handle,n>this.size||this.leq(r[s].key,r[a].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t>>1,a=i[n].handle,n===0||this.leq(r[a].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},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,a;for(a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new Uw;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new Fw}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;Xe(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}(),Pm=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}(),Vw=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),r8=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new Vw,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 Vw;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}(),s8=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,a=i.eUp,n=r.eUp;if(a.Dst===s)return n.Dst===s?Fe.vertLeq(a.Org,n.Org)?Fe.edgeSign(n.Dst,a.Org,n.Org)<=0:Fe.edgeSign(a.Dst,n.Org,a.Org)>=0:Fe.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return Fe.edgeSign(a.Dst,s,a.Org)>=0;var o=Fe.edgeEval(a.Dst,s,a.Org),l=Fe.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Xe(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Xe(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 Pm;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 Tt.ODD:return(i&1)!==0;case Tt.NONZERO:return i!==0;case Tt.POSITIVE:return i>0;case Tt.NEGATIVE:return i<0;case Tt.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,a=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,a=e.regionBelow(n),s=a.eUp,s.Org!=o.Org){if(!a.fixUpperEdge){e.finishRegion(t,n);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,a,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,n),o=a.eUp,n=a}return o},e.addRightEdges=function(t,i,r,s,a,n){var o,l,h,u,c=!0;h=r;do Xe(Fe.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=e.regionBelow(i).eUp.Rprev),l=i,u=a;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,Xe(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Fe.vertL1dist(i,t),a=Fe.vertL1dist(r,t),n=.5*a/(s+a),o=.5*s/(s+a);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,a,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,a,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp;if(Fe.vertLeq(s.Org,a.Org)){if(Fe.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;Fe.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,a.Oprev,s)):(t.mesh.splitEdge(a.Sym),t.mesh.splice(s,a.Oprev),i.dirty=r.dirty=!0)}else{if(Fe.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n;if(Xe(!Fe.vertEq(s.Dst,a.Dst)),Fe.vertLeq(s.Dst,a.Dst)){if(Fe.edgeSign(s.Dst,a.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Sym,n),n.Lface.inside=i.inside}else{if(Fe.edgeSign(a.Dst,s.Dst,a.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Lnext,a.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n=s.Org,o=a.Org,l=s.Dst,h=a.Dst,u,c,d=new yl,p,f;if(Xe(!Fe.vertEq(h,l)),Xe(Fe.edgeSign(l,t.event,n)<=0),Xe(Fe.edgeSign(h,t.event,o)>=0),Xe(n!==t.event&&o!==t.event),Xe(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(u=Math.min(n.t,l.t),c=Math.max(o.t,h.t),u>c))return!1;if(Fe.vertLeq(n,o)){if(Fe.edgeSign(h,n,o)>0)return!1}else if(Fe.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Fe.intersect(l,n,h,o,d),Xe(Math.min(n.t,l.t)<=d.t),Xe(d.t<=Math.max(o.t,h.t)),Xe(Math.min(h.s,l.s)<=d.s),Xe(d.s<=Math.max(o.s,n.s)),Fe.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=Fe.vertLeq(n,o)?n:o,Fe.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),Fe.vertEq(d,n)||Fe.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!Fe.vertEq(l,t.event)&&Fe.edgeSign(l,t.event,d)>=0||!Fe.vertEq(h,t.event)&&Fe.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.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(a.Sym),t.mesh.splice(s.Lnext,a.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=a.Oprev,a=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,a.Onext,s.Rprev,f,!0),!0):(Fe.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),Fe.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(a.Sym),t.mesh.splice(a.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,n,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,a;;){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,a=r.eUp,s.Dst!==a.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(a),r=e.regionBelow(i),a=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==a.Org)if(s.Dst!==a.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||a.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===a.Org&&s.Dst===a.Dst&&(e.addWinding(a,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,a=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Fe.vertEq(o.Org,t.event)&&(t.mesh.splice(a.Oprev,o),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Fe.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,a,a,!0);return}Fe.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,a,n,o,l;if(s=i.eUp,Fe.vertEq(s.Org,r)){Xe(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Fe.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}Xe(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(Xe(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),Fe.edgeGoesLeft(a)||(a=null),e.addRightEdges(t,i,n.Onext,o,a,!0)},e.connectLeftVertex=function(t,i){var r,s,a,n,o,l,h=new Pm;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,Fe.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=Fe.vertLeq(o.Dst,n.Dst)?r:s,r.inside||a.fixUpperEdge){if(a===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var u=t.mesh.connect(o.Dnext,i.anEdge);l=u.Sym}a.fixUpperEdge?e.fixUpperEdge(t,a,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);Xe(s!==null);var a=e.regionBelow(s),n=a.eUp,o=e.finishLeftRegions(t,a,null);o.Onext===n?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,s){var a=new Pm,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=s,n.Dst.s=i,n.Dst.t=s,t.event=n.Dst,a.eUp=n,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=t.dict.insert(a)},e.initEdgeDict=function(t){t.dict=new r8(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,a=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,a,n),e.addSentinel(t,s,a,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Xe(i.fixUpperEdge),Xe(++r===1)),Xe(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,a=t.mesh.eHead;for(i=a.next;i!==a;i=r)r=i.next,s=i.Lnext,Fe.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,a=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)a++;for(a+=8,i=t.pq=new i8(a,Fe.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,a;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,a=r.anEdge,Xe(a.Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),t.mesh.delete(a));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||!Fe.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}(),a8=function(){function e(){this.mesh=new Nw,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=Tt.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,a,n,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],m=this.mesh.vHead;i=m.next;for(var g=0;g<3;++g)a=i.coords[g],h[g]=a,f[g]=i,l[g]=a,p[g]=i;for(i=m.next;i!==m;i=i.next)for(var v=0;v<3;++v)a=i.coords[v],a<h[v]&&(h[v]=a,f[v]=i),a>l[v]&&(l[v]=a,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=m.next;i!==m;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],n=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],n>o&&(o=n,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,a=0,n=t.next;n!==t;n=n.next)if(s=n.anEdge,!(s.winding<=0))do a+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==n.anEdge);if(a<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,a=!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),a=!0),r=this.sUnit,s=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,s[n]=0,s[(n+1)%3]=0,s[(n+2)%3]=i[n]>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);a&&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(;Fe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Fe.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(Fe.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Fe.edgeGoesLeft(s.Lnext)||Fe.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)a=t.connect(s.Lnext,s),s=a.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Fe.edgeGoesRight(r.Lprev)||Fe.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)a=t.connect(r,r.Lprev),r=a.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)a=t.connect(s.Lnext,s),s=a.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,a=t.eHead.next;a!==t.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?i:-i:r?t.delete(a):a.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 a,n=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){a=u.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=n,++n}this.elementCount=n,i===pi.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*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){a=u.anEdge,l=0;do{var h=a.Org;this.elements[d++]=h.n,l++,a=a.Lnext}while(a!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===pi.CONNECTED_POLYGONS){a=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,a=0,n=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;a=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=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,n++,r=r.Lnext;while(r!==s);this.elements[u++]=a,this.elements[u++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new Nw),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,a,n){if(t===void 0&&(t=Tt.ODD),i===void 0&&(i=pi.POLYGONS),n===void 0&&(n=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),s8.computeInterior(this,n);var o=this.mesh;return i===pi.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===pi.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function xn(e){var t=e.windingRule,i=t===void 0?Tt.ODD:t,r=e.elementType,s=r===void 0?pi.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,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,m=e.debug,g=m===void 0?!1:m;if(!d&&f)throw new Error("Contours can't be empty");if(d){var v=new a8;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,n,l,u,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var CQ=Tt.ODD,TQ=Tt.NONZERO,DQ=Tt.POSITIVE,PQ=Tt.NEGATIVE,IQ=Tt.ABS_GEQ_TWO,OQ=pi.POLYGONS,RQ=pi.CONNECTED_POLYGONS,LQ=pi.BOUNDARY_CONTOURS,Nv=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*Nv.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*Nv.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,a=0,n=new Float32Array(r,a*s,3*e);a+=3*e;let o=new Float32Array(r,a*s,3*e);a+=3*e;let l=new Float32Array(r,a*s,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,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)}},AM=Nv;AM.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var n8=Ri(yT()),gy={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},MM={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},EM={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},Im=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),vy=class extends Ue{constructor(e,t,i=0,r=12,s=3,a=Tt.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(M=>{let C=M.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let P=C[D-1],I=C[D-0];T.push(P,I)}return T}),h=[],u=[];for(let M=0;M<o.length;M+=2)u.push([o[M],o[M+1]]);h.push(u);for(let M=0;M<l.length;M++){let C=l[M],T=[];for(let D=0;D<C.length;D+=2)T.push([C[D],C[D+1]]);h.push(T)}let c;e.isText?c=new GA().setFromPoints(e.points.map(M=>M.position)).getSize(new F).length()*.1:h[0].length===0?c=i:c=(0,n8.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let d;try{d=xn({windingRule:a,elementType:pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{d=gy}let p;try{p=xn({windingRule:Tt.ODD,elementType:pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=MM}if(!d)throw new Error("error generating geometry");let f=d.elementCount;if(p){d.elementCount+=p.elementCount;for(let M=0;M<p.elements.length;M++){let C=p.elements[M],T=M%2===0?d.vertexCount:0;d.elements.push(C+T)}for(let M=0;M<p.vertexIndices.length;M++){let C=p.vertexIndices[M],T=d.vertexCount;d.vertexIndices.push(C+T)}for(let M=0;M<p.vertices.length;M++){let C=p.vertices[M];d.vertices.push(C)}}let m=1/0,g=-1/0,v=1/0,y=-1/0;for(let M=0,C=d.vertexCount;M<C;M++){let T=M*2,D=d.vertices[T+0],P=d.vertices[T+1];D<m&&(m=D),D>g&&(g=D),P<v&&(v=P),P>y&&(y=P)}this._minX=m,this._minY=v,this._width=g-m,this._height=y-v,this._buffer=new AM(this._computeBufferEstimatedSize(d));let x=[],b=[];for(let M=d.elementCount-1;M>=0;M--){let C=M>=f,T=M*2,D=d.elements[T+0],P=d.elements[T+1],I=D+P,R={start:D,count:P,normals:[],continuous:[],concave:[]},U=D,N=I-1,L=D+1,W=this._shape.roundedCurves.length;do{let H=U-D,Y=d.vertices[N*2+0],V=d.vertices[N*2+1],ie=d.vertices[U*2+0],Q=d.vertices[U*2+1],re=d.vertices[L*2+0],Z=d.vertices[L*2+1],pe=ie-Y,oe=Q-V,ae=Math.sqrt(pe*pe+oe*oe);pe/=ae,oe/=ae;let Me=ie-re,Ae=Q-Z,Ee=Math.sqrt(Me*Me+Ae*Ae);Me/=Ee,Ae/=Ee,R.normals[H*2+0]=-Ae,R.normals[H*2+1]=Me,R.concave[H]=pe*Ae-oe*Me>0;let Ie=d.vertexIndices[U];if(Array.isArray(Ie))R.continuous[H]=!1;else{let[be,ye]=this._shape.getCurveIndexFromVertexId(Ie-1,!0);if(ye>0&&ye<1)R.continuous[H]=!0;else{let ke=ye===1?be+1:be-1;ke=(ke+W)%W;let Je=ye===1?0:1,z=this._shape.roundedCurves[be].getTangent(ye),O=this._shape.roundedCurves[ke].getTangent(Je);R.continuous[H]=z.dot(O)>.95}}C&&(R.normals[H*2+0]*=-1,R.normals[H*2+1]*=-1),[N,U,L]=[U,L,L+1],L>=I&&(L-=P)}while(L!==D+1);let G=[];G.push({bevelI:0,angle:0,size:0,boundary:{vertices:d.vertices.slice(D*2,I*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((H,Y)=>[Y,Y]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:d.vertices.slice(D*2,I*2)});let j=0;for(let H=1;H<=this._bevelSegments;H++){let Y=H/this._bevelSegments*Math.PI/2,V=(1-Math.cos(Y))*this._bevel,ie=[],Q=[],re=[],Z=[],pe=0;for(let ae=0;ae<P;ae++){let Me=ae*2,Ae=(ae-1+P)%P*2,Ee=d.vertices[R.start*2+Me+0],Ie=d.vertices[R.start*2+Me+1],be=-R.normals[Ae+0]*V,ye=-R.normals[Ae+1]*V,ke=-R.normals[Me+0]*V,Je=-R.normals[Me+1]*V;if(R.concave[ae]||!R.concave[ae]&&C){let z=Math.atan2(ye,be),O=Math.atan2(Je,ke);O>z&&(O-=Math.PI*2);let $=O-z;if(R.continuous[ae]||C){let ge=z+$/2,de=Math.cos(ge)*V,xe=Math.sin(ge)*V;ie[2*pe+0]=Ee+de*(C?-1:1),ie[2*pe+1]=Ie+xe*(C?-1:1),Z[pe]=ae,pe++}else{let ge=Math.max(1,Math.floor(r/4*Math.abs($)/Math.PI));for(let de=0;de<=ge;de++){let xe=z+$*(de/ge),Be=Math.cos(xe)*V,Ce=Math.sin(xe)*V;ie[2*pe+0]=Ee+Be,ie[2*pe+1]=Ie+Ce,Z[pe]=ae,pe++}}}else ie[2*pe+0]=Ee+be,ie[2*pe+1]=Ie+ye,Z[pe]=ae,Q[ae]=pe,pe++,ie[2*pe+0]=Ee,ie[2*pe+1]=Ie,Z[pe]=ae,pe++,ie[2*pe+0]=Ee+ke,ie[2*pe+1]=Ie+Je,Z[pe]=ae,re[ae]=pe,pe++}let oe=xn({windingRule:Tt.POSITIVE,elementType:pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ie],edgeCreateCallback:ae=>{let Me=ae.Org.idx,Ae=Z[Me],Ee=Z[(Me+1)%Z.length];ae.idx=[Ae,Ee],ae.Sym.idx=[Ee,Ae]},vertexIdCallback:ae=>{let Me=ae.Lprev.idx;return[Me?Me[1]:0,ae.idx?ae.idx[0]:0]}});if(!oe)throw console.log("Error"),new Error(`error generating bevel geometry for ${H}'th loop`);if(!oe.vertexCount){let ae=(H-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<oe.vertexIndices.length;ae++){let[Me,Ae]=oe.vertexIndices[ae];if(Me===Ae)continue;let Ee=Ae;Ae<Me&&(Ee+=P);for(let Ie=Me;Ie<Ee;Ie++){let be=Ie%P,ye=(Ie+1)%P;if(!R.continuous[be]||!R.continuous[ye]){oe.vertexIndices[ae]=[Me,be],oe.vertexIndices.splice(ae+1,0,[ye,Ae]),oe.vertices.splice((ae+1)*2,0,oe.vertices[ae*2],oe.vertices[ae*2+1]);break}}}G.push({bevelI:H,angle:Y,size:V,boundary:oe,reverseMap:Z,insetPoints:ie})}let k=(H,Y,V)=>{let ie=0,Q=H.boundary.vertexIndices.length;for(;ie<Q&&V(H.boundary.vertexIndices[Y]);)Y=(Y+1)%Q,ie++;return ie},q=x.length;for(let H=1;H<G.length;H++){let Y=G[H-1],V=G[H],ie=Y.boundary.vertexIndices.length,Q=V.boundary.vertexIndices.length;if(!ie||!Q)break;let re=R.concave.length,Z=0,pe=Im(Z,P);for(;!Y.boundary.vertexIndices.filter(pe).length||!V.boundary.vertexIndices.filter(pe).length;)Z++,pe=Im(Z,P);let oe=Y.boundary.vertexIndices.findIndex(pe),ae=V.boundary.vertexIndices.findIndex(pe);do oe=(oe+1)%ie;while(pe(Y.boundary.vertexIndices[oe]));do ae=(ae+1)%Q;while(pe(V.boundary.vertexIndices[ae]));Z=(Z+1)%P;let Me=Z,Ae=0,Ee=this._buildBevelVert(R,Y,(oe-1+ie)%ie,void 0,Ae),Ie=this._buildBevelVert(R,V,(ae-1+Q)%Q,void 0,Ae),be=Ee,ye=Ie,ke,Je,z=!1;do{Ae=(Z||re)/re,pe=Im(Z,P);let O=k(Y,oe,pe),$=k(V,ae,pe),ge=z;if(z=!1,O&&!$){for(let de=0;de<O;de++)ke=this._buildBevelVert(R,Y,(oe+de)%ie,de/(O-1),Ae),x.push(be.topN,ke.topP,ye.topN),n===!1&&x.push(ke.bottomP,be.bottomN,ye.bottomN),be=ke;z=!0}else if(!O&&$)for(let de=0;de<$;de++)Je=this._buildBevelVert(R,V,(ae+de)%Q,de/($-1),Ae),x.push(ye.topN,be.topP,Je.topP),n===!1&&x.push(be.bottomP,ye.bottomN,Je.bottomP),ye=Je;else if(O&&$)if(ke=this._buildBevelVert(R,Y,oe,0,Ae),Je=this._buildBevelVert(R,V,ae,0,Ae),ge?(x.push(be.topN,Je.topP,ye.topN),x.push(be.topN,ke.topP,Je.topP),n===!1&&(x.push(Je.bottomP,be.bottomN,ye.bottomN),x.push(Je.bottomP,ke.bottomP,be.bottomN))):(x.push(ye.topN,be.topN,ke.topP),x.push(ye.topN,ke.topP,Je.topP),n===!1&&(x.push(ke.bottomP,be.bottomN,ye.bottomN),x.push(ke.bottomP,ye.bottomN,Je.bottomP))),be=ke,ye=Je,O===$)for(let de=1;de<O;de++)ke=this._buildBevelVert(R,Y,(oe+de)%ie,de/(O-1),Ae),Je=this._buildBevelVert(R,V,(ae+de)%Q,de/($-1),Ae),x.push(be.topN,ke.topP,ye.topN),x.push(ye.topN,ke.topP,Je.topP),n===!1&&(x.push(ke.bottomP,be.bottomN,ye.bottomN),x.push(ke.bottomP,ye.bottomN,Je.bottomP)),be=ke,ye=Je;else if(O>$){let de=O/$,xe=0;for(let Be=1;Be<O;Be++)ke=this._buildBevelVert(R,Y,(oe+Be)%ie,Be/(O-1),Ae),x.push(be.topN,ke.topP,ye.topN),n===!1&&x.push(ke.bottomP,be.bottomN,ye.bottomN),be=ke,Be>(xe+1)*de&&(xe++,Je=this._buildBevelVert(R,V,(ae+xe)%Q,xe/($-1),Ae),x.push(ye.topN,ke.topP,Je.topP),n===!1&&x.push(ke.bottomP,ye.bottomN,Je.bottomP),ye=Je)}else{let de=$/O,xe=0;for(let Be=1;Be<$;Be++)Je=this._buildBevelVert(R,V,(ae+Be)%Q,Be/($-1),Ae),x.push(ye.topN,ke.topP,Je.topP),n===!1&&x.push(ke.bottomP,ye.bottomN,Je.bottomP),ye=Je,Be>(xe+1)*de&&(xe++,ke=this._buildBevelVert(R,Y,(oe+xe)%ie,xe/(O-1),Ae),x.push(be.topN,ke.topP,ye.topN),n===!1&&x.push(ke.bottomP,be.bottomN,ye.bottomN),be=ke)}oe=(oe+O)%ie,ae=(ae+$)%Q,Z=(Z+1)%re}while(Z!==Me)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(G,R,x),C){let H=[];for(let Y=x.length-1;Y>=q+2;Y-=3){let V=x[Y-2],ie=x[Y-1],Q=x[Y-0];H.push(Q,ie,V)}x.splice(q,x.length-q,...H)}if(C){let H=[];for(let Y=G[G.length-1].boundary.vertices.length-1;Y>=1;Y-=2){let V=G[G.length-1].boundary.vertices[Y-1],ie=G[G.length-1].boundary.vertices[Y-0];H.push(V,ie)}b.push(H)}if(!C){let H=G[G.length-1],Y;try{Y=xn({windingRule:G.length>1?Tt.POSITIVE:Tt.ODD,elementType:pi.POLYGONS,vertexSize:2,strict:!0,contours:[H.insetPoints,...b]})}catch{Y=EM}if(!Y)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let V=0;V<Y.elementCount*3;V+=3){let ie=this._buildSurfaceVert(Y,Y.elements[V+0],j),Q=this._buildSurfaceVert(Y,Y.elements[V+1],j),re=this._buildSurfaceVert(Y,Y.elements[V+2],j);x.push(ie.top,Q.top,re.top),n===!1&&x.push(re.bottom,Q.bottom,ie.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Ze(Uint32Array.from(x),1),A=new Ze(this._buffer.positions,3),_=new Ze(this._buffer.normals,3),S=new Ze(this._buffer.uvs,2);A.needsUpdate=!0,_.needsUpdate=!0,S.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",_),this.setAttribute("uv",S),this.setIndex(w)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],a=e.vertices[t*2+1],n=(s-this._minX)/this._width,o=(a-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,u=l*2,c={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[u+0]=n,this._buffer.uvs[u+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[u+2]=n,this._buffer.uvs[u+3]=o),this.vertexCache[r]=c,c}_buildBevelVert(e,t,i,r=1,s){let a=`${t.bevelI}:${i}`;if(a in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[n,o]=t.boundary.vertexIndices[i],l,h,u,c;n!==o?(h=n,l=o,c=!1,u=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,u=e.continuous[l]||c);let d=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,m=l*2,g=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,b=(v-this._minX)/this._width,w=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(b=s),w=1);let A=e.normals[m+0],_=e.normals[m+1],S=e.normals[g+0],M=e.normals[g+1];if(c){let I=S-A,R=M-_;A=A+I*(1-r),_=_+R*(1-r);let U=Math.sqrt(A*A+_*_);A/=U,_/=U}let C=this.forPathBevel?this._buffer.get(u?1:2):this._buffer.get(u?2:4),T=C*3,D=C*2,P={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=A*d,this._buffer.normals[T+1]=_*d,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=w,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=A*d,this._buffer.normals[T+4]=_*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=w,this._buffer.uvs[D+3]=b),u||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),P.topP=C+0,P.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=S*d,this._buffer.normals[T+1]=M*d,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=w,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=S*d,this._buffer.normals[T+4]=M*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=w,this._buffer.uvs[D+3]=b)),this.vertexCache[a]=P,P}clone(){let e=new vy(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=$p(this.userData),e}},CM=class extends Ue{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Tt.ODD,this.elementType=pi.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Tt.ODD,elementType:pi.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)),a,n=!0,o=!0,l,h;for(let d=0,p=r.length/2;d<p;d++){let f=d*2,m=r[f+0],g=r[f+1];if(l!==void 0&&m!==l&&(n=!1),h!==void 0&&g!==h&&(o=!1),l=m,h=g,!n&&!o)break}if(!n&&!o)try{a=xn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=gy}let u=a?.vertexCount??1,c=a?.elementCount??1;if(this._positionAttribute=new Ze(new Float32Array(u*3),3),this._normalAttribute=new Ze(new Float32Array(u*3),3),this._uvAttribute=new Ze(new Float32Array(u*2),2),this._indexAttribute=new Ze(new Uint32Array(c*3),1),a){let d=1/0,p=-1/0,f=1/0,m=-1/0;for(let y=0,x=u;y<x;y++){let b=y*2,w=a.vertices[b+0],A=a.vertices[b+1];w<d&&(d=w),w>p&&(p=w),A<f&&(f=A),A>m&&(m=A)}let g=p-d,v=m-f;for(let y=0,x=u;y<x;y++){let b=y*2,w=a.vertices[b+0],A=a.vertices[b+1],_=(w-d)/g,S=(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,x=c;y<x;y++){let b=y*3,w=a.elements[b+0],A=a.elements[b+1],_=a.elements[b+2];this._indexAttribute.setX(b+0,w),this._indexAttribute.setX(b+1,A),this._indexAttribute.setX(b+2,_)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new CM(this._shape,this._curveSegments);return e.userData=$p(this.userData),e}},TM=class extends vy{constructor(e,t,i=0,r=12,s=3,a=Tt.ODD){super(e,t,i,r,s,a),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}clone(){let e=new TM(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=$p(this.userData),e}},Do=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:Tt.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.abs(i.depth??0),n=e.shape??t?.shape,o=n?.roundness??i.roundness;n!==void 0&&(n instanceof Zt?(n.width!==r||n.height!==s)&&n.applySize(r,s):n=new Zt(r,s).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new Zt(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:a,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:a,windingRule:n}=e.parameters;e.shape.roundness=a;let o;return t<=0?o=new CM(e.shape,s,{windingRule:n}):o=new TM(e.shape,t,i,s,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},DM=Math.PI*2,yy=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 i.angle=Le.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof Zt?e.shape:new Zt,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:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,u=t*.5,c=i*.5,d=o8(h,u,c,s*Math.PI/180,r,a);h.isClosed=!0,h.update();let p;return s===0?(p=new Ue,p.setAttribute("position",new Te([],3))):p=Do.create({shape:h,parameters:{subdivisions:d,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function o8(e,t,i,r,s,a){if(r>=DM)return s>30||s%4===0?(h8(e,t,i,a),Math.round(s/4)):jw(e,r,s,t,i,a);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=t8({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?l8(e,n.x,n.y,h,s,t,i,a):jw(e,r,s,t,i,a)}function l8(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint(Ul(t,i));for(let h=0,u=r.length;h<u;h++){let c=r[h],d=e.points[h],p=Ul(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?PM(e,a,n,o):e.addPoint(Ul(0,0)),l}function jw(e,t,i,r,s,a){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,u=Math.cos(l)*s;e.addPoint(Ul(h,u))}return t<DM?a>0?PM(e,r,s,a):e.addPoint(Ul(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&IM(e,r,s,a)),1}function h8(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(au(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(au(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(au(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(au(s,a-i,s+o,a-i,s-o,a-i)),r>0&&IM(e,t,i,r)}function Ul(e,t){return new Nl(Le.generateUUID(),new F(e,t))}function au(e,t,i,r,s,a){let n=Ul(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function PM(e,t,i,r){OM(e,t,i,r).forEach(s=>e.addPoint(s))}function IM(e,t,i,r){let s=OM(e,t,i,r),a=new Zt;s.forEach(n=>a.addPoint(n)),a.isClosed=!0,e.shapeHoles.push(a)}function OM(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new F(s/t,a/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=Le.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),u=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var c8=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),a=Math.abs(i.depth??r),n=Math.abs(Math.min(r,a))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:a,radius:n,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:a,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:c}=e.parameters,d=new RM(!1,t,i,r,s,a,n,o,l,h,u,c);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},Om=new Pl([0,0,0],1),RM=class extends Ue{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,u=1,c=1){if(super(),a===0)return;let d=e&&a===1;d&&(c=0),u>100&&(u=100),u===0&&(c=0);let p=()=>new E,f=new E,m=p(),g=p(),v=p(),y,x,b,w,A,_,S,M,C=p(),T=p(),D=p(),P=p(),I=p(),R=p(),U=p(),N=p(),L=i-2*o+.001,W=L/a,G=Math.ceil(n*a),j=G+1,k=L/G,q=-L/2,H=h+1,Y=2*Math.PI/h,V=Math.PI/2/c,ie=.01,Q=Math.min((1-u/100)*o,o-ie),re=o-Q,Z=0,pe=2,oe=c*pe+pe,ae=H*oe/pe,Me=ae+H*j,Ae=Math.max(0,H*(j+oe)),[Ee,Ie,be]=[3,3,2].map(Oe=>Array(Ae*Oe).fill(0)),ye=[],ke=s-o;function Je(Oe,ze){let Re=Math.PI/2;_=ze*k,M=2*Math.PI*(_%W)/W+Re,_+=q,S=Math.sin(M)*ke,A=Math.cos(M)*ke,e?Oe.set(A,S,_):Oe.set(A,_,S)}Je(f,-1e-10),Je(m,0),C.copy(f),Je(f,1);let z=f.distanceTo(m),O=d?0:re+Q,$=z*G+2*O,ge=Q,de=$-O;for(let Oe=0;Oe<=G;Oe++){Je(g,Oe),N.subVectors(g,C).normalize(),C.copy(g),R.copy(g).setComponent(+e+1,0).normalize(),U.crossVectors(N,R).normalize();let ze=Oe===0,Re=Oe===G,Ke=ze?3*Math.PI/2:V,je=ze?ge:de,vt=ze?H:Me,Nt=ze?0:Ae-H,oi=N.clone().multiplyScalar(ze?-re:re).add(g),X=N.clone().multiplyScalar(ze?-1:1).normalize();for(let ne=0;ne<H;ne++){let ve=ne*Y;if(T.addVectors(f.copy(R).multiplyScalar(o*Math.cos(ve)),m.copy(U).multiplyScalar(o*Math.sin(ve))),D.copy(T).normalize(),ze||Re){d||(Z=Nt+ne,[0,1,2].forEach(_e=>{Ee[Z*3+_e]=oi.getComponent(_e),Ie[Z*3+_e]=X.getComponent(_e)}),be[Z*2]=+Re,be[Z*2+1]=ne/h),m.copy(D).multiplyScalar(Q),v.addVectors(g,m);for(let _e=0;_e<c;_e++){let qe=_e*V+Ke;P.addVectors(f.copy(N).multiplyScalar(re*Math.sin(qe)),m.copy(D).multiplyScalar(re*Math.cos(qe))),I.copy(P).normalize(),m.addVectors(v,P),P.normalize(),Z=vt+_e*H+ne,[0,1,2].forEach(Gt=>{Ee[Z*3+Gt]=m.getComponent(Gt),Ie[Z*3+Gt]=I.getComponent(Gt)});let wt=+ze+Math.sin(qe);be[Z*2]=(je+re*wt)/$,be[Z*2+1]=ne/h}}m.addVectors(g,T),Z=ae+Oe*H+ne,[0,1,2].forEach(_e=>{Ee[Z*3+_e]=m.getComponent(_e),Ie[Z*3+_e]=D.getComponent(_e)}),be[Z*2]=(O+Oe*z)/$,be[Z*2+1]=ne/h}}let xe=j+2*c+pe,Be=1,[Ce,ue]=[+d,xe-1];for(let Oe=Ce;Oe<=ue-1;Oe++){let ze=d&&Oe===ue-1;for(let Re=0;Re<H-1;Re++)y=Oe*H+Re,x=y+1,b=(ze?Re:y)+H,w=(ze?Re+1:x)+H,Oe===0?ye.push(x,w,b):Oe===xe-2?ye.push(y,x,b):ye.push(y,x,b,x,w,b)}this.setIndex(ye),this.setAttribute("position",new Te(Ee,3)),this.setAttribute("normal",new Te(Ie,3)),this.setAttribute("uv",new Te(be,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,a,n,o,l=6*(t-1)*e.radialSegments,h=t,u=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,a=s+1,n=(u?c:s)+i,o=(u?c+1:a)+i,r[l++]=s,r[l++]=a,r[l++]=n,r[l++]=a,r[l++]=o,r[l++]=n;return r.length=l,Om.array=r,Om.count=r.length,Om}},d8=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:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new LM(t*.5,a,n):new RA(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},LM=class extends py{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],a=[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],n="IcosahedronGeometry";super(s,a,n,e,t,i),this.type=n}static fromJSON(e){return new LM(e.radius,e.corner,e.cornerSides)}},u8=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 $u;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 a=new EA(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}},Ls=new me,Rm=new Pt,nu=new E,Pp=class extends Ni{constructor(){super(),this.uuid=Le.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 ri().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 a=0,n=s.vertexNormals.length;a<n;a++)s.vertexNormals[a].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return Ls.makeRotationX(e),this.applyMatrix4(Ls),this}rotateY(e){return Ls.makeRotationY(e),this.applyMatrix4(Ls),this}rotateZ(e){return Ls.makeRotationZ(e),this.applyMatrix4(Ls),this}translate(e,t,i){return Ls.makeTranslation(e,t,i),this.applyMatrix4(Ls),this}scale(e,t,i){return Ls.makeScale(e,t,i),this.applyMatrix4(Ls),this}lookAt(e){return Rm.lookAt(e),Rm.updateMatrix(),this.applyMatrix4(Rm.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,a=r.normal,n=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)),n!==void 0&&t.colors.push(new Ve().fromBufferAttribute(n,c));function h(c,d,p,f){let m=n===void 0?[]:[t.colors[c].clone(),t.colors[d].clone(),t.colors[p].clone()],g=a===void 0?[]:[new E().fromBufferAttribute(a,c),new E().fromBufferAttribute(a,d),new E().fromBufferAttribute(a,p)],v=new Uv(c,d,p,g,m,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new F().fromBufferAttribute(o,c),new F().fromBufferAttribute(o,d),new F().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new F().fromBufferAttribute(l,c),new F().fromBufferAttribute(l,d),new F().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 m=p,g=p+f;m<g;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),d.materialIndex):h(m,m+1,m+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(nu).negate(),this.translate(nu.x,nu.y,nu.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new me;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],a=this.vertices[s.a],n=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,n),t.subVectors(a,n),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,a=this.faces.length;s<a;s++){let n=this.faces[s],o=this.vertices[n.a],l=this.vertices[n.b],h=this.vertices[n.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[n.a].add(i),t[n.b].add(i),t[n.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],a=s.vertexNormals;a.length===3?(a[0].copy(t[s.a]),a[1].copy(t[s.b]),a[2].copy(t[s.c])):(a[0]=t[s.a].clone(),a[1]=t[s.b].clone(),a[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,a=r.vertexNormals.length;s<a;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new Pp;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,a=this.morphNormals[t].vertexNormals;for(let n=0,o=this.faces.length;n<o;n++){let l=new E,h={a:new E,b:new E,c:new E};s.push(l),a.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,a=this.faces.length;s<a;s++){let n=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.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 ai),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Tr),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,a=this.vertices,n=e.vertices,o=this.faces,l=e.faces,h=this.colors,u=e.colors;t!==void 0&&(r=new ri().getNormalMatrix(t));for(let c=0,d=n.length;c<d;c++){let p=n[c].clone();t!==void 0&&p.applyMatrix4(t),a.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,m,g=p.vertexNormals,v=p.vertexColors,y=new Uv(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,b=g.length;x<b;x++)f=g[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,b=v.length;x<b;x++)m=v[x],y.vertexColors.push(m.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,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++)v.push(g[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 a=[];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]){a.push(o);break}}for(let o=a.length-1;o>=0;o--){let l=a[o];this.faces.splice(l,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(l,1)}let n=this.vertices.length-i.length;return this.vertices=i,n}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],a,n;r&&r.length===t&&(a=[]),s&&s.length===t&&(n=[]);for(let o=0;o<t;o++){let l=e[o]._id;a&&a.push(r[l]),n&&n.push(s[l])}a&&(this.faceVertexUvs[0]=a),n&&(this.faceVertexUvs[1]=n)}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={},a=[],n={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],m=!0,g=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,b=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,m),A=h(A,2,g),A=h(A,3,v),A=h(A,4,y),A=h(A,5,x),A=h(A,6,b),A=h(A,7,w),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let _=this.faceVertexUvs[0][p];i.push(d(_[0]),d(_[1]),d(_[2]))}if(y&&i.push(u(f.normal)),x){let _=f.vertexNormals;i.push(u(_[0]),u(_[1]),u(_[2]))}if(b&&i.push(c(f.color)),w){let _=f.vertexColors;i.push(c(_[0]),c(_[1]),c(_[2]))}}function h(p,f,m){return m?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 n[f]!==void 0||(n[f]=a.length,a.push(p.getHex())),n[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,a.length>0&&(e.data.colors=a),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new Pp().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,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++){let b=g[y];v.push(b.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,m=s[c].vertices.length;f<m;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,m=s[c].normals.length;f<m;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let a=e.morphNormals;for(let c=0,d=a.length;c<d;c++){let p={};if(a[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=a[c].vertexNormals.length;f<m;f++){let g=a[c].vertexNormals[f],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),p.vertexNormals.push(v)}}if(a[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=a[c].faceNormals.length;f<m;f++)p.faceNormals.push(a[c].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let c=0,d=n.length;c<d;c++)this.skinWeights.push(n[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 p8().fromGeometry(this),t=new Ue,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",ou.call(new Ze(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",ou.call(new Ze(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",Gw.call(new Ze(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",Hw.call(new Ze(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",Hw.call(new Ze(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],a=e.morphTargets[r];for(let n=0,o=a.length;n<o;n++){let l=a[n],h=new Te(l.data.length*3,3);h.name=l.name,s.push(ou.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Te(e.skinIndices.length*4,4);t.setAttribute("skinIndex",Ww.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Te(e.skinWeights.length*4,4);t.setAttribute("skinWeight",Ww.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 Ue,i=e.geometry;if(e.isPoints||e.isLine){let r=new Te(i.vertices.length*3,3),s=new Te(i.colors.length*3,3);if(t.setAttribute("position",ou.call(r,i.vertices)),t.setAttribute("color",Gw.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let a=new Te(i.lineDistances.length,1);t.setAttribute("lineDistance",f8.call(a,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}};Pp.prototype.isGeometry=!0;var p8=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,a=e.faces;for(r=0;r<a.length;r++){let n=a[r];n.materialIndex!==s&&(s=n.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,a=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let g=0;g<o;g++)l[g]={name:n[g].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,u=h.length,c;if(u>0){c=[];for(let g=0;g<u;g++)c[g]={name:h[g].name,data:[]};this.morphTargets.normal=c}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<t.length;g++){let v=t[g];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 b=v.normal;this.normals.push(b,b,b)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let b=v.color;this.colors.push(b,b,b)}if(s===!0){let b=r[0][g];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new F,new F,new F))}if(a===!0){let b=r[1][g];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new F,new F,new F))}for(let b=0;b<o;b++){let w=n[b].vertices;l[b].data.push(w[v.a],w[v.b],w[v.c])}for(let b=0;b<u;b++){let w=h[b].vertexNormals[g];c[b].data.push(w.a,w.b,w.c)}f&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),m&&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}},Uv=class{constructor(e,t,i,r,s,a=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 Ve,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=a}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 f8(e){return this.array.set(e),this}function Gw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new Ve),t[i++]=a.r,t[i++]=a.g,t[i++]=a.b}return this}function Hw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new F),t[i++]=a.x,t[i++]=a.y}return this}function ou(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new E),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z}return this}function Ww(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new rt),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z,t[i++]=a.w}return this}var m8=["a","b","c"];function g8(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function Lm(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),a=r+"_"+s;return i.get(a)}function Bm(e,t,i,r,s,a){let n=Math.min(e,t),o=Math.max(e,t),l=n+"_"+o,h;if(r.has(l))h=r.get(l);else{let u=i[n],c=i[o];h={a:u,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),a[e].edges.push(h),a[t].edges.push(h)}function v8(e,t,i,r){let s,a,n;for(s=0,a=e.length;s<a;s++)i[s]={edges:[]};for(s=0,a=t.length;s<a;s++)n=t[s],Bm(n.a,n.b,e,r,n,i),Bm(n.b,n.c,e,r,n,i),Bm(n.c,n.a,e,r,n,i)}function lu(e,t,i,r,s){e.push(new Uv(t,i,r,void 0,void 0,s))}function tl(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function hu(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var y8=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Ue?e=new Pp().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,a,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,c=[],d=new Map;v8(o,l,c,d);let p=[],f,m,g,v,y,x,b;for(let ie of Array.from(d.keys())){for(m=d.get(ie),g=new E,y=3/8,x=1/8,b=m.faces.length,b!=2&&(y=.5,x=0,b!=1),g.addVectors(m.a,m.b).multiplyScalar(y),t.set(0,0,0),a=0;a<b;a++){for(v=m.faces[a],n=0;n<3&&(f=o[g8(v,m8[n])],!(f!==m.a&&f!==m.b));n++);f&&t.add(f)}t.multiplyScalar(x),g.add(t),m.newEdge=p.length,p.push(g)}let w,A,_,S,M,C,T,D=[];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),_=w,i<=2&&(i==2?(A=3/4,_=1/8):i==1||i==0),T=C.clone().multiplyScalar(A),t.set(0,0,0),a=0;a<i;a++)S=M[a],f=S.a!==C?S.a:S.b,t.add(f);t.multiplyScalar(Number(_)),T.add(t),D.push(T)}let P=D.concat(p),I=D.length,R,U,N,L=[],W=[],G,j,k,q,H=new F,Y=new F,V=new F;for(r=0,s=l.length;r<s;r++)v=l[r],R=Number(Lm(v.a,v.b,d).newEdge)+I,U=Number(Lm(v.b,v.c,d).newEdge)+I,N=Number(Lm(v.c,v.a,d).newEdge)+I,lu(L,R,U,N,v.materialIndex),lu(L,v.a,R,N,v.materialIndex),lu(L,v.b,U,R,v.materialIndex),lu(L,v.c,N,U,v.materialIndex),u&&(G=h[r],j=G[0],k=G[1],q=G[2],H.set(tl(j.x,k.x),tl(j.y,k.y)),Y.set(tl(k.x,q.x),tl(k.y,q.y)),V.set(tl(j.x,q.x),tl(j.y,q.y)),hu(W,H,Y,V),hu(W,j,H,V),hu(W,k,Y,H),hu(W,q,V,Y));e.vertices=P,e.faces=L,u&&(e.faceVertexUvs[0]=W)}},yi=new E,x8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new Ue().copy(new ta(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(yi),r={width:yi.x,height:yi.y,depth:yi.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,a=e.geometry??new Ue().copy(new ta(100,100,100)),n=a.userData.parameters;n===void 0?(a.computeBoundingBox(),a.boundingBox.getSize(yi)):yi.set(n.width,n.height,n.depth),(t!==yi.x||i!==yi.y||r!==yi.z)&&a.scale(yi.x===0?1:t/yi.x,yi.y===0?1:i/yi.y,yi.z===0?1:r/yi.z);let o=a.originalGeometry;try{s>0?(o===void 0||n?.subdivisions!==s)&&(o===void 0&&(o=a),a=new y8(s).modify(o).toBufferGeometry()):(o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals())}catch{o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals()}return o!==void 0&&Object.assign(a,{originalGeometry:o}),delete e.geometry,Object.assign(a,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new VA(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(yi);let a=100/yi.x;Object.assign(s.parameters,{width:100,height:yi.y*a,depth:yi.z*a}),t(this.build(s))})}},BM=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 Zt?e.shape:new Zt,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:a,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5,c=0,d=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let g=p*m,v=c+Math.sin(g)*h,y=d+Math.cos(g)*u;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=s;l.roundness=s,l.update();let f=Do.create({shape:l,parameters:{roundness:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},b8=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:a,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new _8(t*.5,i,s,a,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Zh(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function zm(e,t,i,r,s,a){let n=t.clone().sub(e),o=i.clone().sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===s){let h=n.add(o).normalize();a.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=n.angleTo(o);a.copy(e),a.addScaledVector(n,s/Math.sin(h)),a.addScaledVector(o,r/Math.sin(h))}}function w8(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var _8=class extends Ue{constructor(e=.5,t=1,i=4,r=1,s=!1,a=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o=[],l=[],h=[],u=[],c=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,g=(i-2)*Math.PI/i,v=Math.PI-g,y=new E(0,-d,0),x=new E(0,d,0),b=new F(e,-d),w=new F(f,-d),A=new F(0,x.y).sub(w),_=new F(0,x.y).sub(b),S=new F(A.y,-A.x).normalize(),M=new F(_.y,-_.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,C);let T;{let L=new E(S.x,S.y,0),W=new E(Math.cos(m)*L.x,L.y,Math.sin(m)*L.x);T=L.angleTo(W)}let D=a/Math.tan((Math.PI-A.angle())/2),P=a/Math.tan((Math.PI-T)/2),I=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),u.push(0,0);let L=c++,W=[],G=b.clone(),j=D/Math.cos(Math.PI/i);G.x-=j;for(let k=0;k<i;k++){let q=k/i*Math.PI*2+p,H=new F(Math.sin(q),Math.cos(q));Zh(G,H,I),l.push(I.x,I.y,I.z),h.push(0,-1,0),u.push(0,0),W.push(c++)}for(let k=0;k<W.length;k++)o.push(W[k],L,W[(k+1)%W.length])}let R=[];{let L=new E,W=new E,G=new E,j=new E,k=new E,q=new E;for(let H=0;H<i;H++){let Y=H/i*Math.PI*2+p,V=(H+.5)/i*Math.PI*2+p,ie=(H+1)/i*Math.PI*2+p,Q=new F(Math.sin(Y),Math.cos(Y)),re=new F(Math.sin(V),Math.cos(V)),Z=new F(Math.sin(ie),Math.cos(ie));Zh(b,Q,W),Zh(b,Z,G),Zh(S,re,L),zm(x,W,G,P,P,j),l.push(j.x,j.y,j.z),zm(W,x,G,P,D,k),l.push(k.x,k.y,k.z),zm(G,W,x,D,P,q),l.push(q.x,q.y,q.z),h.push(L.x,L.y,L.z),h.push(L.x,L.y,L.z),h.push(L.x,L.y,L.z),u.push(0,0),u.push(0,0),u.push(0,0);let pe=c++,oe=c++,ae=c++;if(o.push(pe,oe,ae),a>0){{let Ee=W.clone().add(G).multiplyScalar(.5),Ie=x.clone().sub(Ee).normalize(),be=y.clone().sub(Ee).normalize().add(Ie).normalize().multiplyScalar(-1),ye=q.clone().sub(k);U(Ee,ye,be,A.angle())}let Me,Ae;{let Ee=new E;Zh(M,Z,Ee);let Ie=q.clone().add(j).multiplyScalar(.5);Ie=w8(Ie,G,x);let be=q.clone().sub(j);[Me,Ae]=U(Ie,be,Ee,T,j.y)}{let Ee=Me,Ie=Ee.clone().setY(0).normalize(),be=new E(0,-1,0),ye=Ie.clone().cross(be);N(Ee,Ie,be,ye)}R.concat(Ae);{let Ee=A.angle(),Ie=Math.PI-Ee,be=x.clone();be.y-=a/Math.sin(Ee-Math.PI/2);let ye=new E,ke=[];for(let z=0;z<n;z++){let O=[],$=Math.PI/2-Ie*z/n,ge=Math.cos($),de=Math.sin($),xe=V;for(let Be=0;Be<=z;Be++){let Ce=Math.cos(xe),ue=Math.sin(xe);L.x=ge*ue,L.y=de,L.z=ge*Ce,ye.copy(be).addScaledVector(L,a),l.push(ye.x,ye.y,ye.z),h.push(L.x,L.y,L.z),u.push(0,0),O.push(c++),xe+=Math.PI*2/z/i}ke.push(O)}Ae.reverse(),ke.push(Ae);let Je=ke.length-1;for(let z=0;z<Je;z++){let O=ke[z],$=ke[z+1],ge=O.length-1;o.push($[1],O[0],$[0]);for(let de=1;de<=ge;de++)o.push(O[de],O[de-1],$[de]),o.push($[de+1],O[de],$[de])}}}}}this.setIndex(o),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(u,2));function U(L,W,G,j,k){let q=-j/2,H=(Math.PI-j)/2,Y=W.clone().normalize().cross(G);L.addScaledVector(G,-a/Math.sin(H));let V=new E,ie=new E,Q=1,re=c,Z=[];for(let pe=0;pe<=n;pe++){let oe=q+pe/n*j;ie.set(0,0,0),ie.addScaledVector(Y,Math.sin(oe)),ie.addScaledVector(G,Math.cos(oe));for(let ae=0;ae<=Q;ae++){let Me=ae/Q-.5;if(V.copy(L),V.addScaledVector(W,Me),V.addScaledVector(ie,a),k!=null){let Ae=Math.max(0,V.y-k);V.addScaledVector(W,-Ae/W.y)}l.push(V.x,V.y,V.z),h.push(ie.x,ie.y,ie.z),u.push(0,0),ae===0&&Z.push(c),c++}}for(let pe=0;pe<n;pe++)for(let oe=0;oe<Q;oe++){let ae=re+oe+(Q+1)*pe,Me=ae+(Q+1),Ae=Me+1,Ee=ae+1;o.push(ae,Me,Ee),o.push(Me,Ae,Ee)}return[L.clone().addScaledVector(W,.5),Z]}function N(L,W,G,j){let k=Math.PI/2,q=_.angle()-k,H=[],Y=new E,V=new E;for(let Q=0;Q<=n;Q++){let re=[],Z=Q/n;for(let pe=0;pe<=Q;pe++){let oe=((Q?pe/Q:0)-.5)*v,ae=Math.cos(oe),Me=Math.sin(oe),Ae=Math.atan(Math.tan(q)*ae),Ee=(k+Ae)*Z,Ie=Math.cos(Ee),be=Math.sin(Ee);Y.set(0,0,0),Y.addScaledVector(W,be*ae),Y.addScaledVector(G,Ie),Y.addScaledVector(j,be*Me),V.copy(L).addScaledVector(Y,a),l.push(V.x,V.y,V.z),h.push(Y.x,Y.y,Y.z),u.push(0,0),re.push(c++)}H.push(re)}let ie=H.length-1;for(let Q=0;Q<ie;Q++){let re=H[Q],Z=H[Q+1],pe=re.length-1;o.push(re[0],Z[1],Z[0]);for(let oe=1;oe<=pe;oe++)o.push(re[oe-1],re[oe],Z[oe]),o.push(re[oe],Z[oe+1],Z[oe])}}}},zM=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 Zt?e.shape:new Zt,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:a,depth:n,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(b,w,A){return w>i&&A>r?Math.min(b*i/w,b*r/A):w>i?b*i/w:A>r?b*r/A:b}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,m=c.x,g=c.y,v=u.y;t.addPoint(t.createPoint(f,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let b=0,w=t.points.length;b<w;b++)t.points[b].roundness=p[b],b>0&&p[b]!==p[b-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=a!==1,t.update();let x=Do.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},S8=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:180},e.parameters);return i.thetaLength=Le.clamp(i.thetaLength,0,180),{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:a=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,u;return h===0?(u=new Ue,u.setAttribute("position",new Te([],3))):u=new I0(.5*t,s,a,n,o,l,h*Le.DEG2RAD),u.scale(1,i/t,r/t),Object.assign(u,{userData:{...e,type:"SphereGeometry"}})}},A8=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,a=new jp(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}},M8=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:a,cornerSegments:n}=e.parameters,o=new E8(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},E8=class extends Ue{constructor(e=1,t=1,i=1,r=90,s=10,a=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;s==0&&(a=1),a=Math.max(1,Math.floor(a)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],c=Math.PI/2,d=(ie=0,Q=0,re=0)=>new E(ie,Q,re),p=d(),f=d(),[m,g,v]=[t/2,e/2,i/2],y=-g,x=+g,[b,w,A]=[d(y,-m,+v),d(y,-m,-v),d(y,+m,-v)],_=(ie,Q=!1)=>Math.sin(ie-Math.PI/(1+ +Q)),S=(ie,Q=!1)=>Math.cos(ie-Math.PI/(1+ +Q));A.y=Math.sin(r)*t-m;let M=Math.cos(r)*t-v,C=b.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,b.z-h),p.subVectors(b,w),f.subVectors(A,w);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),P=T/Math.cos(r/2),I=p.clone().normalize().add(f.normalize()).setLength(P).add(w);p.set(0,_(r,!0),S(r,!0)),u.push([A,p.clone()]);let R=(Math.PI-r)/a;for(let ie=0;ie<=a;ie++){let Q=c+r+ie*R;p.set(0,Math.sin(Q)*D,Math.cos(Q)*D),p.add(I),f.set(0,_(Q),S(Q)),u.push([p.clone(),f.clone()])}u.push([b,d(0,1,0)]);let U=Math.sin(R/2)*D*2,N=u.length-1,L=u[0][0].distanceTo(u[1][0]),W=u[N-1][0].distanceTo(u[N][0]),G=L+U*a+W;u[0].push(1);for(let ie=0;ie<=a;ie++)u[ie+1].push(1-(L+ie*U)/G);u[N].push(0);let[j,k,q]=u[0],H,Y,V;for(let ie=1;ie<u.length;ie++)[H,Y,V]=u[ie],n.push(y,j.y,j.z,y,H.y,H.z,x,j.y,j.z,x,j.y,j.z,y,H.y,H.z,x,H.y,H.z),o.push(0,k.y,k.z,0,Y.y,Y.z,0,k.y,k.z,0,k.y,k.z,0,Y.y,Y.z,0,Y.y,Y.z),l.push(0,q,0,V,1,q,1,q,0,V,1,V),[j,k,q]=[H,Y,V];this.setAttribute("position",new Te(n,3)),this.setAttribute("normal",new Te(o,3)),this.setAttribute("uv",new Te(l,2))}},kM=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 Zt?e.shape:new Zt,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:a,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,u=e.shape,c=t*.5,d=i*.5,p=0,f=0,m=n*Math.PI/360/s,g=Math.PI/2*3*-1,v=c*r/100,y=d*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let w=m*b,A=p+Math.sin(w)*c,_=f+Math.cos(w)*d;u.addPoint(u.createPoint(A,_))}}else for(let b=0;b<s;b++){let w=p+Math.cos(g)*c,A=f+Math.sin(g)*d;u.addPoint(u.createPoint(w,A)),g+=m,w=p+Math.cos(g)*v,A=f+Math.sin(g)*y,b<=s,u.addPoint(u.createPoint(w,A)),g+=m}u.isClosed=!0;for(let b=0,w=u.points.length;b<w;b++)u.points[b].roundness=a;u.roundness=a,u.update();let x=Do.create({shape:u,parameters:{roundness:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},C8=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 jp(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},T8=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:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:a})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:a,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=D8(t,i,r,t*.5,n,a,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function D8(e,t,i,r,s,a,n,o,l,h,u){[t,i]=[i,t],n=t/2;let c=Le.clamp(s/360,0,1);if(c===0){let d=new Ue;return d.setAttribute("position",new Te([],3)),d}return c===1&&(h=0),new RM(!0,e,t,i,r,c,a,n,o,l,h,u)}var P8=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:a,q:n}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new LA(o,i,r,s,a,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},I8=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 Zt?e.shape:new Zt,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:a,extrudeBevelSegments:n,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=Do.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function O8(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var R8=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},L8=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},se=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+se.version}static addUnaryOp(e){return se.max_unop_len=Math.max(e.length,se.max_unop_len),se.unary_ops[e]=1,se}static addBinaryOp(e,t,i){return se.max_binop_len=Math.max(e.length,se.max_binop_len),se.binary_ops[e]=t,i?se.right_associative.add(e):se.right_associative.delete(e),se}static addIdentifierChar(e){return se.additional_identifier_chars.add(e),se}static addLiteral(e,t){return se.literals[e]=t,se}static removeUnaryOp(e){return delete se.unary_ops[e],e.length===se.max_unop_len&&(se.max_unop_len=se.getMaxKeyLen(se.unary_ops)),se}static removeAllUnaryOps(){return se.unary_ops={},se.max_unop_len=0,se}static removeIdentifierChar(e){return se.additional_identifier_chars.delete(e),se}static removeBinaryOp(e){return delete se.binary_ops[e],e.length===se.max_binop_len&&(se.max_binop_len=se.getMaxKeyLen(se.binary_ops)),se.right_associative.delete(e),se}static removeAllBinaryOps(){return se.binary_ops={},se.max_binop_len=0,se}static removeLiteral(e){return delete se.literals[e],se}static removeAllLiterals(){return se.literals={},se}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new se(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return se.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!se.binary_ops[String.fromCharCode(e)]||se.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return se.isIdentifierStart(e)||se.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(se.hooks[e]){let i={context:this,node:t};return se.hooks.run(e,i),i.node}return t}searchHook(e){if(se.hooks[e]){let t={context:this};return se.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===se.SPACE_CODE||e===se.TAB_CODE||e===se.LF_CODE||e===se.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:se.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index<this.expr.length;)if(i=this.code,i===se.SEMCOL_CODE||i===se.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(i===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,se.max_binop_len),t=e.length;for(;t>0;){if(se.binary_ops.hasOwnProperty(e)&&(!se.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!se.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,i,r,s,a,n,o,l;if(a=this.gobbleToken(),!a||(t=this.gobbleBinaryOp(),!t))return a;for(s={value:t,prec:se.binaryPrecedence(t),right_a:se.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[a,s,n];t=this.gobbleBinaryOp();){if(i=se.binaryPrecedence(t),i===0){this.index-=t.length;break}s={value:t,prec:i,right_a:se.right_associative.has(t)},l=t;let h=u=>s.right_a&&u.right_a?i>u.prec:i<=u.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,a=r.pop(),e={type:se.BINARY_EXP,operator:t,left:a,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(s,e)}for(o=r.length-1,e=r[o];o>1;)e={type:se.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,se.isDecimalDigit(e)||e===se.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===se.SQUOTE_CODE||e===se.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===se.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,se.max_unop_len),i=t.length;i>0;){if(se.unary_ops.hasOwnProperty(t)&&(!se.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!se.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=i;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:se.UNARY_EXP,operator:t,argument:s,prefix:!0})}t=t.substr(0,--i)}se.isIdentifierStart(e)?(r=this.gobbleIdentifier(),se.literals.hasOwnProperty(r.name)?r={type:se.LITERAL,value:se.literals[r.name],raw:r.name}:r.name===se.this_str&&(r={type:se.THIS_EXP})):e===se.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===se.PERIOD_CODE||t===se.OBRACK_CODE||t===se.OPAREN_CODE||t===se.QUMARK_CODE;){let i;if(t===se.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==se.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===se.OBRACK_CODE?(e={type:se.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==se.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===se.OPAREN_CODE?e={type:se.CALL_EXP,arguments:this.gobbleArguments(se.CPAREN_CODE),callee:e}:(t===se.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:se.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,i;for(;se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===se.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);se.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,se.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===se.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===se.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:se.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===i){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":e+=`
|
|
3153
3153
|
`;break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=s}else e+=s}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:se.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(se.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,se.isIdentifierPart(e));)this.index++;return{type:se.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],i=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===e){i=!0,this.index++,e===se.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(s===se.COMMA_CODE){if(this.index++,r++,r!==t.length){if(e===se.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===se.CBRACK_CODE)for(let a=t.length;a<r;a++)t.push(null)}}else if(t.length!==r&&r!==0)this.throwError("Expected comma");else{let a=this.gobbleExpression();(!a||a.type===se.COMPOUND)&&this.throwError("Expected comma"),t.push(a)}}return i||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(se.CPAREN_CODE);if(this.code===se.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:se.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:se.ARRAY_EXP,elements:this.gobbleArguments(se.CBRACK_CODE)}}},B8=new R8;Object.assign(se,{hooks:B8,plugins:new L8(se),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});se.max_unop_len=se.getMaxKeyLen(se.unary_ops);se.max_binop_len=se.getMaxKeyLen(se.binary_ops);var nh=e=>new se(e).parse(),z8=Object.getOwnPropertyNames(se);z8.forEach(e=>{nh[e]===void 0&&e!=="prototype"&&(nh[e]=se[e])});nh.Jsep=se;var k8="ConditionalExpression",N8={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let i=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),t.node={type:k8,test:i,consequent:r,alternate:s},i.operator&&e.binary_ops[i.operator]<=.9){let a=i;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=i}}else this.throwError("Expected :")}})}};nh.plugins.register(N8);var U8=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],F8=["0","1","2","3","4","5","6","7","8","9","."],V8=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function j8(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))}nh.addBinaryOp("^",11,!0);function NM(e,t,i="number"){let r="";for(let n=0;n<e.length;n++){let o=e[n];if("id"in o){let l=e[n-1];if(n>0&&"id"in l){console.error("Two variables in a row",e);return}let h=t.getVariable(o.id),u=Fr.getDisplayedValue(h);i==="number"&&Fr.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?u=parseFloat(u).toString():i==="boolean"&&Fr.isBoolean(h)?u=h?"true":"false":i==="boolean"&&Fr.isTextValue(h)&&!Array.isArray(h.textValue)&&(u='"'+u+'"'),r+=u;continue}else if(i==="string"){o.name!=='"'&&o.name!=="+"&&(r+=o.name),o.name==="+"&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+o.name);continue}if(o.name==="and"){r+="&&";continue}if(o.name==="or"){r+="||";continue}if(o.name==="True"){r+="true";continue}if(o.name==="False"){r+="false";continue}if(i==="boolean"&&!j8(o.name)&&!F8.includes(o.name)&&!U8.includes(o.name)&&!V8.includes(o.name.replace(/\($/g,""))){r+='"'+o.name+'"';continue}r+=o.name}if(i==="string")return r;if(e.length===0){if(i==="number")return 0;if(i==="boolean")return!1}let s;try{s=nh(r)}catch(n){console.error(r,n);return}let a;try{a=bt(s)}catch(n){console.error(r,s,n)}return a}function bt(e){switch(e.type){case"BinaryExpression":switch(e.operator){case"==":return Number(bt(e.left)===bt(e.right));case"!=":return Number(bt(e.left)!==bt(e.right));case">":return Number(bt(e.left)>bt(e.right));case">=":return Number(bt(e.left)>=bt(e.right));case"<":return Number(bt(e.left)<bt(e.right));case"<=":return Number(bt(e.left)<=bt(e.right));case"+":return bt(e.left)+bt(e.right);case"-":return bt(e.left)-bt(e.right);case"*":return bt(e.left)*bt(e.right);case"/":return bt(e.left)/bt(e.right);case"%":return bt(e.left)%bt(e.right);case"&&":return bt(e.left)&&bt(e.right);case"||":return bt(e.left)||bt(e.right);case"^":return Math.pow(bt(e.left),bt(e.right));default:throw new Error("Unknown operator: "+e.operator)}case"UnaryExpression":switch(e.operator){case"-":return-bt(e.argument);case"!":return Number(!bt(e.argument));default:throw new Error("Unknown operator: "+e.operator)}case"Identifier":throw new Error("Unknown identifier: "+e.name);case"Literal":return e.value;case"CallExpression":if(e.callee.type==="Identifier"){if(e.callee.name==="random"){let t=0,i=1;if(e.arguments.length>=1)try{t=bt(e.arguments[0])}catch(r){console.warn(r)}if(e.arguments.length>=2)try{i=bt(e.arguments[1])}catch(r){console.warn(r)}return t=Math.min(i,t),i=Math.max(i,t),t+Math.random()*(i-t)}return Math[e.callee.name].apply(null,e.arguments.map(bt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+e.type)}}var G8=new me,H8=new me;function W8(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((a,n)=>{let o=s[n],l=Le.lerp(a.length(),o.length(),i);a.lerp(o,i).setLength(l)}),new me().makeBasis(r[0],r[1],r[2])}var q8=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),a=Math.abs(i.depth??0),n=t?.shapeData??yy.create({parameters:oM}).userData.shape;return{path:e.path??xp.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:a,extrusion:{...lM,...i.extrusion}}),shapeData:n}}static build(e){if(e.path.points.length>=2){let t=new Y8(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new Ue,{userData:{...e,type:"PathGeometry"}})}},Y8=class extends Ue{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)||!O8(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;i=Math.max(0,Math.min(i,1)),r=Math.max(0,Math.min(r,1));let s=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(r*s),n=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,n-a+1),s+2),l=[],h=[];for(let N=0;N<o;N++){let L=this.inputs.path.isClosed?(N+a)%e.length:Math.min(N+a,e.length-1);l.push(e[L].clone()),h.push(t[L].clone())}let u=(N,L,W)=>{l[N]=l[N].clone().lerp(l[L],W),h[N]=W8(h[N],h[L],W)},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 N=l.length-1;l[N].copy(l[0]),h[N].copy(h[0])}this._applyPathModifiers(h,c,p);let{bevel:m,bevelSides:g}=this.inputs.parameters.extrusion,v=m>0?this.inputs.parameters.extrusion.capType:"flat",y=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(y=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:b,vertices:w}=this._computeShapePoints(y),A=0,_;v==="round"&&(_=new vy(this.inputs.shapeData,2*m,m,y,g,void 0,!0),A=_.getAttribute("position").count);let S=0,M=0;b.sort((N,L)=>N.start-L.start),b.forEach(N=>{N.verticesStart=S,N.verticesCount=N.continuous.reduce((L,W,G)=>L+(G===0||!W?2:1),0),M+=N.verticesCount,S=M});let C=M*o,T,D=0;if(this._isOpenEnded()&&v==="flat"){try{T=xn({windingRule:Tt.ODD,elementType:pi.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:x})}catch{T=EM}D=T.vertexCount}let P=C+2*D+A*2,I=C+2*D,R={positions:new Float32Array(P*3),normals:new Float32Array(P*3),uvs:new Float32Array(P*2)},U=[];if(b.forEach(N=>{this._extrudeRegion(N,w,h,l,R,U,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,C,U,R,h[0],l[0],!1),this._closeEnd(T,C+D,U,R,h[h.length-1],l[l.length-1],!0)),_){R.positions.set(_.getAttribute("position").array,I*3),R.normals.set(_.getAttribute("normal").array,I*3),R.uvs.set(_.getAttribute("uv").array,I*2);let N=U.length;U.push(..._.getIndex().array.map(G=>G+I)),I+=A,R.positions.set(_.getAttribute("position").array,I*3),R.normals.set(_.getAttribute("normal").array,I*3),R.uvs.set(_.getAttribute("uv").array,I*2);let L=U.length;U.push(..._.getIndex().array.map(G=>G+I)),this.setAttribute("position",new Ze(R.positions,3)),this.setAttribute("normal",new Ze(R.normals,3)),this.setAttribute("uv",new Ze(R.uvs,2)),this.setIndex(U);let W=G8;W.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(W,I,P),W.copy(h[0]).setPosition(l[0]).multiply(H8.makeScale(1,1,-1)),this.applyMatrix4OnRange(W,I-A,I),this.reverseIndicesOnRange(N,L)}else this.setAttribute("position",new Ze(R.positions,3)),this.setAttribute("normal",new Ze(R.normals,3)),this.setAttribute("uv",new Ze(R.uvs,2)),this.setIndex(U)}_extractPathPoints(){let e=vM(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,a=new E,n=new E,o=new E,l=new E(0,1,0);for(let f=0;f<i;f++){let m=e[f],g;f===0?g=r?e[e.length-2]:m.clone().multiplyScalar(2).sub(e[1]):g=e[f-1];let v;f===i-1?v=r?e[1]:m.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=m.clone().sub(g).normalize(),x=v.clone().sub(m).normalize(),b=y.clone().add(x).normalize();n.copy(b),f===0&&(b.equals(l)||b.clone().negate().equals(l))&&l.set(0,0,1);let w=l.clone().cross(b).normalize(),A=b.clone().cross(w).normalize();l.copy(A),o.copy(w),f===0&&(s.copy(A),a.copy(b));let _=new me().makeBasis(w,A,b);t.push(_)}let h=r?a:n,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 m=new me().makeRotationZ(d*f/t.length);t[f].multiply(m)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:a,startScale:n,endScale:o}=this.inputs.parameters.extrusion,l=new me,h=new me;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(Le.lerp(s,s+a,d)*Le.DEG2RAD);let p=Le.lerp(n,o,d);h.makeScale(p,p,p),u.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=Tt.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),m=[];for(let g=f.length-1;g>=1;g-=2){let v=f[g-1],y=f[g-0];m.push(v,y)}return m}),a;try{a=xn({windingRule:t,elementType:pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{a=gy}let n;try{n=xn({windingRule:Tt.ODD,elementType:pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{n=MM}if(!a)throw new Error("error generating geometry");let o=a.elementCount;if(n){a.elementCount+=n.elementCount;for(let p=0;p<n.elements.length;p++){let f=n.elements[p],m=p%2===0?a.vertexCount:0;a.elements.push(f+m)}for(let p=0;p<n.vertexIndices.length;p++){let f=n.vertexIndices[p],m=a.vertexCount;a.vertexIndices.push(f+m)}for(let p=0;p<n.vertices.length;p++){let f=n.vertices[p];a.vertices.push(f)}}let l=1/0,h=-1/0,u=1/0,c=-1/0;for(let p=0,f=a.vertexCount;p<f;p++){let m=p*2,g=a.vertices[m+0],v=a.vertices[m+1];g<l&&(l=g),g>h&&(h=g),v<u&&(u=v),v>c&&(c=v)}let d=[];for(let p=a.elementCount-1;p>=0;p--){let f=p>=o,m=p*2,g=a.elements[m+0],v=a.elements[m+1],y=g+v,x={start:g,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};d.push(x);let b=g,w=y-1,A=g+1,_=i.roundedCurves.length;do{let S=b-g,M=a.vertices[w*2+0],C=a.vertices[w*2+1],T=a.vertices[b*2+0],D=a.vertices[b*2+1],P=a.vertices[A*2+0],I=a.vertices[A*2+1],R=T-M,U=D-C,N=Math.sqrt(R*R+U*U);R/=N,U/=N;let L=T-P,W=D-I,G=Math.sqrt(L*L+W*W);L/=G,W/=G,x.normals[S*2+0]=-W,x.normals[S*2+1]=L;let j=a.vertexIndices[b];if(Array.isArray(j))x.continuous[S]=!1;else{let[k,q]=i.getCurveIndexFromVertexId(j-1,!0);if(q>0&&q<1)x.continuous[S]=!0;else{let H=q===1?k+1:k-1;H=(H+_)%_;let Y=q===1?0:1,V=i.roundedCurves[k].getTangent(q),ie=i.roundedCurves[H].getTangent(Y);x.continuous[S]=V.dot(ie)>.95}}f&&(x.normals[S*2+0]*=-1,x.normals[S*2+1]*=-1),[w,b,A]=[b,A,A+1],A>=y&&(A-=v)}while(A!==g+1)}return{regions:[r,...s],infos:d,vertices:a.vertices}}_insertVertex(e,t,i,r,s){let a=t*2,n=t*3;e.positions[n+0]=i.x,e.positions[n+1]=i.y,e.positions[n+2]=i.z,e.normals[n+0]=r.x,e.normals[n+1]=r.y,e.normals[n+2]=r.z,e.uvs[a+0]=s.x,e.uvs[a+1]=s.y}_extrudeRegion(e,t,i,r,s,a,n){let o=new E,l=new E,h=new E,u=new E,c=new F;i.forEach((p,f)=>{let m=r[f],g=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(m),e.continuous[v])u.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let x=v===0?(e.start+e.count-1)*2:y-2;l.set(t[x+0],t[x+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,g,h,u,c),g++,!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 x=v===e.count-1?e.start*2:y+2;l.set(t[x+0],t[x+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,g,h,u,c),g++}}});let d=i.length-1;for(let p=0;p<d;p++){let f=e.verticesStart*i.length+e.verticesCount*p,m=e.verticesStart*i.length+e.verticesCount*(p+1),g=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&g++;let y=v===e.count-1?0:g+1,x=f+g,b=f+y,w=m+y,A=m+g;e.isHole?a.push(x,w,b,x,A,w):a.push(x,b,w,x,w,A),g++}}}_closeEnd(e,t,i,r,s,a,n){let o=e.vertexCount,l=new E(0,0,n?-1:1).applyMatrix4(s),h=new E,u=new F;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(a),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,m=c[p+(n?1:2)]+t,g=c[p+(n?2:1)]+t;i.push(f,m,g)}}applyMatrix4OnRange(e,t,i){let r=e.elements,s=new ri().getNormalMatrix(e).elements,a,n,o,l,h=this.attributes.position,u=this.attributes.normal;if(!h||!u)return;let c=h.array,d=u.array,p=h.itemSize;for(let f=t*p,m=i*p;f<m;f+=p){if(f===t)debugger;a=c[f+0],n=c[f+1],o=c[f+2],l=1/(r[3]*a+r[7]*n+r[11]*o+r[15]),c[f+0]=(r[0]*a+r[4]*n+r[8]*o+r[12])*l,c[f+1]=(r[1]*a+r[5]*n+r[9]*o+r[13])*l,c[f+2]=(r[2]*a+r[6]*n+r[10]*o+r[14])*l,a=d[f+0],n=d[f+1],o=d[f+2],d[f+0]=s[0]*a+s[3]*n+s[6]*o,d[f+1]=s[1]*a+s[4]*n+s[7]*o,d[f+2]=s[2]*a+s[5]*n+s[8]*o}h.needsUpdate=!0,u.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let s=i.getX(r),a=i.getX(r+1),n=i.getX(r+2);i.setXYZ(r,n,a,s)}i.needsUpdate=!0}}};function UM(){let e=new Ue;return e.setAttribute("position",new Ze(new Float32Array([]),3)),e.setIndex(new Ze(new Uint16Array([]),1)),e}var X8=UM().attributes,Q8=12,Z8=1,FM=class extends Ue{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,X8),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:a,extrudeBevelSegments:n,text:o,textTransform:l}=e,h=Fr.getDisplayedValue(o),u=l===2?h.toUpperCase():l===3?h.toLowerCase():h,c=K8(e,t,u),{shapes:d,charWidths:p,charCoords:f}=t.generateShapes(c,e),m=(typeof i=="number"?i:1)*.5,g=(typeof r=="number"?r:1)*.5,v=d.map(b=>new Zt().fromShape(b,!0));this.vectorShapes=v;let y=v.map(b=>Do.create({shape:b,parameters:{depth:s,extrudeBevelSegments:n,extrudeBevelSize:a,windingRule:s<=0?Tt.NONZERO:Tt.ODD,subdivisions:this.isLowResolution&&s>0?Z8:Q8}})),x=y.length?ao(y):UM();x.translate(-m,g,0),this.dispose(),this.wrappedText=c,this.charCoords=f,this.charWidths=p,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([b,w])=>{this.setAttribute(b,w)}),this.setIndex(x.index),this.computeBoundingSphere()}clone(){let e=Va(new Ue,FM.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 K8(e,t,i){let r=[""],s="";for(let a of i)s+=a,a===" "||a===`
|
|
3154
3154
|
`?(r[r.length-1]+=s,s="",a===`
|
|
3155
|
-
`&&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 VM,xy=new Promise(e=>{VM=e}),qw=!1,cu;function J8(){if(qw)return;if(cu)return cu;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@0.9.502/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});VM(n),qw=!0}return cu=e(),cu}function Ip(e,t,i,r){let s,a,n;e.type==="PathGeometry"?(a=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(a={...e},n=[[]]);for(let h of n){let u=a;for(let c of h)u=u[c];for(s in u){let c=u[s];J6(c)&&(u[s]=t.getVariable(c,[r.uuid,"geometry",...h,s]))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let h=Zt.createFromState(a.shape,a.width,a.height);o.shape=h}else if(a.type==="NonParametricGeometry")a.data.groups&&a.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new VA().parse(a);else if(a.type==="SubdivGeometry"){let h=new sr(a,i);return h.data=e,h}else if(a.type==="TextGeometry")return new FM(a,t);let l;try{l=Kw(o)}catch(h){console.error(h)}if(!l){let h=Zt.createFromState(yp.defaultData(),100,100);o.shape=h,l=Kw(o)}return l}var $8=new me;function Fv(e,t,i,r){let s=e.position.array,a=e.normal.array,n=$8.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=a[u],l=a[u+1],h=a[u+2],a[u]=n[0]*o+n[4]*l+n[8]*h,a[u+1]=n[1]*o+n[5]*l+n[9]*h,a[u+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var du=new ai,il=new E,Ge;xy.then(e=>{Ge=e});var Yw=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Xw=new Uint32Array([0,1,2,3]),Qw=new Uint8Array([4]),sr=class extends Ue{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=fo.div(t,i);this.subdividedGeometry&&Fv(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Fv(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(il.fromArray(r));let a=il.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=sr.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new ta(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&&(sr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;du.setFromBufferAttribute(t),du.getCenter(i),e.boundingSphere.radius=i.distanceTo(du.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),du.getSize(il);let r={width:il.x,height:il.y,depth:il.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,a,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Ge.free_bvh(t),Ge.free_subdivision_surface(t));try{s=sr.allocate(e,r)}catch(l){console.error(l,e),s=sr.allocate({positionWASM:Yw,indexWASM:Xw,verticesPerFaceWASM:Qw},r)}if(Ge.set_destination_refinement_level(s,0),a=sr.buildLevel(s,!0,o),e.subdivisions>0)try{Ge.set_destination_refinement_level(s,e.subdivisions),n=sr.buildLevel(s,!1,o)}catch{try{Ge.set_destination_refinement_level(s,e.subdivisions-1),n=sr.buildLevel(s,!1,o)}catch{n=null}}else n=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:n}}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=e.shape!==void 0||e.path!==void 0?t.geometry:Ip(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let a,n,o,l;({positions:a,triIndices:l}=lf(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let u=e.radialSegments*e.heightSegments*3*2,c=u+e.radialSegments*3;h=[u,c]}return{indices:n,verticesPerFace:o}=jM(a,l,r,h),{positions:a,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,s,a=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=Yw,r=Xw,s=Qw);let o=i.length,l=r.length,h=s.length,u=i.length+a.length+n.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,m=Ge._malloc(d),g=new Float32Array(Ge.HEAPF32.buffer,m,u),v=new Uint32Array(Ge.HEAPU32.buffer,m+p,c);g.set(i,0),g.set(a,i.length),g.set(n,i.length+a.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new me().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?Ge.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Ge.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Ge._free(m),x}static buildLevel(e,t,i,r,s){let a=s?Ge.get_mesh_data2(e,t?Ge.Level.CONTROL:Ge.Level.REFINED,i,s.elements):Ge.get_mesh_data(e,t?Ge.Level.CONTROL:Ge.Level.REFINED,i),n=8,o=Ge.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,4+4),h=0,u=Ge.HEAPU32[o[h]>>2],c=Ge.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Ge.HEAPU32[o[h]>>2],p=Ge.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Ge.HEAPU32[o[h]>>2],m=Ge.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=Ge.HEAPU32[o[h]>>2],v=Ge.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let y=new Ue;if(y.setIndex(new Pl(v,1)),y.setAttribute("position",new Te(c,3)),y.setAttribute("normal",new Te(p,3)),t){y.setAttribute("faceMap",new Pl(m,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ze(x,4))}return Ge.free_mesh_data(a),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,Ge.free_mesh_data(a)}static freeSubdivPointer(e){Ge.free_bvh(e),Ge.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Ge.get_wireframe_data_for_base_level(e),s=4,a=Ge.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,2+2),o=0,l=Ge.HEAPU32[a[o]>>2],h=Ge.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let u=Ge.HEAPU32[a[o]>>2],c=Ge.HEAPU32.subarray(u>>2,(u>>2)+n[o]);if(t===void 0){let d=new Ue;d.setAttribute("position",new Te(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Ze(p,3)),d.setIndex(new Pl(c,1)),Ge.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Ge.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Ge.set_destination_refinement_level(e,t);let s=i?Ge.get_topological_data2(e,r?Ge.Level.CONTROL:Ge.Level.REFINED,i.elements):Ge.get_topological_data(e,r?Ge.Level.CONTROL:Ge.Level.REFINED),a=6,n=Ge.HEAPU32.subarray(s>>2,(s>>2)+a),o=n.subarray(3,3+3),l=0,h=Ge.HEAPU32[n[l]>>2],u=new Float32Array(Ge.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Ge.HEAPU32[n[l]>>2],d=new Uint32Array(Ge.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Ge.HEAPU32[n[l]>>2],f=new Uint8Array(Ge.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Ge.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},Zw=["getX","getY","getZ"];function lf(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],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[Zw[d]](u)*o)},`;if(c in i)a.push(i[c]);else{for(let d=0;d<3;d++)n.push(e[Zw[d]](u));i[c]=s,a.push(s),s++}}let l=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||l.push(a[h],a[h+1],a[h+2]);return{positions:n,triIndices:l}}var uu=new E,km=new E,Nm=new E,Um=new E;function jM(e,t,i,r){let s=[],a=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let d=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let c=0;if(u<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),s.push(c++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),s.push(c++);return a.push(c),{indices:s,verticesPerFace:a}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){uu.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),km.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),Nm.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),Um.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),km.sub(uu).normalize(),Nm.sub(uu).normalize(),Um.sub(uu).normalize();let l=km.cross(Nm).dot(Um);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:o>=r[u]&&o<r[u+1])?(s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),a.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],u=0;for(let c=0,d=0;c<e.length;c+=3,d++)e[c+2]===0&&(l.push(d),u++),e[c+2]===n&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),a.push(u,u)}return{indices:s,verticesPerFace:a}}var Ea={};fT(Ea,{calcBoolean:()=>sG,calcBooleanTopological:()=>rG,freeMeshSet:()=>lG,getMeshSet:()=>aG,hasOpenEdges:()=>nG,transformMeshSet:()=>oG});var GM,eG=new Promise(e=>{GM=e}),pu;function tG(){if(pu)return pu;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@0.9.502/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});GM(n)}return pu=e(),pu}var ht,Fl;eG.then(e=>ht=e);function iG(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:a,triIndices:n}=lf(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=jM(a,n,e);o=h.length,r=[];for(let u=0,c=0;u<o;u++){r.push(h[u]);for(let d=0;d<h[u];d++)r.push(l[c++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,u=0;u<r.length;)r[u++]=3,o++,r[u++]=n[h++],r[u++]=n[h++],r[u++]=n[h++]}return{positions:a,faceIndices:r,nFaces:o}}function HM(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,a=ht._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(ht.HEAPU32.buffer,a,t):new Float32Array(ht.HEAPF32.buffer,a,t)).set(e,0),a}function WM(e){switch(e){case 0:return ht.OP.UNION;case 1:return ht.OP.INTERSECTION;case 2:return ht.OP.A_MINUS_B;case 3:return ht.OP.B_MINUS_A;case 4:return ht.OP.SYMMETRIC_DIFFERENCE;case 5:return ht.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function rG(e,t){Fl===void 0&&(Fl=ht.init_csg());let i=HM(e),r=ht.csg_calc_topological(Fl,i,e.length,WM(t));ht._free(i);let s=6,a=ht.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(3,3+3),o=0,l=ht.HEAPU32[a[o]>>2],h=new Float32Array(ht.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let u=ht.HEAPU32[a[o]>>2],c=new Uint32Array(ht.HEAPU32.subarray(u>>2,(u>>2)+n[o]));o++;let d=ht.HEAPU32[a[o]>>2],p=new Uint8Array(ht.HEAPU32.subarray(d>>2,(d>>2)+n[o]));return ht.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function sG(e,t,i,r){Fl===void 0&&(Fl=ht.init_csg());let s=HM(e),a=ht.csg_calc(Fl,s,e.length,r,WM(t));ht._free(s);let n=5,o=ht.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,2+3),h=0,u=ht.HEAPU32[o[h]>>2],c=ht.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=ht.HEAPU32[o[h]>>2],p=ht.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Te(c,3)),i.setAttribute("normal",new Te(p,3));let m=ht.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Tr),i.boundingSphere.radius=-1,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ht.free_mesh_data(a),f}function aG(e,t,i){if(ht===void 0)return-1;let r,s,a;if(t&&e.userData.positions!==void 0){let g=e.userData;a=g.verticesPerFace.length,r=g.positions,s=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+a);for(let v=0,y=0,x=0;v<g.verticesPerFace.length;v++){s[x++]=g.verticesPerFace[v];for(let b=0;b<g.verticesPerFace[v];b++)s[x++]=g.indices[y++]}}else({positions:r,faceIndices:s,nFaces:a}=iG(e,t,i));let n=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=ht._malloc(u),f=new Float32Array(ht.HEAPF32.buffer,p,l),m=new Uint32Array(ht.HEAPU32.buffer,p+c,h);return f.set(r,0),m.set(s,0),ht.get_csg_mesh(p,n,p+c,o,a)}function nG(e){return ht.has_open_edges(e)}function oG(e,t){ht.transform_csg_mesh(e,t.elements)}function lG(e){ht.free_csg_mesh(e)}var hG={ConeGeometry:Dj,CubeGeometry:Pj,CylinderGeometry:yM,DodecahedronGeometry:Oj,EllipseGeometry:yy,HelixGeometry:c8,IcosahedronGeometry:d8,LatheGeometry:u8,NonParametricGeometry:x8,PolygonGeometry:BM,PyramidGeometry:b8,RectangleGeometry:zM,SphereGeometry:S8,PlaneGeometry:A8,BackdropGeometry:M8,StarGeometry:kM,TextFrameGeometry:C8,TorusGeometry:T8,TorusKnotGeometry:P8,TriangleGeometry:I8,PathGeometry:q8,VectorGeometry:Do},Kw=e=>hG[e.type].create(e);function rl(e){return e!==null&&"booleanOp"in e}var qM=class extends uy(hr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new me}updateVisible(e){super.updateVisible(e),this.visible=!rl(this.parent)&&this.visible,rl(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ea.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rl(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof qM&&(e.freeBooleanPointer(),rl(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&rl(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),rl(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},fu=new ai;function by(e,t=0,i=e.count,r,s){let a=1/0,n=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<a&&(a=d),p<n&&(n=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}fu.min.set(a,n,o),fu.max.set(l,h,u),fu.getCenter(r),fu.getSize(s).multiplyScalar(.5)}var cG=new Ue,dG=new Kc,Dr=class extends qM{constructor(e,t){super(cG,dG),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?by(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},Jw=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}},On=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=Le.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,a){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 On&&(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}},uG=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}},_r=new uG,It=class extends On{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=Le.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let a=e.getNodeData(i),n=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return a.name=a.name||super.build(e,t,i),a.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||a.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,a.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,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}},Pr=class extends It{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,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,a):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,s,a,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,s,a,this.getLabel())),e.format(n.fragment.name,r,t))}},ki=class extends Pr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof F?e:new F(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,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},Zr=class extends Pr{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,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},Cr=class extends Ve{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],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))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(a))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}},Ca=class extends Pr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof Cr?e:new Cr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},pG=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,$w=/[a-z_0-9]+/gi,Se=class extends It{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 a,n=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(;a=$w.exec(this.src);)l.push(a);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&&_r.containsKeyword(c)){let f=this.keywords[c];if(!f){let m=_r.getKeywordData(c);m.cache&&(f=e.keywords[c]),f=f||_r.getKeyword(c,e),m.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+n-1]!=="."&&(o=o.substring(0,u.index+n)+p+o.substring(u.index+c.length+n),n+=p.length-c.length),this.getIncludeByName(p)===void 0&&_r.contains(p)&&e.include(_r.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=pG.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match($w);if(a){let n=0;for(;n<a.length;){let o=a[n++],l;o==="in"||o==="out"||o==="inout"?l=a[n++]:(l=o,o="");let h=a[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},fG=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,YM=class extends It{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||YM.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 a,n,o="",l=fG.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],a=l[2],o=l[3]):(a=this.src,n="f"),this.name=a,this.type=n,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)}},Ct=YM;Ct.PI="PI",Ct.PI2="PI2",Ct.RECIPROCAL_PI="RECIPROCAL_PI",Ct.RECIPROCAL_PI2="RECIPROCAL_PI2",Ct.LOG2="LOG2",Ct.EPSILON="EPSILON";var mG=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3155
|
+
`&&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 VM,xy=new Promise(e=>{VM=e}),qw=!1,cu;function J8(){if(qw)return;if(cu)return cu;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@0.9.503/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});VM(n),qw=!0}return cu=e(),cu}function Ip(e,t,i,r){let s,a,n;e.type==="PathGeometry"?(a=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(a={...e},n=[[]]);for(let h of n){let u=a;for(let c of h)u=u[c];for(s in u){let c=u[s];J6(c)&&(u[s]=t.getVariable(c,[r.uuid,"geometry",...h,s]))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let h=Zt.createFromState(a.shape,a.width,a.height);o.shape=h}else if(a.type==="NonParametricGeometry")a.data.groups&&a.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new VA().parse(a);else if(a.type==="SubdivGeometry"){let h=new sr(a,i);return h.data=e,h}else if(a.type==="TextGeometry")return new FM(a,t);let l;try{l=Kw(o)}catch(h){console.error(h)}if(!l){let h=Zt.createFromState(yp.defaultData(),100,100);o.shape=h,l=Kw(o)}return l}var $8=new me;function Fv(e,t,i,r){let s=e.position.array,a=e.normal.array,n=$8.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=a[u],l=a[u+1],h=a[u+2],a[u]=n[0]*o+n[4]*l+n[8]*h,a[u+1]=n[1]*o+n[5]*l+n[9]*h,a[u+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var du=new ai,il=new E,Ge;xy.then(e=>{Ge=e});var Yw=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Xw=new Uint32Array([0,1,2,3]),Qw=new Uint8Array([4]),sr=class extends Ue{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=fo.div(t,i);this.subdividedGeometry&&Fv(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Fv(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(il.fromArray(r));let a=il.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=sr.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new ta(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&&(sr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;du.setFromBufferAttribute(t),du.getCenter(i),e.boundingSphere.radius=i.distanceTo(du.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),du.getSize(il);let r={width:il.x,height:il.y,depth:il.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,a,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Ge.free_bvh(t),Ge.free_subdivision_surface(t));try{s=sr.allocate(e,r)}catch(l){console.error(l,e),s=sr.allocate({positionWASM:Yw,indexWASM:Xw,verticesPerFaceWASM:Qw},r)}if(Ge.set_destination_refinement_level(s,0),a=sr.buildLevel(s,!0,o),e.subdivisions>0)try{Ge.set_destination_refinement_level(s,e.subdivisions),n=sr.buildLevel(s,!1,o)}catch{try{Ge.set_destination_refinement_level(s,e.subdivisions-1),n=sr.buildLevel(s,!1,o)}catch{n=null}}else n=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:n}}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=e.shape!==void 0||e.path!==void 0?t.geometry:Ip(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let a,n,o,l;({positions:a,triIndices:l}=lf(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let u=e.radialSegments*e.heightSegments*3*2,c=u+e.radialSegments*3;h=[u,c]}return{indices:n,verticesPerFace:o}=jM(a,l,r,h),{positions:a,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,s,a=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=Yw,r=Xw,s=Qw);let o=i.length,l=r.length,h=s.length,u=i.length+a.length+n.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,m=Ge._malloc(d),g=new Float32Array(Ge.HEAPF32.buffer,m,u),v=new Uint32Array(Ge.HEAPU32.buffer,m+p,c);g.set(i,0),g.set(a,i.length),g.set(n,i.length+a.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new me().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?Ge.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Ge.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Ge._free(m),x}static buildLevel(e,t,i,r,s){let a=s?Ge.get_mesh_data2(e,t?Ge.Level.CONTROL:Ge.Level.REFINED,i,s.elements):Ge.get_mesh_data(e,t?Ge.Level.CONTROL:Ge.Level.REFINED,i),n=8,o=Ge.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,4+4),h=0,u=Ge.HEAPU32[o[h]>>2],c=Ge.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Ge.HEAPU32[o[h]>>2],p=Ge.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Ge.HEAPU32[o[h]>>2],m=Ge.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=Ge.HEAPU32[o[h]>>2],v=Ge.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let y=new Ue;if(y.setIndex(new Pl(v,1)),y.setAttribute("position",new Te(c,3)),y.setAttribute("normal",new Te(p,3)),t){y.setAttribute("faceMap",new Pl(m,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ze(x,4))}return Ge.free_mesh_data(a),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,Ge.free_mesh_data(a)}static freeSubdivPointer(e){Ge.free_bvh(e),Ge.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Ge.get_wireframe_data_for_base_level(e),s=4,a=Ge.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,2+2),o=0,l=Ge.HEAPU32[a[o]>>2],h=Ge.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let u=Ge.HEAPU32[a[o]>>2],c=Ge.HEAPU32.subarray(u>>2,(u>>2)+n[o]);if(t===void 0){let d=new Ue;d.setAttribute("position",new Te(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Ze(p,3)),d.setIndex(new Pl(c,1)),Ge.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Ge.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Ge.set_destination_refinement_level(e,t);let s=i?Ge.get_topological_data2(e,r?Ge.Level.CONTROL:Ge.Level.REFINED,i.elements):Ge.get_topological_data(e,r?Ge.Level.CONTROL:Ge.Level.REFINED),a=6,n=Ge.HEAPU32.subarray(s>>2,(s>>2)+a),o=n.subarray(3,3+3),l=0,h=Ge.HEAPU32[n[l]>>2],u=new Float32Array(Ge.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Ge.HEAPU32[n[l]>>2],d=new Uint32Array(Ge.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Ge.HEAPU32[n[l]>>2],f=new Uint8Array(Ge.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Ge.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},Zw=["getX","getY","getZ"];function lf(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],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[Zw[d]](u)*o)},`;if(c in i)a.push(i[c]);else{for(let d=0;d<3;d++)n.push(e[Zw[d]](u));i[c]=s,a.push(s),s++}}let l=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||l.push(a[h],a[h+1],a[h+2]);return{positions:n,triIndices:l}}var uu=new E,km=new E,Nm=new E,Um=new E;function jM(e,t,i,r){let s=[],a=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let d=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let c=0;if(u<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),s.push(c++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),s.push(c++);return a.push(c),{indices:s,verticesPerFace:a}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){uu.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),km.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),Nm.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),Um.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),km.sub(uu).normalize(),Nm.sub(uu).normalize(),Um.sub(uu).normalize();let l=km.cross(Nm).dot(Um);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:o>=r[u]&&o<r[u+1])?(s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),a.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],u=0;for(let c=0,d=0;c<e.length;c+=3,d++)e[c+2]===0&&(l.push(d),u++),e[c+2]===n&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),a.push(u,u)}return{indices:s,verticesPerFace:a}}var Ea={};fT(Ea,{calcBoolean:()=>sG,calcBooleanTopological:()=>rG,freeMeshSet:()=>lG,getMeshSet:()=>aG,hasOpenEdges:()=>nG,transformMeshSet:()=>oG});var GM,eG=new Promise(e=>{GM=e}),pu;function tG(){if(pu)return pu;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@0.9.503/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});GM(n)}return pu=e(),pu}var ht,Fl;eG.then(e=>ht=e);function iG(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:a,triIndices:n}=lf(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=jM(a,n,e);o=h.length,r=[];for(let u=0,c=0;u<o;u++){r.push(h[u]);for(let d=0;d<h[u];d++)r.push(l[c++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,u=0;u<r.length;)r[u++]=3,o++,r[u++]=n[h++],r[u++]=n[h++],r[u++]=n[h++]}return{positions:a,faceIndices:r,nFaces:o}}function HM(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,a=ht._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(ht.HEAPU32.buffer,a,t):new Float32Array(ht.HEAPF32.buffer,a,t)).set(e,0),a}function WM(e){switch(e){case 0:return ht.OP.UNION;case 1:return ht.OP.INTERSECTION;case 2:return ht.OP.A_MINUS_B;case 3:return ht.OP.B_MINUS_A;case 4:return ht.OP.SYMMETRIC_DIFFERENCE;case 5:return ht.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function rG(e,t){Fl===void 0&&(Fl=ht.init_csg());let i=HM(e),r=ht.csg_calc_topological(Fl,i,e.length,WM(t));ht._free(i);let s=6,a=ht.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(3,3+3),o=0,l=ht.HEAPU32[a[o]>>2],h=new Float32Array(ht.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let u=ht.HEAPU32[a[o]>>2],c=new Uint32Array(ht.HEAPU32.subarray(u>>2,(u>>2)+n[o]));o++;let d=ht.HEAPU32[a[o]>>2],p=new Uint8Array(ht.HEAPU32.subarray(d>>2,(d>>2)+n[o]));return ht.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function sG(e,t,i,r){Fl===void 0&&(Fl=ht.init_csg());let s=HM(e),a=ht.csg_calc(Fl,s,e.length,r,WM(t));ht._free(s);let n=5,o=ht.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,2+3),h=0,u=ht.HEAPU32[o[h]>>2],c=ht.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=ht.HEAPU32[o[h]>>2],p=ht.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Te(c,3)),i.setAttribute("normal",new Te(p,3));let m=ht.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Tr),i.boundingSphere.radius=-1,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ht.free_mesh_data(a),f}function aG(e,t,i){if(ht===void 0)return-1;let r,s,a;if(t&&e.userData.positions!==void 0){let g=e.userData;a=g.verticesPerFace.length,r=g.positions,s=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+a);for(let v=0,y=0,x=0;v<g.verticesPerFace.length;v++){s[x++]=g.verticesPerFace[v];for(let b=0;b<g.verticesPerFace[v];b++)s[x++]=g.indices[y++]}}else({positions:r,faceIndices:s,nFaces:a}=iG(e,t,i));let n=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=ht._malloc(u),f=new Float32Array(ht.HEAPF32.buffer,p,l),m=new Uint32Array(ht.HEAPU32.buffer,p+c,h);return f.set(r,0),m.set(s,0),ht.get_csg_mesh(p,n,p+c,o,a)}function nG(e){return ht.has_open_edges(e)}function oG(e,t){ht.transform_csg_mesh(e,t.elements)}function lG(e){ht.free_csg_mesh(e)}var hG={ConeGeometry:Dj,CubeGeometry:Pj,CylinderGeometry:yM,DodecahedronGeometry:Oj,EllipseGeometry:yy,HelixGeometry:c8,IcosahedronGeometry:d8,LatheGeometry:u8,NonParametricGeometry:x8,PolygonGeometry:BM,PyramidGeometry:b8,RectangleGeometry:zM,SphereGeometry:S8,PlaneGeometry:A8,BackdropGeometry:M8,StarGeometry:kM,TextFrameGeometry:C8,TorusGeometry:T8,TorusKnotGeometry:P8,TriangleGeometry:I8,PathGeometry:q8,VectorGeometry:Do},Kw=e=>hG[e.type].create(e);function rl(e){return e!==null&&"booleanOp"in e}var qM=class extends uy(hr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new me}updateVisible(e){super.updateVisible(e),this.visible=!rl(this.parent)&&this.visible,rl(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ea.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rl(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof qM&&(e.freeBooleanPointer(),rl(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&rl(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),rl(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},fu=new ai;function by(e,t=0,i=e.count,r,s){let a=1/0,n=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<a&&(a=d),p<n&&(n=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}fu.min.set(a,n,o),fu.max.set(l,h,u),fu.getCenter(r),fu.getSize(s).multiplyScalar(.5)}var cG=new Ue,dG=new Kc,Dr=class extends qM{constructor(e,t){super(cG,dG),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?by(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},Jw=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}},On=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=Le.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,a){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 On&&(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}},uG=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}},_r=new uG,It=class extends On{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=Le.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let a=e.getNodeData(i),n=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return a.name=a.name||super.build(e,t,i),a.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||a.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,a.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,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}},Pr=class extends It{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,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,a):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,s,a,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,s,a,this.getLabel())),e.format(n.fragment.name,r,t))}},ki=class extends Pr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof F?e:new F(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,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},Zr=class extends Pr{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,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},Cr=class extends Ve{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],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))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(a))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}},Ca=class extends Pr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof Cr?e:new Cr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},pG=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,$w=/[a-z_0-9]+/gi,Se=class extends It{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 a,n=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(;a=$w.exec(this.src);)l.push(a);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&&_r.containsKeyword(c)){let f=this.keywords[c];if(!f){let m=_r.getKeywordData(c);m.cache&&(f=e.keywords[c]),f=f||_r.getKeyword(c,e),m.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+n-1]!=="."&&(o=o.substring(0,u.index+n)+p+o.substring(u.index+c.length+n),n+=p.length-c.length),this.getIncludeByName(p)===void 0&&_r.contains(p)&&e.include(_r.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=pG.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match($w);if(a){let n=0;for(;n<a.length;){let o=a[n++],l;o==="in"||o==="out"||o==="inout"?l=a[n++]:(l=o,o="");let h=a[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},fG=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,YM=class extends It{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||YM.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 a,n,o="",l=fG.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],a=l[2],o=l[3]):(a=this.src,n="f"),this.name=a,this.type=n,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)}},Ct=YM;Ct.PI="PI",Ct.PI2="PI2",Ct.RECIPROCAL_PI="RECIPROCAL_PI",Ct.RECIPROCAL_PI2="RECIPROCAL_PI2",Ct.LOG2="LOG2",Ct.EPSILON="EPSILON";var mG=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3156
3156
|
)*?)}`,"gim"),gG=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),XM=class extends It{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=mG.exec(e);if(t){let i=t[2],r;for(;r=gG.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},wy=class extends It{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)}};_r.addKeyword("uv",function(){return new wy});_r.addKeyword("uv2",function(){return new wy(1)});var xl=class extends It{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??xl.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case ea:return["Linear"];case it:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=xl.Nodes[this.method],a=e.include(s);if(a===xl.LINEAR_TO_LINEAR)return e.format(i,r,t);if(s.inputs?.length===2){let n=this.factor.build(e,"f");return e.format(a+"( "+i+", "+n+" )",r,t)}else return e.format(a+"( "+i+" )",r,t)}fromEncoding(e){let t=xl.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=xl.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Ks=xl;Ks.Nodes={LinearToLinear:new Se(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3157
3157
|
`)),sRGBToLinear:new Se(["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(`
|
|
3158
3158
|
`)),LinearTosRGB:new Se(["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(`
|
|
@@ -6267,7 +6267,7 @@ property scaling ${e.scaling.method}
|
|
|
6267
6267
|
property quaternion ${e.quaternion.method}`;if(e.harmonics&&e.harmonics.length>0)for(let _=0;_<e.harmonics.length;_++)r=`${r}
|
|
6268
6268
|
property harmonics_${_} ${e.harmonics[_].method}`;r=`${r}
|
|
6269
6269
|
end_header
|
|
6270
|
-
`;let s=new TextEncoder().encode(r),a=i*2*4,n=e.xyz.quantized.data.buffer.byteLength,o=e.xyz instanceof Yt?a:0,l=e.color.quantized.data.buffer.byteLength,h=e.color instanceof Yt?a:0,u=e.opacity.quantized.data.buffer.byteLength,c=e.opacity instanceof Yt?a:0,d=e.scaling.quantized.data.buffer.byteLength,p=e.scaling instanceof Yt?a:0,f=e.quaternion.quantized.data.buffer.byteLength,m=e.quaternion instanceof Yt?a:0,g=e.variableChunkSize?Uint16Array.from(e.variableChunkSize):void 0,v=g?g.byteLength:0,y=s.byteLength+v+n+o+l+h+u+c+d+p+f+m,x=0,b=0;if(e.harmonics&&e.harmonics.length>0)for(let _=0;_<e.harmonics.length;_++)x+=e.harmonics[_].quantized.data.buffer.byteLength,b+=e.harmonics[_]instanceof Yt?a:0;x=0,b=0,y+=x+b;let w=new Uint8Array(y),A=0;if(w.set(s,A),A+=s.byteLength,v>0&&(w.set(new Uint8Array(g.buffer),A),A+=v),e.xyz instanceof Yt&&(w.set(new Uint8Array(e.xyz.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.xyz.quantized.data.buffer),A),A+=n,e.color instanceof Yt&&(w.set(new Uint8Array(e.color.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.color.quantized.data.buffer),A),A+=l,e.opacity instanceof Yt&&(w.set(new Uint8Array(e.opacity.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.opacity.quantized.data.buffer),A),A+=u,e.scaling instanceof Yt&&(w.set(new Uint8Array(e.scaling.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.scaling.quantized.data.buffer),A),A+=d,e.quaternion instanceof Yt&&(w.set(new Uint8Array(e.quaternion.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.quaternion.quantized.data.buffer),A),A+=f,x>0&&e.harmonics&&e.harmonics.length>0)for(let _=0;_<e.harmonics.length;_++){let S=e.harmonics[_];S instanceof Yt&&(w.set(new Uint8Array(S.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(S.quantized.data.buffer),A),A+=S.quantized.data.byteLength}return new s0(w.buffer)}},VW="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL",bn=class{};ir(bn,"DepthMapRange",1<<16),ir(bn,"MemoryPageSize",65536),ir(bn,"BytesPerFloat",4),ir(bn,"BytesPerInt",4);function jW(e){let t,i,r,s,a,n,o,l,h,u,c,d,p,f,m,g;function v(T){let D=new Float64Array(u,n,16);for(let
|
|
6270
|
+
`;let s=new TextEncoder().encode(r),a=i*2*4,n=e.xyz.quantized.data.buffer.byteLength,o=e.xyz instanceof Yt?a:0,l=e.color.quantized.data.buffer.byteLength,h=e.color instanceof Yt?a:0,u=e.opacity.quantized.data.buffer.byteLength,c=e.opacity instanceof Yt?a:0,d=e.scaling.quantized.data.buffer.byteLength,p=e.scaling instanceof Yt?a:0,f=e.quaternion.quantized.data.buffer.byteLength,m=e.quaternion instanceof Yt?a:0,g=e.variableChunkSize?Uint16Array.from(e.variableChunkSize):void 0,v=g?g.byteLength:0,y=s.byteLength+v+n+o+l+h+u+c+d+p+f+m,x=0,b=0;if(e.harmonics&&e.harmonics.length>0)for(let _=0;_<e.harmonics.length;_++)x+=e.harmonics[_].quantized.data.buffer.byteLength,b+=e.harmonics[_]instanceof Yt?a:0;x=0,b=0,y+=x+b;let w=new Uint8Array(y),A=0;if(w.set(s,A),A+=s.byteLength,v>0&&(w.set(new Uint8Array(g.buffer),A),A+=v),e.xyz instanceof Yt&&(w.set(new Uint8Array(e.xyz.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.xyz.quantized.data.buffer),A),A+=n,e.color instanceof Yt&&(w.set(new Uint8Array(e.color.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.color.quantized.data.buffer),A),A+=l,e.opacity instanceof Yt&&(w.set(new Uint8Array(e.opacity.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.opacity.quantized.data.buffer),A),A+=u,e.scaling instanceof Yt&&(w.set(new Uint8Array(e.scaling.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.scaling.quantized.data.buffer),A),A+=d,e.quaternion instanceof Yt&&(w.set(new Uint8Array(e.quaternion.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(e.quaternion.quantized.data.buffer),A),A+=f,x>0&&e.harmonics&&e.harmonics.length>0)for(let _=0;_<e.harmonics.length;_++){let S=e.harmonics[_];S instanceof Yt&&(w.set(new Uint8Array(S.minmaxMatrix.data.buffer),A),A+=a),w.set(new Uint8Array(S.quantized.data.buffer),A),A+=S.quantized.data.byteLength}return new s0(w.buffer)}},VW="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL",bn=class{};ir(bn,"DepthMapRange",1<<16),ir(bn,"MemoryPageSize",65536),ir(bn,"BytesPerFloat",4),ir(bn,"BytesPerInt",4);function jW(e){let t,i,r,s,a,n,o,l,h,u,c,d,p,f,m,g;function v(T){let D=new Float64Array(u,n,16);for(let I=0;I<16;I++)D[I]=T[I];let P;if(r>1){t.exports.sortIndexes(s,a,h,n,o,l,d.DepthMapRange,r);let I=new Uint32Array(r);P=I.buffer,I.set(new Uint32Array(u,l,r))}else if(r===1){let I=new Uint32Array(r);I[0]=new Uint32Array(u,s,i)[0],P=I.buffer}else P=new ArrayBuffer(0);e.postMessage({sortDone:!0,indexesBuffer:P},[P])}function y(T,D,P){let I=new Float32Array(u,a,i*3);r=0;let R=new Uint32Array(u,s,i);for(let U=0;U<P.length-1;U++){let N=D[U],L=T[U].elements,W;N?.length>0&&(W=N.map(G=>G.type==="Box"?A(G):M(G)));for(let G=P[U];G<P[U+1];G++){let j=p[G*3],k=p[G*3+1],q=p[G*3+2];if(!W||b(j,k,q,W)){let H=1/(L[3]*j+L[7]*k+L[11]*q+L[15]);I[r*3]=(L[0]*j+L[4]*k+L[8]*q+L[12])*H,I[r*3+1]=(L[1]*j+L[5]*k+L[9]*q+L[13])*H,I[r*3+2]=(L[2]*j+L[6]*k+L[10]*q+L[14])*H,R[r]=G,r++}}}}function x(T,D){let P=[],I;D?.length>0&&(I=D.map(U=>U.type==="Box"?A(U):M(U)));let R=T.length;for(let U=0;U<R;U+=3){let N=T[U],L=T[U+1],W=T[U+2];b(N,L,W,I)===!1&&P.push(U/3)}return P}function b(T,D,P,I,R){return I[R==="Intersect"?"every":"some"](U=>{let N=w(T,D,P,U.invRotationMatrix,U.cropCenter);return Array.isArray(U)?S(N.x,N.y,N.z,U):C(N.x,N.y,N.z,U)})}function w(T,D,P,I,R){let U=T-R[0],N=D-R[1],L=P-R[2],W=1/(I[3]*U+I[7]*N+I[11]*L+I[15]);return{x:(I[0]*U+I[4]*N+I[8]*L+I[12])*W+R[0],y:(I[1]*U+I[5]*N+I[9]*L+I[13])*W+R[1],z:(I[2]*U+I[6]*N+I[10]*L+I[14])*W+R[2]}}function A(T){let D=T.cropSize[0]/2,P=T.cropSize[1]/2,I=T.cropSize[2]/2,R=[T.cropCenter[0]-D,T.cropCenter[1]-P,T.cropCenter[2]-I,T.cropCenter[0]+D,T.cropCenter[1]+P,T.cropCenter[2]+I],U=_(T.cropRotation);return Object.assign(R,{invRotationMatrix:U,cropCenter:T.cropCenter})}function _(T){let D=[],P=T[0]*Math.PI/180,I=T[1]*Math.PI/180,R=T[2]*Math.PI/180,U=Math.cos(P),N=Math.sin(P),L=Math.cos(I),W=Math.sin(I),G=Math.cos(R),j=Math.sin(R),k=U*G,q=U*j,H=N*G,Y=N*j;return D[0]=L*G,D[1]=-L*j,D[2]=W,D[4]=q+H*W,D[5]=k-Y*W,D[6]=-N*L,D[8]=Y-k*W,D[9]=H+q*W,D[10]=U*L,D[12]=0,D[13]=0,D[14]=0,D[3]=0,D[7]=0,D[11]=0,D[15]=1,D}function S(T,D,P,I){return T>=I[0]&&T<=I[3]&&D>=I[1]&&D<=I[4]&&P>=I[2]&&P<=I[5]}function M(T){let D=2/T.cropSize[0],P=2/T.cropSize[1],I=2/T.cropSize[2],R=_(T.cropRotation);return{invRadiusX:D,invRadiusY:P,invRadiusZ:I,cropCenter:T.cropCenter,invRotationMatrix:R}}function C(T,D,P,I){let R=(T-I.cropCenter[0])*I.invRadiusX,U=(D-I.cropCenter[1])*I.invRadiusY,N=(P-I.cropCenter[2])*I.invRadiusZ;return R*R+U*U+N*N<=1}e.onmessage=T=>{if(T.data.getCroppedIndexes){let D=new Uint32Array(x(new Float32Array(T.data.positions),T.data.crops)).buffer;e.postMessage({outOfBoundsIndexes:D},[D])}else if(T.data.positions)c=T.data.positions,p=new Float32Array(c),m=T.data.meshMatrixWorlds,g=T.data.cropsArray,f=T.data.meshIndexIntervals,y(m,g,f),e.postMessage({sortSetupComplete:!0});else if(T.data.sort||T.data.newMatrixWorlds||T.data.newCropsArray)(T.data.newMatrixWorlds||T.data.newCropsArray)&&(g=T.data.newCropsArray||g,m=T.data.newMatrixWorlds||m,y(m,g,f)),v(T.data.sort.view,T.data.sort.cameraPosition);else if(T.data.init){d=T.data.init.Constants,i=T.data.init.splatCount;let D=d.BytesPerInt,P=d.BytesPerFloat*3,I=new Uint8Array(T.data.init.sorterWasmBytes),R=D+P,U=i*R,N=i*d.BytesPerInt*2+d.DepthMapRange*d.BytesPerInt*2,L=d.MemoryPageSize*32,W=U+N+L,G=Math.floor(W/d.MemoryPageSize)+1,j={module:{},env:{memory:new WebAssembly.Memory({initial:G*2,maximum:G*3,shared:!0})}};WebAssembly.compile(I).then(k=>WebAssembly.instantiate(k,j)).then(k=>{t=k,s=0,a=i*D,n=a+i*P,h=n+16*d.BytesPerFloat*2,o=h+i*d.BytesPerInt,l=o+d.DepthMapRange*d.BytesPerInt,u=j.env.memory.buffer,e.postMessage({sortSetupPhase1Complete:!0})})}}}function GW(e){let t=new Worker(URL.createObjectURL(new Blob(["(",jW.toString(),")(self)"],{type:"application/javascript"}))),i=atob(VW),r=new Uint8Array(i.length);for(let s=0;s<i.length;s++)r[s]=i.charCodeAt(s);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:e,Constants:{BytesPerFloat:bn.BytesPerFloat,BytesPerInt:bn.BytesPerInt,DepthMapRange:bn.DepthMapRange,MemoryPageSize:bn.MemoryPageSize}}}),t}var ng=function(){let e=new Float32Array(1),t=new Int32Array(e.buffer);return function(i){return e[0]=i,t[0]}}(),HW=function(e,t,i,r){return e+(t<<8)+(i<<16)+(r<<24)},Eu=new F,Uu=class extends hr{constructor(e,t,i,r,s=!1,a=1,n,o){super(i,r),this.splatCount=t,this.meshIndexIntervals=n,this.meshMatrixWorlds=o,this.splatBuffers=e,this.geometry=i,this.material=r,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=s,this.devicePixelRatio=a,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,t,i=!1,r=1,s,a){let n=Uu.buildGeomtery(t),o=Uu.buildMaterial(s);return new Uu(e,t,n,o,i,r,s,a)}static buildMaterial(e){let t=`
|
|
6271
6271
|
precision highp float;
|
|
6272
6272
|
#include <common>
|
|
6273
6273
|
|
|
@@ -6421,9 +6421,9 @@ end_header
|
|
|
6421
6421
|
A = exp(A) * vColor.a;
|
|
6422
6422
|
gl_FragColor = vec4(color.rgb, A);
|
|
6423
6423
|
gVelocity = vec4(0.0); // so it is ignored by TAA
|
|
6424
|
-
}`,r={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new F},viewport:{type:"v2",value:new F},basisViewport:{type:"v2",value:new F},debugColor:{type:"v3",value:new Ve},covariancesTextureSize:{type:"v2",value:new F(1024,1024)},centersColorsTextureSize:{type:"v2",value:new F(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Lt({uniforms:r,vertexShader:t,fragmentShader:i,transparent:!0,alphaTest:1,blending:ho,depthTest:!0,depthWrite:!1,side:Sr})}static buildGeomtery(e){let t=new Ue;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),r=new Ze(i,3);t.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let s=new FA().copy(t),a=new Uint32Array(e),n=new SA(a,1,!1);return n.setUsage(_3),s.setAttribute("splatIndex",n),s.instanceCount=e,s}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,t=0,i=0;for(let r of this.splatBuffers){let s=r.nsplats;this.colors.subarray(e,e+s*4).set(r.colorsA),e+=s*4,this.centers.subarray(t,t+s*3).set(r.decoded.xyz.denormDequant().data),t+=s*3,this.covariances.subarray(i,i+s*6).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=s*6}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new F(4096,1024);for(;t.x*t.y*2<e*6;)t.y*=2;let i=new F(4096,1024);for(;i.x*i.y*4<e*4;)i.y*=2;let r,s;if(this.halfPrecisionCovariancesOnGPU){s=new Uint16Array(t.x*t.y*2);for(let u=0;u<this.covariances.length;u++)s[u]=Y4.toHalfFloat(this.covariances[u]);r=new pn(s,t.x,t.y,Hu,bo)}else s=new Float32Array(t.x*t.y*2),s.set(this.covariances),r=new pn(s,t.x,t.y,Hu,lr);r.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=r,this.material.uniforms.covariancesTextureSize.value.copy(t);let a=new Uint32Array(i.x*i.y*4);for(let u=0;u<e;u++){let c=u*4,d=u*3,p=u*4;a[p]=HW(this.colors[c],this.colors[c+1],this.colors[c+2],this.colors[c+3]),a[p+1]=ng(this.centers[d]),a[p+2]=ng(this.centers[d+1]),a[p+3]=ng(this.centers[d+2])}let n=new pn(a,i.x,i.y,iA,La);n.internalFormat="RGBA32UI",n.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=n,this.material.uniforms.centersColorsTextureSize.value.copy(i);let o=256*4,l=new Float32Array(256*16);for(let u=0;u<this.meshMatrixWorlds.length;u++)l.set(this.meshMatrixWorlds[u].elements,u*16);let h=new pn(l,o,1,Nr,lr);h.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=h,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:s,texture:r,size:t},centerColors:{data:a,texture:n,size:i},meshMatrixWorlds:{data:l,texture:h}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,i,r){this.splatCount>0&&(Eu.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Eu),this.material.uniforms.basisViewport.value.set(2/Eu.x,2/Eu.y),this.material.uniforms.focal.value.set(t,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}},WW=class{constructor(e={}){ir(this,"updateSplatMeshUniforms",function(){let t=new F;return function(){this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}()),ir(this,"updateView",function(){let t=new me,i=[],r=new E(0,0,-1),s=new E(0,0,-1),a=new E,n=new E;return function(o=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),h=this.cropsChanged();if(!o){s.set(0,0,-1).applyQuaternion(this.camera.quaternion);let c=!1,d=!1;if(s.dot(r)<=.95&&(c=!0),n.copy(this.camera.position).sub(a).length()>=1&&(d=!0),!c&&!d&&!l&&!h)return}a.copy(this.camera.position),r.copy(s),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),i[0]=this.camera.position.x,i[1]=this.camera.position.y,i[2]=this.camera.position.z;let u={sort:{view:t.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...h?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=u:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(u))}}()),this.scene=e.scene,this.currentPage=null,this.renderer=e.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let e=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=e?this:null}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new E().fromArray(e.position)),e.orientation&&(e.orientation=new $e().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let n=a.visible;a.traverseAncestors(o=>{n&&(n=o.visible)}),n&&t.push(a)}}),t.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=t.map(a=>a.matrixWorld.clone()),this.cropsArray=t.map(a=>a.data.crops.map(n=>n.data));let i=t.map(a=>new s0(new Uint8Array(a.data.buffer).buffer)),r=0,s=[0];for(let a of i)r+=a.getSplatCount(),s.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;t<this.meshMatrixWorlds.length;t++)e.set(this.meshMatrixWorlds[t].elements,t*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((t,i)=>t.equals(this.meshMatrixWorldsOld[i]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(t=>t.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{t.data.crops.forEach((r,s)=>{this.cropsArray[i][s]===void 0?(e=!0,this.cropsArray[i][s]=r.data):Object.entries(r.data).forEach(([a,n])=>{Array.isArray(n)&&n.some((o,l)=>o!==this.cropsArray[i][s][a][l])?(e=!0,this.cropsArray[i][s][a]=n):n!==this.cropsArray[i][s]?.[a]&&(e=!0,this.cropsArray[i][s][a]=n)})}),t.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new E,r=new $e,s=!1,a=1,n,o){this.splatMesh=Uu.buildMesh(e,t,s,a,n,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=t}setupSortWorker(e){this.sortWorker=GW(e),this.sortWorker.onmessage=t=>{t.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(t.data.indexesBuffer)),this.lastSortTime=t.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):t.data.sortCanceled?this.sortRunning=!1:t.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):t.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}},a0=new Kc;a0.wireframe=!0;var iS=new E,By=class extends _n{constructor(e,t){super(),this.data=e,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new RW,this.errorPage=new Cn("fdasfa",{...sh.defaultData,name:""}),this.invisibleObjects=new Gl("jflkdsafjasdifjaslk",{...Av.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=DW(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=TW(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Cn&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let a=r.children.indexOf(s);i.splice(0,0,a)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>y6(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===_h)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(),r.resetBBoxNeedsUpdate(),ys(r)&&Zs(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Zs(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),ys(i)&&(i.freeBooleanPointer(),r instanceof lh&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof Oy&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;s.children.splice(a,0,s.children.pop()),ys(i)&&(i.invalidateUpstreamBooleanData(),Zs(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof lh&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Cn&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{CW(s,t,i,{scene:this,shared:r}),s instanceof dr&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{Zs(r)&&r.recomputeBoolean(),r instanceof Xi&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){pt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{pt.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,a,n){if(e){let o=r.find(e);o&&o!==r&&s.forInstancesRec(l=>{l.data=Nc(l.data,h=>{let u=h.events.data(n.id),c=l.goUp(a);if(c){let d=[...C2(c.identity),e].join("-"),p=this.entityIdentityToEntity[d];if(p){let f=p.uuid,m=ar.zoom(u,t);m[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,s,a){e.forEach(n=>{n.data.type==="Transition"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a):n.data.type==="Animation"&&this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Hl&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=Nc(a.data,n=>{a.isInstanceRoot||(n.events.delete(r.id),s=!0)}).data}),s===!1)for(let a of Mp.list)this.rewriteActions(r.data.gameActions[a],["gameActions",a],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(s=>{if(s instanceof Hl&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(a=>{i.addClip(a)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Ry(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof Hl&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)pt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=s=>{for(let a of s.children){let n=a.cloner;if(pt.is(a)&&!a.raycastLock&&(a.visible||n?.object.data.visible))if(t===!0&&a.isInstanceRoot){let o=[];if(e.intersectObject(a,!0,o),o.length){let l=o[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let h=a.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(ys(a)||Qv(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),i0(a,e,i)),r(a)}};return r(this),i}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let a=s.cloner;pt.is(s)&&(s.visible||a?.object.data.visible)&&((ys(s)||Qv(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),i0(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)pt.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)pt.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)pt.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof dr&&i.data.type==="Mesh"&&i.data.geometry.type==="TextGeometry"&&i.data.geometry.font===e){let r=i.geometry,s=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(s);let a=i.invalidateDownstreamBooleanData();Zs(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Hc.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)pt.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,a){let n={scene:this,shared:a},o=Ly(e,t,n);return o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,a)),o.updateState(t,n),o instanceof dr&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{if(l instanceof dr&&l.isSkinnedMesh){let h=l.dataPatched;if(h.bones&&h.boneInverses){let u=h.bones.map(p=>this.find(p)),c=h.boneInverses.map(p=>new me().fromArray(p)),d=new E0(u,c);l.bind(d,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,s=e.length;r<s;++r){let{id:a,recursive:n}=e[r],o=this.find(a),l=n?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new ai;return i.setFromPoints(t),i.getCenter(iS),iS}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e)?.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Dr)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof Pn&&e(t.material[i]);else t.material instanceof Pn&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof Xi&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(e){this.splatViewer=new WW({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}},Fu=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},qW=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return XW(Math.atan2(r,i))},YW=(e,t,i)=>{let r={x:0,y:0};return i=n0(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},n0=e=>e*(Math.PI/180),XW=e=>e*(180/Math.PI),QW=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,og=new Map,rS=e=>{og.has(e)&&clearTimeout(og.get(e)),og.set(e,setTimeout(e,100))},zp=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.addEventListener?e.addEventListener(s,i,!1):e.attachEvent&&e.attachEvent(s,i)},sS=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.removeEventListener?e.removeEventListener(s,i):e.detachEvent&&e.detachEvent(s,i)},jE=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),aS=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},o0=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},zy=(e,t,i)=>{let r=GE(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let a="";for(let n=0,o=t.length;n<o;n+=1)a+=t[n]+" "+i+", ";r[s]=a.slice(0,-2)}return r},ZW=(e,t)=>{let i=GE(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},GE=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},lg=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},KW=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},l0=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},JW=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(HE="ontouchstart"in window,WE=!!window.PointerEvent,qE=!!window.MSPointerEvent);var HE,WE,qE,tc={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Dl,qc={};WE?Dl=tc.pointer:qE?Dl=tc.MSPointer:HE?(Dl=tc.touch,qc=tc.mouse):Dl=tc.mouse;function Po(){}Po.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]=i._handlers_[s]||[],i._handlers_[s].push(t);return i};Po.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};Po.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]&&i._handlers_[s].length&&i._handlers_[s].forEach(function(n){n.call(i,{type:s,target:i},t)})};Po.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=KW(t.options,e))};Po.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},zp(e,Dl[t],i._domHandlers_[t]),qc[t]&&zp(e,qc[t],i._domHandlers_[t]),i};Po.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},sS(e,Dl[t],i._domHandlers_[t]),qc[t]&&sS(e,qc[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var ky=Po;function Mi(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Mi.id,Mi.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Mi.prototype=new ky;Mi.constructor=Mi;Mi.id=0;Mi.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Mi.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=ZW("borderRadius","50%"),i=zy("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},lg(r.el,i),this.options.shape==="circle"&&lg(r.back,t),lg(r.front,t),this.applyStyles(r),this};Mi.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};Mi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Mi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Mi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Mi.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};Mi.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};Mi.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",s={};s.front=zy("transition",["top","left"],r);var a={front:{}};a.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(a),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};Mi.prototype.restCallback=function(){var e=this,t={};t.front=zy("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};Mi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Mi.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,s,a,n;if(t>i&&t<i*3&&!e.lockX?s="up":t>-i&&t<=i&&!e.lockY?s="left":t>-i*3&&t<=-i&&!e.lockX?s="down":e.lockY||(s="right"),e.lockY||(t>-r&&t<r?a="left":a="right"),e.lockX||(t>0?n="up":n="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:a,y:n,angle:s},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+a,e),h.y||this.trigger("plain:"+n,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var $W=Mi;function ni(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=ni.id,ni.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}ni.prototype=new ky;ni.constructor=ni;ni.id=0;ni.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,s=t.length;r<s;r+=1)if(t[r].identifier===i)return t[r];return!1}};ni.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};ni.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};ni.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,s={},a=i.options,n={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)s={x:e.x-n.x,y:e.y-n.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",a.zone.appendChild(o);var l=o.getBoundingClientRect();a.zone.removeChild(o),s=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new $W(i,{color:a.color,size:a.size,threshold:a.threshold,fadeTime:a.fadeTime,dataOnly:a.dataOnly,restJoystick:a.restJoystick,restOpacity:a.restOpacity,mode:a.mode,identifier:t,position:e,zone:a.zone,frontPosition:{x:0,y:0},shape:a.shape});return a.dataOnly||(o0(h.ui.el,s),o0(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};ni.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};ni.prototype.bindNipple=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};ni.prototype.pressureFn=function(e,t,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var a=e.force||e.pressure||e.webkitForce||0;a!==s&&(t.trigger("pressure",a),r.trigger("pressure "+t.identifier+":pressure",a),s=a)}.bind(r),100)};ni.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=jE(e),t.updateBox();var s=function(a){t.actives.length<i.maxNumberOfNipples?t.processOnStart(a):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(l){return l.identifier===n})<0){var o=[e[0]];o.identifier=n,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(a))};return l0(e,s),t.manager.bindDocument(),!1};ni.prototype.processOnStart=function(e){var t=this,i=t.options,r,s=t.manager.getIdentifier(e),a=e.force||e.pressure||e.webkitForce||0,n={x:e.pageX,y:e.pageY},o=t.getOrCreate(s,n);o.identifier!==s&&t.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(u){u.trigger("start",u),t.trigger("start "+u.id+":start",u),u.show(),a>0&&t.pressureFn(e,u,u.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=Fu(n,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};ni.prototype.getOrCreate=function(e,t){var i=this,r=i.options,s;return/(semi|static)/.test(r.mode)?(s=i.idles[0],s?(i.idles.splice(0,1),s):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(s=i.createNipple(t,e),s)};ni.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=t.manager.scroll;if(!QW(e)){this.processOnEnd(e);return}if(!s){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var n=s.el.getBoundingClientRect();s.position={x:a.x+n.left,y:a.y+n.top}}s.identifier=r;var o=s.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h=Fu(l,s.position),u=qW(l,s.position),c=n0(u),d=h/o,p={distance:h,position:l},f,m;if(s.options.shape==="circle"?(f=Math.min(h,o),m=YW(s.position,f,u)):(m=JW(l,s.position,o),f=Fu(m,s.position)),i.follow){if(h>o){let x=l.x-m.x,b=l.y-m.y;s.position.x+=x,s.position.y+=b,s.el.style.top=s.position.y-(t.box.top+a.y)+"px",s.el.style.left=s.position.x-(t.box.left+a.x)+"px",h=Fu(l,s.position)}}else l=m,h=f;var g=l.x-s.position.x,v=l.y-s.position.y;s.frontPosition={x:g,y:v},i.dataOnly||o0(s.ui.front,s.frontPosition);var y={identifier:s.identifier,position:l,force:d,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:c,degree:u},vector:{x:g/o,y:-v/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};y=s.computeDirection(y),y.angle={radian:n0(180-u),degree:180-u},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};ni.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=t.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),t.trigger("removed "+s.id+":removed",s),t.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(t.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),t.trigger("end "+s.id+":end",s),t.ids.indexOf(s.identifier)>=0&&t.ids.splice(t.ids.indexOf(s.identifier),1),t.actives.indexOf(s)>=0&&t.actives.splice(t.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?t.idles.push(s):t.nipples.indexOf(s)>=0&&t.nipples.splice(t.nipples.indexOf(s),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[a.id]=a.identifier))};ni.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};ni.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()};var eq=ni;function Oi(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=aS(),t.config(e),t.prepareCollections();var i=function(){var s;t.collections.forEach(function(a){a.forEach(function(n){s=n.el.getBoundingClientRect(),n.position={x:t.scroll.x+s.left,y:t.scroll.y+s.top}})})};if(typeof window>"u")return t.collections;zp(window,"resize",function(){rS(i)});var r=function(){t.scroll=aS()};return zp(window,"scroll",function(){rS(r)}),t.collections}Oi.prototype=new ky;Oi.constructor=Oi;Oi.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};Oi.prototype.create=function(e){return this.createCollection(e)};Oi.prototype.createCollection=function(e){var t=this,i=new eq(t,e);return t.bindCollection(i),t.collections.push(i),i};Oi.prototype.bindCollection=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};Oi.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};Oi.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Oi.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};Oi.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};Oi.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};Oi.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};Oi.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};Oi.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=jE(t);var a=function(o,l,h){h.ids.indexOf(l)>=0&&(h[s](o),o._found_=!0)},n=function(o){r=i.getIdentifier(o),l0(i.collections,a.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return l0(t,n),!1};Oi.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};Oi.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1)};var tq=Oi,nS=new tq,iq={create:function(e){return nS.create(e)},factory:nS},YE=new Map,Mc=new Map,oo=class{constructor(e,t,i,r){this.data=t;let{audio:s,volume:a,delay:n,loop:o}=t;if(!s)throw new Error("Missing property");let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new mc({src:l,volume:a,delay:n,loop:o}),Mc.has(i.uuid)?Mc.get(i.uuid).push(this):Mc.set(i.uuid,[this]),YE.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},h0=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=YE.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=Mc.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...Mc.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},XE=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new oo(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new h0(t);else throw new Error("Missing property")}dispatchBasic(){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof oo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof oo?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof oo&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}},rq="text/plain",sq="us-ascii",oS=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),aq=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:s,hash:a}=i.groups,n=r.split(";");a=t?"":a;let o=!1;n[n.length-1]==="base64"&&(n.pop(),o=!0);let l=(n.shift()||"").toLowerCase(),h=[...n.map(u=>{let[c,d=""]=u.split("=").map(p=>p.trim());return c==="charset"&&(d=d.toLowerCase(),d===sq)?"":`${c}${d?`=${d}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==rq)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${a?`#${a}`:""}`};function nq(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return aq(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let a=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,n=0,o="";for(;;){let h=a.exec(r.pathname);if(!h)break;let u=h[0],c=h.index,d=r.pathname.slice(n,c);o+=d.replace(/\/{2,}/g,"/"),o+=u,n=c+u.length}let l=r.pathname.slice(n,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let a=r.pathname.split("/"),n=a[a.length-1];oS(n,t.removeDirectoryIndex)&&(a=a.slice(0,-1),r.pathname=a.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let a of[...r.searchParams.keys()])oS(a,t.removeQueryParameters)&&r.searchParams.delete(a);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var oq=class{constructor({url:e,context:t},i,r,s){if(this.controlsManager=i,this.shared=r,this.condition=s,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:nq(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){if(gi(this.shared,this.condition)===!1)return!1;E2?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(Ye[0]),x6())}},QE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=a=>{this.timeoutIdQueue.shift();let n=this.page.scene.find(a);if(n===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=o?n.dataPatched.physics?.fusedBody:!0;if(n.cloner){for(let h of n.cloner.children)l?(h.playModeVisible=!1,h.rigidBody&&n.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0),h.bvhGeometry&&(h.bvhGeometry=void 0)):this.clone===void 0||this.clone===h?(h.playModeVisible=!1,h.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0)):h.playModeVisible===void 0&&(h.playModeVisible=!0);(l||this.clone===void 0||this.clone===!1)&&(n.visible=!1,n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0))}else n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0),n.visible=!1;o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.rigidBody!==void 0),n.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...e.objects]}dispatch(e){if(gi(this.shared,this.condition)===!1)return!1;this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(gi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},ZE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.shared=i,this.eventManager=r,this.condition=s,this.shared=i}dispatch(){if(gi(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Yy(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},KE={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},Ny={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},lq=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],kp={CSS:{},springs:{}};function Ss(e,t,i){return Math.min(Math.max(e,t),i)}function Ec(e,t){return e.indexOf(t)>-1}function hg(e,t){return e.apply(null,t)}var Qe={arr:function(e){return Array.isArray(e)},obj:function(e){return Ec(Object.prototype.toString.call(e),"Object")},pth:function(e){return Qe.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||Qe.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return Qe.hex(e)||Qe.rgb(e)||Qe.hsl(e)},key:function(e){return!KE.hasOwnProperty(e)&&!Ny.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function JE(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function $E(e,t){var i=JE(e),r=Ss(Qe.und(i[0])?1:i[0],.1,100),s=Ss(Qe.und(i[1])?100:i[1],.1,100),a=Ss(Qe.und(i[2])?10:i[2],.1,100),n=Ss(Qe.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=a/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,u=1,c=l<1?(l*o+-n)/h:-n+o;function d(f){var m=t?t*f/1e3:f;return l<1?m=Math.exp(-m*l*o)*(u*Math.cos(h*m)+c*Math.sin(h*m)):m=(u+c*m)*Math.exp(-m*o),f===0||f===1?f:1-m}function p(){var f=kp.springs[e];if(f)return f;for(var m=1/6,g=0,v=0;;)if(g+=m,d(g)===1){if(v++,v>=16)break}else v=0;var y=g*m*1e3;return kp.springs[e]=y,y}return t?d:p}function hq(e){return e===void 0&&(e=10),function(t){return Math.ceil(Ss(t,1e-6,1)*e)*(1/e)}}var cq=function(){var e=11,t=1/(e-1);function i(u,c){return 1-3*c+3*u}function r(u,c){return 3*c-6*u}function s(u){return 3*u}function a(u,c,d){return((i(c,d)*u+r(c,d))*u+s(c))*u}function n(u,c,d){return 3*i(c,d)*u*u+2*r(c,d)*u+s(c)}function o(u,c,d,p,f){var m,g,v=0;do g=c+(d-c)/2,m=a(g,p,f)-u,m>0?d=g:c=g;while(Math.abs(m)>1e-7&&++v<10);return g}function l(u,c,d,p){for(var f=0;f<4;++f){var m=n(c,d,p);if(m===0)return c;var g=a(c,d,p)-u;c-=g/m}return c}function h(u,c,d,p){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var f=new Float32Array(e);if(u!==c||d!==p)for(var m=0;m<e;++m)f[m]=a(m*t,u,d);function g(v){for(var y=0,x=1,b=e-1;x!==b&&f[x]<=v;++x)y+=t;--x;var w=(v-f[x])/(f[x+1]-f[x]),A=y+w*t,_=n(A,u,d);return _>=.001?l(v,A,u,d):_===0?A:o(v,y,y+t,u,d)}return function(v){return u===c&&d===p||v===0||v===1?v:a(g(v),c,p)}}return h}(),eC=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var s,a=4;r<((s=Math.pow(2,--a))-1)/11;);return 1/Math.pow(4,3-a)-7.5625*Math.pow((s*3-2)/22-r,2)}},Elastic:function(r,s){r===void 0&&(r=1),s===void 0&&(s=.5);var a=Ss(r,1,10),n=Ss(s,.1,2);return function(o){return o===0||o===1?o:-a*Math.pow(2,10*(o-1))*Math.sin((o-1-n/(Math.PI*2)*Math.asin(1/a))*(Math.PI*2)/n)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,s){t[r]=function(){return function(a){return Math.pow(a,s+2)}}}),Object.keys(t).forEach(function(r){var s=t[r];e["easeIn"+r]=s,e["easeOut"+r]=function(a,n){return function(o){return 1-s(a,n)(1-o)}},e["easeInOut"+r]=function(a,n){return function(o){return o<.5?s(a,n)(o*2)/2:1-s(a,n)(o*-2+2)/2}}}),e}();function Uy(e,t){if(Qe.fnc(e))return e;var i=e.split("(")[0],r=eC[i],s=JE(e);switch(i){case"spring":return $E(e,t);case"cubicBezier":return hg(cq,s);case"steps":return hg(hq,s);default:return hg(r,s)}}function tC(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function df(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],a=0;a<i;a++)if(a in e){var n=e[a];t.call(r,n,a,e)&&s.push(n)}return s}function uf(e){return e.reduce(function(t,i){return t.concat(Qe.arr(i)?uf(i):i)},[])}function lS(e){return Qe.arr(e)?e:(Qe.str(e)&&(e=tC(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function Fy(e,t){return e.some(function(i){return i===t})}function Vy(e){var t={};for(var i in e)t[i]=e[i];return t}function c0(e,t){var i=Vy(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function pf(e,t){var i=Vy(e);for(var r in t)i[r]=Qe.und(e[r])?t[r]:e[r];return i}function dq(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function uq(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,u){return l+l+h+h+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),s=parseInt(r[1],16),a=parseInt(r[2],16),n=parseInt(r[3],16);return"rgba("+s+","+a+","+n+",1)"}function pq(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,s=parseInt(t[3],10)/100,a=t[4]||1;function n(d,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?d+(p-d)*6*f:f<1/2?p:f<2/3?d+(p-d)*(2/3-f)*6:d}var o,l,h;if(r==0)o=l=h=s;else{var u=s<.5?s*(1+r):s+r-s*r,c=2*s-u;o=n(c,u,i+1/3),l=n(c,u,i),h=n(c,u,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+a+")"}function fq(e){if(Qe.rgb(e))return dq(e);if(Qe.hex(e))return uq(e);if(Qe.hsl(e))return pq(e)}function Ua(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function mq(e){if(Ec(e,"translate")||e==="perspective")return"px";if(Ec(e,"rotate")||Ec(e,"skew"))return"deg"}function d0(e,t){return Qe.fnc(e)?e(t.target,t.id,t.total):e}function Js(e,t){return e.getAttribute(t)}function jy(e,t,i){var r=Ua(t);if(Fy([i,"deg","rad","turn"],r))return t;var s=kp.CSS[t+i];if(!Qe.und(s))return s;var a=100,n=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(n),n.style.position="absolute",n.style.width=a+i;var l=a/n.offsetWidth;o.removeChild(n);var h=l*parseFloat(t);return kp.CSS[t+i]=h,h}function iC(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?jy(e,s,i):s}}function Gy(e,t){if(Qe.dom(e)&&!Qe.inp(e)&&(Js(e,t)||Qe.svg(e)&&e[t]))return"attribute";if(Qe.dom(e)&&Fy(lq,t))return"transform";if(Qe.dom(e)&&t!=="transform"&&iC(e,t))return"css";if(e[t]!=null)return"object"}function rC(e){if(Qe.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,s;s=i.exec(t);)r.set(s[1],s[2]);return r}}function gq(e,t,i,r){var s=Ec(t,"scale")?1:0+mq(t),a=rC(e).get(t)||s;return i&&(i.transforms.list.set(t,a),i.transforms.last=t),r?jy(e,a,r):a}function Hy(e,t,i,r){switch(Gy(e,t)){case"transform":return gq(e,t,r,i);case"css":return iC(e,t,i);case"attribute":return Js(e,t);default:return e[t]||0}}function Wy(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Ua(e)||0,s=parseFloat(t),a=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+a+r;case"-":return s-a+r;case"*":return s*a+r}}function sC(e,t){if(Qe.col(e))return fq(e);if(/\s/g.test(e))return e;var i=Ua(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function qy(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function vq(e){return Math.PI*2*Js(e,"r")}function yq(e){return Js(e,"width")*2+Js(e,"height")*2}function xq(e){return qy({x:Js(e,"x1"),y:Js(e,"y1")},{x:Js(e,"x2"),y:Js(e,"y2")})}function aC(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var a=t.getItem(s);s>0&&(i+=qy(r,a)),r=a}return i}function bq(e){var t=e.points;return aC(e)+qy(t.getItem(t.numberOfItems-1),t.getItem(0))}function nC(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return vq(e);case"rect":return yq(e);case"line":return xq(e);case"polyline":return aC(e);case"polygon":return bq(e)}}function wq(e){var t=nC(e);return e.setAttribute("stroke-dasharray",t),t}function _q(e){for(var t=e.parentNode;Qe.svg(t)&&Qe.svg(t.parentNode);)t=t.parentNode;return t}function oC(e,t){var i=t||{},r=i.el||_q(e),s=r.getBoundingClientRect(),a=Js(r,"viewBox"),n=s.width,o=s.height,l=i.viewBox||(a?a.split(" "):[0,0,n,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:n/l[2],h:o/l[3]}}function Sq(e,t){var i=Qe.str(e)?tC(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:oC(i),totalLength:nC(i)*(r/100)}}}function Aq(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=oC(e.el,e.svg),s=i(),a=i(-1),n=i(1);switch(e.property){case"x":return(s.x-r.x)*r.w;case"y":return(s.y-r.y)*r.h;case"angle":return Math.atan2(n.y-a.y,n.x-a.x)*180/Math.PI}}function hS(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=sC(Qe.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:Qe.str(e)||t?r.split(i):[]}}function lC(e){var t=e?uf(Qe.arr(e)?e.map(lS):lS(e)):[];return df(t,function(i,r,s){return s.indexOf(i)===r})}function hC(e){var t=lC(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:rC(i)}}})}function Mq(e,t){var i=Vy(t);if(/^spring/.test(i.easing)&&(i.duration=$E(i.easing)),Qe.arr(e)){var r=e.length,s=r===2&&!Qe.obj(e[0]);s?e={value:e}:Qe.fnc(t.duration)||(i.duration=t.duration/r)}var a=Qe.arr(e)?e:[e];return a.map(function(n,o){var l=Qe.obj(n)&&!Qe.pth(n)?n:{value:n};return Qe.und(l.delay)&&(l.delay=o?0:t.delay),Qe.und(l.endDelay)&&(l.endDelay=o===a.length-1?t.endDelay:0),l}).map(function(n){return pf(n,i)})}function Eq(e){for(var t=df(uf(e.map(function(a){return Object.keys(a)})),function(a){return Qe.key(a)}).reduce(function(a,n){return a.indexOf(n)<0&&a.push(n),a},[]),i={},r=function(a){var n=t[a];i[n]=e.map(function(o){var l={};for(var h in o)Qe.key(h)?h==n&&(l.value=o[h]):l[h]=o[h];return l})},s=0;s<t.length;s++)r(s);return i}function Cq(e,t){var i=[],r=t.keyframes;r&&(t=pf(Eq(r),t));for(var s in t)Qe.key(s)&&i.push({name:s,tweens:Mq(t[s],e)});return i}function Tq(e,t){var i={};for(var r in e){var s=d0(e[r],t);Qe.arr(s)&&(s=s.map(function(a){return d0(a,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function Dq(e,t){var i;return e.tweens.map(function(r){var s=Tq(r,t),a=s.value,n=Qe.arr(a)?a[1]:a,o=Ua(n),l=Hy(t.target,e.name,o,t),h=i?i.to.original:l,u=Qe.arr(a)?a[0]:h,c=Ua(u)||Ua(l),d=o||c;return Qe.und(n)&&(n=h),s.from=hS(u,d),s.to=hS(Wy(n,u),d),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=Uy(s.easing,s.duration),s.isPath=Qe.pth(a),s.isColor=Qe.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var cC={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,s){if(r.list.set(t,i),t===r.last||s){var a="";r.list.forEach(function(n,o){a+=o+"("+n+") "}),e.style.transform=a}}};function dC(e,t){var i=hC(e);i.forEach(function(r){for(var s in t){var a=d0(t[s],r),n=r.target,o=Ua(a),l=Hy(n,s,o,r),h=o||Ua(l),u=Wy(sC(a,h),l),c=Gy(n,s);cC[c](n,s,u,r.transforms,!0)}})}function Pq(e,t){var i=Gy(e.target,t.name);if(i){var r=Dq(t,e),s=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:s.end,delay:r[0].delay,endDelay:s.endDelay}}}function Iq(e,t){return df(uf(e.map(function(i){return t.map(function(r){return Pq(i,r)})})),function(i){return!Qe.und(i)})}function uC(e,t){var i=e.length,r=function(a){return a.timelineOffset?a.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+l+a.duration*(a.loop??1)})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0;return r(a)+n+o+a.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+a.duration*(a.loop??1)-a.endDelay-l})):t.endDelay,s}var cS=0;function Oq(e){var t=c0(KE,e),i=c0(Ny,e),r=Cq(i,e),s=hC(e.targets),a=Iq(s,r),n=uC(a,i),o=cS;return cS++,pf(t,{id:o,children:[],animatables:s,animations:a,duration:n.duration,delay:n.delay,endDelay:n.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var rs=[],dS=[],Vu,Rq=function(){function e(){Vu=requestAnimationFrame(t)}function t(i){var r=rs.length;if(r){for(var s=0;s<r;){var a=rs[s];a.paused?(rs.splice(s,1),r-=1):(a.tick(i),s++)}e()}else Vu=cancelAnimationFrame(Vu)}return e}();function Lq(e){document.hidden?(rs.forEach(function(t){return t.pause(e.timeStamp)}),dS=rs.slice(0),si.running=rs=[]):dS.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",Lq);function si(e){e===void 0&&(e={});var t=0,i=0,r=0,s,a,n=0,o=null;function l(_){var S=window.Promise&&new Promise(function(M){return o=M});return _.finished=S,S}var h=Oq(e),u=l(h);function c(){var _=h.direction;_!=="alternate"&&(h.direction=_!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,a.forEach(function(S){(S.loop===1||S.loop%2===0)&&(S.reversed=h.reversed)})}function d(){h.direction="normal",h.reversed=!1,a.forEach(function(_){return _.reversed=!1})}function p(_){return h.reversed?h.duration-_:_}function f(){t=0,i=p(h.currentTime)*(1/si.speed)}function m(_,S,M=!1){S&&(h.reversed?S.seek(S.duration*S.loop-(_-S.timelineOffset-S.pingPongDelayCorrection),M):S.seek(_-S.timelineOffset-S.startOnceDelay-S.pingPongDelayCorrection,M))}function g(_,S=!1){if(h.reversed)for(var M=n;M--;)m(_,a[M],S);else for(var C=0;C<n;C++)m(_,a[C],S)}function v(_){var S=0,M=h.animations,C=M.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?_=h.duration-h.delay+h.endDelay-_:_=h.duration+h.delay-h.endDelay-_):w(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?_=h.duration-h.delay+h.endDelay-_:_=h.duration+h.delay-h.endDelay-_);S<C;){var T=M[S],D=T.animatable,P=T.tweens,I=P.length-1,R=P[I];I&&(R=df(P,function(Z){return _<Z.end})[0]||R);let re;h.parent?.reversed&&h.direction==="alternate"?re=Ss(_-R.start-R.endDelay,0,R.duration)/R.duration:re=Ss(_-R.start-R.delay,0,R.duration)/R.duration;for(var U=isNaN(re)?1:R.easing(re),N=R.to.strings,L=R.round,W=[],G=R.to.numbers.length,j=void 0,k=0;k<G;k++){var q=void 0;let Z,pe;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(Z=R.to.numbers[k],pe=R.from.numbers[k]||0):(pe=R.to.numbers[k],Z=R.from.numbers[k]||0):w(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(Z=R.to.numbers[k],pe=R.from.numbers[k]||0):(pe=R.to.numbers[k],Z=R.from.numbers[k]||0),R.isPath?q=Aq(R.value,U*pe):q=Z+U*(pe-Z),L&&(R.isColor&&k>2||(q=Math.round(q*L)/L)),W.push(q)}var H=N.length;if(!H)j=W[0];else{j=N[0];for(var Y=0;Y<H;Y++){var V=N[Y],ie=N[Y+1],Q=W[Y];isNaN(Q)||(ie?j+=Q+ie:j+=Q+" ")}}cC[T.type](D.target,T.property,j,D.transforms),T.currentValue=j,S++}}function y(_){h[_]&&!h.passThrough&&h[_](h)}function x(){h.remaining&&h.remaining!==!0&&h.remaining--}let b={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function w(_,S,M,C,T){return b[_<<4|S<<3|M<<2|C<<1|T]}function A(_,S=!1){var M=h.duration;let C=h.delay,T=M-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(C=h.endDelay,T=M-h.delay);var D=p(_);if(h.progress=Ss(D/M*100,0,100),S||(h.reversePlayback=D<h.currentTime),n&&g(D,S),!h.began&&h.currentTime>=0&&(h.began=!0,y("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,y("loopBegin")),(h.reversed||D>=0)&&D<=C&&h.currentTime!==0&&(v(0),y("change")),(D>=T&&h.currentTime!==M+h.pingPongDelayCorrection||!M)&&(v(M),y("change")),D>C&&D<T?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,y("changeBegin")),v(D),y("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,y("change"),n&&y("timelineChangeComplete")):h.began&&D>T&&y("changeComplete"),h.currentTime=Ss(D,0,M+h.pingPongDelayCorrection),h.began&&y("update"),_>=M)if(x(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,y("loopComplete"),y("complete"),!h.passThrough&&"Promise"in window&&(o(),u=l(h)));else{n?t+=h.duration/si.speed:t+=h.duration;for(let P of a)P.setStartTime(0),P.remaining=P.loop;y("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?c():n&&d()}}return h.reset=function(){var _=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversePlayback=!1,h.reversed=_==="reverse",h.remaining=h.loop,a=h.children,n=a.length;for(var S=n;S--;)h.children[S].reset();v(h.reversed?h.duration:0)},h.setStartTime=function(_){t=_},h.set=function(_,S){return dC(_,S),h},h.tick=function(_){r=_,t||(t=r),A((r+(i-t))*si.speed)},h.seek=function(_,S=!1){A(_-t,S)},h.pause=function(_){h.paused=!0,n&&(s=_??performance.now())},h.play=function(_){!h.paused||(h.completed&&h.reset(),h.paused=!1,rs.push(h),n&&s!==void 0&&(t+=(_??performance.now())-s),Vu||Rq())},h.reverse=function(){c(),h.completed=!h.reversed,f()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function uS(e,t){for(var i=t.length;i--;)Fy(e,t[i].animatable.target)&&t.splice(i,1)}function Bq(e){for(var t=lC(e),i=rs.length;i--;){var r=rs[i],s=r.animations,a=r.children;uS(t,s);for(var n=a.length;n--;){var o=a[n],l=o.animations;uS(t,l),!l.length&&!o.children.length&&a.splice(n,1)}!s.length&&!a.length&&r.pause()}}function zq(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?Uy(t.easing):null,s=t.grid,a=t.axis,n=t.from||0,o=n==="first",l=n==="center",h=n==="last",u=Qe.arr(e),c=parseFloat(u?e[0]:e),d=u?parseFloat(e[1]):0,p=Ua(u?e[1]:e)||0,f=t.start||0+(u?c:0),m=[],g=0;return function(v,y,x){if(o&&(n=0),l&&(n=(x-1)/2),h&&(n=x-1),!m.length){for(var b=0;b<x;b++){if(!s)m.push(Math.abs(n-b));else{var w=l?(s[0]-1)/2:n%s[0],A=l?(s[1]-1)/2:Math.floor(n/s[0]),_=b%s[0],S=Math.floor(b/s[0]),M=w-_,C=A-S,T=Math.sqrt(M*M+C*C);a==="x"&&(T=-M),a==="y"&&(T=-C),m.push(T)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(P){return r(P/g)*g})),i==="reverse"&&(m=m.map(function(P){return a?P<0?P*-1:-P:Math.abs(g-P)}))}var D=u?(d-c)/g:c;return f+D*(Math.round(m[y]*100)/100)+p}}function kq(e){e===void 0&&(e={});var t=si(e);return t.duration=0,t.add=function(i,r){var s=rs.indexOf(t),a=t.children;s>-1&&rs.splice(s,1);function n(d){d.passThrough=!0}for(var o=0;o<a.length;o++)n(a[o]);var l=pf(i,c0(Ny,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=Qe.und(r)?h:Wy(r,h),n(t);var u=si(l);n(u),a.push(u),u.parent=t;var c=uC(a,e);return t.delay=c.delay,t.endDelay=c.endDelay,t.duration=c.duration,u.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}si.version="3.2.0";si.speed=1;si.running=rs;si.remove=Bq;si.get=Hy;si.set=dC;si.convertPx=jy;si.path=Sq;si.setDashoffset=wq;si.stagger=zq;si.timeline=kq;si.easing=Uy;si.penner=eC;si.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var pC=si,pS=new E,fS=new E,mS=new $e;function Nq(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let s=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(s>=1)return i.copy(e);let a=1-s*s;if(a<=Number.EPSILON){let u=1-r;return i.w=u*e.w+r*t.w,i.x=u*e.x+r*t.x,i.y=u*e.y+r*t.y,i.z=u*e.z+r*t.z,i.normalize(),i}let n=Math.sqrt(a),o=Math.atan2(n,s),l=Math.sin((1-r)*o)/n,h=Math.sin(r*o)/n;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function Mo(e,t,i,r,s,a){let n=i[e]?i[e]:void 0,o=r[e];if(o==null)return;let l=n!=null?typeof n=="string"?Number(s.getVariable(n)??0):n:t[e],h=typeof o=="string"?Number(s.getVariable(o)??0):o;if(l!==h)return{update:u=>{let c=Le.lerp(l,h,u);a?t[e]=Math.trunc(c):t[e]=c},start:()=>{t[e]=l},end:()=>{t[e]=h}}}function fC(e,t,i,r,s,a){let n=i[e]?i[e]:void 0,o=r[e];if(!o)return;let l=t[e],h=[...n??l].map(c=>typeof c=="string"?Number(s.getVariable(c)??0):c),u=[...o].map(c=>typeof c=="string"?Number(s.getVariable(c)??0):c);if(!(h.length!==u.length||M2(h,u)))return{update:c=>{h.forEach((d,p)=>{let f=Le.lerp(d,u[p],c);t[e][p]=a?Math.trunc(f):f})},start:()=>{Object.assign(t[e],h)},end:()=>{Object.assign(t[e],u)}}}function Np(e,t,i){return t.forEach((r,s)=>{e.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function gS(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?Np(new E,a,s):o.clone(),h=Np(new E,n,s);if(!l.equals(h))return{update:u=>{o.lerpVectors(l,h,u)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function Uq(e,t,i,r){let s=i[e]?i[e]:void 0,a=r[e];if(!a)return;let n=t[e],o=s?new me().fromArray(s):n.clone(),l=new E,h=new $e,u=new E;o.decompose(l,h,u);let c=new me().fromArray(a),d=new E,p=new $e,f=new E;if(c.decompose(d,p,f),!o.equals(c))return{update:m=>{mS.slerpQuaternions(h,p,m),pS.lerpVectors(l,d,m),fS.lerpVectors(u,f,m),n.compose(pS,mS,fS)},start:()=>{n.compose(l,h,u)},end:()=>{n.compose(d,p,f)}}}function Fq(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?typeof a=="string"?s.getColor(a).clone():new Ve().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new Ve().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let u=o.clone();return t[e]=u,{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Rn(e,t,i,r,s){if(typeof t[e]=="number")return Mo(e,t,i??{},r,s);if(Array.isArray(t[e]))return fC(e,t,i??{},r,s)}function Vq(e,t,i,r){let s=[],a=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let o=a??e.zoom,l=n;o!==l&&s.push({update:h=>{e.zoom=Le.lerp(o,l,h),e.updateProjectionMatrix()},start:()=>{e.zoom=o,e.updateProjectionMatrix()},end:()=>{e.zoom=l,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let o=Mo("targetOffset",e,t,i,r);o&&s.push(o)}return s}function jq(e,t,i,r){if(i.scaleBaked===void 0)return;let s=(t.scaleBaked??e.data.geometry.scaleBaked).map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o),a=i.scaleBaked.map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o);if(fo.isEqual(s,a))return;let n=[];return n.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[Le.lerp(s[0],a[0],o),Le.lerp(s[1],a[1],o),Le.lerp(s[2],a[2],o)]},r),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({scaleBaked:a},r),e.invalidateDownstreamBooleanData()}}),n}function Gq(e,t,i,r){if(!i.extrusion)return;let s=e.extrusion,a=t.extrusion??{},n=i.extrusion,o=[];return hM.forEach(l=>{let h=Rn(l,s,a,n,r);h&&o.push(h)}),o}function Hq(e,t,i,r){let s=[];if(!("geometry"in i))return s;let a=e.geometry.userData.parameters,n="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof Wc){let l=jq(e,n,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,ka(a,sw)),sw.forEach(h=>{let u=Rn(h,l,n,o,r);u&&s.push(u)}),e instanceof Oy){Object.assign(l,{extrusion:{...a.extrusion}});let h=Gq(l,n,o,r);h&&s.push(...h)}s.length&&s.push({update:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},start:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},end:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()}})}return s}function Wq(e,t,i,r){let s=[];if(i.intensity!==void 0){let a=Mo("intensity",e,t,i,r);a&&s.push(a)}if(i.color!==void 0){let a=Fq("color",e,t,i,r);a&&s.push(a)}return s}function qq(e,t,i,r){let s=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return s;let a="materials"in t&&t.materials?t.materials:[],n=i.materials;e.material.forEach((o,l)=>{if(!n[l])return;let h=a[l]??{},u=n[l];typeof h=="string"||typeof u=="string"||s.push(...vS(o,h,u,r))})}else{if(!("material"in i&&i.material))return s;let a="material"in t&&t.material?t.material:{},n=i.material;if(typeof a=="string"||typeof n=="string")return s;s.push(...vS(e.material,a,n,r))}return s}function vS(e,t,i,r){let s=[],a=Tl(i,r)||!!t.layers&&Tl(t,r);s.push(tY(e,a));for(let n of e.layers){let o=t.layers?.data(n.uuid),l=i.layers.data(n.uuid);if(!l||n.type!=="light"&&(!(n.visible??!0)||!(l.visible??!0)))continue;let h=n.getNames().filter(u=>!nM.some(c=>u.includes(c)));for(let u of h)try{let c=n.getValue(u),d;if(u==="colors")d=$q(n,o,l,u);else if(Array.isArray(c))u==="steps"&&(d=Jq(n,o,l,u));else if(typeof c=="number")d=Yq(n,o,l,u,r);else{if(typeof c=="boolean")continue;c instanceof F?d=Xq(n,o,l,u):c instanceof E?d=Qq(n,o,l,u,r):c instanceof Cr?d=Kq(n,o,l,u,r):c instanceof Ve?d=Zq(n,o,l,u,r):"isTexture"in c&&(d=eY(n,o,l,u))}d&&(Array.isArray(d)?s.push(...d):s.push(d))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${u}`,c)}}return s}function Yq(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:e.getValue(r),n=i[r],o=typeof a=="string"?Number(s.getVariable(a)??0):a,l=typeof n=="string"?Number(s.getVariable(n)??0):n;if(o!==l)return{update:h=>{e.setValue(r,Le.lerp(o,l,h))},start:()=>{e.setValue(r,o)},end:()=>{e.setValue(r,l)}}}function Xq(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),a=t?new F().fromArray(t[r]):s.clone(),n=new F().fromArray(i[r]);if(!a.equals(n))return{update:o=>{s.lerpVectors(a,n,o)},start:()=>{s.copy(a)},end:()=>{s.copy(n)}}}function Qq(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=e.getValue(r),n=t?t[r]:void 0,o=i[r],l=n?Np(new E,n,s):a.clone(),h=Np(new E,o,s);if(!l.equals(h))return{update:u=>{a.lerpVectors(l,h,u)},start:()=>{a.copy(l)},end:()=>{a.copy(h)}}}function Zq(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new Ve().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new Ve().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let u=o.clone();return{update:c=>{e.getValue(r)!==u&&e.setValue(r,u),u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Kq(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new Ve().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new Cr(n.r,n.g,n.b,n.a);if(l.equals(h))return;let u=o.clone();return{update:c=>{e.getValue(r)!==u&&e.setValue(r,u),u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Jq(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a,o=i[r];for(let l=0;l<a.length;++l){let h=n[l],u=o[l];h!==u&&s.push({update:c=>{a[l]=Le.lerp(h,u,c)},start:()=>{a[l]=h},end:()=>{a[l]=u}})}return s.length?s:void 0}function $q(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a.map(l=>l.toArray()),o=i[r];for(let l=0;l<a.length;++l){let h=[...n[l]],u=[...o[l]];gp.isEqual(h,u)||s.push({update:c=>{a[l].fromArray(gp.lerp(h,u,c))},start:()=>{a[l].fromArray(h)},end:()=>{a[l].fromArray(u)}})}return s.length?s:void 0}function eY(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("mat");if(!s)return;let a=t?t[r]:s,n=i[r],o=[...a.repeat],l=[...a.offset],h=[...n.repeat],u=[...n.offset];if(!El.isEqual(o,h)||!El.isEqual(l,u))return{update:c=>{s.repeat=El.lerp(o,h,c),s.offset=El.lerp(l,u,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...u],s.updateMatrix()}}}function tY(e,t){return{update:()=>{e.transparent=t}}}var cg=new E,yS=new Di;function iY(e,t,i,r,s){let a=[],n,o,l,h,u,c,d={slide:t.pathSnapping?.slide??e.updatedPathSnapping?.slide??e.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??e.updatedPathSnapping?.offset??e.dataPatched.pathSnapping?.offset??0};if(u=Mo("slide",d,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),u&&a.push(u),c=Mo("offset",d,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),c&&a.push(c),!u&&!c&&(n=gS("position",e,t,i,s),n&&a.push(n),o=gS("scale",e,t,i,s),o&&a.push(o),l=rY(e,t,i,r,s),l&&a.push(l),h=Uq("hiddenMatrix",e,t,i),h&&a.push(h)),n||o||l||h||u||c){let p=()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),ys(e)&&Zs(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,d))};a.push({update:p,start:p,end:p})}return a}function rY(e,t,i,r,s){let a=t?.rotation?t.rotation.map(u=>(typeof u=="string"?Number(s.getVariable(u)??0):u)*Le.DEG2RAD):void 0,n=i.rotation?.map(u=>(typeof u=="string"?Number(s.getVariable(u)??0):u)*Le.DEG2RAD);if(!n)return;let o=a?new E().fromArray(a):new E().setFromEuler(e.rotation),l=new E().fromArray(n);if(o.equals(l))return;let h=cg.subVectors(l,o);if(r&&h.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new $e().setFromEuler(yS.setFromVector3(o)),c=new $e().setFromEuler(yS.setFromVector3(l));return{update:d=>{Nq(u,c,e.quaternion,d)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}else return{update:u=>{cg.lerpVectors(o,l,u),e.rotation.setFromVector3(cg)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}function sY(e,t,i,r){let s=[];if(!("cloner"in i)||!e.cloner)return s;let a=e.cloner,n="cloner"in t?t.cloner:{},o=i.cloner;eM.forEach(p=>{let f;p==="count"?f=Mo("count",a.parameters,n,o,r,!0):f=Rn(p,a.parameters,n??{},o,r),f&&s.push(f)});let l=aY(a,n,o,r);l?.length&&s.push(...l);let h=nY(a,n,o,r);h?.length&&s.push(...h);let u=oY(a,n,o,r);u?.length&&s.push(...u);let c=lY(a,n,o,r);c?.length&&s.push(...c);let d=hY(a,n,o,r);return d?.length&&s.push(...d),s.length&&s.push({update:()=>{a.update()}}),s}function aY(e,t,i,r){if(e.parameters.type!=="radial")return;let s=t.radial,a=i.radial;if(!a)return;let n=e.parameters.radial,o=[];return tM.forEach(l=>{let h=Rn(l,n,s??{},a,r);h&&o.push(h)}),o}function nY(e,t,i,r){if(e.parameters.type!=="linear")return;let s=t.linear,a=i.linear;if(!a)return;let n=[],o=e.parameters.linear;return iM.forEach(l=>{let h=Rn(l,o,s??{},a,r);h&&n.push(h)}),n}function oY(e,t,i,r){if(e.parameters.type!=="grid")return;let s=t.grid,a=i.grid;if(!a)return;let n=[],o=e.parameters.grid;return rM.forEach(l=>{let h;l==="count"?h=fC(l,o,s??{},a,r,!0):h=Rn(l,o,s??{},a,r),h&&n.push(h)}),n}function lY(e,t,i,r){if(e.parameters.type!=="toObject")return;let s=t.toObject,a=i.toObject;if(!a)return;let n=[],o=e.parameters.toObject;return sM.forEach(l=>{let h;l==="count"?h=Mo(l,o,s??{},a,r,!0):h=Rn(l,o,s??{},a,r),h&&n.push(h)}),n}function hY(e,t,i,r){if(!e.parameters.randomness)return;let s=t.randomnessObject,a=i.randomnessObject;if(!a)return;let n=[],o=e.parameters.randomnessObject;return aM.forEach(l=>{let h=Rn(l,o,s??{},a,r);h&&n.push(h)}),n}function xS(e,t,i,r,s){let a=[];return e.data.visible&&a.push(...iY(e,t,i,s,r)),e.data.visible&&a.push(...sY(e,t,i,r)),ys(e)?(e instanceof dr&&e.data.visible&&a.push(...Hq(e,t,i,r)),e.data.visible&&a.push(...qq(e,t,i,r))):p9(e)?e.data.visible&&a.push(...Wq(e,t,i,r)):u9(e)&&a.push(...Vq(e,t,i,r)),a.length?{update:n=>{a.forEach(o=>o.update(n))},start:n=>{a.forEach(o=>o.start?.(n))},end:n=>{a.forEach(o=>o.end?.(n))}}:void 0}var bS=new E;function Yy(e,t,i=!1){let r=[];e.traverseChildren(s=>{if(i&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(bS,!0),s.rigidBody?.setAngvel(bS,!0)),!pt.is(s))return;let a=s.uuid,n=s.data;if(delete s.states,s.uuid===_h)return;let o=!1;r.some(l=>e.scene.find(a)?.isDescendantOf(l))?o=!0:n.physics?.fusedBody===!0&&n.physics.rigidBody==="dynamic"&&r.push(a),s.data=n,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let l of n.states){let h={...l.data};e.data.globalPhysics.usePhysics===!0&&n.physics&&(n.physics.rigidBody==="dynamic"||o)&&(l.data.position!==void 0&&delete h.position,l.data.rotation!==void 0&&delete h.rotation,l.data.hiddenMatrix!==void 0&&delete h.hiddenMatrix),s.states||(s.states={}),s.states[l.id]=so.patch(n,h)}dY(e.scene,s,null,t,n.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),cY(e)})}function cY(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let s of r)if(s.data.type==="Create"&&s.data.hideBase==="Yes"){let a=e.scene.find(s.data.object);a&&(a.visible=!1)}}})}function dY(e,t,i,r,s=!1){if(t instanceof dr&&t.removeInteractionGeometry(),t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof dr&&t.updateGeometryGroupsIfNeeded(),t instanceof Xi&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),t.cloner)for(let a of t.cloner.children)a.playModeVisible=void 0;t.updateVisible()}function mC(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
|
|
6424
|
+
}`,r={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new F},viewport:{type:"v2",value:new F},basisViewport:{type:"v2",value:new F},debugColor:{type:"v3",value:new Ve},covariancesTextureSize:{type:"v2",value:new F(1024,1024)},centersColorsTextureSize:{type:"v2",value:new F(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Lt({uniforms:r,vertexShader:t,fragmentShader:i,transparent:!0,alphaTest:1,blending:ho,depthTest:!0,depthWrite:!1,side:Sr})}static buildGeomtery(e){let t=new Ue;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),r=new Ze(i,3);t.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let s=new FA().copy(t),a=new Uint32Array(e),n=new SA(a,1,!1);return n.setUsage(_3),s.setAttribute("splatIndex",n),s.instanceCount=e,s}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,t=0,i=0;for(let r of this.splatBuffers){let s=r.nsplats;this.colors.subarray(e,e+s*4).set(r.colorsA),e+=s*4,this.centers.subarray(t,t+s*3).set(r.decoded.xyz.denormDequant().data),t+=s*3,this.covariances.subarray(i,i+s*6).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=s*6}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new F(4096,1024);for(;t.x*t.y*2<e*6;)t.y*=2;let i=new F(4096,1024);for(;i.x*i.y*4<e*4;)i.y*=2;let r,s;if(this.halfPrecisionCovariancesOnGPU){s=new Uint16Array(t.x*t.y*2);for(let u=0;u<this.covariances.length;u++)s[u]=Y4.toHalfFloat(this.covariances[u]);r=new pn(s,t.x,t.y,Hu,bo)}else s=new Float32Array(t.x*t.y*2),s.set(this.covariances),r=new pn(s,t.x,t.y,Hu,lr);r.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=r,this.material.uniforms.covariancesTextureSize.value.copy(t);let a=new Uint32Array(i.x*i.y*4);for(let u=0;u<e;u++){let c=u*4,d=u*3,p=u*4;a[p]=HW(this.colors[c],this.colors[c+1],this.colors[c+2],this.colors[c+3]),a[p+1]=ng(this.centers[d]),a[p+2]=ng(this.centers[d+1]),a[p+3]=ng(this.centers[d+2])}let n=new pn(a,i.x,i.y,iA,La);n.internalFormat="RGBA32UI",n.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=n,this.material.uniforms.centersColorsTextureSize.value.copy(i);let o=256*4,l=new Float32Array(256*16);for(let u=0;u<this.meshMatrixWorlds.length;u++)l.set(this.meshMatrixWorlds[u].elements,u*16);let h=new pn(l,o,1,Nr,lr);h.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=h,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:s,texture:r,size:t},centerColors:{data:a,texture:n,size:i},meshMatrixWorlds:{data:l,texture:h}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,i,r){this.splatCount>0&&(Eu.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Eu),this.material.uniforms.basisViewport.value.set(2/Eu.x,2/Eu.y),this.material.uniforms.focal.value.set(t,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose())}},WW=class{constructor(e={}){ir(this,"updateSplatMeshUniforms",function(){let t=new F;return function(){this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}()),ir(this,"updateView",function(){let t=new me,i=[],r=new E(0,0,-1),s=new E(0,0,-1),a=new E,n=new E;return function(o=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),h=this.cropsChanged();if(!o){s.set(0,0,-1).applyQuaternion(this.camera.quaternion);let c=!1,d=!1;if(s.dot(r)<=.95&&(c=!0),n.copy(this.camera.position).sub(a).length()>=1&&(d=!0),!c&&!d&&!l&&!h)return}a.copy(this.camera.position),r.copy(s),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),i[0]=this.camera.position.x,i[1]=this.camera.position.y,i[2]=this.camera.position.z;let u={sort:{view:t.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...h?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=u:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(u))}}()),this.scene=e.scene,this.currentPage=null,this.renderer=e.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let e=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=e?this:null}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new E().fromArray(e.position)),e.orientation&&(e.orientation=new $e().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let n=a.visible;a.traverseAncestors(o=>{n&&(n=o.visible)}),n&&t.push(a)}}),this.splatMesh&&this.splatMesh.dispose(),t.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=t.map(a=>a.matrixWorld.clone()),this.cropsArray=t.map(a=>a.data.crops.map(n=>n.data));let i=t.map(a=>new s0(new Uint8Array(a.data.buffer).buffer)),r=0,s=[0];for(let a of i)r+=a.getSplatCount(),s.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;t<this.meshMatrixWorlds.length;t++)e.set(this.meshMatrixWorlds[t].elements,t*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((t,i)=>t.equals(this.meshMatrixWorldsOld[i]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(t=>t.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{t.data.crops.forEach((r,s)=>{this.cropsArray[i][s]===void 0?(e=!0,this.cropsArray[i][s]=r.data):Object.entries(r.data).forEach(([a,n])=>{Array.isArray(n)&&n.some((o,l)=>o!==this.cropsArray[i][s][a][l])?(e=!0,this.cropsArray[i][s][a]=n):n!==this.cropsArray[i][s]?.[a]&&(e=!0,this.cropsArray[i][s][a]=n)})}),t.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new E,r=new $e,s=!1,a=1,n,o){this.splatMesh=Uu.buildMesh(e,t,s,a,n,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=t}setupSortWorker(e){this.sortWorker=GW(e),this.sortWorker.onmessage=t=>{t.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(t.data.indexesBuffer)),this.lastSortTime=t.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):t.data.sortCanceled?this.sortRunning=!1:t.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):t.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}},a0=new Kc;a0.wireframe=!0;var iS=new E,By=class extends _n{constructor(e,t){super(),this.data=e,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new RW,this.errorPage=new Cn("fdasfa",{...sh.defaultData,name:""}),this.invisibleObjects=new Gl("jflkdsafjasdifjaslk",{...Av.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=DW(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=TW(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Cn&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let a=r.children.indexOf(s);i.splice(0,0,a)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>y6(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===_h)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(),r.resetBBoxNeedsUpdate(),ys(r)&&Zs(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Zs(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),ys(i)&&(i.freeBooleanPointer(),r instanceof lh&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof Oy&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;s.children.splice(a,0,s.children.pop()),ys(i)&&(i.invalidateUpstreamBooleanData(),Zs(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof lh&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Cn&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{CW(s,t,i,{scene:this,shared:r}),s instanceof dr&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{Zs(r)&&r.recomputeBoolean(),r instanceof Xi&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){pt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{pt.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,a,n){if(e){let o=r.find(e);o&&o!==r&&s.forInstancesRec(l=>{l.data=Nc(l.data,h=>{let u=h.events.data(n.id),c=l.goUp(a);if(c){let d=[...C2(c.identity),e].join("-"),p=this.entityIdentityToEntity[d];if(p){let f=p.uuid,m=ar.zoom(u,t);m[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,s,a){e.forEach(n=>{n.data.type==="Transition"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a):n.data.type==="Animation"&&this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Hl&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=Nc(a.data,n=>{a.isInstanceRoot||(n.events.delete(r.id),s=!0)}).data}),s===!1)for(let a of Mp.list)this.rewriteActions(r.data.gameActions[a],["gameActions",a],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(s=>{if(s instanceof Hl&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(a=>{i.addClip(a)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Ry(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof Hl&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)pt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=s=>{for(let a of s.children){let n=a.cloner;if(pt.is(a)&&!a.raycastLock&&(a.visible||n?.object.data.visible))if(t===!0&&a.isInstanceRoot){let o=[];if(e.intersectObject(a,!0,o),o.length){let l=o[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let h=a.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(ys(a)||Qv(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),i0(a,e,i)),r(a)}};return r(this),i}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let a=s.cloner;pt.is(s)&&(s.visible||a?.object.data.visible)&&((ys(s)||Qv(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),i0(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)pt.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)pt.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)pt.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof dr&&i.data.type==="Mesh"&&i.data.geometry.type==="TextGeometry"&&i.data.geometry.font===e){let r=i.geometry,s=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(s);let a=i.invalidateDownstreamBooleanData();Zs(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Hc.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)pt.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,a){let n={scene:this,shared:a},o=Ly(e,t,n);return o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,a)),o.updateState(t,n),o instanceof dr&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{if(l instanceof dr&&l.isSkinnedMesh){let h=l.dataPatched;if(h.bones&&h.boneInverses){let u=h.bones.map(p=>this.find(p)),c=h.boneInverses.map(p=>new me().fromArray(p)),d=new E0(u,c);l.bind(d,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,s=e.length;r<s;++r){let{id:a,recursive:n}=e[r],o=this.find(a),l=n?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new ai;return i.setFromPoints(t),i.getCenter(iS),iS}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e)?.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Dr)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof Pn&&e(t.material[i]);else t.material instanceof Pn&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof Xi&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(e){this.splatViewer=new WW({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}},Fu=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},qW=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return XW(Math.atan2(r,i))},YW=(e,t,i)=>{let r={x:0,y:0};return i=n0(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},n0=e=>e*(Math.PI/180),XW=e=>e*(180/Math.PI),QW=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,og=new Map,rS=e=>{og.has(e)&&clearTimeout(og.get(e)),og.set(e,setTimeout(e,100))},zp=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.addEventListener?e.addEventListener(s,i,!1):e.attachEvent&&e.attachEvent(s,i)},sS=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.removeEventListener?e.removeEventListener(s,i):e.detachEvent&&e.detachEvent(s,i)},jE=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),aS=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},o0=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},zy=(e,t,i)=>{let r=GE(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let a="";for(let n=0,o=t.length;n<o;n+=1)a+=t[n]+" "+i+", ";r[s]=a.slice(0,-2)}return r},ZW=(e,t)=>{let i=GE(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},GE=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},lg=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},KW=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},l0=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},JW=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(HE="ontouchstart"in window,WE=!!window.PointerEvent,qE=!!window.MSPointerEvent);var HE,WE,qE,tc={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Dl,qc={};WE?Dl=tc.pointer:qE?Dl=tc.MSPointer:HE?(Dl=tc.touch,qc=tc.mouse):Dl=tc.mouse;function Po(){}Po.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]=i._handlers_[s]||[],i._handlers_[s].push(t);return i};Po.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};Po.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]&&i._handlers_[s].length&&i._handlers_[s].forEach(function(n){n.call(i,{type:s,target:i},t)})};Po.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=KW(t.options,e))};Po.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},zp(e,Dl[t],i._domHandlers_[t]),qc[t]&&zp(e,qc[t],i._domHandlers_[t]),i};Po.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},sS(e,Dl[t],i._domHandlers_[t]),qc[t]&&sS(e,qc[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var ky=Po;function Mi(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Mi.id,Mi.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Mi.prototype=new ky;Mi.constructor=Mi;Mi.id=0;Mi.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Mi.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=ZW("borderRadius","50%"),i=zy("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},lg(r.el,i),this.options.shape==="circle"&&lg(r.back,t),lg(r.front,t),this.applyStyles(r),this};Mi.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};Mi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Mi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Mi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Mi.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};Mi.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};Mi.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",s={};s.front=zy("transition",["top","left"],r);var a={front:{}};a.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(a),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};Mi.prototype.restCallback=function(){var e=this,t={};t.front=zy("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};Mi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Mi.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,s,a,n;if(t>i&&t<i*3&&!e.lockX?s="up":t>-i&&t<=i&&!e.lockY?s="left":t>-i*3&&t<=-i&&!e.lockX?s="down":e.lockY||(s="right"),e.lockY||(t>-r&&t<r?a="left":a="right"),e.lockX||(t>0?n="up":n="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:a,y:n,angle:s},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+a,e),h.y||this.trigger("plain:"+n,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var $W=Mi;function ni(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=ni.id,ni.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}ni.prototype=new ky;ni.constructor=ni;ni.id=0;ni.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,s=t.length;r<s;r+=1)if(t[r].identifier===i)return t[r];return!1}};ni.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};ni.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};ni.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,s={},a=i.options,n={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)s={x:e.x-n.x,y:e.y-n.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",a.zone.appendChild(o);var l=o.getBoundingClientRect();a.zone.removeChild(o),s=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new $W(i,{color:a.color,size:a.size,threshold:a.threshold,fadeTime:a.fadeTime,dataOnly:a.dataOnly,restJoystick:a.restJoystick,restOpacity:a.restOpacity,mode:a.mode,identifier:t,position:e,zone:a.zone,frontPosition:{x:0,y:0},shape:a.shape});return a.dataOnly||(o0(h.ui.el,s),o0(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};ni.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};ni.prototype.bindNipple=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};ni.prototype.pressureFn=function(e,t,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var a=e.force||e.pressure||e.webkitForce||0;a!==s&&(t.trigger("pressure",a),r.trigger("pressure "+t.identifier+":pressure",a),s=a)}.bind(r),100)};ni.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=jE(e),t.updateBox();var s=function(a){t.actives.length<i.maxNumberOfNipples?t.processOnStart(a):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(l){return l.identifier===n})<0){var o=[e[0]];o.identifier=n,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(a))};return l0(e,s),t.manager.bindDocument(),!1};ni.prototype.processOnStart=function(e){var t=this,i=t.options,r,s=t.manager.getIdentifier(e),a=e.force||e.pressure||e.webkitForce||0,n={x:e.pageX,y:e.pageY},o=t.getOrCreate(s,n);o.identifier!==s&&t.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(u){u.trigger("start",u),t.trigger("start "+u.id+":start",u),u.show(),a>0&&t.pressureFn(e,u,u.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=Fu(n,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};ni.prototype.getOrCreate=function(e,t){var i=this,r=i.options,s;return/(semi|static)/.test(r.mode)?(s=i.idles[0],s?(i.idles.splice(0,1),s):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(s=i.createNipple(t,e),s)};ni.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=t.manager.scroll;if(!QW(e)){this.processOnEnd(e);return}if(!s){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var n=s.el.getBoundingClientRect();s.position={x:a.x+n.left,y:a.y+n.top}}s.identifier=r;var o=s.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h=Fu(l,s.position),u=qW(l,s.position),c=n0(u),d=h/o,p={distance:h,position:l},f,m;if(s.options.shape==="circle"?(f=Math.min(h,o),m=YW(s.position,f,u)):(m=JW(l,s.position,o),f=Fu(m,s.position)),i.follow){if(h>o){let x=l.x-m.x,b=l.y-m.y;s.position.x+=x,s.position.y+=b,s.el.style.top=s.position.y-(t.box.top+a.y)+"px",s.el.style.left=s.position.x-(t.box.left+a.x)+"px",h=Fu(l,s.position)}}else l=m,h=f;var g=l.x-s.position.x,v=l.y-s.position.y;s.frontPosition={x:g,y:v},i.dataOnly||o0(s.ui.front,s.frontPosition);var y={identifier:s.identifier,position:l,force:d,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:c,degree:u},vector:{x:g/o,y:-v/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};y=s.computeDirection(y),y.angle={radian:n0(180-u),degree:180-u},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};ni.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=t.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),t.trigger("removed "+s.id+":removed",s),t.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(t.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),t.trigger("end "+s.id+":end",s),t.ids.indexOf(s.identifier)>=0&&t.ids.splice(t.ids.indexOf(s.identifier),1),t.actives.indexOf(s)>=0&&t.actives.splice(t.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?t.idles.push(s):t.nipples.indexOf(s)>=0&&t.nipples.splice(t.nipples.indexOf(s),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[a.id]=a.identifier))};ni.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};ni.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()};var eq=ni;function Oi(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=aS(),t.config(e),t.prepareCollections();var i=function(){var s;t.collections.forEach(function(a){a.forEach(function(n){s=n.el.getBoundingClientRect(),n.position={x:t.scroll.x+s.left,y:t.scroll.y+s.top}})})};if(typeof window>"u")return t.collections;zp(window,"resize",function(){rS(i)});var r=function(){t.scroll=aS()};return zp(window,"scroll",function(){rS(r)}),t.collections}Oi.prototype=new ky;Oi.constructor=Oi;Oi.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};Oi.prototype.create=function(e){return this.createCollection(e)};Oi.prototype.createCollection=function(e){var t=this,i=new eq(t,e);return t.bindCollection(i),t.collections.push(i),i};Oi.prototype.bindCollection=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};Oi.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};Oi.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Oi.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};Oi.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};Oi.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};Oi.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};Oi.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};Oi.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=jE(t);var a=function(o,l,h){h.ids.indexOf(l)>=0&&(h[s](o),o._found_=!0)},n=function(o){r=i.getIdentifier(o),l0(i.collections,a.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return l0(t,n),!1};Oi.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};Oi.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1)};var tq=Oi,nS=new tq,iq={create:function(e){return nS.create(e)},factory:nS},YE=new Map,Mc=new Map,oo=class{constructor(e,t,i,r){this.data=t;let{audio:s,volume:a,delay:n,loop:o}=t;if(!s)throw new Error("Missing property");let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new mc({src:l,volume:a,delay:n,loop:o}),Mc.has(i.uuid)?Mc.get(i.uuid).push(this):Mc.set(i.uuid,[this]),YE.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},h0=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=YE.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=Mc.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...Mc.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},XE=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new oo(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new h0(t);else throw new Error("Missing property")}dispatchBasic(){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof oo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof oo?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof oo&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}},rq="text/plain",sq="us-ascii",oS=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),aq=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:s,hash:a}=i.groups,n=r.split(";");a=t?"":a;let o=!1;n[n.length-1]==="base64"&&(n.pop(),o=!0);let l=(n.shift()||"").toLowerCase(),h=[...n.map(u=>{let[c,d=""]=u.split("=").map(p=>p.trim());return c==="charset"&&(d=d.toLowerCase(),d===sq)?"":`${c}${d?`=${d}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==rq)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${a?`#${a}`:""}`};function nq(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return aq(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let a=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,n=0,o="";for(;;){let h=a.exec(r.pathname);if(!h)break;let u=h[0],c=h.index,d=r.pathname.slice(n,c);o+=d.replace(/\/{2,}/g,"/"),o+=u,n=c+u.length}let l=r.pathname.slice(n,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let a=r.pathname.split("/"),n=a[a.length-1];oS(n,t.removeDirectoryIndex)&&(a=a.slice(0,-1),r.pathname=a.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let a of[...r.searchParams.keys()])oS(a,t.removeQueryParameters)&&r.searchParams.delete(a);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var oq=class{constructor({url:e,context:t},i,r,s){if(this.controlsManager=i,this.shared=r,this.condition=s,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:nq(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){if(gi(this.shared,this.condition)===!1)return!1;E2?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(Ye[0]),x6())}},QE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=a=>{this.timeoutIdQueue.shift();let n=this.page.scene.find(a);if(n===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=o?n.dataPatched.physics?.fusedBody:!0;if(n.cloner){for(let h of n.cloner.children)l?(h.playModeVisible=!1,h.rigidBody&&n.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0),h.bvhGeometry&&(h.bvhGeometry=void 0)):this.clone===void 0||this.clone===h?(h.playModeVisible=!1,h.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0)):h.playModeVisible===void 0&&(h.playModeVisible=!0);(l||this.clone===void 0||this.clone===!1)&&(n.visible=!1,n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0))}else n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0),n.visible=!1;o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.rigidBody!==void 0),n.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...e.objects]}dispatch(e){if(gi(this.shared,this.condition)===!1)return!1;this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(gi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},ZE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.shared=i,this.eventManager=r,this.condition=s,this.shared=i}dispatch(){if(gi(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Yy(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},KE={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},Ny={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},lq=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],kp={CSS:{},springs:{}};function Ss(e,t,i){return Math.min(Math.max(e,t),i)}function Ec(e,t){return e.indexOf(t)>-1}function hg(e,t){return e.apply(null,t)}var Qe={arr:function(e){return Array.isArray(e)},obj:function(e){return Ec(Object.prototype.toString.call(e),"Object")},pth:function(e){return Qe.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||Qe.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return Qe.hex(e)||Qe.rgb(e)||Qe.hsl(e)},key:function(e){return!KE.hasOwnProperty(e)&&!Ny.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function JE(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function $E(e,t){var i=JE(e),r=Ss(Qe.und(i[0])?1:i[0],.1,100),s=Ss(Qe.und(i[1])?100:i[1],.1,100),a=Ss(Qe.und(i[2])?10:i[2],.1,100),n=Ss(Qe.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=a/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,u=1,c=l<1?(l*o+-n)/h:-n+o;function d(f){var m=t?t*f/1e3:f;return l<1?m=Math.exp(-m*l*o)*(u*Math.cos(h*m)+c*Math.sin(h*m)):m=(u+c*m)*Math.exp(-m*o),f===0||f===1?f:1-m}function p(){var f=kp.springs[e];if(f)return f;for(var m=1/6,g=0,v=0;;)if(g+=m,d(g)===1){if(v++,v>=16)break}else v=0;var y=g*m*1e3;return kp.springs[e]=y,y}return t?d:p}function hq(e){return e===void 0&&(e=10),function(t){return Math.ceil(Ss(t,1e-6,1)*e)*(1/e)}}var cq=function(){var e=11,t=1/(e-1);function i(u,c){return 1-3*c+3*u}function r(u,c){return 3*c-6*u}function s(u){return 3*u}function a(u,c,d){return((i(c,d)*u+r(c,d))*u+s(c))*u}function n(u,c,d){return 3*i(c,d)*u*u+2*r(c,d)*u+s(c)}function o(u,c,d,p,f){var m,g,v=0;do g=c+(d-c)/2,m=a(g,p,f)-u,m>0?d=g:c=g;while(Math.abs(m)>1e-7&&++v<10);return g}function l(u,c,d,p){for(var f=0;f<4;++f){var m=n(c,d,p);if(m===0)return c;var g=a(c,d,p)-u;c-=g/m}return c}function h(u,c,d,p){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var f=new Float32Array(e);if(u!==c||d!==p)for(var m=0;m<e;++m)f[m]=a(m*t,u,d);function g(v){for(var y=0,x=1,b=e-1;x!==b&&f[x]<=v;++x)y+=t;--x;var w=(v-f[x])/(f[x+1]-f[x]),A=y+w*t,_=n(A,u,d);return _>=.001?l(v,A,u,d):_===0?A:o(v,y,y+t,u,d)}return function(v){return u===c&&d===p||v===0||v===1?v:a(g(v),c,p)}}return h}(),eC=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var s,a=4;r<((s=Math.pow(2,--a))-1)/11;);return 1/Math.pow(4,3-a)-7.5625*Math.pow((s*3-2)/22-r,2)}},Elastic:function(r,s){r===void 0&&(r=1),s===void 0&&(s=.5);var a=Ss(r,1,10),n=Ss(s,.1,2);return function(o){return o===0||o===1?o:-a*Math.pow(2,10*(o-1))*Math.sin((o-1-n/(Math.PI*2)*Math.asin(1/a))*(Math.PI*2)/n)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,s){t[r]=function(){return function(a){return Math.pow(a,s+2)}}}),Object.keys(t).forEach(function(r){var s=t[r];e["easeIn"+r]=s,e["easeOut"+r]=function(a,n){return function(o){return 1-s(a,n)(1-o)}},e["easeInOut"+r]=function(a,n){return function(o){return o<.5?s(a,n)(o*2)/2:1-s(a,n)(o*-2+2)/2}}}),e}();function Uy(e,t){if(Qe.fnc(e))return e;var i=e.split("(")[0],r=eC[i],s=JE(e);switch(i){case"spring":return $E(e,t);case"cubicBezier":return hg(cq,s);case"steps":return hg(hq,s);default:return hg(r,s)}}function tC(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function df(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],a=0;a<i;a++)if(a in e){var n=e[a];t.call(r,n,a,e)&&s.push(n)}return s}function uf(e){return e.reduce(function(t,i){return t.concat(Qe.arr(i)?uf(i):i)},[])}function lS(e){return Qe.arr(e)?e:(Qe.str(e)&&(e=tC(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function Fy(e,t){return e.some(function(i){return i===t})}function Vy(e){var t={};for(var i in e)t[i]=e[i];return t}function c0(e,t){var i=Vy(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function pf(e,t){var i=Vy(e);for(var r in t)i[r]=Qe.und(e[r])?t[r]:e[r];return i}function dq(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function uq(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,u){return l+l+h+h+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),s=parseInt(r[1],16),a=parseInt(r[2],16),n=parseInt(r[3],16);return"rgba("+s+","+a+","+n+",1)"}function pq(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,s=parseInt(t[3],10)/100,a=t[4]||1;function n(d,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?d+(p-d)*6*f:f<1/2?p:f<2/3?d+(p-d)*(2/3-f)*6:d}var o,l,h;if(r==0)o=l=h=s;else{var u=s<.5?s*(1+r):s+r-s*r,c=2*s-u;o=n(c,u,i+1/3),l=n(c,u,i),h=n(c,u,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+a+")"}function fq(e){if(Qe.rgb(e))return dq(e);if(Qe.hex(e))return uq(e);if(Qe.hsl(e))return pq(e)}function Ua(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function mq(e){if(Ec(e,"translate")||e==="perspective")return"px";if(Ec(e,"rotate")||Ec(e,"skew"))return"deg"}function d0(e,t){return Qe.fnc(e)?e(t.target,t.id,t.total):e}function Js(e,t){return e.getAttribute(t)}function jy(e,t,i){var r=Ua(t);if(Fy([i,"deg","rad","turn"],r))return t;var s=kp.CSS[t+i];if(!Qe.und(s))return s;var a=100,n=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(n),n.style.position="absolute",n.style.width=a+i;var l=a/n.offsetWidth;o.removeChild(n);var h=l*parseFloat(t);return kp.CSS[t+i]=h,h}function iC(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?jy(e,s,i):s}}function Gy(e,t){if(Qe.dom(e)&&!Qe.inp(e)&&(Js(e,t)||Qe.svg(e)&&e[t]))return"attribute";if(Qe.dom(e)&&Fy(lq,t))return"transform";if(Qe.dom(e)&&t!=="transform"&&iC(e,t))return"css";if(e[t]!=null)return"object"}function rC(e){if(Qe.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,s;s=i.exec(t);)r.set(s[1],s[2]);return r}}function gq(e,t,i,r){var s=Ec(t,"scale")?1:0+mq(t),a=rC(e).get(t)||s;return i&&(i.transforms.list.set(t,a),i.transforms.last=t),r?jy(e,a,r):a}function Hy(e,t,i,r){switch(Gy(e,t)){case"transform":return gq(e,t,r,i);case"css":return iC(e,t,i);case"attribute":return Js(e,t);default:return e[t]||0}}function Wy(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Ua(e)||0,s=parseFloat(t),a=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+a+r;case"-":return s-a+r;case"*":return s*a+r}}function sC(e,t){if(Qe.col(e))return fq(e);if(/\s/g.test(e))return e;var i=Ua(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function qy(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function vq(e){return Math.PI*2*Js(e,"r")}function yq(e){return Js(e,"width")*2+Js(e,"height")*2}function xq(e){return qy({x:Js(e,"x1"),y:Js(e,"y1")},{x:Js(e,"x2"),y:Js(e,"y2")})}function aC(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var a=t.getItem(s);s>0&&(i+=qy(r,a)),r=a}return i}function bq(e){var t=e.points;return aC(e)+qy(t.getItem(t.numberOfItems-1),t.getItem(0))}function nC(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return vq(e);case"rect":return yq(e);case"line":return xq(e);case"polyline":return aC(e);case"polygon":return bq(e)}}function wq(e){var t=nC(e);return e.setAttribute("stroke-dasharray",t),t}function _q(e){for(var t=e.parentNode;Qe.svg(t)&&Qe.svg(t.parentNode);)t=t.parentNode;return t}function oC(e,t){var i=t||{},r=i.el||_q(e),s=r.getBoundingClientRect(),a=Js(r,"viewBox"),n=s.width,o=s.height,l=i.viewBox||(a?a.split(" "):[0,0,n,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:n/l[2],h:o/l[3]}}function Sq(e,t){var i=Qe.str(e)?tC(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:oC(i),totalLength:nC(i)*(r/100)}}}function Aq(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=oC(e.el,e.svg),s=i(),a=i(-1),n=i(1);switch(e.property){case"x":return(s.x-r.x)*r.w;case"y":return(s.y-r.y)*r.h;case"angle":return Math.atan2(n.y-a.y,n.x-a.x)*180/Math.PI}}function hS(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=sC(Qe.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:Qe.str(e)||t?r.split(i):[]}}function lC(e){var t=e?uf(Qe.arr(e)?e.map(lS):lS(e)):[];return df(t,function(i,r,s){return s.indexOf(i)===r})}function hC(e){var t=lC(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:rC(i)}}})}function Mq(e,t){var i=Vy(t);if(/^spring/.test(i.easing)&&(i.duration=$E(i.easing)),Qe.arr(e)){var r=e.length,s=r===2&&!Qe.obj(e[0]);s?e={value:e}:Qe.fnc(t.duration)||(i.duration=t.duration/r)}var a=Qe.arr(e)?e:[e];return a.map(function(n,o){var l=Qe.obj(n)&&!Qe.pth(n)?n:{value:n};return Qe.und(l.delay)&&(l.delay=o?0:t.delay),Qe.und(l.endDelay)&&(l.endDelay=o===a.length-1?t.endDelay:0),l}).map(function(n){return pf(n,i)})}function Eq(e){for(var t=df(uf(e.map(function(a){return Object.keys(a)})),function(a){return Qe.key(a)}).reduce(function(a,n){return a.indexOf(n)<0&&a.push(n),a},[]),i={},r=function(a){var n=t[a];i[n]=e.map(function(o){var l={};for(var h in o)Qe.key(h)?h==n&&(l.value=o[h]):l[h]=o[h];return l})},s=0;s<t.length;s++)r(s);return i}function Cq(e,t){var i=[],r=t.keyframes;r&&(t=pf(Eq(r),t));for(var s in t)Qe.key(s)&&i.push({name:s,tweens:Mq(t[s],e)});return i}function Tq(e,t){var i={};for(var r in e){var s=d0(e[r],t);Qe.arr(s)&&(s=s.map(function(a){return d0(a,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function Dq(e,t){var i;return e.tweens.map(function(r){var s=Tq(r,t),a=s.value,n=Qe.arr(a)?a[1]:a,o=Ua(n),l=Hy(t.target,e.name,o,t),h=i?i.to.original:l,u=Qe.arr(a)?a[0]:h,c=Ua(u)||Ua(l),d=o||c;return Qe.und(n)&&(n=h),s.from=hS(u,d),s.to=hS(Wy(n,u),d),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=Uy(s.easing,s.duration),s.isPath=Qe.pth(a),s.isColor=Qe.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var cC={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,s){if(r.list.set(t,i),t===r.last||s){var a="";r.list.forEach(function(n,o){a+=o+"("+n+") "}),e.style.transform=a}}};function dC(e,t){var i=hC(e);i.forEach(function(r){for(var s in t){var a=d0(t[s],r),n=r.target,o=Ua(a),l=Hy(n,s,o,r),h=o||Ua(l),u=Wy(sC(a,h),l),c=Gy(n,s);cC[c](n,s,u,r.transforms,!0)}})}function Pq(e,t){var i=Gy(e.target,t.name);if(i){var r=Dq(t,e),s=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:s.end,delay:r[0].delay,endDelay:s.endDelay}}}function Iq(e,t){return df(uf(e.map(function(i){return t.map(function(r){return Pq(i,r)})})),function(i){return!Qe.und(i)})}function uC(e,t){var i=e.length,r=function(a){return a.timelineOffset?a.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+l+a.duration*(a.loop??1)})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0;return r(a)+n+o+a.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+a.duration*(a.loop??1)-a.endDelay-l})):t.endDelay,s}var cS=0;function Oq(e){var t=c0(KE,e),i=c0(Ny,e),r=Cq(i,e),s=hC(e.targets),a=Iq(s,r),n=uC(a,i),o=cS;return cS++,pf(t,{id:o,children:[],animatables:s,animations:a,duration:n.duration,delay:n.delay,endDelay:n.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var rs=[],dS=[],Vu,Rq=function(){function e(){Vu=requestAnimationFrame(t)}function t(i){var r=rs.length;if(r){for(var s=0;s<r;){var a=rs[s];a.paused?(rs.splice(s,1),r-=1):(a.tick(i),s++)}e()}else Vu=cancelAnimationFrame(Vu)}return e}();function Lq(e){document.hidden?(rs.forEach(function(t){return t.pause(e.timeStamp)}),dS=rs.slice(0),si.running=rs=[]):dS.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",Lq);function si(e){e===void 0&&(e={});var t=0,i=0,r=0,s,a,n=0,o=null;function l(_){var S=window.Promise&&new Promise(function(M){return o=M});return _.finished=S,S}var h=Oq(e),u=l(h);function c(){var _=h.direction;_!=="alternate"&&(h.direction=_!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,a.forEach(function(S){(S.loop===1||S.loop%2===0)&&(S.reversed=h.reversed)})}function d(){h.direction="normal",h.reversed=!1,a.forEach(function(_){return _.reversed=!1})}function p(_){return h.reversed?h.duration-_:_}function f(){t=0,i=p(h.currentTime)*(1/si.speed)}function m(_,S,M=!1){S&&(h.reversed?S.seek(S.duration*S.loop-(_-S.timelineOffset-S.pingPongDelayCorrection),M):S.seek(_-S.timelineOffset-S.startOnceDelay-S.pingPongDelayCorrection,M))}function g(_,S=!1){if(h.reversed)for(var M=n;M--;)m(_,a[M],S);else for(var C=0;C<n;C++)m(_,a[C],S)}function v(_){var S=0,M=h.animations,C=M.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?_=h.duration-h.delay+h.endDelay-_:_=h.duration+h.delay-h.endDelay-_):w(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?_=h.duration-h.delay+h.endDelay-_:_=h.duration+h.delay-h.endDelay-_);S<C;){var T=M[S],D=T.animatable,P=T.tweens,I=P.length-1,R=P[I];I&&(R=df(P,function(Z){return _<Z.end})[0]||R);let re;h.parent?.reversed&&h.direction==="alternate"?re=Ss(_-R.start-R.endDelay,0,R.duration)/R.duration:re=Ss(_-R.start-R.delay,0,R.duration)/R.duration;for(var U=isNaN(re)?1:R.easing(re),N=R.to.strings,L=R.round,W=[],G=R.to.numbers.length,j=void 0,k=0;k<G;k++){var q=void 0;let Z,pe;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(Z=R.to.numbers[k],pe=R.from.numbers[k]||0):(pe=R.to.numbers[k],Z=R.from.numbers[k]||0):w(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(Z=R.to.numbers[k],pe=R.from.numbers[k]||0):(pe=R.to.numbers[k],Z=R.from.numbers[k]||0),R.isPath?q=Aq(R.value,U*pe):q=Z+U*(pe-Z),L&&(R.isColor&&k>2||(q=Math.round(q*L)/L)),W.push(q)}var H=N.length;if(!H)j=W[0];else{j=N[0];for(var Y=0;Y<H;Y++){var V=N[Y],ie=N[Y+1],Q=W[Y];isNaN(Q)||(ie?j+=Q+ie:j+=Q+" ")}}cC[T.type](D.target,T.property,j,D.transforms),T.currentValue=j,S++}}function y(_){h[_]&&!h.passThrough&&h[_](h)}function x(){h.remaining&&h.remaining!==!0&&h.remaining--}let b={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function w(_,S,M,C,T){return b[_<<4|S<<3|M<<2|C<<1|T]}function A(_,S=!1){var M=h.duration;let C=h.delay,T=M-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(C=h.endDelay,T=M-h.delay);var D=p(_);if(h.progress=Ss(D/M*100,0,100),S||(h.reversePlayback=D<h.currentTime),n&&g(D,S),!h.began&&h.currentTime>=0&&(h.began=!0,y("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,y("loopBegin")),(h.reversed||D>=0)&&D<=C&&h.currentTime!==0&&(v(0),y("change")),(D>=T&&h.currentTime!==M+h.pingPongDelayCorrection||!M)&&(v(M),y("change")),D>C&&D<T?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,y("changeBegin")),v(D),y("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,y("change"),n&&y("timelineChangeComplete")):h.began&&D>T&&y("changeComplete"),h.currentTime=Ss(D,0,M+h.pingPongDelayCorrection),h.began&&y("update"),_>=M)if(x(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,y("loopComplete"),y("complete"),!h.passThrough&&"Promise"in window&&(o(),u=l(h)));else{n?t+=h.duration/si.speed:t+=h.duration;for(let P of a)P.setStartTime(0),P.remaining=P.loop;y("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?c():n&&d()}}return h.reset=function(){var _=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversePlayback=!1,h.reversed=_==="reverse",h.remaining=h.loop,a=h.children,n=a.length;for(var S=n;S--;)h.children[S].reset();v(h.reversed?h.duration:0)},h.setStartTime=function(_){t=_},h.set=function(_,S){return dC(_,S),h},h.tick=function(_){r=_,t||(t=r),A((r+(i-t))*si.speed)},h.seek=function(_,S=!1){A(_-t,S)},h.pause=function(_){h.paused=!0,n&&(s=_??performance.now())},h.play=function(_){!h.paused||(h.completed&&h.reset(),h.paused=!1,rs.push(h),n&&s!==void 0&&(t+=(_??performance.now())-s),Vu||Rq())},h.reverse=function(){c(),h.completed=!h.reversed,f()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function uS(e,t){for(var i=t.length;i--;)Fy(e,t[i].animatable.target)&&t.splice(i,1)}function Bq(e){for(var t=lC(e),i=rs.length;i--;){var r=rs[i],s=r.animations,a=r.children;uS(t,s);for(var n=a.length;n--;){var o=a[n],l=o.animations;uS(t,l),!l.length&&!o.children.length&&a.splice(n,1)}!s.length&&!a.length&&r.pause()}}function zq(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?Uy(t.easing):null,s=t.grid,a=t.axis,n=t.from||0,o=n==="first",l=n==="center",h=n==="last",u=Qe.arr(e),c=parseFloat(u?e[0]:e),d=u?parseFloat(e[1]):0,p=Ua(u?e[1]:e)||0,f=t.start||0+(u?c:0),m=[],g=0;return function(v,y,x){if(o&&(n=0),l&&(n=(x-1)/2),h&&(n=x-1),!m.length){for(var b=0;b<x;b++){if(!s)m.push(Math.abs(n-b));else{var w=l?(s[0]-1)/2:n%s[0],A=l?(s[1]-1)/2:Math.floor(n/s[0]),_=b%s[0],S=Math.floor(b/s[0]),M=w-_,C=A-S,T=Math.sqrt(M*M+C*C);a==="x"&&(T=-M),a==="y"&&(T=-C),m.push(T)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(P){return r(P/g)*g})),i==="reverse"&&(m=m.map(function(P){return a?P<0?P*-1:-P:Math.abs(g-P)}))}var D=u?(d-c)/g:c;return f+D*(Math.round(m[y]*100)/100)+p}}function kq(e){e===void 0&&(e={});var t=si(e);return t.duration=0,t.add=function(i,r){var s=rs.indexOf(t),a=t.children;s>-1&&rs.splice(s,1);function n(d){d.passThrough=!0}for(var o=0;o<a.length;o++)n(a[o]);var l=pf(i,c0(Ny,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=Qe.und(r)?h:Wy(r,h),n(t);var u=si(l);n(u),a.push(u),u.parent=t;var c=uC(a,e);return t.delay=c.delay,t.endDelay=c.endDelay,t.duration=c.duration,u.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}si.version="3.2.0";si.speed=1;si.running=rs;si.remove=Bq;si.get=Hy;si.set=dC;si.convertPx=jy;si.path=Sq;si.setDashoffset=wq;si.stagger=zq;si.timeline=kq;si.easing=Uy;si.penner=eC;si.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var pC=si,pS=new E,fS=new E,mS=new $e;function Nq(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let s=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(s>=1)return i.copy(e);let a=1-s*s;if(a<=Number.EPSILON){let u=1-r;return i.w=u*e.w+r*t.w,i.x=u*e.x+r*t.x,i.y=u*e.y+r*t.y,i.z=u*e.z+r*t.z,i.normalize(),i}let n=Math.sqrt(a),o=Math.atan2(n,s),l=Math.sin((1-r)*o)/n,h=Math.sin(r*o)/n;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function Mo(e,t,i,r,s,a){let n=i[e]?i[e]:void 0,o=r[e];if(o==null)return;let l=n!=null?typeof n=="string"?Number(s.getVariable(n)??0):n:t[e],h=typeof o=="string"?Number(s.getVariable(o)??0):o;if(l!==h)return{update:u=>{let c=Le.lerp(l,h,u);a?t[e]=Math.trunc(c):t[e]=c},start:()=>{t[e]=l},end:()=>{t[e]=h}}}function fC(e,t,i,r,s,a){let n=i[e]?i[e]:void 0,o=r[e];if(!o)return;let l=t[e],h=[...n??l].map(c=>typeof c=="string"?Number(s.getVariable(c)??0):c),u=[...o].map(c=>typeof c=="string"?Number(s.getVariable(c)??0):c);if(!(h.length!==u.length||M2(h,u)))return{update:c=>{h.forEach((d,p)=>{let f=Le.lerp(d,u[p],c);t[e][p]=a?Math.trunc(f):f})},start:()=>{Object.assign(t[e],h)},end:()=>{Object.assign(t[e],u)}}}function Np(e,t,i){return t.forEach((r,s)=>{e.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function gS(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?Np(new E,a,s):o.clone(),h=Np(new E,n,s);if(!l.equals(h))return{update:u=>{o.lerpVectors(l,h,u)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function Uq(e,t,i,r){let s=i[e]?i[e]:void 0,a=r[e];if(!a)return;let n=t[e],o=s?new me().fromArray(s):n.clone(),l=new E,h=new $e,u=new E;o.decompose(l,h,u);let c=new me().fromArray(a),d=new E,p=new $e,f=new E;if(c.decompose(d,p,f),!o.equals(c))return{update:m=>{mS.slerpQuaternions(h,p,m),pS.lerpVectors(l,d,m),fS.lerpVectors(u,f,m),n.compose(pS,mS,fS)},start:()=>{n.compose(l,h,u)},end:()=>{n.compose(d,p,f)}}}function Fq(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?typeof a=="string"?s.getColor(a).clone():new Ve().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new Ve().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let u=o.clone();return t[e]=u,{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Rn(e,t,i,r,s){if(typeof t[e]=="number")return Mo(e,t,i??{},r,s);if(Array.isArray(t[e]))return fC(e,t,i??{},r,s)}function Vq(e,t,i,r){let s=[],a=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let o=a??e.zoom,l=n;o!==l&&s.push({update:h=>{e.zoom=Le.lerp(o,l,h),e.updateProjectionMatrix()},start:()=>{e.zoom=o,e.updateProjectionMatrix()},end:()=>{e.zoom=l,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let o=Mo("targetOffset",e,t,i,r);o&&s.push(o)}return s}function jq(e,t,i,r){if(i.scaleBaked===void 0)return;let s=(t.scaleBaked??e.data.geometry.scaleBaked).map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o),a=i.scaleBaked.map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o);if(fo.isEqual(s,a))return;let n=[];return n.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[Le.lerp(s[0],a[0],o),Le.lerp(s[1],a[1],o),Le.lerp(s[2],a[2],o)]},r),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({scaleBaked:a},r),e.invalidateDownstreamBooleanData()}}),n}function Gq(e,t,i,r){if(!i.extrusion)return;let s=e.extrusion,a=t.extrusion??{},n=i.extrusion,o=[];return hM.forEach(l=>{let h=Rn(l,s,a,n,r);h&&o.push(h)}),o}function Hq(e,t,i,r){let s=[];if(!("geometry"in i))return s;let a=e.geometry.userData.parameters,n="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof Wc){let l=jq(e,n,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,ka(a,sw)),sw.forEach(h=>{let u=Rn(h,l,n,o,r);u&&s.push(u)}),e instanceof Oy){Object.assign(l,{extrusion:{...a.extrusion}});let h=Gq(l,n,o,r);h&&s.push(...h)}s.length&&s.push({update:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},start:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},end:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()}})}return s}function Wq(e,t,i,r){let s=[];if(i.intensity!==void 0){let a=Mo("intensity",e,t,i,r);a&&s.push(a)}if(i.color!==void 0){let a=Fq("color",e,t,i,r);a&&s.push(a)}return s}function qq(e,t,i,r){let s=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return s;let a="materials"in t&&t.materials?t.materials:[],n=i.materials;e.material.forEach((o,l)=>{if(!n[l])return;let h=a[l]??{},u=n[l];typeof h=="string"||typeof u=="string"||s.push(...vS(o,h,u,r))})}else{if(!("material"in i&&i.material))return s;let a="material"in t&&t.material?t.material:{},n=i.material;if(typeof a=="string"||typeof n=="string")return s;s.push(...vS(e.material,a,n,r))}return s}function vS(e,t,i,r){let s=[],a=Tl(i,r)||!!t.layers&&Tl(t,r);s.push(tY(e,a));for(let n of e.layers){let o=t.layers?.data(n.uuid),l=i.layers.data(n.uuid);if(!l||n.type!=="light"&&(!(n.visible??!0)||!(l.visible??!0)))continue;let h=n.getNames().filter(u=>!nM.some(c=>u.includes(c)));for(let u of h)try{let c=n.getValue(u),d;if(u==="colors")d=$q(n,o,l,u);else if(Array.isArray(c))u==="steps"&&(d=Jq(n,o,l,u));else if(typeof c=="number")d=Yq(n,o,l,u,r);else{if(typeof c=="boolean")continue;c instanceof F?d=Xq(n,o,l,u):c instanceof E?d=Qq(n,o,l,u,r):c instanceof Cr?d=Kq(n,o,l,u,r):c instanceof Ve?d=Zq(n,o,l,u,r):"isTexture"in c&&(d=eY(n,o,l,u))}d&&(Array.isArray(d)?s.push(...d):s.push(d))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${u}`,c)}}return s}function Yq(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:e.getValue(r),n=i[r],o=typeof a=="string"?Number(s.getVariable(a)??0):a,l=typeof n=="string"?Number(s.getVariable(n)??0):n;if(o!==l)return{update:h=>{e.setValue(r,Le.lerp(o,l,h))},start:()=>{e.setValue(r,o)},end:()=>{e.setValue(r,l)}}}function Xq(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),a=t?new F().fromArray(t[r]):s.clone(),n=new F().fromArray(i[r]);if(!a.equals(n))return{update:o=>{s.lerpVectors(a,n,o)},start:()=>{s.copy(a)},end:()=>{s.copy(n)}}}function Qq(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=e.getValue(r),n=t?t[r]:void 0,o=i[r],l=n?Np(new E,n,s):a.clone(),h=Np(new E,o,s);if(!l.equals(h))return{update:u=>{a.lerpVectors(l,h,u)},start:()=>{a.copy(l)},end:()=>{a.copy(h)}}}function Zq(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new Ve().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new Ve().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let u=o.clone();return{update:c=>{e.getValue(r)!==u&&e.setValue(r,u),u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Kq(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new Ve().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new Cr(n.r,n.g,n.b,n.a);if(l.equals(h))return;let u=o.clone();return{update:c=>{e.getValue(r)!==u&&e.setValue(r,u),u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Jq(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a,o=i[r];for(let l=0;l<a.length;++l){let h=n[l],u=o[l];h!==u&&s.push({update:c=>{a[l]=Le.lerp(h,u,c)},start:()=>{a[l]=h},end:()=>{a[l]=u}})}return s.length?s:void 0}function $q(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a.map(l=>l.toArray()),o=i[r];for(let l=0;l<a.length;++l){let h=[...n[l]],u=[...o[l]];gp.isEqual(h,u)||s.push({update:c=>{a[l].fromArray(gp.lerp(h,u,c))},start:()=>{a[l].fromArray(h)},end:()=>{a[l].fromArray(u)}})}return s.length?s:void 0}function eY(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("mat");if(!s)return;let a=t?t[r]:s,n=i[r],o=[...a.repeat],l=[...a.offset],h=[...n.repeat],u=[...n.offset];if(!El.isEqual(o,h)||!El.isEqual(l,u))return{update:c=>{s.repeat=El.lerp(o,h,c),s.offset=El.lerp(l,u,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...u],s.updateMatrix()}}}function tY(e,t){return{update:()=>{e.transparent=t}}}var cg=new E,yS=new Di;function iY(e,t,i,r,s){let a=[],n,o,l,h,u,c,d={slide:t.pathSnapping?.slide??e.updatedPathSnapping?.slide??e.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??e.updatedPathSnapping?.offset??e.dataPatched.pathSnapping?.offset??0};if(u=Mo("slide",d,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),u&&a.push(u),c=Mo("offset",d,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),c&&a.push(c),!u&&!c&&(n=gS("position",e,t,i,s),n&&a.push(n),o=gS("scale",e,t,i,s),o&&a.push(o),l=rY(e,t,i,r,s),l&&a.push(l),h=Uq("hiddenMatrix",e,t,i),h&&a.push(h)),n||o||l||h||u||c){let p=()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),ys(e)&&Zs(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,d))};a.push({update:p,start:p,end:p})}return a}function rY(e,t,i,r,s){let a=t?.rotation?t.rotation.map(u=>(typeof u=="string"?Number(s.getVariable(u)??0):u)*Le.DEG2RAD):void 0,n=i.rotation?.map(u=>(typeof u=="string"?Number(s.getVariable(u)??0):u)*Le.DEG2RAD);if(!n)return;let o=a?new E().fromArray(a):new E().setFromEuler(e.rotation),l=new E().fromArray(n);if(o.equals(l))return;let h=cg.subVectors(l,o);if(r&&h.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new $e().setFromEuler(yS.setFromVector3(o)),c=new $e().setFromEuler(yS.setFromVector3(l));return{update:d=>{Nq(u,c,e.quaternion,d)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}else return{update:u=>{cg.lerpVectors(o,l,u),e.rotation.setFromVector3(cg)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}function sY(e,t,i,r){let s=[];if(!("cloner"in i)||!e.cloner)return s;let a=e.cloner,n="cloner"in t?t.cloner:{},o=i.cloner;eM.forEach(p=>{let f;p==="count"?f=Mo("count",a.parameters,n,o,r,!0):f=Rn(p,a.parameters,n??{},o,r),f&&s.push(f)});let l=aY(a,n,o,r);l?.length&&s.push(...l);let h=nY(a,n,o,r);h?.length&&s.push(...h);let u=oY(a,n,o,r);u?.length&&s.push(...u);let c=lY(a,n,o,r);c?.length&&s.push(...c);let d=hY(a,n,o,r);return d?.length&&s.push(...d),s.length&&s.push({update:()=>{a.update()}}),s}function aY(e,t,i,r){if(e.parameters.type!=="radial")return;let s=t.radial,a=i.radial;if(!a)return;let n=e.parameters.radial,o=[];return tM.forEach(l=>{let h=Rn(l,n,s??{},a,r);h&&o.push(h)}),o}function nY(e,t,i,r){if(e.parameters.type!=="linear")return;let s=t.linear,a=i.linear;if(!a)return;let n=[],o=e.parameters.linear;return iM.forEach(l=>{let h=Rn(l,o,s??{},a,r);h&&n.push(h)}),n}function oY(e,t,i,r){if(e.parameters.type!=="grid")return;let s=t.grid,a=i.grid;if(!a)return;let n=[],o=e.parameters.grid;return rM.forEach(l=>{let h;l==="count"?h=fC(l,o,s??{},a,r,!0):h=Rn(l,o,s??{},a,r),h&&n.push(h)}),n}function lY(e,t,i,r){if(e.parameters.type!=="toObject")return;let s=t.toObject,a=i.toObject;if(!a)return;let n=[],o=e.parameters.toObject;return sM.forEach(l=>{let h;l==="count"?h=Mo(l,o,s??{},a,r,!0):h=Rn(l,o,s??{},a,r),h&&n.push(h)}),n}function hY(e,t,i,r){if(!e.parameters.randomness)return;let s=t.randomnessObject,a=i.randomnessObject;if(!a)return;let n=[],o=e.parameters.randomnessObject;return aM.forEach(l=>{let h=Rn(l,o,s??{},a,r);h&&n.push(h)}),n}function xS(e,t,i,r,s){let a=[];return e.data.visible&&a.push(...iY(e,t,i,s,r)),e.data.visible&&a.push(...sY(e,t,i,r)),ys(e)?(e instanceof dr&&e.data.visible&&a.push(...Hq(e,t,i,r)),e.data.visible&&a.push(...qq(e,t,i,r))):p9(e)?e.data.visible&&a.push(...Wq(e,t,i,r)):u9(e)&&a.push(...Vq(e,t,i,r)),a.length?{update:n=>{a.forEach(o=>o.update(n))},start:n=>{a.forEach(o=>o.start?.(n))},end:n=>{a.forEach(o=>o.end?.(n))}}:void 0}var bS=new E;function Yy(e,t,i=!1){let r=[];e.traverseChildren(s=>{if(i&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(bS,!0),s.rigidBody?.setAngvel(bS,!0)),!pt.is(s))return;let a=s.uuid,n=s.data;if(delete s.states,s.uuid===_h)return;let o=!1;r.some(l=>e.scene.find(a)?.isDescendantOf(l))?o=!0:n.physics?.fusedBody===!0&&n.physics.rigidBody==="dynamic"&&r.push(a),s.data=n,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let l of n.states){let h={...l.data};e.data.globalPhysics.usePhysics===!0&&n.physics&&(n.physics.rigidBody==="dynamic"||o)&&(l.data.position!==void 0&&delete h.position,l.data.rotation!==void 0&&delete h.rotation,l.data.hiddenMatrix!==void 0&&delete h.hiddenMatrix),s.states||(s.states={}),s.states[l.id]=so.patch(n,h)}dY(e.scene,s,null,t,n.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),cY(e)})}function cY(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let s of r)if(s.data.type==="Create"&&s.data.hideBase==="Yes"){let a=e.scene.find(s.data.object);a&&(a.visible=!1)}}})}function dY(e,t,i,r,s=!1){if(t instanceof dr&&t.removeInteractionGeometry(),t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof dr&&t.updateGeometryGroupsIfNeeded(),t instanceof Xi&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),t.cloner)for(let a of t.cloner.children)a.playModeVisible=void 0;t.updateVisible()}function mC(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
|
|
6425
6425
|
${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
|
|
6426
|
-
)`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:a}=e;t=`spring( ${i}, ${r}, ${s}, ${a} )`}else{let i;switch(e.easing){case 0:i=ln.linear;break;case 1:i=ln.ease;break;case 2:i=ln.easeIn;break;case 3:i=ln.easeOut;break;case 4:i=ln.easeInOut;break;default:i=ln.linear}let[r,s,a,n]=i;t=`cubicBezier( ${r}, ${s}, ${a}, ${n} )`}return{duration:e.duration,easing:t}}function u0(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var uY={type:"beginState"},pY={type:"completeState",isfromEntity:!1},wS=class{constructor(e,t,i,r,s,a){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=a,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let n=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"beginState",state:n}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Xi&&o.dispatchEvent(uY)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let n=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"completeState",state:n}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Xi&&o.dispatchEvent(pY)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=xS(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=ju(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=ju(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=ju(this.object,i);if(!n)throw new Error("Missing property");this.to=n}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...u0(r),...mC(r),change:this.onChange},this.callback=xS(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},gC=class extends Ni{constructor(e,t,i,r){if(super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let s=this.page.scene.find(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline&&this.timeline.paused===!1}init(){this.initialCurrentState=ju(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=u0(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=pC.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(a=>a?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let a=s===-1?0:s;for(let n=a;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Xi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new wS(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(u.params,{startOnceDelay:0}),this.tweens[n]=u,this.timeline.add(u.params,this.timeline.duration+(n===a?r.delay:0))}this.timeline.duration+=r.endDelay}else{let a=s===-1?this.data.tweens.length-1:s+1;for(let n=a;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Xi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new wS(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(u.params,{startOnceDelay:0}),this.tweens[n-1]=u,this.timeline.add(u.params,this.timeline.duration+(n===a?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(gi(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=u0(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(gi(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function ju(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var fY={type:"beginState"},_S={type:"completeState",isfromEntity:!1},SS={type:"requestRender"},vC=class extends Ni{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new E,this.posEnd=new E,this.qStart=new $e,this.qEnd=new $e,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=pC({targets:i,t:1,...mC(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(fY));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(SS),i.t===1&&r.dispatchEvent(_S)}})}switchCamera(e){let t=this.page.scene.find(e);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(t),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:t})}play(){if(gi(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(gi(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(_S),this.page.activeCamera.dispatchEvent(SS))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},yC=class extends Ni{constructor(e,t,i,r,s){super(),this.page=t,this.animationControls=i,this.shared=r,this.condition=s,this.startOnceDelay=0,this.toggleIsForward=!1;let a=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(a=n.identity[0]),this.data={...e,object:a};let o=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=o?.getClip()?.duration??1;let l=o?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(gi(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Le.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(gi(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let a=r.split("/")[1];this.threeAnimAction!==s&&a===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},xC=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=s,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(gi(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),Yy(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},bC=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=gi(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=NM(this.data.expression,this.shared,Fr.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},wC=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(gi(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function gi(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=NM(t.expression,e,"boolean");return t.negate?!i:!!i}function fr(e,t,i,r,s,a){let n={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},o=l=>({id:h,data:u})=>{try{u.type==="Audio"?Br[e.type].includes("Audio")&&n.Audio.push(new XE(h,u,a,r,l)):u.type==="Video"?Br[e.type].includes("Video")&&n.Video.push(new SC(h,u,a,r,l)):u.type==="Link"?Br[e.type].includes("Link")&&n.Link.push(new oq(u,s.controlsManager,r,l)):u.type==="Create"?Br[e.type].includes("Create")&&n.Create.push(new AC(u,i,s.controlsManager,r,l)):u.type==="Destroy"?Br[e.type].includes("Destroy")&&n.Destroy.push(new QE(u,i,s.controlsManager,r,l)):u.type==="Reset"?Br[e.type].includes("Reset")&&n.Reset.push(new ZE(u,i,r,s,l)):u.type==="Transition"?Br[e.type].includes("Transition")&&n.Transition.push(new gC(u,i,r,l)):u.type==="SwitchCamera"?Br[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new vC(u,i,r,l)):u.type==="SceneTransition"?Br[e.type].includes("SceneTransition")&&n.SceneTransition.push(new xC(u,i,s,r,l)):u.type==="Animation"?Br[e.type].includes("Animation")&&n.Animation.push(new yC(u,i,s.animationControls,r,l)):u.type==="SetVariable"?Br[e.type].includes("SetVariable")&&n.SetVariable.push(new bC(u,i,r,l)):u.type==="DynamicVariablePlay"?Br[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new wC(u,i,r,l)):u.type==="Conditional"&&Br[e.type].includes("Conditional")&&(u.ifActions.forEach(o({expression:u.condition,negate:!1})),u.elseActions.forEach(o({expression:u.condition,negate:!0})))}catch{}};return t.forEach(o()),n}function Ii(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof XE||i instanceof SC||i instanceof yC||i instanceof gC||i instanceof AC||i instanceof QE||i instanceof vC||i instanceof xC||i instanceof ZE||i instanceof bC||i instanceof wC)&&i.dispose()})})}function mY(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var _C=new Map,Cc=new Map,ql=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:a,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=mY(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,a!==void 0&&(this.videoElement.volume=a)),n!==void 0&&(this.delay=n),Cc.has(i.uuid)?Cc.get(i.uuid).push(this):Cc.set(i.uuid,[this]),_C.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},p0=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=_C.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=Cc.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...Cc.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},SC=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new ql(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new p0(t);else throw new Error("Missing property")}dispatchBasic(){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof ql?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof ql?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},AS=(()=>{let e,t,i,r;function s(o){!e&&!MS()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(a)),o&&(t=o,r=o.requestRender)}function a(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,d=0;for(;d<c;){let p=h[d];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&u[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(u[p.userData.actionId]>p.userData.quantity&&u[p.userData.actionId]--,h.splice(d,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}e=d>0?requestAnimationFrame(a):void 0,i=d>0?o:void 0}function n(){MS()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),s})();function MS(){return!!document&&document.hidden}var ES=new $e,gY=new E,vY=new E,AC=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=Le.generateUUID(),this.dispatch=()=>{if(gi(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{if(gi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=n6(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let n=new qi(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.position.fromArray(this.data.position),n.rotation.fromArray(this.data.rotation),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),AS(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof _s)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof qi)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof _s)return;n instanceof qi?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new E().fromArray(this.data.velocity),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(gY,ES,vY),l.applyQuaternion(ES),this.data.velocity.some(u=>u!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(u=>u!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");AS(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},MC=200,dg=.02,ug=.3,yY=65,JQ=new E,CS=new E,TS=new E,xY=new E,er=new E,vr=new E,sn=new E,pg=new me,DS=new me,bY=new me,$Q=new me,ps=new $e,xa=new $e,Ns=new Di(0,0,0,"YXZ"),wY=new E(1,0,0),fs=new E(0,1,0),_Y=new E(0,0,1),PS=new E(1,1,1),eZ=new Tr,SY=1,AY=.025,MY=16e-6,IS=12,EY=20,Ci=new is,Xr=new ai,CY={type:"requestRender"},TY={type:"updateMatrix"},OS=Math.PI/6,f0=class extends Ni{constructor(e,t,i,r,s,a,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=a,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new me,this.target0=new E,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=MC,this.euler0=new Di(0,0,0,"YXZ"),this.position0Cam=new E,this.quat0Cam=new $e,this.scale0Cam=new E,this.hiddenMatrix0Cam=new me,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new is(new E(0,-40,0),new E(0,40,0)),matrix:new me,position:new E,rotation:new $e},this.euler=new Di(0,0,0,"YXZ"),this.eulerDelta=new E,this.lastPosition=new E,this.lastCameraQuaternion=new $e,this.lastCameraPosition=new E,this.PI_2=Math.PI/2,this.prevMouse=new F,this.velocityTarget=new E,this.velocity=new E,this.directionXZ=new E,this.rotVelocityStick=new E,this.rotVelocityTarget=new E,this.rotVelocity=new E,this.rotDirection=new E,this.nonColliderRotOffset=new me,this.nonColliderPosOffset=new me,this.firstPointerId=-1,this.rot=new E,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new me,this.objectToTarget=new E,this.objectToTarget0=new E,this.objectToCamXZ=new E,this.objectToCamXZ0=new E,this.targetToCamera=new E,this.targetToCamera0=new E,this.cameraPolarAxis0=new E,this.targetPos=new E,this.targetQuat=new $e,this.lerpFactorPos=new E().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new $e,this.objXZQuatInv=new $e,this.objXZRotMat=new me,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new E,this.pushedVelocity=new E,this.groundYRotation=0,this.objectRealQuat=new $e,this.colliderWorldQuat=new $e,this.groundNormal=new E,this.groundTilt=new $e,this.groundTiltInv=new $e,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new E,this.quaternion=new $e,this.scale=new E,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Ur&&(!Db||Pb>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(Db&&Pb<15.5&&!Ur?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?f0.isLocked=!0:f0.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),u=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,u,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new E(0,0,-1).applyQuaternion(this.camera.quaternion),m=new E().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g,v;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,v=m.projectOnVector(f)):m.y/f.y>0?v=f.multiplyScalar(m.y/f.y):v=f.multiplyScalar(m.length()),this.targetToCamera0.copy(v).negate(),g=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(g,this.position);let y=new Di().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Xi&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*SY,this.speedOrbit=(i.speedRotate??100)*AY,this.mouseOrbitSensitivity=(i.speedRotate??100)*MY,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??ih.defaultData.gravity)*IS,this.usePhysics=this.gloabalPhysics.usePhysics??ih.defaultData.usePhysics,this.jumpPower=i.jumpPower*EY,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Ep.defaultDataThirdPerson.orientWith,this.slopeThresh=yY*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*dg/this.pixelsPerMeter,this.stepThresh=i.collider.height*ug/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*dg/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*ug/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*dg/this.pixelsPerMeter,this.stepThresh=i.collider.height*ug/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new E().fromArray(i.collider.position),d=new $e().setFromEuler(new Di().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(c,d,PS),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new We;f.push({fi:0,data:{...xr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...xr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new My({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new hr(yM.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new Di().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Xi?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Mp.list.forEach(i=>{this.actions[i]=fr({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Ii(this.actions.idle),Ii(this.actions.move),Ii(this.actions.run),Ii(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return er.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let o=vr.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*IS),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===h&&u.userData.isFollowingObj!==this.object.uuid){(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(er,xa,vr),this.groundVelocity.subVectors(er,u.prevT),this.object.getWorldPosition(vr).add(this.collider.position).sub(er),this.groundYRotation=Ns.setFromQuaternion(xa).y-u.prevR.y,sn.copy(vr).applyAxisAngle(fs,this.groundYRotation),this.groundVelocity.add(sn.sub(vr)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=er.subVectors(this.path[1],this.position),h=vr.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=xY.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=vr.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let o=er;this.camera.getWorldDirection(o);let l=sn.copy(fs).multiplyScalar(o.dot(fs));o.sub(l);let h=vr.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Ns.setFromVector3(this.rot),this.moveMode==="walk"&&(Ns.x=0),n.applyEuler(Ns),a&&(xa.setFromUnitVectors(fs,this.groundNormal),n.applyQuaternion(xa)),i){let o=Ns.set(0,this.vrEulerYOffset*OS,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=vr;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=sn.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),er.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=pt.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==c){let d;l instanceof qi&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),c.dispatchEvent(g0));this.lastHitObj=c}if(u!==null){this.pushedVelocity.copy(h),o.copy(u.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(fs,this.euler.y-this.euler0.y);let o=vr.copy(this.objectToCamXZ).normalize(),l=sn.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(er.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Le.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Le.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Le.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(Ns.copy(t),Ns.y=0):(Ns.copy(this.euler),Ns.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Ns)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*OS),ps.setFromAxisAngle(wY,this.rot.x),xa.setFromAxisAngle(fs,this.rot.y),xa.multiply(ps),ps.setFromAxisAngle(_Y,this.rot.z),xa.multiply(ps),this.quaternion.copy(xa),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=vr.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new E;for(let u=0;u<5;u++){let c=o.length(),d=sn.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,d,this.object.rigidBody?.collider(0).shape,c,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&u===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,b;if(p.cloner){for(let w of p.cloner.children)if(w.rigidBody===x){b=w;break}}y.dispatch(b),p.dispatchEvent(g0)}}}let f=CS.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=TS.copy(d).multiplyScalar(l.toi).dot(f),g=l.toi;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=l.toi*(m-this.offset)/m,h.addScaledVector(d,g)),o.copy(d).multiplyScalar(c-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),y=sn.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let x=v.add(y);x.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);b!==null&&b.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{u===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(er.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(ps.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);pg.lookAt(l,o,fs).setPosition(l),pg.decompose(this.targetPos,this.targetQuat,er),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Le.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Le.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(TY),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(CY),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=ps.setFromAxisAngle(fs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Le.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=Le.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=Le.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=er.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=xa.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){fs.angleTo(e)*180/Math.PI<15||fs.angleTo(e)*180/Math.PI>85?ps.identity():ps.setFromUnitVectors(fs,e),this.groundTilt.slerp(ps,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=TS.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=pg.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(er,ps,vr).compose(er,ps,PS);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;Xr.makeEmpty(),s.updateMatrixWorldSVD();let a=s.matrixWorldRigid,n=DS.copy(a).invert(),o=bY.copy(DS).multiply(i);Ci.copy(this.collider.segment),Ci.start.applyMatrix4(o),Ci.end.applyMatrix4(o);let l=CS.copy(this.position).applyMatrix4(n);Xr.expandByPoint(Ci.start),Xr.expandByPoint(Ci.end),Xr.min.addScalar(-this.collider.radius),Xr.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Ci.end)},intersectsBounds:h=>h.intersectsBox(Xr),intersectsTriangle:h=>{let u=er,c=vr,d=h.closestPointToSegment(Ci,u,c);if(d<this.collider.radius){let p=this.collider.radius-d,f=c.sub(u).normalize(),m=sn.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(a).sub(this.position);t.add(g),Ci.start.addScaledVector(f,p),Ci.end.addScaledVector(f,p)}}})}),Xr.makeEmpty(),Ci.copy(this.collider.segment),Ci.start.applyMatrix4(i),Ci.end.applyMatrix4(i),Xr.expandByPoint(Ci.start),Xr.expandByPoint(Ci.end),Xr.min.addScalar(-this.collider.radius),Xr.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(Ci.end)},intersectsBounds:s=>s.intersectsBox(Xr),intersectsTriangle:s=>{let a=er,n=vr,o=s.closestPointToSegment(Ci,a,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),Ci.start.addScaledVector(h,l),Ci.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},EC=f0;EC.isLocked=!1;var DY=Ri(ZS());function Pa(e,t){let i=new Ue;if(!e.getAttribute("position"))return i.setAttribute("position",new Te([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=lf(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Te(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var PY=new me,IY=new me,Us=[[0,0,0],[0,0,0],[0,0,0]];function CC(e){let t=e.elements;Us[0][0]=t[0],Us[0][1]=t[4],Us[0][2]=t[8],Us[1][0]=t[1],Us[1][1]=t[5],Us[1][2]=t[9],Us[2][0]=t[2],Us[2][1]=t[6],Us[2][2]=t[10];let{u:i,v:r}=(0,DY.SVD)(Us),s=PY.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),a=IY.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);return s.multiply(a.transpose())}var OY=class extends jA{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new In({color:65280,linewidth:10}),t=new E(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new E(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new E().addVectors(t,i.multiplyScalar(r)),a=new Ue;return a.setFromPoints([t,s]),new Ku(a,e)}},TC=e=>e instanceof Gl||e instanceof Hl;function RY(e,t){return e.distance-t.distance}function DC(e,t,i){if(!(!Da(t)||!t.visible)){ys(t)&&t.raycast(e,i);for(let r of t.children)DC(e,r,i)}}function Gu(e,t,i,r=!1){if(!r&&!i.some(a=>Up(e,a)!==void 0))return[];let s=[];return t.children.forEach(a=>DC(e,a,s)),s.sort(RY),s}function m0(e){let t=[];if(e.length){let i=e[0].object;Da(i)&&t.push(i);let r=i.parent;for(;r;)TC(r)&&t.push(r),r=r.parent}return t}function Up(e,t){if(ys(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(TC(t))return PC(e,t)}function PC(e,t){if(!(!Da(t)||!t.visible)){if(ys(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=PC(e,i);if(r)return r}}}function LY(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}var BY=class{constructor(e,t,i,r,s,a,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=a,this.isExport=n,this.frame=o,this.raycaster=new OY,this.raycasterNeedsUpdate=!0,this._useWindowEvents=!1,this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this.domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateDomRect(){this.domRect=this.domElement.getBoundingClientRect()}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.updateDomRect(),this.raycaster.setFromCamera(LY(t,i,this.domRect),this.getCamera())}},IC=(e=>(e[e.keydown=0]="keydown",e[e.keyup=1]="keyup",e[e.pointerdown=2]="pointerdown",e[e.pointerup=3]="pointerup",e[e.pointermove=4]="pointermove",e[e.wheel=5]="wheel",e[e.scroll=6]="scroll",e))(IC||{}),Ds=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},Xy=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],OC=e=>Xy.find(([t,i])=>i===e)?.[0],od=e=>Xy.find(([t])=>t===e)?.[1],zY=(e,t)=>{let i=OC(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},kY=class extends Ds{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[OC(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of Xy)if(i.data.events.some(a=>a.data.type===s&&!a.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let a={id:i.uuid,name:i.name},n=zY(s,a),o=this.splineEvents[r];o?o[i.uuid]=n:this.splineEvents[r]={[i.uuid]:n}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},NY=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.runMode==="Toggle",(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=fr(t,t.actions,r,s,a,i)}disconnect(){Ii(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},UY=class extends Ds{constructor(e,t,i){super(e),this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=a=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(a);let{raycaster:n,page:o}=this.eventContext,l=Gu(n,o,[],!0);this.sceneInterects=l,l.length&&(this.eventContext.sharedAssets.raycastProperty={x:l[0].point.x,y:l[0].point.y,z:l[0].point.z,objX:l[0].object.matrixWorld.elements[12],objY:l[0].object.matrixWorld.elements[13],objZ:l[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=a=>{(a.target===this.eventContext.domElement||a.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&(this.onCanvasRaycast(a),n.dispatch())})},this.onCanvasMouseUp=a=>{(a.target===this.eventContext.domElement||a.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?(this.onCanvasRaycast(a),n.dispatch()):n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=a=>{Ye.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseEvent("MouseDown"))},this.onMouseUp=a=>{Ye.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=a=>{Ye.length>1||(this.eventContext.updateRaycaster(a),this.handleMousePressEvent())},this.onMousePressRelease=a=>{Ye.length>1||(this.eventContext.updateRaycaster(a),this.handleMousePressEvent(!0))},this.onKeyDown=a=>{this.heldKeys[a.key]||(this.handleKeyEvent(a,"KeyDown"),this.handleKeyEventHeld(a,"KeyDown",!0)),this.heldKeys[a.key]=!0},this.onKeyUp=a=>{this.handleKeyEvent(a,"KeyUp"),this.handleKeyEventHeld(a,"KeyUp",!0)},this.onKeyPressDown=a=>{this.heldKeysPress[a.key]?this.handleKeyEventHeld(a,"KeyPress"):(this.handleKeyEvent(a,"KeyPress"),this.handleKeyEventHeld(a,"KeyPress",!0)),this.heldKeysPress[a.key]=!0},this.onKeyPressUp=a=>{this.handleKeyEvent(a,"KeyPress",!0)},this.releaseHeldKey=a=>{delete this.heldKeys[a.key]},this.releaseHeldKeyPress=a=>{delete this.heldKeysPress[a.key]},this._onUserEvent=({eventName:a,target:n,reverse:o})=>{if(!a||!n)return;let l=od(a);l&&(l==="MouseDown"||l==="MouseUp"||l==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[n.uuid]?.forEach(h=>{h.dispatchUserEvent(o)})):(l==="KeyDown"||l==="KeyUp"||l==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[n.uuid]?.forEach(h=>{h.dispatchUserEvent()})))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(a=>{if(!a.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of n){let l=this.eventsPerObjects[o];a.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:u})=>{try{let c=new NY(h,u,a,r,s,t);c.actions.Video.length&&(this.hasVideoAction=!0),(u.type==="MouseDown"||u.type==="MouseUp"||u.type==="MousePress")&&(u.mode==="Canvas"||u.mode==="Window")?this.canvasMouseEvents.push(c):l[a.uuid]?l[a.uuid].push(c):l[a.uuid]=[c]}catch{}}),l[a.uuid]?.length&&this.objectsPerTypes[o].push(a)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r}=this.eventContext,s=this.objectsPerTypes[e];if(!(!s.length&&!this.useForRaycastProperty)){if(t||this.useForRaycastProperty){let a;this.sceneInterects===null?a=Gu(i,r,s,this.useForRaycastProperty):(a=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&a.length&&(this.eventContext.sharedAssets.raycastProperty={x:a[0].point.x,y:a[0].point.y,z:a[0].point.z,objX:a[0].object.matrixWorld.elements[12],objY:a[0].object.matrixWorld.elements[13],objZ:a[0].object.matrixWorld.elements[14]}),t&&m0(a).forEach(n=>{this.eventsPerObjects[e][n.uuid]&&this.handleObjectMouseEventDispatch(n,e)})}t||s.forEach(a=>{Up(i,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:a,page:n}=this.eventContext;if(s){let o=Gu(a,n,i);r=m0(o)}else i.forEach(o=>{Up(a,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:a})=>"key"in a&&a.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},FY=new E,VY=new E,RC=class{constructor(e,t,i,r,s){this.actionsIn=fr(e,e.inActions,i,r,s,t),this.actionsOut=fr(e,e.outActions,i,r,s,t)}disconnect(){Ii(this.actionsIn),Ii(this.actionsOut)}},jY=class extends RC{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let d of this.objects)if(!d.visible)return;let h=FY.setFromMatrixPosition(this.objects[0].matrixWorld),u=VY.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(u)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let d=c==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch()),d.SetVariable.forEach(p=>p.checkConditions()),d.SetVariable.forEach(p=>p.dispatch()),d.DynamicVariablePlay.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let u=r.find(h);if(!u)throw new Error("Missing property");this.objects.push(u)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},GY=class extends RC{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(u=>u.dispatchConditional()),this.actionsOut.Video.forEach(u=>u.dispatchConditional()),this.actionsOut.Link.forEach(u=>u.dispatch()),this.actionsOut.Create.forEach(u=>u.dispatch()),this.actionsOut.Destroy.forEach(u=>u.dispatch()),this.actionsOut.Reset.forEach(u=>u.dispatch()),this.actionsIn.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(u=>u.play()),this.actionsOut.Animation.forEach(u=>u.play()),this.actionsIn.SwitchCamera.forEach(u=>u.pause()),this.actionsOut.SwitchCamera.forEach(u=>u.play()),this.actionsOut.SceneTransition.forEach(u=>u.dispatch()),this.actionsOut.SetVariable.forEach(u=>u.checkConditions()),this.actionsOut.SetVariable.forEach(u=>u.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(u=>u.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(u=>u.dispatchConditional()),this.actionsIn.Video.forEach(u=>u.dispatchConditional()),this.actionsIn.Link.forEach(u=>u.dispatch()),this.actionsIn.Create.forEach(u=>u.dispatch()),this.actionsIn.Destroy.forEach(u=>u.dispatch()),this.actionsIn.Reset.forEach(u=>u.dispatch()),this.actionsOut.Transition.forEach(u=>u.pause()),this.actionsOut.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(u=>u.play()),this.actionsIn.Animation.forEach(u=>u.play()),this.actionsOut.SwitchCamera.forEach(u=>u.pause()),this.actionsIn.SwitchCamera.forEach(u=>u.play()),this.actionsIn.SceneTransition.forEach(u=>u.dispatch()),this.actionsIn.SetVariable.forEach(u=>u.checkConditions()),this.actionsIn.SetVariable.forEach(u=>u.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(u=>u.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,n.state&&!this.toObject.states?.[n.state])throw new Error("Missing property");this.toState=n.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length||this.actionsOut.DynamicVariablePlay.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length||this.actionsIn.DynamicVariablePlay.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},HY=class extends Ds{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="Conditional")try{let o;n.condition.type==="Comparison"||(n.condition.type==="Distance"?o=new jY(a,n,s,i,r,t):n.condition.type==="State"&&(o=new GY(a,n,s,i,r,t))),o&&(this.eventsPerConditions[n.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},ic=new E,an=new E,qn=new E,RS=new kr,WY=.01,At=new E,bi=new E,LS=new E,lo=new $e,fg=new Di,qY=new me,mg=new ri,ll=new E,Fs=new E,hl=.2;function gg(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var YY=function(){let e=new me;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&gg(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?gg(s.position,t.limits):t.reference==="local"&&(lo.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(lo),gg(s.position,t.limits),lo.invert(),s.position.applyQuaternion(lo),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(At,s.quaternion,bi),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof Dr&&Zs(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),XY=class{constructor(e,t,i,r,s,a){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=fr(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=fr(t,t.dragDropActions.drop,i,r,s,this.object);let n=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(n.push(l),a[l.uuid]&&a[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&n.push(u)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),a[l.uuid]&&a[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=n.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new E().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new E().setFromMatrixPosition(o.matrixWorld),pointStart:new E,pointEnd:new E,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new E().copy(o.position),quat0:new $e().copy(o.quaternion),snapped:!1,orientationMatrix:new me,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Ii(this.actionsDrag),Ii(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},QY=class extends Ds{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Ye.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(this.lastDropDestination=null,n.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:u,pointStart:c}of o.dragItems){if(h===n[0].object||h===n[0].object.object||pt.is(h)&&h.isAncestorOf(n[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(At,lo,bi),fg.setFromQuaternion(lo),d.prevR===void 0?(d.prevR=fg.clone(),d.prevT=At.clone()):(d.prevR.copy(fg),d.prevT.copy(At)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Ye.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(Ye.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===n[0]?.object||h===n[0]?.object?.object||pt.is(h)&&h.isAncestorOf(n[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=n.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Gl)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===h.object.uuid||a.scene.find(u).isAncestorOf(h.object.uuid))))[0]),l){let h=LS.copy(l.face.normal).applyMatrix3(mg.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){At.copy(h).applyMatrix3(mg.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;At.x>hl?bi.x=-u.recursiveBBox.min.x:At.x<-hl&&(bi.x=-u.recursiveBBox.max.x),At.y>hl?bi.y=-u.recursiveBBox.min.y:At.y<-hl&&(bi.y=-u.recursiveBBox.max.y),At.z>hl?bi.z=-u.recursiveBBox.min.z:At.z<-hl&&(bi.z=-u.recursiveBBox.max.z),bi.applyMatrix3(mg.invert())}else bi.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(bi)}this.activeEvent.data.autoOrient&&(At.set(0,1,0).cross(h),At.length()<1e-4&&At.set(-1,0,0).cross(h),bi.crossVectors(LS,At),o.orientationMatrix.makeBasis(At,bi,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(h=>h.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(a=>{a.stop(),a.object.currentState!==null&&a.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(a=>{a.stop()}),this.activeEvent.actionsDrag.Audio.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(a=>a.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new XY(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:a}=this.eventContext;s().getWorldDirection(an),an.negate();let n=lo.identity();switch(r==="parent"?qY.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(At,n,bi):r==="local"&&e.matrixWorld.decompose(At,n,bi),i){case"x":At.set(1,0,0).applyQuaternion(n),ll.copy(an).cross(At),Fs.copy(At).cross(ll);break;case"y":At.set(0,1,0).applyQuaternion(n),ll.copy(an).cross(At),Fs.copy(At).cross(ll);break;case"z":At.set(0,0,1).applyQuaternion(n),ll.copy(an).cross(At),Fs.copy(At).cross(ll);break;case"xy":Fs.set(0,0,1).applyQuaternion(n);break;case"yz":Fs.set(1,0,0).applyQuaternion(n);break;case"xz":Fs.set(0,1,0).applyQuaternion(n);break;case"adaptive":an.angleTo(bi.set(0,1,0))>Math.PI/6?(At.crossVectors(bi.set(0,1,0),an),Fs.crossVectors(At,bi)):Fs.set(0,1,0);break;default:Fs.copy(an);break}qn.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:qn;if(RS.setFromNormalAndCoplanarPoint(Fs,o),!!a.ray.intersectPlane(RS,t)&&(i==="x"||i==="y"||i==="z")){let l=bi.subVectors(t,o).dot(At);t.copy(o).addScaledVector(At,l)}}updateDragItem(e,t=!1){qn.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?ic.subVectors(e.fromPosition,qn).divideScalar(e.currentDampingFactor):e.reset==="original"?(ic.subVectors(e.obj.userData.worldPosition0,qn).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):ic.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(qn).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?ic.length()<WY:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&YY(e,ic.add(qn),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},cl=new E,vg=new E,ba=new E,wa=new E,BS=new kr,ZY=.01,KY={type:"requestRender"},JY=function(){let e=new E,t=new E;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),zS=function(){let e=new me;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Dr&&Zs(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),$Y=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new E,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...av.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=fr(e,e.actions,i,r,s,t)}},eX=class extends Ds{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Ye.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new $Y(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Ur&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Ur&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,Ii(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(ba),e.isReset)wa.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(wa);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(vg),vg.negate(),cl.copy(vg)):i==="xy"?cl.set(0,0,1):i==="xz"?cl.set(0,1,0):i==="yz"&&cl.set(1,0,0),BS.setFromNormalAndCoplanarPoint(cl,ba),!o.ray.intersectPlane(BS,wa))return}if(!e.isReset){if(wa.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)wa.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(wa.x=ba.x),e.data.enabledTranslation[1]===!1&&(wa.y=ba.y),e.data.enabledTranslation[2]===!1&&(wa.z=ba.z);let a=JY(ba,wa,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=cl.subVectors(a,ba).divideScalar(e.currentDampingFactor);ba.add(n),t&&zS(e.object,ba),e.paused=n.length()<ZY}else zS(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(KY)}},rc=new E,Cu=new E,sc=new me,dl=new $e,nn=new $e,ac=new E,nc=new E,Yn=new E,_a=new E,yg=new kr,tX=1e-6,iX={type:"requestRender"},rX={type:"changeRotation"},kS=function(){let e=new me;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(CC(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Dr&&Zs(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),sX=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new $e,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...nv.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},aX=class extends Ds{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Ye.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let a=od(r);a&&a==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new sX(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Ur&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let a=this.onTargetChange(i),n=i.target;this.pairOfEventListeners.push([n,a]),n.addEventListener("requestRender",a)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Ur&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:a,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:u,target:c}=e;if(u.getWorldPosition(ac),!e.isReset)if(e.target)e.target.getWorldPosition(nc);else{if(s==="custom"?(l().getWorldDirection(Cu),Cu.negate(),yg.setFromNormalAndCoplanarPoint(Cu,ac)):(s==="xy"?rc.set(0,0,1):s==="xz"?rc.set(0,1,0):s==="yz"&&rc.set(1,0,0),yg.setFromNormalAndCoplanarPoint(rc,ac)),!h.ray.intersectPlane(yg,nc))return;r>0&&(s==="custom"||s===void 0)&&nc.addScaledVector(Cu,r)}if(e.isReset||(c?t==="target"?Yn.copy(c.up).applyMatrix4(sc.extractRotation(c.matrixWorld)).normalize():n.some(d=>d===!1)?(i==="x"?(_a.set(0,0,1),n[2]===!1&&_a.set(0,1,0)):i==="y"?(_a.set(1,0,0),n[0]===!1&&_a.set(0,0,1)):(_a.set(0,1,0),n[1]===!1&&_a.set(1,0,0)),Yn.copy(_a).applyQuaternion(e.worldQuaternion0).normalize()):Yn.set(0,1,0):s==="custom"?Yn.set(0,1,0):Yn.copy(rc)),e.isReset)nn.copy(e.worldQuaternion0);else if(ac.distanceTo(nc)>a&&o&&c)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)nn.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;nX(sc,nc,ac,Yn,i,_a),nn.setFromRotationMatrix(sc),dl.setFromUnitVectors(_a.applyQuaternion(nn),Yn),n.some(d=>d===!1)&&t!=="target"&&nn.premultiply(dl).normalize()}e.currentDampingFactor>1?(u.updateWorldMatrix(!0,!1),dl.setFromRotationMatrix(CC(u.matrixWorld)),dl.slerp(nn,1/e.currentDampingFactor),kS(u,sc.makeRotationFromQuaternion(dl)),e.paused=8*(1-dl.dot(nn))<tX):(kS(u,sc.makeRotationFromQuaternion(nn)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),u.dispatchEvent(iX),u.dispatchEvent(rX)}},Qr=new E,xi=new E,ei=new E;function nX(e,t,i,r,s,a){let n=e.elements;ei.subVectors(t,i),ei.lengthSq()===0&&(ei.z=1),ei.normalize(),xi.crossVectors(r,ei),xi.lengthSq()===0&&(Math.abs(r.z)===1?ei.x+=1e-4:ei.z+=1e-4,ei.normalize(),xi.crossVectors(r,ei)),xi.normalize(),Qr.crossVectors(ei,xi),s==="x"?a.z===1?[xi,Qr,ei]=[ei,xi,Qr]:(xi.negate(),[xi,ei]=[ei,xi]):s==="y"?a.x===1?[xi,Qr,ei]=[Qr,ei,xi]:(xi.negate(),[Qr,ei]=[ei,Qr]):a.x===1&&(xi.negate(),[xi,Qr]=[Qr,xi]),n[0]=xi.x,n[4]=Qr.x,n[8]=ei.x,n[1]=xi.y,n[5]=Qr.y,n[9]=ei.y,n[2]=xi.z,n[6]=Qr.z,n[10]=ei.z}var oX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=fr(t,t.actions,r,s,a,i)}disconnect(){Ii(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},lX=class extends Ds{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{Ye.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Ye.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Ye.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:a,reverse:n})=>{if(!s||!a)return;let o=od(s);o&&o==="MouseHover"&&(a.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[a.uuid]?.forEach(l=>l.dispatchUserEvent(n)))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="MouseHover")try{let o=new oX(a,n,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Ur&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Ur&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s}=this.eventContext;if(i){let a=Gu(r,s,this.objects);t=m0(a)}else this.objects.forEach(a=>{Up(r,a)&&t.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},hX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=fr(t,t.actions,r,s,a,i)}connect(){this.scrollCounter=0}disconnect(){Ii(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},cX=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.object=i,this.domElement=a,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=fr(t,t.actions,r,s,n,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,a=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let n=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?n:l==="bottom"?n-o:n-o*.5;this.scrollStart=a-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Ii(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},dX=class extends Ds{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([n,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=n=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(u=>u.dispatch(o))})},this.onWheel=n=>{!this.isInview||n.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:n.deltaY}),l.forEach(h=>h.dispatch(n.deltaY))})},this.onUserEvent=({eventName:n,target:o,reverse:l})=>{if(!n||!o)return;let h=od(n);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(u=>{u.dispatchUserEvent(l)}))};let{page:i,sharedAssets:r,domElement:s,isExport:a}=this.eventContext;i.traverseEntity(n=>{if(n.data?.events.length){for(let{id:o,data:l}of n.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!a){let h=new hX(o,l,n,i,r,t);this.wheelEventsPerObject.has(n)?this.wheelEventsPerObject.get(n)?.push(h):this.wheelEventsPerObject.set(n,[h])}else{let h=new cX(o,l,n,i,r,s,t);this.scrollEventsPerObject.has(n)?this.scrollEventsPerObject.get(n)?.push(h):this.scrollEventsPerObject.set(n,[h])}}}),this.intersectionObserver=new IntersectionObserver(n=>{let o=n[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},uX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=fr(t,t.actions,r,s,a,i)}disconnect(){Ii(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof oo?t.interaction.audioPlayer.play():t.interaction instanceof h0&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof ql?t.interaction.play(i==="autoplay"):t.interaction instanceof p0&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof oo?t.interaction.audioPlayer.play():t.interaction instanceof h0&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof ql?t.interaction.play():t.interaction instanceof p0&&t.interaction.dispatch()})}},pX=class extends Ds{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,a])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(n=>{n.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(a=>{a.interaction instanceof oo&&a.interaction.audioPlayer.play()}),s.actions.Video.forEach(a=>{let n=a.interaction.data.triggerAfter??"autoplay";a.interaction instanceof ql&&a.interaction.play(n==="autoplay")})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=od(i);a&&a==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext;if(t.traverseEntity(i=>{if(i.data?.events.length)for(let{id:r,data:s}of i.data.events){if(s.disabled||s.type!=="Start")continue;let a=new uX(r,s,i,t,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(i)?this.eventsPerObject.get(i)?.push(a):this.eventsPerObject.set(i,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a]))}}),[...this.eventsAfterPerObject.values()].some(i=>i.length)){if(this.eventManager.activateCount===0){let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,n])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>s.dispatch()),i.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},fX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.alreadyPlayedNonTogglingActions=new Set,this.actions=fr(t,t.actions,r,s,a,i),this.target=t.target,this.useToggle=t.runMode==="Toggle"}disconnect(){Ii(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},mX=class extends Ds{constructor(e,t,i,r,s){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=s,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.events=[],this.onFrame=a=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,o=[],l=[];for(let c=0;c<this.propertiesToWatch.length;c++){let{objectId:d,property:p,prevValue:f}=this.propertiesToWatch[c],m=this.eventContext.scene.find(d),g=lv.propertyPaths[p];if(g[0]==="width"||g[0]==="height"||g[0]==="depth")m=m.geometry.userData.parameters[g[0]];else for(let v=0;v<g.length;v++)m=m[g[v]];f===null?this.propertiesToWatch[c].prevValue=m instanceof E?m.clone():m:(m instanceof E?!m.equals(f):f!==m)&&(l.push({objId:d,property:p}),m instanceof E?this.propertiesToWatch[c].prevValue.copy(m):this.propertiesToWatch[c].prevValue=m)}for(let c=0;c<this.variablesToWatch.length;c++){let{id:d,prevValue:p}=this.variablesToWatch[c],f=this.shared.getVariable(d);f!==p&&(o.push(d),this.variablesToWatch[c].prevValue=f)}for(let c=0;c<this.dynamicVars.length;c++){let{id:d,expectedTime:p,last:f,data:m,timerSeconds:g,startValue:v}=this.dynamicVars[c],y=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?y=1:m.dynamicVariableType==="counter"?y=m.updateInterval:m.dynamicVariableType==="random"&&(y=m.isStatic?1/0:m.updateInterval),p===-1){this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+y;continue}if(!((this.shared.getDynamicVariablePlayState(d)==="Stopped"||this.shared.getDynamicVariablePlayState(d)==="Restarted")&&(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+y,m.dynamicVariableType==="counter"&&this.shared.getVariable(d)!==v&&(this.shared.updateVariable(d,v),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==v&&(this.dynamicVars[c].timerSeconds=v,this.shared.updateVariable(d,vs.getFormattedTimerTime(v,m)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(d)==="Restarted"&&this.shared.setDynamicVariablePlayState(d,"Playing"),this.shared.getDynamicVariablePlayState(d)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(d)==="Paused"){this.dynamicVars[c].deltaToExpectedTime===void 0&&(this.dynamicVars[c].deltaToExpectedTime=Math.max(this.dynamicVars[c].expectedTime-a,0)),this.dynamicVars[c].last=a-(y-this.dynamicVars[c].deltaToExpectedTime),this.dynamicVars[c].expectedTime=a+this.dynamicVars[c].deltaToExpectedTime;continue}else this.dynamicVars[c].deltaToExpectedTime=void 0;if(a>=p)if(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime+=y,m.dynamicVariableType==="random"){let x=m.min+Math.random()*(m.max-m.min),b=m.decimals;x=Math.round(x*Math.pow(10,b))/Math.pow(10,b),this.shared.updateVariable(d,x),o.push(d),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){if(m.increment===0)continue;let x=this.shared.getVariable(d),b=this.shared.getDynamicVariableToggleIsForward(d)??!0,w=this.shared.getVariable(d)+m.increment*(b?1:-1);m.hasEnd&&(w=m.increment>0?Le.clamp(w,v,m.endValue):Le.clamp(w,m.endValue,v),w===v&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?w===m.endValue&&(w=v):(w===v||w===m.endValue)&&this.shared.setDynamicVariablePlayState(d,"Paused")),w!==x&&(o.push(d),this.shared.updateVariable(d,w),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time")this.shared.updateVariable(d,u_(n,m)),o.push(d),this.eventManager.requestRender();else{let x=Fr.isTextValue(m.endValue)?NS(m.endValue.textValue):m.endValue,b=this.shared.getDynamicVariableToggleIsForward(d)??!0,w=g+(a-f)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(b?1:-1);w=Math.max(w,0),m.hasEnd&&(w=m.dynamicVariableType==="stopwatch"?Le.clamp(w,v,x):Le.clamp(w,x,v),w===v&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?Math.abs(w-x)<(m.format==="number3decimal"?1e-4:.1)&&(w=v):(Math.abs(w-v)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(w-x)<(m.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(d,"Paused")),w!==g&&(o.push(d),this.dynamicVars[c].timerSeconds=w,this.shared.updateVariable(d,vs.getFormattedTimerTime(w,m)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(c=>{c.data.variableId==="mouseProperty"&&(c.dispatch(),this.eventManager.requestRender())}));let h=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,h=!0);let u=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,u=!0),this.events.forEach(c=>{(o.includes(c.data.variableId)||l.find(d=>d.objId===c.data.objectId&&d.property===c.data.property)||c.data.variableId==="mouseProperty"&&h||c.data.variableId==="raycastProperty"&&u)&&(c.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()},e.page.traverseEntity(a=>{a.data?.events.filter(n=>n.data.type==="VariableChange"&&!n.data.disabled).forEach(n=>{this.events.push(new gX(a.uuid,n.data,a,e.page,e.sharedAssets,i))})}),this.propertiesToWatch=this.events.filter(a=>a.data.variableId==="objectProperty"&&a.data.objectId!==null).map(a=>({objectId:a.data.objectId,property:a.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:a,data:n})=>{if(!("dynamicVariableType"in n)){this.events.find(l=>l.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let o;if(n.dynamicVariableType==="timer"||n.dynamicVariableType==="stopwatch"){let l;if(Fr.isTextValue(n.value)&&Array.isArray(n.value.textValue)){let h=n.value.textValue;h.length===3?l=h[2]+h[1]*60+h[0]*3600:l=h[1]+h[0]*60}else l=n.value;o=l,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,timerSeconds:l,startValue:o})}else n.dynamicVariableType==="time"&&this.shared.updateVariable(a,u_(new Date,n)),n.dynamicVariableType==="counter"&&(o=Fr.isTextValue(n.value)?NS(n.value.textValue):n.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,startValue:o})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},gX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=fr(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch())}dispose(){Ii(this.actions)}};function NS(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var vX="https://unpkg.com/@splinetool/runtime@0.9.502/build/",yX="https://unpkg.com/@splinetool/navmesh-wasm@0.9.502/build/",xX=`
|
|
6426
|
+
)`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:a}=e;t=`spring( ${i}, ${r}, ${s}, ${a} )`}else{let i;switch(e.easing){case 0:i=ln.linear;break;case 1:i=ln.ease;break;case 2:i=ln.easeIn;break;case 3:i=ln.easeOut;break;case 4:i=ln.easeInOut;break;default:i=ln.linear}let[r,s,a,n]=i;t=`cubicBezier( ${r}, ${s}, ${a}, ${n} )`}return{duration:e.duration,easing:t}}function u0(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var uY={type:"beginState"},pY={type:"completeState",isfromEntity:!1},wS=class{constructor(e,t,i,r,s,a){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=a,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let n=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"beginState",state:n}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Xi&&o.dispatchEvent(uY)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let n=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"completeState",state:n}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Xi&&o.dispatchEvent(pY)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=xS(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=ju(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=ju(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=ju(this.object,i);if(!n)throw new Error("Missing property");this.to=n}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...u0(r),...mC(r),change:this.onChange},this.callback=xS(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},gC=class extends Ni{constructor(e,t,i,r){if(super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let s=this.page.scene.find(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline&&this.timeline.paused===!1}init(){this.initialCurrentState=ju(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=u0(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=pC.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(a=>a?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let a=s===-1?0:s;for(let n=a;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Xi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new wS(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(u.params,{startOnceDelay:0}),this.tweens[n]=u,this.timeline.add(u.params,this.timeline.duration+(n===a?r.delay:0))}this.timeline.duration+=r.endDelay}else{let a=s===-1?this.data.tweens.length-1:s+1;for(let n=a;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Xi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new wS(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(u.params,{startOnceDelay:0}),this.tweens[n-1]=u,this.timeline.add(u.params,this.timeline.duration+(n===a?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(gi(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=u0(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(gi(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function ju(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var fY={type:"beginState"},_S={type:"completeState",isfromEntity:!1},SS={type:"requestRender"},vC=class extends Ni{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new E,this.posEnd=new E,this.qStart=new $e,this.qEnd=new $e,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=pC({targets:i,t:1,...mC(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(fY));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(SS),i.t===1&&r.dispatchEvent(_S)}})}switchCamera(e){let t=this.page.scene.find(e);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(t),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:t})}play(){if(gi(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(gi(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(_S),this.page.activeCamera.dispatchEvent(SS))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},yC=class extends Ni{constructor(e,t,i,r,s){super(),this.page=t,this.animationControls=i,this.shared=r,this.condition=s,this.startOnceDelay=0,this.toggleIsForward=!1;let a=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(a=n.identity[0]),this.data={...e,object:a};let o=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=o?.getClip()?.duration??1;let l=o?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(gi(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Le.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(gi(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let a=r.split("/")[1];this.threeAnimAction!==s&&a===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},xC=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=s,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(gi(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),Yy(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},bC=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=gi(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=NM(this.data.expression,this.shared,Fr.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},wC=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(gi(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function gi(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=NM(t.expression,e,"boolean");return t.negate?!i:!!i}function fr(e,t,i,r,s,a){let n={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},o=l=>({id:h,data:u})=>{try{u.type==="Audio"?Br[e.type].includes("Audio")&&n.Audio.push(new XE(h,u,a,r,l)):u.type==="Video"?Br[e.type].includes("Video")&&n.Video.push(new SC(h,u,a,r,l)):u.type==="Link"?Br[e.type].includes("Link")&&n.Link.push(new oq(u,s.controlsManager,r,l)):u.type==="Create"?Br[e.type].includes("Create")&&n.Create.push(new AC(u,i,s.controlsManager,r,l)):u.type==="Destroy"?Br[e.type].includes("Destroy")&&n.Destroy.push(new QE(u,i,s.controlsManager,r,l)):u.type==="Reset"?Br[e.type].includes("Reset")&&n.Reset.push(new ZE(u,i,r,s,l)):u.type==="Transition"?Br[e.type].includes("Transition")&&n.Transition.push(new gC(u,i,r,l)):u.type==="SwitchCamera"?Br[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new vC(u,i,r,l)):u.type==="SceneTransition"?Br[e.type].includes("SceneTransition")&&n.SceneTransition.push(new xC(u,i,s,r,l)):u.type==="Animation"?Br[e.type].includes("Animation")&&n.Animation.push(new yC(u,i,s.animationControls,r,l)):u.type==="SetVariable"?Br[e.type].includes("SetVariable")&&n.SetVariable.push(new bC(u,i,r,l)):u.type==="DynamicVariablePlay"?Br[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new wC(u,i,r,l)):u.type==="Conditional"&&Br[e.type].includes("Conditional")&&(u.ifActions.forEach(o({expression:u.condition,negate:!1})),u.elseActions.forEach(o({expression:u.condition,negate:!0})))}catch{}};return t.forEach(o()),n}function Ii(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof XE||i instanceof SC||i instanceof yC||i instanceof gC||i instanceof AC||i instanceof QE||i instanceof vC||i instanceof xC||i instanceof ZE||i instanceof bC||i instanceof wC)&&i.dispose()})})}function mY(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var _C=new Map,Cc=new Map,ql=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:a,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=mY(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,a!==void 0&&(this.videoElement.volume=a)),n!==void 0&&(this.delay=n),Cc.has(i.uuid)?Cc.get(i.uuid).push(this):Cc.set(i.uuid,[this]),_C.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},p0=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=_C.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=Cc.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...Cc.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},SC=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new ql(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new p0(t);else throw new Error("Missing property")}dispatchBasic(){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof ql?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(gi(this.shared,this.condition)===!1)return!1;this.interaction instanceof ql?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},AS=(()=>{let e,t,i,r;function s(o){!e&&!MS()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(a)),o&&(t=o,r=o.requestRender)}function a(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,d=0;for(;d<c;){let p=h[d];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&u[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(u[p.userData.actionId]>p.userData.quantity&&u[p.userData.actionId]--,h.splice(d,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}e=d>0?requestAnimationFrame(a):void 0,i=d>0?o:void 0}function n(){MS()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),s})();function MS(){return!!document&&document.hidden}var ES=new $e,gY=new E,vY=new E,AC=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=Le.generateUUID(),this.dispatch=()=>{if(gi(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{if(gi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=n6(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let n=new qi(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.position.fromArray(this.data.position),n.rotation.fromArray(this.data.rotation),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),AS(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof _s)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof qi)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof _s)return;n instanceof qi?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new E().fromArray(this.data.velocity),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(gY,ES,vY),l.applyQuaternion(ES),this.data.velocity.some(u=>u!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(u=>u!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");AS(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},MC=200,dg=.02,ug=.3,yY=65,JQ=new E,CS=new E,TS=new E,xY=new E,er=new E,vr=new E,sn=new E,pg=new me,DS=new me,bY=new me,$Q=new me,ps=new $e,xa=new $e,Ns=new Di(0,0,0,"YXZ"),wY=new E(1,0,0),fs=new E(0,1,0),_Y=new E(0,0,1),PS=new E(1,1,1),eZ=new Tr,SY=1,AY=.025,MY=16e-6,IS=12,EY=20,Ci=new is,Xr=new ai,CY={type:"requestRender"},TY={type:"updateMatrix"},OS=Math.PI/6,f0=class extends Ni{constructor(e,t,i,r,s,a,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=a,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new me,this.target0=new E,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=MC,this.euler0=new Di(0,0,0,"YXZ"),this.position0Cam=new E,this.quat0Cam=new $e,this.scale0Cam=new E,this.hiddenMatrix0Cam=new me,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new is(new E(0,-40,0),new E(0,40,0)),matrix:new me,position:new E,rotation:new $e},this.euler=new Di(0,0,0,"YXZ"),this.eulerDelta=new E,this.lastPosition=new E,this.lastCameraQuaternion=new $e,this.lastCameraPosition=new E,this.PI_2=Math.PI/2,this.prevMouse=new F,this.velocityTarget=new E,this.velocity=new E,this.directionXZ=new E,this.rotVelocityStick=new E,this.rotVelocityTarget=new E,this.rotVelocity=new E,this.rotDirection=new E,this.nonColliderRotOffset=new me,this.nonColliderPosOffset=new me,this.firstPointerId=-1,this.rot=new E,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new me,this.objectToTarget=new E,this.objectToTarget0=new E,this.objectToCamXZ=new E,this.objectToCamXZ0=new E,this.targetToCamera=new E,this.targetToCamera0=new E,this.cameraPolarAxis0=new E,this.targetPos=new E,this.targetQuat=new $e,this.lerpFactorPos=new E().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new $e,this.objXZQuatInv=new $e,this.objXZRotMat=new me,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new E,this.pushedVelocity=new E,this.groundYRotation=0,this.objectRealQuat=new $e,this.colliderWorldQuat=new $e,this.groundNormal=new E,this.groundTilt=new $e,this.groundTiltInv=new $e,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new E,this.quaternion=new $e,this.scale=new E,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Ur&&(!Db||Pb>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(Db&&Pb<15.5&&!Ur?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?f0.isLocked=!0:f0.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),u=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,u,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new E(0,0,-1).applyQuaternion(this.camera.quaternion),m=new E().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g,v;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,v=m.projectOnVector(f)):m.y/f.y>0?v=f.multiplyScalar(m.y/f.y):v=f.multiplyScalar(m.length()),this.targetToCamera0.copy(v).negate(),g=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(g,this.position);let y=new Di().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Xi&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*SY,this.speedOrbit=(i.speedRotate??100)*AY,this.mouseOrbitSensitivity=(i.speedRotate??100)*MY,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??ih.defaultData.gravity)*IS,this.usePhysics=this.gloabalPhysics.usePhysics??ih.defaultData.usePhysics,this.jumpPower=i.jumpPower*EY,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Ep.defaultDataThirdPerson.orientWith,this.slopeThresh=yY*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*dg/this.pixelsPerMeter,this.stepThresh=i.collider.height*ug/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*dg/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*ug/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*dg/this.pixelsPerMeter,this.stepThresh=i.collider.height*ug/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new E().fromArray(i.collider.position),d=new $e().setFromEuler(new Di().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(c,d,PS),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new We;f.push({fi:0,data:{...xr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...xr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new My({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new hr(yM.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new Di().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Xi?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Mp.list.forEach(i=>{this.actions[i]=fr({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Ii(this.actions.idle),Ii(this.actions.move),Ii(this.actions.run),Ii(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return er.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let o=vr.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*IS),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===h&&u.userData.isFollowingObj!==this.object.uuid){(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(er,xa,vr),this.groundVelocity.subVectors(er,u.prevT),this.object.getWorldPosition(vr).add(this.collider.position).sub(er),this.groundYRotation=Ns.setFromQuaternion(xa).y-u.prevR.y,sn.copy(vr).applyAxisAngle(fs,this.groundYRotation),this.groundVelocity.add(sn.sub(vr)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=er.subVectors(this.path[1],this.position),h=vr.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=xY.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=vr.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let o=er;this.camera.getWorldDirection(o);let l=sn.copy(fs).multiplyScalar(o.dot(fs));o.sub(l);let h=vr.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Ns.setFromVector3(this.rot),this.moveMode==="walk"&&(Ns.x=0),n.applyEuler(Ns),a&&(xa.setFromUnitVectors(fs,this.groundNormal),n.applyQuaternion(xa)),i){let o=Ns.set(0,this.vrEulerYOffset*OS,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=vr;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=sn.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),er.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=pt.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==c){let d;l instanceof qi&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),c.dispatchEvent(g0));this.lastHitObj=c}if(u!==null){this.pushedVelocity.copy(h),o.copy(u.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(fs,this.euler.y-this.euler0.y);let o=vr.copy(this.objectToCamXZ).normalize(),l=sn.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(er.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Le.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Le.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Le.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(Ns.copy(t),Ns.y=0):(Ns.copy(this.euler),Ns.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Ns)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*OS),ps.setFromAxisAngle(wY,this.rot.x),xa.setFromAxisAngle(fs,this.rot.y),xa.multiply(ps),ps.setFromAxisAngle(_Y,this.rot.z),xa.multiply(ps),this.quaternion.copy(xa),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=vr.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new E;for(let u=0;u<5;u++){let c=o.length(),d=sn.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,d,this.object.rigidBody?.collider(0).shape,c,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&u===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,b;if(p.cloner){for(let w of p.cloner.children)if(w.rigidBody===x){b=w;break}}y.dispatch(b),p.dispatchEvent(g0)}}}let f=CS.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=TS.copy(d).multiplyScalar(l.toi).dot(f),g=l.toi;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=l.toi*(m-this.offset)/m,h.addScaledVector(d,g)),o.copy(d).multiplyScalar(c-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),y=sn.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let x=v.add(y);x.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);b!==null&&b.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{u===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(er.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(ps.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);pg.lookAt(l,o,fs).setPosition(l),pg.decompose(this.targetPos,this.targetQuat,er),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Le.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Le.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(TY),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(CY),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=ps.setFromAxisAngle(fs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Le.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=Le.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=Le.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=er.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=xa.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){fs.angleTo(e)*180/Math.PI<15||fs.angleTo(e)*180/Math.PI>85?ps.identity():ps.setFromUnitVectors(fs,e),this.groundTilt.slerp(ps,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=TS.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=pg.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(er,ps,vr).compose(er,ps,PS);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;Xr.makeEmpty(),s.updateMatrixWorldSVD();let a=s.matrixWorldRigid,n=DS.copy(a).invert(),o=bY.copy(DS).multiply(i);Ci.copy(this.collider.segment),Ci.start.applyMatrix4(o),Ci.end.applyMatrix4(o);let l=CS.copy(this.position).applyMatrix4(n);Xr.expandByPoint(Ci.start),Xr.expandByPoint(Ci.end),Xr.min.addScalar(-this.collider.radius),Xr.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Ci.end)},intersectsBounds:h=>h.intersectsBox(Xr),intersectsTriangle:h=>{let u=er,c=vr,d=h.closestPointToSegment(Ci,u,c);if(d<this.collider.radius){let p=this.collider.radius-d,f=c.sub(u).normalize(),m=sn.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(a).sub(this.position);t.add(g),Ci.start.addScaledVector(f,p),Ci.end.addScaledVector(f,p)}}})}),Xr.makeEmpty(),Ci.copy(this.collider.segment),Ci.start.applyMatrix4(i),Ci.end.applyMatrix4(i),Xr.expandByPoint(Ci.start),Xr.expandByPoint(Ci.end),Xr.min.addScalar(-this.collider.radius),Xr.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(Ci.end)},intersectsBounds:s=>s.intersectsBox(Xr),intersectsTriangle:s=>{let a=er,n=vr,o=s.closestPointToSegment(Ci,a,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),Ci.start.addScaledVector(h,l),Ci.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},EC=f0;EC.isLocked=!1;var DY=Ri(ZS());function Pa(e,t){let i=new Ue;if(!e.getAttribute("position"))return i.setAttribute("position",new Te([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=lf(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Te(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var PY=new me,IY=new me,Us=[[0,0,0],[0,0,0],[0,0,0]];function CC(e){let t=e.elements;Us[0][0]=t[0],Us[0][1]=t[4],Us[0][2]=t[8],Us[1][0]=t[1],Us[1][1]=t[5],Us[1][2]=t[9],Us[2][0]=t[2],Us[2][1]=t[6],Us[2][2]=t[10];let{u:i,v:r}=(0,DY.SVD)(Us),s=PY.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),a=IY.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);return s.multiply(a.transpose())}var OY=class extends jA{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new In({color:65280,linewidth:10}),t=new E(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new E(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new E().addVectors(t,i.multiplyScalar(r)),a=new Ue;return a.setFromPoints([t,s]),new Ku(a,e)}},TC=e=>e instanceof Gl||e instanceof Hl;function RY(e,t){return e.distance-t.distance}function DC(e,t,i){if(!(!Da(t)||!t.visible)){ys(t)&&t.raycast(e,i);for(let r of t.children)DC(e,r,i)}}function Gu(e,t,i,r=!1){if(!r&&!i.some(a=>Up(e,a)!==void 0))return[];let s=[];return t.children.forEach(a=>DC(e,a,s)),s.sort(RY),s}function m0(e){let t=[];if(e.length){let i=e[0].object;Da(i)&&t.push(i);let r=i.parent;for(;r;)TC(r)&&t.push(r),r=r.parent}return t}function Up(e,t){if(ys(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(TC(t))return PC(e,t)}function PC(e,t){if(!(!Da(t)||!t.visible)){if(ys(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=PC(e,i);if(r)return r}}}function LY(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}var BY=class{constructor(e,t,i,r,s,a,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=a,this.isExport=n,this.frame=o,this.raycaster=new OY,this.raycasterNeedsUpdate=!0,this._useWindowEvents=!1,this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this.domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateDomRect(){this.domRect=this.domElement.getBoundingClientRect()}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.updateDomRect(),this.raycaster.setFromCamera(LY(t,i,this.domRect),this.getCamera())}},IC=(e=>(e[e.keydown=0]="keydown",e[e.keyup=1]="keyup",e[e.pointerdown=2]="pointerdown",e[e.pointerup=3]="pointerup",e[e.pointermove=4]="pointermove",e[e.wheel=5]="wheel",e[e.scroll=6]="scroll",e))(IC||{}),Ds=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},Xy=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],OC=e=>Xy.find(([t,i])=>i===e)?.[0],od=e=>Xy.find(([t])=>t===e)?.[1],zY=(e,t)=>{let i=OC(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},kY=class extends Ds{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[OC(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of Xy)if(i.data.events.some(a=>a.data.type===s&&!a.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let a={id:i.uuid,name:i.name},n=zY(s,a),o=this.splineEvents[r];o?o[i.uuid]=n:this.splineEvents[r]={[i.uuid]:n}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},NY=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.runMode==="Toggle",(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=fr(t,t.actions,r,s,a,i)}disconnect(){Ii(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},UY=class extends Ds{constructor(e,t,i){super(e),this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=a=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(a);let{raycaster:n,page:o}=this.eventContext,l=Gu(n,o,[],!0);this.sceneInterects=l,l.length&&(this.eventContext.sharedAssets.raycastProperty={x:l[0].point.x,y:l[0].point.y,z:l[0].point.z,objX:l[0].object.matrixWorld.elements[12],objY:l[0].object.matrixWorld.elements[13],objZ:l[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=a=>{(a.target===this.eventContext.domElement||a.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&(this.onCanvasRaycast(a),n.dispatch())})},this.onCanvasMouseUp=a=>{(a.target===this.eventContext.domElement||a.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?(this.onCanvasRaycast(a),n.dispatch()):n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=a=>{Ye.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseEvent("MouseDown"))},this.onMouseUp=a=>{Ye.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=a=>{Ye.length>1||(this.eventContext.updateRaycaster(a),this.handleMousePressEvent())},this.onMousePressRelease=a=>{Ye.length>1||(this.eventContext.updateRaycaster(a),this.handleMousePressEvent(!0))},this.onKeyDown=a=>{this.heldKeys[a.key]||(this.handleKeyEvent(a,"KeyDown"),this.handleKeyEventHeld(a,"KeyDown",!0)),this.heldKeys[a.key]=!0},this.onKeyUp=a=>{this.handleKeyEvent(a,"KeyUp"),this.handleKeyEventHeld(a,"KeyUp",!0)},this.onKeyPressDown=a=>{this.heldKeysPress[a.key]?this.handleKeyEventHeld(a,"KeyPress"):(this.handleKeyEvent(a,"KeyPress"),this.handleKeyEventHeld(a,"KeyPress",!0)),this.heldKeysPress[a.key]=!0},this.onKeyPressUp=a=>{this.handleKeyEvent(a,"KeyPress",!0)},this.releaseHeldKey=a=>{delete this.heldKeys[a.key]},this.releaseHeldKeyPress=a=>{delete this.heldKeysPress[a.key]},this._onUserEvent=({eventName:a,target:n,reverse:o})=>{if(!a||!n)return;let l=od(a);l&&(l==="MouseDown"||l==="MouseUp"||l==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[n.uuid]?.forEach(h=>{h.dispatchUserEvent(o)})):(l==="KeyDown"||l==="KeyUp"||l==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[n.uuid]?.forEach(h=>{h.dispatchUserEvent()})))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(a=>{if(!a.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of n){let l=this.eventsPerObjects[o];a.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:u})=>{try{let c=new NY(h,u,a,r,s,t);c.actions.Video.length&&(this.hasVideoAction=!0),(u.type==="MouseDown"||u.type==="MouseUp"||u.type==="MousePress")&&(u.mode==="Canvas"||u.mode==="Window")?this.canvasMouseEvents.push(c):l[a.uuid]?l[a.uuid].push(c):l[a.uuid]=[c]}catch{}}),l[a.uuid]?.length&&this.objectsPerTypes[o].push(a)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r}=this.eventContext,s=this.objectsPerTypes[e];if(!(!s.length&&!this.useForRaycastProperty)){if(t||this.useForRaycastProperty){let a;this.sceneInterects===null?a=Gu(i,r,s,this.useForRaycastProperty):(a=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&a.length&&(this.eventContext.sharedAssets.raycastProperty={x:a[0].point.x,y:a[0].point.y,z:a[0].point.z,objX:a[0].object.matrixWorld.elements[12],objY:a[0].object.matrixWorld.elements[13],objZ:a[0].object.matrixWorld.elements[14]}),t&&m0(a).forEach(n=>{this.eventsPerObjects[e][n.uuid]&&this.handleObjectMouseEventDispatch(n,e)})}t||s.forEach(a=>{Up(i,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:a,page:n}=this.eventContext;if(s){let o=Gu(a,n,i);r=m0(o)}else i.forEach(o=>{Up(a,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:a})=>"key"in a&&a.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},FY=new E,VY=new E,RC=class{constructor(e,t,i,r,s){this.actionsIn=fr(e,e.inActions,i,r,s,t),this.actionsOut=fr(e,e.outActions,i,r,s,t)}disconnect(){Ii(this.actionsIn),Ii(this.actionsOut)}},jY=class extends RC{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let d of this.objects)if(!d.visible)return;let h=FY.setFromMatrixPosition(this.objects[0].matrixWorld),u=VY.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(u)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let d=c==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch()),d.SetVariable.forEach(p=>p.checkConditions()),d.SetVariable.forEach(p=>p.dispatch()),d.DynamicVariablePlay.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let u=r.find(h);if(!u)throw new Error("Missing property");this.objects.push(u)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},GY=class extends RC{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(u=>u.dispatchConditional()),this.actionsOut.Video.forEach(u=>u.dispatchConditional()),this.actionsOut.Link.forEach(u=>u.dispatch()),this.actionsOut.Create.forEach(u=>u.dispatch()),this.actionsOut.Destroy.forEach(u=>u.dispatch()),this.actionsOut.Reset.forEach(u=>u.dispatch()),this.actionsIn.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(u=>u.play()),this.actionsOut.Animation.forEach(u=>u.play()),this.actionsIn.SwitchCamera.forEach(u=>u.pause()),this.actionsOut.SwitchCamera.forEach(u=>u.play()),this.actionsOut.SceneTransition.forEach(u=>u.dispatch()),this.actionsOut.SetVariable.forEach(u=>u.checkConditions()),this.actionsOut.SetVariable.forEach(u=>u.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(u=>u.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(u=>u.dispatchConditional()),this.actionsIn.Video.forEach(u=>u.dispatchConditional()),this.actionsIn.Link.forEach(u=>u.dispatch()),this.actionsIn.Create.forEach(u=>u.dispatch()),this.actionsIn.Destroy.forEach(u=>u.dispatch()),this.actionsIn.Reset.forEach(u=>u.dispatch()),this.actionsOut.Transition.forEach(u=>u.pause()),this.actionsOut.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(u=>u.play()),this.actionsIn.Animation.forEach(u=>u.play()),this.actionsOut.SwitchCamera.forEach(u=>u.pause()),this.actionsIn.SwitchCamera.forEach(u=>u.play()),this.actionsIn.SceneTransition.forEach(u=>u.dispatch()),this.actionsIn.SetVariable.forEach(u=>u.checkConditions()),this.actionsIn.SetVariable.forEach(u=>u.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(u=>u.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,n.state&&!this.toObject.states?.[n.state])throw new Error("Missing property");this.toState=n.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length||this.actionsOut.DynamicVariablePlay.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length||this.actionsIn.DynamicVariablePlay.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},HY=class extends Ds{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="Conditional")try{let o;n.condition.type==="Comparison"||(n.condition.type==="Distance"?o=new jY(a,n,s,i,r,t):n.condition.type==="State"&&(o=new GY(a,n,s,i,r,t))),o&&(this.eventsPerConditions[n.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},ic=new E,an=new E,qn=new E,RS=new kr,WY=.01,At=new E,bi=new E,LS=new E,lo=new $e,fg=new Di,qY=new me,mg=new ri,ll=new E,Fs=new E,hl=.2;function gg(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var YY=function(){let e=new me;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&gg(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?gg(s.position,t.limits):t.reference==="local"&&(lo.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(lo),gg(s.position,t.limits),lo.invert(),s.position.applyQuaternion(lo),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(At,s.quaternion,bi),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof Dr&&Zs(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),XY=class{constructor(e,t,i,r,s,a){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=fr(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=fr(t,t.dragDropActions.drop,i,r,s,this.object);let n=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(n.push(l),a[l.uuid]&&a[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&n.push(u)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),a[l.uuid]&&a[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=n.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new E().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new E().setFromMatrixPosition(o.matrixWorld),pointStart:new E,pointEnd:new E,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new E().copy(o.position),quat0:new $e().copy(o.quaternion),snapped:!1,orientationMatrix:new me,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Ii(this.actionsDrag),Ii(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},QY=class extends Ds{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Ye.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(this.lastDropDestination=null,n.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:u,pointStart:c}of o.dragItems){if(h===n[0].object||h===n[0].object.object||pt.is(h)&&h.isAncestorOf(n[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(At,lo,bi),fg.setFromQuaternion(lo),d.prevR===void 0?(d.prevR=fg.clone(),d.prevT=At.clone()):(d.prevR.copy(fg),d.prevT.copy(At)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Ye.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(Ye.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===n[0]?.object||h===n[0]?.object?.object||pt.is(h)&&h.isAncestorOf(n[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=n.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Gl)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===h.object.uuid||a.scene.find(u).isAncestorOf(h.object.uuid))))[0]),l){let h=LS.copy(l.face.normal).applyMatrix3(mg.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){At.copy(h).applyMatrix3(mg.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;At.x>hl?bi.x=-u.recursiveBBox.min.x:At.x<-hl&&(bi.x=-u.recursiveBBox.max.x),At.y>hl?bi.y=-u.recursiveBBox.min.y:At.y<-hl&&(bi.y=-u.recursiveBBox.max.y),At.z>hl?bi.z=-u.recursiveBBox.min.z:At.z<-hl&&(bi.z=-u.recursiveBBox.max.z),bi.applyMatrix3(mg.invert())}else bi.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(bi)}this.activeEvent.data.autoOrient&&(At.set(0,1,0).cross(h),At.length()<1e-4&&At.set(-1,0,0).cross(h),bi.crossVectors(LS,At),o.orientationMatrix.makeBasis(At,bi,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(h=>h.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(a=>{a.stop(),a.object.currentState!==null&&a.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(a=>{a.stop()}),this.activeEvent.actionsDrag.Audio.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(a=>a.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new XY(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:a}=this.eventContext;s().getWorldDirection(an),an.negate();let n=lo.identity();switch(r==="parent"?qY.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(At,n,bi):r==="local"&&e.matrixWorld.decompose(At,n,bi),i){case"x":At.set(1,0,0).applyQuaternion(n),ll.copy(an).cross(At),Fs.copy(At).cross(ll);break;case"y":At.set(0,1,0).applyQuaternion(n),ll.copy(an).cross(At),Fs.copy(At).cross(ll);break;case"z":At.set(0,0,1).applyQuaternion(n),ll.copy(an).cross(At),Fs.copy(At).cross(ll);break;case"xy":Fs.set(0,0,1).applyQuaternion(n);break;case"yz":Fs.set(1,0,0).applyQuaternion(n);break;case"xz":Fs.set(0,1,0).applyQuaternion(n);break;case"adaptive":an.angleTo(bi.set(0,1,0))>Math.PI/6?(At.crossVectors(bi.set(0,1,0),an),Fs.crossVectors(At,bi)):Fs.set(0,1,0);break;default:Fs.copy(an);break}qn.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:qn;if(RS.setFromNormalAndCoplanarPoint(Fs,o),!!a.ray.intersectPlane(RS,t)&&(i==="x"||i==="y"||i==="z")){let l=bi.subVectors(t,o).dot(At);t.copy(o).addScaledVector(At,l)}}updateDragItem(e,t=!1){qn.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?ic.subVectors(e.fromPosition,qn).divideScalar(e.currentDampingFactor):e.reset==="original"?(ic.subVectors(e.obj.userData.worldPosition0,qn).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):ic.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(qn).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?ic.length()<WY:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&YY(e,ic.add(qn),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},cl=new E,vg=new E,ba=new E,wa=new E,BS=new kr,ZY=.01,KY={type:"requestRender"},JY=function(){let e=new E,t=new E;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),zS=function(){let e=new me;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Dr&&Zs(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),$Y=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new E,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...av.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=fr(e,e.actions,i,r,s,t)}},eX=class extends Ds{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Ye.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new $Y(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Ur&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Ur&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,Ii(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(ba),e.isReset)wa.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(wa);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(vg),vg.negate(),cl.copy(vg)):i==="xy"?cl.set(0,0,1):i==="xz"?cl.set(0,1,0):i==="yz"&&cl.set(1,0,0),BS.setFromNormalAndCoplanarPoint(cl,ba),!o.ray.intersectPlane(BS,wa))return}if(!e.isReset){if(wa.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)wa.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(wa.x=ba.x),e.data.enabledTranslation[1]===!1&&(wa.y=ba.y),e.data.enabledTranslation[2]===!1&&(wa.z=ba.z);let a=JY(ba,wa,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=cl.subVectors(a,ba).divideScalar(e.currentDampingFactor);ba.add(n),t&&zS(e.object,ba),e.paused=n.length()<ZY}else zS(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(KY)}},rc=new E,Cu=new E,sc=new me,dl=new $e,nn=new $e,ac=new E,nc=new E,Yn=new E,_a=new E,yg=new kr,tX=1e-6,iX={type:"requestRender"},rX={type:"changeRotation"},kS=function(){let e=new me;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(CC(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Dr&&Zs(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),sX=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new $e,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...nv.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},aX=class extends Ds{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Ye.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let a=od(r);a&&a==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new sX(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Ur&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let a=this.onTargetChange(i),n=i.target;this.pairOfEventListeners.push([n,a]),n.addEventListener("requestRender",a)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Ur&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:a,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:u,target:c}=e;if(u.getWorldPosition(ac),!e.isReset)if(e.target)e.target.getWorldPosition(nc);else{if(s==="custom"?(l().getWorldDirection(Cu),Cu.negate(),yg.setFromNormalAndCoplanarPoint(Cu,ac)):(s==="xy"?rc.set(0,0,1):s==="xz"?rc.set(0,1,0):s==="yz"&&rc.set(1,0,0),yg.setFromNormalAndCoplanarPoint(rc,ac)),!h.ray.intersectPlane(yg,nc))return;r>0&&(s==="custom"||s===void 0)&&nc.addScaledVector(Cu,r)}if(e.isReset||(c?t==="target"?Yn.copy(c.up).applyMatrix4(sc.extractRotation(c.matrixWorld)).normalize():n.some(d=>d===!1)?(i==="x"?(_a.set(0,0,1),n[2]===!1&&_a.set(0,1,0)):i==="y"?(_a.set(1,0,0),n[0]===!1&&_a.set(0,0,1)):(_a.set(0,1,0),n[1]===!1&&_a.set(1,0,0)),Yn.copy(_a).applyQuaternion(e.worldQuaternion0).normalize()):Yn.set(0,1,0):s==="custom"?Yn.set(0,1,0):Yn.copy(rc)),e.isReset)nn.copy(e.worldQuaternion0);else if(ac.distanceTo(nc)>a&&o&&c)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)nn.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;nX(sc,nc,ac,Yn,i,_a),nn.setFromRotationMatrix(sc),dl.setFromUnitVectors(_a.applyQuaternion(nn),Yn),n.some(d=>d===!1)&&t!=="target"&&nn.premultiply(dl).normalize()}e.currentDampingFactor>1?(u.updateWorldMatrix(!0,!1),dl.setFromRotationMatrix(CC(u.matrixWorld)),dl.slerp(nn,1/e.currentDampingFactor),kS(u,sc.makeRotationFromQuaternion(dl)),e.paused=8*(1-dl.dot(nn))<tX):(kS(u,sc.makeRotationFromQuaternion(nn)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),u.dispatchEvent(iX),u.dispatchEvent(rX)}},Qr=new E,xi=new E,ei=new E;function nX(e,t,i,r,s,a){let n=e.elements;ei.subVectors(t,i),ei.lengthSq()===0&&(ei.z=1),ei.normalize(),xi.crossVectors(r,ei),xi.lengthSq()===0&&(Math.abs(r.z)===1?ei.x+=1e-4:ei.z+=1e-4,ei.normalize(),xi.crossVectors(r,ei)),xi.normalize(),Qr.crossVectors(ei,xi),s==="x"?a.z===1?[xi,Qr,ei]=[ei,xi,Qr]:(xi.negate(),[xi,ei]=[ei,xi]):s==="y"?a.x===1?[xi,Qr,ei]=[Qr,ei,xi]:(xi.negate(),[Qr,ei]=[ei,Qr]):a.x===1&&(xi.negate(),[xi,Qr]=[Qr,xi]),n[0]=xi.x,n[4]=Qr.x,n[8]=ei.x,n[1]=xi.y,n[5]=Qr.y,n[9]=ei.y,n[2]=xi.z,n[6]=Qr.z,n[10]=ei.z}var oX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=fr(t,t.actions,r,s,a,i)}disconnect(){Ii(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},lX=class extends Ds{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{Ye.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Ye.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Ye.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:a,reverse:n})=>{if(!s||!a)return;let o=od(s);o&&o==="MouseHover"&&(a.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[a.uuid]?.forEach(l=>l.dispatchUserEvent(n)))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="MouseHover")try{let o=new oX(a,n,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Ur&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Ur&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s}=this.eventContext;if(i){let a=Gu(r,s,this.objects);t=m0(a)}else this.objects.forEach(a=>{Up(r,a)&&t.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},hX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=fr(t,t.actions,r,s,a,i)}connect(){this.scrollCounter=0}disconnect(){Ii(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},cX=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.object=i,this.domElement=a,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=fr(t,t.actions,r,s,n,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,a=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let n=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?n:l==="bottom"?n-o:n-o*.5;this.scrollStart=a-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Ii(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},dX=class extends Ds{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([n,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=n=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(u=>u.dispatch(o))})},this.onWheel=n=>{!this.isInview||n.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:n.deltaY}),l.forEach(h=>h.dispatch(n.deltaY))})},this.onUserEvent=({eventName:n,target:o,reverse:l})=>{if(!n||!o)return;let h=od(n);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(u=>{u.dispatchUserEvent(l)}))};let{page:i,sharedAssets:r,domElement:s,isExport:a}=this.eventContext;i.traverseEntity(n=>{if(n.data?.events.length){for(let{id:o,data:l}of n.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!a){let h=new hX(o,l,n,i,r,t);this.wheelEventsPerObject.has(n)?this.wheelEventsPerObject.get(n)?.push(h):this.wheelEventsPerObject.set(n,[h])}else{let h=new cX(o,l,n,i,r,s,t);this.scrollEventsPerObject.has(n)?this.scrollEventsPerObject.get(n)?.push(h):this.scrollEventsPerObject.set(n,[h])}}}),this.intersectionObserver=new IntersectionObserver(n=>{let o=n[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},uX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=fr(t,t.actions,r,s,a,i)}disconnect(){Ii(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof oo?t.interaction.audioPlayer.play():t.interaction instanceof h0&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof ql?t.interaction.play(i==="autoplay"):t.interaction instanceof p0&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof oo?t.interaction.audioPlayer.play():t.interaction instanceof h0&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof ql?t.interaction.play():t.interaction instanceof p0&&t.interaction.dispatch()})}},pX=class extends Ds{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,a])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(n=>{n.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(a=>{a.interaction instanceof oo&&a.interaction.audioPlayer.play()}),s.actions.Video.forEach(a=>{let n=a.interaction.data.triggerAfter??"autoplay";a.interaction instanceof ql&&a.interaction.play(n==="autoplay")})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=od(i);a&&a==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext;if(t.traverseEntity(i=>{if(i.data?.events.length)for(let{id:r,data:s}of i.data.events){if(s.disabled||s.type!=="Start")continue;let a=new uX(r,s,i,t,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(i)?this.eventsPerObject.get(i)?.push(a):this.eventsPerObject.set(i,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a]))}}),[...this.eventsAfterPerObject.values()].some(i=>i.length)){if(this.eventManager.activateCount===0){let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,n])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>s.dispatch()),i.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},fX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.alreadyPlayedNonTogglingActions=new Set,this.actions=fr(t,t.actions,r,s,a,i),this.target=t.target,this.useToggle=t.runMode==="Toggle"}disconnect(){Ii(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},mX=class extends Ds{constructor(e,t,i,r,s){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=s,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.events=[],this.onFrame=a=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,o=[],l=[];for(let c=0;c<this.propertiesToWatch.length;c++){let{objectId:d,property:p,prevValue:f}=this.propertiesToWatch[c],m=this.eventContext.scene.find(d),g=lv.propertyPaths[p];if(g[0]==="width"||g[0]==="height"||g[0]==="depth")m=m.geometry.userData.parameters[g[0]];else for(let v=0;v<g.length;v++)m=m[g[v]];f===null?this.propertiesToWatch[c].prevValue=m instanceof E?m.clone():m:(m instanceof E?!m.equals(f):f!==m)&&(l.push({objId:d,property:p}),m instanceof E?this.propertiesToWatch[c].prevValue.copy(m):this.propertiesToWatch[c].prevValue=m)}for(let c=0;c<this.variablesToWatch.length;c++){let{id:d,prevValue:p}=this.variablesToWatch[c],f=this.shared.getVariable(d);f!==p&&(o.push(d),this.variablesToWatch[c].prevValue=f)}for(let c=0;c<this.dynamicVars.length;c++){let{id:d,expectedTime:p,last:f,data:m,timerSeconds:g,startValue:v}=this.dynamicVars[c],y=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?y=1:m.dynamicVariableType==="counter"?y=m.updateInterval:m.dynamicVariableType==="random"&&(y=m.isStatic?1/0:m.updateInterval),p===-1){this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+y;continue}if(!((this.shared.getDynamicVariablePlayState(d)==="Stopped"||this.shared.getDynamicVariablePlayState(d)==="Restarted")&&(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+y,m.dynamicVariableType==="counter"&&this.shared.getVariable(d)!==v&&(this.shared.updateVariable(d,v),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==v&&(this.dynamicVars[c].timerSeconds=v,this.shared.updateVariable(d,vs.getFormattedTimerTime(v,m)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(d)==="Restarted"&&this.shared.setDynamicVariablePlayState(d,"Playing"),this.shared.getDynamicVariablePlayState(d)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(d)==="Paused"){this.dynamicVars[c].deltaToExpectedTime===void 0&&(this.dynamicVars[c].deltaToExpectedTime=Math.max(this.dynamicVars[c].expectedTime-a,0)),this.dynamicVars[c].last=a-(y-this.dynamicVars[c].deltaToExpectedTime),this.dynamicVars[c].expectedTime=a+this.dynamicVars[c].deltaToExpectedTime;continue}else this.dynamicVars[c].deltaToExpectedTime=void 0;if(a>=p)if(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime+=y,m.dynamicVariableType==="random"){let x=m.min+Math.random()*(m.max-m.min),b=m.decimals;x=Math.round(x*Math.pow(10,b))/Math.pow(10,b),this.shared.updateVariable(d,x),o.push(d),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){if(m.increment===0)continue;let x=this.shared.getVariable(d),b=this.shared.getDynamicVariableToggleIsForward(d)??!0,w=this.shared.getVariable(d)+m.increment*(b?1:-1);m.hasEnd&&(w=m.increment>0?Le.clamp(w,v,m.endValue):Le.clamp(w,m.endValue,v),w===v&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?w===m.endValue&&(w=v):(w===v||w===m.endValue)&&this.shared.setDynamicVariablePlayState(d,"Paused")),w!==x&&(o.push(d),this.shared.updateVariable(d,w),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time")this.shared.updateVariable(d,u_(n,m)),o.push(d),this.eventManager.requestRender();else{let x=Fr.isTextValue(m.endValue)?NS(m.endValue.textValue):m.endValue,b=this.shared.getDynamicVariableToggleIsForward(d)??!0,w=g+(a-f)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(b?1:-1);w=Math.max(w,0),m.hasEnd&&(w=m.dynamicVariableType==="stopwatch"?Le.clamp(w,v,x):Le.clamp(w,x,v),w===v&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?Math.abs(w-x)<(m.format==="number3decimal"?1e-4:.1)&&(w=v):(Math.abs(w-v)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(w-x)<(m.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(d,"Paused")),w!==g&&(o.push(d),this.dynamicVars[c].timerSeconds=w,this.shared.updateVariable(d,vs.getFormattedTimerTime(w,m)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(c=>{c.data.variableId==="mouseProperty"&&(c.dispatch(),this.eventManager.requestRender())}));let h=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,h=!0);let u=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,u=!0),this.events.forEach(c=>{(o.includes(c.data.variableId)||l.find(d=>d.objId===c.data.objectId&&d.property===c.data.property)||c.data.variableId==="mouseProperty"&&h||c.data.variableId==="raycastProperty"&&u)&&(c.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()},e.page.traverseEntity(a=>{a.data?.events.filter(n=>n.data.type==="VariableChange"&&!n.data.disabled).forEach(n=>{this.events.push(new gX(a.uuid,n.data,a,e.page,e.sharedAssets,i))})}),this.propertiesToWatch=this.events.filter(a=>a.data.variableId==="objectProperty"&&a.data.objectId!==null).map(a=>({objectId:a.data.objectId,property:a.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:a,data:n})=>{if(!("dynamicVariableType"in n)){this.events.find(l=>l.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let o;if(n.dynamicVariableType==="timer"||n.dynamicVariableType==="stopwatch"){let l;if(Fr.isTextValue(n.value)&&Array.isArray(n.value.textValue)){let h=n.value.textValue;h.length===3?l=h[2]+h[1]*60+h[0]*3600:l=h[1]+h[0]*60}else l=n.value;o=l,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,timerSeconds:l,startValue:o})}else n.dynamicVariableType==="time"&&this.shared.updateVariable(a,u_(new Date,n)),n.dynamicVariableType==="counter"&&(o=Fr.isTextValue(n.value)?NS(n.value.textValue):n.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,startValue:o})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},gX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=fr(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch())}dispose(){Ii(this.actions)}};function NS(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var vX="https://unpkg.com/@splinetool/runtime@0.9.503/build/",yX="https://unpkg.com/@splinetool/navmesh-wasm@0.9.503/build/",xX=`
|
|
6427
6427
|
(async function() {
|
|
6428
6428
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
6429
6429
|
import('${vX}' + 'navmesh.js'),
|
|
@@ -6489,7 +6489,7 @@ onmessage = function(messageEvent) {
|
|
|
6489
6489
|
<path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6490
6490
|
</svg>
|
|
6491
6491
|
`),S.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),S.addEventListener("touchend",C=>C.preventDefault()),this.joysticks[p]=[void 0,f];return}let A={zone:f,mode:"static",position:x,size:m};v==="hide"&&(A.restOpacity=0);let _=iq.create(A);_.on("move",(S,M)=>{let C=this.gameControl;d==="pos"?M.force<.2?C.moveForce=0:(C.movementState.movePosZ=Math.sin(-M.angle.radian),C.movementState.movePosX=Math.cos(-M.angle.radian),M.force>1.2?C.movementState.run=1:C.movementState.run=0,M.force<.3?C.moveForce=(M.force-.2)/.1:C.moveForce=1):d==="rot"&&(M.force<.2?C.rotForce=0:(C.movementState.rotPosX=M.vector.y,C.movementState.rotPosY=-M.vector.x,M.force<.3?C.rotForce=(M.force-.2)/.1:C.rotForce=1)),this.requestRender()}),_.on("end",(S,M)=>{let C=this.gameControl;d==="pos"?(C.movementState.movePosZ=0,C.movementState.movePosX=0,C.moveForce=1):d==="rot"&&(C.movementState.rotPosX=0,C.movementState.rotPosY=0,C.rotForce=1)}),this.joysticks[p]=[_,f]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(d=>d.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new mt.World(new mt.Vector3(0,this.gravity,0)),this.events=new mt.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(n=>{let o;if(n instanceof _s)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof qi)o=n.object;else if(o=n,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0;let l=o.dataPatched,h;for(let g of l.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(h=g.data);if(!l.physics||(l.physics.enabled==="visibility"?!l.visible:!l.physics.enabled))return!0;n.updateMatrixWorldSVD();let u=Fp(l),c=!1,d=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let g of l.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){c=!0;let v=new fX(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(y=>y.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[v]}else if(g.data.type==="Follow"){f=!0;let v=g.data.target;n.traverseVisible(y=>{y.userData.isFollowingObj=v})}}l.physics.rigidBody==="dynamic"&&l.physics.fusedBody===!1&&(n.matrixWorldFusedFalse=n.matrixWorld.clone());let m=n.geometry;if(h!==void 0){let g=mt.RigidBodyDesc.kinematicPositionBased();(n.hasNonUniformScale?n.matrixWorldRigid:n.matrixWorld).decompose(ci,ms,on),n.position0=ci.clone().divideScalar(this.pixelsPerMeter),n.rotation0=ms.clone(),ci.divideScalar(this.pixelsPerMeter),g.setTranslation(ci.x,ci.y,ci.z).setRotation(ms);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);n.rigidBody=v;let y;h.collider.type==="sphere"?y=mt.ColliderDesc.ball(h.collider.radius/this.pixelsPerMeter):h.collider.type==="capsule"?y=mt.ColliderDesc.capsule((h.collider.height/2-h.collider.radius)/this.pixelsPerMeter,h.collider.radius/this.pixelsPerMeter):y=mt.ColliderDesc.cuboid(h.collider.width/this.pixelsPerMeter/2,h.collider.height/this.pixelsPerMeter/2,h.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(mt.CoefficientCombineRule.Average).setRestitutionCombineRule(mt.CoefficientCombineRule.Average).setDensity(l.physics.density).setFriction(l.physics.friction).setRestitution(l.physics.restitution);let x=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(x.handle,o),ci.fromArray(h.collider.position).multiply(on.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),x.setTranslationWrtParent(ci);let b=new $e().setFromEuler(new Di().setFromVector3(new E().fromArray(h.collider.rotation)));x.setRotationWrtParent(b),x.setActiveEvents(mt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else l.physics.rigidBody==="dynamic"||u||f||d||p||c?(this.addRigidBody(n,o,{hasFollow:f,hasTransformAnim:u,hasDrag:p}),this.generateSensorColliderDescs(o,l.physics.fusedBody)):(m&&e.push(Pa(m,n.matrixWorld)),l.physics.fusedBody&&n.traverseObject((g,v)=>{if(v===0)return;let y;if(g instanceof _s)if(g.objectForSample){if(g.objectForSample.dataPatched.physics.fusedBody)return;y=g.object}else return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(g instanceof qi)y=g.object;else if(y=g,y.dataPatched.cloner?.hideBase)return!0;let x=y.dataPatched;if(x.physics.enabled==="visibility"?!x.visible:!x.physics.enabled)return!0;let b=g.geometry;b?.getAttribute("position")!==void 0&&e.push(Pa(b,g.matrixWorld))}),this.generateSensorColliderDescs(o,l.physics.fusedBody,t));if(l.physics?.fusedBody===!0||h)return!0}),e.length===0)return;let i=ao(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=mt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),a=mt.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(mt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(mt.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);for(let[n,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(n,s);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new HS(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new me().compose(gs.fromArray(t.data.position),fl.setFromEuler(WS.fromArray(t.data.rotation)),Ag);if(t.data.triggerZone==="box"){let s=new ai;s.min.fromArray(t.data.size).multiplyScalar(-.5),s.max.fromArray(t.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e,t,i){if(!this.isEnabled)return!0;let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(r=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(e,t,i)&&r),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(e===0)r=this.stepPhysics()&&r;else{let a=e/1e3;a<s&&a>s*.55&&(a=s),this.accumulator+=a;let n=performance.now(),o=0,l=6;for(;this.accumulator>=s&&o<l&&(r=this.stepPhysics()&&r,this.accumulator-=s,o++,!(performance.now()-n>s*1e3)););this.accumulator=this.accumulator%s}}return r}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(ci,ms,on),_g.setFromQuaternion(ms);let t=e;t.prevR===void 0?(t.prevR=_g.clone(),t.prevT=ci.clone()):(t.prevR.copy(_g),t.prevT.copy(ci)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(ci.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(ms))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent,s;if(t.cloner){for(let a of t.cloner.children)if(a.rigidBody===r){s=a;break}}e.dispatch(s),t.dispatchEvent(g0)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=qS.copy(e.matrixWorld).invert();e.traverseEntity((s,a)=>{if(t===!1&&a===1)return!0;for(let n of s.dataPatched.events)if(n.data.type==="Trigger"&&n.data.disabled!==!0){let o=new HS(n.id,n.data,s,this.page,this.sharedAssets,this.eventManager),l;if(n.data.triggerZone==="box"?l=mt.ColliderDesc.cuboid(...n.data.size.map(h=>h/(2*this.pixelsPerMeter))):l=mt.ColliderDesc.ball(n.data.radius/this.pixelsPerMeter),l.setDensity(0).setSensor(!0).setActiveEvents(mt.ActiveEvents.COLLISION_EVENTS),gs.fromArray(n.data.position),fl.setFromEuler(WS.fromArray(n.data.rotation)),Pu.compose(gs,fl,Ag).premultiply(s.matrixWorld),i?(Pu.decompose(gs,fl,Sg),l.setActiveCollisionTypes(mt.ActiveCollisionTypes.KINEMATIC_FIXED|mt.ActiveCollisionTypes.DYNAMIC_FIXED)):(Pu.premultiply(r).decompose(gs,fl,Sg),e.rigidBody.bodyType()===mt.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===mt.RigidBodyType.Fixed?l.setActiveCollisionTypes(mt.ActiveCollisionTypes.KINEMATIC_FIXED|mt.ActiveCollisionTypes.DYNAMIC_FIXED):l.setActiveCollisionTypes(mt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|mt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),gs.divideScalar(this.pixelsPerMeter),l.setTranslation(gs.x,gs.y,gs.z),l.setRotation(fl),i)i.push([l,o]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(l,e.rigidBody);this.sensorToTriggerEvent[h.handle]=o}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,s,a]=this.sharedGameControlGlobals.triggers[t];for(let n=0;n<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;n++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[n];if(s===o||a.isValidTriggeringObject(pt.is(o)?o:o.object)===!1)continue;let l=qS.copy(s.matrixWorld).decompose(gs,YS,Sg).compose(gs,YS,Ag).multiply(r),h=Pu.copy(o.matrixWorld).invert().multiply(l);i instanceof ai?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):(Mg.radius=i,Mg.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere(Mg)),e?a.currentIntersectedObjects.indexOf(o)===-1&&(a.currentIntersectedObjects.push(o),a.dispatch(),s.dispatchEvent(zX)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(u=>u!==o)}}}};function UX(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+e,a=this._loopCount,n=r===y0;if(e===0)return a===-1?s:n&&(a&1)===1?t-(s-i):s;if(r===rA){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),s>=t||s<i){let o=Math.floor((s-i)/(t-i));s-=(t-i)*o,a+=Math.abs(o);let l=this.repetitions-a;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n||(s=e>0?t:i,this.repetitions===1&&(s=t)),this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let h=e<0;this._setEndings(h,!h,n)}else this._setEndings(!1,!1,n);this._loopCount=a,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(n&&(a&1)===1)return t-(s-i)}return s}var XS=!1,FX=class{constructor(e,t,i,r){this.scene=e,this.requestRender=t,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=s=>{s.data.type==="Empty"&&s.data.animations&&s.data.animations.forEach((a,n)=>{let o=a[0]+"/";if(Array.isArray(s.identity)?o+=s.identity[0]:o+=s.uuid,this.clipIdToAction[o])return;let l=Ng.parse(JSON.parse(a[2]));s.animations[n]=l;let h=this.mixer.clipAction(l,s);XS===!1&&(Object.getPrototypeOf(h)._updateTime=UX,XS=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new U4(e),this.scene.traverseEntity(this.addClip)}deleteClip(e,t){let i=this.scene.find(t);if(!i)return;let r=i.animations.find(a=>a.uuid===e);if(!r)return;let s=this.clipIdToAction[e];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[e],i.animations=i.animations.filter(a=>a.uuid!==e))}get isPlaying(){return Object.values(this.clipIdToAction).some(e=>e.isRunning())}playFromInspector(e){this.mixer.stopAllAction();let t=this.clipIdToAction[e];!t||(t.play(),this.activeClip=t.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(e=>{e.repetitions=1/0,e.loop=sA}),this.mixer.stopAllAction(),this.requestRender()}play(e){let t=e.clipId+"/"+e.object,i=this.clipIdToAction[t];if(i)return e&&(e.repeat>=0&&(i.repetitions=e.repeat+1),e.direction==="pingpong"&&e.repeat!==0&&(i.loop=y0)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(e){let t=this.clipIdToAction[e];!t||(t.play(),t.paused=!1,this.requestRender())}pauseFromInspector(e){let t=this.clipIdToAction[e];!t||(t.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(e){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(e/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*this.maxFrames%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??0}setProgressFromInspector(e,t){if(!this.clipIdToAction[t])return;this.activeClip!==this.clipIdToAction[t].getClip()&&this.playFromInspector(t);let i=this.clipIdToAction[t].paused;this.clipIdToAction[t].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?e/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}},Eg=new WeakMap,VX=class extends O0{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let s=new Ug(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{this.decodeDracoFile(a,t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){let s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};return this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){let i=JSON.stringify(t);if(Eg.has(e)){let o=Eg.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,a=e.byteLength,n=this._getWorker(s,a).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[s]={resolve:l,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return n.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),Eg.set(e,{key:i,promise:n}),n}_createGeometry(e){let t=new Ue;e.index&&t.setIndex(new Ze(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r=e.attributes[i],s=r.name,a=r.array,n=r.itemSize;t.setAttribute(s,new Ze(a,n))}return t}_loadLibrary(e,t){let i=new Ug(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{let r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);let s=jX.toString(),a=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
6492
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let a=s.data;switch(a.type){case"decode":r._callbacks[a.id].resolve(a);break;case"error":r._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function jX(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(u){e.onModuleLoaded=function(c){u({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(u=>{let c=u.draco,d=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,d,p,h),m=f.attributes.map(g=>g.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(d)}});break}};function i(n,o,l,h){let u=h.attributeIDs,c=h.attributeTypes,d,p,f=o.GetEncodedGeometryType(l);if(f===n.TRIANGULAR_MESH)d=new n.Mesh,p=o.DecodeBufferToMesh(l,d);else if(f===n.POINT_CLOUD)d=new n.PointCloud,p=o.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let m={index:null,attributes:[]};for(let g in u){let v=self[c[g]],y,x;if(h.useUniqueIDs)x=u[g],y=o.GetAttributeByUniqueId(d,x);else{if(x=o.GetAttributeId(d,n[u[g]]),x===-1)continue;y=o.GetAttribute(d,x)}m.attributes.push(s(n,o,d,g,v,y))}return f===n.TRIANGULAR_MESH&&(m.index=r(n,o,d)),n.destroy(d),m}function r(n,o,l){let h=l.num_faces()*3,u=h*4,c=n._malloc(u);o.GetTrianglesUInt32Array(l,u,c);let d=new Uint32Array(n.HEAPF32.buffer,c,h).slice();return n._free(c),{array:d,itemSize:1}}function s(n,o,l,h,u,c){let d=c.num_components(),p=l.num_points()*d,f=p*u.BYTES_PER_ELEMENT,m=a(n,u),g=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,m,f,g);let v=new u(n.HEAPF32.buffer,g,p).slice();return n._free(g),{name:h,array:v,itemSize:d}}function a(n,o){switch(o){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var wn;function GX(){return wn||(wn=new VX,wn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),wn.decoderPending}async function HX(e){if(wn){let t={attributeIDs:wn.defaultAttributeIDs,attributeTypes:wn.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await wn.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function WX(e,t){let[i,r]=F2(rv.deserialize(new Uint8Array(e)));uM(i);let s=[];i.scene.objects.traverse((a,n)=>{n.type==="Mesh"&&n.geometry.type==="NonParametricGeometry"&&n.geometry.data.draco!==void 0&&s.push(n)}),s.length&&await GX();for(let a of s){let n=await HX(mi(a.geometry.data.draco));if(n){n.index&&(a.geometry.data.index={array:n.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};n.attributes.forEach(({name:l,array:h,itemSize:u})=>{o[l]={array:h,itemSize:u,type:"Float32Array",normalized:!1}}),a.geometry.data.attributes=o,a.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var qX=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=fr(i,t.actions,s,a,n,r)}disconnect(){Ii(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},YX=class extends Ds{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(s=>{let a=ov.deviceToSize(s.data.size),n=s.dataEvent.orientation==="horizontal"?i:r,o;switch(s.data.operator){case"<":o=n<a[0];break;case">":o=n>a[0];break;case"<>":o=n>a[0]&&n<a[1];break}s.stage!==o&&(s.stage=o,s.stage?s.dispatchIn():s.dispatchOut())}),this.eventContext.updateDomRect()},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:s,height:a}=r.contentRect;this.resize(s,a)}})}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext;this.onResizeObserver.observe(i),e.traverseEntity(r=>{if(!(!r.visible||!r.data?.events.length))for(let{data:s}of r.data.events)s.disabled||s.type==="Resize"&&s.breakpoints.forEach(({data:a,id:n})=>{try{let o=new qX(n,a,s,r,e,t,this.eventManager);this.breakpoints.push(o)}catch{}})})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},QS=Object.keys(IC).filter(e=>isNaN(Number(e))),XX=class{constructor(e,t,i,r,s){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=a=>{(a.touches.length>1||this.preventTouchScroll)&&a.preventDefault()},this.onMouseWheelPreventScroll=a=>{this.preventScroll&&a.preventDefault()},this.onMouseMove=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:a.buttons>0}},this.onMouseDown=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!0}},this.onMouseUp=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!1}},this.getMousePosition=a=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=a.touches?.length>0?a.touches[0]:a;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new kY(this.eventContext),DynamicVariable:new mX(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),Conditional:new HY(this.eventContext,this),Start:new pX(this.eventContext,this),Basic:new UY(this.eventContext,this,this.needsRaycast),MouseHover:new lX(this.eventContext,this),Scroll:new dX(this.eventContext,this),Follow:new eX(this.eventContext,this),DragDrop:new QY(this.eventContext,this),LookAt:new aX(this.eventContext),Resize:new YX(this.eventContext,this)};let{page:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),QS.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender),i.destroyedInAction=!1}),QS.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length){for(let r of i.data.events)if(!r.data.disabled)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(t);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(t);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(t);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.actions.forEach(t)}})}},QX=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new F().copy(i),this._editorSize=new F().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=ZX(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function ZX(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var KX=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Ey(e.shared,t),this.scene=new By(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof Cn&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof dr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},JX=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 $X(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 Tc(e){return e instanceof Wc?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function eQ(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Dr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Dr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let a=r.material.uuid,n=t.shared.materials[a];if(n){if(!Yi.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!Yi.isMergable(l.material))return;a=Yi.getHash(l.material)}}i[a]||(i[a]={});let o=i[a][Tc(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[a][Tc(r)]=[r],r.cloner)for(let l of r.cloner.children)i[a][Tc(r)].push(l)}),i}function tQ(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 iQ(e,t){let i=eQ(t,e),r=tQ(i),s=new Array(r),a=0,n=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(g=>{g instanceof Dr&&(n[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),n[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&$X(n[g]);let m=ao(n.slice(0,o),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new hr(m,l[0].material);break}default:{g=new hr(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof Dr&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][Tc(x)]&&i[x.material.uuid][Tc(x)].length>1||(u[c++]=x));for(let x=0;x<c;x++)t.attach(u[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[a++]=x}}}for(let d=0;d<a;d++)s[d].removeFromParent()}var rQ=Ri(TT(),1),sQ=new F;function aQ(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 Qy=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=sQ.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}},this._debouncedResize=$0(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new JX({x:10,y:10})),b6(e)}async load(e,t,i){aQ(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;let r=await WX(e);this._data=r,r.version&&(0,rQ.default)(r.version,"0.9.502")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([O_(r)&&tG(),WH(r)&&J8(),Fc.physicsEnabled(r.scene.objects)&&M6(),E_(r)&&IH(),EX(r)&&S6()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new KX(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();iQ(r,s.scene);let l=performance.now();console.log("Merged geometries in ",l-o," ms")}O_(r)&&this._scene.traverse(o=>{Zs(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof _s&&o.pendingMediaLoad&&o.update()})});let a=Object.keys(r.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);Promise.all(a).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),E_(r)&&kX(r)&&await Promise.all(a),this._scene.rewriteEventsBeforeGoToPlayMode(),Yy(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new bW({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),this._scene.initializeSplatViewer(this._renderer),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let n=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",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=n.size[0],this._viewportHeight=n.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 QX(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"),t){let o=new BY(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,n);this._scene.updateMatrixWorld(!0),this._controls=new NX(o),this._animationControls=new FX(this._scene,this._requestRenderAutoMode),this._eventManager=new XX(r.scene.publish,this._controls,this._animationControls,o,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&Fr.isTextValue(e)?Fr.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}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)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==_h&&!this._scene.isInvisibleObjects(t)&&!(t instanceof Cn)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}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 BC&&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},a=new Cr(t,i,r,s);try{a.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(a),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{Kx.unsubscribe(e)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),w6(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}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;e.traverseAncestors(s=>{s instanceof Cn&&(t=s.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof Cn||e instanceof By?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=Kx(i,(s,a)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=a),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};var ff=window,mf=ff.ShadowRoot&&(ff.ShadyCSS===void 0||ff.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Zy=Symbol(),zC=new WeakMap,ld=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Zy)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(mf&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=zC.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&zC.set(i,t))}return t}toString(){return this.cssText}},kC=e=>new ld(typeof e=="string"?e:e+"",void 0,Zy),Ky=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,a)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[a+1],e[0]);return new ld(i,e,Zy)},Jy=(e,t)=>{mf?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=ff.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},gf=mf?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return kC(i)})(e):e;var $y,vf=window,NC=vf.trustedTypes,nQ=NC?NC.emptyScript:"",UC=vf.reactiveElementPolyfillSupport,t1={toAttribute(e,t){switch(t){case Boolean:e=e?nQ: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}},FC=(e,t)=>t!==e&&(t==t||e==e),e1={attribute:!0,type:String,converter:t1,reflect:!1,hasChanged:FC},Wa=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=e1){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 a=this[t];this[i]=s,this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||e1}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(gf(s))}else t!==void 0&&i.push(gf(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 Jy(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=e1){var s;let a=this.constructor._$Ep(t,r);if(a!==void 0&&r.reflect===!0){let n=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:t1).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(a):this.setAttribute(a,n),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,a=s._$Ev.get(t);if(a!==void 0&&this._$El!==a){let n=s.getPropertyOptions(a),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:t1;this._$El=a,this[a]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||FC)(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,a)=>this[a]=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 a;return(a=s.hostUpdate)===null||a===void 0?void 0:a.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){}};Wa.finalized=!0,Wa.elementProperties=new Map,Wa.elementStyles=[],Wa.shadowRootOptions={mode:"open"},UC?.({ReactiveElement:Wa}),(($y=vf.reactiveElementVersions)!==null&&$y!==void 0?$y:vf.reactiveElementVersions=[]).push("1.6.0");var i1,yf=window,Ch=yf.trustedTypes,VC=Ch?Ch.createPolicy("lit-html",{createHTML:e=>e}):void 0,Ln=`lit$${(Math.random()+"").slice(9)}$`,XC="?"+Ln,oQ=`<${XC}>`,Th=document,cd=(e="")=>Th.createComment(e),dd=e=>e===null||typeof e!="object"&&typeof e!="function",QC=Array.isArray,lQ=e=>QC(e)||typeof e?.[Symbol.iterator]=="function",hd=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,jC=/-->/g,GC=/>/g,Io=RegExp(`>|[
|
|
6492
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let a=s.data;switch(a.type){case"decode":r._callbacks[a.id].resolve(a);break;case"error":r._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function jX(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(u){e.onModuleLoaded=function(c){u({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(u=>{let c=u.draco,d=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,d,p,h),m=f.attributes.map(g=>g.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(d)}});break}};function i(n,o,l,h){let u=h.attributeIDs,c=h.attributeTypes,d,p,f=o.GetEncodedGeometryType(l);if(f===n.TRIANGULAR_MESH)d=new n.Mesh,p=o.DecodeBufferToMesh(l,d);else if(f===n.POINT_CLOUD)d=new n.PointCloud,p=o.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let m={index:null,attributes:[]};for(let g in u){let v=self[c[g]],y,x;if(h.useUniqueIDs)x=u[g],y=o.GetAttributeByUniqueId(d,x);else{if(x=o.GetAttributeId(d,n[u[g]]),x===-1)continue;y=o.GetAttribute(d,x)}m.attributes.push(s(n,o,d,g,v,y))}return f===n.TRIANGULAR_MESH&&(m.index=r(n,o,d)),n.destroy(d),m}function r(n,o,l){let h=l.num_faces()*3,u=h*4,c=n._malloc(u);o.GetTrianglesUInt32Array(l,u,c);let d=new Uint32Array(n.HEAPF32.buffer,c,h).slice();return n._free(c),{array:d,itemSize:1}}function s(n,o,l,h,u,c){let d=c.num_components(),p=l.num_points()*d,f=p*u.BYTES_PER_ELEMENT,m=a(n,u),g=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,m,f,g);let v=new u(n.HEAPF32.buffer,g,p).slice();return n._free(g),{name:h,array:v,itemSize:d}}function a(n,o){switch(o){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var wn;function GX(){return wn||(wn=new VX,wn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),wn.decoderPending}async function HX(e){if(wn){let t={attributeIDs:wn.defaultAttributeIDs,attributeTypes:wn.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await wn.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function WX(e,t){let[i,r]=F2(rv.deserialize(new Uint8Array(e)));uM(i);let s=[];i.scene.objects.traverse((a,n)=>{n.type==="Mesh"&&n.geometry.type==="NonParametricGeometry"&&n.geometry.data.draco!==void 0&&s.push(n)}),s.length&&await GX();for(let a of s){let n=await HX(mi(a.geometry.data.draco));if(n){n.index&&(a.geometry.data.index={array:n.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};n.attributes.forEach(({name:l,array:h,itemSize:u})=>{o[l]={array:h,itemSize:u,type:"Float32Array",normalized:!1}}),a.geometry.data.attributes=o,a.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var qX=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=fr(i,t.actions,s,a,n,r)}disconnect(){Ii(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},YX=class extends Ds{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(s=>{let a=ov.deviceToSize(s.data.size),n=s.dataEvent.orientation==="horizontal"?i:r,o;switch(s.data.operator){case"<":o=n<a[0];break;case">":o=n>a[0];break;case"<>":o=n>a[0]&&n<a[1];break}s.stage!==o&&(s.stage=o,s.stage?s.dispatchIn():s.dispatchOut())}),this.eventContext.updateDomRect()},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:s,height:a}=r.contentRect;this.resize(s,a)}})}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext;this.onResizeObserver.observe(i),e.traverseEntity(r=>{if(!(!r.visible||!r.data?.events.length))for(let{data:s}of r.data.events)s.disabled||s.type==="Resize"&&s.breakpoints.forEach(({data:a,id:n})=>{try{let o=new qX(n,a,s,r,e,t,this.eventManager);this.breakpoints.push(o)}catch{}})})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},QS=Object.keys(IC).filter(e=>isNaN(Number(e))),XX=class{constructor(e,t,i,r,s){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=a=>{(a.touches.length>1||this.preventTouchScroll)&&a.preventDefault()},this.onMouseWheelPreventScroll=a=>{this.preventScroll&&a.preventDefault()},this.onMouseMove=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:a.buttons>0}},this.onMouseDown=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!0}},this.onMouseUp=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!1}},this.getMousePosition=a=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=a.touches?.length>0?a.touches[0]:a;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new kY(this.eventContext),DynamicVariable:new mX(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),Conditional:new HY(this.eventContext,this),Start:new pX(this.eventContext,this),Basic:new UY(this.eventContext,this,this.needsRaycast),MouseHover:new lX(this.eventContext,this),Scroll:new dX(this.eventContext,this),Follow:new eX(this.eventContext,this),DragDrop:new QY(this.eventContext,this),LookAt:new aX(this.eventContext),Resize:new YX(this.eventContext,this)};let{page:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),QS.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender),i.destroyedInAction=!1}),QS.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length){for(let r of i.data.events)if(!r.data.disabled)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(t);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(t);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(t);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.actions.forEach(t)}})}},QX=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new F().copy(i),this._editorSize=new F().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=ZX(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function ZX(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var KX=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Ey(e.shared,t),this.scene=new By(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof Cn&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof dr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},JX=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 $X(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 Tc(e){return e instanceof Wc?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function eQ(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Dr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Dr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let a=r.material.uuid,n=t.shared.materials[a];if(n){if(!Yi.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!Yi.isMergable(l.material))return;a=Yi.getHash(l.material)}}i[a]||(i[a]={});let o=i[a][Tc(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[a][Tc(r)]=[r],r.cloner)for(let l of r.cloner.children)i[a][Tc(r)].push(l)}),i}function tQ(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 iQ(e,t){let i=eQ(t,e),r=tQ(i),s=new Array(r),a=0,n=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(g=>{g instanceof Dr&&(n[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),n[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&$X(n[g]);let m=ao(n.slice(0,o),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new hr(m,l[0].material);break}default:{g=new hr(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof Dr&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][Tc(x)]&&i[x.material.uuid][Tc(x)].length>1||(u[c++]=x));for(let x=0;x<c;x++)t.attach(u[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[a++]=x}}}for(let d=0;d<a;d++)s[d].removeFromParent()}var rQ=Ri(TT(),1),sQ=new F;function aQ(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 Qy=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=sQ.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}},this._debouncedResize=$0(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new JX({x:10,y:10})),b6(e)}async load(e,t,i){aQ(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;let r=await WX(e);this._data=r,r.version&&(0,rQ.default)(r.version,"0.9.503")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([O_(r)&&tG(),WH(r)&&J8(),Fc.physicsEnabled(r.scene.objects)&&M6(),E_(r)&&IH(),EX(r)&&S6()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new KX(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();iQ(r,s.scene);let l=performance.now();console.log("Merged geometries in ",l-o," ms")}O_(r)&&this._scene.traverse(o=>{Zs(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof _s&&o.pendingMediaLoad&&o.update()})});let a=Object.keys(r.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);Promise.all(a).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),E_(r)&&kX(r)&&await Promise.all(a),this._scene.rewriteEventsBeforeGoToPlayMode(),Yy(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new bW({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),this._scene.initializeSplatViewer(this._renderer),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let n=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",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=n.size[0],this._viewportHeight=n.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 QX(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"),t){let o=new BY(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,n);this._scene.updateMatrixWorld(!0),this._controls=new NX(o),this._animationControls=new FX(this._scene,this._requestRenderAutoMode),this._eventManager=new XX(r.scene.publish,this._controls,this._animationControls,o,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&Fr.isTextValue(e)?Fr.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}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)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==_h&&!this._scene.isInvisibleObjects(t)&&!(t instanceof Cn)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}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 BC&&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},a=new Cr(t,i,r,s);try{a.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(a),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{Kx.unsubscribe(e)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),w6(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}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;e.traverseAncestors(s=>{s instanceof Cn&&(t=s.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof Cn||e instanceof By?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=Kx(i,(s,a)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=a),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};var ff=window,mf=ff.ShadowRoot&&(ff.ShadyCSS===void 0||ff.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Zy=Symbol(),zC=new WeakMap,ld=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Zy)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(mf&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=zC.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&zC.set(i,t))}return t}toString(){return this.cssText}},kC=e=>new ld(typeof e=="string"?e:e+"",void 0,Zy),Ky=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,a)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[a+1],e[0]);return new ld(i,e,Zy)},Jy=(e,t)=>{mf?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=ff.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},gf=mf?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return kC(i)})(e):e;var $y,vf=window,NC=vf.trustedTypes,nQ=NC?NC.emptyScript:"",UC=vf.reactiveElementPolyfillSupport,t1={toAttribute(e,t){switch(t){case Boolean:e=e?nQ: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}},FC=(e,t)=>t!==e&&(t==t||e==e),e1={attribute:!0,type:String,converter:t1,reflect:!1,hasChanged:FC},Wa=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=e1){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 a=this[t];this[i]=s,this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||e1}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(gf(s))}else t!==void 0&&i.push(gf(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 Jy(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=e1){var s;let a=this.constructor._$Ep(t,r);if(a!==void 0&&r.reflect===!0){let n=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:t1).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(a):this.setAttribute(a,n),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,a=s._$Ev.get(t);if(a!==void 0&&this._$El!==a){let n=s.getPropertyOptions(a),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:t1;this._$El=a,this[a]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||FC)(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,a)=>this[a]=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 a;return(a=s.hostUpdate)===null||a===void 0?void 0:a.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){}};Wa.finalized=!0,Wa.elementProperties=new Map,Wa.elementStyles=[],Wa.shadowRootOptions={mode:"open"},UC?.({ReactiveElement:Wa}),(($y=vf.reactiveElementVersions)!==null&&$y!==void 0?$y:vf.reactiveElementVersions=[]).push("1.6.0");var i1,yf=window,Ch=yf.trustedTypes,VC=Ch?Ch.createPolicy("lit-html",{createHTML:e=>e}):void 0,Ln=`lit$${(Math.random()+"").slice(9)}$`,XC="?"+Ln,oQ=`<${XC}>`,Th=document,cd=(e="")=>Th.createComment(e),dd=e=>e===null||typeof e!="object"&&typeof e!="function",QC=Array.isArray,lQ=e=>QC(e)||typeof e?.[Symbol.iterator]=="function",hd=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,jC=/-->/g,GC=/>/g,Io=RegExp(`>|[
|
|
6493
6493
|
\f\r](?:([^\\s"'>=/]+)([
|
|
6494
6494
|
\f\r]*=[
|
|
6495
6495
|
\f\r]*(?:[^
|