@splinetool/runtime 1.12.47 → 1.12.48
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/runtime.cjs +5 -5
- package/build/runtime.js +5 -5
- package/package.json +1 -1
package/build/runtime.cjs
CHANGED
|
@@ -3136,7 +3136,7 @@ void main() {
|
|
|
3136
3136
|
squared_mean = squared_mean / samples;
|
|
3137
3137
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3138
3138
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3139
|
-
}`;function H5(n,t,e){let r=new kp,i=new U,s=new U,o=new Ze,a=new zp({depthPacking:Dw}),l=new ow,c={},u=e.maxTextureSize,h={[Jn]:xi,[xi]:Jn,[vi]:vi},d=new $e({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new U},radius:{value:4}},vertexShader:G5,fragmentShader:j5}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new Ce;m.setAttribute("position",new je(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Mt(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=uv,this.render=function(b,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let T=n.getRenderTarget(),S=n.getActiveCubeFace(),M=n.getActiveMipmapLevel(),C=n.state;C.setBlending(or),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let P=0,_=b.length;P<_;P++){let I=b[P],O=I.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",I,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;i.copy(O.mapSize);let L=O.getFrameExtents();if(i.multiply(L),s.copy(O.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/L.x),i.x=s.x*L.x,O.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/L.y),i.y=s.y*L.y,O.mapSize.y=s.y)),O.map===null){let V=this.type!==_p?{minFilter:vt,magFilter:vt}:{};O.map=new at(i.x,i.y,V),O.map.texture.name=I.name+".shadowMap",O.camera.updateProjectionMatrix()}n.setRenderTarget(O.map),n.clear();let j=O.getViewportCount();for(let V=0;V<j;V++){let H=O.getViewport(V);o.set(s.x*H.x,s.y*H.y,s.x*H.z,s.y*H.w),C.viewport(o),O.updateMatrices(I,V),r=O.getFrustum(),v(w,A,O.camera,I,this.type)}O.isPointLightShadow!==!0&&this.type===_p&&y(O,A),O.needsUpdate=!1}g.needsUpdate=!1,n.setRenderTarget(T,S,M)};function y(b,w){let A=t.update(p);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new at(i.x,i.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(w,null,A,d,p,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(w,null,A,f,p,null)}function x(b,w,A,T,S,M){let C=null,P=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(P!==void 0)C=P;else if(C=A.isPointLight===!0?l:a,n.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 _=C.uuid,I=w.uuid,O=c[_];O===void 0&&(O={},c[_]=O);let L=O[I];L===void 0&&(L=C.clone(),O[I]=L),C=L}return C.visible=w.visible,C.wireframe=w.wireframe,M===_p?C.side=w.shadowSide!==null?w.shadowSide:w.side:C.side=w.shadowSide!==null?w.shadowSide:h[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=T,C.farDistance=S),C}function v(b,w,A,T,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===_p)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let P=t.update(b),_=b.material;if(Array.isArray(_)){let I=P.groups;for(let O=0,L=I.length;O<L;O++){let j=I[O],V=_[j.materialIndex];if(V&&V.visible){let H=x(b,V,T,A.near,A.far,S);n.renderBufferDirect(A,null,P,H,b,j)}}}else if(_.visible){let I=x(b,_,T,A.near,A.far,S);n.renderBufferDirect(A,null,P,I,b,null)}}let C=b.children;for(let P=0,_=C.length;P<_;P++)v(C[P],w,A,T,S)}}function W5(n,t,e){let r=e.isWebGL2;function i(){let Z=!1,ve=new Ze,Me=null,qe=new Ze(0,0,0,0);return{setMask:function(Xe){Me!==Xe&&!Z&&(n.colorMask(Xe,Xe,Xe,Xe),Me=Xe)},setLocked:function(Xe){Z=Xe},setClear:function(Xe,Rt,Hr,Wr,va){va===!0&&(Xe*=Wr,Rt*=Wr,Hr*=Wr),ve.set(Xe,Rt,Hr,Wr),qe.equals(ve)===!1&&(n.clearColor(Xe,Rt,Hr,Wr),qe.copy(ve))},reset:function(){Z=!1,Me=null,qe.set(-1,0,0,0)}}}function s(){let Z=!1,ve=null,Me=null,qe=null;return{setTest:function(Xe){Xe?oe(2929):ie(2929)},setMask:function(Xe){ve!==Xe&&!Z&&(n.depthMask(Xe),ve=Xe)},setFunc:function(Xe){if(Me!==Xe){switch(Xe){case wU:n.depthFunc(512);break;case AU:n.depthFunc(519);break;case EU:n.depthFunc(513);break;case WS:n.depthFunc(515);break;case TU:n.depthFunc(514);break;case MU:n.depthFunc(518);break;case CU:n.depthFunc(516);break;case PU:n.depthFunc(517);break;default:n.depthFunc(515)}Me=Xe}},setLocked:function(Xe){Z=Xe},setClear:function(Xe){qe!==Xe&&(n.clearDepth(Xe),qe=Xe)},reset:function(){Z=!1,ve=null,Me=null,qe=null}}}function o(){let Z=!1,ve=null,Me=null,qe=null,Xe=null,Rt=null,Hr=null,Wr=null,va=null;return{setTest:function(Dr){Z||(Dr?oe(2960):ie(2960))},setMask:function(Dr){ve!==Dr&&!Z&&(n.stencilMask(Dr),ve=Dr)},setFunc:function(Dr,us,Rn){(Me!==Dr||qe!==us||Xe!==Rn)&&(n.stencilFunc(Dr,us,Rn),Me=Dr,qe=us,Xe=Rn)},setOp:function(Dr,us,Rn){(Rt!==Dr||Hr!==us||Wr!==Rn)&&(n.stencilOp(Dr,us,Rn),Rt=Dr,Hr=us,Wr=Rn)},setLocked:function(Dr){Z=Dr},setClear:function(Dr){va!==Dr&&(n.clearStencil(Dr),va=Dr)},reset:function(){Z=!1,ve=null,Me=null,qe=null,Xe=null,Rt=null,Hr=null,Wr=null,va=null}}}let a=new i,l=new s,c=new o,u=new WeakMap,h=new WeakMap,d={},f={},m=new WeakMap,p=[],g=null,y=!1,x=null,v=null,b=null,w=null,A=null,T=null,S=null,M=!1,C=null,P=null,_=null,I=null,O=null,L=n.getParameter(35661),j=!1,V=0,H=n.getParameter(7938);H.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(H)[1]),j=V>=1):H.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),j=V>=2);let q=null,X={},K=n.getParameter(3088),z=n.getParameter(2978),Q=new Ze().fromArray(K),te=new Ze().fromArray(z);function $(Z,ve,Me){let qe=new Uint8Array(4),Xe=n.createTexture();n.bindTexture(Z,Xe),n.texParameteri(Z,10241,9728),n.texParameteri(Z,10240,9728);for(let Rt=0;Rt<Me;Rt++)n.texImage2D(ve+Rt,0,6408,1,1,0,6408,5121,qe);return Xe}let W={};W[3553]=$(3553,3553,1),W[34067]=$(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),oe(2929),l.setFunc(WS),ze(!1),ke(OC),oe(2884),De(or);function oe(Z){d[Z]!==!0&&(n.enable(Z),d[Z]=!0)}function ie(Z){d[Z]!==!1&&(n.disable(Z),d[Z]=!1)}function re(Z,ve){return f[Z]!==ve?(n.bindFramebuffer(Z,ve),f[Z]=ve,r&&(Z===36009&&(f[36160]=ve),Z===36160&&(f[36009]=ve)),!0):!1}function J(Z,ve){let Me=p,qe=!1;if(Z)if(Me=m.get(ve),Me===void 0&&(Me=[],m.set(ve,Me)),Z.isWebGLMultipleRenderTargets){let Xe=Z.texture;if(Me.length!==Xe.length||Me[0]!==36064){for(let Rt=0,Hr=Xe.length;Rt<Hr;Rt++)Me[Rt]=36064+Rt;Me.length=Xe.length,qe=!0}}else Me[0]!==36064&&(Me[0]=36064,qe=!0);else Me[0]!==1029&&(Me[0]=1029,qe=!0);qe&&(e.isWebGL2?n.drawBuffers(Me):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Me))}function Ee(Z){return g!==Z?(n.useProgram(Z),g=Z,!0):!1}let xe={[Ku]:32774,[hU]:32778,[dU]:32779};if(r)xe[BC]=32775,xe[FC]=32776;else{let Z=t.get("EXT_blend_minmax");Z!==null&&(xe[BC]=Z.MIN_EXT,xe[FC]=Z.MAX_EXT)}let de={[fU]:0,[pU]:1,[mU]:768,[c_]:770,[SU]:776,[xU]:774,[yU]:772,[gU]:769,[u_]:771,[bU]:775,[vU]:773};function De(Z,ve,Me,qe,Xe,Rt,Hr,Wr){if(Z===or){y===!0&&(ie(3042),y=!1);return}if(y===!1&&(oe(3042),y=!0),Z!==uU){if(Z!==x||Wr!==M){if((v!==Ku||A!==Ku)&&(n.blendEquation(32774),v=Ku,A=Ku),Wr)switch(Z){case ml:n.blendFuncSeparate(1,771,1,771);break;case RC:n.blendFunc(1,1);break;case LC:n.blendFuncSeparate(0,769,0,1);break;case NC:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Z);break}else switch(Z){case ml:n.blendFuncSeparate(770,771,1,771);break;case RC:n.blendFunc(770,1);break;case LC:n.blendFuncSeparate(0,769,0,1);break;case NC:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Z);break}b=null,w=null,T=null,S=null,x=Z,M=Wr}return}Xe=Xe||ve,Rt=Rt||Me,Hr=Hr||qe,(ve!==v||Xe!==A)&&(n.blendEquationSeparate(xe[ve],xe[Xe]),v=ve,A=Xe),(Me!==b||qe!==w||Rt!==T||Hr!==S)&&(n.blendFuncSeparate(de[Me],de[qe],de[Rt],de[Hr]),b=Me,w=qe,T=Rt,S=Hr),x=Z,M=!1}function Pe(Z,ve){Z.side===vi?ie(2884):oe(2884);let Me=Z.side===xi;ve&&(Me=!Me),ze(Me),Z.blending===ml&&Z.transparent===!1?De(or):De(Z.blending,Z.blendEquation,Z.blendSrc,Z.blendDst,Z.blendEquationAlpha,Z.blendSrcAlpha,Z.blendDstAlpha,Z.premultipliedAlpha),l.setFunc(Z.depthFunc),l.setTest(Z.depthTest),l.setMask(Z.depthWrite),a.setMask(Z.colorWrite);let qe=Z.stencilWrite;c.setTest(qe),qe&&(c.setMask(Z.stencilWriteMask),c.setFunc(Z.stencilFunc,Z.stencilRef,Z.stencilFuncMask),c.setOp(Z.stencilFail,Z.stencilZFail,Z.stencilZPass)),Le(Z.polygonOffset,Z.polygonOffsetFactor,Z.polygonOffsetUnits),Z.alphaToCoverage===!0?oe(32926):ie(32926)}function ze(Z){C!==Z&&(Z?n.frontFace(2304):n.frontFace(2305),C=Z)}function ke(Z){Z!==aU?(oe(2884),Z!==P&&(Z===OC?n.cullFace(1029):Z===lU?n.cullFace(1028):n.cullFace(1032))):ie(2884),P=Z}function Ue(Z){Z!==_&&(j&&n.lineWidth(Z),_=Z)}function Le(Z,ve,Me){Z?(oe(32823),(I!==ve||O!==Me)&&(n.polygonOffset(ve,Me),I=ve,O=Me)):ie(32823)}function Qe(Z){Z?oe(3089):ie(3089)}function F(Z){Z===void 0&&(Z=33984+L-1),q!==Z&&(n.activeTexture(Z),q=Z)}function B(Z,ve,Me){Me===void 0&&(q===null?Me=33984+L-1:Me=q);let qe=X[Me];qe===void 0&&(qe={type:void 0,texture:void 0},X[Me]=qe),(qe.type!==Z||qe.texture!==ve)&&(q!==Me&&(n.activeTexture(Me),q=Me),n.bindTexture(Z,ve||W[Z]),qe.type=Z,qe.texture=ve)}function N(){let Z=X[q];Z!==void 0&&Z.type!==void 0&&(n.bindTexture(Z.type,null),Z.type=void 0,Z.texture=void 0)}function ae(){try{n.compressedTexImage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function ye(){try{n.compressedTexImage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function me(){try{n.texSubImage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Ne(){try{n.texSubImage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Fe(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Oe(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function nt(){try{n.texStorage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function We(){try{n.texImage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Be(){try{n.texImage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function tt(Z){Q.equals(Z)===!1&&(n.scissor(Z.x,Z.y,Z.z,Z.w),Q.copy(Z))}function ot(Z){te.equals(Z)===!1&&(n.viewport(Z.x,Z.y,Z.z,Z.w),te.copy(Z))}function Gt(Z,ve){let Me=h.get(ve);Me===void 0&&(Me=new WeakMap,h.set(ve,Me));let qe=Me.get(Z);qe===void 0&&(qe=n.getUniformBlockIndex(ve,Z.name),Me.set(Z,qe))}function xr(Z,ve){let qe=h.get(ve).get(Z);u.get(ve)!==qe&&(n.uniformBlockBinding(ve,qe,Z.__bindingPointIndex),u.set(ve,qe))}function Ir(){n.disable(3042),n.disable(2884),n.disable(2929),n.disable(32823),n.disable(3089),n.disable(2960),n.disable(32926),n.blendEquation(32774),n.blendFunc(1,0),n.blendFuncSeparate(1,0,1,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(513),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(519,0,4294967295),n.stencilOp(7680,7680,7680),n.clearStencil(0),n.cullFace(1029),n.frontFace(2305),n.polygonOffset(0,0),n.activeTexture(33984),n.bindFramebuffer(36160,null),r===!0&&(n.bindFramebuffer(36009,null),n.bindFramebuffer(36008,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),d={},q=null,X={},f={},m=new WeakMap,p=[],g=null,y=!1,x=null,v=null,b=null,w=null,A=null,T=null,S=null,M=!1,C=null,P=null,_=null,I=null,O=null,Q.set(0,0,n.canvas.width,n.canvas.height),te.set(0,0,n.canvas.width,n.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:oe,disable:ie,bindFramebuffer:re,drawBuffers:J,useProgram:Ee,setBlending:De,setMaterial:Pe,setFlipSided:ze,setCullFace:ke,setLineWidth:Ue,setPolygonOffset:Le,setScissorTest:Qe,activeTexture:F,bindTexture:B,unbindTexture:N,compressedTexImage2D:ae,compressedTexImage3D:ye,texImage2D:We,texImage3D:Be,updateUBOMapping:Gt,uniformBlockBinding:xr,texStorage2D:pe,texStorage3D:nt,texSubImage2D:me,texSubImage3D:Ne,compressedTexSubImage2D:Fe,compressedTexSubImage3D:Oe,scissor:tt,viewport:ot,reset:Ir}}function q5(n,t,e,r,i,s,o){let a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,h=i.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(B,N){return y?new OffscreenCanvas(B,N):Vp("canvas")}function v(B,N,ae,ye){let me=1;if((B.width>ye||B.height>ye)&&(me=ye/Math.max(B.width,B.height)),me<1||N===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){let Ne=N?Vy:Math.floor,Fe=Ne(me*B.width),Oe=Ne(me*B.height);p===void 0&&(p=x(Fe,Oe));let pe=ae?x(Fe,Oe):p;return pe.width=Fe,pe.height=Oe,pe.getContext("2d").drawImage(B,0,0,Fe,Oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+Fe+"x"+Oe+")."),pe}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function b(B){return ZS(B.width)&&ZS(B.height)}function w(B){return a?!1:B.wrapS!==tr||B.wrapT!==tr||B.minFilter!==vt&&B.minFilter!==it}function A(B,N){return B.generateMipmaps&&N&&B.minFilter!==vt&&B.minFilter!==it}function T(B){n.generateMipmap(B)}function S(B,N,ae,ye,me=!1){if(a===!1)return N;if(B!==null){if(n[B]!==void 0)return n[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let Ne=N;return N===6403&&(ae===5126&&(Ne=33326),ae===5131&&(Ne=33325),ae===5121&&(Ne=33321)),N===33319&&(ae===5126&&(Ne=33328),ae===5131&&(Ne=33327),ae===5121&&(Ne=33323)),N===6408&&(ae===5126&&(Ne=34836),ae===5131&&(Ne=34842),ae===5121&&(Ne=ye===ut&&me===!1?35907:32856),ae===32819&&(Ne=32854),ae===32820&&(Ne=32855)),(Ne===33325||Ne===33326||Ne===33327||Ne===33328||Ne===34842||Ne===34836)&&t.get("EXT_color_buffer_float"),Ne}function M(B,N,ae){return A(B,ae)===!0||B.isFramebufferTexture&&B.minFilter!==vt&&B.minFilter!==it?Math.log2(Math.max(N.width,N.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?N.mipmaps.length:1}function C(B){return B===vt||B===VC||B===lS?9728:9729}function P(B){let N=B.target;N.removeEventListener("dispose",P),I(N),N.isVideoTexture&&m.delete(N)}function _(B){let N=B.target;N.removeEventListener("dispose",_),L(N)}function I(B){let N=r.get(B);if(N.__webglInit===void 0)return;let ae=B.source,ye=g.get(ae);if(ye){let me=ye[N.__cacheKey];me.usedTimes--,me.usedTimes===0&&O(B),Object.keys(ye).length===0&&g.delete(ae)}r.remove(B)}function O(B){let N=r.get(B);n.deleteTexture(N.__webglTexture);let ae=B.source,ye=g.get(ae);delete ye[N.__cacheKey],o.memory.textures--}function L(B){let N=B.texture,ae=r.get(B),ye=r.get(N);if(ye.__webglTexture!==void 0&&(n.deleteTexture(ye.__webglTexture),o.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)n.deleteFramebuffer(ae.__webglFramebuffer[me]),ae.__webglDepthbuffer&&n.deleteRenderbuffer(ae.__webglDepthbuffer[me]);else{if(n.deleteFramebuffer(ae.__webglFramebuffer),ae.__webglDepthbuffer&&n.deleteRenderbuffer(ae.__webglDepthbuffer),ae.__webglMultisampledFramebuffer&&n.deleteFramebuffer(ae.__webglMultisampledFramebuffer),ae.__webglColorRenderbuffer)for(let me=0;me<ae.__webglColorRenderbuffer.length;me++)ae.__webglColorRenderbuffer[me]&&n.deleteRenderbuffer(ae.__webglColorRenderbuffer[me]);ae.__webglDepthRenderbuffer&&n.deleteRenderbuffer(ae.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let me=0,Ne=N.length;me<Ne;me++){let Fe=r.get(N[me]);Fe.__webglTexture&&(n.deleteTexture(Fe.__webglTexture),o.memory.textures--),r.remove(N[me])}r.remove(N),r.remove(B)}let j=0;function V(){j=0}function H(){let B=j;return B>=l&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+l),j+=1,B}function q(B){let N=[];return N.push(B.wrapS),N.push(B.wrapT),N.push(B.wrapR||0),N.push(B.magFilter),N.push(B.minFilter),N.push(B.anisotropy),N.push(B.internalFormat),N.push(B.format),N.push(B.type),N.push(B.generateMipmaps),N.push(B.premultiplyAlpha),N.push(B.flipY),N.push(B.unpackAlignment),N.push(B.encoding),N.join()}function X(B,N){let ae=r.get(B);if(B.isVideoTexture&&Qe(B),B.isRenderTargetTexture===!1&&B.version>0&&ae.__version!==B.version){let ye=B.image;if(ye===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ae,B,N);return}}e.bindTexture(3553,ae.__webglTexture,33984+N)}function K(B,N){let ae=r.get(B);if(B.version>0&&ae.__version!==B.version){ie(ae,B,N);return}e.bindTexture(35866,ae.__webglTexture,33984+N)}function z(B,N){let ae=r.get(B);if(B.version>0&&ae.__version!==B.version){ie(ae,B,N);return}e.bindTexture(32879,ae.__webglTexture,33984+N)}function Q(B,N){let ae=r.get(B);if(B.version>0&&ae.__version!==B.version){re(ae,B,N);return}e.bindTexture(34067,ae.__webglTexture,33984+N)}let te={[Hs]:10497,[tr]:33071,[YS]:33648},$={[vt]:9728,[VC]:9984,[lS]:9986,[it]:9729,[BU]:9985,[Bc]:9987};function W(B,N,ae){if(ae?(n.texParameteri(B,10242,te[N.wrapS]),n.texParameteri(B,10243,te[N.wrapT]),(B===32879||B===35866)&&n.texParameteri(B,32882,te[N.wrapR]),n.texParameteri(B,10240,$[N.magFilter]),n.texParameteri(B,10241,$[N.minFilter])):(n.texParameteri(B,10242,33071),n.texParameteri(B,10243,33071),(B===32879||B===35866)&&n.texParameteri(B,32882,33071),(N.wrapS!==tr||N.wrapT!==tr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(B,10240,C(N.magFilter)),n.texParameteri(B,10241,C(N.minFilter)),N.minFilter!==vt&&N.minFilter!==it&&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 ye=t.get("EXT_texture_filter_anisotropic");if(N.magFilter===vt||N.minFilter!==lS&&N.minFilter!==Bc||N.type===Ut&&t.has("OES_texture_float_linear")===!1||a===!1&&N.type===$n&&t.has("OES_texture_half_float_linear")===!1)return;(N.anisotropy>1||r.get(N).__currentAnisotropy)&&(n.texParameterf(B,ye.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(N.anisotropy,i.getMaxAnisotropy())),r.get(N).__currentAnisotropy=N.anisotropy)}}function oe(B,N){let ae=!1;B.__webglInit===void 0&&(B.__webglInit=!0,N.addEventListener("dispose",P));let ye=N.source,me=g.get(ye);me===void 0&&(me={},g.set(ye,me));let Ne=q(N);if(Ne!==B.__cacheKey){me[Ne]===void 0&&(me[Ne]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,ae=!0),me[Ne].usedTimes++;let Fe=me[B.__cacheKey];Fe!==void 0&&(me[B.__cacheKey].usedTimes--,Fe.usedTimes===0&&O(N)),B.__cacheKey=Ne,B.__webglTexture=me[Ne].texture}return ae}function ie(B,N,ae){let ye=3553;(N.isDataArrayTexture||N.isCompressedArrayTexture)&&(ye=35866),N.isData3DTexture&&(ye=32879);let me=oe(B,N),Ne=N.source;e.bindTexture(ye,B.__webglTexture,33984+ae);let Fe=r.get(Ne);if(Ne.version!==Fe.__version||me===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,N.flipY),n.pixelStorei(37441,N.premultiplyAlpha),n.pixelStorei(3317,N.unpackAlignment),n.pixelStorei(37443,0);let Oe=w(N)&&b(N.image)===!1,pe=v(N.image,Oe,!1,u);pe=F(N,pe);let nt=b(pe)||a,We=s.convert(N.format,N.encoding),Be=s.convert(N.type),tt=S(N.internalFormat,We,Be,N.encoding,N.isVideoTexture);W(ye,N,nt);let ot,Gt=N.mipmaps,xr=a&&N.isVideoTexture!==!0,Ir=Fe.__version===void 0||me===!0,Z=M(N,pe,nt);if(N.isDepthTexture)tt=6402,a?N.type===Ut?tt=36012:N.type===Gs?tt=33190:N.type===gl?tt=35056:tt=33189:N.type===Ut&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),N.format===Lc&&tt===6402&&N.type!==f_&&N.type!==Gs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),N.type=Gs,Be=s.convert(N.type)),N.format===xl&&tt===6402&&(tt=34041,N.type!==gl&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),N.type=gl,Be=s.convert(N.type))),Ir&&(xr?e.texStorage2D(3553,1,tt,pe.width,pe.height):e.texImage2D(3553,0,tt,pe.width,pe.height,0,We,Be,null));else if(N.isDataTexture)if(Gt.length>0&&nt){xr&&Ir&&e.texStorage2D(3553,Z,tt,Gt[0].width,Gt[0].height);for(let ve=0,Me=Gt.length;ve<Me;ve++)ot=Gt[ve],xr?e.texSubImage2D(3553,ve,0,0,ot.width,ot.height,We,Be,ot.data):e.texImage2D(3553,ve,tt,ot.width,ot.height,0,We,Be,ot.data);N.generateMipmaps=!1}else xr?(Ir&&e.texStorage2D(3553,Z,tt,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,pe.width,pe.height,We,Be,pe.data)):e.texImage2D(3553,0,tt,pe.width,pe.height,0,We,Be,pe.data);else if(N.isCompressedTexture)if(N.isCompressedArrayTexture){xr&&Ir&&e.texStorage3D(35866,Z,tt,Gt[0].width,Gt[0].height,pe.depth);for(let ve=0,Me=Gt.length;ve<Me;ve++)ot=Gt[ve],N.format!==br?We!==null?xr?e.compressedTexSubImage3D(35866,ve,0,0,0,ot.width,ot.height,pe.depth,We,ot.data,0,0):e.compressedTexImage3D(35866,ve,tt,ot.width,ot.height,pe.depth,0,ot.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xr?e.texSubImage3D(35866,ve,0,0,0,ot.width,ot.height,pe.depth,We,Be,ot.data):e.texImage3D(35866,ve,tt,ot.width,ot.height,pe.depth,0,We,Be,ot.data)}else{xr&&Ir&&e.texStorage2D(3553,Z,tt,Gt[0].width,Gt[0].height);for(let ve=0,Me=Gt.length;ve<Me;ve++)ot=Gt[ve],N.format!==br?We!==null?xr?e.compressedTexSubImage2D(3553,ve,0,0,ot.width,ot.height,We,ot.data):e.compressedTexImage2D(3553,ve,tt,ot.width,ot.height,0,ot.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xr?e.texSubImage2D(3553,ve,0,0,ot.width,ot.height,We,Be,ot.data):e.texImage2D(3553,ve,tt,ot.width,ot.height,0,We,Be,ot.data)}else if(N.isDataArrayTexture)xr?(Ir&&e.texStorage3D(35866,Z,tt,pe.width,pe.height,pe.depth),e.texSubImage3D(35866,0,0,0,0,pe.width,pe.height,pe.depth,We,Be,pe.data)):e.texImage3D(35866,0,tt,pe.width,pe.height,pe.depth,0,We,Be,pe.data);else if(N.isData3DTexture)xr?(Ir&&e.texStorage3D(32879,Z,tt,pe.width,pe.height,pe.depth),e.texSubImage3D(32879,0,0,0,0,pe.width,pe.height,pe.depth,We,Be,pe.data)):e.texImage3D(32879,0,tt,pe.width,pe.height,pe.depth,0,We,Be,pe.data);else if(N.isFramebufferTexture){if(Ir)if(xr)e.texStorage2D(3553,Z,tt,pe.width,pe.height);else{let ve=pe.width,Me=pe.height;for(let qe=0;qe<Z;qe++)e.texImage2D(3553,qe,tt,ve,Me,0,We,Be,null),ve>>=1,Me>>=1}}else if(Gt.length>0&&nt){xr&&Ir&&e.texStorage2D(3553,Z,tt,Gt[0].width,Gt[0].height);for(let ve=0,Me=Gt.length;ve<Me;ve++)ot=Gt[ve],xr?e.texSubImage2D(3553,ve,0,0,We,Be,ot):e.texImage2D(3553,ve,tt,We,Be,ot);N.generateMipmaps=!1}else xr?(Ir&&e.texStorage2D(3553,Z,tt,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,We,Be,pe)):e.texImage2D(3553,0,tt,We,Be,pe);A(N,nt)&&T(ye),Fe.__version=Ne.version,N.onUpdate&&N.onUpdate(N)}B.__version=N.version}function re(B,N,ae){if(N.image.length!==6)return;let ye=oe(B,N),me=N.source;e.bindTexture(34067,B.__webglTexture,33984+ae);let Ne=r.get(me);if(me.version!==Ne.__version||ye===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,N.flipY),n.pixelStorei(37441,N.premultiplyAlpha),n.pixelStorei(3317,N.unpackAlignment),n.pixelStorei(37443,0);let Fe=N.isCompressedTexture||N.image[0].isCompressedTexture,Oe=N.image[0]&&N.image[0].isDataTexture,pe=[];for(let ve=0;ve<6;ve++)!Fe&&!Oe?pe[ve]=v(N.image[ve],!1,!0,c):pe[ve]=Oe?N.image[ve].image:N.image[ve],pe[ve]=F(N,pe[ve]);let nt=pe[0],We=b(nt)||a,Be=s.convert(N.format,N.encoding),tt=s.convert(N.type),ot=S(N.internalFormat,Be,tt,N.encoding),Gt=a&&N.isVideoTexture!==!0,xr=Ne.__version===void 0||ye===!0,Ir=M(N,nt,We);W(34067,N,We);let Z;if(Fe){Gt&&xr&&e.texStorage2D(34067,Ir,ot,nt.width,nt.height);for(let ve=0;ve<6;ve++){Z=pe[ve].mipmaps;for(let Me=0;Me<Z.length;Me++){let qe=Z[Me];N.format!==br?Be!==null?Gt?e.compressedTexSubImage2D(34069+ve,Me,0,0,qe.width,qe.height,Be,qe.data):e.compressedTexImage2D(34069+ve,Me,ot,qe.width,qe.height,0,qe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Gt?e.texSubImage2D(34069+ve,Me,0,0,qe.width,qe.height,Be,tt,qe.data):e.texImage2D(34069+ve,Me,ot,qe.width,qe.height,0,Be,tt,qe.data)}}}else{Z=N.mipmaps,Gt&&xr&&(Z.length>0&&Ir++,e.texStorage2D(34067,Ir,ot,pe[0].width,pe[0].height));for(let ve=0;ve<6;ve++)if(Oe){Gt?e.texSubImage2D(34069+ve,0,0,0,pe[ve].width,pe[ve].height,Be,tt,pe[ve].data):e.texImage2D(34069+ve,0,ot,pe[ve].width,pe[ve].height,0,Be,tt,pe[ve].data);for(let Me=0;Me<Z.length;Me++){let Xe=Z[Me].image[ve].image;Gt?e.texSubImage2D(34069+ve,Me+1,0,0,Xe.width,Xe.height,Be,tt,Xe.data):e.texImage2D(34069+ve,Me+1,ot,Xe.width,Xe.height,0,Be,tt,Xe.data)}}else{Gt?e.texSubImage2D(34069+ve,0,0,0,Be,tt,pe[ve]):e.texImage2D(34069+ve,0,ot,Be,tt,pe[ve]);for(let Me=0;Me<Z.length;Me++){let qe=Z[Me];Gt?e.texSubImage2D(34069+ve,Me+1,0,0,Be,tt,qe.image[ve]):e.texImage2D(34069+ve,Me+1,ot,Be,tt,qe.image[ve])}}}A(N,We)&&T(34067),Ne.__version=me.version,N.onUpdate&&N.onUpdate(N)}B.__version=N.version}function J(B,N,ae,ye,me){let Ne=s.convert(ae.format,ae.encoding),Fe=s.convert(ae.type),Oe=S(ae.internalFormat,Ne,Fe,ae.encoding);r.get(N).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Oe,N.width,N.height,N.depth,0,Ne,Fe,null):e.texImage2D(me,0,Oe,N.width,N.height,0,Ne,Fe,null)),e.bindFramebuffer(36160,B),Le(N)?d.framebufferTexture2DMultisampleEXT(36160,ye,me,r.get(ae).__webglTexture,0,Ue(N)):(me===3553||me>=34069&&me<=34074)&&n.framebufferTexture2D(36160,ye,me,r.get(ae).__webglTexture,0),e.bindFramebuffer(36160,null)}function Ee(B,N,ae){if(n.bindRenderbuffer(36161,B),N.depthBuffer&&!N.stencilBuffer){let ye=33189;if(ae||Le(N)){let me=N.depthTexture;me&&me.isDepthTexture&&(me.type===Ut?ye=36012:me.type===Gs&&(ye=33190));let Ne=Ue(N);Le(N)?d.renderbufferStorageMultisampleEXT(36161,Ne,ye,N.width,N.height):n.renderbufferStorageMultisample(36161,Ne,ye,N.width,N.height)}else n.renderbufferStorage(36161,ye,N.width,N.height);n.framebufferRenderbuffer(36160,36096,36161,B)}else if(N.depthBuffer&&N.stencilBuffer){let ye=Ue(N);ae&&Le(N)===!1?n.renderbufferStorageMultisample(36161,ye,35056,N.width,N.height):Le(N)?d.renderbufferStorageMultisampleEXT(36161,ye,35056,N.width,N.height):n.renderbufferStorage(36161,34041,N.width,N.height),n.framebufferRenderbuffer(36160,33306,36161,B)}else{let ye=N.isWebGLMultipleRenderTargets===!0?N.texture:[N.texture];for(let me=0;me<ye.length;me++){let Ne=ye[me],Fe=s.convert(Ne.format,Ne.encoding),Oe=s.convert(Ne.type),pe=S(Ne.internalFormat,Fe,Oe,Ne.encoding),nt=Ue(N);ae&&Le(N)===!1?n.renderbufferStorageMultisample(36161,nt,pe,N.width,N.height):Le(N)?d.renderbufferStorageMultisampleEXT(36161,nt,pe,N.width,N.height):n.renderbufferStorage(36161,pe,N.width,N.height)}}n.bindRenderbuffer(36161,null)}function xe(B,N){if(N&&N.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,B),!(N.depthTexture&&N.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(N.depthTexture).__webglTexture||N.depthTexture.image.width!==N.width||N.depthTexture.image.height!==N.height)&&(N.depthTexture.image.width=N.width,N.depthTexture.image.height=N.height,N.depthTexture.needsUpdate=!0),X(N.depthTexture,0);let ye=r.get(N.depthTexture).__webglTexture,me=Ue(N);if(N.depthTexture.format===Lc)Le(N)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ye,0,me):n.framebufferTexture2D(36160,36096,3553,ye,0);else if(N.depthTexture.format===xl)Le(N)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ye,0,me):n.framebufferTexture2D(36160,33306,3553,ye,0);else throw new Error("Unknown depthTexture format")}function de(B){let N=r.get(B),ae=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!N.__autoAllocateDepthBuffer){if(ae)throw new Error("target.depthTexture not supported in Cube render targets");xe(N.__webglFramebuffer,B)}else if(ae){N.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)e.bindFramebuffer(36160,N.__webglFramebuffer[ye]),N.__webglDepthbuffer[ye]=n.createRenderbuffer(),Ee(N.__webglDepthbuffer[ye],B,!1)}else e.bindFramebuffer(36160,N.__webglFramebuffer),N.__webglDepthbuffer=n.createRenderbuffer(),Ee(N.__webglDepthbuffer,B,!1);e.bindFramebuffer(36160,null)}function De(B,N,ae){let ye=r.get(B);N!==void 0&&J(ye.__webglFramebuffer,B,B.texture,36064,3553),ae!==void 0&&de(B)}function Pe(B){let N=B.texture,ae=r.get(B),ye=r.get(N);B.addEventListener("dispose",_),B.isWebGLMultipleRenderTargets!==!0&&(ye.__webglTexture===void 0&&(ye.__webglTexture=n.createTexture()),ye.__version=N.version,o.memory.textures++);let me=B.isWebGLCubeRenderTarget===!0,Ne=B.isWebGLMultipleRenderTargets===!0,Fe=b(B)||a;if(me){ae.__webglFramebuffer=[];for(let Oe=0;Oe<6;Oe++)ae.__webglFramebuffer[Oe]=n.createFramebuffer()}else{if(ae.__webglFramebuffer=n.createFramebuffer(),Ne)if(i.drawBuffers){let Oe=B.texture;for(let pe=0,nt=Oe.length;pe<nt;pe++){let We=r.get(Oe[pe]);We.__webglTexture===void 0&&(We.__webglTexture=n.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&B.samples>0&&Le(B)===!1){let Oe=Ne?N:[N];ae.__webglMultisampledFramebuffer=n.createFramebuffer(),ae.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ae.__webglMultisampledFramebuffer);for(let pe=0;pe<Oe.length;pe++){let nt=Oe[pe];ae.__webglColorRenderbuffer[pe]=n.createRenderbuffer(),n.bindRenderbuffer(36161,ae.__webglColorRenderbuffer[pe]);let We=s.convert(nt.format,nt.encoding),Be=s.convert(nt.type),tt=S(nt.internalFormat,We,Be,nt.encoding,B.isXRRenderTarget===!0),ot=Ue(B);n.renderbufferStorageMultisample(36161,ot,tt,B.width,B.height),n.framebufferRenderbuffer(36160,36064+pe,36161,ae.__webglColorRenderbuffer[pe])}n.bindRenderbuffer(36161,null),B.depthBuffer&&(ae.__webglDepthRenderbuffer=n.createRenderbuffer(),Ee(ae.__webglDepthRenderbuffer,B,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ye.__webglTexture),W(34067,N,Fe);for(let Oe=0;Oe<6;Oe++)J(ae.__webglFramebuffer[Oe],B,N,36064,34069+Oe);A(N,Fe)&&T(34067),e.unbindTexture()}else if(Ne){let Oe=B.texture;for(let pe=0,nt=Oe.length;pe<nt;pe++){let We=Oe[pe],Be=r.get(We);e.bindTexture(3553,Be.__webglTexture),W(3553,We,Fe),J(ae.__webglFramebuffer,B,We,36064+pe,3553),A(We,Fe)&&T(3553)}e.unbindTexture()}else{let Oe=3553;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(a?Oe=B.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Oe,ye.__webglTexture),W(Oe,N,Fe),J(ae.__webglFramebuffer,B,N,36064,Oe),A(N,Fe)&&T(Oe),e.unbindTexture()}B.depthBuffer&&de(B)}function ze(B){let N=b(B)||a,ae=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let ye=0,me=ae.length;ye<me;ye++){let Ne=ae[ye];if(A(Ne,N)){let Fe=B.isWebGLCubeRenderTarget?34067:3553,Oe=r.get(Ne).__webglTexture;e.bindTexture(Fe,Oe),T(Fe),e.unbindTexture()}}}function ke(B){if(a&&B.samples>0&&Le(B)===!1){let N=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],ae=B.width,ye=B.height,me=16384,Ne=[],Fe=B.stencilBuffer?33306:36096,Oe=r.get(B),pe=B.isWebGLMultipleRenderTargets===!0;if(pe)for(let nt=0;nt<N.length;nt++)e.bindFramebuffer(36160,Oe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+nt,36161,null),e.bindFramebuffer(36160,Oe.__webglFramebuffer),n.framebufferTexture2D(36009,36064+nt,3553,null,0);e.bindFramebuffer(36008,Oe.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Oe.__webglFramebuffer);for(let nt=0;nt<N.length;nt++){Ne.push(36064+nt),B.depthBuffer&&Ne.push(Fe);let We=Oe.__ignoreDepthValues!==void 0?Oe.__ignoreDepthValues:!1;if(We===!1&&(B.depthBuffer&&(me|=256),B.stencilBuffer&&(me|=1024)),pe&&n.framebufferRenderbuffer(36008,36064,36161,Oe.__webglColorRenderbuffer[nt]),We===!0&&(n.invalidateFramebuffer(36008,[Fe]),n.invalidateFramebuffer(36009,[Fe])),pe){let Be=r.get(N[nt]).__webglTexture;n.framebufferTexture2D(36009,36064,3553,Be,0)}n.blitFramebuffer(0,0,ae,ye,0,0,ae,ye,me,9728),f&&n.invalidateFramebuffer(36008,Ne)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),pe)for(let nt=0;nt<N.length;nt++){e.bindFramebuffer(36160,Oe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+nt,36161,Oe.__webglColorRenderbuffer[nt]);let We=r.get(N[nt]).__webglTexture;e.bindFramebuffer(36160,Oe.__webglFramebuffer),n.framebufferTexture2D(36009,36064+nt,3553,We,0)}e.bindFramebuffer(36009,Oe.__webglMultisampledFramebuffer)}}function Ue(B){return Math.min(h,B.samples)}function Le(B){let N=r.get(B);return a&&B.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&N.__useRenderToTexture!==!1}function Qe(B){let N=o.render.frame;m.get(B)!==N&&(m.set(B,N),B.update())}function F(B,N){let ae=B.encoding,ye=B.format,me=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===QS||ae!==xn&&(ae===ut?a===!1?t.has("EXT_sRGB")===!0&&ye===br?(B.format=QS,B.minFilter=it,B.generateMipmaps=!1):N=Uy.sRGBToLinear(N):(ye!==br||me!==Nr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ae)),N}this.allocateTextureUnit=H,this.resetTextureUnits=V,this.setTexture2D=X,this.setTexture2DArray=K,this.setTexture3D=z,this.setTextureCube=Q,this.rebindTextures=De,this.setupRenderTarget=Pe,this.updateRenderTargetMipmap=ze,this.updateMultisampleRenderTarget=ke,this.setupDepthRenderbuffer=de,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Le}function X5(n,t,e){let r=e.isWebGL2;function i(s,o=null){let a;if(s===Nr)return 5121;if(s===kU)return 32819;if(s===zU)return 32820;if(s===FU)return 5120;if(s===VU)return 5122;if(s===f_)return 5123;if(s===UU)return 5124;if(s===Gs)return 5125;if(s===Ut)return 5126;if(s===$n)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===GU)return 6406;if(s===br)return 6408;if(s===jU)return 6409;if(s===HU)return 6410;if(s===Lc)return 6402;if(s===xl)return 34041;if(s===QS)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===Jp)return 6403;if(s===WU)return 36244;if(s===Sh)return 33319;if(s===qU)return 33320;if(s===Cw)return 36249;if(s===cS||s===uS||s===hS||s===dS)if(o===ut)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===cS)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===uS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===hS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===dS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===cS)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===uS)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===hS)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===dS)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===UC||s===kC||s===zC||s===GC)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===UC)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===kC)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===zC)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===GC)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===XU)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===jC||s===HC)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===jC)return o===ut?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===HC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===WC||s===qC||s===XC||s===YC||s===KC||s===QC||s===ZC||s===JC||s===$C||s===eP||s===tP||s===rP||s===iP||s===nP)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===WC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===qC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===XC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===YC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===KC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===QC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ZC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===JC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===$C)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===eP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===tP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===rP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===iP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===nP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===fS)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===fS)return o===ut?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===YU||s===sP||s===oP||s===aP)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===fS)return a.COMPRESSED_RED_RGTC1_EXT;if(s===sP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===oP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===aP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===gl?r?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:i}}var aw=class extends si{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},cn=class extends Dt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Y5={type:"move"},Rp=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new cn,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 cn,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 cn,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(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let r of t.hand.values())this._getHandJoint(e,r)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,r){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){o=!0;for(let p of t.hand.values()){let g=e.getJointPose(p,r),y=this._getHandJoint(c,p);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Y5)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let r=new cn;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},ps=class extends Zt{constructor(t,e,r,i,s,o,a,l,c,u){if(u=u!==void 0?u:Lc,u!==Lc&&u!==xl)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===Lc&&(r=Gs),r===void 0&&u===xl&&(r=gl),super(null,i,s,o,a,l,u,r,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:vt,this.minFilter=l!==void 0?l:vt,this.flipY=!1,this.generateMipmaps=!1}},lw=class extends ar{constructor(t,e){super();let r=this,i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,m=null,p=e.getContextAttributes(),g=null,y=null,x=[],v=[],b=new Set,w=new Map,A=new si;A.layers.enable(1),A.viewport=new Ze;let T=new si;T.layers.enable(2),T.viewport=new Ze;let S=[A,T],M=new aw;M.layers.enable(1),M.layers.enable(2);let C=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let Q=x[z];return Q===void 0&&(Q=new Rp,x[z]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(z){let Q=x[z];return Q===void 0&&(Q=new Rp,x[z]=Q),Q.getGripSpace()},this.getHand=function(z){let Q=x[z];return Q===void 0&&(Q=new Rp,x[z]=Q),Q.getHandSpace()};function _(z){let Q=v.indexOf(z.inputSource);if(Q===-1)return;let te=x[Q];te!==void 0&&te.dispatchEvent({type:z.type,data:z.inputSource})}function I(){i.removeEventListener("select",_),i.removeEventListener("selectstart",_),i.removeEventListener("selectend",_),i.removeEventListener("squeeze",_),i.removeEventListener("squeezestart",_),i.removeEventListener("squeezeend",_),i.removeEventListener("end",I),i.removeEventListener("inputsourceschange",O);for(let z=0;z<x.length;z++){let Q=v[z];Q!==null&&(v[z]=null,x[z].disconnect(Q))}C=null,P=null,t.setRenderTarget(g),f=null,d=null,h=null,i=null,y=null,K.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){s=z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){a=z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(z){c=z},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(z){if(i=z,i!==null){if(g=t.getRenderTarget(),i.addEventListener("select",_),i.addEventListener("selectstart",_),i.addEventListener("selectend",_),i.addEventListener("squeeze",_),i.addEventListener("squeezestart",_),i.addEventListener("squeezeend",_),i.addEventListener("end",I),i.addEventListener("inputsourceschange",O),p.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let Q={antialias:i.renderState.layers===void 0?p.antialias:!0,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,Q),i.updateRenderState({baseLayer:f}),y=new at(f.framebufferWidth,f.framebufferHeight,{format:br,type:Nr,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let Q=null,te=null,$=null;p.depth&&($=p.stencil?35056:33190,Q=p.stencil?xl:Lc,te=p.stencil?gl:Gs);let W={colorFormat:32856,depthFormat:$,scaleFactor:s};h=new XRWebGLBinding(i,e),d=h.createProjectionLayer(W),i.updateRenderState({layers:[d]}),y=new at(d.textureWidth,d.textureHeight,{format:br,type:Nr,depthTexture:new ps(d.textureWidth,d.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,Q),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0});let oe=t.properties.get(y);oe.__ignoreDepthValues=d.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),K.setContext(i),K.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};function O(z){for(let Q=0;Q<z.removed.length;Q++){let te=z.removed[Q],$=v.indexOf(te);$>=0&&(v[$]=null,x[$].disconnect(te))}for(let Q=0;Q<z.added.length;Q++){let te=z.added[Q],$=v.indexOf(te);if($===-1){for(let oe=0;oe<x.length;oe++)if(oe>=v.length){v.push(te),$=oe;break}else if(v[oe]===null){v[oe]=te,$=oe;break}if($===-1)break}let W=x[$];W&&W.connect(te)}}let L=new E,j=new E;function V(z,Q,te){L.setFromMatrixPosition(Q.matrixWorld),j.setFromMatrixPosition(te.matrixWorld);let $=L.distanceTo(j),W=Q.projectionMatrix.elements,oe=te.projectionMatrix.elements,ie=W[14]/(W[10]-1),re=W[14]/(W[10]+1),J=(W[9]+1)/W[5],Ee=(W[9]-1)/W[5],xe=(W[8]-1)/W[0],de=(oe[8]+1)/oe[0],De=ie*xe,Pe=ie*de,ze=$/(-xe+de),ke=ze*-xe;Q.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ke),z.translateZ(ze),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert();let Ue=ie+ze,Le=re+ze,Qe=De-ke,F=Pe+($-ke),B=J*re/Le*Ue,N=Ee*re/Le*Ue;z.projectionMatrix.makePerspective(Qe,F,B,N,Ue,Le)}function H(z,Q){Q===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(Q.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(i===null)return;M.near=T.near=A.near=z.near,M.far=T.far=A.far=z.far,(C!==M.near||P!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),C=M.near,P=M.far);let Q=z.parent,te=M.cameras;H(M,Q);for(let W=0;W<te.length;W++)H(te[W],Q);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),z.matrix.copy(M.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale);let $=z.children;for(let W=0,oe=$.length;W<oe;W++)$[W].updateMatrixWorld(!0);te.length===2?V(M,A,T):M.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(z){l=z,d!==null&&(d.fixedFoveation=z),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=z)},this.getPlanes=function(){return b};let q=null;function X(z,Q){if(u=Q.getViewerPose(c||o),m=Q,u!==null){let te=u.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let $=!1;te.length!==M.cameras.length&&(M.cameras.length=0,$=!0);for(let W=0;W<te.length;W++){let oe=te[W],ie=null;if(f!==null)ie=f.getViewport(oe);else{let J=h.getViewSubImage(d,oe);ie=J.viewport,W===0&&(t.setRenderTargetTextures(y,J.colorTexture,d.ignoreDepthValues?void 0:J.depthStencilTexture),t.setRenderTarget(y))}let re=S[W];re===void 0&&(re=new si,re.layers.enable(W),re.viewport=new Ze,S[W]=re),re.matrix.fromArray(oe.transform.matrix),re.projectionMatrix.fromArray(oe.projectionMatrix),re.viewport.set(ie.x,ie.y,ie.width,ie.height),W===0&&M.matrix.copy(re.matrix),$===!0&&M.cameras.push(re)}}for(let te=0;te<x.length;te++){let $=v[te],W=x[te];$!==null&&W!==void 0&&W.update($,Q,c||o)}if(q&&q(z,Q),Q.detectedPlanes){r.dispatchEvent({type:"planesdetected",data:Q.detectedPlanes});let te=null;for(let $ of b)Q.detectedPlanes.has($)||(te===null&&(te=[]),te.push($));if(te!==null)for(let $ of te)b.delete($),w.delete($),r.dispatchEvent({type:"planeremoved",data:$});for(let $ of Q.detectedPlanes)if(!b.has($))b.add($),w.set($,Q.lastChangedTime),r.dispatchEvent({type:"planeadded",data:$});else{let W=w.get($);$.lastChangedTime>W&&(w.set($,$.lastChangedTime),r.dispatchEvent({type:"planechanged",data:$}))}}m=null}let K=new x_;K.setAnimationLoop(X),this.setAnimationLoop=function(z){q=z},this.dispose=function(){}}};function K5(n,t){function e(p,g){g.color.getRGB(p.fogColor.value,v_(n)),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function r(p,g,y,x,v){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),u(p,g)):g.isMeshPhongMaterial?(i(p,g),c(p,g)):g.isMeshStandardMaterial?(i(p,g),h(p,g),g.isMeshPhysicalMaterial&&d(p,g,v)):g.isMeshMatcapMaterial?(i(p,g),f(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,y,x):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===xi&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===xi&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(p.envMap.value=y,p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let b=n.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let x;g.map?x=g.map:g.specularMap?x=g.specularMap:g.displacementMap?x=g.displacementMap:g.normalMap?x=g.normalMap:g.bumpMap?x=g.bumpMap:g.roughnessMap?x=g.roughnessMap:g.metalnessMap?x=g.metalnessMap:g.alphaMap?x=g.alphaMap:g.emissiveMap?x=g.emissiveMap:g.clearcoatMap?x=g.clearcoatMap:g.clearcoatNormalMap?x=g.clearcoatNormalMap:g.clearcoatRoughnessMap?x=g.clearcoatRoughnessMap:g.iridescenceMap?x=g.iridescenceMap:g.iridescenceThicknessMap?x=g.iridescenceThicknessMap:g.specularIntensityMap?x=g.specularIntensityMap:g.specularColorMap?x=g.specularColorMap:g.transmissionMap?x=g.transmissionMap:g.thicknessMap?x=g.thicknessMap:g.sheenColorMap?x=g.sheenColorMap:g.sheenRoughnessMap&&(x=g.sheenRoughnessMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix));let v;g.aoMap?v=g.aoMap:g.lightMap&&(v=g.lightMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uv2Transform.value.copy(v.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,y,x){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=x*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function c(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function u(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function h(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function d(p,g,y){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===xi&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:r}}function Q5(n,t,e,r){let i={},s={},o=[],a=e.isWebGL2?n.getParameter(35375):0;function l(x,v){let b=v.program;r.uniformBlockBinding(x,b)}function c(x,v){let b=i[x.id];b===void 0&&(m(x),b=u(x),i[x.id]=b,x.addEventListener("dispose",g));let w=v.program;r.updateUBOMapping(x,w);let A=t.render.frame;s[x.id]!==A&&(d(x),s[x.id]=A)}function u(x){let v=h();x.__bindingPointIndex=v;let b=n.createBuffer(),w=x.__size,A=x.usage;return n.bindBuffer(35345,b),n.bufferData(35345,w,A),n.bindBuffer(35345,null),n.bindBufferBase(35345,v,b),b}function h(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){let v=i[x.id],b=x.uniforms,w=x.__cache;n.bindBuffer(35345,v);for(let A=0,T=b.length;A<T;A++){let S=b[A];if(f(S,A,w)===!0){let M=S.__offset,C=Array.isArray(S.value)?S.value:[S.value],P=0;for(let _=0;_<C.length;_++){let I=C[_],O=p(I);typeof I=="number"?(S.__data[0]=I,n.bufferSubData(35345,M+P,S.__data)):I.isMatrix3?(S.__data[0]=I.elements[0],S.__data[1]=I.elements[1],S.__data[2]=I.elements[2],S.__data[3]=I.elements[0],S.__data[4]=I.elements[3],S.__data[5]=I.elements[4],S.__data[6]=I.elements[5],S.__data[7]=I.elements[0],S.__data[8]=I.elements[6],S.__data[9]=I.elements[7],S.__data[10]=I.elements[8],S.__data[11]=I.elements[0]):(I.toArray(S.__data,P),P+=O.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(35345,M,S.__data)}}n.bindBuffer(35345,null)}function f(x,v,b){let w=x.value;if(b[v]===void 0){if(typeof w=="number")b[v]=w;else{let A=Array.isArray(w)?w:[w],T=[];for(let S=0;S<A.length;S++)T.push(A[S].clone());b[v]=T}return!0}else if(typeof w=="number"){if(b[v]!==w)return b[v]=w,!0}else{let A=Array.isArray(b[v])?b[v]:[b[v]],T=Array.isArray(w)?w:[w];for(let S=0;S<A.length;S++){let M=A[S];if(M.equals(T[S])===!1)return M.copy(T[S]),!0}}return!1}function m(x){let v=x.uniforms,b=0,w=16,A=0;for(let T=0,S=v.length;T<S;T++){let M=v[T],C={boundary:0,storage:0},P=Array.isArray(M.value)?M.value:[M.value];for(let _=0,I=P.length;_<I;_++){let O=P[_],L=p(O);C.boundary+=L.boundary,C.storage+=L.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=b,T>0){A=b%w;let _=w-A;A!==0&&_-C.boundary<0&&(b+=w-A,M.__offset=b)}b+=C.storage}return A=b%w,A>0&&(b+=w-A),x.__size=b,x.__cache={},this}function p(x){let v={boundary:0,storage:0};return typeof x=="number"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function g(x){let v=x.target;v.removeEventListener("dispose",g);let b=o.indexOf(v.__bindingPointIndex);o.splice(b,1),n.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function y(){for(let x in i)n.deleteBuffer(i[x]);o=[],i={},s={}}return{bind:l,update:c,dispose:y}}function Z5(){let n=Vp("canvas");return n.style.display="block",n}function Lw(n={}){this.isWebGLRenderer=!0;let t=n.canvas!==void 0?n.canvas:Z5(),e=n.context!==void 0?n.context:null,r=n.depth!==void 0?n.depth:!0,i=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,o=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,a=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",c=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1,u;e!==null?u=e.getContextAttributes().alpha:u=n.alpha!==void 0?n.alpha:!1;let h=null,d=null,f=[],m=[];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=xn,this.physicallyCorrectLights=!1,this.toneMapping=js,this.toneMappingExposure=1;let p=this,g=!1,y=0,x=0,v=null,b=-1,w=null,A=new Ze,T=new Ze,S=null,M=t.width,C=t.height,P=1,_=null,I=null,O=new Ze(0,0,M,C),L=new Ze(0,0,M,C),j=!1,V=new kp,H=!1,q=!1,X=null,K=new ue,z=new U,Q=new E,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function $(){return v===null?P:1}let W=e;function oe(G,le){for(let ge=0;ge<G.length;ge++){let ne=G[ge],be=t.getContext(ne,le);if(be!==null)return be}return null}try{let G={alpha:!0,depth:r,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Pa}`),t.addEventListener("webglcontextlost",tt,!1),t.addEventListener("webglcontextrestored",ot,!1),t.addEventListener("webglcontextcreationerror",Gt,!1),W===null){let le=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&le.shift(),W=oe(le,G),W===null)throw oe(le)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(G){throw console.error("THREE.WebGLRenderer: "+G.message),G}let ie,re,J,Ee,xe,de,De,Pe,ze,ke,Ue,Le,Qe,F,B,N,ae,ye,me,Ne,Fe,Oe,pe,nt;function We(){ie=new v4(W),re=new d4(W,ie,n),ie.init(re),Oe=new X5(W,ie,re),J=new W5(W,ie,re),Ee=new S4,xe=new R5,de=new q5(W,ie,J,xe,re,Oe,Ee),De=new p4(p),Pe=new y4(p),ze=new Ik(W,re),pe=new u4(W,ie,ze,re),ke=new x4(W,ze,Ee,pe),Ue=new T4(W,ke,ze,Ee),me=new E4(W,re,de),N=new f4(xe),Le=new O5(p,De,Pe,ie,re,pe,N),Qe=new K5(p,xe),F=new N5,B=new z5(ie,re),ye=new c4(p,De,Pe,J,Ue,u,o),ae=new H5(p,Ue,re),nt=new Q5(W,Ee,re,J),Ne=new h4(W,ie,Ee,re),Fe=new b4(W,ie,Ee,re),Ee.programs=Le.programs,p.capabilities=re,p.extensions=ie,p.properties=xe,p.renderLists=F,p.shadowMap=ae,p.state=J,p.info=Ee}We();let Be=new lw(p,W);this.xr=Be,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){let G=ie.get("WEBGL_lose_context");G&&G.loseContext()},this.forceContextRestore=function(){let G=ie.get("WEBGL_lose_context");G&&G.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(G){G!==void 0&&(P=G,this.setSize(M,C,!1))},this.getSize=function(G){return G.set(M,C)},this.setSize=function(G,le,ge){if(Be.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=G,C=le,t.width=Math.floor(G*P),t.height=Math.floor(le*P),ge!==!1&&(t.style.width=G+"px",t.style.height=le+"px"),this.setViewport(0,0,G,le)},this.getDrawingBufferSize=function(G){return G.set(M*P,C*P).floor()},this.setDrawingBufferSize=function(G,le,ge){M=G,C=le,P=ge,t.width=Math.floor(G*ge),t.height=Math.floor(le*ge),this.setViewport(0,0,G,le)},this.getCurrentViewport=function(G){return G.copy(A)},this.getViewport=function(G){return G.copy(O)},this.setViewport=function(G,le,ge,ne){G.isVector4?O.set(G.x,G.y,G.z,G.w):O.set(G,le,ge,ne),J.viewport(A.copy(O).multiplyScalar(P).floor())},this.getScissor=function(G){return G.copy(L)},this.setScissor=function(G,le,ge,ne){G.isVector4?L.set(G.x,G.y,G.z,G.w):L.set(G,le,ge,ne),J.scissor(T.copy(L).multiplyScalar(P).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(G){J.setScissorTest(j=G)},this.setOpaqueSort=function(G){_=G},this.setTransparentSort=function(G){I=G},this.getClearColor=function(G){return G.copy(ye.getClearColor())},this.setClearColor=function(){ye.setClearColor.apply(ye,arguments)},this.getClearAlpha=function(){return ye.getClearAlpha()},this.setClearAlpha=function(){ye.setClearAlpha.apply(ye,arguments)},this.clear=function(G=!0,le=!0,ge=!0){let ne=0;G&&(ne|=16384),le&&(ne|=256),ge&&(ne|=1024),W.clear(ne)},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",tt,!1),t.removeEventListener("webglcontextrestored",ot,!1),t.removeEventListener("webglcontextcreationerror",Gt,!1),F.dispose(),B.dispose(),xe.dispose(),De.dispose(),Pe.dispose(),Ue.dispose(),pe.dispose(),nt.dispose(),Le.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",qe),Be.removeEventListener("sessionend",Xe),X&&(X.dispose(),X=null),Rt.stop()};function tt(G){G.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function ot(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let G=Ee.autoReset,le=ae.enabled,ge=ae.autoUpdate,ne=ae.needsUpdate,be=ae.type;We(),Ee.autoReset=G,ae.enabled=le,ae.autoUpdate=ge,ae.needsUpdate=ne,ae.type=be}function Gt(G){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",G.statusMessage)}function xr(G){let le=G.target;le.removeEventListener("dispose",xr),Ir(le)}function Ir(G){Z(G),xe.remove(G)}function Z(G){let le=xe.get(G).programs;le!==void 0&&(le.forEach(function(ge){Le.releaseProgram(ge)}),G.isShaderMaterial&&Le.releaseShaderCache(G))}this.renderBufferDirect=function(G,le,ge,ne,be,st){le===null&&(le=te);let pt=be.isMesh&&be.matrixWorld.determinant()<0,St=rS(G,le,ge,ne,be);J.setMaterial(ne,pt);let Et=ge.index,jt=1;ne.wireframe===!0&&(Et=ke.getWireframeAttribute(ge),jt=2);let Lt=ge.drawRange,Tt=ge.attributes.position,Nt=Lt.start*jt,Mi=(Lt.start+Lt.count)*jt;st!==null&&(Nt=Math.max(Nt,st.start*jt),Mi=Math.min(Mi,(st.start+st.count)*jt)),Et!==null?(Nt=Math.max(Nt,0),Mi=Math.min(Mi,Et.count)):Tt!=null&&(Nt=Math.max(Nt,0),Mi=Math.min(Mi,Tt.count));let an=Mi-Nt;if(an<0||an===1/0)return;pe.setup(be,ne,St,ge,Et);let So,xt=Ne;if(Et!==null&&(So=ze.get(Et),xt=Fe,xt.setIndex(So)),be.isMesh)ne.wireframe===!0?(J.setLineWidth(ne.wireframeLinewidth*$()),xt.setMode(1)):xt.setMode(4);else if(be.isLine){let Vt=ne.linewidth;Vt===void 0&&(Vt=1),J.setLineWidth(Vt*$()),be.isLineSegments?xt.setMode(1):be.isLineLoop?xt.setMode(2):xt.setMode(3)}else be.isPoints?xt.setMode(0):be.isSprite&&xt.setMode(4);if(be.isInstancedMesh)xt.renderInstances(Nt,an,be.count);else if(ge.isInstancedBufferGeometry){let Vt=ge._maxInstanceCount!==void 0?ge._maxInstanceCount:1/0,Du=Math.min(ge.instanceCount,Vt);xt.renderInstances(Nt,an,Du)}else xt.render(Nt,an)},this.compile=function(G,le){function ge(ne,be,st){ne.transparent===!0&&ne.side===vi&&ne.forceSinglePass===!1?(ne.side=xi,ne.needsUpdate=!0,Rn(ne,be,st),ne.side=Jn,ne.needsUpdate=!0,Rn(ne,be,st),ne.side=vi):Rn(ne,be,st)}d=B.get(G),d.init(),m.push(d),G.traverseVisible(function(ne){ne.isLight&&ne.layers.test(le.layers)&&(d.pushLight(ne),ne.castShadow&&d.pushShadow(ne))}),d.setupLights(p.physicallyCorrectLights),G.traverse(function(ne){let be=ne.material;if(be)if(Array.isArray(be))for(let st=0;st<be.length;st++){let pt=be[st];ge(pt,G,ne)}else ge(be,G,ne)}),m.pop(),d=null};let ve=null;function Me(G){ve&&ve(G)}function qe(){Rt.stop()}function Xe(){Rt.start()}let Rt=new x_;Rt.setAnimationLoop(Me),typeof self<"u"&&Rt.setContext(self),this.setAnimationLoop=function(G){ve=G,Be.setAnimationLoop(G),G===null?Rt.stop():Rt.start()},Be.addEventListener("sessionstart",qe),Be.addEventListener("sessionend",Xe),this.render=function(G,le){if(le!==void 0&&le.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;G.matrixWorldAutoUpdate===!0&&G.updateMatrixWorld(),le.parent===null&&le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),Be.enabled===!0&&Be.isPresenting===!0&&(Be.cameraAutoUpdate===!0&&Be.updateCamera(le),le=Be.getCamera()),G.isScene===!0&&G.onBeforeRender(p,G,le,v),d=B.get(G,m.length),d.init(),m.push(d),K.multiplyMatrices(le.projectionMatrix,le.matrixWorldInverse),V.setFromProjectionMatrix(K),q=this.localClippingEnabled,H=N.init(this.clippingPlanes,q),h=F.get(G,f.length),h.init(),f.push(h),Hr(G,le,0,p.sortObjects),h.finish(),p.sortObjects===!0&&h.sort(_,I),H===!0&&N.beginShadows();let ge=d.state.shadowsArray;if(ae.render(ge,G,le),H===!0&&N.endShadows(),this.info.autoReset===!0&&this.info.reset(),ye.render(h,G),d.setupLights(p.physicallyCorrectLights),le.isArrayCamera){let ne=le.cameras;for(let be=0,st=ne.length;be<st;be++){let pt=ne[be];Wr(h,G,pt,pt.viewport)}}else Wr(h,G,le);v!==null&&(de.updateMultisampleRenderTarget(v),de.updateRenderTargetMipmap(v)),G.isScene===!0&&G.onAfterRender(p,G,le),pe.resetDefaultState(),b=-1,w=null,m.pop(),m.length>0?d=m[m.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Hr(G,le,ge,ne){if(G.visible===!1)return;if(G.layers.test(le.layers)){if(G.isGroup)ge=G.renderOrder;else if(G.isLOD)G.autoUpdate===!0&&G.update(le);else if(G.isLight)d.pushLight(G),G.castShadow&&d.pushShadow(G);else if(G.isSprite){if(!G.frustumCulled||V.intersectsSprite(G)){ne&&Q.setFromMatrixPosition(G.matrixWorld).applyMatrix4(K);let pt=Ue.update(G),St=G.material;St.visible&&h.push(G,pt,St,ge,Q.z,null)}}else if((G.isMesh||G.isLine||G.isPoints)&&(G.isSkinnedMesh&&G.skeleton.frame!==Ee.render.frame&&(G.skeleton.update(),G.skeleton.frame=Ee.render.frame),!G.frustumCulled||V.intersectsObject(G))){ne&&Q.setFromMatrixPosition(G.matrixWorld).applyMatrix4(K);let pt=Ue.update(G),St=G.material;if(Array.isArray(St)){let Et=pt.groups;for(let jt=0,Lt=Et.length;jt<Lt;jt++){let Tt=Et[jt],Nt=St[Tt.materialIndex];Nt&&Nt.visible&&h.push(G,pt,Nt,ge,Q.z,Tt)}}else St.visible&&h.push(G,pt,St,ge,Q.z,null)}}let st=G.children;for(let pt=0,St=st.length;pt<St;pt++)Hr(st[pt],le,ge,ne)}function Wr(G,le,ge,ne){let be=G.opaque,st=G.transmissive,pt=G.transparent;d.setupLightsView(ge),H===!0&&N.setGlobalState(p.clippingPlanes,ge),st.length>0&&va(be,le,ge),ne&&J.viewport(A.copy(ne)),be.length>0&&Dr(be,le,ge),st.length>0&&Dr(st,le,ge),pt.length>0&&Dr(pt,le,ge),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function va(G,le,ge){let ne=re.isWebGL2;X===null&&(X=new at(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?$n:Nr,minFilter:Bc,samples:ne&&s===!0?4:0})),p.getDrawingBufferSize(z),ne?X.setSize(z.x,z.y):X.setSize(Vy(z.x),Vy(z.y));let be=p.getRenderTarget();p.setRenderTarget(X),p.clear();let st=p.toneMapping;p.toneMapping=js,Dr(G,le,ge),p.toneMapping=st,de.updateMultisampleRenderTarget(X),de.updateRenderTargetMipmap(X),p.setRenderTarget(be)}function Dr(G,le,ge){let ne=le.isScene===!0?le.overrideMaterial:null;for(let be=0,st=G.length;be<st;be++){let pt=G[be],St=pt.object,Et=pt.geometry,jt=ne===null?pt.material:ne,Lt=pt.group;St.layers.test(ge.layers)&&us(St,le,ge,Et,jt,Lt)}}function us(G,le,ge,ne,be,st){G.onBeforeRender(p,le,ge,ne,be,st),G.modelViewMatrix.multiplyMatrices(ge.matrixWorldInverse,G.matrixWorld),G.normalMatrix.getNormalMatrix(G.modelViewMatrix),be.onBeforeRender(p,le,ge,ne,G,st),be.transparent===!0&&be.side===vi&&be.forceSinglePass===!1?(be.side=xi,be.needsUpdate=!0,p.renderBufferDirect(ge,le,ne,be,G,st),be.side=Jn,be.needsUpdate=!0,p.renderBufferDirect(ge,le,ne,be,G,st),be.side=vi):p.renderBufferDirect(ge,le,ne,be,G,st),G.onAfterRender(p,le,ge,ne,be,st)}function Rn(G,le,ge){le.isScene!==!0&&(le=te);let ne=xe.get(G),be=d.state.lights,st=d.state.shadowsArray,pt=be.state.version,St=Le.getParameters(G,be.state,st,le,ge),Et=Le.getProgramCacheKey(St),jt=ne.programs;ne.environment=G.isMeshStandardMaterial?le.environment:null,ne.fog=le.fog,ne.envMap=(G.isMeshStandardMaterial?Pe:De).get(G.envMap||ne.environment),jt===void 0&&(G.addEventListener("dispose",xr),jt=new Map,ne.programs=jt);let Lt=jt.get(Et);if(Lt!==void 0){if(ne.currentProgram===Lt&&ne.lightsStateVersion===pt)return vp(G,St),Lt}else St.uniforms=Le.getUniforms(G),G.onBuild(ge,St,p),G.onBeforeCompile(St,p),Lt=Le.acquireProgram(St,Et),jt.set(Et,Lt),ne.uniforms=St.uniforms;let Tt=ne.uniforms;(!G.isShaderMaterial&&!G.isRawShaderMaterial||G.clipping===!0)&&(Tt.clippingPlanes=N.uniform),vp(G,St),ne.needsLights=nS(G),ne.lightsStateVersion=pt,ne.needsLights&&(Tt.ambientLightColor.value=be.state.ambient,Tt.lightProbe.value=be.state.probe,Tt.directionalLights.value=be.state.directional,Tt.directionalLightShadows.value=be.state.directionalShadow,Tt.spotLights.value=be.state.spot,Tt.spotLightShadows.value=be.state.spotShadow,Tt.rectAreaLights.value=be.state.rectArea,Tt.ltc_1.value=be.state.rectAreaLTC1,Tt.ltc_2.value=be.state.rectAreaLTC2,Tt.pointLights.value=be.state.point,Tt.pointLightShadows.value=be.state.pointShadow,Tt.hemisphereLights.value=be.state.hemi,Tt.directionalShadowMap.value=be.state.directionalShadowMap,Tt.directionalShadowMatrix.value=be.state.directionalShadowMatrix,Tt.spotShadowMap.value=be.state.spotShadowMap,Tt.spotLightMatrix.value=be.state.spotLightMatrix,Tt.spotLightMap.value=be.state.spotLightMap,Tt.pointShadowMap.value=be.state.pointShadowMap,Tt.pointShadowMatrix.value=be.state.pointShadowMatrix);let Nt=Lt.getUniforms(),Mi=eh.seqWithValue(Nt.seq,Tt);return ne.currentProgram=Lt,ne.uniformsList=Mi,Lt}function vp(G,le){let ge=xe.get(G);ge.outputEncoding=le.outputEncoding,ge.instancing=le.instancing,ge.skinning=le.skinning,ge.morphTargets=le.morphTargets,ge.morphNormals=le.morphNormals,ge.morphColors=le.morphColors,ge.morphTargetsCount=le.morphTargetsCount,ge.numClippingPlanes=le.numClippingPlanes,ge.numIntersection=le.numClipIntersection,ge.vertexAlphas=le.vertexAlphas,ge.vertexTangents=le.vertexTangents,ge.toneMapping=le.toneMapping}function rS(G,le,ge,ne,be){le.isScene!==!0&&(le=te),de.resetTextureUnits();let st=le.fog,pt=ne.isMeshStandardMaterial?le.environment:null,St=v===null?p.outputEncoding:v.isXRRenderTarget===!0?v.texture.encoding:xn,Et=(ne.isMeshStandardMaterial?Pe:De).get(ne.envMap||pt),jt=ne.vertexColors===!0&&!!ge.attributes.color&&ge.attributes.color.itemSize===4,Lt=!!ne.normalMap&&!!ge.attributes.tangent,Tt=!!ge.morphAttributes.position,Nt=!!ge.morphAttributes.normal,Mi=!!ge.morphAttributes.color,an=ne.toneMapped?p.toneMapping:js,So=ge.morphAttributes.position||ge.morphAttributes.normal||ge.morphAttributes.color,xt=So!==void 0?So.length:0,Vt=xe.get(ne),Du=d.state.lights;if(H===!0&&(q===!0||G!==w)){let mi=G===w&&ne.id===b;N.setState(ne,G,mi)}let pi=!1;ne.version===Vt.__version?(Vt.needsLights&&Vt.lightsStateVersion!==Du.state.version||Vt.outputEncoding!==St||be.isInstancedMesh&&Vt.instancing===!1||!be.isInstancedMesh&&Vt.instancing===!0||be.isSkinnedMesh&&Vt.skinning===!1||!be.isSkinnedMesh&&Vt.skinning===!0||Vt.envMap!==Et||ne.fog===!0&&Vt.fog!==st||Vt.numClippingPlanes!==void 0&&(Vt.numClippingPlanes!==N.numPlanes||Vt.numIntersection!==N.numIntersection)||Vt.vertexAlphas!==jt||Vt.vertexTangents!==Lt||Vt.morphTargets!==Tt||Vt.morphNormals!==Nt||Vt.morphColors!==Mi||Vt.toneMapping!==an||re.isWebGL2===!0&&Vt.morphTargetsCount!==xt)&&(pi=!0):(pi=!0,Vt.__version=ne.version);let wo=Vt.currentProgram;pi===!0&&(wo=Rn(ne,le,be));let Ou=!1,Kn=!1,It=!1,Ci=wo.getUniforms(),hs=Vt.uniforms;if(J.useProgram(wo.program)&&(Ou=!0,Kn=!0,It=!0),ne.id!==b&&(b=ne.id,Kn=!0),Ou||w!==G){if(Ci.setValue(W,"projectionMatrix",G.projectionMatrix),re.logarithmicDepthBuffer&&Ci.setValue(W,"logDepthBufFC",2/(Math.log(G.far+1)/Math.LN2)),w!==G&&(w=G,Kn=!0,It=!0),ne.isShaderMaterial||ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshStandardMaterial||ne.envMap){let mi=Ci.map.cameraPosition;mi!==void 0&&mi.setValue(W,Q.setFromMatrixPosition(G.matrixWorld))}(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial)&&Ci.setValue(W,"isOrthographic",G.isOrthographicCamera===!0),(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial||ne.isShadowMaterial||be.isSkinnedMesh)&&Ci.setValue(W,"viewMatrix",G.matrixWorldInverse)}if(be.isSkinnedMesh){Ci.setOptional(W,be,"bindMatrix"),Ci.setOptional(W,be,"bindMatrixInverse");let mi=be.skeleton;mi&&(re.floatVertexTextures?(mi.boneTexture===null&&mi.computeBoneTexture(),Ci.setValue(W,"boneTexture",mi.boneTexture,de),Ci.setValue(W,"boneTextureSize",mi.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 Ru=ge.morphAttributes;if((Ru.position!==void 0||Ru.normal!==void 0||Ru.color!==void 0&&re.isWebGL2===!0)&&me.update(be,ge,ne,wo),(Kn||Vt.receiveShadow!==be.receiveShadow)&&(Vt.receiveShadow=be.receiveShadow,Ci.setValue(W,"receiveShadow",be.receiveShadow)),ne.isMeshGouraudMaterial&&ne.envMap!==null&&(hs.envMap.value=Et,hs.flipEnvMap.value=Et.isCubeTexture&&Et.isRenderTargetTexture===!1?-1:1),Kn&&(Ci.setValue(W,"toneMappingExposure",p.toneMappingExposure),Vt.needsLights&&iS(hs,It),st&&ne.fog===!0&&Qe.refreshFogUniforms(hs,st),Qe.refreshMaterialUniforms(hs,ne,P,C,X),eh.upload(W,Vt.uniformsList,hs,de)),ne.isShaderMaterial&&ne.uniformsNeedUpdate===!0&&(eh.upload(W,Vt.uniformsList,hs,de),ne.uniformsNeedUpdate=!1),ne.isSpriteMaterial&&Ci.setValue(W,"center",be.center),Ci.setValue(W,"modelViewMatrix",be.modelViewMatrix),Ci.setValue(W,"normalMatrix",be.normalMatrix),Ci.setValue(W,"modelMatrix",be.matrixWorld),be.previousModelViewMatrix&&Ci.setValue(W,"previousModelViewMatrix",be.previousModelViewMatrix),G.previousProjectionMatrix&&Ci.setValue(W,"previousProjectionMatrix",G.previousProjectionMatrix),ne.isShaderMaterial||ne.isRawShaderMaterial){let mi=ne.uniformsGroups;for(let D=0,R=mi.length;D<R;D++)if(re.isWebGL2){let Y=mi[D];nt.update(Y,wo),nt.bind(Y,wo)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return wo}function iS(G,le){G.ambientLightColor.needsUpdate=le,G.lightProbe.needsUpdate=le,G.directionalLights.needsUpdate=le,G.directionalLightShadows.needsUpdate=le,G.pointLights.needsUpdate=le,G.pointLightShadows.needsUpdate=le,G.spotLights.needsUpdate=le,G.spotLightShadows.needsUpdate=le,G.rectAreaLights.needsUpdate=le,G.hemisphereLights.needsUpdate=le}function nS(G){return G.isMeshLambertMaterial||G.isMeshToonMaterial||G.isMeshPhongMaterial||G.isMeshStandardMaterial||G.isShadowMaterial||G.isShaderMaterial&&G.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return v},this.setRenderTargetTextures=function(G,le,ge){xe.get(G.texture).__webglTexture=le,xe.get(G.depthTexture).__webglTexture=ge;let ne=xe.get(G);ne.__hasExternalTextures=!0,ne.__hasExternalTextures&&(ne.__autoAllocateDepthBuffer=ge===void 0,ne.__autoAllocateDepthBuffer||ie.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ne.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(G,le){let ge=xe.get(G);ge.__webglFramebuffer=le,ge.__useDefaultFramebuffer=le===void 0},this.setRenderTarget=function(G,le=0,ge=0){v=G,y=le,x=ge;let ne=!0,be=null,st=!1,pt=!1;if(G){let Et=xe.get(G);Et.__useDefaultFramebuffer!==void 0?(J.bindFramebuffer(36160,null),ne=!1):Et.__webglFramebuffer===void 0?de.setupRenderTarget(G):Et.__hasExternalTextures&&de.rebindTextures(G,xe.get(G.texture).__webglTexture,xe.get(G.depthTexture).__webglTexture);let jt=G.texture;(jt.isData3DTexture||jt.isDataArrayTexture||jt.isCompressedArrayTexture)&&(pt=!0);let Lt=xe.get(G).__webglFramebuffer;G.isWebGLCubeRenderTarget?(be=Lt[le],st=!0):re.isWebGL2&&G.samples>0&&de.useMultisampledRTT(G)===!1?be=xe.get(G).__webglMultisampledFramebuffer:be=Lt,A.copy(G.viewport),T.copy(G.scissor),S=G.scissorTest}else A.copy(O).multiplyScalar(P).floor(),T.copy(L).multiplyScalar(P).floor(),S=j;if(J.bindFramebuffer(36160,be)&&re.drawBuffers&&ne&&J.drawBuffers(G,be),J.viewport(A),J.scissor(T),J.setScissorTest(S),st){let Et=xe.get(G.texture);W.framebufferTexture2D(36160,36064,34069+le,Et.__webglTexture,ge)}else if(pt){let Et=xe.get(G.texture),jt=le||0;W.framebufferTextureLayer(36160,36064,Et.__webglTexture,ge||0,jt)}b=-1},this.readRenderTargetPixels=function(G,le,ge,ne,be,st,pt){if(!(G&&G.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=xe.get(G).__webglFramebuffer;if(G.isWebGLCubeRenderTarget&&pt!==void 0&&(St=St[pt]),St){J.bindFramebuffer(36160,St);try{let Et=G.texture,jt=Et.format,Lt=Et.type;if(jt!==br&&Oe.convert(jt)!==W.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Tt=Lt===$n&&(ie.has("EXT_color_buffer_half_float")||re.isWebGL2&&ie.has("EXT_color_buffer_float"));if(Lt!==Nr&&Oe.convert(Lt)!==W.getParameter(35738)&&!(Lt===Ut&&(re.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!Tt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}le>=0&&le<=G.width-ne&&ge>=0&&ge<=G.height-be&&W.readPixels(le,ge,ne,be,Oe.convert(jt),Oe.convert(Lt),st)}finally{let Et=v!==null?xe.get(v).__webglFramebuffer:null;J.bindFramebuffer(36160,Et)}}},this.readRenderTargetPixelsAsync=async function(G,le,ge,ne,be,st,pt){if(!(G&&G.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let St=xe.get(G).__webglFramebuffer;if(G.isWebGLCubeRenderTarget&&pt!==void 0&&(St=St[pt]),St){let Et=G.texture,jt=Et.format,Lt=Et.type;if(le>=0&&le<=G.width-ne&&ge>=0&&ge<=G.height-be){J.bindFramebuffer(W.FRAMEBUFFER,St);let Tt=W.createBuffer();W.bindBuffer(W.PIXEL_PACK_BUFFER,Tt),W.bufferData(W.PIXEL_PACK_BUFFER,st.byteLength,W.STREAM_READ),W.readPixels(le,ge,ne,be,Oe.convert(jt),Oe.convert(Lt),0);let Nt=v!==null?xe.get(v).__webglFramebuffer:null;J.bindFramebuffer(W.FRAMEBUFFER,Nt);let Mi=W.fenceSync(W.SYNC_GPU_COMMANDS_COMPLETE,0);return W.flush(),await fk(W,Mi,4),W.bindBuffer(W.PIXEL_PACK_BUFFER,Tt),W.getBufferSubData(W.PIXEL_PACK_BUFFER,0,st),W.deleteBuffer(Tt),W.deleteSync(Mi),st}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(G,le,ge=0){let ne=Math.pow(2,-ge),be=Math.floor(le.image.width*ne),st=Math.floor(le.image.height*ne);de.setTexture2D(le,0),W.copyTexSubImage2D(3553,ge,0,0,G.x,G.y,be,st),J.unbindTexture()},this.copyTextureToTexture=function(G,le,ge,ne=0){let be=le.image.width,st=le.image.height,pt=Oe.convert(ge.format),St=Oe.convert(ge.type);de.setTexture2D(ge,0),W.pixelStorei(37440,ge.flipY),W.pixelStorei(37441,ge.premultiplyAlpha),W.pixelStorei(3317,ge.unpackAlignment),le.isDataTexture?W.texSubImage2D(3553,ne,G.x,G.y,be,st,pt,St,le.image.data):le.isCompressedTexture?W.compressedTexSubImage2D(3553,ne,G.x,G.y,le.mipmaps[0].width,le.mipmaps[0].height,pt,le.mipmaps[0].data):W.texSubImage2D(3553,ne,G.x,G.y,pt,St,le.image),ne===0&&ge.generateMipmaps&&W.generateMipmap(3553),J.unbindTexture()},this.copyTextureToTexture3D=function(G,le,ge,ne,be=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let st=G.max.x-G.min.x+1,pt=G.max.y-G.min.y+1,St=G.max.z-G.min.z+1,Et=Oe.convert(ne.format),jt=Oe.convert(ne.type),Lt;if(ne.isData3DTexture)de.setTexture3D(ne,0),Lt=32879;else if(ne.isDataArrayTexture)de.setTexture2DArray(ne,0),Lt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}W.pixelStorei(37440,ne.flipY),W.pixelStorei(37441,ne.premultiplyAlpha),W.pixelStorei(3317,ne.unpackAlignment);let Tt=W.getParameter(3314),Nt=W.getParameter(32878),Mi=W.getParameter(3316),an=W.getParameter(3315),So=W.getParameter(32877),xt=ge.isCompressedTexture?ge.mipmaps[0]:ge.image;W.pixelStorei(3314,xt.width),W.pixelStorei(32878,xt.height),W.pixelStorei(3316,G.min.x),W.pixelStorei(3315,G.min.y),W.pixelStorei(32877,G.min.z),ge.isDataTexture||ge.isData3DTexture?W.texSubImage3D(Lt,be,le.x,le.y,le.z,st,pt,St,Et,jt,xt.data):ge.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),W.compressedTexSubImage3D(Lt,be,le.x,le.y,le.z,st,pt,St,Et,xt.data)):W.texSubImage3D(Lt,be,le.x,le.y,le.z,st,pt,St,Et,jt,xt),W.pixelStorei(3314,Tt),W.pixelStorei(32878,Nt),W.pixelStorei(3316,Mi),W.pixelStorei(3315,an),W.pixelStorei(32877,So),be===0&&ne.generateMipmaps&&W.generateMipmap(Lt),J.unbindTexture()},this.initRenderTarget=function(G){xe.get(G).__webglFramebuffer===void 0&&de.setupRenderTarget(G)},this.initTexture=function(G){G.isCubeTexture?de.setTextureCube(G,0):G.isData3DTexture?de.setTexture3D(G,0):G.isDataArrayTexture||G.isCompressedArrayTexture?de.setTexture2DArray(G,0):de.setTexture2D(G,0),J.unbindTexture()},this.resetState=function(){y=0,x=0,v=null,J.reset(),pe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var cw=class extends Lw{};cw.prototype.isWebGL1Renderer=!0;var nh=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new Ge(t),this.near=e,this.far=r}clone(){return new nh(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Er=class extends Dt{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(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},Wy=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=KS,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=fs()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[r+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=fs()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=fs()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.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}}},yn=new E,Vc=class{constructor(t,e,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,r=this.data.count;e<r;e++)yn.fromBufferAttribute(this,e),yn.applyMatrix4(t),this.setXYZ(e,yn.x,yn.y,yn.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)yn.fromBufferAttribute(this,e),yn.applyNormalMatrix(t),this.setXYZ(e,yn.x,yn.y,yn.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)yn.fromBufferAttribute(this,e),yn.transformDirection(t),this.setXYZ(e,yn.x,yn.y,yn.z);return this}setX(t,e){return this.normalized&&(e=Ar(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Ar(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Ar(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Ar(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ma(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ma(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ma(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ma(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ar(e,this.array),r=Ar(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this}setXYZ(t,e,r,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ar(e,this.array),r=Ar(r,this.array),i=Ar(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ar(e,this.array),r=Ar(r,this.array),i=Ar(i,this.array),s=Ar(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new je(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Vc(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var Gp=class extends Dt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Ur=class extends Zt{constructor(t=null,e=1,r=1,i,s,o,a,l,c=vt,u=vt,h,d){super(null,o,a,l,c,u,i,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},kP=new ue,J5=new ue,Sl=class{constructor(t=[],e=[]){this.uuid=fs(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,i=this.bones.length;r<i;r++)this.boneInverses.push(new ue)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let r=new ue;this.bones[t]&&r.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&r.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){let t=this.bones,e=this.boneInverses,r=this.boneMatrices,i=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:J5;kP.multiplyMatrices(a,e[s]),kP.toArray(r,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Sl(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=m_(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new Ur(e,t,t,br,Ut);return r.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=r,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,r=this.bones.length;e<r;e++){let i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let r=0,i=t.bones.length;r<i;r++){let s=t.bones[r],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new Gp),this.bones.push(o),this.boneInverses.push(new ue().fromArray(t.boneInverses[r]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,r=this.boneInverses;for(let i=0,s=e.length;i<s;i++){let o=e[i];t.bones.push(o.uuid);let a=r[i];t.boneInverses.push(a.toArray())}return t}},Mo=class extends je{constructor(t,e,r,i=1){super(t,e,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},zP=new ue,GP=new ue,Ey=[],$5=new ue,Cp=new Mt,qy=class extends Mt{constructor(t,e,r){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Mo(new Float32Array(r*16),16),this.instanceColor=null,this.count=r,this.frustumCulled=!1;for(let i=0;i<r;i++)this.setMatrixAt(i,$5)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}raycast(t,e){let r=this.matrixWorld,i=this.count;if(Cp.geometry=this.geometry,Cp.material=this.material,Cp.material!==void 0)for(let s=0;s<i;s++){this.getMatrixAt(s,zP),GP.multiplyMatrices(r,zP),Cp.matrixWorld=GP,Cp.raycast(t,Ey);for(let o=0,a=Ey.length;o<a;o++){let l=Ey[o];l.instanceId=s,l.object=this,e.push(l)}Ey.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new Mo(new Float32Array(this.instanceMatrix.count*3),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},ms=class extends Fc{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ge(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},jP=new E,HP=new E,WP=new ue,US=new Ws,Ty=new ei,Uc=class extends Dt{constructor(t=new Ce,e=new ms){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[0];for(let i=1,s=e.count;i<s;i++)jP.fromBufferAttribute(e,i-1),HP.fromBufferAttribute(e,i),r[i]=r[i-1],r[i]+=jP.distanceTo(HP);t.setAttribute("lineDistance",new Te(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let r=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Ty.copy(r.boundingSphere),Ty.applyMatrix4(i),Ty.radius+=s,t.ray.intersectsSphere(Ty)===!1)return;WP.copy(i).invert(),US.copy(t.ray).applyMatrix4(WP);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new E,u=new E,h=new E,d=new E,f=this.isLineSegments?2:1,m=r.index,g=r.attributes.position;if(m!==null){let y=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let v=y,b=x-1;v<b;v+=f){let w=m.getX(v),A=m.getX(v+1);if(c.fromBufferAttribute(g,w),u.fromBufferAttribute(g,A),US.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let S=t.ray.origin.distanceTo(d);S<t.near||S>t.far||e.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),x=Math.min(g.count,o.start+o.count);for(let v=y,b=x-1;v<b;v+=f){if(c.fromBufferAttribute(g,v),u.fromBufferAttribute(g,v+1),US.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);A<t.near||A>t.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},qP=new E,XP=new E,wl=class extends Uc{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[];for(let i=0,s=e.count;i<s;i+=2)qP.fromBufferAttribute(e,i),XP.fromBufferAttribute(e,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+qP.distanceTo(XP);t.setAttribute("lineDistance",new Te(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Xy=class extends Zt{constructor(t,e,r,i,s,o,a,l,c){super(t,e,r,i,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:it,this.magFilter=s!==void 0?s:it,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var Yy=class extends Zt{constructor(t,e,r,i,s,o,a,l,c){super(t,e,r,i,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},gs=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),i=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);let u=r[i],d=r[i+1]-u,f=(o-u)/d;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new U:new E);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){let r=new E,i=[],s=[],o=[],a=new E,l=new ue;for(let f=0;f<=t;f++){let m=f/t;i[f]=this.getTangentAt(m,new E)}s[0]=new E,o[0]=new E;let c=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=c&&(c=u,r.set(1,0,0)),h<=c&&(c=h,r.set(0,1,0)),d<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(yi(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(yi(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},kc=class extends gs{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let r=e||new U,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*u-f*h+this.aX,c=d*h+f*u+this.aY}return r.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},uw=class extends kc{constructor(t,e,r,i,s,o){super(t,e,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Nw(){let n=0,t=0,e=0,r=0;function i(s,o,a,l){n=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let d=(o-s)/c-(a-s)/(c+u)+(a-o)/u,f=(a-o)/u-(l-o)/(u+h)+(l-a)/h;d*=u,f*=u,i(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return n+t*s+e*o+r*a}}}var My=new E,kS=new Nw,zS=new Nw,GS=new Nw,hw=class extends gs{constructor(t=[],e=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=i}getPoint(t,e=new E){let r=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%s]:(My.subVectors(i[0],i[1]).add(i[0]),c=My);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(My.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=My),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(c.distanceToSquared(h),f),p=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(u),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),kS.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,p,g),zS.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,p,g),GS.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,p,g)}else this.curveType==="catmullrom"&&(kS.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),zS.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),GS.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return r.set(kS.calc(l),zS.calc(l),GS.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(new E().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function YP(n,t,e,r,i){let s=(r-t)*.5,o=(i-e)*.5,a=n*n,l=n*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*n+e}function ej(n,t){let e=1-n;return e*e*t}function tj(n,t){return 2*(1-n)*n*t}function rj(n,t){return n*n*t}function Lp(n,t,e,r){return ej(n,t)+tj(n,e)+rj(n,r)}function ij(n,t){let e=1-n;return e*e*e*t}function nj(n,t){let e=1-n;return 3*e*e*n*t}function sj(n,t){return 3*(1-n)*n*n*t}function oj(n,t){return n*n*n*t}function Np(n,t,e,r,i){return ij(n,t)+nj(n,e)+sj(n,r)+oj(n,i)}var hn=class extends gs{constructor(t=new U,e=new U,r=new U,i=new U){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new U){let r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Np(t,i.x,s.x,o.x,a.x),Np(t,i.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},zc=class extends gs{constructor(t=new E,e=new E,r=new E,i=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new E){let r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Np(t,i.x,s.x,o.x,a.x),Np(t,i.y,s.y,o.y,a.y),Np(t,i.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},dn=class extends gs{constructor(t=new U,e=new U){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new U){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let r=e||new U;return r.copy(this.v2).sub(this.v1).normalize(),r}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},jp=class extends gs{constructor(t=new E,e=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new E){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},es=class extends gs{constructor(t=new U,e=new U,r=new U){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new U){let r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(Lp(t,i.x,s.x,o.x),Lp(t,i.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},dw=class extends gs{constructor(t=new E,e=new E,r=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new E){let r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(Lp(t,i.x,s.x,o.x),Lp(t,i.y,s.y,o.y),Lp(t,i.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},sh=class extends gs{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new U){let r=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return r.set(YP(a,l.x,c.x,u.x,h.x),YP(a,l.y,c.y,u.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(new U().fromArray(i))}return this}},aj=Object.freeze({__proto__:null,ArcCurve:uw,CatmullRomCurve3:hw,CubicBezierCurve:hn,CubicBezierCurve3:zc,EllipseCurve:kc,LineCurve:dn,LineCurve3:jp,QuadraticBezierCurve:es,QuadraticBezierCurve3:dw,SplineCurve:sh}),Hp=class extends gs{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new dn(e,t))}getPoint(t,e){let r=t*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=r){let o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.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 t=[],e=0;for(let r=0,i=this.curves.length;r<i;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],r;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){let u=l[c];r&&r.equals(u)||(e.push(u),r=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let i=t.curves[e];this.curves.push(new aj[i.type]().fromJSON(i))}return this}},Gc=class extends Hp{constructor(t){super(),this.type="Path",this.currentPoint=new U,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let r=new dn(this.currentPoint.clone(),new U(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,i){let s=new es(this.currentPoint.clone(),new U(t,e),new U(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(t,e,r,i,s,o){let a=new hn(this.currentPoint.clone(),new U(t,e),new U(r,i),new U(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),r=new sh(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}ellipse(t,e,r,i,s,o,a,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+c,e+u,r,i,s,o,a,l),this}absellipse(t,e,r,i,s,o,a,l){let c=new kc(t,e,r,i,s,o,a,l);if(this.curves.length>0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},oh=class extends Ce{constructor(t=[new U(0,-.5),new U(.5,0),new U(0,.5)],e=12,r=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:i},e=Math.floor(e),i=yi(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/e,h=new E,d=new U,f=new E,m=new E,p=new E,g=0,y=0;for(let x=0;x<=t.length-1;x++)switch(x){case 0:g=t[x+1].x-t[x].x,y=t[x+1].y-t[x].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(p.x,p.y,p.z);break;default:g=t[x+1].x-t[x].x,y=t[x+1].y-t[x].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let x=0;x<=e;x++){let v=r+x*u*i,b=Math.sin(v),w=Math.cos(v);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*b,h.y=t[A].y,h.z=t[A].x*w,o.push(h.x,h.y,h.z),d.x=x/e,d.y=A/(t.length-1),a.push(d.x,d.y);let T=l[3*A+0]*b,S=l[3*A+1],M=l[3*A+0]*w;c.push(T,S,M)}}for(let x=0;x<e;x++)for(let v=0;v<t.length-1;v++){let b=v+x*t.length,w=b,A=b+t.length,T=b+t.length+1,S=b+1;s.push(w,A,S),s.push(T,S,A)}this.setIndex(s),this.setAttribute("position",new Te(o,3)),this.setAttribute("uv",new Te(a,2)),this.setAttribute("normal",new Te(c,3))}static fromJSON(t){return new oh(t.points,t.segments,t.phiStart,t.phiLength)}};var jc=class extends Ce{constructor(t=1,e=1,r=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let u=[],h=[],d=[],f=[],m=0,p=[],g=r/2,y=0;x(),o===!1&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new Te(h,3)),this.setAttribute("normal",new Te(d,3)),this.setAttribute("uv",new Te(f,2));function x(){let b=new E,w=new E,A=0,T=(e-t)/r;for(let S=0;S<=s;S++){let M=[],C=S/s,P=C*(e-t)+t;for(let _=0;_<=i;_++){let I=_/i,O=I*l+a,L=Math.sin(O),j=Math.cos(O);w.x=P*L,w.y=-C*r+g,w.z=P*j,h.push(w.x,w.y,w.z),b.set(L,T,j).normalize(),d.push(b.x,b.y,b.z),f.push(I,1-C),M.push(m++)}p.push(M)}for(let S=0;S<i;S++)for(let M=0;M<s;M++){let C=p[M][S],P=p[M+1][S],_=p[M+1][S+1],I=p[M][S+1];u.push(C,P,I),u.push(P,_,I),A+=6}c.addGroup(y,A,0),y+=A}function v(b){let w=m,A=new U,T=new E,S=0,M=b===!0?t:e,C=b===!0?1:-1;for(let _=1;_<=i;_++)h.push(0,g*C,0),d.push(0,C,0),f.push(.5,.5),m++;let P=m;for(let _=0;_<=i;_++){let O=_/i*l+a,L=Math.cos(O),j=Math.sin(O);T.x=M*j,T.y=g*C,T.z=M*L,h.push(T.x,T.y,T.z),d.push(0,C,0),A.x=L*.5+.5,A.y=j*.5*C+.5,f.push(A.x,A.y),m++}for(let _=0;_<i;_++){let I=w+_,O=P+_;b===!0?u.push(O,O+1,I):u.push(O+1,O,I),S+=3}c.addGroup(y,S,b===!0?1:2),y+=S}}static fromJSON(t){return new jc(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Al=class extends jc{constructor(t=1,e=1,r=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,r,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new Al(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ah=class extends Ce{constructor(t=[],e=[],r=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:i};let s=[],o=[];a(i),c(r),u(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(x){let v=new E,b=new E,w=new E;for(let A=0;A<e.length;A+=3)f(e[A+0],v),f(e[A+1],b),f(e[A+2],w),l(v,b,w,x)}function l(x,v,b,w){let A=w+1,T=[];for(let S=0;S<=A;S++){T[S]=[];let M=x.clone().lerp(b,S/A),C=v.clone().lerp(b,S/A),P=A-S;for(let _=0;_<=P;_++)_===0&&S===A?T[S][_]=M:T[S][_]=M.clone().lerp(C,_/P)}for(let S=0;S<A;S++)for(let M=0;M<2*(A-S)-1;M++){let C=Math.floor(M/2);M%2===0?(d(T[S][C+1]),d(T[S+1][C]),d(T[S][C])):(d(T[S][C+1]),d(T[S+1][C+1]),d(T[S+1][C]))}}function c(x){let v=new E;for(let b=0;b<s.length;b+=3)v.x=s[b+0],v.y=s[b+1],v.z=s[b+2],v.normalize().multiplyScalar(x),s[b+0]=v.x,s[b+1]=v.y,s[b+2]=v.z}function u(){let x=new E;for(let v=0;v<s.length;v+=3){x.x=s[v+0],x.y=s[v+1],x.z=s[v+2];let b=g(x)/2/Math.PI+.5,w=y(x)/Math.PI+.5;o.push(b,1-w)}m(),h()}function h(){for(let x=0;x<o.length;x+=6){let v=o[x+0],b=o[x+2],w=o[x+4],A=Math.max(v,b,w),T=Math.min(v,b,w);A>.9&&T<.1&&(v<.2&&(o[x+0]+=1),b<.2&&(o[x+2]+=1),w<.2&&(o[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function f(x,v){let b=x*3;v.x=t[b+0],v.y=t[b+1],v.z=t[b+2]}function m(){let x=new E,v=new E,b=new E,w=new E,A=new U,T=new U,S=new U;for(let M=0,C=0;M<s.length;M+=9,C+=6){x.set(s[M+0],s[M+1],s[M+2]),v.set(s[M+3],s[M+4],s[M+5]),b.set(s[M+6],s[M+7],s[M+8]),A.set(o[C+0],o[C+1]),T.set(o[C+2],o[C+3]),S.set(o[C+4],o[C+5]),w.copy(x).add(v).add(b).divideScalar(3);let P=g(w);p(A,C+0,x,P),p(T,C+2,v,P),p(S,C+4,b,P)}}function p(x,v,b,w){w<0&&x.x===1&&(o[v]=x.x-1),b.x===0&&b.z===0&&(o[v]=w/2/Math.PI+.5)}function g(x){return Math.atan2(x.z,-x.x)}function y(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}static fromJSON(t){return new ah(t.vertices,t.indices,t.radius,t.details)}},lh=class extends ah{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,i=1/r,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,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new lh(t.radius,t.detail)}};var Ca=class extends Gc{constructor(t){super(t),this.uuid=fs(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let r=0,i=this.holes.length;r<i;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let i=t.holes[e];this.holes.push(new Gc().fromJSON(i))}return this}},lj={triangulate:function(n,t,e=2){let r=t&&t.length,i=r?t[0]*e:n.length,s=E_(n,0,i,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,h,d,f;if(r&&(s=fj(n,t,s,e)),n.length>80*e){a=c=n[0],l=u=n[1];for(let m=e;m<i;m+=e)h=n[m],d=n[m+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return Wp(s,o,e,a,l,f,0),o}};function E_(n,t,e,r,i){let s,o;if(i===Ej(n,t,e,r)>0)for(s=t;s<e;s+=r)o=KP(s,n[s],n[s+1],o);else for(s=e-r;s>=t;s-=r)o=KP(s,n[s],n[s+1],o);return o&&dv(o,o.next)&&(Xp(o),o=o.next),o}function Hc(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(dv(e,e.next)||Xr(e.prev,e,e.next)===0)){if(Xp(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Wp(n,t,e,r,i,s,o){if(!n)return;!o&&s&&vj(n,r,i,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?uj(n,r,i,s):cj(n)){t.push(l.i/e|0),t.push(n.i/e|0),t.push(c.i/e|0),Xp(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=hj(Hc(n),t,e),Wp(n,t,e,r,i,s,2)):o===2&&dj(n,t,e,r,i,s):Wp(Hc(n),t,e,r,i,s,1);break}}}function cj(n){let t=n.prev,e=n,r=n.next;if(Xr(t,e,r)>=0)return!1;let i=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,u=i<s?i<o?i:o:s<o?s:o,h=a<l?a<c?a:c:l<c?l:c,d=i>s?i>o?i:o:s>o?s:o,f=a>l?a>c?a:c:l>c?l:c,m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=f&&$u(i,a,s,l,o,c,m.x,m.y)&&Xr(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function uj(n,t,e,r){let i=n.prev,s=n,o=n.next;if(Xr(i,s,o)>=0)return!1;let a=i.x,l=s.x,c=o.x,u=i.y,h=s.y,d=o.y,f=a<l?a<c?a:c:l<c?l:c,m=u<h?u<d?u:d:h<d?h:d,p=a>l?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,y=fw(f,m,t,e,r),x=fw(p,g,t,e,r),v=n.prevZ,b=n.nextZ;for(;v&&v.z>=y&&b&&b.z<=x;){if(v.x>=f&&v.x<=p&&v.y>=m&&v.y<=g&&v!==i&&v!==o&&$u(a,u,l,h,c,d,v.x,v.y)&&Xr(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=f&&b.x<=p&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&$u(a,u,l,h,c,d,b.x,b.y)&&Xr(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=y;){if(v.x>=f&&v.x<=p&&v.y>=m&&v.y<=g&&v!==i&&v!==o&&$u(a,u,l,h,c,d,v.x,v.y)&&Xr(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=p&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&$u(a,u,l,h,c,d,b.x,b.y)&&Xr(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function hj(n,t,e){let r=n;do{let i=r.prev,s=r.next.next;!dv(i,s)&&T_(i,r,r.next,s)&&qp(i,s)&&qp(s,i)&&(t.push(i.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),Xp(r),Xp(r.next),r=n=s),r=r.next}while(r!==n);return Hc(r)}function dj(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Sj(o,a)){let l=M_(o,a);o=Hc(o,o.next),l=Hc(l,l.next),Wp(o,t,e,r,i,s,0),Wp(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function fj(n,t,e,r){let i=[],s,o,a,l,c;for(s=0,o=t.length;s<o;s++)a=t[s]*r,l=s<o-1?t[s+1]*r:n.length,c=E_(n,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(bj(c));for(i.sort(pj),s=0;s<i.length;s++)e=mj(i[s],e);return e}function pj(n,t){return n.x-t.x}function mj(n,t){let e=gj(n,t);if(!e)return t;let r=M_(e,n);return Hc(r,r.next),Hc(e,e.next)}function gj(n,t){let e=t,r=-1/0,i,s=n.x,o=n.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,i=e.x<e.next.x?e:e.next,d===s))return i}e=e.next}while(e!==t);if(!i)return null;let a=i,l=i.x,c=i.y,u=1/0,h;e=i;do s>=e.x&&e.x>=l&&s!==e.x&&$u(o<c?s:r,o,l,c,o<c?r:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),qp(e,n)&&(h<u||h===u&&(e.x>i.x||e.x===i.x&&yj(i,e)))&&(i=e,u=h)),e=e.next;while(e!==a);return i}function yj(n,t){return Xr(n.prev,n,t.prev)<0&&Xr(t.next,n,n.next)<0}function vj(n,t,e,r){let i=n;do i.z===0&&(i.z=fw(i.x,i.y,t,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,xj(i)}function xj(n){let t,e,r,i,s,o,a,l,c=1;do{for(e=n,n=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t<c&&(a++,r=r.nextZ,!!r);t++);for(l=c;a>0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(i=e,e=e.nextZ,a--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;e=r}s.nextZ=null,c*=2}while(o>1);return n}function fw(n,t,e,r,i){return n=(n-e)*i|0,t=(t-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function bj(n){let t=n,e=n;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==n);return e}function $u(n,t,e,r,i,s,o,a){return(i-o)*(t-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function Sj(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!wj(n,t)&&(qp(n,t)&&qp(t,n)&&Aj(n,t)&&(Xr(n.prev,n,t.prev)||Xr(n,t.prev,t))||dv(n,t)&&Xr(n.prev,n,n.next)>0&&Xr(t.prev,t,t.next)>0)}function Xr(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function dv(n,t){return n.x===t.x&&n.y===t.y}function T_(n,t,e,r){let i=Py(Xr(n,t,e)),s=Py(Xr(n,t,r)),o=Py(Xr(e,r,n)),a=Py(Xr(e,r,t));return!!(i!==s&&o!==a||i===0&&Cy(n,e,t)||s===0&&Cy(n,r,t)||o===0&&Cy(e,n,r)||a===0&&Cy(e,t,r))}function Cy(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function Py(n){return n>0?1:n<0?-1:0}function wj(n,t){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&T_(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function qp(n,t){return Xr(n.prev,n,n.next)<0?Xr(n,t,n.next)>=0&&Xr(n,n.prev,t)>=0:Xr(n,t,n.prev)<0||Xr(n,n.next,t)<0}function Aj(n,t){let e=n,r=!1,i=(n.x+t.x)/2,s=(n.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==n);return r}function M_(n,t){let e=new pw(n.i,n.x,n.y),r=new pw(t.i,t.x,t.y),i=n.next,s=t.prev;return n.next=t,t.prev=n,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function KP(n,t,e,r){let i=new pw(n,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Xp(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function pw(n,t,e){this.i=n,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ej(n,t,e,r){let i=0;for(let s=t,o=e-r;s<e;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}var ch=class{static area(t){let e=t.length,r=0;for(let i=e-1,s=0;s<e;i=s++)r+=t[i].x*t[s].y-t[s].x*t[i].y;return r*.5}static isClockWise(t){return ch.area(t)<0}static triangulateShape(t,e){let r=[],i=[],s=[];QP(t),ZP(r,t);let o=t.length;e.forEach(QP);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,ZP(r,e[l]);let a=lj.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function QP(n){let t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function ZP(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}var uh=class extends ah{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,i=[-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],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(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new uh(t.radius,t.detail)}};var qs=class extends Ce{constructor(t=1,e=32,r=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),c=0,u=[],h=new E,d=new E,f=[],m=[],p=[],g=[];for(let y=0;y<=r;y++){let x=[],v=y/r,b=0;y==0&&o==0?b=.5/e:y==r&&l==Math.PI&&(b=-.5/e);for(let w=0;w<=e;w++){let A=w/e;h.x=-t*Math.cos(i+A*s)*Math.sin(o+v*a),h.y=t*Math.cos(o+v*a),h.z=t*Math.sin(i+A*s)*Math.sin(o+v*a),m.push(h.x,h.y,h.z),d.copy(h).normalize(),p.push(d.x,d.y,d.z),g.push(A+b,1-v),x.push(c++)}u.push(x)}for(let y=0;y<r;y++)for(let x=0;x<e;x++){let v=u[y][x+1],b=u[y][x],w=u[y+1][x],A=u[y+1][x+1];(y!==0||o>0)&&f.push(v,b,A),(y!==r-1||l<Math.PI)&&f.push(b,w,A)}this.setIndex(f),this.setAttribute("position",new Te(m,3)),this.setAttribute("normal",new Te(p,3)),this.setAttribute("uv",new Te(g,2))}static fromJSON(t){return new qs(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var hh=class extends Ce{constructor(t=1,e=.4,r=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:i,arc:s},r=Math.floor(r),i=Math.floor(i);let o=[],a=[],l=[],c=[],u=new E,h=new E,d=new E;for(let f=0;f<=r;f++)for(let m=0;m<=i;m++){let p=m/i*s,g=f/r*Math.PI*2;h.x=(t+e*Math.cos(g))*Math.cos(p),h.y=(t+e*Math.cos(g))*Math.sin(p),h.z=e*Math.sin(g),a.push(h.x,h.y,h.z),u.x=t*Math.cos(p),u.y=t*Math.sin(p),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(m/i),c.push(f/r)}for(let f=1;f<=r;f++)for(let m=1;m<=i;m++){let p=(i+1)*f+m-1,g=(i+1)*(f-1)+m-1,y=(i+1)*(f-1)+m,x=(i+1)*f+m;o.push(p,g,x),o.push(g,y,x)}this.setIndex(o),this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(c,2))}static fromJSON(t){return new hh(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},dh=class extends Ce{constructor(t=1,e=.4,r=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:i,p:s,q:o},r=Math.floor(r),i=Math.floor(i);let a=[],l=[],c=[],u=[],h=new E,d=new E,f=new E,m=new E,p=new E,g=new E,y=new E;for(let v=0;v<=r;++v){let b=v/r*s*Math.PI*2;x(b,s,o,t,f),x(b+.01,s,o,t,m),g.subVectors(m,f),y.addVectors(m,f),p.crossVectors(g,y),y.crossVectors(p,g),p.normalize(),y.normalize();for(let w=0;w<=i;++w){let A=w/i*Math.PI*2,T=-e*Math.cos(A),S=e*Math.sin(A);h.x=f.x+(T*y.x+S*p.x),h.y=f.y+(T*y.y+S*p.y),h.z=f.z+(T*y.z+S*p.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),c.push(d.x,d.y,d.z),u.push(v/r),u.push(w/i)}}for(let v=1;v<=r;v++)for(let b=1;b<=i;b++){let w=(i+1)*(v-1)+(b-1),A=(i+1)*v+(b-1),T=(i+1)*v+b,S=(i+1)*(v-1)+b;a.push(w,A,S),a.push(A,T,S)}this.setIndex(a),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2));function x(v,b,w,A,T){let S=Math.cos(v),M=Math.sin(v),C=w/b*v,P=Math.cos(C);T.x=A*(2+P)*.5*S,T.y=A*(2+P)*M*.5,T.z=A*Math.sin(C)*.5}}static fromJSON(t){return new dh(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};var Ky=class extends $e{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};function pl(n,t,e){return C_(n)?new n.constructor(n.subarray(t,e!==void 0?e:n.length)):n.slice(t,e)}function _y(n,t,e){return!n||!e&&n.constructor===t?n:typeof t.BYTES_PER_ELEMENT=="number"?new t(n):Array.prototype.slice.call(n)}function C_(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Tj(n){function t(i,s){return n[i]-n[s]}let e=n.length,r=new Array(e);for(let i=0;i!==e;++i)r[i]=i;return r.sort(t),r}function JP(n,t,e){let r=n.length,i=new n.constructor(r);for(let s=0,o=0;o!==r;++s){let a=e[s]*t;for(let l=0;l!==t;++l)i[o++]=n[a+l]}return i}function P_(n,t,e,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=n[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=n[i++];while(s!==void 0);else do o=s[r],o!==void 0&&(t.push(s.time),e.push(o)),s=n[i++];while(s!==void 0)}var fh=class{constructor(t,e,r,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(r),this.sampleValues=e,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,r=this._cachedIndex,i=e[r],s=e[r-1];e:{t:{let o;r:{i:if(!(t<i)){for(let a=r+2;;){if(i===void 0){if(t<s)break i;return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=i,i=e[++r],t<i)break t}o=e.length;break r}if(!(t>=s)){let a=e[1];t<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(i=s,s=e[--r-1],t>=s)break t}o=r,r=0;break r}break e}for(;r<o;){let a=r+o>>>1;t<e[a]?o=a:r=a+1}if(i=e[r],s=e[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,i)}return this.interpolate_(r,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=r[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},mw=class extends fh{constructor(t,e,r,i){super(t,e,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Qu,endingEnd:Qu}}intervalChanged_(t,e,r){let i=this.parameterPositions,s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Zu:s=t,a=2*e-r;break;case By:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case Zu:o=t,l=2*r-e;break;case By:o=1,l=r+i[1]-i[0];break;default:o=t-1,l=e}let c=(r-e)*.5,u=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(l-r),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,m=(r-e)/(i-e),p=m*m,g=p*m,y=-d*g+2*d*p-d*m,x=(1+d)*g+(-1.5-2*d)*p+(-.5+d)*m+1,v=(-1-f)*g+(1.5+f)*p+.5*m,b=f*g-f*p;for(let w=0;w!==a;++w)s[w]=y*o[u+w]+x*o[c+w]+v*o[l+w]+b*o[h+w];return s}},Qy=class extends fh{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=(r-e)/(i-e),h=1-u;for(let d=0;d!==a;++d)s[d]=o[c+d]*h+o[l+d]*u;return s}},gw=class extends fh{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t){return this.copySampleValue_(t-1)}},ys=class{constructor(t,e,r,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=_y(e,this.TimeBufferType),this.values=_y(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,r;if(e.toJSON!==this.toJSON)r=e.toJSON(t);else{r={name:t.name,times:_y(t.times,Array),values:_y(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(r.interpolation=i)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new gw(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Qy(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new mw(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Ly:e=this.InterpolantFactoryMethodDiscrete;break;case Ny:e=this.InterpolantFactoryMethodLinear;break;case pS:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ly;case this.InterpolantFactoryMethodLinear:return Ny;case this.InterpolantFactoryMethodSmooth:return pS}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let r=0,i=e.length;r!==i;++r)e[r]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let r=0,i=e.length;r!==i;++r)e[r]*=t}return this}trim(t,e){let r=this.times,i=r.length,s=0,o=i-1;for(;s!==i&&r[s]<t;)++s;for(;o!==-1&&r[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=pl(r,s,o),this.values=pl(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let r=this.times,i=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&C_(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=pl(this.times),e=pl(this.values),r=this.getValueSize(),i=this.getInterpolation()===pS,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=t[a],u=t[a+1];if(c!==u&&(a!==1||c!==t[0]))if(i)l=!0;else{let h=a*r,d=h-r,f=h+r;for(let m=0;m!==r;++m){let p=e[h+m];if(p!==e[d+m]||p!==e[f+m]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*r,d=o*r;for(let f=0;f!==r;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*r,l=o*r,c=0;c!==r;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=pl(t,0,o),this.values=pl(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=pl(this.times,0),e=pl(this.values,0),r=this.constructor,i=new r(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};ys.prototype.TimeBufferType=Float32Array;ys.prototype.ValueBufferType=Float32Array;ys.prototype.DefaultInterpolation=Ny;var El=class extends ys{};El.prototype.ValueTypeName="bool";El.prototype.ValueBufferType=Array;El.prototype.DefaultInterpolation=Ly;El.prototype.InterpolantFactoryMethodLinear=void 0;El.prototype.InterpolantFactoryMethodSmooth=void 0;var Zy=class extends ys{};Zy.prototype.ValueTypeName="color";var ph=class extends ys{};ph.prototype.ValueTypeName="number";var yw=class extends fh{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(i-e),c=t*a;for(let u=c+a;c!==u;c+=4)Ye.slerpFlat(s,0,o,c-a,o,c,l);return s}},Wc=class extends ys{InterpolantFactoryMethodLinear(t){return new yw(this.times,this.values,this.getValueSize(),t)}};Wc.prototype.ValueTypeName="quaternion";Wc.prototype.DefaultInterpolation=Ny;Wc.prototype.InterpolantFactoryMethodSmooth=void 0;var Tl=class extends ys{};Tl.prototype.ValueTypeName="string";Tl.prototype.ValueBufferType=Array;Tl.prototype.DefaultInterpolation=Ly;Tl.prototype.InterpolantFactoryMethodLinear=void 0;Tl.prototype.InterpolantFactoryMethodSmooth=void 0;var mh=class extends ys{};mh.prototype.ValueTypeName="vector";var gh=class{constructor(t,e=-1,r,i=Iw){this.name=t,this.tracks=r,this.duration=e,this.blendMode=i,this.uuid=fs(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,i=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(Cj(r[o]).scale(i));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],r=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=r.length;s!==o;++s)e.push(ys.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(t,e,r,i){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);let u=Tj(l);l=JP(l,1,u),c=JP(c,1,u),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new ph(".morphTargetInfluences["+e[a].name+"]",l,c).scale(1/r))}return new this(t,-1,o)}static findByName(t,e){let r=t;if(!Array.isArray(t)){let i=t;r=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<r.length;i++)if(r[i].name===e)return r[i];return null}static CreateClipsFromMorphTargetSequences(t,e,r){let i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let c=t[a],u=c.name.match(s);if(u&&u.length>1){let h=u[1],d=i[h];d||(i[h]=d=[]),d.push(c)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,r));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let r=function(h,d,f,m,p){if(f.length!==0){let g=[],y=[];P_(f,g,y,m),g.length!==0&&p.push(new h(d,g,y))}},i=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,c=t.hierarchy||[];for(let h=0;h<c.length;h++){let d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},m;for(m=0;m<d.length;m++)if(d[m].morphTargets)for(let p=0;p<d[m].morphTargets.length;p++)f[d[m].morphTargets[p]]=-1;for(let p in f){let g=[],y=[];for(let x=0;x!==d[m].morphTargets.length;++x){let v=d[m];g.push(v.time),y.push(v.morphTarget===p?1:0)}i.push(new ph(".morphTargetInfluence["+p+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(mh,f+".position",d,"pos",i),r(Wc,f+".quaternion",d,"rot",i),r(mh,f+".scale",d,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){let t=this.tracks,e=0;for(let r=0,i=t.length;r!==i;++r){let s=this.tracks[r];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function Mj(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ph;case"vector":case"vector2":case"vector3":case"vector4":return mh;case"color":return Zy;case"quaternion":return Wc;case"bool":case"boolean":return El;case"string":return Tl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function Cj(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Mj(n.type);if(n.times===void 0){let e=[],r=[];P_(n.keys,e,r,"value"),n.times=e,n.values=r}return t.parse!==void 0?t.parse(n):new t(n.name,n.times,n.values,n.interpolation)}var Jy={enabled:!1,files:{},add:function(n,t){this.enabled!==!1&&(this.files[n]=t)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},Yp=class{constructor(t,e,r){let i=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(u){a++,s===!1&&i.onStart!==void 0&&i.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){let h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){let f=c[h],m=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return m}return null}}},Pj=new Yp,Ml=class{constructor(t){this.manager=t!==void 0?t:Pj,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let r=this;return new Promise(function(i,s){r.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},Ea={},vw=class extends Error{constructor(t,e){super(t),this.response=e}},yh=class extends Ml{constructor(t){super(t)}load(t,e,r,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=Jy.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(Ea[t]!==void 0){Ea[t].push({onLoad:e,onProgress:r,onError:i});return}Ea[t]=[],Ea[t].push({onLoad:e,onProgress:r,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=Ea[t],h=c.body.getReader(),d=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=d?parseInt(d):0,m=f!==0,p=0,g=new ReadableStream({start(y){x();function x(){h.read().then(({done:v,value:b})=>{if(v)y.close();else{p+=b.byteLength;let w=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let A=0,T=u.length;A<T;A++){let S=u[A];S.onProgress&&S.onProgress(w)}y.enqueue(b),x()}})}}});return new Response(g)}else throw new vw(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{Jy.add(t,c);let u=Ea[t];delete Ea[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=Ea[t];if(u===void 0)throw this.manager.itemError(t),c;delete Ea[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onError&&f.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var xw=class extends Ml{constructor(t){super(t)}load(t,e,r,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=this,o=Jy.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;let a=Vp("img");function l(){u(),Jy.add(t,this),e&&e(this),s.manager.itemEnd(t)}function c(h){u(),i&&i(h),s.manager.itemError(t),s.manager.itemEnd(t)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}};var $y=class extends Ml{constructor(t){super(t)}load(t,e,r,i){let s=new Zt,o=new xw(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,i),s}},Cl=class extends Dt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ge(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},ev=class extends Cl{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ge(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},jS=new ue,$P=new E,e_=new E,Kp=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new U(512,512),this.map=null,this.mapPass=null,this.matrix=new ue,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new kp,this._frameExtents=new U(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;$P.setFromMatrixPosition(t.matrixWorld),e.position.copy($P),e_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(e_),e.updateMatrixWorld(),jS.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(jS),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(jS)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},bw=class extends Kp{constructor(){super(new si(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=Fp*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},tv=class extends Cl{constructor(t,e,r=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new bw}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},t_=new ue,Pp=new E,HS=new E,Sw=class extends Kp{constructor(){super(new si(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new U(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(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(t,e=0){let r=this.camera,i=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Pp.setFromMatrixPosition(t.matrixWorld),r.position.copy(Pp),HS.copy(r.position),HS.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(HS),r.updateMatrixWorld(),i.makeTranslation(-Pp.x,-Pp.y,-Pp.z),t_.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(t_)}},rv=class extends Cl{constructor(t,e,r=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new Sw}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},ww=class extends Kp{constructor(){super(new bl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},iv=class extends Cl{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.shadow=new ww}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var Qp=class extends Ce{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},vh=class extends Ml{constructor(t){super(t)}load(t,e,r,i){let s=this,o=new yh(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},r,i)}parse(t){let e={},r={};function i(f,m){if(e[m]!==void 0)return e[m];let g=f.interleavedBuffers[m],y=s(f,g.buffer),x=sy(g.type,y),v=new Wy(x,g.stride);return v.uuid=g.uuid,e[m]=v,v}function s(f,m){if(r[m]!==void 0)return r[m];let g=f.arrayBuffers[m],y=new Uint32Array(g).buffer;return r[m]=y,y}let o=t.isInstancedBufferGeometry?new Qp:new Ce,a=t.data.index;if(a!==void 0){let f=sy(a.type,a.array);o.setIndex(new je(f,1))}let l=t.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=i(t.data,m.data);p=new Vc(g,m.itemSize,m.offset,m.normalized)}else{let g=sy(m.type,m.array),y=m.isInstancedBufferAttribute?Mo:je;p=new y(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let c=t.data.morphAttributes;if(c)for(let f in c){let m=c[f],p=[];for(let g=0,y=m.length;g<y;g++){let x=m[g],v;if(x.isInterleavedBufferAttribute){let b=i(t.data,x.data);v=new Vc(b,x.itemSize,x.offset,x.normalized)}else{let b=sy(x.type,x.array);v=new je(b,x.itemSize,x.normalized)}x.name!==void 0&&(v.name=x.name),p.push(v)}o.morphAttributes[f]=p}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,m=h.length;f!==m;++f){let p=h[f];o.addGroup(p.start,p.count,p.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new E;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new ei(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var nv=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=r_(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=r_();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function r_(){return(typeof performance>"u"?Date:performance).now()}var Aw=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let i,s,o;switch(e){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let r=this.buffer,i=this.valueSize,s=t*i+i,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,i=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,i=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(r,i,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(r[l]!==r[l+e]){a.setValue(r,i);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,i=r*this._origIndex;t.getValue(e,i);for(let s=r,o=i;s!==o;++s)e[s]=e[i+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r<e;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[e+r]=this.buffer[t+r]}_select(t,e,r,i,s){if(i>=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,i){Ye.slerpFlat(t,e,t,e,t,r,i)}_slerpAdditive(t,e,r,i,s){let o=this._workIndex*s;Ye.multiplyQuaternionsFlat(t,o,t,e,t,r),Ye.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,r,i,s){let o=1-i;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*i}}_lerpAdditive(t,e,r,i,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*i}}},Bw="\\[\\]\\.:\\/",_j=new RegExp("["+Bw+"]","g"),Fw="[^"+Bw+"]",Ij="[^"+Bw.replace("\\.","")+"]",Dj=/((?:WC+[\/:])*)/.source.replace("WC",Fw),Oj=/(WCOD+)?/.source.replace("WCOD",Ij),Rj=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Fw),Lj=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Fw),Nj=new RegExp("^"+Dj+Oj+Rj+Lj+"$"),Bj=["material","materials","bones","map"],Ew=class{constructor(t,e,r){let i=r||sr.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}},sr=class{constructor(t,e,r){this.path=e,this.parsedPath=r||sr.parseTrackName(e),this.node=sr.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new sr.Composite(t,e,r):new sr(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(_j,"")}static parseTrackName(t){let e=Nj.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=r.nodeName.substring(i+1);Bj.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=r(a.children);if(l)return l}return null},i=r(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)t[e++]=r[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,r=e.objectName,i=e.propertyName,s=e.propertyIndex;if(t||(t=sr.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(r){let c=e.objectIndex;switch(r){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===c){c=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}let o=t[i];if(o===void 0){let c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};sr.Composite=Ew;sr.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};sr.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};sr.prototype.GetterByBindingType=[sr.prototype._getValue_direct,sr.prototype._getValue_array,sr.prototype._getValue_arrayElement,sr.prototype._getValue_toArray];sr.prototype.SetterByBindingTypeAndVersioning=[[sr.prototype._setValue_direct,sr.prototype._setValue_direct_setNeedsUpdate,sr.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[sr.prototype._setValue_array,sr.prototype._setValue_array_setNeedsUpdate,sr.prototype._setValue_array_setMatrixWorldNeedsUpdate],[sr.prototype._setValue_arrayElement,sr.prototype._setValue_arrayElement_setNeedsUpdate,sr.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[sr.prototype._setValue_fromArray,sr.prototype._setValue_fromArray_setNeedsUpdate,sr.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Tw=class{constructor(t,e,r=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=i;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Qu,endingEnd:Qu};for(let c=0;c!==o;++c){let u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=_w,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){let i=this._clip.duration,s=t._clip.duration,o=s/i,a=i/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){let i=this._mixer,s=i.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+r,c[0]=t/o,c[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,i){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*r;l<0||r===0?e=0:(this._startTime=null,e=r*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case KU:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Iw:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,r=this.loop,i=this.time+t,s=this._loopCount,o=r===$p;if(t===0)return s===-1?i:o&&(s&1)===1?e-i:i;if(r===Pw){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=e||i<0){let a=Math.floor(i/e);i-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return e-i}return i}_setEndings(t,e,r){let i=this._interpolantSettings;r?(i.endingStart=Zu,i.endingEnd=Zu):(t?i.endingStart=this.zeroSlopeAtStart?Zu:Qu:i.endingStart=By,e?i.endingEnd=this.zeroSlopeAtEnd?Zu:Qu:i.endingEnd=By)}_scheduleFading(t,e,r){let i=this._mixer,s=i.time,o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=r,this}},Fj=new Float32Array(1),sv=class extends ar{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let r=t._localRoot||this._root,i=t._clip.tracks,s=i.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){let d=i[h],f=d.name,m=u[f];if(m!==void 0)++m.referenceCount,o[h]=m;else{if(m=o[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}let p=e&&e._propertyBindings[h].binding.parsedPath;m=new Aw(sr.create(r,f,p),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),o[h]=m}a[h].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let r=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,r)}let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,r){let i=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=i.length,i.push(t),o.actionByRoot[r]=t}_removeInactiveAction(t){let e=this._actions,r=e[e.length-1],i=t._cacheIndex;r._cacheIndex=i,e[i]=r,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=t._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,r=t._cacheIndex,i=this._nActiveActions++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_takeBackAction(t){let e=this._actions,r=t._cacheIndex,i=--this._nActiveActions,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_addInactiveBinding(t,e,r){let i=this._bindingsByRootAndName,s=this._bindings,o=i[e];o===void 0&&(o={},i[e]=o),o[r]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,r=t.binding,i=r.rootNode.uuid,s=r.path,o=this._bindingsByRootAndName,a=o[i],l=e[e.length-1],c=t._cacheIndex;l._cacheIndex=c,e[c]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[i]}_lendBinding(t){let e=this._bindings,r=t._cacheIndex,i=this._nActiveBindings++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_takeBackBinding(t){let e=this._bindings,r=t._cacheIndex,i=--this._nActiveBindings,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,r=t[e];return r===void 0&&(r=new Qy(new Float32Array(2),new Float32Array(2),1,Fj),r.__cacheIndex=e,t[e]=r),r}_takeBackControlInterpolant(t){let e=this._controlInterpolants,r=t.__cacheIndex,i=--this._nActiveControlInterpolants,s=e[i];t.__cacheIndex=i,e[i]=t,s.__cacheIndex=r,e[r]=s}clipAction(t,e,r){let i=e||this._root,s=i.uuid,o=typeof t=="string"?gh.findByName(i,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],c=null;if(r===void 0&&(o!==null?r=o.blendMode:r=Iw),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===r)return h;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;let u=new Tw(this,o,e,r);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(t,e){let r=e||this._root,i=r.uuid,s=typeof t=="string"?gh.findByName(r,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let r=e-1;r>=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,i=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let c=0;c!==r;++c)e[c]._update(i,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,r=t.uuid,i=this._actionsByClip,s=i[r];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let c=o[a];this._deactivateAction(c);let u=c._cacheIndex,h=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,e[u]=h,e.pop(),this._removeInactiveBindingsForAction(c)}delete i[r]}}uncacheRoot(t){let e=t.uuid,r=this._actionsByClip;for(let o in r){let a=r[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let i=this._bindingsByRootAndName,s=i[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let r=this.existingAction(t,e);r!==null&&(this._deactivateAction(r),this._removeInactiveAction(r))}},ce=class{constructor(t){this.value=t}clone(){return new ce(this.value.clone===void 0?this.value:this.value.clone())}};var xh=class{constructor(t,e,r=0,i=1/0){this.ray=new Ws(t,e),this.near=r,this.far=i,this.camera=null,this.layers=new Up,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,r=[]){return Mw(t,this,r,e),r.sort(i_),r}intersectObjects(t,e=!0,r=[]){for(let i=0,s=t.length;i<s;i++)Mw(t[i],this,r,e);return r.sort(i_),r}};function i_(n,t){return n.distance-t.distance}function Mw(n,t,e,r){if(n.layers.test(t.layers)&&n.raycast(t,e),r===!0){let i=n.children;for(let s=0,o=i.length;s<o;s++)Mw(i[s],t,e,!0)}}var Zp=class{constructor(t=1,e=0,r=0){return this.radius=t,this.phi=e,this.theta=r,this}set(t,e,r){return this.radius=t,this.phi=e,this.theta=r,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,r){return this.radius=Math.sqrt(t*t+e*e+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,r),this.phi=Math.acos(yi(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var n_=new U,Pl=class{constructor(t=new U(1/0,1/0),e=new U(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=n_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return n_.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},s_=new E,Iy=new E,Di=class{constructor(t=new E,e=new E){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){s_.subVectors(t,this.start),Iy.subVectors(this.end,this.start);let r=Iy.dot(Iy),s=Iy.dot(s_)/r;return e&&(s=yi(s,0,1)),s}closestPointToPoint(t,e,r){let i=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},o_=new E,ov=class extends Dt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new Ce,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,u=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}r.setAttribute("position",new Te(i,3));let s=new ms({fog:!1,toneMapped:!1});this.cone=new wl(r,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 t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),o_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(o_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var av=class extends Mt{constructor(t,e,r){let i=new qs(e,4,2),s=new un({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=t,this.color=r,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)}};var a_=new E,Dy=new E,l_=new E,lv=class extends Dt{constructor(t,e,r){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new Ce;i.setAttribute("position",new Te([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new ms({fog:!1,toneMapped:!1});this.lightPlane=new Uc(i,s),this.add(this.lightPlane),i=new Ce,i.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Uc(i,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),a_.setFromMatrixPosition(this.light.matrixWorld),Dy.setFromMatrixPosition(this.light.target.matrixWorld),l_.subVectors(Dy,a_),this.lightPlane.lookAt(Dy),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(Dy),this.targetLine.scale.z=l_.length()}},Oy=new E,$r=new bn,_l=class extends wl{constructor(t){let e=new Ce,r=new ms({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){i.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}e.setAttribute("position",new Te(i,3)),e.setAttribute("color",new Te(s,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let c=new Ge(16755200),u=new Ge(16711680),h=new Ge(43775),d=new Ge(16777215),f=new Ge(3355443);this.setColors(c,u,h,d,f)}setColors(t,e,r,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,r.r,r.g,r.b),a.setXYZ(33,r.r,r.g,r.b),a.setXYZ(34,r.r,r.g,r.b),a.setXYZ(35,r.r,r.g,r.b),a.setXYZ(36,r.r,r.g,r.b),a.setXYZ(37,r.r,r.g,r.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.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 t=this.geometry,e=this.pointMap,r=1,i=1;$r.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ni("c",e,t,$r,0,0,-1),ni("t",e,t,$r,0,0,1),ni("n1",e,t,$r,-r,-i,-1),ni("n2",e,t,$r,r,-i,-1),ni("n3",e,t,$r,-r,i,-1),ni("n4",e,t,$r,r,i,-1),ni("f1",e,t,$r,-r,-i,1),ni("f2",e,t,$r,r,-i,1),ni("f3",e,t,$r,-r,i,1),ni("f4",e,t,$r,r,i,1),ni("u1",e,t,$r,r*.7,i*1.1,-1),ni("u2",e,t,$r,-r*.7,i*1.1,-1),ni("u3",e,t,$r,0,i*2,-1),ni("cf1",e,t,$r,-r,0,1),ni("cf2",e,t,$r,r,0,1),ni("cf3",e,t,$r,0,-i,1),ni("cf4",e,t,$r,0,i,1),ni("cn1",e,t,$r,-r,0,-1),ni("cn2",e,t,$r,r,0,-1),ni("cn3",e,t,$r,0,-i,-1),ni("cn4",e,t,$r,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ni(n,t,e,r,i,s,o){Oy.set(i,s,o).unproject(r);let a=t[n];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],Oy.x,Oy.y,Oy.z)}}var Il=class extends wl{constructor(t,e=16776960){let r=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]),i=[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 Ce;s.setIndex(new je(r,1)),s.setAttribute("position",new Te(i,3)),super(s,new ms({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var cv=class extends wl{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Ce;i.setAttribute("position",new Te(e,3)),i.setAttribute("color",new Te(r,3));let s=new ms({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,r){let i=new Ge,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var Ta=Vj();function Vj(){let n=new ArrayBuffer(4),t=new Float32Array(n),e=new Uint32Array(n),r=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){let c=l-127;c<-27?(r[l]=0,r[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(r[l]=1024>>-c-14,r[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(r[l]=c+15<<10,r[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(r[l]=31744,r[l|256]=64512,i[l]=24,i[l|256]=24):(r[l]=31744,r[l|256]=64512,i[l]=13,i[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:t,uint32View:e,baseTable:r,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}function Uj(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=yi(n,-65504,65504),Ta.floatView[0]=n;let t=Ta.uint32View[0],e=t>>23&511;return Ta.baseTable[e]+((t&8388607)>>Ta.shiftTable[e])}function kj(n){let t=n>>10;return Ta.uint32View[0]=Ta.mantissaTable[Ta.offsetTable[t]+(n&1023)]+Ta.exponentTable[t],Ta.floatView[0]}var __=Object.freeze({__proto__:null,fromHalfFloat:kj,toHalfFloat:Uj});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Pa}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Pa);var Ah=".",em=Symbol("target"),Vw=Symbol("unsubscribe");function tm(n){return n instanceof Date||n instanceof Set||n instanceof Map||n instanceof WeakSet||n instanceof WeakMap||ArrayBuffer.isView(n)}function I_(n){return(typeof n=="object"?n===null:typeof n!="function")||n instanceof RegExp}var rs=Array.isArray;function qc(n){return typeof n=="symbol"}var zj={after:(n,t)=>rs(n)?n.slice(t.length):t===""?n:n.slice(t.length+1),concat:(n,t)=>rs(n)?(n=[...n],t&&n.push(t),n):t&&t.toString!==void 0?(n!==""&&(n+=Ah),qc(t)?n+t.toString():n+t):n,initial:n=>{if(rs(n))return n.slice(0,-1);if(n==="")return n;let t=n.lastIndexOf(Ah);return t===-1?"":n.slice(0,t)},last:n=>{if(rs(n))return n[n.length-1]||"";if(n==="")return n;let t=n.lastIndexOf(Ah);return t===-1?n:n.slice(t+1)},walk:(n,t)=>{if(rs(n))for(let e of n)t(e);else if(n!==""){let e=0,r=n.indexOf(Ah);if(r===-1)t(n);else for(;e<n.length;)r===-1&&(r=n.length),t(n.slice(e,r)),e=r+1,r=n.indexOf(Ah,e)}},get(n,t){return this.walk(t,e=>{n&&(n=n[e])}),n}},Sn=zj;function Uw(n){return typeof n=="object"&&typeof n.next=="function"}function kw(n,t,e,r,i){let s=n.next;if(t.name==="entries")n.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],t,o.value[0],r),o.value[1]=i(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[em].keys();n.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,t,o.next().value,r)),a}}else n.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,t,o.value,r)),o};return n}function fv(n,t,e){return n.isUnsubscribed||t.ignoreSymbols&&qc(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var rm=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),r=e.get(t);return r===void 0&&(r={},e.set(t,r)),r}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let r=this._getProperties(t),i=r[e];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(t,e),r[e]=i),i}getProxy(t,e,r,i){if(this.isUnsubscribed)return t;let s=t[i],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,r):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,Sn.get(e,this.getPath(t)))}defineProperty(t,e,r){return Reflect.defineProperty(t,e,r)?(this.isUnsubscribed||(this._getProperties(t)[e]=r),!0):!1}setProperty(t,e,r,i,s){if(!this._equals(s,r)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,r,i):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(t);i&&(delete i[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let i=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&i!==void 0&&Object.is(t.value,i.value)&&(t.writable||!1)===(i.writable||!1)&&(t.enumerable||!1)===(i.enumerable||!1)&&(t.configurable||!1)===(i.configurable||!1)&&t.get===i.get&&t.set===i.set}isGetInvariant(t,e){let r=this._getOwnPropertyDescriptor(t,e);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Eh(n){return toString.call(n)==="[object Object]"}function Th(){return!0}function Dl(n,t){return n.length!==t.length||n.some((e,r)=>t[r]!==e)}var pv=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var Gj=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),zw={push:Th,pop:Th,shift:Th,unshift:Th,copyWithin:Dl,reverse:Dl,sort:Dl,splice:Dl,flat:Dl,fill:Dl},D_=new Set([...pv,...Gj,...Object.keys(zw)]);function Mh(n,t){if(n.size!==t.size)return!0;for(let e of n)if(!t.has(e))return!0;return!1}var Gw=["keys","values","entries"],jw=new Set(["has","toString"]),Hw={add:Mh,clear:Mh,delete:Mh,forEach:Mh},O_=new Set([...jw,...Object.keys(Hw),...Gw]);function Ch(n,t){if(n.size!==t.size)return!0;let e;for(let[r,i]of n)if(e=t.get(r),e!==i||e===void 0&&!t.has(r))return!0;return!1}var jj=new Set([...jw,"get"]),Ww={set:Ch,clear:Ch,delete:Ch,forEach:Ch},R_=new Set([...jj,...Object.keys(Ww),...Gw]);var Gi=class{constructor(t,e,r,i){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return pv.has(t)}_shallowClone(t){let e=t;if(Eh(t))e={...t};else if(rs(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(r=>this._shallowClone(r)));else if(t instanceof Map){e=new Map;for(let[r,i]of t.entries())e.set(r,this._shallowClone(i))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,i){return t?(rs(i)?this._onIsChanged=zw[e]:i instanceof Set?this._onIsChanged=Hw[e]:i instanceof Map&&(this._onIsChanged=Ww[e]),i):r}update(t,e,r){let i=Sn.after(t,this._path);if(e!=="length"){let s=this.clone;Sn.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:e,previous:r}),s&&s[e]&&(s[e]=r)}this._isChanged=!0}undo(t){let e;for(let r=this._changes.length-1;r!==-1;r--)e=this._changes[r],Sn.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Ph=class extends Gi{static isHandledMethod(t){return D_.has(t)}};var im=class extends Gi{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var _h=class extends Gi{static isHandledMethod(t){return O_.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var Ih=class extends Gi{static isHandledMethod(t){return R_.has(t)}undo(t){for(let[e,r]of this.clone.entries())t.set(e,r);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var nm=class extends Gi{constructor(t,e,r,i){super(void 0,e,r,i),this._arg1=r[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var sm=class extends Gi{constructor(t,e,r,i){super(void 0,e,r,i),this._weakKey=r[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Ys=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return Eh(t)||rs(t)||tm(t)}static isHandledMethod(t,e){return Eh(t)?Gi.isHandledMethod(e):rs(t)?Ph.isHandledMethod(e):t instanceof Set?_h.isHandledMethod(e):t instanceof Map?Ih.isHandledMethod(e):tm(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let i=Gi;rs(t)?i=Ph:t instanceof Date?i=im:t instanceof Set?i=_h:t instanceof Map?i=Ih:t instanceof WeakSet?i=nm:t instanceof WeakMap&&(i=sm),this._stack.push(new i(t,e,r,this._hasOnValidate))}update(t,e,r){this._stack[this._stack.length-1].update(t,e,r)}preferredThisArg(t,e,r){let{name:i}=t,s=Ys.isHandledMethod(r,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,e,r)}isChanged(t,e,r){return this._stack[this._stack.length-1].isChanged(t,e,r)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var Hj={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},qw=(n,t,e={})=>{e={...Hj,...e};let r=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new rm(i),c=typeof e.onValidate=="function",u=new Ys(c),h=(x,v,b,w,A)=>!c||u.isCloning||e.onValidate(Sn.concat(l.getPath(x),v),b,w,A)===!0,d=(x,v,b,w)=>{!fv(l,e,v)&&!(o&&l.isDetached(x,n))&&f(l.getPath(x),v,b,w)},f=(x,v,b,w,A)=>{u.isCloning?u.update(x,v,w):t(Sn.concat(x,v),b,w,A)},m=x=>x&&(x[r]||x),p=(x,v,b,w)=>I_(x)||b==="constructor"||s&&!Ys.isHandledMethod(v,b)||fv(l,e,b)||l.isGetInvariant(v,b)||o&&l.isDetached(v,n)?x:(w===void 0&&(w=l.getPath(v)),l.getProxy(x,Sn.concat(w,b),g,r)),g={get(x,v,b){if(qc(v)){if(v===r||v===em)return x;if(v===Vw&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let w=tm(x)?Reflect.get(x,v):Reflect.get(x,v,b);return p(w,x,v)},set(x,v,b,w){b=m(b);let A=x[r]||x,T=A[v];if(i(T,b)&&v in x)return!0;let S=h(x,v,b,T);return S&&l.setProperty(A,v,b,w,T)?(d(x,v,x[v],T),!0):!S},defineProperty(x,v,b){if(!l.isSameDescriptor(b,x,v)){let w=x[v];h(x,v,b.value,w)&&l.defineProperty(x,v,b,w)&&d(x,v,b.value,w)}return!0},deleteProperty(x,v){if(!Reflect.has(x,v))return!0;let b=Reflect.get(x,v),w=h(x,v,void 0,b);return w&&l.deleteProperty(x,v,b)?(d(x,v,void 0,b),!0):!w},apply(x,v,b){let w=v[r]||v;if(l.isUnsubscribed)return Reflect.apply(x,w,b);if((a===!1||a!==!0&&!a.includes(x.name))&&Ys.isHandledType(w)){let A=Sn.initial(l.getPath(x)),T=Ys.isHandledMethod(w,x.name);u.start(w,A,b);let S=Reflect.apply(x,u.preferredThisArg(x,v,w),T?b.map(P=>m(P)):b),M=u.isChanged(w,i),C=u.stop();if(Ys.isHandledType(S)&&T&&(v instanceof Map&&x.name==="get"&&(A=Sn.concat(A,b[0])),S=l.getProxy(S,A,g)),M){let P={name:x.name,args:b,result:S},_=u.isCloning?Sn.initial(A):A,I=u.isCloning?Sn.last(A):"";h(Sn.get(n,_),I,w,C,P)?f(_,I,w,C,P):u.undo(w)}return(v instanceof Map||v instanceof Set)&&Uw(S)?kw(S,x,v,A,p):S}return Reflect.apply(x,v,b)}},y=l.getProxy(n,e.pathAsArray?[]:"",g);return t=t.bind(y),c&&(e.onValidate=e.onValidate.bind(y)),y};qw.target=n=>n&&n[em]||n;qw.unsubscribe=n=>n[Vw]||n;var Xw=qw;var Wj=typeof global=="object"&&global&&global.Object===Object&&global,mv=Wj;var qj=typeof self=="object"&&self&&self.Object===Object&&self,Xj=mv||qj||Function("return this")(),ti=Xj;var Yj=ti.Symbol,ji=Yj;var L_=Object.prototype,Kj=L_.hasOwnProperty,Qj=L_.toString,om=ji?ji.toStringTag:void 0;function Zj(n){var t=Kj.call(n,om),e=n[om];try{n[om]=void 0;var r=!0}catch{}var i=Qj.call(n);return r&&(t?n[om]=e:delete n[om]),i}var N_=Zj;var Jj=Object.prototype,$j=Jj.toString;function eH(n){return $j.call(n)}var B_=eH;var tH="[object Null]",rH="[object Undefined]",F_=ji?ji.toStringTag:void 0;function iH(n){return n==null?n===void 0?rH:tH:F_&&F_ in Object(n)?N_(n):B_(n)}var is=iH;function nH(n){return n!=null&&typeof n=="object"}var Zi=nH;var sH="[object Symbol]";function oH(n){return typeof n=="symbol"||Zi(n)&&is(n)==sH}var Co=oH;function aH(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var gv=aH;var lH=Array.isArray,Oi=lH;var cH=1/0,V_=ji?ji.prototype:void 0,U_=V_?V_.toString:void 0;function k_(n){if(typeof n=="string")return n;if(Oi(n))return gv(n,k_)+"";if(Co(n))return U_?U_.call(n):"";var t=n+"";return t=="0"&&1/n==-cH?"-0":t}var yv=k_;var uH=/\s/;function hH(n){for(var t=n.length;t--&&uH.test(n.charAt(t)););return t}var vv=hH;var dH=/^\s+/;function fH(n){return n&&n.slice(0,vv(n)+1).replace(dH,"")}var z_=fH;function pH(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var kr=pH;var G_=0/0,mH=/^[-+]0x[0-9a-f]+$/i,gH=/^0b[01]+$/i,yH=/^0o[0-7]+$/i,vH=parseInt;function xH(n){if(typeof n=="number")return n;if(Co(n))return G_;if(kr(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=kr(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=z_(n);var e=gH.test(n);return e||yH.test(n)?vH(n.slice(2),e?2:8):mH.test(n)?G_:+n}var Yw=xH;function bH(n){return n}var xv=bH;var SH="[object AsyncFunction]",wH="[object Function]",AH="[object GeneratorFunction]",EH="[object Proxy]";function TH(n){if(!kr(n))return!1;var t=is(n);return t==wH||t==AH||t==SH||t==EH}var bv=TH;var MH=ti["__core-js_shared__"],Sv=MH;var j_=function(){var n=/[^.]+$/.exec(Sv&&Sv.keys&&Sv.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function CH(n){return!!j_&&j_ in n}var H_=CH;var PH=Function.prototype,_H=PH.toString;function IH(n){if(n!=null){try{return _H.call(n)}catch{}try{return n+""}catch{}}return""}var _a=IH;var DH=/[\\^$.*+?()[\]{}|]/g,OH=/^\[object .+?Constructor\]$/,RH=Function.prototype,LH=Object.prototype,NH=RH.toString,BH=LH.hasOwnProperty,FH=RegExp("^"+NH.call(BH).replace(DH,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function VH(n){if(!kr(n)||H_(n))return!1;var t=bv(n)?FH:OH;return t.test(_a(n))}var W_=VH;function UH(n,t){return n?.[t]}var q_=UH;function kH(n,t){var e=q_(n,t);return W_(e)?e:void 0}var Ln=kH;var zH=Ln(ti,"WeakMap"),wv=zH;var X_=Object.create,GH=function(){function n(){}return function(t){if(!kr(t))return{};if(X_)return X_(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),Y_=GH;function jH(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var K_=jH;function HH(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var Q_=HH;var WH=800,qH=16,XH=Date.now;function YH(n){var t=0,e=0;return function(){var r=XH(),i=qH-(r-e);if(e=r,i>0){if(++t>=WH)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var Z_=YH;function KH(n){return function(){return n}}var J_=KH;var QH=function(){try{var n=Ln(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Dh=QH;var ZH=Dh?function(n,t){return Dh(n,"toString",{configurable:!0,enumerable:!1,value:J_(t),writable:!0})}:xv,$_=ZH;var JH=Z_($_),e2=JH;function $H(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var t2=$H;function eW(n,t,e,r){for(var i=n.length,s=e+(r?1:-1);r?s--:++s<i;)if(t(n[s],s,n))return s;return-1}var r2=eW;function tW(n){return n!==n}var i2=tW;function rW(n,t,e){for(var r=e-1,i=n.length;++r<i;)if(n[r]===t)return r;return-1}var n2=rW;function iW(n,t,e){return t===t?n2(n,t,e):r2(n,i2,e)}var s2=iW;var nW=9007199254740991,sW=/^(?:0|[1-9]\d*)$/;function oW(n,t){var e=typeof n;return t=t??nW,!!t&&(e=="number"||e!="symbol"&&sW.test(n))&&n>-1&&n%1==0&&n<t}var Oh=oW;function aW(n,t,e){t=="__proto__"&&Dh?Dh(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Av=aW;function lW(n,t){return n===t||n!==n&&t!==t}var Rh=lW;var cW=Object.prototype,uW=cW.hasOwnProperty;function hW(n,t,e){var r=n[t];(!(uW.call(n,t)&&Rh(r,e))||e===void 0&&!(t in n))&&Av(n,t,e)}var Lh=hW;function dW(n,t,e,r){var i=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=r?r(e[a],n[a],a,e,n):void 0;l===void 0&&(l=n[a]),i?Av(e,a,l):Lh(e,a,l)}return e}var Po=dW;var o2=Math.max;function fW(n,t,e){return t=o2(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,s=o2(r.length-t,0),o=Array(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=e(o),K_(n,this,a)}}var a2=fW;var pW=9007199254740991;function mW(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=pW}var Nh=mW;function gW(n){return n!=null&&Nh(n.length)&&!bv(n)}var Ev=gW;var yW=Object.prototype;function vW(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||yW;return n===e}var Bh=vW;function xW(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var l2=xW;var bW="[object Arguments]";function SW(n){return Zi(n)&&is(n)==bW}var Kw=SW;var c2=Object.prototype,wW=c2.hasOwnProperty,AW=c2.propertyIsEnumerable,EW=Kw(function(){return arguments}())?Kw:function(n){return Zi(n)&&wW.call(n,"callee")&&!AW.call(n,"callee")},Fh=EW;function TW(){return!1}var u2=TW;var f2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,h2=f2&&typeof module=="object"&&module&&!module.nodeType&&module,MW=h2&&h2.exports===f2,d2=MW?ti.Buffer:void 0,CW=d2?d2.isBuffer:void 0,PW=CW||u2,Xc=PW;var _W="[object Arguments]",IW="[object Array]",DW="[object Boolean]",OW="[object Date]",RW="[object Error]",LW="[object Function]",NW="[object Map]",BW="[object Number]",FW="[object Object]",VW="[object RegExp]",UW="[object Set]",kW="[object String]",zW="[object WeakMap]",GW="[object ArrayBuffer]",jW="[object DataView]",HW="[object Float32Array]",WW="[object Float64Array]",qW="[object Int8Array]",XW="[object Int16Array]",YW="[object Int32Array]",KW="[object Uint8Array]",QW="[object Uint8ClampedArray]",ZW="[object Uint16Array]",JW="[object Uint32Array]",Br={};Br[HW]=Br[WW]=Br[qW]=Br[XW]=Br[YW]=Br[KW]=Br[QW]=Br[ZW]=Br[JW]=!0;Br[_W]=Br[IW]=Br[GW]=Br[DW]=Br[jW]=Br[OW]=Br[RW]=Br[LW]=Br[NW]=Br[BW]=Br[FW]=Br[VW]=Br[UW]=Br[kW]=Br[zW]=!1;function $W(n){return Zi(n)&&Nh(n.length)&&!!Br[is(n)]}var p2=$W;function e6(n){return function(t){return n(t)}}var Vh=e6;var m2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,am=m2&&typeof module=="object"&&module&&!module.nodeType&&module,t6=am&&am.exports===m2,Qw=t6&&mv.process,r6=function(){try{var n=am&&am.require&&am.require("util").types;return n||Qw&&Qw.binding&&Qw.binding("util")}catch{}}(),Ia=r6;var g2=Ia&&Ia.isTypedArray,i6=g2?Vh(g2):p2,Tv=i6;var n6=Object.prototype,s6=n6.hasOwnProperty;function o6(n,t){var e=Oi(n),r=!e&&Fh(n),i=!e&&!r&&Xc(n),s=!e&&!r&&!i&&Tv(n),o=e||r||i||s,a=o?l2(n.length,String):[],l=a.length;for(var c in n)(t||s6.call(n,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Oh(c,l)))&&a.push(c);return a}var Mv=o6;function a6(n,t){return function(e){return n(t(e))}}var Cv=a6;var l6=Cv(Object.keys,Object),y2=l6;var c6=Object.prototype,u6=c6.hasOwnProperty;function h6(n){if(!Bh(n))return y2(n);var t=[];for(var e in Object(n))u6.call(n,e)&&e!="constructor"&&t.push(e);return t}var v2=h6;function d6(n){return Ev(n)?Mv(n):v2(n)}var Uh=d6;function f6(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var x2=f6;var p6=Object.prototype,m6=p6.hasOwnProperty;function g6(n){if(!kr(n))return x2(n);var t=Bh(n),e=[];for(var r in n)r=="constructor"&&(t||!m6.call(n,r))||e.push(r);return e}var b2=g6;function y6(n){return Ev(n)?Mv(n,!0):b2(n)}var vs=y6;var v6=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,x6=/^\w*$/;function b6(n,t){if(Oi(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Co(n)?!0:x6.test(n)||!v6.test(n)||t!=null&&n in Object(t)}var S2=b6;var S6=Ln(Object,"create"),Da=S6;function w6(){this.__data__=Da?Da(null):{},this.size=0}var w2=w6;function A6(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var A2=A6;var E6="__lodash_hash_undefined__",T6=Object.prototype,M6=T6.hasOwnProperty;function C6(n){var t=this.__data__;if(Da){var e=t[n];return e===E6?void 0:e}return M6.call(t,n)?t[n]:void 0}var E2=C6;var P6=Object.prototype,_6=P6.hasOwnProperty;function I6(n){var t=this.__data__;return Da?t[n]!==void 0:_6.call(t,n)}var T2=I6;var D6="__lodash_hash_undefined__";function O6(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Da&&t===void 0?D6:t,this}var M2=O6;function kh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}kh.prototype.clear=w2;kh.prototype.delete=A2;kh.prototype.get=E2;kh.prototype.has=T2;kh.prototype.set=M2;var Zw=kh;function R6(){this.__data__=[],this.size=0}var C2=R6;function L6(n,t){for(var e=n.length;e--;)if(Rh(n[e][0],t))return e;return-1}var Ol=L6;var N6=Array.prototype,B6=N6.splice;function F6(n){var t=this.__data__,e=Ol(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():B6.call(t,e,1),--this.size,!0}var P2=F6;function V6(n){var t=this.__data__,e=Ol(t,n);return e<0?void 0:t[e][1]}var _2=V6;function U6(n){return Ol(this.__data__,n)>-1}var I2=U6;function k6(n,t){var e=this.__data__,r=Ol(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var D2=k6;function zh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}zh.prototype.clear=C2;zh.prototype.delete=P2;zh.prototype.get=_2;zh.prototype.has=I2;zh.prototype.set=D2;var Rl=zh;var z6=Ln(ti,"Map"),Ll=z6;function G6(){this.size=0,this.__data__={hash:new Zw,map:new(Ll||Rl),string:new Zw}}var O2=G6;function j6(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var R2=j6;function H6(n,t){var e=n.__data__;return R2(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Nl=H6;function W6(n){var t=Nl(this,n).delete(n);return this.size-=t?1:0,t}var L2=W6;function q6(n){return Nl(this,n).get(n)}var N2=q6;function X6(n){return Nl(this,n).has(n)}var B2=X6;function Y6(n,t){var e=Nl(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var F2=Y6;function Gh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Gh.prototype.clear=O2;Gh.prototype.delete=L2;Gh.prototype.get=N2;Gh.prototype.has=B2;Gh.prototype.set=F2;var Yc=Gh;var K6="Expected a function";function Jw(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(K6);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],s=e.cache;if(s.has(i))return s.get(i);var o=n.apply(this,r);return e.cache=s.set(i,o)||s,o};return e.cache=new(Jw.Cache||Yc),e}Jw.Cache=Yc;var V2=Jw;var Q6=500;function Z6(n){var t=V2(n,function(r){return e.size===Q6&&e.clear(),r}),e=t.cache;return t}var U2=Z6;var J6=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$6=/\\(\\)?/g,e8=U2(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(J6,function(e,r,i,s){t.push(i?s.replace($6,"$1"):r||e)}),t}),k2=e8;function t8(n){return n==null?"":yv(n)}var Pv=t8;function r8(n,t){return Oi(n)?n:S2(n,t)?[n]:k2(Pv(n))}var xs=r8;var i8=1/0;function n8(n){if(typeof n=="string"||Co(n))return n;var t=n+"";return t=="0"&&1/n==-i8?"-0":t}var Bl=n8;function s8(n,t){t=xs(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[Bl(t[e++])];return e&&e==r?n:void 0}var _v=s8;function o8(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var jh=o8;var z2=ji?ji.isConcatSpreadable:void 0;function a8(n){return Oi(n)||Fh(n)||!!(z2&&n&&n[z2])}var G2=a8;function j2(n,t,e,r,i){var s=-1,o=n.length;for(e||(e=G2),i||(i=[]);++s<o;){var a=n[s];t>0&&e(a)?t>1?j2(a,t-1,e,r,i):jh(i,a):r||(i[i.length]=a)}return i}var H2=j2;function l8(n){var t=n==null?0:n.length;return t?H2(n,1):[]}var W2=l8;function c8(n){return e2(a2(n,void 0,W2),n+"")}var Iv=c8;var u8=Cv(Object.getPrototypeOf,Object),Hh=u8;var h8="[object Object]",d8=Function.prototype,f8=Object.prototype,q2=d8.toString,p8=f8.hasOwnProperty,m8=q2.call(Object);function g8(n){if(!Zi(n)||is(n)!=h8)return!1;var t=Hh(n);if(t===null)return!0;var e=p8.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&q2.call(e)==m8}var X2=g8;function y8(n,t,e){var r=-1,i=n.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(i);++r<i;)s[r]=n[r+t];return s}var Dv=y8;function v8(n,t,e){var r=n.length;return e=e===void 0?r:e,!t&&e>=r?n:Dv(n,t,e)}var Y2=v8;var x8="\\ud800-\\udfff",b8="\\u0300-\\u036f",S8="\\ufe20-\\ufe2f",w8="\\u20d0-\\u20ff",A8=b8+S8+w8,E8="\\ufe0e\\ufe0f",T8="\\u200d",M8=RegExp("["+T8+x8+A8+E8+"]");function C8(n){return M8.test(n)}var K2=C8;function P8(n){return n.split("")}var Q2=P8;var Z2="\\ud800-\\udfff",_8="\\u0300-\\u036f",I8="\\ufe20-\\ufe2f",D8="\\u20d0-\\u20ff",O8=_8+I8+D8,R8="\\ufe0e\\ufe0f",L8="["+Z2+"]",$w="["+O8+"]",eA="\\ud83c[\\udffb-\\udfff]",N8="(?:"+$w+"|"+eA+")",J2="[^"+Z2+"]",$2="(?:\\ud83c[\\udde6-\\uddff]){2}",eI="[\\ud800-\\udbff][\\udc00-\\udfff]",B8="\\u200d",tI=N8+"?",rI="["+R8+"]?",F8="(?:"+B8+"(?:"+[J2,$2,eI].join("|")+")"+rI+tI+")*",V8=rI+tI+F8,U8="(?:"+[J2+$w+"?",$w,$2,eI,L8].join("|")+")",k8=RegExp(eA+"(?="+eA+")|"+U8+V8,"g");function z8(n){return n.match(k8)||[]}var iI=z8;function G8(n){return K2(n)?iI(n):Q2(n)}var tA=G8;function j8(){this.__data__=new Rl,this.size=0}var nI=j8;function H8(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var sI=H8;function W8(n){return this.__data__.get(n)}var oI=W8;function q8(n){return this.__data__.has(n)}var aI=q8;var X8=200;function Y8(n,t){var e=this.__data__;if(e instanceof Rl){var r=e.__data__;if(!Ll||r.length<X8-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Yc(r)}return e.set(n,t),this.size=e.size,this}var lI=Y8;function Wh(n){var t=this.__data__=new Rl(n);this.size=t.size}Wh.prototype.clear=nI;Wh.prototype.delete=sI;Wh.prototype.get=oI;Wh.prototype.has=aI;Wh.prototype.set=lI;var qh=Wh;function K8(n,t){return n&&Po(t,Uh(t),n)}var cI=K8;function Q8(n,t){return n&&Po(t,vs(t),n)}var uI=Q8;var pI=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hI=pI&&typeof module=="object"&&module&&!module.nodeType&&module,Z8=hI&&hI.exports===pI,dI=Z8?ti.Buffer:void 0,fI=dI?dI.allocUnsafe:void 0;function J8(n,t){if(t)return n.slice();var e=n.length,r=fI?fI(e):new n.constructor(e);return n.copy(r),r}var mI=J8;function $8(n,t){for(var e=-1,r=n==null?0:n.length,i=0,s=[];++e<r;){var o=n[e];t(o,e,n)&&(s[i++]=o)}return s}var gI=$8;function e9(){return[]}var Ov=e9;var t9=Object.prototype,r9=t9.propertyIsEnumerable,yI=Object.getOwnPropertySymbols,i9=yI?function(n){return n==null?[]:(n=Object(n),gI(yI(n),function(t){return r9.call(n,t)}))}:Ov,Xh=i9;function n9(n,t){return Po(n,Xh(n),t)}var vI=n9;var s9=Object.getOwnPropertySymbols,o9=s9?function(n){for(var t=[];n;)jh(t,Xh(n)),n=Hh(n);return t}:Ov,Rv=o9;function a9(n,t){return Po(n,Rv(n),t)}var xI=a9;function l9(n,t,e){var r=t(n);return Oi(n)?r:jh(r,e(n))}var Lv=l9;function c9(n){return Lv(n,Uh,Xh)}var lm=c9;function u9(n){return Lv(n,vs,Rv)}var Nv=u9;var h9=Ln(ti,"DataView"),Bv=h9;var d9=Ln(ti,"Promise"),Fv=d9;var f9=Ln(ti,"Set"),Vv=f9;var bI="[object Map]",p9="[object Object]",SI="[object Promise]",wI="[object Set]",AI="[object WeakMap]",EI="[object DataView]",m9=_a(Bv),g9=_a(Ll),y9=_a(Fv),v9=_a(Vv),x9=_a(wv),Kc=is;(Bv&&Kc(new Bv(new ArrayBuffer(1)))!=EI||Ll&&Kc(new Ll)!=bI||Fv&&Kc(Fv.resolve())!=SI||Vv&&Kc(new Vv)!=wI||wv&&Kc(new wv)!=AI)&&(Kc=function(n){var t=is(n),e=t==p9?n.constructor:void 0,r=e?_a(e):"";if(r)switch(r){case m9:return EI;case g9:return bI;case y9:return SI;case v9:return wI;case x9:return AI}return t});var Oa=Kc;var b9=Object.prototype,S9=b9.hasOwnProperty;function w9(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&S9.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var TI=w9;var A9=ti.Uint8Array,Yh=A9;function E9(n){var t=new n.constructor(n.byteLength);return new Yh(t).set(new Yh(n)),t}var Kh=E9;function T9(n,t){var e=t?Kh(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var MI=T9;var M9=/\w*$/;function C9(n){var t=new n.constructor(n.source,M9.exec(n));return t.lastIndex=n.lastIndex,t}var CI=C9;var PI=ji?ji.prototype:void 0,_I=PI?PI.valueOf:void 0;function P9(n){return _I?Object(_I.call(n)):{}}var II=P9;function _9(n,t){var e=t?Kh(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var DI=_9;var I9="[object Boolean]",D9="[object Date]",O9="[object Map]",R9="[object Number]",L9="[object RegExp]",N9="[object Set]",B9="[object String]",F9="[object Symbol]",V9="[object ArrayBuffer]",U9="[object DataView]",k9="[object Float32Array]",z9="[object Float64Array]",G9="[object Int8Array]",j9="[object Int16Array]",H9="[object Int32Array]",W9="[object Uint8Array]",q9="[object Uint8ClampedArray]",X9="[object Uint16Array]",Y9="[object Uint32Array]";function K9(n,t,e){var r=n.constructor;switch(t){case V9:return Kh(n);case I9:case D9:return new r(+n);case U9:return MI(n,e);case k9:case z9:case G9:case j9:case H9:case W9:case q9:case X9:case Y9:return DI(n,e);case O9:return new r;case R9:case B9:return new r(n);case L9:return CI(n);case N9:return new r;case F9:return II(n)}}var OI=K9;function Q9(n){return typeof n.constructor=="function"&&!Bh(n)?Y_(Hh(n)):{}}var RI=Q9;var Z9="[object Map]";function J9(n){return Zi(n)&&Oa(n)==Z9}var LI=J9;var NI=Ia&&Ia.isMap,$9=NI?Vh(NI):LI,BI=$9;var eq="[object Set]";function tq(n){return Zi(n)&&Oa(n)==eq}var FI=tq;var VI=Ia&&Ia.isSet,rq=VI?Vh(VI):FI,UI=rq;var iq=1,nq=2,sq=4,kI="[object Arguments]",oq="[object Array]",aq="[object Boolean]",lq="[object Date]",cq="[object Error]",zI="[object Function]",uq="[object GeneratorFunction]",hq="[object Map]",dq="[object Number]",GI="[object Object]",fq="[object RegExp]",pq="[object Set]",mq="[object String]",gq="[object Symbol]",yq="[object WeakMap]",vq="[object ArrayBuffer]",xq="[object DataView]",bq="[object Float32Array]",Sq="[object Float64Array]",wq="[object Int8Array]",Aq="[object Int16Array]",Eq="[object Int32Array]",Tq="[object Uint8Array]",Mq="[object Uint8ClampedArray]",Cq="[object Uint16Array]",Pq="[object Uint32Array]",Rr={};Rr[kI]=Rr[oq]=Rr[vq]=Rr[xq]=Rr[aq]=Rr[lq]=Rr[bq]=Rr[Sq]=Rr[wq]=Rr[Aq]=Rr[Eq]=Rr[hq]=Rr[dq]=Rr[GI]=Rr[fq]=Rr[pq]=Rr[mq]=Rr[gq]=Rr[Tq]=Rr[Mq]=Rr[Cq]=Rr[Pq]=!0;Rr[cq]=Rr[zI]=Rr[yq]=!1;function Uv(n,t,e,r,i,s){var o,a=t&iq,l=t&nq,c=t&sq;if(e&&(o=i?e(n,r,i,s):e(n)),o!==void 0)return o;if(!kr(n))return n;var u=Oi(n);if(u){if(o=TI(n),!a)return Q_(n,o)}else{var h=Oa(n),d=h==zI||h==uq;if(Xc(n))return mI(n,a);if(h==GI||h==kI||d&&!i){if(o=l||d?{}:RI(n),!a)return l?xI(n,uI(o,n)):vI(n,cI(o,n))}else{if(!Rr[h])return i?n:{};o=OI(n,h,a)}}s||(s=new qh);var f=s.get(n);if(f)return f;s.set(n,o),UI(n)?n.forEach(function(g){o.add(Uv(g,t,e,g,n,s))}):BI(n)&&n.forEach(function(g,y){o.set(y,Uv(g,t,e,y,n,s))});var m=c?l?Nv:lm:l?vs:Uh,p=u?void 0:m(n);return t2(p||n,function(g,y){p&&(y=g,g=n[y]),Lh(o,y,Uv(g,t,e,y,n,s))}),o}var kv=Uv;var _q=1,Iq=4;function Dq(n){return kv(n,_q|Iq)}var Ra=Dq;var Oq="__lodash_hash_undefined__";function Rq(n){return this.__data__.set(n,Oq),this}var jI=Rq;function Lq(n){return this.__data__.has(n)}var HI=Lq;function zv(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new Yc;++t<e;)this.add(n[t])}zv.prototype.add=zv.prototype.push=jI;zv.prototype.has=HI;var WI=zv;function Nq(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var qI=Nq;function Bq(n,t){return n.has(t)}var XI=Bq;var Fq=1,Vq=2;function Uq(n,t,e,r,i,s){var o=e&Fq,a=n.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var c=s.get(n),u=s.get(t);if(c&&u)return c==t&&u==n;var h=-1,d=!0,f=e&Vq?new WI:void 0;for(s.set(n,t),s.set(t,n);++h<a;){var m=n[h],p=t[h];if(r)var g=o?r(p,m,h,t,n,s):r(m,p,h,n,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!qI(t,function(y,x){if(!XI(f,x)&&(m===y||i(m,y,e,r,s)))return f.push(x)})){d=!1;break}}else if(!(m===p||i(m,p,e,r,s))){d=!1;break}}return s.delete(n),s.delete(t),d}var Gv=Uq;function kq(n){var t=-1,e=Array(n.size);return n.forEach(function(r,i){e[++t]=[i,r]}),e}var YI=kq;function zq(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var KI=zq;var Gq=1,jq=2,Hq="[object Boolean]",Wq="[object Date]",qq="[object Error]",Xq="[object Map]",Yq="[object Number]",Kq="[object RegExp]",Qq="[object Set]",Zq="[object String]",Jq="[object Symbol]",$q="[object ArrayBuffer]",e7="[object DataView]",QI=ji?ji.prototype:void 0,rA=QI?QI.valueOf:void 0;function t7(n,t,e,r,i,s,o){switch(e){case e7:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case $q:return!(n.byteLength!=t.byteLength||!s(new Yh(n),new Yh(t)));case Hq:case Wq:case Yq:return Rh(+n,+t);case qq:return n.name==t.name&&n.message==t.message;case Kq:case Zq:return n==t+"";case Xq:var a=YI;case Qq:var l=r&Gq;if(a||(a=KI),n.size!=t.size&&!l)return!1;var c=o.get(n);if(c)return c==t;r|=jq,o.set(n,t);var u=Gv(a(n),a(t),r,i,s,o);return o.delete(n),u;case Jq:if(rA)return rA.call(n)==rA.call(t)}return!1}var ZI=t7;var r7=1,i7=Object.prototype,n7=i7.hasOwnProperty;function s7(n,t,e,r,i,s){var o=e&r7,a=lm(n),l=a.length,c=lm(t),u=c.length;if(l!=u&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:n7.call(t,d)))return!1}var f=s.get(n),m=s.get(t);if(f&&m)return f==t&&m==n;var p=!0;s.set(n,t),s.set(t,n);for(var g=o;++h<l;){d=a[h];var y=n[d],x=t[d];if(r)var v=o?r(x,y,d,t,n,s):r(y,x,d,n,t,s);if(!(v===void 0?y===x||i(y,x,e,r,s):v)){p=!1;break}g||(g=d=="constructor")}if(p&&!g){var b=n.constructor,w=t.constructor;b!=w&&"constructor"in n&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(p=!1)}return s.delete(n),s.delete(t),p}var JI=s7;var o7=1,$I="[object Arguments]",eD="[object Array]",jv="[object Object]",a7=Object.prototype,tD=a7.hasOwnProperty;function l7(n,t,e,r,i,s){var o=Oi(n),a=Oi(t),l=o?eD:Oa(n),c=a?eD:Oa(t);l=l==$I?jv:l,c=c==$I?jv:c;var u=l==jv,h=c==jv,d=l==c;if(d&&Xc(n)){if(!Xc(t))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new qh),o||Tv(n)?Gv(n,t,e,r,i,s):ZI(n,t,l,e,r,i,s);if(!(e&o7)){var f=u&&tD.call(n,"__wrapped__"),m=h&&tD.call(t,"__wrapped__");if(f||m){var p=f?n.value():n,g=m?t.value():t;return s||(s=new qh),i(p,g,e,r,s)}}return d?(s||(s=new qh),JI(n,t,e,r,i,s)):!1}var rD=l7;function iD(n,t,e,r,i){return n===t?!0:n==null||t==null||!Zi(n)&&!Zi(t)?n!==n&&t!==t:rD(n,t,e,r,iD,i)}var nD=iD;function c7(n,t){return n!=null&&t in Object(n)}var sD=c7;function u7(n,t,e){t=xs(t,n);for(var r=-1,i=t.length,s=!1;++r<i;){var o=Bl(t[r]);if(!(s=n!=null&&e(n,o)))break;n=n[o]}return s||++r!=i?s:(i=n==null?0:n.length,!!i&&Nh(i)&&Oh(o,i)&&(Oi(n)||Fh(n)))}var oD=u7;function h7(n,t){return n!=null&&oD(n,t,sD)}var aD=h7;var d7=function(){return ti.Date.now()},Hv=d7;var f7="Expected a function",p7=Math.max,m7=Math.min;function g7(n,t,e){var r,i,s,o,a,l,c=0,u=!1,h=!1,d=!0;if(typeof n!="function")throw new TypeError(f7);t=Yw(t)||0,kr(e)&&(u=!!e.leading,h="maxWait"in e,s=h?p7(Yw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(A){var T=r,S=i;return r=i=void 0,c=A,o=n.apply(S,T),o}function m(A){return c=A,a=setTimeout(y,t),u?f(A):o}function p(A){var T=A-l,S=A-c,M=t-T;return h?m7(M,s-S):M}function g(A){var T=A-l,S=A-c;return l===void 0||T>=t||T<0||h&&S>=s}function y(){var A=Hv();if(g(A))return x(A);a=setTimeout(y,p(A))}function x(A){return a=void 0,d&&r?f(A):(r=i=void 0,o)}function v(){a!==void 0&&clearTimeout(a),c=0,r=l=i=a=void 0}function b(){return a===void 0?o:x(Hv())}function w(){var A=Hv(),T=g(A);if(r=arguments,i=this,l=A,T){if(a===void 0)return m(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=v,w.flush=b,w}var _o=g7;function y7(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var lD=y7;function v7(n,t){return n>t}var cD=v7;function x7(n,t){return t.length<2?n:_v(n,Dv(t,0,-1))}var uD=x7;function b7(n,t){return nD(n,t)}var Qc=b7;function S7(n,t,e){for(var r=-1,i=n.length;++r<i;){var s=n[r],o=t(s);if(o!=null&&(a===void 0?o===o&&!Co(o):e(o,a)))var a=o,l=s}return l}var hD=S7;function w7(n){return n&&n.length?hD(n,xv,cD):void 0}var iA=w7;function A7(n,t){return t=xs(t,n),n=uD(n,t),n==null||delete n[Bl(lD(t))]}var dD=A7;function E7(n){return X2(n)?void 0:n}var fD=E7;var T7=1,M7=2,C7=4,P7=Iv(function(n,t){var e={};if(n==null)return e;var r=!1;t=gv(t,function(s){return s=xs(s,n),r||(r=s.length>1),s}),Po(n,Nv(n),e),r&&(e=kv(e,T7|M7|C7,fD));for(var i=t.length;i--;)dD(e,t[i]);return e}),Qh=P7;function _7(n,t,e,r){if(!kr(n))return n;t=xs(t,n);for(var i=-1,s=t.length,o=s-1,a=n;a!=null&&++i<s;){var l=Bl(t[i]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(i!=o){var u=a[l];c=r?r(u,l,a):void 0,c===void 0&&(c=kr(u)?u:Oh(t[i+1])?[]:{})}Lh(a,l,c),a=a[l]}return n}var pD=_7;function I7(n,t,e){for(var r=-1,i=t.length,s={};++r<i;){var o=t[r],a=_v(n,o);e(a,o)&&pD(s,xs(o,n),a)}return s}var mD=I7;function D7(n,t){return mD(n,t,function(e,r){return aD(n,r)})}var gD=D7;var O7=Iv(function(n,t){return n==null?{}:gD(n,t)}),Nn=O7;var R7="Expected a function";function L7(n,t,e){var r=!0,i=!0;if(typeof n!="function")throw new TypeError(R7);return kr(e)&&(r="leading"in e?!!e.leading:r,i="trailing"in e?!!e.trailing:i),_o(n,t,{leading:r,maxWait:t,trailing:i})}var nA=L7;function N7(n,t){for(var e=n.length;e--&&s2(t,n[e],0)>-1;);return e}var yD=N7;function B7(n,t,e){if(n=Pv(n),n&&(e||t===void 0))return n.slice(0,vv(n)+1);if(!n||!(t=yv(t)))return n;var r=tA(n),i=yD(r,tA(t))+1;return Y2(r,0,i).join("")}var sA=B7;function Wv(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function Ri(n,t){return Object.setPrototypeOf(n,t),n}var F7=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),V7=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),U7=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Zh&&"ontouchend"in document,k7=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,z7=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,G7=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(t)},j7=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},H7=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},oA=F7(),Bde=oA?H7():void 0,Zh=V7(),bs=U7(),vD=k7(),Li=z7(),aA=G7(),xD=Number(j7());function qv(n){return Array.isArray(n)?n:[n]}function Xv(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}function cm(n){return Zh?n.metaKey:n.ctrlKey}function bD(n){return n.wheelDeltaY===0||n.deltaY===0?Zh&&n.shiftKey&&Math.abs(n.wheelDeltaX)>=120?!1:n.wheelDeltaX?n.wheelDeltaX===-3*n.deltaX||n.wheelDeltaX===-3*window.devicePixelRatio*n.deltaX:n.deltaMode===0:n.wheelDeltaY?n.wheelDeltaY===-3*n.deltaY||n.wheelDeltaY===-3*window.devicePixelRatio*n.deltaY:n.deltaMode===0}var et=[],Kv={},um={},Yv={};function SD(n){et.includes(n)||et.push(n)}function Jh(n){delete Kv[n.pointerId];for(let t=0;t<et.length;t++)if(et[t].pointerId===n.pointerId){et.splice(t,1);break}}function wD(){et.splice(0,et.length)}function Qv(n){if(n.pointerType!=="touch")return;let t=Kv[n.pointerId];t===void 0&&(t={x:0,y:0},Kv[n.pointerId]=t),t.x=n.pageX,t.y=n.pageY}function Zv(n){let t=n.pointerId===et[0].pointerId?et[1]:et[0];return Kv[t.pointerId]}function AD(n){um[n.key]=!0,Yv[n.key]=Yv[n.key]===void 0?1:Yv[n.key]+1}function ED(n){if(Zh&&um.Meta)for(let t in um)um[t]=!1;else um[n.key]=!1;Yv={}}function TD(n){n.addEventListener("pointerdown",SD,!0),n.addEventListener("pointerdown",Qv,!0),n.addEventListener("pointermove",Qv,!0),n.addEventListener("pointerup",Jh,!0),n.addEventListener("pointercancel",Jh,!0),n.addEventListener("pointerleave",Jh,!0),window.addEventListener("keydown",AD,!0),window.addEventListener("keyup",ED,!0)}function MD(n){n.removeEventListener("pointerdown",SD,!0),n.removeEventListener("pointerdown",Qv,!0),n.removeEventListener("pointermove",Qv,!0),n.removeEventListener("pointerup",Jh,!0),n.removeEventListener("pointercancel",Jh,!0),n.removeEventListener("pointerleave",Jh,!0),window.removeEventListener("keydown",AD,!0),window.removeEventListener("keyup",ED,!0)}var CD,PD=new Promise(n=>{CD=n});var Jv;function _D(n){if(Jv)return Jv;async function t(){let r=n??(!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@1.12.47/build"),s=import("./navmesh.js"),[o,a]=await Promise.all([s,fetch(`${r}/navmesh.wasm`).then(u=>u.arrayBuffer())]),l=o.default,c=await l({wasmBinary:a});CD(c)}return Jv=t(),Jv}var ID,DD=new Promise(n=>{ID=n});var $v;function OD(){if($v)return $v;async function n(){let e=await import("./physics.js");await e.init(),ID(e)}return $v=n(),$v}var He=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let s={...r,[t]:e};return Object.setPrototypeOf(s,He.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],i;r===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,He.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:r}=t,i=e[r];if(i===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,He.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:i}}}}return null}};function hm(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&hm(r)}return Object.freeze(n)}function RD(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var $h=class extends Error{};function e0(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function Io(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let s=n;n=t,t=s}let r=[],i=1/(e+1);for(let s=0;s<e;s++){let o=n+(t-n)*(s+.75+Math.random()*.5)*i;r.push(o)}return r}function ed(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function LD(){return typeof process<"u"}function ND(n,t){for(let e of n)t(e.id,e.data)!==!0&&ND(e.children,t)}function BD(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)BD(e,t)}var wr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,wr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)hm(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);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,r){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===r)return!0;e=i}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let i=this.parent(e);if(i===r)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,r){if(e===null)this.traverse(r);else{let i=this.get(e);i&&BD(i,r)}}traverse(e){ND(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(e,r){let i=e,s=r;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let c=s.findIndex(u=>u.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,wr.prototype);let o=s;return o.fillCaches(),o}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:r}){if(this.get(e)!==void 0)return!0;for(let i of r)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:r,fi:i,id:s,data:o,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:i,id:s,data:o,children:a};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(c=>c.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:r,fi:i,id:s}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new $h("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(f=>f.id===s);l=[...l];let u=l.splice(c,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=u.fi;return u={...u,fi:i},l=[...l,u],l.sort((f,m)=>f.fi-m.fi),e.localIndex=l.indexOf(u),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,r){if(r===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(e)){if(s.id===r)return i;i=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===e)+1;if(s<i.length)return i[s].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(i[s].id):r}}getAllSorted(e){let r=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&r.push({...i,...s})}r.sort((i,s)=>RD(i.sortKey,s.sortKey));for(let i of r)delete i.sortKey;return r}getWithSortKey(e){var r=e;let i=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)i.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:i}}}insertBeforeHelper(e,r,i){return this.insertAfterHelper(e,this.previous(e,r),i)}insertAfterHelper(e,r,i){let s=this.childrenArray(e);if(r===null){if(s.length===0)return Io(0,i,i);{let o=s[0].fi;return Io(o-i,o,i)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Io(l,l+i,i)}else return Io(o.fi,a.fi,i)}}};var td;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let i=r.props,s={},o=[...e],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=i[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let i=r.props,s={},o={...e},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let c=i[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=n})(td||(td={}));var Re=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Re.prototype)}deepFreeze(){let e=0;for(;e<this.length;)hm(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(c=>c.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,Re.prototype);let r=e;return LD()||r.fillCaches(),r}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:r,id:i,data:s}=e,o=this,a={fi:r,id:i,data:s};return o=[...o,a],o.sort((c,u)=>c.fi-u.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:r}=e,i=this,s=i.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:i}=e,s=this;s=[...s];let o=s.findIndex(u=>u.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((u,h)=>u.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),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 r=null;for(let i of this){if(i.id===e)return r;r=i.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let i=this;if(e===null){if(i.length===0)return Io(0,r,r);{let s=i[0].fi;return Io(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return Io(a,a+r,r)}else return Io(s.fi,o.fi,r)}}};function rd(n){return n&&typeof n=="object"&&n instanceof lr}var lr=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,i=0,s={};for(;i<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[i]],r!==void 0&&!rd(r))return null;i+=1}r=r?e0(r):new lr;for(let[l,c]of Object.entries(t.props)){let u=r[l];s[l]=u,c===void 0?delete r[l]:r[l]=c}for(;i>0;){if(Object.keys(r).length===0){let l=e[i-1];l&&(r=e0(l),delete r[t.path[i-1]])}else{let l=e[i-1];if(l){let c=e0(l);c[t.path[i-1]]=r,r=c}else{let c=new lr;c[t.path[i-1]]=r,r=c}}i-=1}let o=Object.setPrototypeOf(r,lr.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Do;(r=>{function n(i,s){return dm(i,s)??i}r.apply=n;function t(i,s){return cA(i,s)}r.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o<a.length&&l!==void 0;){if(l=Mr.zoomOnce(l,a[o]),l===void 0)return s;if(!rd(l))return;o+=1}if(l===void 0)return s;if(!!rd(l))if(s.type===0){let c={...s.props};for(let u of Object.keys(l))delete c[u];return{...s,props:c}}else if(s.type===1||s.type===4||s.type===7){let c=lA([s],l);return c?c[0]:s}else return s}r.filterOp=e})(Do||(Do={}));function lA(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=dm(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=lA(i.children,t);return a!==void 0?e=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(e)return r}function W7(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=dm(i.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function dm(n,t){if(!rd(t))return t;if(n instanceof wr){let e=lA(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof Re)return W7(n,t);if(Array.isArray(n)){let e=!1,r=n.map((i,s)=>{let o=dm(i,t[s]);return e=e||o!==void 0,o===void 0&&(o=i),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof lr)return cA(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[i,s]of Object.entries(n)){let o=dm(s,t[i]);r=r||o!==void 0,o===void 0&&(o=s),e[i]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function cA(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!rd(t))return t;if(!rd(n))return Do.apply(n,t);let e=new Set;for(let i of Object.keys(n))e.add(i);for(let i of Object.keys(t))e.add(i);let r=new lr;for(let i of e){let s=cA(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=s}return r}function FD(n,t){let e={cur:[],result:[],len:0};return n=fm(n,t,e)??n,[n,e.result]}function t0(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function r0(n){n&&(n.len-=1)}function q7(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function VD(n,t,e){let r=!1,i=n.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=fm(s.data,t,t0(e,o));r0(e),r=r||l!==void 0,l===void 0&&(l=s.data);let c=VD(s.children,t,e);return c!==void 0?r=!0:c=s.children,{...s,id:o,data:l,children:c}});if(r)return i}function X7(n,t,e){let r=!1,i=n.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=fm(s.data,t,t0(e,o));return r0(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i}function fm(n,t,e){if(n instanceof wr){let r=VD(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof Re)return X7(n,t,e);if(Array.isArray(n)){let r=!1,i=n.map((s,o)=>{let a=fm(s,t,t0(e,o));return r0(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i):void 0}else if(n&&typeof n=="object"&&!ed(n)){let r={},i=!1;for(let[s,o]of Object.entries(n))if(s!=="name"&&s!=="variableId"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");i=!0,s=a}let l=fm(o,t,t0(e,s));r0(e),i=i||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&q7(e),r}else return}}var id;(t=>{function n(e,r){let i=Mr.zoom(r,e.path);if(typeof i=="object"){let s={};for(let o of Object.keys(e.props))s[o]=i[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=n})(id||(id={}));var zr;(a=>{function n(l,c){return{...l,path:l.path.slice(c)}}a.drop=n;function t(l,c){return e(l,c)?.data??l}a.applySimple=t;function e(l,c){let u=c.path;for(var h=[];;){let d;if(l instanceof lr&&c.type===0&&(d=l.runOp({...c,path:u.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===u.length&&(l instanceof wr||l instanceof Re||l instanceof He?d=l.runOp(c):d=td.runOp(l,c)),d!==void 0)if(d!==null){let p=d.data;for(let g=h.length-1;g>=0;g--){let y=u[g],x=h[g];if(x instanceof wr){if(typeof y=="number")throw new Error("illegal arg");p=x.modifyById(y,p)}else if(x instanceof Re){if(typeof y=="number")throw new Error("illegal arg");p=x.modifyById(y,p)}else if(x instanceof He){if(typeof y=="number")throw new Error("illegal arg");p=x.modifyById(y,p)}else if(x instanceof lr){let v={...x,[y]:p};p=Object.setPrototypeOf(v,lr.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let v=p;p=[...x],p[y]=v}else p={...x,[y]:p};else return null}return{data:p,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[h.length],m;if(l instanceof wr){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else if(l instanceof Re){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else l!==null&&(m=l[f]);if(m!==void 0)h.push(l),l=m;else return null}}a.apply=e;function r(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}a.pathDisjoint=r;function i(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}a.pathEq=i;function s(l,c){return r(l.path,c.path)}a.commutative=s;function o(l,c){return l.type===0&&c.type===0&&i(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}a.subsumed=o})(zr||(zr={}));var pm;(l=>{function n(){return[]}l.empty=n;function t(c,u){let h=[];for(let d of c){let[f,...m]=d.path;f===u&&h.push({...d,path:m})}return h}l.removePrefix=t;function e(c,u){return c.map(h=>({...h,path:[u,...h.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function i(c,u){return[...c.filter(d=>!u.some(f=>zr.subsumed(d,f))),...u]}l.compress=i;function s(c,u){return c.every(h=>u.every(d=>zr.commutative(h,d)))}l.commutative=s;function o(c,u){for(let h of u){let d=a(c,h);d!==null&&(c=d.data)}return c}l.applyAll=o;function a(c,u){var h=c;let d=[],f=[];for(let m of u)try{if(m.type===3||m.type===5&&m.path[m.path.length-1]==="variables"){let p,g,y;if(m.type===3?(p=Mr.zoom(h,[...m.path,m.id]),y=zr.apply(h,{...m,type:2})):(p=Mr.zoom(h,[...m.path,m.id,"value"]),y=zr.apply(h,m)),y!==null){h=y.data;let[x,v]=FD(h,{[m.id]:p});h=x;for(let b=0;b<v.length;b++){let w=v[b],A=w.pop();if(typeof A=="number"){let T=[A];for(let M=b+1;M<v.length;M++){let C=v[M],P=C[C.length-1];if(typeof P=="number"&&Mr.equal(w,C.slice(0,C.length-1)))T.push(P),v.splice(M,1);else break}let S=Mr.zoom(h,w);g=S.map((M,C)=>T.includes(C)?m.id:M),p=S,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){p/=100;let T=p,S=Mr.zoom(h,w.slice(0,w.length-2)),M=S.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:T}}:C);Object.setPrototypeOf(M,Object.getPrototypeOf(S.layers)),S.layers=M}g=m.id}d.push({type:0,path:w,props:{[A]:p}}),f.push({type:0,path:w,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let p=zr.apply(h,m);p!==null&&(d.push(p.actual),h=p.data,f.push(p.reverse))}}catch(p){if(p instanceof $h)return null;throw p}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(pm||(pm={}));var UD=Symbol(),Y7=Symbol(),n0=Symbol(),Zc=class{reportOp(t,e,r=[]){let i=this;if(e===null)return;i._current=e.data;let s=r;for(;!(i instanceof i0);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[n0];r&&r(),delete this._children[t]}}}},hA=class extends Zc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else if(this._current instanceof lr){let r={...this._current,[t]:e};this._current=Object.setPrototypeOf(r,lr.prototype)}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,td.runOp(this._current,t),t.path)}},dA=class extends Zc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,He.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},kD={get(n,t){if(t===n0)return()=>{n._parent=null};if(t===UD)return n._current;if(t===Y7)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e[t],o=s0(n,t,s);return o!==s?(r===void 0&&(r={},n._children=r),r[t]=o,o):s},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},K7={...kD,set(n,t,e){let r={type:0,props:{[t]:Yr(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},Q7={...kD,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},nd=class extends Zc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[n0]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=s0(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,i,s){this.runOp({type:7,parent:t,fi:e,id:r,data:i,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,i[s],o.id,o.data,o.children)}}insertBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,i[s],o.id,o.data,o.children)}}moveAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,i[s],o)}}moveBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,i[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},sd=class extends Zc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[n0]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id,s=this._current[r].fi;t(this.data(this._current[r].id),i,s)}}find(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id;if(t(this.data(i),i))return this.get(i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=s0(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(r[i],s.id,s.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(r[i],s.id,s.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(r[i],s)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(r[i],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function uA(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&Mr.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var i0=class extends Zc{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,i){uA(this.ts,e,t),uA(this.actual,r,t),uA(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function s0(n,t,e){return e instanceof wr?new nd(n,t,e):e instanceof Re?new sd(n,t,e):e instanceof He?new Proxy(new dA(n,t,e),Q7):e!==null&&typeof e=="object"?ed(e)?e:new Proxy(new hA(n,t,e),K7):e}function fA(n){let t=new i0(n);return[s0(t,"",n),t]}function Fl(n,t){let[e,r]=fA(n);return t(e),r.result()}function Yr(n){return n instanceof nd||n instanceof sd?n._current:n!==null&&typeof n=="object"?n[UD]:n}var Mr;(i=>{function n(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=n;function t(s,o,a){let l=r(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...o};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return o}i.removeOverridden=t;function e(s,o){if((s instanceof wr||s instanceof nd)&&typeof o=="string")return s.data(o);if((s instanceof Re||s instanceof sd)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=e;function r(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}i.zoom=r})(Mr||(Mr={}));function zD(n,t){let e=[];if(t.length===n.length)for(var r=0;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}function kt(n,t){let e=[];if(t.length<=n.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}var o0=class{},mm=class extends o0{constructor(e){super();this.id=e}},gm=class extends o0{constructor(e){super();this.data=e}};var mA;try{mA=new TextDecoder}catch{}var Ke,Ul,se=0;var KD=[],gA=KD,yA=0,Bn={},rr,Vl,Ss=0,Oo=0,ns,La,wn=[],fr,GD={useRecords:!1,mapsAsObjects:!0},ym=class{},xA=new ym;xA.name="MessagePack 0xC1";var od=!1,Ro=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(Ke)return eO(()=>(l0(),this?this.unpack(t,e):Ro.prototype.unpack.call(GD,t,e)));Ul=e>-1?e:t.length,se=0,yA=0,Oo=0,Vl=null,gA=KD,ns=null,Ke=t;try{fr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw Ke=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ro){if(Bn=this,this.structures)return rr=this.structures,a0();(!rr||rr.length>0)&&(rr=[])}else Bn=GD,(!rr||rr.length>0)&&(rr=[]);return a0()}unpackMultiple(t,e){let r,i=0;try{od=!0;let s=t.length,o=this?this.unpack(t,s):h0.unpack(t,s);if(e){for(e(o);se<s;)if(i=se,e(a0())===!1)return}else{for(r=[o];se<s;)i=se,r.push(a0());return r}}catch(s){throw s.lastPosition=i,s.values=r,s}finally{od=!1,l0()}}_mergeStructures(t,e){t=t||[];for(let r=0,i=t.length;r<i;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let i=t[r],s=e[r];s&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[r]=i),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function a0(){try{if(!Bn.trusted&&!od){let t=rr.sharedLength||0;t<rr.length&&(rr.length=t)}let n=ri();if(se==Ul)rr.restoreStructures&&jD(),rr=null,Ke=null,La&&(La=null);else if(se>Ul){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!od)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw rr.restoreStructures&&jD(),l0(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function jD(){for(let n in rr.restoreStructures)rr[n]=rr.restoreStructures[n];rr.restoreStructures=null}function ri(){let n=Ke[se++];if(n<160)if(n<128){if(n<64)return n;{let t=rr[n&63]||Bn.getStructures&&QD()[n&63];return t?(t.read||(t.read=bA(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,Bn.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[JD()]=ri();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(ri(),ri());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=ri();return t}else if(n<192){let t=n-160;if(Oo>=se)return Vl.slice(se-Ss,(se+=t)-Ss);if(Oo==0&&Ul<140){let e=t<16?SA(t):ZD(t);if(e!=null)return e}return vA(t)}else{let t;switch(n){case 192:return null;case 193:return ns?(t=ri(),t>0?ns[1].slice(ns.position1,ns.position1+=t):ns[0].slice(ns.position0,ns.position0-=t)):xA;case 194:return!1;case 195:return!0;case 196:return pA(Ke[se++]);case 197:return t=fr.getUint16(se),se+=2,pA(t);case 198:return t=fr.getUint32(se),se+=4,pA(t);case 199:return Jc(Ke[se++]);case 200:return t=fr.getUint16(se),se+=2,Jc(t);case 201:return t=fr.getUint32(se),se+=4,Jc(t);case 202:if(t=fr.getFloat32(se),Bn.useFloat32>2){let e=u0[(Ke[se]&127)<<1|Ke[se+1]>>7];return se+=4,(e*t+(t>0?.5:-.5)>>0)/e}return se+=4,t;case 203:return t=fr.getFloat64(se),se+=8,t;case 204:return Ke[se++];case 205:return t=fr.getUint16(se),se+=2,t;case 206:return t=fr.getUint32(se),se+=4,t;case 207:return Bn.int64AsNumber?(t=fr.getUint32(se)*4294967296,t+=fr.getUint32(se+4)):t=fr.getBigUint64(se),se+=8,t;case 208:return fr.getInt8(se++);case 209:return t=fr.getInt16(se),se+=2,t;case 210:return t=fr.getInt32(se),se+=4,t;case 211:return Bn.int64AsNumber?(t=fr.getInt32(se)*4294967296,t+=fr.getUint32(se+4)):t=fr.getBigInt64(se),se+=8,t;case 212:if(t=Ke[se++],t==114)return YD(Ke[se++]&63);{let e=wn[t];if(e)return e.read?(se++,e.read(ri())):e.noBuffer?(se++,e()):e(Ke.subarray(se,++se));throw new Error("Unknown extension "+t)}case 213:return t=Ke[se],t==114?(se++,YD(Ke[se++]&63,Ke[se++])):Jc(2);case 214:return Jc(4);case 215:return Jc(8);case 216:return Jc(16);case 217:return t=Ke[se++],Oo>=se?Vl.slice(se-Ss,(se+=t)-Ss):J7(t);case 218:return t=fr.getUint16(se),se+=2,Oo>=se?Vl.slice(se-Ss,(se+=t)-Ss):$7(t);case 219:return t=fr.getUint32(se),se+=4,Oo>=se?Vl.slice(se-Ss,(se+=t)-Ss):eX(t);case 220:return t=fr.getUint16(se),se+=2,WD(t);case 221:return t=fr.getUint32(se),se+=4,WD(t);case 222:return t=fr.getUint16(se),se+=2,qD(t);case 223:return t=fr.getUint32(se),se+=4,qD(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var Z7=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function bA(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(s=>Z7.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(ri);return n.highByte===0&&(n.read=HD(t,n.read)),i()}let r={};for(let i=0,s=n.length;i<s;i++){let o=n[i];r[o]=ri()}return r}return e.count=0,n.highByte===0?HD(t,e):e}var HD=(n,t)=>function(){let e=Ke[se++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=rr[r]||QD()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=bA(i,n)),i.read()};function QD(){let n=eO(()=>(Ke=null,Bn.getStructures()));return rr=Bn._mergeStructures(n,rr)}var vA=c0,J7=c0,$7=c0,eX=c0;function c0(n){let t;if(n<16&&(t=SA(n)))return t;if(n>64&&mA)return mA.decode(Ke.subarray(se,se+=n));let e=se+n,r=[];for(t="";se<e;){let i=Ke[se++];if((i&128)===0)r.push(i);else if((i&224)===192){let s=Ke[se++]&63;r.push((i&31)<<6|s)}else if((i&240)===224){let s=Ke[se++]&63,o=Ke[se++]&63;r.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ke[se++]&63,o=Ke[se++]&63,a=Ke[se++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(i);r.length>=4096&&(t+=Hi.apply(String,r),r.length=0)}return r.length>0&&(t+=Hi.apply(String,r)),t}function WD(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=ri();return t}function qD(n){if(Bn.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[JD()]=ri();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(ri(),ri());return t}}var Hi=String.fromCharCode;function ZD(n){let t=se,e=new Array(n);for(let r=0;r<n;r++){let i=Ke[se++];if((i&128)>0){se=t;return}e[r]=i}return Hi.apply(String,e)}function SA(n){if(n<4)if(n<2){if(n===0)return"";{let t=Ke[se++];if((t&128)>1){se-=1;return}return Hi(t)}}else{let t=Ke[se++],e=Ke[se++];if((t&128)>0||(e&128)>0){se-=2;return}if(n<3)return Hi(t,e);let r=Ke[se++];if((r&128)>0){se-=3;return}return Hi(t,e,r)}else{let t=Ke[se++],e=Ke[se++],r=Ke[se++],i=Ke[se++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){se-=4;return}if(n<6){if(n===4)return Hi(t,e,r,i);{let s=Ke[se++];if((s&128)>0){se-=5;return}return Hi(t,e,r,i,s)}}else if(n<8){let s=Ke[se++],o=Ke[se++];if((s&128)>0||(o&128)>0){se-=6;return}if(n<7)return Hi(t,e,r,i,s,o);let a=Ke[se++];if((a&128)>0){se-=7;return}return Hi(t,e,r,i,s,o,a)}else{let s=Ke[se++],o=Ke[se++],a=Ke[se++],l=Ke[se++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){se-=8;return}if(n<10){if(n===8)return Hi(t,e,r,i,s,o,a,l);{let c=Ke[se++];if((c&128)>0){se-=9;return}return Hi(t,e,r,i,s,o,a,l,c)}}else if(n<12){let c=Ke[se++],u=Ke[se++];if((c&128)>0||(u&128)>0){se-=10;return}if(n<11)return Hi(t,e,r,i,s,o,a,l,c,u);let h=Ke[se++];if((h&128)>0){se-=11;return}return Hi(t,e,r,i,s,o,a,l,c,u,h)}else{let c=Ke[se++],u=Ke[se++],h=Ke[se++],d=Ke[se++];if((c&128)>0||(u&128)>0||(h&128)>0||(d&128)>0){se-=12;return}if(n<14){if(n===12)return Hi(t,e,r,i,s,o,a,l,c,u,h,d);{let f=Ke[se++];if((f&128)>0){se-=13;return}return Hi(t,e,r,i,s,o,a,l,c,u,h,d,f)}}else{let f=Ke[se++],m=Ke[se++];if((f&128)>0||(m&128)>0){se-=14;return}if(n<15)return Hi(t,e,r,i,s,o,a,l,c,u,h,d,f,m);let p=Ke[se++];if((p&128)>0){se-=15;return}return Hi(t,e,r,i,s,o,a,l,c,u,h,d,f,m,p)}}}}}function pA(n){return Bn.copyBuffers?Uint8Array.prototype.slice.call(Ke,se,se+=n):Ke.subarray(se,se+=n)}function Jc(n){let t=Ke[se++];if(wn[t])return wn[t](Ke.subarray(se,se+=n));throw new Error("Unknown extension type "+t)}var XD=new Array(4096);function JD(){let n=Ke[se++];if(n>=160&&n<192){if(n=n-160,Oo>=se)return Vl.slice(se-Ss,(se+=n)-Ss);if(!(Oo==0&&Ul<180))return vA(n)}else return se--,ri();let t=(n<<5^(n>1?fr.getUint16(se):n>0?Ke[se]:0))&4095,e=XD[t],r=se,i=se+n-3,s,o=0;if(e&&e.bytes==n){for(;r<i;){if(s=fr.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(s=Ke[r++],s!=e[o++]){r=1879048192;break}if(r===i)return se=r,e.string;i-=3,r=se}for(e=[],XD[t]=e,e.bytes=n;r<i;)s=fr.getUint32(r),e.push(s),r+=4;for(i+=3;r<i;)s=Ke[r++],e.push(s);let a=n<16?SA(n):ZD(n);return a!=null?e.string=a:e.string=vA(n)}var YD=(n,t)=>{var e=ri();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=rr[n];return i&&i.isShared&&((rr.restoreStructures||(rr.restoreStructures=[]))[n]=i),rr[n]=e,e.read=bA(e,r),e.read()},$D=typeof self=="object"?self:global;wn[0]=()=>{};wn[0].noBuffer=!0;wn[101]=()=>{let n=ri();return($D[n[0]]||Error)(n[1])};wn[105]=n=>{let t=fr.getUint32(se-4);La||(La=new Map);let e=Ke[se],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let i={target:r};La.set(t,i);let s=ri();return i.used?Object.assign(r,s):(i.target=s,s)};wn[112]=n=>{let t=fr.getUint32(se-4),e=La.get(t);return e.used=!0,e.target};wn[115]=()=>new Set(ri());var wA=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");wn[116]=n=>{let t=n[0],e=wA[t];if(!e)throw new Error("Could not find typed array for code "+t);return new $D[e](Uint8Array.prototype.slice.call(n,1).buffer)};wn[120]=()=>{let n=ri();return new RegExp(n[0],n[1])};wn[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=se;se+=t-4,ns=[ri(),ri()],ns.position0=0,ns.position1=0;let r=se;se=e;try{return ri()}finally{se=r}};wn[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function eO(n){let t=Ul,e=se,r=yA,i=Ss,s=Oo,o=Vl,a=gA,l=La,c=ns,u=new Uint8Array(Ke.slice(0,Ul)),h=rr,d=rr.slice(0,rr.length),f=Bn,m=od,p=n();return Ul=t,se=e,yA=r,Ss=i,Oo=s,Vl=o,gA=a,La=l,ns=c,Ke=u,od=m,rr=h,rr.splice(0,rr.length,...d),Bn=f,fr=new DataView(Ke.buffer,Ke.byteOffset,Ke.byteLength),p}function l0(){Ke=null,La=null,rr=null}function tO(n){n.unpack?wn[n.type]=n.unpack:wn[n.type]=n}var u0=new Array(147);for(let n=0;n<256;n++)u0[n]=+("1e"+Math.floor(45.15-n*.30103));var h0=new Ro({useRecords:!1}),tX=h0.unpack,rX=h0.unpackMultiple,iX=h0.unpack,d0={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},nX=new Float32Array(1),Yfe=new Uint8Array(nX.buffer,0,4);var f0;try{f0=new TextEncoder}catch{}var p0,EA,m0=typeof Buffer<"u",AA=m0?Buffer.allocUnsafeSlow:Uint8Array,sO=m0?Buffer:Uint8Array,rO=m0?4294967296:2144337920,we,oi,he=0,Lo,No=null,sX=/[\u0080-\uFFFF]/,vm=Symbol("record-id"),$c=class extends Ro{constructor(t){super(t),this.offset=0;let e,r,i,s,o,a,l=0,c=sO.prototype.utf8Write?function(S,M,C){return we.utf8Write(S,M,C)}:f0&&f0.encodeInto?function(S,M){return f0.encodeInto(S,we.subarray(M)).written}:!1,u=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=t.maxOwnStructures;m==null&&(m=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,y=f+m+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let x=[],v=0,b=0;this.pack=this.encode=function(S,M){if(we||(we=new AA(8192),oi=new DataView(we.buffer,0,8192),he=0),Lo=we.length-10,Lo-he<2048?(we=new AA(we.length),oi=new DataView(we.buffer,0,we.length),Lo=we.length-10,he=0):he=he+7&2147483640,r=he,a=u.structuredClone?new Map:null,u.bundleStrings?(No=["",""],we[he++]=214,we[he++]=98,No.position=he-r,he+=4):No=null,i=u.structures,i){i.uninitialized&&(i=u._mergeStructures(u.getStructures()));let C=i.sharedLength||0;if(C>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let P=0;P<C;P++){let _=i[P];if(!_)continue;let I,O=i.transitions;for(let L=0,j=_.length;L<j;L++){let V=_[L];I=O[V],I||(I=O[V]=Object.create(null)),O=I}O[vm]=P+64}l=C}h||(i.nextId=C+64)}s&&(s=!1),o=i||[];try{if(w(S),No){oi.setUint32(No.position+r,he-No.position-r);let C=No;No=null,w(C[0]),w(C[1])}if(u.offset=he,a&&a.idsToInsert){he+=a.idsToInsert.length*6,he>Lo&&T(he),u.offset=he;let C=aX(we.subarray(r,he),a.idsToInsert);return a=null,C}return M&aO?(we.start=r,we.end=he,we):we.subarray(r,he)}finally{if(i){if(b<10&&b++,v>1e4)i.transitions=null,b=0,v=0,x.length>0&&(x=[]);else if(x.length>0&&!h){for(let C=0,P=x.length;C<P;C++)x[C][vm]=0;x=[]}if(s&&u.saveStructures){let C=i.sharedLength||f;i.length>C&&(i=i.slice(0,C));let P=we.subarray(r,he);return u.saveStructures(i,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(S)):(l=C,P)}}M&pX&&(he=r)}};let w=S=>{he>Lo&&(we=T(he));var M=typeof S,C;if(M==="string"){let P=S.length;if(No&&P>=8&&P<4096){let O=sX.test(S);No[O?0:1]+=S,we[he++]=193,w(O?-P:P);return}let _;P<32?_=1:P<256?_=2:P<65536?_=3:_=5;let I=P*3;if(he+I>Lo&&(we=T(he+I)),P<64||!c){let O,L,j,V=he+_;for(O=0;O<P;O++)L=S.charCodeAt(O),L<128?we[V++]=L:L<2048?(we[V++]=L>>6|192,we[V++]=L&63|128):(L&64512)===55296&&((j=S.charCodeAt(O+1))&64512)===56320?(L=65536+((L&1023)<<10)+(j&1023),O++,we[V++]=L>>18|240,we[V++]=L>>12&63|128,we[V++]=L>>6&63|128,we[V++]=L&63|128):(we[V++]=L>>12|224,we[V++]=L>>6&63|128,we[V++]=L&63|128);C=V-he-_}else C=c(S,he+_,I);C<32?we[he++]=160|C:C<256?(_<2&&we.copyWithin(he+2,he+1,he+1+C),we[he++]=217,we[he++]=C):C<65536?(_<3&&we.copyWithin(he+3,he+2,he+2+C),we[he++]=218,we[he++]=C>>8,we[he++]=C&255):(_<5&&we.copyWithin(he+5,he+3,he+3+C),we[he++]=219,oi.setUint32(he,C),he+=4),he+=C}else if(M==="number")if(S>>>0===S)S<64?we[he++]=S:S<256?(we[he++]=204,we[he++]=S):S<65536?(we[he++]=205,we[he++]=S>>8,we[he++]=S&255):(we[he++]=206,oi.setUint32(he,S),he+=4);else if(S>>0===S)S>=-32?we[he++]=256+S:S>=-128?(we[he++]=208,we[he++]=S+256):S>=-32768?(we[he++]=209,oi.setInt16(he,S),he+=2):(we[he++]=210,oi.setInt32(he,S),he+=4);else{let P;if((P=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){we[he++]=202,oi.setFloat32(he,S);let _;if(P<4||(_=S*u0[(we[he]&127)<<1|we[he+1]>>7])>>0===_){he+=4;return}else he--}we[he++]=203,oi.setFloat64(he,S),he+=8}else if(M==="object")if(!S)we[he++]=192;else{if(a){let _=a.get(S);if(_){if(!_.id){let I=a.idsToInsert||(a.idsToInsert=[]);_.id=I.push(_)}we[he++]=214,we[he++]=112,oi.setUint32(he,_.id),he+=4;return}else a.set(S,{offset:he-r})}let P=S.constructor;if(P===Object)A(S,!0);else if(P===Array){C=S.length,C<16?we[he++]=144|C:C<65536?(we[he++]=220,we[he++]=C>>8,we[he++]=C&255):(we[he++]=221,oi.setUint32(he,C),he+=4);for(let _=0;_<C;_++)w(S[_])}else if(P===Map){C=S.size,C<16?we[he++]=128|C:C<65536?(we[he++]=222,we[he++]=C>>8,we[he++]=C&255):(we[he++]=223,oi.setUint32(he,C),he+=4);for(let[_,I]of S)w(_),w(I)}else{for(let _=0,I=p0.length;_<I;_++){let O=EA[_];if(S instanceof O){let L=p0[_];if(L.write){L.type&&(we[he++]=212,we[he++]=L.type,we[he++]=0),w(L.write.call(this,S));return}let j=we,V=oi,H=he;we=null;let q;try{q=L.pack.call(this,S,X=>(we=j,j=null,he+=X,he>Lo&&T(he),{target:we,targetView:oi,position:he-X}),w)}finally{j&&(we=j,oi=V,he=H,Lo=we.length-10)}q&&(q.length+he>Lo&&T(q.length+he),he=oX(q,we,he,L.type));return}}A(S,!S.hasOwnProperty)}}else if(M==="boolean")we[he++]=S?195:194;else if(M==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))we[he++]=211,oi.setBigInt64(he,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)we[he++]=207,oi.setBigUint64(he,S);else if(this.largeBigIntToFloat)we[he++]=203,oi.setFloat64(he,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");he+=8}else if(M==="undefined")this.encodeUndefinedAsNil?we[he++]=192:(we[he++]=212,we[he++]=0,we[he++]=0);else if(M==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},A=this.useRecords===!1?this.variableMapSize?S=>{let M=Object.keys(S),C=M.length;C<16?we[he++]=128|C:C<65536?(we[he++]=222,we[he++]=C>>8,we[he++]=C&255):(we[he++]=223,oi.setUint32(he,C),he+=4);let P;for(let _=0;_<C;_++)w(P=M[_]),w(S[P])}:(S,M)=>{we[he++]=222;let C=he-r;he+=2;let P=0;for(let _ in S)(M||S.hasOwnProperty(_))&&(w(_),w(S[_]),P++);we[C+++r]=P>>8,we[C+r]=P&255}:S=>{let M=Object.keys(S),C,P=o.transitions||(o.transitions=Object.create(null)),_=0;for(let O=0,L=M.length;O<L;O++){let j=M[O];C=P[j],C||(C=P[j]=Object.create(null),_++),P=C}let I=P[vm];if(I)I>=96&&p?(we[he++]=((I-=96)&31)+96,we[he++]=I>>5):we[he++]=I;else{I=o.nextId,I||(I=64),I<g&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(I=o.nextOwnId,I<y||(I=g),o.nextOwnId=I+1):(I>=y&&(I=g),o.nextId=I+1);let O=M.highByte=I>=96&&p?I-96>>5:-1;P[vm]=I,o[I-64]=M,I<g?(M.isShared=!0,o.sharedLength=I-63,s=!0,O>=0?(we[he++]=(I&31)+96,we[he++]=O):we[he++]=I):(O>=0?(we[he++]=213,we[he++]=114,we[he++]=(I&31)+96,we[he++]=O):(we[he++]=212,we[he++]=114,we[he++]=I),_&&(v+=b*_),x.length>=m&&(x.shift()[vm]=0),x.push(P),w(M))}for(let O=0,L=M.length;O<L;O++)w(S[M[O]])},T=S=>{let M;if(S>16777216){if(S-r>rO)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(rO,Math.round(Math.max((S-r)*(S>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(S-r<<2,we.length-1)>>12)+1<<12;let C=new AA(M);return oi=new DataView(C.buffer,0,M),we.copy?we.copy(C,0,r,S):C.set(we.slice(r,S)),he-=r,r=0,Lo=C.length-10,we=C}}useBuffer(t){we=t,oi=new DataView(we.buffer,we.byteOffset,we.byteLength),he=0}};EA=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,ym];p0=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:s,position:o}=t(6);i[o++]=214,i[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:i,targetView:s,position:o}=t(10);i[o++]=215,i[o++]=255,s.setUint32(o,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:s,position:o}=t(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=t(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,n.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:i,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),e(r)}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=101,r[i++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=120,r[i++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?iO(n,16,t):nO(m0?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==sO&&this.structuredClone?iO(n,wA.indexOf(e.name),t):nO(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function iO(n,t,e,r){let i=n.byteLength;if(i+1<256){var{target:s,position:o}=e(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=e(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=e(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),o)}function nO(n,t){let e=n.byteLength;var r,i;if(e<256){var{target:r,position:i}=t(e+2);r[i++]=196,r[i++]=e}else if(e<65536){var{target:r,position:i}=t(e+3);r[i++]=197,r[i++]=e>>8,r[i++]=e&255}else{var{target:r,position:i,targetView:s}=t(e+5);r[i++]=198,s.setUint32(i,e),i+=4}r.set(n,i)}function oX(n,t,e,r){let i=n.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=r,t.set(n,e),e+=i,e}function aX(n,t){let e,r=t.length*6,i=n.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;n.copyWithin(s+r,s,i),r-=6;let a=s+r;n[a++]=214,n[a++]=105,n[a++]=o>>24,n[a++]=o>>16&255,n[a++]=o>>8&255,n[a++]=o&255,i=s}return n}function kl(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");EA.unshift(n.Class),p0.unshift(n)}tO(n)}var oO=new $c({useRecords:!1}),lX=oO.pack,cX=oO.pack;var{NEVER:uX,ALWAYS:hX,DECIMAL_ROUND:dX,DECIMAL_FIT:fX}=d0,aO=512,pX=1024;var lO=new $c({structuredClone:!0});kl({Class:He.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,He.prototype),n}});kl({Class:Re.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Re.prototype),n}});kl({Class:wr.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,wr.prototype),n}});kl({Class:mm.prototype.constructor,type:4,write(n){return n.id},read(n){return new mm(n)}});kl({Class:gm.prototype.constructor,type:5,write(n){return n.data},read(n){return new gm(n)}});kl({Class:lr.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,lr.prototype),n}});function mX(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function TA(n){if(ed(n))return n;if(Array.isArray(n))return n.map(TA);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=TA(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var ad;(r=>{function n(i){return lO.pack(i)}r.serialize=n;function t(i){return lO.unpack(i)}r.deserialize=t;function e(i){return mX(n(TA(i))).toString()}r.checksum=e})(ad||(ad={}));var cO;(e=>{function n(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=n;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(cO||(cO={}));function xm(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var Wi={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseHover"]:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Scroll"]:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Start"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Conditional"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseDown"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseUp"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MousePress"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyDown"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyUp"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyPress"]:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["GameControl"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],["Collision"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Trigger"]:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Resize"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["VariableChange"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["API"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["WEBHOOK"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["AIAssistantListener"]:["SetVariable"],["AIAssistantTrigger"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},uO;(e=>{function n(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=n;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,name:"",actions:new Re}:{type:r,disabled:!1,name:"",key:void 0,actions:new Re}}e.defaultData=t})(uO||(uO={}));var g0;(e=>{function n(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=n,e.valueDefaultData={type:"Literal",value:0}})(g0||(g0={}));var MA;(r=>{function n(i){return{type:"Comparison",operator:"==",lOperand:g0.propertyDefaultData(i),rOperand:{...g0.valueDefaultData}}}r.comparisonDefaultData=n;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}r.distanceDefaultData=t;function e(i,s){return{type:"State",object:i??null,state:s??null}}r.stateDefaultData=e})(MA||(MA={}));var hO;(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(hO||(hO={}));var dO;(e=>{function n(r){return r.type==="Conditional"}e.is=n;function t(r){return{type:"Conditional",disabled:!1,name:"",inActions:new Re,outActions:new Re,condition:MA.distanceDefaultData(r)}}e.defaultData=t})(dO||(dO={}));var fO;(t=>t.defaultData={type:"DragDrop",name:"",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 Re,drop:new Re}})(fO||(fO={}));var y0;(t=>t.defaultData={type:"Follow",disabled:!1,name:"",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 Re})(y0||(y0={}));var v0;(t=>t.defaultData={type:"LookAt",disabled:!1,name:"",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})(v0||(v0={}));var pO;(e=>{function n(r){return r.type==="MouseHover"}e.is=n;function t(){return{type:"MouseHover",disabled:!1,name:"",actions:new Re}}e.defaultData=t})(pO||(pO={}));var mO;(e=>{function n(r){return r.type==="Scroll"}e.is=n;function t(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Re}}e.defaultData=t})(mO||(mO={}));var gO;(e=>{function n(r){return r.type==="Start"}e.is=n;function t(){return{type:"Start",disabled:!1,name:"",actions:new Re}}e.defaultData=t})(gO||(gO={}));var yO;(e=>{function n(r){return r.type==="Collision"}e.is=n;function t(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new Re}}e.defaultData=t})(yO||(yO={}));var vO;(e=>{function n(r){return r.type==="Trigger"}e.is=n;function t(r,i){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new Re,triggerZone:"box",position:i.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(vO||(vO={}));var x0;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function r(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=r;function i(){let a={size:"mobile",operator:"<",actions:new Re},l={size:"tablet",operator:"<",actions:new Re},c={size:[...o.defaultSizes.custom],operator:"<>",actions:new Re},u=new Re;return u.push({id:Se.generateUUID(),fi:0,data:a},{id:Se.generateUUID(),fi:1,data:l},{id:Se.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:u}}o.defaultData=i;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Re}}o.defaultBreakpointData=s})(x0||(x0={}));var b0;(r=>{r.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(i){return i.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",name:"",actions:new Re,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(b0||(b0={}));var xO;(e=>{function n(r){return r.type==="API"}e.is=n;function t(){return{disabled:!1,type:"API",name:"",successActions:new Re,errorActions:new Re,userAPIId:""}}e.defaultData=t})(xO||(xO={}));var bO;(e=>{function n(r){return r.type==="WEBHOOK"}e.is=n;function t(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new Re,userWebhookId:""}}e.defaultData=t})(bO||(bO={}));var SO;(e=>{function n(r){return r.type==="AIAssistantListener"}e.is=n;function t(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new Re,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=t})(SO||(SO={}));var wO;(e=>{function n(r){return r.type==="AIAssistantTrigger"}e.is=n;function t(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new Re}}e.defaultData=t})(wO||(wO={}));var As="personal camera",Gl="a218fcc3-276b-49b9-b485-49037fd14f5f",EO=2960946;var ai=5526619,w0=(r=>(r.x="x",r.y="y",r.z="z",r))(w0||{}),ss;(f=>{function n(m,p){return m[0]===p[0]&&m[1]===p[1]}f.isEqual=n;function t(m,p,g){return[m[0]+(p[0]-m[0])*g,m[1]+(p[1]-m[1])*g]}f.lerp=t;function e(m,p){return[m[0]+p[0],m[1]+p[1]]}f.add=e;function r(m,p){return[m[0]-p[0],m[1]-p[1]]}f.sub=r;function i(m,p){return[m[0]*p[0],m[1]*p[1]]}f.multiply=i;function s(m,p){return[m[0]/p[0],m[1]/p[1]]}f.divide=s;function o(m,p){return Math.pow(p[0]-m[0],2)+Math.pow(p[1]-m[1],2)}f.distanceSquared=o;function a(m,p){return Math.sqrt(o(m,p))}f.distance=a;function l(m,p){return m[0]*p[0]+m[1]*p[1]}f.dot=l;function c(m,p){return[m[0]*p,m[1]*p]}f.scalarMultiply=c;function u(m,p,g){let y=f.sub(p,m),x=f.sub(g,m),v=f.dot(y,x)/f.dot(y,y),b=f.scalarMultiply(y,v);return f.add(m,b)}f.projectionOnto=u;function h(m,p,g){return a(m,u(m,p,g))}f.projectionOntoDistance=h;function d(m,p){return[(m[0]+p[0])*.5,(m[1]+p[1])*.5]}f.center=d})(ss||(ss={}));var ws;(a=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}a.isEqual=n;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}a.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}a.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}a.div=r;function i(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}a.mul=i;function s(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}a.dist=s;function o(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}a.lerp=o})(ws||(ws={}));var eu;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}e.isEqual=n;function t(r,i,s){return[r[0]+(i[0]-r[0])*s,r[1]+(i[1]-r[1])*s,r[2]+(i[2]-r[2])*s,r[3]+(i[3]-r[3])*s]}e.lerp=t})(eu||(eu={}));var AO;(o=>{let n=180/Math.PI,t=Math.PI/180;function e(a){return typeof a=="number"?a*n:a}function r(a){return typeof a=="number"?a*t:a}function i(a){return[e(a[0]),e(a[1]),e(a[2])]}o.radToDeg=i;function s(a){return[r(a[0]),r(a[1]),r(a[2])]}o.degToRad=s})(AO||(AO={}));var zl;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=t;function e(s){return s??i.identity}i.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,c=o.length;l<c;l+=3){let u=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/u,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/u,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/u}return a}i.applyMatrix4=r})(zl||(zl={}));var Fr;(d=>{function n(f){return typeof f=="object"&&typeof f.r=="number"&&typeof f.g=="number"&&typeof f.b=="number"}d.isRGB=n,d.white={r:1,g:1,b:1},d.red={r:1,g:0,b:0},d.black={r:0,g:0,b:0};function i(f){return{r:Math.round(f.r*255),g:Math.round(f.g*255),b:Math.round(f.b*255),a:1}}d.toRgb255a1=i;function s(f){return{r:f.r,g:f.g,b:f.b}}d.clone=s;function o(f){return f=Math.floor(f),{r:(f>>16&255)/255,g:(f>>8&255)/255,b:(f&255)/255}}d.fromHex=o;function a(f){return Math.round(f.r*255)*65536+Math.round(f.g*255)*256+Math.round(f.b*255)}d.toHex=a;function l(f,m){return f.r===m.r&&f.g===m.g&&f.b===m.b}d.equals=l;function c(f,m){return f.r.toFixed(2)===m.r.toFixed(2)&&f.g.toFixed(2)===m.g.toFixed(2)&&f.b.toFixed(2)===m.b.toFixed(2)}d.equalsFixed=c;function u(f,m,p){return{r:f.r+(m.r-f.r)*p,g:f.g+(m.g-f.g)*p,b:f.b+(m.b-f.b)*p}}d.lerp=u;function h(f){return kr(f)?"r"in f&&"g"in f&&"b"in f&&!("a"in f):!1}d.is=h})(Fr||(Fr={}));var At;(u=>{u.white={...Fr.white,a:1};function t(h){return kr(h)?"r"in h&&"g"in h&&"b"in h&&"a"in h:!1}u.is=t,u.transparent={...Fr.white,a:0};function r(h){return{r:h[0],g:h[1],b:h[2],a:h[3]}}u.from0to1=r;function i(h,d){return{...Fr.fromHex(h),a:d}}u.fromHexAndA=i;function s(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:h.a}}u.toRgb255a1=s;function o(h,d){return Fr.equals(h,d)&&h.a===d.a}u.equals=o;function a(h,d){return Fr.equalsFixed(h,d)&&h.a.toFixed(2)===d.a.toFixed(2)}u.equalsFixed=a;function l(h,d,f){return{r:h.r+(d.r-h.r)*f,g:h.g+(d.g-h.g)*f,b:h.b+(d.b-h.b)*f,a:h.a+(d.a-h.a)*f}}u.lerp=l;function c({r:h,g:d,b:f,a:m}=u.white){return`rgba(${h*255}, ${d*255}, ${f*255}, ${m})`}u.toStyle=c})(At||(At={}));var S0;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(S0||(S0={}));var tu=(c=>(c[c.LINEAR=0]="LINEAR",c[c.EASE=1]="EASE",c[c.EASE_IN=2]="EASE_IN",c[c.EASE_OUT=3]="EASE_OUT",c[c.EASE_IN_OUT=4]="EASE_IN_OUT",c[c.CUBIC=5]="CUBIC",c[c.SPRING=6]="SPRING",c[c.ARC=7]="ARC",c[c.NONE=8]="NONE",c))(tu||{}),ld;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(ld||(ld={}));var cd;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(cd||(cd={}));var Na;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(Na||(Na={}));function CA(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Ks;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Ks||(Ks={}));var jl;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}i.getZoom=r})(jl||(jl={}));var Bo;(r=>{function n(i,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(typeof i[0]=="number"?i[0]:1,typeof i[1]=="number"?i[1]:1)*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[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",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof i[0]=="number"?i[0]+i[0]:1)*s,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:i.map(o=>(typeof o=="number"?o:1)*(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"}}}r.defaultData=n;function t(i,s){let o={...i};if(PA.forEach(a=>{Object.assign(o,{[a]:s[a]??i[a]})}),o.radial={...i.radial},s.radial){let a=i.radial,l=s.radial;E0.forEach(c=>{Object.assign(o.radial,{[c]:l[c]??a[c]})})}if(o.linear={...i.linear},s.linear){let a=i.linear,l=s.linear;T0.forEach(c=>{Object.assign(o.linear,{[c]:l[c]??a[c]})})}if(o.grid={...i.grid},s.grid){let a=i.grid,l=s.grid;M0.forEach(c=>{Object.assign(o.grid,{[c]:l[c]??a[c]})})}if(o.toObject={...i.toObject},s.toObject){let a=i.toObject,l=s.toObject;C0.forEach(c=>{Object.assign(o.toObject,{[c]:l[c]??a[c]})})}if(o.randomnessObject={...i.randomnessObject},s.randomnessObject){let a=i.randomnessObject,l=s.randomnessObject;P0.forEach(c=>{Object.assign(o.randomnessObject,{[c]:l[c]??a[c]})})}return o}r.merge=t;function e(i){return!!(i.randomnessObject||i.toObject)}r.isPartial=e})(Bo||(Bo={}));var A0;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of t){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(A0||(A0={}));var PA=["count"],E0=["radius","start","end","position","scale","rotation"],T0=["position","scale","rotation"],M0=["count","size"],C0=["count","position","scale","rotation"],P0=["strength","scale","rotation","position","movement","seed","freqScale"];var _0;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(_0||(_0={}));var I0;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:At.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:At.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:At.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(I0||(I0={}));var ud;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(ud||(ud={}));var Hl;(t=>t.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]})(Hl||(Hl={}));var DA=(r=>(r[r.Front=0]="Front",r[r.Back=1]="Back",r[r.Double=2]="Double",r))(DA||{}),_A;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(_A||(_A={}));var IA;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe}e.equals=t})(IA||(IA={}));var D0;(t=>t.defaultData={...IA.defaultData,..._A.defaultData})(D0||(D0={}));var TO;(t=>{function n(e,r){let i=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&i.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;o&&i.push(o)}return i}t.getMaterialData=n})(TO||(TO={}));var hd;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(hd||(hd={}));var MO;(t=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=n})(MO||(MO={}));function PO(n){return n.type!=="displace"}var CO;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(CO||(CO={}));var O0=(r=>(r[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",r))(O0||{}),bm=(r=>(r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",r))(bm||{}),R0=(r=>(r[r.NearestFilter=1003]="NearestFilter",r[r.LinearFilter=1006]="LinearFilter",r[r.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",r))(R0||{}),OA=(s=>(s[s.UV=0]="UV",s[s.Planar=1]="Planar",s[s.Spherical=2]="Spherical",s[s.Cylindrical=3]="Cylindrical",s[s.Triplanar=4]="Triplanar",s))(OA||{}),RA=(o=>(o[o.Simplex=0]="Simplex",o[o.SimplexFractal=1]="SimplexFractal",o[o.Ashima=2]="Ashima",o[o.Fbm=3]="Fbm",o[o.Perlin=4]="Perlin",o[o.Voronoi=5]="Voronoi",o))(RA||{}),L0=(l=>(l[l.F1=0]="F1",l[l.F2=1]="F2",l[l.F2MinusF1=2]="F2MinusF1",l[l.SmoothBlend=3]="SmoothBlend",l[l.Edge=4]="Edge",l[l.Power=5]="Power",l[l.Lines=6]="Lines",l[l.Cells=7]="Cells",l))(L0||{}),LA=(r=>(r[r.Lights=0]="Lights",r[r.Static=1]="Static",r[r.Camera=2]="Camera",r))(LA||{}),NA=(l=>(l[l.Circle=0]="Circle",l[l.Ring=1]="Ring",l[l.Polygon=2]="Polygon",l[l.Cross=3]="Cross",l[l.Diamond=4]="Diamond",l[l.Checkerboard=5]="Checkerboard",l[l.Line=6]="Line",l[l.Wave=7]="Wave",l))(NA||{}),N0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],_O=["wrapping","image","video","name","minFilter","magFilter"],Cr;(s=>{function n(o,a){let{texture:l,...c}=a;if(Object.assign(o,c),l){let u=o.texture;u&&Object.assign(u,l)}}s.patch=n;function t(o){return{...s.defaultData("color"),color:o}}s.defaultColorLayer=t;function e(o,a){return o==="light"&&a?r(a):i(o)}s.defaultData=e;function r(o){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(o){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function i(o){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(o){case"texture":return{...a,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],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:hd.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...a,type:"color",color:Fr.fromHex(ai)};case"depth":return{...a,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{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,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{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Fr.fromHex(6710886),a:1},colorB:{...Fr.fromHex(6710886),a:1},colorC:{...Fr.fromHex(16777215),a:1},colorD:{...Fr.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{...a,type:"fresnel",color:At.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,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:At.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:At.fromHexAndA(0,1),contourColor:At.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{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...a,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{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Fr.fromHex(0),a:1},colorB:{...Fr.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}}}})(Cr||(Cr={}));var Kr;(u=>{function n(h){return!h.layers.some(f=>f.data.type==="texture"&&f.data.projection!==0||f.data.type==="depth"&&!f.data.isWorldSpace||f.data.type==="noise"||f.data.type==="displace")}u.isMergable=n;function t(h){let d="";return h.layers.forEach(f=>{Object.entries(f.data).forEach(([m,p])=>{d+=`${m}${p}`,Array.isArray(p)?p.forEach(g=>d+=`${g}`):typeof p=="object"?Object.values(p).forEach(g=>{typeof g=="number"?d+=`${g.toFixed(4)}`:d+=`${g}`}):d+=`${p}`})}),d}u.getHash=t;function e(){return{layers:new Re}}u.defaultEmptyData=e;function r(h="layer1",d="layer2"){return s("phong",h,d)}u.defaultData=r;function i(h,d){return{...h,name:d}}u.withName=i;function s(h,d="layer1",f="layer2",m=Fr.fromHex(16777215)){let p=new Re;return p.push({fi:0,data:Cr.defaultData("light",h),id:d}),p.push({fi:1,data:Cr.defaultData("color"),id:f}),{layers:p}}u.defaultTwoLayerData=s;function o(h,d,f="layer1",m="layer2"){let p=new Re;return p.push({fi:0,data:Cr.defaultData("light",d),id:f}),p.push({fi:1,data:Cr.defaultColorLayer(h),id:m}),{layers:p}}u.defaultColorMaterial=o;function a(h){let d=Cr.defaultData("texture");h&&Object.assign(d.texture,{image:h});let f=new Re;return f.push({fi:0,data:d,id:"layer1"}),f.push({fi:1,data:{...Cr.defaultData("transmission"),alpha:1},id:"layer2"}),f.push({fi:2,data:{...Cr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:f}}u.defaultUIObjectMaterial=a;function l(h,d="phong",f="layer1",m="layer2"){let p=Cr.defaultData("texture");Object.assign(p.texture,{image:h});let g=new Re;return g.push({fi:0,data:p,id:f}),g.push({fi:1,data:Cr.defaultData("light",d),id:m}),{layers:g}}u.defaultTwoLayerTextureData=l;function c(h,d="phong",f="layer1",m="layer2"){let p=Cr.defaultData("video");Object.assign(p.texture,{video:h});let g=new Re;return g.push({fi:0,data:p,id:f}),g.push({fi:1,data:Cr.defaultData("light",d),id:m}),{layers:g}}u.defaultTwoLayerVideoTextureData=c})(Kr||(Kr={}));var dd;(t=>{function n(){return{points:new Re,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(dd||(dd={}));var fd;(t=>{function n(){return{points:new Re,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}t.defaultData=n})(fd||(fd={}));var ru={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var B0;(t=>{function n(e,r){let i={...e};return V0.forEach(s=>{Object.assign(i,{[s]:r[s]??e[s]})}),i}t.merge=n})(B0||(B0={}));var F0={shape:ru,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},V0=["depth","offset","angle","twist","startScale","endScale"];var Sm;(r=>{function n(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"}r.is2DParametricMesh=n;function t(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="BooleanGeometry"||i==="TextGeometry"||i==="InputGeometry"}r.isParametricMesh=t;function e(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="TextGeometry"||i==="SubdivGeometry"||i==="NonParametricGeometry"}r.isSwappableGeometry=e})(Sm||(Sm={}));var U0;(t=>{function n(e,r){let i={...e};return Object.assign(i,r),i.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,B0.merge(i.extrusion,r.extrusion))),i}t.merge=n})(U0||(U0={}));var Fo;(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:fd.defaultData(),extrusion:F0};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:dd.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="ShapeBlendGeometry")return{type:e,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="InputGeometry")return{...t.defaultData("TextGeometry"),type:e,editable:!0};if(e==="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")}t.defaultData=n})(Fo||(Fo={}));var k0=["width","height","depth"];var z0;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Fr.white,near:.1,far:2e3})(z0||(z0={}));var pd;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focusDistance:100,focalLength:20,bokehScale:5},noise:{...n,blendFunction:16}}})(pd||(pd={}));var BA;(t=>t.defaultData={softShadowQuality:"low"})(BA||(BA={}));var FA;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(FA||(FA={}));var VA;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(VA||(VA={}));var Wl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Wl||(Wl={}));var UA;(t=>t.defaultData={playCamera:As,gameControlObject:null})(UA||(UA={}));var G0;(t=>t.defaultData={backgroundColor:At.fromHexAndA(EO,1),postprocessing:pd.defaultData,fog:z0.defaultData,globalPhysics:Wl.defaultData,ambient:FA.defaultData,ao:VA.defaultData,shadow:BA.defaultData,publish:UA.defaultData})(G0||(G0={}));var j0;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(j0||(j0={}));var IO;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(IO||(IO={}));var md;(i=>{i.identity={...S0.identity,hiddenMatrix:zl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,pivot:s.pivot,pivotRotation:s.pivotRotation,hiddenMatrix:s.hiddenMatrix}}i.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,pivot:o?.pivot||s.pivot,pivotRotation:o?.pivotRotation||s.pivotRotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=e;function r(s,o){return Wv({position:ws.isEqual(s.position,o.position)?void 0:o.position,rotation:ws.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:ws.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:zl.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=r})(md||(md={}));var LO=["slide","offset"],li;(t=>t.defaultData={states:new Re,events:new Re,timelineAnimations:new He,visible:!0,raycastLock:!1,physics:Hl.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...md.identity,cloner:null})(li||(li={}));var H0;(t=>t.defaultData={type:"Empty",...li.defaultData})(H0||(H0={}));var DO;(t=>t.defaultData={type:"ParticleCollider",...j0.defaultData,...li.defaultData})(DO||(DO={}));var OO;(t=>t.defaultData={type:"Component",...li.defaultData})(OO||(OO={}));var RO;(t=>t.defaultData={type:"Particle",...li.defaultData,...ud.defaultData})(RO||(RO={}));var Ba;(t=>t.defaultData={type:"Mesh",...li.defaultData,...D0.defaultData})(Ba||(Ba={}));var iu;(t=>t.defaultData={...li.defaultData,...md.identity,position:[0,0,jl.DefaultTargetOffset],...jl.defaultData})(iu||(iu={}));var W0;(e=>{function n(r){return{...li.defaultData,...I0.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(W0||(W0={}));var gd;(e=>{function n(r,i,s=0){for(;s<i.length;){let o=r?r[i[s]]:void 0;if(i.length===s+1)return o;if(o)r=o.descendants,s+=1;else return}}e.resolveWithDes=n;function t(r,i,s=0){let o=n(r,i,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(gd||(gd={}));var Vo;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...li.defaultData,...a,component:o,overrides:new lr,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function i(o){let a=md.fromObject(o.data);return r(o.id,a)}s.fromComponentData=i})(Vo||(Vo={}));var Fa;(e=>{e.defaultData={type:"Page",...li.defaultData,physics:{...Hl.defaultData,fusedBody:!1},...G0.defaultData,camera:iu.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(Fa||(Fa={}));var q0;(a=>(a.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:zl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Hl.defaultData,states:new Re,events:new Re,timelineAnimations:new He,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...jl.defaultData},a.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"]},a.defaultMeshObject={name:"Rectangle",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("RectangleGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},a.defaultBooleanObject={name:"Boolean",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("BooleanGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},a.defaultShapeBlendObject={name:"Shape Blend",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("ShapeBlendGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},a.defaultTextObject={name:"Text",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("TextGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},a.defaultInputObject={name:"Input",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("InputGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")}))(q0||(q0={}));var Qs;(i=>{function n(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new lr}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new lr})))):Ks.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=n;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Fl(a.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(o.material.layers)){let h=l.layers.data(c);h&&Cr.patch(h,u)}}).data),a.materials&&o.materials&&(a.materials=Fl(a.materials,l=>{for(let c=0;c<a.materials.length;c++){let u=o.materials[c];if(typeof u!="string")for(let[h,d]of Object.entries(u.layers)){let f=l[c]?.layers?.data(h);f&&Cr.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],c={orthographic:0,perspective:0,geometry:0};function u(h,d){for(let[f,m]of Object.entries(d.layers)){let{texture:p,...g}=m;if(p!==void 0&&Object.keys(p).length>0){let y={path:[...h,"layers",f,"texture"],props:p,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...A0.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")u(["material"],d);else if(h==="materials")for(let[f,m]of Object.entries(d))u(["materials",f],m);else if(c[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}i.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,md.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Ks.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:U0.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bo.merge(a.cloner,o.cloner)});else if(_0.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=Fr.clone(l.color))}return a}i.patch=r})(Qs||(Qs={}));var yd;(t=>t.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,rotationSpeed:1,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})(yd||(yd={}));var Es;(t=>t.defaultData={orbitControls:yd.defaultData,playPage:Gl,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let i=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?i=30:(r===4||r===11||r===9)&&(i=-30),[120,[i,s],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(Es||(Es={}));var kA;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(kA||(kA={}));var zA;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(zA||(zA={}));var Va;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...kA.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:zA.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Va||(Va={}));var ql;(e=>{function n(r){return r.find(i=>i.data.type==="Page"&&i.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,i,s){r.scene.objects.traverseFrom(i,(o,a)=>{if(a.type==="Instance"){let l=Uo.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(ql||(ql={}));var Ua;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:W0.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,h=[]){let d=[],f=q0.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...h);let m=new wr;return m.push({fi:1,id:Gl,data:{...Fa.defaultData,name:"Scene 1"},children:d}),m}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Es.defaultData,styles:Va.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new wr,publish:Es.defaultData,styles:Va.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Es.defaultData,styles:Va.defaultData()}},c.emptyData=function(){return{objects:new wr,publish:{...Es.defaultData},styles:Va.defaultData()}};function a(u){return{...c.defaultData,objects:Ri(u,wr.prototype)}}c.withObjs=a;function l(u,h){return a([{id:u,data:h,children:[],fi:0}])}c.withObj=l})(Ua||(Ua={}));var vd;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(vd||(vd={}));var X0;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new Re}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(X0||(X0={}));var NO;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new Re,queries:new Re,autoStart:!0}))(NO||(NO={}));var Gr;(s=>{function n(o){return o.textValue!==void 0}s.isTextValue=n;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return n(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function i(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=i})(Gr||(Gr={}));var GA;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(GA||(GA={}));var BO;(t=>t.all=[...GA.all,"components"])(BO||(BO={}));var FO;(t=>{function n(){return{images:new He,videos:new He,colors:new He,audios:new He,particles:new He,fonts:new He,materials:new He,components:new He,variables:new He,userAPIs:new He,userWebhooks:new He,timelineAnimations:new He}}t.defaultData=n})(FO||(FO={}));var Zs;(t=>{function n(){return{images:new He,videos:new He,colors:new He,audios:new He,particles:new He,fonts:new He,materials:new He,components:new He,variables:new He,userAPIs:new He,userWebhooks:new He,timelineAnimations:new He}}t.defaultData=n})(Zs||(Zs={}));var An;(s=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ri(o,He.prototype)}s.defaultColors=n;function t(){return Ri({},He.prototype)}s.defaultImages=t;function e(){return{catelogs:new He,materials:new He,images:new He,videos:new He,colors:new He,timelineAnimations:new He,audios:new He,particles:new He,fonts:new He,variables:new Re,userAPIs:new He,userWebhooks:new He,lib:Zs.defaultData()}}s.emptyData=e;function r(o){switch(o){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 a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,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",o)}}s.defaultVariables=r;function i(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),c=Math.floor((o-l*3600)/60),u=Math.round(o-l*3600-c*60);return{textValue:[l,c,u]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),c=Math.round(o-l*60);return{textValue:[l,c]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=i})(An||(An={}));var xd;(t=>t.list=["idle","move","jump","run"])(xd||(xd={}));var bd;(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 Re,move:new Re,jump:new Re,run:new Re},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:At.fromHexAndA(3728051,1)}}))(bd||(bd={}));function VO(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,i=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...Nn(Yr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...Yr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function ka(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function za(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((i,s)=>{i===void 0&&(r.materials[s]=Kr.defaultData(),i=r.materials[s]),typeof i!="string"&&t(i)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Kr.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Kr.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(i=>{i.material&&typeof i.material!="string"&&Object.getPrototypeOf(i.material)!==lr.prototype&&t(i.material)})})}function gX(n){Object.assign(n.scene.publish,{orbitControls:{...yd.defaultData,...Yr(n.scene.publish.orbitControls)}})}function yX(n){Object.assign(n.scene.publish.settings,{video:{...Es.defaultData.settings.video,...Yr(n.scene.publish.settings.video)}})}function vX(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[i,s]of Object.entries(r))if((N0.includes(i)||typeof s=="boolean")&&delete r[i],i==="texture")for(let[o,a]of Object.entries(s))(_O.includes(o)||typeof a=="boolean")&&delete s[o]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(i=>{let s=i;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function xX(n){n.scene.publish.withBackground=!0}function bX(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function SX(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(i=>i+1),r.linear.scale=r.linear.scale.map(i=>i+1))})}function wX(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function AX(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let i=Yr(n.scene.objects.data(r));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Yr(e).booleanExclude!==!0)}})}function EX(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function TX(n){function t(r){Object.setPrototypeOf(r,lr.prototype),r.texture&&Object.setPrototypeOf(r.texture,lr.prototype)}function e(r){Object.setPrototypeOf(r,lr.prototype);for(let i in r)t(r[i])}n.scene.objects.traverse((r,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=Yr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],c=Yr(l).layers;e(c),l.layers=c}})})}function UO(n){n.layers===void 0&&Object.assign(n,Kr.defaultTwoLayerData("lambert"))}function jA(n){!n.layers||n.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let i={...Yr(t),colors:e,steps:r};Object.assign(t,i)}})}function MX(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function kO(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&jA(r)}):"material"in e&&typeof e.material!="string"&&jA(e.material)}),Object.values(n.shared.materials).forEach(t=>jA(t))}function CX(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function PX(n){n.shared.audios=Ri({},He.prototype)}function _X(n){n.shared.videos=Ri({},He.prototype)}function IX(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let i={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,{[e]:i})}})}function DX(n){Object.entries(Yr(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(Yr(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function OX(n){n.scene.publish.settings.web.preload=!1}function zO(n){n.layers&&n.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 GO(n){n.layers&&n.layers.forEach(t=>{PO(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 RX(n){n.shared.fonts=Ri({},He.prototype)}function LX(n){return n.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(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function NX(n){let t=[];n.scene.objects.traverse((e,r)=>{let i=r;if(i.type==="TextFrame"){let s=Kr.defaultTwoLayerData("phong"),o=typeof i.color=="string"?n.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=LX(i.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let l={name:i.name,...li.defaultData,...Ba.defaultData,flatShading:!1,wireframe:!1,geometry:{...Fo.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Yr(i.states),events:Yr(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},c=Yr(n.scene.objects).parent(e);n.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function BX(n){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,r)=>{r.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new Re,move:new Re,jump:new Re}});else{let s=new Re;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:Se.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(u,Nn(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(u,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...u},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Re({fi:0,id:Se.generateUUID(),data:c},{fi:1,id:Se.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function FX(n){n.scene.objects.traverse((t,e)=>{function r(i,s){let o=new Re,a=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(c),l.interaction==="play"?h={...Nn(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")&&(h={...Nn(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:u,id:c,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(c=>c.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Se.generateUUID(),data:{type:i,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function jO(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Cr.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function HO(n){ka(n,jO),za(n,jO)}function VX(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function UX(n){n.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.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 kX(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Kr.defaultTwoLayerData("phong"))})}function zX(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function GX(n){n.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function jX(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function HX(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function WX(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function qX(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function XX(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=bd.defaultDataThirdPerson.navmesh)})})}function YX(n){n.scene.styles||(n.scene.styles=Va.defaultData())}function WO(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function KX(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),za(n,WO),ka(n,WO)}function QX(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Re})})})}function ZX(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function qO(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function XO(n,t){if(t<1&&(za(n,VO),ka(n,VO),n.schema=1),t<2&&(gX(n),n.schema=2),t<3&&(vX(n),n.schema=3),t<4&&(xX(n),n.schema=4),t<5&&(bX(n),n.schema=5),t<6&&(SX(n),n.schema=6),t<7&&(wX(n),n.schema=7),t<8&&(n.schema=8),t<9&&(kO(n),n.schema=9),t<10&&(MX(n),n.schema=10),t<11&&(CX(n),n.schema=11),t<12&&(kO(n),n.schema=12),t<13&&(PX(n),n.schema=13),t<14&&(IX(n),n.schema=14),t<15&&(DX(n),n.schema=15),t<16&&(OX(n),n.schema=16),t<17&&(za(n,zO),ka(n,zO),n.schema=17),t<18&&(za(n,UO),ka(n,UO),n.schema=18),t<19&&(yX(n),n.schema=19),t<20&&(RX(n),NX(n),n.schema=20),t<21&&(BX(n),FX(n),n.schema=21),t<22&&(HO(n),n.schema=22),t<23&&(VX(n),n.schema=23),t<24&&(UX(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(_X(n),t<25&&(n.schema=25)),t<26&&(AX(n),n.schema=26),t<27&&(EX(n),n.schema=27),t<28&&(HO(n),n.schema=28),t<29&&(TX(n),n.schema=29),t<30&&(kX(n),n.schema=30),t<31&&(zX(n),n.schema=31),t<33&&(GX(n),n.schema=33),t<34&&(jX(n),n.schema=34),t<35&&(HX(n),n.schema=35),t<36&&(WX(n),n.schema=36),t<37&&(qX(n),n.schema=37),t<38&&(za(n,GO),ka(n,GO),n.schema=38),t<39&&(XX(n),n.schema=39),t<40&&(YX(n),n.schema=40),t<41&&(KX(n),n.schema=41),t<42&&(QX(n),n.schema=42),t<43&&(ZX(n),n.schema=43),t<99){za(n,qO),ka(n,qO),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=As);let e=Yr(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=Gl,r.insertBefore(null,null,[{id:Gl,data:{...Fa.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Nn(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Nn(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Wl.defaultData,...Nn(n.scene.environment,"usePhysics","gravity")},camera:Yr(n.scene.ownerCamera)??Fa.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==Ua.TRASH_CAN_ID&&r.move(Gl,o.fi,o.id);let i=0,s=0;n.shared.penumbraSize&&n.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=n.shared.penumbraSize[Math.min(i,2)],i+=1):a.type==="SpotLight"&&(a.penumbraSize=n.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Hl.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}function YO(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function JX(n){n.scene.objects.traverse((t,e)=>{let r=e.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"))})}function $X(n){Array.isArray(Yr(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Sd=180/Math.PI;function KO(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Sd)}function QO(n){KO(n),n.type==="Page"&&KO(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Sd))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Sd),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Sd),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Sd,t.extrusion.twist*=Sd),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(Yr(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function eY(n){n.shared.variables=Ri({},He.prototype)}function tY(n){let t=Yr(n.shared.variables);n.shared.variables=Ri(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),Re.prototype)}var ko=122;function Y0(n,t){t(n.data);for(let e of n.children)Y0(e,t)}function rY(n){let t=n.schema??104;t!==ko&&(t<105&&(Y0(n.asset,QO),n.schema=105),t<118&&(Y0(n.asset,ZO),n.schema=118),t<121&&(Y0(n.asset,HA),n.schema=121))}function iY(n){n.shared.particles=Ri({},He.prototype),n.shared.lib&&(n.shared.lib.particles=Zs.defaultData().particles)}function nY(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function sY(n){n.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function oY(n){n.scene.objects.traverse((t,e)=>{Array.isArray(Yr(e.events))!==!1&&e.events?.forEach(r=>{let i=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode=i??"Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode=i==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(o=>{r.gameActions[o]?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),a.type==="Animation"&&(a.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(s=>{s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Once"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}),r.outActions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}))})})}function aY(n){n.shared.userAPIs=Ri({},He.prototype),n.shared.userWebhooks=Ri({},He.prototype),n.shared.lib&&(n.shared.lib.userAPIs=Zs.defaultData().userAPIs,n.shared.lib.userWebhooks=Zs.defaultData().userWebhooks)}function lY(n){n.scene.publish.settings.videoStatic===void 0&&(n.scene.publish.settings.videoStatic=Es.defaultData.settings.videoStatic)}function ZO(n){n.timelineAnimations=Ri({},He.prototype)}function HA(n){console.log("Updating pivot for object:",n.name),n.pivot=[0,0,0],n.pivotRotation=[0,0,0]}function K0(n){let t=n.schema??0;if(t!==ko){console.warn("updating from ",t,"to ",ko),XO(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Es.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(za(n,YO),ka(n,YO),n.schema=101),t<102&&(JX(n),n.schema=102),t<104&&(n.shared.catelogs=new He,n.shared.lib=Zs.defaultData(),n.schema=104),t<105&&(eY(n),n.scene.objects.traverse((e,r)=>{QO(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))rY(e);t<106&&(tY(n),n.schema=106),t<107&&(n.shared.lib.variables=Zs.defaultData().variables,n.schema=107),t<109&&(iY(n),n.schema=109),t<110&&(nY(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{$X(r)}),n.schema=111),t<112&&(sY(n),n.schema=112),t<113&&(oY(n),n.schema=113),t<114&&(n.scene.publish.settings.web.imageQuality===void 0&&(n.scene.publish.settings.web.imageQuality=70),n.schema=114),t<115&&(aY(n),n.schema=115),t<116&&(lY(n),n.schema=116),t<117&&(n.scene.publish.settings.web.pixelRatioMobile===void 0&&(n.scene.publish.settings.web.pixelRatioMobile=0),n.scene.publish.settings.web.pixelRatioDesktop===void 0&&(n.scene.publish.settings.web.pixelRatioDesktop=0),n.schema=117),t<118&&(n.shared.timelineAnimations=Ri({},He.prototype),n.scene.objects.traverse((e,r)=>{ZO(r)}),n.schema=118),t<119&&(n.scene.publish.settings.videoStatic.format=Uo.defaultData.scene.publish.settings.videoStatic.format,n.scene.publish.settings.videoStatic.imageFormat=Uo.defaultData.scene.publish.settings.videoStatic.imageFormat,n.schema=119),t<120&&(n.scene.publish.settings.image.colorSpace="display-p3",n.scene.publish.settings.videoStatic.colorSpace="display-p3",n.schema=120),t<121&&(n.scene.objects.traverse((e,r)=>{HA(r),r.type==="Page"&&HA(r.camera)}),n.schema=121),t<122&&(delete n.scene.publish.settings.video,n.scene.publish.orbitControls.rotationSpeed=Uo.defaultData.scene.publish.orbitControls.rotationSpeed,n.schema=122)}}var Uo;(c=>{c.defaultData={schema:ko,scene:Ua.defaultData,frames:new He().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",vd.defaultData),shared:{...An.emptyData(),colors:An.defaultColors()}},c.emptyDataForImports=function(){let u=Ua.emptyDataWithPage();return{schema:ko,scene:u,frames:new He().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",vd.defaultData),shared:{...An.emptyData(),colors:An.defaultColors(),images:An.defaultImages()}}},c.emptyData=function(){return{schema:ko,scene:Ua.emptyDataWithPage(),frames:new He().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",vd.defaultData),shared:An.emptyData()}},c.clipboard2dData=function(){return{schema:ko,scene:Ua.emptyData(),frames:new He,shared:An.emptyData()}},c.collabHelper={...pm,updateSchema(u){return(u.schema??0)<ko?Fl(u,K0):(u.schema??0)-ko}};function s(u){let h=c.collabHelper.updateSchema(u);return typeof h=="number"?h===0?u:null:h.data}c.updateSchemaDirectly=s;function o(u){return{...u,shared:{...u.shared,lib:Zs.defaultData()}}}c.withoutLib=o;function a(u,h){let d=u.scene.objects.get(h);if(d&&d.data.type==="Component")return d;{let f=u.shared.lib.components[h];if(f)return{...f.asset,id:h}}}c.getComponentData=a;function l(u){let h=Object.values(u.shared.userAPIs);for(let d of h){let f=d.headers;for(let m of f)if(m.data.key.toLowerCase()==="authorization"&&m.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(Uo||(Uo={}));var Q0;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Q0||(Q0={}));var JO;(t=>{function n(e){return!0}t.is=n})(JO||(JO={}));var Z0;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(i,s){return{position:s?.position??i.position,rotation:s?.rotation??i.rotation,scale:s?.scale??i.scale,shear:s?.shear??i.shear}}r.merge=t;function e(i,s){return Wv({position:ss.isEqual(i.position,s.position)?void 0:s.position,rotation:i.rotation===s.rotation?void 0:s.rotation,scale:ss.isEqual(i.scale,s.scale)?void 0:s.scale,shear:i.shear&&s.shear&&ss.isEqual(i.shear,s.shear)?void 0:s.shear})}r.diff=e})(Z0||(Z0={}));var WA;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(WA||(WA={}));var $O;(t=>t.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})($O||($O={}));var J0;(t=>t.defaultData={opacity:1,fill:{color:At.fromHexAndA(ai,1),enabled:!0},stroke:{color:At.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:At.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:At.from0to1([0,0,0,1]),enabled:!1,spread:0}})(J0||(J0={}));var Ga;(s=>{function n(o,a){return{name:a}}s.newEmpty=n;function t(o,a){if(a===void 0)return o;let l={...o},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in a&&a[u]!==void 0&&Object.assign(l,{[u]:a[u]});return l}function e(o,a){if(a===void 0)return o;let l={...o};return"fill"in l&&"fill"in a&&a.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...a.fill}}),"stroke"in l&&"stroke"in a&&a.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...a.stroke}}),"layerBlur"in l&&"layerBlur"in a&&a.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...a.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in a&&a.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...a.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in a&&a.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...a.dropShadow}}),"innerShadow"in l&&"innerShadow"in a&&a.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...a.innerShadow}}),l}function r(o,a){if(a===void 0)return o;let l={...o};return Object.assign(l,Z0.merge(l,a)),l=t(l,a),l=e(l,a),l}s.patch=r;function i(o,a){let l,c=[];for(let[u,h]of Object.entries(a))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=h);return c}s.toOps=i})(Ga||(Ga={}));var wm;(t=>t.defaultData={...Z0.defaultData,...WA.defaultData,states:new Re,events:new Re,visible:!0,raycastLock:!1})(wm||(wm={}));var wd;(t=>t.defaultData={...wm.defaultData,...J0.defaultData})(wd||(wd={}));var $0;(t=>t.defaultData={cornerRadius:[0,0,0,0]})($0||($0={}));var qA;(t=>t.defaultData={...wd.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(qA||(qA={}));var Ad;(t=>t.defaultData={...wd.defaultData,...$0.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Ad||(Ad={}));var XA;(t=>t.defaultData={...wd.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(XA||(XA={}));var YA;(t=>t.defaultData={...wd.defaultData,type:"path2d",path:"",name:"Path"})(YA||(YA={}));var eR;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(eR||(eR={}));var Am;(t=>t.defaultData={...wm.defaultData,name:"Group",type:"group2d"})(Am||(Am={}));var KA;(t=>t.defaultData=()=>({...wm.defaultData,...$0.defaultData,...J0.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:At.fromHexAndA(4737101,1),enabled:!0},stroke:{color:At.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(KA||(KA={}));var ja;(s=>{function n(o){switch(o){case"rectangle2d":return{...Ad.defaultData};case"ellipse2d":return{...qA.defaultData};case"text2d":return{...XA.defaultData};case"vector2d":return{...Ad.defaultData};case"path2d":return{...YA.defaultData};case"frame2d":return{...KA.defaultData()};case"group2d":return{...Am.defaultData}}}s.defaultData=n;function t(o){return"width"in o&&"height"in o?[typeof o.width=="number"?o.width*.5:0,typeof o.height=="number"?o.height*.5:0]:[0,0]}s.getPivot=t;function e(o){return o.type==="rectangle2d"||o.type==="ellipse2d"||o.type==="text2d"||o.type==="frame2d"}s.isResizeable=e;function r(o){return o.type==="frame2d"&&o.autoLayout!==void 0}s.isAutoLayoutable=r;function i(o){return o.type==="rectangle2d"||o.type==="frame2d"}s.hasCorners=i})(ja||(ja={}));var ex;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new wr},e.emptyData=function(){return{type:"scene2d",objects:new wr}}))(ex||(ex={}));function Js(n,t=!1){let e=n[0].index!==null,r=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),s={},o={},a=n[0].morphTargetsRelative,l=new Ce,c=0;for(let u=0;u<n.length;++u){let h=n[u],d=0;if(e!==(h.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 f in h.attributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),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(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.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(c,f,u),c+=f}}if(e){let u=0,h=[];for(let d=0;d<n.length;++d){let f=n[d].index;for(let m=0;m<f.count;++m)h.push(f.getX(m)+u);u+=n[d].attributes.position.count}l.setIndex(h)}for(let u in s){let h=tR(s[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,h)}for(let u in o){let h=o[u][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<h;++d){let f=[];for(let p=0;p<o[u].length;++p)f.push(o[u][p][d]);let m=tR(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(m)}}return l}function tR(n){let t,e,r,i=0;for(let a=0;a<n.length;++a){let l=n[a];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(e===void 0&&(e=l.itemSize),e!==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;i+=l.array.length}let s=new t(i),o=0;for(let a=0;a<n.length;++a)s.set(n[a].array,o),o+=n[a].array.length;return new je(s,e,r)}var aR={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},eE={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},cY=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],tx={CSS:{},springs:{}};function $s(n,t,e){return Math.min(Math.max(n,t),e)}function Em(n,t){return n.indexOf(t)>-1}function QA(n,t){return n.apply(null,t)}var dt={arr:function(n){return Array.isArray(n)},obj:function(n){return Em(Object.prototype.toString.call(n),"Object")},pth:function(n){return dt.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return!("isNode"in n)&&(n.nodeType||dt.svg(n))},str:function(n){return typeof n=="string"},fnc:function(n){return typeof n=="function"},und:function(n){return typeof n>"u"},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return dt.hex(n)||dt.rgb(n)||dt.hsl(n)},key:function(n){return!aR.hasOwnProperty(n)&&!eE.hasOwnProperty(n)&&n!=="targets"&&n!=="keyframes"}};function lR(n){var t=/\(([^)]+)\)/.exec(n);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function cR(n,t){var e=lR(n),r=$s(dt.und(e[0])?1:e[0],.1,100),i=$s(dt.und(e[1])?100:e[1],.1,100),s=$s(dt.und(e[2])?10:e[2],.1,100),o=$s(dt.und(e[3])?0:e[3],.1,100),a=Math.sqrt(i/r),l=s/(2*Math.sqrt(i*r)),c=l<1?a*Math.sqrt(1-l*l):0,u=1,h=l<1?(l*a+-o)/c:-o+a;function d(m){var p=t?t*m/1e3:m;return l<1?p=Math.exp(-p*l*a)*(u*Math.cos(c*p)+h*Math.sin(c*p)):p=(u+h*p)*Math.exp(-p*a),m===0||m===1?m:1-p}function f(){var m=tx.springs[n];if(m)return m;for(var p=1/6,g=0,y=0;;)if(g+=p,d(g)===1){if(y++,y>=16)break}else y=0;var x=g*p*1e3;return tx.springs[n]=x,x}return t?d:f}function uY(n){return n===void 0&&(n=10),function(t){return Math.ceil($s(t,1e-6,1)*n)*(1/n)}}var hY=function(){var n=11,t=1/(n-1);function e(u,h){return 1-3*h+3*u}function r(u,h){return 3*h-6*u}function i(u){return 3*u}function s(u,h,d){return((e(h,d)*u+r(h,d))*u+i(h))*u}function o(u,h,d){return 3*e(h,d)*u*u+2*r(h,d)*u+i(h)}function a(u,h,d,f,m){var p,g,y=0;do g=h+(d-h)/2,p=s(g,f,m)-u,p>0?d=g:h=g;while(Math.abs(p)>1e-7&&++y<10);return g}function l(u,h,d,f){for(var m=0;m<4;++m){var p=o(h,d,f);if(p===0)return h;var g=s(h,d,f)-u;h-=g/p}return h}function c(u,h,d,f){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var m=new Float32Array(n);if(u!==h||d!==f)for(var p=0;p<n;++p)m[p]=s(p*t,u,d);function g(y){for(var x=0,v=1,b=n-1;v!==b&&m[v]<=y;++v)x+=t;--v;var w=(y-m[v])/(m[v+1]-m[v]),A=x+w*t,T=o(A,u,d);return T>=.001?l(y,A,u,d):T===0?A:a(y,x,x+t,u,d)}return function(y){return u===h&&d===f||y===0||y===1?y:s(g(y),h,f)}}return c}(),uR=function(){var n={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 i,s=4;r<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-r,2)}},Elastic:function(r,i){r===void 0&&(r=1),i===void 0&&(i=.5);var s=$s(r,1,10),o=$s(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(r,i){t[r]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(t).forEach(function(r){var i=t[r];n["easeIn"+r]=i,n["easeOut"+r]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},n["easeInOut"+r]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),n}();function tE(n,t){if(dt.fnc(n))return n;var e=n.split("(")[0],r=uR[e],i=lR(n);switch(e){case"spring":return cR(n,t);case"cubicBezier":return QA(hY,i);case"steps":return QA(uY,i);default:return QA(r,i)}}function hR(n){try{var t=document.querySelectorAll(n);return t}catch{return}}function rx(n,t){for(var e=n.length,r=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<e;s++)if(s in n){var o=n[s];t.call(r,o,s,n)&&i.push(o)}return i}function ix(n){return n.reduce(function(t,e){return t.concat(dt.arr(e)?ix(e):e)},[])}function rR(n){return dt.arr(n)?n:(dt.str(n)&&(n=hR(n)||n),n instanceof NodeList||n instanceof HTMLCollection?[].slice.call(n):[n])}function rE(n,t){return n.some(function(e){return e===t})}function iE(n){var t={};for(var e in n)t[e]=n[e];return t}function ZA(n,t){var e=iE(n);for(var r in n)e[r]=t.hasOwnProperty(r)?t[r]:n[r];return e}function nx(n,t){var e=iE(n);for(var r in t)e[r]=dt.und(n[r])?t[r]:n[r];return e}function dY(n){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(n);return t?"rgba("+t[1]+",1)":n}function fY(n){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=n.replace(t,function(a,l,c,u){return l+l+c+c+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),i=parseInt(r[1],16),s=parseInt(r[2],16),o=parseInt(r[3],16);return"rgba("+i+","+s+","+o+",1)"}function pY(n){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(n)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(n),e=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100,s=t[4]||1;function o(d,f,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(f-d)*6*m:m<1/2?f:m<2/3?d+(f-d)*(2/3-m)*6:d}var a,l,c;if(r==0)a=l=c=i;else{var u=i<.5?i*(1+r):i+r-i*r,h=2*i-u;a=o(h,u,e+1/3),l=o(h,u,e),c=o(h,u,e-1/3)}return"rgba("+a*255+","+l*255+","+c*255+","+s+")"}function mY(n){if(dt.rgb(n))return dY(n);if(dt.hex(n))return fY(n);if(dt.hsl(n))return pY(n)}function Ha(n){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(n);if(t)return t[1]}function gY(n){if(Em(n,"translate")||n==="perspective")return"px";if(Em(n,"rotate")||Em(n,"skew"))return"deg"}function JA(n,t){return dt.fnc(n)?n(t.target,t.id,t.total):n}function zo(n,t){return n.getAttribute(t)}function nE(n,t,e){var r=Ha(t);if(rE([e,"deg","rad","turn"],r))return t;var i=tx.CSS[t+e];if(!dt.und(i))return i;var s=100,o=document.createElement(n.tagName),a=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var c=l*parseFloat(t);return tx.CSS[t+e]=c,c}function dR(n,t,e){if(t in n.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=n.style[t]||getComputedStyle(n).getPropertyValue(r)||"0";return e?nE(n,i,e):i}}function sE(n,t){if(dt.dom(n)&&!dt.inp(n)&&(zo(n,t)||dt.svg(n)&&n[t]))return"attribute";if(dt.dom(n)&&rE(cY,t))return"transform";if(dt.dom(n)&&t!=="transform"&&dR(n,t))return"css";if(n[t]!=null)return"object"}function fR(n){if(!!dt.dom(n)){for(var t=n.style.transform||"",e=/(\w+)\(([^)]*)\)/g,r=new Map,i;i=e.exec(t);)r.set(i[1],i[2]);return r}}function yY(n,t,e,r){var i=Em(t,"scale")?1:0+gY(t),s=fR(n).get(t)||i;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),r?nE(n,s,r):s}function oE(n,t,e,r){switch(sE(n,t)){case"transform":return yY(n,t,r,e);case"css":return dR(n,t,e);case"attribute":return zo(n,t);default:return n[t]||0}}function aE(n,t){var e=/^(\*=|\+=|-=)/.exec(n);if(!e)return n;var r=Ha(n)||0,i=parseFloat(t),s=parseFloat(n.replace(e[0],""));switch(e[0][0]){case"+":return i+s+r;case"-":return i-s+r;case"*":return i*s+r}}function pR(n,t){if(dt.col(n))return mY(n);if(/\s/g.test(n))return n;var e=Ha(n),r=e?n.substr(0,n.length-e.length):n;return t?r+t:r}function lE(n,t){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))}function vY(n){return Math.PI*2*zo(n,"r")}function xY(n){return zo(n,"width")*2+zo(n,"height")*2}function bY(n){return lE({x:zo(n,"x1"),y:zo(n,"y1")},{x:zo(n,"x2"),y:zo(n,"y2")})}function mR(n){for(var t=n.points,e=0,r,i=0;i<t.numberOfItems;i++){var s=t.getItem(i);i>0&&(e+=lE(r,s)),r=s}return e}function SY(n){var t=n.points;return mR(n)+lE(t.getItem(t.numberOfItems-1),t.getItem(0))}function gR(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return vY(n);case"rect":return xY(n);case"line":return bY(n);case"polyline":return mR(n);case"polygon":return SY(n)}}function wY(n){var t=gR(n);return n.setAttribute("stroke-dasharray",t),t}function AY(n){for(var t=n.parentNode;dt.svg(t)&&dt.svg(t.parentNode);)t=t.parentNode;return t}function yR(n,t){var e=t||{},r=e.el||AY(n),i=r.getBoundingClientRect(),s=zo(r,"viewBox"),o=i.width,a=i.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function EY(n,t){var e=dt.str(n)?hR(n)[0]:n,r=t||100;return function(i){return{property:i,el:e,svg:yR(e),totalLength:gR(e)*(r/100)}}}function TY(n,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return n.el.getPointAtLength(l)}var r=yR(n.el,n.svg),i=e(),s=e(-1),o=e(1);switch(n.property){case"x":return(i.x-r.x)*r.w;case"y":return(i.y-r.y)*r.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function iR(n,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=pR(dt.pth(n)?n.totalLength:n,t)+"";return{original:r,numbers:r.match(e)?r.match(e).map(Number):[0],strings:dt.str(n)||t?r.split(e):[]}}function vR(n){var t=n?ix(dt.arr(n)?n.map(rR):rR(n)):[];return rx(t,function(e,r,i){return i.indexOf(e)===r})}function xR(n){var t=vR(n);return t.map(function(e,r){return{target:e,id:r,total:t.length,transforms:{list:fR(e)}}})}function MY(n,t){var e=iE(t);if(/^spring/.test(e.easing)&&(e.duration=cR(e.easing)),dt.arr(n)){var r=n.length,i=r===2&&!dt.obj(n[0]);i?n={value:n}:dt.fnc(t.duration)||(e.duration=t.duration/r)}var s=dt.arr(n)?n:[n];return s.map(function(o,a){var l=dt.obj(o)&&!dt.pth(o)?o:{value:o};return dt.und(l.delay)&&(l.delay=a?0:t.delay),dt.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return nx(o,e)})}function CY(n){for(var t=rx(ix(n.map(function(s){return Object.keys(s)})),function(s){return dt.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},r=function(s){var o=t[s];e[o]=n.map(function(a){var l={};for(var c in a)dt.key(c)?c==o&&(l.value=a[c]):l[c]=a[c];return l})},i=0;i<t.length;i++)r(i);return e}function PY(n,t){var e=[],r=t.keyframes;r&&(t=nx(CY(r),t));for(var i in t)dt.key(i)&&e.push({name:i,tweens:MY(t[i],n)});return e}function _Y(n,t){var e={};for(var r in n){var i=JA(n[r],t);dt.arr(i)&&(i=i.map(function(s){return JA(s,t)}),i.length===1&&(i=i[0])),e[r]=i}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function IY(n,t){var e;return n.tweens.map(function(r){var i=_Y(r,t),s=i.value,o=dt.arr(s)?s[1]:s,a=Ha(o),l=oE(t.target,n.name,a,t),c=e?e.to.original:l,u=dt.arr(s)?s[0]:c,h=Ha(u)||Ha(l),d=a||h;return dt.und(o)&&(o=c),i.from=iR(u,d),i.to=iR(aE(o,u),d),i.start=e?e.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=tE(i.easing,i.duration),i.isPath=dt.pth(s),i.isColor=dt.col(i.from.original),i.isColor&&(i.round=1),e=i,i})}var bR={css:function(n,t,e){return n.style[t]=e},attribute:function(n,t,e){return n.setAttribute(t,e)},object:function(n,t,e){return n[t]=e},transform:function(n,t,e,r,i){if(r.list.set(t,e),t===r.last||i){var s="";r.list.forEach(function(o,a){s+=a+"("+o+") "}),n.style.transform=s}}};function SR(n,t){var e=xR(n);e.forEach(function(r){for(var i in t){var s=JA(t[i],r),o=r.target,a=Ha(s),l=oE(o,i,a,r),c=a||Ha(l),u=aE(pR(s,c),l),h=sE(o,i);bR[h](o,i,u,r.transforms,!0)}})}function DY(n,t){var e=sE(n.target,t.name);if(e){var r=IY(t,n),i=r[r.length-1];return{type:e,property:t.name,animatable:n,tweens:r,duration:i.end,delay:r[0].delay,endDelay:i.endDelay}}}function OY(n,t){return rx(ix(n.map(function(e){return t.map(function(r){return DY(e,r)})})),function(e){return!dt.und(e)})}function wR(n,t){var e=n.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=e?Math.max.apply(Math,n.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,i.delay=e?Math.min.apply(Math,n.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return r(s)+o+a+s.delay})):t.delay,i.endDelay=e?i.duration-Math.max.apply(Math,n.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,i}var nR=0;function RY(n){var t=ZA(aR,n),e=ZA(eE,n),r=PY(e,n),i=xR(n.targets),s=OY(i,r),o=wR(s,e),a=nR;return nR++,nx(t,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var Ts=[],sR=[],Ed,$A=function(){let n=0,t=!0;function e(s){let o=Ts.length;if(o){let a=0;for(;a<o;){let l=Ts[a];l.paused?(Ts.splice(a,1),o--):(l.tick(s),a++)}t&&(Ed=requestAnimationFrame(e))}else Ed&&(cancelAnimationFrame(Ed),Ed=null)}function r(){n=performance.now(),Ed=requestAnimationFrame(e)}function i(s){n+=s,e(n)}return{get isUsingInternalRaf(){return t},set isUsingInternalRaf(s){t=s},play:r,update:i}}();function LY(n){!$A.isUsingInternalRaf||(document.hidden?(Ts.forEach(function(t){return t.pause(n.timeStamp)}),sR=Ts.slice(0),ci.running=Ts=[]):sR.forEach(function(t){return t.play(n.timeStamp)}))}typeof document<"u"&&document.addEventListener("visibilitychange",LY);function ci(n){n===void 0&&(n={});var t=0,e=0,r=0,i,s,o=0,a=null;function l(T){var S=window.Promise&&new Promise(function(M){return a=M});return T.finished=S,S}var c=RY(n),u=l(c);function h(){var T=c.direction;T!=="alternate"&&(c.direction=T!=="normal"?"normal":"reverse"),c.reversed=!c.reversed,s.forEach(function(S){(S.loop===1||S.loop%2===0)&&(S.reversed=c.reversed)})}function d(){c.direction="normal",c.reversed=!1,s.forEach(function(T){return T.reversed=!1})}function f(T){return c.reversed?c.duration-T:T}function m(){t=0,e=f(c.currentTime)*(1/ci.speed)}function p(T,S,M=!1){S&&(c.reversed?S.seek(S.duration*S.loop-(T-S.timelineOffset-S.pingPongDelayCorrection),M):S.seek(T-S.timelineOffset-S.startOnceDelay-S.pingPongDelayCorrection,M))}function g(T,S=!1){if(c.reversed)for(var C=o;C--;)p(T,s[C],S);else for(var M=0;M<o;M++)p(T,s[M],S)}function y(T){var S=0,M=c.animations,C=M.length;for(c.direction!=="alternate"&&c.parent?.direction==="alternate"?c.parent?.rewind===!1&&c.reversePlayback===!0&&c.rewind===!1&&(c.parent?.reversed&&c.direction==="alternate"?T=c.duration-c.delay+c.endDelay-T:T=c.duration+c.delay-c.endDelay-T):w(!1,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)&&(c.parent?.reversed&&c.direction==="alternate"?T=c.duration-c.delay+c.endDelay-T:T=c.duration+c.delay-c.endDelay-T);S<C;){var P=M[S],_=P.animatable,I=P.tweens,O=I.length-1,L=I[O];O&&(L=rx(I,function(J){return T<J.end})[0]||L);let re;c.parent?.reversed&&c.direction==="alternate"?re=$s(T-L.start-L.endDelay,0,L.duration)/L.duration:re=$s(T-L.start-L.delay,0,L.duration)/L.duration;for(var j=isNaN(re)?1:L.easing(re),V=L.to.strings,H=L.round,q=[],X=L.to.numbers.length,K=void 0,z=0;z<X;z++){var Q=void 0;let J,Ee;c.direction!=="alternate"?c.parent?.rewind===!1&&c.reversePlayback===!0&&c.rewind===!1?(J=L.to.numbers[z],Ee=L.from.numbers[z]||0):(Ee=L.to.numbers[z],J=L.from.numbers[z]||0):w(!0,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)?(J=L.to.numbers[z],Ee=L.from.numbers[z]||0):(Ee=L.to.numbers[z],J=L.from.numbers[z]||0),L.isPath?Q=TY(L.value,j*Ee):Q=J+j*(Ee-J),H&&(L.isColor&&z>2||(Q=Math.round(Q*H)/H)),q.push(Q)}var te=V.length;if(!te)K=q[0];else{K=V[0];for(var $=0;$<te;$++){var W=V[$],oe=V[$+1],ie=q[$];isNaN(ie)||(oe?K+=ie+oe:K+=ie+" ")}}bR[P.type](_.target,P.property,K,_.transforms),P.currentValue=K,S++}}function x(T){c[T]&&!c.passThrough&&c[T](c)}function v(){c.remaining&&c.remaining!==!0&&c.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(T,S,M,C,P){return b[T<<4|S<<3|M<<2|C<<1|P]}function A(T,S=!1){var M=c.duration;let C=c.delay,P=M-c.endDelay;c.parent?.reversed&&c.direction==="alternate"&&(C=c.endDelay,P=M-c.delay);var _=f(T);if(c.progress=$s(_/M*100,0,100),S||(c.reversePlayback=_<c.currentTime),o&&g(_,S),!c.began&&_>=C&&(c.began=!0),!c.loopBegan&&c.currentTime>0&&(c.loopBegan=!0,x("loopBegin")),(c.reversed||_>=0)&&_<=C&&c.currentTime!==0&&(y(0),x("change")),(_>=P&&c.currentTime!==M+c.pingPongDelayCorrection||!M)&&(y(M),x("change")),_>C&&_<P?(c.changeBegan||(c.changeBegan=!0,c.changeCompleted=!1,x("changeBegin")),y(_),x("change")):c.changeBegan?(c.changeCompleted=!0,c.changeBegan=!1,x("change"),o&&x("timelineChangeComplete")):c.began&&_>P&&x("changeComplete"),c.currentTime=$s(_,0,M+c.pingPongDelayCorrection),c.began&&x("update"),T>=M)if(v(),!c.remaining)c.paused=!0,c.completed||(c.completed=!0,x("loopComplete"),x("complete"),!c.passThrough&&"Promise"in window&&(a(),u=l(c)));else{o?t+=c.duration/ci.speed:t+=c.duration;for(let I of s)I.setStartTime(0),I.remaining=I.loop;x("loopComplete"),c.loopBegan=!1,c.direction==="alternate"?h():o&&d()}}return c.reset=function(){var T=c.direction;c.passThrough=!1,c.currentTime=0,c.progress=0,c.paused=!0,c.began=!1,c.loopBegan=!1,c.changeBegan=!1,c.completed=!1,c.changeCompleted=!1,c.reversed=T==="reverse",c.remaining=c.loop,s=c.children,o=s.length;for(var S=o;S--;)c.children[S].reset();y(c.reversed?c.duration:0)},c.setStartTime=function(T){t=T},c.set=function(T,S){return SR(T,S),c},c.tick=function(T){r=T,t||(t=r),A((r+(e-t))*ci.speed)},c.seek=function(T,S=!1){A(T-t,S)},c.pause=function(T){c.paused=!0,o&&(i=T??performance.now())},c.play=function(T){!c.paused||(c.completed&&c.reset(),c.paused=!1,Ts.push(c),o&&i!==void 0&&(t+=(T??performance.now())-i),!Ed&&$A.isUsingInternalRaf&&$A.play())},c.reverse=function(T=0){h(),c.completed=!c.reversed,t=void 0,e=T},c.restart=function(){c.reset(),t=void 0,e=0,c.play()},c.reset(),c.autoplay&&c.play(),c}function oR(n,t){for(var e=t.length;e--;)rE(n,t[e].animatable.target)&&t.splice(e,1)}function NY(n){for(var t=vR(n),e=Ts.length;e--;){var r=Ts[e],i=r.animations,s=r.children;oR(t,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;oR(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&r.pause()}}function BY(n,t){t===void 0&&(t={});var e=t.direction||"normal",r=t.easing?tE(t.easing):null,i=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",c=o==="last",u=dt.arr(n),h=parseFloat(u?n[0]:n),d=u?parseFloat(n[1]):0,f=Ha(u?n[1]:n)||0,m=t.start||0+(u?h:0),p=[],g=0;return function(y,x,v){if(a&&(o=0),l&&(o=(v-1)/2),c&&(o=v-1),!p.length){for(var b=0;b<v;b++){if(!i)p.push(Math.abs(o-b));else{var w=l?(i[0]-1)/2:o%i[0],A=l?(i[1]-1)/2:Math.floor(o/i[0]),T=b%i[0],S=Math.floor(b/i[0]),M=w-T,C=A-S,P=Math.sqrt(M*M+C*C);s==="x"&&(P=-M),s==="y"&&(P=-C),p.push(P)}g=Math.max.apply(Math,p)}r&&(p=p.map(function(I){return r(I/g)*g})),e==="reverse"&&(p=p.map(function(I){return s?I<0?I*-1:-I:Math.abs(g-I)}))}var _=u?(d-h)/g:h;return m+_*(Math.round(p[x]*100)/100)+f}}function FY(n){n===void 0&&(n={});var t=ci(n);return t.duration=0,t.add=function(e,r){var i=Ts.indexOf(t),s=t.children;i>-1&&Ts.splice(i,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=nx(e,ZA(eE,n));l.targets=l.targets||n.targets;var c=t.duration;l.autoplay=!1,l.timelineOffset=dt.und(r)?c:aE(r,c),o(t);var u=ci(l);o(u),s.push(u),u.parent=t;var h=wR(s,n);return t.delay=h.delay,t.endDelay=h.endDelay,t.duration=h.duration,u.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}ci.version="3.2.0";ci.speed=1;ci.running=Ts;ci.remove=NY;ci.get=oE;ci.set=SR;ci.convertPx=nE;ci.path=EY;ci.setDashoffset=wY;ci.stagger=BY;ci.timeline=FY;ci.easing=tE;ci.penner=uR;ci.random=function(n,t){return Math.floor(Math.random()*(t-n+1))+n};var Ms=ci;var cr=class extends Ge{constructor(e,r,i,s){super(e,r,i);this.isColorA=!0;this.a=s}setRGBA(e,r,i,s){super.setRGB(e,r,i),this.a=s}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)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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}};var{degToRad:Xye,radToDeg:Yye}=Se,AR=new E,ER=new E,TR=new Ye,VY=1e-4;function CR(n,t,e,r){if(r===0)return e.copy(n);if(r===1)return e.copy(t);let i=n.w*t.w+n.x*t.x+n.y*t.y+n.z*t.z;if(i>=1)return e.copy(n);let s=1-i*i;if(s<=Number.EPSILON){let u=1-r;return e.w=u*n.w+r*t.w,e.x=u*n.x+r*t.x,e.y=u*n.y+r*t.y,e.z=u*n.z+r*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-r)*a)/o,c=Math.sin(r*a)/o;return e.w=n.w*l+t.w*c,e.x=n.x*l+t.x*c,e.y=n.y*l+t.y*c,e.z=n.z*l+t.z*c,e}function ii(n,t,e,r,i,s){let o=e[n]!==void 0?e[n]:void 0,a=r[n];if(a==null)return;let l=o!=null?typeof o=="string"?Number(i.getVariable(o)??0):o:t[n],c=typeof a=="string"?Number(i.getVariable(a)??0):a;if(l!==c)return{update:u=>{let h=Se.lerp(l,c,u);s?t[n]=Math.trunc(h):t[n]=h},start:()=>{t[n]=l},end:()=>{t[n]=c}}}function Mm(n,t,e,r,i,s){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let l=t[n],c=[...o??l].map(h=>typeof h=="string"?Number(i.getVariable(h)??0):h),u=[...a].map(h=>typeof h=="string"?Number(i.getVariable(h)??0):h);if(!(c.length!==u.length||Qc(c,u)))return{update:h=>{c.forEach((d,f)=>{let m=Se.lerp(d,u[f],h);t[n][f]=s?Math.trunc(m):m})},start:()=>{Object.assign(t[n],c)},end:()=>{Object.assign(t[n],u)}}}function Tm(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function cE(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=s?Tm(new E,s,i):a.clone(),c=Tm(new E,o,i);if(!l.equals(c))return{update:u=>{a.lerpVectors(l,c,u)},start:()=>{a.copy(l)},end:()=>{a.copy(c)}}}function MR(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function Td(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=!(a instanceof U),c=a instanceof U?a:new U().fromArray(a),u=s?MR(new U,s,i):c.clone(),h=MR(new U,o,i);if(!u.equals(h))return{update:d=>{c.lerpVectors(u,h,d),l&&(t[n]=c.toArray())},start:()=>{c.copy(u),l&&(t[n]=c.toArray())},end:()=>{c.copy(h),l&&(t[n]=c.toArray())}}}function PR(n,t,e,r){let i=e[n]?e[n]:void 0,s=r[n];if(!s)return;let o=t[n],a=i?new ue().fromArray(i):o.clone(),l=new E,c=new Ye,u=new E;a.decompose(l,c,u);let h=new ue().fromArray(s),d=new E,f=new Ye,m=new E;if(h.decompose(d,f,m),!a.equals(h))return{update:p=>{TR.slerpQuaternions(c,f,p),AR.lerpVectors(l,d,p),ER.lerpVectors(u,m,p),o.compose(AR,TR,ER)},start:()=>{o.compose(l,c,u)},end:()=>{o.compose(d,f,m)}}}function _R(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=s?typeof s=="string"?i.getColor(s).clone():new Ge().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new Ge().setRGB(o.r,o.g,o.b);if(l.equals(c))return;let u=a.clone();return{update:h=>{u.lerpColors(l,c,h),t[n]?.copy?.(u)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function Cm(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=new cr(a.r,a.g,a.b,a.a),c=s?typeof s=="string"?i.getColor(s).clone():new cr(s.r,s.g,s.b,s.a):l.clone(),u=typeof o=="string"?i.getColor(o).clone():new cr(o.r,o.g,o.b,o.a);if(!c.equals(u))return{update:h=>{l.lerpColors(c,u,h);let d=Se.lerp(c.a,u.a,h);l.a=d,t[n]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(c)},end:()=>{l.copy(u)}}}function Go(n,t,e,r,i){if(typeof t[n]=="number")return ii(n,t,e??{},r,i);if(Array.isArray(t[n]))return Mm(n,t,e??{},r,i)}var Kye=new Jt;function jo(n,t,e,r,i){let s=e[n],o=r[n];if(typeof t[n]=="number")Math.abs(s-o)>VY&&(t[n]=Se.lerp(s,o,i));else if(Array.isArray(t[n]))for(let a=0,l=s.length;a<l;a++)t[n][a]=Se.lerp(s[a],o[a],i)}function IR(n,t,e,r){let i=[];if(!("cloner"in e)||!n.cloner)return i;let s=n.cloner,o="cloner"in t?t.cloner:{},a=e.cloner;PA.forEach(f=>{let m;f==="count"?m=ii("count",s.parameters,o,a,r.shared,!0):m=Go(f,s.parameters,o??{},a,r.shared),m&&i.push(m)});let l=UY(s,o,a,r.shared);l?.length&&i.push(...l);let c=kY(s,o,a,r.shared);c?.length&&i.push(...c);let u=zY(s,o,a,r.shared);u?.length&&i.push(...u);let h=GY(s,o,a,r.shared);h?.length&&i.push(...h);let d=jY(s,o,a,r.shared);return d?.length&&i.push(...d),i.length&&i.push({update:()=>{s.update(r)}}),i}function UY(n,t,e,r){if(n.parameters.type!=="radial")return;let i=t.radial,s=e.radial;if(!s)return;let o=n.parameters.radial,a=[];return E0.forEach(l=>{let c=Go(l,o,i??{},s,r);c&&a.push(c)}),a}function kY(n,t,e,r){if(n.parameters.type!=="linear")return;let i=t.linear,s=e.linear;if(!s)return;let o=[],a=n.parameters.linear;return T0.forEach(l=>{let c=Go(l,a,i??{},s,r);c&&o.push(c)}),o}function zY(n,t,e,r){if(n.parameters.type!=="grid")return;let i=t.grid,s=e.grid;if(!s)return;let o=[],a=n.parameters.grid;return M0.forEach(l=>{let c;l==="count"?c=Mm(l,a,i??{},s,r,!0):c=Go(l,a,i??{},s,r),c&&o.push(c)}),o}function GY(n,t,e,r){if(n.parameters.type!=="toObject")return;let i=t.toObject,s=e.toObject;if(!s)return;let o=[],a=n.parameters.toObject;return C0.forEach(l=>{let c;l==="count"?c=ii(l,a,i??{},s,r,!0):c=Go(l,a,i??{},s,r),c&&o.push(c)}),o}function jY(n,t,e,r){if(!n.parameters.randomness)return;let i=t.randomnessObject,s=e.randomnessObject;if(!s)return;let o=[],a=n.parameters.randomnessObject;return P0.forEach(l=>{let c=Go(l,a,i??{},s,r);c&&o.push(c)}),o}function DR(n,t,e,r){let i=r.cloner?.parameters;if(!!i){jo("count",i,n,t,e),i.count=Math.trunc(i.count);for(let s of E0)jo(s,i.radial,n.radial,t.radial,e);for(let s of T0)jo(s,i.linear,n.linear,t.linear,e);for(let s of M0)jo(s,i.grid,n.grid,t.grid,e);for(let s of C0)jo(s,i.toObject,n.toObject,t.toObject,e);return i}}function OR(n,t,e,r){let i=r.cloner?.parameters;if(!!i){for(let s of P0)jo(s,i.randomnessObject,n.randomnessObject,t.randomnessObject,e);return i}}function wi(n,t=[0,0]){!1&&n&&(isNaN(n[0])||isNaN(n[1]))&&console.warn("Invalid cubic bezier control point with NaN value. Using fallback instead.",n);let e=n&&!isNaN(n[0])?n[0]:t[0],r=n&&!isNaN(n[1])?n[1]:t[1];return[e,r]}function En(n,t,e){switch(n){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:let{control1:r,control2:i}=t??{...cd.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${i[0]}, ${i[1]} )`;case 6:let{mass:s,stiffness:o,damping:a,velocity:l}=e??{...ld.defaultData},c=new uE(s,o,a,l),u=c.solve(1);return()=>h=>c.solve(h)/u;case 8:return()=>h=>Math.floor(h)}}var RR;(t=>{function n(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}t.is=n})(RR||(RR={}));var sx;(a=>{function n(l,c){let u=[0,0],h=[1,1];if(l?.cubicControls)u=wi(l.cubicControls.control1,u);else switch(l?.type){case 2:u=[.42,0];break;case 3:u=[0,0];break;case 4:u=[.42,0];break;case 1:u=[.25,.1];break;case 0:u=[0,0];break;case 7:u=[.25,1];break}if(c?.cubicControls)h=wi(c.cubicControls.control2,h);else switch(c?.type){case 2:h=[1,1];break;case 3:h=[.58,1];break;case 4:h=[.58,1];break;case 1:h=[.25,1];break;case 0:h=[1,1];break;case 7:h=[.5,1];break}return{control1:u,control2:h}}a.getControlsWithDefault=n;function t(l,c){return{id:l,name:c,to:5,properties:new Re}}a.defaultData=t;function e(l){let c=new Re;return l.forEach(({data:u,id:h,fi:d})=>{if(u.type==="light"){let f=LR(["material",`${u.category} lighting`],h,d);c.push(f)}else{let f=LR(["material",u.type],h,d);c.push(f)}}),c}a.createMaterialGroup=e;function r(l){return Object.entries(l).reduce((c,[u,h])=>(typeof h!="string"&&c.push({name:h.name}),c),[])}a.createName=r;function i(l,c,u){let h=Ms.timeline({easing:En(0),begin(){l.resetBBoxNeedsUpdate()},change(){l.resetBBoxNeedsUpdate()},direction:c.direction,autoplay:!1});return s(l,c,u).forEach(f=>h.add(f,0)),h.duration=c.to*1e3,h}a.createTimeline=i;function s(l,c,u,h){let d=[];return c.properties.forEach((f,m)=>{let p=f.data.path?.[0];if(p&&["position","rotation","scale"].includes(p)){let g=HY(f.data,u?.[p]);g&&d.push(...g)}if(p&&p==="shape size"&&"geometry"in l){let g=WY(l,f.data,u?.shapeSize);g&&d.push(...g)}if(p&&p==="path extrusion"&&l instanceof qo){let g=qY(l,f.data,u?.pathExtrusion);g&&d.push(g)}if(p&&p==="path snapping"&&l.data.pathSnapping){let g=XY(l,f.data,u?.pathSnapping);g&&d.push(g)}if(p&&p==="material"&&l.type==="Mesh"&&"material"in l&&l.material instanceof fn){let g=f.data.id;if(g){let y=l.material.getLayerByUuid(g);if(y){let x=NR(y,f.data,u?.material,h);x&&d.push(x)}else{let x=l.material.getLayersOfType(f.data.type);if(x)for(let v of x){let b=NR(v,f.data,u?.material,h);b&&d.push(b)}}}}if(p&&p==="opacity"&&l.type==="Mesh"&&"material"in l){let g=YY(f.data,u?.opacity);g&&d.push(g)}if(p&&p==="cloner"){let g=KY(l,f.data,u?.cloner);g&&d.push(g)}if(p&&p==="camera"&&l instanceof ir){let g=QY(l,f.data,u?.camera,"zoom");g&&d.push(g)}if(p&&p==="light"&&(l instanceof Ho||l instanceof Xl||l instanceof Wo)){let g=ZY(l,f.data,u?.light,f.data.path[1],h);g&&d.push(g)}}),d}a.addKeyframesToTimeline=s,a.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:En(3),duration:1e3},opacity:{value:[0,1],easing:En(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:En(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:En(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:En(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(sx||(sx={}));function LR(n,t,e){let r=t;return{id:r,fi:e,data:{id:r,path:n,keyframes:new Re}}}var BR=["x","y","z"];function HY(n,t=()=>{}){let e=[];for(let r of BR){let i=[...n.keyframes??[]].filter(a=>a.data.value[r]!==void 0).sort((a,l)=>a.data.time-l.data.time),s=i[0];s&&t?.(s.data.value);let o={index:[],t:[]};for(let a=0;a<i.length-1;a++){let l=i[a],c=i[a+1]??l,u={duration:(c?.data?.time-l.data.time)*1e3,delay:a===0?i[0].data.time*1e3:0};a<i.length-1&&(o.t.push({...u,value:a%2===0?1:0,easing:En(l.data.easing.type,{control1:wi(l.data.easing.cubicControls?.control1,[0,0]),control2:wi(c.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters)}),o.index.push({...u,value:a,easing:"linear"}))}if(i.length>1){let a={t:0,index:0};e.push({targets:a,...o,update:l=>{let c=Math.ceil(a.index),u=c%2===0?a.t:1-a.t,h=i?.[c].data.value,d=i?.[c+1]?.data.value;if(h!==void 0&&d!==void 0){let f={[r]:h[r]+(d[r]-h[r])*u};t?.(f)}}})}}return e}function WY(n,t,e){let r=[];for(let i of BR){let s={},o=[...t.keyframes??[]].filter(l=>l.data.value[i]!==void 0).sort((l,c)=>l.data.time-c.data.time),a=o[0];a&&e?.(a.data.value),s={index:[],t:[]};for(let l=0;l<o.length-1;l++){let c=o[l],u=o[l+1]??c,h={duration:(u?.data?.time-c.data.time)*1e3,delay:l===0?o[0].data.time*1e3:0};l<o.length-1&&(s.t.push({...h,value:l%2===0?1:0,easing:En(c.data.easing.type,{control1:wi(c.data.easing.cubicControls?.control1,[0,0]),control2:wi(u.data.easing.cubicControls?.control2,[1,1])},c.data.easing.springParameters)}),s.index.push({...h,value:l,easing:"linear"}))}if(o.length>1){let l={t:0,index:0};r.push({targets:l,...s,update:c=>{let u=Math.ceil(l.index),h=u%2===0?l.t:1-l.t,d=o?.[u].data.value,f=o?.[u+1]?.data.value;if(d!==void 0&&f!==void 0){let m={[i]:d[i]+(f[i]-d[i])*h};e?.(m)}}})}}return r}function qY(n,t,e){let r={},i=[...t.keyframes??[]].sort((o,a)=>o.data.time-a.data.time),s=i[0];s&&e?.(n,s.data.value),r={index:[],t:[]};for(let o=0;o<i.length-1;o++){let a=i[o],l=i[o+1]??a,c={duration:(l?.data?.time-a.data.time)*1e3,delay:o===0?i[0].data.time*1e3:0};o<i.length-1&&(r.t.push({...c,value:o%2===0?1:0,easing:En(a.data.easing.type,{control1:wi(a.data.easing.cubicControls?.control1,[0,0]),control2:wi(l.data.easing.cubicControls?.control2,[1,1])},a.data.easing.springParameters)}),r.index.push({...c,value:o,easing:"linear"}))}if(i.length>1){let o={t:0,index:0};return{targets:o,...r,update:a=>{let l=Math.ceil(o.index),c=l%2===0?o.t:1-o.t,u=i?.[Math.min(l,i.length-1)].data.value,h=i?.[Math.min(l,i.length-1)+1]?.data.value;e?.(n,FR(n,u,h,c))}}}}function XY(n,t,e){let r={},i=[...t.keyframes??[]].sort((o,a)=>o.data.time-a.data.time),s=i[0];s&&e?.(s.data.value),r={index:[],t:[]};for(let o=0;o<i.length-1;o++){let a=i[o],l=i[o+1]??a,c={duration:(l?.data?.time-a.data.time)*1e3,delay:o===0?i[0].data.time*1e3:0};o<i.length-1&&(r.t.push({...c,value:o%2===0?1:0,easing:En(a.data.easing.type,{control1:wi(a.data.easing.cubicControls?.control1,[0,0]),control2:wi(l.data.easing.cubicControls?.control2,[1,1])},a.data.easing.springParameters)}),r.index.push({...c,value:o,easing:"linear"}))}if(i.length>1){let o={t:0,index:0};return{targets:o,...r,update:a=>{let l=Math.ceil(o.index),c=l%2===0?o.t:1-o.t,u=i?.[Math.min(l,i.length-1)].data.value,h=i?.[Math.min(l,i.length-1)+1]?.data.value;e?.(VR(n,u,h,c))}}}}function NR(n,t,e,r){if(t){let i={},s=[...t.keyframes??[]].sort((o,a)=>o.data.time-a.data.time);if("data"in n){let o=s[0];o&&e?.(o.data.value,n),i={index:[],t:[]};for(let a=0;a<s.length-1;a++){let l=s[a],c=s[a+1]??l,u={duration:(c?.data?.time-l.data.time)*1e3,delay:a===0?s[0].data.time*1e3:0};a<s.length-1&&(i.t.push({...u,value:a%2===0?1:0,easing:En(l.data.easing.type,{control1:wi(l.data.easing.cubicControls?.control1,[0,0]),control2:wi(c.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters)}),i.index.push({...u,value:a,easing:"linear"}))}if(s.length>1){let a={t:0,index:0};return{targets:a,...i,update:l=>{let c=Math.ceil(a.index),u=c%2===0?a.t:1-a.t,h=s?.[Math.min(c,s.length-1)].data.value,d=s?.[Math.min(c,s.length-1)+1]?.data.value,f={},m={};if(Object.keys(h).length>0&&Object.keys(d).length>0){for(let p in n.data)if(p in h&&p in d){let g=hE(h[p],d[p],u,r);g!==void 0&&(f[p]=g,m[p]={start:h,end:d,t:u})}}e?.({...f},n,m)}}}}}}function YY(n,t){if(n){let e={},r=[...n.keyframes??[]].sort((s,o)=>s.data.time-o.data.time),i=r[0];i&&t?.(i.data.value),e={index:[],t:[]};for(let s=0;s<r.length-1;s++){let o=r[s],a=r[s+1]??o,l={duration:(a?.data?.time-o.data.time)*1e3,delay:s===0?r[0].data.time*1e3:0};s<r.length-1&&(e.t.push({...l,value:s%2===0?1:0,easing:En(o.data.easing.type,{control1:wi(o.data.easing.cubicControls?.control1,[0,0]),control2:wi(a.data.easing.cubicControls?.control2,[1,1])},o.data.easing.springParameters)}),e.index.push({...l,value:s,easing:"linear"}))}if(r.length>1){let s={t:0,index:0};return{targets:s,...e,update:o=>{let a=Math.ceil(s.index),l=a%2===0?s.t:1-s.t,c=r?.[Math.min(a,r.length-1)].data.value,u=r?.[Math.min(a,r.length-1)+1]?.data.value,h=Se.lerp(c,u,l);t?.(h)}}}}}function KY(n,t,e){let r={},i=[...t.keyframes??[]].sort((o,a)=>o.data.time-a.data.time),s=i[0];s&&e?.(n,s.data.value,s.data.value),r={index:[],t:[]};for(let o=0;o<i.length-1;o++){let a=i[o],l=i[o+1]??a,c={duration:(l?.data?.time-a.data.time)*1e3,delay:o===0?i[0].data.time*1e3:0};o<i.length-1&&(r.t.push({...c,value:o%2===0?1:0,easing:En(a.data.easing.type,{control1:wi(a.data.easing.cubicControls?.control1,[0,0]),control2:wi(l.data.easing.cubicControls?.control2,[1,1])},a.data.easing.springParameters)}),r.index.push({...c,value:o,easing:"linear"}))}if(i.length>1){let o={t:0,index:0};return{targets:o,...r,update:a=>{let l=Math.ceil(o.index),c=l%2===0?o.t:1-o.t,u=i?.[Math.min(l,i.length-1)].data.value,h=i?.[Math.min(l,i.length-1)+1]?.data.value;e?.(n,u.randomnessObject?void 0:DR(u,h,c,n),u.randomnessObject?OR(u,h,c,n):void 0)}}}}function hE(n,t,e,r){if(typeof n=="string"&&r&&(n=r.color(n)),typeof t=="string"&&r&&(n=r.color(t)),typeof n=="number")return n===t?void 0:Se.lerp(n,t,e);if(At.is(n))return At.lerp(n,t,e);if(Fr.is(n))return Fr.lerp(n,t,e);if(Array.isArray(n))return(n.length>t.length?t:n).map((s,o,a)=>{if(Array.isArray(s)){let l=n[o].length>t[o].length?t[o].length:n[o].length;return(l===4?eu:l===3?ws:ss).lerp(n[o],t[o],e)}else return Se.lerp(n[o],t[o],e)});if(typeof n=="object"&&n!==null){let i={};for(let s in n){let o=hE(n[s],t[s],e,r);o!==void 0&&(i[s]=o)}return i}}function QY(n,t,e,r){if(t){let i={[r]:[]},s=[...t.keyframes??[]].sort((a,l)=>a.data.time-l.data.time),o=s[0];o&&(n[r]=o.data.value,o&&e?.(r,o.data.value));for(let a=0;a<s.length-1;a++){let l=s[a];if(!Number.isFinite(l.data.value))continue;let c=s[a+1]??l,u=c.data.value;i[r].push({value:u,easing:En(l.data.easing.type,{control1:wi(l.data.easing.cubicControls?.control1,[0,0]),control2:wi(c.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters),duration:(c?.data?.time-l.data.time)*1e3,delay:a===0?s[0].data.time*1e3:0})}if(s.length>1)return{targets:n,...i,update:()=>{e?.(r,n[r])}}}}function ZY(n,t,e,r,i){if(t){let s={},o=[...t.keyframes??[]].sort((l,c)=>l.data.time-c.data.time),a=o[0];if(a){let l=a.data.value;n[r]=l,e?.(r,l)}s={index:[],t:[]};for(let l=0;l<o.length-1;l++){let c=o[l],u=o[l+1]??c,h={duration:(u?.data?.time-c.data.time)*1e3,delay:l===0?o[0].data.time*1e3:0};l<o.length-1&&(s.t.push({...h,value:l%2===0?1:0,easing:En(c.data.easing.type,{control1:wi(c.data.easing.cubicControls?.control1,[0,0]),control2:wi(u.data.easing.cubicControls?.control2,[1,1])},c.data.easing.springParameters)}),s.index.push({...h,value:l,easing:"linear"}))}if(o.length>1){let l={t:0,index:0};return{targets:l,...s,update:()=>{let c=Math.ceil(l.index),u=c%2===0?l.t:1-l.t,h=o?.[Math.min(c,o.length-1)].data.value,d=o?.[Math.min(c,o.length-1)+1]?.data.value,f=hE(h,d,u,i);e?.(r,f)}}}}}var uE=class{constructor(t=1,e=100,r=10,i=0){this.mass=t,this.stiffness=e,this.damping=r,this.initialVelocity=i,this.m_w0=Math.sqrt(e/t),this.m_zeta=r/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0+-i)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-i+this.m_w0)}solve(t){return this.m_zeta<1?t=Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):t=(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0),1-t}getDuration(){let t=.16666666666666666,e=0,r=0;for(;;)if(e+=t,this.solve(e)===1){if(r++,r>=16)break}else r=0;return e*t*1e3}};var UR=Math.pow(2,-24);var nu=class{constructor(){}};function Cs(n,t,e){return e.min.x=t[n],e.min.y=t[n+1],e.min.z=t[n+2],e.max.x=t[n+3],e.max.y=t[n+4],e.max.z=t[n+5],e}function dE(n){let t=-1,e=-1/0;for(let r=0;r<3;r++){let i=n[r+3]-n[r];i>e&&(e=i,t=r)}return t}function fE(n,t){t.set(n)}function pE(n,t,e){let r,i;for(let s=0;s<3;s++){let o=s+3;r=n[s],i=t[s],e[s]=r<i?r:i,r=n[o],i=t[o],e[o]=r>i?r:i}}function Pm(n,t,e){for(let r=0;r<3;r++){let i=t[n+2*r],s=t[n+2*r+1],o=i-s,a=i+s;o<e[r]&&(e[r]=o),a>e[r+3]&&(e[r+3]=a)}}function Md(n){let t=n[3]-n[0],e=n[4]-n[1],r=n[5]-n[2];return 2*(t*e+e*r+r*t)}function eK(n,t){if(!n.index){let e=n.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;e>65535?i=new Uint32Array(new r(4*e)):i=new Uint16Array(new r(2*e)),n.setIndex(new je(i,1));for(let s=0;s<e;s++)i[s]=s}}function tK(n){if(!n.groups||!n.groups.length)return[{offset:0,count:n.index.count/3}];let t=[],e=new Set;for(let i of n.groups)e.add(i.start),e.add(i.start+i.count);let r=Array.from(e.values()).sort((i,s)=>i-s);for(let i=0;i<r.length-1;i++){let s=r[i],o=r[i+1];t.push({offset:s/3,count:(o-s)/3})}return t}function gE(n,t,e,r,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,m=-1/0,p=-1/0,g=-1/0,y=i!==null;for(let x=t*6,v=(t+e)*6;x<v;x+=6){let b=n[x+0],w=n[x+1],A=b-w,T=b+w;A<s&&(s=A),T>l&&(l=T),y&&b<h&&(h=b),y&&b>m&&(m=b);let S=n[x+2],M=n[x+3],C=S-M,P=S+M;C<o&&(o=C),P>c&&(c=P),y&&S<d&&(d=S),y&&S>p&&(p=S);let _=n[x+4],I=n[x+5],O=_-I,L=_+I;O<a&&(a=O),L>u&&(u=L),y&&_<f&&(f=_),y&&_>g&&(g=_)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=c,r[5]=u,y&&(i[0]=h,i[1]=d,i[2]=f,i[3]=m,i[4]=p,i[5]=g)}function rK(n,t,e,r){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=t*6,h=(t+e)*6;u<h;u+=6){let d=n[u+0];d<i&&(i=d),d>a&&(a=d);let f=n[u+2];f<s&&(s=f),f>l&&(l=f);let m=n[u+4];m<o&&(o=m),m>c&&(c=m)}r[0]=i,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=c}function iK(n,t,e,r,i){let s=e,o=e+r-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let c=0;c<3;c++){let u=n[s*3+c];n[s*3+c]=n[o*3+c],n[o*3+c]=u;let h=t[s*6+c*2+0];t[s*6+c*2+0]=t[o*6+c*2+0],t[o*6+c*2+0]=h;let d=t[s*6+c*2+1];t[s*6+c*2+1]=t[o*6+c*2+1],t[o*6+c*2+1]=d}s++,o--}else return s}}var Wa=32,nK=(n,t)=>n.candidate-t.candidate,Yl=new Array(Wa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ox=new Float32Array(6);function sK(n,t,e,r,i,s){let o=-1,a=0;if(s===0)o=dE(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=dE(n),o!==-1&&(a=oK(e,r,i,o));else if(s===2){let l=Md(n),c=1.25*i,u=r*6,h=(r+i)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/Wa;if(i<Wa/4){let y=[...Yl];y.length=i;let x=0;for(let b=u;b<h;b+=6,x++){let w=y[x];w.candidate=e[b+2*d],w.count=0;let{bounds:A,leftCacheBounds:T,rightCacheBounds:S}=w;for(let M=0;M<3;M++)S[M]=1/0,S[M+3]=-1/0,T[M]=1/0,T[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;Pm(b,e,A)}y.sort(nK);let v=i;for(let b=0;b<v;b++){let w=y[b];for(;b+1<v&&y[b+1].candidate===w.candidate;)y.splice(b+1,1),v--}for(let b=u;b<h;b+=6){let w=e[b+2*d];for(let A=0;A<v;A++){let T=y[A];w>=T.candidate?Pm(b,e,T.rightCacheBounds):(Pm(b,e,T.leftCacheBounds),T.count++)}}for(let b=0;b<v;b++){let w=y[b],A=w.count,T=i-w.count,S=w.leftCacheBounds,M=w.rightCacheBounds,C=0;A!==0&&(C=Md(S)/l);let P=0;T!==0&&(P=Md(M)/l);let _=1+1.25*(C*A+P*T);_<c&&(o=d,c=_,a=w.candidate)}}else{for(let v=0;v<Wa;v++){let b=Yl[v];b.count=0,b.candidate=f+g+v*g;let w=b.bounds;for(let A=0;A<3;A++)w[A]=1/0,w[A+3]=-1/0}for(let v=u;v<h;v+=6){let A=~~((e[v+2*d]-f)/g);A>=Wa&&(A=Wa-1);let T=Yl[A];T.count++,Pm(v,e,T.bounds)}let y=Yl[Wa-1];fE(y.bounds,y.rightCacheBounds);for(let v=Wa-2;v>=0;v--){let b=Yl[v],w=Yl[v+1];pE(b.bounds,w.rightCacheBounds,b.rightCacheBounds)}let x=0;for(let v=0;v<Wa-1;v++){let b=Yl[v],w=b.count,A=b.bounds,S=Yl[v+1].rightCacheBounds;w!==0&&(x===0?fE(A,ox):pE(A,ox,ox)),x+=w;let M=0,C=0;x!==0&&(M=Md(ox)/l);let P=i-x;P!==0&&(C=Md(S)/l);let _=1+1.25*(M*x+C*P);_<c&&(o=d,c=_,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function oK(n,t,e,r){let i=0;for(let s=t,o=t+e;s<o;s++)i+=n[s*6+r*2];return i/e}function aK(n,t){let e=n.attributes.position,r=n.index.array,i=r.length/3,s=new Float32Array(i*6),o=e.normalized,a=e.array,l=e.offset||0,c=3;e.isInterleavedBufferAttribute&&(c=e.data.stride);let u=["getX","getY","getZ"];for(let h=0;h<i;h++){let d=h*3,f=h*6,m,p,g;o?(m=r[d+0],p=r[d+1],g=r[d+2]):(m=r[d+0]*c+l,p=r[d+1]*c+l,g=r[d+2]*c+l);for(let y=0;y<3;y++){let x,v,b;o?(x=e[u[y]](m),v=e[u[y]](p),b=e[u[y]](g)):(x=a[m+y],v=a[p+y],b=a[g+y]);let w=x;v<w&&(w=v),b<w&&(w=b);let A=x;v>A&&(A=v),b>A&&(A=b);let T=(A-w)/2,S=y*2;s[f+S+0]=w+T,s[f+S+1]=T+(Math.abs(w)+T)*UR,w<t[y]&&(t[y]=w),A>t[y+3]&&(t[y+3]=A)}}return s}function lK(n,t){function e(y){d&&d(y/f)}function r(y,x,v,b=null,w=0){if(!m&&w>=l&&(m=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(n))),v<=u||w>=l)return e(x+v),y.offset=x,y.count=v,y;let A=sK(y.boundingData,b,o,x,v,h);if(A.axis===-1)return e(x+v),y.offset=x,y.count=v,y;let T=iK(a,o,x,v,A);if(T===x||T===x+v)e(x+v),y.offset=x,y.count=v;else{y.splitAxis=A.axis;let S=new nu,M=x,C=T-x;y.left=S,S.boundingData=new Float32Array(6),gE(o,M,C,S.boundingData,s),r(S,M,C,s,w+1);let P=new nu,_=T,I=v-C;y.right=P,P.boundingData=new Float32Array(6),gE(o,_,I,P.boundingData,s),r(P,_,I,s,w+1)}return y}eK(n,t);let i=new Float32Array(6),s=new Float32Array(6),o=aK(n,i),a=n.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=n.index.count/3,m=!1,p=[],g=tK(n);if(g.length===1){let y=g[0],x=new nu;x.boundingData=i,rK(o,y.offset,y.count,s),r(x,y.offset,y.count,s),p.push(x)}else for(let y of g){let x=new nu;x.boundingData=new Float32Array(6),gE(o,y.offset,y.count,x.boundingData,s),r(x,y.offset,y.count,s),p.push(x)}return p}function GR(n,t){let e=lK(n,t),r,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<e.length;u++){let h=e[u],d=l(h),f=new a(32*d);r=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),c(0,h),o.push(f)}return o;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function c(u,h){let d=u/4,f=u/2,m=!!h.count,p=h.boundingData;for(let g=0;g<6;g++)r[d+g]=p[g];if(m){let g=h.offset,y=h.count;return i[d+6]=g,s[f+14]=y,s[f+15]=65535,u+32}else{let g=h.left,y=h.right,x=h.splitAxis,v;if(v=c(u+32,g),v/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[d+6]=v/4,v=c(v,y),i[d+7]=x,v}}}var Fn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];r=l<r?l:r,i=l>i?l:i}this.min=r,this.max=i}setFromPoints(t,e){let r=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);r=l<r?l:r,i=l>i?l:i}this.min=r,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};Fn.prototype.setFromBox=function(){let n=new E;return function(e,r){let i=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){n.x=i.x*l+s.x*(1-l),n.y=i.y*c+s.y*(1-c),n.z=i.z*u+s.z*(1-u);let h=e.dot(n);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var Nve=function(){let n=new Fn;return function(e,r){let i=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,c=r.satBounds;for(let u=0;u<3;u++){let h=o[u],d=s[u];if(n.setFromPoints(d,a),h.isSeparated(n))return!1}for(let u=0;u<3;u++){let h=c[u],d=l[u];if(n.setFromPoints(d,i),h.isSeparated(n))return!1}}}();var cK=function(){let n=new E,t=new E,e=new E;return function(i,s,o){let a=i.start,l=n,c=s.start,u=t;e.subVectors(a,c),n.subVectors(i.end,i.start),t.subVectors(s.end,s.start);let h=e.dot(u),d=u.dot(l),f=u.dot(u),m=e.dot(l),g=l.dot(l)*f-d*d,y,x;g!==0?y=(h*d-m*f)/g:y=0,x=(h+y*d)/f,o.x=y,o.y=x}}(),_m=function(){let n=new U,t=new E,e=new E;return function(i,s,o,a){cK(i,s,n);let l=n.x,c=n.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=i.start:u=i.end;let h;c<0?h=s.start:h=s.end;let d=t,f=e;if(i.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(u)){o.copy(d),a.copy(h);return}else{o.copy(u),a.copy(f);return}}}}(),jR=function(){let n=new E,t=new E,e=new qr,r=new Di;return function(s,o){let{radius:a,center:l}=s,{a:c,b:u,c:h}=o;if(r.start=c,r.end=u,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a)||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a))return!0;let p=o.getPlane(e);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var uK=1e-15;function Cd(n){return Math.abs(n)<uK}var Vn=class extends Or{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new Fn),this.points=[this.a,this.b,this.c],this.sphere=new ei,this.plane=new qr,this.needsUpdate=!0}intersectsSphere(t){return jR(t,this)}update(){let t=this.a,e=this.b,r=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let c=s[1],u=o[1];c.subVectors(t,e),u.setFromPoints(c,i);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,i);let f=s[3],m=o[3];f.subVectors(r,t),m.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};Vn.prototype.closestPointToSegment=function(){let n=new E,t=new E,e=new Di;return function(i,s=null,o=null){let{start:a,end:l}=i,c=this.points,u,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(c[d]),e.end.copy(c[f]),_m(e,i,n,t),u=n.distanceToSquared(t),u<h&&(h=u,s&&s.copy(n),o&&o.copy(t))}return this.closestPointToPoint(a,n),u=a.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),o&&o.copy(a)),this.closestPointToPoint(l,n),u=l.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),o&&o.copy(l)),Math.sqrt(h)}}();Vn.prototype.intersectsTriangle=function(){let n=new Vn,t=new Array(3),e=new Array(3),r=new Fn,i=new Fn,s=new E,o=new E,a=new E,l=new E,c=new Di,u=new Di,h=new Di;return function(f,m=null,p=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(n.copy(f),n.update(),f=n);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let x=this.satBounds,v=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let T=x[A],S=v[A];if(r.setFromPoints(S,e),T.isSeparated(r))return!1}let b=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let A=0;A<4;A++){let T=b[A],S=w[A];if(r.setFromPoints(S,t),T.isSeparated(r))return!1}for(let A=0;A<4;A++){let T=v[A];for(let S=0;S<4;S++){let M=w[S];if(s.crossVectors(T,M),r.setFromPoints(s,t),i.setFromPoints(s,e),r.isSeparated(i))return!1}}return m&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{let x=this.points,v=!1,b=0;for(let O=0;O<3;O++){let L=x[O],j=x[(O+1)%3];c.start.copy(L),c.end.copy(j),c.delta(o);let V=v?u.start:u.end,H=Cd(y.distanceToPoint(L));if(Cd(y.normal.dot(o))&&H){u.copy(c),b=2;break}if((y.intersectLine(c,V)||H)&&!Cd(V.distanceTo(j))){if(b++,v)break;v=!0}}if(b===1&&f.containsPoint(u.end))return m&&(m.start.copy(u.end),m.end.copy(u.end)),!0;if(b!==2)return!1;let w=f.points,A=!1,T=0;for(let O=0;O<3;O++){let L=w[O],j=w[(O+1)%3];c.start.copy(L),c.end.copy(j),c.delta(a);let V=A?h.start:h.end,H=Cd(g.distanceToPoint(L));if(Cd(g.normal.dot(a))&&H){h.copy(c),T=2;break}if((g.intersectLine(c,V)||H)&&!Cd(V.distanceTo(j))){if(T++,A)break;A=!0}}if(T===1&&this.containsPoint(h.end))return m&&(m.start.copy(h.end),m.end.copy(h.end)),!0;if(T!==2)return!1;if(u.delta(o),h.delta(a),o.dot(a)<0){let O=h.start;h.start=h.end,h.end=O}let S=u.start.dot(o),M=u.end.dot(o),C=h.start.dot(o),P=h.end.dot(o),_=M<C,I=S<P;return S!==P&&C!==M&&_===I?!1:(m&&(l.subVectors(u.start,h.start),l.dot(o)>0?m.start.copy(u.start):m.start.copy(h.start),l.subVectors(u.end,h.end),l.dot(o)<0?m.end.copy(u.end):m.end.copy(h.end)),!0)}}}();Vn.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();Vn.prototype.distanceToTriangle=function(){let n=new E,t=new E,e=["a","b","c"],r=new Di,i=new Di;return function(o,a=null,l=null){let c=a||l?r:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let h=0;h<3;h++){let d,f=e[h],m=o[f];this.closestPointToPoint(m,n),d=m.distanceToSquared(n),d<u&&(u=d,a&&a.copy(n),l&&l.copy(m));let p=this[f];o.closestPointToPoint(p,n),d=p.distanceToSquared(n),d<u&&(u=d,a&&a.copy(p),l&&l.copy(n))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];r.set(this[d],this[f]);for(let m=0;m<3;m++){let p=e[m],g=e[(m+1)%3];i.set(o[p],o[g]),_m(r,i,n,t);let y=n.distanceToSquared(t);y<u&&(u=y,a&&a.copy(n),l&&l.copy(t))}}return Math.sqrt(u)}}();var Un=class{constructor(t,e,r){this.isOrientedBox=!0,this.min=new E,this.max=new E,this.matrix=new ue,this.invMatrix=new ue,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 Fn),this.alignedSatBounds=new Array(3).fill().map(()=>new Fn),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),r&&this.matrix.copy(r)}set(t,e,r){this.min.copy(t),this.max.copy(e),this.matrix.copy(r),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Un.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,i=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){let d=1*c|2*u|4*h,f=i[d];f.x=c?r.x:e.x,f.y=u?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let c=0;c<3;c++){let u=o[c],h=s[c],d=1<<c,f=i[d];u.subVectors(a,f),h.setFromPoints(u,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Un.prototype.intersectsBox=function(){let n=new Fn;return function(e){this.needsUpdate&&this.update();let r=e.min,i=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(n.min=r.x,n.max=i.x,a[0].isSeparated(n)||(n.min=r.y,n.max=i.y,a[1].isSeparated(n))||(n.min=r.z,n.max=i.z,a[2].isSeparated(n)))return!1;for(let l=0;l<3;l++){let c=o[l],u=s[l];if(n.setFromBox(c,e),u.isSeparated(n))return!1}return!0}}();Un.prototype.intersectsTriangle=function(){let n=new Vn,t=new Array(3),e=new Fn,r=new Fn,i=new E;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(n.copy(o),n.update(),o=n);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],m=l[d];if(e.setFromPoints(m,t),f.isSeparated(e))return!1}let c=o.satBounds,u=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=c[d],m=u[d];if(e.setFromPoints(m,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let m=0;m<4;m++){let p=u[m];if(i.crossVectors(f,p),e.setFromPoints(i,t),r.setFromPoints(i,h),e.isSeparated(r))return!1}}return!0}}();Un.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();Un.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();Un.prototype.distanceToBox=function(){let n=["x","y","z"],t=new Array(12).fill().map(()=>new Di),e=new Array(12).fill().map(()=>new Di),r=new E,i=new E;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(i),this.closestPointToPoint(i,r),o.closestPointToPoint(r,i),l&&l.copy(r),c&&c.copy(i)),0;let u=a*a,h=o.min,d=o.max,f=this.points,m=1/0;for(let g=0;g<8;g++){let y=f[g];i.copy(y).clamp(h,d);let x=y.distanceToSquared(i);if(x<m&&(m=x,l&&l.copy(y),c&&c.copy(i),x<u))return Math.sqrt(x)}let p=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let x=0;x<=1;x++){let v=(g+1)%3,b=(g+2)%3,w=y<<v|x<<b,A=1<<g|y<<v|x<<b,T=f[w],S=f[A];t[p].set(T,S);let C=n[g],P=n[v],_=n[b],I=e[p],O=I.start,L=I.end;O[C]=h[C],O[P]=y?h[P]:d[P],O[_]=x?h[_]:d[P],L[C]=d[C],L[P]=y?h[P]:d[P],L[_]=x?h[_]:d[P],p++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let x=0;x<=1;x++){i.x=g?d.x:h.x,i.y=y?d.y:h.y,i.z=x?d.z:h.z,this.closestPointToPoint(i,r);let v=i.distanceToSquared(r);if(v<m&&(m=v,l&&l.copy(r),c&&c.copy(i),v<u))return Math.sqrt(v)}for(let g=0;g<12;g++){let y=t[g];for(let x=0;x<12;x++){let v=e[x];_m(y,v,r,i);let b=r.distanceToSquared(i);if(b<m&&(m=b,l&&l.copy(r),c&&c.copy(i),b<u))return Math.sqrt(b)}}return Math.sqrt(m)}}();var Pd=new E,_d=new E,Id=new E,lx=new U,cx=new U,ux=new U,HR=new E,WR=new E,qR=new E,hx=new E;function hK(n,t,e,r,i,s){let o;return s===xi?o=n.intersectTriangle(r,e,t,!0,i):o=n.intersectTriangle(t,e,r,s!==vi,i),o===null?null:{distance:n.origin.distanceTo(i),point:i.clone()}}function dK(n,t,e,r,i,s,o,a,l){Pd.fromBufferAttribute(t,s),_d.fromBufferAttribute(t,o),Id.fromBufferAttribute(t,a);let c=hK(n,Pd,_d,Id,hx,l);if(c){r&&(lx.fromBufferAttribute(r,s),cx.fromBufferAttribute(r,o),ux.fromBufferAttribute(r,a),c.uv=Or.getInterpolation(hx,Pd,_d,Id,lx,cx,ux,new U)),i&&(lx.fromBufferAttribute(i,s),cx.fromBufferAttribute(i,o),ux.fromBufferAttribute(i,a),c.uv1=Or.getInterpolation(hx,Pd,_d,Id,lx,cx,ux,new U)),e&&(HR.fromBufferAttribute(e,s),WR.fromBufferAttribute(e,o),qR.fromBufferAttribute(e,a),c.normal=Or.getInterpolation(hx,Pd,_d,Id,HR,WR,qR,new E),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));let u={a:s,b:o,c:a,normal:new E,materialIndex:0};Or.getNormal(Pd,_d,Id,u.normal),c.face=u,c.faceIndex=s}return c}function vE(n,t,e,r,i){let s=r*3,o=n.index.getX(s),a=n.index.getX(s+1),l=n.index.getX(s+2),{position:c,normal:u,uv:h,uv1:d}=n.attributes,f=dK(e,c,u,h,d,o,a,l,t);return f?(f.faceIndex=r,i&&i.push(f),f):null}function XR(n,t,e,r,i,s){for(let o=r,a=r+i;o<a;o++)vE(n,t,e,o,s)}function YR(n,t,e,r,i){let s=1/0,o=null;for(let a=r,l=r+i;a<l;a++){let c=vE(n,t,e,a);c&&c.distance<s&&(o=c,s=c.distance)}return o}function Ps(n,t,e,r){let i=n.a,s=n.b,o=n.c,a=t,l=t+1,c=t+2;e&&(a=e.getX(t),l=e.getX(t+1),c=e.getX(t+2)),i.x=r.getX(a),i.y=r.getY(a),i.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(c),o.y=r.getY(c),o.z=r.getZ(c)}function xE(n,t,e,r,i,s,o){let a=e.index,l=e.attributes.position;for(let c=n,u=t+n;c<u;c++)if(Ps(o,c*3,a,l),o.needsUpdate=!0,r(o,c,i,s))return!0;return!1}var Dd=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function qa(n,t){return t[n+15]===65535}function su(n,t){return t[n+6]}function Od(n,t){return t[n+14]}function Rd(n){return n+8}function Ld(n,t){return t[n+6]}function KR(n,t){return t[n+7]}var Nd=new Yt,fx=new E,pK=["x","y","z"];function px(n,t,e,r,i){let s=n*2,o=Bd,a=Kl,l=Ql;if(qa(s,a)){let u=su(n,l),h=Od(s,a);XR(t,e,r,u,h,i)}else{let u=Rd(n);gx(u,o,r,fx)&&px(u,t,e,r,i);let h=Ld(n,l);gx(h,o,r,fx)&&px(h,t,e,r,i)}}function mx(n,t,e,r){let i=n*2,s=Bd,o=Kl,a=Ql;if(qa(i,o)){let c=su(n,a),u=Od(i,o);return YR(t,e,r,c,u)}else{let c=KR(n,a),u=pK[c],d=r.direction[u]>=0,f,m;d?(f=Rd(n),m=Ld(n,a)):(f=Ld(n,a),m=Rd(n));let g=gx(f,s,r,fx)?mx(f,t,e,r):null;if(g){let v=g.point[u];if(d?v<=s[m+c]:v>=s[m+c+3])return g}let x=gx(m,s,r,fx)?mx(m,t,e,r):null;return g&&x?g.distance<=x.distance?g:x:g||x||null}}var QR=function(){let n,t,e=[],r=new Dd(()=>new Yt);return function(...o){n=r.getPrimitive(),t=r.getPrimitive(),e.push(n,t);let a=i(...o);r.releasePrimitive(n),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],n=e[l-2]),a};function i(s,o,a,l,c=null,u=0,h=0){function d(v){let b=v*2,w=Kl,A=Ql;for(;!qa(b,w);)v=Rd(v),b=v*2;return su(v,A)}function f(v){let b=v*2,w=Kl,A=Ql;for(;!qa(b,w);)v=Ld(v,A),b=v*2;return su(v,A)+Od(b,w)}let m=s*2,p=Bd,g=Kl,y=Ql;if(qa(m,g)){let v=su(s,y),b=Od(m,g);return Cs(s,p,n),l(v,b,!1,h,u+s,n)}else{let v=Rd(s),b=Ld(s,y),w=v,A=b,T,S,M,C;if(c&&(M=n,C=t,Cs(w,p,M),Cs(A,p,C),T=c(M),S=c(C),S<T)){w=b,A=v;let V=T;T=S,S=V,M=C}M||(M=n,Cs(w,p,M));let P=qa(w*2,g),_=a(M,P,T,h+1,u+w),I;if(_===2){let V=d(w),q=f(w)-V;I=l(V,q,!0,h+1,u+w,M)}else I=_&&i(w,o,a,l,c,u,h+1);if(I)return!0;C=t,Cs(A,p,C);let O=qa(A*2,g),L=a(C,O,S,h+1,u+A),j;if(L===2){let V=d(A),q=f(A)-V;j=l(V,q,!0,h+1,u+A,C)}else j=L&&i(A,o,a,l,c,u,h+1);return!!j}}}(),ZR=function(){let n=new Vn,t=new Vn,e=new ue,r=new Un,i=new Un;return function s(o,a,l,c,u=null){let h=o*2,d=Bd,f=Kl,m=Ql;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,c),u=r),qa(h,f)){let g=a,y=g.index,x=g.attributes.position,v=l.index,b=l.attributes.position,w=su(o,m),A=Od(h,f);if(e.copy(c).invert(),l.boundsTree)return Cs(o,d,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>i.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(c),S.b.applyMatrix4(c),S.c.applyMatrix4(c),S.needsUpdate=!0;for(let M=w*3,C=(A+w)*3;M<C;M+=3)if(Ps(t,M,y,x),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let T=w*3,S=A+w*3;T<S;T+=3){Ps(n,T,y,x),n.a.applyMatrix4(e),n.b.applyMatrix4(e),n.c.applyMatrix4(e),n.needsUpdate=!0;for(let M=0,C=v.count;M<C;M+=3)if(Ps(t,M,v,b),t.needsUpdate=!0,n.intersectsTriangle(t))return!0}}else{let g=o+8,y=m[o+6];return Cs(g,d,Nd),!!(u.intersectsBox(Nd)&&s(g,a,l,c,u)||(Cs(y,d,Nd),u.intersectsBox(Nd)&&s(y,a,l,c,u)))}}}();function gx(n,t,e,r){return Cs(n,t,Nd),e.intersectBox(Nd,r)}var bE=[],dx,Bd,Kl,Ql;function Fd(n){dx&&bE.push(dx),dx=n,Bd=new Float32Array(n),Kl=new Uint16Array(n),Ql=new Uint32Array(n)}function Im(){dx=null,Bd=null,Kl=null,Ql=null,bE.length&&Fd(bE.pop())}var SE=Symbol("skip tree generation"),wE=new Yt,AE=new Yt,Vd=new ue,ou=new Un,Dm=new Un,Om=new E,yx=new E,mK=new E,gK=new E,yK=new E,JR=new Yt,Xo=new Dd(()=>new Vn),Yo=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Yo.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,i=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(t,e,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Yo.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:i,roots:s}=t,o=new Yo(e,{...r,[SE]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new je(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[SE]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[SE]||(this._roots=GR(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Yt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,i=e.attributes.position,s,o,a,l,c=0,u=this._roots;for(let d=0,f=u.length;d<f;d++)s=u[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,c),c+=s.byteLength;function h(d,f,m=!1){let p=d*2;if(a[p+15]===65535){let y=o[d+6],x=a[p+14],v=1/0,b=1/0,w=1/0,A=-1/0,T=-1/0,S=-1/0;for(let M=3*y,C=3*(y+x);M<C;M++){let P=r[M],_=i.getX(P),I=i.getY(P),O=i.getZ(P);_<v&&(v=_),_>A&&(A=_),I<b&&(b=I),I>T&&(T=I),O<w&&(w=O),O>S&&(S=O)}return l[d+0]!==v||l[d+1]!==b||l[d+2]!==w||l[d+3]!==A||l[d+4]!==T||l[d+5]!==S?(l[d+0]=v,l[d+1]=b,l[d+2]=w,l[d+3]=A,l[d+4]=T,l[d+5]=S,!0):!1}else{let y=d+8,x=o[d+6],v=y+f,b=x+f,w=m,A=!1,T=!1;t?w||(A=t.has(v),T=t.has(b),w=!A&&!T):(A=!0,T=!0);let S=w||A,M=w||T,C=!1;S&&(C=h(y,f,w));let P=!1;M&&(P=h(x,f,w));let _=C||P;if(_)for(let I=0;I<3;I++){let O=y+I,L=x+I,j=l[O],V=l[O+3],H=l[L],q=l[L+3];l[d+I]=j<H?j:H,l[d+I+3]=V>q?V:q}return _}}}traverse(t,e=0){let r=this._roots[e],i=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let c=a*2,u=s[c+15]===65535;if(u){let h=i[a+6],d=s[c+14];t(l,u,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=i[a+6],f=i[a+7];t(l,u,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Jn){let r=this._roots,i=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=i.groups,c=o?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=a?e[l[u].materialIndex].side:c,f=s.length;if(Fd(r[u]),px(0,i,d,t,s),Im(),a){let m=l[u].materialIndex;for(let p=f,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(t,e=Jn){let r=this._roots,i=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=i.groups,c=s?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=o?e[l[u].materialIndex].side:c;Fd(r[u]);let f=mx(0,i,d,t);Im(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[u].materialIndex))}return a}intersectsGeometry(t,e){let r=this.geometry,i=!1;for(let s of this._roots)if(Fd(s),i=ZR(0,r,t,e),Im(),i)break;return i}shapecast(t,e,r){let i=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,m,p,g)=>{let y=m*3;return d(f,y,y+1,y+2,p,g)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,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=Xo.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:c}=t;if(l&&c){let d=l;l=(f,m,p,g,y)=>d(f,m,p,g,y)?!0:xE(f,m,i,c,p,g,s)}else l||(c?l=(d,f,m,p)=>xE(d,f,i,c,m,p,s):l=(d,f,m)=>m);let u=!1,h=0;for(let d of this._roots){if(Fd(d),u=QR(0,i,a,l,o,h),Im(),u)break;h+=d.byteLength}return Xo.releasePrimitive(s),u}bvhcast(t,e,r){let{intersectsRanges:i,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,c=t.geometry.attributes.position;Vd.copy(e).invert();let u=Xo.getPrimitive(),h=Xo.getPrimitive();if(s){let f=function(m,p,g,y,x,v,b,w){for(let A=g,T=g+y;A<T;A++){Ps(h,A*3,l,c),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let S=m,M=m+p;S<M;S++)if(Ps(u,S*3,o,a),u.needsUpdate=!0,s(u,h,S,A,x,v,b,w))return!0}return!1};if(i){let m=i;i=function(p,g,y,x,v,b,w,A){return m(p,g,y,x,v,b,w,A)?!0:f(p,g,y,x,v,b,w,A)}}else i=f}t.getBoundingBox(AE),AE.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>AE.intersectsBox(f),intersectsRange:(f,m,p,g,y,x)=>(wE.copy(x),wE.applyMatrix4(Vd),t.shapecast({intersectsBounds:v=>wE.intersectsBox(v),intersectsRange:(v,b,w,A,T)=>i(f,m,v,b,g,y,A,T)}))});return Xo.releasePrimitive(u),Xo.releasePrimitive(h),d}intersectsBox(t,e){return ou.set(t.min,t.max,e),ou.needsUpdate=!0,this.shapecast({intersectsBounds:r=>ou.intersectsBox(r),intersectsTriangle:r=>ou.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},i={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),ou.set(t.boundingBox.min,t.boundingBox.max,e),ou.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,c=a.index,u=t.attributes.position,h=t.index,d=Xo.getPrimitive(),f=Xo.getPrimitive(),m=yx,p=mK,g=null,y=null;i&&(g=gK,y=yK);let x=1/0,v=null,b=null;return Vd.copy(e).invert(),Dm.matrix.copy(Vd),this.shapecast({boundsTraverseOrder:w=>ou.distanceToBox(w),intersectsBounds:(w,A,T)=>T<x&&T<o?(A&&(Dm.min.copy(w.min),Dm.max.copy(w.max),Dm.needsUpdate=!0),!0):!1,intersectsRange:(w,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:T=>Dm.distanceToBox(T),intersectsBounds:(T,S,M)=>M<x&&M<o,intersectsRange:(T,S)=>{for(let M=T*3,C=(T+S)*3;M<C;M+=3){Ps(f,M,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let P=w*3,_=(w+A)*3;P<_;P+=3){Ps(d,P,c,l),d.needsUpdate=!0;let I=d.distanceToTriangle(f,m,g);if(I<x&&(p.copy(m),y&&y.copy(g),x=I,v=P/3,b=M/3),I<s)return!0}}}});{let T=h?h.count:u.count;for(let S=0,M=T;S<M;S+=3){Ps(f,S,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=w*3,P=(w+A)*3;C<P;C+=3){Ps(d,C,c,l),d.needsUpdate=!0;let _=d.distanceToTriangle(f,m,g);if(_<x&&(p.copy(m),y&&y.copy(g),x=_,v=C/3,b=S/3),_<s)return!0}}}}}),Xo.releasePrimitive(d),Xo.releasePrimitive(f),x===1/0?null:(r.point?r.point.copy(p):r.point=p.clone(),r.distance=x,r.faceIndex=v,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(Vd),p.applyMatrix4(Vd),i.distance=p.sub(i.point).length(),i.faceIndex=b),r)}closestPointToPoint(t,e={},r=0,i=1/0){let s=r*r,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:u=>(Om.copy(t).clamp(u.min,u.max),Om.distanceToSquared(t)),intersectsBounds:(u,h,d)=>d<a&&d<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,Om);let d=t.distanceToSquared(Om);return d<a&&(yx.copy(Om),a=d,l=h),d<s}}),a===1/0)return null;let c=Math.sqrt(a);return e.point?e.point.copy(yx):e.point=yx.clone(),e.distance=c,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{Cs(0,new Float32Array(r),JR),t.union(JR)}),t}};var mb=cl(e3());var vK=.5*(Math.sqrt(3)-1),Rm=(3-Math.sqrt(3))/6,xK=1/3,Ko=1/6,P0e=(Math.sqrt(5)-1)/4,_0e=(5-Math.sqrt(5))/20,Lm=n=>Math.floor(n)|0,t3=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]),TE=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 r3(n=Math.random){let t=n3(n),e=new Float64Array(t).map(i=>t3[i%12*2]),r=new Float64Array(t).map(i=>t3[i%12*2+1]);return function(s,o){let a=0,l=0,c=0,u=(s+o)*vK,h=Lm(s+u),d=Lm(o+u),f=(h+d)*Rm,m=h-f,p=d-f,g=s-m,y=o-p,x,v;g>y?(x=1,v=0):(x=0,v=1);let b=g-x+Rm,w=y-v+Rm,A=g-1+2*Rm,T=y-1+2*Rm,S=h&255,M=d&255,C=.5-g*g-y*y;if(C>=0){let I=S+t[M],O=e[I],L=r[I];C*=C,a=C*C*(O*g+L*y)}let P=.5-b*b-w*w;if(P>=0){let I=S+x+t[M+v],O=e[I],L=r[I];P*=P,l=P*P*(O*b+L*w)}let _=.5-A*A-T*T;if(_>=0){let I=S+1+t[M+1],O=e[I],L=r[I];_*=_,c=_*_*(O*A+L*T)}return 70*(a+l+c)}}function i3(n=Math.random){let t=n3(n),e=new Float64Array(t).map(s=>TE[s%12*3]),r=new Float64Array(t).map(s=>TE[s%12*3+1]),i=new Float64Array(t).map(s=>TE[s%12*3+2]);return function(o,a,l){let c,u,h,d,f=(o+a+l)*xK,m=Lm(o+f),p=Lm(a+f),g=Lm(l+f),y=(m+p+g)*Ko,x=m-y,v=p-y,b=g-y,w=o-x,A=a-v,T=l-b,S,M,C,P,_,I;w>=A?A>=T?(S=1,M=0,C=0,P=1,_=1,I=0):w>=T?(S=1,M=0,C=0,P=1,_=0,I=1):(S=0,M=0,C=1,P=1,_=0,I=1):A<T?(S=0,M=0,C=1,P=0,_=1,I=1):w<T?(S=0,M=1,C=0,P=0,_=1,I=1):(S=0,M=1,C=0,P=1,_=1,I=0);let O=w-S+Ko,L=A-M+Ko,j=T-C+Ko,V=w-P+2*Ko,H=A-_+2*Ko,q=T-I+2*Ko,X=w-1+3*Ko,K=A-1+3*Ko,z=T-1+3*Ko,Q=m&255,te=p&255,$=g&255,W=.6-w*w-A*A-T*T;if(W<0)c=0;else{let J=Q+t[te+t[$]];W*=W,c=W*W*(e[J]*w+r[J]*A+i[J]*T)}let oe=.6-O*O-L*L-j*j;if(oe<0)u=0;else{let J=Q+S+t[te+M+t[$+C]];oe*=oe,u=oe*oe*(e[J]*O+r[J]*L+i[J]*j)}let ie=.6-V*V-H*H-q*q;if(ie<0)h=0;else{let J=Q+P+t[te+_+t[$+I]];ie*=ie,h=ie*ie*(e[J]*V+r[J]*H+i[J]*q)}let re=.6-X*X-K*K-z*z;if(re<0)d=0;else{let J=Q+1+t[te+1+t[$+1]];re*=re,d=re*re*(e[J]*X+r[J]*K+i[J]*z)}return 32*(c+u+h+d)}}function n3(n){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let i=r+~~(n()*(256-r)),s=e[r];e[r]=e[i],e[i]=s}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var eo=new Or,vx=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let s=1;eo.a.fromBufferAttribute(t,i),eo.b.fromBufferAttribute(t,i+1),eo.c.fromBufferAttribute(t,i+2),s*=eo.getArea(),e[i/3]=s}this.distribution=new Float32Array(t.count/3);let r=0;for(let i=0;i<e.length;i++)r+=e[i],this.distribution[i]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*r);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,i=e.length-1,s=-1;for(;r<=i;){let o=Math.ceil((r+i)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?i=o-1:r=o+1}return s}sampleFace(t,e,r){let i=this.randomFunction(),s=this.randomFunction();return i+s>1&&(i=1-i,s=1-s),eo.a.fromBufferAttribute(this.positionAttribute,t*3),eo.b.fromBufferAttribute(this.positionAttribute,t*3+1),eo.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(eo.a,i).addScaledVector(eo.b,s).addScaledVector(eo.c,1-(i+s)),eo.getNormal(r),this}};var o3=cl(ME()),bK=new ue,SK=new ue,wK=new ue,Xa;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(Xa||(Xa={}));var Ud=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new ue;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ue;this.pivotMatrix=new ue;this.matrixWorldRigid=new ue;this.shearScale=new ue;this.shearScaleInv=new ue}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Dt&&(r=r.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===r)return!0;i=i.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(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.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.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)),this.matrixWorld.multiply(this.pivotMatrix),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,i=0){for(let s of this.children)Xa.is(s)&&s.traverseObject(r,i+1)}traverseObject(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Xa.is(o)&&o.traverseObject(r,i+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,i=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:s,v:o,q:a}=(0,o3.SVD)(i),l=bK.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),c=SK.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),u=wK.copy(c).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,i){this.updateWorldMatrix(!0,!1);let s=new ue().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ue?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),i!==void 0&&(this.children.pop(),this.children.splice(i,0,r)),this}copy(r,i=!1){return super.copy(r,i),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,i,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var CE=class extends Ud(Dt){},AK=n=>n.type==="Mesh",Lr=class extends CE{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let i=this.children[e];i?.object!==r&&(i&&this.remove(i),i=new Lr(r),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=r.matrix,i.hiddenMatrix=r.hiddenMatrix,i.pivotMatrix=r.pivotMatrix),i.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}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 AK(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}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};var au=new E,lu=new E,kd=new ue,l3=[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)],EK=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],TK=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],a3=(n,t,e)=>{n.updateEntityBoxSize(au,lu),kd.copy(t).multiply(n.matrixWorld),lu.x===0&&lu.y===0&&lu.z===0?e.push(new E(au.x,au.y,au.z).applyMatrix4(kd)):l3.forEach(r=>{e.push(r.clone().multiply(lu).add(au).applyMatrix4(kd))})},Nm=class extends Yt{constructor(){super(...arguments);this.matrix=new ue;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new ue().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,r)}expandByObjectSize(e,r,i=!1){let s=[];return i===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new E);return}a3(o,r,s)}}):a3(e,r,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(kd.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(lu).multiplyScalar(.5),this.getCenter(au),kd.copy(this.matrix).setPosition(au),this.vertices=l3.map(e=>e.clone().multiply(lu).applyMatrix4(kd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=EK.map(([e,r])=>new Di(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=TK.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var to={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var _E=class extends Hp{constructor(){super()}getPoints(t=12){let e=[],r,i=this.getCurveLengths(),o=i[i.length-1]/i.length;for(let a=0,l=this.curves;a<l.length;a++){let c=l[a],u=a===0?i[a]:i[a]-i[a-1],h=Math.ceil(t*u/o),d=c.getPoints(h);for(let f=0;f<d.length;f++){let m=d[f];r&&r.equals(m)||(e.push(m),r=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var IE=.001;function DE(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=IE}function PE(n,t){let e=new E(...n.position),r=new E(...n.controlNext.position),i=new E(...t.controlPrevious.position),s=new E(...t.position);return DE(e,r,s)&&DE(e,i,s)}function bx(n){let t=n.points.map(u=>new E(...u.data.position)),e=[n.points[0]],r=new E(...e[0].data.position);for(let u=0;u<n.points.length-1;u++)DE(r,t[u],t[u+1])||(e.push(n.points[u]),r=t[u]);e.push(n.points[n.points.length-1]);let i=n.isClosed,s=e.length-(i?0:1),o=e.length,a=[];for(let u=0;u<o;u++){let h=e[u].data,d=new E(...h.position),f=new E(...h.controlPrevious.position),m=new E(...h.controlNext.position),p={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:m};if(h.roundness===0||!n.isClosed&&(u===0||u===o-1)){a[u]={...p,removedLength:0};continue}let g=i&&u==0?o-1:u-1,y=i&&u==o-1?0:u+1,x=e[g].data,v=e[y].data,b=new E(...x.position),w=new E(...v.position),A=b.clone().sub(d).normalize(),T=w.clone().sub(d).normalize();Object.assign(p,{prevDir:A,nextDir:T});let S=PE(x,h),M=PE(h,v);if(!S||!M)a[u]={...p,removedLength:0};else{let C=A.clone().add(T).normalize(),P=C.clone().cross(A).length()/A.dot(C);a[u]={...p,tan:P,removedLength:h.roundness/P}}}for(let u=0;u<s;u++){let h=u,d=i&&u===o-1?0:u+1,f=a[h],m=a[d];if(f.removedLength!==0||m.removedLength!==0){let p=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,p/2),m.removedLength=Math.min(m.removedLength,p/2)}}let l=[];for(let u=0;u<s;u++){let h=u,d=i&&u===o-1?0:u+1,f=a[h],m=a[d],p=null;if(!PE(e[h].data,e[d].data))f.position.distanceTo(m.position)>IE&&(p=new zc(f.position,f.controlNext,m.controlPrevious,m.position));else{let g=f.position.clone(),y=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&y.add(m.prevDir.clone().setLength(m.removedLength))),g.distanceTo(y)>IE&&(p=new zc(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*u+1]=p}for(let u=0;u<o;u++){let h=a[u];if(h.removedLength===0){l[2*u]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),m=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),p=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(m,.5),x=f.distanceTo(m)/2,v=g.clone().multiplyScalar(Math.sqrt(Math.pow(p,2)-Math.pow(x,2))).add(y),b=g.clone().multiplyScalar(-p).add(v),w=d.distanceTo(b)/d.distanceTo(y),A=h.prevDir.clone().multiplyScalar(w*d.distanceTo(f)).add(d),T=A.clone().lerp(b,2),S=f.clone().lerp(A,4/3),M=m.clone().lerp(T,4/3);l[2*u]=new zc(f,S,M,m)}let c=new _E;return l.forEach(u=>{u&&c.add(u)}),c}var gt;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(gt||(gt={}));var Qo=n=>gt.is(n),MK={type:"completeState",isfromEntity:!0},CK=["x","y","z"],Bm=new E,c3=new E(1,1,1),OE=new Ye,u3=new Jt,PK=new E().set(0,1,0),zd=n=>class extends Ud(n){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.currentAnimationAction=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Nm;this._recursiveBBox=new Nm;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let i=this.children[r];if(gt.is(i))return i}entityChildrenCount(){let r=this.children.length;for(;r--;)if(gt.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let i=r.parent;if(gt.is(i))r=i;else return}return r}forInstancesRec(r){this.instances.forEach(i=>{i.disposed||r(i),i.forInstancesRec(r)})}super_Entity(r,i){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)Qs.toOps(this.data,o.data).forEach(l=>{let c=id.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,i)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=Qs.patch(this.data,o),Qs.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}s&&this.updateTransformState(this.dataPatched,i),this.stateSelection=r,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(r,i){r.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Qo(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let i;return this.traverseEntity(s=>{s.uuid===r&&(i=s)}),i}traverseSortNextHelper(){let r=this.parent;if(r){let i=r.children,s=i.indexOf(this)+1;if(gt.is(i[s]))return i[s];if(gt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&>.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let i=this;for(;r>0&&i!==null;)i=i.parent,r-=1;return i}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let i=this.parent;for(;i;){if(r===i)return!0;i=i.parent}return!1}countToAccestor(r){let i=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(r){for(let i of this.children)Qo(i)&&r(i)}traverseEntityAncestors(r){this.traverseAncestors(i=>{gt.is(i)&&r(i)})}traverseConcreteEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Qo(o)&&o.isConcreteEntity&&o.traverseEntity(r,i+1)}traverseEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Qo(o)&&o.traverseEntity(r,i+1)}traverseVisibleEntity(r){r(this);for(let i of this.children)Qo(i)&&i.visible&&i.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,i=!1){return super.copy(r,i),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Qo(r))}isAncestorOf(r){if(this.uuid===r)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===r&&(i=!0)}),i}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*Se.RAD2DEG,this.rotation.y*Se.RAD2DEG,this.rotation.z*Se.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]};return Qh(i,r)}getTransformValues(r,i,s){return i[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,CK[a]])??o)}updateTransformState(r,i){let s=!1;if(r.position&&(this.position.fromArray(this.getTransformValues("position",r,i)),s=!0),r.rotation&&(Bm.fromArray(this.getTransformValues("rotation",r,i)).multiplyScalar(Se.DEG2RAD),this.rotation.setFromVector3(Bm),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,i)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??zl.identity)),r.pivot!==void 0||r.pivotRotation!==void 0){if(s=!0,r.pivot!==void 0&&r.pivotRotation!==void 0)this.pivotMatrix.compose(Bm.fromArray(r.pivot).negate(),OE.setFromEuler(u3.fromArray(r.pivotRotation.map(o=>o*Se.DEG2RAD))).invert(),c3);else if(r.pivot!==void 0)this.pivotMatrix.setPosition(-r.pivot[0],-r.pivot[1],-r.pivot[2]);else if(r.pivotRotation!==void 0){let o=Bm.setFromMatrixPosition(this.pivotMatrix);OE.setFromEuler(u3.fromArray(r.pivotRotation.map(a=>a*Se.DEG2RAD))).invert(),this.pivotMatrix.compose(o,OE,c3)}}return s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender()}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)gt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{gt.is(r)&&r.disposeRecursively()})}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Qh(i,r)}updateByObjUpdateOp(r,i){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},i,!1)}updateByOp(r,i,s,o){let a=this.data;this.data=i;let l=r,c=kt(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let h={...r.props};if(delete h.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Mr.zoom(d,r.path.slice(2));if(f)for(let m in r.props)r.props[m]===void 0&&m in f&&(h[m]=f[m])}}l={...r,props:h,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:d,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let h=Mr.removeOverridden(r.path,r.props,u);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,Qs.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),kt(r.path,["overrides"])){let u=[],h=[...r.path];for(u.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)u.push(h[1]),h.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){u[u.length-1]=d;let f=s.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[d],f.updateState(Do.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...u]);if(d){let f=Mr.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let m=r.props;if(f)for(let[p,g]of Object.entries(r.props))g===void 0&&(m===r.props&&(m={...r.props}),m[p]=f[p]);r={...r,props:m}}d.overrideData=gd.resolve(i.overrides,u),d.updateByOp(r,zr.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let h;for(let d of Vo.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(u={...r,props:h})}else for(let h of Vo.rootOverrideProps)if(kt(r.path,[h])){u=r;break}u!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Do.filterOp(h.overrideData,u);d&&h.updateByOp(d,zr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Do.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=i:f=zr.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,i,s){if(this.dataPatched=i,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Ks.is(r.props.type)&&to.changeEntityProptotype(this,i,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){to.changeEntityProptotype(this,i,s);for(let o of this.children)gt.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,i,s)}updateByPatchedOp(r,i,s){if(r.path.length===0&&r.type===0?this.updateState(r.props,s):r.type===0&&("resolutionLevel"in r.props||"useChildrenColors"in r.props)&&this.updateState(i,s),r.path[0]==="morphTargetInfluences"&&r.type===0){let a=i.morphTargetInfluences.get(r.path[1])?.data.name;a&&this.updateMorphInfluences(a,s.shared.getVariable(r.props.value,[this.uuid,"morphTargetInfluences",a]))}if(kt(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),kt(r.path,["cloner"])!==null){let o=zr.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s):(this.setFromClonerState(i.cloner,s),this.expandCloner(s)),this.updateVisible(s.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=r.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=bx(c.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=null;try{d=u.curves.length?u.getPointAt(h):null}catch(g){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(g))}if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ue;l.updateMatrixWorld();let m=new ue().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(m);let p={position:d.toArray(),rotation:c.rotation};if(a==="tangential"){let g=new ue().extractRotation(l.matrixWorld),y=u.getTangentAt(h).applyMatrix4(g).add(d),x=new ue().lookAt(d,y,PK),v=Bm.setFromEuler(new Jt().setFromRotationMatrix(x)).multiplyScalar(Se.RAD2DEG);p={...p,rotation:v.toArray()}}this.updateTransformState(p),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(MK)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let i=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return i=!0,!0}),i&&r.reloadSplats()}updateState_Entity(r,i){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(r,i)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof to.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,i){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new to.Cloner(this,r),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,i))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var Sx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.parameters?.radiusTop,r=n.parameters?.radiusBottom,i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);i.thetaLength=Se.clamp(i.thetaLength,0,360);let s=i.width/2,o=i.radiusTop??s,a=i.radiusBottom??s;if(o===a?(o=s,a=s):o>a?(o=s,a=a*s/o):(o=o*s/a,a=s),i.shapeBlendNode){o=e??s,a=r??s;let l=Math.max(o,a)*2;i.width=l,i.depth=l}return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:o,radiusBottom:a})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:h,cornerSegments:d,hollow:f}=n.parameters,m;return l===0?(m=new Ce,m.setAttribute("position",new Te([],3))):h||f?m=new Fm(c,u,r,i,s,o,a,l*Math.PI/180,h,h,d,f):m=new jc(c,u,r,i,s,o,a,l*Math.PI/180),m.scale(1,1,e/t),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function Zl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function h3(n){return new U(n.y,-n.x)}var Fm=class extends Ce{constructor(t,e,r,i,s,o,a,l,c,u,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,u=0);let m=[],p=[],g=[],y=[],x=0,v=r/2,b=new E,w=new E;f&&t==0&&(t=c),f&&e==0&&(e=u);let A=new U(t,v),T=new U(e,-v),S=null,M=null,C=null,P=null,_=A.clone().sub(T),I=0,O=0,L=0;d>0&&(I=Math.min(t,e)*(1-d),O=t-I,L=e-I);let j=A.clone();j.x-=I;let V=Math.PI-_.angle(),H=_.angle(),q=Math.tan(H/2),X=Math.tan(V/2),K=q+X,z=d?K:X,Q=d?K:q;if(c=Math.min(c,(t-O)/z,_.length()/K),u=Math.min(u,(e-L)/Q,_.length()/K),c>0){let re=c/q;S=A.clone().sub(new U(re,c)),d&&(C=S.clone(),C.x-=I-K*c),A.sub(_.clone().setLength(re))}if(u>0){let re=u/X;M=T.clone().sub(new U(re,-u)),T.add(_.clone().setLength(re)),d&&(P=M.clone(),P.x-=I-K*u,j.sub(_.clone().setLength(re)))}_=A.clone().sub(T);let te=_.length()<.5,$=[];for(let re=0;re<=i;re++){let J=[],Ee=re/i,xe=Ee*l+a,de=new U(Math.sin(xe),Math.cos(xe));P&&M?(W(J,Ee,de,V,u,P,-1,!0),W(J,Ee,de,H,u,M,-1,!1)):M?(oe(J,de,M.x,0,-1),W(J,Ee,de,H,u,M,-1,!1)):o||oe(J,de,e,L,-1);let De=h3(_).normalize();if(Zl(De,de,b),!te)for(let Pe=0;Pe<=s;Pe++){let ze=Pe/s,ke=_.clone().multiplyScalar(ze).add(T);Zl(ke,de,w),p.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(Ee,.5+w.y/r),J.push(x++)}if(C&&S?(W(J,Ee,de,V,c,S,1,!1),W(J,Ee,de,H,c,C,1,!0)):S?(W(J,Ee,de,V,c,S,1,!1),oe(J,de,S.x,0,1)):o||oe(J,de,t,O,1),d&&!te){let Pe=h3(_).multiplyScalar(-1).normalize();Zl(Pe,de,b);for(let ze=0;ze<=s;ze++){let ke=ze/s,Ue=_.clone().multiplyScalar(-ke).add(j);Zl(Ue,de,w),p.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(Ee,.5+w.y/r),J.push(x++)}}d&&!o&&J.push(J[0]),$.push(J)}for(let re=0;re<$.length-1;re++)for(let J=0;J<$[0].length-1;J++){if(o&&d&&J==s)continue;let Ee=$[re][J],xe=$[re+1][J],de=$[re+1][J+1],De=$[re][J+1],Pe=p[de*3+0],ze=p[de*3+2];m.push(Ee,xe,De),(Pe!=0||ze!=0)&&m.push(xe,de,De)}l<Math.PI*2&&(ie(-1,$[0],a),ie(1,$[$.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(g,3)),this.setAttribute("uv",new Te(y,2));function W(re,J,Ee,xe,de,De,Pe,ze){for(let ke=0;ke<h+1;ke++){let Ue=ke/h,Le=Pe<0?Ue:1-Ue;ze&&(Le-=1),Le*=xe;let Qe=new U(Math.sin(Le),Math.cos(Le)*Pe),F=Qe.clone().multiplyScalar(de).add(De);Zl(F,Ee,w),p.push(w.x,w.y,w.z),Zl(Qe,Ee,b),g.push(b.x,b.y,b.z),y.push(J,.5+w.y/r),re.push(x++)}}function oe(re,J,Ee,xe,de){let De=new E,Pe=new U,ze=[Ee,xe];de<0&&ze.reverse();for(let ke of ze)Pe.set(ke,v*de),Zl(Pe,J,De),p.push(De.x,De.y,De.z),g.push(0,de,0),y.push(.5,.5),re.push(x++)}function ie(re,J,Ee){let xe=new U(Math.sin(Ee),Math.cos(Ee)),de=new U(-Math.cos(Ee),Math.sin(Ee)),De=new E,Pe=re<0?(Ue,Le,Qe)=>m.push(Ue,Le,Qe):(Ue,Le,Qe)=>m.push(Ue,Qe,Le),ze=new U((t+e+O+L)/4,0);Zl(ze,xe,De),p.push(De.x,De.y,De.z),g.push(de.x,0,de.y),y.push(.5,.5);let ke=x++;for(let Ue of J){let Le=p.slice(Ue*3,Ue*3+3);p.push(...Le),g.push(de.x,0,de.y);let Qe=y.slice(Ue*2,Ue*2+2);y.push(...Qe),x++}for(let Ue=ke+1;Ue<x-1;Ue++)Pe(ke,Ue,Ue+1);Pe(ke,x-1,ke+1)}}};var d3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=Se.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:h}=n.parameters,d;return l===0?(d=new Ce,d.setAttribute("position",new Te([],3))):c>0||u>0||l<360?d=new Fm(0,t/2,r,i,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new Al(t/2,r,i,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};var f3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=n.parameters,c;return a===0?c=new bi(t,e,r,i,s,o):c=new LE(t,e,r,i,s,o,a,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},RE=Math.PI/2,LE=class extends Ce{constructor(t=1,e=1,r=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry",i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let c=[],u=[],h=[],d=[],f=0;m("z","y","x",-1,-1,r,e,t,o,s),m("z","y","x",1,-1,r,e,-t,o,s),m("x","z","y",1,1,t,r,e,i,o),m("x","z","y",1,-1,t,r,-e,i,o),m("x","y","z",1,-1,t,e,r,i,s),m("x","y","z",-1,-1,t,e,-r,i,s),a>0&&(p("z","y","x",-1,-1,1,r,e,t,o),p("z","y","x",1,-1,-1,r,e,t,o),p("z","y","x",-1,1,-1,r,e,t,o),p("z","y","x",1,1,1,r,e,t,o),p("x","y","z",-1,-1,-1,t,e,r,i),p("x","y","z",1,-1,1,t,e,r,i),p("x","y","z",-1,1,1,t,e,r,i),p("x","y","z",1,1,-1,t,e,r,i),p("y","x","z",-1,-1,1,e,t,r,s),p("y","x","z",1,-1,-1,e,t,r,s),p("y","x","z",1,1,1,e,t,r,s),p("y","x","z",-1,1,-1,e,t,r,s),g(1,1,1),g(-1,1,1),g(1,-1,1),g(-1,-1,1),g(1,1,-1),g(-1,1,-1),g(1,-1,-1),g(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Te(u,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(d,2));function m(y,x,v,b,w,A,T,S,M,C){let P=(A-2*a)/M,_=(T-2*a)/C,I=A/2-a,O=T/2-a,L=S/2,j=M+1,V=C+1,H=0,q=new E;for(let X=0;X<V;X++){let K=X*_-O;for(let z=0;z<j;z++){let Q=z*P-I;q[y]=Q*b,q[x]=K*w,q[v]=L,u.push(q.x,q.y,q.z),q[y]=0,q[x]=0,q[v]=S>0?1:-1,h.push(q.x,q.y,q.z),d.push(z/M),d.push(1-X/C),H+=1}}for(let X=0;X<C;X++)for(let K=0;K<M;K++){let z=f+K+j*X,Q=f+K+j*(X+1),te=f+(K+1)+j*(X+1),$=f+(K+1)+j*X;c.push(z,Q,$),c.push(Q,te,$)}f+=H}function p(y,x,v,b,w,A,T,S,M,C){let P=(T-2*a)/C,_=T/2-a,I=S/2-a,O=M/2,L=C+1,j=0,V=new E,H=new E;for(let q=0;q<l+1;q++){let X=q/l*RE,K=Math.sin(X)*a,z=(1-Math.cos(X))*a,Q=Math.sin(X),te=Math.cos(X);V[x]=(I+K)*w,V[v]=(O-z)*A,H[y]=0,H[x]=Q*Math.sign(V[x]),H[v]=te*Math.sign(V[v]);for(let $=0;$<L;$++){let W=$*P-_;V[y]=W*b,u.push(V.x,V.y,V.z),h.push(H.x,H.y,H.z),d.push($/C),d.push(0),j+=1}}for(let q=0;q<l;q++)for(let X=0;X<C;X++){let K=f+X+L*q,z=f+X+L*(q+1),Q=f+(X+1)+L*(q+1),te=f+(X+1)+L*q;c.push(K,z,te),c.push(z,Q,te)}f+=j}function g(y,x,v){let b=new E,w=new E(t/2,e/2,r/2);w.subScalar(a);let A=[],T=y*x*v>0?(M,C,P)=>c.push(M,C,P):(M,C,P)=>c.push(M,P,C);for(let M=0;M<=l;M++){let C=[],P=RE*(1-M/l),_=Math.cos(P),I=Math.sin(P),O=0;for(let L=0;L<=M;L++){let j=Math.cos(O),V=Math.sin(O);b.x=_*j,b.y=I,b.z=_*V;let H=w.clone().addScaledVector(b,a);u.push(y*H.x,x*H.y,v*H.z),h.push(y*b.x,x*b.y,v*b.z),d.push(0,0),C.push(f++),O+=RE/M}A.push(C)}let S=A.length-1;for(let M=0;M<S;M++){let C=A[M],P=A[M+1],_=C.length-1;T(C[0],P[1],P[0]);for(let I=1;I<=_;I++)T(C[I-1],C[I],P[I]),T(C[I],P[I+1],P[I])}}}};var Jl=class extends Ce{constructor(t=[],e=[],r="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];u(),h(),this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(l,2));return;function u(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new E,p=m.clone(),g=new Or,y=s*i,x=i-y,v=o+1,b=new E,w=(q,X)=>b.subVectors(q,X).normalize(),A=(q,X)=>Array(q).fill(void 0).map(X),T=A(t.length/3,(q,X)=>new E().fromArray(t,X*3).setLength(i)),S=[],M=1e6;for(let q=0;q<T.length;q++){let X=T[q],K=[],z,Q,te,$=1e10,W=-1;for(;(W=e.indexOf(q,W+1))!=-1;){let J=W-W%3;z=e[J+(W+1)%3],Q=e[J+(W+2)%3],te=X.distanceToSquared(T[z]),$=Math.min($,te),K.push([z,Q,te])}$+=1e-6;let oe=[],ie=0,re=K.length;for(let J=0;J<re;J++){[z,Q,te]=K[ie];let Ee=S[z]?.includes(q)==!0;te<=$&&oe.push(z+ +Ee*M),ie=K.findIndex(xe=>xe[0]==Q)}S.push(oe)}let C=[];{let q=0,X=0,K,z,Q=f==3;for(let te=0;te<=o;te++){K=te*(te+1)/2,z=(te+1)*(te+2)/2;for(let $=0;$<o-te;$++)[q,X]=[K+$+te+2,z+$+te+3],C.push(K,z,...Q?[X,K]:[q,z],X,q),[K,z]=[q,X];C.push(K,z,K+o+2)}}let P=m.clone(),_=m.clone(),I=m.clone(),O=m.clone(),L=m.clone(),j=[],V=A(T.length,()=>A(f,()=>m.clone()));for(let q=0;q<T.length;q++){m.copy(T[q]).normalize(),P.copy(m).multiplyScalar(x);let X=S[q];for(let oe=0;oe<X.length;oe++){let ie=X[oe],re=X[(oe+1)%f];g.setFromPointsAndIndices(T,q,ie%M,re%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(P,V[q][oe])}let K=[],z=[],Q=[],te=new E;o==0&&[...V[q]].reduce((oe,ie)=>oe.add(ie),te).multiplyScalar(1/f);for(let oe=0;oe<f;oe++){let ie=[],re=(oe-1+f)%f,J=V[q][re],Ee=V[q][oe];m.copy(J).sub(P),p.copy(Ee).sub(P);let xe=P.angleTo(m),de=m.angleTo(p),De=Math.cos(xe)*y;o==0?_.copy(te):_.copy(P).setLength(x+De),z.push(De);let Pe=[_,J,Ee];for(let ze=0;ze<2;ze++){let ke=Pe[ze],Ue=Pe[ze+1];O.subVectors(ke,P),L.subVectors(Ue,P),I.crossVectors(O,L).normalize();for(let Le=0;Le<v;Le++){let Qe=[xe,de][ze]*Le/v;m.copy(O).applyAxisAngle(I,Qe).add(P),K.push(m.clone()),ze&&(w(m,P),ie.push([Le==0?ke:m.clone(),b.clone()]))}ze&&(w(Ue,P),ie.push([Ue,b.clone()]))}Q.push(ie)}j.push(Q);let $=2*v,W=2;for(let oe=0;oe<f;oe++){let ie=$*oe,re=$*((oe+1)%f),J=[K[ie]];for(let xe=1;xe<v;xe++){O=K[ie+xe],L=K[re+xe],J.push(O);for(let de=1,De=xe-W+1;de<=De;de++)m.lerpVectors(O,L,de/(De+1)),m.sub(P).setLength(z[oe]).add(P),J.push(m.clone());J.push(L)}for(let xe=0;xe<v;xe++)J.push(K[xe+v+ie]);J.push(K[re+v]);let Ee=C.map(xe=>J[xe]);a.push(...Ee.map(xe=>[xe.x,xe.y,xe.z]).flat()),c.push(...Ee.map(xe=>(w(xe,P),[b.x,b.y,b.z])).flat())}}let H=[];for(let q=0;q<S.length;q++)for(let X=0;X<f;X++){let K=S[q][X];if(K<M){let z=S[K].findIndex($=>$%M==q),Q=j[q][X],te=j[K][z];for(let $=0;$<v;$++){let W=Q[$],oe=te[v-$],ie=Q[$+1],re=te[v-($+1)];[W,oe,ie,ie,oe,re].forEach(J=>{a.push(J[0].x,J[0].y,J[0].z),c.push(J[1].x,J[1].y,J[1].z)})}H.push(Q[0][0],te[v][0],Q[v][0],te[0][0])}}for(;H.length;){let q,X,K,z;[q,X]=H.splice(0,2);let Q=[q];for(;q!=X;)Q.push(X),K=H.indexOf(X),z=K%2,X=H.splice(K-z,2)[1-z];b.subVectors(Q[0],Q[1]).cross(m.subVectors(Q[0],Q[2])).normalize();let te=b.dot(Q[0])<0;te&&b.negate();for(let $=1;$<=Q.length-2;$++)[Q[$+ +te],Q[$+1-+te],Q[0]].forEach(W=>{a.push(W.x,W.y,W.z),c.push(b.x,b.y,b.z)})}}function h(){let d=new E;for(let T=0;T<a.length;T+=3){d.x=a[T+0],d.y=a[T+1],d.z=a[T+2];let S=w(d)/2/Math.PI+.5,M=A(d)/Math.PI+.5;l.push(S,1-M)}let f=new E,m=new E,p=new E,g=new E,y=new U,x=new U,v=new U,b=(T,S,M,C)=>{C<0&&T.x===1&&(l[S]=T.x-1),M.x===0&&M.z===0&&(l[S]=C/2/Math.PI+.5)};for(let T=0,S=0;T<a.length;T+=9,S+=6){f.set(a[T+0],a[T+1],a[T+2]),m.set(a[T+3],a[T+4],a[T+5]),p.set(a[T+6],a[T+7],a[T+8]),y.set(l[S+0],l[S+1]),x.set(l[S+2],l[S+3]),v.set(l[S+4],l[S+5]),g.copy(f).add(m).add(p).divideScalar(3);let M=w(g);b(y,S+0,f,M),b(x,S+2,m,M),b(v,S+4,p,M)}for(let T=0;T<l.length;T+=6){let S=l[T+0],M=l[T+2],C=l[T+4],P=Math.max(S,M,C),_=Math.min(S,M,C);P>.9&&_<.1&&(S<.2&&(l[T+0]+=1),M<.2&&(l[T+2]+=1),C<.2&&(l[T+4]+=1))}function w(T){return Math.atan2(T.z,-T.x)}function A(T){return Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))}}}static fromJSON(t){return new Jl(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var p3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new Vm(t*.5,s,o):new lh(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},Vm=class extends Jl{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-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,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,r),this.type=l}static fromJSON(t){return new Vm(t.radius,t.corner,t.cornerSides)}};var Um=1e-12,Gd=class{constructor(t){this.position=new U;this.startPosition=new U;this.uuid=Se.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Gd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},jd=class extends Gd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new jd(this.parent).copy(this)}},ro=class extends Gd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new jd(this),new jd(this))}static create(e,r){let i=new ro(e,new U(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.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 ro(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new U,r=new U){let[i,s]=this.computeTangents();return i&&s&&(m3(i,e),m3(s,r)),[e,r]}computeTangent(e=new U){let[r,i]=this.computeTangents();return r&&i&&e.copy(r).add(i).normalize(),e}computeNormal(e=new U){let[r,i]=this.computeNormals();return e.copy(r).add(i).normalize(),e}};function m3(n,t=new U){let e=n.length();return t.set(-n.y/e,n.x/e)}var BE=n=>n,Hd=new U,wx=new U,_K=new U,IK=new U,DK=new U,OK=new U,y3=new E,v3=new E;function x3(n){let t=new U;t.addVectors(n.v0,Hd.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new U;return e.addVectors(n.v2,wx.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new hn(n.v0,t,e,n.v2)}function km(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function RK(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function LK(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function FE(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((i*i+r*r-s*s)/(2*i*r))}function b3(n,t,e){return g3(n,t)&&g3(t,e)&&NE(n.position,t.position,e.position)}function NE(n,t,e){return Hd.copy(t).sub(n).cross(wx.copy(e).sub(n))===0}function S3(n,t,e,r,i){let s=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=(n.y+t.y)/2,a=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(n.y-t.y)/s,c=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-n.x)/s;return r.set(a+l,o+c),i.set(a-l,o-c),[r,i]}function w3(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function A3(n,t,e,r,i,s){let o=t.x-n.x,a=t.y-n.y,l=e.x-n.x,c=e.y-n.y,u=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c)),h;return FE(t,n,e)>Math.PI&&(u*=-1),km(c,a)?h=(a+c)*(r/u-.5)*8/3/(o-l):h=(o+l)*(r/u-.5)*8/3/(c-a),i.set(t.x-h*a,t.y+h*o),s.set(e.x+h*c,e.y-h*l),[i,s]}function VE(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function g3(n,t){return NE(n.position,n.controls[1].position,t.position)&&NE(n.position,t.controls[0].position,t.position)}function E3(n,t,e,r,i=.5){let s=Hd.subVectors(t,n).multiplyScalar(i).add(n),o=wx.subVectors(e,t).multiplyScalar(i).add(t),a=_K.subVectors(r,e).multiplyScalar(i).add(e),l=s,c=IK.subVectors(o,s).multiplyScalar(i).add(s),u=DK.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=OK.subVectors(u,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,h.x,h.y,r.x,r.y]}function T3(n,t,e=12,r=!0){let i=v3.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let c=BE(t[l]),u=Hd,h=$l(c,e);a.push(h);for(let d=0;d<=h;d++)if(c instanceof hn||c instanceof es||c instanceof dn){if(c.getPoint(d/h,u),i.set(u.x,u.y,0),s!==void 0&&LK(s,i))continue;s===void 0&&(s=y3),s.copy(i),n.setXYZ(o,i.x,i.y,i.z),o++}}return r&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),n}function M3(n,t,e,r=12,i=!0){let s=v3.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=BE(t[l]),h=Hd,d=$l(u,r);a.push(d);for(let f=0;f<=d;f++)if(u instanceof hn||u instanceof es||u instanceof dn){if(u.getPoint(f/d,h),s.set(h.x,h.y,0),c?.equals(s))continue;c===void 0?c=y3:(n.setXYZ(o,c.x,c.y,c.z),o++,n.setXYZ(o,s.x,s.y,s.z),o++),c.copy(s)}}return i&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),a}function UE(n,t=12,e=!1){let r=[];for(let i=0,s=n.length;i<s;i++){let o=n[i],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=$l(o.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=$l(o.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=$l(n[0].roundedCurveCorner,t)*.5),r}function $l(n,t=12){return n&&n instanceof kc?t*2:n&&(n instanceof dn||n instanceof jp)?1:n&&n instanceof sh?t*n.points.length:t}function C3(n,t,e=12,r=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=BE(t[o]),l=$l(a,e),c=Hd;for(let u=0;u<=l;u++)if(a instanceof hn||a instanceof es||a instanceof dn){if(a.getPoint(u/l,c),i!==void 0&&RK(i,c,Um))continue;i===void 0&&(i=wx),i.copy(c),n.push(c.x,c.y),s++}}return km(n[0],n[n.length-2],Um)&&km(n[1],n[n.length-1],Um)&&(n.pop(),n.pop()),r&&s>1&&!(km(n[s-1],n[1],Um)&&km(n[s-2],n[0],Um))&&(n.push(n[0],n[1]),s++),n}var kE=new U,NK=new U,BK=new U,FK=new U,VK=new U,UK=new U,$t=class extends Ca{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new qr(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=Se.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,i){let s=new $t;return s.isClosed=e.isClosed,s.points=e.points.map(o=>ro.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>$t.createFromState(o)),r!==void 0&&i!==void 0&&s.applySize(r,i),s.update(),s}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 r=0,i=this.points.length;r<i;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,i=this.points.findIndex(s=>s.uuid===e);if(i<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],c=l.points.length,u=l.getPointIndexById(e);if(u<0)s+=c;else return u+s}}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 r=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=e-r;if(a<=o.points.length-1)return o.points[a];r+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(e);if(a>=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let i=kE.set(e,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,r);this._update()}createPoint(e,r=0,i=Se.generateUUID()){let s;e instanceof U?s=e:s=new U(e,r);let o=new ro(i,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,i=this.points.length;r<i;r++){let s=this.points[r];if(s.uuid===e)return s}for(let r=0,i=this.shapeHoles.length;r<i;r++){let o=this.shapeHoles[r].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(i=>i.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=i?this.roundedCurveDivisions:this.curveDivisions;return T3(e,i?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=UE(this.points,e,!1),this.roundedCurveDivisions=UE(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return M3(e,this.curves,r,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),C3(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=$l(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l<c;l++){let u=s[l];if(a<i+u)return[l,(a-i+1)/u];i+=u}return[0,1]}getCurveT(e,r,i){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(VE(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(kE.set(i.x,i.y))/h}let c=0;for(let h=0;h<e;h++)c+=a[h];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){VE(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.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,r.curveAfter=i;let s=i.clone();e.roundedCurveBefore=s,r.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,i=this.points.length;r<i;r++){let s=this.points[r];if(r===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[r-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(r,i)}if(this.points.length>2){let r=0;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],c=o.roundness,u=a&&l&&b3(a,o,l);if(!o.controlsMoved()&&c>0&&!u){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,m=o.roundedCurveAfter,p=h.getLength(),g=d.getLength(),y=Math.min(c,p*.499),x=Math.min(c,g*.499),v=Math.min(y,x),b=1-v/p,w=v/g,A=h.getPointAt(b,kE),T=d.getPointAt(w,NK);this._subSplitCurve(h,f,b,A,void 0),this._subSplitCurve(d,m,w,void 0,T);let S;if(this.useCubicForRoundedCorners){let M=FE(A,o.position,T)/2,C=Math.tan(M)*A.distanceTo(o.position),[P,_]=S3(A,T,C,BK,FK),I=w3(P,_,o.position),[O,L]=A3(I,A,T,C,VK,UK);S=new hn(A.clone(),O.clone(),L.clone(),T.clone())}else S=new es(A.clone(),o.position.clone(),T.clone());o.roundedCurveCorner=S,this.roundedCurves.splice(i+r,0,S),r++}}}}_subSplitCurve(e,r,i,s,o){if(e instanceof dn)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,c=a.getUtoTmapping(i,0),u=E3(a.v0,a.v1,a.v2,a.v3,c);return s!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),o!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return r}clone(){let e=new $t(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let i=0;i<r;i++){let s=i*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],c=e.points[s+3],u=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new ro(Se.generateUUID(),new U(o,a));f.controls[0].position.set(l,c),f.controls[1].position.set(u,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let s=new $t;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let i=(o,a)=>{a instanceof hn&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,c;for(l=0,c=o.length;l<c;l++)o[l]instanceof es&&(o[l]=x3(o[l]));for(l=0,c=o.length;l<c;l++){let d=o[l],f=l>0?o[l-1]:null,m;d instanceof hn?(m=this.createPoint(d.v0),m.controls[1].position.copy(d.v1)):d instanceof dn&&(m=this.createPoint(d.v1)),m!==void 0&&(f!==null&&i(m,f),a.push(m))}let u=o[o.length-1],h=!1;return u instanceof hn?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),h=!0):u instanceof dn&&u.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof Ca&&(this.shapeHoles=e.holes.map(o=>{let a=new $t;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let i=this.getPointByUuid(e);i&&(r.position!==void 0&&i.position.fromArray(r.position),r.roundness!==void 0&&(i.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let s=this.getPointByUuid(e)?.controls[0];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let s=this.getPointByUuid(e)?.controls[1];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}};var GE=Math.PI*2;function zE({x:n,y:t},e,r,i,s){return{x:n*e+i,y:t*r+s}}function kK(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),i=Math.sin(n),s=Math.cos(n+t),o=Math.sin(n+t);return[{x:r-i*e,y:i+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function P3(n,t,e,r){let i=n*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,n*e+t*r));return i*Math.acos(s)}function zK(n,t,e,r,i,s,o,a,l,c){let u=Math.pow(i,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),m=u*h-u*f-h*d;m<0&&(m=0),m/=u*f+h*d,m=Math.sqrt(m)*(l===c?-1:1);let p=m*i/s*a,g=m*-s/i*o,y=p+(n+e)/2,x=g+(t+r)/2,v=(o-p)/i,b=(a-g)/s,w=(-o-p)/i,A=(-a-g)/s,T=P3(1,0,v,b),S=P3(v,b,w,A);return!c&&S>0&&(S-=GE),c&&S<0&&(S+=GE),{centerx:y,centery:x,ang1:T,ang2:S}}function _3({px:n,py:t,cx:e,cy:r,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let c=(n-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];i=Math.abs(i),s=Math.abs(s);let h=Math.pow(c,2)/Math.pow(i,2)+Math.pow(u,2)/Math.pow(s,2);h>1&&(i*=Math.sqrt(h),s*=Math.sqrt(h));let d=zK(n,t,e,r,i,s,c,u,o,a),{ang1:f,ang2:m}=d,{centerx:p,centery:g}=d,y=Math.abs(m)/(GE/4);Math.abs(1-y)<1e-7&&(y=1);let x=Math.max(Math.ceil(y),1);m/=x;for(let v=0;v<x;v++)l.push(kK(f,m)),f+=m;return l.map(v=>{let{x:b,y:w}=zE(v[0],i,s,p,g),{x:A,y:T}=zE(v[1],i,s,p,g),{x:S,y:M}=zE(v[2],i,s,p,g);return{x1:b,y1:w,x2:A,y2:T,x:S,y:M}})}var qt;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(qt||(qt={}));var Qr;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Qr||(Qr={}));function ft(n,t){if(!n)throw t||"Assertion Failed!"}var lt=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){ft(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,s=r.s-e.s;return i+s>0?i<s?e.t-t.t+(t.t-r.t)*(i/(i+s)):e.t-r.t+(r.t-t.t)*(s/(i+s)):0},n.edgeSign=function(t,e,r){ft(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,s=r.s-e.s;return i+s>0?(e.t-r.t)*i+(e.t-t.t)*s:0},n.transEval=function(t,e,r){ft(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,s=r.t-e.t;return i+s>0?i<s?e.s-t.s+(t.s-r.s)*(i/(i+s)):e.s-r.s+(r.s-t.s)*(s/(i+s)):0},n.transSign=function(t,e,r){ft(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,s=r.t-e.t;return i+s>0?(e.s-r.s)*i+(e.s-t.s)*s:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,i){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+i)/2:e+(i-e)*(t/(t+r)):i+(e-i)*(r/(t+r))},n.intersect=function(t,e,r,i,s){var o,a,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.vertLeq(r,e)?n.vertLeq(e,i)?(o=n.edgeEval(t,r,e),a=n.edgeEval(r,e,i),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,e.s)):(o=n.edgeSign(t,r,e),a=-n.edgeSign(t,i,e),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,i.s)):s.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.transLeq(r,e)?n.transLeq(e,i)?(o=n.transEval(t,r,e),a=n.transEval(r,e,i),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,e.t)):(o=n.transSign(t,r,e),a=-n.transSign(t,i,e),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,i.t)):s.t=(r.t+e.t)/2},n}(),zm=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Ax=function(){function n(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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Wd=function(){function n(){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 n}(),I3=function(){function n(){var t=new Wd,e=new zm,r=new Ax(0),i=new Ax(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(t){var e=new Ax(0),r=new Ax(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return r.next=i,i.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},n.prototype.splice_=function(t,e){var r=t.Onext,i=e.Onext;r.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var i=t;ft(i,"Vertex can't be null!");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=e;var o=e;do o.Org=i,o=o.Onext;while(o!==e)},n.prototype.makeFace_=function(t,e,r){var i=t;ft(i,"Face can't be null");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=r.inside;var o=e;do o.Lface=i,o=o.Lnext;while(o!==e)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,i=r;do i.Org=e,i=i.Onext;while(i!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},n.prototype.killFace_=function(t,e){var r=t.anEdge,i=r;do i.Lface=e,i=i.Lnext;while(i!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},n.prototype.makeEdge=function(){var t=new Wd,e=new Wd,r=new zm,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(t,e){var r=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var s=new Wd;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new zm;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=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 i=new zm;this.makeFace_(i,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Wd;return this.makeVertex_(i,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.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},n.prototype.connect=function(t,e){var r=!1,i=this.makeEdge_(t),s=i.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(s,e),i.Org=t.Dst,s.Org=e.Org,i.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var o=new zm;this.makeFace_(o,i,t.Lface)}return i},n.prototype.zapFace=function(t){var e=t.anEdge,r,i,s,o,a;i=e.Lnext;do r=i,i=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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,i,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,o=r.Org;i=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&<.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&<.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=i;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,i,s,o,a,l,c;for(s=t,s=t;(i=s.next)!==t;s=i){ft(i.prev===s),l=i.anEdge;do ft(l.Sym!==l),ft(l.Sym.Sym===l),ft(l.Lnext.Onext.Sym===l),ft(l.Onext.Sym.Lnext===l),ft(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(ft(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){ft(o.prev===a),l=o.anEdge;do ft(l.Sym!==l),ft(l.Sym.Sym===l),ft(l.Lnext.Onext.Sym===l),ft(l.Onext.Sym.Lnext===l),ft(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(ft(o.prev===a&&o.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ft(l.Sym.next===c.Sym),ft(l.Sym!==l),ft(l.Sym.Sym===l),ft(l.Org!==null),ft(l.Dst!==null),ft(l.Lnext.Onext.Sym===l),ft(l.Onext.Sym.Lnext===l);ft(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),D3=function(){function n(){this.handle=null}return n}(),O3=function(){function n(){this.key=null,this.node=0}return n}(),GK=function(){function n(t,e){this.leq=e,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 D3,this.handles[r]=new O3;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(r[e[o+1].handle].key,r[e[o].handle].key)&&++o,ft(o<=this.max),s=e[o].handle,o>this.size||this.leq(r[i].key,r[s].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=s,r[s].node=t,t=o}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[i].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=s,r[s].node=t,t=o}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new D3;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new O3}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,i=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),i},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,i;ft(t>=1&&t<=this.max&&r[t].key!==null),i=r[t].node,e[i].handle=e[this.size].handle,r[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[e[i>>1].handle].key,r[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),jE=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),R3=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),jK=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new R3,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new R3;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),HK=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var i=t.event,s=e.eUp,o=r.eUp;if(s.Dst===i)return o.Dst===i?lt.vertLeq(s.Org,o.Org)?lt.edgeSign(o.Dst,s.Org,o.Org)<=0:lt.edgeSign(s.Dst,o.Org,s.Org)>=0:lt.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return lt.edgeSign(s.Dst,i,s.Org)>=0;var a=lt.edgeEval(s.Dst,i,s.Org),l=lt.edgeEval(o.Dst,i,o.Org);return a>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ft(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ft(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,i;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(i=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;n.fixUpperEdge(t,e,i),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var i=new jE;return i.eUp=r,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(t,e){switch(t.windingRule){case qt.ODD:return(e&1)!==0;case qt.NONZERO:return e!==0;case qt.POSITIVE:return e>0;case qt.NEGATIVE:return e<0;case qt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,i=r.Lface;i.inside=e.inside,i.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var i,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=n.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){n.finishRegion(t,o);break}i=t.mesh.connect(a.Lprev,i.Sym),n.fixUpperEdge(t,s,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),n.finishRegion(t,o),a=s.eUp,o=s}return a},n.addRightEdges=function(t,e,r,i,s,o){var a,l,c,u,h=!0;c=r;do ft(lt.vertLeq(c.Org,c.Dst)),n.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==i);for(s===null&&(s=n.regionBelow(e).eUp.Rprev),l=e,u=s;a=n.regionBelow(l),c=a.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=n.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&n.checkForRightSplice(t,l)&&(n.addWinding(c,u),n.deleteRegion(t,l),t.mesh.delete(u)),h=!1,l=a,u=c;l.dirty=!0,ft(l.windingNumber-c.winding===a.windingNumber),o&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var i=lt.vertL1dist(e,t),s=lt.vertL1dist(r,t),o=.5*s/(i+s),a=.5*i/(i+s);t.coords[0]+=o*e.coords[0]+a*r.coords[0],t.coords[1]+=o*e.coords[1]+a*r.coords[1],t.coords[2]+=o*e.coords[2]+a*r.coords[2]},n.getIntersectData=function(t,e,r,i,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,i),n.vertexWeights(e,s,o)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp;if(lt.vertLeq(i.Org,s.Org)){if(lt.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;lt.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(t.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(t,s.Oprev,i)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(i,s.Oprev),e.dirty=r.dirty=!0)}else{if(lt.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Oprev,i)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp,o;if(ft(!lt.vertEq(i.Dst,s.Dst)),lt.vertLeq(i.Dst,s.Dst)){if(lt.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(i),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(lt.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp,o=i.Org,a=s.Org,l=i.Dst,c=s.Dst,u,h,d=new Wd,f,m;if(ft(!lt.vertEq(c,l)),ft(lt.edgeSign(l,t.event,o)<=0),ft(lt.edgeSign(c,t.event,a)>=0),ft(o!==t.event&&a!==t.event),ft(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(u=Math.min(o.t,l.t),h=Math.max(a.t,c.t),u>h))return!1;if(lt.vertLeq(o,a)){if(lt.edgeSign(c,o,a)>0)return!1}else if(lt.edgeSign(l,a,o)<0)return!1;return n.debugEvent(t),lt.intersect(l,o,c,a,d),ft(Math.min(o.t,l.t)<=d.t),ft(d.t<=Math.max(a.t,c.t)),ft(Math.min(c.s,l.s)<=d.s),ft(d.s<=Math.max(a.s,o.s)),lt.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=lt.vertLeq(o,a)?o:a,lt.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),lt.vertEq(d,o)||lt.vertEq(d,a)?(n.checkForRightSplice(t,e),!1):!lt.vertEq(l,t.event)&<.edgeSign(l,t.event,d)>=0||!lt.vertEq(c,t.event)&<.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Sym,i),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(i.Lnext,s.Oprev),r=e,e=n.topRightRegion(e),m=n.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,s.Onext,i.Rprev,m,!0),!0):(lt.edgeSign(l,t.event,d)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),lt.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=t.pq.insert(i.Org),n.getIntersectData(t,i.Org,o,l,a,c),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),i,s;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,s=r.eUp,i.Dst!==s.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(s),r=n.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r),i=e.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===t.event||s.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);i.Org===s.Org&&i.Dst===s.Dst&&(n.addWinding(s,i),n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var i,s=r.Onext,o=n.regionBelow(e),a=e.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&n.checkForIntersect(t,e),lt.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=n.topLeftRegion(t,e),s=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),o),c=!0),lt.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,o,null),c=!0),c){n.addRightEdges(t,e,r.Onext,s,s,!0);return}lt.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(r.Lprev,i),n.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var i,s,o,a,l;if(i=e.eUp,lt.vertEq(i.Org,r)){ft(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!lt.vertEq(i.Dst,r)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,i),n.sweepEvent(t,r);return}ft(!1),e=n.topRightRegion(e),l=n.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(ft(s!==o),n.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),lt.edgeGoesLeft(s)||(s=null),n.addRightEdges(t,e,o.Onext,a,s,!0)},n.connectLeftVertex=function(t,e){var r,i,s,o,a,l,c=new jE;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(o=r.eUp,a=i.eUp,lt.edgeSign(o.Dst,e,o.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(s=lt.vertLeq(a.Dst,o.Dst)?r:i,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var u=t.mesh.connect(a.Dnext,e.anEdge);l=u.Sym}s.fixUpperEdge?n.fixUpperEdge(t,s,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var i=n.topLeftRegion(t,r.activeRegion);ft(i!==null);var s=n.regionBelow(i),o=s.eUp,a=n.finishLeftRegions(t,s,null);a.Onext===o?n.connectRightVertex(t,i,a):n.addRightEdges(t,i,a.Onext,o,o,!0)},n.addSentinel=function(t,e,r,i){var s=new jE,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=i,o.Dst.s=e,o.Dst.t=i,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},n.initEdgeDict=function(t){t.dict=new jK(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;n.addSentinel(t,i,s,o),n.addSentinel(t,i,s,a)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(ft(e.fixUpperEdge),ft(++r===1)),ft(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,i,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,i=e.Lnext,lt.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,i,s=0;for(i=t.mesh.vHead,r=i.next;r!==i;r=r.next)s++;for(s+=8,e=t.pq=new GK(s,lt.vertLeq),i=t.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=e.insert(r);return r!==i?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,i,s;for(r=e.fHead.next;r!==e.fHead;r=i)i=r.next,s=r.anEdge,ft(s.Lnext!==s),s.Lnext.Lnext===s&&(n.addWinding(s.Onext,s),t.mesh.delete(s));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,i;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!lt.vertEq(i,r));)i=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,i.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),WK=function(){function n(){this.mesh=new I3,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=qt.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 n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,i,s,o,a,l=[0,0,0],c=[0,0,0],u=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;e=p.next;for(var g=0;g<3;++g)s=e.coords[g],c[g]=s,m[g]=e,l[g]=s,f[g]=e;for(e=p.next;e!==p;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<c[y]&&(c[y]=s,m[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var x=0;if(l[1]-c[1]>l[0]-c[0]&&(x=1),l[2]-c[2]>l[x]-c[x]&&(x=2),c[x]>=l[x]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=m[x],i=f[x],u[0]=r.coords[0]-i.coords[0],u[1]=r.coords[1]-i.coords[1],u[2]=r.coords[2]-i.coords[2],e=p.next;e!==p;e=e.next)h[0]=e.coords[0]-i.coords[0],h[1]=e.coords[1]-i.coords[1],h[2]=e.coords[2]-i.coords[2],d[0]=u[1]*h[2]-u[2]*h[1],d[1]=u[2]*h[0]-u[0]*h[2],d[2]=u[0]*h[1]-u[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,i,s=0,o=t.next;o!==t;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,i,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),r=this.sUnit,i=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,i;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;lt.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;lt.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var s=void 0;r.Lnext!==i;)if(lt.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(lt.edgeGoesLeft(i.Lnext)||lt.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=t.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(lt.edgeGoesRight(r.Lprev)||lt.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)s=t.connect(i.Lnext,i),i=s.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var i,s=t.eHead.next;s!==t.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,i){var s,o=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=o,++o}this.elementCount=o,e===Qr.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var h=c.n*i;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],i>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;this.elements[d++]=c.n,l++,s=s.Lnext}while(s!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===Qr.CONNECTED_POLYGONS){s=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==u.anEdge);for(var m=l;m<r;++m)this.elements[d++]=-1}}},n.prototype.outputContours_=function(t,e){var r,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){i=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,u=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,i=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==i);this.elements[u++]=s,this.elements[u++]=o,s+=o}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new I3),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i<e.length;i+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[i+0],r.Org.coords[1]=e[i+1],t>2?r.Org.coords[2]=e[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,i,s,o){if(t===void 0&&(t=qt.ODD),e===void 0&&(e=Qr.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),HK.computeInterior(this,o);var a=this.mesh;return e===Qr.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===Qr.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,r,i),!0},n}();function io(n){var t=n.windingRule,e=t===void 0?qt.ODD:t,r=n.elementType,i=r===void 0?Qr.POLYGONS:r,s=n.polySize,o=s===void 0?3:s,a=n.vertexSize,l=a===void 0?2:a,c=n.normal,u=c===void 0?[0,0,1]:c,h=n.contours,d=h===void 0?[]:h,f=n.strict,m=f===void 0?!0:f,p=n.debug,g=p===void 0?!1:p;if(!d&&m)throw new Error("Contours can't be empty");if(!!d){var y=new WK;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var x=0;x<d.length;x++)y.addContour(l||2,d[x]);return y.tesselate(e,i,o,l,u,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var sbe=qt.ODD,obe=qt.NONZERO,abe=qt.POSITIVE,lbe=qt.NEGATIVE,cbe=qt.ABS_GEQ_TWO,ube=Qr.POLYGONS,hbe=Qr.CONNECTED_POLYGONS,dbe=Qr.BOUNDARY_CONTOURS;var Ex=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Ex.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*i,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Ex.eSize,i=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*t);o+=3*t;let l=new Float32Array(i,o*s,3*t);o+=3*t;let c=new Float32Array(i,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Gm=Ex;Gm.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var jm=class{constructor(t=[],e=(r,i)=>r<i?-1:r>i?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,i=e[t];for(;t>0;){let s=t-1>>1,o=e[s];if(r(i,o)>=0)break;e[t]=o,t=s}e[t]=i}_down(t){let{data:e,compare:r}=this,i=this.length>>1,s=e[t];for(;t<i;){let o=(t<<1)+1,a=o+1;if(a<this.length&&r(e[a],e[o])<0&&(o=a),r(e[o],s)>=0)break;e[t]=e[o],t=o}e[t]=s}};function HE(n,t,e=1,r=!1){let i=1/0,s=1/0,o=-1/0,a=-1/0;for(let[x,v]of n[0])x<i&&(i=x),v<s&&(s=v),x>o&&(o=x),v>a&&(a=v);let l=o-i,c=a-s,u=Math.max(e,Math.min(l,c));if(u===e){let x=[i,s];return x.distance=0,x.distance}let h=new jm([],(x,v)=>v.max-x.max),d=XK(n),f=new Tx(i+l/2,s+c/2,0,n);f.d>d.d&&(d=f);let m=2;function p(x,v,b){let w=new Tx(x,v,b,n);if(m++,w.max>d.d+e&&h.push(w),w.d>d.d&&(d=w,r&&console.log(`found best ${Math.round(1e4*w.d)/1e4} after ${m} probes`),d.d>t))return t}let g=u/2;for(let x=i;x<o;x+=u)for(let v=s;v<a;v+=u)p(x+g,v+g,g);for(;h.length;){let{max:x,x:v,y:b,h:w}=h.pop();if(x-d.d<=e)break;g=w/2,p(v-g,b-g,g),p(v+g,b-g,g),p(v-g,b+g,g),p(v+g,b+g,g)}r&&console.log(`num probes: ${m}
|
|
3139
|
+
}`;function H5(n,t,e){let r=new kp,i=new U,s=new U,o=new Ze,a=new zp({depthPacking:Dw}),l=new ow,c={},u=e.maxTextureSize,h={[Jn]:xi,[xi]:Jn,[vi]:vi},d=new $e({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new U},radius:{value:4}},vertexShader:G5,fragmentShader:j5}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new Ce;m.setAttribute("position",new je(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Mt(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=uv,this.render=function(b,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let T=n.getRenderTarget(),S=n.getActiveCubeFace(),M=n.getActiveMipmapLevel(),C=n.state;C.setBlending(or),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let P=0,_=b.length;P<_;P++){let I=b[P],O=I.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",I,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;i.copy(O.mapSize);let L=O.getFrameExtents();if(i.multiply(L),s.copy(O.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/L.x),i.x=s.x*L.x,O.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/L.y),i.y=s.y*L.y,O.mapSize.y=s.y)),O.map===null){let V=this.type!==_p?{minFilter:vt,magFilter:vt}:{};O.map=new at(i.x,i.y,V),O.map.texture.name=I.name+".shadowMap",O.camera.updateProjectionMatrix()}n.setRenderTarget(O.map),n.clear();let j=O.getViewportCount();for(let V=0;V<j;V++){let H=O.getViewport(V);o.set(s.x*H.x,s.y*H.y,s.x*H.z,s.y*H.w),C.viewport(o),O.updateMatrices(I,V),r=O.getFrustum(),v(w,A,O.camera,I,this.type)}O.isPointLightShadow!==!0&&this.type===_p&&y(O,A),O.needsUpdate=!1}g.needsUpdate=!1,n.setRenderTarget(T,S,M)};function y(b,w){let A=t.update(p);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new at(i.x,i.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(w,null,A,d,p,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(w,null,A,f,p,null)}function x(b,w,A,T,S,M){let C=null,P=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(P!==void 0)C=P;else if(C=A.isPointLight===!0?l:a,n.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 _=C.uuid,I=w.uuid,O=c[_];O===void 0&&(O={},c[_]=O);let L=O[I];L===void 0&&(L=C.clone(),O[I]=L),C=L}return C.visible=w.visible,C.wireframe=w.wireframe,M===_p?C.side=w.shadowSide!==null?w.shadowSide:w.side:C.side=w.shadowSide!==null?w.shadowSide:h[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=T,C.farDistance=S),C}function v(b,w,A,T,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===_p)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let P=t.update(b),_=b.material;if(Array.isArray(_)){let I=P.groups;for(let O=0,L=I.length;O<L;O++){let j=I[O],V=_[j.materialIndex];if(V&&V.visible){let H=x(b,V,T,A.near,A.far,S);n.renderBufferDirect(A,null,P,H,b,j)}}}else if(_.visible){let I=x(b,_,T,A.near,A.far,S);n.renderBufferDirect(A,null,P,I,b,null)}}let C=b.children;for(let P=0,_=C.length;P<_;P++)v(C[P],w,A,T,S)}}function W5(n,t,e){let r=e.isWebGL2;function i(){let Z=!1,ve=new Ze,Me=null,qe=new Ze(0,0,0,0);return{setMask:function(Xe){Me!==Xe&&!Z&&(n.colorMask(Xe,Xe,Xe,Xe),Me=Xe)},setLocked:function(Xe){Z=Xe},setClear:function(Xe,Rt,Hr,Wr,va){va===!0&&(Xe*=Wr,Rt*=Wr,Hr*=Wr),ve.set(Xe,Rt,Hr,Wr),qe.equals(ve)===!1&&(n.clearColor(Xe,Rt,Hr,Wr),qe.copy(ve))},reset:function(){Z=!1,Me=null,qe.set(-1,0,0,0)}}}function s(){let Z=!1,ve=null,Me=null,qe=null;return{setTest:function(Xe){Xe?oe(2929):ie(2929)},setMask:function(Xe){ve!==Xe&&!Z&&(n.depthMask(Xe),ve=Xe)},setFunc:function(Xe){if(Me!==Xe){switch(Xe){case wU:n.depthFunc(512);break;case AU:n.depthFunc(519);break;case EU:n.depthFunc(513);break;case WS:n.depthFunc(515);break;case TU:n.depthFunc(514);break;case MU:n.depthFunc(518);break;case CU:n.depthFunc(516);break;case PU:n.depthFunc(517);break;default:n.depthFunc(515)}Me=Xe}},setLocked:function(Xe){Z=Xe},setClear:function(Xe){qe!==Xe&&(n.clearDepth(Xe),qe=Xe)},reset:function(){Z=!1,ve=null,Me=null,qe=null}}}function o(){let Z=!1,ve=null,Me=null,qe=null,Xe=null,Rt=null,Hr=null,Wr=null,va=null;return{setTest:function(Dr){Z||(Dr?oe(2960):ie(2960))},setMask:function(Dr){ve!==Dr&&!Z&&(n.stencilMask(Dr),ve=Dr)},setFunc:function(Dr,us,Rn){(Me!==Dr||qe!==us||Xe!==Rn)&&(n.stencilFunc(Dr,us,Rn),Me=Dr,qe=us,Xe=Rn)},setOp:function(Dr,us,Rn){(Rt!==Dr||Hr!==us||Wr!==Rn)&&(n.stencilOp(Dr,us,Rn),Rt=Dr,Hr=us,Wr=Rn)},setLocked:function(Dr){Z=Dr},setClear:function(Dr){va!==Dr&&(n.clearStencil(Dr),va=Dr)},reset:function(){Z=!1,ve=null,Me=null,qe=null,Xe=null,Rt=null,Hr=null,Wr=null,va=null}}}let a=new i,l=new s,c=new o,u=new WeakMap,h=new WeakMap,d={},f={},m=new WeakMap,p=[],g=null,y=!1,x=null,v=null,b=null,w=null,A=null,T=null,S=null,M=!1,C=null,P=null,_=null,I=null,O=null,L=n.getParameter(35661),j=!1,V=0,H=n.getParameter(7938);H.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(H)[1]),j=V>=1):H.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),j=V>=2);let q=null,X={},K=n.getParameter(3088),z=n.getParameter(2978),Q=new Ze().fromArray(K),te=new Ze().fromArray(z);function $(Z,ve,Me){let qe=new Uint8Array(4),Xe=n.createTexture();n.bindTexture(Z,Xe),n.texParameteri(Z,10241,9728),n.texParameteri(Z,10240,9728);for(let Rt=0;Rt<Me;Rt++)n.texImage2D(ve+Rt,0,6408,1,1,0,6408,5121,qe);return Xe}let W={};W[3553]=$(3553,3553,1),W[34067]=$(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),oe(2929),l.setFunc(WS),ze(!1),ke(OC),oe(2884),De(or);function oe(Z){d[Z]!==!0&&(n.enable(Z),d[Z]=!0)}function ie(Z){d[Z]!==!1&&(n.disable(Z),d[Z]=!1)}function re(Z,ve){return f[Z]!==ve?(n.bindFramebuffer(Z,ve),f[Z]=ve,r&&(Z===36009&&(f[36160]=ve),Z===36160&&(f[36009]=ve)),!0):!1}function J(Z,ve){let Me=p,qe=!1;if(Z)if(Me=m.get(ve),Me===void 0&&(Me=[],m.set(ve,Me)),Z.isWebGLMultipleRenderTargets){let Xe=Z.texture;if(Me.length!==Xe.length||Me[0]!==36064){for(let Rt=0,Hr=Xe.length;Rt<Hr;Rt++)Me[Rt]=36064+Rt;Me.length=Xe.length,qe=!0}}else Me[0]!==36064&&(Me[0]=36064,qe=!0);else Me[0]!==1029&&(Me[0]=1029,qe=!0);qe&&(e.isWebGL2?n.drawBuffers(Me):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Me))}function Ee(Z){return g!==Z?(n.useProgram(Z),g=Z,!0):!1}let xe={[Ku]:32774,[hU]:32778,[dU]:32779};if(r)xe[BC]=32775,xe[FC]=32776;else{let Z=t.get("EXT_blend_minmax");Z!==null&&(xe[BC]=Z.MIN_EXT,xe[FC]=Z.MAX_EXT)}let de={[fU]:0,[pU]:1,[mU]:768,[c_]:770,[SU]:776,[xU]:774,[yU]:772,[gU]:769,[u_]:771,[bU]:775,[vU]:773};function De(Z,ve,Me,qe,Xe,Rt,Hr,Wr){if(Z===or){y===!0&&(ie(3042),y=!1);return}if(y===!1&&(oe(3042),y=!0),Z!==uU){if(Z!==x||Wr!==M){if((v!==Ku||A!==Ku)&&(n.blendEquation(32774),v=Ku,A=Ku),Wr)switch(Z){case ml:n.blendFuncSeparate(1,771,1,771);break;case RC:n.blendFunc(1,1);break;case LC:n.blendFuncSeparate(0,769,0,1);break;case NC:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Z);break}else switch(Z){case ml:n.blendFuncSeparate(770,771,1,771);break;case RC:n.blendFunc(770,1);break;case LC:n.blendFuncSeparate(0,769,0,1);break;case NC:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Z);break}b=null,w=null,T=null,S=null,x=Z,M=Wr}return}Xe=Xe||ve,Rt=Rt||Me,Hr=Hr||qe,(ve!==v||Xe!==A)&&(n.blendEquationSeparate(xe[ve],xe[Xe]),v=ve,A=Xe),(Me!==b||qe!==w||Rt!==T||Hr!==S)&&(n.blendFuncSeparate(de[Me],de[qe],de[Rt],de[Hr]),b=Me,w=qe,T=Rt,S=Hr),x=Z,M=!1}function Pe(Z,ve){Z.side===vi?ie(2884):oe(2884);let Me=Z.side===xi;ve&&(Me=!Me),ze(Me),Z.blending===ml&&Z.transparent===!1?De(or):De(Z.blending,Z.blendEquation,Z.blendSrc,Z.blendDst,Z.blendEquationAlpha,Z.blendSrcAlpha,Z.blendDstAlpha,Z.premultipliedAlpha),l.setFunc(Z.depthFunc),l.setTest(Z.depthTest),l.setMask(Z.depthWrite),a.setMask(Z.colorWrite);let qe=Z.stencilWrite;c.setTest(qe),qe&&(c.setMask(Z.stencilWriteMask),c.setFunc(Z.stencilFunc,Z.stencilRef,Z.stencilFuncMask),c.setOp(Z.stencilFail,Z.stencilZFail,Z.stencilZPass)),Le(Z.polygonOffset,Z.polygonOffsetFactor,Z.polygonOffsetUnits),Z.alphaToCoverage===!0?oe(32926):ie(32926)}function ze(Z){C!==Z&&(Z?n.frontFace(2304):n.frontFace(2305),C=Z)}function ke(Z){Z!==aU?(oe(2884),Z!==P&&(Z===OC?n.cullFace(1029):Z===lU?n.cullFace(1028):n.cullFace(1032))):ie(2884),P=Z}function Ue(Z){Z!==_&&(j&&n.lineWidth(Z),_=Z)}function Le(Z,ve,Me){Z?(oe(32823),(I!==ve||O!==Me)&&(n.polygonOffset(ve,Me),I=ve,O=Me)):ie(32823)}function Qe(Z){Z?oe(3089):ie(3089)}function F(Z){Z===void 0&&(Z=33984+L-1),q!==Z&&(n.activeTexture(Z),q=Z)}function B(Z,ve,Me){Me===void 0&&(q===null?Me=33984+L-1:Me=q);let qe=X[Me];qe===void 0&&(qe={type:void 0,texture:void 0},X[Me]=qe),(qe.type!==Z||qe.texture!==ve)&&(q!==Me&&(n.activeTexture(Me),q=Me),n.bindTexture(Z,ve||W[Z]),qe.type=Z,qe.texture=ve)}function N(){let Z=X[q];Z!==void 0&&Z.type!==void 0&&(n.bindTexture(Z.type,null),Z.type=void 0,Z.texture=void 0)}function ae(){try{n.compressedTexImage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function ye(){try{n.compressedTexImage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function me(){try{n.texSubImage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Ne(){try{n.texSubImage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Fe(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Oe(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function nt(){try{n.texStorage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function We(){try{n.texImage2D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Be(){try{n.texImage3D.apply(n,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function tt(Z){Q.equals(Z)===!1&&(n.scissor(Z.x,Z.y,Z.z,Z.w),Q.copy(Z))}function ot(Z){te.equals(Z)===!1&&(n.viewport(Z.x,Z.y,Z.z,Z.w),te.copy(Z))}function Gt(Z,ve){let Me=h.get(ve);Me===void 0&&(Me=new WeakMap,h.set(ve,Me));let qe=Me.get(Z);qe===void 0&&(qe=n.getUniformBlockIndex(ve,Z.name),Me.set(Z,qe))}function xr(Z,ve){let qe=h.get(ve).get(Z);u.get(ve)!==qe&&(n.uniformBlockBinding(ve,qe,Z.__bindingPointIndex),u.set(ve,qe))}function Ir(){n.disable(3042),n.disable(2884),n.disable(2929),n.disable(32823),n.disable(3089),n.disable(2960),n.disable(32926),n.blendEquation(32774),n.blendFunc(1,0),n.blendFuncSeparate(1,0,1,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(513),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(519,0,4294967295),n.stencilOp(7680,7680,7680),n.clearStencil(0),n.cullFace(1029),n.frontFace(2305),n.polygonOffset(0,0),n.activeTexture(33984),n.bindFramebuffer(36160,null),r===!0&&(n.bindFramebuffer(36009,null),n.bindFramebuffer(36008,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),d={},q=null,X={},f={},m=new WeakMap,p=[],g=null,y=!1,x=null,v=null,b=null,w=null,A=null,T=null,S=null,M=!1,C=null,P=null,_=null,I=null,O=null,Q.set(0,0,n.canvas.width,n.canvas.height),te.set(0,0,n.canvas.width,n.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:oe,disable:ie,bindFramebuffer:re,drawBuffers:J,useProgram:Ee,setBlending:De,setMaterial:Pe,setFlipSided:ze,setCullFace:ke,setLineWidth:Ue,setPolygonOffset:Le,setScissorTest:Qe,activeTexture:F,bindTexture:B,unbindTexture:N,compressedTexImage2D:ae,compressedTexImage3D:ye,texImage2D:We,texImage3D:Be,updateUBOMapping:Gt,uniformBlockBinding:xr,texStorage2D:pe,texStorage3D:nt,texSubImage2D:me,texSubImage3D:Ne,compressedTexSubImage2D:Fe,compressedTexSubImage3D:Oe,scissor:tt,viewport:ot,reset:Ir}}function q5(n,t,e,r,i,s,o){let a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,h=i.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(B,N){return y?new OffscreenCanvas(B,N):Vp("canvas")}function v(B,N,ae,ye){let me=1;if((B.width>ye||B.height>ye)&&(me=ye/Math.max(B.width,B.height)),me<1||N===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){let Ne=N?Vy:Math.floor,Fe=Ne(me*B.width),Oe=Ne(me*B.height);p===void 0&&(p=x(Fe,Oe));let pe=ae?x(Fe,Oe):p;return pe.width=Fe,pe.height=Oe,pe.getContext("2d").drawImage(B,0,0,Fe,Oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+Fe+"x"+Oe+")."),pe}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function b(B){return ZS(B.width)&&ZS(B.height)}function w(B){return a?!1:B.wrapS!==tr||B.wrapT!==tr||B.minFilter!==vt&&B.minFilter!==it}function A(B,N){return B.generateMipmaps&&N&&B.minFilter!==vt&&B.minFilter!==it}function T(B){n.generateMipmap(B)}function S(B,N,ae,ye,me=!1){if(a===!1)return N;if(B!==null){if(n[B]!==void 0)return n[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let Ne=N;return N===6403&&(ae===5126&&(Ne=33326),ae===5131&&(Ne=33325),ae===5121&&(Ne=33321)),N===33319&&(ae===5126&&(Ne=33328),ae===5131&&(Ne=33327),ae===5121&&(Ne=33323)),N===6408&&(ae===5126&&(Ne=34836),ae===5131&&(Ne=34842),ae===5121&&(Ne=ye===ut&&me===!1?35907:32856),ae===32819&&(Ne=32854),ae===32820&&(Ne=32855)),(Ne===33325||Ne===33326||Ne===33327||Ne===33328||Ne===34842||Ne===34836)&&t.get("EXT_color_buffer_float"),Ne}function M(B,N,ae){return A(B,ae)===!0||B.isFramebufferTexture&&B.minFilter!==vt&&B.minFilter!==it?Math.log2(Math.max(N.width,N.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?N.mipmaps.length:1}function C(B){return B===vt||B===VC||B===lS?9728:9729}function P(B){let N=B.target;N.removeEventListener("dispose",P),I(N),N.isVideoTexture&&m.delete(N)}function _(B){let N=B.target;N.removeEventListener("dispose",_),L(N)}function I(B){let N=r.get(B);if(N.__webglInit===void 0)return;let ae=B.source,ye=g.get(ae);if(ye){let me=ye[N.__cacheKey];me.usedTimes--,me.usedTimes===0&&O(B),Object.keys(ye).length===0&&g.delete(ae)}r.remove(B)}function O(B){let N=r.get(B);n.deleteTexture(N.__webglTexture);let ae=B.source,ye=g.get(ae);delete ye[N.__cacheKey],o.memory.textures--}function L(B){let N=B.texture,ae=r.get(B),ye=r.get(N);if(ye.__webglTexture!==void 0&&(n.deleteTexture(ye.__webglTexture),o.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)n.deleteFramebuffer(ae.__webglFramebuffer[me]),ae.__webglDepthbuffer&&n.deleteRenderbuffer(ae.__webglDepthbuffer[me]);else{if(n.deleteFramebuffer(ae.__webglFramebuffer),ae.__webglDepthbuffer&&n.deleteRenderbuffer(ae.__webglDepthbuffer),ae.__webglMultisampledFramebuffer&&n.deleteFramebuffer(ae.__webglMultisampledFramebuffer),ae.__webglColorRenderbuffer)for(let me=0;me<ae.__webglColorRenderbuffer.length;me++)ae.__webglColorRenderbuffer[me]&&n.deleteRenderbuffer(ae.__webglColorRenderbuffer[me]);ae.__webglDepthRenderbuffer&&n.deleteRenderbuffer(ae.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let me=0,Ne=N.length;me<Ne;me++){let Fe=r.get(N[me]);Fe.__webglTexture&&(n.deleteTexture(Fe.__webglTexture),o.memory.textures--),r.remove(N[me])}r.remove(N),r.remove(B)}let j=0;function V(){j=0}function H(){let B=j;return B>=l&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+l),j+=1,B}function q(B){let N=[];return N.push(B.wrapS),N.push(B.wrapT),N.push(B.wrapR||0),N.push(B.magFilter),N.push(B.minFilter),N.push(B.anisotropy),N.push(B.internalFormat),N.push(B.format),N.push(B.type),N.push(B.generateMipmaps),N.push(B.premultiplyAlpha),N.push(B.flipY),N.push(B.unpackAlignment),N.push(B.encoding),N.join()}function X(B,N){let ae=r.get(B);if(B.isVideoTexture&&Qe(B),B.isRenderTargetTexture===!1&&B.version>0&&ae.__version!==B.version){let ye=B.image;if(ye===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ae,B,N);return}}e.bindTexture(3553,ae.__webglTexture,33984+N)}function K(B,N){let ae=r.get(B);if(B.version>0&&ae.__version!==B.version){ie(ae,B,N);return}e.bindTexture(35866,ae.__webglTexture,33984+N)}function z(B,N){let ae=r.get(B);if(B.version>0&&ae.__version!==B.version){ie(ae,B,N);return}e.bindTexture(32879,ae.__webglTexture,33984+N)}function Q(B,N){let ae=r.get(B);if(B.version>0&&ae.__version!==B.version){re(ae,B,N);return}e.bindTexture(34067,ae.__webglTexture,33984+N)}let te={[Hs]:10497,[tr]:33071,[YS]:33648},$={[vt]:9728,[VC]:9984,[lS]:9986,[it]:9729,[BU]:9985,[Bc]:9987};function W(B,N,ae){if(ae?(n.texParameteri(B,10242,te[N.wrapS]),n.texParameteri(B,10243,te[N.wrapT]),(B===32879||B===35866)&&n.texParameteri(B,32882,te[N.wrapR]),n.texParameteri(B,10240,$[N.magFilter]),n.texParameteri(B,10241,$[N.minFilter])):(n.texParameteri(B,10242,33071),n.texParameteri(B,10243,33071),(B===32879||B===35866)&&n.texParameteri(B,32882,33071),(N.wrapS!==tr||N.wrapT!==tr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(B,10240,C(N.magFilter)),n.texParameteri(B,10241,C(N.minFilter)),N.minFilter!==vt&&N.minFilter!==it&&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 ye=t.get("EXT_texture_filter_anisotropic");if(N.magFilter===vt||N.minFilter!==lS&&N.minFilter!==Bc||N.type===Ut&&t.has("OES_texture_float_linear")===!1||a===!1&&N.type===$n&&t.has("OES_texture_half_float_linear")===!1)return;(N.anisotropy>1||r.get(N).__currentAnisotropy)&&(n.texParameterf(B,ye.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(N.anisotropy,i.getMaxAnisotropy())),r.get(N).__currentAnisotropy=N.anisotropy)}}function oe(B,N){let ae=!1;B.__webglInit===void 0&&(B.__webglInit=!0,N.addEventListener("dispose",P));let ye=N.source,me=g.get(ye);me===void 0&&(me={},g.set(ye,me));let Ne=q(N);if(Ne!==B.__cacheKey){me[Ne]===void 0&&(me[Ne]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,ae=!0),me[Ne].usedTimes++;let Fe=me[B.__cacheKey];Fe!==void 0&&(me[B.__cacheKey].usedTimes--,Fe.usedTimes===0&&O(N)),B.__cacheKey=Ne,B.__webglTexture=me[Ne].texture}return ae}function ie(B,N,ae){let ye=3553;(N.isDataArrayTexture||N.isCompressedArrayTexture)&&(ye=35866),N.isData3DTexture&&(ye=32879);let me=oe(B,N),Ne=N.source;e.bindTexture(ye,B.__webglTexture,33984+ae);let Fe=r.get(Ne);if(Ne.version!==Fe.__version||me===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,N.flipY),n.pixelStorei(37441,N.premultiplyAlpha),n.pixelStorei(3317,N.unpackAlignment),n.pixelStorei(37443,0);let Oe=w(N)&&b(N.image)===!1,pe=v(N.image,Oe,!1,u);pe=F(N,pe);let nt=b(pe)||a,We=s.convert(N.format,N.encoding),Be=s.convert(N.type),tt=S(N.internalFormat,We,Be,N.encoding,N.isVideoTexture);W(ye,N,nt);let ot,Gt=N.mipmaps,xr=a&&N.isVideoTexture!==!0,Ir=Fe.__version===void 0||me===!0,Z=M(N,pe,nt);if(N.isDepthTexture)tt=6402,a?N.type===Ut?tt=36012:N.type===Gs?tt=33190:N.type===gl?tt=35056:tt=33189:N.type===Ut&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),N.format===Lc&&tt===6402&&N.type!==f_&&N.type!==Gs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),N.type=Gs,Be=s.convert(N.type)),N.format===xl&&tt===6402&&(tt=34041,N.type!==gl&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),N.type=gl,Be=s.convert(N.type))),Ir&&(xr?e.texStorage2D(3553,1,tt,pe.width,pe.height):e.texImage2D(3553,0,tt,pe.width,pe.height,0,We,Be,null));else if(N.isDataTexture)if(Gt.length>0&&nt){xr&&Ir&&e.texStorage2D(3553,Z,tt,Gt[0].width,Gt[0].height);for(let ve=0,Me=Gt.length;ve<Me;ve++)ot=Gt[ve],xr?e.texSubImage2D(3553,ve,0,0,ot.width,ot.height,We,Be,ot.data):e.texImage2D(3553,ve,tt,ot.width,ot.height,0,We,Be,ot.data);N.generateMipmaps=!1}else xr?(Ir&&e.texStorage2D(3553,Z,tt,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,pe.width,pe.height,We,Be,pe.data)):e.texImage2D(3553,0,tt,pe.width,pe.height,0,We,Be,pe.data);else if(N.isCompressedTexture)if(N.isCompressedArrayTexture){xr&&Ir&&e.texStorage3D(35866,Z,tt,Gt[0].width,Gt[0].height,pe.depth);for(let ve=0,Me=Gt.length;ve<Me;ve++)ot=Gt[ve],N.format!==br?We!==null?xr?e.compressedTexSubImage3D(35866,ve,0,0,0,ot.width,ot.height,pe.depth,We,ot.data,0,0):e.compressedTexImage3D(35866,ve,tt,ot.width,ot.height,pe.depth,0,ot.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xr?e.texSubImage3D(35866,ve,0,0,0,ot.width,ot.height,pe.depth,We,Be,ot.data):e.texImage3D(35866,ve,tt,ot.width,ot.height,pe.depth,0,We,Be,ot.data)}else{xr&&Ir&&e.texStorage2D(3553,Z,tt,Gt[0].width,Gt[0].height);for(let ve=0,Me=Gt.length;ve<Me;ve++)ot=Gt[ve],N.format!==br?We!==null?xr?e.compressedTexSubImage2D(3553,ve,0,0,ot.width,ot.height,We,ot.data):e.compressedTexImage2D(3553,ve,tt,ot.width,ot.height,0,ot.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xr?e.texSubImage2D(3553,ve,0,0,ot.width,ot.height,We,Be,ot.data):e.texImage2D(3553,ve,tt,ot.width,ot.height,0,We,Be,ot.data)}else if(N.isDataArrayTexture)xr?(Ir&&e.texStorage3D(35866,Z,tt,pe.width,pe.height,pe.depth),e.texSubImage3D(35866,0,0,0,0,pe.width,pe.height,pe.depth,We,Be,pe.data)):e.texImage3D(35866,0,tt,pe.width,pe.height,pe.depth,0,We,Be,pe.data);else if(N.isData3DTexture)xr?(Ir&&e.texStorage3D(32879,Z,tt,pe.width,pe.height,pe.depth),e.texSubImage3D(32879,0,0,0,0,pe.width,pe.height,pe.depth,We,Be,pe.data)):e.texImage3D(32879,0,tt,pe.width,pe.height,pe.depth,0,We,Be,pe.data);else if(N.isFramebufferTexture){if(Ir)if(xr)e.texStorage2D(3553,Z,tt,pe.width,pe.height);else{let ve=pe.width,Me=pe.height;for(let qe=0;qe<Z;qe++)e.texImage2D(3553,qe,tt,ve,Me,0,We,Be,null),ve>>=1,Me>>=1}}else if(Gt.length>0&&nt){xr&&Ir&&e.texStorage2D(3553,Z,tt,Gt[0].width,Gt[0].height);for(let ve=0,Me=Gt.length;ve<Me;ve++)ot=Gt[ve],xr?e.texSubImage2D(3553,ve,0,0,We,Be,ot):e.texImage2D(3553,ve,tt,We,Be,ot);N.generateMipmaps=!1}else xr?(Ir&&e.texStorage2D(3553,Z,tt,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,We,Be,pe)):e.texImage2D(3553,0,tt,We,Be,pe);A(N,nt)&&T(ye),Fe.__version=Ne.version,N.onUpdate&&N.onUpdate(N)}B.__version=N.version}function re(B,N,ae){if(N.image.length!==6)return;let ye=oe(B,N),me=N.source;e.bindTexture(34067,B.__webglTexture,33984+ae);let Ne=r.get(me);if(me.version!==Ne.__version||ye===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,N.flipY),n.pixelStorei(37441,N.premultiplyAlpha),n.pixelStorei(3317,N.unpackAlignment),n.pixelStorei(37443,0);let Fe=N.isCompressedTexture||N.image[0].isCompressedTexture,Oe=N.image[0]&&N.image[0].isDataTexture,pe=[];for(let ve=0;ve<6;ve++)!Fe&&!Oe?pe[ve]=v(N.image[ve],!1,!0,c):pe[ve]=Oe?N.image[ve].image:N.image[ve],pe[ve]=F(N,pe[ve]);let nt=pe[0],We=b(nt)||a,Be=s.convert(N.format,N.encoding),tt=s.convert(N.type),ot=S(N.internalFormat,Be,tt,N.encoding),Gt=a&&N.isVideoTexture!==!0,xr=Ne.__version===void 0||ye===!0,Ir=M(N,nt,We);W(34067,N,We);let Z;if(Fe){Gt&&xr&&e.texStorage2D(34067,Ir,ot,nt.width,nt.height);for(let ve=0;ve<6;ve++){Z=pe[ve].mipmaps;for(let Me=0;Me<Z.length;Me++){let qe=Z[Me];N.format!==br?Be!==null?Gt?e.compressedTexSubImage2D(34069+ve,Me,0,0,qe.width,qe.height,Be,qe.data):e.compressedTexImage2D(34069+ve,Me,ot,qe.width,qe.height,0,qe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Gt?e.texSubImage2D(34069+ve,Me,0,0,qe.width,qe.height,Be,tt,qe.data):e.texImage2D(34069+ve,Me,ot,qe.width,qe.height,0,Be,tt,qe.data)}}}else{Z=N.mipmaps,Gt&&xr&&(Z.length>0&&Ir++,e.texStorage2D(34067,Ir,ot,pe[0].width,pe[0].height));for(let ve=0;ve<6;ve++)if(Oe){Gt?e.texSubImage2D(34069+ve,0,0,0,pe[ve].width,pe[ve].height,Be,tt,pe[ve].data):e.texImage2D(34069+ve,0,ot,pe[ve].width,pe[ve].height,0,Be,tt,pe[ve].data);for(let Me=0;Me<Z.length;Me++){let Xe=Z[Me].image[ve].image;Gt?e.texSubImage2D(34069+ve,Me+1,0,0,Xe.width,Xe.height,Be,tt,Xe.data):e.texImage2D(34069+ve,Me+1,ot,Xe.width,Xe.height,0,Be,tt,Xe.data)}}else{Gt?e.texSubImage2D(34069+ve,0,0,0,Be,tt,pe[ve]):e.texImage2D(34069+ve,0,ot,Be,tt,pe[ve]);for(let Me=0;Me<Z.length;Me++){let qe=Z[Me];Gt?e.texSubImage2D(34069+ve,Me+1,0,0,Be,tt,qe.image[ve]):e.texImage2D(34069+ve,Me+1,ot,Be,tt,qe.image[ve])}}}A(N,We)&&T(34067),Ne.__version=me.version,N.onUpdate&&N.onUpdate(N)}B.__version=N.version}function J(B,N,ae,ye,me){let Ne=s.convert(ae.format,ae.encoding),Fe=s.convert(ae.type),Oe=S(ae.internalFormat,Ne,Fe,ae.encoding);r.get(N).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Oe,N.width,N.height,N.depth,0,Ne,Fe,null):e.texImage2D(me,0,Oe,N.width,N.height,0,Ne,Fe,null)),e.bindFramebuffer(36160,B),Le(N)?d.framebufferTexture2DMultisampleEXT(36160,ye,me,r.get(ae).__webglTexture,0,Ue(N)):(me===3553||me>=34069&&me<=34074)&&n.framebufferTexture2D(36160,ye,me,r.get(ae).__webglTexture,0),e.bindFramebuffer(36160,null)}function Ee(B,N,ae){if(n.bindRenderbuffer(36161,B),N.depthBuffer&&!N.stencilBuffer){let ye=33189;if(ae||Le(N)){let me=N.depthTexture;me&&me.isDepthTexture&&(me.type===Ut?ye=36012:me.type===Gs&&(ye=33190));let Ne=Ue(N);Le(N)?d.renderbufferStorageMultisampleEXT(36161,Ne,ye,N.width,N.height):n.renderbufferStorageMultisample(36161,Ne,ye,N.width,N.height)}else n.renderbufferStorage(36161,ye,N.width,N.height);n.framebufferRenderbuffer(36160,36096,36161,B)}else if(N.depthBuffer&&N.stencilBuffer){let ye=Ue(N);ae&&Le(N)===!1?n.renderbufferStorageMultisample(36161,ye,35056,N.width,N.height):Le(N)?d.renderbufferStorageMultisampleEXT(36161,ye,35056,N.width,N.height):n.renderbufferStorage(36161,34041,N.width,N.height),n.framebufferRenderbuffer(36160,33306,36161,B)}else{let ye=N.isWebGLMultipleRenderTargets===!0?N.texture:[N.texture];for(let me=0;me<ye.length;me++){let Ne=ye[me],Fe=s.convert(Ne.format,Ne.encoding),Oe=s.convert(Ne.type),pe=S(Ne.internalFormat,Fe,Oe,Ne.encoding),nt=Ue(N);ae&&Le(N)===!1?n.renderbufferStorageMultisample(36161,nt,pe,N.width,N.height):Le(N)?d.renderbufferStorageMultisampleEXT(36161,nt,pe,N.width,N.height):n.renderbufferStorage(36161,pe,N.width,N.height)}}n.bindRenderbuffer(36161,null)}function xe(B,N){if(N&&N.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,B),!(N.depthTexture&&N.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(N.depthTexture).__webglTexture||N.depthTexture.image.width!==N.width||N.depthTexture.image.height!==N.height)&&(N.depthTexture.image.width=N.width,N.depthTexture.image.height=N.height,N.depthTexture.needsUpdate=!0),X(N.depthTexture,0);let ye=r.get(N.depthTexture).__webglTexture,me=Ue(N);if(N.depthTexture.format===Lc)Le(N)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ye,0,me):n.framebufferTexture2D(36160,36096,3553,ye,0);else if(N.depthTexture.format===xl)Le(N)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ye,0,me):n.framebufferTexture2D(36160,33306,3553,ye,0);else throw new Error("Unknown depthTexture format")}function de(B){let N=r.get(B),ae=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!N.__autoAllocateDepthBuffer){if(ae)throw new Error("target.depthTexture not supported in Cube render targets");xe(N.__webglFramebuffer,B)}else if(ae){N.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)e.bindFramebuffer(36160,N.__webglFramebuffer[ye]),N.__webglDepthbuffer[ye]=n.createRenderbuffer(),Ee(N.__webglDepthbuffer[ye],B,!1)}else e.bindFramebuffer(36160,N.__webglFramebuffer),N.__webglDepthbuffer=n.createRenderbuffer(),Ee(N.__webglDepthbuffer,B,!1);e.bindFramebuffer(36160,null)}function De(B,N,ae){let ye=r.get(B);N!==void 0&&J(ye.__webglFramebuffer,B,B.texture,36064,3553),ae!==void 0&&de(B)}function Pe(B){let N=B.texture,ae=r.get(B),ye=r.get(N);B.addEventListener("dispose",_),B.isWebGLMultipleRenderTargets!==!0&&(ye.__webglTexture===void 0&&(ye.__webglTexture=n.createTexture()),ye.__version=N.version,o.memory.textures++);let me=B.isWebGLCubeRenderTarget===!0,Ne=B.isWebGLMultipleRenderTargets===!0,Fe=b(B)||a;if(me){ae.__webglFramebuffer=[];for(let Oe=0;Oe<6;Oe++)ae.__webglFramebuffer[Oe]=n.createFramebuffer()}else{if(ae.__webglFramebuffer=n.createFramebuffer(),Ne)if(i.drawBuffers){let Oe=B.texture;for(let pe=0,nt=Oe.length;pe<nt;pe++){let We=r.get(Oe[pe]);We.__webglTexture===void 0&&(We.__webglTexture=n.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&B.samples>0&&Le(B)===!1){let Oe=Ne?N:[N];ae.__webglMultisampledFramebuffer=n.createFramebuffer(),ae.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ae.__webglMultisampledFramebuffer);for(let pe=0;pe<Oe.length;pe++){let nt=Oe[pe];ae.__webglColorRenderbuffer[pe]=n.createRenderbuffer(),n.bindRenderbuffer(36161,ae.__webglColorRenderbuffer[pe]);let We=s.convert(nt.format,nt.encoding),Be=s.convert(nt.type),tt=S(nt.internalFormat,We,Be,nt.encoding,B.isXRRenderTarget===!0),ot=Ue(B);n.renderbufferStorageMultisample(36161,ot,tt,B.width,B.height),n.framebufferRenderbuffer(36160,36064+pe,36161,ae.__webglColorRenderbuffer[pe])}n.bindRenderbuffer(36161,null),B.depthBuffer&&(ae.__webglDepthRenderbuffer=n.createRenderbuffer(),Ee(ae.__webglDepthRenderbuffer,B,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ye.__webglTexture),W(34067,N,Fe);for(let Oe=0;Oe<6;Oe++)J(ae.__webglFramebuffer[Oe],B,N,36064,34069+Oe);A(N,Fe)&&T(34067),e.unbindTexture()}else if(Ne){let Oe=B.texture;for(let pe=0,nt=Oe.length;pe<nt;pe++){let We=Oe[pe],Be=r.get(We);e.bindTexture(3553,Be.__webglTexture),W(3553,We,Fe),J(ae.__webglFramebuffer,B,We,36064+pe,3553),A(We,Fe)&&T(3553)}e.unbindTexture()}else{let Oe=3553;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(a?Oe=B.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Oe,ye.__webglTexture),W(Oe,N,Fe),J(ae.__webglFramebuffer,B,N,36064,Oe),A(N,Fe)&&T(Oe),e.unbindTexture()}B.depthBuffer&&de(B)}function ze(B){let N=b(B)||a,ae=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let ye=0,me=ae.length;ye<me;ye++){let Ne=ae[ye];if(A(Ne,N)){let Fe=B.isWebGLCubeRenderTarget?34067:3553,Oe=r.get(Ne).__webglTexture;e.bindTexture(Fe,Oe),T(Fe),e.unbindTexture()}}}function ke(B){if(a&&B.samples>0&&Le(B)===!1){let N=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],ae=B.width,ye=B.height,me=16384,Ne=[],Fe=B.stencilBuffer?33306:36096,Oe=r.get(B),pe=B.isWebGLMultipleRenderTargets===!0;if(pe)for(let nt=0;nt<N.length;nt++)e.bindFramebuffer(36160,Oe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+nt,36161,null),e.bindFramebuffer(36160,Oe.__webglFramebuffer),n.framebufferTexture2D(36009,36064+nt,3553,null,0);e.bindFramebuffer(36008,Oe.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Oe.__webglFramebuffer);for(let nt=0;nt<N.length;nt++){Ne.push(36064+nt),B.depthBuffer&&Ne.push(Fe);let We=Oe.__ignoreDepthValues!==void 0?Oe.__ignoreDepthValues:!1;if(We===!1&&(B.depthBuffer&&(me|=256),B.stencilBuffer&&(me|=1024)),pe&&n.framebufferRenderbuffer(36008,36064,36161,Oe.__webglColorRenderbuffer[nt]),We===!0&&(n.invalidateFramebuffer(36008,[Fe]),n.invalidateFramebuffer(36009,[Fe])),pe){let Be=r.get(N[nt]).__webglTexture;n.framebufferTexture2D(36009,36064,3553,Be,0)}n.blitFramebuffer(0,0,ae,ye,0,0,ae,ye,me,9728),f&&n.invalidateFramebuffer(36008,Ne)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),pe)for(let nt=0;nt<N.length;nt++){e.bindFramebuffer(36160,Oe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+nt,36161,Oe.__webglColorRenderbuffer[nt]);let We=r.get(N[nt]).__webglTexture;e.bindFramebuffer(36160,Oe.__webglFramebuffer),n.framebufferTexture2D(36009,36064+nt,3553,We,0)}e.bindFramebuffer(36009,Oe.__webglMultisampledFramebuffer)}}function Ue(B){return Math.min(h,B.samples)}function Le(B){let N=r.get(B);return a&&B.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&N.__useRenderToTexture!==!1}function Qe(B){let N=o.render.frame;m.get(B)!==N&&(m.set(B,N),B.update())}function F(B,N){let ae=B.encoding,ye=B.format,me=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===QS||ae!==xn&&(ae===ut?a===!1?t.has("EXT_sRGB")===!0&&ye===br?(B.format=QS,B.minFilter=it,B.generateMipmaps=!1):N=Uy.sRGBToLinear(N):(ye!==br||me!==Nr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ae)),N}this.allocateTextureUnit=H,this.resetTextureUnits=V,this.setTexture2D=X,this.setTexture2DArray=K,this.setTexture3D=z,this.setTextureCube=Q,this.rebindTextures=De,this.setupRenderTarget=Pe,this.updateRenderTargetMipmap=ze,this.updateMultisampleRenderTarget=ke,this.setupDepthRenderbuffer=de,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Le}function X5(n,t,e){let r=e.isWebGL2;function i(s,o=null){let a;if(s===Nr)return 5121;if(s===kU)return 32819;if(s===zU)return 32820;if(s===FU)return 5120;if(s===VU)return 5122;if(s===f_)return 5123;if(s===UU)return 5124;if(s===Gs)return 5125;if(s===Ut)return 5126;if(s===$n)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===GU)return 6406;if(s===br)return 6408;if(s===jU)return 6409;if(s===HU)return 6410;if(s===Lc)return 6402;if(s===xl)return 34041;if(s===QS)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===Jp)return 6403;if(s===WU)return 36244;if(s===Sh)return 33319;if(s===qU)return 33320;if(s===Cw)return 36249;if(s===cS||s===uS||s===hS||s===dS)if(o===ut)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===cS)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===uS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===hS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===dS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===cS)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===uS)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===hS)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===dS)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===UC||s===kC||s===zC||s===GC)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===UC)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===kC)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===zC)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===GC)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===XU)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===jC||s===HC)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===jC)return o===ut?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===HC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===WC||s===qC||s===XC||s===YC||s===KC||s===QC||s===ZC||s===JC||s===$C||s===eP||s===tP||s===rP||s===iP||s===nP)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===WC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===qC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===XC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===YC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===KC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===QC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ZC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===JC)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===$C)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===eP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===tP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===rP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===iP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===nP)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===fS)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===fS)return o===ut?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===YU||s===sP||s===oP||s===aP)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===fS)return a.COMPRESSED_RED_RGTC1_EXT;if(s===sP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===oP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===aP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===gl?r?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:i}}var aw=class extends si{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},cn=class extends Dt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Y5={type:"move"},Rp=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new cn,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 cn,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 cn,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(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let r of t.hand.values())this._getHandJoint(e,r)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,r){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){o=!0;for(let p of t.hand.values()){let g=e.getJointPose(p,r),y=this._getHandJoint(c,p);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Y5)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let r=new cn;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},ps=class extends Zt{constructor(t,e,r,i,s,o,a,l,c,u){if(u=u!==void 0?u:Lc,u!==Lc&&u!==xl)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===Lc&&(r=Gs),r===void 0&&u===xl&&(r=gl),super(null,i,s,o,a,l,u,r,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:vt,this.minFilter=l!==void 0?l:vt,this.flipY=!1,this.generateMipmaps=!1}},lw=class extends ar{constructor(t,e){super();let r=this,i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,m=null,p=e.getContextAttributes(),g=null,y=null,x=[],v=[],b=new Set,w=new Map,A=new si;A.layers.enable(1),A.viewport=new Ze;let T=new si;T.layers.enable(2),T.viewport=new Ze;let S=[A,T],M=new aw;M.layers.enable(1),M.layers.enable(2);let C=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let Q=x[z];return Q===void 0&&(Q=new Rp,x[z]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(z){let Q=x[z];return Q===void 0&&(Q=new Rp,x[z]=Q),Q.getGripSpace()},this.getHand=function(z){let Q=x[z];return Q===void 0&&(Q=new Rp,x[z]=Q),Q.getHandSpace()};function _(z){let Q=v.indexOf(z.inputSource);if(Q===-1)return;let te=x[Q];te!==void 0&&te.dispatchEvent({type:z.type,data:z.inputSource})}function I(){i.removeEventListener("select",_),i.removeEventListener("selectstart",_),i.removeEventListener("selectend",_),i.removeEventListener("squeeze",_),i.removeEventListener("squeezestart",_),i.removeEventListener("squeezeend",_),i.removeEventListener("end",I),i.removeEventListener("inputsourceschange",O);for(let z=0;z<x.length;z++){let Q=v[z];Q!==null&&(v[z]=null,x[z].disconnect(Q))}C=null,P=null,t.setRenderTarget(g),f=null,d=null,h=null,i=null,y=null,K.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){s=z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){a=z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(z){c=z},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(z){if(i=z,i!==null){if(g=t.getRenderTarget(),i.addEventListener("select",_),i.addEventListener("selectstart",_),i.addEventListener("selectend",_),i.addEventListener("squeeze",_),i.addEventListener("squeezestart",_),i.addEventListener("squeezeend",_),i.addEventListener("end",I),i.addEventListener("inputsourceschange",O),p.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let Q={antialias:i.renderState.layers===void 0?p.antialias:!0,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,Q),i.updateRenderState({baseLayer:f}),y=new at(f.framebufferWidth,f.framebufferHeight,{format:br,type:Nr,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let Q=null,te=null,$=null;p.depth&&($=p.stencil?35056:33190,Q=p.stencil?xl:Lc,te=p.stencil?gl:Gs);let W={colorFormat:32856,depthFormat:$,scaleFactor:s};h=new XRWebGLBinding(i,e),d=h.createProjectionLayer(W),i.updateRenderState({layers:[d]}),y=new at(d.textureWidth,d.textureHeight,{format:br,type:Nr,depthTexture:new ps(d.textureWidth,d.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,Q),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0});let oe=t.properties.get(y);oe.__ignoreDepthValues=d.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),K.setContext(i),K.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};function O(z){for(let Q=0;Q<z.removed.length;Q++){let te=z.removed[Q],$=v.indexOf(te);$>=0&&(v[$]=null,x[$].disconnect(te))}for(let Q=0;Q<z.added.length;Q++){let te=z.added[Q],$=v.indexOf(te);if($===-1){for(let oe=0;oe<x.length;oe++)if(oe>=v.length){v.push(te),$=oe;break}else if(v[oe]===null){v[oe]=te,$=oe;break}if($===-1)break}let W=x[$];W&&W.connect(te)}}let L=new E,j=new E;function V(z,Q,te){L.setFromMatrixPosition(Q.matrixWorld),j.setFromMatrixPosition(te.matrixWorld);let $=L.distanceTo(j),W=Q.projectionMatrix.elements,oe=te.projectionMatrix.elements,ie=W[14]/(W[10]-1),re=W[14]/(W[10]+1),J=(W[9]+1)/W[5],Ee=(W[9]-1)/W[5],xe=(W[8]-1)/W[0],de=(oe[8]+1)/oe[0],De=ie*xe,Pe=ie*de,ze=$/(-xe+de),ke=ze*-xe;Q.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ke),z.translateZ(ze),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert();let Ue=ie+ze,Le=re+ze,Qe=De-ke,F=Pe+($-ke),B=J*re/Le*Ue,N=Ee*re/Le*Ue;z.projectionMatrix.makePerspective(Qe,F,B,N,Ue,Le)}function H(z,Q){Q===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(Q.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(i===null)return;M.near=T.near=A.near=z.near,M.far=T.far=A.far=z.far,(C!==M.near||P!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),C=M.near,P=M.far);let Q=z.parent,te=M.cameras;H(M,Q);for(let W=0;W<te.length;W++)H(te[W],Q);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),z.matrix.copy(M.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale);let $=z.children;for(let W=0,oe=$.length;W<oe;W++)$[W].updateMatrixWorld(!0);te.length===2?V(M,A,T):M.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(z){l=z,d!==null&&(d.fixedFoveation=z),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=z)},this.getPlanes=function(){return b};let q=null;function X(z,Q){if(u=Q.getViewerPose(c||o),m=Q,u!==null){let te=u.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let $=!1;te.length!==M.cameras.length&&(M.cameras.length=0,$=!0);for(let W=0;W<te.length;W++){let oe=te[W],ie=null;if(f!==null)ie=f.getViewport(oe);else{let J=h.getViewSubImage(d,oe);ie=J.viewport,W===0&&(t.setRenderTargetTextures(y,J.colorTexture,d.ignoreDepthValues?void 0:J.depthStencilTexture),t.setRenderTarget(y))}let re=S[W];re===void 0&&(re=new si,re.layers.enable(W),re.viewport=new Ze,S[W]=re),re.matrix.fromArray(oe.transform.matrix),re.projectionMatrix.fromArray(oe.projectionMatrix),re.viewport.set(ie.x,ie.y,ie.width,ie.height),W===0&&M.matrix.copy(re.matrix),$===!0&&M.cameras.push(re)}}for(let te=0;te<x.length;te++){let $=v[te],W=x[te];$!==null&&W!==void 0&&W.update($,Q,c||o)}if(q&&q(z,Q),Q.detectedPlanes){r.dispatchEvent({type:"planesdetected",data:Q.detectedPlanes});let te=null;for(let $ of b)Q.detectedPlanes.has($)||(te===null&&(te=[]),te.push($));if(te!==null)for(let $ of te)b.delete($),w.delete($),r.dispatchEvent({type:"planeremoved",data:$});for(let $ of Q.detectedPlanes)if(!b.has($))b.add($),w.set($,Q.lastChangedTime),r.dispatchEvent({type:"planeadded",data:$});else{let W=w.get($);$.lastChangedTime>W&&(w.set($,$.lastChangedTime),r.dispatchEvent({type:"planechanged",data:$}))}}m=null}let K=new x_;K.setAnimationLoop(X),this.setAnimationLoop=function(z){q=z},this.dispose=function(){}}};function K5(n,t){function e(p,g){g.color.getRGB(p.fogColor.value,v_(n)),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function r(p,g,y,x,v){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),u(p,g)):g.isMeshPhongMaterial?(i(p,g),c(p,g)):g.isMeshStandardMaterial?(i(p,g),h(p,g),g.isMeshPhysicalMaterial&&d(p,g,v)):g.isMeshMatcapMaterial?(i(p,g),f(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,y,x):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===xi&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===xi&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(p.envMap.value=y,p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let b=n.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let x;g.map?x=g.map:g.specularMap?x=g.specularMap:g.displacementMap?x=g.displacementMap:g.normalMap?x=g.normalMap:g.bumpMap?x=g.bumpMap:g.roughnessMap?x=g.roughnessMap:g.metalnessMap?x=g.metalnessMap:g.alphaMap?x=g.alphaMap:g.emissiveMap?x=g.emissiveMap:g.clearcoatMap?x=g.clearcoatMap:g.clearcoatNormalMap?x=g.clearcoatNormalMap:g.clearcoatRoughnessMap?x=g.clearcoatRoughnessMap:g.iridescenceMap?x=g.iridescenceMap:g.iridescenceThicknessMap?x=g.iridescenceThicknessMap:g.specularIntensityMap?x=g.specularIntensityMap:g.specularColorMap?x=g.specularColorMap:g.transmissionMap?x=g.transmissionMap:g.thicknessMap?x=g.thicknessMap:g.sheenColorMap?x=g.sheenColorMap:g.sheenRoughnessMap&&(x=g.sheenRoughnessMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix));let v;g.aoMap?v=g.aoMap:g.lightMap&&(v=g.lightMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uv2Transform.value.copy(v.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,y,x){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=x*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function c(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function u(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function h(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function d(p,g,y){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===xi&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:r}}function Q5(n,t,e,r){let i={},s={},o=[],a=e.isWebGL2?n.getParameter(35375):0;function l(x,v){let b=v.program;r.uniformBlockBinding(x,b)}function c(x,v){let b=i[x.id];b===void 0&&(m(x),b=u(x),i[x.id]=b,x.addEventListener("dispose",g));let w=v.program;r.updateUBOMapping(x,w);let A=t.render.frame;s[x.id]!==A&&(d(x),s[x.id]=A)}function u(x){let v=h();x.__bindingPointIndex=v;let b=n.createBuffer(),w=x.__size,A=x.usage;return n.bindBuffer(35345,b),n.bufferData(35345,w,A),n.bindBuffer(35345,null),n.bindBufferBase(35345,v,b),b}function h(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){let v=i[x.id],b=x.uniforms,w=x.__cache;n.bindBuffer(35345,v);for(let A=0,T=b.length;A<T;A++){let S=b[A];if(f(S,A,w)===!0){let M=S.__offset,C=Array.isArray(S.value)?S.value:[S.value],P=0;for(let _=0;_<C.length;_++){let I=C[_],O=p(I);typeof I=="number"?(S.__data[0]=I,n.bufferSubData(35345,M+P,S.__data)):I.isMatrix3?(S.__data[0]=I.elements[0],S.__data[1]=I.elements[1],S.__data[2]=I.elements[2],S.__data[3]=I.elements[0],S.__data[4]=I.elements[3],S.__data[5]=I.elements[4],S.__data[6]=I.elements[5],S.__data[7]=I.elements[0],S.__data[8]=I.elements[6],S.__data[9]=I.elements[7],S.__data[10]=I.elements[8],S.__data[11]=I.elements[0]):(I.toArray(S.__data,P),P+=O.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(35345,M,S.__data)}}n.bindBuffer(35345,null)}function f(x,v,b){let w=x.value;if(b[v]===void 0){if(typeof w=="number")b[v]=w;else{let A=Array.isArray(w)?w:[w],T=[];for(let S=0;S<A.length;S++)T.push(A[S].clone());b[v]=T}return!0}else if(typeof w=="number"){if(b[v]!==w)return b[v]=w,!0}else{let A=Array.isArray(b[v])?b[v]:[b[v]],T=Array.isArray(w)?w:[w];for(let S=0;S<A.length;S++){let M=A[S];if(M.equals(T[S])===!1)return M.copy(T[S]),!0}}return!1}function m(x){let v=x.uniforms,b=0,w=16,A=0;for(let T=0,S=v.length;T<S;T++){let M=v[T],C={boundary:0,storage:0},P=Array.isArray(M.value)?M.value:[M.value];for(let _=0,I=P.length;_<I;_++){let O=P[_],L=p(O);C.boundary+=L.boundary,C.storage+=L.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=b,T>0){A=b%w;let _=w-A;A!==0&&_-C.boundary<0&&(b+=w-A,M.__offset=b)}b+=C.storage}return A=b%w,A>0&&(b+=w-A),x.__size=b,x.__cache={},this}function p(x){let v={boundary:0,storage:0};return typeof x=="number"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function g(x){let v=x.target;v.removeEventListener("dispose",g);let b=o.indexOf(v.__bindingPointIndex);o.splice(b,1),n.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function y(){for(let x in i)n.deleteBuffer(i[x]);o=[],i={},s={}}return{bind:l,update:c,dispose:y}}function Z5(){let n=Vp("canvas");return n.style.display="block",n}function Lw(n={}){this.isWebGLRenderer=!0;let t=n.canvas!==void 0?n.canvas:Z5(),e=n.context!==void 0?n.context:null,r=n.depth!==void 0?n.depth:!0,i=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,o=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,a=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",c=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1,u;e!==null?u=e.getContextAttributes().alpha:u=n.alpha!==void 0?n.alpha:!1;let h=null,d=null,f=[],m=[];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=xn,this.physicallyCorrectLights=!1,this.toneMapping=js,this.toneMappingExposure=1;let p=this,g=!1,y=0,x=0,v=null,b=-1,w=null,A=new Ze,T=new Ze,S=null,M=t.width,C=t.height,P=1,_=null,I=null,O=new Ze(0,0,M,C),L=new Ze(0,0,M,C),j=!1,V=new kp,H=!1,q=!1,X=null,K=new ue,z=new U,Q=new E,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function $(){return v===null?P:1}let W=e;function oe(G,le){for(let ge=0;ge<G.length;ge++){let ne=G[ge],be=t.getContext(ne,le);if(be!==null)return be}return null}try{let G={alpha:!0,depth:r,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Pa}`),t.addEventListener("webglcontextlost",tt,!1),t.addEventListener("webglcontextrestored",ot,!1),t.addEventListener("webglcontextcreationerror",Gt,!1),W===null){let le=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&le.shift(),W=oe(le,G),W===null)throw oe(le)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(G){throw console.error("THREE.WebGLRenderer: "+G.message),G}let ie,re,J,Ee,xe,de,De,Pe,ze,ke,Ue,Le,Qe,F,B,N,ae,ye,me,Ne,Fe,Oe,pe,nt;function We(){ie=new v4(W),re=new d4(W,ie,n),ie.init(re),Oe=new X5(W,ie,re),J=new W5(W,ie,re),Ee=new S4,xe=new R5,de=new q5(W,ie,J,xe,re,Oe,Ee),De=new p4(p),Pe=new y4(p),ze=new Ik(W,re),pe=new u4(W,ie,ze,re),ke=new x4(W,ze,Ee,pe),Ue=new T4(W,ke,ze,Ee),me=new E4(W,re,de),N=new f4(xe),Le=new O5(p,De,Pe,ie,re,pe,N),Qe=new K5(p,xe),F=new N5,B=new z5(ie,re),ye=new c4(p,De,Pe,J,Ue,u,o),ae=new H5(p,Ue,re),nt=new Q5(W,Ee,re,J),Ne=new h4(W,ie,Ee,re),Fe=new b4(W,ie,Ee,re),Ee.programs=Le.programs,p.capabilities=re,p.extensions=ie,p.properties=xe,p.renderLists=F,p.shadowMap=ae,p.state=J,p.info=Ee}We();let Be=new lw(p,W);this.xr=Be,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){let G=ie.get("WEBGL_lose_context");G&&G.loseContext()},this.forceContextRestore=function(){let G=ie.get("WEBGL_lose_context");G&&G.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(G){G!==void 0&&(P=G,this.setSize(M,C,!1))},this.getSize=function(G){return G.set(M,C)},this.setSize=function(G,le,ge){if(Be.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=G,C=le,t.width=Math.floor(G*P),t.height=Math.floor(le*P),ge!==!1&&(t.style.width=G+"px",t.style.height=le+"px"),this.setViewport(0,0,G,le)},this.getDrawingBufferSize=function(G){return G.set(M*P,C*P).floor()},this.setDrawingBufferSize=function(G,le,ge){M=G,C=le,P=ge,t.width=Math.floor(G*ge),t.height=Math.floor(le*ge),this.setViewport(0,0,G,le)},this.getCurrentViewport=function(G){return G.copy(A)},this.getViewport=function(G){return G.copy(O)},this.setViewport=function(G,le,ge,ne){G.isVector4?O.set(G.x,G.y,G.z,G.w):O.set(G,le,ge,ne),J.viewport(A.copy(O).multiplyScalar(P).floor())},this.getScissor=function(G){return G.copy(L)},this.setScissor=function(G,le,ge,ne){G.isVector4?L.set(G.x,G.y,G.z,G.w):L.set(G,le,ge,ne),J.scissor(T.copy(L).multiplyScalar(P).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(G){J.setScissorTest(j=G)},this.setOpaqueSort=function(G){_=G},this.setTransparentSort=function(G){I=G},this.getClearColor=function(G){return G.copy(ye.getClearColor())},this.setClearColor=function(){ye.setClearColor.apply(ye,arguments)},this.getClearAlpha=function(){return ye.getClearAlpha()},this.setClearAlpha=function(){ye.setClearAlpha.apply(ye,arguments)},this.clear=function(G=!0,le=!0,ge=!0){let ne=0;G&&(ne|=16384),le&&(ne|=256),ge&&(ne|=1024),W.clear(ne)},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",tt,!1),t.removeEventListener("webglcontextrestored",ot,!1),t.removeEventListener("webglcontextcreationerror",Gt,!1),F.dispose(),B.dispose(),xe.dispose(),De.dispose(),Pe.dispose(),Ue.dispose(),pe.dispose(),nt.dispose(),Le.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",qe),Be.removeEventListener("sessionend",Xe),X&&(X.dispose(),X=null),Rt.stop()};function tt(G){G.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function ot(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let G=Ee.autoReset,le=ae.enabled,ge=ae.autoUpdate,ne=ae.needsUpdate,be=ae.type;We(),Ee.autoReset=G,ae.enabled=le,ae.autoUpdate=ge,ae.needsUpdate=ne,ae.type=be}function Gt(G){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",G.statusMessage)}function xr(G){let le=G.target;le.removeEventListener("dispose",xr),Ir(le)}function Ir(G){Z(G),xe.remove(G)}function Z(G){let le=xe.get(G).programs;le!==void 0&&(le.forEach(function(ge){Le.releaseProgram(ge)}),G.isShaderMaterial&&Le.releaseShaderCache(G))}this.renderBufferDirect=function(G,le,ge,ne,be,st){le===null&&(le=te);let pt=be.isMesh&&be.matrixWorld.determinant()<0,St=rS(G,le,ge,ne,be);J.setMaterial(ne,pt);let Et=ge.index,jt=1;ne.wireframe===!0&&(Et=ke.getWireframeAttribute(ge),jt=2);let Lt=ge.drawRange,Tt=ge.attributes.position,Nt=Lt.start*jt,Mi=(Lt.start+Lt.count)*jt;st!==null&&(Nt=Math.max(Nt,st.start*jt),Mi=Math.min(Mi,(st.start+st.count)*jt)),Et!==null?(Nt=Math.max(Nt,0),Mi=Math.min(Mi,Et.count)):Tt!=null&&(Nt=Math.max(Nt,0),Mi=Math.min(Mi,Tt.count));let an=Mi-Nt;if(an<0||an===1/0)return;pe.setup(be,ne,St,ge,Et);let So,xt=Ne;if(Et!==null&&(So=ze.get(Et),xt=Fe,xt.setIndex(So)),be.isMesh)ne.wireframe===!0?(J.setLineWidth(ne.wireframeLinewidth*$()),xt.setMode(1)):xt.setMode(4);else if(be.isLine){let Vt=ne.linewidth;Vt===void 0&&(Vt=1),J.setLineWidth(Vt*$()),be.isLineSegments?xt.setMode(1):be.isLineLoop?xt.setMode(2):xt.setMode(3)}else be.isPoints?xt.setMode(0):be.isSprite&&xt.setMode(4);if(be.isInstancedMesh)xt.renderInstances(Nt,an,be.count);else if(ge.isInstancedBufferGeometry){let Vt=ge._maxInstanceCount!==void 0?ge._maxInstanceCount:1/0,Du=Math.min(ge.instanceCount,Vt);xt.renderInstances(Nt,an,Du)}else xt.render(Nt,an)},this.compile=function(G,le){function ge(ne,be,st){ne.transparent===!0&&ne.side===vi&&ne.forceSinglePass===!1?(ne.side=xi,ne.needsUpdate=!0,Rn(ne,be,st),ne.side=Jn,ne.needsUpdate=!0,Rn(ne,be,st),ne.side=vi):Rn(ne,be,st)}d=B.get(G),d.init(),m.push(d),G.traverseVisible(function(ne){ne.isLight&&ne.layers.test(le.layers)&&(d.pushLight(ne),ne.castShadow&&d.pushShadow(ne))}),d.setupLights(p.physicallyCorrectLights),G.traverse(function(ne){let be=ne.material;if(be)if(Array.isArray(be))for(let st=0;st<be.length;st++){let pt=be[st];ge(pt,G,ne)}else ge(be,G,ne)}),m.pop(),d=null};let ve=null;function Me(G){ve&&ve(G)}function qe(){Rt.stop()}function Xe(){Rt.start()}let Rt=new x_;Rt.setAnimationLoop(Me),typeof self<"u"&&Rt.setContext(self),this.setAnimationLoop=function(G){ve=G,Be.setAnimationLoop(G),G===null?Rt.stop():Rt.start()},Be.addEventListener("sessionstart",qe),Be.addEventListener("sessionend",Xe),this.render=function(G,le){if(le!==void 0&&le.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;G.matrixWorldAutoUpdate===!0&&G.updateMatrixWorld(),le.parent===null&&le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),Be.enabled===!0&&Be.isPresenting===!0&&(Be.cameraAutoUpdate===!0&&Be.updateCamera(le),le=Be.getCamera()),G.isScene===!0&&G.onBeforeRender(p,G,le,v),d=B.get(G,m.length),d.init(),m.push(d),K.multiplyMatrices(le.projectionMatrix,le.matrixWorldInverse),V.setFromProjectionMatrix(K),q=this.localClippingEnabled,H=N.init(this.clippingPlanes,q),h=F.get(G,f.length),h.init(),f.push(h),Hr(G,le,0,p.sortObjects),h.finish(),p.sortObjects===!0&&h.sort(_,I),H===!0&&N.beginShadows();let ge=d.state.shadowsArray;if(ae.render(ge,G,le),H===!0&&N.endShadows(),this.info.autoReset===!0&&this.info.reset(),ye.render(h,G),d.setupLights(p.physicallyCorrectLights),le.isArrayCamera){let ne=le.cameras;for(let be=0,st=ne.length;be<st;be++){let pt=ne[be];Wr(h,G,pt,pt.viewport)}}else Wr(h,G,le);v!==null&&(de.updateMultisampleRenderTarget(v),de.updateRenderTargetMipmap(v)),G.isScene===!0&&G.onAfterRender(p,G,le),pe.resetDefaultState(),b=-1,w=null,m.pop(),m.length>0?d=m[m.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Hr(G,le,ge,ne){if(G.visible===!1)return;if(G.layers.test(le.layers)){if(G.isGroup)ge=G.renderOrder;else if(G.isLOD)G.autoUpdate===!0&&G.update(le);else if(G.isLight)d.pushLight(G),G.castShadow&&d.pushShadow(G);else if(G.isSprite){if(!G.frustumCulled||V.intersectsSprite(G)){ne&&Q.setFromMatrixPosition(G.matrixWorld).applyMatrix4(K);let pt=Ue.update(G),St=G.material;St.visible&&h.push(G,pt,St,ge,Q.z,null)}}else if((G.isMesh||G.isLine||G.isPoints)&&(G.isSkinnedMesh&&G.skeleton.frame!==Ee.render.frame&&(G.skeleton.update(),G.skeleton.frame=Ee.render.frame),!G.frustumCulled||V.intersectsObject(G))){ne&&Q.setFromMatrixPosition(G.matrixWorld).applyMatrix4(K);let pt=Ue.update(G),St=G.material;if(Array.isArray(St)){let Et=pt.groups;for(let jt=0,Lt=Et.length;jt<Lt;jt++){let Tt=Et[jt],Nt=St[Tt.materialIndex];Nt&&Nt.visible&&h.push(G,pt,Nt,ge,Q.z,Tt)}}else St.visible&&h.push(G,pt,St,ge,Q.z,null)}}let st=G.children;for(let pt=0,St=st.length;pt<St;pt++)Hr(st[pt],le,ge,ne)}function Wr(G,le,ge,ne){let be=G.opaque,st=G.transmissive,pt=G.transparent;d.setupLightsView(ge),H===!0&&N.setGlobalState(p.clippingPlanes,ge),st.length>0&&va(be,le,ge),ne&&J.viewport(A.copy(ne)),be.length>0&&Dr(be,le,ge),st.length>0&&Dr(st,le,ge),pt.length>0&&Dr(pt,le,ge),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function va(G,le,ge){let ne=re.isWebGL2;X===null&&(X=new at(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?$n:Nr,minFilter:Bc,samples:ne&&s===!0?4:0})),p.getDrawingBufferSize(z),ne?X.setSize(z.x,z.y):X.setSize(Vy(z.x),Vy(z.y));let be=p.getRenderTarget();p.setRenderTarget(X),p.clear();let st=p.toneMapping;p.toneMapping=js,Dr(G,le,ge),p.toneMapping=st,de.updateMultisampleRenderTarget(X),de.updateRenderTargetMipmap(X),p.setRenderTarget(be)}function Dr(G,le,ge){let ne=le.isScene===!0?le.overrideMaterial:null;for(let be=0,st=G.length;be<st;be++){let pt=G[be],St=pt.object,Et=pt.geometry,jt=ne===null?pt.material:ne,Lt=pt.group;St.layers.test(ge.layers)&&us(St,le,ge,Et,jt,Lt)}}function us(G,le,ge,ne,be,st){G.onBeforeRender(p,le,ge,ne,be,st),G.modelViewMatrix.multiplyMatrices(ge.matrixWorldInverse,G.matrixWorld),G.normalMatrix.getNormalMatrix(G.modelViewMatrix),be.onBeforeRender(p,le,ge,ne,G,st),be.transparent===!0&&be.side===vi&&be.forceSinglePass===!1?(be.side=xi,be.needsUpdate=!0,p.renderBufferDirect(ge,le,ne,be,G,st),be.side=Jn,be.needsUpdate=!0,p.renderBufferDirect(ge,le,ne,be,G,st),be.side=vi):p.renderBufferDirect(ge,le,ne,be,G,st),G.onAfterRender(p,le,ge,ne,be,st)}function Rn(G,le,ge){le.isScene!==!0&&(le=te);let ne=xe.get(G),be=d.state.lights,st=d.state.shadowsArray,pt=be.state.version,St=Le.getParameters(G,be.state,st,le,ge),Et=Le.getProgramCacheKey(St),jt=ne.programs;ne.environment=G.isMeshStandardMaterial?le.environment:null,ne.fog=le.fog,ne.envMap=(G.isMeshStandardMaterial?Pe:De).get(G.envMap||ne.environment),jt===void 0&&(G.addEventListener("dispose",xr),jt=new Map,ne.programs=jt);let Lt=jt.get(Et);if(Lt!==void 0){if(ne.currentProgram===Lt&&ne.lightsStateVersion===pt)return vp(G,St),Lt}else St.uniforms=Le.getUniforms(G),G.onBuild(ge,St,p),G.onBeforeCompile(St,p),Lt=Le.acquireProgram(St,Et),jt.set(Et,Lt),ne.uniforms=St.uniforms;let Tt=ne.uniforms;(!G.isShaderMaterial&&!G.isRawShaderMaterial||G.clipping===!0)&&(Tt.clippingPlanes=N.uniform),vp(G,St),ne.needsLights=nS(G),ne.lightsStateVersion=pt,ne.needsLights&&(Tt.ambientLightColor.value=be.state.ambient,Tt.lightProbe.value=be.state.probe,Tt.directionalLights.value=be.state.directional,Tt.directionalLightShadows.value=be.state.directionalShadow,Tt.spotLights.value=be.state.spot,Tt.spotLightShadows.value=be.state.spotShadow,Tt.rectAreaLights.value=be.state.rectArea,Tt.ltc_1.value=be.state.rectAreaLTC1,Tt.ltc_2.value=be.state.rectAreaLTC2,Tt.pointLights.value=be.state.point,Tt.pointLightShadows.value=be.state.pointShadow,Tt.hemisphereLights.value=be.state.hemi,Tt.directionalShadowMap.value=be.state.directionalShadowMap,Tt.directionalShadowMatrix.value=be.state.directionalShadowMatrix,Tt.spotShadowMap.value=be.state.spotShadowMap,Tt.spotLightMatrix.value=be.state.spotLightMatrix,Tt.spotLightMap.value=be.state.spotLightMap,Tt.pointShadowMap.value=be.state.pointShadowMap,Tt.pointShadowMatrix.value=be.state.pointShadowMatrix);let Nt=Lt.getUniforms(),Mi=eh.seqWithValue(Nt.seq,Tt);return ne.currentProgram=Lt,ne.uniformsList=Mi,Lt}function vp(G,le){let ge=xe.get(G);ge.outputEncoding=le.outputEncoding,ge.instancing=le.instancing,ge.skinning=le.skinning,ge.morphTargets=le.morphTargets,ge.morphNormals=le.morphNormals,ge.morphColors=le.morphColors,ge.morphTargetsCount=le.morphTargetsCount,ge.numClippingPlanes=le.numClippingPlanes,ge.numIntersection=le.numClipIntersection,ge.vertexAlphas=le.vertexAlphas,ge.vertexTangents=le.vertexTangents,ge.toneMapping=le.toneMapping}function rS(G,le,ge,ne,be){le.isScene!==!0&&(le=te),de.resetTextureUnits();let st=le.fog,pt=ne.isMeshStandardMaterial?le.environment:null,St=v===null?p.outputEncoding:v.isXRRenderTarget===!0?v.texture.encoding:xn,Et=(ne.isMeshStandardMaterial?Pe:De).get(ne.envMap||pt),jt=ne.vertexColors===!0&&!!ge.attributes.color&&ge.attributes.color.itemSize===4,Lt=!!ne.normalMap&&!!ge.attributes.tangent,Tt=!!ge.morphAttributes.position,Nt=!!ge.morphAttributes.normal,Mi=!!ge.morphAttributes.color,an=ne.toneMapped?p.toneMapping:js,So=ge.morphAttributes.position||ge.morphAttributes.normal||ge.morphAttributes.color,xt=So!==void 0?So.length:0,Vt=xe.get(ne),Du=d.state.lights;if(H===!0&&(q===!0||G!==w)){let mi=G===w&&ne.id===b;N.setState(ne,G,mi)}let pi=!1;ne.version===Vt.__version?(Vt.needsLights&&Vt.lightsStateVersion!==Du.state.version||Vt.outputEncoding!==St||be.isInstancedMesh&&Vt.instancing===!1||!be.isInstancedMesh&&Vt.instancing===!0||be.isSkinnedMesh&&Vt.skinning===!1||!be.isSkinnedMesh&&Vt.skinning===!0||Vt.envMap!==Et||ne.fog===!0&&Vt.fog!==st||Vt.numClippingPlanes!==void 0&&(Vt.numClippingPlanes!==N.numPlanes||Vt.numIntersection!==N.numIntersection)||Vt.vertexAlphas!==jt||Vt.vertexTangents!==Lt||Vt.morphTargets!==Tt||Vt.morphNormals!==Nt||Vt.morphColors!==Mi||Vt.toneMapping!==an||re.isWebGL2===!0&&Vt.morphTargetsCount!==xt)&&(pi=!0):(pi=!0,Vt.__version=ne.version);let wo=Vt.currentProgram;pi===!0&&(wo=Rn(ne,le,be));let Ou=!1,Kn=!1,It=!1,Ci=wo.getUniforms(),hs=Vt.uniforms;if(J.useProgram(wo.program)&&(Ou=!0,Kn=!0,It=!0),ne.id!==b&&(b=ne.id,Kn=!0),Ou||w!==G){if(Ci.setValue(W,"projectionMatrix",G.projectionMatrix),re.logarithmicDepthBuffer&&Ci.setValue(W,"logDepthBufFC",2/(Math.log(G.far+1)/Math.LN2)),w!==G&&(w=G,Kn=!0,It=!0),ne.isShaderMaterial||ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshStandardMaterial||ne.envMap){let mi=Ci.map.cameraPosition;mi!==void 0&&mi.setValue(W,Q.setFromMatrixPosition(G.matrixWorld))}(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial)&&Ci.setValue(W,"isOrthographic",G.isOrthographicCamera===!0),(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial||ne.isShadowMaterial||be.isSkinnedMesh)&&Ci.setValue(W,"viewMatrix",G.matrixWorldInverse)}if(be.isSkinnedMesh){Ci.setOptional(W,be,"bindMatrix"),Ci.setOptional(W,be,"bindMatrixInverse");let mi=be.skeleton;mi&&(re.floatVertexTextures?(mi.boneTexture===null&&mi.computeBoneTexture(),Ci.setValue(W,"boneTexture",mi.boneTexture,de),Ci.setValue(W,"boneTextureSize",mi.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 Ru=ge.morphAttributes;if((Ru.position!==void 0||Ru.normal!==void 0||Ru.color!==void 0&&re.isWebGL2===!0)&&me.update(be,ge,ne,wo),(Kn||Vt.receiveShadow!==be.receiveShadow)&&(Vt.receiveShadow=be.receiveShadow,Ci.setValue(W,"receiveShadow",be.receiveShadow)),ne.isMeshGouraudMaterial&&ne.envMap!==null&&(hs.envMap.value=Et,hs.flipEnvMap.value=Et.isCubeTexture&&Et.isRenderTargetTexture===!1?-1:1),Kn&&(Ci.setValue(W,"toneMappingExposure",p.toneMappingExposure),Vt.needsLights&&iS(hs,It),st&&ne.fog===!0&&Qe.refreshFogUniforms(hs,st),Qe.refreshMaterialUniforms(hs,ne,P,C,X),eh.upload(W,Vt.uniformsList,hs,de)),ne.isShaderMaterial&&ne.uniformsNeedUpdate===!0&&(eh.upload(W,Vt.uniformsList,hs,de),ne.uniformsNeedUpdate=!1),ne.isSpriteMaterial&&Ci.setValue(W,"center",be.center),Ci.setValue(W,"modelViewMatrix",be.modelViewMatrix),Ci.setValue(W,"normalMatrix",be.normalMatrix),Ci.setValue(W,"modelMatrix",be.matrixWorld),be.previousModelViewMatrix&&Ci.setValue(W,"previousModelViewMatrix",be.previousModelViewMatrix),G.previousProjectionMatrix&&Ci.setValue(W,"previousProjectionMatrix",G.previousProjectionMatrix),ne.isShaderMaterial||ne.isRawShaderMaterial){let mi=ne.uniformsGroups;for(let D=0,R=mi.length;D<R;D++)if(re.isWebGL2){let Y=mi[D];nt.update(Y,wo),nt.bind(Y,wo)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return wo}function iS(G,le){G.ambientLightColor.needsUpdate=le,G.lightProbe.needsUpdate=le,G.directionalLights.needsUpdate=le,G.directionalLightShadows.needsUpdate=le,G.pointLights.needsUpdate=le,G.pointLightShadows.needsUpdate=le,G.spotLights.needsUpdate=le,G.spotLightShadows.needsUpdate=le,G.rectAreaLights.needsUpdate=le,G.hemisphereLights.needsUpdate=le}function nS(G){return G.isMeshLambertMaterial||G.isMeshToonMaterial||G.isMeshPhongMaterial||G.isMeshStandardMaterial||G.isShadowMaterial||G.isShaderMaterial&&G.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return v},this.setRenderTargetTextures=function(G,le,ge){xe.get(G.texture).__webglTexture=le,xe.get(G.depthTexture).__webglTexture=ge;let ne=xe.get(G);ne.__hasExternalTextures=!0,ne.__hasExternalTextures&&(ne.__autoAllocateDepthBuffer=ge===void 0,ne.__autoAllocateDepthBuffer||ie.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ne.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(G,le){let ge=xe.get(G);ge.__webglFramebuffer=le,ge.__useDefaultFramebuffer=le===void 0},this.setRenderTarget=function(G,le=0,ge=0){v=G,y=le,x=ge;let ne=!0,be=null,st=!1,pt=!1;if(G){let Et=xe.get(G);Et.__useDefaultFramebuffer!==void 0?(J.bindFramebuffer(36160,null),ne=!1):Et.__webglFramebuffer===void 0?de.setupRenderTarget(G):Et.__hasExternalTextures&&de.rebindTextures(G,xe.get(G.texture).__webglTexture,xe.get(G.depthTexture).__webglTexture);let jt=G.texture;(jt.isData3DTexture||jt.isDataArrayTexture||jt.isCompressedArrayTexture)&&(pt=!0);let Lt=xe.get(G).__webglFramebuffer;G.isWebGLCubeRenderTarget?(be=Lt[le],st=!0):re.isWebGL2&&G.samples>0&&de.useMultisampledRTT(G)===!1?be=xe.get(G).__webglMultisampledFramebuffer:be=Lt,A.copy(G.viewport),T.copy(G.scissor),S=G.scissorTest}else A.copy(O).multiplyScalar(P).floor(),T.copy(L).multiplyScalar(P).floor(),S=j;if(J.bindFramebuffer(36160,be)&&re.drawBuffers&&ne&&J.drawBuffers(G,be),J.viewport(A),J.scissor(T),J.setScissorTest(S),st){let Et=xe.get(G.texture);W.framebufferTexture2D(36160,36064,34069+le,Et.__webglTexture,ge)}else if(pt){let Et=xe.get(G.texture),jt=le||0;W.framebufferTextureLayer(36160,36064,Et.__webglTexture,ge||0,jt)}b=-1},this.readRenderTargetPixels=function(G,le,ge,ne,be,st,pt){if(!(G&&G.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=xe.get(G).__webglFramebuffer;if(G.isWebGLCubeRenderTarget&&pt!==void 0&&(St=St[pt]),St){J.bindFramebuffer(36160,St);try{let Et=G.texture,jt=Et.format,Lt=Et.type;if(jt!==br&&Oe.convert(jt)!==W.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Tt=Lt===$n&&(ie.has("EXT_color_buffer_half_float")||re.isWebGL2&&ie.has("EXT_color_buffer_float"));if(Lt!==Nr&&Oe.convert(Lt)!==W.getParameter(35738)&&!(Lt===Ut&&(re.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!Tt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}le>=0&&le<=G.width-ne&&ge>=0&&ge<=G.height-be&&W.readPixels(le,ge,ne,be,Oe.convert(jt),Oe.convert(Lt),st)}finally{let Et=v!==null?xe.get(v).__webglFramebuffer:null;J.bindFramebuffer(36160,Et)}}},this.readRenderTargetPixelsAsync=async function(G,le,ge,ne,be,st,pt){if(!(G&&G.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let St=xe.get(G).__webglFramebuffer;if(G.isWebGLCubeRenderTarget&&pt!==void 0&&(St=St[pt]),St){let Et=G.texture,jt=Et.format,Lt=Et.type;if(le>=0&&le<=G.width-ne&&ge>=0&&ge<=G.height-be){J.bindFramebuffer(W.FRAMEBUFFER,St);let Tt=W.createBuffer();W.bindBuffer(W.PIXEL_PACK_BUFFER,Tt),W.bufferData(W.PIXEL_PACK_BUFFER,st.byteLength,W.STREAM_READ),W.readPixels(le,ge,ne,be,Oe.convert(jt),Oe.convert(Lt),0);let Nt=v!==null?xe.get(v).__webglFramebuffer:null;J.bindFramebuffer(W.FRAMEBUFFER,Nt);let Mi=W.fenceSync(W.SYNC_GPU_COMMANDS_COMPLETE,0);return W.flush(),await fk(W,Mi,4),W.bindBuffer(W.PIXEL_PACK_BUFFER,Tt),W.getBufferSubData(W.PIXEL_PACK_BUFFER,0,st),W.deleteBuffer(Tt),W.deleteSync(Mi),st}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(G,le,ge=0){let ne=Math.pow(2,-ge),be=Math.floor(le.image.width*ne),st=Math.floor(le.image.height*ne);de.setTexture2D(le,0),W.copyTexSubImage2D(3553,ge,0,0,G.x,G.y,be,st),J.unbindTexture()},this.copyTextureToTexture=function(G,le,ge,ne=0){let be=le.image.width,st=le.image.height,pt=Oe.convert(ge.format),St=Oe.convert(ge.type);de.setTexture2D(ge,0),W.pixelStorei(37440,ge.flipY),W.pixelStorei(37441,ge.premultiplyAlpha),W.pixelStorei(3317,ge.unpackAlignment),le.isDataTexture?W.texSubImage2D(3553,ne,G.x,G.y,be,st,pt,St,le.image.data):le.isCompressedTexture?W.compressedTexSubImage2D(3553,ne,G.x,G.y,le.mipmaps[0].width,le.mipmaps[0].height,pt,le.mipmaps[0].data):W.texSubImage2D(3553,ne,G.x,G.y,pt,St,le.image),ne===0&&ge.generateMipmaps&&W.generateMipmap(3553),J.unbindTexture()},this.copyTextureToTexture3D=function(G,le,ge,ne,be=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let st=G.max.x-G.min.x+1,pt=G.max.y-G.min.y+1,St=G.max.z-G.min.z+1,Et=Oe.convert(ne.format),jt=Oe.convert(ne.type),Lt;if(ne.isData3DTexture)de.setTexture3D(ne,0),Lt=32879;else if(ne.isDataArrayTexture)de.setTexture2DArray(ne,0),Lt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}W.pixelStorei(37440,ne.flipY),W.pixelStorei(37441,ne.premultiplyAlpha),W.pixelStorei(3317,ne.unpackAlignment);let Tt=W.getParameter(3314),Nt=W.getParameter(32878),Mi=W.getParameter(3316),an=W.getParameter(3315),So=W.getParameter(32877),xt=ge.isCompressedTexture?ge.mipmaps[0]:ge.image;W.pixelStorei(3314,xt.width),W.pixelStorei(32878,xt.height),W.pixelStorei(3316,G.min.x),W.pixelStorei(3315,G.min.y),W.pixelStorei(32877,G.min.z),ge.isDataTexture||ge.isData3DTexture?W.texSubImage3D(Lt,be,le.x,le.y,le.z,st,pt,St,Et,jt,xt.data):ge.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),W.compressedTexSubImage3D(Lt,be,le.x,le.y,le.z,st,pt,St,Et,xt.data)):W.texSubImage3D(Lt,be,le.x,le.y,le.z,st,pt,St,Et,jt,xt),W.pixelStorei(3314,Tt),W.pixelStorei(32878,Nt),W.pixelStorei(3316,Mi),W.pixelStorei(3315,an),W.pixelStorei(32877,So),be===0&&ne.generateMipmaps&&W.generateMipmap(Lt),J.unbindTexture()},this.initRenderTarget=function(G){xe.get(G).__webglFramebuffer===void 0&&de.setupRenderTarget(G)},this.initTexture=function(G){G.isCubeTexture?de.setTextureCube(G,0):G.isData3DTexture?de.setTexture3D(G,0):G.isDataArrayTexture||G.isCompressedArrayTexture?de.setTexture2DArray(G,0):de.setTexture2D(G,0),J.unbindTexture()},this.resetState=function(){y=0,x=0,v=null,J.reset(),pe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var cw=class extends Lw{};cw.prototype.isWebGL1Renderer=!0;var nh=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new Ge(t),this.near=e,this.far=r}clone(){return new nh(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Er=class extends Dt{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(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},Wy=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=KS,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=fs()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[r+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=fs()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=fs()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.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}}},yn=new E,Vc=class{constructor(t,e,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,r=this.data.count;e<r;e++)yn.fromBufferAttribute(this,e),yn.applyMatrix4(t),this.setXYZ(e,yn.x,yn.y,yn.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)yn.fromBufferAttribute(this,e),yn.applyNormalMatrix(t),this.setXYZ(e,yn.x,yn.y,yn.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)yn.fromBufferAttribute(this,e),yn.transformDirection(t),this.setXYZ(e,yn.x,yn.y,yn.z);return this}setX(t,e){return this.normalized&&(e=Ar(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Ar(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Ar(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Ar(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ma(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ma(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ma(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ma(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ar(e,this.array),r=Ar(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this}setXYZ(t,e,r,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ar(e,this.array),r=Ar(r,this.array),i=Ar(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ar(e,this.array),r=Ar(r,this.array),i=Ar(i,this.array),s=Ar(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new je(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Vc(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var Gp=class extends Dt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Ur=class extends Zt{constructor(t=null,e=1,r=1,i,s,o,a,l,c=vt,u=vt,h,d){super(null,o,a,l,c,u,i,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},kP=new ue,J5=new ue,Sl=class{constructor(t=[],e=[]){this.uuid=fs(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,i=this.bones.length;r<i;r++)this.boneInverses.push(new ue)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let r=new ue;this.bones[t]&&r.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&r.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){let t=this.bones,e=this.boneInverses,r=this.boneMatrices,i=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:J5;kP.multiplyMatrices(a,e[s]),kP.toArray(r,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Sl(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=m_(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new Ur(e,t,t,br,Ut);return r.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=r,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,r=this.bones.length;e<r;e++){let i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let r=0,i=t.bones.length;r<i;r++){let s=t.bones[r],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new Gp),this.bones.push(o),this.boneInverses.push(new ue().fromArray(t.boneInverses[r]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,r=this.boneInverses;for(let i=0,s=e.length;i<s;i++){let o=e[i];t.bones.push(o.uuid);let a=r[i];t.boneInverses.push(a.toArray())}return t}},Mo=class extends je{constructor(t,e,r,i=1){super(t,e,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},zP=new ue,GP=new ue,Ey=[],$5=new ue,Cp=new Mt,qy=class extends Mt{constructor(t,e,r){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Mo(new Float32Array(r*16),16),this.instanceColor=null,this.count=r,this.frustumCulled=!1;for(let i=0;i<r;i++)this.setMatrixAt(i,$5)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}raycast(t,e){let r=this.matrixWorld,i=this.count;if(Cp.geometry=this.geometry,Cp.material=this.material,Cp.material!==void 0)for(let s=0;s<i;s++){this.getMatrixAt(s,zP),GP.multiplyMatrices(r,zP),Cp.matrixWorld=GP,Cp.raycast(t,Ey);for(let o=0,a=Ey.length;o<a;o++){let l=Ey[o];l.instanceId=s,l.object=this,e.push(l)}Ey.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new Mo(new Float32Array(this.instanceMatrix.count*3),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},ms=class extends Fc{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ge(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},jP=new E,HP=new E,WP=new ue,US=new Ws,Ty=new ei,Uc=class extends Dt{constructor(t=new Ce,e=new ms){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[0];for(let i=1,s=e.count;i<s;i++)jP.fromBufferAttribute(e,i-1),HP.fromBufferAttribute(e,i),r[i]=r[i-1],r[i]+=jP.distanceTo(HP);t.setAttribute("lineDistance",new Te(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let r=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Ty.copy(r.boundingSphere),Ty.applyMatrix4(i),Ty.radius+=s,t.ray.intersectsSphere(Ty)===!1)return;WP.copy(i).invert(),US.copy(t.ray).applyMatrix4(WP);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new E,u=new E,h=new E,d=new E,f=this.isLineSegments?2:1,m=r.index,g=r.attributes.position;if(m!==null){let y=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let v=y,b=x-1;v<b;v+=f){let w=m.getX(v),A=m.getX(v+1);if(c.fromBufferAttribute(g,w),u.fromBufferAttribute(g,A),US.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let S=t.ray.origin.distanceTo(d);S<t.near||S>t.far||e.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),x=Math.min(g.count,o.start+o.count);for(let v=y,b=x-1;v<b;v+=f){if(c.fromBufferAttribute(g,v),u.fromBufferAttribute(g,v+1),US.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);A<t.near||A>t.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},qP=new E,XP=new E,wl=class extends Uc{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[];for(let i=0,s=e.count;i<s;i+=2)qP.fromBufferAttribute(e,i),XP.fromBufferAttribute(e,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+qP.distanceTo(XP);t.setAttribute("lineDistance",new Te(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Xy=class extends Zt{constructor(t,e,r,i,s,o,a,l,c){super(t,e,r,i,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:it,this.magFilter=s!==void 0?s:it,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var Yy=class extends Zt{constructor(t,e,r,i,s,o,a,l,c){super(t,e,r,i,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},gs=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),i=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);let u=r[i],d=r[i+1]-u,f=(o-u)/d;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new U:new E);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){let r=new E,i=[],s=[],o=[],a=new E,l=new ue;for(let f=0;f<=t;f++){let m=f/t;i[f]=this.getTangentAt(m,new E)}s[0]=new E,o[0]=new E;let c=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=c&&(c=u,r.set(1,0,0)),h<=c&&(c=h,r.set(0,1,0)),d<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(yi(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(yi(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},kc=class extends gs{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let r=e||new U,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*u-f*h+this.aX,c=d*h+f*u+this.aY}return r.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},uw=class extends kc{constructor(t,e,r,i,s,o){super(t,e,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Nw(){let n=0,t=0,e=0,r=0;function i(s,o,a,l){n=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let d=(o-s)/c-(a-s)/(c+u)+(a-o)/u,f=(a-o)/u-(l-o)/(u+h)+(l-a)/h;d*=u,f*=u,i(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return n+t*s+e*o+r*a}}}var My=new E,kS=new Nw,zS=new Nw,GS=new Nw,hw=class extends gs{constructor(t=[],e=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=i}getPoint(t,e=new E){let r=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%s]:(My.subVectors(i[0],i[1]).add(i[0]),c=My);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(My.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=My),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(c.distanceToSquared(h),f),p=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(u),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),kS.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,p,g),zS.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,p,g),GS.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,p,g)}else this.curveType==="catmullrom"&&(kS.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),zS.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),GS.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return r.set(kS.calc(l),zS.calc(l),GS.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(new E().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function YP(n,t,e,r,i){let s=(r-t)*.5,o=(i-e)*.5,a=n*n,l=n*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*n+e}function ej(n,t){let e=1-n;return e*e*t}function tj(n,t){return 2*(1-n)*n*t}function rj(n,t){return n*n*t}function Lp(n,t,e,r){return ej(n,t)+tj(n,e)+rj(n,r)}function ij(n,t){let e=1-n;return e*e*e*t}function nj(n,t){let e=1-n;return 3*e*e*n*t}function sj(n,t){return 3*(1-n)*n*n*t}function oj(n,t){return n*n*n*t}function Np(n,t,e,r,i){return ij(n,t)+nj(n,e)+sj(n,r)+oj(n,i)}var hn=class extends gs{constructor(t=new U,e=new U,r=new U,i=new U){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new U){let r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Np(t,i.x,s.x,o.x,a.x),Np(t,i.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},zc=class extends gs{constructor(t=new E,e=new E,r=new E,i=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new E){let r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Np(t,i.x,s.x,o.x,a.x),Np(t,i.y,s.y,o.y,a.y),Np(t,i.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},dn=class extends gs{constructor(t=new U,e=new U){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new U){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let r=e||new U;return r.copy(this.v2).sub(this.v1).normalize(),r}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},jp=class extends gs{constructor(t=new E,e=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new E){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},es=class extends gs{constructor(t=new U,e=new U,r=new U){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new U){let r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(Lp(t,i.x,s.x,o.x),Lp(t,i.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},dw=class extends gs{constructor(t=new E,e=new E,r=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new E){let r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(Lp(t,i.x,s.x,o.x),Lp(t,i.y,s.y,o.y),Lp(t,i.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},sh=class extends gs{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new U){let r=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return r.set(YP(a,l.x,c.x,u.x,h.x),YP(a,l.y,c.y,u.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(new U().fromArray(i))}return this}},aj=Object.freeze({__proto__:null,ArcCurve:uw,CatmullRomCurve3:hw,CubicBezierCurve:hn,CubicBezierCurve3:zc,EllipseCurve:kc,LineCurve:dn,LineCurve3:jp,QuadraticBezierCurve:es,QuadraticBezierCurve3:dw,SplineCurve:sh}),Hp=class extends gs{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new dn(e,t))}getPoint(t,e){let r=t*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=r){let o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.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 t=[],e=0;for(let r=0,i=this.curves.length;r<i;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],r;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){let u=l[c];r&&r.equals(u)||(e.push(u),r=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let i=t.curves[e];this.curves.push(new aj[i.type]().fromJSON(i))}return this}},Gc=class extends Hp{constructor(t){super(),this.type="Path",this.currentPoint=new U,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let r=new dn(this.currentPoint.clone(),new U(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,i){let s=new es(this.currentPoint.clone(),new U(t,e),new U(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(t,e,r,i,s,o){let a=new hn(this.currentPoint.clone(),new U(t,e),new U(r,i),new U(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),r=new sh(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}ellipse(t,e,r,i,s,o,a,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+c,e+u,r,i,s,o,a,l),this}absellipse(t,e,r,i,s,o,a,l){let c=new kc(t,e,r,i,s,o,a,l);if(this.curves.length>0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},oh=class extends Ce{constructor(t=[new U(0,-.5),new U(.5,0),new U(0,.5)],e=12,r=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:i},e=Math.floor(e),i=yi(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/e,h=new E,d=new U,f=new E,m=new E,p=new E,g=0,y=0;for(let x=0;x<=t.length-1;x++)switch(x){case 0:g=t[x+1].x-t[x].x,y=t[x+1].y-t[x].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(p.x,p.y,p.z);break;default:g=t[x+1].x-t[x].x,y=t[x+1].y-t[x].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let x=0;x<=e;x++){let v=r+x*u*i,b=Math.sin(v),w=Math.cos(v);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*b,h.y=t[A].y,h.z=t[A].x*w,o.push(h.x,h.y,h.z),d.x=x/e,d.y=A/(t.length-1),a.push(d.x,d.y);let T=l[3*A+0]*b,S=l[3*A+1],M=l[3*A+0]*w;c.push(T,S,M)}}for(let x=0;x<e;x++)for(let v=0;v<t.length-1;v++){let b=v+x*t.length,w=b,A=b+t.length,T=b+t.length+1,S=b+1;s.push(w,A,S),s.push(T,S,A)}this.setIndex(s),this.setAttribute("position",new Te(o,3)),this.setAttribute("uv",new Te(a,2)),this.setAttribute("normal",new Te(c,3))}static fromJSON(t){return new oh(t.points,t.segments,t.phiStart,t.phiLength)}};var jc=class extends Ce{constructor(t=1,e=1,r=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let u=[],h=[],d=[],f=[],m=0,p=[],g=r/2,y=0;x(),o===!1&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new Te(h,3)),this.setAttribute("normal",new Te(d,3)),this.setAttribute("uv",new Te(f,2));function x(){let b=new E,w=new E,A=0,T=(e-t)/r;for(let S=0;S<=s;S++){let M=[],C=S/s,P=C*(e-t)+t;for(let _=0;_<=i;_++){let I=_/i,O=I*l+a,L=Math.sin(O),j=Math.cos(O);w.x=P*L,w.y=-C*r+g,w.z=P*j,h.push(w.x,w.y,w.z),b.set(L,T,j).normalize(),d.push(b.x,b.y,b.z),f.push(I,1-C),M.push(m++)}p.push(M)}for(let S=0;S<i;S++)for(let M=0;M<s;M++){let C=p[M][S],P=p[M+1][S],_=p[M+1][S+1],I=p[M][S+1];u.push(C,P,I),u.push(P,_,I),A+=6}c.addGroup(y,A,0),y+=A}function v(b){let w=m,A=new U,T=new E,S=0,M=b===!0?t:e,C=b===!0?1:-1;for(let _=1;_<=i;_++)h.push(0,g*C,0),d.push(0,C,0),f.push(.5,.5),m++;let P=m;for(let _=0;_<=i;_++){let O=_/i*l+a,L=Math.cos(O),j=Math.sin(O);T.x=M*j,T.y=g*C,T.z=M*L,h.push(T.x,T.y,T.z),d.push(0,C,0),A.x=L*.5+.5,A.y=j*.5*C+.5,f.push(A.x,A.y),m++}for(let _=0;_<i;_++){let I=w+_,O=P+_;b===!0?u.push(O,O+1,I):u.push(O+1,O,I),S+=3}c.addGroup(y,S,b===!0?1:2),y+=S}}static fromJSON(t){return new jc(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Al=class extends jc{constructor(t=1,e=1,r=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,r,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new Al(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ah=class extends Ce{constructor(t=[],e=[],r=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:i};let s=[],o=[];a(i),c(r),u(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(x){let v=new E,b=new E,w=new E;for(let A=0;A<e.length;A+=3)f(e[A+0],v),f(e[A+1],b),f(e[A+2],w),l(v,b,w,x)}function l(x,v,b,w){let A=w+1,T=[];for(let S=0;S<=A;S++){T[S]=[];let M=x.clone().lerp(b,S/A),C=v.clone().lerp(b,S/A),P=A-S;for(let _=0;_<=P;_++)_===0&&S===A?T[S][_]=M:T[S][_]=M.clone().lerp(C,_/P)}for(let S=0;S<A;S++)for(let M=0;M<2*(A-S)-1;M++){let C=Math.floor(M/2);M%2===0?(d(T[S][C+1]),d(T[S+1][C]),d(T[S][C])):(d(T[S][C+1]),d(T[S+1][C+1]),d(T[S+1][C]))}}function c(x){let v=new E;for(let b=0;b<s.length;b+=3)v.x=s[b+0],v.y=s[b+1],v.z=s[b+2],v.normalize().multiplyScalar(x),s[b+0]=v.x,s[b+1]=v.y,s[b+2]=v.z}function u(){let x=new E;for(let v=0;v<s.length;v+=3){x.x=s[v+0],x.y=s[v+1],x.z=s[v+2];let b=g(x)/2/Math.PI+.5,w=y(x)/Math.PI+.5;o.push(b,1-w)}m(),h()}function h(){for(let x=0;x<o.length;x+=6){let v=o[x+0],b=o[x+2],w=o[x+4],A=Math.max(v,b,w),T=Math.min(v,b,w);A>.9&&T<.1&&(v<.2&&(o[x+0]+=1),b<.2&&(o[x+2]+=1),w<.2&&(o[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function f(x,v){let b=x*3;v.x=t[b+0],v.y=t[b+1],v.z=t[b+2]}function m(){let x=new E,v=new E,b=new E,w=new E,A=new U,T=new U,S=new U;for(let M=0,C=0;M<s.length;M+=9,C+=6){x.set(s[M+0],s[M+1],s[M+2]),v.set(s[M+3],s[M+4],s[M+5]),b.set(s[M+6],s[M+7],s[M+8]),A.set(o[C+0],o[C+1]),T.set(o[C+2],o[C+3]),S.set(o[C+4],o[C+5]),w.copy(x).add(v).add(b).divideScalar(3);let P=g(w);p(A,C+0,x,P),p(T,C+2,v,P),p(S,C+4,b,P)}}function p(x,v,b,w){w<0&&x.x===1&&(o[v]=x.x-1),b.x===0&&b.z===0&&(o[v]=w/2/Math.PI+.5)}function g(x){return Math.atan2(x.z,-x.x)}function y(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}static fromJSON(t){return new ah(t.vertices,t.indices,t.radius,t.details)}},lh=class extends ah{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,i=1/r,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,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new lh(t.radius,t.detail)}};var Ca=class extends Gc{constructor(t){super(t),this.uuid=fs(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let r=0,i=this.holes.length;r<i;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let i=t.holes[e];this.holes.push(new Gc().fromJSON(i))}return this}},lj={triangulate:function(n,t,e=2){let r=t&&t.length,i=r?t[0]*e:n.length,s=E_(n,0,i,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,h,d,f;if(r&&(s=fj(n,t,s,e)),n.length>80*e){a=c=n[0],l=u=n[1];for(let m=e;m<i;m+=e)h=n[m],d=n[m+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return Wp(s,o,e,a,l,f,0),o}};function E_(n,t,e,r,i){let s,o;if(i===Ej(n,t,e,r)>0)for(s=t;s<e;s+=r)o=KP(s,n[s],n[s+1],o);else for(s=e-r;s>=t;s-=r)o=KP(s,n[s],n[s+1],o);return o&&dv(o,o.next)&&(Xp(o),o=o.next),o}function Hc(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(dv(e,e.next)||Xr(e.prev,e,e.next)===0)){if(Xp(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Wp(n,t,e,r,i,s,o){if(!n)return;!o&&s&&vj(n,r,i,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?uj(n,r,i,s):cj(n)){t.push(l.i/e|0),t.push(n.i/e|0),t.push(c.i/e|0),Xp(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=hj(Hc(n),t,e),Wp(n,t,e,r,i,s,2)):o===2&&dj(n,t,e,r,i,s):Wp(Hc(n),t,e,r,i,s,1);break}}}function cj(n){let t=n.prev,e=n,r=n.next;if(Xr(t,e,r)>=0)return!1;let i=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,u=i<s?i<o?i:o:s<o?s:o,h=a<l?a<c?a:c:l<c?l:c,d=i>s?i>o?i:o:s>o?s:o,f=a>l?a>c?a:c:l>c?l:c,m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=f&&$u(i,a,s,l,o,c,m.x,m.y)&&Xr(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function uj(n,t,e,r){let i=n.prev,s=n,o=n.next;if(Xr(i,s,o)>=0)return!1;let a=i.x,l=s.x,c=o.x,u=i.y,h=s.y,d=o.y,f=a<l?a<c?a:c:l<c?l:c,m=u<h?u<d?u:d:h<d?h:d,p=a>l?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,y=fw(f,m,t,e,r),x=fw(p,g,t,e,r),v=n.prevZ,b=n.nextZ;for(;v&&v.z>=y&&b&&b.z<=x;){if(v.x>=f&&v.x<=p&&v.y>=m&&v.y<=g&&v!==i&&v!==o&&$u(a,u,l,h,c,d,v.x,v.y)&&Xr(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=f&&b.x<=p&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&$u(a,u,l,h,c,d,b.x,b.y)&&Xr(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=y;){if(v.x>=f&&v.x<=p&&v.y>=m&&v.y<=g&&v!==i&&v!==o&&$u(a,u,l,h,c,d,v.x,v.y)&&Xr(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=p&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&$u(a,u,l,h,c,d,b.x,b.y)&&Xr(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function hj(n,t,e){let r=n;do{let i=r.prev,s=r.next.next;!dv(i,s)&&T_(i,r,r.next,s)&&qp(i,s)&&qp(s,i)&&(t.push(i.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),Xp(r),Xp(r.next),r=n=s),r=r.next}while(r!==n);return Hc(r)}function dj(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Sj(o,a)){let l=M_(o,a);o=Hc(o,o.next),l=Hc(l,l.next),Wp(o,t,e,r,i,s,0),Wp(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function fj(n,t,e,r){let i=[],s,o,a,l,c;for(s=0,o=t.length;s<o;s++)a=t[s]*r,l=s<o-1?t[s+1]*r:n.length,c=E_(n,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(bj(c));for(i.sort(pj),s=0;s<i.length;s++)e=mj(i[s],e);return e}function pj(n,t){return n.x-t.x}function mj(n,t){let e=gj(n,t);if(!e)return t;let r=M_(e,n);return Hc(r,r.next),Hc(e,e.next)}function gj(n,t){let e=t,r=-1/0,i,s=n.x,o=n.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,i=e.x<e.next.x?e:e.next,d===s))return i}e=e.next}while(e!==t);if(!i)return null;let a=i,l=i.x,c=i.y,u=1/0,h;e=i;do s>=e.x&&e.x>=l&&s!==e.x&&$u(o<c?s:r,o,l,c,o<c?r:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),qp(e,n)&&(h<u||h===u&&(e.x>i.x||e.x===i.x&&yj(i,e)))&&(i=e,u=h)),e=e.next;while(e!==a);return i}function yj(n,t){return Xr(n.prev,n,t.prev)<0&&Xr(t.next,n,n.next)<0}function vj(n,t,e,r){let i=n;do i.z===0&&(i.z=fw(i.x,i.y,t,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,xj(i)}function xj(n){let t,e,r,i,s,o,a,l,c=1;do{for(e=n,n=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t<c&&(a++,r=r.nextZ,!!r);t++);for(l=c;a>0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(i=e,e=e.nextZ,a--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;e=r}s.nextZ=null,c*=2}while(o>1);return n}function fw(n,t,e,r,i){return n=(n-e)*i|0,t=(t-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function bj(n){let t=n,e=n;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==n);return e}function $u(n,t,e,r,i,s,o,a){return(i-o)*(t-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function Sj(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!wj(n,t)&&(qp(n,t)&&qp(t,n)&&Aj(n,t)&&(Xr(n.prev,n,t.prev)||Xr(n,t.prev,t))||dv(n,t)&&Xr(n.prev,n,n.next)>0&&Xr(t.prev,t,t.next)>0)}function Xr(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function dv(n,t){return n.x===t.x&&n.y===t.y}function T_(n,t,e,r){let i=Py(Xr(n,t,e)),s=Py(Xr(n,t,r)),o=Py(Xr(e,r,n)),a=Py(Xr(e,r,t));return!!(i!==s&&o!==a||i===0&&Cy(n,e,t)||s===0&&Cy(n,r,t)||o===0&&Cy(e,n,r)||a===0&&Cy(e,t,r))}function Cy(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function Py(n){return n>0?1:n<0?-1:0}function wj(n,t){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&T_(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function qp(n,t){return Xr(n.prev,n,n.next)<0?Xr(n,t,n.next)>=0&&Xr(n,n.prev,t)>=0:Xr(n,t,n.prev)<0||Xr(n,n.next,t)<0}function Aj(n,t){let e=n,r=!1,i=(n.x+t.x)/2,s=(n.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==n);return r}function M_(n,t){let e=new pw(n.i,n.x,n.y),r=new pw(t.i,t.x,t.y),i=n.next,s=t.prev;return n.next=t,t.prev=n,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function KP(n,t,e,r){let i=new pw(n,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Xp(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function pw(n,t,e){this.i=n,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ej(n,t,e,r){let i=0;for(let s=t,o=e-r;s<e;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}var ch=class{static area(t){let e=t.length,r=0;for(let i=e-1,s=0;s<e;i=s++)r+=t[i].x*t[s].y-t[s].x*t[i].y;return r*.5}static isClockWise(t){return ch.area(t)<0}static triangulateShape(t,e){let r=[],i=[],s=[];QP(t),ZP(r,t);let o=t.length;e.forEach(QP);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,ZP(r,e[l]);let a=lj.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function QP(n){let t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function ZP(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}var uh=class extends ah{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,i=[-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],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(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new uh(t.radius,t.detail)}};var qs=class extends Ce{constructor(t=1,e=32,r=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),c=0,u=[],h=new E,d=new E,f=[],m=[],p=[],g=[];for(let y=0;y<=r;y++){let x=[],v=y/r,b=0;y==0&&o==0?b=.5/e:y==r&&l==Math.PI&&(b=-.5/e);for(let w=0;w<=e;w++){let A=w/e;h.x=-t*Math.cos(i+A*s)*Math.sin(o+v*a),h.y=t*Math.cos(o+v*a),h.z=t*Math.sin(i+A*s)*Math.sin(o+v*a),m.push(h.x,h.y,h.z),d.copy(h).normalize(),p.push(d.x,d.y,d.z),g.push(A+b,1-v),x.push(c++)}u.push(x)}for(let y=0;y<r;y++)for(let x=0;x<e;x++){let v=u[y][x+1],b=u[y][x],w=u[y+1][x],A=u[y+1][x+1];(y!==0||o>0)&&f.push(v,b,A),(y!==r-1||l<Math.PI)&&f.push(b,w,A)}this.setIndex(f),this.setAttribute("position",new Te(m,3)),this.setAttribute("normal",new Te(p,3)),this.setAttribute("uv",new Te(g,2))}static fromJSON(t){return new qs(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var hh=class extends Ce{constructor(t=1,e=.4,r=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:i,arc:s},r=Math.floor(r),i=Math.floor(i);let o=[],a=[],l=[],c=[],u=new E,h=new E,d=new E;for(let f=0;f<=r;f++)for(let m=0;m<=i;m++){let p=m/i*s,g=f/r*Math.PI*2;h.x=(t+e*Math.cos(g))*Math.cos(p),h.y=(t+e*Math.cos(g))*Math.sin(p),h.z=e*Math.sin(g),a.push(h.x,h.y,h.z),u.x=t*Math.cos(p),u.y=t*Math.sin(p),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(m/i),c.push(f/r)}for(let f=1;f<=r;f++)for(let m=1;m<=i;m++){let p=(i+1)*f+m-1,g=(i+1)*(f-1)+m-1,y=(i+1)*(f-1)+m,x=(i+1)*f+m;o.push(p,g,x),o.push(g,y,x)}this.setIndex(o),this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(c,2))}static fromJSON(t){return new hh(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},dh=class extends Ce{constructor(t=1,e=.4,r=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:i,p:s,q:o},r=Math.floor(r),i=Math.floor(i);let a=[],l=[],c=[],u=[],h=new E,d=new E,f=new E,m=new E,p=new E,g=new E,y=new E;for(let v=0;v<=r;++v){let b=v/r*s*Math.PI*2;x(b,s,o,t,f),x(b+.01,s,o,t,m),g.subVectors(m,f),y.addVectors(m,f),p.crossVectors(g,y),y.crossVectors(p,g),p.normalize(),y.normalize();for(let w=0;w<=i;++w){let A=w/i*Math.PI*2,T=-e*Math.cos(A),S=e*Math.sin(A);h.x=f.x+(T*y.x+S*p.x),h.y=f.y+(T*y.y+S*p.y),h.z=f.z+(T*y.z+S*p.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),c.push(d.x,d.y,d.z),u.push(v/r),u.push(w/i)}}for(let v=1;v<=r;v++)for(let b=1;b<=i;b++){let w=(i+1)*(v-1)+(b-1),A=(i+1)*v+(b-1),T=(i+1)*v+b,S=(i+1)*(v-1)+b;a.push(w,A,S),a.push(A,T,S)}this.setIndex(a),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2));function x(v,b,w,A,T){let S=Math.cos(v),M=Math.sin(v),C=w/b*v,P=Math.cos(C);T.x=A*(2+P)*.5*S,T.y=A*(2+P)*M*.5,T.z=A*Math.sin(C)*.5}}static fromJSON(t){return new dh(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};var Ky=class extends $e{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};function pl(n,t,e){return C_(n)?new n.constructor(n.subarray(t,e!==void 0?e:n.length)):n.slice(t,e)}function _y(n,t,e){return!n||!e&&n.constructor===t?n:typeof t.BYTES_PER_ELEMENT=="number"?new t(n):Array.prototype.slice.call(n)}function C_(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Tj(n){function t(i,s){return n[i]-n[s]}let e=n.length,r=new Array(e);for(let i=0;i!==e;++i)r[i]=i;return r.sort(t),r}function JP(n,t,e){let r=n.length,i=new n.constructor(r);for(let s=0,o=0;o!==r;++s){let a=e[s]*t;for(let l=0;l!==t;++l)i[o++]=n[a+l]}return i}function P_(n,t,e,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=n[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=n[i++];while(s!==void 0);else do o=s[r],o!==void 0&&(t.push(s.time),e.push(o)),s=n[i++];while(s!==void 0)}var fh=class{constructor(t,e,r,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(r),this.sampleValues=e,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,r=this._cachedIndex,i=e[r],s=e[r-1];e:{t:{let o;r:{i:if(!(t<i)){for(let a=r+2;;){if(i===void 0){if(t<s)break i;return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=i,i=e[++r],t<i)break t}o=e.length;break r}if(!(t>=s)){let a=e[1];t<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(i=s,s=e[--r-1],t>=s)break t}o=r,r=0;break r}break e}for(;r<o;){let a=r+o>>>1;t<e[a]?o=a:r=a+1}if(i=e[r],s=e[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,i)}return this.interpolate_(r,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=r[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},mw=class extends fh{constructor(t,e,r,i){super(t,e,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Qu,endingEnd:Qu}}intervalChanged_(t,e,r){let i=this.parameterPositions,s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Zu:s=t,a=2*e-r;break;case By:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case Zu:o=t,l=2*r-e;break;case By:o=1,l=r+i[1]-i[0];break;default:o=t-1,l=e}let c=(r-e)*.5,u=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(l-r),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,m=(r-e)/(i-e),p=m*m,g=p*m,y=-d*g+2*d*p-d*m,x=(1+d)*g+(-1.5-2*d)*p+(-.5+d)*m+1,v=(-1-f)*g+(1.5+f)*p+.5*m,b=f*g-f*p;for(let w=0;w!==a;++w)s[w]=y*o[u+w]+x*o[c+w]+v*o[l+w]+b*o[h+w];return s}},Qy=class extends fh{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=(r-e)/(i-e),h=1-u;for(let d=0;d!==a;++d)s[d]=o[c+d]*h+o[l+d]*u;return s}},gw=class extends fh{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t){return this.copySampleValue_(t-1)}},ys=class{constructor(t,e,r,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=_y(e,this.TimeBufferType),this.values=_y(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,r;if(e.toJSON!==this.toJSON)r=e.toJSON(t);else{r={name:t.name,times:_y(t.times,Array),values:_y(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(r.interpolation=i)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new gw(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Qy(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new mw(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Ly:e=this.InterpolantFactoryMethodDiscrete;break;case Ny:e=this.InterpolantFactoryMethodLinear;break;case pS:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ly;case this.InterpolantFactoryMethodLinear:return Ny;case this.InterpolantFactoryMethodSmooth:return pS}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let r=0,i=e.length;r!==i;++r)e[r]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let r=0,i=e.length;r!==i;++r)e[r]*=t}return this}trim(t,e){let r=this.times,i=r.length,s=0,o=i-1;for(;s!==i&&r[s]<t;)++s;for(;o!==-1&&r[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=pl(r,s,o),this.values=pl(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let r=this.times,i=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&C_(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=pl(this.times),e=pl(this.values),r=this.getValueSize(),i=this.getInterpolation()===pS,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=t[a],u=t[a+1];if(c!==u&&(a!==1||c!==t[0]))if(i)l=!0;else{let h=a*r,d=h-r,f=h+r;for(let m=0;m!==r;++m){let p=e[h+m];if(p!==e[d+m]||p!==e[f+m]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*r,d=o*r;for(let f=0;f!==r;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*r,l=o*r,c=0;c!==r;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=pl(t,0,o),this.values=pl(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=pl(this.times,0),e=pl(this.values,0),r=this.constructor,i=new r(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};ys.prototype.TimeBufferType=Float32Array;ys.prototype.ValueBufferType=Float32Array;ys.prototype.DefaultInterpolation=Ny;var El=class extends ys{};El.prototype.ValueTypeName="bool";El.prototype.ValueBufferType=Array;El.prototype.DefaultInterpolation=Ly;El.prototype.InterpolantFactoryMethodLinear=void 0;El.prototype.InterpolantFactoryMethodSmooth=void 0;var Zy=class extends ys{};Zy.prototype.ValueTypeName="color";var ph=class extends ys{};ph.prototype.ValueTypeName="number";var yw=class extends fh{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(i-e),c=t*a;for(let u=c+a;c!==u;c+=4)Ye.slerpFlat(s,0,o,c-a,o,c,l);return s}},Wc=class extends ys{InterpolantFactoryMethodLinear(t){return new yw(this.times,this.values,this.getValueSize(),t)}};Wc.prototype.ValueTypeName="quaternion";Wc.prototype.DefaultInterpolation=Ny;Wc.prototype.InterpolantFactoryMethodSmooth=void 0;var Tl=class extends ys{};Tl.prototype.ValueTypeName="string";Tl.prototype.ValueBufferType=Array;Tl.prototype.DefaultInterpolation=Ly;Tl.prototype.InterpolantFactoryMethodLinear=void 0;Tl.prototype.InterpolantFactoryMethodSmooth=void 0;var mh=class extends ys{};mh.prototype.ValueTypeName="vector";var gh=class{constructor(t,e=-1,r,i=Iw){this.name=t,this.tracks=r,this.duration=e,this.blendMode=i,this.uuid=fs(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,i=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(Cj(r[o]).scale(i));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],r=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=r.length;s!==o;++s)e.push(ys.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(t,e,r,i){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);let u=Tj(l);l=JP(l,1,u),c=JP(c,1,u),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new ph(".morphTargetInfluences["+e[a].name+"]",l,c).scale(1/r))}return new this(t,-1,o)}static findByName(t,e){let r=t;if(!Array.isArray(t)){let i=t;r=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<r.length;i++)if(r[i].name===e)return r[i];return null}static CreateClipsFromMorphTargetSequences(t,e,r){let i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let c=t[a],u=c.name.match(s);if(u&&u.length>1){let h=u[1],d=i[h];d||(i[h]=d=[]),d.push(c)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,r));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let r=function(h,d,f,m,p){if(f.length!==0){let g=[],y=[];P_(f,g,y,m),g.length!==0&&p.push(new h(d,g,y))}},i=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,c=t.hierarchy||[];for(let h=0;h<c.length;h++){let d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},m;for(m=0;m<d.length;m++)if(d[m].morphTargets)for(let p=0;p<d[m].morphTargets.length;p++)f[d[m].morphTargets[p]]=-1;for(let p in f){let g=[],y=[];for(let x=0;x!==d[m].morphTargets.length;++x){let v=d[m];g.push(v.time),y.push(v.morphTarget===p?1:0)}i.push(new ph(".morphTargetInfluence["+p+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(mh,f+".position",d,"pos",i),r(Wc,f+".quaternion",d,"rot",i),r(mh,f+".scale",d,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){let t=this.tracks,e=0;for(let r=0,i=t.length;r!==i;++r){let s=this.tracks[r];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function Mj(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ph;case"vector":case"vector2":case"vector3":case"vector4":return mh;case"color":return Zy;case"quaternion":return Wc;case"bool":case"boolean":return El;case"string":return Tl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function Cj(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Mj(n.type);if(n.times===void 0){let e=[],r=[];P_(n.keys,e,r,"value"),n.times=e,n.values=r}return t.parse!==void 0?t.parse(n):new t(n.name,n.times,n.values,n.interpolation)}var Jy={enabled:!1,files:{},add:function(n,t){this.enabled!==!1&&(this.files[n]=t)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},Yp=class{constructor(t,e,r){let i=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(u){a++,s===!1&&i.onStart!==void 0&&i.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){let h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){let f=c[h],m=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return m}return null}}},Pj=new Yp,Ml=class{constructor(t){this.manager=t!==void 0?t:Pj,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let r=this;return new Promise(function(i,s){r.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},Ea={},vw=class extends Error{constructor(t,e){super(t),this.response=e}},yh=class extends Ml{constructor(t){super(t)}load(t,e,r,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=Jy.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(Ea[t]!==void 0){Ea[t].push({onLoad:e,onProgress:r,onError:i});return}Ea[t]=[],Ea[t].push({onLoad:e,onProgress:r,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=Ea[t],h=c.body.getReader(),d=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=d?parseInt(d):0,m=f!==0,p=0,g=new ReadableStream({start(y){x();function x(){h.read().then(({done:v,value:b})=>{if(v)y.close();else{p+=b.byteLength;let w=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let A=0,T=u.length;A<T;A++){let S=u[A];S.onProgress&&S.onProgress(w)}y.enqueue(b),x()}})}}});return new Response(g)}else throw new vw(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{Jy.add(t,c);let u=Ea[t];delete Ea[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=Ea[t];if(u===void 0)throw this.manager.itemError(t),c;delete Ea[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onError&&f.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var xw=class extends Ml{constructor(t){super(t)}load(t,e,r,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=this,o=Jy.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;let a=Vp("img");function l(){u(),Jy.add(t,this),e&&e(this),s.manager.itemEnd(t)}function c(h){u(),i&&i(h),s.manager.itemError(t),s.manager.itemEnd(t)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}};var $y=class extends Ml{constructor(t){super(t)}load(t,e,r,i){let s=new Zt,o=new xw(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,i),s}},Cl=class extends Dt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ge(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},ev=class extends Cl{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ge(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},jS=new ue,$P=new E,e_=new E,Kp=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new U(512,512),this.map=null,this.mapPass=null,this.matrix=new ue,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new kp,this._frameExtents=new U(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;$P.setFromMatrixPosition(t.matrixWorld),e.position.copy($P),e_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(e_),e.updateMatrixWorld(),jS.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(jS),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(jS)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},bw=class extends Kp{constructor(){super(new si(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=Fp*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},tv=class extends Cl{constructor(t,e,r=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new bw}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},t_=new ue,Pp=new E,HS=new E,Sw=class extends Kp{constructor(){super(new si(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new U(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(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(t,e=0){let r=this.camera,i=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Pp.setFromMatrixPosition(t.matrixWorld),r.position.copy(Pp),HS.copy(r.position),HS.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(HS),r.updateMatrixWorld(),i.makeTranslation(-Pp.x,-Pp.y,-Pp.z),t_.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(t_)}},rv=class extends Cl{constructor(t,e,r=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new Sw}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},ww=class extends Kp{constructor(){super(new bl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},iv=class extends Cl{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.shadow=new ww}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var Qp=class extends Ce{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},vh=class extends Ml{constructor(t){super(t)}load(t,e,r,i){let s=this,o=new yh(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},r,i)}parse(t){let e={},r={};function i(f,m){if(e[m]!==void 0)return e[m];let g=f.interleavedBuffers[m],y=s(f,g.buffer),x=sy(g.type,y),v=new Wy(x,g.stride);return v.uuid=g.uuid,e[m]=v,v}function s(f,m){if(r[m]!==void 0)return r[m];let g=f.arrayBuffers[m],y=new Uint32Array(g).buffer;return r[m]=y,y}let o=t.isInstancedBufferGeometry?new Qp:new Ce,a=t.data.index;if(a!==void 0){let f=sy(a.type,a.array);o.setIndex(new je(f,1))}let l=t.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=i(t.data,m.data);p=new Vc(g,m.itemSize,m.offset,m.normalized)}else{let g=sy(m.type,m.array),y=m.isInstancedBufferAttribute?Mo:je;p=new y(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let c=t.data.morphAttributes;if(c)for(let f in c){let m=c[f],p=[];for(let g=0,y=m.length;g<y;g++){let x=m[g],v;if(x.isInterleavedBufferAttribute){let b=i(t.data,x.data);v=new Vc(b,x.itemSize,x.offset,x.normalized)}else{let b=sy(x.type,x.array);v=new je(b,x.itemSize,x.normalized)}x.name!==void 0&&(v.name=x.name),p.push(v)}o.morphAttributes[f]=p}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,m=h.length;f!==m;++f){let p=h[f];o.addGroup(p.start,p.count,p.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new E;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new ei(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var nv=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=r_(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=r_();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function r_(){return(typeof performance>"u"?Date:performance).now()}var Aw=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let i,s,o;switch(e){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let r=this.buffer,i=this.valueSize,s=t*i+i,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,i=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,i=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(r,i,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(r[l]!==r[l+e]){a.setValue(r,i);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,i=r*this._origIndex;t.getValue(e,i);for(let s=r,o=i;s!==o;++s)e[s]=e[i+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r<e;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[e+r]=this.buffer[t+r]}_select(t,e,r,i,s){if(i>=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,i){Ye.slerpFlat(t,e,t,e,t,r,i)}_slerpAdditive(t,e,r,i,s){let o=this._workIndex*s;Ye.multiplyQuaternionsFlat(t,o,t,e,t,r),Ye.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,r,i,s){let o=1-i;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*i}}_lerpAdditive(t,e,r,i,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*i}}},Bw="\\[\\]\\.:\\/",_j=new RegExp("["+Bw+"]","g"),Fw="[^"+Bw+"]",Ij="[^"+Bw.replace("\\.","")+"]",Dj=/((?:WC+[\/:])*)/.source.replace("WC",Fw),Oj=/(WCOD+)?/.source.replace("WCOD",Ij),Rj=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Fw),Lj=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Fw),Nj=new RegExp("^"+Dj+Oj+Rj+Lj+"$"),Bj=["material","materials","bones","map"],Ew=class{constructor(t,e,r){let i=r||sr.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}},sr=class{constructor(t,e,r){this.path=e,this.parsedPath=r||sr.parseTrackName(e),this.node=sr.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new sr.Composite(t,e,r):new sr(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(_j,"")}static parseTrackName(t){let e=Nj.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=r.nodeName.substring(i+1);Bj.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=r(a.children);if(l)return l}return null},i=r(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)t[e++]=r[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,r=e.objectName,i=e.propertyName,s=e.propertyIndex;if(t||(t=sr.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(r){let c=e.objectIndex;switch(r){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===c){c=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}let o=t[i];if(o===void 0){let c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};sr.Composite=Ew;sr.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};sr.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};sr.prototype.GetterByBindingType=[sr.prototype._getValue_direct,sr.prototype._getValue_array,sr.prototype._getValue_arrayElement,sr.prototype._getValue_toArray];sr.prototype.SetterByBindingTypeAndVersioning=[[sr.prototype._setValue_direct,sr.prototype._setValue_direct_setNeedsUpdate,sr.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[sr.prototype._setValue_array,sr.prototype._setValue_array_setNeedsUpdate,sr.prototype._setValue_array_setMatrixWorldNeedsUpdate],[sr.prototype._setValue_arrayElement,sr.prototype._setValue_arrayElement_setNeedsUpdate,sr.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[sr.prototype._setValue_fromArray,sr.prototype._setValue_fromArray_setNeedsUpdate,sr.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Tw=class{constructor(t,e,r=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=i;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Qu,endingEnd:Qu};for(let c=0;c!==o;++c){let u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=_w,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){let i=this._clip.duration,s=t._clip.duration,o=s/i,a=i/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){let i=this._mixer,s=i.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+r,c[0]=t/o,c[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,i){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*r;l<0||r===0?e=0:(this._startTime=null,e=r*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case KU:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Iw:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,r=this.loop,i=this.time+t,s=this._loopCount,o=r===$p;if(t===0)return s===-1?i:o&&(s&1)===1?e-i:i;if(r===Pw){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=e||i<0){let a=Math.floor(i/e);i-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return e-i}return i}_setEndings(t,e,r){let i=this._interpolantSettings;r?(i.endingStart=Zu,i.endingEnd=Zu):(t?i.endingStart=this.zeroSlopeAtStart?Zu:Qu:i.endingStart=By,e?i.endingEnd=this.zeroSlopeAtEnd?Zu:Qu:i.endingEnd=By)}_scheduleFading(t,e,r){let i=this._mixer,s=i.time,o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=r,this}},Fj=new Float32Array(1),sv=class extends ar{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let r=t._localRoot||this._root,i=t._clip.tracks,s=i.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){let d=i[h],f=d.name,m=u[f];if(m!==void 0)++m.referenceCount,o[h]=m;else{if(m=o[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}let p=e&&e._propertyBindings[h].binding.parsedPath;m=new Aw(sr.create(r,f,p),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),o[h]=m}a[h].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let r=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,r)}let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,r){let i=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=i.length,i.push(t),o.actionByRoot[r]=t}_removeInactiveAction(t){let e=this._actions,r=e[e.length-1],i=t._cacheIndex;r._cacheIndex=i,e[i]=r,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=t._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,r=t._cacheIndex,i=this._nActiveActions++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_takeBackAction(t){let e=this._actions,r=t._cacheIndex,i=--this._nActiveActions,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_addInactiveBinding(t,e,r){let i=this._bindingsByRootAndName,s=this._bindings,o=i[e];o===void 0&&(o={},i[e]=o),o[r]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,r=t.binding,i=r.rootNode.uuid,s=r.path,o=this._bindingsByRootAndName,a=o[i],l=e[e.length-1],c=t._cacheIndex;l._cacheIndex=c,e[c]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[i]}_lendBinding(t){let e=this._bindings,r=t._cacheIndex,i=this._nActiveBindings++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_takeBackBinding(t){let e=this._bindings,r=t._cacheIndex,i=--this._nActiveBindings,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,r=t[e];return r===void 0&&(r=new Qy(new Float32Array(2),new Float32Array(2),1,Fj),r.__cacheIndex=e,t[e]=r),r}_takeBackControlInterpolant(t){let e=this._controlInterpolants,r=t.__cacheIndex,i=--this._nActiveControlInterpolants,s=e[i];t.__cacheIndex=i,e[i]=t,s.__cacheIndex=r,e[r]=s}clipAction(t,e,r){let i=e||this._root,s=i.uuid,o=typeof t=="string"?gh.findByName(i,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],c=null;if(r===void 0&&(o!==null?r=o.blendMode:r=Iw),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===r)return h;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;let u=new Tw(this,o,e,r);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(t,e){let r=e||this._root,i=r.uuid,s=typeof t=="string"?gh.findByName(r,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let r=e-1;r>=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,i=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let c=0;c!==r;++c)e[c]._update(i,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,r=t.uuid,i=this._actionsByClip,s=i[r];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let c=o[a];this._deactivateAction(c);let u=c._cacheIndex,h=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,e[u]=h,e.pop(),this._removeInactiveBindingsForAction(c)}delete i[r]}}uncacheRoot(t){let e=t.uuid,r=this._actionsByClip;for(let o in r){let a=r[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let i=this._bindingsByRootAndName,s=i[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let r=this.existingAction(t,e);r!==null&&(this._deactivateAction(r),this._removeInactiveAction(r))}},ce=class{constructor(t){this.value=t}clone(){return new ce(this.value.clone===void 0?this.value:this.value.clone())}};var xh=class{constructor(t,e,r=0,i=1/0){this.ray=new Ws(t,e),this.near=r,this.far=i,this.camera=null,this.layers=new Up,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,r=[]){return Mw(t,this,r,e),r.sort(i_),r}intersectObjects(t,e=!0,r=[]){for(let i=0,s=t.length;i<s;i++)Mw(t[i],this,r,e);return r.sort(i_),r}};function i_(n,t){return n.distance-t.distance}function Mw(n,t,e,r){if(n.layers.test(t.layers)&&n.raycast(t,e),r===!0){let i=n.children;for(let s=0,o=i.length;s<o;s++)Mw(i[s],t,e,!0)}}var Zp=class{constructor(t=1,e=0,r=0){return this.radius=t,this.phi=e,this.theta=r,this}set(t,e,r){return this.radius=t,this.phi=e,this.theta=r,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,r){return this.radius=Math.sqrt(t*t+e*e+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,r),this.phi=Math.acos(yi(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var n_=new U,Pl=class{constructor(t=new U(1/0,1/0),e=new U(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=n_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return n_.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},s_=new E,Iy=new E,Di=class{constructor(t=new E,e=new E){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){s_.subVectors(t,this.start),Iy.subVectors(this.end,this.start);let r=Iy.dot(Iy),s=Iy.dot(s_)/r;return e&&(s=yi(s,0,1)),s}closestPointToPoint(t,e,r){let i=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},o_=new E,ov=class extends Dt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new Ce,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,u=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}r.setAttribute("position",new Te(i,3));let s=new ms({fog:!1,toneMapped:!1});this.cone=new wl(r,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 t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),o_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(o_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var av=class extends Mt{constructor(t,e,r){let i=new qs(e,4,2),s=new un({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=t,this.color=r,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)}};var a_=new E,Dy=new E,l_=new E,lv=class extends Dt{constructor(t,e,r){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new Ce;i.setAttribute("position",new Te([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new ms({fog:!1,toneMapped:!1});this.lightPlane=new Uc(i,s),this.add(this.lightPlane),i=new Ce,i.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Uc(i,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),a_.setFromMatrixPosition(this.light.matrixWorld),Dy.setFromMatrixPosition(this.light.target.matrixWorld),l_.subVectors(Dy,a_),this.lightPlane.lookAt(Dy),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(Dy),this.targetLine.scale.z=l_.length()}},Oy=new E,$r=new bn,_l=class extends wl{constructor(t){let e=new Ce,r=new ms({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){i.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}e.setAttribute("position",new Te(i,3)),e.setAttribute("color",new Te(s,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let c=new Ge(16755200),u=new Ge(16711680),h=new Ge(43775),d=new Ge(16777215),f=new Ge(3355443);this.setColors(c,u,h,d,f)}setColors(t,e,r,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,r.r,r.g,r.b),a.setXYZ(33,r.r,r.g,r.b),a.setXYZ(34,r.r,r.g,r.b),a.setXYZ(35,r.r,r.g,r.b),a.setXYZ(36,r.r,r.g,r.b),a.setXYZ(37,r.r,r.g,r.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.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 t=this.geometry,e=this.pointMap,r=1,i=1;$r.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ni("c",e,t,$r,0,0,-1),ni("t",e,t,$r,0,0,1),ni("n1",e,t,$r,-r,-i,-1),ni("n2",e,t,$r,r,-i,-1),ni("n3",e,t,$r,-r,i,-1),ni("n4",e,t,$r,r,i,-1),ni("f1",e,t,$r,-r,-i,1),ni("f2",e,t,$r,r,-i,1),ni("f3",e,t,$r,-r,i,1),ni("f4",e,t,$r,r,i,1),ni("u1",e,t,$r,r*.7,i*1.1,-1),ni("u2",e,t,$r,-r*.7,i*1.1,-1),ni("u3",e,t,$r,0,i*2,-1),ni("cf1",e,t,$r,-r,0,1),ni("cf2",e,t,$r,r,0,1),ni("cf3",e,t,$r,0,-i,1),ni("cf4",e,t,$r,0,i,1),ni("cn1",e,t,$r,-r,0,-1),ni("cn2",e,t,$r,r,0,-1),ni("cn3",e,t,$r,0,-i,-1),ni("cn4",e,t,$r,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ni(n,t,e,r,i,s,o){Oy.set(i,s,o).unproject(r);let a=t[n];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],Oy.x,Oy.y,Oy.z)}}var Il=class extends wl{constructor(t,e=16776960){let r=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]),i=[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 Ce;s.setIndex(new je(r,1)),s.setAttribute("position",new Te(i,3)),super(s,new ms({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var cv=class extends wl{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Ce;i.setAttribute("position",new Te(e,3)),i.setAttribute("color",new Te(r,3));let s=new ms({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,r){let i=new Ge,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var Ta=Vj();function Vj(){let n=new ArrayBuffer(4),t=new Float32Array(n),e=new Uint32Array(n),r=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){let c=l-127;c<-27?(r[l]=0,r[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(r[l]=1024>>-c-14,r[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(r[l]=c+15<<10,r[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(r[l]=31744,r[l|256]=64512,i[l]=24,i[l|256]=24):(r[l]=31744,r[l|256]=64512,i[l]=13,i[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:t,uint32View:e,baseTable:r,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}function Uj(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=yi(n,-65504,65504),Ta.floatView[0]=n;let t=Ta.uint32View[0],e=t>>23&511;return Ta.baseTable[e]+((t&8388607)>>Ta.shiftTable[e])}function kj(n){let t=n>>10;return Ta.uint32View[0]=Ta.mantissaTable[Ta.offsetTable[t]+(n&1023)]+Ta.exponentTable[t],Ta.floatView[0]}var __=Object.freeze({__proto__:null,fromHalfFloat:kj,toHalfFloat:Uj});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Pa}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Pa);var Ah=".",em=Symbol("target"),Vw=Symbol("unsubscribe");function tm(n){return n instanceof Date||n instanceof Set||n instanceof Map||n instanceof WeakSet||n instanceof WeakMap||ArrayBuffer.isView(n)}function I_(n){return(typeof n=="object"?n===null:typeof n!="function")||n instanceof RegExp}var rs=Array.isArray;function qc(n){return typeof n=="symbol"}var zj={after:(n,t)=>rs(n)?n.slice(t.length):t===""?n:n.slice(t.length+1),concat:(n,t)=>rs(n)?(n=[...n],t&&n.push(t),n):t&&t.toString!==void 0?(n!==""&&(n+=Ah),qc(t)?n+t.toString():n+t):n,initial:n=>{if(rs(n))return n.slice(0,-1);if(n==="")return n;let t=n.lastIndexOf(Ah);return t===-1?"":n.slice(0,t)},last:n=>{if(rs(n))return n[n.length-1]||"";if(n==="")return n;let t=n.lastIndexOf(Ah);return t===-1?n:n.slice(t+1)},walk:(n,t)=>{if(rs(n))for(let e of n)t(e);else if(n!==""){let e=0,r=n.indexOf(Ah);if(r===-1)t(n);else for(;e<n.length;)r===-1&&(r=n.length),t(n.slice(e,r)),e=r+1,r=n.indexOf(Ah,e)}},get(n,t){return this.walk(t,e=>{n&&(n=n[e])}),n}},Sn=zj;function Uw(n){return typeof n=="object"&&typeof n.next=="function"}function kw(n,t,e,r,i){let s=n.next;if(t.name==="entries")n.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],t,o.value[0],r),o.value[1]=i(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[em].keys();n.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,t,o.next().value,r)),a}}else n.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,t,o.value,r)),o};return n}function fv(n,t,e){return n.isUnsubscribed||t.ignoreSymbols&&qc(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var rm=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),r=e.get(t);return r===void 0&&(r={},e.set(t,r)),r}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let r=this._getProperties(t),i=r[e];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(t,e),r[e]=i),i}getProxy(t,e,r,i){if(this.isUnsubscribed)return t;let s=t[i],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,r):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,Sn.get(e,this.getPath(t)))}defineProperty(t,e,r){return Reflect.defineProperty(t,e,r)?(this.isUnsubscribed||(this._getProperties(t)[e]=r),!0):!1}setProperty(t,e,r,i,s){if(!this._equals(s,r)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,r,i):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(t);i&&(delete i[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let i=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&i!==void 0&&Object.is(t.value,i.value)&&(t.writable||!1)===(i.writable||!1)&&(t.enumerable||!1)===(i.enumerable||!1)&&(t.configurable||!1)===(i.configurable||!1)&&t.get===i.get&&t.set===i.set}isGetInvariant(t,e){let r=this._getOwnPropertyDescriptor(t,e);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Eh(n){return toString.call(n)==="[object Object]"}function Th(){return!0}function Dl(n,t){return n.length!==t.length||n.some((e,r)=>t[r]!==e)}var pv=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var Gj=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),zw={push:Th,pop:Th,shift:Th,unshift:Th,copyWithin:Dl,reverse:Dl,sort:Dl,splice:Dl,flat:Dl,fill:Dl},D_=new Set([...pv,...Gj,...Object.keys(zw)]);function Mh(n,t){if(n.size!==t.size)return!0;for(let e of n)if(!t.has(e))return!0;return!1}var Gw=["keys","values","entries"],jw=new Set(["has","toString"]),Hw={add:Mh,clear:Mh,delete:Mh,forEach:Mh},O_=new Set([...jw,...Object.keys(Hw),...Gw]);function Ch(n,t){if(n.size!==t.size)return!0;let e;for(let[r,i]of n)if(e=t.get(r),e!==i||e===void 0&&!t.has(r))return!0;return!1}var jj=new Set([...jw,"get"]),Ww={set:Ch,clear:Ch,delete:Ch,forEach:Ch},R_=new Set([...jj,...Object.keys(Ww),...Gw]);var Gi=class{constructor(t,e,r,i){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return pv.has(t)}_shallowClone(t){let e=t;if(Eh(t))e={...t};else if(rs(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(r=>this._shallowClone(r)));else if(t instanceof Map){e=new Map;for(let[r,i]of t.entries())e.set(r,this._shallowClone(i))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,i){return t?(rs(i)?this._onIsChanged=zw[e]:i instanceof Set?this._onIsChanged=Hw[e]:i instanceof Map&&(this._onIsChanged=Ww[e]),i):r}update(t,e,r){let i=Sn.after(t,this._path);if(e!=="length"){let s=this.clone;Sn.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:e,previous:r}),s&&s[e]&&(s[e]=r)}this._isChanged=!0}undo(t){let e;for(let r=this._changes.length-1;r!==-1;r--)e=this._changes[r],Sn.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Ph=class extends Gi{static isHandledMethod(t){return D_.has(t)}};var im=class extends Gi{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var _h=class extends Gi{static isHandledMethod(t){return O_.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var Ih=class extends Gi{static isHandledMethod(t){return R_.has(t)}undo(t){for(let[e,r]of this.clone.entries())t.set(e,r);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var nm=class extends Gi{constructor(t,e,r,i){super(void 0,e,r,i),this._arg1=r[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var sm=class extends Gi{constructor(t,e,r,i){super(void 0,e,r,i),this._weakKey=r[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Ys=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return Eh(t)||rs(t)||tm(t)}static isHandledMethod(t,e){return Eh(t)?Gi.isHandledMethod(e):rs(t)?Ph.isHandledMethod(e):t instanceof Set?_h.isHandledMethod(e):t instanceof Map?Ih.isHandledMethod(e):tm(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let i=Gi;rs(t)?i=Ph:t instanceof Date?i=im:t instanceof Set?i=_h:t instanceof Map?i=Ih:t instanceof WeakSet?i=nm:t instanceof WeakMap&&(i=sm),this._stack.push(new i(t,e,r,this._hasOnValidate))}update(t,e,r){this._stack[this._stack.length-1].update(t,e,r)}preferredThisArg(t,e,r){let{name:i}=t,s=Ys.isHandledMethod(r,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,e,r)}isChanged(t,e,r){return this._stack[this._stack.length-1].isChanged(t,e,r)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var Hj={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},qw=(n,t,e={})=>{e={...Hj,...e};let r=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new rm(i),c=typeof e.onValidate=="function",u=new Ys(c),h=(x,v,b,w,A)=>!c||u.isCloning||e.onValidate(Sn.concat(l.getPath(x),v),b,w,A)===!0,d=(x,v,b,w)=>{!fv(l,e,v)&&!(o&&l.isDetached(x,n))&&f(l.getPath(x),v,b,w)},f=(x,v,b,w,A)=>{u.isCloning?u.update(x,v,w):t(Sn.concat(x,v),b,w,A)},m=x=>x&&(x[r]||x),p=(x,v,b,w)=>I_(x)||b==="constructor"||s&&!Ys.isHandledMethod(v,b)||fv(l,e,b)||l.isGetInvariant(v,b)||o&&l.isDetached(v,n)?x:(w===void 0&&(w=l.getPath(v)),l.getProxy(x,Sn.concat(w,b),g,r)),g={get(x,v,b){if(qc(v)){if(v===r||v===em)return x;if(v===Vw&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let w=tm(x)?Reflect.get(x,v):Reflect.get(x,v,b);return p(w,x,v)},set(x,v,b,w){b=m(b);let A=x[r]||x,T=A[v];if(i(T,b)&&v in x)return!0;let S=h(x,v,b,T);return S&&l.setProperty(A,v,b,w,T)?(d(x,v,x[v],T),!0):!S},defineProperty(x,v,b){if(!l.isSameDescriptor(b,x,v)){let w=x[v];h(x,v,b.value,w)&&l.defineProperty(x,v,b,w)&&d(x,v,b.value,w)}return!0},deleteProperty(x,v){if(!Reflect.has(x,v))return!0;let b=Reflect.get(x,v),w=h(x,v,void 0,b);return w&&l.deleteProperty(x,v,b)?(d(x,v,void 0,b),!0):!w},apply(x,v,b){let w=v[r]||v;if(l.isUnsubscribed)return Reflect.apply(x,w,b);if((a===!1||a!==!0&&!a.includes(x.name))&&Ys.isHandledType(w)){let A=Sn.initial(l.getPath(x)),T=Ys.isHandledMethod(w,x.name);u.start(w,A,b);let S=Reflect.apply(x,u.preferredThisArg(x,v,w),T?b.map(P=>m(P)):b),M=u.isChanged(w,i),C=u.stop();if(Ys.isHandledType(S)&&T&&(v instanceof Map&&x.name==="get"&&(A=Sn.concat(A,b[0])),S=l.getProxy(S,A,g)),M){let P={name:x.name,args:b,result:S},_=u.isCloning?Sn.initial(A):A,I=u.isCloning?Sn.last(A):"";h(Sn.get(n,_),I,w,C,P)?f(_,I,w,C,P):u.undo(w)}return(v instanceof Map||v instanceof Set)&&Uw(S)?kw(S,x,v,A,p):S}return Reflect.apply(x,v,b)}},y=l.getProxy(n,e.pathAsArray?[]:"",g);return t=t.bind(y),c&&(e.onValidate=e.onValidate.bind(y)),y};qw.target=n=>n&&n[em]||n;qw.unsubscribe=n=>n[Vw]||n;var Xw=qw;var Wj=typeof global=="object"&&global&&global.Object===Object&&global,mv=Wj;var qj=typeof self=="object"&&self&&self.Object===Object&&self,Xj=mv||qj||Function("return this")(),ti=Xj;var Yj=ti.Symbol,ji=Yj;var L_=Object.prototype,Kj=L_.hasOwnProperty,Qj=L_.toString,om=ji?ji.toStringTag:void 0;function Zj(n){var t=Kj.call(n,om),e=n[om];try{n[om]=void 0;var r=!0}catch{}var i=Qj.call(n);return r&&(t?n[om]=e:delete n[om]),i}var N_=Zj;var Jj=Object.prototype,$j=Jj.toString;function eH(n){return $j.call(n)}var B_=eH;var tH="[object Null]",rH="[object Undefined]",F_=ji?ji.toStringTag:void 0;function iH(n){return n==null?n===void 0?rH:tH:F_&&F_ in Object(n)?N_(n):B_(n)}var is=iH;function nH(n){return n!=null&&typeof n=="object"}var Zi=nH;var sH="[object Symbol]";function oH(n){return typeof n=="symbol"||Zi(n)&&is(n)==sH}var Co=oH;function aH(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var gv=aH;var lH=Array.isArray,Oi=lH;var cH=1/0,V_=ji?ji.prototype:void 0,U_=V_?V_.toString:void 0;function k_(n){if(typeof n=="string")return n;if(Oi(n))return gv(n,k_)+"";if(Co(n))return U_?U_.call(n):"";var t=n+"";return t=="0"&&1/n==-cH?"-0":t}var yv=k_;var uH=/\s/;function hH(n){for(var t=n.length;t--&&uH.test(n.charAt(t)););return t}var vv=hH;var dH=/^\s+/;function fH(n){return n&&n.slice(0,vv(n)+1).replace(dH,"")}var z_=fH;function pH(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var kr=pH;var G_=0/0,mH=/^[-+]0x[0-9a-f]+$/i,gH=/^0b[01]+$/i,yH=/^0o[0-7]+$/i,vH=parseInt;function xH(n){if(typeof n=="number")return n;if(Co(n))return G_;if(kr(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=kr(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=z_(n);var e=gH.test(n);return e||yH.test(n)?vH(n.slice(2),e?2:8):mH.test(n)?G_:+n}var Yw=xH;function bH(n){return n}var xv=bH;var SH="[object AsyncFunction]",wH="[object Function]",AH="[object GeneratorFunction]",EH="[object Proxy]";function TH(n){if(!kr(n))return!1;var t=is(n);return t==wH||t==AH||t==SH||t==EH}var bv=TH;var MH=ti["__core-js_shared__"],Sv=MH;var j_=function(){var n=/[^.]+$/.exec(Sv&&Sv.keys&&Sv.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function CH(n){return!!j_&&j_ in n}var H_=CH;var PH=Function.prototype,_H=PH.toString;function IH(n){if(n!=null){try{return _H.call(n)}catch{}try{return n+""}catch{}}return""}var _a=IH;var DH=/[\\^$.*+?()[\]{}|]/g,OH=/^\[object .+?Constructor\]$/,RH=Function.prototype,LH=Object.prototype,NH=RH.toString,BH=LH.hasOwnProperty,FH=RegExp("^"+NH.call(BH).replace(DH,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function VH(n){if(!kr(n)||H_(n))return!1;var t=bv(n)?FH:OH;return t.test(_a(n))}var W_=VH;function UH(n,t){return n?.[t]}var q_=UH;function kH(n,t){var e=q_(n,t);return W_(e)?e:void 0}var Ln=kH;var zH=Ln(ti,"WeakMap"),wv=zH;var X_=Object.create,GH=function(){function n(){}return function(t){if(!kr(t))return{};if(X_)return X_(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),Y_=GH;function jH(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var K_=jH;function HH(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var Q_=HH;var WH=800,qH=16,XH=Date.now;function YH(n){var t=0,e=0;return function(){var r=XH(),i=qH-(r-e);if(e=r,i>0){if(++t>=WH)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var Z_=YH;function KH(n){return function(){return n}}var J_=KH;var QH=function(){try{var n=Ln(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Dh=QH;var ZH=Dh?function(n,t){return Dh(n,"toString",{configurable:!0,enumerable:!1,value:J_(t),writable:!0})}:xv,$_=ZH;var JH=Z_($_),e2=JH;function $H(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var t2=$H;function eW(n,t,e,r){for(var i=n.length,s=e+(r?1:-1);r?s--:++s<i;)if(t(n[s],s,n))return s;return-1}var r2=eW;function tW(n){return n!==n}var i2=tW;function rW(n,t,e){for(var r=e-1,i=n.length;++r<i;)if(n[r]===t)return r;return-1}var n2=rW;function iW(n,t,e){return t===t?n2(n,t,e):r2(n,i2,e)}var s2=iW;var nW=9007199254740991,sW=/^(?:0|[1-9]\d*)$/;function oW(n,t){var e=typeof n;return t=t??nW,!!t&&(e=="number"||e!="symbol"&&sW.test(n))&&n>-1&&n%1==0&&n<t}var Oh=oW;function aW(n,t,e){t=="__proto__"&&Dh?Dh(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Av=aW;function lW(n,t){return n===t||n!==n&&t!==t}var Rh=lW;var cW=Object.prototype,uW=cW.hasOwnProperty;function hW(n,t,e){var r=n[t];(!(uW.call(n,t)&&Rh(r,e))||e===void 0&&!(t in n))&&Av(n,t,e)}var Lh=hW;function dW(n,t,e,r){var i=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=r?r(e[a],n[a],a,e,n):void 0;l===void 0&&(l=n[a]),i?Av(e,a,l):Lh(e,a,l)}return e}var Po=dW;var o2=Math.max;function fW(n,t,e){return t=o2(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,s=o2(r.length-t,0),o=Array(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=e(o),K_(n,this,a)}}var a2=fW;var pW=9007199254740991;function mW(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=pW}var Nh=mW;function gW(n){return n!=null&&Nh(n.length)&&!bv(n)}var Ev=gW;var yW=Object.prototype;function vW(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||yW;return n===e}var Bh=vW;function xW(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var l2=xW;var bW="[object Arguments]";function SW(n){return Zi(n)&&is(n)==bW}var Kw=SW;var c2=Object.prototype,wW=c2.hasOwnProperty,AW=c2.propertyIsEnumerable,EW=Kw(function(){return arguments}())?Kw:function(n){return Zi(n)&&wW.call(n,"callee")&&!AW.call(n,"callee")},Fh=EW;function TW(){return!1}var u2=TW;var f2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,h2=f2&&typeof module=="object"&&module&&!module.nodeType&&module,MW=h2&&h2.exports===f2,d2=MW?ti.Buffer:void 0,CW=d2?d2.isBuffer:void 0,PW=CW||u2,Xc=PW;var _W="[object Arguments]",IW="[object Array]",DW="[object Boolean]",OW="[object Date]",RW="[object Error]",LW="[object Function]",NW="[object Map]",BW="[object Number]",FW="[object Object]",VW="[object RegExp]",UW="[object Set]",kW="[object String]",zW="[object WeakMap]",GW="[object ArrayBuffer]",jW="[object DataView]",HW="[object Float32Array]",WW="[object Float64Array]",qW="[object Int8Array]",XW="[object Int16Array]",YW="[object Int32Array]",KW="[object Uint8Array]",QW="[object Uint8ClampedArray]",ZW="[object Uint16Array]",JW="[object Uint32Array]",Br={};Br[HW]=Br[WW]=Br[qW]=Br[XW]=Br[YW]=Br[KW]=Br[QW]=Br[ZW]=Br[JW]=!0;Br[_W]=Br[IW]=Br[GW]=Br[DW]=Br[jW]=Br[OW]=Br[RW]=Br[LW]=Br[NW]=Br[BW]=Br[FW]=Br[VW]=Br[UW]=Br[kW]=Br[zW]=!1;function $W(n){return Zi(n)&&Nh(n.length)&&!!Br[is(n)]}var p2=$W;function e6(n){return function(t){return n(t)}}var Vh=e6;var m2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,am=m2&&typeof module=="object"&&module&&!module.nodeType&&module,t6=am&&am.exports===m2,Qw=t6&&mv.process,r6=function(){try{var n=am&&am.require&&am.require("util").types;return n||Qw&&Qw.binding&&Qw.binding("util")}catch{}}(),Ia=r6;var g2=Ia&&Ia.isTypedArray,i6=g2?Vh(g2):p2,Tv=i6;var n6=Object.prototype,s6=n6.hasOwnProperty;function o6(n,t){var e=Oi(n),r=!e&&Fh(n),i=!e&&!r&&Xc(n),s=!e&&!r&&!i&&Tv(n),o=e||r||i||s,a=o?l2(n.length,String):[],l=a.length;for(var c in n)(t||s6.call(n,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Oh(c,l)))&&a.push(c);return a}var Mv=o6;function a6(n,t){return function(e){return n(t(e))}}var Cv=a6;var l6=Cv(Object.keys,Object),y2=l6;var c6=Object.prototype,u6=c6.hasOwnProperty;function h6(n){if(!Bh(n))return y2(n);var t=[];for(var e in Object(n))u6.call(n,e)&&e!="constructor"&&t.push(e);return t}var v2=h6;function d6(n){return Ev(n)?Mv(n):v2(n)}var Uh=d6;function f6(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var x2=f6;var p6=Object.prototype,m6=p6.hasOwnProperty;function g6(n){if(!kr(n))return x2(n);var t=Bh(n),e=[];for(var r in n)r=="constructor"&&(t||!m6.call(n,r))||e.push(r);return e}var b2=g6;function y6(n){return Ev(n)?Mv(n,!0):b2(n)}var vs=y6;var v6=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,x6=/^\w*$/;function b6(n,t){if(Oi(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Co(n)?!0:x6.test(n)||!v6.test(n)||t!=null&&n in Object(t)}var S2=b6;var S6=Ln(Object,"create"),Da=S6;function w6(){this.__data__=Da?Da(null):{},this.size=0}var w2=w6;function A6(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var A2=A6;var E6="__lodash_hash_undefined__",T6=Object.prototype,M6=T6.hasOwnProperty;function C6(n){var t=this.__data__;if(Da){var e=t[n];return e===E6?void 0:e}return M6.call(t,n)?t[n]:void 0}var E2=C6;var P6=Object.prototype,_6=P6.hasOwnProperty;function I6(n){var t=this.__data__;return Da?t[n]!==void 0:_6.call(t,n)}var T2=I6;var D6="__lodash_hash_undefined__";function O6(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Da&&t===void 0?D6:t,this}var M2=O6;function kh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}kh.prototype.clear=w2;kh.prototype.delete=A2;kh.prototype.get=E2;kh.prototype.has=T2;kh.prototype.set=M2;var Zw=kh;function R6(){this.__data__=[],this.size=0}var C2=R6;function L6(n,t){for(var e=n.length;e--;)if(Rh(n[e][0],t))return e;return-1}var Ol=L6;var N6=Array.prototype,B6=N6.splice;function F6(n){var t=this.__data__,e=Ol(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():B6.call(t,e,1),--this.size,!0}var P2=F6;function V6(n){var t=this.__data__,e=Ol(t,n);return e<0?void 0:t[e][1]}var _2=V6;function U6(n){return Ol(this.__data__,n)>-1}var I2=U6;function k6(n,t){var e=this.__data__,r=Ol(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var D2=k6;function zh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}zh.prototype.clear=C2;zh.prototype.delete=P2;zh.prototype.get=_2;zh.prototype.has=I2;zh.prototype.set=D2;var Rl=zh;var z6=Ln(ti,"Map"),Ll=z6;function G6(){this.size=0,this.__data__={hash:new Zw,map:new(Ll||Rl),string:new Zw}}var O2=G6;function j6(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var R2=j6;function H6(n,t){var e=n.__data__;return R2(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Nl=H6;function W6(n){var t=Nl(this,n).delete(n);return this.size-=t?1:0,t}var L2=W6;function q6(n){return Nl(this,n).get(n)}var N2=q6;function X6(n){return Nl(this,n).has(n)}var B2=X6;function Y6(n,t){var e=Nl(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var F2=Y6;function Gh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Gh.prototype.clear=O2;Gh.prototype.delete=L2;Gh.prototype.get=N2;Gh.prototype.has=B2;Gh.prototype.set=F2;var Yc=Gh;var K6="Expected a function";function Jw(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(K6);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],s=e.cache;if(s.has(i))return s.get(i);var o=n.apply(this,r);return e.cache=s.set(i,o)||s,o};return e.cache=new(Jw.Cache||Yc),e}Jw.Cache=Yc;var V2=Jw;var Q6=500;function Z6(n){var t=V2(n,function(r){return e.size===Q6&&e.clear(),r}),e=t.cache;return t}var U2=Z6;var J6=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$6=/\\(\\)?/g,e8=U2(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(J6,function(e,r,i,s){t.push(i?s.replace($6,"$1"):r||e)}),t}),k2=e8;function t8(n){return n==null?"":yv(n)}var Pv=t8;function r8(n,t){return Oi(n)?n:S2(n,t)?[n]:k2(Pv(n))}var xs=r8;var i8=1/0;function n8(n){if(typeof n=="string"||Co(n))return n;var t=n+"";return t=="0"&&1/n==-i8?"-0":t}var Bl=n8;function s8(n,t){t=xs(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[Bl(t[e++])];return e&&e==r?n:void 0}var _v=s8;function o8(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var jh=o8;var z2=ji?ji.isConcatSpreadable:void 0;function a8(n){return Oi(n)||Fh(n)||!!(z2&&n&&n[z2])}var G2=a8;function j2(n,t,e,r,i){var s=-1,o=n.length;for(e||(e=G2),i||(i=[]);++s<o;){var a=n[s];t>0&&e(a)?t>1?j2(a,t-1,e,r,i):jh(i,a):r||(i[i.length]=a)}return i}var H2=j2;function l8(n){var t=n==null?0:n.length;return t?H2(n,1):[]}var W2=l8;function c8(n){return e2(a2(n,void 0,W2),n+"")}var Iv=c8;var u8=Cv(Object.getPrototypeOf,Object),Hh=u8;var h8="[object Object]",d8=Function.prototype,f8=Object.prototype,q2=d8.toString,p8=f8.hasOwnProperty,m8=q2.call(Object);function g8(n){if(!Zi(n)||is(n)!=h8)return!1;var t=Hh(n);if(t===null)return!0;var e=p8.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&q2.call(e)==m8}var X2=g8;function y8(n,t,e){var r=-1,i=n.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(i);++r<i;)s[r]=n[r+t];return s}var Dv=y8;function v8(n,t,e){var r=n.length;return e=e===void 0?r:e,!t&&e>=r?n:Dv(n,t,e)}var Y2=v8;var x8="\\ud800-\\udfff",b8="\\u0300-\\u036f",S8="\\ufe20-\\ufe2f",w8="\\u20d0-\\u20ff",A8=b8+S8+w8,E8="\\ufe0e\\ufe0f",T8="\\u200d",M8=RegExp("["+T8+x8+A8+E8+"]");function C8(n){return M8.test(n)}var K2=C8;function P8(n){return n.split("")}var Q2=P8;var Z2="\\ud800-\\udfff",_8="\\u0300-\\u036f",I8="\\ufe20-\\ufe2f",D8="\\u20d0-\\u20ff",O8=_8+I8+D8,R8="\\ufe0e\\ufe0f",L8="["+Z2+"]",$w="["+O8+"]",eA="\\ud83c[\\udffb-\\udfff]",N8="(?:"+$w+"|"+eA+")",J2="[^"+Z2+"]",$2="(?:\\ud83c[\\udde6-\\uddff]){2}",eI="[\\ud800-\\udbff][\\udc00-\\udfff]",B8="\\u200d",tI=N8+"?",rI="["+R8+"]?",F8="(?:"+B8+"(?:"+[J2,$2,eI].join("|")+")"+rI+tI+")*",V8=rI+tI+F8,U8="(?:"+[J2+$w+"?",$w,$2,eI,L8].join("|")+")",k8=RegExp(eA+"(?="+eA+")|"+U8+V8,"g");function z8(n){return n.match(k8)||[]}var iI=z8;function G8(n){return K2(n)?iI(n):Q2(n)}var tA=G8;function j8(){this.__data__=new Rl,this.size=0}var nI=j8;function H8(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var sI=H8;function W8(n){return this.__data__.get(n)}var oI=W8;function q8(n){return this.__data__.has(n)}var aI=q8;var X8=200;function Y8(n,t){var e=this.__data__;if(e instanceof Rl){var r=e.__data__;if(!Ll||r.length<X8-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Yc(r)}return e.set(n,t),this.size=e.size,this}var lI=Y8;function Wh(n){var t=this.__data__=new Rl(n);this.size=t.size}Wh.prototype.clear=nI;Wh.prototype.delete=sI;Wh.prototype.get=oI;Wh.prototype.has=aI;Wh.prototype.set=lI;var qh=Wh;function K8(n,t){return n&&Po(t,Uh(t),n)}var cI=K8;function Q8(n,t){return n&&Po(t,vs(t),n)}var uI=Q8;var pI=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hI=pI&&typeof module=="object"&&module&&!module.nodeType&&module,Z8=hI&&hI.exports===pI,dI=Z8?ti.Buffer:void 0,fI=dI?dI.allocUnsafe:void 0;function J8(n,t){if(t)return n.slice();var e=n.length,r=fI?fI(e):new n.constructor(e);return n.copy(r),r}var mI=J8;function $8(n,t){for(var e=-1,r=n==null?0:n.length,i=0,s=[];++e<r;){var o=n[e];t(o,e,n)&&(s[i++]=o)}return s}var gI=$8;function e9(){return[]}var Ov=e9;var t9=Object.prototype,r9=t9.propertyIsEnumerable,yI=Object.getOwnPropertySymbols,i9=yI?function(n){return n==null?[]:(n=Object(n),gI(yI(n),function(t){return r9.call(n,t)}))}:Ov,Xh=i9;function n9(n,t){return Po(n,Xh(n),t)}var vI=n9;var s9=Object.getOwnPropertySymbols,o9=s9?function(n){for(var t=[];n;)jh(t,Xh(n)),n=Hh(n);return t}:Ov,Rv=o9;function a9(n,t){return Po(n,Rv(n),t)}var xI=a9;function l9(n,t,e){var r=t(n);return Oi(n)?r:jh(r,e(n))}var Lv=l9;function c9(n){return Lv(n,Uh,Xh)}var lm=c9;function u9(n){return Lv(n,vs,Rv)}var Nv=u9;var h9=Ln(ti,"DataView"),Bv=h9;var d9=Ln(ti,"Promise"),Fv=d9;var f9=Ln(ti,"Set"),Vv=f9;var bI="[object Map]",p9="[object Object]",SI="[object Promise]",wI="[object Set]",AI="[object WeakMap]",EI="[object DataView]",m9=_a(Bv),g9=_a(Ll),y9=_a(Fv),v9=_a(Vv),x9=_a(wv),Kc=is;(Bv&&Kc(new Bv(new ArrayBuffer(1)))!=EI||Ll&&Kc(new Ll)!=bI||Fv&&Kc(Fv.resolve())!=SI||Vv&&Kc(new Vv)!=wI||wv&&Kc(new wv)!=AI)&&(Kc=function(n){var t=is(n),e=t==p9?n.constructor:void 0,r=e?_a(e):"";if(r)switch(r){case m9:return EI;case g9:return bI;case y9:return SI;case v9:return wI;case x9:return AI}return t});var Oa=Kc;var b9=Object.prototype,S9=b9.hasOwnProperty;function w9(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&S9.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var TI=w9;var A9=ti.Uint8Array,Yh=A9;function E9(n){var t=new n.constructor(n.byteLength);return new Yh(t).set(new Yh(n)),t}var Kh=E9;function T9(n,t){var e=t?Kh(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var MI=T9;var M9=/\w*$/;function C9(n){var t=new n.constructor(n.source,M9.exec(n));return t.lastIndex=n.lastIndex,t}var CI=C9;var PI=ji?ji.prototype:void 0,_I=PI?PI.valueOf:void 0;function P9(n){return _I?Object(_I.call(n)):{}}var II=P9;function _9(n,t){var e=t?Kh(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var DI=_9;var I9="[object Boolean]",D9="[object Date]",O9="[object Map]",R9="[object Number]",L9="[object RegExp]",N9="[object Set]",B9="[object String]",F9="[object Symbol]",V9="[object ArrayBuffer]",U9="[object DataView]",k9="[object Float32Array]",z9="[object Float64Array]",G9="[object Int8Array]",j9="[object Int16Array]",H9="[object Int32Array]",W9="[object Uint8Array]",q9="[object Uint8ClampedArray]",X9="[object Uint16Array]",Y9="[object Uint32Array]";function K9(n,t,e){var r=n.constructor;switch(t){case V9:return Kh(n);case I9:case D9:return new r(+n);case U9:return MI(n,e);case k9:case z9:case G9:case j9:case H9:case W9:case q9:case X9:case Y9:return DI(n,e);case O9:return new r;case R9:case B9:return new r(n);case L9:return CI(n);case N9:return new r;case F9:return II(n)}}var OI=K9;function Q9(n){return typeof n.constructor=="function"&&!Bh(n)?Y_(Hh(n)):{}}var RI=Q9;var Z9="[object Map]";function J9(n){return Zi(n)&&Oa(n)==Z9}var LI=J9;var NI=Ia&&Ia.isMap,$9=NI?Vh(NI):LI,BI=$9;var eq="[object Set]";function tq(n){return Zi(n)&&Oa(n)==eq}var FI=tq;var VI=Ia&&Ia.isSet,rq=VI?Vh(VI):FI,UI=rq;var iq=1,nq=2,sq=4,kI="[object Arguments]",oq="[object Array]",aq="[object Boolean]",lq="[object Date]",cq="[object Error]",zI="[object Function]",uq="[object GeneratorFunction]",hq="[object Map]",dq="[object Number]",GI="[object Object]",fq="[object RegExp]",pq="[object Set]",mq="[object String]",gq="[object Symbol]",yq="[object WeakMap]",vq="[object ArrayBuffer]",xq="[object DataView]",bq="[object Float32Array]",Sq="[object Float64Array]",wq="[object Int8Array]",Aq="[object Int16Array]",Eq="[object Int32Array]",Tq="[object Uint8Array]",Mq="[object Uint8ClampedArray]",Cq="[object Uint16Array]",Pq="[object Uint32Array]",Rr={};Rr[kI]=Rr[oq]=Rr[vq]=Rr[xq]=Rr[aq]=Rr[lq]=Rr[bq]=Rr[Sq]=Rr[wq]=Rr[Aq]=Rr[Eq]=Rr[hq]=Rr[dq]=Rr[GI]=Rr[fq]=Rr[pq]=Rr[mq]=Rr[gq]=Rr[Tq]=Rr[Mq]=Rr[Cq]=Rr[Pq]=!0;Rr[cq]=Rr[zI]=Rr[yq]=!1;function Uv(n,t,e,r,i,s){var o,a=t&iq,l=t&nq,c=t&sq;if(e&&(o=i?e(n,r,i,s):e(n)),o!==void 0)return o;if(!kr(n))return n;var u=Oi(n);if(u){if(o=TI(n),!a)return Q_(n,o)}else{var h=Oa(n),d=h==zI||h==uq;if(Xc(n))return mI(n,a);if(h==GI||h==kI||d&&!i){if(o=l||d?{}:RI(n),!a)return l?xI(n,uI(o,n)):vI(n,cI(o,n))}else{if(!Rr[h])return i?n:{};o=OI(n,h,a)}}s||(s=new qh);var f=s.get(n);if(f)return f;s.set(n,o),UI(n)?n.forEach(function(g){o.add(Uv(g,t,e,g,n,s))}):BI(n)&&n.forEach(function(g,y){o.set(y,Uv(g,t,e,y,n,s))});var m=c?l?Nv:lm:l?vs:Uh,p=u?void 0:m(n);return t2(p||n,function(g,y){p&&(y=g,g=n[y]),Lh(o,y,Uv(g,t,e,y,n,s))}),o}var kv=Uv;var _q=1,Iq=4;function Dq(n){return kv(n,_q|Iq)}var Ra=Dq;var Oq="__lodash_hash_undefined__";function Rq(n){return this.__data__.set(n,Oq),this}var jI=Rq;function Lq(n){return this.__data__.has(n)}var HI=Lq;function zv(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new Yc;++t<e;)this.add(n[t])}zv.prototype.add=zv.prototype.push=jI;zv.prototype.has=HI;var WI=zv;function Nq(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var qI=Nq;function Bq(n,t){return n.has(t)}var XI=Bq;var Fq=1,Vq=2;function Uq(n,t,e,r,i,s){var o=e&Fq,a=n.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var c=s.get(n),u=s.get(t);if(c&&u)return c==t&&u==n;var h=-1,d=!0,f=e&Vq?new WI:void 0;for(s.set(n,t),s.set(t,n);++h<a;){var m=n[h],p=t[h];if(r)var g=o?r(p,m,h,t,n,s):r(m,p,h,n,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!qI(t,function(y,x){if(!XI(f,x)&&(m===y||i(m,y,e,r,s)))return f.push(x)})){d=!1;break}}else if(!(m===p||i(m,p,e,r,s))){d=!1;break}}return s.delete(n),s.delete(t),d}var Gv=Uq;function kq(n){var t=-1,e=Array(n.size);return n.forEach(function(r,i){e[++t]=[i,r]}),e}var YI=kq;function zq(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var KI=zq;var Gq=1,jq=2,Hq="[object Boolean]",Wq="[object Date]",qq="[object Error]",Xq="[object Map]",Yq="[object Number]",Kq="[object RegExp]",Qq="[object Set]",Zq="[object String]",Jq="[object Symbol]",$q="[object ArrayBuffer]",e7="[object DataView]",QI=ji?ji.prototype:void 0,rA=QI?QI.valueOf:void 0;function t7(n,t,e,r,i,s,o){switch(e){case e7:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case $q:return!(n.byteLength!=t.byteLength||!s(new Yh(n),new Yh(t)));case Hq:case Wq:case Yq:return Rh(+n,+t);case qq:return n.name==t.name&&n.message==t.message;case Kq:case Zq:return n==t+"";case Xq:var a=YI;case Qq:var l=r&Gq;if(a||(a=KI),n.size!=t.size&&!l)return!1;var c=o.get(n);if(c)return c==t;r|=jq,o.set(n,t);var u=Gv(a(n),a(t),r,i,s,o);return o.delete(n),u;case Jq:if(rA)return rA.call(n)==rA.call(t)}return!1}var ZI=t7;var r7=1,i7=Object.prototype,n7=i7.hasOwnProperty;function s7(n,t,e,r,i,s){var o=e&r7,a=lm(n),l=a.length,c=lm(t),u=c.length;if(l!=u&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:n7.call(t,d)))return!1}var f=s.get(n),m=s.get(t);if(f&&m)return f==t&&m==n;var p=!0;s.set(n,t),s.set(t,n);for(var g=o;++h<l;){d=a[h];var y=n[d],x=t[d];if(r)var v=o?r(x,y,d,t,n,s):r(y,x,d,n,t,s);if(!(v===void 0?y===x||i(y,x,e,r,s):v)){p=!1;break}g||(g=d=="constructor")}if(p&&!g){var b=n.constructor,w=t.constructor;b!=w&&"constructor"in n&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(p=!1)}return s.delete(n),s.delete(t),p}var JI=s7;var o7=1,$I="[object Arguments]",eD="[object Array]",jv="[object Object]",a7=Object.prototype,tD=a7.hasOwnProperty;function l7(n,t,e,r,i,s){var o=Oi(n),a=Oi(t),l=o?eD:Oa(n),c=a?eD:Oa(t);l=l==$I?jv:l,c=c==$I?jv:c;var u=l==jv,h=c==jv,d=l==c;if(d&&Xc(n)){if(!Xc(t))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new qh),o||Tv(n)?Gv(n,t,e,r,i,s):ZI(n,t,l,e,r,i,s);if(!(e&o7)){var f=u&&tD.call(n,"__wrapped__"),m=h&&tD.call(t,"__wrapped__");if(f||m){var p=f?n.value():n,g=m?t.value():t;return s||(s=new qh),i(p,g,e,r,s)}}return d?(s||(s=new qh),JI(n,t,e,r,i,s)):!1}var rD=l7;function iD(n,t,e,r,i){return n===t?!0:n==null||t==null||!Zi(n)&&!Zi(t)?n!==n&&t!==t:rD(n,t,e,r,iD,i)}var nD=iD;function c7(n,t){return n!=null&&t in Object(n)}var sD=c7;function u7(n,t,e){t=xs(t,n);for(var r=-1,i=t.length,s=!1;++r<i;){var o=Bl(t[r]);if(!(s=n!=null&&e(n,o)))break;n=n[o]}return s||++r!=i?s:(i=n==null?0:n.length,!!i&&Nh(i)&&Oh(o,i)&&(Oi(n)||Fh(n)))}var oD=u7;function h7(n,t){return n!=null&&oD(n,t,sD)}var aD=h7;var d7=function(){return ti.Date.now()},Hv=d7;var f7="Expected a function",p7=Math.max,m7=Math.min;function g7(n,t,e){var r,i,s,o,a,l,c=0,u=!1,h=!1,d=!0;if(typeof n!="function")throw new TypeError(f7);t=Yw(t)||0,kr(e)&&(u=!!e.leading,h="maxWait"in e,s=h?p7(Yw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(A){var T=r,S=i;return r=i=void 0,c=A,o=n.apply(S,T),o}function m(A){return c=A,a=setTimeout(y,t),u?f(A):o}function p(A){var T=A-l,S=A-c,M=t-T;return h?m7(M,s-S):M}function g(A){var T=A-l,S=A-c;return l===void 0||T>=t||T<0||h&&S>=s}function y(){var A=Hv();if(g(A))return x(A);a=setTimeout(y,p(A))}function x(A){return a=void 0,d&&r?f(A):(r=i=void 0,o)}function v(){a!==void 0&&clearTimeout(a),c=0,r=l=i=a=void 0}function b(){return a===void 0?o:x(Hv())}function w(){var A=Hv(),T=g(A);if(r=arguments,i=this,l=A,T){if(a===void 0)return m(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=v,w.flush=b,w}var _o=g7;function y7(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var lD=y7;function v7(n,t){return n>t}var cD=v7;function x7(n,t){return t.length<2?n:_v(n,Dv(t,0,-1))}var uD=x7;function b7(n,t){return nD(n,t)}var Qc=b7;function S7(n,t,e){for(var r=-1,i=n.length;++r<i;){var s=n[r],o=t(s);if(o!=null&&(a===void 0?o===o&&!Co(o):e(o,a)))var a=o,l=s}return l}var hD=S7;function w7(n){return n&&n.length?hD(n,xv,cD):void 0}var iA=w7;function A7(n,t){return t=xs(t,n),n=uD(n,t),n==null||delete n[Bl(lD(t))]}var dD=A7;function E7(n){return X2(n)?void 0:n}var fD=E7;var T7=1,M7=2,C7=4,P7=Iv(function(n,t){var e={};if(n==null)return e;var r=!1;t=gv(t,function(s){return s=xs(s,n),r||(r=s.length>1),s}),Po(n,Nv(n),e),r&&(e=kv(e,T7|M7|C7,fD));for(var i=t.length;i--;)dD(e,t[i]);return e}),Qh=P7;function _7(n,t,e,r){if(!kr(n))return n;t=xs(t,n);for(var i=-1,s=t.length,o=s-1,a=n;a!=null&&++i<s;){var l=Bl(t[i]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(i!=o){var u=a[l];c=r?r(u,l,a):void 0,c===void 0&&(c=kr(u)?u:Oh(t[i+1])?[]:{})}Lh(a,l,c),a=a[l]}return n}var pD=_7;function I7(n,t,e){for(var r=-1,i=t.length,s={};++r<i;){var o=t[r],a=_v(n,o);e(a,o)&&pD(s,xs(o,n),a)}return s}var mD=I7;function D7(n,t){return mD(n,t,function(e,r){return aD(n,r)})}var gD=D7;var O7=Iv(function(n,t){return n==null?{}:gD(n,t)}),Nn=O7;var R7="Expected a function";function L7(n,t,e){var r=!0,i=!0;if(typeof n!="function")throw new TypeError(R7);return kr(e)&&(r="leading"in e?!!e.leading:r,i="trailing"in e?!!e.trailing:i),_o(n,t,{leading:r,maxWait:t,trailing:i})}var nA=L7;function N7(n,t){for(var e=n.length;e--&&s2(t,n[e],0)>-1;);return e}var yD=N7;function B7(n,t,e){if(n=Pv(n),n&&(e||t===void 0))return n.slice(0,vv(n)+1);if(!n||!(t=yv(t)))return n;var r=tA(n),i=yD(r,tA(t))+1;return Y2(r,0,i).join("")}var sA=B7;function Wv(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function Ri(n,t){return Object.setPrototypeOf(n,t),n}var F7=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),V7=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),U7=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Zh&&"ontouchend"in document,k7=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,z7=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,G7=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(t)},j7=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},H7=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},oA=F7(),Bde=oA?H7():void 0,Zh=V7(),bs=U7(),vD=k7(),Li=z7(),aA=G7(),xD=Number(j7());function qv(n){return Array.isArray(n)?n:[n]}function Xv(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}function cm(n){return Zh?n.metaKey:n.ctrlKey}function bD(n){return n.wheelDeltaY===0||n.deltaY===0?Zh&&n.shiftKey&&Math.abs(n.wheelDeltaX)>=120?!1:n.wheelDeltaX?n.wheelDeltaX===-3*n.deltaX||n.wheelDeltaX===-3*window.devicePixelRatio*n.deltaX:n.deltaMode===0:n.wheelDeltaY?n.wheelDeltaY===-3*n.deltaY||n.wheelDeltaY===-3*window.devicePixelRatio*n.deltaY:n.deltaMode===0}var et=[],Kv={},um={},Yv={};function SD(n){et.includes(n)||et.push(n)}function Jh(n){delete Kv[n.pointerId];for(let t=0;t<et.length;t++)if(et[t].pointerId===n.pointerId){et.splice(t,1);break}}function wD(){et.splice(0,et.length)}function Qv(n){if(n.pointerType!=="touch")return;let t=Kv[n.pointerId];t===void 0&&(t={x:0,y:0},Kv[n.pointerId]=t),t.x=n.pageX,t.y=n.pageY}function Zv(n){let t=n.pointerId===et[0].pointerId?et[1]:et[0];return Kv[t.pointerId]}function AD(n){um[n.key]=!0,Yv[n.key]=Yv[n.key]===void 0?1:Yv[n.key]+1}function ED(n){if(Zh&&um.Meta)for(let t in um)um[t]=!1;else um[n.key]=!1;Yv={}}function TD(n){n.addEventListener("pointerdown",SD,!0),n.addEventListener("pointerdown",Qv,!0),n.addEventListener("pointermove",Qv,!0),n.addEventListener("pointerup",Jh,!0),n.addEventListener("pointercancel",Jh,!0),n.addEventListener("pointerleave",Jh,!0),window.addEventListener("keydown",AD,!0),window.addEventListener("keyup",ED,!0)}function MD(n){n.removeEventListener("pointerdown",SD,!0),n.removeEventListener("pointerdown",Qv,!0),n.removeEventListener("pointermove",Qv,!0),n.removeEventListener("pointerup",Jh,!0),n.removeEventListener("pointercancel",Jh,!0),n.removeEventListener("pointerleave",Jh,!0),window.removeEventListener("keydown",AD,!0),window.removeEventListener("keyup",ED,!0)}var CD,PD=new Promise(n=>{CD=n});var Jv;function _D(n){if(Jv)return Jv;async function t(){let r=n??(!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@1.12.48/build"),s=import("./navmesh.js"),[o,a]=await Promise.all([s,fetch(`${r}/navmesh.wasm`).then(u=>u.arrayBuffer())]),l=o.default,c=await l({wasmBinary:a});CD(c)}return Jv=t(),Jv}var ID,DD=new Promise(n=>{ID=n});var $v;function OD(){if($v)return $v;async function n(){let e=await import("./physics.js");await e.init(),ID(e)}return $v=n(),$v}var He=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let s={...r,[t]:e};return Object.setPrototypeOf(s,He.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],i;r===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,He.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:r}=t,i=e[r];if(i===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,He.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:i}}}}return null}};function hm(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&hm(r)}return Object.freeze(n)}function RD(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var $h=class extends Error{};function e0(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function Io(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let s=n;n=t,t=s}let r=[],i=1/(e+1);for(let s=0;s<e;s++){let o=n+(t-n)*(s+.75+Math.random()*.5)*i;r.push(o)}return r}function ed(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function LD(){return typeof process<"u"}function ND(n,t){for(let e of n)t(e.id,e.data)!==!0&&ND(e.children,t)}function BD(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)BD(e,t)}var wr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,wr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)hm(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);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,r){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===r)return!0;e=i}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let i=this.parent(e);if(i===r)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,r){if(e===null)this.traverse(r);else{let i=this.get(e);i&&BD(i,r)}}traverse(e){ND(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(e,r){let i=e,s=r;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let c=s.findIndex(u=>u.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,wr.prototype);let o=s;return o.fillCaches(),o}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:r}){if(this.get(e)!==void 0)return!0;for(let i of r)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:r,fi:i,id:s,data:o,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:i,id:s,data:o,children:a};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(c=>c.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:r,fi:i,id:s}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new $h("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(f=>f.id===s);l=[...l];let u=l.splice(c,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=u.fi;return u={...u,fi:i},l=[...l,u],l.sort((f,m)=>f.fi-m.fi),e.localIndex=l.indexOf(u),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,r){if(r===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(e)){if(s.id===r)return i;i=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===e)+1;if(s<i.length)return i[s].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(i[s].id):r}}getAllSorted(e){let r=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&r.push({...i,...s})}r.sort((i,s)=>RD(i.sortKey,s.sortKey));for(let i of r)delete i.sortKey;return r}getWithSortKey(e){var r=e;let i=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)i.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:i}}}insertBeforeHelper(e,r,i){return this.insertAfterHelper(e,this.previous(e,r),i)}insertAfterHelper(e,r,i){let s=this.childrenArray(e);if(r===null){if(s.length===0)return Io(0,i,i);{let o=s[0].fi;return Io(o-i,o,i)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Io(l,l+i,i)}else return Io(o.fi,a.fi,i)}}};var td;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let i=r.props,s={},o=[...e],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=i[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let i=r.props,s={},o={...e},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let c=i[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=n})(td||(td={}));var Re=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Re.prototype)}deepFreeze(){let e=0;for(;e<this.length;)hm(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(c=>c.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,Re.prototype);let r=e;return LD()||r.fillCaches(),r}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:r,id:i,data:s}=e,o=this,a={fi:r,id:i,data:s};return o=[...o,a],o.sort((c,u)=>c.fi-u.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:r}=e,i=this,s=i.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:i}=e,s=this;s=[...s];let o=s.findIndex(u=>u.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((u,h)=>u.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),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 r=null;for(let i of this){if(i.id===e)return r;r=i.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let i=this;if(e===null){if(i.length===0)return Io(0,r,r);{let s=i[0].fi;return Io(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return Io(a,a+r,r)}else return Io(s.fi,o.fi,r)}}};function rd(n){return n&&typeof n=="object"&&n instanceof lr}var lr=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,i=0,s={};for(;i<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[i]],r!==void 0&&!rd(r))return null;i+=1}r=r?e0(r):new lr;for(let[l,c]of Object.entries(t.props)){let u=r[l];s[l]=u,c===void 0?delete r[l]:r[l]=c}for(;i>0;){if(Object.keys(r).length===0){let l=e[i-1];l&&(r=e0(l),delete r[t.path[i-1]])}else{let l=e[i-1];if(l){let c=e0(l);c[t.path[i-1]]=r,r=c}else{let c=new lr;c[t.path[i-1]]=r,r=c}}i-=1}let o=Object.setPrototypeOf(r,lr.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Do;(r=>{function n(i,s){return dm(i,s)??i}r.apply=n;function t(i,s){return cA(i,s)}r.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o<a.length&&l!==void 0;){if(l=Mr.zoomOnce(l,a[o]),l===void 0)return s;if(!rd(l))return;o+=1}if(l===void 0)return s;if(!!rd(l))if(s.type===0){let c={...s.props};for(let u of Object.keys(l))delete c[u];return{...s,props:c}}else if(s.type===1||s.type===4||s.type===7){let c=lA([s],l);return c?c[0]:s}else return s}r.filterOp=e})(Do||(Do={}));function lA(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=dm(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=lA(i.children,t);return a!==void 0?e=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(e)return r}function W7(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=dm(i.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function dm(n,t){if(!rd(t))return t;if(n instanceof wr){let e=lA(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof Re)return W7(n,t);if(Array.isArray(n)){let e=!1,r=n.map((i,s)=>{let o=dm(i,t[s]);return e=e||o!==void 0,o===void 0&&(o=i),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof lr)return cA(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[i,s]of Object.entries(n)){let o=dm(s,t[i]);r=r||o!==void 0,o===void 0&&(o=s),e[i]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function cA(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!rd(t))return t;if(!rd(n))return Do.apply(n,t);let e=new Set;for(let i of Object.keys(n))e.add(i);for(let i of Object.keys(t))e.add(i);let r=new lr;for(let i of e){let s=cA(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=s}return r}function FD(n,t){let e={cur:[],result:[],len:0};return n=fm(n,t,e)??n,[n,e.result]}function t0(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function r0(n){n&&(n.len-=1)}function q7(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function VD(n,t,e){let r=!1,i=n.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=fm(s.data,t,t0(e,o));r0(e),r=r||l!==void 0,l===void 0&&(l=s.data);let c=VD(s.children,t,e);return c!==void 0?r=!0:c=s.children,{...s,id:o,data:l,children:c}});if(r)return i}function X7(n,t,e){let r=!1,i=n.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=fm(s.data,t,t0(e,o));return r0(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i}function fm(n,t,e){if(n instanceof wr){let r=VD(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof Re)return X7(n,t,e);if(Array.isArray(n)){let r=!1,i=n.map((s,o)=>{let a=fm(s,t,t0(e,o));return r0(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i):void 0}else if(n&&typeof n=="object"&&!ed(n)){let r={},i=!1;for(let[s,o]of Object.entries(n))if(s!=="name"&&s!=="variableId"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");i=!0,s=a}let l=fm(o,t,t0(e,s));r0(e),i=i||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&q7(e),r}else return}}var id;(t=>{function n(e,r){let i=Mr.zoom(r,e.path);if(typeof i=="object"){let s={};for(let o of Object.keys(e.props))s[o]=i[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=n})(id||(id={}));var zr;(a=>{function n(l,c){return{...l,path:l.path.slice(c)}}a.drop=n;function t(l,c){return e(l,c)?.data??l}a.applySimple=t;function e(l,c){let u=c.path;for(var h=[];;){let d;if(l instanceof lr&&c.type===0&&(d=l.runOp({...c,path:u.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===u.length&&(l instanceof wr||l instanceof Re||l instanceof He?d=l.runOp(c):d=td.runOp(l,c)),d!==void 0)if(d!==null){let p=d.data;for(let g=h.length-1;g>=0;g--){let y=u[g],x=h[g];if(x instanceof wr){if(typeof y=="number")throw new Error("illegal arg");p=x.modifyById(y,p)}else if(x instanceof Re){if(typeof y=="number")throw new Error("illegal arg");p=x.modifyById(y,p)}else if(x instanceof He){if(typeof y=="number")throw new Error("illegal arg");p=x.modifyById(y,p)}else if(x instanceof lr){let v={...x,[y]:p};p=Object.setPrototypeOf(v,lr.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let v=p;p=[...x],p[y]=v}else p={...x,[y]:p};else return null}return{data:p,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[h.length],m;if(l instanceof wr){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else if(l instanceof Re){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else l!==null&&(m=l[f]);if(m!==void 0)h.push(l),l=m;else return null}}a.apply=e;function r(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}a.pathDisjoint=r;function i(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}a.pathEq=i;function s(l,c){return r(l.path,c.path)}a.commutative=s;function o(l,c){return l.type===0&&c.type===0&&i(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}a.subsumed=o})(zr||(zr={}));var pm;(l=>{function n(){return[]}l.empty=n;function t(c,u){let h=[];for(let d of c){let[f,...m]=d.path;f===u&&h.push({...d,path:m})}return h}l.removePrefix=t;function e(c,u){return c.map(h=>({...h,path:[u,...h.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function i(c,u){return[...c.filter(d=>!u.some(f=>zr.subsumed(d,f))),...u]}l.compress=i;function s(c,u){return c.every(h=>u.every(d=>zr.commutative(h,d)))}l.commutative=s;function o(c,u){for(let h of u){let d=a(c,h);d!==null&&(c=d.data)}return c}l.applyAll=o;function a(c,u){var h=c;let d=[],f=[];for(let m of u)try{if(m.type===3||m.type===5&&m.path[m.path.length-1]==="variables"){let p,g,y;if(m.type===3?(p=Mr.zoom(h,[...m.path,m.id]),y=zr.apply(h,{...m,type:2})):(p=Mr.zoom(h,[...m.path,m.id,"value"]),y=zr.apply(h,m)),y!==null){h=y.data;let[x,v]=FD(h,{[m.id]:p});h=x;for(let b=0;b<v.length;b++){let w=v[b],A=w.pop();if(typeof A=="number"){let T=[A];for(let M=b+1;M<v.length;M++){let C=v[M],P=C[C.length-1];if(typeof P=="number"&&Mr.equal(w,C.slice(0,C.length-1)))T.push(P),v.splice(M,1);else break}let S=Mr.zoom(h,w);g=S.map((M,C)=>T.includes(C)?m.id:M),p=S,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){p/=100;let T=p,S=Mr.zoom(h,w.slice(0,w.length-2)),M=S.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:T}}:C);Object.setPrototypeOf(M,Object.getPrototypeOf(S.layers)),S.layers=M}g=m.id}d.push({type:0,path:w,props:{[A]:p}}),f.push({type:0,path:w,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let p=zr.apply(h,m);p!==null&&(d.push(p.actual),h=p.data,f.push(p.reverse))}}catch(p){if(p instanceof $h)return null;throw p}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(pm||(pm={}));var UD=Symbol(),Y7=Symbol(),n0=Symbol(),Zc=class{reportOp(t,e,r=[]){let i=this;if(e===null)return;i._current=e.data;let s=r;for(;!(i instanceof i0);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[n0];r&&r(),delete this._children[t]}}}},hA=class extends Zc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else if(this._current instanceof lr){let r={...this._current,[t]:e};this._current=Object.setPrototypeOf(r,lr.prototype)}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,td.runOp(this._current,t),t.path)}},dA=class extends Zc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,He.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},kD={get(n,t){if(t===n0)return()=>{n._parent=null};if(t===UD)return n._current;if(t===Y7)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e[t],o=s0(n,t,s);return o!==s?(r===void 0&&(r={},n._children=r),r[t]=o,o):s},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},K7={...kD,set(n,t,e){let r={type:0,props:{[t]:Yr(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},Q7={...kD,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},nd=class extends Zc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[n0]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=s0(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,i,s){this.runOp({type:7,parent:t,fi:e,id:r,data:i,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,i[s],o.id,o.data,o.children)}}insertBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,i[s],o.id,o.data,o.children)}}moveAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,i[s],o)}}moveBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,i[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},sd=class extends Zc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[n0]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id,s=this._current[r].fi;t(this.data(this._current[r].id),i,s)}}find(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id;if(t(this.data(i),i))return this.get(i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=s0(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(r[i],s.id,s.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(r[i],s.id,s.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(r[i],s)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(r[i],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function uA(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&Mr.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var i0=class extends Zc{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,i){uA(this.ts,e,t),uA(this.actual,r,t),uA(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function s0(n,t,e){return e instanceof wr?new nd(n,t,e):e instanceof Re?new sd(n,t,e):e instanceof He?new Proxy(new dA(n,t,e),Q7):e!==null&&typeof e=="object"?ed(e)?e:new Proxy(new hA(n,t,e),K7):e}function fA(n){let t=new i0(n);return[s0(t,"",n),t]}function Fl(n,t){let[e,r]=fA(n);return t(e),r.result()}function Yr(n){return n instanceof nd||n instanceof sd?n._current:n!==null&&typeof n=="object"?n[UD]:n}var Mr;(i=>{function n(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=n;function t(s,o,a){let l=r(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...o};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return o}i.removeOverridden=t;function e(s,o){if((s instanceof wr||s instanceof nd)&&typeof o=="string")return s.data(o);if((s instanceof Re||s instanceof sd)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=e;function r(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}i.zoom=r})(Mr||(Mr={}));function zD(n,t){let e=[];if(t.length===n.length)for(var r=0;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}function kt(n,t){let e=[];if(t.length<=n.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}var o0=class{},mm=class extends o0{constructor(e){super();this.id=e}},gm=class extends o0{constructor(e){super();this.data=e}};var mA;try{mA=new TextDecoder}catch{}var Ke,Ul,se=0;var KD=[],gA=KD,yA=0,Bn={},rr,Vl,Ss=0,Oo=0,ns,La,wn=[],fr,GD={useRecords:!1,mapsAsObjects:!0},ym=class{},xA=new ym;xA.name="MessagePack 0xC1";var od=!1,Ro=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(Ke)return eO(()=>(l0(),this?this.unpack(t,e):Ro.prototype.unpack.call(GD,t,e)));Ul=e>-1?e:t.length,se=0,yA=0,Oo=0,Vl=null,gA=KD,ns=null,Ke=t;try{fr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw Ke=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ro){if(Bn=this,this.structures)return rr=this.structures,a0();(!rr||rr.length>0)&&(rr=[])}else Bn=GD,(!rr||rr.length>0)&&(rr=[]);return a0()}unpackMultiple(t,e){let r,i=0;try{od=!0;let s=t.length,o=this?this.unpack(t,s):h0.unpack(t,s);if(e){for(e(o);se<s;)if(i=se,e(a0())===!1)return}else{for(r=[o];se<s;)i=se,r.push(a0());return r}}catch(s){throw s.lastPosition=i,s.values=r,s}finally{od=!1,l0()}}_mergeStructures(t,e){t=t||[];for(let r=0,i=t.length;r<i;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let i=t[r],s=e[r];s&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[r]=i),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function a0(){try{if(!Bn.trusted&&!od){let t=rr.sharedLength||0;t<rr.length&&(rr.length=t)}let n=ri();if(se==Ul)rr.restoreStructures&&jD(),rr=null,Ke=null,La&&(La=null);else if(se>Ul){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!od)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw rr.restoreStructures&&jD(),l0(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function jD(){for(let n in rr.restoreStructures)rr[n]=rr.restoreStructures[n];rr.restoreStructures=null}function ri(){let n=Ke[se++];if(n<160)if(n<128){if(n<64)return n;{let t=rr[n&63]||Bn.getStructures&&QD()[n&63];return t?(t.read||(t.read=bA(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,Bn.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[JD()]=ri();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(ri(),ri());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=ri();return t}else if(n<192){let t=n-160;if(Oo>=se)return Vl.slice(se-Ss,(se+=t)-Ss);if(Oo==0&&Ul<140){let e=t<16?SA(t):ZD(t);if(e!=null)return e}return vA(t)}else{let t;switch(n){case 192:return null;case 193:return ns?(t=ri(),t>0?ns[1].slice(ns.position1,ns.position1+=t):ns[0].slice(ns.position0,ns.position0-=t)):xA;case 194:return!1;case 195:return!0;case 196:return pA(Ke[se++]);case 197:return t=fr.getUint16(se),se+=2,pA(t);case 198:return t=fr.getUint32(se),se+=4,pA(t);case 199:return Jc(Ke[se++]);case 200:return t=fr.getUint16(se),se+=2,Jc(t);case 201:return t=fr.getUint32(se),se+=4,Jc(t);case 202:if(t=fr.getFloat32(se),Bn.useFloat32>2){let e=u0[(Ke[se]&127)<<1|Ke[se+1]>>7];return se+=4,(e*t+(t>0?.5:-.5)>>0)/e}return se+=4,t;case 203:return t=fr.getFloat64(se),se+=8,t;case 204:return Ke[se++];case 205:return t=fr.getUint16(se),se+=2,t;case 206:return t=fr.getUint32(se),se+=4,t;case 207:return Bn.int64AsNumber?(t=fr.getUint32(se)*4294967296,t+=fr.getUint32(se+4)):t=fr.getBigUint64(se),se+=8,t;case 208:return fr.getInt8(se++);case 209:return t=fr.getInt16(se),se+=2,t;case 210:return t=fr.getInt32(se),se+=4,t;case 211:return Bn.int64AsNumber?(t=fr.getInt32(se)*4294967296,t+=fr.getUint32(se+4)):t=fr.getBigInt64(se),se+=8,t;case 212:if(t=Ke[se++],t==114)return YD(Ke[se++]&63);{let e=wn[t];if(e)return e.read?(se++,e.read(ri())):e.noBuffer?(se++,e()):e(Ke.subarray(se,++se));throw new Error("Unknown extension "+t)}case 213:return t=Ke[se],t==114?(se++,YD(Ke[se++]&63,Ke[se++])):Jc(2);case 214:return Jc(4);case 215:return Jc(8);case 216:return Jc(16);case 217:return t=Ke[se++],Oo>=se?Vl.slice(se-Ss,(se+=t)-Ss):J7(t);case 218:return t=fr.getUint16(se),se+=2,Oo>=se?Vl.slice(se-Ss,(se+=t)-Ss):$7(t);case 219:return t=fr.getUint32(se),se+=4,Oo>=se?Vl.slice(se-Ss,(se+=t)-Ss):eX(t);case 220:return t=fr.getUint16(se),se+=2,WD(t);case 221:return t=fr.getUint32(se),se+=4,WD(t);case 222:return t=fr.getUint16(se),se+=2,qD(t);case 223:return t=fr.getUint32(se),se+=4,qD(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var Z7=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function bA(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(s=>Z7.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(ri);return n.highByte===0&&(n.read=HD(t,n.read)),i()}let r={};for(let i=0,s=n.length;i<s;i++){let o=n[i];r[o]=ri()}return r}return e.count=0,n.highByte===0?HD(t,e):e}var HD=(n,t)=>function(){let e=Ke[se++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=rr[r]||QD()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=bA(i,n)),i.read()};function QD(){let n=eO(()=>(Ke=null,Bn.getStructures()));return rr=Bn._mergeStructures(n,rr)}var vA=c0,J7=c0,$7=c0,eX=c0;function c0(n){let t;if(n<16&&(t=SA(n)))return t;if(n>64&&mA)return mA.decode(Ke.subarray(se,se+=n));let e=se+n,r=[];for(t="";se<e;){let i=Ke[se++];if((i&128)===0)r.push(i);else if((i&224)===192){let s=Ke[se++]&63;r.push((i&31)<<6|s)}else if((i&240)===224){let s=Ke[se++]&63,o=Ke[se++]&63;r.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ke[se++]&63,o=Ke[se++]&63,a=Ke[se++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(i);r.length>=4096&&(t+=Hi.apply(String,r),r.length=0)}return r.length>0&&(t+=Hi.apply(String,r)),t}function WD(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=ri();return t}function qD(n){if(Bn.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[JD()]=ri();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(ri(),ri());return t}}var Hi=String.fromCharCode;function ZD(n){let t=se,e=new Array(n);for(let r=0;r<n;r++){let i=Ke[se++];if((i&128)>0){se=t;return}e[r]=i}return Hi.apply(String,e)}function SA(n){if(n<4)if(n<2){if(n===0)return"";{let t=Ke[se++];if((t&128)>1){se-=1;return}return Hi(t)}}else{let t=Ke[se++],e=Ke[se++];if((t&128)>0||(e&128)>0){se-=2;return}if(n<3)return Hi(t,e);let r=Ke[se++];if((r&128)>0){se-=3;return}return Hi(t,e,r)}else{let t=Ke[se++],e=Ke[se++],r=Ke[se++],i=Ke[se++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){se-=4;return}if(n<6){if(n===4)return Hi(t,e,r,i);{let s=Ke[se++];if((s&128)>0){se-=5;return}return Hi(t,e,r,i,s)}}else if(n<8){let s=Ke[se++],o=Ke[se++];if((s&128)>0||(o&128)>0){se-=6;return}if(n<7)return Hi(t,e,r,i,s,o);let a=Ke[se++];if((a&128)>0){se-=7;return}return Hi(t,e,r,i,s,o,a)}else{let s=Ke[se++],o=Ke[se++],a=Ke[se++],l=Ke[se++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){se-=8;return}if(n<10){if(n===8)return Hi(t,e,r,i,s,o,a,l);{let c=Ke[se++];if((c&128)>0){se-=9;return}return Hi(t,e,r,i,s,o,a,l,c)}}else if(n<12){let c=Ke[se++],u=Ke[se++];if((c&128)>0||(u&128)>0){se-=10;return}if(n<11)return Hi(t,e,r,i,s,o,a,l,c,u);let h=Ke[se++];if((h&128)>0){se-=11;return}return Hi(t,e,r,i,s,o,a,l,c,u,h)}else{let c=Ke[se++],u=Ke[se++],h=Ke[se++],d=Ke[se++];if((c&128)>0||(u&128)>0||(h&128)>0||(d&128)>0){se-=12;return}if(n<14){if(n===12)return Hi(t,e,r,i,s,o,a,l,c,u,h,d);{let f=Ke[se++];if((f&128)>0){se-=13;return}return Hi(t,e,r,i,s,o,a,l,c,u,h,d,f)}}else{let f=Ke[se++],m=Ke[se++];if((f&128)>0||(m&128)>0){se-=14;return}if(n<15)return Hi(t,e,r,i,s,o,a,l,c,u,h,d,f,m);let p=Ke[se++];if((p&128)>0){se-=15;return}return Hi(t,e,r,i,s,o,a,l,c,u,h,d,f,m,p)}}}}}function pA(n){return Bn.copyBuffers?Uint8Array.prototype.slice.call(Ke,se,se+=n):Ke.subarray(se,se+=n)}function Jc(n){let t=Ke[se++];if(wn[t])return wn[t](Ke.subarray(se,se+=n));throw new Error("Unknown extension type "+t)}var XD=new Array(4096);function JD(){let n=Ke[se++];if(n>=160&&n<192){if(n=n-160,Oo>=se)return Vl.slice(se-Ss,(se+=n)-Ss);if(!(Oo==0&&Ul<180))return vA(n)}else return se--,ri();let t=(n<<5^(n>1?fr.getUint16(se):n>0?Ke[se]:0))&4095,e=XD[t],r=se,i=se+n-3,s,o=0;if(e&&e.bytes==n){for(;r<i;){if(s=fr.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(s=Ke[r++],s!=e[o++]){r=1879048192;break}if(r===i)return se=r,e.string;i-=3,r=se}for(e=[],XD[t]=e,e.bytes=n;r<i;)s=fr.getUint32(r),e.push(s),r+=4;for(i+=3;r<i;)s=Ke[r++],e.push(s);let a=n<16?SA(n):ZD(n);return a!=null?e.string=a:e.string=vA(n)}var YD=(n,t)=>{var e=ri();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=rr[n];return i&&i.isShared&&((rr.restoreStructures||(rr.restoreStructures=[]))[n]=i),rr[n]=e,e.read=bA(e,r),e.read()},$D=typeof self=="object"?self:global;wn[0]=()=>{};wn[0].noBuffer=!0;wn[101]=()=>{let n=ri();return($D[n[0]]||Error)(n[1])};wn[105]=n=>{let t=fr.getUint32(se-4);La||(La=new Map);let e=Ke[se],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let i={target:r};La.set(t,i);let s=ri();return i.used?Object.assign(r,s):(i.target=s,s)};wn[112]=n=>{let t=fr.getUint32(se-4),e=La.get(t);return e.used=!0,e.target};wn[115]=()=>new Set(ri());var wA=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");wn[116]=n=>{let t=n[0],e=wA[t];if(!e)throw new Error("Could not find typed array for code "+t);return new $D[e](Uint8Array.prototype.slice.call(n,1).buffer)};wn[120]=()=>{let n=ri();return new RegExp(n[0],n[1])};wn[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=se;se+=t-4,ns=[ri(),ri()],ns.position0=0,ns.position1=0;let r=se;se=e;try{return ri()}finally{se=r}};wn[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function eO(n){let t=Ul,e=se,r=yA,i=Ss,s=Oo,o=Vl,a=gA,l=La,c=ns,u=new Uint8Array(Ke.slice(0,Ul)),h=rr,d=rr.slice(0,rr.length),f=Bn,m=od,p=n();return Ul=t,se=e,yA=r,Ss=i,Oo=s,Vl=o,gA=a,La=l,ns=c,Ke=u,od=m,rr=h,rr.splice(0,rr.length,...d),Bn=f,fr=new DataView(Ke.buffer,Ke.byteOffset,Ke.byteLength),p}function l0(){Ke=null,La=null,rr=null}function tO(n){n.unpack?wn[n.type]=n.unpack:wn[n.type]=n}var u0=new Array(147);for(let n=0;n<256;n++)u0[n]=+("1e"+Math.floor(45.15-n*.30103));var h0=new Ro({useRecords:!1}),tX=h0.unpack,rX=h0.unpackMultiple,iX=h0.unpack,d0={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},nX=new Float32Array(1),Yfe=new Uint8Array(nX.buffer,0,4);var f0;try{f0=new TextEncoder}catch{}var p0,EA,m0=typeof Buffer<"u",AA=m0?Buffer.allocUnsafeSlow:Uint8Array,sO=m0?Buffer:Uint8Array,rO=m0?4294967296:2144337920,we,oi,he=0,Lo,No=null,sX=/[\u0080-\uFFFF]/,vm=Symbol("record-id"),$c=class extends Ro{constructor(t){super(t),this.offset=0;let e,r,i,s,o,a,l=0,c=sO.prototype.utf8Write?function(S,M,C){return we.utf8Write(S,M,C)}:f0&&f0.encodeInto?function(S,M){return f0.encodeInto(S,we.subarray(M)).written}:!1,u=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=t.maxOwnStructures;m==null&&(m=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,y=f+m+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let x=[],v=0,b=0;this.pack=this.encode=function(S,M){if(we||(we=new AA(8192),oi=new DataView(we.buffer,0,8192),he=0),Lo=we.length-10,Lo-he<2048?(we=new AA(we.length),oi=new DataView(we.buffer,0,we.length),Lo=we.length-10,he=0):he=he+7&2147483640,r=he,a=u.structuredClone?new Map:null,u.bundleStrings?(No=["",""],we[he++]=214,we[he++]=98,No.position=he-r,he+=4):No=null,i=u.structures,i){i.uninitialized&&(i=u._mergeStructures(u.getStructures()));let C=i.sharedLength||0;if(C>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let P=0;P<C;P++){let _=i[P];if(!_)continue;let I,O=i.transitions;for(let L=0,j=_.length;L<j;L++){let V=_[L];I=O[V],I||(I=O[V]=Object.create(null)),O=I}O[vm]=P+64}l=C}h||(i.nextId=C+64)}s&&(s=!1),o=i||[];try{if(w(S),No){oi.setUint32(No.position+r,he-No.position-r);let C=No;No=null,w(C[0]),w(C[1])}if(u.offset=he,a&&a.idsToInsert){he+=a.idsToInsert.length*6,he>Lo&&T(he),u.offset=he;let C=aX(we.subarray(r,he),a.idsToInsert);return a=null,C}return M&aO?(we.start=r,we.end=he,we):we.subarray(r,he)}finally{if(i){if(b<10&&b++,v>1e4)i.transitions=null,b=0,v=0,x.length>0&&(x=[]);else if(x.length>0&&!h){for(let C=0,P=x.length;C<P;C++)x[C][vm]=0;x=[]}if(s&&u.saveStructures){let C=i.sharedLength||f;i.length>C&&(i=i.slice(0,C));let P=we.subarray(r,he);return u.saveStructures(i,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(S)):(l=C,P)}}M&pX&&(he=r)}};let w=S=>{he>Lo&&(we=T(he));var M=typeof S,C;if(M==="string"){let P=S.length;if(No&&P>=8&&P<4096){let O=sX.test(S);No[O?0:1]+=S,we[he++]=193,w(O?-P:P);return}let _;P<32?_=1:P<256?_=2:P<65536?_=3:_=5;let I=P*3;if(he+I>Lo&&(we=T(he+I)),P<64||!c){let O,L,j,V=he+_;for(O=0;O<P;O++)L=S.charCodeAt(O),L<128?we[V++]=L:L<2048?(we[V++]=L>>6|192,we[V++]=L&63|128):(L&64512)===55296&&((j=S.charCodeAt(O+1))&64512)===56320?(L=65536+((L&1023)<<10)+(j&1023),O++,we[V++]=L>>18|240,we[V++]=L>>12&63|128,we[V++]=L>>6&63|128,we[V++]=L&63|128):(we[V++]=L>>12|224,we[V++]=L>>6&63|128,we[V++]=L&63|128);C=V-he-_}else C=c(S,he+_,I);C<32?we[he++]=160|C:C<256?(_<2&&we.copyWithin(he+2,he+1,he+1+C),we[he++]=217,we[he++]=C):C<65536?(_<3&&we.copyWithin(he+3,he+2,he+2+C),we[he++]=218,we[he++]=C>>8,we[he++]=C&255):(_<5&&we.copyWithin(he+5,he+3,he+3+C),we[he++]=219,oi.setUint32(he,C),he+=4),he+=C}else if(M==="number")if(S>>>0===S)S<64?we[he++]=S:S<256?(we[he++]=204,we[he++]=S):S<65536?(we[he++]=205,we[he++]=S>>8,we[he++]=S&255):(we[he++]=206,oi.setUint32(he,S),he+=4);else if(S>>0===S)S>=-32?we[he++]=256+S:S>=-128?(we[he++]=208,we[he++]=S+256):S>=-32768?(we[he++]=209,oi.setInt16(he,S),he+=2):(we[he++]=210,oi.setInt32(he,S),he+=4);else{let P;if((P=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){we[he++]=202,oi.setFloat32(he,S);let _;if(P<4||(_=S*u0[(we[he]&127)<<1|we[he+1]>>7])>>0===_){he+=4;return}else he--}we[he++]=203,oi.setFloat64(he,S),he+=8}else if(M==="object")if(!S)we[he++]=192;else{if(a){let _=a.get(S);if(_){if(!_.id){let I=a.idsToInsert||(a.idsToInsert=[]);_.id=I.push(_)}we[he++]=214,we[he++]=112,oi.setUint32(he,_.id),he+=4;return}else a.set(S,{offset:he-r})}let P=S.constructor;if(P===Object)A(S,!0);else if(P===Array){C=S.length,C<16?we[he++]=144|C:C<65536?(we[he++]=220,we[he++]=C>>8,we[he++]=C&255):(we[he++]=221,oi.setUint32(he,C),he+=4);for(let _=0;_<C;_++)w(S[_])}else if(P===Map){C=S.size,C<16?we[he++]=128|C:C<65536?(we[he++]=222,we[he++]=C>>8,we[he++]=C&255):(we[he++]=223,oi.setUint32(he,C),he+=4);for(let[_,I]of S)w(_),w(I)}else{for(let _=0,I=p0.length;_<I;_++){let O=EA[_];if(S instanceof O){let L=p0[_];if(L.write){L.type&&(we[he++]=212,we[he++]=L.type,we[he++]=0),w(L.write.call(this,S));return}let j=we,V=oi,H=he;we=null;let q;try{q=L.pack.call(this,S,X=>(we=j,j=null,he+=X,he>Lo&&T(he),{target:we,targetView:oi,position:he-X}),w)}finally{j&&(we=j,oi=V,he=H,Lo=we.length-10)}q&&(q.length+he>Lo&&T(q.length+he),he=oX(q,we,he,L.type));return}}A(S,!S.hasOwnProperty)}}else if(M==="boolean")we[he++]=S?195:194;else if(M==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))we[he++]=211,oi.setBigInt64(he,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)we[he++]=207,oi.setBigUint64(he,S);else if(this.largeBigIntToFloat)we[he++]=203,oi.setFloat64(he,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");he+=8}else if(M==="undefined")this.encodeUndefinedAsNil?we[he++]=192:(we[he++]=212,we[he++]=0,we[he++]=0);else if(M==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},A=this.useRecords===!1?this.variableMapSize?S=>{let M=Object.keys(S),C=M.length;C<16?we[he++]=128|C:C<65536?(we[he++]=222,we[he++]=C>>8,we[he++]=C&255):(we[he++]=223,oi.setUint32(he,C),he+=4);let P;for(let _=0;_<C;_++)w(P=M[_]),w(S[P])}:(S,M)=>{we[he++]=222;let C=he-r;he+=2;let P=0;for(let _ in S)(M||S.hasOwnProperty(_))&&(w(_),w(S[_]),P++);we[C+++r]=P>>8,we[C+r]=P&255}:S=>{let M=Object.keys(S),C,P=o.transitions||(o.transitions=Object.create(null)),_=0;for(let O=0,L=M.length;O<L;O++){let j=M[O];C=P[j],C||(C=P[j]=Object.create(null),_++),P=C}let I=P[vm];if(I)I>=96&&p?(we[he++]=((I-=96)&31)+96,we[he++]=I>>5):we[he++]=I;else{I=o.nextId,I||(I=64),I<g&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(I=o.nextOwnId,I<y||(I=g),o.nextOwnId=I+1):(I>=y&&(I=g),o.nextId=I+1);let O=M.highByte=I>=96&&p?I-96>>5:-1;P[vm]=I,o[I-64]=M,I<g?(M.isShared=!0,o.sharedLength=I-63,s=!0,O>=0?(we[he++]=(I&31)+96,we[he++]=O):we[he++]=I):(O>=0?(we[he++]=213,we[he++]=114,we[he++]=(I&31)+96,we[he++]=O):(we[he++]=212,we[he++]=114,we[he++]=I),_&&(v+=b*_),x.length>=m&&(x.shift()[vm]=0),x.push(P),w(M))}for(let O=0,L=M.length;O<L;O++)w(S[M[O]])},T=S=>{let M;if(S>16777216){if(S-r>rO)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(rO,Math.round(Math.max((S-r)*(S>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(S-r<<2,we.length-1)>>12)+1<<12;let C=new AA(M);return oi=new DataView(C.buffer,0,M),we.copy?we.copy(C,0,r,S):C.set(we.slice(r,S)),he-=r,r=0,Lo=C.length-10,we=C}}useBuffer(t){we=t,oi=new DataView(we.buffer,we.byteOffset,we.byteLength),he=0}};EA=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,ym];p0=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:s,position:o}=t(6);i[o++]=214,i[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:i,targetView:s,position:o}=t(10);i[o++]=215,i[o++]=255,s.setUint32(o,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:s,position:o}=t(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=t(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,n.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:i,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),e(r)}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=101,r[i++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=120,r[i++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?iO(n,16,t):nO(m0?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==sO&&this.structuredClone?iO(n,wA.indexOf(e.name),t):nO(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function iO(n,t,e,r){let i=n.byteLength;if(i+1<256){var{target:s,position:o}=e(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=e(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=e(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),o)}function nO(n,t){let e=n.byteLength;var r,i;if(e<256){var{target:r,position:i}=t(e+2);r[i++]=196,r[i++]=e}else if(e<65536){var{target:r,position:i}=t(e+3);r[i++]=197,r[i++]=e>>8,r[i++]=e&255}else{var{target:r,position:i,targetView:s}=t(e+5);r[i++]=198,s.setUint32(i,e),i+=4}r.set(n,i)}function oX(n,t,e,r){let i=n.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=r,t.set(n,e),e+=i,e}function aX(n,t){let e,r=t.length*6,i=n.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;n.copyWithin(s+r,s,i),r-=6;let a=s+r;n[a++]=214,n[a++]=105,n[a++]=o>>24,n[a++]=o>>16&255,n[a++]=o>>8&255,n[a++]=o&255,i=s}return n}function kl(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");EA.unshift(n.Class),p0.unshift(n)}tO(n)}var oO=new $c({useRecords:!1}),lX=oO.pack,cX=oO.pack;var{NEVER:uX,ALWAYS:hX,DECIMAL_ROUND:dX,DECIMAL_FIT:fX}=d0,aO=512,pX=1024;var lO=new $c({structuredClone:!0});kl({Class:He.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,He.prototype),n}});kl({Class:Re.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Re.prototype),n}});kl({Class:wr.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,wr.prototype),n}});kl({Class:mm.prototype.constructor,type:4,write(n){return n.id},read(n){return new mm(n)}});kl({Class:gm.prototype.constructor,type:5,write(n){return n.data},read(n){return new gm(n)}});kl({Class:lr.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,lr.prototype),n}});function mX(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function TA(n){if(ed(n))return n;if(Array.isArray(n))return n.map(TA);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=TA(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var ad;(r=>{function n(i){return lO.pack(i)}r.serialize=n;function t(i){return lO.unpack(i)}r.deserialize=t;function e(i){return mX(n(TA(i))).toString()}r.checksum=e})(ad||(ad={}));var cO;(e=>{function n(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=n;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(cO||(cO={}));function xm(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var Wi={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseHover"]:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Scroll"]:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Start"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Conditional"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseDown"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseUp"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MousePress"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyDown"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyUp"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyPress"]:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["GameControl"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],["Collision"]:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Trigger"]:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Resize"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["VariableChange"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["API"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["WEBHOOK"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["AIAssistantListener"]:["SetVariable"],["AIAssistantTrigger"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},uO;(e=>{function n(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=n;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,name:"",actions:new Re}:{type:r,disabled:!1,name:"",key:void 0,actions:new Re}}e.defaultData=t})(uO||(uO={}));var g0;(e=>{function n(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=n,e.valueDefaultData={type:"Literal",value:0}})(g0||(g0={}));var MA;(r=>{function n(i){return{type:"Comparison",operator:"==",lOperand:g0.propertyDefaultData(i),rOperand:{...g0.valueDefaultData}}}r.comparisonDefaultData=n;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}r.distanceDefaultData=t;function e(i,s){return{type:"State",object:i??null,state:s??null}}r.stateDefaultData=e})(MA||(MA={}));var hO;(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(hO||(hO={}));var dO;(e=>{function n(r){return r.type==="Conditional"}e.is=n;function t(r){return{type:"Conditional",disabled:!1,name:"",inActions:new Re,outActions:new Re,condition:MA.distanceDefaultData(r)}}e.defaultData=t})(dO||(dO={}));var fO;(t=>t.defaultData={type:"DragDrop",name:"",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 Re,drop:new Re}})(fO||(fO={}));var y0;(t=>t.defaultData={type:"Follow",disabled:!1,name:"",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 Re})(y0||(y0={}));var v0;(t=>t.defaultData={type:"LookAt",disabled:!1,name:"",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})(v0||(v0={}));var pO;(e=>{function n(r){return r.type==="MouseHover"}e.is=n;function t(){return{type:"MouseHover",disabled:!1,name:"",actions:new Re}}e.defaultData=t})(pO||(pO={}));var mO;(e=>{function n(r){return r.type==="Scroll"}e.is=n;function t(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Re}}e.defaultData=t})(mO||(mO={}));var gO;(e=>{function n(r){return r.type==="Start"}e.is=n;function t(){return{type:"Start",disabled:!1,name:"",actions:new Re}}e.defaultData=t})(gO||(gO={}));var yO;(e=>{function n(r){return r.type==="Collision"}e.is=n;function t(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new Re}}e.defaultData=t})(yO||(yO={}));var vO;(e=>{function n(r){return r.type==="Trigger"}e.is=n;function t(r,i){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new Re,triggerZone:"box",position:i.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(vO||(vO={}));var x0;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function r(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=r;function i(){let a={size:"mobile",operator:"<",actions:new Re},l={size:"tablet",operator:"<",actions:new Re},c={size:[...o.defaultSizes.custom],operator:"<>",actions:new Re},u=new Re;return u.push({id:Se.generateUUID(),fi:0,data:a},{id:Se.generateUUID(),fi:1,data:l},{id:Se.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:u}}o.defaultData=i;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Re}}o.defaultBreakpointData=s})(x0||(x0={}));var b0;(r=>{r.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(i){return i.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",name:"",actions:new Re,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(b0||(b0={}));var xO;(e=>{function n(r){return r.type==="API"}e.is=n;function t(){return{disabled:!1,type:"API",name:"",successActions:new Re,errorActions:new Re,userAPIId:""}}e.defaultData=t})(xO||(xO={}));var bO;(e=>{function n(r){return r.type==="WEBHOOK"}e.is=n;function t(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new Re,userWebhookId:""}}e.defaultData=t})(bO||(bO={}));var SO;(e=>{function n(r){return r.type==="AIAssistantListener"}e.is=n;function t(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new Re,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=t})(SO||(SO={}));var wO;(e=>{function n(r){return r.type==="AIAssistantTrigger"}e.is=n;function t(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new Re}}e.defaultData=t})(wO||(wO={}));var As="personal camera",Gl="a218fcc3-276b-49b9-b485-49037fd14f5f",EO=2960946;var ai=5526619,w0=(r=>(r.x="x",r.y="y",r.z="z",r))(w0||{}),ss;(f=>{function n(m,p){return m[0]===p[0]&&m[1]===p[1]}f.isEqual=n;function t(m,p,g){return[m[0]+(p[0]-m[0])*g,m[1]+(p[1]-m[1])*g]}f.lerp=t;function e(m,p){return[m[0]+p[0],m[1]+p[1]]}f.add=e;function r(m,p){return[m[0]-p[0],m[1]-p[1]]}f.sub=r;function i(m,p){return[m[0]*p[0],m[1]*p[1]]}f.multiply=i;function s(m,p){return[m[0]/p[0],m[1]/p[1]]}f.divide=s;function o(m,p){return Math.pow(p[0]-m[0],2)+Math.pow(p[1]-m[1],2)}f.distanceSquared=o;function a(m,p){return Math.sqrt(o(m,p))}f.distance=a;function l(m,p){return m[0]*p[0]+m[1]*p[1]}f.dot=l;function c(m,p){return[m[0]*p,m[1]*p]}f.scalarMultiply=c;function u(m,p,g){let y=f.sub(p,m),x=f.sub(g,m),v=f.dot(y,x)/f.dot(y,y),b=f.scalarMultiply(y,v);return f.add(m,b)}f.projectionOnto=u;function h(m,p,g){return a(m,u(m,p,g))}f.projectionOntoDistance=h;function d(m,p){return[(m[0]+p[0])*.5,(m[1]+p[1])*.5]}f.center=d})(ss||(ss={}));var ws;(a=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}a.isEqual=n;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}a.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}a.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}a.div=r;function i(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}a.mul=i;function s(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}a.dist=s;function o(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}a.lerp=o})(ws||(ws={}));var eu;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}e.isEqual=n;function t(r,i,s){return[r[0]+(i[0]-r[0])*s,r[1]+(i[1]-r[1])*s,r[2]+(i[2]-r[2])*s,r[3]+(i[3]-r[3])*s]}e.lerp=t})(eu||(eu={}));var AO;(o=>{let n=180/Math.PI,t=Math.PI/180;function e(a){return typeof a=="number"?a*n:a}function r(a){return typeof a=="number"?a*t:a}function i(a){return[e(a[0]),e(a[1]),e(a[2])]}o.radToDeg=i;function s(a){return[r(a[0]),r(a[1]),r(a[2])]}o.degToRad=s})(AO||(AO={}));var zl;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=t;function e(s){return s??i.identity}i.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,c=o.length;l<c;l+=3){let u=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/u,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/u,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/u}return a}i.applyMatrix4=r})(zl||(zl={}));var Fr;(d=>{function n(f){return typeof f=="object"&&typeof f.r=="number"&&typeof f.g=="number"&&typeof f.b=="number"}d.isRGB=n,d.white={r:1,g:1,b:1},d.red={r:1,g:0,b:0},d.black={r:0,g:0,b:0};function i(f){return{r:Math.round(f.r*255),g:Math.round(f.g*255),b:Math.round(f.b*255),a:1}}d.toRgb255a1=i;function s(f){return{r:f.r,g:f.g,b:f.b}}d.clone=s;function o(f){return f=Math.floor(f),{r:(f>>16&255)/255,g:(f>>8&255)/255,b:(f&255)/255}}d.fromHex=o;function a(f){return Math.round(f.r*255)*65536+Math.round(f.g*255)*256+Math.round(f.b*255)}d.toHex=a;function l(f,m){return f.r===m.r&&f.g===m.g&&f.b===m.b}d.equals=l;function c(f,m){return f.r.toFixed(2)===m.r.toFixed(2)&&f.g.toFixed(2)===m.g.toFixed(2)&&f.b.toFixed(2)===m.b.toFixed(2)}d.equalsFixed=c;function u(f,m,p){return{r:f.r+(m.r-f.r)*p,g:f.g+(m.g-f.g)*p,b:f.b+(m.b-f.b)*p}}d.lerp=u;function h(f){return kr(f)?"r"in f&&"g"in f&&"b"in f&&!("a"in f):!1}d.is=h})(Fr||(Fr={}));var At;(u=>{u.white={...Fr.white,a:1};function t(h){return kr(h)?"r"in h&&"g"in h&&"b"in h&&"a"in h:!1}u.is=t,u.transparent={...Fr.white,a:0};function r(h){return{r:h[0],g:h[1],b:h[2],a:h[3]}}u.from0to1=r;function i(h,d){return{...Fr.fromHex(h),a:d}}u.fromHexAndA=i;function s(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:h.a}}u.toRgb255a1=s;function o(h,d){return Fr.equals(h,d)&&h.a===d.a}u.equals=o;function a(h,d){return Fr.equalsFixed(h,d)&&h.a.toFixed(2)===d.a.toFixed(2)}u.equalsFixed=a;function l(h,d,f){return{r:h.r+(d.r-h.r)*f,g:h.g+(d.g-h.g)*f,b:h.b+(d.b-h.b)*f,a:h.a+(d.a-h.a)*f}}u.lerp=l;function c({r:h,g:d,b:f,a:m}=u.white){return`rgba(${h*255}, ${d*255}, ${f*255}, ${m})`}u.toStyle=c})(At||(At={}));var S0;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(S0||(S0={}));var tu=(c=>(c[c.LINEAR=0]="LINEAR",c[c.EASE=1]="EASE",c[c.EASE_IN=2]="EASE_IN",c[c.EASE_OUT=3]="EASE_OUT",c[c.EASE_IN_OUT=4]="EASE_IN_OUT",c[c.CUBIC=5]="CUBIC",c[c.SPRING=6]="SPRING",c[c.ARC=7]="ARC",c[c.NONE=8]="NONE",c))(tu||{}),ld;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(ld||(ld={}));var cd;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(cd||(cd={}));var Na;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(Na||(Na={}));function CA(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Ks;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Ks||(Ks={}));var jl;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}i.getZoom=r})(jl||(jl={}));var Bo;(r=>{function n(i,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(typeof i[0]=="number"?i[0]:1,typeof i[1]=="number"?i[1]:1)*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[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",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof i[0]=="number"?i[0]+i[0]:1)*s,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:i.map(o=>(typeof o=="number"?o:1)*(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"}}}r.defaultData=n;function t(i,s){let o={...i};if(PA.forEach(a=>{Object.assign(o,{[a]:s[a]??i[a]})}),o.radial={...i.radial},s.radial){let a=i.radial,l=s.radial;E0.forEach(c=>{Object.assign(o.radial,{[c]:l[c]??a[c]})})}if(o.linear={...i.linear},s.linear){let a=i.linear,l=s.linear;T0.forEach(c=>{Object.assign(o.linear,{[c]:l[c]??a[c]})})}if(o.grid={...i.grid},s.grid){let a=i.grid,l=s.grid;M0.forEach(c=>{Object.assign(o.grid,{[c]:l[c]??a[c]})})}if(o.toObject={...i.toObject},s.toObject){let a=i.toObject,l=s.toObject;C0.forEach(c=>{Object.assign(o.toObject,{[c]:l[c]??a[c]})})}if(o.randomnessObject={...i.randomnessObject},s.randomnessObject){let a=i.randomnessObject,l=s.randomnessObject;P0.forEach(c=>{Object.assign(o.randomnessObject,{[c]:l[c]??a[c]})})}return o}r.merge=t;function e(i){return!!(i.randomnessObject||i.toObject)}r.isPartial=e})(Bo||(Bo={}));var A0;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of t){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(A0||(A0={}));var PA=["count"],E0=["radius","start","end","position","scale","rotation"],T0=["position","scale","rotation"],M0=["count","size"],C0=["count","position","scale","rotation"],P0=["strength","scale","rotation","position","movement","seed","freqScale"];var _0;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(_0||(_0={}));var I0;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:At.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:At.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:At.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(I0||(I0={}));var ud;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(ud||(ud={}));var Hl;(t=>t.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]})(Hl||(Hl={}));var DA=(r=>(r[r.Front=0]="Front",r[r.Back=1]="Back",r[r.Double=2]="Double",r))(DA||{}),_A;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(_A||(_A={}));var IA;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe}e.equals=t})(IA||(IA={}));var D0;(t=>t.defaultData={...IA.defaultData,..._A.defaultData})(D0||(D0={}));var TO;(t=>{function n(e,r){let i=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&i.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;o&&i.push(o)}return i}t.getMaterialData=n})(TO||(TO={}));var hd;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(hd||(hd={}));var MO;(t=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=n})(MO||(MO={}));function PO(n){return n.type!=="displace"}var CO;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(CO||(CO={}));var O0=(r=>(r[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",r))(O0||{}),bm=(r=>(r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",r))(bm||{}),R0=(r=>(r[r.NearestFilter=1003]="NearestFilter",r[r.LinearFilter=1006]="LinearFilter",r[r.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",r))(R0||{}),OA=(s=>(s[s.UV=0]="UV",s[s.Planar=1]="Planar",s[s.Spherical=2]="Spherical",s[s.Cylindrical=3]="Cylindrical",s[s.Triplanar=4]="Triplanar",s))(OA||{}),RA=(o=>(o[o.Simplex=0]="Simplex",o[o.SimplexFractal=1]="SimplexFractal",o[o.Ashima=2]="Ashima",o[o.Fbm=3]="Fbm",o[o.Perlin=4]="Perlin",o[o.Voronoi=5]="Voronoi",o))(RA||{}),L0=(l=>(l[l.F1=0]="F1",l[l.F2=1]="F2",l[l.F2MinusF1=2]="F2MinusF1",l[l.SmoothBlend=3]="SmoothBlend",l[l.Edge=4]="Edge",l[l.Power=5]="Power",l[l.Lines=6]="Lines",l[l.Cells=7]="Cells",l))(L0||{}),LA=(r=>(r[r.Lights=0]="Lights",r[r.Static=1]="Static",r[r.Camera=2]="Camera",r))(LA||{}),NA=(l=>(l[l.Circle=0]="Circle",l[l.Ring=1]="Ring",l[l.Polygon=2]="Polygon",l[l.Cross=3]="Cross",l[l.Diamond=4]="Diamond",l[l.Checkerboard=5]="Checkerboard",l[l.Line=6]="Line",l[l.Wave=7]="Wave",l))(NA||{}),N0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],_O=["wrapping","image","video","name","minFilter","magFilter"],Cr;(s=>{function n(o,a){let{texture:l,...c}=a;if(Object.assign(o,c),l){let u=o.texture;u&&Object.assign(u,l)}}s.patch=n;function t(o){return{...s.defaultData("color"),color:o}}s.defaultColorLayer=t;function e(o,a){return o==="light"&&a?r(a):i(o)}s.defaultData=e;function r(o){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(o){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function i(o){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(o){case"texture":return{...a,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],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:hd.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...a,type:"color",color:Fr.fromHex(ai)};case"depth":return{...a,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{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,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{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Fr.fromHex(6710886),a:1},colorB:{...Fr.fromHex(6710886),a:1},colorC:{...Fr.fromHex(16777215),a:1},colorD:{...Fr.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{...a,type:"fresnel",color:At.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,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:At.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:At.fromHexAndA(0,1),contourColor:At.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{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...a,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{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Fr.fromHex(0),a:1},colorB:{...Fr.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}}}})(Cr||(Cr={}));var Kr;(u=>{function n(h){return!h.layers.some(f=>f.data.type==="texture"&&f.data.projection!==0||f.data.type==="depth"&&!f.data.isWorldSpace||f.data.type==="noise"||f.data.type==="displace")}u.isMergable=n;function t(h){let d="";return h.layers.forEach(f=>{Object.entries(f.data).forEach(([m,p])=>{d+=`${m}${p}`,Array.isArray(p)?p.forEach(g=>d+=`${g}`):typeof p=="object"?Object.values(p).forEach(g=>{typeof g=="number"?d+=`${g.toFixed(4)}`:d+=`${g}`}):d+=`${p}`})}),d}u.getHash=t;function e(){return{layers:new Re}}u.defaultEmptyData=e;function r(h="layer1",d="layer2"){return s("phong",h,d)}u.defaultData=r;function i(h,d){return{...h,name:d}}u.withName=i;function s(h,d="layer1",f="layer2",m=Fr.fromHex(16777215)){let p=new Re;return p.push({fi:0,data:Cr.defaultData("light",h),id:d}),p.push({fi:1,data:Cr.defaultData("color"),id:f}),{layers:p}}u.defaultTwoLayerData=s;function o(h,d,f="layer1",m="layer2"){let p=new Re;return p.push({fi:0,data:Cr.defaultData("light",d),id:f}),p.push({fi:1,data:Cr.defaultColorLayer(h),id:m}),{layers:p}}u.defaultColorMaterial=o;function a(h){let d=Cr.defaultData("texture");h&&Object.assign(d.texture,{image:h});let f=new Re;return f.push({fi:0,data:d,id:"layer1"}),f.push({fi:1,data:{...Cr.defaultData("transmission"),alpha:1},id:"layer2"}),f.push({fi:2,data:{...Cr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:f}}u.defaultUIObjectMaterial=a;function l(h,d="phong",f="layer1",m="layer2"){let p=Cr.defaultData("texture");Object.assign(p.texture,{image:h});let g=new Re;return g.push({fi:0,data:p,id:f}),g.push({fi:1,data:Cr.defaultData("light",d),id:m}),{layers:g}}u.defaultTwoLayerTextureData=l;function c(h,d="phong",f="layer1",m="layer2"){let p=Cr.defaultData("video");Object.assign(p.texture,{video:h});let g=new Re;return g.push({fi:0,data:p,id:f}),g.push({fi:1,data:Cr.defaultData("light",d),id:m}),{layers:g}}u.defaultTwoLayerVideoTextureData=c})(Kr||(Kr={}));var dd;(t=>{function n(){return{points:new Re,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(dd||(dd={}));var fd;(t=>{function n(){return{points:new Re,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}t.defaultData=n})(fd||(fd={}));var ru={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var B0;(t=>{function n(e,r){let i={...e};return V0.forEach(s=>{Object.assign(i,{[s]:r[s]??e[s]})}),i}t.merge=n})(B0||(B0={}));var F0={shape:ru,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},V0=["depth","offset","angle","twist","startScale","endScale"];var Sm;(r=>{function n(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"}r.is2DParametricMesh=n;function t(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="BooleanGeometry"||i==="TextGeometry"||i==="InputGeometry"}r.isParametricMesh=t;function e(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="TextGeometry"||i==="SubdivGeometry"||i==="NonParametricGeometry"}r.isSwappableGeometry=e})(Sm||(Sm={}));var U0;(t=>{function n(e,r){let i={...e};return Object.assign(i,r),i.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,B0.merge(i.extrusion,r.extrusion))),i}t.merge=n})(U0||(U0={}));var Fo;(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:fd.defaultData(),extrusion:F0};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:dd.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="ShapeBlendGeometry")return{type:e,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="InputGeometry")return{...t.defaultData("TextGeometry"),type:e,editable:!0};if(e==="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")}t.defaultData=n})(Fo||(Fo={}));var k0=["width","height","depth"];var z0;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Fr.white,near:.1,far:2e3})(z0||(z0={}));var pd;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focusDistance:100,focalLength:20,bokehScale:5},noise:{...n,blendFunction:16}}})(pd||(pd={}));var BA;(t=>t.defaultData={softShadowQuality:"low"})(BA||(BA={}));var FA;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(FA||(FA={}));var VA;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(VA||(VA={}));var Wl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Wl||(Wl={}));var UA;(t=>t.defaultData={playCamera:As,gameControlObject:null})(UA||(UA={}));var G0;(t=>t.defaultData={backgroundColor:At.fromHexAndA(EO,1),postprocessing:pd.defaultData,fog:z0.defaultData,globalPhysics:Wl.defaultData,ambient:FA.defaultData,ao:VA.defaultData,shadow:BA.defaultData,publish:UA.defaultData})(G0||(G0={}));var j0;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(j0||(j0={}));var IO;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(IO||(IO={}));var md;(i=>{i.identity={...S0.identity,hiddenMatrix:zl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,pivot:s.pivot,pivotRotation:s.pivotRotation,hiddenMatrix:s.hiddenMatrix}}i.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,pivot:o?.pivot||s.pivot,pivotRotation:o?.pivotRotation||s.pivotRotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=e;function r(s,o){return Wv({position:ws.isEqual(s.position,o.position)?void 0:o.position,rotation:ws.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:ws.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:zl.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=r})(md||(md={}));var LO=["slide","offset"],li;(t=>t.defaultData={states:new Re,events:new Re,timelineAnimations:new He,visible:!0,raycastLock:!1,physics:Hl.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...md.identity,cloner:null})(li||(li={}));var H0;(t=>t.defaultData={type:"Empty",...li.defaultData})(H0||(H0={}));var DO;(t=>t.defaultData={type:"ParticleCollider",...j0.defaultData,...li.defaultData})(DO||(DO={}));var OO;(t=>t.defaultData={type:"Component",...li.defaultData})(OO||(OO={}));var RO;(t=>t.defaultData={type:"Particle",...li.defaultData,...ud.defaultData})(RO||(RO={}));var Ba;(t=>t.defaultData={type:"Mesh",...li.defaultData,...D0.defaultData})(Ba||(Ba={}));var iu;(t=>t.defaultData={...li.defaultData,...md.identity,position:[0,0,jl.DefaultTargetOffset],...jl.defaultData})(iu||(iu={}));var W0;(e=>{function n(r){return{...li.defaultData,...I0.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(W0||(W0={}));var gd;(e=>{function n(r,i,s=0){for(;s<i.length;){let o=r?r[i[s]]:void 0;if(i.length===s+1)return o;if(o)r=o.descendants,s+=1;else return}}e.resolveWithDes=n;function t(r,i,s=0){let o=n(r,i,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(gd||(gd={}));var Vo;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...li.defaultData,...a,component:o,overrides:new lr,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function i(o){let a=md.fromObject(o.data);return r(o.id,a)}s.fromComponentData=i})(Vo||(Vo={}));var Fa;(e=>{e.defaultData={type:"Page",...li.defaultData,physics:{...Hl.defaultData,fusedBody:!1},...G0.defaultData,camera:iu.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(Fa||(Fa={}));var q0;(a=>(a.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:zl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Hl.defaultData,states:new Re,events:new Re,timelineAnimations:new He,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...jl.defaultData},a.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"]},a.defaultMeshObject={name:"Rectangle",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("RectangleGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},a.defaultBooleanObject={name:"Boolean",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("BooleanGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},a.defaultShapeBlendObject={name:"Shape Blend",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("ShapeBlendGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},a.defaultTextObject={name:"Text",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("TextGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},a.defaultInputObject={name:"Input",...li.defaultData,...Ba.defaultData,geometry:Fo.defaultData("InputGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")}))(q0||(q0={}));var Qs;(i=>{function n(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new lr}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new lr})))):Ks.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=n;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Fl(a.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(o.material.layers)){let h=l.layers.data(c);h&&Cr.patch(h,u)}}).data),a.materials&&o.materials&&(a.materials=Fl(a.materials,l=>{for(let c=0;c<a.materials.length;c++){let u=o.materials[c];if(typeof u!="string")for(let[h,d]of Object.entries(u.layers)){let f=l[c]?.layers?.data(h);f&&Cr.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],c={orthographic:0,perspective:0,geometry:0};function u(h,d){for(let[f,m]of Object.entries(d.layers)){let{texture:p,...g}=m;if(p!==void 0&&Object.keys(p).length>0){let y={path:[...h,"layers",f,"texture"],props:p,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...A0.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")u(["material"],d);else if(h==="materials")for(let[f,m]of Object.entries(d))u(["materials",f],m);else if(c[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}i.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,md.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Ks.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:U0.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bo.merge(a.cloner,o.cloner)});else if(_0.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=Fr.clone(l.color))}return a}i.patch=r})(Qs||(Qs={}));var yd;(t=>t.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,rotationSpeed:1,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})(yd||(yd={}));var Es;(t=>t.defaultData={orbitControls:yd.defaultData,playPage:Gl,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let i=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?i=30:(r===4||r===11||r===9)&&(i=-30),[120,[i,s],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(Es||(Es={}));var kA;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(kA||(kA={}));var zA;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(zA||(zA={}));var Va;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...kA.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:zA.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Va||(Va={}));var ql;(e=>{function n(r){return r.find(i=>i.data.type==="Page"&&i.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,i,s){r.scene.objects.traverseFrom(i,(o,a)=>{if(a.type==="Instance"){let l=Uo.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(ql||(ql={}));var Ua;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:W0.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,h=[]){let d=[],f=q0.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...h);let m=new wr;return m.push({fi:1,id:Gl,data:{...Fa.defaultData,name:"Scene 1"},children:d}),m}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Es.defaultData,styles:Va.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new wr,publish:Es.defaultData,styles:Va.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Es.defaultData,styles:Va.defaultData()}},c.emptyData=function(){return{objects:new wr,publish:{...Es.defaultData},styles:Va.defaultData()}};function a(u){return{...c.defaultData,objects:Ri(u,wr.prototype)}}c.withObjs=a;function l(u,h){return a([{id:u,data:h,children:[],fi:0}])}c.withObj=l})(Ua||(Ua={}));var vd;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(vd||(vd={}));var X0;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new Re}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(X0||(X0={}));var NO;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new Re,queries:new Re,autoStart:!0}))(NO||(NO={}));var Gr;(s=>{function n(o){return o.textValue!==void 0}s.isTextValue=n;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return n(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function i(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=i})(Gr||(Gr={}));var GA;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(GA||(GA={}));var BO;(t=>t.all=[...GA.all,"components"])(BO||(BO={}));var FO;(t=>{function n(){return{images:new He,videos:new He,colors:new He,audios:new He,particles:new He,fonts:new He,materials:new He,components:new He,variables:new He,userAPIs:new He,userWebhooks:new He,timelineAnimations:new He}}t.defaultData=n})(FO||(FO={}));var Zs;(t=>{function n(){return{images:new He,videos:new He,colors:new He,audios:new He,particles:new He,fonts:new He,materials:new He,components:new He,variables:new He,userAPIs:new He,userWebhooks:new He,timelineAnimations:new He}}t.defaultData=n})(Zs||(Zs={}));var An;(s=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ri(o,He.prototype)}s.defaultColors=n;function t(){return Ri({},He.prototype)}s.defaultImages=t;function e(){return{catelogs:new He,materials:new He,images:new He,videos:new He,colors:new He,timelineAnimations:new He,audios:new He,particles:new He,fonts:new He,variables:new Re,userAPIs:new He,userWebhooks:new He,lib:Zs.defaultData()}}s.emptyData=e;function r(o){switch(o){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 a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,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",o)}}s.defaultVariables=r;function i(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),c=Math.floor((o-l*3600)/60),u=Math.round(o-l*3600-c*60);return{textValue:[l,c,u]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),c=Math.round(o-l*60);return{textValue:[l,c]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=i})(An||(An={}));var xd;(t=>t.list=["idle","move","jump","run"])(xd||(xd={}));var bd;(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 Re,move:new Re,jump:new Re,run:new Re},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:At.fromHexAndA(3728051,1)}}))(bd||(bd={}));function VO(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,i=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...Nn(Yr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...Yr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function ka(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function za(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((i,s)=>{i===void 0&&(r.materials[s]=Kr.defaultData(),i=r.materials[s]),typeof i!="string"&&t(i)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Kr.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Kr.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(i=>{i.material&&typeof i.material!="string"&&Object.getPrototypeOf(i.material)!==lr.prototype&&t(i.material)})})}function gX(n){Object.assign(n.scene.publish,{orbitControls:{...yd.defaultData,...Yr(n.scene.publish.orbitControls)}})}function yX(n){Object.assign(n.scene.publish.settings,{video:{...Es.defaultData.settings.video,...Yr(n.scene.publish.settings.video)}})}function vX(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[i,s]of Object.entries(r))if((N0.includes(i)||typeof s=="boolean")&&delete r[i],i==="texture")for(let[o,a]of Object.entries(s))(_O.includes(o)||typeof a=="boolean")&&delete s[o]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(i=>{let s=i;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function xX(n){n.scene.publish.withBackground=!0}function bX(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function SX(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(i=>i+1),r.linear.scale=r.linear.scale.map(i=>i+1))})}function wX(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function AX(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let i=Yr(n.scene.objects.data(r));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Yr(e).booleanExclude!==!0)}})}function EX(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function TX(n){function t(r){Object.setPrototypeOf(r,lr.prototype),r.texture&&Object.setPrototypeOf(r.texture,lr.prototype)}function e(r){Object.setPrototypeOf(r,lr.prototype);for(let i in r)t(r[i])}n.scene.objects.traverse((r,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=Yr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],c=Yr(l).layers;e(c),l.layers=c}})})}function UO(n){n.layers===void 0&&Object.assign(n,Kr.defaultTwoLayerData("lambert"))}function jA(n){!n.layers||n.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let i={...Yr(t),colors:e,steps:r};Object.assign(t,i)}})}function MX(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function kO(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&jA(r)}):"material"in e&&typeof e.material!="string"&&jA(e.material)}),Object.values(n.shared.materials).forEach(t=>jA(t))}function CX(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function PX(n){n.shared.audios=Ri({},He.prototype)}function _X(n){n.shared.videos=Ri({},He.prototype)}function IX(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let i={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,{[e]:i})}})}function DX(n){Object.entries(Yr(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(Yr(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function OX(n){n.scene.publish.settings.web.preload=!1}function zO(n){n.layers&&n.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 GO(n){n.layers&&n.layers.forEach(t=>{PO(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 RX(n){n.shared.fonts=Ri({},He.prototype)}function LX(n){return n.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(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function NX(n){let t=[];n.scene.objects.traverse((e,r)=>{let i=r;if(i.type==="TextFrame"){let s=Kr.defaultTwoLayerData("phong"),o=typeof i.color=="string"?n.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=LX(i.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let l={name:i.name,...li.defaultData,...Ba.defaultData,flatShading:!1,wireframe:!1,geometry:{...Fo.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Yr(i.states),events:Yr(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},c=Yr(n.scene.objects).parent(e);n.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function BX(n){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,r)=>{r.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new Re,move:new Re,jump:new Re}});else{let s=new Re;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:Se.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(u,Nn(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(u,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...u},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Re({fi:0,id:Se.generateUUID(),data:c},{fi:1,id:Se.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function FX(n){n.scene.objects.traverse((t,e)=>{function r(i,s){let o=new Re,a=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(c),l.interaction==="play"?h={...Nn(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")&&(h={...Nn(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:u,id:c,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(c=>c.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Se.generateUUID(),data:{type:i,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function jO(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Cr.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function HO(n){ka(n,jO),za(n,jO)}function VX(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function UX(n){n.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.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 kX(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Kr.defaultTwoLayerData("phong"))})}function zX(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function GX(n){n.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function jX(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function HX(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function WX(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function qX(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function XX(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=bd.defaultDataThirdPerson.navmesh)})})}function YX(n){n.scene.styles||(n.scene.styles=Va.defaultData())}function WO(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function KX(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),za(n,WO),ka(n,WO)}function QX(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Re})})})}function ZX(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function qO(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function XO(n,t){if(t<1&&(za(n,VO),ka(n,VO),n.schema=1),t<2&&(gX(n),n.schema=2),t<3&&(vX(n),n.schema=3),t<4&&(xX(n),n.schema=4),t<5&&(bX(n),n.schema=5),t<6&&(SX(n),n.schema=6),t<7&&(wX(n),n.schema=7),t<8&&(n.schema=8),t<9&&(kO(n),n.schema=9),t<10&&(MX(n),n.schema=10),t<11&&(CX(n),n.schema=11),t<12&&(kO(n),n.schema=12),t<13&&(PX(n),n.schema=13),t<14&&(IX(n),n.schema=14),t<15&&(DX(n),n.schema=15),t<16&&(OX(n),n.schema=16),t<17&&(za(n,zO),ka(n,zO),n.schema=17),t<18&&(za(n,UO),ka(n,UO),n.schema=18),t<19&&(yX(n),n.schema=19),t<20&&(RX(n),NX(n),n.schema=20),t<21&&(BX(n),FX(n),n.schema=21),t<22&&(HO(n),n.schema=22),t<23&&(VX(n),n.schema=23),t<24&&(UX(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(_X(n),t<25&&(n.schema=25)),t<26&&(AX(n),n.schema=26),t<27&&(EX(n),n.schema=27),t<28&&(HO(n),n.schema=28),t<29&&(TX(n),n.schema=29),t<30&&(kX(n),n.schema=30),t<31&&(zX(n),n.schema=31),t<33&&(GX(n),n.schema=33),t<34&&(jX(n),n.schema=34),t<35&&(HX(n),n.schema=35),t<36&&(WX(n),n.schema=36),t<37&&(qX(n),n.schema=37),t<38&&(za(n,GO),ka(n,GO),n.schema=38),t<39&&(XX(n),n.schema=39),t<40&&(YX(n),n.schema=40),t<41&&(KX(n),n.schema=41),t<42&&(QX(n),n.schema=42),t<43&&(ZX(n),n.schema=43),t<99){za(n,qO),ka(n,qO),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=As);let e=Yr(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=Gl,r.insertBefore(null,null,[{id:Gl,data:{...Fa.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Nn(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Nn(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Wl.defaultData,...Nn(n.scene.environment,"usePhysics","gravity")},camera:Yr(n.scene.ownerCamera)??Fa.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==Ua.TRASH_CAN_ID&&r.move(Gl,o.fi,o.id);let i=0,s=0;n.shared.penumbraSize&&n.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=n.shared.penumbraSize[Math.min(i,2)],i+=1):a.type==="SpotLight"&&(a.penumbraSize=n.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Hl.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}function YO(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function JX(n){n.scene.objects.traverse((t,e)=>{let r=e.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"))})}function $X(n){Array.isArray(Yr(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Sd=180/Math.PI;function KO(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Sd)}function QO(n){KO(n),n.type==="Page"&&KO(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Sd))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Sd),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Sd),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Sd,t.extrusion.twist*=Sd),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(Yr(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function eY(n){n.shared.variables=Ri({},He.prototype)}function tY(n){let t=Yr(n.shared.variables);n.shared.variables=Ri(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),Re.prototype)}var ko=122;function Y0(n,t){t(n.data);for(let e of n.children)Y0(e,t)}function rY(n){let t=n.schema??104;t!==ko&&(t<105&&(Y0(n.asset,QO),n.schema=105),t<118&&(Y0(n.asset,ZO),n.schema=118),t<121&&(Y0(n.asset,HA),n.schema=121))}function iY(n){n.shared.particles=Ri({},He.prototype),n.shared.lib&&(n.shared.lib.particles=Zs.defaultData().particles)}function nY(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function sY(n){n.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function oY(n){n.scene.objects.traverse((t,e)=>{Array.isArray(Yr(e.events))!==!1&&e.events?.forEach(r=>{let i=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode=i??"Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode=i==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(o=>{r.gameActions[o]?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),a.type==="Animation"&&(a.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(s=>{s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Once"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}),r.outActions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}))})})}function aY(n){n.shared.userAPIs=Ri({},He.prototype),n.shared.userWebhooks=Ri({},He.prototype),n.shared.lib&&(n.shared.lib.userAPIs=Zs.defaultData().userAPIs,n.shared.lib.userWebhooks=Zs.defaultData().userWebhooks)}function lY(n){n.scene.publish.settings.videoStatic===void 0&&(n.scene.publish.settings.videoStatic=Es.defaultData.settings.videoStatic)}function ZO(n){n.timelineAnimations=Ri({},He.prototype)}function HA(n){console.log("Updating pivot for object:",n.name),n.pivot=[0,0,0],n.pivotRotation=[0,0,0]}function K0(n){let t=n.schema??0;if(t!==ko){console.warn("updating from ",t,"to ",ko),XO(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Es.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(za(n,YO),ka(n,YO),n.schema=101),t<102&&(JX(n),n.schema=102),t<104&&(n.shared.catelogs=new He,n.shared.lib=Zs.defaultData(),n.schema=104),t<105&&(eY(n),n.scene.objects.traverse((e,r)=>{QO(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))rY(e);t<106&&(tY(n),n.schema=106),t<107&&(n.shared.lib.variables=Zs.defaultData().variables,n.schema=107),t<109&&(iY(n),n.schema=109),t<110&&(nY(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{$X(r)}),n.schema=111),t<112&&(sY(n),n.schema=112),t<113&&(oY(n),n.schema=113),t<114&&(n.scene.publish.settings.web.imageQuality===void 0&&(n.scene.publish.settings.web.imageQuality=70),n.schema=114),t<115&&(aY(n),n.schema=115),t<116&&(lY(n),n.schema=116),t<117&&(n.scene.publish.settings.web.pixelRatioMobile===void 0&&(n.scene.publish.settings.web.pixelRatioMobile=0),n.scene.publish.settings.web.pixelRatioDesktop===void 0&&(n.scene.publish.settings.web.pixelRatioDesktop=0),n.schema=117),t<118&&(n.shared.timelineAnimations=Ri({},He.prototype),n.scene.objects.traverse((e,r)=>{ZO(r)}),n.schema=118),t<119&&(n.scene.publish.settings.videoStatic.format=Uo.defaultData.scene.publish.settings.videoStatic.format,n.scene.publish.settings.videoStatic.imageFormat=Uo.defaultData.scene.publish.settings.videoStatic.imageFormat,n.schema=119),t<120&&(n.scene.publish.settings.image.colorSpace="display-p3",n.scene.publish.settings.videoStatic.colorSpace="display-p3",n.schema=120),t<121&&(n.scene.objects.traverse((e,r)=>{HA(r),r.type==="Page"&&HA(r.camera)}),n.schema=121),t<122&&(delete n.scene.publish.settings.video,n.scene.publish.orbitControls.rotationSpeed=Uo.defaultData.scene.publish.orbitControls.rotationSpeed,n.schema=122)}}var Uo;(c=>{c.defaultData={schema:ko,scene:Ua.defaultData,frames:new He().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",vd.defaultData),shared:{...An.emptyData(),colors:An.defaultColors()}},c.emptyDataForImports=function(){let u=Ua.emptyDataWithPage();return{schema:ko,scene:u,frames:new He().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",vd.defaultData),shared:{...An.emptyData(),colors:An.defaultColors(),images:An.defaultImages()}}},c.emptyData=function(){return{schema:ko,scene:Ua.emptyDataWithPage(),frames:new He().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",vd.defaultData),shared:An.emptyData()}},c.clipboard2dData=function(){return{schema:ko,scene:Ua.emptyData(),frames:new He,shared:An.emptyData()}},c.collabHelper={...pm,updateSchema(u){return(u.schema??0)<ko?Fl(u,K0):(u.schema??0)-ko}};function s(u){let h=c.collabHelper.updateSchema(u);return typeof h=="number"?h===0?u:null:h.data}c.updateSchemaDirectly=s;function o(u){return{...u,shared:{...u.shared,lib:Zs.defaultData()}}}c.withoutLib=o;function a(u,h){let d=u.scene.objects.get(h);if(d&&d.data.type==="Component")return d;{let f=u.shared.lib.components[h];if(f)return{...f.asset,id:h}}}c.getComponentData=a;function l(u){let h=Object.values(u.shared.userAPIs);for(let d of h){let f=d.headers;for(let m of f)if(m.data.key.toLowerCase()==="authorization"&&m.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(Uo||(Uo={}));var Q0;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Q0||(Q0={}));var JO;(t=>{function n(e){return!0}t.is=n})(JO||(JO={}));var Z0;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(i,s){return{position:s?.position??i.position,rotation:s?.rotation??i.rotation,scale:s?.scale??i.scale,shear:s?.shear??i.shear}}r.merge=t;function e(i,s){return Wv({position:ss.isEqual(i.position,s.position)?void 0:s.position,rotation:i.rotation===s.rotation?void 0:s.rotation,scale:ss.isEqual(i.scale,s.scale)?void 0:s.scale,shear:i.shear&&s.shear&&ss.isEqual(i.shear,s.shear)?void 0:s.shear})}r.diff=e})(Z0||(Z0={}));var WA;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(WA||(WA={}));var $O;(t=>t.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})($O||($O={}));var J0;(t=>t.defaultData={opacity:1,fill:{color:At.fromHexAndA(ai,1),enabled:!0},stroke:{color:At.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:At.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:At.from0to1([0,0,0,1]),enabled:!1,spread:0}})(J0||(J0={}));var Ga;(s=>{function n(o,a){return{name:a}}s.newEmpty=n;function t(o,a){if(a===void 0)return o;let l={...o},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in a&&a[u]!==void 0&&Object.assign(l,{[u]:a[u]});return l}function e(o,a){if(a===void 0)return o;let l={...o};return"fill"in l&&"fill"in a&&a.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...a.fill}}),"stroke"in l&&"stroke"in a&&a.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...a.stroke}}),"layerBlur"in l&&"layerBlur"in a&&a.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...a.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in a&&a.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...a.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in a&&a.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...a.dropShadow}}),"innerShadow"in l&&"innerShadow"in a&&a.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...a.innerShadow}}),l}function r(o,a){if(a===void 0)return o;let l={...o};return Object.assign(l,Z0.merge(l,a)),l=t(l,a),l=e(l,a),l}s.patch=r;function i(o,a){let l,c=[];for(let[u,h]of Object.entries(a))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=h);return c}s.toOps=i})(Ga||(Ga={}));var wm;(t=>t.defaultData={...Z0.defaultData,...WA.defaultData,states:new Re,events:new Re,visible:!0,raycastLock:!1})(wm||(wm={}));var wd;(t=>t.defaultData={...wm.defaultData,...J0.defaultData})(wd||(wd={}));var $0;(t=>t.defaultData={cornerRadius:[0,0,0,0]})($0||($0={}));var qA;(t=>t.defaultData={...wd.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(qA||(qA={}));var Ad;(t=>t.defaultData={...wd.defaultData,...$0.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Ad||(Ad={}));var XA;(t=>t.defaultData={...wd.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(XA||(XA={}));var YA;(t=>t.defaultData={...wd.defaultData,type:"path2d",path:"",name:"Path"})(YA||(YA={}));var eR;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(eR||(eR={}));var Am;(t=>t.defaultData={...wm.defaultData,name:"Group",type:"group2d"})(Am||(Am={}));var KA;(t=>t.defaultData=()=>({...wm.defaultData,...$0.defaultData,...J0.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:At.fromHexAndA(4737101,1),enabled:!0},stroke:{color:At.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(KA||(KA={}));var ja;(s=>{function n(o){switch(o){case"rectangle2d":return{...Ad.defaultData};case"ellipse2d":return{...qA.defaultData};case"text2d":return{...XA.defaultData};case"vector2d":return{...Ad.defaultData};case"path2d":return{...YA.defaultData};case"frame2d":return{...KA.defaultData()};case"group2d":return{...Am.defaultData}}}s.defaultData=n;function t(o){return"width"in o&&"height"in o?[typeof o.width=="number"?o.width*.5:0,typeof o.height=="number"?o.height*.5:0]:[0,0]}s.getPivot=t;function e(o){return o.type==="rectangle2d"||o.type==="ellipse2d"||o.type==="text2d"||o.type==="frame2d"}s.isResizeable=e;function r(o){return o.type==="frame2d"&&o.autoLayout!==void 0}s.isAutoLayoutable=r;function i(o){return o.type==="rectangle2d"||o.type==="frame2d"}s.hasCorners=i})(ja||(ja={}));var ex;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new wr},e.emptyData=function(){return{type:"scene2d",objects:new wr}}))(ex||(ex={}));function Js(n,t=!1){let e=n[0].index!==null,r=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),s={},o={},a=n[0].morphTargetsRelative,l=new Ce,c=0;for(let u=0;u<n.length;++u){let h=n[u],d=0;if(e!==(h.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 f in h.attributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),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(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.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(c,f,u),c+=f}}if(e){let u=0,h=[];for(let d=0;d<n.length;++d){let f=n[d].index;for(let m=0;m<f.count;++m)h.push(f.getX(m)+u);u+=n[d].attributes.position.count}l.setIndex(h)}for(let u in s){let h=tR(s[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,h)}for(let u in o){let h=o[u][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<h;++d){let f=[];for(let p=0;p<o[u].length;++p)f.push(o[u][p][d]);let m=tR(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(m)}}return l}function tR(n){let t,e,r,i=0;for(let a=0;a<n.length;++a){let l=n[a];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(e===void 0&&(e=l.itemSize),e!==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;i+=l.array.length}let s=new t(i),o=0;for(let a=0;a<n.length;++a)s.set(n[a].array,o),o+=n[a].array.length;return new je(s,e,r)}var aR={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},eE={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},cY=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],tx={CSS:{},springs:{}};function $s(n,t,e){return Math.min(Math.max(n,t),e)}function Em(n,t){return n.indexOf(t)>-1}function QA(n,t){return n.apply(null,t)}var dt={arr:function(n){return Array.isArray(n)},obj:function(n){return Em(Object.prototype.toString.call(n),"Object")},pth:function(n){return dt.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return!("isNode"in n)&&(n.nodeType||dt.svg(n))},str:function(n){return typeof n=="string"},fnc:function(n){return typeof n=="function"},und:function(n){return typeof n>"u"},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return dt.hex(n)||dt.rgb(n)||dt.hsl(n)},key:function(n){return!aR.hasOwnProperty(n)&&!eE.hasOwnProperty(n)&&n!=="targets"&&n!=="keyframes"}};function lR(n){var t=/\(([^)]+)\)/.exec(n);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function cR(n,t){var e=lR(n),r=$s(dt.und(e[0])?1:e[0],.1,100),i=$s(dt.und(e[1])?100:e[1],.1,100),s=$s(dt.und(e[2])?10:e[2],.1,100),o=$s(dt.und(e[3])?0:e[3],.1,100),a=Math.sqrt(i/r),l=s/(2*Math.sqrt(i*r)),c=l<1?a*Math.sqrt(1-l*l):0,u=1,h=l<1?(l*a+-o)/c:-o+a;function d(m){var p=t?t*m/1e3:m;return l<1?p=Math.exp(-p*l*a)*(u*Math.cos(c*p)+h*Math.sin(c*p)):p=(u+h*p)*Math.exp(-p*a),m===0||m===1?m:1-p}function f(){var m=tx.springs[n];if(m)return m;for(var p=1/6,g=0,y=0;;)if(g+=p,d(g)===1){if(y++,y>=16)break}else y=0;var x=g*p*1e3;return tx.springs[n]=x,x}return t?d:f}function uY(n){return n===void 0&&(n=10),function(t){return Math.ceil($s(t,1e-6,1)*n)*(1/n)}}var hY=function(){var n=11,t=1/(n-1);function e(u,h){return 1-3*h+3*u}function r(u,h){return 3*h-6*u}function i(u){return 3*u}function s(u,h,d){return((e(h,d)*u+r(h,d))*u+i(h))*u}function o(u,h,d){return 3*e(h,d)*u*u+2*r(h,d)*u+i(h)}function a(u,h,d,f,m){var p,g,y=0;do g=h+(d-h)/2,p=s(g,f,m)-u,p>0?d=g:h=g;while(Math.abs(p)>1e-7&&++y<10);return g}function l(u,h,d,f){for(var m=0;m<4;++m){var p=o(h,d,f);if(p===0)return h;var g=s(h,d,f)-u;h-=g/p}return h}function c(u,h,d,f){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var m=new Float32Array(n);if(u!==h||d!==f)for(var p=0;p<n;++p)m[p]=s(p*t,u,d);function g(y){for(var x=0,v=1,b=n-1;v!==b&&m[v]<=y;++v)x+=t;--v;var w=(y-m[v])/(m[v+1]-m[v]),A=x+w*t,T=o(A,u,d);return T>=.001?l(y,A,u,d):T===0?A:a(y,x,x+t,u,d)}return function(y){return u===h&&d===f||y===0||y===1?y:s(g(y),h,f)}}return c}(),uR=function(){var n={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 i,s=4;r<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-r,2)}},Elastic:function(r,i){r===void 0&&(r=1),i===void 0&&(i=.5);var s=$s(r,1,10),o=$s(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(r,i){t[r]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(t).forEach(function(r){var i=t[r];n["easeIn"+r]=i,n["easeOut"+r]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},n["easeInOut"+r]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),n}();function tE(n,t){if(dt.fnc(n))return n;var e=n.split("(")[0],r=uR[e],i=lR(n);switch(e){case"spring":return cR(n,t);case"cubicBezier":return QA(hY,i);case"steps":return QA(uY,i);default:return QA(r,i)}}function hR(n){try{var t=document.querySelectorAll(n);return t}catch{return}}function rx(n,t){for(var e=n.length,r=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<e;s++)if(s in n){var o=n[s];t.call(r,o,s,n)&&i.push(o)}return i}function ix(n){return n.reduce(function(t,e){return t.concat(dt.arr(e)?ix(e):e)},[])}function rR(n){return dt.arr(n)?n:(dt.str(n)&&(n=hR(n)||n),n instanceof NodeList||n instanceof HTMLCollection?[].slice.call(n):[n])}function rE(n,t){return n.some(function(e){return e===t})}function iE(n){var t={};for(var e in n)t[e]=n[e];return t}function ZA(n,t){var e=iE(n);for(var r in n)e[r]=t.hasOwnProperty(r)?t[r]:n[r];return e}function nx(n,t){var e=iE(n);for(var r in t)e[r]=dt.und(n[r])?t[r]:n[r];return e}function dY(n){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(n);return t?"rgba("+t[1]+",1)":n}function fY(n){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=n.replace(t,function(a,l,c,u){return l+l+c+c+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),i=parseInt(r[1],16),s=parseInt(r[2],16),o=parseInt(r[3],16);return"rgba("+i+","+s+","+o+",1)"}function pY(n){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(n)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(n),e=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100,s=t[4]||1;function o(d,f,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(f-d)*6*m:m<1/2?f:m<2/3?d+(f-d)*(2/3-m)*6:d}var a,l,c;if(r==0)a=l=c=i;else{var u=i<.5?i*(1+r):i+r-i*r,h=2*i-u;a=o(h,u,e+1/3),l=o(h,u,e),c=o(h,u,e-1/3)}return"rgba("+a*255+","+l*255+","+c*255+","+s+")"}function mY(n){if(dt.rgb(n))return dY(n);if(dt.hex(n))return fY(n);if(dt.hsl(n))return pY(n)}function Ha(n){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(n);if(t)return t[1]}function gY(n){if(Em(n,"translate")||n==="perspective")return"px";if(Em(n,"rotate")||Em(n,"skew"))return"deg"}function JA(n,t){return dt.fnc(n)?n(t.target,t.id,t.total):n}function zo(n,t){return n.getAttribute(t)}function nE(n,t,e){var r=Ha(t);if(rE([e,"deg","rad","turn"],r))return t;var i=tx.CSS[t+e];if(!dt.und(i))return i;var s=100,o=document.createElement(n.tagName),a=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var c=l*parseFloat(t);return tx.CSS[t+e]=c,c}function dR(n,t,e){if(t in n.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=n.style[t]||getComputedStyle(n).getPropertyValue(r)||"0";return e?nE(n,i,e):i}}function sE(n,t){if(dt.dom(n)&&!dt.inp(n)&&(zo(n,t)||dt.svg(n)&&n[t]))return"attribute";if(dt.dom(n)&&rE(cY,t))return"transform";if(dt.dom(n)&&t!=="transform"&&dR(n,t))return"css";if(n[t]!=null)return"object"}function fR(n){if(!!dt.dom(n)){for(var t=n.style.transform||"",e=/(\w+)\(([^)]*)\)/g,r=new Map,i;i=e.exec(t);)r.set(i[1],i[2]);return r}}function yY(n,t,e,r){var i=Em(t,"scale")?1:0+gY(t),s=fR(n).get(t)||i;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),r?nE(n,s,r):s}function oE(n,t,e,r){switch(sE(n,t)){case"transform":return yY(n,t,r,e);case"css":return dR(n,t,e);case"attribute":return zo(n,t);default:return n[t]||0}}function aE(n,t){var e=/^(\*=|\+=|-=)/.exec(n);if(!e)return n;var r=Ha(n)||0,i=parseFloat(t),s=parseFloat(n.replace(e[0],""));switch(e[0][0]){case"+":return i+s+r;case"-":return i-s+r;case"*":return i*s+r}}function pR(n,t){if(dt.col(n))return mY(n);if(/\s/g.test(n))return n;var e=Ha(n),r=e?n.substr(0,n.length-e.length):n;return t?r+t:r}function lE(n,t){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))}function vY(n){return Math.PI*2*zo(n,"r")}function xY(n){return zo(n,"width")*2+zo(n,"height")*2}function bY(n){return lE({x:zo(n,"x1"),y:zo(n,"y1")},{x:zo(n,"x2"),y:zo(n,"y2")})}function mR(n){for(var t=n.points,e=0,r,i=0;i<t.numberOfItems;i++){var s=t.getItem(i);i>0&&(e+=lE(r,s)),r=s}return e}function SY(n){var t=n.points;return mR(n)+lE(t.getItem(t.numberOfItems-1),t.getItem(0))}function gR(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return vY(n);case"rect":return xY(n);case"line":return bY(n);case"polyline":return mR(n);case"polygon":return SY(n)}}function wY(n){var t=gR(n);return n.setAttribute("stroke-dasharray",t),t}function AY(n){for(var t=n.parentNode;dt.svg(t)&&dt.svg(t.parentNode);)t=t.parentNode;return t}function yR(n,t){var e=t||{},r=e.el||AY(n),i=r.getBoundingClientRect(),s=zo(r,"viewBox"),o=i.width,a=i.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function EY(n,t){var e=dt.str(n)?hR(n)[0]:n,r=t||100;return function(i){return{property:i,el:e,svg:yR(e),totalLength:gR(e)*(r/100)}}}function TY(n,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return n.el.getPointAtLength(l)}var r=yR(n.el,n.svg),i=e(),s=e(-1),o=e(1);switch(n.property){case"x":return(i.x-r.x)*r.w;case"y":return(i.y-r.y)*r.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function iR(n,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=pR(dt.pth(n)?n.totalLength:n,t)+"";return{original:r,numbers:r.match(e)?r.match(e).map(Number):[0],strings:dt.str(n)||t?r.split(e):[]}}function vR(n){var t=n?ix(dt.arr(n)?n.map(rR):rR(n)):[];return rx(t,function(e,r,i){return i.indexOf(e)===r})}function xR(n){var t=vR(n);return t.map(function(e,r){return{target:e,id:r,total:t.length,transforms:{list:fR(e)}}})}function MY(n,t){var e=iE(t);if(/^spring/.test(e.easing)&&(e.duration=cR(e.easing)),dt.arr(n)){var r=n.length,i=r===2&&!dt.obj(n[0]);i?n={value:n}:dt.fnc(t.duration)||(e.duration=t.duration/r)}var s=dt.arr(n)?n:[n];return s.map(function(o,a){var l=dt.obj(o)&&!dt.pth(o)?o:{value:o};return dt.und(l.delay)&&(l.delay=a?0:t.delay),dt.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return nx(o,e)})}function CY(n){for(var t=rx(ix(n.map(function(s){return Object.keys(s)})),function(s){return dt.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},r=function(s){var o=t[s];e[o]=n.map(function(a){var l={};for(var c in a)dt.key(c)?c==o&&(l.value=a[c]):l[c]=a[c];return l})},i=0;i<t.length;i++)r(i);return e}function PY(n,t){var e=[],r=t.keyframes;r&&(t=nx(CY(r),t));for(var i in t)dt.key(i)&&e.push({name:i,tweens:MY(t[i],n)});return e}function _Y(n,t){var e={};for(var r in n){var i=JA(n[r],t);dt.arr(i)&&(i=i.map(function(s){return JA(s,t)}),i.length===1&&(i=i[0])),e[r]=i}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function IY(n,t){var e;return n.tweens.map(function(r){var i=_Y(r,t),s=i.value,o=dt.arr(s)?s[1]:s,a=Ha(o),l=oE(t.target,n.name,a,t),c=e?e.to.original:l,u=dt.arr(s)?s[0]:c,h=Ha(u)||Ha(l),d=a||h;return dt.und(o)&&(o=c),i.from=iR(u,d),i.to=iR(aE(o,u),d),i.start=e?e.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=tE(i.easing,i.duration),i.isPath=dt.pth(s),i.isColor=dt.col(i.from.original),i.isColor&&(i.round=1),e=i,i})}var bR={css:function(n,t,e){return n.style[t]=e},attribute:function(n,t,e){return n.setAttribute(t,e)},object:function(n,t,e){return n[t]=e},transform:function(n,t,e,r,i){if(r.list.set(t,e),t===r.last||i){var s="";r.list.forEach(function(o,a){s+=a+"("+o+") "}),n.style.transform=s}}};function SR(n,t){var e=xR(n);e.forEach(function(r){for(var i in t){var s=JA(t[i],r),o=r.target,a=Ha(s),l=oE(o,i,a,r),c=a||Ha(l),u=aE(pR(s,c),l),h=sE(o,i);bR[h](o,i,u,r.transforms,!0)}})}function DY(n,t){var e=sE(n.target,t.name);if(e){var r=IY(t,n),i=r[r.length-1];return{type:e,property:t.name,animatable:n,tweens:r,duration:i.end,delay:r[0].delay,endDelay:i.endDelay}}}function OY(n,t){return rx(ix(n.map(function(e){return t.map(function(r){return DY(e,r)})})),function(e){return!dt.und(e)})}function wR(n,t){var e=n.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=e?Math.max.apply(Math,n.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,i.delay=e?Math.min.apply(Math,n.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return r(s)+o+a+s.delay})):t.delay,i.endDelay=e?i.duration-Math.max.apply(Math,n.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,i}var nR=0;function RY(n){var t=ZA(aR,n),e=ZA(eE,n),r=PY(e,n),i=xR(n.targets),s=OY(i,r),o=wR(s,e),a=nR;return nR++,nx(t,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var Ts=[],sR=[],Ed,$A=function(){let n=0,t=!0;function e(s){let o=Ts.length;if(o){let a=0;for(;a<o;){let l=Ts[a];l.paused?(Ts.splice(a,1),o--):(l.tick(s),a++)}t&&(Ed=requestAnimationFrame(e))}else Ed&&(cancelAnimationFrame(Ed),Ed=null)}function r(){n=performance.now(),Ed=requestAnimationFrame(e)}function i(s){n+=s,e(n)}return{get isUsingInternalRaf(){return t},set isUsingInternalRaf(s){t=s},play:r,update:i}}();function LY(n){!$A.isUsingInternalRaf||(document.hidden?(Ts.forEach(function(t){return t.pause(n.timeStamp)}),sR=Ts.slice(0),ci.running=Ts=[]):sR.forEach(function(t){return t.play(n.timeStamp)}))}typeof document<"u"&&document.addEventListener("visibilitychange",LY);function ci(n){n===void 0&&(n={});var t=0,e=0,r=0,i,s,o=0,a=null;function l(T){var S=window.Promise&&new Promise(function(M){return a=M});return T.finished=S,S}var c=RY(n),u=l(c);function h(){var T=c.direction;T!=="alternate"&&(c.direction=T!=="normal"?"normal":"reverse"),c.reversed=!c.reversed,s.forEach(function(S){(S.loop===1||S.loop%2===0)&&(S.reversed=c.reversed)})}function d(){c.direction="normal",c.reversed=!1,s.forEach(function(T){return T.reversed=!1})}function f(T){return c.reversed?c.duration-T:T}function m(){t=0,e=f(c.currentTime)*(1/ci.speed)}function p(T,S,M=!1){S&&(c.reversed?S.seek(S.duration*S.loop-(T-S.timelineOffset-S.pingPongDelayCorrection),M):S.seek(T-S.timelineOffset-S.startOnceDelay-S.pingPongDelayCorrection,M))}function g(T,S=!1){if(c.reversed)for(var C=o;C--;)p(T,s[C],S);else for(var M=0;M<o;M++)p(T,s[M],S)}function y(T){var S=0,M=c.animations,C=M.length;for(c.direction!=="alternate"&&c.parent?.direction==="alternate"?c.parent?.rewind===!1&&c.reversePlayback===!0&&c.rewind===!1&&(c.parent?.reversed&&c.direction==="alternate"?T=c.duration-c.delay+c.endDelay-T:T=c.duration+c.delay-c.endDelay-T):w(!1,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)&&(c.parent?.reversed&&c.direction==="alternate"?T=c.duration-c.delay+c.endDelay-T:T=c.duration+c.delay-c.endDelay-T);S<C;){var P=M[S],_=P.animatable,I=P.tweens,O=I.length-1,L=I[O];O&&(L=rx(I,function(J){return T<J.end})[0]||L);let re;c.parent?.reversed&&c.direction==="alternate"?re=$s(T-L.start-L.endDelay,0,L.duration)/L.duration:re=$s(T-L.start-L.delay,0,L.duration)/L.duration;for(var j=isNaN(re)?1:L.easing(re),V=L.to.strings,H=L.round,q=[],X=L.to.numbers.length,K=void 0,z=0;z<X;z++){var Q=void 0;let J,Ee;c.direction!=="alternate"?c.parent?.rewind===!1&&c.reversePlayback===!0&&c.rewind===!1?(J=L.to.numbers[z],Ee=L.from.numbers[z]||0):(Ee=L.to.numbers[z],J=L.from.numbers[z]||0):w(!0,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)?(J=L.to.numbers[z],Ee=L.from.numbers[z]||0):(Ee=L.to.numbers[z],J=L.from.numbers[z]||0),L.isPath?Q=TY(L.value,j*Ee):Q=J+j*(Ee-J),H&&(L.isColor&&z>2||(Q=Math.round(Q*H)/H)),q.push(Q)}var te=V.length;if(!te)K=q[0];else{K=V[0];for(var $=0;$<te;$++){var W=V[$],oe=V[$+1],ie=q[$];isNaN(ie)||(oe?K+=ie+oe:K+=ie+" ")}}bR[P.type](_.target,P.property,K,_.transforms),P.currentValue=K,S++}}function x(T){c[T]&&!c.passThrough&&c[T](c)}function v(){c.remaining&&c.remaining!==!0&&c.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(T,S,M,C,P){return b[T<<4|S<<3|M<<2|C<<1|P]}function A(T,S=!1){var M=c.duration;let C=c.delay,P=M-c.endDelay;c.parent?.reversed&&c.direction==="alternate"&&(C=c.endDelay,P=M-c.delay);var _=f(T);if(c.progress=$s(_/M*100,0,100),S||(c.reversePlayback=_<c.currentTime),o&&g(_,S),!c.began&&_>=C&&(c.began=!0),!c.loopBegan&&c.currentTime>0&&(c.loopBegan=!0,x("loopBegin")),(c.reversed||_>=0)&&_<=C&&c.currentTime!==0&&(y(0),x("change")),(_>=P&&c.currentTime!==M+c.pingPongDelayCorrection||!M)&&(y(M),x("change")),_>C&&_<P?(c.changeBegan||(c.changeBegan=!0,c.changeCompleted=!1,x("changeBegin")),y(_),x("change")):c.changeBegan?(c.changeCompleted=!0,c.changeBegan=!1,x("change"),o&&x("timelineChangeComplete")):c.began&&_>P&&x("changeComplete"),c.currentTime=$s(_,0,M+c.pingPongDelayCorrection),c.began&&x("update"),T>=M)if(v(),!c.remaining)c.paused=!0,c.completed||(c.completed=!0,x("loopComplete"),x("complete"),!c.passThrough&&"Promise"in window&&(a(),u=l(c)));else{o?t+=c.duration/ci.speed:t+=c.duration;for(let I of s)I.setStartTime(0),I.remaining=I.loop;x("loopComplete"),c.loopBegan=!1,c.direction==="alternate"?h():o&&d()}}return c.reset=function(){var T=c.direction;c.passThrough=!1,c.currentTime=0,c.progress=0,c.paused=!0,c.began=!1,c.loopBegan=!1,c.changeBegan=!1,c.completed=!1,c.changeCompleted=!1,c.reversed=T==="reverse",c.remaining=c.loop,s=c.children,o=s.length;for(var S=o;S--;)c.children[S].reset();y(c.reversed?c.duration:0)},c.setStartTime=function(T){t=T},c.set=function(T,S){return SR(T,S),c},c.tick=function(T){r=T,t||(t=r),A((r+(e-t))*ci.speed)},c.seek=function(T,S=!1){A(T-t,S)},c.pause=function(T){c.paused=!0,o&&(i=T??performance.now())},c.play=function(T){!c.paused||(c.completed&&c.reset(),c.paused=!1,Ts.push(c),o&&i!==void 0&&(t+=(T??performance.now())-i),!Ed&&$A.isUsingInternalRaf&&$A.play())},c.reverse=function(T=0){h(),c.completed=!c.reversed,t=void 0,e=T},c.restart=function(){c.reset(),t=void 0,e=0,c.play()},c.reset(),c.autoplay&&c.play(),c}function oR(n,t){for(var e=t.length;e--;)rE(n,t[e].animatable.target)&&t.splice(e,1)}function NY(n){for(var t=vR(n),e=Ts.length;e--;){var r=Ts[e],i=r.animations,s=r.children;oR(t,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;oR(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&r.pause()}}function BY(n,t){t===void 0&&(t={});var e=t.direction||"normal",r=t.easing?tE(t.easing):null,i=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",c=o==="last",u=dt.arr(n),h=parseFloat(u?n[0]:n),d=u?parseFloat(n[1]):0,f=Ha(u?n[1]:n)||0,m=t.start||0+(u?h:0),p=[],g=0;return function(y,x,v){if(a&&(o=0),l&&(o=(v-1)/2),c&&(o=v-1),!p.length){for(var b=0;b<v;b++){if(!i)p.push(Math.abs(o-b));else{var w=l?(i[0]-1)/2:o%i[0],A=l?(i[1]-1)/2:Math.floor(o/i[0]),T=b%i[0],S=Math.floor(b/i[0]),M=w-T,C=A-S,P=Math.sqrt(M*M+C*C);s==="x"&&(P=-M),s==="y"&&(P=-C),p.push(P)}g=Math.max.apply(Math,p)}r&&(p=p.map(function(I){return r(I/g)*g})),e==="reverse"&&(p=p.map(function(I){return s?I<0?I*-1:-I:Math.abs(g-I)}))}var _=u?(d-h)/g:h;return m+_*(Math.round(p[x]*100)/100)+f}}function FY(n){n===void 0&&(n={});var t=ci(n);return t.duration=0,t.add=function(e,r){var i=Ts.indexOf(t),s=t.children;i>-1&&Ts.splice(i,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=nx(e,ZA(eE,n));l.targets=l.targets||n.targets;var c=t.duration;l.autoplay=!1,l.timelineOffset=dt.und(r)?c:aE(r,c),o(t);var u=ci(l);o(u),s.push(u),u.parent=t;var h=wR(s,n);return t.delay=h.delay,t.endDelay=h.endDelay,t.duration=h.duration,u.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}ci.version="3.2.0";ci.speed=1;ci.running=Ts;ci.remove=NY;ci.get=oE;ci.set=SR;ci.convertPx=nE;ci.path=EY;ci.setDashoffset=wY;ci.stagger=BY;ci.timeline=FY;ci.easing=tE;ci.penner=uR;ci.random=function(n,t){return Math.floor(Math.random()*(t-n+1))+n};var Ms=ci;var cr=class extends Ge{constructor(e,r,i,s){super(e,r,i);this.isColorA=!0;this.a=s}setRGBA(e,r,i,s){super.setRGB(e,r,i),this.a=s}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)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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}};var{degToRad:Xye,radToDeg:Yye}=Se,AR=new E,ER=new E,TR=new Ye,VY=1e-4;function CR(n,t,e,r){if(r===0)return e.copy(n);if(r===1)return e.copy(t);let i=n.w*t.w+n.x*t.x+n.y*t.y+n.z*t.z;if(i>=1)return e.copy(n);let s=1-i*i;if(s<=Number.EPSILON){let u=1-r;return e.w=u*n.w+r*t.w,e.x=u*n.x+r*t.x,e.y=u*n.y+r*t.y,e.z=u*n.z+r*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-r)*a)/o,c=Math.sin(r*a)/o;return e.w=n.w*l+t.w*c,e.x=n.x*l+t.x*c,e.y=n.y*l+t.y*c,e.z=n.z*l+t.z*c,e}function ii(n,t,e,r,i,s){let o=e[n]!==void 0?e[n]:void 0,a=r[n];if(a==null)return;let l=o!=null?typeof o=="string"?Number(i.getVariable(o)??0):o:t[n],c=typeof a=="string"?Number(i.getVariable(a)??0):a;if(l!==c)return{update:u=>{let h=Se.lerp(l,c,u);s?t[n]=Math.trunc(h):t[n]=h},start:()=>{t[n]=l},end:()=>{t[n]=c}}}function Mm(n,t,e,r,i,s){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let l=t[n],c=[...o??l].map(h=>typeof h=="string"?Number(i.getVariable(h)??0):h),u=[...a].map(h=>typeof h=="string"?Number(i.getVariable(h)??0):h);if(!(c.length!==u.length||Qc(c,u)))return{update:h=>{c.forEach((d,f)=>{let m=Se.lerp(d,u[f],h);t[n][f]=s?Math.trunc(m):m})},start:()=>{Object.assign(t[n],c)},end:()=>{Object.assign(t[n],u)}}}function Tm(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function cE(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=s?Tm(new E,s,i):a.clone(),c=Tm(new E,o,i);if(!l.equals(c))return{update:u=>{a.lerpVectors(l,c,u)},start:()=>{a.copy(l)},end:()=>{a.copy(c)}}}function MR(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function Td(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=!(a instanceof U),c=a instanceof U?a:new U().fromArray(a),u=s?MR(new U,s,i):c.clone(),h=MR(new U,o,i);if(!u.equals(h))return{update:d=>{c.lerpVectors(u,h,d),l&&(t[n]=c.toArray())},start:()=>{c.copy(u),l&&(t[n]=c.toArray())},end:()=>{c.copy(h),l&&(t[n]=c.toArray())}}}function PR(n,t,e,r){let i=e[n]?e[n]:void 0,s=r[n];if(!s)return;let o=t[n],a=i?new ue().fromArray(i):o.clone(),l=new E,c=new Ye,u=new E;a.decompose(l,c,u);let h=new ue().fromArray(s),d=new E,f=new Ye,m=new E;if(h.decompose(d,f,m),!a.equals(h))return{update:p=>{TR.slerpQuaternions(c,f,p),AR.lerpVectors(l,d,p),ER.lerpVectors(u,m,p),o.compose(AR,TR,ER)},start:()=>{o.compose(l,c,u)},end:()=>{o.compose(d,f,m)}}}function _R(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=s?typeof s=="string"?i.getColor(s).clone():new Ge().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new Ge().setRGB(o.r,o.g,o.b);if(l.equals(c))return;let u=a.clone();return{update:h=>{u.lerpColors(l,c,h),t[n]?.copy?.(u)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function Cm(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=new cr(a.r,a.g,a.b,a.a),c=s?typeof s=="string"?i.getColor(s).clone():new cr(s.r,s.g,s.b,s.a):l.clone(),u=typeof o=="string"?i.getColor(o).clone():new cr(o.r,o.g,o.b,o.a);if(!c.equals(u))return{update:h=>{l.lerpColors(c,u,h);let d=Se.lerp(c.a,u.a,h);l.a=d,t[n]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(c)},end:()=>{l.copy(u)}}}function Go(n,t,e,r,i){if(typeof t[n]=="number")return ii(n,t,e??{},r,i);if(Array.isArray(t[n]))return Mm(n,t,e??{},r,i)}var Kye=new Jt;function jo(n,t,e,r,i){let s=e[n],o=r[n];if(typeof t[n]=="number")Math.abs(s-o)>VY&&(t[n]=Se.lerp(s,o,i));else if(Array.isArray(t[n]))for(let a=0,l=s.length;a<l;a++)t[n][a]=Se.lerp(s[a],o[a],i)}function IR(n,t,e,r){let i=[];if(!("cloner"in e)||!n.cloner)return i;let s=n.cloner,o="cloner"in t?t.cloner:{},a=e.cloner;PA.forEach(f=>{let m;f==="count"?m=ii("count",s.parameters,o,a,r.shared,!0):m=Go(f,s.parameters,o??{},a,r.shared),m&&i.push(m)});let l=UY(s,o,a,r.shared);l?.length&&i.push(...l);let c=kY(s,o,a,r.shared);c?.length&&i.push(...c);let u=zY(s,o,a,r.shared);u?.length&&i.push(...u);let h=GY(s,o,a,r.shared);h?.length&&i.push(...h);let d=jY(s,o,a,r.shared);return d?.length&&i.push(...d),i.length&&i.push({update:()=>{s.update(r)}}),i}function UY(n,t,e,r){if(n.parameters.type!=="radial")return;let i=t.radial,s=e.radial;if(!s)return;let o=n.parameters.radial,a=[];return E0.forEach(l=>{let c=Go(l,o,i??{},s,r);c&&a.push(c)}),a}function kY(n,t,e,r){if(n.parameters.type!=="linear")return;let i=t.linear,s=e.linear;if(!s)return;let o=[],a=n.parameters.linear;return T0.forEach(l=>{let c=Go(l,a,i??{},s,r);c&&o.push(c)}),o}function zY(n,t,e,r){if(n.parameters.type!=="grid")return;let i=t.grid,s=e.grid;if(!s)return;let o=[],a=n.parameters.grid;return M0.forEach(l=>{let c;l==="count"?c=Mm(l,a,i??{},s,r,!0):c=Go(l,a,i??{},s,r),c&&o.push(c)}),o}function GY(n,t,e,r){if(n.parameters.type!=="toObject")return;let i=t.toObject,s=e.toObject;if(!s)return;let o=[],a=n.parameters.toObject;return C0.forEach(l=>{let c;l==="count"?c=ii(l,a,i??{},s,r,!0):c=Go(l,a,i??{},s,r),c&&o.push(c)}),o}function jY(n,t,e,r){if(!n.parameters.randomness)return;let i=t.randomnessObject,s=e.randomnessObject;if(!s)return;let o=[],a=n.parameters.randomnessObject;return P0.forEach(l=>{let c=Go(l,a,i??{},s,r);c&&o.push(c)}),o}function DR(n,t,e,r){let i=r.cloner?.parameters;if(!!i){jo("count",i,n,t,e),i.count=Math.trunc(i.count);for(let s of E0)jo(s,i.radial,n.radial,t.radial,e);for(let s of T0)jo(s,i.linear,n.linear,t.linear,e);for(let s of M0)jo(s,i.grid,n.grid,t.grid,e);for(let s of C0)jo(s,i.toObject,n.toObject,t.toObject,e);return i}}function OR(n,t,e,r){let i=r.cloner?.parameters;if(!!i){for(let s of P0)jo(s,i.randomnessObject,n.randomnessObject,t.randomnessObject,e);return i}}function wi(n,t=[0,0]){!1&&n&&(isNaN(n[0])||isNaN(n[1]))&&console.warn("Invalid cubic bezier control point with NaN value. Using fallback instead.",n);let e=n&&!isNaN(n[0])?n[0]:t[0],r=n&&!isNaN(n[1])?n[1]:t[1];return[e,r]}function En(n,t,e){switch(n){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:let{control1:r,control2:i}=t??{...cd.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${i[0]}, ${i[1]} )`;case 6:let{mass:s,stiffness:o,damping:a,velocity:l}=e??{...ld.defaultData},c=new uE(s,o,a,l),u=c.solve(1);return()=>h=>c.solve(h)/u;case 8:return()=>h=>Math.floor(h)}}var RR;(t=>{function n(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}t.is=n})(RR||(RR={}));var sx;(a=>{function n(l,c){let u=[0,0],h=[1,1];if(l?.cubicControls)u=wi(l.cubicControls.control1,u);else switch(l?.type){case 2:u=[.42,0];break;case 3:u=[0,0];break;case 4:u=[.42,0];break;case 1:u=[.25,.1];break;case 0:u=[0,0];break;case 7:u=[.25,1];break}if(c?.cubicControls)h=wi(c.cubicControls.control2,h);else switch(c?.type){case 2:h=[1,1];break;case 3:h=[.58,1];break;case 4:h=[.58,1];break;case 1:h=[.25,1];break;case 0:h=[1,1];break;case 7:h=[.5,1];break}return{control1:u,control2:h}}a.getControlsWithDefault=n;function t(l,c){return{id:l,name:c,to:5,properties:new Re}}a.defaultData=t;function e(l){let c=new Re;return l.forEach(({data:u,id:h,fi:d})=>{if(u.type==="light"){let f=LR(["material",`${u.category} lighting`],h,d);c.push(f)}else{let f=LR(["material",u.type],h,d);c.push(f)}}),c}a.createMaterialGroup=e;function r(l){return Object.entries(l).reduce((c,[u,h])=>(typeof h!="string"&&c.push({name:h.name}),c),[])}a.createName=r;function i(l,c,u){let h=Ms.timeline({easing:En(0),begin(){l.resetBBoxNeedsUpdate()},change(){l.resetBBoxNeedsUpdate()},direction:c.direction,autoplay:!1});return s(l,c,u).forEach(f=>h.add(f,0)),h.duration=c.to*1e3,h}a.createTimeline=i;function s(l,c,u,h){let d=[];return c.properties.forEach((f,m)=>{let p=f.data.path?.[0];if(p&&["position","rotation","scale"].includes(p)){let g=HY(f.data,u?.[p]);g&&d.push(...g)}if(p&&p==="shape size"&&"geometry"in l){let g=WY(l,f.data,u?.shapeSize);g&&d.push(...g)}if(p&&p==="path extrusion"&&l instanceof qo){let g=qY(l,f.data,u?.pathExtrusion);g&&d.push(g)}if(p&&p==="path snapping"&&l.data.pathSnapping){let g=XY(l,f.data,u?.pathSnapping);g&&d.push(g)}if(p&&p==="material"&&l.type==="Mesh"&&"material"in l&&l.material instanceof fn){let g=f.data.id;if(g){let y=l.material.getLayerByUuid(g);if(y){let x=NR(y,f.data,u?.material,h);x&&d.push(x)}else{let x=l.material.getLayersOfType(f.data.type);if(x)for(let v of x){let b=NR(v,f.data,u?.material,h);b&&d.push(b)}}}}if(p&&p==="opacity"&&l.type==="Mesh"&&"material"in l){let g=YY(f.data,u?.opacity);g&&d.push(g)}if(p&&p==="cloner"){let g=KY(l,f.data,u?.cloner);g&&d.push(g)}if(p&&p==="camera"&&l instanceof ir){let g=QY(l,f.data,u?.camera,"zoom");g&&d.push(g)}if(p&&p==="light"&&(l instanceof Ho||l instanceof Xl||l instanceof Wo)){let g=ZY(l,f.data,u?.light,f.data.path[1],h);g&&d.push(g)}}),d}a.addKeyframesToTimeline=s,a.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:En(3),duration:1e3},opacity:{value:[0,1],easing:En(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:En(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:En(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:En(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(sx||(sx={}));function LR(n,t,e){let r=t;return{id:r,fi:e,data:{id:r,path:n,keyframes:new Re}}}var BR=["x","y","z"];function HY(n,t=()=>{}){let e=[];for(let r of BR){let i=[...n.keyframes??[]].filter(a=>a.data.value[r]!==void 0).sort((a,l)=>a.data.time-l.data.time),s=i[0];s&&t?.(s.data.value);let o={index:[],t:[]};for(let a=0;a<i.length-1;a++){let l=i[a],c=i[a+1]??l,u={duration:(c?.data?.time-l.data.time)*1e3,delay:a===0?i[0].data.time*1e3:0};a<i.length-1&&(o.t.push({...u,value:a%2===0?1:0,easing:En(l.data.easing.type,{control1:wi(l.data.easing.cubicControls?.control1,[0,0]),control2:wi(c.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters)}),o.index.push({...u,value:a,easing:"linear"}))}if(i.length>1){let a={t:0,index:0};e.push({targets:a,...o,update:l=>{let c=Math.ceil(a.index),u=c%2===0?a.t:1-a.t,h=i?.[c].data.value,d=i?.[c+1]?.data.value;if(h!==void 0&&d!==void 0){let f={[r]:h[r]+(d[r]-h[r])*u};t?.(f)}}})}}return e}function WY(n,t,e){let r=[];for(let i of BR){let s={},o=[...t.keyframes??[]].filter(l=>l.data.value[i]!==void 0).sort((l,c)=>l.data.time-c.data.time),a=o[0];a&&e?.(a.data.value),s={index:[],t:[]};for(let l=0;l<o.length-1;l++){let c=o[l],u=o[l+1]??c,h={duration:(u?.data?.time-c.data.time)*1e3,delay:l===0?o[0].data.time*1e3:0};l<o.length-1&&(s.t.push({...h,value:l%2===0?1:0,easing:En(c.data.easing.type,{control1:wi(c.data.easing.cubicControls?.control1,[0,0]),control2:wi(u.data.easing.cubicControls?.control2,[1,1])},c.data.easing.springParameters)}),s.index.push({...h,value:l,easing:"linear"}))}if(o.length>1){let l={t:0,index:0};r.push({targets:l,...s,update:c=>{let u=Math.ceil(l.index),h=u%2===0?l.t:1-l.t,d=o?.[u].data.value,f=o?.[u+1]?.data.value;if(d!==void 0&&f!==void 0){let m={[i]:d[i]+(f[i]-d[i])*h};e?.(m)}}})}}return r}function qY(n,t,e){let r={},i=[...t.keyframes??[]].sort((o,a)=>o.data.time-a.data.time),s=i[0];s&&e?.(n,s.data.value),r={index:[],t:[]};for(let o=0;o<i.length-1;o++){let a=i[o],l=i[o+1]??a,c={duration:(l?.data?.time-a.data.time)*1e3,delay:o===0?i[0].data.time*1e3:0};o<i.length-1&&(r.t.push({...c,value:o%2===0?1:0,easing:En(a.data.easing.type,{control1:wi(a.data.easing.cubicControls?.control1,[0,0]),control2:wi(l.data.easing.cubicControls?.control2,[1,1])},a.data.easing.springParameters)}),r.index.push({...c,value:o,easing:"linear"}))}if(i.length>1){let o={t:0,index:0};return{targets:o,...r,update:a=>{let l=Math.ceil(o.index),c=l%2===0?o.t:1-o.t,u=i?.[Math.min(l,i.length-1)].data.value,h=i?.[Math.min(l,i.length-1)+1]?.data.value;e?.(n,FR(n,u,h,c))}}}}function XY(n,t,e){let r={},i=[...t.keyframes??[]].sort((o,a)=>o.data.time-a.data.time),s=i[0];s&&e?.(s.data.value),r={index:[],t:[]};for(let o=0;o<i.length-1;o++){let a=i[o],l=i[o+1]??a,c={duration:(l?.data?.time-a.data.time)*1e3,delay:o===0?i[0].data.time*1e3:0};o<i.length-1&&(r.t.push({...c,value:o%2===0?1:0,easing:En(a.data.easing.type,{control1:wi(a.data.easing.cubicControls?.control1,[0,0]),control2:wi(l.data.easing.cubicControls?.control2,[1,1])},a.data.easing.springParameters)}),r.index.push({...c,value:o,easing:"linear"}))}if(i.length>1){let o={t:0,index:0};return{targets:o,...r,update:a=>{let l=Math.ceil(o.index),c=l%2===0?o.t:1-o.t,u=i?.[Math.min(l,i.length-1)].data.value,h=i?.[Math.min(l,i.length-1)+1]?.data.value;e?.(VR(n,u,h,c))}}}}function NR(n,t,e,r){if(t){let i={},s=[...t.keyframes??[]].sort((o,a)=>o.data.time-a.data.time);if("data"in n){let o=s[0];o&&e?.(o.data.value,n),i={index:[],t:[]};for(let a=0;a<s.length-1;a++){let l=s[a],c=s[a+1]??l,u={duration:(c?.data?.time-l.data.time)*1e3,delay:a===0?s[0].data.time*1e3:0};a<s.length-1&&(i.t.push({...u,value:a%2===0?1:0,easing:En(l.data.easing.type,{control1:wi(l.data.easing.cubicControls?.control1,[0,0]),control2:wi(c.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters)}),i.index.push({...u,value:a,easing:"linear"}))}if(s.length>1){let a={t:0,index:0};return{targets:a,...i,update:l=>{let c=Math.ceil(a.index),u=c%2===0?a.t:1-a.t,h=s?.[Math.min(c,s.length-1)].data.value,d=s?.[Math.min(c,s.length-1)+1]?.data.value,f={},m={};if(Object.keys(h).length>0&&Object.keys(d).length>0){for(let p in n.data)if(p in h&&p in d){let g=hE(h[p],d[p],u,r);g!==void 0&&(f[p]=g,m[p]={start:h,end:d,t:u})}}e?.({...f},n,m)}}}}}}function YY(n,t){if(n){let e={},r=[...n.keyframes??[]].sort((s,o)=>s.data.time-o.data.time),i=r[0];i&&t?.(i.data.value),e={index:[],t:[]};for(let s=0;s<r.length-1;s++){let o=r[s],a=r[s+1]??o,l={duration:(a?.data?.time-o.data.time)*1e3,delay:s===0?r[0].data.time*1e3:0};s<r.length-1&&(e.t.push({...l,value:s%2===0?1:0,easing:En(o.data.easing.type,{control1:wi(o.data.easing.cubicControls?.control1,[0,0]),control2:wi(a.data.easing.cubicControls?.control2,[1,1])},o.data.easing.springParameters)}),e.index.push({...l,value:s,easing:"linear"}))}if(r.length>1){let s={t:0,index:0};return{targets:s,...e,update:o=>{let a=Math.ceil(s.index),l=a%2===0?s.t:1-s.t,c=r?.[Math.min(a,r.length-1)].data.value,u=r?.[Math.min(a,r.length-1)+1]?.data.value,h=Se.lerp(c,u,l);t?.(h)}}}}}function KY(n,t,e){let r={},i=[...t.keyframes??[]].sort((o,a)=>o.data.time-a.data.time),s=i[0];s&&e?.(n,s.data.value,s.data.value),r={index:[],t:[]};for(let o=0;o<i.length-1;o++){let a=i[o],l=i[o+1]??a,c={duration:(l?.data?.time-a.data.time)*1e3,delay:o===0?i[0].data.time*1e3:0};o<i.length-1&&(r.t.push({...c,value:o%2===0?1:0,easing:En(a.data.easing.type,{control1:wi(a.data.easing.cubicControls?.control1,[0,0]),control2:wi(l.data.easing.cubicControls?.control2,[1,1])},a.data.easing.springParameters)}),r.index.push({...c,value:o,easing:"linear"}))}if(i.length>1){let o={t:0,index:0};return{targets:o,...r,update:a=>{let l=Math.ceil(o.index),c=l%2===0?o.t:1-o.t,u=i?.[Math.min(l,i.length-1)].data.value,h=i?.[Math.min(l,i.length-1)+1]?.data.value;e?.(n,u.randomnessObject?void 0:DR(u,h,c,n),u.randomnessObject?OR(u,h,c,n):void 0)}}}}function hE(n,t,e,r){if(typeof n=="string"&&r&&(n=r.color(n)),typeof t=="string"&&r&&(n=r.color(t)),typeof n=="number")return n===t?void 0:Se.lerp(n,t,e);if(At.is(n))return At.lerp(n,t,e);if(Fr.is(n))return Fr.lerp(n,t,e);if(Array.isArray(n))return(n.length>t.length?t:n).map((s,o,a)=>{if(Array.isArray(s)){let l=n[o].length>t[o].length?t[o].length:n[o].length;return(l===4?eu:l===3?ws:ss).lerp(n[o],t[o],e)}else return Se.lerp(n[o],t[o],e)});if(typeof n=="object"&&n!==null){let i={};for(let s in n){let o=hE(n[s],t[s],e,r);o!==void 0&&(i[s]=o)}return i}}function QY(n,t,e,r){if(t){let i={[r]:[]},s=[...t.keyframes??[]].sort((a,l)=>a.data.time-l.data.time),o=s[0];o&&(n[r]=o.data.value,o&&e?.(r,o.data.value));for(let a=0;a<s.length-1;a++){let l=s[a];if(!Number.isFinite(l.data.value))continue;let c=s[a+1]??l,u=c.data.value;i[r].push({value:u,easing:En(l.data.easing.type,{control1:wi(l.data.easing.cubicControls?.control1,[0,0]),control2:wi(c.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters),duration:(c?.data?.time-l.data.time)*1e3,delay:a===0?s[0].data.time*1e3:0})}if(s.length>1)return{targets:n,...i,update:()=>{e?.(r,n[r])}}}}function ZY(n,t,e,r,i){if(t){let s={},o=[...t.keyframes??[]].sort((l,c)=>l.data.time-c.data.time),a=o[0];if(a){let l=a.data.value;n[r]=l,e?.(r,l)}s={index:[],t:[]};for(let l=0;l<o.length-1;l++){let c=o[l],u=o[l+1]??c,h={duration:(u?.data?.time-c.data.time)*1e3,delay:l===0?o[0].data.time*1e3:0};l<o.length-1&&(s.t.push({...h,value:l%2===0?1:0,easing:En(c.data.easing.type,{control1:wi(c.data.easing.cubicControls?.control1,[0,0]),control2:wi(u.data.easing.cubicControls?.control2,[1,1])},c.data.easing.springParameters)}),s.index.push({...h,value:l,easing:"linear"}))}if(o.length>1){let l={t:0,index:0};return{targets:l,...s,update:()=>{let c=Math.ceil(l.index),u=c%2===0?l.t:1-l.t,h=o?.[Math.min(c,o.length-1)].data.value,d=o?.[Math.min(c,o.length-1)+1]?.data.value,f=hE(h,d,u,i);e?.(r,f)}}}}}var uE=class{constructor(t=1,e=100,r=10,i=0){this.mass=t,this.stiffness=e,this.damping=r,this.initialVelocity=i,this.m_w0=Math.sqrt(e/t),this.m_zeta=r/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0+-i)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-i+this.m_w0)}solve(t){return this.m_zeta<1?t=Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):t=(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0),1-t}getDuration(){let t=.16666666666666666,e=0,r=0;for(;;)if(e+=t,this.solve(e)===1){if(r++,r>=16)break}else r=0;return e*t*1e3}};var UR=Math.pow(2,-24);var nu=class{constructor(){}};function Cs(n,t,e){return e.min.x=t[n],e.min.y=t[n+1],e.min.z=t[n+2],e.max.x=t[n+3],e.max.y=t[n+4],e.max.z=t[n+5],e}function dE(n){let t=-1,e=-1/0;for(let r=0;r<3;r++){let i=n[r+3]-n[r];i>e&&(e=i,t=r)}return t}function fE(n,t){t.set(n)}function pE(n,t,e){let r,i;for(let s=0;s<3;s++){let o=s+3;r=n[s],i=t[s],e[s]=r<i?r:i,r=n[o],i=t[o],e[o]=r>i?r:i}}function Pm(n,t,e){for(let r=0;r<3;r++){let i=t[n+2*r],s=t[n+2*r+1],o=i-s,a=i+s;o<e[r]&&(e[r]=o),a>e[r+3]&&(e[r+3]=a)}}function Md(n){let t=n[3]-n[0],e=n[4]-n[1],r=n[5]-n[2];return 2*(t*e+e*r+r*t)}function eK(n,t){if(!n.index){let e=n.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;e>65535?i=new Uint32Array(new r(4*e)):i=new Uint16Array(new r(2*e)),n.setIndex(new je(i,1));for(let s=0;s<e;s++)i[s]=s}}function tK(n){if(!n.groups||!n.groups.length)return[{offset:0,count:n.index.count/3}];let t=[],e=new Set;for(let i of n.groups)e.add(i.start),e.add(i.start+i.count);let r=Array.from(e.values()).sort((i,s)=>i-s);for(let i=0;i<r.length-1;i++){let s=r[i],o=r[i+1];t.push({offset:s/3,count:(o-s)/3})}return t}function gE(n,t,e,r,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,m=-1/0,p=-1/0,g=-1/0,y=i!==null;for(let x=t*6,v=(t+e)*6;x<v;x+=6){let b=n[x+0],w=n[x+1],A=b-w,T=b+w;A<s&&(s=A),T>l&&(l=T),y&&b<h&&(h=b),y&&b>m&&(m=b);let S=n[x+2],M=n[x+3],C=S-M,P=S+M;C<o&&(o=C),P>c&&(c=P),y&&S<d&&(d=S),y&&S>p&&(p=S);let _=n[x+4],I=n[x+5],O=_-I,L=_+I;O<a&&(a=O),L>u&&(u=L),y&&_<f&&(f=_),y&&_>g&&(g=_)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=c,r[5]=u,y&&(i[0]=h,i[1]=d,i[2]=f,i[3]=m,i[4]=p,i[5]=g)}function rK(n,t,e,r){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=t*6,h=(t+e)*6;u<h;u+=6){let d=n[u+0];d<i&&(i=d),d>a&&(a=d);let f=n[u+2];f<s&&(s=f),f>l&&(l=f);let m=n[u+4];m<o&&(o=m),m>c&&(c=m)}r[0]=i,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=c}function iK(n,t,e,r,i){let s=e,o=e+r-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let c=0;c<3;c++){let u=n[s*3+c];n[s*3+c]=n[o*3+c],n[o*3+c]=u;let h=t[s*6+c*2+0];t[s*6+c*2+0]=t[o*6+c*2+0],t[o*6+c*2+0]=h;let d=t[s*6+c*2+1];t[s*6+c*2+1]=t[o*6+c*2+1],t[o*6+c*2+1]=d}s++,o--}else return s}}var Wa=32,nK=(n,t)=>n.candidate-t.candidate,Yl=new Array(Wa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ox=new Float32Array(6);function sK(n,t,e,r,i,s){let o=-1,a=0;if(s===0)o=dE(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=dE(n),o!==-1&&(a=oK(e,r,i,o));else if(s===2){let l=Md(n),c=1.25*i,u=r*6,h=(r+i)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/Wa;if(i<Wa/4){let y=[...Yl];y.length=i;let x=0;for(let b=u;b<h;b+=6,x++){let w=y[x];w.candidate=e[b+2*d],w.count=0;let{bounds:A,leftCacheBounds:T,rightCacheBounds:S}=w;for(let M=0;M<3;M++)S[M]=1/0,S[M+3]=-1/0,T[M]=1/0,T[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;Pm(b,e,A)}y.sort(nK);let v=i;for(let b=0;b<v;b++){let w=y[b];for(;b+1<v&&y[b+1].candidate===w.candidate;)y.splice(b+1,1),v--}for(let b=u;b<h;b+=6){let w=e[b+2*d];for(let A=0;A<v;A++){let T=y[A];w>=T.candidate?Pm(b,e,T.rightCacheBounds):(Pm(b,e,T.leftCacheBounds),T.count++)}}for(let b=0;b<v;b++){let w=y[b],A=w.count,T=i-w.count,S=w.leftCacheBounds,M=w.rightCacheBounds,C=0;A!==0&&(C=Md(S)/l);let P=0;T!==0&&(P=Md(M)/l);let _=1+1.25*(C*A+P*T);_<c&&(o=d,c=_,a=w.candidate)}}else{for(let v=0;v<Wa;v++){let b=Yl[v];b.count=0,b.candidate=f+g+v*g;let w=b.bounds;for(let A=0;A<3;A++)w[A]=1/0,w[A+3]=-1/0}for(let v=u;v<h;v+=6){let A=~~((e[v+2*d]-f)/g);A>=Wa&&(A=Wa-1);let T=Yl[A];T.count++,Pm(v,e,T.bounds)}let y=Yl[Wa-1];fE(y.bounds,y.rightCacheBounds);for(let v=Wa-2;v>=0;v--){let b=Yl[v],w=Yl[v+1];pE(b.bounds,w.rightCacheBounds,b.rightCacheBounds)}let x=0;for(let v=0;v<Wa-1;v++){let b=Yl[v],w=b.count,A=b.bounds,S=Yl[v+1].rightCacheBounds;w!==0&&(x===0?fE(A,ox):pE(A,ox,ox)),x+=w;let M=0,C=0;x!==0&&(M=Md(ox)/l);let P=i-x;P!==0&&(C=Md(S)/l);let _=1+1.25*(M*x+C*P);_<c&&(o=d,c=_,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function oK(n,t,e,r){let i=0;for(let s=t,o=t+e;s<o;s++)i+=n[s*6+r*2];return i/e}function aK(n,t){let e=n.attributes.position,r=n.index.array,i=r.length/3,s=new Float32Array(i*6),o=e.normalized,a=e.array,l=e.offset||0,c=3;e.isInterleavedBufferAttribute&&(c=e.data.stride);let u=["getX","getY","getZ"];for(let h=0;h<i;h++){let d=h*3,f=h*6,m,p,g;o?(m=r[d+0],p=r[d+1],g=r[d+2]):(m=r[d+0]*c+l,p=r[d+1]*c+l,g=r[d+2]*c+l);for(let y=0;y<3;y++){let x,v,b;o?(x=e[u[y]](m),v=e[u[y]](p),b=e[u[y]](g)):(x=a[m+y],v=a[p+y],b=a[g+y]);let w=x;v<w&&(w=v),b<w&&(w=b);let A=x;v>A&&(A=v),b>A&&(A=b);let T=(A-w)/2,S=y*2;s[f+S+0]=w+T,s[f+S+1]=T+(Math.abs(w)+T)*UR,w<t[y]&&(t[y]=w),A>t[y+3]&&(t[y+3]=A)}}return s}function lK(n,t){function e(y){d&&d(y/f)}function r(y,x,v,b=null,w=0){if(!m&&w>=l&&(m=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(n))),v<=u||w>=l)return e(x+v),y.offset=x,y.count=v,y;let A=sK(y.boundingData,b,o,x,v,h);if(A.axis===-1)return e(x+v),y.offset=x,y.count=v,y;let T=iK(a,o,x,v,A);if(T===x||T===x+v)e(x+v),y.offset=x,y.count=v;else{y.splitAxis=A.axis;let S=new nu,M=x,C=T-x;y.left=S,S.boundingData=new Float32Array(6),gE(o,M,C,S.boundingData,s),r(S,M,C,s,w+1);let P=new nu,_=T,I=v-C;y.right=P,P.boundingData=new Float32Array(6),gE(o,_,I,P.boundingData,s),r(P,_,I,s,w+1)}return y}eK(n,t);let i=new Float32Array(6),s=new Float32Array(6),o=aK(n,i),a=n.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=n.index.count/3,m=!1,p=[],g=tK(n);if(g.length===1){let y=g[0],x=new nu;x.boundingData=i,rK(o,y.offset,y.count,s),r(x,y.offset,y.count,s),p.push(x)}else for(let y of g){let x=new nu;x.boundingData=new Float32Array(6),gE(o,y.offset,y.count,x.boundingData,s),r(x,y.offset,y.count,s),p.push(x)}return p}function GR(n,t){let e=lK(n,t),r,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<e.length;u++){let h=e[u],d=l(h),f=new a(32*d);r=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),c(0,h),o.push(f)}return o;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function c(u,h){let d=u/4,f=u/2,m=!!h.count,p=h.boundingData;for(let g=0;g<6;g++)r[d+g]=p[g];if(m){let g=h.offset,y=h.count;return i[d+6]=g,s[f+14]=y,s[f+15]=65535,u+32}else{let g=h.left,y=h.right,x=h.splitAxis,v;if(v=c(u+32,g),v/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[d+6]=v/4,v=c(v,y),i[d+7]=x,v}}}var Fn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];r=l<r?l:r,i=l>i?l:i}this.min=r,this.max=i}setFromPoints(t,e){let r=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);r=l<r?l:r,i=l>i?l:i}this.min=r,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};Fn.prototype.setFromBox=function(){let n=new E;return function(e,r){let i=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){n.x=i.x*l+s.x*(1-l),n.y=i.y*c+s.y*(1-c),n.z=i.z*u+s.z*(1-u);let h=e.dot(n);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var Nve=function(){let n=new Fn;return function(e,r){let i=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,c=r.satBounds;for(let u=0;u<3;u++){let h=o[u],d=s[u];if(n.setFromPoints(d,a),h.isSeparated(n))return!1}for(let u=0;u<3;u++){let h=c[u],d=l[u];if(n.setFromPoints(d,i),h.isSeparated(n))return!1}}}();var cK=function(){let n=new E,t=new E,e=new E;return function(i,s,o){let a=i.start,l=n,c=s.start,u=t;e.subVectors(a,c),n.subVectors(i.end,i.start),t.subVectors(s.end,s.start);let h=e.dot(u),d=u.dot(l),f=u.dot(u),m=e.dot(l),g=l.dot(l)*f-d*d,y,x;g!==0?y=(h*d-m*f)/g:y=0,x=(h+y*d)/f,o.x=y,o.y=x}}(),_m=function(){let n=new U,t=new E,e=new E;return function(i,s,o,a){cK(i,s,n);let l=n.x,c=n.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=i.start:u=i.end;let h;c<0?h=s.start:h=s.end;let d=t,f=e;if(i.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(u)){o.copy(d),a.copy(h);return}else{o.copy(u),a.copy(f);return}}}}(),jR=function(){let n=new E,t=new E,e=new qr,r=new Di;return function(s,o){let{radius:a,center:l}=s,{a:c,b:u,c:h}=o;if(r.start=c,r.end=u,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a)||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a))return!0;let p=o.getPlane(e);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var uK=1e-15;function Cd(n){return Math.abs(n)<uK}var Vn=class extends Or{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new Fn),this.points=[this.a,this.b,this.c],this.sphere=new ei,this.plane=new qr,this.needsUpdate=!0}intersectsSphere(t){return jR(t,this)}update(){let t=this.a,e=this.b,r=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let c=s[1],u=o[1];c.subVectors(t,e),u.setFromPoints(c,i);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,i);let f=s[3],m=o[3];f.subVectors(r,t),m.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};Vn.prototype.closestPointToSegment=function(){let n=new E,t=new E,e=new Di;return function(i,s=null,o=null){let{start:a,end:l}=i,c=this.points,u,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(c[d]),e.end.copy(c[f]),_m(e,i,n,t),u=n.distanceToSquared(t),u<h&&(h=u,s&&s.copy(n),o&&o.copy(t))}return this.closestPointToPoint(a,n),u=a.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),o&&o.copy(a)),this.closestPointToPoint(l,n),u=l.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),o&&o.copy(l)),Math.sqrt(h)}}();Vn.prototype.intersectsTriangle=function(){let n=new Vn,t=new Array(3),e=new Array(3),r=new Fn,i=new Fn,s=new E,o=new E,a=new E,l=new E,c=new Di,u=new Di,h=new Di;return function(f,m=null,p=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(n.copy(f),n.update(),f=n);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let x=this.satBounds,v=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let T=x[A],S=v[A];if(r.setFromPoints(S,e),T.isSeparated(r))return!1}let b=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let A=0;A<4;A++){let T=b[A],S=w[A];if(r.setFromPoints(S,t),T.isSeparated(r))return!1}for(let A=0;A<4;A++){let T=v[A];for(let S=0;S<4;S++){let M=w[S];if(s.crossVectors(T,M),r.setFromPoints(s,t),i.setFromPoints(s,e),r.isSeparated(i))return!1}}return m&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{let x=this.points,v=!1,b=0;for(let O=0;O<3;O++){let L=x[O],j=x[(O+1)%3];c.start.copy(L),c.end.copy(j),c.delta(o);let V=v?u.start:u.end,H=Cd(y.distanceToPoint(L));if(Cd(y.normal.dot(o))&&H){u.copy(c),b=2;break}if((y.intersectLine(c,V)||H)&&!Cd(V.distanceTo(j))){if(b++,v)break;v=!0}}if(b===1&&f.containsPoint(u.end))return m&&(m.start.copy(u.end),m.end.copy(u.end)),!0;if(b!==2)return!1;let w=f.points,A=!1,T=0;for(let O=0;O<3;O++){let L=w[O],j=w[(O+1)%3];c.start.copy(L),c.end.copy(j),c.delta(a);let V=A?h.start:h.end,H=Cd(g.distanceToPoint(L));if(Cd(g.normal.dot(a))&&H){h.copy(c),T=2;break}if((g.intersectLine(c,V)||H)&&!Cd(V.distanceTo(j))){if(T++,A)break;A=!0}}if(T===1&&this.containsPoint(h.end))return m&&(m.start.copy(h.end),m.end.copy(h.end)),!0;if(T!==2)return!1;if(u.delta(o),h.delta(a),o.dot(a)<0){let O=h.start;h.start=h.end,h.end=O}let S=u.start.dot(o),M=u.end.dot(o),C=h.start.dot(o),P=h.end.dot(o),_=M<C,I=S<P;return S!==P&&C!==M&&_===I?!1:(m&&(l.subVectors(u.start,h.start),l.dot(o)>0?m.start.copy(u.start):m.start.copy(h.start),l.subVectors(u.end,h.end),l.dot(o)<0?m.end.copy(u.end):m.end.copy(h.end)),!0)}}}();Vn.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();Vn.prototype.distanceToTriangle=function(){let n=new E,t=new E,e=["a","b","c"],r=new Di,i=new Di;return function(o,a=null,l=null){let c=a||l?r:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let h=0;h<3;h++){let d,f=e[h],m=o[f];this.closestPointToPoint(m,n),d=m.distanceToSquared(n),d<u&&(u=d,a&&a.copy(n),l&&l.copy(m));let p=this[f];o.closestPointToPoint(p,n),d=p.distanceToSquared(n),d<u&&(u=d,a&&a.copy(p),l&&l.copy(n))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];r.set(this[d],this[f]);for(let m=0;m<3;m++){let p=e[m],g=e[(m+1)%3];i.set(o[p],o[g]),_m(r,i,n,t);let y=n.distanceToSquared(t);y<u&&(u=y,a&&a.copy(n),l&&l.copy(t))}}return Math.sqrt(u)}}();var Un=class{constructor(t,e,r){this.isOrientedBox=!0,this.min=new E,this.max=new E,this.matrix=new ue,this.invMatrix=new ue,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 Fn),this.alignedSatBounds=new Array(3).fill().map(()=>new Fn),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),r&&this.matrix.copy(r)}set(t,e,r){this.min.copy(t),this.max.copy(e),this.matrix.copy(r),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Un.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,i=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){let d=1*c|2*u|4*h,f=i[d];f.x=c?r.x:e.x,f.y=u?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let c=0;c<3;c++){let u=o[c],h=s[c],d=1<<c,f=i[d];u.subVectors(a,f),h.setFromPoints(u,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Un.prototype.intersectsBox=function(){let n=new Fn;return function(e){this.needsUpdate&&this.update();let r=e.min,i=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(n.min=r.x,n.max=i.x,a[0].isSeparated(n)||(n.min=r.y,n.max=i.y,a[1].isSeparated(n))||(n.min=r.z,n.max=i.z,a[2].isSeparated(n)))return!1;for(let l=0;l<3;l++){let c=o[l],u=s[l];if(n.setFromBox(c,e),u.isSeparated(n))return!1}return!0}}();Un.prototype.intersectsTriangle=function(){let n=new Vn,t=new Array(3),e=new Fn,r=new Fn,i=new E;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(n.copy(o),n.update(),o=n);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],m=l[d];if(e.setFromPoints(m,t),f.isSeparated(e))return!1}let c=o.satBounds,u=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=c[d],m=u[d];if(e.setFromPoints(m,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let m=0;m<4;m++){let p=u[m];if(i.crossVectors(f,p),e.setFromPoints(i,t),r.setFromPoints(i,h),e.isSeparated(r))return!1}}return!0}}();Un.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();Un.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();Un.prototype.distanceToBox=function(){let n=["x","y","z"],t=new Array(12).fill().map(()=>new Di),e=new Array(12).fill().map(()=>new Di),r=new E,i=new E;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(i),this.closestPointToPoint(i,r),o.closestPointToPoint(r,i),l&&l.copy(r),c&&c.copy(i)),0;let u=a*a,h=o.min,d=o.max,f=this.points,m=1/0;for(let g=0;g<8;g++){let y=f[g];i.copy(y).clamp(h,d);let x=y.distanceToSquared(i);if(x<m&&(m=x,l&&l.copy(y),c&&c.copy(i),x<u))return Math.sqrt(x)}let p=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let x=0;x<=1;x++){let v=(g+1)%3,b=(g+2)%3,w=y<<v|x<<b,A=1<<g|y<<v|x<<b,T=f[w],S=f[A];t[p].set(T,S);let C=n[g],P=n[v],_=n[b],I=e[p],O=I.start,L=I.end;O[C]=h[C],O[P]=y?h[P]:d[P],O[_]=x?h[_]:d[P],L[C]=d[C],L[P]=y?h[P]:d[P],L[_]=x?h[_]:d[P],p++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let x=0;x<=1;x++){i.x=g?d.x:h.x,i.y=y?d.y:h.y,i.z=x?d.z:h.z,this.closestPointToPoint(i,r);let v=i.distanceToSquared(r);if(v<m&&(m=v,l&&l.copy(r),c&&c.copy(i),v<u))return Math.sqrt(v)}for(let g=0;g<12;g++){let y=t[g];for(let x=0;x<12;x++){let v=e[x];_m(y,v,r,i);let b=r.distanceToSquared(i);if(b<m&&(m=b,l&&l.copy(r),c&&c.copy(i),b<u))return Math.sqrt(b)}}return Math.sqrt(m)}}();var Pd=new E,_d=new E,Id=new E,lx=new U,cx=new U,ux=new U,HR=new E,WR=new E,qR=new E,hx=new E;function hK(n,t,e,r,i,s){let o;return s===xi?o=n.intersectTriangle(r,e,t,!0,i):o=n.intersectTriangle(t,e,r,s!==vi,i),o===null?null:{distance:n.origin.distanceTo(i),point:i.clone()}}function dK(n,t,e,r,i,s,o,a,l){Pd.fromBufferAttribute(t,s),_d.fromBufferAttribute(t,o),Id.fromBufferAttribute(t,a);let c=hK(n,Pd,_d,Id,hx,l);if(c){r&&(lx.fromBufferAttribute(r,s),cx.fromBufferAttribute(r,o),ux.fromBufferAttribute(r,a),c.uv=Or.getInterpolation(hx,Pd,_d,Id,lx,cx,ux,new U)),i&&(lx.fromBufferAttribute(i,s),cx.fromBufferAttribute(i,o),ux.fromBufferAttribute(i,a),c.uv1=Or.getInterpolation(hx,Pd,_d,Id,lx,cx,ux,new U)),e&&(HR.fromBufferAttribute(e,s),WR.fromBufferAttribute(e,o),qR.fromBufferAttribute(e,a),c.normal=Or.getInterpolation(hx,Pd,_d,Id,HR,WR,qR,new E),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));let u={a:s,b:o,c:a,normal:new E,materialIndex:0};Or.getNormal(Pd,_d,Id,u.normal),c.face=u,c.faceIndex=s}return c}function vE(n,t,e,r,i){let s=r*3,o=n.index.getX(s),a=n.index.getX(s+1),l=n.index.getX(s+2),{position:c,normal:u,uv:h,uv1:d}=n.attributes,f=dK(e,c,u,h,d,o,a,l,t);return f?(f.faceIndex=r,i&&i.push(f),f):null}function XR(n,t,e,r,i,s){for(let o=r,a=r+i;o<a;o++)vE(n,t,e,o,s)}function YR(n,t,e,r,i){let s=1/0,o=null;for(let a=r,l=r+i;a<l;a++){let c=vE(n,t,e,a);c&&c.distance<s&&(o=c,s=c.distance)}return o}function Ps(n,t,e,r){let i=n.a,s=n.b,o=n.c,a=t,l=t+1,c=t+2;e&&(a=e.getX(t),l=e.getX(t+1),c=e.getX(t+2)),i.x=r.getX(a),i.y=r.getY(a),i.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(c),o.y=r.getY(c),o.z=r.getZ(c)}function xE(n,t,e,r,i,s,o){let a=e.index,l=e.attributes.position;for(let c=n,u=t+n;c<u;c++)if(Ps(o,c*3,a,l),o.needsUpdate=!0,r(o,c,i,s))return!0;return!1}var Dd=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function qa(n,t){return t[n+15]===65535}function su(n,t){return t[n+6]}function Od(n,t){return t[n+14]}function Rd(n){return n+8}function Ld(n,t){return t[n+6]}function KR(n,t){return t[n+7]}var Nd=new Yt,fx=new E,pK=["x","y","z"];function px(n,t,e,r,i){let s=n*2,o=Bd,a=Kl,l=Ql;if(qa(s,a)){let u=su(n,l),h=Od(s,a);XR(t,e,r,u,h,i)}else{let u=Rd(n);gx(u,o,r,fx)&&px(u,t,e,r,i);let h=Ld(n,l);gx(h,o,r,fx)&&px(h,t,e,r,i)}}function mx(n,t,e,r){let i=n*2,s=Bd,o=Kl,a=Ql;if(qa(i,o)){let c=su(n,a),u=Od(i,o);return YR(t,e,r,c,u)}else{let c=KR(n,a),u=pK[c],d=r.direction[u]>=0,f,m;d?(f=Rd(n),m=Ld(n,a)):(f=Ld(n,a),m=Rd(n));let g=gx(f,s,r,fx)?mx(f,t,e,r):null;if(g){let v=g.point[u];if(d?v<=s[m+c]:v>=s[m+c+3])return g}let x=gx(m,s,r,fx)?mx(m,t,e,r):null;return g&&x?g.distance<=x.distance?g:x:g||x||null}}var QR=function(){let n,t,e=[],r=new Dd(()=>new Yt);return function(...o){n=r.getPrimitive(),t=r.getPrimitive(),e.push(n,t);let a=i(...o);r.releasePrimitive(n),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],n=e[l-2]),a};function i(s,o,a,l,c=null,u=0,h=0){function d(v){let b=v*2,w=Kl,A=Ql;for(;!qa(b,w);)v=Rd(v),b=v*2;return su(v,A)}function f(v){let b=v*2,w=Kl,A=Ql;for(;!qa(b,w);)v=Ld(v,A),b=v*2;return su(v,A)+Od(b,w)}let m=s*2,p=Bd,g=Kl,y=Ql;if(qa(m,g)){let v=su(s,y),b=Od(m,g);return Cs(s,p,n),l(v,b,!1,h,u+s,n)}else{let v=Rd(s),b=Ld(s,y),w=v,A=b,T,S,M,C;if(c&&(M=n,C=t,Cs(w,p,M),Cs(A,p,C),T=c(M),S=c(C),S<T)){w=b,A=v;let V=T;T=S,S=V,M=C}M||(M=n,Cs(w,p,M));let P=qa(w*2,g),_=a(M,P,T,h+1,u+w),I;if(_===2){let V=d(w),q=f(w)-V;I=l(V,q,!0,h+1,u+w,M)}else I=_&&i(w,o,a,l,c,u,h+1);if(I)return!0;C=t,Cs(A,p,C);let O=qa(A*2,g),L=a(C,O,S,h+1,u+A),j;if(L===2){let V=d(A),q=f(A)-V;j=l(V,q,!0,h+1,u+A,C)}else j=L&&i(A,o,a,l,c,u,h+1);return!!j}}}(),ZR=function(){let n=new Vn,t=new Vn,e=new ue,r=new Un,i=new Un;return function s(o,a,l,c,u=null){let h=o*2,d=Bd,f=Kl,m=Ql;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,c),u=r),qa(h,f)){let g=a,y=g.index,x=g.attributes.position,v=l.index,b=l.attributes.position,w=su(o,m),A=Od(h,f);if(e.copy(c).invert(),l.boundsTree)return Cs(o,d,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>i.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(c),S.b.applyMatrix4(c),S.c.applyMatrix4(c),S.needsUpdate=!0;for(let M=w*3,C=(A+w)*3;M<C;M+=3)if(Ps(t,M,y,x),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let T=w*3,S=A+w*3;T<S;T+=3){Ps(n,T,y,x),n.a.applyMatrix4(e),n.b.applyMatrix4(e),n.c.applyMatrix4(e),n.needsUpdate=!0;for(let M=0,C=v.count;M<C;M+=3)if(Ps(t,M,v,b),t.needsUpdate=!0,n.intersectsTriangle(t))return!0}}else{let g=o+8,y=m[o+6];return Cs(g,d,Nd),!!(u.intersectsBox(Nd)&&s(g,a,l,c,u)||(Cs(y,d,Nd),u.intersectsBox(Nd)&&s(y,a,l,c,u)))}}}();function gx(n,t,e,r){return Cs(n,t,Nd),e.intersectBox(Nd,r)}var bE=[],dx,Bd,Kl,Ql;function Fd(n){dx&&bE.push(dx),dx=n,Bd=new Float32Array(n),Kl=new Uint16Array(n),Ql=new Uint32Array(n)}function Im(){dx=null,Bd=null,Kl=null,Ql=null,bE.length&&Fd(bE.pop())}var SE=Symbol("skip tree generation"),wE=new Yt,AE=new Yt,Vd=new ue,ou=new Un,Dm=new Un,Om=new E,yx=new E,mK=new E,gK=new E,yK=new E,JR=new Yt,Xo=new Dd(()=>new Vn),Yo=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Yo.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,i=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(t,e,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Yo.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:i,roots:s}=t,o=new Yo(e,{...r,[SE]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new je(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[SE]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[SE]||(this._roots=GR(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Yt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,i=e.attributes.position,s,o,a,l,c=0,u=this._roots;for(let d=0,f=u.length;d<f;d++)s=u[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,c),c+=s.byteLength;function h(d,f,m=!1){let p=d*2;if(a[p+15]===65535){let y=o[d+6],x=a[p+14],v=1/0,b=1/0,w=1/0,A=-1/0,T=-1/0,S=-1/0;for(let M=3*y,C=3*(y+x);M<C;M++){let P=r[M],_=i.getX(P),I=i.getY(P),O=i.getZ(P);_<v&&(v=_),_>A&&(A=_),I<b&&(b=I),I>T&&(T=I),O<w&&(w=O),O>S&&(S=O)}return l[d+0]!==v||l[d+1]!==b||l[d+2]!==w||l[d+3]!==A||l[d+4]!==T||l[d+5]!==S?(l[d+0]=v,l[d+1]=b,l[d+2]=w,l[d+3]=A,l[d+4]=T,l[d+5]=S,!0):!1}else{let y=d+8,x=o[d+6],v=y+f,b=x+f,w=m,A=!1,T=!1;t?w||(A=t.has(v),T=t.has(b),w=!A&&!T):(A=!0,T=!0);let S=w||A,M=w||T,C=!1;S&&(C=h(y,f,w));let P=!1;M&&(P=h(x,f,w));let _=C||P;if(_)for(let I=0;I<3;I++){let O=y+I,L=x+I,j=l[O],V=l[O+3],H=l[L],q=l[L+3];l[d+I]=j<H?j:H,l[d+I+3]=V>q?V:q}return _}}}traverse(t,e=0){let r=this._roots[e],i=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let c=a*2,u=s[c+15]===65535;if(u){let h=i[a+6],d=s[c+14];t(l,u,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=i[a+6],f=i[a+7];t(l,u,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Jn){let r=this._roots,i=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=i.groups,c=o?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=a?e[l[u].materialIndex].side:c,f=s.length;if(Fd(r[u]),px(0,i,d,t,s),Im(),a){let m=l[u].materialIndex;for(let p=f,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(t,e=Jn){let r=this._roots,i=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=i.groups,c=s?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=o?e[l[u].materialIndex].side:c;Fd(r[u]);let f=mx(0,i,d,t);Im(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[u].materialIndex))}return a}intersectsGeometry(t,e){let r=this.geometry,i=!1;for(let s of this._roots)if(Fd(s),i=ZR(0,r,t,e),Im(),i)break;return i}shapecast(t,e,r){let i=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,m,p,g)=>{let y=m*3;return d(f,y,y+1,y+2,p,g)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,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=Xo.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:c}=t;if(l&&c){let d=l;l=(f,m,p,g,y)=>d(f,m,p,g,y)?!0:xE(f,m,i,c,p,g,s)}else l||(c?l=(d,f,m,p)=>xE(d,f,i,c,m,p,s):l=(d,f,m)=>m);let u=!1,h=0;for(let d of this._roots){if(Fd(d),u=QR(0,i,a,l,o,h),Im(),u)break;h+=d.byteLength}return Xo.releasePrimitive(s),u}bvhcast(t,e,r){let{intersectsRanges:i,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,c=t.geometry.attributes.position;Vd.copy(e).invert();let u=Xo.getPrimitive(),h=Xo.getPrimitive();if(s){let f=function(m,p,g,y,x,v,b,w){for(let A=g,T=g+y;A<T;A++){Ps(h,A*3,l,c),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let S=m,M=m+p;S<M;S++)if(Ps(u,S*3,o,a),u.needsUpdate=!0,s(u,h,S,A,x,v,b,w))return!0}return!1};if(i){let m=i;i=function(p,g,y,x,v,b,w,A){return m(p,g,y,x,v,b,w,A)?!0:f(p,g,y,x,v,b,w,A)}}else i=f}t.getBoundingBox(AE),AE.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>AE.intersectsBox(f),intersectsRange:(f,m,p,g,y,x)=>(wE.copy(x),wE.applyMatrix4(Vd),t.shapecast({intersectsBounds:v=>wE.intersectsBox(v),intersectsRange:(v,b,w,A,T)=>i(f,m,v,b,g,y,A,T)}))});return Xo.releasePrimitive(u),Xo.releasePrimitive(h),d}intersectsBox(t,e){return ou.set(t.min,t.max,e),ou.needsUpdate=!0,this.shapecast({intersectsBounds:r=>ou.intersectsBox(r),intersectsTriangle:r=>ou.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},i={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),ou.set(t.boundingBox.min,t.boundingBox.max,e),ou.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,c=a.index,u=t.attributes.position,h=t.index,d=Xo.getPrimitive(),f=Xo.getPrimitive(),m=yx,p=mK,g=null,y=null;i&&(g=gK,y=yK);let x=1/0,v=null,b=null;return Vd.copy(e).invert(),Dm.matrix.copy(Vd),this.shapecast({boundsTraverseOrder:w=>ou.distanceToBox(w),intersectsBounds:(w,A,T)=>T<x&&T<o?(A&&(Dm.min.copy(w.min),Dm.max.copy(w.max),Dm.needsUpdate=!0),!0):!1,intersectsRange:(w,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:T=>Dm.distanceToBox(T),intersectsBounds:(T,S,M)=>M<x&&M<o,intersectsRange:(T,S)=>{for(let M=T*3,C=(T+S)*3;M<C;M+=3){Ps(f,M,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let P=w*3,_=(w+A)*3;P<_;P+=3){Ps(d,P,c,l),d.needsUpdate=!0;let I=d.distanceToTriangle(f,m,g);if(I<x&&(p.copy(m),y&&y.copy(g),x=I,v=P/3,b=M/3),I<s)return!0}}}});{let T=h?h.count:u.count;for(let S=0,M=T;S<M;S+=3){Ps(f,S,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=w*3,P=(w+A)*3;C<P;C+=3){Ps(d,C,c,l),d.needsUpdate=!0;let _=d.distanceToTriangle(f,m,g);if(_<x&&(p.copy(m),y&&y.copy(g),x=_,v=C/3,b=S/3),_<s)return!0}}}}}),Xo.releasePrimitive(d),Xo.releasePrimitive(f),x===1/0?null:(r.point?r.point.copy(p):r.point=p.clone(),r.distance=x,r.faceIndex=v,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(Vd),p.applyMatrix4(Vd),i.distance=p.sub(i.point).length(),i.faceIndex=b),r)}closestPointToPoint(t,e={},r=0,i=1/0){let s=r*r,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:u=>(Om.copy(t).clamp(u.min,u.max),Om.distanceToSquared(t)),intersectsBounds:(u,h,d)=>d<a&&d<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,Om);let d=t.distanceToSquared(Om);return d<a&&(yx.copy(Om),a=d,l=h),d<s}}),a===1/0)return null;let c=Math.sqrt(a);return e.point?e.point.copy(yx):e.point=yx.clone(),e.distance=c,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{Cs(0,new Float32Array(r),JR),t.union(JR)}),t}};var mb=cl(e3());var vK=.5*(Math.sqrt(3)-1),Rm=(3-Math.sqrt(3))/6,xK=1/3,Ko=1/6,P0e=(Math.sqrt(5)-1)/4,_0e=(5-Math.sqrt(5))/20,Lm=n=>Math.floor(n)|0,t3=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]),TE=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 r3(n=Math.random){let t=n3(n),e=new Float64Array(t).map(i=>t3[i%12*2]),r=new Float64Array(t).map(i=>t3[i%12*2+1]);return function(s,o){let a=0,l=0,c=0,u=(s+o)*vK,h=Lm(s+u),d=Lm(o+u),f=(h+d)*Rm,m=h-f,p=d-f,g=s-m,y=o-p,x,v;g>y?(x=1,v=0):(x=0,v=1);let b=g-x+Rm,w=y-v+Rm,A=g-1+2*Rm,T=y-1+2*Rm,S=h&255,M=d&255,C=.5-g*g-y*y;if(C>=0){let I=S+t[M],O=e[I],L=r[I];C*=C,a=C*C*(O*g+L*y)}let P=.5-b*b-w*w;if(P>=0){let I=S+x+t[M+v],O=e[I],L=r[I];P*=P,l=P*P*(O*b+L*w)}let _=.5-A*A-T*T;if(_>=0){let I=S+1+t[M+1],O=e[I],L=r[I];_*=_,c=_*_*(O*A+L*T)}return 70*(a+l+c)}}function i3(n=Math.random){let t=n3(n),e=new Float64Array(t).map(s=>TE[s%12*3]),r=new Float64Array(t).map(s=>TE[s%12*3+1]),i=new Float64Array(t).map(s=>TE[s%12*3+2]);return function(o,a,l){let c,u,h,d,f=(o+a+l)*xK,m=Lm(o+f),p=Lm(a+f),g=Lm(l+f),y=(m+p+g)*Ko,x=m-y,v=p-y,b=g-y,w=o-x,A=a-v,T=l-b,S,M,C,P,_,I;w>=A?A>=T?(S=1,M=0,C=0,P=1,_=1,I=0):w>=T?(S=1,M=0,C=0,P=1,_=0,I=1):(S=0,M=0,C=1,P=1,_=0,I=1):A<T?(S=0,M=0,C=1,P=0,_=1,I=1):w<T?(S=0,M=1,C=0,P=0,_=1,I=1):(S=0,M=1,C=0,P=1,_=1,I=0);let O=w-S+Ko,L=A-M+Ko,j=T-C+Ko,V=w-P+2*Ko,H=A-_+2*Ko,q=T-I+2*Ko,X=w-1+3*Ko,K=A-1+3*Ko,z=T-1+3*Ko,Q=m&255,te=p&255,$=g&255,W=.6-w*w-A*A-T*T;if(W<0)c=0;else{let J=Q+t[te+t[$]];W*=W,c=W*W*(e[J]*w+r[J]*A+i[J]*T)}let oe=.6-O*O-L*L-j*j;if(oe<0)u=0;else{let J=Q+S+t[te+M+t[$+C]];oe*=oe,u=oe*oe*(e[J]*O+r[J]*L+i[J]*j)}let ie=.6-V*V-H*H-q*q;if(ie<0)h=0;else{let J=Q+P+t[te+_+t[$+I]];ie*=ie,h=ie*ie*(e[J]*V+r[J]*H+i[J]*q)}let re=.6-X*X-K*K-z*z;if(re<0)d=0;else{let J=Q+1+t[te+1+t[$+1]];re*=re,d=re*re*(e[J]*X+r[J]*K+i[J]*z)}return 32*(c+u+h+d)}}function n3(n){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let i=r+~~(n()*(256-r)),s=e[r];e[r]=e[i],e[i]=s}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var eo=new Or,vx=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let s=1;eo.a.fromBufferAttribute(t,i),eo.b.fromBufferAttribute(t,i+1),eo.c.fromBufferAttribute(t,i+2),s*=eo.getArea(),e[i/3]=s}this.distribution=new Float32Array(t.count/3);let r=0;for(let i=0;i<e.length;i++)r+=e[i],this.distribution[i]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*r);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,i=e.length-1,s=-1;for(;r<=i;){let o=Math.ceil((r+i)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?i=o-1:r=o+1}return s}sampleFace(t,e,r){let i=this.randomFunction(),s=this.randomFunction();return i+s>1&&(i=1-i,s=1-s),eo.a.fromBufferAttribute(this.positionAttribute,t*3),eo.b.fromBufferAttribute(this.positionAttribute,t*3+1),eo.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(eo.a,i).addScaledVector(eo.b,s).addScaledVector(eo.c,1-(i+s)),eo.getNormal(r),this}};var o3=cl(ME()),bK=new ue,SK=new ue,wK=new ue,Xa;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(Xa||(Xa={}));var Ud=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new ue;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ue;this.pivotMatrix=new ue;this.matrixWorldRigid=new ue;this.shearScale=new ue;this.shearScaleInv=new ue}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Dt&&(r=r.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===r)return!0;i=i.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(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.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.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)),this.matrixWorld.multiply(this.pivotMatrix),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,i=0){for(let s of this.children)Xa.is(s)&&s.traverseObject(r,i+1)}traverseObject(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Xa.is(o)&&o.traverseObject(r,i+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,i=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:s,v:o,q:a}=(0,o3.SVD)(i),l=bK.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),c=SK.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),u=wK.copy(c).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,i){this.updateWorldMatrix(!0,!1);let s=new ue().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ue?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),i!==void 0&&(this.children.pop(),this.children.splice(i,0,r)),this}copy(r,i=!1){return super.copy(r,i),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,i,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var CE=class extends Ud(Dt){},AK=n=>n.type==="Mesh",Lr=class extends CE{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let i=this.children[e];i?.object!==r&&(i&&this.remove(i),i=new Lr(r),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=r.matrix,i.hiddenMatrix=r.hiddenMatrix,i.pivotMatrix=r.pivotMatrix),i.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}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 AK(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}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};var au=new E,lu=new E,kd=new ue,l3=[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)],EK=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],TK=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],a3=(n,t,e)=>{n.updateEntityBoxSize(au,lu),kd.copy(t).multiply(n.matrixWorld),lu.x===0&&lu.y===0&&lu.z===0?e.push(new E(au.x,au.y,au.z).applyMatrix4(kd)):l3.forEach(r=>{e.push(r.clone().multiply(lu).add(au).applyMatrix4(kd))})},Nm=class extends Yt{constructor(){super(...arguments);this.matrix=new ue;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new ue().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,r)}expandByObjectSize(e,r,i=!1){let s=[];return i===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new E);return}a3(o,r,s)}}):a3(e,r,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(kd.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(lu).multiplyScalar(.5),this.getCenter(au),kd.copy(this.matrix).setPosition(au),this.vertices=l3.map(e=>e.clone().multiply(lu).applyMatrix4(kd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=EK.map(([e,r])=>new Di(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=TK.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var to={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var _E=class extends Hp{constructor(){super()}getPoints(t=12){let e=[],r,i=this.getCurveLengths(),o=i[i.length-1]/i.length;for(let a=0,l=this.curves;a<l.length;a++){let c=l[a],u=a===0?i[a]:i[a]-i[a-1],h=Math.ceil(t*u/o),d=c.getPoints(h);for(let f=0;f<d.length;f++){let m=d[f];r&&r.equals(m)||(e.push(m),r=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var IE=.001;function DE(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=IE}function PE(n,t){let e=new E(...n.position),r=new E(...n.controlNext.position),i=new E(...t.controlPrevious.position),s=new E(...t.position);return DE(e,r,s)&&DE(e,i,s)}function bx(n){let t=n.points.map(u=>new E(...u.data.position)),e=[n.points[0]],r=new E(...e[0].data.position);for(let u=0;u<n.points.length-1;u++)DE(r,t[u],t[u+1])||(e.push(n.points[u]),r=t[u]);e.push(n.points[n.points.length-1]);let i=n.isClosed,s=e.length-(i?0:1),o=e.length,a=[];for(let u=0;u<o;u++){let h=e[u].data,d=new E(...h.position),f=new E(...h.controlPrevious.position),m=new E(...h.controlNext.position),p={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:m};if(h.roundness===0||!n.isClosed&&(u===0||u===o-1)){a[u]={...p,removedLength:0};continue}let g=i&&u==0?o-1:u-1,y=i&&u==o-1?0:u+1,x=e[g].data,v=e[y].data,b=new E(...x.position),w=new E(...v.position),A=b.clone().sub(d).normalize(),T=w.clone().sub(d).normalize();Object.assign(p,{prevDir:A,nextDir:T});let S=PE(x,h),M=PE(h,v);if(!S||!M)a[u]={...p,removedLength:0};else{let C=A.clone().add(T).normalize(),P=C.clone().cross(A).length()/A.dot(C);a[u]={...p,tan:P,removedLength:h.roundness/P}}}for(let u=0;u<s;u++){let h=u,d=i&&u===o-1?0:u+1,f=a[h],m=a[d];if(f.removedLength!==0||m.removedLength!==0){let p=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,p/2),m.removedLength=Math.min(m.removedLength,p/2)}}let l=[];for(let u=0;u<s;u++){let h=u,d=i&&u===o-1?0:u+1,f=a[h],m=a[d],p=null;if(!PE(e[h].data,e[d].data))f.position.distanceTo(m.position)>IE&&(p=new zc(f.position,f.controlNext,m.controlPrevious,m.position));else{let g=f.position.clone(),y=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&y.add(m.prevDir.clone().setLength(m.removedLength))),g.distanceTo(y)>IE&&(p=new zc(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*u+1]=p}for(let u=0;u<o;u++){let h=a[u];if(h.removedLength===0){l[2*u]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),m=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),p=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(m,.5),x=f.distanceTo(m)/2,v=g.clone().multiplyScalar(Math.sqrt(Math.pow(p,2)-Math.pow(x,2))).add(y),b=g.clone().multiplyScalar(-p).add(v),w=d.distanceTo(b)/d.distanceTo(y),A=h.prevDir.clone().multiplyScalar(w*d.distanceTo(f)).add(d),T=A.clone().lerp(b,2),S=f.clone().lerp(A,4/3),M=m.clone().lerp(T,4/3);l[2*u]=new zc(f,S,M,m)}let c=new _E;return l.forEach(u=>{u&&c.add(u)}),c}var gt;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(gt||(gt={}));var Qo=n=>gt.is(n),MK={type:"completeState",isfromEntity:!0},CK=["x","y","z"],Bm=new E,c3=new E(1,1,1),OE=new Ye,u3=new Jt,PK=new E().set(0,1,0),zd=n=>class extends Ud(n){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.currentAnimationAction=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Nm;this._recursiveBBox=new Nm;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let i=this.children[r];if(gt.is(i))return i}entityChildrenCount(){let r=this.children.length;for(;r--;)if(gt.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let i=r.parent;if(gt.is(i))r=i;else return}return r}forInstancesRec(r){this.instances.forEach(i=>{i.disposed||r(i),i.forInstancesRec(r)})}super_Entity(r,i){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)Qs.toOps(this.data,o.data).forEach(l=>{let c=id.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,i)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=Qs.patch(this.data,o),Qs.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}s&&this.updateTransformState(this.dataPatched,i),this.stateSelection=r,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(r,i){r.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Qo(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let i;return this.traverseEntity(s=>{s.uuid===r&&(i=s)}),i}traverseSortNextHelper(){let r=this.parent;if(r){let i=r.children,s=i.indexOf(this)+1;if(gt.is(i[s]))return i[s];if(gt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&>.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let i=this;for(;r>0&&i!==null;)i=i.parent,r-=1;return i}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let i=this.parent;for(;i;){if(r===i)return!0;i=i.parent}return!1}countToAccestor(r){let i=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(r){for(let i of this.children)Qo(i)&&r(i)}traverseEntityAncestors(r){this.traverseAncestors(i=>{gt.is(i)&&r(i)})}traverseConcreteEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Qo(o)&&o.isConcreteEntity&&o.traverseEntity(r,i+1)}traverseEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Qo(o)&&o.traverseEntity(r,i+1)}traverseVisibleEntity(r){r(this);for(let i of this.children)Qo(i)&&i.visible&&i.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,i=!1){return super.copy(r,i),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Qo(r))}isAncestorOf(r){if(this.uuid===r)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===r&&(i=!0)}),i}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*Se.RAD2DEG,this.rotation.y*Se.RAD2DEG,this.rotation.z*Se.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]};return Qh(i,r)}getTransformValues(r,i,s){return i[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,CK[a]])??o)}updateTransformState(r,i){let s=!1;if(r.position&&(this.position.fromArray(this.getTransformValues("position",r,i)),s=!0),r.rotation&&(Bm.fromArray(this.getTransformValues("rotation",r,i)).multiplyScalar(Se.DEG2RAD),this.rotation.setFromVector3(Bm),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,i)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??zl.identity)),r.pivot!==void 0||r.pivotRotation!==void 0){if(s=!0,r.pivot!==void 0&&r.pivotRotation!==void 0)this.pivotMatrix.compose(Bm.fromArray(r.pivot).negate(),OE.setFromEuler(u3.fromArray(r.pivotRotation.map(o=>o*Se.DEG2RAD))).invert(),c3);else if(r.pivot!==void 0)this.pivotMatrix.setPosition(-r.pivot[0],-r.pivot[1],-r.pivot[2]);else if(r.pivotRotation!==void 0){let o=Bm.setFromMatrixPosition(this.pivotMatrix);OE.setFromEuler(u3.fromArray(r.pivotRotation.map(a=>a*Se.DEG2RAD))).invert(),this.pivotMatrix.compose(o,OE,c3)}}return s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender()}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)gt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{gt.is(r)&&r.disposeRecursively()})}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Qh(i,r)}updateByObjUpdateOp(r,i){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},i,!1)}updateByOp(r,i,s,o){let a=this.data;this.data=i;let l=r,c=kt(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let h={...r.props};if(delete h.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Mr.zoom(d,r.path.slice(2));if(f)for(let m in r.props)r.props[m]===void 0&&m in f&&(h[m]=f[m])}}l={...r,props:h,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:d,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let h=Mr.removeOverridden(r.path,r.props,u);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,Qs.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),kt(r.path,["overrides"])){let u=[],h=[...r.path];for(u.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)u.push(h[1]),h.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){u[u.length-1]=d;let f=s.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[d],f.updateState(Do.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...u]);if(d){let f=Mr.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let m=r.props;if(f)for(let[p,g]of Object.entries(r.props))g===void 0&&(m===r.props&&(m={...r.props}),m[p]=f[p]);r={...r,props:m}}d.overrideData=gd.resolve(i.overrides,u),d.updateByOp(r,zr.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let h;for(let d of Vo.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(u={...r,props:h})}else for(let h of Vo.rootOverrideProps)if(kt(r.path,[h])){u=r;break}u!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Do.filterOp(h.overrideData,u);d&&h.updateByOp(d,zr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Do.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=i:f=zr.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,i,s){if(this.dataPatched=i,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Ks.is(r.props.type)&&to.changeEntityProptotype(this,i,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){to.changeEntityProptotype(this,i,s);for(let o of this.children)gt.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,i,s)}updateByPatchedOp(r,i,s){if(r.path.length===0&&r.type===0?this.updateState(r.props,s):r.type===0&&("resolutionLevel"in r.props||"useChildrenColors"in r.props)&&this.updateState(i,s),r.path[0]==="morphTargetInfluences"&&r.type===0){let a=i.morphTargetInfluences.get(r.path[1])?.data.name;a&&this.updateMorphInfluences(a,s.shared.getVariable(r.props.value,[this.uuid,"morphTargetInfluences",a]))}if(kt(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),kt(r.path,["cloner"])!==null){let o=zr.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s):(this.setFromClonerState(i.cloner,s),this.expandCloner(s)),this.updateVisible(s.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=r.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=bx(c.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=null;try{d=u.curves.length?u.getPointAt(h):null}catch(g){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(g))}if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ue;l.updateMatrixWorld();let m=new ue().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(m);let p={position:d.toArray(),rotation:c.rotation};if(a==="tangential"){let g=new ue().extractRotation(l.matrixWorld),y=u.getTangentAt(h).applyMatrix4(g).add(d),x=new ue().lookAt(d,y,PK),v=Bm.setFromEuler(new Jt().setFromRotationMatrix(x)).multiplyScalar(Se.RAD2DEG);p={...p,rotation:v.toArray()}}this.updateTransformState(p),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(MK)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let i=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return i=!0,!0}),i&&r.reloadSplats()}updateState_Entity(r,i){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(r,i)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof to.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,i){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new to.Cloner(this,r),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,i))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var Sx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.parameters?.radiusTop,r=n.parameters?.radiusBottom,i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);i.thetaLength=Se.clamp(i.thetaLength,0,360);let s=i.width/2,o=i.radiusTop??s,a=i.radiusBottom??s;if(o===a?(o=s,a=s):o>a?(o=s,a=a*s/o):(o=o*s/a,a=s),i.shapeBlendNode){o=e??s,a=r??s;let l=Math.max(o,a)*2;i.width=l,i.depth=l}return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:o,radiusBottom:a})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:h,cornerSegments:d,hollow:f}=n.parameters,m;return l===0?(m=new Ce,m.setAttribute("position",new Te([],3))):h||f?m=new Fm(c,u,r,i,s,o,a,l*Math.PI/180,h,h,d,f):m=new jc(c,u,r,i,s,o,a,l*Math.PI/180),m.scale(1,1,e/t),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function Zl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function h3(n){return new U(n.y,-n.x)}var Fm=class extends Ce{constructor(t,e,r,i,s,o,a,l,c,u,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,u=0);let m=[],p=[],g=[],y=[],x=0,v=r/2,b=new E,w=new E;f&&t==0&&(t=c),f&&e==0&&(e=u);let A=new U(t,v),T=new U(e,-v),S=null,M=null,C=null,P=null,_=A.clone().sub(T),I=0,O=0,L=0;d>0&&(I=Math.min(t,e)*(1-d),O=t-I,L=e-I);let j=A.clone();j.x-=I;let V=Math.PI-_.angle(),H=_.angle(),q=Math.tan(H/2),X=Math.tan(V/2),K=q+X,z=d?K:X,Q=d?K:q;if(c=Math.min(c,(t-O)/z,_.length()/K),u=Math.min(u,(e-L)/Q,_.length()/K),c>0){let re=c/q;S=A.clone().sub(new U(re,c)),d&&(C=S.clone(),C.x-=I-K*c),A.sub(_.clone().setLength(re))}if(u>0){let re=u/X;M=T.clone().sub(new U(re,-u)),T.add(_.clone().setLength(re)),d&&(P=M.clone(),P.x-=I-K*u,j.sub(_.clone().setLength(re)))}_=A.clone().sub(T);let te=_.length()<.5,$=[];for(let re=0;re<=i;re++){let J=[],Ee=re/i,xe=Ee*l+a,de=new U(Math.sin(xe),Math.cos(xe));P&&M?(W(J,Ee,de,V,u,P,-1,!0),W(J,Ee,de,H,u,M,-1,!1)):M?(oe(J,de,M.x,0,-1),W(J,Ee,de,H,u,M,-1,!1)):o||oe(J,de,e,L,-1);let De=h3(_).normalize();if(Zl(De,de,b),!te)for(let Pe=0;Pe<=s;Pe++){let ze=Pe/s,ke=_.clone().multiplyScalar(ze).add(T);Zl(ke,de,w),p.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(Ee,.5+w.y/r),J.push(x++)}if(C&&S?(W(J,Ee,de,V,c,S,1,!1),W(J,Ee,de,H,c,C,1,!0)):S?(W(J,Ee,de,V,c,S,1,!1),oe(J,de,S.x,0,1)):o||oe(J,de,t,O,1),d&&!te){let Pe=h3(_).multiplyScalar(-1).normalize();Zl(Pe,de,b);for(let ze=0;ze<=s;ze++){let ke=ze/s,Ue=_.clone().multiplyScalar(-ke).add(j);Zl(Ue,de,w),p.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(Ee,.5+w.y/r),J.push(x++)}}d&&!o&&J.push(J[0]),$.push(J)}for(let re=0;re<$.length-1;re++)for(let J=0;J<$[0].length-1;J++){if(o&&d&&J==s)continue;let Ee=$[re][J],xe=$[re+1][J],de=$[re+1][J+1],De=$[re][J+1],Pe=p[de*3+0],ze=p[de*3+2];m.push(Ee,xe,De),(Pe!=0||ze!=0)&&m.push(xe,de,De)}l<Math.PI*2&&(ie(-1,$[0],a),ie(1,$[$.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(g,3)),this.setAttribute("uv",new Te(y,2));function W(re,J,Ee,xe,de,De,Pe,ze){for(let ke=0;ke<h+1;ke++){let Ue=ke/h,Le=Pe<0?Ue:1-Ue;ze&&(Le-=1),Le*=xe;let Qe=new U(Math.sin(Le),Math.cos(Le)*Pe),F=Qe.clone().multiplyScalar(de).add(De);Zl(F,Ee,w),p.push(w.x,w.y,w.z),Zl(Qe,Ee,b),g.push(b.x,b.y,b.z),y.push(J,.5+w.y/r),re.push(x++)}}function oe(re,J,Ee,xe,de){let De=new E,Pe=new U,ze=[Ee,xe];de<0&&ze.reverse();for(let ke of ze)Pe.set(ke,v*de),Zl(Pe,J,De),p.push(De.x,De.y,De.z),g.push(0,de,0),y.push(.5,.5),re.push(x++)}function ie(re,J,Ee){let xe=new U(Math.sin(Ee),Math.cos(Ee)),de=new U(-Math.cos(Ee),Math.sin(Ee)),De=new E,Pe=re<0?(Ue,Le,Qe)=>m.push(Ue,Le,Qe):(Ue,Le,Qe)=>m.push(Ue,Qe,Le),ze=new U((t+e+O+L)/4,0);Zl(ze,xe,De),p.push(De.x,De.y,De.z),g.push(de.x,0,de.y),y.push(.5,.5);let ke=x++;for(let Ue of J){let Le=p.slice(Ue*3,Ue*3+3);p.push(...Le),g.push(de.x,0,de.y);let Qe=y.slice(Ue*2,Ue*2+2);y.push(...Qe),x++}for(let Ue=ke+1;Ue<x-1;Ue++)Pe(ke,Ue,Ue+1);Pe(ke,x-1,ke+1)}}};var d3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=Se.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:h}=n.parameters,d;return l===0?(d=new Ce,d.setAttribute("position",new Te([],3))):c>0||u>0||l<360?d=new Fm(0,t/2,r,i,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new Al(t/2,r,i,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};var f3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=n.parameters,c;return a===0?c=new bi(t,e,r,i,s,o):c=new LE(t,e,r,i,s,o,a,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},RE=Math.PI/2,LE=class extends Ce{constructor(t=1,e=1,r=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry",i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let c=[],u=[],h=[],d=[],f=0;m("z","y","x",-1,-1,r,e,t,o,s),m("z","y","x",1,-1,r,e,-t,o,s),m("x","z","y",1,1,t,r,e,i,o),m("x","z","y",1,-1,t,r,-e,i,o),m("x","y","z",1,-1,t,e,r,i,s),m("x","y","z",-1,-1,t,e,-r,i,s),a>0&&(p("z","y","x",-1,-1,1,r,e,t,o),p("z","y","x",1,-1,-1,r,e,t,o),p("z","y","x",-1,1,-1,r,e,t,o),p("z","y","x",1,1,1,r,e,t,o),p("x","y","z",-1,-1,-1,t,e,r,i),p("x","y","z",1,-1,1,t,e,r,i),p("x","y","z",-1,1,1,t,e,r,i),p("x","y","z",1,1,-1,t,e,r,i),p("y","x","z",-1,-1,1,e,t,r,s),p("y","x","z",1,-1,-1,e,t,r,s),p("y","x","z",1,1,1,e,t,r,s),p("y","x","z",-1,1,-1,e,t,r,s),g(1,1,1),g(-1,1,1),g(1,-1,1),g(-1,-1,1),g(1,1,-1),g(-1,1,-1),g(1,-1,-1),g(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Te(u,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(d,2));function m(y,x,v,b,w,A,T,S,M,C){let P=(A-2*a)/M,_=(T-2*a)/C,I=A/2-a,O=T/2-a,L=S/2,j=M+1,V=C+1,H=0,q=new E;for(let X=0;X<V;X++){let K=X*_-O;for(let z=0;z<j;z++){let Q=z*P-I;q[y]=Q*b,q[x]=K*w,q[v]=L,u.push(q.x,q.y,q.z),q[y]=0,q[x]=0,q[v]=S>0?1:-1,h.push(q.x,q.y,q.z),d.push(z/M),d.push(1-X/C),H+=1}}for(let X=0;X<C;X++)for(let K=0;K<M;K++){let z=f+K+j*X,Q=f+K+j*(X+1),te=f+(K+1)+j*(X+1),$=f+(K+1)+j*X;c.push(z,Q,$),c.push(Q,te,$)}f+=H}function p(y,x,v,b,w,A,T,S,M,C){let P=(T-2*a)/C,_=T/2-a,I=S/2-a,O=M/2,L=C+1,j=0,V=new E,H=new E;for(let q=0;q<l+1;q++){let X=q/l*RE,K=Math.sin(X)*a,z=(1-Math.cos(X))*a,Q=Math.sin(X),te=Math.cos(X);V[x]=(I+K)*w,V[v]=(O-z)*A,H[y]=0,H[x]=Q*Math.sign(V[x]),H[v]=te*Math.sign(V[v]);for(let $=0;$<L;$++){let W=$*P-_;V[y]=W*b,u.push(V.x,V.y,V.z),h.push(H.x,H.y,H.z),d.push($/C),d.push(0),j+=1}}for(let q=0;q<l;q++)for(let X=0;X<C;X++){let K=f+X+L*q,z=f+X+L*(q+1),Q=f+(X+1)+L*(q+1),te=f+(X+1)+L*q;c.push(K,z,te),c.push(z,Q,te)}f+=j}function g(y,x,v){let b=new E,w=new E(t/2,e/2,r/2);w.subScalar(a);let A=[],T=y*x*v>0?(M,C,P)=>c.push(M,C,P):(M,C,P)=>c.push(M,P,C);for(let M=0;M<=l;M++){let C=[],P=RE*(1-M/l),_=Math.cos(P),I=Math.sin(P),O=0;for(let L=0;L<=M;L++){let j=Math.cos(O),V=Math.sin(O);b.x=_*j,b.y=I,b.z=_*V;let H=w.clone().addScaledVector(b,a);u.push(y*H.x,x*H.y,v*H.z),h.push(y*b.x,x*b.y,v*b.z),d.push(0,0),C.push(f++),O+=RE/M}A.push(C)}let S=A.length-1;for(let M=0;M<S;M++){let C=A[M],P=A[M+1],_=C.length-1;T(C[0],P[1],P[0]);for(let I=1;I<=_;I++)T(C[I-1],C[I],P[I]),T(C[I],P[I+1],P[I])}}}};var Jl=class extends Ce{constructor(t=[],e=[],r="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];u(),h(),this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(l,2));return;function u(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new E,p=m.clone(),g=new Or,y=s*i,x=i-y,v=o+1,b=new E,w=(q,X)=>b.subVectors(q,X).normalize(),A=(q,X)=>Array(q).fill(void 0).map(X),T=A(t.length/3,(q,X)=>new E().fromArray(t,X*3).setLength(i)),S=[],M=1e6;for(let q=0;q<T.length;q++){let X=T[q],K=[],z,Q,te,$=1e10,W=-1;for(;(W=e.indexOf(q,W+1))!=-1;){let J=W-W%3;z=e[J+(W+1)%3],Q=e[J+(W+2)%3],te=X.distanceToSquared(T[z]),$=Math.min($,te),K.push([z,Q,te])}$+=1e-6;let oe=[],ie=0,re=K.length;for(let J=0;J<re;J++){[z,Q,te]=K[ie];let Ee=S[z]?.includes(q)==!0;te<=$&&oe.push(z+ +Ee*M),ie=K.findIndex(xe=>xe[0]==Q)}S.push(oe)}let C=[];{let q=0,X=0,K,z,Q=f==3;for(let te=0;te<=o;te++){K=te*(te+1)/2,z=(te+1)*(te+2)/2;for(let $=0;$<o-te;$++)[q,X]=[K+$+te+2,z+$+te+3],C.push(K,z,...Q?[X,K]:[q,z],X,q),[K,z]=[q,X];C.push(K,z,K+o+2)}}let P=m.clone(),_=m.clone(),I=m.clone(),O=m.clone(),L=m.clone(),j=[],V=A(T.length,()=>A(f,()=>m.clone()));for(let q=0;q<T.length;q++){m.copy(T[q]).normalize(),P.copy(m).multiplyScalar(x);let X=S[q];for(let oe=0;oe<X.length;oe++){let ie=X[oe],re=X[(oe+1)%f];g.setFromPointsAndIndices(T,q,ie%M,re%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(P,V[q][oe])}let K=[],z=[],Q=[],te=new E;o==0&&[...V[q]].reduce((oe,ie)=>oe.add(ie),te).multiplyScalar(1/f);for(let oe=0;oe<f;oe++){let ie=[],re=(oe-1+f)%f,J=V[q][re],Ee=V[q][oe];m.copy(J).sub(P),p.copy(Ee).sub(P);let xe=P.angleTo(m),de=m.angleTo(p),De=Math.cos(xe)*y;o==0?_.copy(te):_.copy(P).setLength(x+De),z.push(De);let Pe=[_,J,Ee];for(let ze=0;ze<2;ze++){let ke=Pe[ze],Ue=Pe[ze+1];O.subVectors(ke,P),L.subVectors(Ue,P),I.crossVectors(O,L).normalize();for(let Le=0;Le<v;Le++){let Qe=[xe,de][ze]*Le/v;m.copy(O).applyAxisAngle(I,Qe).add(P),K.push(m.clone()),ze&&(w(m,P),ie.push([Le==0?ke:m.clone(),b.clone()]))}ze&&(w(Ue,P),ie.push([Ue,b.clone()]))}Q.push(ie)}j.push(Q);let $=2*v,W=2;for(let oe=0;oe<f;oe++){let ie=$*oe,re=$*((oe+1)%f),J=[K[ie]];for(let xe=1;xe<v;xe++){O=K[ie+xe],L=K[re+xe],J.push(O);for(let de=1,De=xe-W+1;de<=De;de++)m.lerpVectors(O,L,de/(De+1)),m.sub(P).setLength(z[oe]).add(P),J.push(m.clone());J.push(L)}for(let xe=0;xe<v;xe++)J.push(K[xe+v+ie]);J.push(K[re+v]);let Ee=C.map(xe=>J[xe]);a.push(...Ee.map(xe=>[xe.x,xe.y,xe.z]).flat()),c.push(...Ee.map(xe=>(w(xe,P),[b.x,b.y,b.z])).flat())}}let H=[];for(let q=0;q<S.length;q++)for(let X=0;X<f;X++){let K=S[q][X];if(K<M){let z=S[K].findIndex($=>$%M==q),Q=j[q][X],te=j[K][z];for(let $=0;$<v;$++){let W=Q[$],oe=te[v-$],ie=Q[$+1],re=te[v-($+1)];[W,oe,ie,ie,oe,re].forEach(J=>{a.push(J[0].x,J[0].y,J[0].z),c.push(J[1].x,J[1].y,J[1].z)})}H.push(Q[0][0],te[v][0],Q[v][0],te[0][0])}}for(;H.length;){let q,X,K,z;[q,X]=H.splice(0,2);let Q=[q];for(;q!=X;)Q.push(X),K=H.indexOf(X),z=K%2,X=H.splice(K-z,2)[1-z];b.subVectors(Q[0],Q[1]).cross(m.subVectors(Q[0],Q[2])).normalize();let te=b.dot(Q[0])<0;te&&b.negate();for(let $=1;$<=Q.length-2;$++)[Q[$+ +te],Q[$+1-+te],Q[0]].forEach(W=>{a.push(W.x,W.y,W.z),c.push(b.x,b.y,b.z)})}}function h(){let d=new E;for(let T=0;T<a.length;T+=3){d.x=a[T+0],d.y=a[T+1],d.z=a[T+2];let S=w(d)/2/Math.PI+.5,M=A(d)/Math.PI+.5;l.push(S,1-M)}let f=new E,m=new E,p=new E,g=new E,y=new U,x=new U,v=new U,b=(T,S,M,C)=>{C<0&&T.x===1&&(l[S]=T.x-1),M.x===0&&M.z===0&&(l[S]=C/2/Math.PI+.5)};for(let T=0,S=0;T<a.length;T+=9,S+=6){f.set(a[T+0],a[T+1],a[T+2]),m.set(a[T+3],a[T+4],a[T+5]),p.set(a[T+6],a[T+7],a[T+8]),y.set(l[S+0],l[S+1]),x.set(l[S+2],l[S+3]),v.set(l[S+4],l[S+5]),g.copy(f).add(m).add(p).divideScalar(3);let M=w(g);b(y,S+0,f,M),b(x,S+2,m,M),b(v,S+4,p,M)}for(let T=0;T<l.length;T+=6){let S=l[T+0],M=l[T+2],C=l[T+4],P=Math.max(S,M,C),_=Math.min(S,M,C);P>.9&&_<.1&&(S<.2&&(l[T+0]+=1),M<.2&&(l[T+2]+=1),C<.2&&(l[T+4]+=1))}function w(T){return Math.atan2(T.z,-T.x)}function A(T){return Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))}}}static fromJSON(t){return new Jl(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var p3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new Vm(t*.5,s,o):new lh(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},Vm=class extends Jl{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-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,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,r),this.type=l}static fromJSON(t){return new Vm(t.radius,t.corner,t.cornerSides)}};var Um=1e-12,Gd=class{constructor(t){this.position=new U;this.startPosition=new U;this.uuid=Se.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Gd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},jd=class extends Gd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new jd(this.parent).copy(this)}},ro=class extends Gd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new jd(this),new jd(this))}static create(e,r){let i=new ro(e,new U(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.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 ro(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new U,r=new U){let[i,s]=this.computeTangents();return i&&s&&(m3(i,e),m3(s,r)),[e,r]}computeTangent(e=new U){let[r,i]=this.computeTangents();return r&&i&&e.copy(r).add(i).normalize(),e}computeNormal(e=new U){let[r,i]=this.computeNormals();return e.copy(r).add(i).normalize(),e}};function m3(n,t=new U){let e=n.length();return t.set(-n.y/e,n.x/e)}var BE=n=>n,Hd=new U,wx=new U,_K=new U,IK=new U,DK=new U,OK=new U,y3=new E,v3=new E;function x3(n){let t=new U;t.addVectors(n.v0,Hd.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new U;return e.addVectors(n.v2,wx.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new hn(n.v0,t,e,n.v2)}function km(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function RK(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function LK(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function FE(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((i*i+r*r-s*s)/(2*i*r))}function b3(n,t,e){return g3(n,t)&&g3(t,e)&&NE(n.position,t.position,e.position)}function NE(n,t,e){return Hd.copy(t).sub(n).cross(wx.copy(e).sub(n))===0}function S3(n,t,e,r,i){let s=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=(n.y+t.y)/2,a=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(n.y-t.y)/s,c=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-n.x)/s;return r.set(a+l,o+c),i.set(a-l,o-c),[r,i]}function w3(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function A3(n,t,e,r,i,s){let o=t.x-n.x,a=t.y-n.y,l=e.x-n.x,c=e.y-n.y,u=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c)),h;return FE(t,n,e)>Math.PI&&(u*=-1),km(c,a)?h=(a+c)*(r/u-.5)*8/3/(o-l):h=(o+l)*(r/u-.5)*8/3/(c-a),i.set(t.x-h*a,t.y+h*o),s.set(e.x+h*c,e.y-h*l),[i,s]}function VE(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function g3(n,t){return NE(n.position,n.controls[1].position,t.position)&&NE(n.position,t.controls[0].position,t.position)}function E3(n,t,e,r,i=.5){let s=Hd.subVectors(t,n).multiplyScalar(i).add(n),o=wx.subVectors(e,t).multiplyScalar(i).add(t),a=_K.subVectors(r,e).multiplyScalar(i).add(e),l=s,c=IK.subVectors(o,s).multiplyScalar(i).add(s),u=DK.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=OK.subVectors(u,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,h.x,h.y,r.x,r.y]}function T3(n,t,e=12,r=!0){let i=v3.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let c=BE(t[l]),u=Hd,h=$l(c,e);a.push(h);for(let d=0;d<=h;d++)if(c instanceof hn||c instanceof es||c instanceof dn){if(c.getPoint(d/h,u),i.set(u.x,u.y,0),s!==void 0&&LK(s,i))continue;s===void 0&&(s=y3),s.copy(i),n.setXYZ(o,i.x,i.y,i.z),o++}}return r&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),n}function M3(n,t,e,r=12,i=!0){let s=v3.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=BE(t[l]),h=Hd,d=$l(u,r);a.push(d);for(let f=0;f<=d;f++)if(u instanceof hn||u instanceof es||u instanceof dn){if(u.getPoint(f/d,h),s.set(h.x,h.y,0),c?.equals(s))continue;c===void 0?c=y3:(n.setXYZ(o,c.x,c.y,c.z),o++,n.setXYZ(o,s.x,s.y,s.z),o++),c.copy(s)}}return i&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),a}function UE(n,t=12,e=!1){let r=[];for(let i=0,s=n.length;i<s;i++){let o=n[i],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=$l(o.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=$l(o.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=$l(n[0].roundedCurveCorner,t)*.5),r}function $l(n,t=12){return n&&n instanceof kc?t*2:n&&(n instanceof dn||n instanceof jp)?1:n&&n instanceof sh?t*n.points.length:t}function C3(n,t,e=12,r=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=BE(t[o]),l=$l(a,e),c=Hd;for(let u=0;u<=l;u++)if(a instanceof hn||a instanceof es||a instanceof dn){if(a.getPoint(u/l,c),i!==void 0&&RK(i,c,Um))continue;i===void 0&&(i=wx),i.copy(c),n.push(c.x,c.y),s++}}return km(n[0],n[n.length-2],Um)&&km(n[1],n[n.length-1],Um)&&(n.pop(),n.pop()),r&&s>1&&!(km(n[s-1],n[1],Um)&&km(n[s-2],n[0],Um))&&(n.push(n[0],n[1]),s++),n}var kE=new U,NK=new U,BK=new U,FK=new U,VK=new U,UK=new U,$t=class extends Ca{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new qr(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=Se.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,i){let s=new $t;return s.isClosed=e.isClosed,s.points=e.points.map(o=>ro.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>$t.createFromState(o)),r!==void 0&&i!==void 0&&s.applySize(r,i),s.update(),s}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 r=0,i=this.points.length;r<i;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,i=this.points.findIndex(s=>s.uuid===e);if(i<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],c=l.points.length,u=l.getPointIndexById(e);if(u<0)s+=c;else return u+s}}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 r=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=e-r;if(a<=o.points.length-1)return o.points[a];r+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(e);if(a>=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let i=kE.set(e,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,r);this._update()}createPoint(e,r=0,i=Se.generateUUID()){let s;e instanceof U?s=e:s=new U(e,r);let o=new ro(i,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,i=this.points.length;r<i;r++){let s=this.points[r];if(s.uuid===e)return s}for(let r=0,i=this.shapeHoles.length;r<i;r++){let o=this.shapeHoles[r].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(i=>i.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=i?this.roundedCurveDivisions:this.curveDivisions;return T3(e,i?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=UE(this.points,e,!1),this.roundedCurveDivisions=UE(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return M3(e,this.curves,r,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),C3(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=$l(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l<c;l++){let u=s[l];if(a<i+u)return[l,(a-i+1)/u];i+=u}return[0,1]}getCurveT(e,r,i){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(VE(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(kE.set(i.x,i.y))/h}let c=0;for(let h=0;h<e;h++)c+=a[h];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){VE(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.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,r.curveAfter=i;let s=i.clone();e.roundedCurveBefore=s,r.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,i=this.points.length;r<i;r++){let s=this.points[r];if(r===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[r-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(r,i)}if(this.points.length>2){let r=0;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],c=o.roundness,u=a&&l&&b3(a,o,l);if(!o.controlsMoved()&&c>0&&!u){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,m=o.roundedCurveAfter,p=h.getLength(),g=d.getLength(),y=Math.min(c,p*.499),x=Math.min(c,g*.499),v=Math.min(y,x),b=1-v/p,w=v/g,A=h.getPointAt(b,kE),T=d.getPointAt(w,NK);this._subSplitCurve(h,f,b,A,void 0),this._subSplitCurve(d,m,w,void 0,T);let S;if(this.useCubicForRoundedCorners){let M=FE(A,o.position,T)/2,C=Math.tan(M)*A.distanceTo(o.position),[P,_]=S3(A,T,C,BK,FK),I=w3(P,_,o.position),[O,L]=A3(I,A,T,C,VK,UK);S=new hn(A.clone(),O.clone(),L.clone(),T.clone())}else S=new es(A.clone(),o.position.clone(),T.clone());o.roundedCurveCorner=S,this.roundedCurves.splice(i+r,0,S),r++}}}}_subSplitCurve(e,r,i,s,o){if(e instanceof dn)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,c=a.getUtoTmapping(i,0),u=E3(a.v0,a.v1,a.v2,a.v3,c);return s!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),o!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return r}clone(){let e=new $t(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let i=0;i<r;i++){let s=i*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],c=e.points[s+3],u=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new ro(Se.generateUUID(),new U(o,a));f.controls[0].position.set(l,c),f.controls[1].position.set(u,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let s=new $t;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let i=(o,a)=>{a instanceof hn&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,c;for(l=0,c=o.length;l<c;l++)o[l]instanceof es&&(o[l]=x3(o[l]));for(l=0,c=o.length;l<c;l++){let d=o[l],f=l>0?o[l-1]:null,m;d instanceof hn?(m=this.createPoint(d.v0),m.controls[1].position.copy(d.v1)):d instanceof dn&&(m=this.createPoint(d.v1)),m!==void 0&&(f!==null&&i(m,f),a.push(m))}let u=o[o.length-1],h=!1;return u instanceof hn?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),h=!0):u instanceof dn&&u.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof Ca&&(this.shapeHoles=e.holes.map(o=>{let a=new $t;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let i=this.getPointByUuid(e);i&&(r.position!==void 0&&i.position.fromArray(r.position),r.roundness!==void 0&&(i.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let s=this.getPointByUuid(e)?.controls[0];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let s=this.getPointByUuid(e)?.controls[1];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}};var GE=Math.PI*2;function zE({x:n,y:t},e,r,i,s){return{x:n*e+i,y:t*r+s}}function kK(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),i=Math.sin(n),s=Math.cos(n+t),o=Math.sin(n+t);return[{x:r-i*e,y:i+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function P3(n,t,e,r){let i=n*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,n*e+t*r));return i*Math.acos(s)}function zK(n,t,e,r,i,s,o,a,l,c){let u=Math.pow(i,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),m=u*h-u*f-h*d;m<0&&(m=0),m/=u*f+h*d,m=Math.sqrt(m)*(l===c?-1:1);let p=m*i/s*a,g=m*-s/i*o,y=p+(n+e)/2,x=g+(t+r)/2,v=(o-p)/i,b=(a-g)/s,w=(-o-p)/i,A=(-a-g)/s,T=P3(1,0,v,b),S=P3(v,b,w,A);return!c&&S>0&&(S-=GE),c&&S<0&&(S+=GE),{centerx:y,centery:x,ang1:T,ang2:S}}function _3({px:n,py:t,cx:e,cy:r,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let c=(n-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];i=Math.abs(i),s=Math.abs(s);let h=Math.pow(c,2)/Math.pow(i,2)+Math.pow(u,2)/Math.pow(s,2);h>1&&(i*=Math.sqrt(h),s*=Math.sqrt(h));let d=zK(n,t,e,r,i,s,c,u,o,a),{ang1:f,ang2:m}=d,{centerx:p,centery:g}=d,y=Math.abs(m)/(GE/4);Math.abs(1-y)<1e-7&&(y=1);let x=Math.max(Math.ceil(y),1);m/=x;for(let v=0;v<x;v++)l.push(kK(f,m)),f+=m;return l.map(v=>{let{x:b,y:w}=zE(v[0],i,s,p,g),{x:A,y:T}=zE(v[1],i,s,p,g),{x:S,y:M}=zE(v[2],i,s,p,g);return{x1:b,y1:w,x2:A,y2:T,x:S,y:M}})}var qt;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(qt||(qt={}));var Qr;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Qr||(Qr={}));function ft(n,t){if(!n)throw t||"Assertion Failed!"}var lt=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){ft(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,s=r.s-e.s;return i+s>0?i<s?e.t-t.t+(t.t-r.t)*(i/(i+s)):e.t-r.t+(r.t-t.t)*(s/(i+s)):0},n.edgeSign=function(t,e,r){ft(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,s=r.s-e.s;return i+s>0?(e.t-r.t)*i+(e.t-t.t)*s:0},n.transEval=function(t,e,r){ft(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,s=r.t-e.t;return i+s>0?i<s?e.s-t.s+(t.s-r.s)*(i/(i+s)):e.s-r.s+(r.s-t.s)*(s/(i+s)):0},n.transSign=function(t,e,r){ft(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,s=r.t-e.t;return i+s>0?(e.s-r.s)*i+(e.s-t.s)*s:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,i){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+i)/2:e+(i-e)*(t/(t+r)):i+(e-i)*(r/(t+r))},n.intersect=function(t,e,r,i,s){var o,a,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.vertLeq(r,e)?n.vertLeq(e,i)?(o=n.edgeEval(t,r,e),a=n.edgeEval(r,e,i),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,e.s)):(o=n.edgeSign(t,r,e),a=-n.edgeSign(t,i,e),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,i.s)):s.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.transLeq(r,e)?n.transLeq(e,i)?(o=n.transEval(t,r,e),a=n.transEval(r,e,i),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,e.t)):(o=n.transSign(t,r,e),a=-n.transSign(t,i,e),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,i.t)):s.t=(r.t+e.t)/2},n}(),zm=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Ax=function(){function n(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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Wd=function(){function n(){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 n}(),I3=function(){function n(){var t=new Wd,e=new zm,r=new Ax(0),i=new Ax(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(t){var e=new Ax(0),r=new Ax(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return r.next=i,i.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},n.prototype.splice_=function(t,e){var r=t.Onext,i=e.Onext;r.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var i=t;ft(i,"Vertex can't be null!");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=e;var o=e;do o.Org=i,o=o.Onext;while(o!==e)},n.prototype.makeFace_=function(t,e,r){var i=t;ft(i,"Face can't be null");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=r.inside;var o=e;do o.Lface=i,o=o.Lnext;while(o!==e)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,i=r;do i.Org=e,i=i.Onext;while(i!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},n.prototype.killFace_=function(t,e){var r=t.anEdge,i=r;do i.Lface=e,i=i.Lnext;while(i!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},n.prototype.makeEdge=function(){var t=new Wd,e=new Wd,r=new zm,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(t,e){var r=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var s=new Wd;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new zm;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=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 i=new zm;this.makeFace_(i,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Wd;return this.makeVertex_(i,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.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},n.prototype.connect=function(t,e){var r=!1,i=this.makeEdge_(t),s=i.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(s,e),i.Org=t.Dst,s.Org=e.Org,i.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var o=new zm;this.makeFace_(o,i,t.Lface)}return i},n.prototype.zapFace=function(t){var e=t.anEdge,r,i,s,o,a;i=e.Lnext;do r=i,i=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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,i,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,o=r.Org;i=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&<.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&<.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=i;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,i,s,o,a,l,c;for(s=t,s=t;(i=s.next)!==t;s=i){ft(i.prev===s),l=i.anEdge;do ft(l.Sym!==l),ft(l.Sym.Sym===l),ft(l.Lnext.Onext.Sym===l),ft(l.Onext.Sym.Lnext===l),ft(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(ft(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){ft(o.prev===a),l=o.anEdge;do ft(l.Sym!==l),ft(l.Sym.Sym===l),ft(l.Lnext.Onext.Sym===l),ft(l.Onext.Sym.Lnext===l),ft(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(ft(o.prev===a&&o.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ft(l.Sym.next===c.Sym),ft(l.Sym!==l),ft(l.Sym.Sym===l),ft(l.Org!==null),ft(l.Dst!==null),ft(l.Lnext.Onext.Sym===l),ft(l.Onext.Sym.Lnext===l);ft(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),D3=function(){function n(){this.handle=null}return n}(),O3=function(){function n(){this.key=null,this.node=0}return n}(),GK=function(){function n(t,e){this.leq=e,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 D3,this.handles[r]=new O3;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(r[e[o+1].handle].key,r[e[o].handle].key)&&++o,ft(o<=this.max),s=e[o].handle,o>this.size||this.leq(r[i].key,r[s].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=s,r[s].node=t,t=o}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[i].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=s,r[s].node=t,t=o}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new D3;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new O3}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,i=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),i},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,i;ft(t>=1&&t<=this.max&&r[t].key!==null),i=r[t].node,e[i].handle=e[this.size].handle,r[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[e[i>>1].handle].key,r[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),jE=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),R3=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),jK=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new R3,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new R3;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),HK=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var i=t.event,s=e.eUp,o=r.eUp;if(s.Dst===i)return o.Dst===i?lt.vertLeq(s.Org,o.Org)?lt.edgeSign(o.Dst,s.Org,o.Org)<=0:lt.edgeSign(s.Dst,o.Org,s.Org)>=0:lt.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return lt.edgeSign(s.Dst,i,s.Org)>=0;var a=lt.edgeEval(s.Dst,i,s.Org),l=lt.edgeEval(o.Dst,i,o.Org);return a>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ft(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ft(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,i;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(i=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;n.fixUpperEdge(t,e,i),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var i=new jE;return i.eUp=r,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(t,e){switch(t.windingRule){case qt.ODD:return(e&1)!==0;case qt.NONZERO:return e!==0;case qt.POSITIVE:return e>0;case qt.NEGATIVE:return e<0;case qt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,i=r.Lface;i.inside=e.inside,i.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var i,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=n.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){n.finishRegion(t,o);break}i=t.mesh.connect(a.Lprev,i.Sym),n.fixUpperEdge(t,s,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),n.finishRegion(t,o),a=s.eUp,o=s}return a},n.addRightEdges=function(t,e,r,i,s,o){var a,l,c,u,h=!0;c=r;do ft(lt.vertLeq(c.Org,c.Dst)),n.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==i);for(s===null&&(s=n.regionBelow(e).eUp.Rprev),l=e,u=s;a=n.regionBelow(l),c=a.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=n.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&n.checkForRightSplice(t,l)&&(n.addWinding(c,u),n.deleteRegion(t,l),t.mesh.delete(u)),h=!1,l=a,u=c;l.dirty=!0,ft(l.windingNumber-c.winding===a.windingNumber),o&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var i=lt.vertL1dist(e,t),s=lt.vertL1dist(r,t),o=.5*s/(i+s),a=.5*i/(i+s);t.coords[0]+=o*e.coords[0]+a*r.coords[0],t.coords[1]+=o*e.coords[1]+a*r.coords[1],t.coords[2]+=o*e.coords[2]+a*r.coords[2]},n.getIntersectData=function(t,e,r,i,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,i),n.vertexWeights(e,s,o)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp;if(lt.vertLeq(i.Org,s.Org)){if(lt.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;lt.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(t.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(t,s.Oprev,i)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(i,s.Oprev),e.dirty=r.dirty=!0)}else{if(lt.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Oprev,i)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp,o;if(ft(!lt.vertEq(i.Dst,s.Dst)),lt.vertLeq(i.Dst,s.Dst)){if(lt.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(i),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(lt.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp,o=i.Org,a=s.Org,l=i.Dst,c=s.Dst,u,h,d=new Wd,f,m;if(ft(!lt.vertEq(c,l)),ft(lt.edgeSign(l,t.event,o)<=0),ft(lt.edgeSign(c,t.event,a)>=0),ft(o!==t.event&&a!==t.event),ft(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(u=Math.min(o.t,l.t),h=Math.max(a.t,c.t),u>h))return!1;if(lt.vertLeq(o,a)){if(lt.edgeSign(c,o,a)>0)return!1}else if(lt.edgeSign(l,a,o)<0)return!1;return n.debugEvent(t),lt.intersect(l,o,c,a,d),ft(Math.min(o.t,l.t)<=d.t),ft(d.t<=Math.max(a.t,c.t)),ft(Math.min(c.s,l.s)<=d.s),ft(d.s<=Math.max(a.s,o.s)),lt.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=lt.vertLeq(o,a)?o:a,lt.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),lt.vertEq(d,o)||lt.vertEq(d,a)?(n.checkForRightSplice(t,e),!1):!lt.vertEq(l,t.event)&<.edgeSign(l,t.event,d)>=0||!lt.vertEq(c,t.event)&<.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Sym,i),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(i.Lnext,s.Oprev),r=e,e=n.topRightRegion(e),m=n.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,s.Onext,i.Rprev,m,!0),!0):(lt.edgeSign(l,t.event,d)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),lt.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=t.pq.insert(i.Org),n.getIntersectData(t,i.Org,o,l,a,c),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),i,s;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,s=r.eUp,i.Dst!==s.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(s),r=n.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r),i=e.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===t.event||s.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);i.Org===s.Org&&i.Dst===s.Dst&&(n.addWinding(s,i),n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var i,s=r.Onext,o=n.regionBelow(e),a=e.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&n.checkForIntersect(t,e),lt.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=n.topLeftRegion(t,e),s=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),o),c=!0),lt.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,o,null),c=!0),c){n.addRightEdges(t,e,r.Onext,s,s,!0);return}lt.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(r.Lprev,i),n.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var i,s,o,a,l;if(i=e.eUp,lt.vertEq(i.Org,r)){ft(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!lt.vertEq(i.Dst,r)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,i),n.sweepEvent(t,r);return}ft(!1),e=n.topRightRegion(e),l=n.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(ft(s!==o),n.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),lt.edgeGoesLeft(s)||(s=null),n.addRightEdges(t,e,o.Onext,a,s,!0)},n.connectLeftVertex=function(t,e){var r,i,s,o,a,l,c=new jE;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(o=r.eUp,a=i.eUp,lt.edgeSign(o.Dst,e,o.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(s=lt.vertLeq(a.Dst,o.Dst)?r:i,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var u=t.mesh.connect(a.Dnext,e.anEdge);l=u.Sym}s.fixUpperEdge?n.fixUpperEdge(t,s,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var i=n.topLeftRegion(t,r.activeRegion);ft(i!==null);var s=n.regionBelow(i),o=s.eUp,a=n.finishLeftRegions(t,s,null);a.Onext===o?n.connectRightVertex(t,i,a):n.addRightEdges(t,i,a.Onext,o,o,!0)},n.addSentinel=function(t,e,r,i){var s=new jE,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=i,o.Dst.s=e,o.Dst.t=i,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},n.initEdgeDict=function(t){t.dict=new jK(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;n.addSentinel(t,i,s,o),n.addSentinel(t,i,s,a)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(ft(e.fixUpperEdge),ft(++r===1)),ft(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,i,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,i=e.Lnext,lt.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,i,s=0;for(i=t.mesh.vHead,r=i.next;r!==i;r=r.next)s++;for(s+=8,e=t.pq=new GK(s,lt.vertLeq),i=t.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=e.insert(r);return r!==i?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,i,s;for(r=e.fHead.next;r!==e.fHead;r=i)i=r.next,s=r.anEdge,ft(s.Lnext!==s),s.Lnext.Lnext===s&&(n.addWinding(s.Onext,s),t.mesh.delete(s));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,i;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!lt.vertEq(i,r));)i=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,i.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),WK=function(){function n(){this.mesh=new I3,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=qt.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 n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,i,s,o,a,l=[0,0,0],c=[0,0,0],u=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;e=p.next;for(var g=0;g<3;++g)s=e.coords[g],c[g]=s,m[g]=e,l[g]=s,f[g]=e;for(e=p.next;e!==p;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<c[y]&&(c[y]=s,m[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var x=0;if(l[1]-c[1]>l[0]-c[0]&&(x=1),l[2]-c[2]>l[x]-c[x]&&(x=2),c[x]>=l[x]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=m[x],i=f[x],u[0]=r.coords[0]-i.coords[0],u[1]=r.coords[1]-i.coords[1],u[2]=r.coords[2]-i.coords[2],e=p.next;e!==p;e=e.next)h[0]=e.coords[0]-i.coords[0],h[1]=e.coords[1]-i.coords[1],h[2]=e.coords[2]-i.coords[2],d[0]=u[1]*h[2]-u[2]*h[1],d[1]=u[2]*h[0]-u[0]*h[2],d[2]=u[0]*h[1]-u[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,i,s=0,o=t.next;o!==t;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,i,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),r=this.sUnit,i=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,i;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;lt.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;lt.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var s=void 0;r.Lnext!==i;)if(lt.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(lt.edgeGoesLeft(i.Lnext)||lt.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=t.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(lt.edgeGoesRight(r.Lprev)||lt.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)s=t.connect(i.Lnext,i),i=s.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var i,s=t.eHead.next;s!==t.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,i){var s,o=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=o,++o}this.elementCount=o,e===Qr.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var h=c.n*i;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],i>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;this.elements[d++]=c.n,l++,s=s.Lnext}while(s!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===Qr.CONNECTED_POLYGONS){s=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==u.anEdge);for(var m=l;m<r;++m)this.elements[d++]=-1}}},n.prototype.outputContours_=function(t,e){var r,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){i=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,u=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,i=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==i);this.elements[u++]=s,this.elements[u++]=o,s+=o}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new I3),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i<e.length;i+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[i+0],r.Org.coords[1]=e[i+1],t>2?r.Org.coords[2]=e[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,i,s,o){if(t===void 0&&(t=qt.ODD),e===void 0&&(e=Qr.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),HK.computeInterior(this,o);var a=this.mesh;return e===Qr.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===Qr.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,r,i),!0},n}();function io(n){var t=n.windingRule,e=t===void 0?qt.ODD:t,r=n.elementType,i=r===void 0?Qr.POLYGONS:r,s=n.polySize,o=s===void 0?3:s,a=n.vertexSize,l=a===void 0?2:a,c=n.normal,u=c===void 0?[0,0,1]:c,h=n.contours,d=h===void 0?[]:h,f=n.strict,m=f===void 0?!0:f,p=n.debug,g=p===void 0?!1:p;if(!d&&m)throw new Error("Contours can't be empty");if(!!d){var y=new WK;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var x=0;x<d.length;x++)y.addContour(l||2,d[x]);return y.tesselate(e,i,o,l,u,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var sbe=qt.ODD,obe=qt.NONZERO,abe=qt.POSITIVE,lbe=qt.NEGATIVE,cbe=qt.ABS_GEQ_TWO,ube=Qr.POLYGONS,hbe=Qr.CONNECTED_POLYGONS,dbe=Qr.BOUNDARY_CONTOURS;var Ex=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Ex.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*i,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Ex.eSize,i=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*t);o+=3*t;let l=new Float32Array(i,o*s,3*t);o+=3*t;let c=new Float32Array(i,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Gm=Ex;Gm.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var jm=class{constructor(t=[],e=(r,i)=>r<i?-1:r>i?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,i=e[t];for(;t>0;){let s=t-1>>1,o=e[s];if(r(i,o)>=0)break;e[t]=o,t=s}e[t]=i}_down(t){let{data:e,compare:r}=this,i=this.length>>1,s=e[t];for(;t<i;){let o=(t<<1)+1,a=o+1;if(a<this.length&&r(e[a],e[o])<0&&(o=a),r(e[o],s)>=0)break;e[t]=e[o],t=o}e[t]=s}};function HE(n,t,e=1,r=!1){let i=1/0,s=1/0,o=-1/0,a=-1/0;for(let[x,v]of n[0])x<i&&(i=x),v<s&&(s=v),x>o&&(o=x),v>a&&(a=v);let l=o-i,c=a-s,u=Math.max(e,Math.min(l,c));if(u===e){let x=[i,s];return x.distance=0,x.distance}let h=new jm([],(x,v)=>v.max-x.max),d=XK(n),f=new Tx(i+l/2,s+c/2,0,n);f.d>d.d&&(d=f);let m=2;function p(x,v,b){let w=new Tx(x,v,b,n);if(m++,w.max>d.d+e&&h.push(w),w.d>d.d&&(d=w,r&&console.log(`found best ${Math.round(1e4*w.d)/1e4} after ${m} probes`),d.d>t))return t}let g=u/2;for(let x=i;x<o;x+=u)for(let v=s;v<a;v+=u)p(x+g,v+g,g);for(;h.length;){let{max:x,x:v,y:b,h:w}=h.pop();if(x-d.d<=e)break;g=w/2,p(v-g,b-g,g),p(v+g,b-g,g),p(v-g,b+g,g),p(v+g,b+g,g)}r&&console.log(`num probes: ${m}
|
|
3140
3140
|
best distance: ${d.d}`);let y=[d.x,d.y];return y.distance=d.d,y.distance}function Tx(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=qK(n,t,r),this.max=this.d+this.h*Math.SQRT2}function qK(n,t,e){let r=!1,i=1/0;for(let s of e)for(let o=0,a=s.length,l=a-1;o<a;l=o++){let c=s[o],u=s[l];c[1]>t!=u[1]>t&&n<(u[0]-c[0])*(t-c[1])/(u[1]-c[1])+c[0]&&(r=!r),i=Math.min(i,YK(n,t,c,u))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function XK(n){let t=0,e=0,r=0,i=n[0];for(let o=0,a=i.length,l=a-1;o<a;l=o++){let c=i[o],u=i[l],h=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*h,r+=(c[1]+u[1])*h,t+=h*3}let s=new Tx(e/t,r/t,0,n);return t===0||s.d<0?new Tx(i[0][0],i[0][1],0,n):s}function YK(n,t,e,r){let i=e[0],s=e[1],o=r[0]-i,a=r[1]-s;if(o!==0||a!==0){let l=((n-i)*o+(t-s)*a)/(o*o+a*a);l>1?(i=r[0],s=r[1]):l>0&&(i+=o*l,s+=a*l)}return o=n-i,a=t-s,o*o+a*a}var Hm={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},qE={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},XE={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},WE=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),ec=class extends Ce{constructor(e,r,i=0,s=12,o=3,a=qt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=s,this._bevelSegmentsInput=o;let c=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(P=>{let _=P.extractShapePointsToFlatArray([],s),I=[];for(let O=_.length-1;O>=1;O-=2){let L=_[O-1],j=_[O-0];I.push(L,j)}return I}),h=[],d=[];for(let P=0;P<c.length;P+=2)d.push([c[P],c[P+1]]);h.push(d);for(let P=0;P<u.length;P++){let _=u[P],I=[];for(let O=0;O<_.length;O+=2)I.push([_[O],_[O+1]]);h.push(I)}let f;e.isText?f=new Pl().setFromPoints(e.points.map(_=>_.position)).getSize(new U).length()*.1:h[0].length===0?f=i:i>0?f=HE(h,i):f=1e-5,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,f,r/2),this._bevelSegments=Math.floor(o));let m;try{m=io({windingRule:a,elementType:Qr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{m=Hm}let p;try{p=io({windingRule:qt.ODD,elementType:Qr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{p=qE}if(!m)throw new Error("error generating geometry");let g=m.elementCount;if(p){m.elementCount+=p.elementCount;for(let P=0;P<p.elements.length;P++){let _=p.elements[P],I=P%2===0?m.vertexCount:0;m.elements.push(_+I)}for(let P=0;P<p.vertexIndices.length;P++){let _=p.vertexIndices[P],I=m.vertexCount;m.vertexIndices.push(_+I)}for(let P=0;P<p.vertices.length;P++){let _=p.vertices[P];m.vertices.push(_)}}let y=1/0,x=-1/0,v=1/0,b=-1/0;for(let P=0,_=m.vertexCount;P<_;P++){let I=P*2,O=m.vertices[I+0],L=m.vertices[I+1];O<y&&(y=O),O>x&&(x=O),L<v&&(v=L),L>b&&(b=L)}this._minX=y,this._minY=v,this._width=x-y,this._height=b-v,this._buffer=new Gm(this._computeBufferEstimatedSize(m));let w=[],A=[];for(let P=m.elementCount-1;P>=0;P--){let _=P>=g,I=P*2,O=m.elements[I+0],L=m.elements[I+1],j=O+L,V={start:O,count:L,normals:[],continuous:[],concave:[]},H=O,q=j-1,X=O+1,K=this._shape.roundedCurves.length;do{let W=H-O,oe=m.vertices[q*2+0],ie=m.vertices[q*2+1],re=m.vertices[H*2+0],J=m.vertices[H*2+1],Ee=m.vertices[X*2+0],xe=m.vertices[X*2+1],de=re-oe,De=J-ie,Pe=Math.sqrt(de*de+De*De);de/=Pe,De/=Pe;let ze=re-Ee,ke=J-xe,Ue=Math.sqrt(ze*ze+ke*ke);ze/=Ue,ke/=Ue,V.normals[W*2+0]=-ke,V.normals[W*2+1]=ze,V.concave[W]=de*ke-De*ze>0;let Le=m.vertexIndices[H];if(Array.isArray(Le))V.continuous[W]=!1;else{let[Qe,F]=this._shape.getCurveIndexFromVertexId(Le-1,!0);if(F>0&&F<1)V.continuous[W]=!0;else{let B=F===1?Qe+1:Qe-1;B=(B+K)%K;let N=F===1?0:1,ae=this._shape.roundedCurves[Qe].getTangent(F),ye=this._shape.roundedCurves[B].getTangent(N);V.continuous[W]=ae.dot(ye)>.95}}_&&(V.normals[W*2+0]*=-1,V.normals[W*2+1]*=-1),[q,H,X]=[H,X,X+1],X>=j&&(X-=L)}while(X!==O+1);let z=[];z.push({bevelI:0,angle:0,size:0,boundary:{vertices:m.vertices.slice(O*2,j*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((W,oe)=>[oe,oe]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:m.vertices.slice(O*2,j*2)});let Q=0;for(let W=1;W<=this._bevelSegments;W++){let oe=W/this._bevelSegments*Math.PI/2,ie=(1-Math.cos(oe))*this._bevel,re=[],J=[],Ee=[],xe=[],de=0;for(let Pe=0;Pe<L;Pe++){let ze=Pe*2,ke=(Pe-1+L)%L*2,Ue=m.vertices[V.start*2+ze+0],Le=m.vertices[V.start*2+ze+1],Qe=-V.normals[ke+0]*ie,F=-V.normals[ke+1]*ie,B=-V.normals[ze+0]*ie,N=-V.normals[ze+1]*ie;if(V.concave[Pe]||!V.concave[Pe]&&_){let ae=Math.atan2(F,Qe),ye=Math.atan2(N,B);ye>ae&&(ye-=Math.PI*2);let me=ye-ae;if(V.continuous[Pe]||_){let Ne=ae+me/2,Fe=Math.cos(Ne)*ie,Oe=Math.sin(Ne)*ie;re[2*de+0]=Ue+Fe*(_?-1:1),re[2*de+1]=Le+Oe*(_?-1:1),xe[de]=Pe,de++}else{let Ne=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Fe=0;Fe<=Ne;Fe++){let Oe=ae+me*(Fe/Ne),pe=Math.cos(Oe)*ie,nt=Math.sin(Oe)*ie;re[2*de+0]=Ue+pe,re[2*de+1]=Le+nt,xe[de]=Pe,de++}}}else re[2*de+0]=Ue+Qe,re[2*de+1]=Le+F,xe[de]=Pe,J[Pe]=de,de++,re[2*de+0]=Ue,re[2*de+1]=Le,xe[de]=Pe,de++,re[2*de+0]=Ue+B,re[2*de+1]=Le+N,xe[de]=Pe,Ee[Pe]=de,de++}let De=io({windingRule:qt.POSITIVE,elementType:Qr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[re],edgeCreateCallback:Pe=>{let ke=Pe.Org.idx,Ue=xe[ke],Le=xe[(ke+1)%xe.length];Pe.idx=[Ue,Le],Pe.Sym.idx=[Le,Ue]},vertexIdCallback:Pe=>{let ze=Pe.Lprev.idx;return[ze?ze[1]:0,Pe.idx?Pe.idx[0]:0]}});if(!De)throw console.log("Error"),new Error(`error generating bevel geometry for ${W}'th loop`);if(!De.vertexCount){let Pe=(W-1)/this._bevelSegments*Math.PI/2;Q=(1-Math.sin(Pe))*this._bevel;break}for(let Pe=0;Pe<De.vertexIndices.length;Pe++){let[ze,ke]=De.vertexIndices[Pe];if(ze===ke)continue;let Ue=ke;ke<ze&&(Ue+=L);for(let Le=ze;Le<Ue;Le++){let Qe=Le%L,F=(Le+1)%L;if(!V.continuous[Qe]||!V.continuous[F]){De.vertexIndices[Pe]=[ze,Qe],De.vertexIndices.splice(Pe+1,0,[F,ke]),De.vertices.splice((Pe+1)*2,0,De.vertices[Pe*2],De.vertices[Pe*2+1]);break}}}z.push({bevelI:W,angle:oe,size:ie,boundary:De,reverseMap:xe,insetPoints:re})}let te=(W,oe,ie)=>{let re=0,J=W.boundary.vertexIndices.length;for(;re<J&&ie(W.boundary.vertexIndices[oe]);)oe=(oe+1)%J,re++;return re},$=w.length;for(let W=1;W<z.length;W++){let oe=z[W-1],ie=z[W],re=oe.boundary.vertexIndices.length,J=ie.boundary.vertexIndices.length;if(!re||!J)break;let Ee=V.concave.length,xe=0,de=WE(xe,L);for(;!oe.boundary.vertexIndices.filter(de).length||!ie.boundary.vertexIndices.filter(de).length;)xe++,de=WE(xe,L);let De=oe.boundary.vertexIndices.findIndex(de),Pe=ie.boundary.vertexIndices.findIndex(de);do De=(De+1)%re;while(de(oe.boundary.vertexIndices[De]));do Pe=(Pe+1)%J;while(de(ie.boundary.vertexIndices[Pe]));xe=(xe+1)%L;let ze=xe,ke=0,Ue=this._buildBevelVert(V,oe,(De-1+re)%re,void 0,ke),Le=this._buildBevelVert(V,ie,(Pe-1+J)%J,void 0,ke),Qe=Ue,F=Le,B,N,ae=!1;do{ke=(xe||Ee)/Ee,de=WE(xe,L);let ye=te(oe,De,de),me=te(ie,Pe,de),Ne=ae;if(ae=!1,ye&&!me){for(let Fe=0;Fe<ye;Fe++)B=this._buildBevelVert(V,oe,(De+Fe)%re,Fe/(ye-1),ke),w.push(Qe.topN,B.topP,F.topN),l===!1&&w.push(B.bottomP,Qe.bottomN,F.bottomN),Qe=B;ae=!0}else if(!ye&&me)for(let Fe=0;Fe<me;Fe++)N=this._buildBevelVert(V,ie,(Pe+Fe)%J,Fe/(me-1),ke),w.push(F.topN,Qe.topP,N.topP),l===!1&&w.push(Qe.bottomP,F.bottomN,N.bottomP),F=N;else if(ye&&me)if(B=this._buildBevelVert(V,oe,De,0,ke),N=this._buildBevelVert(V,ie,Pe,0,ke),Ne?(w.push(Qe.topN,N.topP,F.topN),w.push(Qe.topN,B.topP,N.topP),l===!1&&(w.push(N.bottomP,Qe.bottomN,F.bottomN),w.push(N.bottomP,B.bottomP,Qe.bottomN))):(w.push(F.topN,Qe.topN,B.topP),w.push(F.topN,B.topP,N.topP),l===!1&&(w.push(B.bottomP,Qe.bottomN,F.bottomN),w.push(B.bottomP,F.bottomN,N.bottomP))),Qe=B,F=N,ye===me)for(let Fe=1;Fe<ye;Fe++)B=this._buildBevelVert(V,oe,(De+Fe)%re,Fe/(ye-1),ke),N=this._buildBevelVert(V,ie,(Pe+Fe)%J,Fe/(me-1),ke),w.push(Qe.topN,B.topP,F.topN),w.push(F.topN,B.topP,N.topP),l===!1&&(w.push(B.bottomP,Qe.bottomN,F.bottomN),w.push(B.bottomP,F.bottomN,N.bottomP)),Qe=B,F=N;else if(ye>me){let Fe=ye/me,Oe=0;for(let pe=1;pe<ye;pe++)B=this._buildBevelVert(V,oe,(De+pe)%re,pe/(ye-1),ke),w.push(Qe.topN,B.topP,F.topN),l===!1&&w.push(B.bottomP,Qe.bottomN,F.bottomN),Qe=B,pe>(Oe+1)*Fe&&(Oe++,N=this._buildBevelVert(V,ie,(Pe+Oe)%J,Oe/(me-1),ke),w.push(F.topN,B.topP,N.topP),l===!1&&w.push(B.bottomP,F.bottomN,N.bottomP),F=N)}else{let Fe=me/ye,Oe=0;for(let pe=1;pe<me;pe++)N=this._buildBevelVert(V,ie,(Pe+pe)%J,pe/(me-1),ke),w.push(F.topN,B.topP,N.topP),l===!1&&w.push(B.bottomP,F.bottomN,N.bottomP),F=N,pe>(Oe+1)*Fe&&(Oe++,B=this._buildBevelVert(V,oe,(De+Oe)%re,Oe/(ye-1),ke),w.push(Qe.topN,B.topP,F.topN),l===!1&&w.push(B.bottomP,Qe.bottomN,F.bottomN),Qe=B)}De=(De+ye)%re,Pe=(Pe+me)%J,xe=(xe+1)%Ee}while(xe!==ze)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(z,V,w),_){let W=[];for(let oe=w.length-1;oe>=$+2;oe-=3){let ie=w[oe-2],re=w[oe-1],J=w[oe-0];W.push(J,re,ie)}w.splice($,w.length-$,...W)}if(_){let W=[];for(let oe=z[z.length-1].boundary.vertices.length-1;oe>=1;oe-=2){let ie=z[z.length-1].boundary.vertices[oe-1],re=z[z.length-1].boundary.vertices[oe-0];W.push(ie,re)}A.push(W)}if(!_){let W=z[z.length-1],oe;try{oe=io({windingRule:z.length>1?qt.POSITIVE:qt.ODD,elementType:Qr.POLYGONS,vertexSize:2,strict:!0,contours:[W.insetPoints,...A]})}catch{oe=XE}if(!oe)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ie=0;ie<oe.elementCount*3;ie+=3){let re=this._buildSurfaceVert(oe,oe.elements[ie+0],Q),J=this._buildSurfaceVert(oe,oe.elements[ie+1],Q),Ee=this._buildSurfaceVert(oe,oe.elements[ie+2],Q);w.push(re.top,J.top,Ee.top),l===!1&&w.push(Ee.bottom,J.bottom,re.bottom)}}this.vertexCache={}}this._buffer.shrink();let T=new je(Uint32Array.from(w),1),S=new je(this._buffer.positions,3),M=new je(this._buffer.normals,3),C=new je(this._buffer.uvs,2);S.needsUpdate=!0,M.needsUpdate=!0,C.needsUpdate=!0,T.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",M),this.setAttribute("uv",C),this.setIndex(T)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),c=this._buildBevelVert(r,s,(o+1)%a);i.push(c.topP,l.topN,l.bottomN),i.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,r,i){let s=r.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[r*2+0],a=e.vertices[r*2+1],l=(o-this._minX)/this._width,c=(a-this._minY)/this._height;this.forPathBevel&&(c=1);let u=this._buffer.get(this.forPathBevel?1:2),h=u*3,d=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[h+0]=o,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[d+0]=l,this._buffer.uvs[d+1]=c,this.forPathBevel===!1&&(this._buffer.positions[h+3]=o,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[d+2]=l,this._buffer.uvs[d+3]=c),this.vertexCache[s]=f,f}_buildBevelVert(e,r,i,s=1,o){let a=`${r.bevelI}:${i}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,c]=r.boundary.vertexIndices[i],u,h,d,f;l!==c?(h=l,u=c,f=!1,d=e.continuous[h]&&e.continuous[u]):(u=l,h=(u-1+e.count)%e.count,f=e.concave[u]&&r.bevelI>0,d=e.continuous[u]||f);let m=Math.cos(r.angle),p=Math.sin(r.angle),g=i*2,y=u*2,x=h*2,v=r.boundary.vertices[g+0],b=r.boundary.vertices[g+1],w=(1-p)*this._bevel,A=(v-this._minX)/this._width,T=(b-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(A=o),T=1);let S=e.normals[y+0],M=e.normals[y+1],C=e.normals[x+0],P=e.normals[x+1];if(f){let j=C-S,V=P-M;S=S+j*(1-s),M=M+V*(1-s);let H=Math.sqrt(S*S+M*M);S/=H,M/=H}let _=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),I=_*3,O=_*2,L={i,fi:u,topP:_+0,topN:_+0,bottomP:_+1,bottomN:_+1,pathBevelUCoord:o};return this._buffer.positions[I+0]=v,this._buffer.positions[I+1]=b,this._buffer.positions[I+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[I+0]=S*m,this._buffer.normals[I+1]=M*m,this._buffer.normals[I+2]=p,this._buffer.uvs[O+0]=A,this._buffer.uvs[O+1]=T,this.forPathBevel===!1&&(this._buffer.positions[I+3]=v,this._buffer.positions[I+4]=b,this._buffer.positions[I+5]=w,this._buffer.normals[I+3]=S*m,this._buffer.normals[I+4]=M*m,this._buffer.normals[I+5]=-p,this._buffer.uvs[O+2]=T,this._buffer.uvs[O+3]=A),d||(this.forPathBevel?(_+=1,I+=3,O+=2):(_+=2,I+=6,O+=4),L.topP=_+0,L.bottomP=_+1,this._buffer.positions[I+0]=v,this._buffer.positions[I+1]=b,this._buffer.positions[I+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[I+0]=C*m,this._buffer.normals[I+1]=P*m,this._buffer.normals[I+2]=p,this._buffer.uvs[O+0]=A,this._buffer.uvs[O+1]=T,this.forPathBevel===!1&&(this._buffer.positions[I+3]=v,this._buffer.positions[I+4]=b,this._buffer.positions[I+5]=w,this._buffer.normals[I+3]=C*m,this._buffer.normals[I+4]=P*m,this._buffer.normals[I+5]=-p,this._buffer.uvs[O+2]=T,this._buffer.uvs[O+3]=A)),this.vertexCache[a]=L,L}clone(){let e=new ec(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ra(this.userData),e}};var qd=class extends Ce{constructor(e,r=12,i={}){super();this.type="ShapeGeometry";this.windingRule=qt.ODD;this.elementType=Qr.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:qt.ODD,elementType:Qr.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,u,h;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,y=s[g+0],x=s[g+1];if(u!==void 0&&y!==u&&(l=!1),h!==void 0&&x!==h&&(c=!1),u=y,h=x,!l&&!c)break}if(!l&&!c)try{a=io({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Hm}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new je(new Float32Array(d*3),3),this._normalAttribute=new je(new Float32Array(d*3),3),this._uvAttribute=new je(new Float32Array(d*2),2),this._indexAttribute=new je(new Uint32Array(f*3),1),a){let m=1/0,p=-1/0,g=1/0,y=-1/0;for(let b=0,w=d;b<w;b++){let A=b*2,T=a.vertices[A+0],S=a.vertices[A+1];T<m&&(m=T),T>p&&(p=T),S<g&&(g=S),S>y&&(y=S)}let x=p-m,v=y-g;for(let b=0,w=d;b<w;b++){let A=b*2,T=a.vertices[A+0],S=a.vertices[A+1],M=(T-m)/x,C=(S-g)/v;this._positionAttribute.setXYZ(b,T,S,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,M,C)}for(let b=0,w=f;b<w;b++){let A=b*3,T=a.elements[A+0],S=a.elements[A+1],M=a.elements[A+2];this._indexAttribute.setX(A+0,T),this._indexAttribute.setX(A+1,S),this._indexAttribute.setX(A+2,M)}}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 qd(this._shape,this._curveSegments);return e.userData=Ra(this.userData),e}};var Xd=class extends ec{constructor(e,r,i=0,s=12,o=3,a=qt.ODD){super(e,r,i,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),c=this._buildBevelVert(r,s,(o+1)%a);i.push(c.topP,l.topN,l.bottomN),i.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new Xd(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ra(this.userData),e}};var kn=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:qt.ODD},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=n.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof $t?(o.width!==r||o.height!==i)&&o.applySize(r,i):o=new $t(r,i).fromJSON(o),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&o.update());let l=o??new $t(r,i);return{parameters:Object.assign(e,{width:r,height:i,depth:s,roundness:a}),shape:l}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:i,roundness:s,windingRule:o}=n.parameters;n.shape.roundness=s;let a;return t<=0?a=new qd(n.shape,i,{windingRule:o}):a=new Xd(n.shape,t,e,i,r,o),Object.assign(a,{userData:{...n,type:"VectorGeometry"}})}};var N3=Math.PI*2,Kd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=Se.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof $t?n.shape:new $t,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c=n.shape,u=t*.5,h=e*.5,d=KK(c,u,h,i*Math.PI/180,r,s);c.isClosed=!0,c.update();let f;return i===0?(f=new Ce,f.setAttribute("position",new Te([],3))):f=kn.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function KK(n,t,e,r,i,s){if(r>=N3)return i>30||i%4===0?(ZK(n,t,e,s),Math.round(i/4)):L3(n,r,i,t,e,s);r=Math.max(r,.001);let o={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=_3({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?QK(n,o.x,o.y,c,i,t,e,s):L3(n,r,i,t,e,s)}function QK(n,t,e,r,i,s,o,a){let l=Math.round(i/r.length);n.addPoint(Yd(t,e));for(let c=0,u=r.length;c<u;c++){let h=r[c],d=n.points[c],f=Yd(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),n.addPoint(f)}return a>0?B3(n,s,o,a):n.addPoint(Yd(0,0)),l}function L3(n,t,e,r,i,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,c=Math.sin(l)*r,u=Math.cos(l)*i;n.addPoint(Yd(c,u))}return t<N3?s>0?B3(n,r,i,s):n.addPoint(Yd(0,0)):(n.removePoint(n.points[n.points.length-1]),s>0&&F3(n,r,i,s)),1}function ZK(n,t,e,r=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;n.addPoint(Mx(i-t,s,i-t,s-l,i-t,s+l)),n.addPoint(Mx(i,s+e,i-a,s+e,i+a,s+e)),n.addPoint(Mx(i+t,s,i+t,s+l,i+t,s-l)),n.addPoint(Mx(i,s-e,i+a,s-e,i-a,s-e)),r>0&&F3(n,t,e,r)}function Yd(n,t){return new ro(Se.generateUUID(),new U(n,t))}function Mx(n,t,e,r,i,s){let o=Yd(n,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(i,s),o}function B3(n,t,e,r){V3(n,t,e,r).forEach(s=>n.addPoint(s))}function F3(n,t,e,r){let i=V3(n,t,e,r),s=new $t;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,n.shapeHoles.push(s)}function V3(n,t,e,r){let i=r*t/100,s=i*(Math.abs(e)/Math.abs(t)),o=new U(i/t,s/e),a=n.points.map(l=>{let c=l.clone();return c.uuid=Se.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),u=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),a}var U3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??r),s=Math.abs(e.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(e,{width:r,height:i,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:h}=n.parameters,d=new Wm(!1,t,e,r,i,s,o,a,l,c,u,h);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},YE=new To([0,0,0],1),Wm=class extends Ce{constructor(t=!0,e=1,r=1,i=1,s=1,o=1,a=1,l=1,c=1,u=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let m=()=>new E,p=new E,g=m(),y=m(),x=m(),v,b,w,A,T,S,M,C,P=m(),_=m(),I=m(),O=m(),L=m(),j=m(),V=m(),H=m(),q=r-2*l+.001,X=q/o,K=Math.ceil(a*o),z=K+1,Q=q/K,te=-q/2,$=u+1,W=2*Math.PI/u,oe=Math.PI/2/d,ie=.01,re=Math.min((1-h/100)*l,l-ie),J=l-re,Ee=0,xe=2,de=d*xe+xe,De=$*de/xe,Pe=De+$*z,ze=Math.max(0,$*(z+de)),[ke,Ue,Le]=[3,3,2].map(We=>Array(ze*We).fill(0)),Qe=[],F=s-l;function B(We,Be){let tt=Math.PI/2;S=Be*Q,C=2*Math.PI*(S%X)/X+tt,S+=te,M=Math.sin(C)*F,T=Math.cos(C)*F,t?We.set(T,M,S):We.set(T,S,M)}B(p,-1e-10),B(g,0),P.copy(p),B(p,1);let N=p.distanceTo(g),ae=f?0:J+re,ye=N*K+2*ae,me=re,Ne=ye-ae;for(let We=0;We<=K;We++){B(y,We),H.subVectors(y,P).normalize(),P.copy(y),j.copy(y).setComponent(+t+1,0).normalize(),V.crossVectors(H,j).normalize();let Be=We===0,tt=We===K,ot=Be?3*Math.PI/2:oe,Gt=Be?me:Ne,xr=Be?$:Pe,Ir=Be?0:ze-$,Z=H.clone().multiplyScalar(Be?-J:J).add(y),ve=H.clone().multiplyScalar(Be?-1:1).normalize();for(let Me=0;Me<$;Me++){let qe=Me*W;if(_.addVectors(p.copy(j).multiplyScalar(l*Math.cos(qe)),g.copy(V).multiplyScalar(l*Math.sin(qe))),I.copy(_).normalize(),Be||tt){f||(Ee=Ir+Me,[0,1,2].forEach(Xe=>{ke[Ee*3+Xe]=Z.getComponent(Xe),Ue[Ee*3+Xe]=ve.getComponent(Xe)}),Le[Ee*2]=+tt,Le[Ee*2+1]=Me/u),g.copy(I).multiplyScalar(re),x.addVectors(y,g);for(let Xe=0;Xe<d;Xe++){let Rt=Xe*oe+ot;O.addVectors(p.copy(H).multiplyScalar(J*Math.sin(Rt)),g.copy(I).multiplyScalar(J*Math.cos(Rt))),L.copy(O).normalize(),g.addVectors(x,O),O.normalize(),Ee=xr+Xe*$+Me,[0,1,2].forEach(Wr=>{ke[Ee*3+Wr]=g.getComponent(Wr),Ue[Ee*3+Wr]=L.getComponent(Wr)});let Hr=+Be+Math.sin(Rt);Le[Ee*2]=(Gt+J*Hr)/ye,Le[Ee*2+1]=Me/u}}g.addVectors(y,_),Ee=De+We*$+Me,[0,1,2].forEach(Xe=>{ke[Ee*3+Xe]=g.getComponent(Xe),Ue[Ee*3+Xe]=I.getComponent(Xe)}),Le[Ee*2]=(ae+We*N)/ye,Le[Ee*2+1]=Me/u}}let Fe=z+2*d+xe,Oe=1,[pe,nt]=[+f,Fe-1];for(let We=pe;We<=nt-1;We++){let Be=f&&We===nt-1;for(let tt=0;tt<$-1;tt++)v=We*$+tt,b=v+1,w=(Be?tt:v)+$,A=(Be?tt+1:b)+$,We===0?Qe.push(b,A,w):We===Fe-2?Qe.push(v,b,w):Qe.push(v,b,w,b,A,w)}this.setIndex(Qe),this.setAttribute("position",new Te(ke,3)),this.setAttribute("normal",new Te(Ue,3)),this.setAttribute("uv",new Te(Le,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,i=Array.from(this.getIndex().array),s,o,a,l,c=6*(e-1)*t.radialSegments,u=e,h=u===e;for(let d=0;d<t.radialSegments;d++)s=u*r+d,o=s+1,a=(h?d:s)+r,l=(h?d+1:o)+r,i[c++]=s,i[c++]=o,i[c++]=a,i[c++]=o,i[c++]=l,i[c++]=a;return i.length=c,YE.array=i,YE.count=i.length,YE}};var k3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new qm(t*.5,s,o):new uh(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"IcosahedronGeometry"}})}},qm=class extends Jl{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,s=[-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],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,r),this.type=a}static fromJSON(t){return new qm(t.radius,t.corner,t.cornerSides)}};var z3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=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}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,i=new Ca;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new oh(i.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...n,type:"LatheGeometry"}})}};var Zo=new ue,KE=new Dt,Cx=new E,tc=class extends ar{constructor(){super(),this.uuid=Se.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(t){let e=new Sr().getNormalMatrix(t);for(let r=0,i=this.vertices.length;r<i;r++)this.vertices[r].applyMatrix4(t);for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Zo.makeRotationX(t),this.applyMatrix4(Zo),this}rotateY(t){return Zo.makeRotationY(t),this.applyMatrix4(Zo),this}rotateZ(t){return Zo.makeRotationZ(t),this.applyMatrix4(Zo),this}translate(t,e,r){return Zo.makeTranslation(t,e,r),this.applyMatrix4(Zo),this}scale(t,e,r){return Zo.makeScale(t,e,r),this.applyMatrix4(Zo),this}lookAt(t){return KE.lookAt(t),KE.updateMatrix(),this.applyMatrix4(KE.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,i=t.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,c=i.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)e.vertices.push(new E().fromBufferAttribute(s,d)),a!==void 0&&e.colors.push(new Ge().fromBufferAttribute(a,d));function u(d,f,m,p){let g=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[m].clone()],y=o===void 0?[]:[new E().fromBufferAttribute(o,d),new E().fromBufferAttribute(o,f),new E().fromBufferAttribute(o,m)],x=new Qd(d,f,m,y,g,p);e.faces.push(x),l!==void 0&&e.faceVertexUvs[0].push([new U().fromBufferAttribute(l,d),new U().fromBufferAttribute(l,f),new U().fromBufferAttribute(l,m)]),c!==void 0&&e.faceVertexUvs[1].push([new U().fromBufferAttribute(c,d),new U().fromBufferAttribute(c,f),new U().fromBufferAttribute(c,m)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],m=f.start,p=f.count;for(let g=m,y=m+p;g<y;g+=3)r!==void 0?u(r.getX(g),r.getX(g+1),r.getX(g+2),f.materialIndex):u(g,g+1,g+2,f.materialIndex)}else if(r!==void 0)for(let d=0;d<r.count;d+=3)u(r.getX(d),r.getX(d+1),r.getX(d+2));else for(let d=0;d<s.count;d+=3)u(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cx).negate(),this.translate(Cx.x,Cx.y,Cx.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,i=new ue;return i.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let t=new E,e=new E;for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,i=this.vertices.length;r<i;r++)e[r]=new E;if(t){let r=new E,i=new E;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],c=this.vertices[a.b],u=this.vertices[a.c];r.subVectors(u,c),i.subVectors(l,c),r.cross(i),e[a.a].add(r),e[a.b].add(r),e[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let r=0,i=this.vertices.length;r<i;r++)e[r].normalize();for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],i=r.vertexNormals;i.length===3?(i[0].copy(r.normal),i[1].copy(r.normal),i[2].copy(r.normal)):(i[0]=r.normal.clone(),i[1]=r.normal.clone(),i[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let i=this.faces[e];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let t=new tc;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new E,u={a:new E,b:new E,c:new E};s.push(c),o.push(u)}}let i=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],c=i.vertexNormals[s];l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let i=this.faces[e];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ei),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let i,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,c=t.faces,u=this.colors,h=t.colors;e!==void 0&&(i=new Sr().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let p=a[d].clone();e!==void 0&&p.applyMatrix4(e),o.push(p)}for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone());for(let d=0,f=c.length;d<f;d++){let m=c[d],p,g,y=m.vertexNormals,x=m.vertexColors,v=new Qd(m.a+s,m.b+s,m.c+s);v.normal.copy(m.normal),i!==void 0&&v.normal.applyMatrix3(i).normalize();for(let b=0,w=y.length;b<w;b++)p=y[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),v.vertexNormals.push(p);v.color.copy(m.color);for(let b=0,w=x.length;b<w;b++)g=x[b],v.vertexColors.push(g.clone());v.materialIndex=m.materialIndex+r,l.push(v)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let m=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],x=[];for(let v=0,b=y.length;v<b;v++)x.push(y[v].clone());this.faceVertexUvs[d].push(x)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],i=[],s=Math.pow(10,t);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],h=Math.round(u.x*s)+"_"+Math.round(u.y*s)+"_"+Math.round(u.z*s);e[h]===void 0?(e[h]=l,r.push(this.vertices[l]),i[l]=r.length-1):i[l]=i[e[h]]}let o=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=i[u.a],u.b=i[u.b],u.c=i[u.c];let h=[u.a,u.b,u.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let c=o[l];this.faces.splice(c,1);for(let u=0,h=this.faceVertexUvs.length;u<h;u++)this.faceVertexUvs[u].splice(c,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let i=t[e];this.vertices.push(new E(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}t.sort(r);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let c=t[l]._id;o&&o.push(i[c]),a&&a.push(s[c])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(t[p]=m[p]);return t}let e=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];e.push(p.x,p.y,p.z)}let r=[],i=[],s={},o=[],a={},l=[],c={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,y=!1,x=this.faceVertexUvs[0][m]!==void 0,v=p.normal.length()>0,b=p.vertexNormals.length>0,w=p.color.r!==1||p.color.g!==1||p.color.b!==1,A=p.vertexColors.length>0,T=0;if(T=u(T,0,0),T=u(T,1,g),T=u(T,2,y),T=u(T,3,x),T=u(T,4,v),T=u(T,5,b),T=u(T,6,w),T=u(T,7,A),r.push(T),r.push(p.a,p.b,p.c),r.push(p.materialIndex),x){let S=this.faceVertexUvs[0][m];r.push(f(S[0]),f(S[1]),f(S[2]))}if(v&&r.push(h(p.normal)),b){let S=p.vertexNormals;r.push(h(S[0]),h(S[1]),h(S[2]))}if(w&&r.push(d(p.color)),A){let S=p.vertexColors;r.push(d(S[0]),d(S[1]),d(S[2]))}}function u(m,p,g){return g?m|1<<p:m&~(1<<p)}function h(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function d(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function f(m){let p=m.x.toString()+m.y.toString();return c[p]!==void 0||(c[p]=l.length/2,l.push(m.x,m.y)),c[p]}return t.data={},t.data.vertices=e,t.data.normals=i,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new tc().copy(this)}copy(t){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=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let r=t.colors;for(let d=0,f=r.length;d<f;d++)this.colors.push(r[d].clone());let i=t.faces;for(let d=0,f=i.length;d<f;d++)this.faces.push(i[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let m=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],x=[];for(let v=0,b=y.length;v<b;v++){let w=y[v];x.push(w.clone())}this.faceVertexUvs[d].push(x)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let m={};if(m.name=s[d].name,s[d].vertices!==void 0){m.vertices=[];for(let p=0,g=s[d].vertices.length;p<g;p++)m.vertices.push(s[d].vertices[p].clone())}if(s[d].normals!==void 0){m.normals=[];for(let p=0,g=s[d].normals.length;p<g;p++)m.normals.push(s[d].normals[p].clone())}this.morphTargets.push(m)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let m={};if(o[d].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[d].vertexNormals.length;p<g;p++){let y=o[d].vertexNormals[p],x={};x.a=y.a.clone(),x.b=y.b.clone(),x.c=y.c.clone(),m.vertexNormals.push(x)}}if(o[d].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[d].faceNormals.length;p<g;p++)m.faceNormals.push(o[d].faceNormals[p].clone())}this.morphNormals.push(m)}let a=t.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=t.lineDistances;for(let d=0,f=c.length;d<f;d++)this.lineDistances.push(c[d]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new QE().fromGeometry(this),e=new Ce,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Px.call(new je(r,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",Px.call(new je(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",G3.call(new je(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",j3.call(new je(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",j3.call(new je(i,2),t.uvs2))}e.groups=t.groups;for(let i in t.morphTargets){let s=[],o=t.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let c=o[a],u=new Te(c.data.length*3,3);u.name=c.name,s.push(Px.call(u,c.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new Te(t.skinIndices.length*4,4);e.setAttribute("skinIndex",H3.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new Te(t.skinWeights.length*4,4);e.setAttribute("skinWeight",H3.call(i,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Ce,r=t.geometry;if(t.isPoints||t.isLine){let i=new Te(r.vertices.length*3,3),s=new Te(r.colors.length*3,3);if(e.setAttribute("position",Px.call(i,r.vertices)),e.setAttribute("color",G3.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Te(r.lineDistances.length,1);e.setAttribute("lineDistance",JK.call(o,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};tc.prototype.isGeometry=!0;var QE=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(t){let e=[],r,i,s,o=t.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,r!==void 0&&(r.count=i*3-r.start,e.push(r)),r={start:i*3,materialIndex:s})}r!==void 0&&(r.count=i*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,i=t.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=t.morphTargets,l=a.length,c;if(l>0){c=[];for(let y=0;y<l;y++)c[y]={name:a[y].name,data:[]};this.morphTargets.position=c}let u=t.morphNormals,h=u.length,d;if(h>0){d=[];for(let y=0;y<h;y++)d[y]={name:u[y].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,m=t.skinWeights,p=f.length===r.length,g=m.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let x=e[y];this.vertices.push(r[x.a],r[x.b],r[x.c]);let v=x.vertexNormals;if(v.length===3)this.normals.push(v[0],v[1],v[2]);else{let w=x.normal;this.normals.push(w,w,w)}let b=x.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let w=x.color;this.colors.push(w,w,w)}if(s===!0){let w=i[0][y];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new U,new U,new U))}if(o===!0){let w=i[1][y];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new U,new U,new U))}for(let w=0;w<l;w++){let A=a[w].vertices;c[w].data.push(A[x.a],A[x.b],A[x.c])}for(let w=0;w<h;w++){let A=u[w].vertexNormals[y];d[w].data.push(A.a,A.b,A.c)}p&&this.skinIndices.push(f[x.a],f[x.b],f[x.c]),g&&this.skinWeights.push(m[x.a],m[x.b],m[x.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Qd=class{constructor(t,e,r,i,s,o=0){this.a=t,this.b=e,this.c=r,this.normal=i&&i.isVector3?i:new E,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Ge,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function JK(n){return this.array.set(n),this}function G3(n){let t=this.array,e=0;for(let r=0,i=n.length;r<i;r++){let s=n[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new Ge),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function j3(n){let t=this.array,e=0;for(let r=0,i=n.length;r<i;r++){let s=n[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new U),t[e++]=s.x,t[e++]=s.y}return this}function Px(n){let t=this.array,e=0;for(let r=0,i=n.length;r<i;r++){let s=n[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new E),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function H3(n){let t=this.array,e=0;for(let r=0,i=n.length;r<i;r++){let s=n[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Ze),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var $K=["a","b","c"];function eQ(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function ZE(n,t,e){let r=Math.min(n,t),i=Math.max(n,t),s=r+"_"+i;return e.get(s)}function JE(n,t,e,r,i,s){let o=Math.min(n,t),a=Math.max(n,t),l=o+"_"+a,c;if(r.has(l))c=r.get(l);else{let u=e[o],h=e[a];c={a:u,b:h,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(i),s[n].edges.push(c),s[t].edges.push(c)}function tQ(n,t,e,r){let i,s,o;for(i=0,s=n.length;i<s;i++)e[i]={edges:[]};for(i=0,s=t.length;i<s;i++)o=t[i],JE(o.a,o.b,n,r,o,e),JE(o.b,o.c,n,r,o,e),JE(o.c,o.a,n,r,o,e)}function _x(n,t,e,r,i){n.push(new Qd(t,e,r,void 0,void 0,i))}function Zd(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Ix(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var Dx=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ce?t=new tc().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new E,r,i,s,o,a,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],h=u!==void 0&&u.length>0,d=[],f=new Map;tQ(l,c,d,f);let m=[],p,g,y,x,v,b,w;for(let ie of Array.from(f.keys())){for(g=f.get(ie),y=new E,v=3/8,b=1/8,w=g.faces.length,w!=2&&(v=.5,b=0,w!=1),y.addVectors(g.a,g.b).multiplyScalar(v),e.set(0,0,0),o=0;o<w;o++){for(x=g.faces[o],a=0;a<3&&(p=l[eQ(x,$K[a])],!(p!==g.a&&p!==g.b));a++);p&&e.add(p)}e.multiplyScalar(b),y.add(e),g.newEdge=m.length,m.push(y)}let A,T,S,M,C,P,_,I=[];for(i=0,s=l.length;i<s;i++){for(P=l[i],C=d[i].edges,r=C.length,r==3?A=3/16:r>3&&(A=3/(8*r)),T=1-r*Number(A),S=A,r<=2&&(r==2?(T=3/4,S=1/8):r==1||r==0),_=P.clone().multiplyScalar(T),e.set(0,0,0),o=0;o<r;o++)M=C[o],p=M.a!==P?M.a:M.b,e.add(p);e.multiplyScalar(Number(S)),_.add(e),I.push(_)}let O=I.concat(m),L=I.length,j,V,H,q=[],X=[],K,z,Q,te,$=new U,W=new U,oe=new U;for(i=0,s=c.length;i<s;i++)x=c[i],j=Number(ZE(x.a,x.b,f).newEdge)+L,V=Number(ZE(x.b,x.c,f).newEdge)+L,H=Number(ZE(x.c,x.a,f).newEdge)+L,_x(q,j,V,H,x.materialIndex),_x(q,x.a,j,H,x.materialIndex),_x(q,x.b,V,j,x.materialIndex),_x(q,x.c,H,V,x.materialIndex),h&&(K=u[i],z=K[0],Q=K[1],te=K[2],$.set(Zd(z.x,Q.x),Zd(z.y,Q.y)),W.set(Zd(Q.x,te.x),Zd(Q.y,te.y)),oe.set(Zd(z.x,te.x),Zd(z.y,te.y)),Ix(X,$,W,oe),Ix(X,z,$,oe),Ix(X,Q,W,$),Ix(X,te,oe,W));t.vertices=O,t.faces=q,h&&(t.faceVertexUvs[0]=X)}};var Ni=new E,W3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new Ce().copy(new bi(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ni),r={width:Ni.x,height:Ni.y,depth:Ni.z,subdivisions:0}):r=t.parameters;let i={...r,...n.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(n){let{width:t,height:e,depth:r,subdivisions:i}=n.parameters,s=n.geometry??new Ce().copy(new bi(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Ni)):Ni.set(o.width,o.height,o.depth),(t!==Ni.x||e!==Ni.y||r!==Ni.z)&&s.scale(Ni.x===0?1:t/Ni.x,Ni.y===0?1:e/Ni.y,Ni.z===0?1:r/Ni.z);let a=s.originalGeometry;try{i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new Dx(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete n.geometry,Object.assign(s,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new vh(e).load(n,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Ni);let o=100/Ni.x;Object.assign(s.parameters,{width:100,height:Ni.y*o,depth:Ni.z*o}),t(this.build(s))})}};var Ox=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof $t?n.shape:new $t,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=n.parameters,l=n.shape,c=t*.5,u=e*.5,h=0,d=0,f=2*Math.PI/r;for(let p=0;p<r;p++){let g=f*p,y=h+Math.sin(g)*c,x=d+Math.cos(g)*u;l.addPoint(l.createPoint(y,x))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=kn.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};var q3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=n.parameters,c=new eT(t*.5,e,i,s,o,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function Xm(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function $E(n,t,e,r,i,s){let o=t.clone().sub(n),a=e.clone().sub(n),l=o.angleTo(a);if(o.normalize(),a.normalize(),r===i){let c=o.add(a).normalize();s.copy(n).addScaledVector(c,r/Math.sin(l/2))}else{let c=o.angleTo(a);s.copy(n),s.addScaledVector(o,i/Math.sin(c)),s.addScaledVector(a,r/Math.sin(c))}}function rQ(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var eT=class extends Ce{constructor(t=.5,e=1,r=4,i=1,s=!1,o=0,a=4){super(),r=Math.floor(Math.max(3,r)),i=Math.floor(i),a=Math.floor(a);let l=[],c=[],u=[],h=[],d=0,f=e/2,m=Math.PI/r,p=t*Math.cos(Math.PI/r),g=2*Math.PI/r,y=(r-2)*Math.PI/r,x=Math.PI-y,v=new E(0,-f,0),b=new E(0,f,0),w=new U(t,-f),A=new U(p,-f),T=new U(0,b.y).sub(A),S=new U(0,b.y).sub(w),M=new U(T.y,-T.x).normalize(),C=new U(S.y,-S.x).normalize(),_=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-T.angle())/2)-1e-8;o=Math.min(o,_);let I;{let X=new E(M.x,M.y,0),K=new E(Math.cos(g)*X.x,X.y,Math.sin(g)*X.x);I=X.angleTo(K)}let O=o/Math.tan((Math.PI-T.angle())/2),L=o/Math.tan((Math.PI-I)/2),j=new E;if(!s){c.push(v.x,v.y,v.z),u.push(0,-1,0),h.push(0,0);let X=d++,K=[],z=w.clone(),Q=O/Math.cos(Math.PI/r);z.x-=Q;for(let te=0;te<r;te++){let $=te/r*Math.PI*2+m,W=new U(Math.sin($),Math.cos($));Xm(z,W,j),c.push(j.x,j.y,j.z),u.push(0,-1,0),h.push(0,0),K.push(d++)}for(let te=0;te<K.length;te++)l.push(K[te],X,K[(te+1)%K.length])}let V=[];{let X=new E,K=new E,z=new E,Q=new E,te=new E,$=new E;for(let W=0;W<r;W++){let oe=W/r*Math.PI*2+m,ie=(W+.5)/r*Math.PI*2+m,re=(W+1)/r*Math.PI*2+m,J=new U(Math.sin(oe),Math.cos(oe)),Ee=new U(Math.sin(ie),Math.cos(ie)),xe=new U(Math.sin(re),Math.cos(re));Xm(w,J,K),Xm(w,xe,z),Xm(M,Ee,X),$E(b,K,z,L,L,Q),c.push(Q.x,Q.y,Q.z),$E(K,b,z,L,O,te),c.push(te.x,te.y,te.z),$E(z,K,b,O,L,$),c.push($.x,$.y,$.z),u.push(X.x,X.y,X.z),u.push(X.x,X.y,X.z),u.push(X.x,X.y,X.z),h.push(0,0),h.push(0,0),h.push(0,0);let de=d++,De=d++,Pe=d++;if(l.push(de,De,Pe),o>0){{let Ue=K.clone().add(z).multiplyScalar(.5),Le=b.clone().sub(Ue).normalize(),F=v.clone().sub(Ue).normalize().add(Le).normalize().multiplyScalar(-1),B=$.clone().sub(te);H(Ue,B,F,T.angle())}let ze,ke;{let Ue=new E;Xm(C,xe,Ue);let Le=$.clone().add(Q).multiplyScalar(.5);Le=rQ(Le,z,b);let Qe=$.clone().sub(Q);[ze,ke]=H(Le,Qe,Ue,I,Q.y)}{let Ue=ze,Le=Ue.clone().setY(0).normalize(),Qe=new E(0,-1,0),F=Le.clone().cross(Qe);q(Ue,Le,Qe,F)}V.concat(ke);{let Ue=T.angle(),Le=Math.PI-Ue,Qe=b.clone();Qe.y-=o/Math.sin(Ue-Math.PI/2);let F=new E,B=[];for(let ae=0;ae<a;ae++){let ye=[],me=Math.PI/2-Le*ae/a,Ne=Math.cos(me),Fe=Math.sin(me),Oe=ie;for(let pe=0;pe<=ae;pe++){let nt=Math.cos(Oe),We=Math.sin(Oe);X.x=Ne*We,X.y=Fe,X.z=Ne*nt,F.copy(Qe).addScaledVector(X,o),c.push(F.x,F.y,F.z),u.push(X.x,X.y,X.z),h.push(0,0),ye.push(d++),Oe+=Math.PI*2/ae/r}B.push(ye)}ke.reverse(),B.push(ke);let N=B.length-1;for(let ae=0;ae<N;ae++){let ye=B[ae],me=B[ae+1],Ne=ye.length-1;l.push(me[1],ye[0],me[0]);for(let Fe=1;Fe<=Ne;Fe++)l.push(ye[Fe],ye[Fe-1],me[Fe]),l.push(me[Fe+1],ye[Fe],me[Fe])}}}}}this.setIndex(l),this.setAttribute("position",new Te(c,3)),this.setAttribute("normal",new Te(u,3)),this.setAttribute("uv",new Te(h,2));function H(X,K,z,Q,te){let $=-Q/2,W=(Math.PI-Q)/2,oe=K.clone().normalize().cross(z);X.addScaledVector(z,-o/Math.sin(W));let ie=new E,re=new E,J=1,Ee=d,xe=[];for(let de=0;de<=a;de++){let De=$+de/a*Q;re.set(0,0,0),re.addScaledVector(oe,Math.sin(De)),re.addScaledVector(z,Math.cos(De));for(let Pe=0;Pe<=J;Pe++){let ze=Pe/J-.5;if(ie.copy(X),ie.addScaledVector(K,ze),ie.addScaledVector(re,o),te!=null){let ke=Math.max(0,ie.y-te);ie.addScaledVector(K,-ke/K.y)}c.push(ie.x,ie.y,ie.z),u.push(re.x,re.y,re.z),h.push(0,0),Pe===0&&xe.push(d),d++}}for(let de=0;de<a;de++)for(let De=0;De<J;De++){let Pe=Ee+De+(J+1)*de,ze=Pe+(J+1),ke=ze+1,Ue=Pe+1;l.push(Pe,ze,Ue),l.push(ze,ke,Ue)}return[X.clone().addScaledVector(K,.5),xe]}function q(X,K,z,Q){let te=Math.PI/2,$=S.angle()-te,W=[],oe=new E,ie=new E;for(let J=0;J<=a;J++){let Ee=[],xe=J/a;for(let de=0;de<=J;de++){let Pe=((J?de/J:0)-.5)*x,ze=Math.cos(Pe),ke=Math.sin(Pe),Ue=Math.atan(Math.tan($)*ze),Le=(te+Ue)*xe,Qe=Math.cos(Le),F=Math.sin(Le);oe.set(0,0,0),oe.addScaledVector(K,F*ze),oe.addScaledVector(z,Qe),oe.addScaledVector(Q,F*ke),ie.copy(X).addScaledVector(oe,o),c.push(ie.x,ie.y,ie.z),u.push(oe.x,oe.y,oe.z),h.push(0,0),Ee.push(d++)}W.push(Ee)}let re=W.length-1;for(let J=0;J<re;J++){let Ee=W[J],xe=W[J+1],de=Ee.length-1;l.push(Ee[0],xe[1],xe[0]);for(let De=1;De<=de;De++)l.push(Ee[De-1],Ee[De],xe[De]),l.push(Ee[De],xe[De+1],xe[De])}}}};var Jd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof $t?n.shape:new $t,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(n){let t=n.shape,{width:e,height:r,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c={x:e*.5,y:r*.5},u={x:-c.x,y:-c.y},h={x:c.x,y:c.y};function d(b,w,A){return w>e&&A>r?Math.min(b*e/w,b*r/A):w>e?b*e/w:A>r?b*r/A:b}let f=[];f[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let m=u.x,p=h.x,g=h.y,y=u.y;t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let x=!0;for(let b=0,w=t.points.length;b<w;b++)t.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(x=!1);x&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let v=kn.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(v,{userData:{...n,type:"RectangleGeometry"}})}};var X3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=Se.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=n.parameters,u;return c===0?(u=new Ce,u.setAttribute("position",new Te([],3))):u=new qs(.5*t,i,s,o,a,l,c*Se.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};var Y3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:i=8}=n.parameters,s=new Si(t,e,r,i);return s.scale(1,1,1),Object.assign(s,{userData:{...n,type:"PlaneGeometry"}})}};var K3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,angle:i,cornerRadius:s,cornerSegments:o}=n.parameters,a=new tT(t,e,r,i,s,o);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},tT=class extends Ce{constructor(t=1,e=1,r=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],u=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-u,i),i*=Math.PI/180;let h=[],d=Math.PI/2,f=(ie=0,re=0,J=0)=>new E(ie,re,J),m=f(),p=f(),[g,y,x]=[e/2,t/2,r/2],v=-y,b=+y,[w,A,T]=[f(v,-g,+x),f(v,-g,-x),f(v,+g,-x)],S=(ie,re=!1)=>Math.sin(ie-Math.PI/(1+ +re)),M=(ie,re=!1)=>Math.cos(ie-Math.PI/(1+ +re));T.y=Math.sin(i)*e-g;let C=Math.cos(i)*e-x,P=w.z-u;i<=d?(T.z=Math.min(C,P),T.z==P&&(T.y-=(C-P)/Math.tan(d-i))):A.z=Math.min(A.z-C-x,w.z-u),m.subVectors(w,A),p.subVectors(T,A);let _=Math.min(m.length(),p.length())*s/100,I=_*Math.tan(i/2),O=_/Math.cos(i/2),L=m.clone().normalize().add(p.normalize()).setLength(O).add(A);m.set(0,S(i,!0),M(i,!0)),h.push([T,m.clone()]);let j=(Math.PI-i)/o;for(let ie=0;ie<=o;ie++){let re=d+i+ie*j;m.set(0,Math.sin(re)*I,Math.cos(re)*I),m.add(L),p.set(0,S(re),M(re)),h.push([m.clone(),p.clone()])}h.push([w,f(0,1,0)]);let V=Math.sin(j/2)*I*2,H=h.length-1,q=h[0][0].distanceTo(h[1][0]),X=h[H-1][0].distanceTo(h[H][0]),K=q+V*o+X;h[0].push(1);for(let ie=0;ie<=o;ie++)h[ie+1].push(1-(q+ie*V)/K);h[H].push(0);let[z,Q,te]=h[0],$,W,oe;for(let ie=1;ie<h.length;ie++)[$,W,oe]=h[ie],a.push(v,z.y,z.z,v,$.y,$.z,b,z.y,z.z,b,z.y,z.z,v,$.y,$.z,b,$.y,$.z),l.push(0,Q.y,Q.z,0,W.y,W.z,0,Q.y,Q.z,0,Q.y,Q.z,0,W.y,W.z,0,W.y,W.z),c.push(0,te,0,oe,1,te,1,te,0,oe,1,oe),[z,Q,te]=[$,W,oe];this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(c,2))}};var Rx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof $t?n.shape:new $t,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,u=n.shape,h=t*.5,d=e*.5,f=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,y=h*r/100,x=d*r/100;if(i===3&&r===50){p=2*Math.PI/i;for(let b=0;b<i;b++){let w=p*b,A=f+Math.sin(w)*h,T=m+Math.cos(w)*d;u.addPoint(u.createPoint(A,T))}}else for(let b=0;b<i;b++){let w=f+Math.cos(g)*h,A=m+Math.sin(g)*d;u.addPoint(u.createPoint(w,A)),g+=p,w=f+Math.cos(g)*y,A=m+Math.sin(g)*x,b<=i,u.addPoint(u.createPoint(w,A)),g+=p}u.isClosed=!0;for(let b=0,w=u.points.length;b<w;b++)u.points[b].roundness=s;u.roundness=s,u.update();let v=kn.create({shape:u,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(v,{userData:{...n,type:"StarGeometry"}})}};var Q3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e}=n.parameters,r=new Si(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var Z3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width);e.shapeBlendNode&&(i=r);let s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:i,depth:s})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=n.parameters,c=iQ(t,e,r,t*.5,o,s,0,0,i,a,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...n,type:"TorusGeometry"}})}};function iQ(n,t,e,r,i,s,o,a,l,c,u){[t,e]=[e,t],o=t/2;let h=Se.clamp(i/360,0,1);if(h===0){let d=new Ce;return d.setAttribute("position",new Te([],3)),d}return h===1&&(c=0),new Wm(!0,n,t,e,r,h,s,o,a,l,c,u)}var J3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:t,tube:e,tubularSegments:r,radialSegments:i,p:s,q:o}=n.parameters,a=t*.5;a!==e&&(a-=e);let l=new dh(a,e,r,i,s,o);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var $3=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof $t?n.shape:new $t,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t=100,height:e,cornerRadius:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=n.parameters,l=n.shape,c=t*.5,u=e*.5;a?(l.addPoint(l.createPoint(-c,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=r;l.roundness=r,l.update();let h=kn.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...n,type:"TriangleGeometry"}})}};function eL(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}function nQ(n){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(n.toLowerCase())}function sQ(n,t,e){let r,i,s,o=Math.floor(n*6),a=n*6-o,l=e*(1-t),c=e*(1-a*t),u=e*(1-(1-a)*t);switch(o%6){case 0:r=e,i=u,s=l;break;case 1:r=c,i=e,s=l;break;case 2:r=l,i=e,s=u;break;case 3:r=l,i=c,s=e;break;case 4:r=u,i=l,s=e;break;case 5:default:r=e,i=l,s=c;break}return{r:r*255,g:i*255,b:s*255}}function oQ(n,t,e){n/=255,t/=255,e/=255;let r=Math.max(n,t,e),i=Math.min(n,t,e),s=r,o=r-i,a=r==0?0:o/r,l;if(r==i)l=0;else{switch(r){case n:l=(t-e)/o+(t<e?6:0);break;case t:l=(e-n)/o+2;break;case e:default:l=(n-t)/o+4;break}l/=6}return{h:l,s:a,v:s}}function aQ(n){return n=Math.floor(n),{r:n>>16&255,g:n>>8&255,b:n&255}}function lQ(n,t,e){return(n<<16)+(t<<8)+e}function cQ(n,t,e){return n=Math.round(n),t=Math.round(t),e=Math.round(e),"#"+[n,t,e].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function uQ(n){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(t,(r,i,s,o)=>String(i+i+s+s+o+o));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}var tL={parseRgba:nQ,hsvToRgb:sQ,rgbToHsv:oQ,hexToRgb:aQ,rgbToHex:lQ,rgbToHexString:cQ,hexStringToRgb:uQ};var rT=class{add(t,e,r){if(typeof arguments[0]!="string")for(let i in arguments[0])this.add(i,arguments[0][i],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(i){this[i]=this[i]||[],e&&this[i][r?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(r){r.call(e&&e.context?e.context:e,e)})}},iT=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},fe=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+fe.version}static addUnaryOp(t){return fe.max_unop_len=Math.max(t.length,fe.max_unop_len),fe.unary_ops[t]=1,fe}static addBinaryOp(t,e,r){return fe.max_binop_len=Math.max(t.length,fe.max_binop_len),fe.binary_ops[t]=e,r?fe.right_associative.add(t):fe.right_associative.delete(t),fe}static addIdentifierChar(t){return fe.additional_identifier_chars.add(t),fe}static addLiteral(t,e){return fe.literals[t]=e,fe}static removeUnaryOp(t){return delete fe.unary_ops[t],t.length===fe.max_unop_len&&(fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops)),fe}static removeAllUnaryOps(){return fe.unary_ops={},fe.max_unop_len=0,fe}static removeIdentifierChar(t){return fe.additional_identifier_chars.delete(t),fe}static removeBinaryOp(t){return delete fe.binary_ops[t],t.length===fe.max_binop_len&&(fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops)),fe.right_associative.delete(t),fe}static removeAllBinaryOps(){return fe.binary_ops={},fe.max_binop_len=0,fe}static removeLiteral(t){return delete fe.literals[t],fe}static removeAllLiterals(){return fe.literals={},fe}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new fe(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return fe.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!fe.binary_ops[String.fromCharCode(t)]||fe.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return fe.isIdentifierStart(t)||fe.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(fe.hooks[t]){let r={context:this,node:e};return fe.hooks.run(t,r),r.node}return e}searchHook(t){if(fe.hooks[t]){let e={context:this};return fe.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===fe.SPACE_CODE||t===fe.TAB_CODE||t===fe.LF_CODE||t===fe.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:fe.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,i;for(;this.index<this.expr.length;)if(r=this.code,r===fe.SEMCOL_CODE||r===fe.COMMA_CODE)this.index++;else if(i=this.gobbleExpression())e.push(i);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,fe.max_binop_len),e=t.length;for(;e>0;){if(fe.binary_ops.hasOwnProperty(t)&&(!fe.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!fe.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,r,i,s,o,a,l,c;if(o=this.gobbleToken(),!o||(e=this.gobbleBinaryOp(),!e))return o;for(s={value:e,prec:fe.binaryPrecedence(e),right_a:fe.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),i=[o,s,a];e=this.gobbleBinaryOp();){if(r=fe.binaryPrecedence(e),r===0){this.index-=e.length;break}s={value:e,prec:r,right_a:fe.right_associative.has(e)},c=e;let u=h=>s.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;i.length>2&&u(i[i.length-2]);)a=i.pop(),e=i.pop().value,o=i.pop(),t={type:fe.BINARY_EXP,operator:e,left:o,right:a},i.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+c),i.push(s,t)}for(l=i.length-1,t=i[l];l>1;)t={type:fe.BINARY_EXP,operator:i[l-1].value,left:i[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(t=this.code,fe.isDecimalDigit(t)||t===fe.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===fe.SQUOTE_CODE||t===fe.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===fe.OBRACK_CODE)i=this.gobbleArray();else{for(e=this.expr.substr(this.index,fe.max_unop_len),r=e.length;r>0;){if(fe.unary_ops.hasOwnProperty(e)&&(!fe.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!fe.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=r;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:fe.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--r)}fe.isIdentifierStart(t)?(i=this.gobbleIdentifier(),fe.literals.hasOwnProperty(i.name)?i={type:fe.LITERAL,value:fe.literals[i.name],raw:i.name}:i.name===fe.this_str&&(i={type:fe.THIS_EXP})):t===fe.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===fe.PERIOD_CODE||e===fe.OBRACK_CODE||e===fe.OPAREN_CODE||e===fe.QUMARK_CODE;){let r;if(e===fe.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==fe.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===fe.OBRACK_CODE?(t={type:fe.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==fe.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===fe.OPAREN_CODE?t={type:fe.CALL_EXP,arguments:this.gobbleArguments(fe.CPAREN_CODE),callee:t}:(e===fe.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),t={type:fe.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),r&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,r;for(;fe.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===fe.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);fe.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));fe.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);fe.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return r=this.code,fe.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(r===fe.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===fe.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:fe.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,r=this.expr.charAt(this.index++),i=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===r){i=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
|
|
3141
3141
|
`;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=s}else t+=s}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:fe.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(fe.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,fe.isIdentifierPart(t));)this.index++;return{type:fe.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],r=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){r=!0,this.index++,t===fe.CPAREN_CODE&&i&&i>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===fe.COMMA_CODE){if(this.index++,i++,i!==e.length){if(t===fe.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===fe.CBRACK_CODE)for(let o=e.length;o<i;o++)e.push(null)}}else if(e.length!==i&&i!==0)this.throwError("Expected comma");else{let o=this.gobbleExpression();(!o||o.type===fe.COMPOUND)&&this.throwError("Expected comma"),e.push(o)}}return r||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(fe.CPAREN_CODE);if(this.code===fe.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:fe.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:fe.ARRAY_EXP,elements:this.gobbleArguments(fe.CBRACK_CODE)}}},hQ=new rT;Object.assign(fe,{hooks:hQ,plugins:new iT(fe),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"});fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops);fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops);var cu=n=>new fe(n).parse(),dQ=Object.getOwnPropertyNames(fe);dQ.forEach(n=>{cu[n]===void 0&&n!=="prototype"&&(cu[n]=fe[n])});cu.Jsep=fe;var fQ="ConditionalExpression",pQ={name:"ternary",init(n){n.hooks.add("after-expression",function(e){if(e.node&&this.code===n.QUMARK_CODE){this.index++;let r=e.node,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===n.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:fQ,test:r,consequent:i,alternate:s},r.operator&&n.binary_ops[r.operator]<=.9){let o=r;for(;o.right.operator&&n.binary_ops[o.right.operator]<=.9;)o=o.right;e.node.test=o.right,o.right=e.node,e.node=r}}else this.throwError("Expected :")}})}};cu.plugins.register(pQ);function Ya(n){return{all:n=n||new Map,on:function(t,e){var r=n.get(t);r?r.push(e):n.set(t,[e])},off:function(t,e){var r=n.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var r=n.get(t);r&&r.slice().map(function(i){i(e)}),(r=n.get("*"))&&r.slice().map(function(i){i(t,e)})}}}var $d=class{constructor(t,e,r){this.id=t;this.userAPI=e;this.result=void 0;this.error="null";this.isPrefetched=!1;this.isLoading=!1;this.isLoaded=!1;this.prefetchPromise=new Promise(t=>t());this.emitter=Ya();this._innerCallUserAPI=async t=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await xQ(this.userAPI,t),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(e){let r=e.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=r,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0};e?.integration?.type==="OpenAI"?this.result={content:""}:e.method==="GET"&&e.url!==""&&(this.prefetchPromise=this.prefetch(r)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=_o(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?_o(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(t){await this.callUserAPI(t)}async callUserAPI(t){await this._debouncedCallUserAPI(t)}update(t,e,r=!0){this.userAPI=t,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&r&&this._debouncedPrefetch(e)}retrieveValue(t){if(this.result)try{return Mr.zoom(this.result,t)}catch(e){console.error(e)}}retrieveZoomedKeyValues(t){if(this.result){let e=t&&t.length?Mr.zoom(this.result,t):this.result;if(vQ(e))return Object.entries(e);if(yQ(e))return e.map((r,i)=>[i.toString(),r]);throw gQ(e)?new Error("This path points to a value, use retrieveValue() instead. "+t?.join(".")):new Error("Path error"+t?.join("."))}}dispose(){}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}get autostart(){return this.userAPI.autoStart}};function mQ(n){let t=new Headers;return n.headers.forEach(e=>{e.data.key!==""&&t.append(e.data.key,e.data.value)}),t}function gQ(n){return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null}function yQ(n){return Array.isArray(n)}function vQ(n){return typeof n=="object"&&n!==null}async function xQ(n,t,e=new AbortController){let r,i=n.url,s=n.proxy?.enabled??!1,o;if(n.integration?.type==="OpenAI"){let l=Ym(n.integration.prompt===""?[]:JSON.parse(n.integration.prompt),t),c=n.integration.behavior===""?[]:Ym(JSON.parse(n.integration.behavior),t);o=`{
|
|
3142
3142
|
"model": "${n.integration.model}",
|
|
@@ -3153,7 +3153,7 @@ best distance: ${d.d}`);let y=[d.x,d.y];return y.distance=d.d,y.distance}functio
|
|
|
3153
3153
|
}`}if(s){i=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${n.proxy.fileId}/external-api/request?uuidexternalapi=${n.proxy.proxyId}`;let u;o!==void 0?u=o:n.method==="POST"&&n.body&&(u=Ym(JSON.parse(n.body),t)),u!==void 0&&(i+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else n.integration?.type==="OpenAI"?r=o:n.method==="POST"&&n.body&&(r=Ym(JSON.parse(n.body),t));let a=await fetch(i,{method:s?"GET":n.method,headers:s?void 0:mQ(n),signal:e.signal,body:r});if(!a.ok)throw new Error("status:"+a.status+"_:_"+a.statusText);if(n.integration?.type==="OpenAI"){let l=await a.json();return s&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await a.json();return s&&(l=l.response),l}}var rL=(n,t)=>{if(typeof n=="string"){let e=t.getVariable(n);if(e)return rL(e,t)}return Gr.isBoolean(n)?Gr.getDisplayedValue(n).toLowerCase():Gr.getDisplayedValue(n)},Ym=(n,t)=>n.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
|
|
3154
3154
|
`:"")+Ym(e.children,t);if(e.type==="variable"){let i=t.getVariable(e.variableId);if(i!==void 0)return rL(i,t)}}return""}).join("");var bQ=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],SQ=["0","1","2","3","4","5","6","7","8","9","."],wQ=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function AQ(n){return typeof n!="string"?!1:!isNaN(n)&&!isNaN(parseFloat(n))}cu.addBinaryOp("^",11,!0);function Lx(n,t,e="number"){let r="";for(let o=0;o<n.length;o++){let a=n[o];if("objType"in a&&a.objType==="api"){let l=JSON.parse(a.id),c=l[0],u=t.getUserAPI(c);if(u!==void 0&&u instanceof $d){let h=u.retrieveValue(l.slice(1));h!==void 0&&(r+=h)}continue}if("objType"in a&&a.objType==="webhook"){let l=JSON.parse(a.id),[c,u]=l,h=t.getUserWebhook(c);if(h!==void 0){let d=h.getParameterValue(u);d!==void 0&&(r+=d)}continue}if("objType"in a&&a.objType==="aiAssistant"){let l=t.openAIRealtime;if("objId"in a&&a.objId!==void 0){let c;if(t.scene.data.objects.traverse((u,h)=>{let d=h.events?.find(f=>f.id===a.objId);d&&(c=d)}),c!==void 0&&c.data.type==="AIAssistantListener"){let u=l?.computeAnalysisForListenerEvent(c.data);if(u!==void 0){r+=u;continue}}}r+=l?.voice??0;continue}if("id"in a){let l=n[o-1];if(o>0&&"id"in l){console.error("Two variables in a row",n);return}let c=t.getVariable(a.id),u=Gr.getDisplayedValue(c);e==="number"&&Gr.isTextValue(c)&&Array.isArray(c.textValue)&&c.textValue.length===1?u=parseFloat(u).toString():e==="boolean"&&Gr.isBoolean(c)?u=c?"true":"false":e==="boolean"&&Gr.isTextValue(c)&&!Array.isArray(c.textValue)&&(u='"'+u+'"'),r+=u;continue}else if(e==="string"){a.name!=='"'&&(a.name!=="+"||a.escaped)&&(r+=a.name),a.name==="+"&&!a.escaped&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+a.name);continue}if(a.name==="and"){r+="&&";continue}if(a.name==="or"){r+="||";continue}if(a.name==="True"){r+="true";continue}if(a.name==="False"){r+="false";continue}if(e==="boolean"&&!AQ(a.name)&&!SQ.includes(a.name)&&!bQ.includes(a.name)&&!wQ.includes(a.name.replace(/\($/g,""))){r+='"'+a.name+'"';continue}r+=a.name}if(e==="string")return r;if(n.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let i;try{i=cu(r)}catch(o){console.error(r,o);return}let s;try{s=Kt(i)}catch(o){console.error(r,i,o)}return s}function Kt(n){switch(n.type){case"BinaryExpression":switch(n.operator){case"==":return Number(Kt(n.left)===Kt(n.right));case"!=":return Number(Kt(n.left)!==Kt(n.right));case">":return Number(Kt(n.left)>Kt(n.right));case">=":return Number(Kt(n.left)>=Kt(n.right));case"<":return Number(Kt(n.left)<Kt(n.right));case"<=":return Number(Kt(n.left)<=Kt(n.right));case"+":return Kt(n.left)+Kt(n.right);case"-":return Kt(n.left)-Kt(n.right);case"*":return Kt(n.left)*Kt(n.right);case"/":return Kt(n.left)/Kt(n.right);case"%":return Kt(n.left)%Kt(n.right);case"&&":return Kt(n.left)&&Kt(n.right);case"||":return Kt(n.left)||Kt(n.right);case"^":return Math.pow(Kt(n.left),Kt(n.right));default:throw new Error("Unknown operator: "+n.operator)}case"UnaryExpression":switch(n.operator){case"-":return-Kt(n.argument);case"!":return Number(!Kt(n.argument));default:throw new Error("Unknown operator: "+n.operator)}case"Identifier":throw new Error("Unknown identifier: "+n.name);case"Literal":return n.value;case"CallExpression":if(n.callee.type==="Identifier"){if(n.callee.name==="random"){let t=0,e=1;if(n.arguments.length>=1)try{t=Kt(n.arguments[0])}catch(r){console.warn(r)}if(n.arguments.length>=2)try{e=Kt(n.arguments[1])}catch(r){console.warn(r)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[n.callee.name].apply(null,n.arguments.map(Kt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+n.type)}}var EQ=new ue,TQ=new ue;function MQ(n,t,e){let r=[new E,new E,new E],i=[new E,new E,new E];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(i[0],i[1],i[2]),r.forEach((s,o)=>{let a=i[o],l=Se.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ue().makeBasis(r[0],r[1],r[2])}var iL=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Kd.create({parameters:{...ru,width:typeof ru.width=="number"?ru.width:100,height:typeof ru.height=="number"?ru.height:100}}).userData.shape;return{path:n.path??fd.defaultData(),parameters:Object.assign(e,{width:r,height:i,depth:s,extrusion:{...F0,...e.extrusion}}),shapeData:o}}static build(n){if(n.path.points.length>=2){let e=new nT(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Ce,{userData:{...n,type:"PathGeometry"}})}},nT=class extends Ce{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)||!eL(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:i,offset:s}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),s=Math.max(0,Math.min(s,1));let o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((i+s)*o):Math.ceil(Math.min(1,i+s)*o),c=Math.min(Math.max(2,l-a+1),o+2),u=[],h=[];for(let q=0;q<c;q++){let X=this.inputs.path.isClosed?(q+a)%e.length:Math.min(q+a,e.length-1);u.push(e[X].clone()),h.push(r[X].clone())}let d=(q,X,K)=>{u[q]=u[q].clone().lerp(u[X],K),h[q]=MQ(h[q],h[X],K)},f=0,m=s*o%1;(!this.inputs.path.isClosed||i<=1)&&(m||s===0)&&(f=m,d(0,1,f));let p=0,g=(s+i)*o%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&s+i<1)&&g&&(p=g,d(u.length-1,u.length-2,1-p)),i===0){let q=u.length-1;u[q].copy(u[0]),h[q].copy(h[0])}this._applyPathModifiers(h,f,p);let{bevel:y,bevelSides:x}=this.inputs.parameters.extrusion,v=y>0?this.inputs.parameters.extrusion.capType:"flat",b=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(b=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:w,infos:A,vertices:T}=this._computeShapePoints(b),S=0,M;v==="round"&&(M=new ec(this.inputs.shapeData,2*y,y,b,x,void 0,!0),S=M.getAttribute("position").count);let C=0,P=0;A.sort((q,X)=>q.start-X.start),A.forEach(q=>{q.verticesStart=C,q.verticesCount=q.continuous.reduce((X,K,z)=>X+(z===0||!K?2:1),0),P+=q.verticesCount,C=P});let _=P*c,I,O=0;if(this._isOpenEnded()&&v==="flat"){try{I=io({windingRule:qt.ODD,elementType:Qr.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:w})}catch{I=XE}O=I.vertexCount}let L=_+2*O+S*2,j=_+2*O,V={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},H=[];if(A.forEach(q=>{this._extrudeRegion(q,T,h,u,V,H,this._isGeometryClosed()&&!this._isOpenEnded())}),I&&(this._closeEnd(I,_,H,V,h[0],u[0],!1),this._closeEnd(I,_+O,H,V,h[h.length-1],u[u.length-1],!0)),M){V.positions.set(M.getAttribute("position").array,j*3),V.normals.set(M.getAttribute("normal").array,j*3),V.uvs.set(M.getAttribute("uv").array,j*2);for(let z=j;z<j+S;z++)V.uvs[z*2+1]=1e-4;let q=H.length;H.push(...M.getIndex().array.map(z=>z+j)),j+=S,V.positions.set(M.getAttribute("position").array,j*3),V.normals.set(M.getAttribute("normal").array,j*3),V.uvs.set(M.getAttribute("uv").array,j*2);let X=H.length;H.push(...M.getIndex().array.map(z=>z+j)),this.setAttribute("position",new je(V.positions,3)),this.setAttribute("normal",new je(V.normals,3)),this.setAttribute("uv",new je(V.uvs,2)),this.setIndex(H);let K=EQ;K.copy(h[h.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(K,j,L),K.copy(h[0]).setPosition(u[0]).multiply(TQ.makeScale(1,1,-1)),this.applyMatrix4OnRange(K,j-S,j),this.reverseIndicesOnRange(q,X)}else this.setAttribute("position",new je(V.positions,3)),this.setAttribute("normal",new je(V.normals,3)),this.setAttribute("uv",new je(V.uvs,2)),this.setIndex(H)}_extractPathPoints(){let e=bx(this.inputs.path),r=this.inputs.path.subdivisions,i=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(i.length<2)return[];let s=[i[0]];return i.forEach(a=>{s[s.length-1].distanceToSquared(a)>.001&&s.push(a)}),this.inputs.path.isClosed&&s[s.length-1].distanceTo(s[0])<.001&&s.pop(),s}_computeBasisMatrices(e){let r=[],i=e.length,s=this.inputs.path.isClosed,o=new E,a=new E,l=new E,c=new E,u=new E(0,1,0);for(let g=0;g<i;g++){let y=e[g],x;g===0?x=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):x=e[g-1];let v;g===i-1?v=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):v=e[g+1];let b=y.clone().sub(x).normalize(),w=v.clone().sub(y).normalize(),A=b.clone().add(w).normalize();l.copy(A),g===0&&(A.equals(u)||A.clone().negate().equals(u))&&u.set(0,0,1);let T=u.clone().cross(A).normalize(),S=A.clone().cross(T).normalize();u.copy(S),c.copy(T),g===0&&(o.copy(S),a.copy(A));let M=new ue().makeBasis(T,S,A);r.push(M)}let h=s?a:l,d=s?o:new E(0,1,0),f=h.clone().cross(c).normalize(),m=Math.acos(d.dot(f));if(isNaN(m))return r;let p=d.clone().cross(f);h.dot(p)>0&&(m*=-1);for(let g=1;g<r.length;g++){let y=new ue().makeRotationZ(m*g/r.length);r[g].multiply(y)}return r}_applyPathModifiers(e,r,i){let s=e.length,{angle:o,twist:a,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new ue,h=new ue;return e.forEach((d,f)=>{let m=f===0?0:f===s-1?1:(f-r)/(s-(i===0?0:1)-(r+(1-i)));u.makeRotationZ(Se.lerp(o,o+a,m)*Se.DEG2RAD);let p=Se.lerp(l,c,m);h.makeScale(p,p,p),d.multiply(u).multiply(h)}),e}_computeShapePoints(e=12,r=qt.ODD){let i=this.inputs.shapeData,s=i.extractShapePointsToFlatArray([],e),o=i.shapeHoles.map(p=>{let g=p.extractShapePointsToFlatArray([],e),y=[];for(let x=g.length-1;x>=1;x-=2){let v=g[x-1],b=g[x-0];y.push(v,b)}return y}),a;try{a=io({windingRule:r,elementType:Qr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Hm}let l;try{l=io({windingRule:qt.ODD,elementType:Qr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=qE}if(!a)throw new Error("error generating geometry");let c=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let p=0;p<l.elements.length;p++){let g=l.elements[p],y=p%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let p=0;p<l.vertexIndices.length;p++){let g=l.vertexIndices[p],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let p=0;p<l.vertices.length;p++){let g=l.vertices[p];a.vertices.push(g)}}let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let p=0,g=a.vertexCount;p<g;p++){let y=p*2,x=a.vertices[y+0],v=a.vertices[y+1];x<u&&(u=x),x>h&&(h=x),v<d&&(d=v),v>f&&(f=v)}let m=[];for(let p=a.elementCount-1;p>=0;p--){let g=p>=c,y=p*2,x=a.elements[y+0],v=a.elements[y+1],b=x+v,w={start:x,count:v,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};m.push(w);let A=x,T=b-1,S=x+1,M=i.roundedCurves.length;do{let C=A-x,P=a.vertices[T*2+0],_=a.vertices[T*2+1],I=a.vertices[A*2+0],O=a.vertices[A*2+1],L=a.vertices[S*2+0],j=a.vertices[S*2+1],V=I-P,H=O-_,q=Math.sqrt(V*V+H*H);V/=q,H/=q;let X=I-L,K=O-j,z=Math.sqrt(X*X+K*K);X/=z,K/=z,w.normals[C*2+0]=-K,w.normals[C*2+1]=X;let Q=a.vertexIndices[A];if(Array.isArray(Q))w.continuous[C]=!1;else{let[te,$]=i.getCurveIndexFromVertexId(Q-1,!0);if($>0&&$<1)w.continuous[C]=!0;else{let W=$===1?te+1:te-1;W=(W+M)%M;let oe=$===1?0:1,ie=i.roundedCurves[te].getTangent($),re=i.roundedCurves[W].getTangent(oe);w.continuous[C]=ie.dot(re)>.95}}g&&(w.normals[C*2+0]*=-1,w.normals[C*2+1]*=-1),[T,A,S]=[A,S,S+1],S>=b&&(S-=v)}while(S!==x+1)}return{regions:[s,...o],infos:m,vertices:a.vertices}}_insertVertex(e,r,i,s,o){let a=r*2,l=r*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,r,i,s,o,a,l){let c=new E,u=new E,h=new E,d=new E,f=new U;i.forEach((p,g)=>{let y=s[g],x=e.verticesStart*i.length+e.verticesCount*g;for(let v=0;v<e.count;v++){let b=(e.start+v)*2;if(c.set(r[b+0],r[b+1],0),h.copy(c).applyMatrix4(p).add(y),e.continuous[v])d.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let w=v===0?(e.start+e.count-1)*2:b-2;u.set(r[w+0],r[w+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(p).normalize(),f.set(v===0?1:v/e.count,g/(i.length-1)),this._insertVertex(o,x,h,d,f),x++,!e.continuous[v]||v===0){if(v===0)d.set(e.normals[v*2+0],e.normals[v*2+1],0),f.set(0,g/(i.length-1));else{let w=v===e.count-1?e.start*2:b+2;u.set(r[w+0],r[w+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(p).normalize(),this._insertVertex(o,x,h,d,f),x++}}});let m=i.length-1;for(let p=0;p<m;p++){let g=e.verticesStart*i.length+e.verticesCount*p,y=e.verticesStart*i.length+e.verticesCount*(p+1),x=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&x++;let b=v===e.count-1?0:x+1,w=g+x,A=g+b,T=y+b,S=y+x;e.isHole?a.push(w,T,A,w,S,T):a.push(w,A,T,w,T,S),x++}}}_closeEnd(e,r,i,s,o,a,l){let c=e.vertexCount,u=new E(0,0,l?-1:1).applyMatrix4(o),h=new E,d=new U;for(let m=0;m<c;m++){let p=2*m;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(o).add(a),this._insertVertex(s,r+m,h,u,d)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let p=3*m,g=f[p+0]+r,y=f[p+(l?1:2)]+r,x=f[p+(l?2:1)]+r;i.push(g,y,x)}}applyMatrix4OnRange(e,r,i){let s=e.elements,o=new Sr().getNormalMatrix(e).elements,a,l,c,u,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let f=h.array,m=d.array,p=h.itemSize;for(let g=r*p,y=i*p;g<y;g+=p){if(g===r)debugger;a=f[g+0],l=f[g+1],c=f[g+2],u=1/(s[3]*a+s[7]*l+s[11]*c+s[15]),f[g+0]=(s[0]*a+s[4]*l+s[8]*c+s[12])*u,f[g+1]=(s[1]*a+s[5]*l+s[9]*c+s[13])*u,f[g+2]=(s[2]*a+s[6]*l+s[10]*c+s[14])*u,a=m[g+0],l=m[g+1],c=m[g+2],m[g+0]=o[0]*a+o[3]*l+o[6]*c,m[g+1]=o[1]*a+o[4]*l+o[7]*c,m[g+2]=o[2]*a+o[5]*l+o[8]*c}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let i=this.index;if(i){for(let s=e;s<r;s+=3){let o=i.getX(s),a=i.getX(s+1),l=i.getX(s+2);i.setXYZ(s,l,a,o)}i.needsUpdate=!0}}};function nL(){let n=new Ce;return n.setAttribute("position",new je(new Float32Array([]),3)),n.setIndex(new je(new Uint16Array([]),1)),n}var PQ=nL().attributes,_Q=12,IQ=1,uu=class extends Ce{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,PQ),this.userData={parameters:e,type:"TextGeometry"};let i=r.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let i=r.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,r){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:s,height:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:h}=e,d=Gr.getDisplayedValue(u),f=h===2?d.toUpperCase():h===3?d.toLowerCase():d,m=DQ(e,i,f,r),{shapes:p,charWidths:g,charCoords:y}=i.generateShapes(m,e,r),x=(typeof s=="number"?s:Number(r.getVariable(s)))*.5,v=(typeof o=="number"?o:Number(r.getVariable(o)))*.5,b=p.map(T=>new $t().fromShape(T,!0));this.vectorShapes=b;let w=b.map(T=>kn.create({shape:T,parameters:{depth:a,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:a<=0?qt.NONZERO:qt.ODD,subdivisions:this.isLowResolution&&a>0?IQ:_Q}})),A=w.length?Js(w):nL();A.translate(-x,v,0),this.dispose(),this.wrappedText=m,this.charCoords=y,this.charWidths=g,this.deleteAttribute("extrudeNormal"),Object.entries(A.attributes).forEach(([T,S])=>{this.setAttribute(T,S)}),this.setIndex(A.index),this.computeBoundingSphere()}clone(){let e=Ri(new Ce,uu.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,i])=>{this.setAttribute(r,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function DQ(n,t,e,r){let i=typeof n.width=="string"?Number(r.getVariable(n.width)):n.width,s=[""],o="";for(let a of e)o+=a,a===" "||a===`
|
|
3155
3155
|
`?(s[s.length-1]+=o,o="",a===`
|
|
3156
|
-
`&&s.push("")):t.getTextWidth(s[s.length-1]+o,n)>i&&(s[s.length-1].length&&s.push(""),t.getTextWidth(s[s.length-1]+o,n)>i&&(o.length===1?(s[s.length-1]+=o,o=""):(s[s.length-1]+=o.slice(0,-1),o=o[o.length-1],s.push(""))));return s[s.length-1]+=o,s}var oL,Bx=new Promise(n=>{oL=n}),sL=!1;var Nx;function aL(n){if(sL)return;if(Nx)return Nx;async function t(){let r=n??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.47/build"),s=import("./process.js"),[o,a]=await Promise.all([s,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=o.default,c=await l({wasmBinary:a});oL(c),sL=!0}return Nx=t(),Nx}var OQ=["font"];function Jo(n,t,e,r){let i,s,o;n.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(n)),o=[[],["extrusion"]]):(s={...n},o=[[]]);for(let c of o){let u=s;for(let h of c)u=u[h];for(i in u){let h=u[i];CA(h)&&!OQ.includes(i)&&(u[i]=t.getVariable(h,[r.uuid,"geometry",...c,i]),CA(u[i])&&(u[i]=1))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let c=$t.createFromState(s.shape,s.width,s.height);a.shape=c}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),a.geometry=new vh().parse(s),a.geometry.groups.length===0){let c=a.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(s.type==="SubdivGeometry"){let c=new ui(s,e);return c.data=n,c}else{if(s.type==="TextGeometry")return new uu(s,t);if(s.type==="InputGeometry")return new uu(s,t);if(s.type==="UIGeometry")return Jd.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=sT(a)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${a}`);let u=$t.createFromState(dd.defaultData(),100,100);a.shape=u,a.type="VectorGeometry",l=sT(a)}return l}var RQ=new ue;function Km(n,t,e,r){let i=n.position.array,s=n.normal.array,o=RQ.makeScale(t,e,r).invert().elements,a,l,c;for(var u=0,h=i.length;u<h;u+=3)i[u]*=t,i[u+1]*=e,i[u+2]*=r,a=s[u],l=s[u+1],c=s[u+2],s[u]=o[0]*a+o[4]*l+o[8]*c,s[u+1]=o[1]*a+o[5]*l+o[9]*c,s[u+2]=o[2]*a+o[6]*l+o[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Fx=new Yt,ef=new E,ht;Bx.then(n=>{ht=n});var lL=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),cL=new Uint32Array([0,1,2,3]),uL=new Uint8Array([4]),ui=class extends Ce{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let i=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),s=ws.div(r.map(l=>typeof l=="number"?l:0),i);if(s.every(l=>l===1))return;this.subdividedGeometry&&Km(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Km(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(ef.fromArray(s));let a=ef.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,i;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:i}=ui.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new bi(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ui.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ei,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;Fx.setFromBufferAttribute(r),Fx.getCenter(i),e.boundingSphere.radius=i.distanceTo(Fx.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Fx.getSize(ef);let s={width:ef.x,height:ef.y,depth:ef.z};return this.userData.parameters=s,s}static build(e,r,i,s){let o,a,l,c=e?.phongAngle??35;i===!1&&(c=-1),r&&(ht.free_bvh(r),ht.free_subdivision_surface(r));try{o=ui.allocate(e,s)}catch(u){console.error(u,e),o=ui.allocate({positionWASM:lL,indexWASM:cL,verticesPerFaceWASM:uL},s)}if(ht.set_destination_refinement_level(o,0),a=ui.buildLevel(o,!0,c),e.subdivisions>0)try{ht.set_destination_refinement_level(o,e.subdivisions),l=ui.buildLevel(o,!1,c)}catch{try{ht.set_destination_refinement_level(o,e.subdivisions-1),l=ui.buildLevel(o,!1,c)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,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 s=e.shape!==void 0||e.path!==void 0?r.geometry:Jo(e,i,!1,r),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,c,u;({positions:a,triIndices:u}=hu(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:c}=cT(a,u,s,h),{positions:a,indices:l,verticesPerFace:c}}static allocate(e,r){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=lL,s=cL,o=uL);let c=i.length,u=s.length,h=o.length,d=i.length+a.length+l.length,f=s.length+o.length,m=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=d*Float32Array.BYTES_PER_ELEMENT,g=ht._malloc(m),y=new Float32Array(ht.HEAPF32.buffer,g,d),x=new Uint32Array(ht.HEAPU32.buffer,g+p,f);y.set(i,0),y.set(a,i.length),y.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let v;e?.scaleBaked?.some(w=>w!==1)&&(v=new ue().makeScale(...e.scaleBaked.map(w=>typeof w=="number"?w:1))),r&&(v?v.premultiply(r):v=r);let b=v?ht.alloc_subdivision_surface2(g,c,g+p,u,g+p+s.length*Uint32Array.BYTES_PER_ELEMENT,h,v.elements):ht.alloc_subdivision_surface(g,c,g+p,u,g+p+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return ht._free(g),b}static buildLevel(e,r,i,s,o){let a=o?ht.get_mesh_data2(e,r?ht.Level.CONTROL:ht.Level.REFINED,i,o.elements):ht.get_mesh_data(e,r?ht.Level.CONTROL:ht.Level.REFINED,i),l=8,c=ht.HEAPU32.subarray(a>>2,(a>>2)+l),u=c.subarray(4,4+4),h=0,d=ht.HEAPU32[c[h]>>2],f=ht.HEAPF32.subarray(d>>2,(d>>2)+u[h]);h++;let m=ht.HEAPU32[c[h]>>2],p=ht.HEAPF32.subarray(m>>2,(m>>2)+u[h]);h++;let g=ht.HEAPU32[c[h]>>2],y=ht.HEAPU32.subarray(g>>2,(g>>2)+u[h]);h++;let x=ht.HEAPU32[c[h]>>2],v=ht.HEAPU32.subarray(x>>2,(x>>2)+u[h]);if(h++,s===void 0){let b=new Ce;if(b.setIndex(new To(v,1)),b.setAttribute("position",new Te(f,3)),b.setAttribute("normal",new Te(p,3)),r){b.setAttribute("faceMap",new To(y,1));let w=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new je(w,4))}return ht.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,ht.free_mesh_data(a)}static freeSubdivPointer(e){ht.free_bvh(e),ht.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let s=ht.get_wireframe_data_for_base_level(e),o=4,a=ht.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),c=0,u=ht.HEAPU32[a[c]>>2],h=ht.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=ht.HEAPU32[a[c]>>2],f=ht.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let m=new Ce;m.setAttribute("position",new Te(h,3));let p=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)p[g++]=i.r,p[g++]=i.g,p[g++]=i.b;return m.setAttribute("color",new je(p,3)),m.setIndex(new To(f,1)),ht.free_wireframe_data_for_base_level(s),m}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,ht.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,i){let s=r===0;s||ht.set_destination_refinement_level(e,r);let o=i?ht.get_topological_data2(e,s?ht.Level.CONTROL:ht.Level.REFINED,i.elements):ht.get_topological_data(e,s?ht.Level.CONTROL:ht.Level.REFINED),a=6,l=ht.HEAPU32.subarray(o>>2,(o>>2)+a),c=l.subarray(3,3+3),u=0,h=ht.HEAPU32[l[u]>>2],d=new Float32Array(ht.HEAPF32.subarray(h>>2,(h>>2)+c[u]));u++;let f=ht.HEAPU32[l[u]>>2],m=new Uint32Array(ht.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let p=ht.HEAPU32[l[u]>>2],g=new Uint8Array(ht.HEAPU32.subarray(p>>2,(p>>2)+c[u]));return ht.free_topological_data(o),{positions:d,indices:m,verticesPerFace:g}}};var hL=["getX","getY","getZ"];function hu(n,t){let e={},r=t?t.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,h="";for(let d=0;d<3;d++)h+=`${~~(n[hL[d]](u)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(n[hL[d]](u));e[h]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var Vx=new E,oT=new E,aT=new E,lT=new E;function cT(n,t,e,r){let i=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,m)=>Math.floor(m/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]);n.length=0;let h=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),i.push(h++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),i.push(h++);return s.push(h),{indices:i,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[a]*3+2]===o||n[t[a]*3+2]===0)&&l++,(n[t[a+1]*3+2]===o||n[t[a+1]*3+2]===0)&&l++,(n[t[a+2]*3+2]===o||n[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Vx.set(n[t[a]*3],n[t[a]*3+1],n[t[a]*3+2]),oT.set(n[t[a+1]*3],n[t[a+1]*3+1],n[t[a+1]*3+2]),aT.set(n[t[a+4]*3],n[t[a+4]*3+1],n[t[a+4]*3+2]),lT.set(n[t[a+5]*3],n[t[a+5]*3+1],n[t[a+5]*3+2]),oT.sub(Vx).normalize(),aT.sub(Vx).normalize(),lT.sub(Vx).normalize();let l=oT.cross(aT).dot(lT),c=a;Math.abs(l)>.005||r&&r.some((u,h)=>h%2===1?!1:c>=r[h]&&c<r[h+1])?(i.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(i.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else i.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let h=0,d=0;h<n.length;h+=3,d++)n[h+2]===0&&(l.push(d),u++),n[h+2]===o&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=c[0];c[0]=c[1],c[1]=h}l.reverse(),i.push(...l,...c),s.push(u,u)}return{indices:i,verticesPerFace:s}}var _s={};IC(_s,{calcBoolean:()=>BQ,calcBooleanTopological:()=>NQ,freeMeshSet:()=>kQ,getMeshSet:()=>FQ,hasOpenEdges:()=>VQ,transformMeshSet:()=>UQ});var dL,fL=new Promise(n=>{dL=n});var Ux;function pL(n){if(Ux)return Ux;async function t(){let r=n??(!1?".":"https://unpkg.com/@splinetool/boolean-wasm@1.12.47/build"),s=import("./boolean.js"),[o,a]=await Promise.all([s,fetch(`${r}/boolean.wasm`).then(u=>u.arrayBuffer())]),l=o.default,c=await l({wasmBinary:a});dL(c)}return Ux=t(),Ux}var zt,tf;fL.then(n=>zt=n);function LQ(n,t,e){let r,i;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?i=n.getClosedTorusIndicesForBooleanOrSubdiv():i=n.getIndex();let{positions:s,triIndices:o}=hu(n.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:c}=cT(s,o,n);a=c.length,r=[];for(let u=0,h=0;u<a;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[h++])}}else{let l=o.length;r=Array(l+l/3),a=0;for(let c=0,u=0;u<r.length;)r[u++]=3,a++,r[u++]=o[c++],r[u++]=o[c++],r[u++]=o[c++]}return{positions:s,faceIndices:r,nFaces:a}}function mL(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(n[0])?e:r,s=zt._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(zt.HEAPU32.buffer,s,t):new Float32Array(zt.HEAPF32.buffer,s,t)).set(n,0),s}function gL(n){switch(n){case 0:return zt.OP.UNION;case 1:return zt.OP.INTERSECTION;case 2:return zt.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+n)}}function NQ(n,t){tf===void 0&&(tf=zt.init_csg());let e=mL(n),r=zt.csg_calc_topological(tf,e,n.length,gL(t));zt._free(e);let i=6,s=zt.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=zt.HEAPU32[s[a]>>2],c=new Float32Array(zt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let u=zt.HEAPU32[s[a]>>2],h=new Uint32Array(zt.HEAPU32.subarray(u>>2,(u>>2)+o[a]));a++;let d=zt.HEAPU32[s[a]>>2],f=new Uint8Array(zt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return zt.free_mesh_data(r),{positions:c,indices:h,verticesPerFace:f}}function BQ(n,t,e,r){tf===void 0&&(tf=zt.init_csg());let i=mL(n),s=zt.csg_calc(tf,i,n.length,r,gL(t));zt._free(i);let o=5,a=zt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,u=zt.HEAPU32[a[c]>>2],h=zt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=zt.HEAPU32[a[c]>>2],f=zt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let m=l[c];e.setAttribute("position",new Te(h,3)),e.setAttribute("normal",new Te(f,3));let p=zt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ei),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},zt.free_mesh_data(s),m}function FQ(n,t,e){if(zt===void 0)return-1;let r,i,s;if(t&&n.userData.positions!==void 0){let y=n.userData;s=y.verticesPerFace.length,r=y.positions,i=Array(y.verticesPerFace.reduce((x,v)=>x+v,0)+s);for(let x=0,v=0,b=0;x<y.verticesPerFace.length;x++){i[b++]=y.verticesPerFace[x];for(let w=0;w<y.verticesPerFace[x];w++)i[b++]=y.indices[v++]}}else({positions:r,faceIndices:i,nFaces:s}=LQ(n,t,e));let o=r.length,a=i.length,l=r.length,c=i.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=zt._malloc(u),m=new Float32Array(zt.HEAPF32.buffer,f,l),p=new Uint32Array(zt.HEAPU32.buffer,f+h,c);m.set(r,0),p.set(i,0);let g=zt.get_csg_mesh(f,o,f+h,a,s);return zt._free(f),g}function VQ(n){return zt.has_open_edges(n)}function UQ(n,t){zt.transform_csg_mesh(n,t.elements)}function kQ(n){zt.free_csg_mesh(n)}var zQ={ConeGeometry:d3,CubeGeometry:f3,CylinderGeometry:Sx,DodecahedronGeometry:p3,EllipseGeometry:Kd,HelixGeometry:U3,IcosahedronGeometry:k3,LatheGeometry:z3,NonParametricGeometry:W3,PolygonGeometry:Ox,PyramidGeometry:q3,RectangleGeometry:Jd,SphereGeometry:X3,PlaneGeometry:Y3,BackdropGeometry:K3,StarGeometry:Rx,TextFrameGeometry:Q3,TorusGeometry:Z3,TorusKnotGeometry:J3,TriangleGeometry:$3,PathGeometry:iL,VectorGeometry:kn},sT=n=>zQ[n.type].create(n);function rf(n){return n!==null&&"booleanOp"in n}var nf=class extends zd(Mt){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ue}updateVisible(e){super.updateVisible(e),this.visible=!rf(this.parent)&&this.visible,rf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(_s.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof nf&&(e.freeBooleanPointer(),rf(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let i=super.updateTransformState(e,r);return i&&rf(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),rf(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var kx=new Yt;function Qm(n,t=0,e=n.count,r,i){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;for(let h=t;h<e;h++){let d=n.getX(h),f=n.getY(h),m=n.getZ(h);d<s&&(s=d),f<o&&(o=f),m<a&&(a=m),d>l&&(l=d),f>c&&(c=f),m>u&&(u=m)}kx.min.set(s,o,a),kx.max.set(l,c,u),kx.getCenter(r),kx.getSize(i).multiplyScalar(.5)}var GQ=new Ce,jQ=new un,nr=class extends nf{constructor(t,e){super(GQ,jQ),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Qm(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Ka=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Ka.uuidContext===null)throw new Error("plz startContext");Ka.uuidContext===Ka.globalContext?this.uuid="_gid"+Ka.uuidContext.nodeContextUuid++:this.uuid="_uid"+Ka.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Ka.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,r){e=e??this.getType(t,e);let i=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,i,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,i,s,o){return""}generate(t,e,r,i,s){return""}parse(t,e,r,i){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let i=t.getTypeLength(r);(i>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=i,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},pr=Ka;pr.globalContext={nodeContextUuid:0},pr.uuidContext=Ka.globalContext;var Zm=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var uT=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Bi=new uT;var rt=class extends pr{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,i,s){if(r=r??this.getType(e),this.getShared(e,r)){let o=this.getUnique(e,r);o&&this.uuid===void 0&&(this.uuid=Se.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,i)):super.build(e,r,i);if(o)return a.name=a.name||super.build(e,r,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,i);i=this.getUUID(!1);let c=this.getTemp(e,i);if(c)return e.format(c,l,r);{c=super.generate(e,r,i,a.output,s);let u=this.generate(e,l,i);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,i)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let i=e.getVars()[r];return i?i.name:void 0}generate(e,r,i,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var mr=class extends rt{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,i,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}};var Zr=class extends mr{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof U?e:new U(e,r)}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,r,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var Ji=class extends mr{constructor(e=0,r,i){super("v3");this.nodeType="Vector3";this.value=e instanceof E?e:new E(e,r,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,r,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var zn=class extends mr{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,r,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var HQ=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,yL=/[a-z_0-9]+/gi,Ae=class extends rt{constructor(e,r,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,r,i,s)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,i,s,o){let a,l=0,c=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 u=[];for(;a=yL.exec(this.src);)u.push(a);for(let h=0;h<u.length;h++){let d=u[h],f=d[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&Bi.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=Bi.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||Bi.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}p=g.build(e)}f!==p&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+p+c.substring(d.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&Bi.contains(p)&&e.include(Bi.get(p))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,i,s){if(this.src=e||"",this.includes=r??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=HQ.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(yL);if(a){let l=0;for(;l<a.length;){let c=a[l++],u;c==="in"||c==="out"||c==="inout"?u=a[l++]:(u=c,c="");let h=a[l++];this.inputs.push({name:h,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var WQ=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,hT=class extends rt{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||hT.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,i,s,o){this.src=e||"";let a,l,c="",u=WQ.exec(e);this.useDefine=o??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],a=u[2],c=u[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(e,r){if(r==="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),r)}generate(e,r,i,s,o){return e.format(this.name,this.getType(e),r)}},Ht=hT;Ht.PI="PI",Ht.PI2="PI2",Ht.RECIPROCAL_PI="RECIPROCAL_PI",Ht.RECIPROCAL_PI2="RECIPROCAL_PI2",Ht.LOG2="LOG2",Ht.EPSILON="EPSILON";var qQ=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3156
|
+
`&&s.push("")):t.getTextWidth(s[s.length-1]+o,n)>i&&(s[s.length-1].length&&s.push(""),t.getTextWidth(s[s.length-1]+o,n)>i&&(o.length===1?(s[s.length-1]+=o,o=""):(s[s.length-1]+=o.slice(0,-1),o=o[o.length-1],s.push(""))));return s[s.length-1]+=o,s}var oL,Bx=new Promise(n=>{oL=n}),sL=!1;var Nx;function aL(n){if(sL)return;if(Nx)return Nx;async function t(){let r=n??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.48/build"),s=import("./process.js"),[o,a]=await Promise.all([s,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=o.default,c=await l({wasmBinary:a});oL(c),sL=!0}return Nx=t(),Nx}var OQ=["font"];function Jo(n,t,e,r){let i,s,o;n.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(n)),o=[[],["extrusion"]]):(s={...n},o=[[]]);for(let c of o){let u=s;for(let h of c)u=u[h];for(i in u){let h=u[i];CA(h)&&!OQ.includes(i)&&(u[i]=t.getVariable(h,[r.uuid,"geometry",...c,i]),CA(u[i])&&(u[i]=1))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let c=$t.createFromState(s.shape,s.width,s.height);a.shape=c}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),a.geometry=new vh().parse(s),a.geometry.groups.length===0){let c=a.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(s.type==="SubdivGeometry"){let c=new ui(s,e);return c.data=n,c}else{if(s.type==="TextGeometry")return new uu(s,t);if(s.type==="InputGeometry")return new uu(s,t);if(s.type==="UIGeometry")return Jd.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=sT(a)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${a}`);let u=$t.createFromState(dd.defaultData(),100,100);a.shape=u,a.type="VectorGeometry",l=sT(a)}return l}var RQ=new ue;function Km(n,t,e,r){let i=n.position.array,s=n.normal.array,o=RQ.makeScale(t,e,r).invert().elements,a,l,c;for(var u=0,h=i.length;u<h;u+=3)i[u]*=t,i[u+1]*=e,i[u+2]*=r,a=s[u],l=s[u+1],c=s[u+2],s[u]=o[0]*a+o[4]*l+o[8]*c,s[u+1]=o[1]*a+o[5]*l+o[9]*c,s[u+2]=o[2]*a+o[6]*l+o[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Fx=new Yt,ef=new E,ht;Bx.then(n=>{ht=n});var lL=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),cL=new Uint32Array([0,1,2,3]),uL=new Uint8Array([4]),ui=class extends Ce{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let i=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),s=ws.div(r.map(l=>typeof l=="number"?l:0),i);if(s.every(l=>l===1))return;this.subdividedGeometry&&Km(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Km(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(ef.fromArray(s));let a=ef.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,i;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:i}=ui.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new bi(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ui.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ei,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;Fx.setFromBufferAttribute(r),Fx.getCenter(i),e.boundingSphere.radius=i.distanceTo(Fx.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Fx.getSize(ef);let s={width:ef.x,height:ef.y,depth:ef.z};return this.userData.parameters=s,s}static build(e,r,i,s){let o,a,l,c=e?.phongAngle??35;i===!1&&(c=-1),r&&(ht.free_bvh(r),ht.free_subdivision_surface(r));try{o=ui.allocate(e,s)}catch(u){console.error(u,e),o=ui.allocate({positionWASM:lL,indexWASM:cL,verticesPerFaceWASM:uL},s)}if(ht.set_destination_refinement_level(o,0),a=ui.buildLevel(o,!0,c),e.subdivisions>0)try{ht.set_destination_refinement_level(o,e.subdivisions),l=ui.buildLevel(o,!1,c)}catch{try{ht.set_destination_refinement_level(o,e.subdivisions-1),l=ui.buildLevel(o,!1,c)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,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 s=e.shape!==void 0||e.path!==void 0?r.geometry:Jo(e,i,!1,r),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,c,u;({positions:a,triIndices:u}=hu(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:c}=cT(a,u,s,h),{positions:a,indices:l,verticesPerFace:c}}static allocate(e,r){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=lL,s=cL,o=uL);let c=i.length,u=s.length,h=o.length,d=i.length+a.length+l.length,f=s.length+o.length,m=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=d*Float32Array.BYTES_PER_ELEMENT,g=ht._malloc(m),y=new Float32Array(ht.HEAPF32.buffer,g,d),x=new Uint32Array(ht.HEAPU32.buffer,g+p,f);y.set(i,0),y.set(a,i.length),y.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let v;e?.scaleBaked?.some(w=>w!==1)&&(v=new ue().makeScale(...e.scaleBaked.map(w=>typeof w=="number"?w:1))),r&&(v?v.premultiply(r):v=r);let b=v?ht.alloc_subdivision_surface2(g,c,g+p,u,g+p+s.length*Uint32Array.BYTES_PER_ELEMENT,h,v.elements):ht.alloc_subdivision_surface(g,c,g+p,u,g+p+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return ht._free(g),b}static buildLevel(e,r,i,s,o){let a=o?ht.get_mesh_data2(e,r?ht.Level.CONTROL:ht.Level.REFINED,i,o.elements):ht.get_mesh_data(e,r?ht.Level.CONTROL:ht.Level.REFINED,i),l=8,c=ht.HEAPU32.subarray(a>>2,(a>>2)+l),u=c.subarray(4,4+4),h=0,d=ht.HEAPU32[c[h]>>2],f=ht.HEAPF32.subarray(d>>2,(d>>2)+u[h]);h++;let m=ht.HEAPU32[c[h]>>2],p=ht.HEAPF32.subarray(m>>2,(m>>2)+u[h]);h++;let g=ht.HEAPU32[c[h]>>2],y=ht.HEAPU32.subarray(g>>2,(g>>2)+u[h]);h++;let x=ht.HEAPU32[c[h]>>2],v=ht.HEAPU32.subarray(x>>2,(x>>2)+u[h]);if(h++,s===void 0){let b=new Ce;if(b.setIndex(new To(v,1)),b.setAttribute("position",new Te(f,3)),b.setAttribute("normal",new Te(p,3)),r){b.setAttribute("faceMap",new To(y,1));let w=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new je(w,4))}return ht.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,ht.free_mesh_data(a)}static freeSubdivPointer(e){ht.free_bvh(e),ht.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let s=ht.get_wireframe_data_for_base_level(e),o=4,a=ht.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),c=0,u=ht.HEAPU32[a[c]>>2],h=ht.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=ht.HEAPU32[a[c]>>2],f=ht.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let m=new Ce;m.setAttribute("position",new Te(h,3));let p=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)p[g++]=i.r,p[g++]=i.g,p[g++]=i.b;return m.setAttribute("color",new je(p,3)),m.setIndex(new To(f,1)),ht.free_wireframe_data_for_base_level(s),m}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,ht.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,i){let s=r===0;s||ht.set_destination_refinement_level(e,r);let o=i?ht.get_topological_data2(e,s?ht.Level.CONTROL:ht.Level.REFINED,i.elements):ht.get_topological_data(e,s?ht.Level.CONTROL:ht.Level.REFINED),a=6,l=ht.HEAPU32.subarray(o>>2,(o>>2)+a),c=l.subarray(3,3+3),u=0,h=ht.HEAPU32[l[u]>>2],d=new Float32Array(ht.HEAPF32.subarray(h>>2,(h>>2)+c[u]));u++;let f=ht.HEAPU32[l[u]>>2],m=new Uint32Array(ht.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let p=ht.HEAPU32[l[u]>>2],g=new Uint8Array(ht.HEAPU32.subarray(p>>2,(p>>2)+c[u]));return ht.free_topological_data(o),{positions:d,indices:m,verticesPerFace:g}}};var hL=["getX","getY","getZ"];function hu(n,t){let e={},r=t?t.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,h="";for(let d=0;d<3;d++)h+=`${~~(n[hL[d]](u)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(n[hL[d]](u));e[h]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var Vx=new E,oT=new E,aT=new E,lT=new E;function cT(n,t,e,r){let i=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,m)=>Math.floor(m/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]);n.length=0;let h=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),i.push(h++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),i.push(h++);return s.push(h),{indices:i,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[a]*3+2]===o||n[t[a]*3+2]===0)&&l++,(n[t[a+1]*3+2]===o||n[t[a+1]*3+2]===0)&&l++,(n[t[a+2]*3+2]===o||n[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Vx.set(n[t[a]*3],n[t[a]*3+1],n[t[a]*3+2]),oT.set(n[t[a+1]*3],n[t[a+1]*3+1],n[t[a+1]*3+2]),aT.set(n[t[a+4]*3],n[t[a+4]*3+1],n[t[a+4]*3+2]),lT.set(n[t[a+5]*3],n[t[a+5]*3+1],n[t[a+5]*3+2]),oT.sub(Vx).normalize(),aT.sub(Vx).normalize(),lT.sub(Vx).normalize();let l=oT.cross(aT).dot(lT),c=a;Math.abs(l)>.005||r&&r.some((u,h)=>h%2===1?!1:c>=r[h]&&c<r[h+1])?(i.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(i.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else i.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let h=0,d=0;h<n.length;h+=3,d++)n[h+2]===0&&(l.push(d),u++),n[h+2]===o&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=c[0];c[0]=c[1],c[1]=h}l.reverse(),i.push(...l,...c),s.push(u,u)}return{indices:i,verticesPerFace:s}}var _s={};IC(_s,{calcBoolean:()=>BQ,calcBooleanTopological:()=>NQ,freeMeshSet:()=>kQ,getMeshSet:()=>FQ,hasOpenEdges:()=>VQ,transformMeshSet:()=>UQ});var dL,fL=new Promise(n=>{dL=n});var Ux;function pL(n){if(Ux)return Ux;async function t(){let r=n??(!1?".":"https://unpkg.com/@splinetool/boolean-wasm@1.12.48/build"),s=import("./boolean.js"),[o,a]=await Promise.all([s,fetch(`${r}/boolean.wasm`).then(u=>u.arrayBuffer())]),l=o.default,c=await l({wasmBinary:a});dL(c)}return Ux=t(),Ux}var zt,tf;fL.then(n=>zt=n);function LQ(n,t,e){let r,i;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?i=n.getClosedTorusIndicesForBooleanOrSubdiv():i=n.getIndex();let{positions:s,triIndices:o}=hu(n.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:c}=cT(s,o,n);a=c.length,r=[];for(let u=0,h=0;u<a;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[h++])}}else{let l=o.length;r=Array(l+l/3),a=0;for(let c=0,u=0;u<r.length;)r[u++]=3,a++,r[u++]=o[c++],r[u++]=o[c++],r[u++]=o[c++]}return{positions:s,faceIndices:r,nFaces:a}}function mL(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(n[0])?e:r,s=zt._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(zt.HEAPU32.buffer,s,t):new Float32Array(zt.HEAPF32.buffer,s,t)).set(n,0),s}function gL(n){switch(n){case 0:return zt.OP.UNION;case 1:return zt.OP.INTERSECTION;case 2:return zt.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+n)}}function NQ(n,t){tf===void 0&&(tf=zt.init_csg());let e=mL(n),r=zt.csg_calc_topological(tf,e,n.length,gL(t));zt._free(e);let i=6,s=zt.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=zt.HEAPU32[s[a]>>2],c=new Float32Array(zt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let u=zt.HEAPU32[s[a]>>2],h=new Uint32Array(zt.HEAPU32.subarray(u>>2,(u>>2)+o[a]));a++;let d=zt.HEAPU32[s[a]>>2],f=new Uint8Array(zt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return zt.free_mesh_data(r),{positions:c,indices:h,verticesPerFace:f}}function BQ(n,t,e,r){tf===void 0&&(tf=zt.init_csg());let i=mL(n),s=zt.csg_calc(tf,i,n.length,r,gL(t));zt._free(i);let o=5,a=zt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,u=zt.HEAPU32[a[c]>>2],h=zt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=zt.HEAPU32[a[c]>>2],f=zt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let m=l[c];e.setAttribute("position",new Te(h,3)),e.setAttribute("normal",new Te(f,3));let p=zt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ei),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},zt.free_mesh_data(s),m}function FQ(n,t,e){if(zt===void 0)return-1;let r,i,s;if(t&&n.userData.positions!==void 0){let y=n.userData;s=y.verticesPerFace.length,r=y.positions,i=Array(y.verticesPerFace.reduce((x,v)=>x+v,0)+s);for(let x=0,v=0,b=0;x<y.verticesPerFace.length;x++){i[b++]=y.verticesPerFace[x];for(let w=0;w<y.verticesPerFace[x];w++)i[b++]=y.indices[v++]}}else({positions:r,faceIndices:i,nFaces:s}=LQ(n,t,e));let o=r.length,a=i.length,l=r.length,c=i.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=zt._malloc(u),m=new Float32Array(zt.HEAPF32.buffer,f,l),p=new Uint32Array(zt.HEAPU32.buffer,f+h,c);m.set(r,0),p.set(i,0);let g=zt.get_csg_mesh(f,o,f+h,a,s);return zt._free(f),g}function VQ(n){return zt.has_open_edges(n)}function UQ(n,t){zt.transform_csg_mesh(n,t.elements)}function kQ(n){zt.free_csg_mesh(n)}var zQ={ConeGeometry:d3,CubeGeometry:f3,CylinderGeometry:Sx,DodecahedronGeometry:p3,EllipseGeometry:Kd,HelixGeometry:U3,IcosahedronGeometry:k3,LatheGeometry:z3,NonParametricGeometry:W3,PolygonGeometry:Ox,PyramidGeometry:q3,RectangleGeometry:Jd,SphereGeometry:X3,PlaneGeometry:Y3,BackdropGeometry:K3,StarGeometry:Rx,TextFrameGeometry:Q3,TorusGeometry:Z3,TorusKnotGeometry:J3,TriangleGeometry:$3,PathGeometry:iL,VectorGeometry:kn},sT=n=>zQ[n.type].create(n);function rf(n){return n!==null&&"booleanOp"in n}var nf=class extends zd(Mt){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ue}updateVisible(e){super.updateVisible(e),this.visible=!rf(this.parent)&&this.visible,rf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(_s.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof nf&&(e.freeBooleanPointer(),rf(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let i=super.updateTransformState(e,r);return i&&rf(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),rf(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var kx=new Yt;function Qm(n,t=0,e=n.count,r,i){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;for(let h=t;h<e;h++){let d=n.getX(h),f=n.getY(h),m=n.getZ(h);d<s&&(s=d),f<o&&(o=f),m<a&&(a=m),d>l&&(l=d),f>c&&(c=f),m>u&&(u=m)}kx.min.set(s,o,a),kx.max.set(l,c,u),kx.getCenter(r),kx.getSize(i).multiplyScalar(.5)}var GQ=new Ce,jQ=new un,nr=class extends nf{constructor(t,e){super(GQ,jQ),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Qm(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Ka=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Ka.uuidContext===null)throw new Error("plz startContext");Ka.uuidContext===Ka.globalContext?this.uuid="_gid"+Ka.uuidContext.nodeContextUuid++:this.uuid="_uid"+Ka.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Ka.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,r){e=e??this.getType(t,e);let i=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,i,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,i,s,o){return""}generate(t,e,r,i,s){return""}parse(t,e,r,i){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let i=t.getTypeLength(r);(i>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=i,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},pr=Ka;pr.globalContext={nodeContextUuid:0},pr.uuidContext=Ka.globalContext;var Zm=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var uT=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Bi=new uT;var rt=class extends pr{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,i,s){if(r=r??this.getType(e),this.getShared(e,r)){let o=this.getUnique(e,r);o&&this.uuid===void 0&&(this.uuid=Se.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,i)):super.build(e,r,i);if(o)return a.name=a.name||super.build(e,r,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,i);i=this.getUUID(!1);let c=this.getTemp(e,i);if(c)return e.format(c,l,r);{c=super.generate(e,r,i,a.output,s);let u=this.generate(e,l,i);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,i)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let i=e.getVars()[r];return i?i.name:void 0}generate(e,r,i,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var mr=class extends rt{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,i,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}};var Zr=class extends mr{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof U?e:new U(e,r)}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,r,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var Ji=class extends mr{constructor(e=0,r,i){super("v3");this.nodeType="Vector3";this.value=e instanceof E?e:new E(e,r,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,r,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var zn=class extends mr{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,r,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var HQ=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,yL=/[a-z_0-9]+/gi,Ae=class extends rt{constructor(e,r,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,r,i,s)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,i,s,o){let a,l=0,c=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 u=[];for(;a=yL.exec(this.src);)u.push(a);for(let h=0;h<u.length;h++){let d=u[h],f=d[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&Bi.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=Bi.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||Bi.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}p=g.build(e)}f!==p&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+p+c.substring(d.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&Bi.contains(p)&&e.include(Bi.get(p))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,i,s){if(this.src=e||"",this.includes=r??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=HQ.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(yL);if(a){let l=0;for(;l<a.length;){let c=a[l++],u;c==="in"||c==="out"||c==="inout"?u=a[l++]:(u=c,c="");let h=a[l++];this.inputs.push({name:h,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var WQ=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,hT=class extends rt{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||hT.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,i,s,o){this.src=e||"";let a,l,c="",u=WQ.exec(e);this.useDefine=o??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],a=u[2],c=u[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(e,r){if(r==="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),r)}generate(e,r,i,s,o){return e.format(this.name,this.getType(e),r)}},Ht=hT;Ht.PI="PI",Ht.PI2="PI2",Ht.RECIPROCAL_PI="RECIPROCAL_PI",Ht.RECIPROCAL_PI2="RECIPROCAL_PI2",Ht.LOG2="LOG2",Ht.EPSILON="EPSILON";var qQ=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3157
3157
|
)*?)}`,"gim"),XQ=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),sf=class extends rt{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,i,s,o){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=qQ.exec(e);if(r){let i=r[2],s;for(;s=XQ.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var of=class extends rt{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(s,this.getType(e),r)}};Bi.addKeyword("uv",function(){return new of});Bi.addKeyword("uv2",function(){return new of(1)});var du=class extends rt{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??du.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case xn:return["Linear"];case ut:return["sRGB"];default:return[]}}generate(e,r){let i=this.input.build(e,"v4"),s=this.getType(e),o=du.Nodes[this.method],a=e.include(o);if(a===du.LINEAR_TO_LINEAR)return e.format(i,s,r);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+i+", "+l+" )",s,r)}else return e.format(a+"( "+i+" )",s,r)}fromEncoding(e){let r=du.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=du.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Tn=du;Tn.Nodes={LinearToLinear:new Ae(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3158
3158
|
`)),sRGBToLinear:new Ae(["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(`
|
|
3159
3159
|
`)),LinearTosRGB:new Ae(["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(`
|
|
@@ -5011,7 +5011,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
5011
5011
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
5012
5012
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
5013
5013
|
return displaced_position;
|
|
5014
|
-
}`,[e,r])}}();var Je={normalRenderTarget:new Mn,normalRenderTargetDepth:new Mn,transmissionRenderTarget:new Mn,aspectRatio:new Zr,transmissionSize:new Zr(2048,2048),transmissionRenderTargetDepth:new Mn,aoRenderTarget:new Mn,aoEnabled:new Jr,pixelRatioNode:new Ve(1),resolution:new Zr,penumbraSize:new so(5,.5),frameIndex:new Bt(0),transmissionLod:new Bt(2),taaEnabled:new Jr(!0)};for(let n of Object.values(Je))n.isRenderGlobal=!0;var Wx={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.
|
|
5014
|
+
}`,[e,r])}}();var Je={normalRenderTarget:new Mn,normalRenderTargetDepth:new Mn,transmissionRenderTarget:new Mn,aspectRatio:new Zr,transmissionSize:new Zr(2048,2048),transmissionRenderTargetDepth:new Mn,aoRenderTarget:new Mn,aoEnabled:new Jr,pixelRatioNode:new Ve(1),resolution:new Zr,penumbraSize:new so(5,.5),frameIndex:new Bt(0),transmissionLod:new Bt(2),taaEnabled:new Jr(!0)};for(let n of Object.values(Je))n.isRenderGlobal=!0;var Wx={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.48/build/ui.wasm"};var Qa=class extends pr{constructor(){super("basic");this.nodeType="Basic";this.color=new ur(ai),this.shadingAlpha=new Ve(1),this.shadingBlend=new Bt(0),this.previousModelViewMatrix=new $i,this.previouseProjectionMatrix=new $i}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Je.frameIndex}),e.mergeUniform({resolution:Je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Xs.merge([Ie.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
|
|
5015
5015
|
`));let s=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
|
|
5016
5016
|
#include <skinbase_vertex>
|
|
5017
5017
|
#include <skinnormal_vertex>
|
|
@@ -8103,7 +8103,7 @@ void main() {
|
|
|
8103
8103
|
gVelocity = vec4(0.0); // so it is ignored by TAA
|
|
8104
8104
|
}`,s={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new U},viewport:{type:"v2",value:new U},basisViewport:{type:"v2",value:new U},debugColor:{type:"v3",value:new Ge},covariancesTextureSize:{type:"v2",value:new U(1024,1024)},centersColorsTextureSize:{type:"v2",value:new U(1024,1024)},orthoZoom:{type:"f",value:-1}};return new $e({uniforms:s,vertexShader:r,fragmentShader:i,transparent:!0,alphaTest:1,blending:ml,depthTest:!0,depthWrite:!1,side:vi})}static buildGeomtery(e){let r=new Ce;r.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),s=new je(i,3);r.setAttribute("position",s),s.setXYZ(0,-1,-1,0),s.setXYZ(1,-1,1,0),s.setXYZ(2,1,1,0),s.setXYZ(3,1,-1,0),s.needsUpdate=!0;let o=new Qp().copy(r),a=new Uint32Array(e),l=new Mo(a,1,!1);return l.setUsage(p_),o.setAttribute("splatIndex",l),o.instanceCount=e,o}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(s=>s.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,r=0,i=0;for(let s of this.splatBuffers){let o=s.nsplats;this.colors.subarray(e,e+o*4).set(s.colorsA),e+=o*4,this.centers.subarray(r,r+o*3).set(s.decoded.xyz.denormDequant().data),r+=o*3,this.covariances.subarray(i,i+o*6).set(new Float32Array(s.precomputedCovarianceBufferData)),i+=o*6}}allocateAndStoreLocalSplatDataInTextures(){let i=this.splatCount,s=new U(4096,1024);for(;s.x*s.y*2<i*6;)s.y*=2;let o=new U(4096,1024);for(;o.x*o.y*4<i*4;)o.y*=2;let a,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(s.x*s.y*2);for(let m=0;m<this.covariances.length;m++)l[m]=__.toHalfFloat(this.covariances[m]);a=new Ur(l,s.x,s.y,Sh,$n)}else l=new Float32Array(s.x*s.y*2),l.set(this.covariances),a=new Ur(l,s.x,s.y,Sh,Ut);a.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=a,this.material.uniforms.covariancesTextureSize.value.copy(s);let c=new Uint32Array(o.x*o.y*4);for(let m=0;m<i;m++){let p=m*4,g=m*3,y=m*4;c[y]=gF(this.colors[p],this.colors[p+1],this.colors[p+2],this.colors[p+3]),c[y+1]=s1(this.centers[g]),c[y+2]=s1(this.centers[g+1]),c[y+3]=s1(this.centers[g+2])}let u=new Ur(c,o.x,o.y,Cw,Gs);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(o);let h=256*4,d=new Float32Array(256*16);for(let m=0;m<this.meshMatrixWorlds.length;m++)d.set(this.meshMatrixWorlds[m].elements,m*16);let f=new Ur(d,h,1,br,Ut);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:a,size:s},centerColors:{data:c,texture:u,size:o},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,i,s){this.splatCount>0&&(o1.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(o1),this.material.uniforms.basisViewport.value.set(2/o1.x,2/o1.y),this.material.uniforms.focal.value.set(r,i),this.material.uniforms.orthoZoom.value=s,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()),this.removeFromParent()}};var vF,PM=new Promise(n=>{vF=n}),yF=!1;var l1;function _M(){if(yF)return;if(l1)return l1;async function n(){let e=await import("./gaussian-splat-compression.js");vF(e),yF=!0}return l1=n(),l1}var xF;PM.then(n=>xF=n);var Tg=class{constructor(t={}){Pc(this,"updateView",function(){let t=new ue,e=[],r=new E(0,0,-1),i=new E(0,0,-1),s=new E,o=new E;return function(a=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!a){i.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(i.dot(r)<=.95&&(d=!0),o.copy(l.position).sub(s).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,s.copy(l.position),r.copy(i),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let h={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=h:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(h))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new ue().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new U;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new E().fromArray(t.position)),t.orientation&&(t.orientation=new Ye().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(o=>{o.data.type==="Splat"&&e.push(o)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(o=>o.matrixWorld),this.meshMatrixWorldsOld=e.map(o=>o.matrixWorld.clone()),this.cropsArray=e.map(o=>o.data.crops.map(a=>a.data));let r=e.map(o=>new xF.GSplineBuffer(new Uint8Array(o.data.buffer).buffer)),i=0,s=[0];for(let o of r)i+=o.getSplatCount(),s.push(i);return this.setupSplatMesh(r,i,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(i),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((i,s)=>{this.cropsArray[r][s]===void 0?(t=!0,this.cropsArray[r][s]=i.data):Object.entries(i.data).forEach(([o,a])=>{Array.isArray(a)&&a.some((l,c)=>l!==this.cropsArray[r][s][o][c])?(t=!0,this.cropsArray[r][s][o]=a):a!==this.cropsArray[r][s]?.[o]&&(t=!0,this.cropsArray[r][s][o]=a)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new E,i=new Ye,s=!1,o=1,a,l){this.splatMesh=Sc.buildMesh(t,e,s,o,a,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(i),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,h)=>this.update(c,h)}setupSortWorker(t){this.sortWorker=mF(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var Bb=new un;Bb.wireframe=!0;var bF=new E,fc=class extends Er{constructor(e,r){super();this.data=e;this.sharedAssets=r;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.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new n1;this.invisibleObjects=new Ns("jflkdsafjasdifjaslk",{...H0.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new yr("fdasfa",{...Fa.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=fF(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=dF(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),i=this.entityIdentityToEntity[r];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof yr&&(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 r=this.find(e);if(r===void 0)return;let i=[],s=r;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);i.splice(0,0,a)}return{entity:r,sortKey:i}}getAllSorted(e){let r=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&r.push(s)}return r.sort((i,s)=>Xv(i.sortKey,s.sortKey)),r.map(i=>i.entity)}nonExistOrDescendantOf(e,r){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===r)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===As)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof yr&&r.uiScene){let i=r.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof yr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(i=>{r===void 0&&i instanceof _r&&(r=i.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof yr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.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(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){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 s=this.createObject(e.id,e.data,e.children,i,e.localIndex,r);s.updateVisible(this),s.resetBBoxNeedsUpdate(),Wn(s)&&Dn(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty(),s.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");i.traverseEntity(o=>{o instanceof cs&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(a=>a!==o))}),this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Dn(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Wn(i)&&(i.freeBooleanPointer(),s instanceof Hn&&s.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof qo&&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 s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(i),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Wn(i)&&(i.invalidateUpstreamBooleanData(),Dn(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Hn&&s.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 r of this.children)r instanceof yr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,i,s){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:a}=r.props;r={...r,props:a},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let o=this.find(e);if(o)try{oF(o,r,i,{scene:this,shared:s}),o instanceof Ct&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}updateEntity2DByOp(e,r,i,s,o,a=[]){e.updateEntityByOp(r,i,s,o),this.traverseEntity(l=>{(l instanceof _r||l instanceof yr)&&(a.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,i,s,o)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let i=Object.entries(r.data.lib.components).map((s,o)=>({data:s[1].asset.data,children:s[1].asset.children,id:s[0],fi:o}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(s=>{s instanceof ir&&s.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){gt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{gt.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,i,s,o,a,l){if(e){let c=s.find(e);c&&c!==s&&o.forInstancesRec(u=>{u.data=Fl(u.data,h=>{let d=h.events.data(l.id),f=u.goUp(a);if(f){let m=[...qv(f.identity),e].join("-"),p=this.entityIdentityToEntity[m];if(p){let g=p.uuid,y=Mr.zoom(d,r);y[i]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,i,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",i,s,o,a):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",i,s,o,a):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],i,s,o,a),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],i,s,o,a))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ho&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,i)=>{r.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(r.forInstancesRec(a=>{a.data=Fl(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of xd.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,r,i,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,r,i,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,r,i,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,r,i,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,i,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,i,s)),this.rewriteActions(s.data.inActions,["inActions"],e,r,i,s),this.rewriteActions(s.data.outActions,["outActions"],e,r,i,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,r,i,s)})}),!0})}expandInstances(e,r,i){let s=new Set;this.traverseEntity(o=>{if(o instanceof ho&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),r||o.resetBBoxNeedsUpdate(),i&&o.traverseEntity(a=>{i.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),Yb(o)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof ho&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let i=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[i]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[i]),r.dispose()})}clearScene(){for(let e of this.children)gt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let i=[],s=o=>{for(let a of o.children){let l=a.cloner;if(gt.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(r===!0&&a.isInstanceRoot){let c=[];if(e.intersectObject(a,!0,c),c.length){let u=c[0];u.object=a,u.point.applyMatrix4(u.object.matrixWorld);let h=a.matrixWorld.clone().invert();u.point.applyMatrix4(h),i.push(u)}}else(Wn(a)||pg(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),Ag(a,e,i)),s(a)}};return s(this.activePage),i}raycastWithClones(e){let r=[],i=s=>{for(let o of s.children){let a=o.cloner;gt.is(o)&&(o.visible||a?.object.data.visible)&&((Wn(o)||pg(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),Ag(o,e,r,!0)),i(o))}};return i(this),r}forEachEntity(e){for(let r of this.children)gt.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)gt.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)gt.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(i=>{if(i instanceof Ct&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===e){let s=i.geometry,o=i.data.geometry;s.updateFont(e,r).then(()=>{s.update(o,r);let a=i.invalidateDownstreamBooleanData();Dn(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Xa.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)gt.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,i){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,r,s,i),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,i,s,o,a){let l={scene:this,shared:a},c=t1(e,r,l);return c instanceof cs&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,s.add(c),s.children.splice(o,0,s.children.pop()),i.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,c,a)),c.updateState(r,l),c instanceof Ct&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let h=u.dataPatched;if(u instanceof Ct&&h.bones&&h.boneInverses){let d=h.bones.map(p=>this.find(p)),f=h.boneInverses.map(p=>new ue().fromArray(p)),m=new Sl(d,f);u.bind(m,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let s=0,o=e.length;s<o;++s){let{id:a,recursive:l}=e[s],c=this.find(a),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let i=new Yt;return i.setFromPoints(r),i.getCenter(bF),bF}copyMatrixWorld(e,r){if(e===null){r.identity();return}let i=this.find(e);i?r.copy(i.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let i=this.find(e)?.parent;i?r.copy(i.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof nr)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)r.material[i]instanceof fn&&e(r.material[i]);else r.material instanceof fn&&e(r.material)})}updateViewPlaneSize(e,r,i=!1){this.traverseConcreteEntity(s=>{s instanceof ir&&s.setViewplaneSize(e,r,i)})}initializeSplatViewer(){this.splatViewer=new Tg({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var Mg=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},SF=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return _ee(Math.atan2(r,e))},wF=(n,t,e)=>{let r={x:0,y:0};return e=c1(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},c1=n=>n*(Math.PI/180),_ee=n=>n*(180/Math.PI),AF=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,IM=new Map,DM=n=>{IM.has(n)&&clearTimeout(IM.get(n)),IM.set(n,setTimeout(n,100))},tp=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let s=0;s<r.length;s+=1)i=r[s],n.addEventListener?n.addEventListener(i,e,!1):n.attachEvent&&n.attachEvent(i,e)},OM=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let s=0;s<r.length;s+=1)i=r[s],n.removeEventListener?n.removeEventListener(i,e):n.detachEvent&&n.detachEvent(i,e)};var u1=n=>(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),RM=()=>{if(typeof window>"u")return;let n=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:n,y:t}},h1=(n,t)=>{t.top||t.right||t.bottom||t.left?(n.style.top=t.top,n.style.right=t.right,n.style.bottom=t.bottom,n.style.left=t.left):(n.style.left=t.x+"px",n.style.top=t.y+"px")},d1=(n,t,e)=>{let r=TF(n);for(let i in r)if(r.hasOwnProperty(i))if(typeof t=="string")r[i]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";r[i]=s.slice(0,-2)}return r},EF=(n,t)=>{let e=TF(n);for(let r in e)e.hasOwnProperty(r)&&(e[r]=t);return e},TF=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},f1=(n,t)=>{for(let e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n},MF=(n,t)=>{let e={};for(let r in n)n.hasOwnProperty(r)&&t.hasOwnProperty(r)?e[r]=t[r]:n.hasOwnProperty(r)&&(e[r]=n[r]);return e},Cg=(n,t)=>{if(n.length)for(let e=0,r=n.length;e<r;e+=1)t(n[e]);else t(n)},CF=(n,t,e)=>({x:Math.min(Math.max(n.x,t.x-e),t.x+e),y:Math.min(Math.max(n.y,t.y-e),t.y+e)});typeof window<"u"&&(PF="ontouchstart"in window,_F=!!window.PointerEvent,IF=!!window.MSPointerEvent);var PF,_F,IF,Pg={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"}},rp,_g={};_F?rp=Pg.pointer:IF?rp=Pg.MSPointer:PF?(rp=Pg.touch,_g=Pg.mouse):rp=Pg.mouse;function Cu(){}Cu.prototype.on=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)i=r[s],e._handlers_[i]=e._handlers_[i]||[],e._handlers_[i].push(t);return e};Cu.prototype.off=function(n,t){var e=this;return e._handlers_=e._handlers_||{},n===void 0?e._handlers_={}:t===void 0?e._handlers_[n]=null:e._handlers_[n]&&e._handlers_[n].indexOf(t)>=0&&e._handlers_[n].splice(e._handlers_[n].indexOf(t),1),e};Cu.prototype.trigger=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)i=r[s],e._handlers_[i]&&e._handlers_[i].length&&e._handlers_[i].forEach(function(o){o.call(e,{type:i,target:e},t)})};Cu.prototype.config=function(n){var t=this;t.options=t.defaults||{},n&&(t.options=MF(t.options,n))};Cu.prototype.bindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},tp(n,rp[t],e._domHandlers_[t]),_g[t]&&tp(n,_g[t],e._domHandlers_[t]),e};Cu.prototype.unbindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},OM(n,rp[t],e._domHandlers_[t]),_g[t]&&OM(n,_g[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var ip=Cu;function Fi(n,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=n,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=Fi.id,Fi.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}Fi.prototype=new ip;Fi.constructor=Fi;Fi.id=0;Fi.prototype.buildEl=function(n){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)};Fi.prototype.stylize=function(){if(this.options.dataOnly)return this;var n=this.options.fadeTime+"ms",t=EF("borderRadius","50%"),e=d1("transition","opacity",n),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)"},f1(r.el,e),this.options.shape==="circle"&&f1(r.back,t),f1(r.front,t),this.applyStyles(r),this};Fi.prototype.applyStyles=function(n){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in n[t])this.ui[t].style[e]=n[t][e];return this};Fi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Fi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Fi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Fi.prototype.show=function(n){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 n=="function"&&n.call(this)},t.options.fadeTime)),t};Fi.prototype.hide=function(n){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 e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof n=="function"&&n.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(n,r)}return t};Fi.prototype.setPosition=function(n,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",i={};i.front=d1("transition",["top","left"],r);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(i),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof n=="function"&&n.call(e),e.restCallback()},e.options.fadeTime)};Fi.prototype.restCallback=function(){var n=this,t={};t.front=d1("transition","none",""),n.applyStyles(t),n.trigger("rested",n.instance)};Fi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Fi.prototype.computeDirection=function(n){var t=n.angle.radian,e=Math.PI/4,r=Math.PI/2,i,s,o;if(t>e&&t<e*3&&!n.lockX?i="up":t>-e&&t<=e&&!n.lockY?i="left":t>-e*3&&t<=-e&&!n.lockX?i="down":n.lockY||(i="right"),n.lockY||(t>-r&&t<r?s="left":s="right"),n.lockX||(t>0?o="up":o="down"),n.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var c={};this.direction={x:s,y:o,angle:i},n.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return n;(!c.x||!c.y)&&this.trigger("plain",n),c.x||this.trigger("plain:"+s,n),c.y||this.trigger("plain:"+o,n),c.angle||this.trigger("dir dir:"+i,n)}else this.resetDirection();return n};var DF=Fi;function di(n,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=n,e.id=di.id,di.id+=1,e.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},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}di.prototype=new ip;di.constructor=di;di.id=0;di.prototype.prepareNipples=function(){var n=this,t=n.nipples;t.on=n.on.bind(n),t.off=n.off.bind(n),t.options=n.options,t.destroy=n.destroy.bind(n),t.ids=n.ids,t.id=n.id,t.processOnMove=n.processOnMove.bind(n),t.processOnEnd=n.processOnEnd.bind(n),t.get=function(e){if(e===void 0)return t[0];for(var r=0,i=t.length;r<i;r+=1)if(t[r].identifier===e)return t[r];return!1}};di.prototype.bindings=function(){var n=this;n.bindEvt(n.options.zone,"start"),n.options.zone.style.touchAction="none",n.options.zone.style.msTouchAction="none"};di.prototype.begin=function(){var n=this,t=n.options;if(t.mode==="static"){var e=n.createNipple(t.position,n.manager.getIdentifier());e.add(),n.idles.push(e)}};di.prototype.createNipple=function(n,t){var e=this,r=e.manager.scroll,i={},s=e.options,o={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(n.x&&n.y)i={x:n.x-o.x,y:n.y-o.y};else if(n.top||n.right||n.bottom||n.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=n.top,a.style.right=n.right,a.style.bottom=n.bottom,a.style.left=n.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),i=n,n={x:l.left+r.x,y:l.top+r.y}}var c=new DF(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:n,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(h1(c.ui.el,i),h1(c.ui.front,c.frontPosition)),e.nipples.push(c),e.trigger("added "+c.identifier+":added",c),e.manager.trigger("added "+c.identifier+":added",c),e.bindNipple(c),c};di.prototype.updateBox=function(){var n=this;n.box=n.options.zone.getBoundingClientRect()};di.prototype.bindNipple=function(n){var t=this,e,r=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};di.prototype.pressureFn=function(n,t,e){var r=this,i=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var s=n.force||n.pressure||n.webkitForce||0;s!==i&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),i=s)}.bind(r),100)};di.prototype.onstart=function(n){var t=this,e=t.options,r=n;n=u1(n),t.updateBox();var i=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(r.touches).findIndex(function(l){return l.identifier===o})<0){var a=[n[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return Cg(n,i),t.manager.bindDocument(),!1};di.prototype.processOnStart=function(n){var t=this,e=t.options,r,i=t.manager.getIdentifier(n),s=n.force||n.pressure||n.webkitForce||0,o={x:n.pageX,y:n.pageY},a=t.getOrCreate(i,o);a.identifier!==i&&t.manager.removeIdentifier(a.identifier),a.identifier=i;var l=function(u){u.trigger("start",u),t.trigger("start "+u.id+":start",u),u.show(),s>0&&t.pressureFn(n,u,u.identifier),t.processOnMove(n)};if((r=t.idles.indexOf(a))>=0&&t.idles.splice(r,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var c=Mg(o,a.position);if(c<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(n);return}}return a};di.prototype.getOrCreate=function(n,t){var e=this,r=e.options,i;return/(semi|static)/.test(r.mode)?(i=e.idles[0],i?(e.idles.splice(0,1),i):r.mode==="semi"?e.createNipple(t,n):(console.warn("Coudln't find the needed nipple."),!1)):(i=e.createNipple(t,n),i)};di.prototype.processOnMove=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),s=t.manager.scroll;if(!AF(n)){this.processOnEnd(n);return}if(!i){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var o=i.el.getBoundingClientRect();i.position={x:s.x+o.left,y:s.y+o.top}}i.identifier=r;var a=i.options.size/2,l={x:n.pageX,y:n.pageY};e.lockX&&(l.y=i.position.y),e.lockY&&(l.x=i.position.x);var c=Mg(l,i.position),u=SF(l,i.position),h=c1(u),d=c/a,f={distance:c,position:l},m,p;if(i.options.shape==="circle"?(m=Math.min(c,a),p=wF(i.position,m,u)):(p=CF(l,i.position,a),m=Mg(p,i.position)),e.follow){if(c>a){let v=l.x-p.x,b=l.y-p.y;i.position.x+=v,i.position.y+=b,i.el.style.top=i.position.y-(t.box.top+s.y)+"px",i.el.style.left=i.position.x-(t.box.left+s.x)+"px",c=Mg(l,i.position)}}else l=p,c=m;var g=l.x-i.position.x,y=l.y-i.position.y;i.frontPosition={x:g,y},e.dataOnly||h1(i.ui.front,i.frontPosition);var x={identifier:i.identifier,position:l,force:d,pressure:n.force||n.pressure||n.webkitForce||0,distance:c,angle:{radian:h,degree:u},vector:{x:g/a,y:-y/a},raw:f,instance:i,lockX:e.lockX,lockY:e.lockY};x=i.computeDirection(x),x.angle={radian:c1(180-u),degree:180-u},i.trigger("move",x),t.trigger("move "+i.id+":move",x)};di.prototype.processOnEnd=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),s=t.manager.removeIdentifier(i.identifier);!i||(e.dataOnly||i.hide(function(){e.mode==="dynamic"&&(i.trigger("removed",i),t.trigger("removed "+i.id+":removed",i),t.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(t.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),t.trigger("end "+i.id+":end",i),t.ids.indexOf(i.identifier)>=0&&t.ids.splice(t.ids.indexOf(i.identifier),1),t.actives.indexOf(i)>=0&&t.actives.splice(t.actives.indexOf(i),1),/(semi|static)/.test(e.mode)?t.idles.push(i):t.nipples.indexOf(i)>=0&&t.nipples.splice(t.nipples.indexOf(i),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};di.prototype.onDestroyed=function(n,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};di.prototype.destroy=function(){var n=this;n.unbindEvt(n.options.zone,"start"),n.nipples.forEach(function(e){e.destroy()});for(var t in n.pressureIntervals)n.pressureIntervals.hasOwnProperty(t)&&clearInterval(n.pressureIntervals[t]);n.trigger("destroyed",n.nipples),n.manager.unbindDocument(),n.off()};var OF=di;function Ki(n){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=RM(),t.config(n),t.prepareCollections();var e=function(){var i;t.collections.forEach(function(s){s.forEach(function(o){i=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+i.left,y:t.scroll.y+i.top}})})};if(typeof window>"u")return t.collections;tp(window,"resize",function(){DM(e)});var r=function(){t.scroll=RM()};return tp(window,"scroll",function(){DM(r)}),t.collections}Ki.prototype=new ip;Ki.constructor=Ki;Ki.prototype.prepareCollections=function(){var n=this;n.collections.create=n.create.bind(n),n.collections.on=n.on.bind(n),n.collections.off=n.off.bind(n),n.collections.destroy=n.destroy.bind(n),n.collections.get=function(t){var e;return n.collections.every(function(r){return e=r.get(t),!e}),e}};Ki.prototype.create=function(n){return this.createCollection(n)};Ki.prototype.createCollection=function(n){var t=this,e=new OF(t,n);return t.bindCollection(e),t.collections.push(e),e};Ki.prototype.bindCollection=function(n){var t=this,e,r=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};Ki.prototype.bindDocument=function(){var n=this;n.binded||(n.bindEvt(document,"move").bindEvt(document,"end"),n.binded=!0)};Ki.prototype.unbindDocument=function(n){var t=this;(!Object.keys(t.ids).length||n===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Ki.prototype.getIdentifier=function(n){var t;return n?(t=n.identifier===void 0?n.pointerId:n.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]};Ki.prototype.removeIdentifier=function(n){var t={};for(var e in this.ids)if(this.ids[e]===n){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};Ki.prototype.onmove=function(n){var t=this;return t.onAny("move",n),!1};Ki.prototype.onend=function(n){var t=this;return t.onAny("end",n),!1};Ki.prototype.oncancel=function(n){var t=this;return t.onAny("end",n),!1};Ki.prototype.onAny=function(n,t){var e=this,r,i="processOn"+n.charAt(0).toUpperCase()+n.slice(1);t=u1(t);var s=function(a,l,c){c.ids.indexOf(l)>=0&&(c[i](a),a._found_=!0)},o=function(a){r=e.getIdentifier(a),Cg(e.collections,s.bind(null,a,r)),a._found_||e.removeIdentifier(r)};return Cg(t,o),!1};Ki.prototype.destroy=function(){var n=this;n.unbindDocument(!0),n.ids={},n.index=0,n.collections.forEach(function(t){t.destroy()}),n.off()};Ki.prototype.onDestroyed=function(n,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var RF=Ki;var LF=new RF,NF={create:function(n){return LF.create(n)},factory:LF};var BF=new Map,Ig=new Map,da=class{constructor(t,e,r,i){this.data=e;let{audio:s,volume:o,delay:a,loop:l}=e;if(!s)throw new Error("Missing property");try{let c=typeof s=="string"?i.getAudio(s).src:s.data;this.audioPlayer=new el({src:c,volume:o,delay:a,loop:l})}catch{console.warn(`Could not create an audio player for this object: "${r.name}" and this audio: "${s}"`)}Ig.has(r.uuid)?Ig.get(r.uuid).push(this):Ig.set(r.uuid,[this]),BF.set(t,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()}},np=class{constructor(t){this.data=t}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=BF.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=Ig.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let t=[...Ig.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Dg=class{constructor(t,e,r,i,s){this.data=e;this.shared=i;this.condition=s;if(e.interaction==="play")this.interaction=new da(t,e,r,i);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new np(e);else throw new Error("Missing property")}dispatchBasic(){if(_t(this.shared,this.condition)===!1)return!1;this.interaction instanceof da?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(_t(this.shared,this.condition)===!1)return!1;this.interaction instanceof da?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(t){if(_t(this.shared,this.condition)===!1)return!1;this.interaction instanceof da&&(t==="start"?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}};var Og=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.delay=0;this.emission=t.emission,t.delay!==void 0&&(this.delay=t.delay),this.particleSystem=this.page.scene.find(this.data.emitterObjectId)}toggleEmitting(){this.particleSystem.started&&!this.particleSystem.stopped?this.stop(this.delay):this.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze(this.delay):this.unFreeze(this.delay)}start(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},t);return}this.particleSystem.start()}stop(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.stop(0),this.clearDelay()},t);return}this.particleSystem.stop()}freeze(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.freeze(0),this.clearDelay()},t);return}this.particleSystem.froze()}unFreeze(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.unFreeze(0),this.clearDelay()},t);return}this.particleSystem.unFroze()}reset(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.reset(0),this.clearDelay()},t);return}this.particleSystem.reset()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze();break}}dispatchBasic(){if(_t(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"emitToggle":this.toggleEmitting();break;case"pause":this.freeze(this.delay);break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchConditional(){if(_t(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchGameControl(t){if(_t(this.shared,this.condition)===!1||!this.particleSystem)return!1;t==="start"?this.start(this.delay):this.stop(this.delay)}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}};var Iee="text/plain",Dee="us-ascii",FF=(n,t)=>t.some(e=>e instanceof RegExp?e.test(n):e===n),Oee=(n,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(n);if(!e)throw new Error(`Invalid URL: ${n}`);let{type:r,data:i,hash:s}=e.groups,o=r.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),u=[...o.map(h=>{let[d,f=""]=h.split("=").map(m=>m.trim());return d==="charset"&&(f=f.toLowerCase(),f===Dee)?"":`${d}${f?`=${f}`:""}`}).filter(Boolean)];return a&&u.push("base64"),(u.length>0||l&&l!==Iee)&&u.unshift(l),`data:${u.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function LM(n,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},n=n.trim(),/^data:/i.test(n))return Oee(n,t);if(/^view-source:/i.test(n))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=n.startsWith("//");!e&&/^\.*\//.test(n)||(n=n.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let i=new URL(n);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),t.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),t.stripAuthentication&&(i.username="",i.password=""),t.stripHash?i.hash="":t.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let u=o.exec(i.pathname);if(!u)break;let h=u[0],d=u.index,f=i.pathname.slice(a,d);l+=f.replace(/\/{2,}/g,"/"),l+=h,a=d+h.length}let c=i.pathname.slice(a,i.pathname.length);l+=c.replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=i.pathname.split("/"),a=o[o.length-1];FF(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),i.pathname=o.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...i.searchParams.keys()])FF(o,t.removeQueryParameters)&&i.searchParams.delete(o);if(t.removeQueryParameters===!0&&(i.search=""),t.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}t.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let s=n;return n=i.toString(),!t.removeSingleSlash&&i.pathname==="/"&&!s.endsWith("/")&&i.hash===""&&(n=n.replace(/\/$/,"")),(t.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&t.removeSingleSlash&&(n=n.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(n=n.replace(/^http:\/\//,"//")),t.stripProtocol&&(n=n.replace(/^(?:https?:)?\/\//,"")),n}var m1=class{constructor({url:t,context:e},r,i,s){this.controlsManager=r;this.shared=i;this.condition=s;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:LM(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(_t(this.shared,this.condition)===!1)return!1;bs?window.location.assign(this.url):(this.context==="tab"||oA&&this.context==="none"?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(et[0]),wD())}};var Rg=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=i;this.condition=s;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let r=this.controlsManager.sharedGameControlGlobals.rapierWorld,i=r?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)i?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0)):this.clone===void 0||this.clone===s?(s.playModeVisible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(i||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;r===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.rigidBody!==void 0),e.destroyedInAction=!0,this.controlsManager.requestRender()};this.objects=[...t.objects]}dispatch(t){if(_t(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(_t(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};var Lg=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.shared=r;this.eventManager=i;this.condition=s;this.shared=r}dispatch(){if(_t(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),sp(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}};function VF(n,t,e,r){let i=[],s=n.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,o=n.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(o!==void 0){let a=s??n.zoom,l=o;a!==l&&i.push({update:c=>{n.zoom=Se.lerp(a,l,c),n.updateProjectionMatrix()},start:()=>{n.zoom=a,n.updateProjectionMatrix()},end:()=>{n.zoom=l,n.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let a=ii("targetOffset",n,t,e,r);a&&i.push(a)}return i}function Ree(n,t,e,r){if(e.scaleBaked===void 0)return;let i=(t.scaleBaked??n.data.geometry.scaleBaked).map(a=>typeof a=="string"?Number(r.shared.getVariable(a)??0):a),s=e.scaleBaked.map(a=>typeof a=="string"?Number(r.shared.getVariable(a)??0):a);if(ws.isEqual(i,s))return;let o=[];return o.push({update:a=>{n.updateGeometryInteractions({scaleBaked:[Se.lerp(i[0],s[0],a),Se.lerp(i[1],s[1],a),Se.lerp(i[2],s[2],a)]},r.shared),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions(r)},start:()=>{n.updateGeometryInteractions({scaleBaked:i},r.shared),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions(r)},end:()=>{n.updateGeometryInteractions({scaleBaked:s},r.shared),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions(r)}}),o}function Lee(n,t,e,r){if(!e.extrusion)return;let i=n.extrusion,s=t.extrusion??{},o=e.extrusion,a=[];return V0.forEach(l=>{let c=Go(l,i,s,o,r);c&&a.push(c)}),a}function UF(n,t,e,r){let i=[];if(!("geometry"in e))return i;let s=n.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(n instanceof lo){let l=Ree(n,o,a,r);l&&i.push(...l)}else{let l={};if(Object.assign(l,Nn(s,k0),Nn(o,k0)),k0.forEach(c=>{let u=Go(c,l,o,a,r.shared);u&&i.push(u)}),n instanceof qo){Object.assign(l,{extrusion:{...s.extrusion}});let c=Lee(l,o,a,r.shared);c&&i.push(...c)}i.length&&i.push({update:c=>{n.updateGeometryInteractions(l,r.shared),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions(r)},start:c=>{n.updateGeometryInteractions(l,r.shared),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions(r)},end:c=>{n.updateGeometryInteractions(l,r.shared),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions(r)}})}return i}function FR(n,t,e,r){let i=n.geometry.userData.parameters.extrusion;if(!!i)return V0.forEach(s=>{jo(s,i,t,e,r)}),i}function VR(n,t,e,r){let i=n.updatedPathSnapping;if(!!i)return LO.forEach(s=>{jo(s,i,t,e,r)}),i}function kF(n,t,e,r){let i=[];if(e.intensity!==void 0){let s=ii("intensity",n,t,e,r);s&&i.push(s)}if(e.color!==void 0){let s=_R("color",n,t,e,r);s&&i.push(s)}return i}function GF(n,t,e,r){let i=[];if(Array.isArray(n.material)){if(!("materials"in e&&e.materials))return i;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;n.material.forEach((a,l)=>{if(!o[l])return;let c=s[l]??{},u=o[l];typeof c=="string"||typeof u=="string"||i.push(...zF(a,c,u,r))})}else{if(!("material"in e&&e.material))return i;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return i;i.push(...zF(n.material,s,o,r))}return i}function zF(n,t,e,r){let i=[],s=yu(e,r)||!!t.layers&&yu(t,r);i.push(Nee(n,s));for(let o of n.layers){let a=t.layers?.data(o.uuid),l=e.layers.data(o.uuid);if(!l||o.type!=="light"&&(!(o.visible??!0)||!(l.visible??!0)))continue;let c=o.getNames().filter(u=>!N0.some(h=>u.includes(h)));for(let u of c)try{let h=o.getValue(u),d;if(u==="colors")d=KF(o,a,l,u);else if(Array.isArray(h))u==="steps"&&(d=YF(o,a,l,u));else if(typeof h=="number")d=jF(o,a,l,u,r);else{if(typeof h=="boolean")continue;h instanceof U?d=HF(o,a,l,u):h instanceof E?d=WF(o,a,l,u,r):h instanceof cr?d=XF(o,a,l,u,r):h instanceof Ge?d=qF(o,a,l,u,r):"isTexture"in h&&(d=QF(o,a,l,u))}d&&(Array.isArray(d)?i.push(...d):i.push(d))}catch(h){console.error(`lerpMaterial: unexpected material layer for ${u}`,h)}}return i}function jF(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let s=t?t[r]:n.getValue(r),o=e[r],a=typeof s=="string"?Number(i.getVariable(s)??0):s,l=typeof o=="string"?Number(i.getVariable(o)??0):o;if(a!==l)return{update:c=>{n.setValue(r,Se.lerp(a,l,c))},start:()=>{n.setValue(r,a)},end:()=>{n.setValue(r,l)}}}function HF(n,t,e,r){if(!n.hasValue(r)||!(r in e))return;let i=n.getValue(r),s=t?new U().fromArray(t[r]):i.clone(),o=new U().fromArray(e[r]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function WF(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let s=n.getValue(r),o=t?t[r]:void 0,a=e[r],l=o?Tm(new E,o,i):s.clone(),c=Tm(new E,a,i);if(!l.equals(c))return{update:u=>{s.lerpVectors(l,c,u)},start:()=>{s.copy(l)},end:()=>{s.copy(c)}}}function qF(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=n.getValue(r),l=s?typeof s=="string"?i.getColor(s).clone():new Ge().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new Ge().setRGB(o.r,o.g,o.b);if(l.equals(c))return;let u=a.clone();return{update:h=>{n.getValue(r)!==u&&n.setValue(r,u),u.lerpColors(l,c,h)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function XF(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=n.getValue(r),l=s?typeof s=="string"?i.color(s).clone():new Ge().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new cr(o.r,o.g,o.b,o.a);if(l.equals(c))return;let u=a.clone();return{update:h=>{n.getValue(r)!==u&&n.setValue(r,u),u.lerpColors(l,c,h)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function YF(n,t,e,r="steps"){if(!n.hasValue(r)||!(r in e))return;let i=[],s=n.getValue(r),o=t?t[r]:s,a=e[r];return Qc(o,a)||i.push({update:l=>{let c=[...s];for(let u=0;u<s.length;++u){let h=o[u],d=a[u];c[u]=Se.lerp(h,d,l)}n.setValue(r,c)},start:()=>{n.setValue(r,o)},end:()=>{n.setValue(r,a)}}),i.length?i:void 0}function KF(n,t,e,r="colors"){if(!n.hasValue(r)||!(r in e))return;let i=[],s=n.getValue(r),o=t?t[r]:s.map(l=>l.toArray()),a=e[r];for(let l=0;l<s.length;++l){let c=[...o[l]],u=[...a[l]];eu.isEqual(c,u)||i.push({update:h=>{s[l].fromArray(eu.lerp(c,u,h))},start:()=>{s[l].fromArray(c)},end:()=>{s[l].fromArray(u)}})}return i.length?i:void 0}function QF(n,t,e,r="texture"){if(!n.hasValue(r)||!(r in e))return;let i=n.getNode("rotation"),s=t?.[r]?.rotation??0,o=e[r]?.rotation??0;if(i&&s!==o)return{update:g=>{i.value=Se.lerp(s,o,g)*Se.DEG2RAD},start:()=>{i.value=s*Se.DEG2RAD},end:()=>{i.value=o*Se.DEG2RAD}};let a=n.getNode("mat");if(!a)return;let l=t?t[r]:a,c=e[r],u=[...l.repeat],h=[...l.offset],d=[...c.repeat],f=[...c.offset],m=l.rotation??0,p=c.rotation??0;if(!ss.isEqual(u,d)||!ss.isEqual(h,f)||m!==p)return{update:g=>{a.repeat=ss.lerp(u,d,g),a.offset=ss.lerp(h,f,g),a.rotation=Se.lerp(m,p,g),a.updateMatrix()},start:()=>{a.repeat=[...u],a.offset=[...h],a.rotation=m,a.updateMatrix()},end:()=>{a.repeat=[...d],a.offset=[...f],a.rotation=p,a.updateMatrix()}}}function NM(n,t,e,r,i,s,o){if(n==="colors")KF(t,e,r,n)?.forEach(a=>a.update(i));else if(Array.isArray(s))n==="steps"&&YF(t,e,r,n)?.forEach(a=>a.update(i));else if(typeof s=="number")jF(t,e,r,n,o)?.update(i);else{if(typeof s=="boolean")return;s instanceof U?HF(t,e,r,n)?.update(i):s instanceof E?WF(t,e,r,n,o)?.update(i):s instanceof cr&&o?XF(t,e,r,n,o)?.update(i):s instanceof Ge&&o?qF(t,e,r,n,o)?.update(i):"isTexture"in s&&QF(t,e,r,n)?.update(i)}}function Nee(n,t){return{update:()=>{n.transparent=t}}}var BM=new E,ZF=new Jt;function JF(n,t,e,r,i){let s=[],o,a,l,c,u,h,d,f;if(n instanceof hr?(o=Td("position",n,t,e,i),o&&s.push(o),l=ii("rotation",n,t,e,i),l&&s.push(l),c=Td("shear",n,t,e,i),c&&s.push(c)):(f={slide:t.pathSnapping?.slide??n.updatedPathSnapping?.slide??n.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??n.updatedPathSnapping?.offset??n.dataPatched.pathSnapping?.offset??0},h=ii("slide",f,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),h&&s.push(h),d=ii("offset",f,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),d&&s.push(d),!h&&!d&&(o=cE("position",n,t,e,i),o&&s.push(o),a=cE("scale",n,t,e,i),a&&s.push(a),l=Bee(n,t,e,r,i),l&&s.push(l),u=PR("hiddenMatrix",n,t,e),u&&s.push(u))),o||a||l||u||h||d){let m=n instanceof hr?()=>{n.updateWorldMatrix(!0,!1,!0),n.resetBBoxNeedsUpdate()}:()=>{n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldSVD()),n.parent?.matrixWorldFusedFalse&&(n.matrixWorld.multiplyMatrices(n.parent.matrixWorldFusedFalse,n.matrix),n.matrixWorldNeedsUpdate=!1),Wn(n)&&Dn(n.parent)&&n.invalidateDownstreamBooleanData(!0),n.updatePathSnapping(Object.assign({},t.pathSnapping,f))};s.push({update:m,start:m,end:m})}return s}function Bee(n,t,e,r,i){let s=t?.rotation?t.rotation.map(u=>(typeof u=="string"?Number(i.getVariable(u)??0):u)*Se.DEG2RAD):void 0,o=e.rotation?.map(u=>(typeof u=="string"?Number(i.getVariable(u)??0):u)*Se.DEG2RAD);if(!o)return;let a=s?new E().fromArray(s):new E().setFromEuler(n.rotation),l=new E().fromArray(o);if(a.equals(l))return;let c=BM.subVectors(l,a);if(r&&c.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new Ye().setFromEuler(ZF.setFromVector3(a)),h=new Ye().setFromEuler(ZF.setFromVector3(l));return{update:d=>{CR(u,h,n.quaternion,d)},start:()=>{n.rotation.setFromVector3(a)},end:()=>{n.rotation.setFromVector3(l)}}}else return{update:u=>{BM.lerpVectors(a,l,u),n.rotation.setFromVector3(BM)},start:()=>{n.rotation.setFromVector3(a)},end:()=>{n.rotation.setFromVector3(l)}}}function Fee(n,t){return{update:()=>{n instanceof Pr&&(n.fill.enabled=t)}}}function Vee(n,t){return{update:()=>{n instanceof Pr&&(n.stroke.enabled=t)}}}function Uee(n,t){return{update:()=>{n instanceof Pr&&(n.dropShadow.enabled=t)}}}function kee(n,t){return{update:()=>{n instanceof Pr&&(n.innerShadow.enabled=t)}}}function zee(n,t){return{update:()=>{n instanceof Pr&&(n.backgroundBlur.enabled=t)}}}function Gee(n,t){return{update:()=>{n instanceof Pr&&(n.layerBlur.enabled=t)}}}function $F(n,t,e,r,i){let s=[],o,a,l,c,u,h,d,f,m,p,g,y,x,v,b;if("width"in n&&(o=ii("width",n,t,e,i),o&&s.push(o)),"height"in n&&(a=ii("height",n,t,e,i),a&&s.push(a)),n instanceof Pr||n instanceof rn){let w={...t.fill},A={...e.fill};w.enabled!==void 0&&w.enabled!==A.enabled&&(s.push(Fee(n,!0)),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),l=Cm("color",n.fill,w,A,i),l&&s.push(l)}if(n instanceof Pr){let w={...t.stroke},A={...e.stroke};(w.enabled||A.enabled)&&(s.push(Vee(n,!0)),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),c=Cm("color",n.stroke,w,A,i),c&&s.push(c),u=ii("thickness",n.stroke,w,A,i),u&&s.push(u)}if(n instanceof Pr){let w={...t.dropShadow},A={...e.dropShadow};(w.enabled||A.enabled)&&(s.push(Uee(n,!0)),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),h=Cm("color",n.dropShadow,w,A,i),h&&s.push(h),d=ii("blurRadius",n.dropShadow,w,A,i),d&&s.push(d),m=ii("spread",n.dropShadow,w,A,i),m&&s.push(m),f=Td("offset",n.dropShadow,w,A,i),f&&s.push(f)}if(n instanceof Pr){let w={...t.innerShadow},A={...e.innerShadow};(w.enabled||A.enabled)&&(s.push(kee(n,!0)),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),p=Cm("color",n.innerShadow,w,A,i),p&&s.push(p),g=ii("blurRadius",n.innerShadow,w,A,i),g&&s.push(g),x=ii("spread",n.innerShadow,w,A,i),x&&s.push(x),y=Td("offset",n.innerShadow,w,A,i),y&&s.push(y)}if(n instanceof Pr||n instanceof rn){let w={...t.backgroundBlur},A={...e.backgroundBlur};(w.enabled||A.enabled)&&(s.push(zee(n,!0)),w.enabled||Object.assign(w,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),v=ii("radius",n.backgroundBlur,w,A,i),v&&s.push(v)}if(n instanceof Pr){let w={...t.layerBlur},A={...e.layerBlur};(w.enabled||A.enabled)&&(s.push(Gee(n,!0)),w.enabled||Object.assign(w,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),b=ii("radius",n.layerBlur,w,A,i),b&&s.push(b)}if(n instanceof rn||n instanceof Bs){let w=Mm("cornerRadius",n,t,e,i);w&&s.push(w)}return s}function FM(n,t,e,r,i){let s=[];return n.data.visible&&s.push(...JF(n,t,e,i,r.shared)),n instanceof hr?s.push(...$F(n,t,e,i,r.shared)):(n.data.visible&&s.push(...IR(n,t,e,r)),n instanceof nr?(n instanceof Ct&&n.data.visible&&s.push(...UF(n,t,e,r)),n.data.visible&&s.push(...GF(n,t,e,r.shared))):Of.is(n)?n.data.visible&&s.push(...kF(n,t,e,r.shared)):n instanceof ir&&s.push(...VF(n,t,e,r.shared))),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}function eV(n,t){return{position(e){Object.assign(n.position,e),(e.x!==void 0||e.y!==void 0||e.z!==void 0)&&(n.updateMatrix(),n.resetBBoxNeedsUpdate(),n instanceof Ct&&n.invalidateDownstreamBooleanData(),n.dispatchEvent({type:"requestRender"}))},rotation(e){let r=Object.keys(e)[0];n.rotation[r]=e[r]*Se.DEG2RAD,(e.x!==void 0||e.y!==void 0||e.z!==void 0)&&(n.updateMatrix(),n.resetBBoxNeedsUpdate(),n instanceof Ct&&n.invalidateDownstreamBooleanData(),n.dispatchEvent({type:"requestRender"}))},scale(e){Object.assign(n.scale,e),(e.x!==void 0||e.y!==void 0||e.z!==void 0)&&(n.updateMatrix(),n.resetBBoxNeedsUpdate(),n instanceof Ct&&n.invalidateDownstreamBooleanData(),n.dispatchEvent({type:"requestRender"}))},shapeSize(e){n instanceof Ct&&(n.userData.value={...n.userData.value,...e},(e.x!==void 0||e.y!==void 0||e.z!==void 0)&&(n.updateGeometryInteractions({width:n.userData.value.x,height:n.userData.value.y,depth:n.userData.value.z},t.shared),n.resetBBoxNeedsUpdate(),n.invalidateDownstreamBooleanData(),n.dispatchEvent({type:"requestRender"})))},material(e,r,i){i&&(Object.entries(i).forEach(([s,{start:o,end:a,t:l}])=>{let c=r.getValue(s);c!==void 0&&NM(s,r,o,a,l,c,t.shared)}),n.dispatchEvent({type:"requestRender"}))},opacity(e){if(n instanceof nr&&!Array.isArray(n.material)){let r=n.material.getLayersOfType("light")[0];n.material.transparent=!0,NM("alphaOverride",r,{alphaOverride:e},{alphaOverride:e+1},0,e,t.shared),n.dispatchEvent({type:"requestRender"})}},light(e,r){(n instanceof Ho||n instanceof Xl||n instanceof Wo)&&(n[e]=r,n.dispatchEvent({type:"requestRender"}))},cloner(e){e.cloner?.update(t),e instanceof Ct&&e.invalidateDownstreamBooleanData(),e.dispatchEvent({type:"requestRender"})},pathExtrusion(e,r){e.geometry.userData.parameters.extrusion={...e.geometry.userData.parameters.extrusion,...r},e.updateGeometryInteractions({extrusion:{...e.geometry.userData.parameters.extrusion}},t.shared),e.resetBBoxNeedsUpdate(),e.invalidateDownstreamBooleanData(),e.dispatchEvent({type:"requestRender"})},pathSnapping(e){n.userData.pathSnapping={...n.userData.pathSnapping,...e},n.updatePathSnapping(n.userData.pathSnapping),n.dispatchEvent({type:"requestRender"})}}}var tV=new E;function sp(n,t,e=!1){let r=[],i=s=>{let o=s.data;delete s.states,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let a of o.states){let l={...a.data};s.states||(s.states={}),s.states[a.id]=Ga.patch(o,l)}iV(n.scene,s,null,t,o.events.find(a=>a.data.type==="Follow"||a.data.type==="LookAt")!==void 0),rV(n)};n.scene.traverse2D(i),n.traverseChildren(s=>{if(e&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(tV,!0),s.rigidBody?.setAngvel(tV,!0)),!gt.is(s))return;let o=s.uuid,a=s.data;if(delete s.states,s.uuid===As)return;let l=!1;r.some(c=>n.scene.find(o)?.isDescendantOf(c))?l=!0:a.physics?.fusedBody===!0&&a.physics.rigidBody==="dynamic"&&r.push(o),s.data=a,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let c of a.states){let u={...c.data};n.data.globalPhysics.usePhysics===!0&&a.physics&&(a.physics.rigidBody==="dynamic"||l)&&(c.data.position!==void 0&&delete u.position,c.data.rotation!==void 0&&delete u.rotation,c.data.hiddenMatrix!==void 0&&delete u.hiddenMatrix),s.states||(s.states={}),s.states[c.id]=Qs.patch(a,u)}iV(n.scene,s,null,t,a.events.find(c=>c.data.type==="Follow"||c.data.type==="LookAt")!==void 0),s instanceof _r&&s.frame&&(s.frame.traverse(c=>i(c)),s.uiCanvas?.applySize())}),rV(n),n.frame&&(n.frame.traverse(s=>i(s)),n.uiCanvas?.applySize())}function rV(n){n.traverseEntity(t=>{for(let e of t.data.events){let r=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...e.data.actions);break;case"GameControl":for(let i of Object.values(e.data.gameActions))r.push(...i);break;case"DragDrop":r.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":r.push(...e.data.inActions,...e.data.outActions);break}for(let i of r)if(i.data.type==="Create"&&i.data.hideBase==="Yes"){let s=n.scene.find(i.data.object);s&&(s.visible=!1)}}})}function iV(n,t,e,r,i=!1){if(t instanceof Ct&&!(t instanceof cs)&&t.removeInteractionGeometry(r),t instanceof hr?t.changeSelectedState(e,{shared:r},i):t.changeSelectedState(e,{scene:n,shared:r},i),t instanceof Ct&&t.updateGeometryGroupsIfNeeded(),t instanceof ir&&t.updateCameraState(t.dataPatched,{scene:n,shared:r}),!(t instanceof hr)){if(t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}}function VM(n){let t;if(n.easing===5){let{control1:e,control2:r}=n;t=`cubicBezier(
|
|
8105
8105
|
${e[0]}, ${e[1]}, ${r[0]}, ${r[1]}
|
|
8106
|
-
)`}else if(n.easing===6){let{mass:e,stiffness:r,damping:i,velocity:s}=n;t=`spring( ${e}, ${r}, ${i}, ${s} )`}else{let e;switch(n.easing){case 0:e=Na.linear;break;case 1:e=Na.ease;break;case 2:e=Na.easeIn;break;case 3:e=Na.easeOut;break;case 4:e=Na.easeInOut;break;default:e=Na.linear}let[r,i,s,o]=e;t=`cubicBezier( ${r}, ${i}, ${s}, ${o} )`}return{duration:Math.max(n.duration,1e-4),easing:t}}function Ng(n){let t={delay:0,loop:n.repeat===-1?!0:n.repeat+1};if(n.repeat===0)t.direction="normal",t.rewind=!1;else switch(n.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,n.delayDirection){case"start-once":t.startOnceDelay=n.delay;break;case"start":t.delay=n.delay;break;case"end":t.endDelay=n.delay;break;case"start-end":case void 0:t.delay=n.delay,t.endDelay=n.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,n.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):n.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):n.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var UM={type:"beginState"},kM={type:"completeState",isfromEntity:!1},op=class{constructor(t,e,r,i,s,o,a){this.object=t;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.page=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.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 t=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=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object instanceof hr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof ir&&e.dispatchEvent(UM)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=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=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object instanceof hr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof ir&&e.dispatchEvent(kM)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=FM(this.object,this.from.data,this.to.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp))};if(e===void 0){let l=g1(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!l)throw new Error("Missing property");this.from=l}else{let l=g1(this.object,e);if(!l)throw new Error("Missing property");this.from=l}if(r===void 0)throw new Error("Missing property");{let l=g1(this.object,r);if(!l)throw new Error("Missing property");this.to=l}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...Ng(i),...VM(i),change:this.onChange},this.callback=FM(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},ap=class extends ar{constructor(e,r,i,s,o){super();this.eventType=e;this.data=r;this.page=i;this.shared=s;this.condition=o;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.hasPlayedOnce=!1;this.pauseOnNextLoopEnd=!1;this.onTimelineChangeComplete=()=>{if(this.pauseOnNextLoopEnd){this.pauseOnNextLoopEnd=!1,this.timeline?.pause();return}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())};if(!r.object)throw new Error("Missing property");let a=this.page.scene.find(r.object)??this.page.uiCanvas?.find(r.object)??this.page.scene.find2DInUIObjects(r.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,r.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=r.tweens[0].data.delayDirection==="start-once"?r.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline?.paused===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=g1(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"&&xm(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:i=!1}={}){try{let s=Ng(this.data.tweens[0].data);i&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=Ms.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(r===!0&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let c=this.data.tweens[l],u=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof ir&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new op(this.object,h,u.data.state===void 0?this.currentState:u.data.state,u.data,this.shared,this.data.allowSlerp??!1,this.page);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.delay:0))}this.timeline.duration+=s.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let c=this.data.tweens[l],u=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof ir&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new op(this.object,h,u.data.state===void 0?this.currentState:u.data.state,c.data,this.shared,this.data.allowSlerp??!1,this.page);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.endDelay:0))}this.timeline.duration+=s.delay}}catch(s){s instanceof Error&&console.error(s.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(_t(this.shared,this.condition)===!1||xm(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;this.startTimeout?.pause();let e=Ng(this.data.tweens[0].data).pingPongDelayCorrection;this.startTimeout=Ms({targets:{},duration:this.startOnceDelay+e,easing:"linear",complete:()=>{this.startTimeout=void 0;try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.message)}}})}pause(){this.timeline?.pause(),this.startTimeout?.pause(),this.tweens=Array(this.data.tweens.length-1),delete this.startTimeout}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof hr?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){if(_t(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(_t(this.shared,this.condition)===!1)return!1;this.startTimeout?.pause(),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.pauseOnNextLoopEnd=!0,this.timeline.play()):this.startTimeout=Ms({targets:{},duration:this.startOnceDelay,easing:"linear",complete:()=>{this.startTimeout=void 0,this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()}})}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function g1(n,t){let e,r;if(typeof t=="string"?(e=t,r=n.states?.[e]):t===null&&(e=null,r=n.data),!(e===void 0||r===void 0))return{id:e,data:r}}var jee={type:"beginState"},nV={type:"completeState",isfromEntity:!1},sV={type:"requestRender"},Bg=class extends ar{constructor(e,r,i,s){super();this.data=e;this.page=r;this.shared=i;this.condition=s;this.toggleIsForward=!1;this.posStart=new E;this.posEnd=new E;this.qStart=new Ye;this.qEnd=new Ye;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 r=this.page.scene.find(this.data.targetCamera);if(!r||!r.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=Ms({targets:i,t:1,...VM(this.data),update:()=>{i.t===0&&(this.data.runMode==="Toggle"&&!this.toggleIsForward?this.fromCamera&&(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(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(jee));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,i.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(sV),i.t===1&&s.dispatchEvent(nV)}})}switchCamera(e){let r=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),r.dispatchEvent({type:"cameraChange",camera:i})}play(){if(_t(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(_t(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,e!==this.toggleIsForward)try{this.playing?(this.animation?.pause(),this.toggleIsForward=e??!this.toggleIsForward,this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=e??!this.toggleIsForward,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(nV),this.page.activeCamera.dispatchEvent(sV))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var Fg=class extends ar{constructor(e,r,i,s,o){super();this.id=e;this.data=r;this.scene=i;this.sharedAssets=s;this.eventType=o;this.toggleIsForward=!1;this._finished=!1;this.hasPlayedOnce=!1;this._shouldForwardLoop=!1;this._shouldPauseOnNextLoopComplete=!1;this._onLoopComplete=()=>{this._shouldPauseOnNextLoopComplete&&(this.timeline.pause(),this._shouldPauseOnNextLoopComplete=!1)};try{let a=Ng(this.data);typeof a.loop=="number"&&a.loop--,this.timeline=Ms.timeline({...a,autoplay:!1}),this._shouldForwardLoop=a.loop===!0||typeof a.loop=="number"&&a.loop>1;let l=this.sharedAssets.data.timelineAnimations[this.data.timeline].mapping;Object.entries(l).forEach(([c,u])=>{let h=this.scene.find(c);if(!h)return;let d=h.data.timelineAnimations[u];if(!d)return;let f=sx.addKeyframesToTimeline(h,{...d},eV(h,{scene:i,shared:s}),this.sharedAssets),m=(this.data.delayDirection==="start"?this.data.delay:0)+(this.data.delayDirection==="start-end"?this.data.delay:0)+(this.data.delayDirection==="start-once"?this.data.delay:0);f.forEach(p=>{this.timeline.add(p,m)}),this.timeline.duration=d.to*1e3+m}),this.timeline.delay=0,this.timeline.duration+=(this.data.delayDirection==="start"?this.data.delay:0)+(this.data.delayDirection==="end"?this.data.delay:0)+(this.data.delayDirection==="start-end"?this.data.delay*2:0)+(this.data.delayDirection==="start-once"?this.data.delay*2:0),this.timeline.finished.then(()=>{Object.keys(l).forEach(c=>{let u=this.scene.find(c);u instanceof ir&&u.dispatchEvent(kM)}),this._finished=!0}),this.timeline.loopComplete=this._onLoopComplete}catch(a){throw!1&&console.error(a),new Error("Missing property")}}get playing(){return this.timeline.paused===!1}get finished(){return this._finished}get paused(){return this.timeline.paused}play(){if(this.eventType!==void 0&&xm(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0;let e=this.sharedAssets.data.timelineAnimations[this.data.timeline].mapping;Object.keys(e).forEach(r=>{let i=this.scene.find(r);i instanceof ir&&i.dispatchEvent(UM)}),this.timeline.restart()}pause(){this.timeline.pause()}stop(){this.pause(),this.seek(0),this.timeline.reset(),this._finished=!1}seek(e){this.timeline.seek(e*this.timeline.duration,!0)}toggle(e){if(this.toggleIsForward=e??!this.toggleIsForward,this.playing){if(!this.toggleIsForward&&this.timeline.reversed&&this._shouldForwardLoop&&this.timeline.remaining%2===1){this._shouldPauseOnNextLoopComplete=!0;return}this.timeline.reverse(this.timeline.duration-this.timeline.currentTime),this._shouldForwardLoop&&this.timeline.loop&&this.timeline.reversed&&(this._shouldPauseOnNextLoopComplete=!0)}else(!this.toggleIsForward!==this.timeline.reversed||!this.toggleIsForward&&this.timeline.reversed&&this.timeline.direction==="alternate")&&this.timeline.reverse(),typeof this.timeline.loop=="number"&&typeof this.timeline.remaining=="number"&&this.timeline.remaining<this.timeline.loop&&this.toggleIsForward&&(this.timeline.remaining=this.timeline.loop),this.timeline.play()}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function zM(n){let t=n?.tracks.filter(e=>e.ValueTypeName==="vector"||e.ValueTypeName==="quaternion").map(e=>e.times.length);if(t?.length){let e=iA(t);return e&&e>2?e:2}return 2}var Vg=class extends ar{constructor(e,r,i,s,o){super();this.data=e;this.page=r;this.animationControls=i;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let c=this.animationControls.clipIdToAction[e.clipId+"/"+a];if(this.duration=c?.getClip()?.duration??1,this.data.crop2){let u=zM(c?.getClip());this.leftFrameTime=this.data.crop2[0]/(u-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(u-1)*this.duration}else{let u=c?.getClip()?.tracks[0]?.times.length;u&&u>1?(this.leftFrameTime=this.data.crop[0]/u*this.duration,this.rightFrameTime=this.data.crop[1]/u*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(_t(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 r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,s])=>{let o=i.split("/")[1];this.threeAnimAction!==s&&o===r&&(e?s.fadeOut(.2):s.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=Se.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(_t(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(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===i&&o.isRunning()&&(r?o.fadeOut(.2):o.stop())}),r&&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()}};var Ug=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.eventManager=r;this.shared=i;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(_t(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(r=>r.uuid!==this.data.target||r.data.uiScene))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 t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(r=>{r.type==="ParticleSystem"&&(r.sleep(),r.wakeUp(),r.data.autoPlay?r.start():r.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),sp(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var kg=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=_t(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=Lx(this.data.expression,this.shared,Gr.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var zg=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.timeoutId=null}dispatchInner(){if(_t(this.shared,this.condition)===!1)return!1;let t=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,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="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"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="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 e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e===void 0?!1:!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};var y1=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(_t(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(e=>{this.shared.getVariable(e);let r=this.shared.data.variables.data(e)?.value;r!==void 0&&this.shared.updateVariable(e,r),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(cb(e))})}dispose(){}};var v1=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(_t(this.shared,this.condition)===!1)return!1;if(this.data.userAPIId){let t=this.shared.getUserAPI(this.data.userAPIId);t&&"callUserAPI"in t&&t.callUserAPI(this.shared)}}dispose(){}};function _t(n,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=Lx(t.expression,n,"boolean");return t.negate?!e:!!e}function Wt(n,t,e,r,i,s){let o={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],TimelineAnimation:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},a=l=>({id:c,data:u})=>{try{u.type==="Audio"?Wi[n.type].includes("Audio")&&o.Audio.push(new Dg(c,u,s,r,l)):u.type==="Video"&&!(s instanceof hr)?Wi[n.type].includes("Video")&&o.Video.push(new Gg(c,u,s,r,l)):u.type==="Particles"?Wi[n.type].includes("Particles")&&o.Particles.push(new Og(u,e,r,l)):u.type==="Link"?Wi[n.type].includes("Link")&&o.Link.push(new m1(u,i.controlsManager,r,l)):u.type==="Create"?Wi[n.type].includes("Create")&&o.Create.push(new jg(u,e,i.controlsManager,r,l)):u.type==="Destroy"?Wi[n.type].includes("Destroy")&&o.Destroy.push(new Rg(u,e,i.controlsManager,r,l)):u.type==="Reset"?Wi[n.type].includes("Reset")&&o.Reset.push(new Lg(u,e,r,i,l)):u.type==="Transition"?Wi[n.type].includes("Transition")&&o.Transition.push(new ap(n.type,u,e,r,l)):u.type==="SwitchCamera"?Wi[n.type].includes("SwitchCamera")&&o.SwitchCamera.push(new Bg(u,e,r,l)):u.type==="SceneTransition"?Wi[n.type].includes("SceneTransition")&&o.SceneTransition.push(new Ug(u,e,i,r,l)):u.type==="Animation"?Wi[n.type].includes("Animation")&&o.Animation.push(new Vg(u,e,i.animationControls,r,l)):u.type==="SetVariable"?Wi[n.type].includes("SetVariable")&&o.SetVariable.push(new kg(u,e,r,l)):u.type==="DynamicVariablePlay"?Wi[n.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new zg(u,e,r,l)):u.type==="Conditional"?Wi[n.type].includes("Conditional")&&(u.ifActions.forEach(a({expression:u.condition,negate:!1})),u.elseActions.forEach(a({expression:u.condition,negate:!0}))):u.type==="ClearLocalStorage"?Wi[n.type].includes("ClearLocalStorage")&&o.ClearLocalStorage.push(new y1(u,e,r,l)):u.type==="UserAPI"?Wi[n.type].includes("UserAPI")&&o.UserAPI.push(new v1(u,e,r,l)):u.type==="TimelineAnimation"&&Wi[n.type].includes("TimelineAnimation")&&o.TimelineAnimation.push(new Fg(c,u,e.scene,r,n.type))}catch(h){!1&&console.error(h)}};return t.forEach(a()),o}function vr(n){Object.values(n).forEach(t=>{t.forEach(e=>{(e instanceof Dg||e instanceof Gg||e instanceof ap||e instanceof Fg||e instanceof Og||e instanceof Vg||e instanceof ap||e instanceof jg||e instanceof Rg||e instanceof Bg||e instanceof Ug||e instanceof Lg||e instanceof kg||e instanceof zg)&&e.dispose()})})}function oV(n,t){let e;if("material"in n){let r=n.material;Array.isArray(r)?e=n.material[0].layers.find(i=>i.uuid===t):e=n.material.layers.find(i=>i.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var aV=new Map,Hg=new Map,po=class{constructor(t,e,r){this.data=e;this.delay=0;this.status="stopped";let{layerId:i,loop:s,volume:o,delay:a}=e;if(this.object=r,i===void 0)throw new Error("Missing property");let l=oV(r,i);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,bs&&(this.videoElement.autoplay=!0),o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),Hg.has(r.uuid)?Hg.get(r.uuid).push(this):Hg.set(r.uuid,[this]),aV.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(i=>{}).catch(i=>{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())}seek(t){return new Promise(e=>{if(!this.videoElement)return e();let r=this.videoElement.duration;if(r>0){let i=t%r;this.videoElement.currentTime=i}this.videoElement.addEventListener("seeked",()=>e(),{once:!0})})}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)}},lp=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=aV.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=Hg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[...Hg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Gg=class{constructor(t,e,r,i,s){this.data=e;this.shared=i;this.condition=s;if(e.interaction==="play")this.interaction=new po(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new lp(e);else throw new Error("Missing property")}dispatchBasic(){if(_t(this.shared,this.condition)===!1)return!1;this.interaction instanceof po?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(_t(this.shared,this.condition)===!1)return!1;this.interaction instanceof po?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var lV=(()=>{let n,t,e,r;function i(a){!n&&!cV()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(n=requestAnimationFrame(s)),a&&(t=a,r=a.requestRender)}function s(a){let l=e?a-e:0,c=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,h=c.length,d=0;for(;d<h;){let f=c[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&u[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),r()),d++):(u[f.userData.actionId]>f.userData.quantity&&u[f.userData.actionId]--,c.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(m=>m.bvhGeometry!==void 0)),h--,r())}n=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){cV()?n&&(cancelAnimationFrame(n),n=void 0,e=void 0):i()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),i})();function cV(){return!!document&&document.hidden}var uV=new Ye,Hee=new E,Wee=new E,jg=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=i;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Se.generateUUID();this.dispatch=()=>{if(_t(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(_t(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=nA(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 t=new Lr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,i=this.page.scene.find(r);i&&(i.updateMatrixWorldSVD(),t.hiddenMatrix.copy(i.matrixWorldRigid))}t.scale.copy(this.object.scale),t.position.fromArray(this.data.position.map(r=>typeof r=="number"?r:0)),t.rotation.fromArray(this.data.rotation.map(r=>typeof r=="number"?r:0)),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),lV(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Ai)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof Lr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Ai)return;t instanceof Lr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new E().fromArray(this.data.velocity.map(s=>typeof s=="number"?s:0)),i=e.dataPatched;if(!(i.physics.enabled==="visibility"?!i.visible:!i.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(Hee,uV,Wee),r.applyQuaternion(uV),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");lV(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var WM=200,GM=.02,jM=.3,qee=65,hV=new E,dV=new E,Xee=new E,On=new E,Yn=new E,wc=new E,HM=new ue,fV=new ue,Yee=new ue,mo=new Ye,sl=new Ye,fa=new Jt(0,0,0,"YXZ"),Kee=new E(1,0,0),go=new E(0,1,0),Qee=new E(0,0,1),pV=new E(1,1,1),Zee=1,Jee=.025,$ee=16e-6,mV=12,ete=20,Qi=new Di,Fs=new Yt,tte={type:"requestRender"},rte={type:"updateMatrix"},gV=Math.PI/6,x1=class extends ar{constructor(e,r,i,s,o,a,l,c,u){super();this.object=e;this.domElement=r;this.data=i;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=c;this.sharedAssets=u;this.enableDamping=!0;this.hiddenMatrix0=new ue;this.target0=new E;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=WM;this.euler0=new Jt(0,0,0,"YXZ");this.position0Cam=new E;this.quat0Cam=new Ye;this.scale0Cam=new E;this.hiddenMatrix0Cam=new ue;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Di(new E(0,-40,0),new E(0,40,0)),matrix:new ue,position:new E,rotation:new Ye};this.euler=new Jt(0,0,0,"YXZ");this.eulerDelta=new E;this.lastPosition=new E;this.lastCameraQuaternion=new Ye;this.lastCameraPosition=new E;this.PI_2=Math.PI/2;this.prevMouse=new U;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 ue;this.nonColliderPosOffset=new ue;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 ue;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 Ye;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 Ye;this.objXZQuatInv=new Ye;this.objXZRotMat=new ue;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new E;this.pushedVelocity=new E;this.groundYRotation=0;this.objectRealQuat=new Ye;this.colliderWorldQuat=new Ye;this.groundNormal=new E;this.groundTilt=new Ye;this.groundTiltInv=new Ye;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new E;this.quaternion=new Ye;this.scale=new E;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Li&&!aA&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,i=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(aA&&xD<15.5&&!Li?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-i*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?x1.isLocked=!0:x1.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let i=2;i<4;i++){let s=e.axes[i];r===0?i===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,i===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(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(),d=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,d,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 g=new E(0,0,-1).applyQuaternion(this.camera.quaternion),y=new E().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let x,v;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,v=y.projectOnVector(g)):y.y/g.y>0?v=g.multiplyScalar(y.y/g.y):v=g.multiplyScalar(y.length()),this.targetToCamera0.copy(v).negate(),x=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(x,this.position);let b=new Jt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-b.x,b.x=0,b.z=0,b.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(b)}if(this.object instanceof ir&&(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)*Zee,this.speedOrbit=(i.speedRotate??100)*Jee,this.mouseOrbitSensitivity=(i.speedRotate??100)*$ee,this.keyAssignments=i.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),i.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][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??Wl.defaultData.gravity)*mV,this.usePhysics=this.gloabalPhysics.usePhysics??Wl.defaultData.usePhysics,this.jumpPower=i.jumpPower*ete,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??bd.defaultDataThirdPerson.orientWith,this.slopeThresh=qee*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*GM/this.pixelsPerMeter,this.stepThresh=i.collider.height*jM/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*GM/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*jM/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*GM/this.pixelsPerMeter,this.stepThresh=i.collider.height*jM/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let f=new E().fromArray(i.collider.position.map(g=>typeof g=="number"?g:0)),m=new Ye().setFromEuler(new Jt().fromArray([...i.collider.rotation.map(g=>typeof g=="number"?g:0),"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(m),this.collider.matrix.compose(f,m,pV),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.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let g=new Re;g.push({fi:0,data:{...Cr.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...Cr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let y=new $a({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Mt(Sx.create({parameters:{width:p,height:p/10,hollow:.7}}),y),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 r=new Jt().setFromQuaternion(this.quaternion,"YXZ"),i=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,i,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof ir?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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},xd.list.forEach(i=>{this.actions[i]=Wt({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,r,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"),vr(this.actions.idle),vr(this.actions.move),vr(this.actions.run),vr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(r=>{r.play()}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(r=>{r.stop()}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return On.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,r,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 s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let c=Yn.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*mV),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(u){this.onObject=!0,this.groundNormal.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),u.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=u.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(On,sl,Yn),this.groundVelocity.subVectors(On,d.prevT),this.object.getWorldPosition(Yn).add(this.collider.position).sub(On),this.groundYRotation=fa.setFromQuaternion(sl).y-d.prevR.y,wc.copy(Yn).applyAxisAngle(go,this.groundYRotation),this.groundVelocity.add(wc.sub(Yn)).divideScalar(s);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*o),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 c=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 u=On.subVectors(this.path[1],this.position),h=Yn.subVectors(this.path[1],this.path[0]);u.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),c.opacity=c.userData.opacity0}else c.opacity-=.05*c.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)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):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.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=Xee.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let c=Yn.copy(l);c.y=0,l.set(0,l.y,c.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let c=On;this.camera.getWorldDirection(c);let u=wc.copy(go).multiplyScalar(c.dot(go));c.sub(u);let h=Yn.copy(this.directionXZ);h.x*=-1,this.rot.y=c.angleTo(h)*(c.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(fa.setFromVector3(this.rot),this.moveMode==="walk"&&(fa.x=0),l.applyEuler(fa),a&&(sl.setFromUnitVectors(go,this.groundNormal),l.applyQuaternion(sl)),i){let c=fa.set(0,this.vrEulerYOffset*gV,0);i.applyEuler(c),l.x+=i.x,l.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*s}if(this.usePhysics===!0&&this.object.rigidBody){let c=Yn;this.pushedVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=wc.setFromMatrixPosition(u.matrixWorld).sub(u.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=u.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),On.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=gt.is(u)?u:u.object;if(d!==null&&this.lastHitObj!==f){let m;u instanceof Lr&&(m=u);let p=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(p)for(let g of p)g.data.target==="character"&&(g.dispatch(m),f.dispatchEvent(b1));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),c.copy(d.normal1).applyQuaternion(u.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let u=c.dot(l);u<0&&l.addScaledVector(c,-u),l.add(this.pushedVelocity)}else l.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(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(go,this.euler.y-this.euler0.y);let c=Yn.copy(this.objectToCamXZ).normalize(),u=wc.copy(l).multiplyScalar(s);u.y=0;let h=u.sub(On.copy(c).multiplyScalar(u.dot(c))).cross(c).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+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=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Se.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(fa.copy(r),fa.y=0):(fa.copy(this.euler),fa.y=0),this.nonColliderRotOffset.makeRotationFromEuler(fa)),r&&(this.moveMode==="walk"?(this.rot.y=r.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(r),this.rot.y+=this.vrEulerYOffset*gV),mo.setFromAxisAngle(Kee,this.rot.x),sl.setFromAxisAngle(go,this.rot.y),sl.multiply(mo),mo.setFromAxisAngle(Qee,this.rot.z),sl.multiply(mo),this.quaternion.copy(sl),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let c=Yn.copy(l).multiplyScalar(s/this.pixelsPerMeter),u=null;this.didHit=!1;let h=new E;for(let d=0;d<5;d++){let f=c.length(),m=wc.copy(c).normalize();if(u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,m,this.object.rigidBody.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),u!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(u.collider.handle);if(p!==this.lastHitObj&&d===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let b of v)if(b.data.target==="character"){let w=(this.sharedGameControlGlobals.rapierWorld?.getCollider(u.collider.handle))._parent,A;if(p.cloner){for(let T of p.cloner.children)if(T.rigidBody===w){A=T;break}}b.dispatch(A),p.dispatchEvent(b1)}}}let g=hV.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat),y=dV.copy(m).multiplyScalar(u.toi).dot(g),x=u.toi;if(x===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(x=u.toi*(y-this.offset)/y,h.addScaledVector(m,x)),c.copy(m).multiplyScalar(f-x),Math.acos(-g.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),b=wc.copy(u.witness2).applyQuaternion(this.colliderWorldQuat);b.y=0;let w=v.add(b);w.y+=this.stepThresh;let A=this.sharedGameControlGlobals.rapierWorld.castShape(w,this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);A!==null&&A.toi===0&&(g.y=0,g.normalize())}c.addScaledVector(g,-c.dot(g))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(c);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(On.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(mo.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let c=this.onObject?1:5,u=l.multiplyScalar(s/c);for(let h=0;h<c;h++)this.position.add(u),this.collisionAdjustment(s/c)}else this.position.addScaledVector(l,s);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 c=this.objectToTarget.add(this.position),u=this.targetToCamera.add(c);HM.lookAt(u,c,go).setPosition(u),HM.decompose(this.targetPos,this.targetQuat,On),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Se.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Se.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(rte),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(tte),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=mo.setFromAxisAngle(go,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Se.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 r;this.cameraXAxis==="Limit"?r=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=On.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let s=sl.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){go.angleTo(e)*180/Math.PI<15||go.angleTo(e)*180/Math.PI>85?mo.identity():mo.setFromUnitVectors(go,e),this.groundTilt.slerp(mo,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=dV.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=HM.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(On,mo,Yn).compose(On,mo,pV);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object)||!o.bvhGeometry||!o.bvhGeometry.boundsTree)return;Fs.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=fV.copy(a).invert(),c=Yee.copy(fV).multiply(i);Qi.copy(this.collider.segment),Qi.start.applyMatrix4(c),Qi.end.applyMatrix4(c);let u=hV.copy(this.position).applyMatrix4(l);Fs.expandByPoint(Qi.start),Fs.expandByPoint(Qi.end),Fs.min.addScalar(-this.collider.radius),Fs.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Qi.end)},intersectsBounds:h=>h.intersectsBox(Fs),intersectsTriangle:h=>{let d=On,f=Yn,m=h.closestPointToSegment(Qi,d,f);if(m<this.collider.radius){let p=this.collider.radius-m,g=f.sub(d).normalize(),y=wc.copy(u);y.addScaledVector(g,p);let x=y.applyMatrix4(a).sub(this.position);r.add(x),Qi.start.addScaledVector(g,p),Qi.end.addScaledVector(g,p)}}})}),Fs.makeEmpty(),Qi.copy(this.collider.segment),Qi.start.applyMatrix4(i),Qi.end.applyMatrix4(i),Fs.expandByPoint(Qi.start),Fs.expandByPoint(Qi.end),Fs.min.addScalar(-this.collider.radius),Fs.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(Qi.end)},intersectsBounds:o=>o.intersectsBox(Fs),intersectsTriangle:o=>{let a=On,l=Yn,c=o.closestPointToSegment(Qi,a,l);if(c<this.collider.radius){let u=this.collider.radius-c,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),r.addScaledVector(h,u),Qi.start.addScaledVector(h,u),Qi.end.addScaledVector(h,u)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(s),this.position.add(r)}pause(){this.firstPointerId=-1,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.deactivate()}resume(){this.activate()}},Wg=x1;Wg.isLocked=!1;var yV=cl(ME());function qM(n){let t=n.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,i=t[8]**2+t[9]**2+t[10]**2,s=t[0]**2+t[4]**2+t[8]**2,o=t[1]**2+t[5]**2+t[9]**2,a=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||i<l||s<l||o<l||a<l}function yo(n,t){let e=new Ce;if(t&&qM(t))return e.setAttribute("position",new Te([],3)),e.setIndex([]),e;if(!n.getAttribute("position"))return e.setAttribute("position",new Te([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=hu(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new Te(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}var ite=new ue,nte=new ue,pa=[[0,0,0],[0,0,0],[0,0,0]];function XM(n){let t=n.elements;pa[0][0]=t[0],pa[0][1]=t[4],pa[0][2]=t[8],pa[1][0]=t[1],pa[1][1]=t[5],pa[1][2]=t[9],pa[2][0]=t[2],pa[2][1]=t[6],pa[2][2]=t[10];let{u:e,v:r}=(0,yV.SVD)(pa),i=ite.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=nte.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 i.multiply(s.transpose())}var S1=class extends xh{constructor(){super(),this.layers.enable(3),this.layers.enable(8),this.layers.enable(9)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,r=[]){return t.forEach(i=>{i.visible&&this.intersectObject(i,e,r)}),r}createRaycastLineHelper(){let t=new ms({color:65280,linewidth:10}),e=new E(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new E(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new E().addVectors(e,r.multiplyScalar(i)),o=new Ce;return o.setFromPoints([e,s]),new Uc(o,t)}};var vV=n=>n instanceof Ns||n instanceof ho;function ste(n,t){return n.distance-t.distance}function xV(n,t,e){if(!(!Qo(t)||!t.visible)){Wn(t)&&t.raycast(n,e);for(let r of t.children)xV(n,r,e)}}function cp(n,t,e,r=!1){if(!r&&!e.some(s=>up(n,s)!==void 0))return[];let i=[];return t.children.forEach(s=>xV(n,s,i)),i.sort(ste),i}function qg(n){let t=[];if(n.length){let e=n[0].object;Qo(e)&&t.push(e);let r=e.parent;for(;r;)vV(r)&&t.push(r),r=r.parent}return t}function vo(n,t,e,r){let i=n.frame;if(i){let s=t[0]*i.width,o=(1-t[1])*i.height;for(let a of e){let l=a===i.uuid?i:i.find(a);if(l?.intersects(s,o))return r(l),!0}}return!1}function up(n,t){if(Wn(t)){if(t.visible){let e=[];return t.raycast(n,e),e.length?e[0]:void 0}}else if(vV(t))return bV(n,t)}function bV(n,t){if(!(!Qo(t)||!t.visible)){if(Wn(t)){let e=[];if(t.raycast(n,e),e.length)return e[0]}for(let e of t.children){let r=bV(n,e);if(r)return r}}}function ote(n,t,e){return{x:(n-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}function ate(n,t,e){return{x:(n-(e.left+window.scrollX))/e.width,y:1-(t-(e.top+window.scrollY))/e.height}}var w1=class{constructor(t,e,r,i,s,o,a,l){this.renderer=t;this.publish=e;this.scene=r;this.getCamera=i;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new S1;this._useWindowEvents=!1;this.pointerWorld={x:0,y:0};this.pointerScreen={x:0,y:0};this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(t){this._domRect=t}get domRect(){return this._domRect}updateRaycaster(t){let{pageX:e,pageY:r}=t.touches?.length>0?t.touches[0]:t;this.pointerWorld=ote(e,r,this._domRect),this.pointerScreen=ate(e,r,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}};var Qt=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var YM=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],SV=n=>YM.find(([t,e])=>e===n)?.[0],ma=n=>YM.find(([t])=>t===n)?.[1],lte=(n,t)=>{let e=SV(n);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},A1=class extends Qt{constructor(){super(...arguments);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let r=this.splineEvents[SV(e.eventName)]?.[e.target.uuid];if(!r)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(r,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(r)}}connect(){let{page:e}=this.eventContext;e.traverseEntity(r=>{if(!!r.data?.events.length){for(let[i,s]of YM)if(r.data.events.some(o=>o.data.type===s&&!o.data.disabled)){this.objectsPerEvents.has(i)?this.objectsPerEvents.get(i)?.push(r):this.objectsPerEvents.set(i,[r]);let o={id:r.uuid,name:r.name},a=lte(s,o),l=this.splineEvents[i];l?l[r.uuid]=a:this.splineEvents[i]={[r.uuid]:a}}}}),this.objectsPerEvents.forEach(r=>{r.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.removeEventListener("beginEvent",this.onBeginEvent)})})}};var KM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;if((e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=Wt(e,e.actions,i,s,o,r)}disconnect(){vr(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(i=>i.playing&&i.data.runMode!=="Toggle")||this.actions.Transition.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()}),this.actions.SwitchCamera.some(i=>i.playing&&i.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()}),this.actions.Animation.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()}),this.actions.TimelineAnimation.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},E1=class extends Qt{constructor(e,r,i){super(e);this.eventManager=r;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=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=cp(r,i,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{(r.data.type==="MouseDown"||r.data.type==="MousePress")&&(this.onCanvasRaycast(e),r.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{r.data.type==="MouseUp"?(this.onCanvasRaycast(e),r.dispatch()):r.data.type==="MousePress"&&r.dispatchRelease()})};this.onMouseDown=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=ma(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent(i)}),this.canvasMouseEvents.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent()})))}}connect(){let{page:e,sharedAssets:r,domElement:i}=this.eventContext,s=(o,a)=>{if(!o.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let c of l){let u=this.eventsPerObjects[c];if(o.data.events.filter(({data:h})=>h.type===c&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new KM(h,d,o,e,r,this.eventManager);f.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(f):(u[o.uuid]?u[o.uuid].some(m=>m.id===f.id)||u[o.uuid].push(f):u[o.uuid]=[f],o instanceof cs&&o.traverseChildren(m=>{if(!m.visible)return!0;m instanceof Ct&&"shapeBlendNode"in m.data.geometry&&m.data.geometry.shapeBlendNode?.operation!==2&&(u[m.uuid]?u[m.uuid].push(f):u[m.uuid]=[f])}))}catch(f){!1&&console.error(f)}}),u[o.uuid]?.length&&(this.objectsPerTypes[c].push(o instanceof hr&&(c==="MouseDown"||c==="MouseUp"||c==="MousePress")?a:o),o instanceof cs)){let h=this.objectsPerTypes[c];o.traverseChildren(d=>{if(!d.visible)return!0;d instanceof Ct&&h.indexOf(d)===-1&&h.push(d)})}}};e.traverseEntity(o=>{(o instanceof _r||o instanceof yr)&&o.frame?.traverse(a=>{s(a,o)}),s(o)}),this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),i.addEventListener("pointerdown",this.onCanvasMouseDown),i.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),i.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(([o,a])=>{a.forEach(l=>{l.addEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(o=>{o.object.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(r=>{Object.values(r).forEach(i=>{i.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(r=>{r.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([r,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(r=>{r.object.removeEventListener("userEvent",this._onUserEvent)})}handleMouseEvent(e){let{stopRaycast:r,raycaster:i,page:s,pointerScreen:o}=this.eventContext,a=this.objectsPerTypes[e],l=a.filter(c=>!(c instanceof hr));if(!(!a.length&&!this.useForRaycastProperty)&&!(s.uiCanvas&&vo(s,[o.x,o.y],Object.keys(this.eventsPerObjects[e]),u=>{this.handleObjectMouseEventDispatch(u,e)}))){if(r||this.useForRaycastProperty){let c;if(this.sceneInterects===null?c=cp(i,s,l,this.useForRaycastProperty):(c=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&c.length&&(this.eventContext.sharedAssets.raycastProperty={x:c[0].point.x,y:c[0].point.y,z:c[0].point.z,objX:c[0].object.matrixWorld.elements[12],objY:c[0].object.matrixWorld.elements[13],objZ:c[0].object.matrixWorld.elements[14]}),r){let u=[c[0]?.uv?.x??0,c[0]?.uv?.y??0];qg(c).forEach(h=>{h instanceof _r&&vo(h,u,Object.keys(this.eventsPerObjects[e]),d=>{this.handleObjectMouseEventDispatch(d,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}r||l.forEach(c=>{let u=up(i,c);u&&(this.handleObjectMouseEventDispatch(c,e),c instanceof _r&&vo(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let r="MousePress",i=this.objectsPerTypes[r],s=i.filter(a=>!(a instanceof hr)),o=[];if(!!i.length){if(!e){let{stopRaycast:a,raycaster:l,page:c,pointerScreen:u}=this.eventContext,h=!1;if(c.uiCanvas&&(h=vo(c,[u.x,u.y],Object.keys(this.eventsPerObjects[r]),d=>{o.push(d)})),a&&!h){let d=cp(l,c,s);o=qg(d),d.forEach(f=>{f.object instanceof _r&&vo(f.object,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),m=>{o.push(m)})})}else s.forEach(d=>{let f=up(l,d);f&&(o.push(d),d instanceof _r&&vo(d,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),m=>{o.push(m)}))})}this._prevObjects.length&&this._prevObjects.forEach(a=>{o.includes(a)||this.handleObjectMouseEventDispatchRelease(a,r)}),o.length&&o.forEach(a=>{this.handleObjectMouseEventDispatch(a,r)}),this._prevObjects=o}}handleObjectMouseEventDispatch(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,r,i=!1){this.objectsPerTypes[r].forEach(s=>{let o=this.eventsPerObjects[r][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:r}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,r,i=!1){this.objectsPerTypes[r].forEach(s=>{this.eventsPerObjects[r][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(i)})})}};var cte=new E,ute=new E;var T1=class{constructor(t,e,r,i,s){this.actionsIn=Wt(t,t.inActions,r,i,s,e),this.actionsOut=Wt(t,t.outActions,r,i,s,e)}disconnect(){vr(this.actionsIn),vr(this.actionsOut)}};var QM=class extends T1{constructor(e,r,i,s,o,a){super(r,i,s,o,a);this.id=e;this.data=r;this.object=i;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=cte.setFromMatrixPosition(this.objects[0].matrixWorld),r=ute.setFromMatrixPosition(this.objects[1].matrixWorld),i=e.distanceTo(r)<=this.distance?"in":"out";if(this.stage!==i){this.stage=i;let s=i==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Particles.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.TimelineAnimation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch()),s.DynamicVariablePlay.forEach(o=>o.dispatch()),s.ClearLocalStorage.forEach(o=>o.dispatch()),s.UserAPI.forEach(o=>o.dispatch())}};let{distance:l,fromObject:c,toObject:u}=r.condition;this.distance=l;for(let h of[c,u]){if(!h)throw new Error("Missing property");let d=s.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}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)})}},ZM=class extends T1{constructor(e,r,i,s,o,a){super(r,i,s,o,a);this.id=e;this.data=r;this.object=i;this.onBegin=({target:e,state:r})=>{this.toState!==r&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Particles.forEach(i=>i.dispatchConditional()),this.actionsOut.Video.forEach(i=>i.dispatchConditional()),this.actionsOut.Link.forEach(i=>i.dispatch()),this.actionsOut.Create.forEach(i=>i.dispatch()),this.actionsOut.Destroy.forEach(i=>i.dispatch()),this.actionsOut.Reset.forEach(i=>i.dispatch()),this.actionsIn.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(i=>i.play()),this.actionsOut.Animation.forEach(i=>i.play()),this.actionsOut.TimelineAnimation.forEach(i=>i.play()),this.actionsIn.SwitchCamera.forEach(i=>i.pause()),this.actionsOut.SwitchCamera.forEach(i=>i.play()),this.actionsOut.SceneTransition.forEach(i=>i.dispatch()),this.actionsOut.SetVariable.forEach(i=>i.checkConditions()),this.actionsOut.SetVariable.forEach(i=>i.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(i=>i.dispatch()),this.actionsOut.ClearLocalStorage.forEach(i=>i.dispatch()),this.actionsOut.UserAPI.forEach(i=>i.dispatch()))};this.onComplete=({target:e,state:r})=>{this.toState===r&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Particles.forEach(i=>i.dispatchConditional()),this.actionsIn.Video.forEach(i=>i.dispatchConditional()),this.actionsIn.Link.forEach(i=>i.dispatch()),this.actionsIn.Create.forEach(i=>i.dispatch()),this.actionsIn.Destroy.forEach(i=>i.dispatch()),this.actionsIn.Reset.forEach(i=>i.dispatch()),this.actionsOut.Transition.forEach(i=>i.pause()),this.actionsOut.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(i=>i.play()),this.actionsIn.Animation.forEach(i=>i.play()),this.actionsIn.TimelineAnimation.forEach(i=>i.play()),this.actionsOut.SwitchCamera.forEach(i=>i.pause()),this.actionsIn.SwitchCamera.forEach(i=>i.play()),this.actionsIn.SceneTransition.forEach(i=>i.dispatch()),this.actionsIn.SetVariable.forEach(i=>i.checkConditions()),this.actionsIn.SetVariable.forEach(i=>i.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(i=>i.dispatch()),this.actionsOut.ClearLocalStorage.forEach(i=>i.dispatch()),this.actionsOut.UserAPI.forEach(i=>i.dispatch()))};let{condition:l}=r;if(!l.object)throw new Error("Missing property");let c=s.find(l.object)??s.scene.find2D(l.object);if(!c)throw new Error("Missing property");if(this.toObject=c,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){vs(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),vs(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),vs(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),vs(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},M1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1}connect(){super.connect();let{page:e,sharedAssets:r}=this.eventContext;e.traverseEntity(i=>{if(!!i.data?.events.length){for(let{id:s,data:o}of i.data.events)if(!o.disabled&&o.type==="Conditional")try{let a;o.condition.type==="Comparison"||(o.condition.type==="Distance"?a=new QM(s,o,i,e,r,this.eventManager):o.condition.type==="State"&&(a=new ZM(s,o,i,e,r,this.eventManager))),a&&(this.eventsPerConditions[o.condition.type].push(a),(a.actionsIn.Video.length||a.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(a){!1&&console.error(a)}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(s=>s.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.disconnect()))}};var Xg=new E,Ac=new E,Pu=new E,wV=new qr,hte=.01,dr=new E,Vi=new E,AV=new E,_u=new Ye,JM=new Jt,dte=new ue,$M=new Sr,hp=new E,ga=new E,dp=.2;function eC(n,t){!t||(t[0]<t[1]&&(n.x=Math.min(Math.max(n.x,t[0]),t[1])),t[2]<t[3]&&(n.y=Math.min(Math.max(n.y,t[2]),t[3])),t[4]<t[5]&&(n.z=Math.min(Math.max(n.z,t[4]),t[5])))}var fte=function(){let n=new ue;return(t,e,r)=>{let i=t.obj;n.copy(i.hiddenMatrix),i.parent!==null&&n.premultiply(i.parent.matrixWorld),n.invert(),i.position.copy(e),t.reference==="global"&&eC(i.position,t.limits),i.position.applyMatrix4(n),t.reference==="parent"?eC(i.position,t.limits):t.reference==="local"&&(_u.copy(t.quat0).invert(),i.position.sub(t.position0),i.position.applyQuaternion(_u),eC(i.position,t.limits),_u.invert(),i.position.applyQuaternion(_u),i.position.add(t.position0)),n.multiply(r??i.matrixWorld).decompose(dr,i.quaternion,Vi),i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i instanceof nr&&Dn(i.parent)&&i.invalidateDownstreamBooleanData(!0)}}(),tC=class{constructor(t,e,r,i,s,o,a){this.object=t;this.id=e;this.data=r;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=Wt(r,r.dragDropActions.drag,i,s,o,this.object),this.actionsDrop=Wt(r,r.dragDropActions.drop,i,s,o,this.object);let l=[];this.data.objects.forEach(c=>{let u=i.find(c);!u||u.data.visible!==!1&&(l.push(u),a[u.uuid]&&a[u.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&l.push(d)}))}),this.data.dropDestinations.forEach(c=>{let u=i.find(c);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),a[u.uuid]&&a[u.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=l.map(c=>(this.data.planeMode==="locked"&&(c.userData.lockedPlane=!0),c.userData.worldPosition0=new E().setFromMatrixPosition(c.matrixWorld),{obj:c,fromPosition:new E().setFromMatrixPosition(c.matrixWorld),pointStart:new E,pointEnd:new E,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new E().copy(c.position),quat0:new Ye().copy(c.quaternion),snapped:!1,orientationMatrix:new ue,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){vr(this.actionsDrag),vr(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},C1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(et.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=i.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:c,pointStart:u}of o.dragItems){if(l===s[0].object||l===s[0].object.object||gt.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,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 h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(dr,_u,Vi),JM.setFromQuaternion(_u),h.prevR===void 0?(h.prevR=JM.clone(),h.prevT=dr.clone()):(h.prevR.copy(JM),h.prevT.copy(dr)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,u,o.data.plane,o.data.referenceFrame),c.copy(u),(this.eventManager.controlsManager.usePhysics&&l.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}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(et.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=i.raycastWithClones(r);if(et.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||gt.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.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 a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof Ns)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(c=>c===l.object.uuid||i.scene.find(c).isAncestorOf(l.object.uuid))))[0]),a){let l=AV.copy(a.face.normal).applyMatrix3($M.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){dr.copy(l).applyMatrix3($M.setFromMatrix4(o.obj.matrixWorld).transpose());let c=o.obj;dr.x>dp?Vi.x=-c.recursiveBBox.min.x:dr.x<-dp&&(Vi.x=-c.recursiveBBox.max.x),dr.y>dp?Vi.y=-c.recursiveBBox.min.y:dr.y<-dp&&(Vi.y=-c.recursiveBBox.max.y),dr.z>dp?Vi.z=-c.recursiveBBox.min.z:dr.z<-dp&&(Vi.z=-c.recursiveBBox.max.z),Vi.applyMatrix3($M.invert())}else Vi.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Vi)}this.activeEvent.data.autoOrient&&(dr.set(0,1,0).cross(l),dr.length()<1e-4&&dr.set(-1,0,0).cross(l),Vi.crossVectors(AV,dr),o.orientationMatrix.makeBasis(dr,Vi,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Animation.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Audio.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(c=>{c.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(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.ClearLocalStorage.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.UserAPI.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=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||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(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(i=>{i.stop(),i.object.currentState!==null&&i.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(i=>{i.stop()}),this.activeEvent.actionsDrag.Audio.forEach(i=>{i.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(i=>{i.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(i=>i.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(i=>i.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(i=>i.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(i=>i.dispatch()),this.activeEvent.actionsDrop.UserAPI.forEach(i=>i.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}}}connect(){let e={};if(this.eventContext.page.traverseEntity(i=>{i.component&&(e[i.component.uuid]?e[i.component.uuid].push(i.uuid):e[i.component.uuid]=[i.uuid])}),this.eventContext.page.traverseEntity(i=>{i.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new tC(i,s.id,s.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,e))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let r=this.eventContext.domElement;r.addEventListener("pointerdown",this.onPointerDown),r.addEventListener("pointermove",this.onPointerMove),r.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(r=>r.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let r of e.dragItems)r.paused||this.updateDragItem(r,!0)}calcPlaneIntersectPos(e,r,i,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(Ac),Ac.negate();let l=_u.identity();switch(s==="parent"?dte.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(dr,l,Vi):s==="local"&&e.matrixWorld.decompose(dr,l,Vi),i){case"x":dr.set(1,0,0).applyQuaternion(l),hp.copy(Ac).cross(dr),ga.copy(dr).cross(hp);break;case"y":dr.set(0,1,0).applyQuaternion(l),hp.copy(Ac).cross(dr),ga.copy(dr).cross(hp);break;case"z":dr.set(0,0,1).applyQuaternion(l),hp.copy(Ac).cross(dr),ga.copy(dr).cross(hp);break;case"xy":ga.set(0,0,1).applyQuaternion(l);break;case"yz":ga.set(1,0,0).applyQuaternion(l);break;case"xz":ga.set(0,1,0).applyQuaternion(l);break;case"adaptive":Ac.angleTo(Vi.set(0,1,0))>Math.PI/6?(dr.crossVectors(Vi.set(0,1,0),Ac),ga.crossVectors(dr,Vi)):ga.set(0,1,0);break;default:ga.copy(Ac);break}Pu.setFromMatrixPosition(e.matrixWorld);let c=e.userData.lockedPlane?e.userData.worldPosition0:Pu;if(wV.setFromNormalAndCoplanarPoint(ga,c),!!a.ray.intersectPlane(wV,r)&&(i==="x"||i==="y"||i==="z")){let u=Vi.subVectors(r,c).dot(dr);r.copy(c).addScaledVector(dr,u)}}updateDragItem(e,r=!1){Pu.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Xg.subVectors(e.fromPosition,Pu).divideScalar(e.currentDampingFactor):e.reset==="original"?(Xg.subVectors(e.obj.userData.worldPosition0,Pu).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Xg.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Pu).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Xg.length()<hte:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&fte(e,Xg.add(Pu),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var fp=new E,rC=new E,ol=new E,al=new E,EV=new qr,pte=.01,mte={type:"requestRender"},gte=function(){let n=new E,t=new E;return(e,r,i)=>i>0?(n.subVectors(e,r),n.length()<=i?e:t.copy(r).add(n.normalize().multiplyScalar(i))):r}(),TV=function(){let n=new ue;return(t,e)=>{t.position.copy(e),t.parent!==null&&(n.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(n)),n.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(n),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof nr&&Dn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),iC=class{constructor(t,e,r,i,s,o){this.data=t;this.id=e;this.object=r;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={...y0.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=i.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Wt(t,t.actions,i,s,o,r)}},P1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(et.length>1)){this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!e.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new iC(o.data,o.id,s,e,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:r,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),Li&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(r.addEventListener("pointerenter",this.onMouseEnter),r.addEventListener("pointerleave",this.onMouseLeave));for(let s of this.events)if(s.target!==void 0){let o=s.target,a=this.onTargetChange(s);this.pairOfEventListeners.push([o,a]),o.addEventListener("requestRender",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Li&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let i of this.events)i.paused=!0,i.isReset=!1,vr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,r=!1){this.events.forEach(l=>{l.actions.Create.forEach(c=>{c.dispatchThrottled()})});let{plane:i,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(ol),e.isReset)al.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(al);else{let{getCamera:l,raycaster:c}=this.eventContext;if(i==="custom"?(l().getWorldDirection(rC),rC.negate(),fp.copy(rC)):i==="xy"?fp.set(0,0,1):i==="xz"?fp.set(0,1,0):i==="yz"&&fp.set(1,0,0),EV.setFromNormalAndCoplanarPoint(fp,ol),!c.ray.intersectPlane(EV,al))return}if(!e.isReset){if(al.distanceTo(e.worldPosition0)>s&&o&&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)al.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&&(al.x=ol.x),e.data.enabledTranslation[1]===!1&&(al.y=ol.y),e.data.enabledTranslation[2]===!1&&(al.z=ol.z);let a=gte(ol,al,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=fp.subVectors(a,ol).divideScalar(e.currentDampingFactor);ol.add(l),r&&TV(e.object,ol),e.paused=l.length()<pte}else TV(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(mte)}};var Yg=new E,_1=new E,Kg=new ue,pp=new Ye,Ec=new Ye,Qg=new E,Zg=new E,Iu=new E,ll=new E,nC=new qr,yte=1e-6,vte={type:"requestRender"},xte={type:"changeRotation"},MV=function(){let n=new ue;return function(e,r){e.parent!==null?n.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):n.copy(e.hiddenMatrix),r.premultiply(XM(n).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof nr&&Dn(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),sC=class{constructor(t,e,r,i){this.id=e;this.object=r;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Ye;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...v0.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=i.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),isNaN(this.worldQuaternion0.x)&&(this.worldQuaternion0.x=0),isNaN(this.worldQuaternion0.y)&&(this.worldQuaternion0.y=0),isNaN(this.worldQuaternion0.z)&&(this.worldQuaternion0.z=0),isNaN(this.worldQuaternion0.w)&&(this.worldQuaternion0.w=1),this.resetDampingFactor=80/this.data.resetSpeed+1}},I1=class extends Qt{constructor(){super(...arguments);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(et.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{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=e=>{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=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:r,target:i})=>{if(!r||!i)return;let s=ma(r);s&&s==="LookAt"&&this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="LookAt"&&!a.data.disabled);o&&(!e.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new sC(o.data,o.id,s,e))}),!this.events.length)return;let{domElement:r,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),Li&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(r.addEventListener("pointerenter",this.onMouseEnter),r.addEventListener("pointerleave",this.onMouseLeave));for(let s of this.events){if(s.target!==void 0){let l=this.onTargetChange(s),c=s.target;this.pairOfEventListeners.push([c,l]),c.addEventListener("requestRender",l)}let o=this.createUserEventListener(s),a=s.object;this.pairOfUserEventListeners.push([a,o]),a.addEventListener("userEvent",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Li&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),r.removeEventListener("scroll",this.onScroll);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let[i,s]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",s);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:r,axis:i,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:c}=e.data,{getCamera:u,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(Qg),!e.isReset)if(e.target)e.target.getWorldPosition(Zg);else{if(o==="custom"?(u().getWorldDirection(_1),_1.negate(),nC.setFromNormalAndCoplanarPoint(_1,Qg)):(o==="xy"?Yg.set(0,0,1):o==="xz"?Yg.set(0,1,0):o==="yz"&&Yg.set(1,0,0),nC.setFromNormalAndCoplanarPoint(Yg,Qg)),!h.ray.intersectPlane(nC,Zg))return;s>0&&(o==="custom"||o===void 0)&&Zg.addScaledVector(_1,s)}if(e.isReset||(f?r==="target"?Iu.copy(f.up).applyMatrix4(Kg.extractRotation(f.matrixWorld)).normalize():l.some(m=>m===!1)?(i==="x"?(ll.set(0,0,1),l[2]===!1&&ll.set(0,1,0)):i==="y"?(ll.set(1,0,0),l[0]===!1&&ll.set(0,0,1)):(ll.set(0,1,0),l[1]===!1&&ll.set(1,0,0)),Iu.copy(ll).applyQuaternion(e.worldQuaternion0).normalize()):Iu.set(0,1,0):o==="custom"?Iu.set(0,1,0):Iu.copy(Yg)),e.isReset)Ec.copy(e.worldQuaternion0);else if(Qg.distanceTo(Zg)>a&&c&&f)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)Ec.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;bte(Kg,Zg,Qg,Iu,i,ll),Ec.setFromRotationMatrix(Kg),pp.setFromUnitVectors(ll.applyQuaternion(Ec),Iu),l.some(m=>m===!1)&&r!=="target"&&Ec.premultiply(pp).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),pp.setFromRotationMatrix(XM(d.matrixWorld)),pp.slerp(Ec,1/e.currentDampingFactor),MV(d,Kg.makeRotationFromQuaternion(pp)),e.paused=8*(1-pp.dot(Ec))<yte):(MV(d,Kg.makeRotationFromQuaternion(Ec)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(vte),d.dispatchEvent(xte)}},Vs=new E,Ui=new E,fi=new E;function bte(n,t,e,r,i,s){let o=n.elements;fi.subVectors(t,e),fi.lengthSq()===0&&(fi.z=1),fi.normalize(),Ui.crossVectors(r,fi),Ui.lengthSq()===0&&(Math.abs(r.z)===1?fi.x+=1e-4:fi.z+=1e-4,fi.normalize(),Ui.crossVectors(r,fi)),Ui.normalize(),Vs.crossVectors(fi,Ui),i==="x"?s.z===1?[Ui,Vs,fi]=[fi,Ui,Vs]:(Ui.negate(),[Ui,fi]=[fi,Ui]):i==="y"?s.x===1?[Ui,Vs,fi]=[Vs,fi,Ui]:(Ui.negate(),[Vs,fi]=[fi,Vs]):s.x===1&&(Ui.negate(),[Ui,Vs]=[Vs,Ui]),o[0]=Ui.x,o[4]=Vs.x,o[8]=fi.x,o[1]=Ui.y,o[5]=Vs.y,o[9]=fi.y,o[2]=Ui.z,o[6]=Vs.z,o[10]=fi.z}var oC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=Wt(e,e.actions,i,s,o,r)}disconnect(){vr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatchStart()),this.actions.Particles.forEach(t=>t.dispatchBasic()),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()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()),this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Particles.forEach(e=>e.dispatchBasic()),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()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},D1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObjects={};this.objects=[];this.objects2D=[];this._prevObjects=[];this.onMouseDown=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{et.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=ma(e);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(o=>o.dispatchUserEvent(i)))}}connect(){let{page:e,sharedAssets:r}=this.eventContext,i=(o,a)=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:l,data:c}of o.data.events)if(!c.disabled&&c.type==="MouseHover")try{let u=new oC(l,c,o,e,r,this.eventManager);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.error(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o instanceof hr?a:o)}};if(e.traverseEntity(o=>{(o instanceof _r||o instanceof yr)&&o.frame?.traverse(a=>{i(a,o)}),i(o)}),!this.objects.length)return;let{domElement:s}=this.eventContext;this.domEventsNeeded.clear(),Li&&(this.domEventsNeeded.add("pointerdown"),s.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),s.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),s.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(o=>{o.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Li&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(r=>{r.forEach(i=>{i.disconnect()})}),this.objects.forEach(r=>{r.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let r=[];if(!e){let{stopRaycast:i,raycaster:s,page:o,pointerScreen:a}=this.eventContext,l=!1;if(o.uiCanvas&&(l=vo(o,[a.x,a.y],Object.keys(this.eventsPerObjects),c=>{r.push(c)})),i&&!l){let c=cp(s,o,this.objects);r=qg(c),c.forEach(u=>{u.object instanceof _r&&vo(u.object,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)})})}else this.objects.forEach(c=>{let u=up(s,c);u&&(r.push(c),c instanceof _r&&vo(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{r.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),r.length&&r.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=r}};var aC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=Wt(e,e.actions,i,s,o,r)}connect(){this.scrollCounter=0}disconnect(){vr(this.actions)}dispatch(t){this.actions.Transition.forEach(i=>{i.object.currentTransitionEvent!==this&&(i.object.currentTransitionEvent=this,i.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let r=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(i=>i.seek(r)),this.actions.Animation.forEach(i=>i.seek(e)),this.actions.TimelineAnimation.forEach(i=>i.seek(r)),this.actions.Create.forEach(i=>i.dispatchThrottled()),this.actions.SetVariable.forEach(i=>i.checkConditions()),this.actions.SetVariable.forEach(i=>i.dispatch()),this.actions.DynamicVariablePlay.forEach(i=>i.dispatch()),this.actions.ClearLocalStorage.forEach(i=>i.dispatch()),this.actions.UserAPI.forEach(i=>i.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()}),this.actions.TimelineAnimation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},lC=class{constructor(t,e,r,i,s,o,a){this.id=t;this.data=e;this.object=r;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=Wt(e,e.actions,i,s,a,r)}getStickyParentElement(){let t=this.domElement;for(;t;){if(window.getComputedStyle(t).position==="sticky")return t;t=t.parentElement}return null}computeScrollBounds(){let t=this.getStickyParentElement(),e=t?.parentElement,r=this.domElement.getBoundingClientRect(),i={top:r.top,bottom:r.bottom,left:r.left,right:r.right,width:r.width,height:r.height};if(e){let u=e.getBoundingClientRect(),h=window.getComputedStyle(t),d=parseFloat(h.marginTop)+parseFloat(h.marginBottom),f=parseFloat(h.top),m=parseFloat(h.bottom),p=u.height-d;if(!isNaN(f))r.top===f?(i.top+=u.top-f,i.bottom+=u.top-f):r.top<0&&(i.top-=p-r.height,i.bottom-=p-r.height);else if(!isNaN(m)){let g=document.body.clientHeight??window.innerHeight,y=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);r.bottom===g-m?(i.top+=u.top-r.height+m+y,i.bottom+=u.top-r.height+m+y):r.bottom<g-m&&(i.top-=p-r.height,i.bottom-=p-r.height)}}let s=document.body,o=document.documentElement,a=window.pageYOffset||o.scrollTop||s.scrollTop,l=o.clientTop||s.clientTop||0,c=Math.round(i.top+a-l);if(this.data.startFrom==="enter"){let u=window.innerHeight,h=i.height,d=this.data.enterAnchor,f=d==="top"?u:d==="bottom"?u-h:u-h*.5;this.scrollStart=c-f}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=i,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){vr(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:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let r=this.scrollEnd-this.scrollStart,i=Math.min(1,Math.max(0,(e-this.scrollStart)/r));this.actions.Transition.forEach(s=>s.seek(i)),this.actions.Animation.forEach(s=>s.seek(i)),this.actions.TimelineAnimation.forEach(s=>s.seek(i)),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()),this.actions.ClearLocalStorage.forEach(s=>s.dispatch()),this.actions.UserAPI.forEach(s=>s.dispatch())}dispatch(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()}),this.actions.TimelineAnimation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},O1=class extends Qt{constructor(e,r){super(e);this.managers=r;this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(i=>i.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([i,s])=>{i.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(o=>o.dispatch(r))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,i])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),i.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=ma(e);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(i)}))}}connect(){let{page:e,sharedAssets:r,domElement:i,isExport:s}=this.eventContext,o=a=>{if(!!a.data?.events.length){for(let{id:l,data:c}of a.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!s){let u=new aC(l,c,a,e,r,this.managers);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(u):this.wheelEventsPerObject.set(a,[u])}else{let u=new lC(l,c,a,e,r,i,this.managers);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(u):this.scrollEventsPerObject.set(a,[u])}}};e.traverseEntity(a=>{(a instanceof _r||a instanceof yr)&&a.frame?.traverse(l=>{o(l)}),o(a)}),this.intersectionObserver=new IntersectionObserver(a=>{let l=a[0];l&&(this.isInview=l.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([a,l])=>{l.forEach(c=>c.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([a,l])=>{l.forEach(c=>c.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(a=>a.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,r])=>{r.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var cC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Wt(e,e.actions,i,s,o,r)}disconnect(){vr(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.TimelineAnimation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Reset.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.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof da?e.interaction.audioPlayer?.play():e.interaction instanceof np&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof po?e.interaction.play(r==="autoplay"):e.interaction instanceof lp&&e.interaction.dispatch())}),this.actions.Particles.forEach(e=>{(e.data.triggerAfter??"any")===t&&e.dispatchBasic()})}async seekVideos(t){let e=[];this.actions.Video.forEach(r=>{(r.interaction.data.triggerAfter??"autoplay")==="autoplay"&&r.interaction instanceof po&&e.push(r.interaction.seek(t))}),await Promise.all(e)}pauseVideos(){this.actions.Video.forEach(t=>{t.interaction instanceof po&&t.interaction.pause()})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Reset.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.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof da?e.interaction.audioPlayer?.play():e.interaction instanceof np&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof po?e.interaction.play():e.interaction instanceof lp&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},R1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:r}=this.eventContext,i=r?document:e;i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.actions.Audio.forEach(s=>{s.interaction instanceof da&&s.interaction.audioPlayer?.play()}),i.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof po&&s.interaction.play(o==="autoplay")}),i.actions.Particles.forEach(s=>{s.dispatchBasic()})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.dispatchAfter("autoplay")})})};this.seekVideos=async e=>{let r=[];[...this.eventsAfterPerObject.entries()].forEach(([i,s])=>{!i.data.visible||s.forEach(o=>{r.push(o.seekVideos(e))})}),await Promise.all(r)};this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{r.forEach(i=>{i.pauseVideos()})})};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=ma(e);s&&s==="Start"&&(r instanceof hr||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(i)}))}}connect(){let{sharedAssets:e,page:r}=this.eventContext,i=s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let l=new cC(o,a,s,r,e,this.eventManager);(l.actions.Transition.length||l.actions.TimelineAnimation.length||l.actions.Animation.length||l.actions.SwitchCamera.length||l.actions.Create.length||l.actions.Destroy.length||l.actions.SceneTransition.length||l.actions.Reset.length||l.actions.SetVariable.length||l.actions.DynamicVariablePlay.length||l.actions.ClearLocalStorage.length||l.actions.UserAPI.length)&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])),l.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Particles.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l]))}};if(r.traverseEntity(s=>{(s instanceof _r||s instanceof yr)&&s.frame?.traverse(o=>{i(o)}),i(s)}),[...this.eventsAfterPerObject.values()].some(s=>s.length)){if(this.eventManager.activateCount===0){let{domElement:s,isExport:o}=this.eventContext,a=o?document:s;a.addEventListener("pointerdown",this.onMouseDown,{once:!0}),a.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),a.addEventListener("pointerdown",this.onAny),a.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([l,c])=>{l.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>a.dispatch()),s.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:r}=this.eventContext,i=r?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(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,r])=>{e.removeEventListener("userEvent",this.onUserEvent),r.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var L1=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.initialDisabled=!1;this.actions=Wt(e,e.actions,i,s,o,r),this.target=e.target}disconnect(){vr(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Animation.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}};var N1=class extends Qt{constructor(e,r,i,s,o){super(e);this.sharedVariables=r;this.eventManager=i;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.isOutOfFocus=!1;this.events=[];this.onFrame=e=>{let r=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let i=new Date,s=[],o=[];for(let c=0;c<this.propertiesToWatch.length;c++){let{objectId:u,property:h,prevValue:d}=this.propertiesToWatch[c],f=this.eventContext.scene.find(u),m=b0.propertyPaths[h];if(m[0]==="width"||m[0]==="height"||m[0]==="depth")f=f.geometry.userData.parameters[m[0]];else for(let p=0;p<m.length;p++)f=f[m[p]];d===null?this.propertiesToWatch[c].prevValue=f instanceof E?f.clone():f:(f instanceof E?!f.equals(d):d!==f)&&(o.push({objId:u,property:h}),f instanceof E?this.propertiesToWatch[c].prevValue.copy(f):this.propertiesToWatch[c].prevValue=f)}for(let c=0;c<this.variablesToWatch.length;c++){let{id:u,prevValue:h}=this.variablesToWatch[c],d=r.getVariable(u);d!==h&&(s.push(u),this.variablesToWatch[c].prevValue=d)}for(let c=0;c<this.dynamicVars.length;c++){let{id:u,expectedTime:h,last:d,data:f,timerSeconds:m,startValue:p}=this.dynamicVars[c],g=1e3;if((f.dynamicVariableType==="timer"||f.dynamicVariableType==="stopwatch")&&f.format==="number3decimal"?g=1:f.dynamicVariableType==="counter"?g=f.updateInterval:f.dynamicVariableType==="random"&&(g=f.isStatic?1/0:f.updateInterval),h===-1){this.dynamicVars[c].last=e,this.dynamicVars[c].expectedTime=e+g;continue}if(!((r.getDynamicVariablePlayState(u)==="Stopped"||r.getDynamicVariablePlayState(u)==="Restarted")&&(this.dynamicVars[c].last=e,this.dynamicVars[c].expectedTime=e+g,f.dynamicVariableType==="counter"&&r.getVariable(u)!==p&&(r.updateVariable(u,p),this.eventManager.requestRender()),(f.dynamicVariableType==="timer"||f.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==p&&(this.dynamicVars[c].timerSeconds=p,r.updateVariable(u,An.getFormattedTimerTime(p,f)),this.eventManager.requestRender()),r.getDynamicVariablePlayState(u)==="Restarted"&&r.setDynamicVariablePlayState(u,"Playing"),r.getDynamicVariablePlayState(u)==="Stopped"))){if(r.getDynamicVariablePlayState(u)==="Paused"){this.dynamicVars[c].deltaToExpectedTime===void 0&&(this.dynamicVars[c].deltaToExpectedTime=Math.max(this.dynamicVars[c].expectedTime-e,0)),this.dynamicVars[c].last=e-(g-this.dynamicVars[c].deltaToExpectedTime),this.dynamicVars[c].expectedTime=e+this.dynamicVars[c].deltaToExpectedTime;continue}else this.dynamicVars[c].deltaToExpectedTime=void 0;if(e>=h)if(this.dynamicVars[c].last=e,this.dynamicVars[c].expectedTime+=g,f.dynamicVariableType==="random"){let y=f.min+Math.random()*(f.max-f.min),x=f.decimals;y=Math.round(y*Math.pow(10,x))/Math.pow(10,x),r.updateVariable(u,y),s.push(u),this.eventManager.requestRender()}else if(f.dynamicVariableType==="counter"){let y=r.getVariable(u),x=r.getDynamicVariableToggleIsForward(u)??!0,v=r.getVariable(u)+f.increment*(x?1:-1);f.hasEnd&&(v=f.increment>0?Se.clamp(v,p,f.endValue):Se.clamp(v,f.endValue,p),v===p&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?v===f.endValue&&(v=p):(v===p||v===f.endValue)&&r.setDynamicVariablePlayState(u,"Paused")),v!==y&&(s.push(u),r.updateVariable(u,v),this.eventManager.requestRender())}else if(f.dynamicVariableType==="time"){let y=r.getVariable(u),x=RT(i,f);if(typeof y=="object"&&"textValue"in y&&typeof x=="object"&&"textValue"in x){if(Array.isArray(y.textValue)&&Array.isArray(x.textValue)){if(y.textValue.every((v,b)=>v===x.textValue[b]))continue}else if(y.textValue===x.textValue)continue}else if(y===x)continue;r.updateVariable(u,x),s.push(u),this.eventManager.requestRender()}else{let y=Gr.isTextValue(f.endValue)?CV(f.endValue.textValue):f.endValue,x=r.getDynamicVariableToggleIsForward(u)??!0,v=m+(e-d)/1e3*(f.dynamicVariableType==="timer"?-1:1)*(x?1:-1);v=Math.max(v,0),f.hasEnd&&(v=f.dynamicVariableType==="stopwatch"?Se.clamp(v,p,y):Se.clamp(v,y,p),v===p&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?Math.abs(v-y)<(f.format==="number3decimal"?1e-4:.1)&&(v=p):(Math.abs(v-p)<(f.format==="number3decimal"?1e-4:.1)||Math.abs(v-y)<(f.format==="number3decimal"?1e-4:.1))&&r.setDynamicVariablePlayState(u,"Paused")),v!==m&&(s.push(u),this.dynamicVars[c].timerSeconds=v,r.updateVariable(u,An.getFormattedTimerTime(v,f)),this.eventManager.requestRender())}}}let a=!1;r.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=r.mouseProperty,a=!0);let l=!1;r.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=r.raycastProperty,l=!0),this.events.forEach(c=>{(s.includes(c.data.variableId)||o.find(u=>u.objId===c.data.objectId&&u.property===c.data.property)||c.data.variableId==="mouseProperty"&&a||c.data.variableId==="raycastProperty"&&l)&&(c.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()}}pause(){this.isOutOfFocus||(this.isOutOfFocus=!0,this.pauseTime=Date.now())}resume(){if(!this.isOutOfFocus)return;this.isOutOfFocus=!1;let e=Date.now()-this.pauseTime;for(let r=0;r<this.dynamicVars.length;r++)this.dynamicVars[r].last+=e,this.dynamicVars[r].expectedTime+=e}connect(){this.eventContext.page.traverseEntity(r=>{r.data?.events.filter(i=>i.data.type==="VariableChange"&&!i.data.disabled).forEach(i=>{this.events.push(new uC(i.id,i.data,r,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(r=>r.data.variableId==="objectProperty"&&r.data.objectId!==null).map(r=>({objectId:r.data.objectId,property:r.data.property,prevValue:null}));let e=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:r,data:i})=>{if(!("dynamicVariableType"in i)){this.events.find(o=>o.data.variableId===r)&&this.variablesToWatch.push({id:r,prevValue:e.getVariable(r)});return}let s;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let o;if(Gr.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let a=i.value.textValue;a.length===3?o=a[2]+a[1]*60+a[0]*3600:o=a[1]+a[0]*60}else o=i.value;s=o,this.dynamicVars.push({id:r,last:-1,expectedTime:-1,data:i,timerSeconds:o,startValue:s})}else i.dynamicVariableType==="time"&&e.updateVariable(r,RT(new Date,i)),i.dynamicVariableType==="counter"&&(s=Gr.isTextValue(i.value)?CV(i.value.textValue):i.value),this.dynamicVars.push({id:r,last:-1,expectedTime:-1,data:i,startValue:s})}),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())}},uC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Wt(e,e.actions,i,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispose(){vr(this.actions)}};function CV(n){return n.length===3?n[2]+n[1]*60+n[0]*3600:n[1]+n[0]*60}var _V=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@1.12.47/build/",Ste=!1?_V:"https://unpkg.com/@splinetool/navmesh-wasm@1.12.47/build/",wte=`
|
|
8106
|
+
)`}else if(n.easing===6){let{mass:e,stiffness:r,damping:i,velocity:s}=n;t=`spring( ${e}, ${r}, ${i}, ${s} )`}else{let e;switch(n.easing){case 0:e=Na.linear;break;case 1:e=Na.ease;break;case 2:e=Na.easeIn;break;case 3:e=Na.easeOut;break;case 4:e=Na.easeInOut;break;default:e=Na.linear}let[r,i,s,o]=e;t=`cubicBezier( ${r}, ${i}, ${s}, ${o} )`}return{duration:Math.max(n.duration,1e-4),easing:t}}function Ng(n){let t={delay:0,loop:n.repeat===-1?!0:n.repeat+1};if(n.repeat===0)t.direction="normal",t.rewind=!1;else switch(n.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,n.delayDirection){case"start-once":t.startOnceDelay=n.delay;break;case"start":t.delay=n.delay;break;case"end":t.endDelay=n.delay;break;case"start-end":case void 0:t.delay=n.delay,t.endDelay=n.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,n.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):n.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):n.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var UM={type:"beginState"},kM={type:"completeState",isfromEntity:!1},op=class{constructor(t,e,r,i,s,o,a){this.object=t;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.page=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.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 t=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=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object instanceof hr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof ir&&e.dispatchEvent(UM)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=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=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object instanceof hr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof ir&&e.dispatchEvent(kM)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=FM(this.object,this.from.data,this.to.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp))};if(e===void 0){let l=g1(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!l)throw new Error("Missing property");this.from=l}else{let l=g1(this.object,e);if(!l)throw new Error("Missing property");this.from=l}if(r===void 0)throw new Error("Missing property");{let l=g1(this.object,r);if(!l)throw new Error("Missing property");this.to=l}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...Ng(i),...VM(i),change:this.onChange},this.callback=FM(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},ap=class extends ar{constructor(e,r,i,s,o){super();this.eventType=e;this.data=r;this.page=i;this.shared=s;this.condition=o;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.hasPlayedOnce=!1;this.pauseOnNextLoopEnd=!1;this.onTimelineChangeComplete=()=>{if(this.pauseOnNextLoopEnd){this.pauseOnNextLoopEnd=!1,this.timeline?.pause();return}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())};if(!r.object)throw new Error("Missing property");let a=this.page.scene.find(r.object)??this.page.uiCanvas?.find(r.object)??this.page.scene.find2DInUIObjects(r.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,r.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=r.tweens[0].data.delayDirection==="start-once"?r.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline?.paused===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=g1(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"&&xm(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:i=!1}={}){try{let s=Ng(this.data.tweens[0].data);i&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=Ms.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(r===!0&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let c=this.data.tweens[l],u=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof ir&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new op(this.object,h,u.data.state===void 0?this.currentState:u.data.state,u.data,this.shared,this.data.allowSlerp??!1,this.page);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.delay:0))}this.timeline.duration+=s.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let c=this.data.tweens[l],u=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof ir&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new op(this.object,h,u.data.state===void 0?this.currentState:u.data.state,c.data,this.shared,this.data.allowSlerp??!1,this.page);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.endDelay:0))}this.timeline.duration+=s.delay}}catch(s){s instanceof Error&&console.error(s.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(_t(this.shared,this.condition)===!1||xm(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;this.startTimeout?.pause();let e=Ng(this.data.tweens[0].data).pingPongDelayCorrection;this.startTimeout=Ms({targets:{},duration:this.startOnceDelay+e,easing:"linear",complete:()=>{this.startTimeout=void 0;try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.message)}}})}pause(){this.timeline?.pause(),this.startTimeout?.pause(),this.tweens=Array(this.data.tweens.length-1),delete this.startTimeout}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof hr?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){if(_t(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(_t(this.shared,this.condition)===!1)return!1;this.startTimeout?.pause(),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.pauseOnNextLoopEnd=!0,this.timeline.play()):this.startTimeout=Ms({targets:{},duration:this.startOnceDelay,easing:"linear",complete:()=>{this.startTimeout=void 0,this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()}})}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function g1(n,t){let e,r;if(typeof t=="string"?(e=t,r=n.states?.[e]):t===null&&(e=null,r=n.data),!(e===void 0||r===void 0))return{id:e,data:r}}var jee={type:"beginState"},nV={type:"completeState",isfromEntity:!1},sV={type:"requestRender"},Bg=class extends ar{constructor(e,r,i,s){super();this.data=e;this.page=r;this.shared=i;this.condition=s;this.toggleIsForward=!1;this.posStart=new E;this.posEnd=new E;this.qStart=new Ye;this.qEnd=new Ye;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 r=this.page.scene.find(this.data.targetCamera);if(!r||!r.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=Ms({targets:i,t:1,...VM(this.data),update:()=>{i.t===0&&(this.data.runMode==="Toggle"&&!this.toggleIsForward?this.fromCamera&&(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(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(jee));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,i.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(sV),i.t===1&&s.dispatchEvent(nV)}})}switchCamera(e){let r=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),r.dispatchEvent({type:"cameraChange",camera:i})}play(){if(_t(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(_t(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,e!==this.toggleIsForward)try{this.playing?(this.animation?.pause(),this.toggleIsForward=e??!this.toggleIsForward,this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=e??!this.toggleIsForward,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(nV),this.page.activeCamera.dispatchEvent(sV))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var Fg=class extends ar{constructor(e,r,i,s,o){super();this.id=e;this.data=r;this.scene=i;this.sharedAssets=s;this.eventType=o;this.toggleIsForward=!1;this._finished=!1;this.hasPlayedOnce=!1;this._shouldForwardLoop=!1;this._shouldPauseOnNextLoopComplete=!1;this._onLoopComplete=()=>{this._shouldPauseOnNextLoopComplete&&(this.timeline.pause(),this._shouldPauseOnNextLoopComplete=!1)};try{let a=Ng(this.data);typeof a.loop=="number"&&a.loop--,this.timeline=Ms.timeline({...a,autoplay:!1}),this._shouldForwardLoop=a.loop===!0||typeof a.loop=="number"&&a.loop>1;let l=this.sharedAssets.data.timelineAnimations[this.data.timeline].mapping;Object.entries(l).forEach(([c,u])=>{let h=this.scene.find(c);if(!h)return;let d=h.data.timelineAnimations[u];if(!d)return;let f=sx.addKeyframesToTimeline(h,{...d},eV(h,{scene:i,shared:s}),this.sharedAssets),m=(this.data.delayDirection==="start"?this.data.delay:0)+(this.data.delayDirection==="start-end"?this.data.delay:0)+(this.data.delayDirection==="start-once"?this.data.delay:0);f.forEach(p=>{this.timeline.add(p,m)}),this.timeline.duration=d.to*1e3+m}),this.timeline.delay=0,this.timeline.duration+=(this.data.delayDirection==="start"?this.data.delay:0)+(this.data.delayDirection==="end"?this.data.delay:0)+(this.data.delayDirection==="start-end"?this.data.delay*2:0)+(this.data.delayDirection==="start-once"?this.data.delay*2:0),this.timeline.finished.then(()=>{Object.keys(l).forEach(c=>{let u=this.scene.find(c);u instanceof ir&&u.dispatchEvent(kM)}),this._finished=!0}),this.timeline.loopComplete=this._onLoopComplete}catch(a){throw!1&&console.error(a),new Error("Missing property")}}get playing(){return this.timeline.paused===!1}get finished(){return this._finished}get paused(){return this.timeline.paused}play(){if(this.eventType!==void 0&&xm(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0;let e=this.sharedAssets.data.timelineAnimations[this.data.timeline].mapping;Object.keys(e).forEach(r=>{let i=this.scene.find(r);i instanceof ir&&i.dispatchEvent(UM)}),this.timeline.restart()}pause(){this.timeline.pause()}stop(){this.pause(),this.seek(0),this.timeline.reset(),this._finished=!1}seek(e){this.timeline.seek(e*this.timeline.duration,!0)}toggle(e){if(this.toggleIsForward=e??!this.toggleIsForward,this.playing){if(!this.toggleIsForward&&this.timeline.reversed&&this._shouldForwardLoop&&this.timeline.remaining%2===1){this._shouldPauseOnNextLoopComplete=!0;return}this.timeline.reverse(this.timeline.duration-this.timeline.currentTime),this._shouldForwardLoop&&this.timeline.loop&&this.timeline.reversed&&(this._shouldPauseOnNextLoopComplete=!0)}else(!this.toggleIsForward!==this.timeline.reversed||!this.toggleIsForward&&this.timeline.reversed&&this.timeline.direction==="alternate")&&this.timeline.reverse(),typeof this.timeline.loop=="number"&&typeof this.timeline.remaining=="number"&&this.timeline.remaining<this.timeline.loop&&this.toggleIsForward&&(this.timeline.remaining=this.timeline.loop),this.timeline.play()}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function zM(n){let t=n?.tracks.filter(e=>e.ValueTypeName==="vector"||e.ValueTypeName==="quaternion").map(e=>e.times.length);if(t?.length){let e=iA(t);return e&&e>2?e:2}return 2}var Vg=class extends ar{constructor(e,r,i,s,o){super();this.data=e;this.page=r;this.animationControls=i;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let c=this.animationControls.clipIdToAction[e.clipId+"/"+a];if(this.duration=c?.getClip()?.duration??1,this.data.crop2){let u=zM(c?.getClip());this.leftFrameTime=this.data.crop2[0]/(u-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(u-1)*this.duration}else{let u=c?.getClip()?.tracks[0]?.times.length;u&&u>1?(this.leftFrameTime=this.data.crop[0]/u*this.duration,this.rightFrameTime=this.data.crop[1]/u*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(_t(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 r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,s])=>{let o=i.split("/")[1];this.threeAnimAction!==s&&o===r&&(e?s.fadeOut(.2):s.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=Se.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(_t(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(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===i&&o.isRunning()&&(r?o.fadeOut(.2):o.stop())}),r&&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()}};var Ug=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.eventManager=r;this.shared=i;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(_t(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(r=>r.uuid!==this.data.target||r.data.uiScene))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 t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(r=>{r.type==="ParticleSystem"&&(r.sleep(),r.wakeUp(),r.data.autoPlay?r.start():r.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),sp(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var kg=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=_t(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=Lx(this.data.expression,this.shared,Gr.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var zg=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.timeoutId=null}dispatchInner(){if(_t(this.shared,this.condition)===!1)return!1;let t=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,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="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"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="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 e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e===void 0?!1:!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};var y1=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(_t(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(e=>{this.shared.getVariable(e);let r=this.shared.data.variables.data(e)?.value;r!==void 0&&this.shared.updateVariable(e,r),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(cb(e))})}dispose(){}};var v1=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(_t(this.shared,this.condition)===!1)return!1;if(this.data.userAPIId){let t=this.shared.getUserAPI(this.data.userAPIId);t&&"callUserAPI"in t&&t.callUserAPI(this.shared)}}dispose(){}};function _t(n,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=Lx(t.expression,n,"boolean");return t.negate?!e:!!e}function Wt(n,t,e,r,i,s){let o={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],TimelineAnimation:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},a=l=>({id:c,data:u})=>{try{u.type==="Audio"?Wi[n.type].includes("Audio")&&o.Audio.push(new Dg(c,u,s,r,l)):u.type==="Video"&&!(s instanceof hr)?Wi[n.type].includes("Video")&&o.Video.push(new Gg(c,u,s,r,l)):u.type==="Particles"?Wi[n.type].includes("Particles")&&o.Particles.push(new Og(u,e,r,l)):u.type==="Link"?Wi[n.type].includes("Link")&&o.Link.push(new m1(u,i.controlsManager,r,l)):u.type==="Create"?Wi[n.type].includes("Create")&&o.Create.push(new jg(u,e,i.controlsManager,r,l)):u.type==="Destroy"?Wi[n.type].includes("Destroy")&&o.Destroy.push(new Rg(u,e,i.controlsManager,r,l)):u.type==="Reset"?Wi[n.type].includes("Reset")&&o.Reset.push(new Lg(u,e,r,i,l)):u.type==="Transition"?Wi[n.type].includes("Transition")&&o.Transition.push(new ap(n.type,u,e,r,l)):u.type==="SwitchCamera"?Wi[n.type].includes("SwitchCamera")&&o.SwitchCamera.push(new Bg(u,e,r,l)):u.type==="SceneTransition"?Wi[n.type].includes("SceneTransition")&&o.SceneTransition.push(new Ug(u,e,i,r,l)):u.type==="Animation"?Wi[n.type].includes("Animation")&&o.Animation.push(new Vg(u,e,i.animationControls,r,l)):u.type==="SetVariable"?Wi[n.type].includes("SetVariable")&&o.SetVariable.push(new kg(u,e,r,l)):u.type==="DynamicVariablePlay"?Wi[n.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new zg(u,e,r,l)):u.type==="Conditional"?Wi[n.type].includes("Conditional")&&(u.ifActions.forEach(a({expression:u.condition,negate:!1})),u.elseActions.forEach(a({expression:u.condition,negate:!0}))):u.type==="ClearLocalStorage"?Wi[n.type].includes("ClearLocalStorage")&&o.ClearLocalStorage.push(new y1(u,e,r,l)):u.type==="UserAPI"?Wi[n.type].includes("UserAPI")&&o.UserAPI.push(new v1(u,e,r,l)):u.type==="TimelineAnimation"&&Wi[n.type].includes("TimelineAnimation")&&o.TimelineAnimation.push(new Fg(c,u,e.scene,r,n.type))}catch(h){!1&&console.error(h)}};return t.forEach(a()),o}function vr(n){Object.values(n).forEach(t=>{t.forEach(e=>{(e instanceof Dg||e instanceof Gg||e instanceof ap||e instanceof Fg||e instanceof Og||e instanceof Vg||e instanceof ap||e instanceof jg||e instanceof Rg||e instanceof Bg||e instanceof Ug||e instanceof Lg||e instanceof kg||e instanceof zg)&&e.dispose()})})}function oV(n,t){let e;if("material"in n){let r=n.material;Array.isArray(r)?e=n.material[0].layers.find(i=>i.uuid===t):e=n.material.layers.find(i=>i.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var aV=new Map,Hg=new Map,po=class{constructor(t,e,r){this.data=e;this.delay=0;this.status="stopped";let{layerId:i,loop:s,volume:o,delay:a}=e;if(this.object=r,i===void 0)throw new Error("Missing property");let l=oV(r,i);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,bs&&(this.videoElement.autoplay=!0),o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),Hg.has(r.uuid)?Hg.get(r.uuid).push(this):Hg.set(r.uuid,[this]),aV.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(i=>{}).catch(i=>{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())}seek(t){return new Promise(e=>{if(!this.videoElement)return e();let r=this.videoElement.duration;if(r>0){let i=t%r;this.videoElement.currentTime=i}this.videoElement.addEventListener("seeked",()=>e(),{once:!0})})}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)}},lp=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=aV.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=Hg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[...Hg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Gg=class{constructor(t,e,r,i,s){this.data=e;this.shared=i;this.condition=s;if(e.interaction==="play")this.interaction=new po(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new lp(e);else throw new Error("Missing property")}dispatchBasic(){if(_t(this.shared,this.condition)===!1)return!1;this.interaction instanceof po?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(_t(this.shared,this.condition)===!1)return!1;this.interaction instanceof po?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var lV=(()=>{let n,t,e,r;function i(a){!n&&!cV()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(n=requestAnimationFrame(s)),a&&(t=a,r=a.requestRender)}function s(a){let l=e?a-e:0,c=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,h=c.length,d=0;for(;d<h;){let f=c[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&u[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),r()),d++):(u[f.userData.actionId]>f.userData.quantity&&u[f.userData.actionId]--,c.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(m=>m.bvhGeometry!==void 0)),h--,r())}n=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){cV()?n&&(cancelAnimationFrame(n),n=void 0,e=void 0):i()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),i})();function cV(){return!!document&&document.hidden}var uV=new Ye,Hee=new E,Wee=new E,jg=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=i;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Se.generateUUID();this.dispatch=()=>{if(_t(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(_t(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=nA(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 t=new Lr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,i=this.page.scene.find(r);i&&(i.updateMatrixWorldSVD(),t.hiddenMatrix.copy(i.matrixWorldRigid))}t.scale.copy(this.object.scale),t.position.fromArray(this.data.position.map(r=>typeof r=="number"?r:0)),t.rotation.fromArray(this.data.rotation.map(r=>typeof r=="number"?r:0)),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),lV(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Ai)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof Lr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Ai)return;t instanceof Lr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new E().fromArray(this.data.velocity.map(s=>typeof s=="number"?s:0)),i=e.dataPatched;if(!(i.physics.enabled==="visibility"?!i.visible:!i.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(Hee,uV,Wee),r.applyQuaternion(uV),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");lV(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var WM=200,GM=.02,jM=.3,qee=65,hV=new E,dV=new E,Xee=new E,On=new E,Yn=new E,wc=new E,HM=new ue,fV=new ue,Yee=new ue,mo=new Ye,sl=new Ye,fa=new Jt(0,0,0,"YXZ"),Kee=new E(1,0,0),go=new E(0,1,0),Qee=new E(0,0,1),pV=new E(1,1,1),Zee=1,Jee=.025,$ee=16e-6,mV=12,ete=20,Qi=new Di,Fs=new Yt,tte={type:"requestRender"},rte={type:"updateMatrix"},gV=Math.PI/6,x1=class extends ar{constructor(e,r,i,s,o,a,l,c,u){super();this.object=e;this.domElement=r;this.data=i;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=c;this.sharedAssets=u;this.enableDamping=!0;this.hiddenMatrix0=new ue;this.target0=new E;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=WM;this.euler0=new Jt(0,0,0,"YXZ");this.position0Cam=new E;this.quat0Cam=new Ye;this.scale0Cam=new E;this.hiddenMatrix0Cam=new ue;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Di(new E(0,-40,0),new E(0,40,0)),matrix:new ue,position:new E,rotation:new Ye};this.euler=new Jt(0,0,0,"YXZ");this.eulerDelta=new E;this.lastPosition=new E;this.lastCameraQuaternion=new Ye;this.lastCameraPosition=new E;this.PI_2=Math.PI/2;this.prevMouse=new U;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 ue;this.nonColliderPosOffset=new ue;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 ue;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 Ye;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 Ye;this.objXZQuatInv=new Ye;this.objXZRotMat=new ue;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new E;this.pushedVelocity=new E;this.groundYRotation=0;this.objectRealQuat=new Ye;this.colliderWorldQuat=new Ye;this.groundNormal=new E;this.groundTilt=new Ye;this.groundTiltInv=new Ye;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new E;this.quaternion=new Ye;this.scale=new E;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Li&&!aA&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,i=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(aA&&xD<15.5&&!Li?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-i*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?x1.isLocked=!0:x1.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let i=2;i<4;i++){let s=e.axes[i];r===0?i===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,i===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(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(),d=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,d,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 g=new E(0,0,-1).applyQuaternion(this.camera.quaternion),y=new E().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let x,v;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,v=y.projectOnVector(g)):y.y/g.y>0?v=g.multiplyScalar(y.y/g.y):v=g.multiplyScalar(y.length()),this.targetToCamera0.copy(v).negate(),x=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(x,this.position);let b=new Jt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-b.x,b.x=0,b.z=0,b.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(b)}if(this.object instanceof ir&&(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)*Zee,this.speedOrbit=(i.speedRotate??100)*Jee,this.mouseOrbitSensitivity=(i.speedRotate??100)*$ee,this.keyAssignments=i.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),i.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][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??Wl.defaultData.gravity)*mV,this.usePhysics=this.gloabalPhysics.usePhysics??Wl.defaultData.usePhysics,this.jumpPower=i.jumpPower*ete,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??bd.defaultDataThirdPerson.orientWith,this.slopeThresh=qee*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*GM/this.pixelsPerMeter,this.stepThresh=i.collider.height*jM/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*GM/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*jM/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*GM/this.pixelsPerMeter,this.stepThresh=i.collider.height*jM/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let f=new E().fromArray(i.collider.position.map(g=>typeof g=="number"?g:0)),m=new Ye().setFromEuler(new Jt().fromArray([...i.collider.rotation.map(g=>typeof g=="number"?g:0),"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(m),this.collider.matrix.compose(f,m,pV),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.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let g=new Re;g.push({fi:0,data:{...Cr.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...Cr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let y=new $a({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Mt(Sx.create({parameters:{width:p,height:p/10,hollow:.7}}),y),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 r=new Jt().setFromQuaternion(this.quaternion,"YXZ"),i=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,i,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof ir?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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},xd.list.forEach(i=>{this.actions[i]=Wt({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,r,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"),vr(this.actions.idle),vr(this.actions.move),vr(this.actions.run),vr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(r=>{r.play()}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(r=>{r.stop()}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return On.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,r,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 s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let c=Yn.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*mV),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(u){this.onObject=!0,this.groundNormal.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),u.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=u.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(On,sl,Yn),this.groundVelocity.subVectors(On,d.prevT),this.object.getWorldPosition(Yn).add(this.collider.position).sub(On),this.groundYRotation=fa.setFromQuaternion(sl).y-d.prevR.y,wc.copy(Yn).applyAxisAngle(go,this.groundYRotation),this.groundVelocity.add(wc.sub(Yn)).divideScalar(s);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*o),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 c=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 u=On.subVectors(this.path[1],this.position),h=Yn.subVectors(this.path[1],this.path[0]);u.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),c.opacity=c.userData.opacity0}else c.opacity-=.05*c.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)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):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.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=Xee.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let c=Yn.copy(l);c.y=0,l.set(0,l.y,c.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let c=On;this.camera.getWorldDirection(c);let u=wc.copy(go).multiplyScalar(c.dot(go));c.sub(u);let h=Yn.copy(this.directionXZ);h.x*=-1,this.rot.y=c.angleTo(h)*(c.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(fa.setFromVector3(this.rot),this.moveMode==="walk"&&(fa.x=0),l.applyEuler(fa),a&&(sl.setFromUnitVectors(go,this.groundNormal),l.applyQuaternion(sl)),i){let c=fa.set(0,this.vrEulerYOffset*gV,0);i.applyEuler(c),l.x+=i.x,l.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*s}if(this.usePhysics===!0&&this.object.rigidBody){let c=Yn;this.pushedVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=wc.setFromMatrixPosition(u.matrixWorld).sub(u.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=u.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),On.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=gt.is(u)?u:u.object;if(d!==null&&this.lastHitObj!==f){let m;u instanceof Lr&&(m=u);let p=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(p)for(let g of p)g.data.target==="character"&&(g.dispatch(m),f.dispatchEvent(b1));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),c.copy(d.normal1).applyQuaternion(u.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let u=c.dot(l);u<0&&l.addScaledVector(c,-u),l.add(this.pushedVelocity)}else l.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(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(go,this.euler.y-this.euler0.y);let c=Yn.copy(this.objectToCamXZ).normalize(),u=wc.copy(l).multiplyScalar(s);u.y=0;let h=u.sub(On.copy(c).multiplyScalar(u.dot(c))).cross(c).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+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=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Se.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(fa.copy(r),fa.y=0):(fa.copy(this.euler),fa.y=0),this.nonColliderRotOffset.makeRotationFromEuler(fa)),r&&(this.moveMode==="walk"?(this.rot.y=r.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(r),this.rot.y+=this.vrEulerYOffset*gV),mo.setFromAxisAngle(Kee,this.rot.x),sl.setFromAxisAngle(go,this.rot.y),sl.multiply(mo),mo.setFromAxisAngle(Qee,this.rot.z),sl.multiply(mo),this.quaternion.copy(sl),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let c=Yn.copy(l).multiplyScalar(s/this.pixelsPerMeter),u=null;this.didHit=!1;let h=new E;for(let d=0;d<5;d++){let f=c.length(),m=wc.copy(c).normalize();if(u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,m,this.object.rigidBody.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),u!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(u.collider.handle);if(p!==this.lastHitObj&&d===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let b of v)if(b.data.target==="character"){let w=(this.sharedGameControlGlobals.rapierWorld?.getCollider(u.collider.handle))._parent,A;if(p.cloner){for(let T of p.cloner.children)if(T.rigidBody===w){A=T;break}}b.dispatch(A),p.dispatchEvent(b1)}}}let g=hV.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat),y=dV.copy(m).multiplyScalar(u.toi).dot(g),x=u.toi;if(x===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(x=u.toi*(y-this.offset)/y,h.addScaledVector(m,x)),c.copy(m).multiplyScalar(f-x),Math.acos(-g.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),b=wc.copy(u.witness2).applyQuaternion(this.colliderWorldQuat);b.y=0;let w=v.add(b);w.y+=this.stepThresh;let A=this.sharedGameControlGlobals.rapierWorld.castShape(w,this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);A!==null&&A.toi===0&&(g.y=0,g.normalize())}c.addScaledVector(g,-c.dot(g))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(c);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(On.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(mo.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let c=this.onObject?1:5,u=l.multiplyScalar(s/c);for(let h=0;h<c;h++)this.position.add(u),this.collisionAdjustment(s/c)}else this.position.addScaledVector(l,s);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 c=this.objectToTarget.add(this.position),u=this.targetToCamera.add(c);HM.lookAt(u,c,go).setPosition(u),HM.decompose(this.targetPos,this.targetQuat,On),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Se.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Se.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(rte),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(tte),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=mo.setFromAxisAngle(go,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Se.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 r;this.cameraXAxis==="Limit"?r=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=On.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let s=sl.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){go.angleTo(e)*180/Math.PI<15||go.angleTo(e)*180/Math.PI>85?mo.identity():mo.setFromUnitVectors(go,e),this.groundTilt.slerp(mo,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=dV.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=HM.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(On,mo,Yn).compose(On,mo,pV);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object)||!o.bvhGeometry||!o.bvhGeometry.boundsTree)return;Fs.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=fV.copy(a).invert(),c=Yee.copy(fV).multiply(i);Qi.copy(this.collider.segment),Qi.start.applyMatrix4(c),Qi.end.applyMatrix4(c);let u=hV.copy(this.position).applyMatrix4(l);Fs.expandByPoint(Qi.start),Fs.expandByPoint(Qi.end),Fs.min.addScalar(-this.collider.radius),Fs.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Qi.end)},intersectsBounds:h=>h.intersectsBox(Fs),intersectsTriangle:h=>{let d=On,f=Yn,m=h.closestPointToSegment(Qi,d,f);if(m<this.collider.radius){let p=this.collider.radius-m,g=f.sub(d).normalize(),y=wc.copy(u);y.addScaledVector(g,p);let x=y.applyMatrix4(a).sub(this.position);r.add(x),Qi.start.addScaledVector(g,p),Qi.end.addScaledVector(g,p)}}})}),Fs.makeEmpty(),Qi.copy(this.collider.segment),Qi.start.applyMatrix4(i),Qi.end.applyMatrix4(i),Fs.expandByPoint(Qi.start),Fs.expandByPoint(Qi.end),Fs.min.addScalar(-this.collider.radius),Fs.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(Qi.end)},intersectsBounds:o=>o.intersectsBox(Fs),intersectsTriangle:o=>{let a=On,l=Yn,c=o.closestPointToSegment(Qi,a,l);if(c<this.collider.radius){let u=this.collider.radius-c,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),r.addScaledVector(h,u),Qi.start.addScaledVector(h,u),Qi.end.addScaledVector(h,u)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(s),this.position.add(r)}pause(){this.firstPointerId=-1,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.deactivate()}resume(){this.activate()}},Wg=x1;Wg.isLocked=!1;var yV=cl(ME());function qM(n){let t=n.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,i=t[8]**2+t[9]**2+t[10]**2,s=t[0]**2+t[4]**2+t[8]**2,o=t[1]**2+t[5]**2+t[9]**2,a=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||i<l||s<l||o<l||a<l}function yo(n,t){let e=new Ce;if(t&&qM(t))return e.setAttribute("position",new Te([],3)),e.setIndex([]),e;if(!n.getAttribute("position"))return e.setAttribute("position",new Te([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=hu(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new Te(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}var ite=new ue,nte=new ue,pa=[[0,0,0],[0,0,0],[0,0,0]];function XM(n){let t=n.elements;pa[0][0]=t[0],pa[0][1]=t[4],pa[0][2]=t[8],pa[1][0]=t[1],pa[1][1]=t[5],pa[1][2]=t[9],pa[2][0]=t[2],pa[2][1]=t[6],pa[2][2]=t[10];let{u:e,v:r}=(0,yV.SVD)(pa),i=ite.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=nte.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 i.multiply(s.transpose())}var S1=class extends xh{constructor(){super(),this.layers.enable(3),this.layers.enable(8),this.layers.enable(9)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,r=[]){return t.forEach(i=>{i.visible&&this.intersectObject(i,e,r)}),r}createRaycastLineHelper(){let t=new ms({color:65280,linewidth:10}),e=new E(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new E(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new E().addVectors(e,r.multiplyScalar(i)),o=new Ce;return o.setFromPoints([e,s]),new Uc(o,t)}};var vV=n=>n instanceof Ns||n instanceof ho;function ste(n,t){return n.distance-t.distance}function xV(n,t,e){if(!(!Qo(t)||!t.visible)){Wn(t)&&t.raycast(n,e);for(let r of t.children)xV(n,r,e)}}function cp(n,t,e,r=!1){if(!r&&!e.some(s=>up(n,s)!==void 0))return[];let i=[];return t.children.forEach(s=>xV(n,s,i)),i.sort(ste),i}function qg(n){let t=[];if(n.length){let e=n[0].object;Qo(e)&&t.push(e);let r=e.parent;for(;r;)vV(r)&&t.push(r),r=r.parent}return t}function vo(n,t,e,r){let i=n.frame;if(i){let s=t[0]*i.width,o=(1-t[1])*i.height;for(let a of e){let l=a===i.uuid?i:i.find(a);if(l?.intersects(s,o))return r(l),!0}}return!1}function up(n,t){if(Wn(t)){if(t.visible){let e=[];return t.raycast(n,e),e.length?e[0]:void 0}}else if(vV(t))return bV(n,t)}function bV(n,t){if(!(!Qo(t)||!t.visible)){if(Wn(t)){let e=[];if(t.raycast(n,e),e.length)return e[0]}for(let e of t.children){let r=bV(n,e);if(r)return r}}}function ote(n,t,e){return{x:(n-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}function ate(n,t,e){return{x:(n-(e.left+window.scrollX))/e.width,y:1-(t-(e.top+window.scrollY))/e.height}}var w1=class{constructor(t,e,r,i,s,o,a,l){this.renderer=t;this.publish=e;this.scene=r;this.getCamera=i;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new S1;this._useWindowEvents=!1;this.pointerWorld={x:0,y:0};this.pointerScreen={x:0,y:0};this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(t){this._domRect=t}get domRect(){return this._domRect}updateRaycaster(t){let{pageX:e,pageY:r}=t.touches?.length>0?t.touches[0]:t;this.pointerWorld=ote(e,r,this._domRect),this.pointerScreen=ate(e,r,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}};var Qt=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var YM=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],SV=n=>YM.find(([t,e])=>e===n)?.[0],ma=n=>YM.find(([t])=>t===n)?.[1],lte=(n,t)=>{let e=SV(n);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},A1=class extends Qt{constructor(){super(...arguments);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let r=this.splineEvents[SV(e.eventName)]?.[e.target.uuid];if(!r)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(r,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(r)}}connect(){let{page:e}=this.eventContext;e.traverseEntity(r=>{if(!!r.data?.events.length){for(let[i,s]of YM)if(r.data.events.some(o=>o.data.type===s&&!o.data.disabled)){this.objectsPerEvents.has(i)?this.objectsPerEvents.get(i)?.push(r):this.objectsPerEvents.set(i,[r]);let o={id:r.uuid,name:r.name},a=lte(s,o),l=this.splineEvents[i];l?l[r.uuid]=a:this.splineEvents[i]={[r.uuid]:a}}}}),this.objectsPerEvents.forEach(r=>{r.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.removeEventListener("beginEvent",this.onBeginEvent)})})}};var KM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;if((e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=Wt(e,e.actions,i,s,o,r)}disconnect(){vr(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(i=>i.playing&&i.data.runMode!=="Toggle")||this.actions.Transition.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()}),this.actions.SwitchCamera.some(i=>i.playing&&i.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()}),this.actions.Animation.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()}),this.actions.TimelineAnimation.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},E1=class extends Qt{constructor(e,r,i){super(e);this.eventManager=r;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=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=cp(r,i,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{(r.data.type==="MouseDown"||r.data.type==="MousePress")&&(this.onCanvasRaycast(e),r.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{r.data.type==="MouseUp"?(this.onCanvasRaycast(e),r.dispatch()):r.data.type==="MousePress"&&r.dispatchRelease()})};this.onMouseDown=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=ma(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent(i)}),this.canvasMouseEvents.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent()})))}}connect(){let{page:e,sharedAssets:r,domElement:i}=this.eventContext,s=(o,a)=>{if(!o.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let c of l){let u=this.eventsPerObjects[c];if(o.data.events.filter(({data:h})=>h.type===c&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new KM(h,d,o,e,r,this.eventManager);f.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(f):(u[o.uuid]?u[o.uuid].some(m=>m.id===f.id)||u[o.uuid].push(f):u[o.uuid]=[f],o instanceof cs&&o.traverseChildren(m=>{if(!m.visible)return!0;m instanceof Ct&&"shapeBlendNode"in m.data.geometry&&m.data.geometry.shapeBlendNode?.operation!==2&&(u[m.uuid]?u[m.uuid].push(f):u[m.uuid]=[f])}))}catch(f){!1&&console.error(f)}}),u[o.uuid]?.length&&(this.objectsPerTypes[c].push(o instanceof hr&&(c==="MouseDown"||c==="MouseUp"||c==="MousePress")?a:o),o instanceof cs)){let h=this.objectsPerTypes[c];o.traverseChildren(d=>{if(!d.visible)return!0;d instanceof Ct&&h.indexOf(d)===-1&&h.push(d)})}}};e.traverseEntity(o=>{(o instanceof _r||o instanceof yr)&&o.frame?.traverse(a=>{s(a,o)}),s(o)}),this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),i.addEventListener("pointerdown",this.onCanvasMouseDown),i.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),i.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(([o,a])=>{a.forEach(l=>{l.addEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(o=>{o.object.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(r=>{Object.values(r).forEach(i=>{i.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(r=>{r.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([r,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(r=>{r.object.removeEventListener("userEvent",this._onUserEvent)})}handleMouseEvent(e){let{stopRaycast:r,raycaster:i,page:s,pointerScreen:o}=this.eventContext,a=this.objectsPerTypes[e],l=a.filter(c=>!(c instanceof hr));if(!(!a.length&&!this.useForRaycastProperty)&&!(s.uiCanvas&&vo(s,[o.x,o.y],Object.keys(this.eventsPerObjects[e]),u=>{this.handleObjectMouseEventDispatch(u,e)}))){if(r||this.useForRaycastProperty){let c;if(this.sceneInterects===null?c=cp(i,s,l,this.useForRaycastProperty):(c=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&c.length&&(this.eventContext.sharedAssets.raycastProperty={x:c[0].point.x,y:c[0].point.y,z:c[0].point.z,objX:c[0].object.matrixWorld.elements[12],objY:c[0].object.matrixWorld.elements[13],objZ:c[0].object.matrixWorld.elements[14]}),r){let u=[c[0]?.uv?.x??0,c[0]?.uv?.y??0];qg(c).forEach(h=>{h instanceof _r&&vo(h,u,Object.keys(this.eventsPerObjects[e]),d=>{this.handleObjectMouseEventDispatch(d,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}r||l.forEach(c=>{let u=up(i,c);u&&(this.handleObjectMouseEventDispatch(c,e),c instanceof _r&&vo(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let r="MousePress",i=this.objectsPerTypes[r],s=i.filter(a=>!(a instanceof hr)),o=[];if(!!i.length){if(!e){let{stopRaycast:a,raycaster:l,page:c,pointerScreen:u}=this.eventContext,h=!1;if(c.uiCanvas&&(h=vo(c,[u.x,u.y],Object.keys(this.eventsPerObjects[r]),d=>{o.push(d)})),a&&!h){let d=cp(l,c,s);o=qg(d),d.forEach(f=>{f.object instanceof _r&&vo(f.object,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),m=>{o.push(m)})})}else s.forEach(d=>{let f=up(l,d);f&&(o.push(d),d instanceof _r&&vo(d,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),m=>{o.push(m)}))})}this._prevObjects.length&&this._prevObjects.forEach(a=>{o.includes(a)||this.handleObjectMouseEventDispatchRelease(a,r)}),o.length&&o.forEach(a=>{this.handleObjectMouseEventDispatch(a,r)}),this._prevObjects=o}}handleObjectMouseEventDispatch(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,r,i=!1){this.objectsPerTypes[r].forEach(s=>{let o=this.eventsPerObjects[r][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:r}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,r,i=!1){this.objectsPerTypes[r].forEach(s=>{this.eventsPerObjects[r][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(i)})})}};var cte=new E,ute=new E;var T1=class{constructor(t,e,r,i,s){this.actionsIn=Wt(t,t.inActions,r,i,s,e),this.actionsOut=Wt(t,t.outActions,r,i,s,e)}disconnect(){vr(this.actionsIn),vr(this.actionsOut)}};var QM=class extends T1{constructor(e,r,i,s,o,a){super(r,i,s,o,a);this.id=e;this.data=r;this.object=i;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=cte.setFromMatrixPosition(this.objects[0].matrixWorld),r=ute.setFromMatrixPosition(this.objects[1].matrixWorld),i=e.distanceTo(r)<=this.distance?"in":"out";if(this.stage!==i){this.stage=i;let s=i==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Particles.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.TimelineAnimation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch()),s.DynamicVariablePlay.forEach(o=>o.dispatch()),s.ClearLocalStorage.forEach(o=>o.dispatch()),s.UserAPI.forEach(o=>o.dispatch())}};let{distance:l,fromObject:c,toObject:u}=r.condition;this.distance=l;for(let h of[c,u]){if(!h)throw new Error("Missing property");let d=s.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}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)})}},ZM=class extends T1{constructor(e,r,i,s,o,a){super(r,i,s,o,a);this.id=e;this.data=r;this.object=i;this.onBegin=({target:e,state:r})=>{this.toState!==r&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Particles.forEach(i=>i.dispatchConditional()),this.actionsOut.Video.forEach(i=>i.dispatchConditional()),this.actionsOut.Link.forEach(i=>i.dispatch()),this.actionsOut.Create.forEach(i=>i.dispatch()),this.actionsOut.Destroy.forEach(i=>i.dispatch()),this.actionsOut.Reset.forEach(i=>i.dispatch()),this.actionsIn.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(i=>i.play()),this.actionsOut.Animation.forEach(i=>i.play()),this.actionsOut.TimelineAnimation.forEach(i=>i.play()),this.actionsIn.SwitchCamera.forEach(i=>i.pause()),this.actionsOut.SwitchCamera.forEach(i=>i.play()),this.actionsOut.SceneTransition.forEach(i=>i.dispatch()),this.actionsOut.SetVariable.forEach(i=>i.checkConditions()),this.actionsOut.SetVariable.forEach(i=>i.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(i=>i.dispatch()),this.actionsOut.ClearLocalStorage.forEach(i=>i.dispatch()),this.actionsOut.UserAPI.forEach(i=>i.dispatch()))};this.onComplete=({target:e,state:r})=>{this.toState===r&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Particles.forEach(i=>i.dispatchConditional()),this.actionsIn.Video.forEach(i=>i.dispatchConditional()),this.actionsIn.Link.forEach(i=>i.dispatch()),this.actionsIn.Create.forEach(i=>i.dispatch()),this.actionsIn.Destroy.forEach(i=>i.dispatch()),this.actionsIn.Reset.forEach(i=>i.dispatch()),this.actionsOut.Transition.forEach(i=>i.pause()),this.actionsOut.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(i=>i.play()),this.actionsIn.Animation.forEach(i=>i.play()),this.actionsIn.TimelineAnimation.forEach(i=>i.play()),this.actionsOut.SwitchCamera.forEach(i=>i.pause()),this.actionsIn.SwitchCamera.forEach(i=>i.play()),this.actionsIn.SceneTransition.forEach(i=>i.dispatch()),this.actionsIn.SetVariable.forEach(i=>i.checkConditions()),this.actionsIn.SetVariable.forEach(i=>i.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(i=>i.dispatch()),this.actionsOut.ClearLocalStorage.forEach(i=>i.dispatch()),this.actionsOut.UserAPI.forEach(i=>i.dispatch()))};let{condition:l}=r;if(!l.object)throw new Error("Missing property");let c=s.find(l.object)??s.scene.find2D(l.object);if(!c)throw new Error("Missing property");if(this.toObject=c,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){vs(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),vs(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),vs(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),vs(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},M1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1}connect(){super.connect();let{page:e,sharedAssets:r}=this.eventContext;e.traverseEntity(i=>{if(!!i.data?.events.length){for(let{id:s,data:o}of i.data.events)if(!o.disabled&&o.type==="Conditional")try{let a;o.condition.type==="Comparison"||(o.condition.type==="Distance"?a=new QM(s,o,i,e,r,this.eventManager):o.condition.type==="State"&&(a=new ZM(s,o,i,e,r,this.eventManager))),a&&(this.eventsPerConditions[o.condition.type].push(a),(a.actionsIn.Video.length||a.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(a){!1&&console.error(a)}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(s=>s.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.disconnect()))}};var Xg=new E,Ac=new E,Pu=new E,wV=new qr,hte=.01,dr=new E,Vi=new E,AV=new E,_u=new Ye,JM=new Jt,dte=new ue,$M=new Sr,hp=new E,ga=new E,dp=.2;function eC(n,t){!t||(t[0]<t[1]&&(n.x=Math.min(Math.max(n.x,t[0]),t[1])),t[2]<t[3]&&(n.y=Math.min(Math.max(n.y,t[2]),t[3])),t[4]<t[5]&&(n.z=Math.min(Math.max(n.z,t[4]),t[5])))}var fte=function(){let n=new ue;return(t,e,r)=>{let i=t.obj;n.copy(i.hiddenMatrix),i.parent!==null&&n.premultiply(i.parent.matrixWorld),n.invert(),i.position.copy(e),t.reference==="global"&&eC(i.position,t.limits),i.position.applyMatrix4(n),t.reference==="parent"?eC(i.position,t.limits):t.reference==="local"&&(_u.copy(t.quat0).invert(),i.position.sub(t.position0),i.position.applyQuaternion(_u),eC(i.position,t.limits),_u.invert(),i.position.applyQuaternion(_u),i.position.add(t.position0)),n.multiply(r??i.matrixWorld).decompose(dr,i.quaternion,Vi),i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i instanceof nr&&Dn(i.parent)&&i.invalidateDownstreamBooleanData(!0)}}(),tC=class{constructor(t,e,r,i,s,o,a){this.object=t;this.id=e;this.data=r;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=Wt(r,r.dragDropActions.drag,i,s,o,this.object),this.actionsDrop=Wt(r,r.dragDropActions.drop,i,s,o,this.object);let l=[];this.data.objects.forEach(c=>{let u=i.find(c);!u||u.data.visible!==!1&&(l.push(u),a[u.uuid]&&a[u.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&l.push(d)}))}),this.data.dropDestinations.forEach(c=>{let u=i.find(c);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),a[u.uuid]&&a[u.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=l.map(c=>(this.data.planeMode==="locked"&&(c.userData.lockedPlane=!0),c.userData.worldPosition0=new E().setFromMatrixPosition(c.matrixWorld),{obj:c,fromPosition:new E().setFromMatrixPosition(c.matrixWorld),pointStart:new E,pointEnd:new E,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new E().copy(c.position),quat0:new Ye().copy(c.quaternion),snapped:!1,orientationMatrix:new ue,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){vr(this.actionsDrag),vr(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},C1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(et.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=i.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:c,pointStart:u}of o.dragItems){if(l===s[0].object||l===s[0].object.object||gt.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,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 h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(dr,_u,Vi),JM.setFromQuaternion(_u),h.prevR===void 0?(h.prevR=JM.clone(),h.prevT=dr.clone()):(h.prevR.copy(JM),h.prevT.copy(dr)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,u,o.data.plane,o.data.referenceFrame),c.copy(u),(this.eventManager.controlsManager.usePhysics&&l.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}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(et.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=i.raycastWithClones(r);if(et.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||gt.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.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 a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof Ns)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(c=>c===l.object.uuid||i.scene.find(c).isAncestorOf(l.object.uuid))))[0]),a){let l=AV.copy(a.face.normal).applyMatrix3($M.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){dr.copy(l).applyMatrix3($M.setFromMatrix4(o.obj.matrixWorld).transpose());let c=o.obj;dr.x>dp?Vi.x=-c.recursiveBBox.min.x:dr.x<-dp&&(Vi.x=-c.recursiveBBox.max.x),dr.y>dp?Vi.y=-c.recursiveBBox.min.y:dr.y<-dp&&(Vi.y=-c.recursiveBBox.max.y),dr.z>dp?Vi.z=-c.recursiveBBox.min.z:dr.z<-dp&&(Vi.z=-c.recursiveBBox.max.z),Vi.applyMatrix3($M.invert())}else Vi.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Vi)}this.activeEvent.data.autoOrient&&(dr.set(0,1,0).cross(l),dr.length()<1e-4&&dr.set(-1,0,0).cross(l),Vi.crossVectors(AV,dr),o.orientationMatrix.makeBasis(dr,Vi,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Animation.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Audio.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(c=>{c.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(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.ClearLocalStorage.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.UserAPI.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=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||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(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(i=>{i.stop(),i.object.currentState!==null&&i.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(i=>{i.stop()}),this.activeEvent.actionsDrag.Audio.forEach(i=>{i.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(i=>{i.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(i=>i.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(i=>i.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(i=>i.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(i=>i.dispatch()),this.activeEvent.actionsDrop.UserAPI.forEach(i=>i.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}}}connect(){let e={};if(this.eventContext.page.traverseEntity(i=>{i.component&&(e[i.component.uuid]?e[i.component.uuid].push(i.uuid):e[i.component.uuid]=[i.uuid])}),this.eventContext.page.traverseEntity(i=>{i.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new tC(i,s.id,s.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,e))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let r=this.eventContext.domElement;r.addEventListener("pointerdown",this.onPointerDown),r.addEventListener("pointermove",this.onPointerMove),r.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(r=>r.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let r of e.dragItems)r.paused||this.updateDragItem(r,!0)}calcPlaneIntersectPos(e,r,i,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(Ac),Ac.negate();let l=_u.identity();switch(s==="parent"?dte.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(dr,l,Vi):s==="local"&&e.matrixWorld.decompose(dr,l,Vi),i){case"x":dr.set(1,0,0).applyQuaternion(l),hp.copy(Ac).cross(dr),ga.copy(dr).cross(hp);break;case"y":dr.set(0,1,0).applyQuaternion(l),hp.copy(Ac).cross(dr),ga.copy(dr).cross(hp);break;case"z":dr.set(0,0,1).applyQuaternion(l),hp.copy(Ac).cross(dr),ga.copy(dr).cross(hp);break;case"xy":ga.set(0,0,1).applyQuaternion(l);break;case"yz":ga.set(1,0,0).applyQuaternion(l);break;case"xz":ga.set(0,1,0).applyQuaternion(l);break;case"adaptive":Ac.angleTo(Vi.set(0,1,0))>Math.PI/6?(dr.crossVectors(Vi.set(0,1,0),Ac),ga.crossVectors(dr,Vi)):ga.set(0,1,0);break;default:ga.copy(Ac);break}Pu.setFromMatrixPosition(e.matrixWorld);let c=e.userData.lockedPlane?e.userData.worldPosition0:Pu;if(wV.setFromNormalAndCoplanarPoint(ga,c),!!a.ray.intersectPlane(wV,r)&&(i==="x"||i==="y"||i==="z")){let u=Vi.subVectors(r,c).dot(dr);r.copy(c).addScaledVector(dr,u)}}updateDragItem(e,r=!1){Pu.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Xg.subVectors(e.fromPosition,Pu).divideScalar(e.currentDampingFactor):e.reset==="original"?(Xg.subVectors(e.obj.userData.worldPosition0,Pu).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Xg.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Pu).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Xg.length()<hte:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&fte(e,Xg.add(Pu),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var fp=new E,rC=new E,ol=new E,al=new E,EV=new qr,pte=.01,mte={type:"requestRender"},gte=function(){let n=new E,t=new E;return(e,r,i)=>i>0?(n.subVectors(e,r),n.length()<=i?e:t.copy(r).add(n.normalize().multiplyScalar(i))):r}(),TV=function(){let n=new ue;return(t,e)=>{t.position.copy(e),t.parent!==null&&(n.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(n)),n.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(n),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof nr&&Dn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),iC=class{constructor(t,e,r,i,s,o){this.data=t;this.id=e;this.object=r;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={...y0.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=i.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Wt(t,t.actions,i,s,o,r)}},P1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(et.length>1)){this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!e.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new iC(o.data,o.id,s,e,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:r,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),Li&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(r.addEventListener("pointerenter",this.onMouseEnter),r.addEventListener("pointerleave",this.onMouseLeave));for(let s of this.events)if(s.target!==void 0){let o=s.target,a=this.onTargetChange(s);this.pairOfEventListeners.push([o,a]),o.addEventListener("requestRender",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Li&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let i of this.events)i.paused=!0,i.isReset=!1,vr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,r=!1){this.events.forEach(l=>{l.actions.Create.forEach(c=>{c.dispatchThrottled()})});let{plane:i,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(ol),e.isReset)al.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(al);else{let{getCamera:l,raycaster:c}=this.eventContext;if(i==="custom"?(l().getWorldDirection(rC),rC.negate(),fp.copy(rC)):i==="xy"?fp.set(0,0,1):i==="xz"?fp.set(0,1,0):i==="yz"&&fp.set(1,0,0),EV.setFromNormalAndCoplanarPoint(fp,ol),!c.ray.intersectPlane(EV,al))return}if(!e.isReset){if(al.distanceTo(e.worldPosition0)>s&&o&&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)al.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&&(al.x=ol.x),e.data.enabledTranslation[1]===!1&&(al.y=ol.y),e.data.enabledTranslation[2]===!1&&(al.z=ol.z);let a=gte(ol,al,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=fp.subVectors(a,ol).divideScalar(e.currentDampingFactor);ol.add(l),r&&TV(e.object,ol),e.paused=l.length()<pte}else TV(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(mte)}};var Yg=new E,_1=new E,Kg=new ue,pp=new Ye,Ec=new Ye,Qg=new E,Zg=new E,Iu=new E,ll=new E,nC=new qr,yte=1e-6,vte={type:"requestRender"},xte={type:"changeRotation"},MV=function(){let n=new ue;return function(e,r){e.parent!==null?n.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):n.copy(e.hiddenMatrix),r.premultiply(XM(n).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof nr&&Dn(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),sC=class{constructor(t,e,r,i){this.id=e;this.object=r;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Ye;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...v0.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=i.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),isNaN(this.worldQuaternion0.x)&&(this.worldQuaternion0.x=0),isNaN(this.worldQuaternion0.y)&&(this.worldQuaternion0.y=0),isNaN(this.worldQuaternion0.z)&&(this.worldQuaternion0.z=0),isNaN(this.worldQuaternion0.w)&&(this.worldQuaternion0.w=1),this.resetDampingFactor=80/this.data.resetSpeed+1}},I1=class extends Qt{constructor(){super(...arguments);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(et.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{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=e=>{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=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:r,target:i})=>{if(!r||!i)return;let s=ma(r);s&&s==="LookAt"&&this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="LookAt"&&!a.data.disabled);o&&(!e.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new sC(o.data,o.id,s,e))}),!this.events.length)return;let{domElement:r,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),Li&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(r.addEventListener("pointerenter",this.onMouseEnter),r.addEventListener("pointerleave",this.onMouseLeave));for(let s of this.events){if(s.target!==void 0){let l=this.onTargetChange(s),c=s.target;this.pairOfEventListeners.push([c,l]),c.addEventListener("requestRender",l)}let o=this.createUserEventListener(s),a=s.object;this.pairOfUserEventListeners.push([a,o]),a.addEventListener("userEvent",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Li&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),r.removeEventListener("scroll",this.onScroll);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let[i,s]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",s);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:r,axis:i,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:c}=e.data,{getCamera:u,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(Qg),!e.isReset)if(e.target)e.target.getWorldPosition(Zg);else{if(o==="custom"?(u().getWorldDirection(_1),_1.negate(),nC.setFromNormalAndCoplanarPoint(_1,Qg)):(o==="xy"?Yg.set(0,0,1):o==="xz"?Yg.set(0,1,0):o==="yz"&&Yg.set(1,0,0),nC.setFromNormalAndCoplanarPoint(Yg,Qg)),!h.ray.intersectPlane(nC,Zg))return;s>0&&(o==="custom"||o===void 0)&&Zg.addScaledVector(_1,s)}if(e.isReset||(f?r==="target"?Iu.copy(f.up).applyMatrix4(Kg.extractRotation(f.matrixWorld)).normalize():l.some(m=>m===!1)?(i==="x"?(ll.set(0,0,1),l[2]===!1&&ll.set(0,1,0)):i==="y"?(ll.set(1,0,0),l[0]===!1&&ll.set(0,0,1)):(ll.set(0,1,0),l[1]===!1&&ll.set(1,0,0)),Iu.copy(ll).applyQuaternion(e.worldQuaternion0).normalize()):Iu.set(0,1,0):o==="custom"?Iu.set(0,1,0):Iu.copy(Yg)),e.isReset)Ec.copy(e.worldQuaternion0);else if(Qg.distanceTo(Zg)>a&&c&&f)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)Ec.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;bte(Kg,Zg,Qg,Iu,i,ll),Ec.setFromRotationMatrix(Kg),pp.setFromUnitVectors(ll.applyQuaternion(Ec),Iu),l.some(m=>m===!1)&&r!=="target"&&Ec.premultiply(pp).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),pp.setFromRotationMatrix(XM(d.matrixWorld)),pp.slerp(Ec,1/e.currentDampingFactor),MV(d,Kg.makeRotationFromQuaternion(pp)),e.paused=8*(1-pp.dot(Ec))<yte):(MV(d,Kg.makeRotationFromQuaternion(Ec)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(vte),d.dispatchEvent(xte)}},Vs=new E,Ui=new E,fi=new E;function bte(n,t,e,r,i,s){let o=n.elements;fi.subVectors(t,e),fi.lengthSq()===0&&(fi.z=1),fi.normalize(),Ui.crossVectors(r,fi),Ui.lengthSq()===0&&(Math.abs(r.z)===1?fi.x+=1e-4:fi.z+=1e-4,fi.normalize(),Ui.crossVectors(r,fi)),Ui.normalize(),Vs.crossVectors(fi,Ui),i==="x"?s.z===1?[Ui,Vs,fi]=[fi,Ui,Vs]:(Ui.negate(),[Ui,fi]=[fi,Ui]):i==="y"?s.x===1?[Ui,Vs,fi]=[Vs,fi,Ui]:(Ui.negate(),[Vs,fi]=[fi,Vs]):s.x===1&&(Ui.negate(),[Ui,Vs]=[Vs,Ui]),o[0]=Ui.x,o[4]=Vs.x,o[8]=fi.x,o[1]=Ui.y,o[5]=Vs.y,o[9]=fi.y,o[2]=Ui.z,o[6]=Vs.z,o[10]=fi.z}var oC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=Wt(e,e.actions,i,s,o,r)}disconnect(){vr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatchStart()),this.actions.Particles.forEach(t=>t.dispatchBasic()),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()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()),this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Particles.forEach(e=>e.dispatchBasic()),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()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},D1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObjects={};this.objects=[];this.objects2D=[];this._prevObjects=[];this.onMouseDown=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{et.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{et.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=ma(e);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(o=>o.dispatchUserEvent(i)))}}connect(){let{page:e,sharedAssets:r}=this.eventContext,i=(o,a)=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:l,data:c}of o.data.events)if(!c.disabled&&c.type==="MouseHover")try{let u=new oC(l,c,o,e,r,this.eventManager);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.error(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o instanceof hr?a:o)}};if(e.traverseEntity(o=>{(o instanceof _r||o instanceof yr)&&o.frame?.traverse(a=>{i(a,o)}),i(o)}),!this.objects.length)return;let{domElement:s}=this.eventContext;this.domEventsNeeded.clear(),Li&&(this.domEventsNeeded.add("pointerdown"),s.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),s.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),s.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(o=>{o.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Li&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(r=>{r.forEach(i=>{i.disconnect()})}),this.objects.forEach(r=>{r.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let r=[];if(!e){let{stopRaycast:i,raycaster:s,page:o,pointerScreen:a}=this.eventContext,l=!1;if(o.uiCanvas&&(l=vo(o,[a.x,a.y],Object.keys(this.eventsPerObjects),c=>{r.push(c)})),i&&!l){let c=cp(s,o,this.objects);r=qg(c),c.forEach(u=>{u.object instanceof _r&&vo(u.object,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)})})}else this.objects.forEach(c=>{let u=up(s,c);u&&(r.push(c),c instanceof _r&&vo(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{r.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),r.length&&r.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=r}};var aC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=Wt(e,e.actions,i,s,o,r)}connect(){this.scrollCounter=0}disconnect(){vr(this.actions)}dispatch(t){this.actions.Transition.forEach(i=>{i.object.currentTransitionEvent!==this&&(i.object.currentTransitionEvent=this,i.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let r=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(i=>i.seek(r)),this.actions.Animation.forEach(i=>i.seek(e)),this.actions.TimelineAnimation.forEach(i=>i.seek(r)),this.actions.Create.forEach(i=>i.dispatchThrottled()),this.actions.SetVariable.forEach(i=>i.checkConditions()),this.actions.SetVariable.forEach(i=>i.dispatch()),this.actions.DynamicVariablePlay.forEach(i=>i.dispatch()),this.actions.ClearLocalStorage.forEach(i=>i.dispatch()),this.actions.UserAPI.forEach(i=>i.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()}),this.actions.TimelineAnimation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},lC=class{constructor(t,e,r,i,s,o,a){this.id=t;this.data=e;this.object=r;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=Wt(e,e.actions,i,s,a,r)}getStickyParentElement(){let t=this.domElement;for(;t;){if(window.getComputedStyle(t).position==="sticky")return t;t=t.parentElement}return null}computeScrollBounds(){let t=this.getStickyParentElement(),e=t?.parentElement,r=this.domElement.getBoundingClientRect(),i={top:r.top,bottom:r.bottom,left:r.left,right:r.right,width:r.width,height:r.height};if(e){let u=e.getBoundingClientRect(),h=window.getComputedStyle(t),d=parseFloat(h.marginTop)+parseFloat(h.marginBottom),f=parseFloat(h.top),m=parseFloat(h.bottom),p=u.height-d;if(!isNaN(f))r.top===f?(i.top+=u.top-f,i.bottom+=u.top-f):r.top<0&&(i.top-=p-r.height,i.bottom-=p-r.height);else if(!isNaN(m)){let g=document.body.clientHeight??window.innerHeight,y=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);r.bottom===g-m?(i.top+=u.top-r.height+m+y,i.bottom+=u.top-r.height+m+y):r.bottom<g-m&&(i.top-=p-r.height,i.bottom-=p-r.height)}}let s=document.body,o=document.documentElement,a=window.pageYOffset||o.scrollTop||s.scrollTop,l=o.clientTop||s.clientTop||0,c=Math.round(i.top+a-l);if(this.data.startFrom==="enter"){let u=window.innerHeight,h=i.height,d=this.data.enterAnchor,f=d==="top"?u:d==="bottom"?u-h:u-h*.5;this.scrollStart=c-f}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=i,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){vr(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:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let r=this.scrollEnd-this.scrollStart,i=Math.min(1,Math.max(0,(e-this.scrollStart)/r));this.actions.Transition.forEach(s=>s.seek(i)),this.actions.Animation.forEach(s=>s.seek(i)),this.actions.TimelineAnimation.forEach(s=>s.seek(i)),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()),this.actions.ClearLocalStorage.forEach(s=>s.dispatch()),this.actions.UserAPI.forEach(s=>s.dispatch())}dispatch(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()}),this.actions.TimelineAnimation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},O1=class extends Qt{constructor(e,r){super(e);this.managers=r;this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(i=>i.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([i,s])=>{i.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(o=>o.dispatch(r))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,i])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),i.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=ma(e);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(i)}))}}connect(){let{page:e,sharedAssets:r,domElement:i,isExport:s}=this.eventContext,o=a=>{if(!!a.data?.events.length){for(let{id:l,data:c}of a.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!s){let u=new aC(l,c,a,e,r,this.managers);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(u):this.wheelEventsPerObject.set(a,[u])}else{let u=new lC(l,c,a,e,r,i,this.managers);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(u):this.scrollEventsPerObject.set(a,[u])}}};e.traverseEntity(a=>{(a instanceof _r||a instanceof yr)&&a.frame?.traverse(l=>{o(l)}),o(a)}),this.intersectionObserver=new IntersectionObserver(a=>{let l=a[0];l&&(this.isInview=l.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([a,l])=>{l.forEach(c=>c.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([a,l])=>{l.forEach(c=>c.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(a=>a.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,r])=>{r.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var cC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Wt(e,e.actions,i,s,o,r)}disconnect(){vr(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.TimelineAnimation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Reset.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.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof da?e.interaction.audioPlayer?.play():e.interaction instanceof np&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof po?e.interaction.play(r==="autoplay"):e.interaction instanceof lp&&e.interaction.dispatch())}),this.actions.Particles.forEach(e=>{(e.data.triggerAfter??"any")===t&&e.dispatchBasic()})}async seekVideos(t){let e=[];this.actions.Video.forEach(r=>{(r.interaction.data.triggerAfter??"autoplay")==="autoplay"&&r.interaction instanceof po&&e.push(r.interaction.seek(t))}),await Promise.all(e)}pauseVideos(){this.actions.Video.forEach(t=>{t.interaction instanceof po&&t.interaction.pause()})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Reset.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.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof da?e.interaction.audioPlayer?.play():e.interaction instanceof np&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof po?e.interaction.play():e.interaction instanceof lp&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},R1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:r}=this.eventContext,i=r?document:e;i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.actions.Audio.forEach(s=>{s.interaction instanceof da&&s.interaction.audioPlayer?.play()}),i.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof po&&s.interaction.play(o==="autoplay")}),i.actions.Particles.forEach(s=>{s.dispatchBasic()})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.dispatchAfter("autoplay")})})};this.seekVideos=async e=>{let r=[];[...this.eventsAfterPerObject.entries()].forEach(([i,s])=>{!i.data.visible||s.forEach(o=>{r.push(o.seekVideos(e))})}),await Promise.all(r)};this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{r.forEach(i=>{i.pauseVideos()})})};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=ma(e);s&&s==="Start"&&(r instanceof hr||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(i)}))}}connect(){let{sharedAssets:e,page:r}=this.eventContext,i=s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let l=new cC(o,a,s,r,e,this.eventManager);(l.actions.Transition.length||l.actions.TimelineAnimation.length||l.actions.Animation.length||l.actions.SwitchCamera.length||l.actions.Create.length||l.actions.Destroy.length||l.actions.SceneTransition.length||l.actions.Reset.length||l.actions.SetVariable.length||l.actions.DynamicVariablePlay.length||l.actions.ClearLocalStorage.length||l.actions.UserAPI.length)&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])),l.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Particles.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l]))}};if(r.traverseEntity(s=>{(s instanceof _r||s instanceof yr)&&s.frame?.traverse(o=>{i(o)}),i(s)}),[...this.eventsAfterPerObject.values()].some(s=>s.length)){if(this.eventManager.activateCount===0){let{domElement:s,isExport:o}=this.eventContext,a=o?document:s;a.addEventListener("pointerdown",this.onMouseDown,{once:!0}),a.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),a.addEventListener("pointerdown",this.onAny),a.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([l,c])=>{l.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>a.dispatch()),s.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:r}=this.eventContext,i=r?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(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,r])=>{e.removeEventListener("userEvent",this.onUserEvent),r.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var L1=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.initialDisabled=!1;this.actions=Wt(e,e.actions,i,s,o,r),this.target=e.target}disconnect(){vr(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Animation.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}};var N1=class extends Qt{constructor(e,r,i,s,o){super(e);this.sharedVariables=r;this.eventManager=i;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.isOutOfFocus=!1;this.events=[];this.onFrame=e=>{let r=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let i=new Date,s=[],o=[];for(let c=0;c<this.propertiesToWatch.length;c++){let{objectId:u,property:h,prevValue:d}=this.propertiesToWatch[c],f=this.eventContext.scene.find(u),m=b0.propertyPaths[h];if(m[0]==="width"||m[0]==="height"||m[0]==="depth")f=f.geometry.userData.parameters[m[0]];else for(let p=0;p<m.length;p++)f=f[m[p]];d===null?this.propertiesToWatch[c].prevValue=f instanceof E?f.clone():f:(f instanceof E?!f.equals(d):d!==f)&&(o.push({objId:u,property:h}),f instanceof E?this.propertiesToWatch[c].prevValue.copy(f):this.propertiesToWatch[c].prevValue=f)}for(let c=0;c<this.variablesToWatch.length;c++){let{id:u,prevValue:h}=this.variablesToWatch[c],d=r.getVariable(u);d!==h&&(s.push(u),this.variablesToWatch[c].prevValue=d)}for(let c=0;c<this.dynamicVars.length;c++){let{id:u,expectedTime:h,last:d,data:f,timerSeconds:m,startValue:p}=this.dynamicVars[c],g=1e3;if((f.dynamicVariableType==="timer"||f.dynamicVariableType==="stopwatch")&&f.format==="number3decimal"?g=1:f.dynamicVariableType==="counter"?g=f.updateInterval:f.dynamicVariableType==="random"&&(g=f.isStatic?1/0:f.updateInterval),h===-1){this.dynamicVars[c].last=e,this.dynamicVars[c].expectedTime=e+g;continue}if(!((r.getDynamicVariablePlayState(u)==="Stopped"||r.getDynamicVariablePlayState(u)==="Restarted")&&(this.dynamicVars[c].last=e,this.dynamicVars[c].expectedTime=e+g,f.dynamicVariableType==="counter"&&r.getVariable(u)!==p&&(r.updateVariable(u,p),this.eventManager.requestRender()),(f.dynamicVariableType==="timer"||f.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==p&&(this.dynamicVars[c].timerSeconds=p,r.updateVariable(u,An.getFormattedTimerTime(p,f)),this.eventManager.requestRender()),r.getDynamicVariablePlayState(u)==="Restarted"&&r.setDynamicVariablePlayState(u,"Playing"),r.getDynamicVariablePlayState(u)==="Stopped"))){if(r.getDynamicVariablePlayState(u)==="Paused"){this.dynamicVars[c].deltaToExpectedTime===void 0&&(this.dynamicVars[c].deltaToExpectedTime=Math.max(this.dynamicVars[c].expectedTime-e,0)),this.dynamicVars[c].last=e-(g-this.dynamicVars[c].deltaToExpectedTime),this.dynamicVars[c].expectedTime=e+this.dynamicVars[c].deltaToExpectedTime;continue}else this.dynamicVars[c].deltaToExpectedTime=void 0;if(e>=h)if(this.dynamicVars[c].last=e,this.dynamicVars[c].expectedTime+=g,f.dynamicVariableType==="random"){let y=f.min+Math.random()*(f.max-f.min),x=f.decimals;y=Math.round(y*Math.pow(10,x))/Math.pow(10,x),r.updateVariable(u,y),s.push(u),this.eventManager.requestRender()}else if(f.dynamicVariableType==="counter"){let y=r.getVariable(u),x=r.getDynamicVariableToggleIsForward(u)??!0,v=r.getVariable(u)+f.increment*(x?1:-1);f.hasEnd&&(v=f.increment>0?Se.clamp(v,p,f.endValue):Se.clamp(v,f.endValue,p),v===p&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?v===f.endValue&&(v=p):(v===p||v===f.endValue)&&r.setDynamicVariablePlayState(u,"Paused")),v!==y&&(s.push(u),r.updateVariable(u,v),this.eventManager.requestRender())}else if(f.dynamicVariableType==="time"){let y=r.getVariable(u),x=RT(i,f);if(typeof y=="object"&&"textValue"in y&&typeof x=="object"&&"textValue"in x){if(Array.isArray(y.textValue)&&Array.isArray(x.textValue)){if(y.textValue.every((v,b)=>v===x.textValue[b]))continue}else if(y.textValue===x.textValue)continue}else if(y===x)continue;r.updateVariable(u,x),s.push(u),this.eventManager.requestRender()}else{let y=Gr.isTextValue(f.endValue)?CV(f.endValue.textValue):f.endValue,x=r.getDynamicVariableToggleIsForward(u)??!0,v=m+(e-d)/1e3*(f.dynamicVariableType==="timer"?-1:1)*(x?1:-1);v=Math.max(v,0),f.hasEnd&&(v=f.dynamicVariableType==="stopwatch"?Se.clamp(v,p,y):Se.clamp(v,y,p),v===p&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?Math.abs(v-y)<(f.format==="number3decimal"?1e-4:.1)&&(v=p):(Math.abs(v-p)<(f.format==="number3decimal"?1e-4:.1)||Math.abs(v-y)<(f.format==="number3decimal"?1e-4:.1))&&r.setDynamicVariablePlayState(u,"Paused")),v!==m&&(s.push(u),this.dynamicVars[c].timerSeconds=v,r.updateVariable(u,An.getFormattedTimerTime(v,f)),this.eventManager.requestRender())}}}let a=!1;r.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=r.mouseProperty,a=!0);let l=!1;r.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=r.raycastProperty,l=!0),this.events.forEach(c=>{(s.includes(c.data.variableId)||o.find(u=>u.objId===c.data.objectId&&u.property===c.data.property)||c.data.variableId==="mouseProperty"&&a||c.data.variableId==="raycastProperty"&&l)&&(c.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()}}pause(){this.isOutOfFocus||(this.isOutOfFocus=!0,this.pauseTime=Date.now())}resume(){if(!this.isOutOfFocus)return;this.isOutOfFocus=!1;let e=Date.now()-this.pauseTime;for(let r=0;r<this.dynamicVars.length;r++)this.dynamicVars[r].last+=e,this.dynamicVars[r].expectedTime+=e}connect(){this.eventContext.page.traverseEntity(r=>{r.data?.events.filter(i=>i.data.type==="VariableChange"&&!i.data.disabled).forEach(i=>{this.events.push(new uC(i.id,i.data,r,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(r=>r.data.variableId==="objectProperty"&&r.data.objectId!==null).map(r=>({objectId:r.data.objectId,property:r.data.property,prevValue:null}));let e=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:r,data:i})=>{if(!("dynamicVariableType"in i)){this.events.find(o=>o.data.variableId===r)&&this.variablesToWatch.push({id:r,prevValue:e.getVariable(r)});return}let s;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let o;if(Gr.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let a=i.value.textValue;a.length===3?o=a[2]+a[1]*60+a[0]*3600:o=a[1]+a[0]*60}else o=i.value;s=o,this.dynamicVars.push({id:r,last:-1,expectedTime:-1,data:i,timerSeconds:o,startValue:s})}else i.dynamicVariableType==="time"&&e.updateVariable(r,RT(new Date,i)),i.dynamicVariableType==="counter"&&(s=Gr.isTextValue(i.value)?CV(i.value.textValue):i.value),this.dynamicVars.push({id:r,last:-1,expectedTime:-1,data:i,startValue:s})}),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())}},uC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Wt(e,e.actions,i,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispose(){vr(this.actions)}};function CV(n){return n.length===3?n[2]+n[1]*60+n[0]*3600:n[1]+n[0]*60}var _V=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@1.12.48/build/",Ste=!1?_V:"https://unpkg.com/@splinetool/navmesh-wasm@1.12.48/build/",wte=`
|
|
8107
8107
|
(async function() {
|
|
8108
8108
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
8109
8109
|
import('${_V}' + 'navmesh.js'),
|
|
@@ -8171,4 +8171,4 @@ onmessage = function(messageEvent) {
|
|
|
8171
8171
|
`),M.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),M.addEventListener("touchend",P=>P.preventDefault()),this.joysticks[m]=[void 0,p];return}let T={zone:p,mode:"static",position:b,size:g};x==="hide"&&(T.restOpacity=0);let S=NF.create(T);S.on("move",(M,C)=>{let P=this.gameControl;f==="pos"?C.force<.2?P.moveForce=0:(P.movementState.movePosZ=Math.sin(-C.angle.radian),P.movementState.movePosX=Math.cos(-C.angle.radian),C.force>1.2?P.movementState.run=1:P.movementState.run=0,C.force<.3?P.moveForce=(C.force-.2)/.1:P.moveForce=1):f==="rot"&&(C.force<.2?P.rotForce=0:(P.movementState.rotPosX=C.vector.y,P.movementState.rotPosY=-C.vector.x,C.force<.3?P.rotForce=(C.force-.2)/.1:P.rotForce=1)),this.requestRender()}),S.on("end",(M,C)=>{let P=this.gameControl;f==="pos"?(P.movementState.movePosZ=0,P.movementState.movePosX=0,P.moveForce=1):f==="rot"&&(P.movementState.rotPosX=0,P.movementState.rotPosY=0,P.rotForce=1)}),this.joysticks[m]=[S,p]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(f=>f.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Xt.World(new Xt.Vector3(0,this.gravity,0)),this.events=new Xt.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let l;if(a instanceof Ai)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;l=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(a instanceof Lr)l=a.object;else{if(a instanceof ca||a instanceof oa)return;if(l=a,l.dataPatched.cloner?.disabled===!1&&l.dataPatched.cloner?.hideBase&&l.dataPatched.physics?.fusedBody!==!0)return!0}let c=l.dataPatched,u;for(let y of c.events)y.data.disabled!==!0&&y.data.type==="GameControl"&&(u=y.data);if(!c.physics||(c.physics.enabled==="visibility"?!c.visible:!c.physics.enabled))return!0;a.updateMatrixWorldSVD();let h=Jg(c),d=!1,f=l.userData.hasDestroy,m=l.userData.hasDrag,p=!1;for(let y of c.events)if(y.data.disabled!==!0){if(y.data.type==="Collision"){d=!0;let x=new L1(y.id,y.data,l,this.page,this.sharedAssets,this.eventManager);x.initialDisabled=!0,this.collisionEvents.push(x),this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].every(v=>v.id!==y.id)?this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].push(x):this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]=[x]}else if(y.data.type==="Follow"){p=!0;let x=y.data.target;a.traverseVisible(v=>{v.userData.isFollowingObj=x})}}c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(u!==void 0){let y=Xt.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(Ti,xo,Tc),a.position0=Ti.clone().divideScalar(this.pixelsPerMeter),a.rotation0=xo.clone(),Ti.divideScalar(this.pixelsPerMeter),y.setTranslation(Ti.x,Ti.y,Ti.z).setRotation(xo);let x=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);a.rigidBody=x;let v;u.collider.type==="sphere"?v=Xt.ColliderDesc.ball(u.collider.radius/this.pixelsPerMeter):u.collider.type==="capsule"?v=Xt.ColliderDesc.capsule((u.collider.height/2-u.collider.radius)/this.pixelsPerMeter,u.collider.radius/this.pixelsPerMeter):v=Xt.ColliderDesc.cuboid(u.collider.width/this.pixelsPerMeter/2,u.collider.height/this.pixelsPerMeter/2,u.collider.depth/this.pixelsPerMeter/2),v.setFrictionCombineRule(Xt.CoefficientCombineRule.Average).setRestitutionCombineRule(Xt.CoefficientCombineRule.Average).setDensity(c.physics.density).setFriction(c.physics.friction).setRestitution(c.physics.restitution);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(v,x);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,l),Ti.fromArray(u.collider.position.map(A=>typeof A=="number"?A:0)).multiply(Tc.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(Ti);let w=new Ye().setFromEuler(new Jt().setFromVector3(new E().fromArray(u.collider.rotation.map(A=>typeof A=="number"?A:0))));b.setRotationWrtParent(w),b.setActiveEvents(Xt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else c.physics.rigidBody==="dynamic"||h||p||f||m||d?(this.addRigidBody(a,l,{hasFollow:p,hasTransformAnim:h,hasDrag:m}),this.generateSensorColliderDescs(l,c.physics.fusedBody)):(g&&t.push(yo(g,a.matrixWorld)),c.physics.fusedBody&&a.traverseObject((y,x)=>{if(x===0)return;let v;if(y instanceof Ai)if(y.objectForSample){if(y.objectForSample.dataPatched.physics.fusedBody)return;v=y.object}else return y.object.dataPatched.physics.fusedBody===!0&&y.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else{if(y instanceof ca||y instanceof oa)return;if(y instanceof Lr)v=y.object;else if(v=y,v.dataPatched.cloner?.hideBase)return!0}let b=v.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let w=y.geometry;w?.getAttribute("position")!==void 0&&t.push(yo(w,y.matrixWorld))}),this.generateSensorColliderDescs(l,c.physics.fusedBody,e));if(c.physics?.fusedBody===!0||u)return!0}),t.length===0)return;let r=Js(t);r.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let i=Xt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(i),o=Xt.ColliderDesc.trimesh(r.getAttribute("position").array,r.getIndex().array).setFrictionCombineRule(Xt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Xt.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(o,s);for(let[a,l]of e){let c=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[c.handle]=l}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let r=new ey(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),i=new ue().compose(bo.fromArray(e.data.position.map(s=>typeof s=="number"?s:0)),yp.setFromEuler(LV.fromArray(e.data.rotation.map(s=>typeof s=="number"?s:0))),xC);if(e.data.triggerZone==="box"){let s=new Yt;s.min.fromArray(e.data.size.map(o=>typeof o=="number"?o:0)).multiplyScalar(-.5),s.max.fromArray(e.data.size.map(o=>typeof o=="number"?o:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,i,t,r])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,i,t,r])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(!!this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.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(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t,e,r){if(!this.isEnabled)return!0;let i=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),i=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,i=!1):this.initializationCounter===2&&this.gameControl&&(i=!this.gameControl.update(t,e,r)&&i),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(t===0)i=this.stepPhysics()&&i;else{let o=t/1e3;o<s&&o>s*.55&&(o=s),this.accumulator+=o;let a=performance.now(),l=0,c=6;for(;this.accumulator>=s&&l<c&&(i=this.stepPhysics()&&i,this.accumulator-=s,l++,!(performance.now()-a>s*1e3)););this.accumulator=this.accumulator%s}}this.skipRender=i}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(Ti,xo,Tc),yC.setFromQuaternion(xo);let r=e;r.prevR===void 0?(r.prevR=yC.clone(),r.prevT=Ti.clone()):(r.prevR.copy(yC),r.prevT.copy(Ti)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(Ti.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(xo))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,r){let i=(this.sharedGameControlGlobals.rapierWorld?.getCollider(r))._parent,s;if(e.cloner){for(let o of e.cloner.children)if(o.rigidBody===i){s=o;break}}t.dispatch(s),e.dispatchEvent(b1)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,r){let i=NV.copy(t.matrixWorld).invert();t.traverseEntity((s,o)=>{if(e===!1&&o===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let l=new ey(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),c;if(a.data.triggerZone==="box"?c=Xt.ColliderDesc.cuboid(...a.data.size.map(u=>(typeof u=="number"?u:1)/(2*this.pixelsPerMeter))):c=Xt.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),c.setDensity(0).setSensor(!0).setActiveEvents(Xt.ActiveEvents.COLLISION_EVENTS),bo.fromArray(a.data.position.map(u=>typeof u=="number"?u:0)),yp.setFromEuler(LV.fromArray(a.data.rotation.map(u=>typeof u=="number"?u:0))),k1.compose(bo,yp,xC).premultiply(s.matrixWorld),r?(k1.decompose(bo,yp,vC),c.setActiveCollisionTypes(Xt.ActiveCollisionTypes.KINEMATIC_FIXED|Xt.ActiveCollisionTypes.DYNAMIC_FIXED)):(k1.premultiply(i).decompose(bo,yp,vC),t.rigidBody.bodyType()===Xt.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===Xt.RigidBodyType.Fixed?c.setActiveCollisionTypes(Xt.ActiveCollisionTypes.KINEMATIC_FIXED|Xt.ActiveCollisionTypes.DYNAMIC_FIXED):c.setActiveCollisionTypes(Xt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Xt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),bo.divideScalar(this.pixelsPerMeter),c.setTranslation(bo.x,bo.y,bo.z),c.setRotation(yp),r)r.push([c,l]);else{let u=this.sharedGameControlGlobals.rapierWorld.createCollider(c,t.rigidBody);this.sensorToTriggerEvent[u.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[r,i,s,o]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let l=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===l||o.isValidTriggeringObject(gt.is(l)?l:l.object)===!1)continue;let c=NV.copy(s.matrixWorld).decompose(bo,BV,vC).compose(bo,BV,xC).multiply(i),u=k1.copy(l.matrixWorld).invert().multiply(c);r instanceof Yt?t=l.bvhGeometry.boundsTree.intersectsBox(r,u):(bC.radius=r,bC.center.setFromMatrixPosition(u),t=l.bvhGeometry.boundsTree.intersectsSphere(bC)),t?o.currentIntersectedObjects.indexOf(l)===-1&&(o.currentIntersectedObjects.push(l),o.dispatch(),s.dispatchEvent(Nte)):o.currentIntersectedObjects=o.currentIntersectedObjects.filter(h=>h!==l)}}}};function VV(n){let t=this._clip.duration,e=this._clip.start??0,r=this.loop,i=this.time+n,s=this._loopCount,o=r===$p;if(n===0)return s===-1?i:o&&(s&1)===1?t-(i-e):i;if(r===Pw){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:n<0?-1:1})}}else{if(s===-1&&(n>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<e){let a=Math.floor((i-e)/(t-e));i-=(t-e)*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o||(i=n>0?t:e,this.repetitions===1&&(i=t)),this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:n>0?1:-1});else{if(l===1){let c=n<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return t-(i-e)}return i}var UV=!1,G1=class{constructor(t,e,r,i){this.scene=t;this.requestRender=e;this.updateDisplayProgress=r;this.animationInspectorState=i;this.clipIdToAction={};this.activeClip=null;this.needsUpdate=!1;this.addClip=t=>{t.data.type==="Empty"&&t.data.animations&&t.data.animations.forEach((e,r)=>{let i=e[0]+"/";if(Array.isArray(t.identity)?i+=t.identity[0]:i+=t.uuid,this.clipIdToAction[i])return;let s=gh.parse(JSON.parse(e[2]));t.animations[r]=s;let o=this.mixer.clipAction(s,t);UV===!1&&(Object.getPrototypeOf(o)._updateTime=VV,UV=!0),o.clampWhenFinished=!0,this.clipIdToAction[i]=o})};this.mixer=new sv(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let r=this.scene.find(e);if(!r)return;let i=r.animations.find(o=>o.uuid===t);if(!i)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(i),delete this.clipIdToAction[t],r.animations=r.animations.filter(o=>o.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=_w}),this.mixer.stopAllAction(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,r=this.clipIdToAction[e];if(!!r)return t&&(t.repeat>=0&&(r.repetitions=t.repeat+1),t.direction==="pingpong"&&t.repeat!==0&&(r.loop=$p)),r.play(),r.paused=!1,this.requestRender(),r}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*(this.maxFrames-1)%(this.maxFrames-1))),this.requestRender()}get maxFrames(){return zM(this.activeClip??void 0)}setProgressFromInspector(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let r=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(t/(this.maxFrames-1),.9999)*this.activeClip.duration),this.requestRender(),r&&(this.clipIdToAction[e].paused=!0)}};var SC=new WeakMap,j1=class extends Ml{constructor(t){super(t),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(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,r,i){let s=new yh(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,o=>{this.decodeDracoFile(o,e).catch(i)},r,i)}decodeDracoFile(t,e,r,i){let s={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!r};return this.decodeGeometry(t,s).then(e)}decodeGeometry(t,e){let r=JSON.stringify(e);if(SC.has(t)){let l=SC.get(t);if(l.key===r)return l.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=t.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((c,u)=>{i._callbacks[s]={resolve:c,reject:u},i.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),SC.set(t,{key:r,promise:a}),a}_createGeometry(t){let e=new Ce;t.index&&e.setIndex(new je(t.index.array,1));for(let r=0;r<t.attributes.length;r++){let i=t.attributes[r],s=i.name,o=i.array,a=i.itemSize;e.setAttribute(s,new je(o,a))}return e}_loadLibrary(t,e){let r=new yh(this.manager);return r.setPath(this.decoderPath),r.setResponseType(e),r.setWithCredentials(this.withCredentials),new Promise((i,s)=>{r.load(t,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(r=>{let i=r[0];t||(this.decoderConfig.wasmBinary=r[1]);let s=Bte.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
8172
8172
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){let o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[t]=e,r._taskLoad+=e,r})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function Bte(){let n,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":n=a.decoderConfig,t=new Promise(function(u){n.onModuleLoaded=function(h){u({draco:h})},DracoDecoderModule(n)});break;case"decode":let l=a.buffer,c=a.taskConfig;t.then(u=>{let h=u.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let m=e(h,d,f,c),p=m.attributes.map(g=>g.array.buffer);m.index&&p.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},p)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{h.destroy(f),h.destroy(d)}});break}};function e(o,a,l,c){let u=c.attributeIDs,h=c.attributeTypes,d,f,m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(m===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let p={index:null,attributes:[]};for(let g in u){let y=self[h[g]],x,v;if(c.useUniqueIDs)v=u[g],x=a.GetAttributeByUniqueId(d,v);else{if(v=a.GetAttributeId(d,o[u[g]]),v===-1)continue;x=a.GetAttribute(d,v)}p.attributes.push(i(o,a,d,g,y,x))}return m===o.TRIANGULAR_MESH&&(p.index=r(o,a,d)),o.destroy(d),p}function r(o,a,l){let u=l.num_faces()*3,h=u*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,u).slice();return o._free(d),{array:f,itemSize:1}}function i(o,a,l,c,u,h){let d=h.num_components(),m=l.num_points()*d,p=m*u.BYTES_PER_ELEMENT,g=s(o,u),y=o._malloc(p);a.GetAttributeDataArrayForAllPoints(l,h,g,p,y);let x=new u(o.HEAPF32.buffer,y,m).slice();return o._free(y),{name:c,array:x,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var Mc;function wC(n){return Mc||(Mc=new j1,Mc.setDecoderPath(n?`${n}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Mc.decoderPending}async function Fte(n){if(Mc){let t={attributeIDs:Mc.defaultAttributeIDs,attributeTypes:Mc.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Mc.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,i])=>({name:r,itemSize:i.itemSize,array:i.array}))}}return null}async function kV(n,t){let[e,r]=fA(ad.deserialize(new Uint8Array(n)));return K0(e),t&&t(e),r.result().data}function zV(n){let t=[];return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function AC(n){for(let t of n){let e=await Fte(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let i={};e.attributes.forEach(({name:s,array:o,itemSize:a})=>{i[s]={array:o,itemSize:a,type:"Float32Array",normalized:!1}}),r.attributes=i,r.draco=void 0}}}var H1=class{constructor(){this._clickCount=0;this._lastTime=0;this._lastPosition=[0,0];this._delay=500;this._distance=2;this._onMouseDown=t=>{let e=[t.clientX,t.clientY],r=new Date().getTime();if(this._clickCount>0){let i=e[0]-this._lastPosition[0],s=e[1]-this._lastPosition[1];Math.sqrt(i*i+s*s)>this._distance&&(this._clickCount=0)}this._lastPosition=e,this._clickCount=r-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=r};this._onMouseUp=t=>{}}start(t,e=500,r=2){this._target&&this.stop(),this.reset(),this._delay=e,this._distance=r,this._target=t,this._target.addEventListener("pointerdown",this._onMouseDown,!1),this._target.addEventListener("pointerup",this._onMouseUp,!1)}stop(){this._target&&(this._target.removeEventListener("pointerdown",this._onMouseDown,!1),this._target.removeEventListener("pointerup",this._onMouseUp,!1),this._target=void 0)}get clickCount(){return this._clickCount}reset(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0]}};var EC=class{constructor(t,e,r,i,s,o,a,l){this.eventId=t;this.id=e;this.data=r;this.dataEvent=i;this.object=s;this.stage=!1;this.actions=Wt(i,r.actions,o,a,l,s)}disconnect(){vr(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),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.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},W1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.breakpoints=[];this.resize=(e,r)=>{this.breakpoints.forEach(i=>{let s=x0.deviceToSize(i.data.size),o=i.dataEvent.orientation==="horizontal"?e:r,a;switch(i.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}i.stage!==a&&(i.stage=a,i.stage?i.dispatchIn():i.dispatchOut())})};this.onResizeObserver=new ResizeObserver(e=>{for(let r of e){let{width:i,height:s}=r.contentRect;this.resize(i,s)}})}connect(){let{page:e,sharedAssets:r,domElement:i}=this.eventContext;this.onResizeObserver.observe(i);let s=o=>{if(!(!o.visible||!o.data?.events.length))for(let{data:a,id:l}of o.data.events)a.disabled||a.type==="Resize"&&a.breakpoints.forEach(({data:c,id:u})=>{try{let h=new EC(l,u,c,a,o,e,r,this.eventManager);this.breakpoints.push(h)}catch(h){!1&&console.error(h)}})};e.traverseEntity(o=>{(o instanceof _r||o instanceof yr)&&o.frame?.traverse(a=>{s(a)}),s(o)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}};var q1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.userAPIs={};this.events=[];this.onSuccess=({userAPIId:e})=>{this.events.forEach(r=>{r.data.userAPIId===e&&r.dispatchSuccess()})};this.onError=({userAPIId:e})=>{this.events.forEach(r=>{r.data.userAPIId===e&&r.dispatchError()})};this.userAPIs=e.sharedAssets.getUserAPIs()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="API"&&!r.data.disabled).forEach(r=>{this.events.push(new TC(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userAPIs).forEach(([e,r])=>{r.on("success",this.onSuccess),r.on("error",this.onError),r.autostart&&r.callUserAPI(this.eventContext.sharedAssets)})}disconnect(){Object.entries(this.userAPIs).forEach(([e,r])=>{r.off("success",this.onSuccess),r.off("error",this.onError)})}},TC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.successActions=Wt(e,e.successActions,i,s,o,r),this.errorActions=Wt(e,e.errorActions,i,s,o,r)}dispatchSuccess(){this.dispatchActions(this.successActions)}dispatchError(){this.dispatchActions(this.errorActions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}};var X1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.userWebhooks={};this.events=[];this.onMessage=({userWebhookId:e})=>{this.events.forEach(r=>{r.data.userWebhookId===e&&r.dispatch()})};this.userWebhooks=e.sharedAssets.getUserWebhooks()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="WEBHOOK"&&!r.data.disabled).forEach(r=>{this.events.push(new MC(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userWebhooks).forEach(([e,r])=>{r.connect(),r.on("message",this.onMessage)})}disconnect(){Object.entries(this.userWebhooks).forEach(([e,r])=>{r.off("message",this.onMessage),r.disconnect()})}},MC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Wt(e,e.actions,i,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}};function Vte(){let n=document.createElement("textarea");return n.style.position="fixed",n.style.top="200px",n.style.left="400px",n.style.zIndex="-1",n.style.border="1px solid rgba(255,0,0,0.5)",n.style.width="10px",n.style.height="500px",n.style.color="white",n.style.opacity="0.5",n.style.background="transparent",n.style.display="none",n.style.margin="0px",n.style.padding="0px",n.style.boxSizing="content-box",n.style.pointerEvents="none",n}var Ute=new E(0,0,1),GV=new E,jV=new E,HV=new Sr,Y1=class{constructor(t,e,r,i,s){this.containerScene=t;this.raycaster=e;this.sharedAssets=r;this.requestRender=i;this.onExit=s;this.htmlInput=null;this.virtualInput=null;this.helper=new Kf;this.doubleClickHandler=new H1;this.isDragging=!1;this.plane=new qr;this.caretInterval=0;this.planeIntersection=new E;this.projected=new U;this._lastIndex=0;this._isFirstDragMove=!1;this.selectionOnDragStart=0;this.onTextMaterialChanged=()=>{let t=this.virtualInput?.data;if(this.virtualInput!==void 0&&t){let e=t.material,r=typeof e=="string"?this.sharedAssets.data.materials[e]:e,i=fB(r,this.sharedAssets);this.helper.setCaretColor(i)}};this.stopAnimateTextCursor=()=>{clearInterval(this.caretInterval),this.helper&&(this.helper.caretMesh.visible=!1)};this.startAnimateTextCursor=()=>{this.stopAnimateTextCursor(),this.helper&&(this.helper.caretMesh.visible=!0,this.caretInterval=setInterval(()=>{this.helper&&(this.helper.caretMesh.visible=!this.helper.caretMesh.visible),this.requestRender()},600))};this.handleCaretUpdate=t=>{if(!this.htmlInput||!this.virtualInput)return;let e=this.helper,r=t?.key==="ArrowLeft"||t?.key==="ArrowRight",i=t?.key==="ArrowUp"||t?.key==="ArrowDown";this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(e.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:r,verticalKeyMove:i}),this.startAnimateTextCursor()):e.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()};this.containerScene.add(this.helper)}createInput(){return this.htmlInput=Vte(),this.htmlInput}connect(){}disconnect(){this.stopAnimateTextCursor(),this.helper.hide(),this.htmlInput?.remove(),this.doubleClickHandler.stop()}handleMouseDown(){if(!this.htmlInput||!this.virtualInput)return!0;this.getPointOnPlane();let t=this.doubleClickHandler.clickCount,{index:e,lineIndex:r,characterIndex:i}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,t>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0};this.virtualInput?.wrappedText?.length&&this.virtualInput.wrappedText[r][Math.max(0,i-1)]===`
|
|
8173
8173
|
`&&(e--,i--),this._lastIndex=e,this._isFirstDragMove=!0;let s=this.checkClickedObject();if(t===1){if(s===null)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=e,this.isDragging=!0,this.setInputSelection(e)}else s===this.virtualInput&&(t===2?this.selectClosestWord(r,i):t>2&&(this.setInputSelection(0,this.htmlInput.value.length),this.doubleClickHandler.reset()))}handleMouseUp(){this.applyRangeToTextInput(),this.isDragging=!1,this._isFirstDragMove=!1}handleMouseMove(){!this.virtualInput||(this._isFirstDragMove&&this.doubleClickHandler.clickCount>1&&(this.selectionOnDragStart=this._lastIndex,this.isDragging=!0,this.setInputSelection(this._lastIndex)),this._isFirstDragMove=!1,this.getPointOnPlane(),this.applyRangeToTextInput())}focus(t){if(this.virtualInput=t,this.updateTextInputStyles(),this.htmlInput)if(t){let e=this.data?.geometry.text;this.htmlInput.value=typeof e=="string"?"":e?.textValue.toString()??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:t}=this;if(t)return t.dataPatched}applyRangeToTextInput(){if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let t=this.selectionOnDragStart,{index:e,lineIndex:r,characterIndex:i}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0};r!==void 0&&i!==void 0&&this.virtualInput?.wrappedText[r][i-1]===`
|
|
8174
|
-
`&&e--,this.htmlInput.setSelectionRange(Math.min(t,e),Math.max(t,e))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof yc)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let r=this.virtualInput.wrappedText,i=r[t],s=e+1,o=e;i[e]!==" "&&(s=this.findNextCharOccurence(i,e,"forward"," "),o=this.findNextCharOccurence(i,e,"backward"," "),o>0&&o++,s>=i.length-1&&t===r.length-1&&s++);let a=this.helper,l=a.getGlobalIndexFromLineAndCharIndexes(r,t,o),c=a.getGlobalIndexFromLineAndCharIndexes(r,t,s);this.setInputSelection(l,c)}findNextCharOccurence(t,e,r,i=" "){let s=Math.max(0,t.length-1),o=r==="forward"?s:0,a=r==="forward"?1:-1,l=Math.max(Math.min(e,s),0);for(;l!==o;)if(l+=a,t.charAt(l)===i)return l;return o}getPointOnPlane(){let t=this.virtualInput?.data;if(!(!this.virtualInput||!t)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new E);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let r=typeof t.geometry.width=="number"?t.geometry.width:1,i=typeof t.geometry.height=="number"?t.geometry.height:1;this.projected.set(e.x+r*.5,e.y-i*.5)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(HV.getNormalMatrix(this.virtualInput.matrixWorld),GV.copy(Ute).applyMatrix3(HV).normalize(),this.virtualInput.localToWorld(jV.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(GV,jV))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),bs&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=kte(t.geometry.horizontalAlign))}};function kte(n){return n===4?"justify":n===2?"right":n===3?"center":"left"}var qV=(n,t)=>{if(typeof n=="string"){let e=t.data(n);if(e)return qV(e.value,t)}return Gr.getDisplayedValue(n)};function WV(n,t){let e=n.text,r="";if(typeof e=="string"){let i=t.variables.data(r);i&&(r=qV(i.value,t.variables))}else r=e.textValue.toString();return r}var K1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this._textInputs=[];this.sceneHelpers=new Er;this.helper=new Kf;this._onMouseDownFocusIn=e=>{if(et.length>1)return;this.eventContext.updateRaycaster(e);let r=null;if(this.eventContext.raycaster){for(let i of this._textInputs)if(this.eventContext.raycaster.intersectObject(i,!0).length>0){r=i;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(e),this._onMouseDown(e)};this.onExit=()=>{let{virtualInput:e}=this.textInputManager;if(e===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r?.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:i}=this.eventContext;i.removeEventListener("pointerdown",this._onMouseDown,!1),i.removeEventListener("pointerup",this._onMouseUp,!1),i.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),i.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()};this._onMouseDown=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)};this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)};this._onMouseMove=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseMove()};this._onTextEdit=e=>{let{htmlInput:r,virtualInput:i,helper:s}=this.textInputManager;if(!r||!i)return;let o=r.value;i.textGeometry.setText(o,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let a=i.data;s.update();let l=a.geometry.text;if(typeof l=="string"){let c=l;this.eventContext.sharedAssets.updateVariable(c,{textValue:o})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()};this._onCaretUpdate=e=>{this.textInputManager.handleCaretUpdate(e)};this._onKeyPress=e=>{e.key==="Escape"&&this.onExit()};this.textInputManager=new Y1(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(s=>{s instanceof yc&&e.push(s)}),this._textInputs=e,e.length===0)return;let{domElement:r}=this.eventContext;r.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let e=this.textInputManager.htmlInput,{domElement:r,sharedAssets:i}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),e?.removeEventListener("keyup",this._onCaretUpdate),e?.removeEventListener("keydown",this._onCaretUpdate),e?.removeEventListener("beforeinput",this._onCaretUpdate),e?.removeEventListener("paste",this._onCaretUpdate),e?.removeEventListener("cut",this._onCaretUpdate),e?.removeEventListener("select",this._onCaretUpdate),e?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(s=>{let o=WV(s.data.geometry,this.eventContext.sharedAssets.data);s.textGeometry.setText(o,i)}),r.removeEventListener("pointerdown",this._onMouseDown,!1),r.removeEventListener("pointerup",this._onMouseUp,!1),r.removeEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(e){this.textInputManager.focus(e),this.textInputManager.onTextMaterialChanged();let r=this.textInputManager.htmlInput;if(!r||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=WV(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);r.value=i,r.setSelectionRange(0,0),this.textInputManager.helper.show(e),r.style.display="block",r.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:s}=this.eventContext;s.removeEventListener("pointerdown",this._onMouseDownFocusIn),s.addEventListener("pointerdown",this._onMouseDown,!1),s.addEventListener("pointerup",this._onMouseUp,!1),s.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};var Q1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onVoice=({value:e,frequencies:r})=>{this.events.forEach(i=>{i.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantListener"&&!r.data.disabled).forEach(r=>{this.events.push(new CC(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},CC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Wt(e,e.actions,i,s,o,r)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}};var Z1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onTriggerEvent=({description:e,direction:r})=>{let i=this.events.find(s=>s.data.description===e);i&&(r==="backward"?i.dispatchReverse():i.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantTrigger"&&!r.data.disabled).forEach(r=>{this.events.push(new PC(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},PC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Wt(e,e.actions,i,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispatchReverse(){let t=this.actions;t.Transition.forEach(e=>e.reverseFromCurrent()),t.Particles.forEach(e=>e.reverseFromCurrent()),t.Animation.forEach(e=>e.reverseFromCurrent()),t.SwitchCamera.forEach(e=>e.reverseFromCurrent()),t.Create.forEach(e=>e.dispatchStop())}};var J1=class{constructor(t,e,r,i,s){this.publish=t;this.controlsManager=e;this.animationControls=r;this.eventContext=i;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onTouchMovePreventScroll=t=>{let e=window.parent!==window,r=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(t.touches.length>1||this.preventTouchScroll||e===!1&&r===!1)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!1}};this.getMousePosition=t=>{let{domRect:e}=this.eventContext,{pageX:r,pageY:i}=t.touches?.length>0?t.touches[0]:t;return{x:r-(e.left+window.scrollX),y:i-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=i.requestRender}activate(t=!1){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 A1(this.eventContext),["VariableChange"]:new N1(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["API"]:new q1(this.eventContext,this),["WEBHOOK"]:new X1(this.eventContext,this),["AIAssistantListener"]:new Q1(this.eventContext,this),["AIAssistantTrigger"]:new Z1(this.eventContext,this),["Conditional"]:new M1(this.eventContext,this),["Start"]:new R1(this.eventContext,this),Basic:new E1(this.eventContext,this,this.needsRaycast),["MouseHover"]:new D1(this.eventContext,this),["Scroll"]:new O1(this.eventContext,this),["Follow"]:new P1(this.eventContext,this),["DragDrop"]:new C1(this.eventContext,this),["LookAt"]:new I1(this.eventContext),["Resize"]:new W1(this.eventContext,this),Textfields:new K1(this.eventContext,this)};let{page:e,domElement:r}=this.eventContext;this.hideCursor&&(r.style.cursor="none"),e.traverseEntity(i=>{i.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(i=>i.connect()),r.addEventListener("wheel",this.onMouseWheelPreventScroll),r.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,t||this.eventContext.sharedAssets.openAIRealtime?.connect()}deactivate(t=!1){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:r}=this.eventContext;r.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}),r.removeEventListener("touchmove",this.onTouchMovePreventScroll),r.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),t||this.eventContext.sharedAssets.openAIRealtime?.disconnect()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=r=>{if(r.data.type==="Conditional"&&(r.data.ifActions.forEach(e),r.data.elseActions.forEach(e)),r.data.type==="Conditional"||r.data.type==="SetVariable")for(let i of r.data.type==="Conditional"?r.data.condition:r.data.expression)"id"in i&&Array.isArray(i.id)&&(i.id[0]==="mouse"&&(this.needsMouse=!0),i.id[0]==="raycast"&&(this.needsRaycast=!0));r.data.type==="DynamicVariablePlay"&&r.data.variableId!==""&&(r.data.mode==="Play"||r.data.mode==="PlayPause"||r.data.mode==="Toggle")&&t.setDynamicVariablePlayState(r.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length)for(let i of r.data.events)if(i.data.type==="VariableChange"&&(i.data.variableId==="mouseProperty"&&(this.needsMouse=!0),i.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),i.data.type==="Conditional")for(let s of["inActions","outActions"])i.data[s].forEach(e);else if(i.data.type==="DragDrop")for(let s of["drag","drop"])i.data.dragDropActions[s].forEach(e);else if(i.data.type==="GameControl")for(let s of["idle","move","jump","run"])i.data.gameActions[s].forEach(e);else if(i.data.type==="Resize")for(let s of i.data.breakpoints)s.data.actions.forEach(e);else i.data.type==="LookAt"||i.data.type==="API"||i.data.actions.forEach(e)})}};var $1=class{constructor(t,e,r,i,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new U().copy(r),this._editorSize=new U().copy(i),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,r=this._editorSize.y;this._aspect=t/e,e<=r&&(this._camera.zoom*=r/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,r=this._editorSize.y,i=this._fov;if(t&&e>r){let s=zte(e,1080,2160,1,15)/100;i*=e/r,i*=1-s}this._camera.aspect=this._aspect,this._camera.fov=i,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function zte(n,t,e,r,i){return(n-t)/(e-t)*(i-r)+r}var eS=class{get sharedAssets(){return this.shared}constructor(t,e={},r=!0){this.shared=new xu(t.shared,e,!0,r),this.scene=new fc(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof yr&&!t.uiScene&&t.personalCamera.updateState(t.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(t=>{t instanceof Ct&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var tS=class{constructor({x:t=10,y:e=10}){this._startTime=0;let r=document.getElementById("spe-perfs");r?this.element=r:(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=`${t}px`,this.element.style.top=`${e}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 Gte(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}function ty(n){return n instanceof lo?"SubdivObject":n.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function jte(n,t){let e={};return n.traverseEntity(r=>{if(!r.visible||!(r instanceof nr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let i=r.parent;for(;i;){if(i instanceof nr&&r.states&&Object.keys(r.states).length)return;i=i.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!Kr.isMergable(o))return}else{let c=t.scene.objects.get(r.uuid)?.data;if(c&&"material"in c&&typeof c.material!="string"){if(!Kr.isMergable(c.material))return;s=Kr.getHash(c.material)}}e[s]||(e[s]={});let l=e[s][ty(r)];if(l){if(l.push(r),r.cloner)for(let c of r.cloner.children)l.push(c)}else if(e[s][ty(r)]=[r],r.cloner)for(let c of r.cloner.children)e[s][ty(r)].push(c)}),e}function Hte(n){let t=0;return Object.values(n).forEach(e=>{Object.values(e).forEach(r=>{let i=r.length;i>t&&(t=i)})}),t}function XV(n,t){let e=jte(t,n),r=Hte(e),i=new Array(r),s=0,o=new Array(r),a=0,l=new Array(r),c=0,u=new Array(r),h=0;for(let[d,f]of Object.entries(e))for(let m of Object.values(f)){if(a=0,c=0,m.forEach(g=>{g instanceof nr&&(o[a++]=g.geometry.clone(),l[c++]=g)}),c<2)continue;for(let g=0;g<c;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&Gte(o[g]);let p=Js(o.slice(0,a),!1);if(p){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Mt(p,l[0].material);break}default:{g=new Mt(p,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=x=>{h=0;for(let v of x)v.children&&y(v.children),v instanceof nr&&(Array.isArray(v.material)||e[v.material.uuid]&&e[v.material.uuid][ty(v)]&&e[v.material.uuid][ty(v)].length>1||(u[h++]=v));for(let v=0;v<h;v++)t.attach(u[v])};for(let x=0;x<c;x++){let v=l[x];y(v.children),i[s++]=v}}}for(let d=0;d<s;d++)i[d].removeFromParent()}var $V=cl(KV(),1);function QV(n){let t=Array.isArray(n)?n[0]:n,e=t.layers.map(Wte),r=t.layers.find(i=>i.type==="light");return{layers:e,alpha:r.node.alphaOverride?.value??1}}function Wte(n){return n.type==="texture"||n.type==="video"||n.type==="matcap"?{...n.data,updateTexture(t){return n.color.texture.image.updateSrc(t)}}:{...n.data}}function ZV(n,t,e){let r=Array.isArray(e)?e[0]:e;if(n[0]==="layers"){let i=parseInt(n[1]),s=r.layers[i],o=n[2];s&&o&&qte(n.slice(2),t,s)}else n[0]==="alpha"&&r.layers.forEach(i=>{i.type==="light"&&i.node.alphaOverride!==void 0&&(i.node.alphaOverride.value=t,t<1&&(r.transparent=!0))})}var ry=new cr(0,0,0,1);function qte(n,t,e){let r=n[0];try{if(Kte(r,e.type,n.slice(1)))if(r==="colors"){if(n.length<2)throw new Error("You cannot mutate the colors array, only its items");let i=parseInt(n[1]),o=e.getValue(r)?.[i];if(o)ry.setStyle(t),o.set(ry.r,ry.g,ry.b,ry.a);else throw new Error("Color index out of range")}else e.getValue(r)?.setStyle(t);else if(r==="texture"||r==="video"){let i=e.color;Xte(n.slice(1),t,i,e)}else{let i=n[1],s=e.getValue(r);s?.isVector3&&i!==void 0||s?.isVector2&&i!==void 0?s.setComponent(parseInt(i),t):e.setValue(r,t)}}catch(i){console.error("Error setting material value",i)}}function Xte(n,t,e,r){let i=n[0];if(i==="repeat"||i==="offset"){let s=n[1];if(s===void 0)t instanceof Array&&t.length===2&&Object.assign(e.mat,{[i]:t});else{let o=e.mat[i],a=parseInt(s)===0?[parseFloat(t),o[1]]:[o[0],parseFloat(t)];Object.assign(e.mat,{[i]:a})}e.mat.updateMatrix()}else i==="rotation"?(e.mat.rotation=parseFloat(t),e.mat.updateMatrix()):i==="wrapping"||i==="minFilter"||i==="magFilter"?i==="wrapping"?e.texture.wrap=t:e.texture[i]=t:i==="image"&&n[1]==="data"&&e.texture.image.updateSrc(t)}var Yte={color:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],matcap:[],pattern:["colorA","colorB"],light:[],displace:[],rainbow:[],particle:[]};function Kte(n,t,e){return!!Yte[t]?.includes(n)}var Zte=new U;function Jte(n){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";n.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):n.endsWith(".splinecode")||console.warn(t)}function JV(n){let t=new cr(0,0,0,1);try{t.setStyle(n)}catch(e){console.error(e)}finally{return t}}var _C=class{constructor(t,{renderOnDemand:e,renderMode:r="auto",wasmPath:i}={}){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=t=>{if(this.time=t,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)??!1),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?.traverseVisibleEntity(e=>{e.type==="ParticleSystem"&&(e.update(this.dt),this._skipRender=!1)}),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 e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,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=t=>{if(!!this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Zte.set(this._viewportWidth,this._viewportHeight)),t){let e=this._viewportWidth,r=this._viewportHeight;this._renderer.setSize(e-1,r-1,!1),this._renderer.setSize(e,r,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);if(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 e=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(e!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}};this._debouncedResize=_o(this._resize,10);this._onScroll=t=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())};this.canvas=t,this.renderMode=e?"auto":r,i&&(this._wasmPath=sA(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 tS({x:10,y:10})),TD(t)}async load(t,e,r){Jte(t),this.disposed=!1;let s=await(await fetch(t,r)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:r}={}){if(this.disposed)return;let i=await kV(t);this._data=i;let s=zV(i);i.version&&(0,$V.default)(i.version,"1.12.47")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath&&this.setUIWasmUrl(`${this._wasmPath}/ui.wasm`),await Promise.all([s.length&&wC(this._wasmPath),eM(i)&&pL(this._wasmPath),dN(i)&&aL(this._wasmPath),ql.physicsEnabled(i.scene.objects)&&OD(),WT(i)&&rN(),a1(i)&&_M(),$L(i)&&QL(),dM(i)&&CB(),dC(i)&&_D(this._wasmPath)].filter(Boolean)),s.length&&await AC(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let o=new eS(i);if(o.resetPersonalCameraFromDocumentData(),this._scene=o.scene,this._sharedAssetsManager=o.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let c=performance.now();XV(i,o.scene);let u=performance.now();console.log("Merged geometries in ",u-c," ms")}eM(i)&&this._scene.traverse(c=>{Dn(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{c instanceof Ai&&c.pendingMediaLoad&&c.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(c=>{c.type==="ParticleSystem"&&(c.wakeUp(),c.data.autoPlay?c.start():c.stop())});let a=Object.keys(i.shared.fonts).map(c=>this._sharedAssetsManager.getFont(c).loadingPromise);if(Promise.all(a).then(()=>{o.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),WT(i)&&FV(i)&&await Promise.all(a),dM(i)){let c=[];this._scene.traverseEntity(u=>{(u instanceof _r||u instanceof yr)&&u.uiCanvas&&c.push(u.uiCanvas)}),await Promise.all(c.map(u=>u.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),sp(this._scene.activePage,this._sharedAssetsManager),!this._renderer){this._renderer=new Nb({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0;let c=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),u=this._getPixelRatio(c()?i.scene.publish.settings.web.pixelRatioMobile:i.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(u),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),i.shared.images.SplineWatermark){let h=this._sharedAssetsManager.getImage("SplineWatermark");await h.loadPromise;let d=h.getTexture(1001);this._renderer.pipeline.setWatermark(d)}}a1(i)&&this._scene.initializeSplatViewer(),i.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(i.scene.blueNoiseTextureData);let l=Object.values(i.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(l.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=l.size[0],this._viewportHeight=l.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 $1(this._renderer,this._camera,new U(this._viewportWidth,this._viewportHeight),new U(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(l.allowResponsive??!1)&&l.preset==="fullscreen"),e){let c=new w1(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,l);this._scene.updateMatrixWorld(!0),this._controls=new z1(c),this._animationControls=new G1(this._scene,this._requestRenderAutoMode),this._eventManager=new J1(i.scene.publish,this._controls,this._animationControls,c,i.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this._resize(!0)}),r!==void 0&&this.setVariables(r),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),document.addEventListener("scroll",this._onScroll)}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[r,i]of e)this.setVariable(r,i)}}setVariable(t,e){let r=this._getVariableByName(t);if(r&&!("dynamicVariableType"in r.data)){let i=e;typeof r.data.value=="number"?i=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof r.data.value=="boolean"?i=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof r.data.value!="string"&&r.data.value.textValue!==void 0&&(i=e.toString());let s=typeof i=="string"?{textValue:i}:i;this._sharedAssetsManager?.updateVariable(r.id,s),this.requestRender(),this._requestRenderAutoMode()}else r===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in r.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let r=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(r)}}_getVariableValue(t){return typeof t!="string"&&Gr.isTextValue(t)?Gr.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(r=>r.data.name===t);return e&&this._variablesCache.set(t,e),e}}_getPixelRatio(t){switch(t){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==As&&!this._scene.isInvisibleObjects(e)&&!(e instanceof yr)){let r=this._createProxyObject(e);r&&t.push(r)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof gp&&this._controls?.orbitControls.setZoom(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let e=JV(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{Xw.unsubscribe(t)}),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(),this.dt=0,MD(this.canvas),document.removeEventListener("scroll",this._onScroll)}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(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(!this._scene)return;let e=this._scene;if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let r;t.traverseAncestors(u=>{u instanceof yr&&(r=u.name)});let i=this._sharedAssetsManager,s={shared:i,scene:this._scene},o=u=>{if(u===null||u==="Base State")return null;if(u&&t.data.states){let h=t.data.states.find(d=>d.data.name===u);return h?h.id:void 0}},a="material"in t?t.material:void 0,l={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:r,material:a?QV(a):void 0,parentUuid:t.parent instanceof yr||t instanceof fc?void 0:t.parent?.uuid,emitEvent(u){t.dispatchEvent({type:"userEvent",eventName:u})},emitEventReverse(u){t.dispatchEvent({type:"userEvent",eventName:u,reverse:!0})},hide(){t.visible&&(t.visible=!1,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let u=t.stateSelection;if(u!==null)return t.data.states.find(({id:h})=>h===u)?.data.name},set state(u){let h;if(u!==void 0){let d=typeof u=="string"?t.data.states.find(({id:f})=>f===u):t.data.states[u];if(d)h=d.id;else{let f=typeof u=="string"?o(u):void 0;f&&(h=f)}}t.changeSelectedState(h??null,s),t.currentState=h??null,t.dispatchEvent({type:"completeState",state:h??null}),s.shared.requestRender()},transition(u){let h=this,d,f=Ms.timeline({autoplay:u.autoPlay??!0}),m={transition({from:p,to:g,duration:y,delay:x,...v}){let b=o(p);b===void 0&&(b=d);let w=o(g);d=w;let A=new op(t,b,w,{state:w,repeat:0,delay:x??0,delayDirection:"start-once",direction:"normal",duration:y??1e3,...v,...v.easing===6?ld.defaultData:v.easing===5?cd.defaultData:{}},i,!1,e.activePage);return f.add({...A.params,begin:()=>{(p&&b||p==="Base State"&&!b)&&(h.state=b??void 0)},complete:()=>{h.state=w??void 0}},f.duration),this},play(){return f.play(),this},pause(){return f.pause(),this},reset(){return f.reset(),this},seek(p){return f.seek(p),this}};return m.transition(u),m},set color(u){let h=JV(u);if(Of.is(t)){t.color=h;return}else if(t.type!=="Mesh"||!("material"in t)||!(t instanceof _n))return;let d={r:h.r,g:h.g,b:h.b,a:h.a},f=Array.isArray(t.material)?t.material[0]:t.material,m=f.data.layers.find(p=>p.data.type==="color")?.id;if(m)f.updateByOp({type:0,path:["layers",m],props:{color:{...d}}},f.data,s);else{let p=f.data,g=p.layers.find(T=>T.data.type==="light");if(!g)return;let y=p.layers.indexOf(g)===0?g:null,x=p.layers.at(y?p.layers.indexOf(y)+1:0),v=y?y.fi+(x?(x.fi-y.fi)/2:1):x?x.fi/2:1,b={type:4,fi:v,id:Se.generateUUID(),data:{...Cr.defaultData("color"),color:d},localIndex:0},w=p.layers.insertAfterHelper(y?.id??null,1),A=p.layers.runOp({...b,fi:w[0]}).data;Object.assign(f.data,{layers:A}),f.updateByOp({...b,path:["layers"]},f.data,s)}}},c=Xw(l,(u,h)=>{let d=t[u],f=$te(u);f[0]==="material"&&a&&ZV(f.slice(1),h,a),typeof d!="object"&&Object.getOwnPropertyDescriptor(t,u)?.writable&&(t[u]=h),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,c),c}setUIWasmUrl(t){Wx.skiaWasmUrl=t}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(t,e){let r;if(typeof e=="string")if(e.endsWith(".splinegeometry")){let u=await(await fetch(e)).arrayBuffer();r=new Uint8Array(u)}else throw new Error("Only .splinegeometry format is supported");else r=e;let i=ad.deserialize(r),s="data"in i&&i.data.draco!==void 0;s&&await wC(this._wasmPath);let o=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!o){console.warn(`Object ${t} not found`);return}if(o.data.type!=="Mesh"||!(o instanceof _n)){console.warn(`Object ${t} is not a mesh`);return}let a=o,l={...a.data,geometry:i};s&&await AC([l]),a.updateByOp({type:0,path:[],props:{geometry:l.geometry}},l,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let c of a.data.states){let u={...c.data};a.states||(a.states={}),a.states[c.id]=Qs.patch(l,u)}return r}};function $te(n){return n.split(".")}
|
|
8174
|
+
`&&e--,this.htmlInput.setSelectionRange(Math.min(t,e),Math.max(t,e))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof yc)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let r=this.virtualInput.wrappedText,i=r[t],s=e+1,o=e;i[e]!==" "&&(s=this.findNextCharOccurence(i,e,"forward"," "),o=this.findNextCharOccurence(i,e,"backward"," "),o>0&&o++,s>=i.length-1&&t===r.length-1&&s++);let a=this.helper,l=a.getGlobalIndexFromLineAndCharIndexes(r,t,o),c=a.getGlobalIndexFromLineAndCharIndexes(r,t,s);this.setInputSelection(l,c)}findNextCharOccurence(t,e,r,i=" "){let s=Math.max(0,t.length-1),o=r==="forward"?s:0,a=r==="forward"?1:-1,l=Math.max(Math.min(e,s),0);for(;l!==o;)if(l+=a,t.charAt(l)===i)return l;return o}getPointOnPlane(){let t=this.virtualInput?.data;if(!(!this.virtualInput||!t)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new E);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let r=typeof t.geometry.width=="number"?t.geometry.width:1,i=typeof t.geometry.height=="number"?t.geometry.height:1;this.projected.set(e.x+r*.5,e.y-i*.5)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(HV.getNormalMatrix(this.virtualInput.matrixWorld),GV.copy(Ute).applyMatrix3(HV).normalize(),this.virtualInput.localToWorld(jV.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(GV,jV))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),bs&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=kte(t.geometry.horizontalAlign))}};function kte(n){return n===4?"justify":n===2?"right":n===3?"center":"left"}var qV=(n,t)=>{if(typeof n=="string"){let e=t.data(n);if(e)return qV(e.value,t)}return Gr.getDisplayedValue(n)};function WV(n,t){let e=n.text,r="";if(typeof e=="string"){let i=t.variables.data(r);i&&(r=qV(i.value,t.variables))}else r=e.textValue.toString();return r}var K1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this._textInputs=[];this.sceneHelpers=new Er;this.helper=new Kf;this._onMouseDownFocusIn=e=>{if(et.length>1)return;this.eventContext.updateRaycaster(e);let r=null;if(this.eventContext.raycaster){for(let i of this._textInputs)if(this.eventContext.raycaster.intersectObject(i,!0).length>0){r=i;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(e),this._onMouseDown(e)};this.onExit=()=>{let{virtualInput:e}=this.textInputManager;if(e===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r?.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:i}=this.eventContext;i.removeEventListener("pointerdown",this._onMouseDown,!1),i.removeEventListener("pointerup",this._onMouseUp,!1),i.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),i.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()};this._onMouseDown=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)};this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)};this._onMouseMove=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseMove()};this._onTextEdit=e=>{let{htmlInput:r,virtualInput:i,helper:s}=this.textInputManager;if(!r||!i)return;let o=r.value;i.textGeometry.setText(o,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let a=i.data;s.update();let l=a.geometry.text;if(typeof l=="string"){let c=l;this.eventContext.sharedAssets.updateVariable(c,{textValue:o})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()};this._onCaretUpdate=e=>{this.textInputManager.handleCaretUpdate(e)};this._onKeyPress=e=>{e.key==="Escape"&&this.onExit()};this.textInputManager=new Y1(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(s=>{s instanceof yc&&e.push(s)}),this._textInputs=e,e.length===0)return;let{domElement:r}=this.eventContext;r.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let e=this.textInputManager.htmlInput,{domElement:r,sharedAssets:i}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),e?.removeEventListener("keyup",this._onCaretUpdate),e?.removeEventListener("keydown",this._onCaretUpdate),e?.removeEventListener("beforeinput",this._onCaretUpdate),e?.removeEventListener("paste",this._onCaretUpdate),e?.removeEventListener("cut",this._onCaretUpdate),e?.removeEventListener("select",this._onCaretUpdate),e?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(s=>{let o=WV(s.data.geometry,this.eventContext.sharedAssets.data);s.textGeometry.setText(o,i)}),r.removeEventListener("pointerdown",this._onMouseDown,!1),r.removeEventListener("pointerup",this._onMouseUp,!1),r.removeEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(e){this.textInputManager.focus(e),this.textInputManager.onTextMaterialChanged();let r=this.textInputManager.htmlInput;if(!r||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=WV(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);r.value=i,r.setSelectionRange(0,0),this.textInputManager.helper.show(e),r.style.display="block",r.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:s}=this.eventContext;s.removeEventListener("pointerdown",this._onMouseDownFocusIn),s.addEventListener("pointerdown",this._onMouseDown,!1),s.addEventListener("pointerup",this._onMouseUp,!1),s.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};var Q1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onVoice=({value:e,frequencies:r})=>{this.events.forEach(i=>{i.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantListener"&&!r.data.disabled).forEach(r=>{this.events.push(new CC(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},CC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Wt(e,e.actions,i,s,o,r)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}};var Z1=class extends Qt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onTriggerEvent=({description:e,direction:r})=>{let i=this.events.find(s=>s.data.description===e);i&&(r==="backward"?i.dispatchReverse():i.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantTrigger"&&!r.data.disabled).forEach(r=>{this.events.push(new PC(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},PC=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Wt(e,e.actions,i,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispatchReverse(){let t=this.actions;t.Transition.forEach(e=>e.reverseFromCurrent()),t.Particles.forEach(e=>e.reverseFromCurrent()),t.Animation.forEach(e=>e.reverseFromCurrent()),t.SwitchCamera.forEach(e=>e.reverseFromCurrent()),t.Create.forEach(e=>e.dispatchStop())}};var J1=class{constructor(t,e,r,i,s){this.publish=t;this.controlsManager=e;this.animationControls=r;this.eventContext=i;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onTouchMovePreventScroll=t=>{let e=window.parent!==window,r=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(t.touches.length>1||this.preventTouchScroll||e===!1&&r===!1)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!1}};this.getMousePosition=t=>{let{domRect:e}=this.eventContext,{pageX:r,pageY:i}=t.touches?.length>0?t.touches[0]:t;return{x:r-(e.left+window.scrollX),y:i-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=i.requestRender}activate(t=!1){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 A1(this.eventContext),["VariableChange"]:new N1(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["API"]:new q1(this.eventContext,this),["WEBHOOK"]:new X1(this.eventContext,this),["AIAssistantListener"]:new Q1(this.eventContext,this),["AIAssistantTrigger"]:new Z1(this.eventContext,this),["Conditional"]:new M1(this.eventContext,this),["Start"]:new R1(this.eventContext,this),Basic:new E1(this.eventContext,this,this.needsRaycast),["MouseHover"]:new D1(this.eventContext,this),["Scroll"]:new O1(this.eventContext,this),["Follow"]:new P1(this.eventContext,this),["DragDrop"]:new C1(this.eventContext,this),["LookAt"]:new I1(this.eventContext),["Resize"]:new W1(this.eventContext,this),Textfields:new K1(this.eventContext,this)};let{page:e,domElement:r}=this.eventContext;this.hideCursor&&(r.style.cursor="none"),e.traverseEntity(i=>{i.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(i=>i.connect()),r.addEventListener("wheel",this.onMouseWheelPreventScroll),r.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,t||this.eventContext.sharedAssets.openAIRealtime?.connect()}deactivate(t=!1){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:r}=this.eventContext;r.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}),r.removeEventListener("touchmove",this.onTouchMovePreventScroll),r.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),t||this.eventContext.sharedAssets.openAIRealtime?.disconnect()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=r=>{if(r.data.type==="Conditional"&&(r.data.ifActions.forEach(e),r.data.elseActions.forEach(e)),r.data.type==="Conditional"||r.data.type==="SetVariable")for(let i of r.data.type==="Conditional"?r.data.condition:r.data.expression)"id"in i&&Array.isArray(i.id)&&(i.id[0]==="mouse"&&(this.needsMouse=!0),i.id[0]==="raycast"&&(this.needsRaycast=!0));r.data.type==="DynamicVariablePlay"&&r.data.variableId!==""&&(r.data.mode==="Play"||r.data.mode==="PlayPause"||r.data.mode==="Toggle")&&t.setDynamicVariablePlayState(r.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length)for(let i of r.data.events)if(i.data.type==="VariableChange"&&(i.data.variableId==="mouseProperty"&&(this.needsMouse=!0),i.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),i.data.type==="Conditional")for(let s of["inActions","outActions"])i.data[s].forEach(e);else if(i.data.type==="DragDrop")for(let s of["drag","drop"])i.data.dragDropActions[s].forEach(e);else if(i.data.type==="GameControl")for(let s of["idle","move","jump","run"])i.data.gameActions[s].forEach(e);else if(i.data.type==="Resize")for(let s of i.data.breakpoints)s.data.actions.forEach(e);else i.data.type==="LookAt"||i.data.type==="API"||i.data.actions.forEach(e)})}};var $1=class{constructor(t,e,r,i,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new U().copy(r),this._editorSize=new U().copy(i),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,r=this._editorSize.y;this._aspect=t/e,e<=r&&(this._camera.zoom*=r/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,r=this._editorSize.y,i=this._fov;if(t&&e>r){let s=zte(e,1080,2160,1,15)/100;i*=e/r,i*=1-s}this._camera.aspect=this._aspect,this._camera.fov=i,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function zte(n,t,e,r,i){return(n-t)/(e-t)*(i-r)+r}var eS=class{get sharedAssets(){return this.shared}constructor(t,e={},r=!0){this.shared=new xu(t.shared,e,!0,r),this.scene=new fc(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof yr&&!t.uiScene&&t.personalCamera.updateState(t.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(t=>{t instanceof Ct&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var tS=class{constructor({x:t=10,y:e=10}){this._startTime=0;let r=document.getElementById("spe-perfs");r?this.element=r:(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=`${t}px`,this.element.style.top=`${e}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 Gte(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}function ty(n){return n instanceof lo?"SubdivObject":n.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function jte(n,t){let e={};return n.traverseEntity(r=>{if(!r.visible||!(r instanceof nr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let i=r.parent;for(;i;){if(i instanceof nr&&r.states&&Object.keys(r.states).length)return;i=i.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!Kr.isMergable(o))return}else{let c=t.scene.objects.get(r.uuid)?.data;if(c&&"material"in c&&typeof c.material!="string"){if(!Kr.isMergable(c.material))return;s=Kr.getHash(c.material)}}e[s]||(e[s]={});let l=e[s][ty(r)];if(l){if(l.push(r),r.cloner)for(let c of r.cloner.children)l.push(c)}else if(e[s][ty(r)]=[r],r.cloner)for(let c of r.cloner.children)e[s][ty(r)].push(c)}),e}function Hte(n){let t=0;return Object.values(n).forEach(e=>{Object.values(e).forEach(r=>{let i=r.length;i>t&&(t=i)})}),t}function XV(n,t){let e=jte(t,n),r=Hte(e),i=new Array(r),s=0,o=new Array(r),a=0,l=new Array(r),c=0,u=new Array(r),h=0;for(let[d,f]of Object.entries(e))for(let m of Object.values(f)){if(a=0,c=0,m.forEach(g=>{g instanceof nr&&(o[a++]=g.geometry.clone(),l[c++]=g)}),c<2)continue;for(let g=0;g<c;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&Gte(o[g]);let p=Js(o.slice(0,a),!1);if(p){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Mt(p,l[0].material);break}default:{g=new Mt(p,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=x=>{h=0;for(let v of x)v.children&&y(v.children),v instanceof nr&&(Array.isArray(v.material)||e[v.material.uuid]&&e[v.material.uuid][ty(v)]&&e[v.material.uuid][ty(v)].length>1||(u[h++]=v));for(let v=0;v<h;v++)t.attach(u[v])};for(let x=0;x<c;x++){let v=l[x];y(v.children),i[s++]=v}}}for(let d=0;d<s;d++)i[d].removeFromParent()}var $V=cl(KV(),1);function QV(n){let t=Array.isArray(n)?n[0]:n,e=t.layers.map(Wte),r=t.layers.find(i=>i.type==="light");return{layers:e,alpha:r.node.alphaOverride?.value??1}}function Wte(n){return n.type==="texture"||n.type==="video"||n.type==="matcap"?{...n.data,updateTexture(t){return n.color.texture.image.updateSrc(t)}}:{...n.data}}function ZV(n,t,e){let r=Array.isArray(e)?e[0]:e;if(n[0]==="layers"){let i=parseInt(n[1]),s=r.layers[i],o=n[2];s&&o&&qte(n.slice(2),t,s)}else n[0]==="alpha"&&r.layers.forEach(i=>{i.type==="light"&&i.node.alphaOverride!==void 0&&(i.node.alphaOverride.value=t,t<1&&(r.transparent=!0))})}var ry=new cr(0,0,0,1);function qte(n,t,e){let r=n[0];try{if(Kte(r,e.type,n.slice(1)))if(r==="colors"){if(n.length<2)throw new Error("You cannot mutate the colors array, only its items");let i=parseInt(n[1]),o=e.getValue(r)?.[i];if(o)ry.setStyle(t),o.set(ry.r,ry.g,ry.b,ry.a);else throw new Error("Color index out of range")}else e.getValue(r)?.setStyle(t);else if(r==="texture"||r==="video"){let i=e.color;Xte(n.slice(1),t,i,e)}else{let i=n[1],s=e.getValue(r);s?.isVector3&&i!==void 0||s?.isVector2&&i!==void 0?s.setComponent(parseInt(i),t):e.setValue(r,t)}}catch(i){console.error("Error setting material value",i)}}function Xte(n,t,e,r){let i=n[0];if(i==="repeat"||i==="offset"){let s=n[1];if(s===void 0)t instanceof Array&&t.length===2&&Object.assign(e.mat,{[i]:t});else{let o=e.mat[i],a=parseInt(s)===0?[parseFloat(t),o[1]]:[o[0],parseFloat(t)];Object.assign(e.mat,{[i]:a})}e.mat.updateMatrix()}else i==="rotation"?(e.mat.rotation=parseFloat(t),e.mat.updateMatrix()):i==="wrapping"||i==="minFilter"||i==="magFilter"?i==="wrapping"?e.texture.wrap=t:e.texture[i]=t:i==="image"&&n[1]==="data"&&e.texture.image.updateSrc(t)}var Yte={color:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],matcap:[],pattern:["colorA","colorB"],light:[],displace:[],rainbow:[],particle:[]};function Kte(n,t,e){return!!Yte[t]?.includes(n)}var Zte=new U;function Jte(n){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";n.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):n.endsWith(".splinecode")||console.warn(t)}function JV(n){let t=new cr(0,0,0,1);try{t.setStyle(n)}catch(e){console.error(e)}finally{return t}}var _C=class{constructor(t,{renderOnDemand:e,renderMode:r="auto",wasmPath:i}={}){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=t=>{if(this.time=t,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)??!1),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?.traverseVisibleEntity(e=>{e.type==="ParticleSystem"&&(e.update(this.dt),this._skipRender=!1)}),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 e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,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=t=>{if(!!this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Zte.set(this._viewportWidth,this._viewportHeight)),t){let e=this._viewportWidth,r=this._viewportHeight;this._renderer.setSize(e-1,r-1,!1),this._renderer.setSize(e,r,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);if(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 e=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(e!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}};this._debouncedResize=_o(this._resize,10);this._onScroll=t=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())};this.canvas=t,this.renderMode=e?"auto":r,i&&(this._wasmPath=sA(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 tS({x:10,y:10})),TD(t)}async load(t,e,r){Jte(t),this.disposed=!1;let s=await(await fetch(t,r)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:r}={}){if(this.disposed)return;let i=await kV(t);this._data=i;let s=zV(i);i.version&&(0,$V.default)(i.version,"1.12.48")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath&&this.setUIWasmUrl(`${this._wasmPath}/ui.wasm`),await Promise.all([s.length&&wC(this._wasmPath),eM(i)&&pL(this._wasmPath),dN(i)&&aL(this._wasmPath),ql.physicsEnabled(i.scene.objects)&&OD(),WT(i)&&rN(),a1(i)&&_M(),$L(i)&&QL(),dM(i)&&CB(),dC(i)&&_D(this._wasmPath)].filter(Boolean)),s.length&&await AC(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let o=new eS(i);if(o.resetPersonalCameraFromDocumentData(),this._scene=o.scene,this._sharedAssetsManager=o.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let c=performance.now();XV(i,o.scene);let u=performance.now();console.log("Merged geometries in ",u-c," ms")}eM(i)&&this._scene.traverse(c=>{Dn(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{c instanceof Ai&&c.pendingMediaLoad&&c.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(c=>{c.type==="ParticleSystem"&&(c.wakeUp(),c.data.autoPlay?c.start():c.stop())});let a=Object.keys(i.shared.fonts).map(c=>this._sharedAssetsManager.getFont(c).loadingPromise);if(Promise.all(a).then(()=>{o.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),WT(i)&&FV(i)&&await Promise.all(a),dM(i)){let c=[];this._scene.traverseEntity(u=>{(u instanceof _r||u instanceof yr)&&u.uiCanvas&&c.push(u.uiCanvas)}),await Promise.all(c.map(u=>u.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),sp(this._scene.activePage,this._sharedAssetsManager),!this._renderer){this._renderer=new Nb({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0;let c=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),u=this._getPixelRatio(c()?i.scene.publish.settings.web.pixelRatioMobile:i.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(u),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),i.shared.images.SplineWatermark){let h=this._sharedAssetsManager.getImage("SplineWatermark");await h.loadPromise;let d=h.getTexture(1001);this._renderer.pipeline.setWatermark(d)}}a1(i)&&this._scene.initializeSplatViewer(),i.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(i.scene.blueNoiseTextureData);let l=Object.values(i.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(l.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=l.size[0],this._viewportHeight=l.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 $1(this._renderer,this._camera,new U(this._viewportWidth,this._viewportHeight),new U(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(l.allowResponsive??!1)&&l.preset==="fullscreen"),e){let c=new w1(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,l);this._scene.updateMatrixWorld(!0),this._controls=new z1(c),this._animationControls=new G1(this._scene,this._requestRenderAutoMode),this._eventManager=new J1(i.scene.publish,this._controls,this._animationControls,c,i.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this._resize(!0)}),r!==void 0&&this.setVariables(r),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),document.addEventListener("scroll",this._onScroll)}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[r,i]of e)this.setVariable(r,i)}}setVariable(t,e){let r=this._getVariableByName(t);if(r&&!("dynamicVariableType"in r.data)){let i=e;typeof r.data.value=="number"?i=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof r.data.value=="boolean"?i=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof r.data.value!="string"&&r.data.value.textValue!==void 0&&(i=e.toString());let s=typeof i=="string"?{textValue:i}:i;this._sharedAssetsManager?.updateVariable(r.id,s),this.requestRender(),this._requestRenderAutoMode()}else r===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in r.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let r=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(r)}}_getVariableValue(t){return typeof t!="string"&&Gr.isTextValue(t)?Gr.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(r=>r.data.name===t);return e&&this._variablesCache.set(t,e),e}}_getPixelRatio(t){switch(t){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==As&&!this._scene.isInvisibleObjects(e)&&!(e instanceof yr)){let r=this._createProxyObject(e);r&&t.push(r)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof gp&&this._controls?.orbitControls.setZoom(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let e=JV(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{Xw.unsubscribe(t)}),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(),this.dt=0,MD(this.canvas),document.removeEventListener("scroll",this._onScroll)}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(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(!this._scene)return;let e=this._scene;if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let r;t.traverseAncestors(u=>{u instanceof yr&&(r=u.name)});let i=this._sharedAssetsManager,s={shared:i,scene:this._scene},o=u=>{if(u===null||u==="Base State")return null;if(u&&t.data.states){let h=t.data.states.find(d=>d.data.name===u);return h?h.id:void 0}},a="material"in t?t.material:void 0,l={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:r,material:a?QV(a):void 0,parentUuid:t.parent instanceof yr||t instanceof fc?void 0:t.parent?.uuid,emitEvent(u){t.dispatchEvent({type:"userEvent",eventName:u})},emitEventReverse(u){t.dispatchEvent({type:"userEvent",eventName:u,reverse:!0})},hide(){t.visible&&(t.visible=!1,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let u=t.stateSelection;if(u!==null)return t.data.states.find(({id:h})=>h===u)?.data.name},set state(u){let h;if(u!==void 0){let d=typeof u=="string"?t.data.states.find(({id:f})=>f===u):t.data.states[u];if(d)h=d.id;else{let f=typeof u=="string"?o(u):void 0;f&&(h=f)}}t.changeSelectedState(h??null,s),t.currentState=h??null,t.dispatchEvent({type:"completeState",state:h??null}),s.shared.requestRender()},transition(u){let h=this,d,f=Ms.timeline({autoplay:u.autoPlay??!0}),m={transition({from:p,to:g,duration:y,delay:x,...v}){let b=o(p);b===void 0&&(b=d);let w=o(g);d=w;let A=new op(t,b,w,{state:w,repeat:0,delay:x??0,delayDirection:"start-once",direction:"normal",duration:y??1e3,...v,...v.easing===6?ld.defaultData:v.easing===5?cd.defaultData:{}},i,!1,e.activePage);return f.add({...A.params,begin:()=>{(p&&b||p==="Base State"&&!b)&&(h.state=b??void 0)},complete:()=>{h.state=w??void 0}},f.duration),this},play(){return f.play(),this},pause(){return f.pause(),this},reset(){return f.reset(),this},seek(p){return f.seek(p),this}};return m.transition(u),m},set color(u){let h=JV(u);if(Of.is(t)){t.color=h;return}else if(t.type!=="Mesh"||!("material"in t)||!(t instanceof _n))return;let d={r:h.r,g:h.g,b:h.b,a:h.a},f=Array.isArray(t.material)?t.material[0]:t.material,m=f.data.layers.find(p=>p.data.type==="color")?.id;if(m)f.updateByOp({type:0,path:["layers",m],props:{color:{...d}}},f.data,s);else{let p=f.data,g=p.layers.find(T=>T.data.type==="light");if(!g)return;let y=p.layers.indexOf(g)===0?g:null,x=p.layers.at(y?p.layers.indexOf(y)+1:0),v=y?y.fi+(x?(x.fi-y.fi)/2:1):x?x.fi/2:1,b={type:4,fi:v,id:Se.generateUUID(),data:{...Cr.defaultData("color"),color:d},localIndex:0},w=p.layers.insertAfterHelper(y?.id??null,1),A=p.layers.runOp({...b,fi:w[0]}).data;Object.assign(f.data,{layers:A}),f.updateByOp({...b,path:["layers"]},f.data,s)}}},c=Xw(l,(u,h)=>{let d=t[u],f=$te(u);f[0]==="material"&&a&&ZV(f.slice(1),h,a),typeof d!="object"&&Object.getOwnPropertyDescriptor(t,u)?.writable&&(t[u]=h),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,c),c}setUIWasmUrl(t){Wx.skiaWasmUrl=t}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(t,e){let r;if(typeof e=="string")if(e.endsWith(".splinegeometry")){let u=await(await fetch(e)).arrayBuffer();r=new Uint8Array(u)}else throw new Error("Only .splinegeometry format is supported");else r=e;let i=ad.deserialize(r),s="data"in i&&i.data.draco!==void 0;s&&await wC(this._wasmPath);let o=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!o){console.warn(`Object ${t} not found`);return}if(o.data.type!=="Mesh"||!(o instanceof _n)){console.warn(`Object ${t} is not a mesh`);return}let a=o,l={...a.data,geometry:i};s&&await AC([l]),a.updateByOp({type:0,path:[],props:{geometry:l.geometry}},l,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let c of a.data.states){let u={...c.data};a.states||(a.states={}),a.states[c.id]=Qs.patch(l,u)}return r}};function $te(n){return n.split(".")}
|